Does there exist a continuous onto function from $\mathbb{R}-\mathbb{Q}$ to $\mathbb{Q}$?

Does there exist a continuous onto function from $\mathbb{R}-\mathbb{Q}$ to $\mathbb{Q}$? (where domain is all irrational numbers)

I found many answers for contradicting the fact that there doesnt exist a continuous function which maps rationals to irrationals and vice versa.

But proving that thing was easier since our domain of definition of function was a connected set, we could use that connectedness or we could use the fact that rationals are countable and irrationals are uncountable.

But in this case those properties are not useful. I somehow think that baire category theorem might be useful but I am not good at using it.

• Try $f(x)=1$... – David C. Ullrich Sep 13 '15 at 18:07
• you missed onto. – Landon Carter Sep 13 '15 at 18:07
• @DavidC.Ullrich - OP asked for an onto function. – Sam Cappleman-Lynes Sep 13 '15 at 18:07

Yes. Say $E_n$ is the set of irrationals in the interval $(n,n+1)$. Say $(q_n)$ is an enumeration of $\Bbb Q$. Define $f(x)=q_n$ for $x\in E_n$.

• This is amazing!! How could you create such a function? I mean how did you come up with this? – Landon Carter Sep 13 '15 at 18:14
• Can you give more explanation , what is enumeration of rational ? – Shubham Ugare Sep 13 '15 at 18:21
• I guess this construction can also be used to show that, if $X$ is any topological space which can be partitioned into a countably infinite collection of open sets (which are then automatically closed too) and $Y$ is any countable topological space, then there exists a continuous surjection $X \to Y$. – Mike F Sep 13 '15 at 18:25
• @ShubhamUgare The rationals are countable. An enumeration of the rationals is just a sequence containing each rational exactly once. (Here just for convenience we took that "sequence" to be indexed by integers instead of natural numbers.) – David C. Ullrich Sep 13 '15 at 18:27
• @LandonCarter I have a hard time saying how I came up with that, sorry. Seemed like an obvious thing... – David C. Ullrich Sep 13 '15 at 18:30

Yes, there exists such a function.

Biject $\mathbb{Q}$ with $\mathbb{Z}$ to get $\mathbb{Q} = \{q_n \mid n \in \mathbb{Z}\}$, and let $\mathbb{I}$ be the set of irrational numbers.

Define $I_n$ for $n \in \mathbb{Z}$ as $\mathbb{I} \cap (n, n+1)$. Then define $f(x) = q_n$ for all $x \in I_n$.

This is continuous, since for any irrational number in $I_n$, there is a small neighbourhood of it which is contained entirely within $I_n$ (because the "endpoints" of $I_n$ were chosen to be rational)

• Did you notice that that's exactly the same as the example I gave? – David C. Ullrich Sep 13 '15 at 18:26
• Yes - but we answered at almost the same time. – Sam Cappleman-Lynes Sep 13 '15 at 18:27