Prove functions defined by sup and inf are continuous [duplicate]

Suppose $f$ is continuous on $[a,b]$. Show that the functions defined by $m(x)=\inf\{f(y):y\in[a,x]\}$ and $M(x)=\sup\{f(y):y\in[a,x]\}$ are well defined and are also continuous on $[a,b]$

I have already managed to prove that they are well defined, since $f$ is continuous on $[a,b]$ so it is bounded. Therefore for every $x\in[a,b]$, the set $\{f(y):y\in[a,x]\}$ has a supremum and an infimum. To prove that they are continuous on $[a,b]$, I've taken an arbitrary sequence $\{x_n\}$ contained in $[a,b]$ converging to some number $c\in[a,b]$ and am attempting to show that $m(x_n)\rightarrow m(c)$ and $M(x_n)\rightarrow M(c)$, but I'm not quite sure how. Any help would be appreciated, thanks!


I'll give you the thought process; let's see if you can turn that in to a proof.

The idea here is this: suppose that $\delta>0$ is pretty small. When you compute $m(x)$, you're computing the greatest lower bound on $f(y)$ for $y\in[a,x]$; when you compute $m(x+\delta)$, you're computing the greatest lower bound on $f(y)$ for $y\in[a,x+\delta]$.

The only place that a difference can be introduced is in the values that are considered by $m(x+\delta)$ but not by $m(x)$: namely, $y\in(x,x+\delta]$.

If $\delta$ is small enough, what does continuity of $f$ tell you about the relationship between the values $f(y)$ for $y\in[x,x+\delta]$?

The key is that $f(y)\approx f(x)$ for $y\in[x,x+\delta]$, as long as $\delta$ is small. So, even if there are smaller values for $f(y)$ with $y\in(x,x+\delta]$ than with $y\in[a,x]$, they can't be MUCH smaller than $f(x)$

Do you see how to turn this heuristic in to a proof? Try considering two cases: where $m(x)=f(x)$ and where $m(x)<f(x)$.