Prove that $f_n(x) → f(x)$ uniformly on $E$ as $n → ∞.$ Let $E ⊂ \mathbb{R}$ be a compact (i.e., closed bounded) set of real numbers. Suppose $\{f_n\}$ is a sequence of real-valued continuous functions which converges pointwise on $E$ to a function $f$ that is also continuous on $E.$ Suppose further that the sequence $\{f_n\}$ is monotonic: $f_{n+1}(x) ≤ f_n(x)$ for all $x ∈ E$ and all $n = 1,2,....$
(a) Prove that $f_n(x) → f(x)$ uniformly on $E$ as $n → ∞.$
(b) Show by example that the hypothesis of compactness is essential.
I need to show that $||f_n - f||_{\infty}$ tends to $0$ as $n$ tends to $\infty$ but I am not really sure how to do this.  Advice would be awesome.  Thanks.
 A: This is known as Dini's theorem. Since $f_n-f$ is also continuous, we may assume $f_n\searrow 0$. Given $\varepsilon >0$, consider the sets $O_n=f_n^{-1}(-\infty,\varepsilon)$. Since $f_n$ is continuous, each one is open. Prove that
$(\rm i)$ $E=\bigcup O_n$
$(\rm ii)$ $O_n\subseteq O_{n+1}$
Since $E$ is compact, you will find $N$ such that $E\subseteq O_N$. But if $x\in O_N$, $|f_n(x)|<\varepsilon$ for $n\geqslant N$ (why?), which shows that $f_n\to 0$ uniformly.
The hypotheses that $E$ is compact, the $f_n$ are monotone and the limit is cotinuous are all necessary and independent. Can you find counterexamples in each case, that is, a sequences satisfying two of the three premises but not the third, such that the theorem fails?

 Solutions $(1)$ Take $E=[0,1]$, $f_n(x)=x^n$. Then we have monotonicity, compactness, but the limit is not continuous and the theorem fails. $(2)$ Take $\chi_{[n,n+1])}(x-n)+\chi_{(n,\infty)}$ over $E=\Bbb R$. Then we have monotonicty, continuity, but $\Bbb R$ is not compact. $(3)$ Take $E=[0,1]$, $f_n(x)=(1-|nx-1|)\chi_{[0,2n^{-1}]}$. Then each $f_n$ is continuous, the limit is continuous, $E$ is comapct but the sequence is not monotone, and the theorem fails.

A: Let $g_n(x)=f_n(x)-f(x)$ and note that $0\le g_{n+1}(x)\le g_n(x)$ for all $x\in E$. Let $x_n\in E$ be such that $$g_n(x_n)=\|g_n\|_\infty,$$
As $E$ is compact, there is a subsequence $x_{n_k}$ such that $x_{n_k}\to x$ in $E$. Take  $\epsilon>0$ and choose $N$ such that $|g_n(x)|<\epsilon$ for $n>N$. If $n_k>n$, we have that $$g_{n_k}(x_{n_k})<g_n(x_{n_k}),$$
therefore, by taking $n>N$ and making $k\to \infty$, we conclude that $$\lim_{k\to \infty} g_{n_k}(x_{n_k})<\lim_{k\to \infty}g_n(x_{n_k})=g_n(x)<\epsilon.$$
In particular, $g_{n_k}(x_{n_k})\to 0$. 
To conclude, choose $K>0$ such that $g_{n_k}(x_{n_k})<\epsilon$ for $k>K$. Once $g_n$ is monotone, we have that $g_n(x_n)\le g_{n_K}(x_{n_K})$ for all $n>K$, therefore, $g_n(x_n)<\epsilon$ for $n>K$. 
