Does condition $\int\limits_a^bf(x)\,\mathrm{d}x=U(f,P)$ for some partition $P$ imply constantness? 
True or false? 
(1) Let $f:[a,b]\to \mathbb{R}$ function and $\int\limits_a^bf(x)\,\mathrm{d}x=U(f,P)$ for all partitions $P$ of $[a,b]$. Then $f$ is constant on some subinterval of $[a,b]$.
(2) Let $f:[a,b]\to \mathbb{R}$ continuous function and $\int\limits_a^bf(x)\,\mathrm{d}x=U(f,P)$ for some partition $P$ of $[a,b]$. Then $f$ is constant. 
(equivalent version for (2): if $f$ is continuous, non-constant function, then $\int\limits_a^bf(x)\,\mathrm{d}x<U(f,P)$ for all partitions $P$ of $[a,b]$).

Attempt. (1) False. A counterexample is $-f$, being $f$ 
the Thomae function on $[0,1]$, where $\int\limits_0^1(-f)(x)\,\mathrm{d}x=U(-f,P)=0$ for all partitions $P$ of $[0,1].$
(2) I believe so. Suppose $f$ is non-constant. Maybe we could find another partition $Q$ of $[a,b]$ ($f$ is non-constant and continuous) such that $P\subset Q$ and:$$\int\limits_a^bf(x)\,\mathrm{d}x \leqslant U(f,Q)<U(f,P).$$
If so, how could this be done?
Thanks in advance.
 A: For sake of contradiction, suppose $f$ is nonconstant and we have a partition $P$ with $U(f,P) = \int_{a}^{b} f$. Then, in particular, $f$ will be nonconstant on some subinterval of this partition $P$, say the subinterval is $[p_i, p_{i+1}]$. Let $C = \max_{x \in [p_i, p_{i+1}]} f(x)$ (note continuity is assumed, hence the maximum indeed exists) and since $f$ is nonconstant on this subinterval we get that there exists an $s \in [p_i, p_{i+1}]$ with $f(s) < C$. By continuity, it's not hard to justify the slightly stronger claim that there indeed exists an $s \in (p_i, p_{i+1})$ with $f(s)<C$. We will use this stronger claim below. 
By continuity, and since $s$ is in the interior of $[p_i, p_{i+1}]$, there exists a small nondegenerate closed interval $[c,d] \subsetneq [p_i, p_{i+1}]$ containing $s$ such that $f(x) < C$ for all $x$ within this closed interval. In particular, $C' = \max_{x \in [c,d]} f(x) < C$. 
Now let $P' = P \cup \{c,d\}$. In light of the above, it should be clear that a very simple estimate will give $U(f,P') < U(f,P) = \int_{a}^{b} f$, but this is clearly absurd, since $\int_{a}^{b} f \leq U(f,P)$ for any partition $P$. Thus we reached a contradiction. 
