If $S(P)=\int_{a}^{b} f$ Then $f$ is Constant 
Prove that if $f$ is continuous on $[a,b]$ and exists a
  partition $P$ such that $S(P)=\sum_{i=1}^{n}M_i \Delta x_i=\int_{a}^{b} f$ then $f$ is constant on
  $[a,b]$.

I have no idea where to actually start other that if we assume that $f$ isn't constant, then there's a segment $[x_i,x_{i-1}]\subseteq[a,b]$ in which $M_i>m_i$.
 A: First, we prove that if $S(P)=\int_a^bf$ and $f$ is continuous, then $f$ is a step function.
To see this, pick an interval $[x_i,x_{i+1}]$ determined by the partition. Since $S(P)=\int_a^bf$, we must have $M_i(x_{i+1}-x_i)=\int_{x_i}^{x_{i+1}}f$. With effect, note that $$\int_{x_i}^{x_{i+1}}  (M_i-f(x))dx \geq 0,$$
so $M_i(x_{i+1}-x_i) \geq \int_{x_i}^{x_{i+1}} f$. Since this holds for every interval, if one of them was strictly greater the sum would be as well (recall that $S(P) \geq \int_a^b f$), yielding a contradiction since we have $S(P)=\int_a^b f$.
It follows that $\int_{x_i}^{x_{i+1}}(M_i-f(x))dx=0.$ Since the input is a continuous non-negative function, this implies that $M_i-f(x)=0$ for all $x$ in $[x_i,x_{i+1}]$. Since the interval is arbitrary, this proves that $f$ is a step function.
But a continuous step function (on an interval) must be constant.
A: Since the integral is the infimum of all upper sums, it follows that for all partitions $P'\supseteq P$ of $[a, b] $ we have $S(P') =I=\int_{a} ^{b} f$. Consider addition of a point $x$ in $P$ to get a refined partition $P'$ ie let $$P=\{a=x_0,x_1,x_2,\dots, x_n=b\}, P'=P\cup\{x\}, x\in(x_{k-1},x_k)$$ If the supremum of $f$ on either of the intervals $[x_{k-1},x]$ or $[x, x_k] $ is less than that on $[x_{k-1},x_k]$ then $S(P') <S(P) $. It follows that the supremum of $f$ remains same in both these subintervals. Thus adding points to $P$ does not decrease supremum of $f$ in any of the subintervals of $P$. It follows that supremum of $f$ on any subinterval of $[x_{k-1},x_k]$ is equal to the supremum of $f$ on $[x_{k-1},x_{k}]$. Therefore by continuity of $f$ we can see that $f$ is constant on each interval $[x_{k-1},x_k] $ and thus it is constant on whole of $[a, b] $. 
