Continuous function $f$ on $\mathbb R$ such that $f(\mathbb Q)\subseteq \mathbb R-\mathbb Q$ and $f(\mathbb R-\mathbb Q)\subseteq \mathbb Q$? 
Possible Duplicate:
No continuous function that switches $\mathbb{Q}$ and the irrationals 

Is there a continuous function $f\colon\mathbb R\to \mathbb R$ such that $f(\mathbb Q)\subseteq \mathbb R-\mathbb Q$ and $f(\mathbb R-\mathbb Q)\subseteq \mathbb Q$?
 A: Hint: Consider a continuous function $f:\mathbb R\to\mathbb R$. Either $f$ is constant or $f(\mathbb R)$ is uncountable. (Can you show this? Sub-hint: intermediate value theorem.) If $f(\mathbb R\setminus\mathbb Q)$ is countable, what  about the countability/uncountability of the set $f(\mathbb R)$, using the fact that $f(\mathbb R)=f(\mathbb Q)\cup f(\mathbb R\setminus\mathbb Q)$?
A: HINT: If such an $f$ exists, $$\Bbb R\setminus\Bbb Q=\bigcup_{q\in\Bbb Q}f^{-1}[\{q\}]$$ is the union of countably many closed sets. Now apply the Baire category theorem.
A: Suppose by contradiction that such a function exists. Then it is non-constant.
Let $a<b$ be so that $f(a) \neq f(b)$. Then by the IVT $f([a,b])$ is a non-trivial interval. Let call this interval $[c,d]$.
Thus
$$f([ a,b] \cap \mathbb Q)= [c,d] \cap (\mathbb R \backslash \mathbb Q) \,.$$
This implies that $f$ takes a countable set onto an uncountable set, contradiction.
A: See, $f(\mathbb{Q})$ is a countable set, how $f(\mathbb{R-Q})\subset \mathbb{Q}$, then, $f(\mathbb{R-Q})$ is too a countable set, then $f(\mathbb{R})$ is also a countable set. See, a continuous function have a countable image if only if $f$ is a constant function, contradiction!
