# $f:X\longrightarrow\mathbb{R}$ is continuous iff $\{x\in X:f(x)\geq\alpha\}$ and $\{x\in X:f(x)\leq\alpha\}$ are closed $\forall\alpha\in\mathbb{R}$

I'm trying to prove that $f:X\longrightarrow\mathbb{R}$ is continuous if, and only if, the sets $$\{x\in X:f(x)\geq\alpha\} \text{ and } \{x\in X:f(x)\leq\alpha\}$$ are closed $\forall\alpha\in\mathbb{R}$, where $X$ is a metric space.

I've managed to prove the $\left(\Rightarrow\right)$ direction:

I'm using the negative, that is, supposing that one of the sets are not closed and showing that $f$ won't be continuous. Suppose $A\equiv\{x\in X:f(x)\geq\alpha\}$ is not closed, then there's a limit point $y\notin \{x\in X:f(x)\geq\alpha\}$ and a sequence $y_n\longrightarrow y$. Without loss of generality, let $y_n\in A,\forall n\in\mathbb{N}$, then $f(y_n)\geq\alpha$, but $f(y)<\alpha$.

Therefore, $|f(y)-f(y_n)|\geq\varepsilon >0,\forall n\in\mathbb{N}$, where $\varepsilon = \alpha - f(y)>0$. $\Box$

However, I'm having some trouble with the $\left(\Leftarrow\right)$. Can anyone give me some tips?

Thanks for helping! :D

• "Not closed" is not the same as "open". – Sal Mar 9 '15 at 20:15

$(\implies)$ Observe that $\{x|f(x)\geq\alpha\}=f^{-1}([\alpha,\infty[)$. Similarly the second set is $f^{-1}(]\infty,\alpha])$. If $f$ is continuous then, as these sets are the preimages of closed sets of the real line, they are closed.

$(\impliedby)$ Let $\forall\alpha:f^{-1}([\alpha,\infty[),f^{-1}(]\infty,\alpha])$ be closed. It suffices to show that the preimage of an open interval under $f$ is open (since open intervals generate the topology of the real line). Let $O:=]a,b[\subseteq\mathbb{R}$. Then $O=\mathbb{R}\setminus(]\infty,a]\cup[b,\infty[)$.

$\implies f^{-1}(O)=(f^{-1}(]\infty,a]\cup[b,\infty[))^c=(f^{-1}(]\infty,a])\cup f^{-1}([b,\infty[))^c$. Union of two closed sets are closed, hence the result follows.

Note: Admittedly this is a topological proof, so to speak. If you need an analytical argument let me know.

• Thanks for your answer. I was looking for a more "simple" proof, since I wasn't recording the equivalence between pre-image of opens and closed and the continuity of a function. I posted simpler solution, but I'm accepting yours as the answer, because it is more interesting. – Guilherme Salomé Mar 9 '15 at 21:14
• 'Simple' is a relative term, see Linderholm's Mathematics Made Difficult. :) – Alp Uzman Mar 10 '15 at 4:02

$\left(\Leftarrow\right)$ Suppose $f$ is not continuous, then there's a point and a sequence $x,x_n\in X$ such that $x_n\longrightarrow x$, but $|f(x_n)-f(x)|>\varepsilon>0,\forall n\in\mathbb{N}$. Without loss of generality, let $f(x_n)\geq f(x),\forall n$. Taking $\alpha=f(x)+\varepsilon/2$, the set $B\equiv\{x\in X:f(x)\geq\alpha\}$ is not closed, since $x_n\in B,\forall n$, but $x\notin B$.

• The wlog you are using might need some justification though. – Alp Uzman Mar 10 '15 at 3:59