$f\left(x_{0}\right)=\sup _{x \in X} f(x)<\infty$ in a compact metric space

Suppose that a $(X, \rho)$ is a compact metric space and $f: X \rightarrow \mathbb{R}$ is a function. If for every $t \in \mathbb{R}$, $f^{-1}([t, \infty))$ is closed, then there is some $x_{0} \in X$ so that $f\left(x_{0}\right)=\sup _{x \in X} f(x)<\infty$.

I think if I set $M=\sup _{x \in X} f(x)$, then there exists a sequence $\{x_{n}\}_{n=1}^{\infty}\in X$ such that $M=\lim_{n\to \infty}f(x_{n})$. Then suppose $f(x_{1}) $ is smallest among all $f(x_{n})$, $f^{-1}\left([f(x_{1}),\infty)\right)$ is in $X$ and thus is compact since it's a closed subset of a compact set. And this set contains $\{x_{n}\}_{n=1}^{\infty}$. Therefore, it contains a limit point $x_{0}$. Then I guess I will have $f\left(x_{0}\right)=\sup _{x \in X} f(x)$. Is that correct?


Solution 1:

A more direct approach is to use Cantor's intersection theorem on the nested sequence of compact sets $$f^{-1}([t_1, \infty)) \supseteq f^{-1}([t_2, \infty)) \supseteq f^{-1}([t_3, \infty)), \ldots$$ for some increasing sequence $(t_n)$ approaching $M$ from below. The theorem implies there exists some $x$ such that $f(x) \ge t_n$ for every $n$.