Maximization of a Function over a Sequence of Nested Compact Sets Given a continuous function $f:\mathbb{R}\to\mathbb{R}$ and a sequence of nested compact subsets of $\mathbb{R}$, $A_{n}\supseteq A_{n+1}$ for all $n\ge 1$. Let $A_{\infty}=\cap_{n\ge 1}A_n$. Want to show $$\lim_{n\to\infty} \max_{x\in A_n}f(x)=\max_{x\in A_{\infty}}f(x).$$
Let $f^*_n=\max_{x\in A_n}f(x)$. Since $A_n$'s are nested, $f^*_n$ is a non-increasing sequence. By monotone convergence theorem, $\lim_{n\to\infty}f^*_n$ exists, which we denote it by $L$. The next step is to show $L=\max_{x\in A_{\infty}}f(x)$.
Since $L=\lim_{n\to\infty}f^*_n$, we know that for any $\epsilon>0$, there exists an $N$ such that $|\max_{x\in A_n}f(x)-L|<\epsilon$ for all $n\ge N$. As the inequality is true for all $n\ge N$, we may say that $|\max_{x\in \cap_{n\ge N} A_n}f(x)-L|<\epsilon$ and hence $|\max_{x\in A_\infty}f(x)-L|<\epsilon$.
I feel the last step of my approach is not rigorous. I wonder if anyone can point out the problem or give me other suggestion to prove this result. Thanks in advance.
 A: Well, the problem is that you say "As the inequality is true for all $n\geq N$, we may say that $|\max_{x\in \cap_{n≥N}A_n}f(x)−L|<\varepsilon$" without providing a justification. The entire point of the exericse is establishing a link between the quantities $\max_{x\in A_n} f(x)$ and $\max_{x\in \cap_{n\geq N} A_n}f(x)$. Indeed, just consider the non-compact case where
$$
f(x)=\begin{cases}1 & x\in  [0,\infty) \\ -1 & else\end{cases}
$$
and $A_n=(-\infty,0)\cup [n,\infty)$. Then, the $A_n$ are nested, $\max_{x\in A_n}f(x)$ exists for every $n$ and is non-decreasing (it's constantly equal to 1). However, its limit is not equal to $\max_{x\in \cap_{n\geq 1} A_n} f(x)=-1$, even though the latter quantity exists.
So clearly, we need compactness for more than just the the abstract existence of a limit of the $f_n^*$.
Let $\varepsilon$ be given and consider the Hausdorff distance
$$
d(A_N,\cap_{n=1}^{\infty}A_n)=\max\{\sup_{x\in A_N}\inf_{y\in \cap_{n\geq 1}A_n} |x-y|,\sup_{x\in \cap_{n\geq 1} A_n} \inf_{y\in A_N} |x-y| \}
$$
We claim that $d(A_N,\cap_{n=1}^{\infty}A_n)\to 0$ as $N\to\infty$. Indeed, if that were not the case, there would exist $\varepsilon>0$ and sequences $x_N\in A_N$ and $y_N\in \cap_{n\geq 1}A_n$ such that either $|x_N-y|\geq \varepsilon$ for all $y\in \cap_{n\geq 1}A_n$ or $|y_N-x|\geq \varepsilon$ for all $x\in A_N$. Since $\cap_{n\geq 1} A_n\subseteq A_N,$ the latter case is absurd. Hence, we can focus on the $x_N$. Since $x_N$ is a sequence in $A_1$, we can extract a convergenct subsequence $x_{N_k}$ with limit $x_{\infty}$. For given $K,$ $x_{N_k}\in A_K$ for $k$ large and thus, we get that $x_{\infty} \in A_K$, since $A_K$ is closed. Accordingly $x_{\infty}\in \cap_{n=1}^{\infty}, A_n$. However, that is absurd, since then, $|x_N-x_{\infty}|\geq \varepsilon$ for all $N$. Thus, we must have $d(A_N,\cap_{n=1}^{\infty} A_n)\to 0$.
Hence, given $\varepsilon>0$, fix $\delta>0$ such that $|x-y|\leq \delta$ implies $|f(x)-f(y)|<\varepsilon$ for all $x,y\in A_1$. Then, fix $N$ large enough that $d(A_N,\cap_{n=1}^{\infty} A_n)<\delta$. Then, for any $x\in A_N$, there exists $y\in \cap_{n\geq 1} A_n$ such that $|x-y|<\delta$. However, then $|f(x)-f(y)|<\varepsilon$. In particular, $f(x)\leq \max_{y\in \max \cap_{n\geq 1} A_n} f(y)+\varepsilon$. Since $x$ was arbitrary, we get that
$$
\max_{y\in \max \cap_{n\geq 1} A_n} f(y)\leq \max_{x\in A_N} f(x)\leq \max_{y\in \max \cap_{n\geq 1} A_n} f(y)+\varepsilon
$$
for $N$ sufficiently large (note that the first inequality is obvious). Since $\varepsilon$ was arbitrary, this finishes the proof.
