Intermediate value property and closedness of rational level sets implies continuity Suppose $f$ satisfies the intermediate value property, i.e. if $f(a)<c<f(b)$, then there exists $a<x<b$ such that $f(x)=c$ and for every rational $r$, $S_r$ such that $f(x)=r$ is a closed set. Prove $f$ is continuous.
This looks pretty daunting. I am guessing it uses some sort of sequential continuity argument, but I am somewhat lost. Hints would be most appreciated.
 A: suppose $f$ has at least one discontinuity point $x$, i.e.
$$
(\exists\epsilon>0)(\forall\delta>0)(\exists x'\in(x-\delta,x+\delta))\quad|f(x')-f(x)|\ge\epsilon\text;
$$
in particular, for each $n\in\mathbb N$ we can choose $x_n$ so that
$$
|x_n-x|<\frac1{n+1}\quad\&\quad|f(x_n)-f(x)|\ge\epsilon\text;
$$
choose
$$
r_+\in(f(x),f(x)+\epsilon)\cap\mathbb Q
\\ r_-\in(f(x)-\epsilon,f(x))\cap\mathbb Q
$$
then, by the IVP, there exists some $y_n$ between $x_n$ and $x$ such that
$$
f(y_n)=r_+\quad\text{or}\quad f(y_n)=r_-
$$
(depending whether $f(x_n)>f(x)$ or $f(x_n)<f(x)$); in particular,
$$
y_n\rightarrow x\text;
$$
suppose the '$+$' case occurs infinitely often (otherwise consider the '$-$' case): the corresponding subsequence lies in $f^{-1}(r_+)$ (closed by assumption), thus
$$
f(x)=r_+\text,
$$
in contradiction to the choice of $r_+$. this shows that no discontinuity point exists, i.e. $f$ is continuous.
EDIT my previous attempt (below) was wrong, disregard
consider the preimage of $I\cap\mathbb Q$, where $I=[a,b]$, and show that its closure is the preimage of $I$.
for any $x\in \overline {f^{-1}(I\cap\mathbb Q)}$ take a sequence $\{x_n\}$ in $f^{-1}(I\cap\mathbb Q)$ converging to $x$. then either infinitely many $x_n$'s lie in one of the $f^{-1}(r)$'s, or each $f^{-1}(r)$ only contains finitely many $x_n$'s (so the sequence intersects infinitely many $f^{-1}(r)$'s).


*

*in the first case, the subsequence lying in $f^{-1}(r)$ (closed) converges in this set, so $x\in f^{-1}(r)$.

*in the second case, construct a sequence $\{r_m\}$ and show $$f(x)=\lim_{m\rightarrow\infty}r_m$$
