Give a continuous surjective function from the irrationals in $[0,1]$ onto the rationals in $[0,1]$. Can we at least prove the existence of such a function? I couldn't see a function off the top of my head. Here we assume $[0,1]\setminus\mathbb Q$ with its usual metric.
Real Analysis – Continuous Onto Function from Irrationals in [0,1] onto Rationals in [0,1]
real-analysis
Related Question
- Thomae’s Function – Continuity at Irrationals
- [Math] Does there exist a continuous onto function from $\mathbb{R}-\mathbb{Q}$ to $\mathbb{Q}$
- [Math] A continuous onto function from $[0,1)$ to $(-1,1)$
- Problem with proof from Pugh’s Analysis book on the presence of both rationals and irrationals in every interval
- Real Analysis – No Function Continuous at Rational Points and Discontinuous at Irrational Points
Best Answer
Let $I = [0,1]\setminus \mathbb{Q}$, the set of irrationals in the unit interval.
Partition $I$ into countably many nonempty pieces, each given by the intersection of an open set in $[0,1]$ and $I$, such that $I = \cup_{k=0}^\infty I_k$. For example,
$I_0 = \left(\frac{1}{2},1\right) \cap I$,
$I_1 = \left(\frac{1}{4},\frac{1}{2}\right)\cap I$,
and in general $I_k = \left(\frac{1}{2^{k+1}},\frac{1}{2^k}\right)\cap I$. Note that each $I_k$ is open in $I$.
Enumerate $\mathbb{Q} \cap [0,1]$ (in any way you like): $\{q_0, q_1, q_2,\dots\}$.
For any $x\in I$, $x\in I_k$ for exactly one $k$. Define $f(x) = q_k$.
Note that $f$ is surjective, since each $I_k$ is nonempty.
We want to show that $f$ is continuous. Let $O\subseteq \mathbb{Q}\cap [0,1]$ be an open set. We can write $O = \bigcup_{q_k\in O} \{q_k\}$.
$$f^{-1}[O] = \bigcup_{q_k\in O}\,f^{-1}[\{q_k\}] = \bigcup_{q_k\in O} I_k.$$
This is a union of open sets in $I$, so it is open.
Note that we didn't actually use that $O$ was an open set: our function $f$ is continuous even if we give $\mathbb{Q}$ the discrete topology!