# Problem 19 chapter 4 from baby Rudin

Suppose $f$ is a real function with domain $\mathbb{R}^1$ which has the intermediate value property: If $f(a)<c<f(b)$, then $f(x)=c$ for some $x$ between $a$ and $b$. Suppose also, for every rational $r$, that the set of all $x$ with $f(x)=r$ is closed. Prove that $f$ is continuous.

Proof: By contradiction. Let's $f$ is not continuous at some point $p\in \mathbb{R}^1$. Then $\exists \{x_n\}$ such that $x_n\to p$ but $f(x_n)\nrightarrow f(p)$. It means that $\forall N$ $\exists n\geqslant N$ such that $|f(x_n)-f(p)|\geqslant \varepsilon$ for some $\varepsilon>0$. Thus $\exists \{n_k\}$ such that $x_{n_k}\to p$ but $|f(x_{n_k})-f(p)|\geqslant \varepsilon$. Let $\{k_j\}$ such that $x_{n_{k_j}}\to p$ and $f(x_{n_{k_j}})\leqslant f(p)-\varepsilon<f(p)$ but $(f(p)-\varepsilon,f(p))$ contains some $q\in\mathbb{Q}$. Hence $f(x_{n_{k_j}})<q<f(p)$ for all $j$ and some $q$. By intermediate value property $\exists a$ between $x_{n_{k_j}}$ and $p$ such that $f(a)=q.$ Then $\exists \{j_r\}$ such that $$x_{n_{k_{j_r}}}<a<p\quad \text{or}\quad p<a<x_{n_{k_{j_r}}}.$$ WLOG we can consider the first inequality and making limit conversion we get $p\leqslant a<p.$ It's nonsense. I guess that here must $p\leqslant a\leqslant p$ or not?

Can anyone help to me? What's next?

Hint: You should be able to find a sequence $a_n \to p$ so that $f(a_n) = q$ for all $n$. By the closedness of $f^{-1}(q)$, we have $f(p)= q$. However, there are more than one $q$'s so that $q\in [f(p)-\varepsilon , f(p)]$. Can you see how you could come up with a contradiction?
• That $a$ actually depends on $x_{n_{k_{j_r}}}$ (That's the sequence I am using in my answer). @RFZ – user99914 Sep 28 '15 at 22:12
• Why? We have that $f(x_{n_{k_{j_{r}}}})<q<f(p)$ for all $r$ and some rational $q$. I think that $a$ does not depends on $x...$. – ZFR Sep 28 '15 at 22:16
• But $a$ is found in $(x_{n_{k_{j_r}}}, p)$. This interval is changing depending on $r$. For any $r$, you can find an element in this interval. But this interval is getting smaller and smaller, it will not contain any fixed $a$ as $r\to \infty$. @RFZ – user99914 Sep 28 '15 at 22:22
• Sorry please. But why $a$ is found on above interval? – ZFR Sep 28 '15 at 22:33