# Is there a continuous function with the following properties? [duplicate]

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$?

-

## marked as duplicate by David Mitra, Did, Erick Wong, hardmath, ThomasJan 1 '13 at 19:52

What do you think? –  Did Jan 1 '13 at 18:08
19 minutes.  –  Did Jan 1 '13 at 18:28
See here and here . –  David Mitra Jan 1 '13 at 18:56
@nice question ali. +1 –  Babak S. Jan 1 '13 at 19:17

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.

-
I just love it when Baire knocks at the door ... –  Hagen von Eitzen Jan 1 '13 at 18:17
@Hagen: Lions and tigers and Baires [oh my]. :-) –  Brian M. Scott Jan 1 '13 at 18:18
@ Brian M. Scott Thanks very much –  aliakbar Jan 1 '13 at 18:27
Hammer, nails, and all that... –  Did Jan 1 '13 at 18:29
I wonder how many of the downvoters understand that the answer is correct, albeit less elementary than was actually necessary. –  Brian M. Scott Jan 1 '13 at 20:14

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)$?

-
Ah, a smaller hammer; nice. –  Brian M. Scott Jan 1 '13 at 18:29
@BrianM.Scott Indeed. –  Did Jan 1 '13 at 18:31
@did Thanks very much –  aliakbar Jan 1 '13 at 18:41
@aliakbar You are welcome. Say, did you actually understand Brian's answer before accepting it? –  Did Jan 1 '13 at 21:22

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.

-

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!

-