Does $f$ achieve its max on $X$? Prove or disprove.
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 believe this is false since $f$ is not assumed to be continuous. But since the preimage of that subset of the range is closed, it makes me think that maybe it does indeed reach a maximum. I'm quite stumped. Any nudges in the right direction would be terrific.
 A: First we prove that $f$ is bounded above. If not, there is a sequence of points $x_i$ such that $f(x_i) > i$ for all $i$. $x_i$, being an infinite sequence, has a convergent subsequence with limit $x$, which is contained in $f^{-1}([i,\infty))$ for all $i$, which is closed. But $\bigcap [i,\infty)$ is empty, so this cannot be the case, and we have a contradiction. Thus $f$ is bounded above. 
Now let $A = \sup f$. Choose a sequence $x_i$ such that $A-f(x_i) < 2^{-i}$ for all $i$. Then this has a convergent subsequence with limit $x$, which is contained in $f^{-1}([A-2^{-i},\infty))$ for all $i$, hence is contained in $f^{-1}([A,\infty))$. Thus $f(x)=A$.
A: If $f$ is assumed to be bounded above thee its maximum is attained: let $M$ be teh supremum of $f$ on $X$. Then for each $n$ there exists $x_n\in X$ such that $f(x_n) >M-\frac 1 n$. By compactness there is a subsequence of $\{x_n\}$ which converges to some $x$. Now $x_m \in f^{-1}[M-\frac 1 n, \infty)$ for all $m \geq n$. By hypothesis this implies $x \in f^{-1}[M-\frac 1 n, \infty)$ which means $f(x) \geq M-\frac 1 n$. Since this is true for each $n$ we get $f(x)=M$. 
Actually, characterization of compactness by finite intersection property shows that $f$ is necessarily bounded. [Consider the compact sets $f^{-1}[n,\infty)$]. 
