TITLE: Prove or disprove that there does not exist a monotone function $f:\mathbb{R}\rightarrow\mathbb{Q}$ which is onto.
QUESTION [5 upvotes]: Prove or disprove that there does not exist a monotone function $f:\mathbb{R}\rightarrow\mathbb{Q}$ which is onto.
Clearly $f$ can not be continuous. Suppose $f$ is discontinuous. Then it can have only countably many points of discontinuity. From this how to proceed?

REPLY [3 votes]: There's nothing wrong with the proof above.  I offer a slightly different approach.
If such a function $f$ exists, then (substituting $-f$ for $f$ if necessary) there is an increasing function that works.
Choose $y \in \Bbb R \setminus \Bbb Q$.  Then $\exists r \in \Bbb Q$ with $y \lt r$.  Since $f$ is surjective, $\exists t \in \Bbb R$ such that $f(t) = r$.  Because $f$ is increasing, that means that $t$ is an upper bound for $A= \{ x \in \Bbb R ~\vert~ f(x) \lt y \}$ (which we know is non-empty because $f$ is surjective and $\exists s \lt y$ with $s$ rational), so $x = \sup A$ exists.
Since (by assumption) $y \notin \Bbb Q = \operatorname{range}(f)$, we have $f(x) \neq y$.  If $f(x) \lt y$, then because $\Bbb Q$ is dense in $\Bbb R, \exists s \in \Bbb Q$ with $f(x) \lt s \lt y$.  But then $f$ surjective $\Rightarrow \exists x_1$ such that $f(x_1) = s$.  Since $f$ is increasing, $x \lt x_1$, but $x_1 \in A$ and $x = \sup A \Rightarrow x_1 \leq x$ so that's not possible.
Conversely, if $y \lt f(x)$, then $\exists s \in \Bbb Q$ with $y \lt s=f(x_2) \lt f(x)$.  But then $x_2 \lt x$ is an upper bound for $A$, contradicting our definition of $x$.
So there is no value $f(x)$ can take, establishing a contradiction.  Thus, no such function $f$ can exist.