Real Analysis: Proving Continuity ($\epsilon$ $\delta$ argument) Given a bounded function $f: [a,b] \rightarrow \mathbb{R}$, let $H(x)=\lim\limits_{\delta\to 0}$ $\sup_{|y-x|\leq \delta},f(y)$,
$h(x)=\lim\limits_{\delta\to 0}$ $\inf_{|y-x|\leq \delta} f(y)$
Show that $H(x)=h(x)$ iff $f$ is continuous at $x$
Proof:
I'm not sure about one direction of the proof: that is, proving that f is continuous at x, assuming that $H(x)=h(x)$.
(Attempt):
Suppose $H(x)=h(x)$. Given $\epsilon >0$, there exists $\delta>0$ so that $|H(x)-f(y)|<\epsilon$ and $|f(y)-h(x)|<\epsilon$ when $|y-x|<\delta$.
It follows then
$|f(y)-f(x)| \leq |f(y)-h(x)|+|H(x)-f(y)| \leq 2\epsilon  $ Thus f is continuous at x.
Is this correct? I'm not sure about the last step as when I use the triangle inequality I don't use f(x) but f(y).  Is this still valid? I say in the last step above $|H(x)-f(y)|$ not $|H(x)-f(x)|$.
I'm not completely sure about the logic, thanks.
Any help would be much appreciated.
 A: I recommend to organize the proof as follows.
For $\delta \ge 0$ define
$$s_x(\delta) = \sup_{|y-x|\leq \delta}f(y), i_x(\delta) = \inf_{|y-x|\leq \delta}f(y) .$$
Obviously we have
$$(*) \phantom{xx} i_x(\delta) \le f(y) \le s_x(\delta) \text{ for all } y \text{ such that }\lvert y - x \rvert \le \delta .$$
The function $s_x$ is monotonically decreasing in the variable $\delta$ and bounded from below by $f(x)$, hence $H(x) = \lim\limits_{\delta\to 0}  s_x(\delta)$ exists. Similarly $h(x) = \lim\limits_{\delta\to 0}  i_x(\delta)$ exists. Thus
$$H(x) - h(x) =  \lim\limits_{\delta\to 0}  (s_x(\delta) - i_x(\delta)) \ge 0 .$$
1) If $H(x) = h(x)$, then $f$ is  continuous at $x$:
Let $\epsilon > 0$. We can find $r > 0$ such that
$s_x(\delta) - i_x(\delta) < \epsilon$ for $0 \le \delta < r$. Now consider $y$ such that $\lvert y - x \rvert  < r$. Letting $\delta = \lvert y - x \rvert $, we get by $(*)$
$$i_x(\delta) \le f(y), f(x) \le s_x(\delta)$$
which yields
$$\lvert f(y) - f(x) \rvert  \le s_x(\delta) - i_x(\delta) < \epsilon .$$
2) If $f$ is continuous at $x$, then $H(x) = h(x)$:
It suffices to show that $H(x) - h(x) < 2\epsilon$ for any $\epsilon > 0$.
There exists $\delta > 0$ such that if $\lvert y - x \rvert \le \delta$, then $\lvert f(y) - f(x) \rvert < \epsilon$. This implies $s_x(\delta) - f(x) < \epsilon$ and $f(x) - i_x(\delta) <\epsilon$, hence
$$H(x) - h(x) \le s_x(\delta) - i_x(\delta) < 2\epsilon .$$
