Suppose $X$ is a compact metric space and $f: X \rightarrow \mathbb{R}$ is a function for which $f^{-1}([t,\infty))$ is closed for any real $t$. Then $f$ achieves its maximum value on $X$.
I am first trying to prove that that $f$ is bounded above. Suppose, for the sake of contradiction, that $f$ is not bounded above. So for all $M \in \Bbb{R}$, there is a $x \in X$ such that $f(x) > M$. So there exists a sequence $\{x_n\}$ in $X$ such that for all $n \in \Bbb{N}$, we have $f(x_n) > n$. So $x_n \in f^{-1}([n,\infty))$ for all $n \in \Bbb{N}$. Since $f^{-1}([n,\infty)) \subseteq X$ are closed for all $n \in \Bbb{N}$, $f^{-1}([n,\infty))$ are compact for all $n \in \Bbb{N}$. Further, since each $f^{-1}([n,\infty))$ is nonempty, and $f^{-1}([n + 1,\infty)) \subseteq f^{-1}([n,\infty))$ for all $n \in \Bbb{N}$, $\bigcap\limits_{n = 1}^\infty f^{-1}([n,\infty))$ is not empty, and it is also closed.
I am trying to show now that $\{x_n\}$ has a convergent subsequence $\{x_{n_k}\}$ that converges to some $x \in \bigcap\limits_{n = 1}^\infty f^{-1}([n,\infty))$, and reach a contradiction since $$\bigcap\limits_{n = 1}^\infty f^{-1}([n,\infty)) = f^{-1}(\bigcap\limits_{n = 1}^\infty [n,\infty))$$ is empty (since $\bigcap\limits_{n = 1}^\infty [n,\infty)$ is empty).
My issue is, how do I know $x \in \bigcap\limits_{n = 1}^\infty f^{-1}([n,\infty))$? I know its in $X$ since it is compact, but I don't know if its in $x \in \bigcap\limits_{n = 1}^\infty f^{-1}([n,\infty))$.
Help, please.
You cannot know that, since it is not true. Suppose that $x\in\bigcap_{n=1}^\infty f^{-1}\bigl([n,\infty)\bigr)$. Then $(\forall n\in\mathbb{N}):f(x)\geqslant n$. But no real number is greater than or equal to every natural number.