True or false: There exists a continuous function $f: \Bbb R \to \Bbb R$ such that $f(\Bbb Q) \subseteq {\Bbb R}\setminus {\Bbb Q}$ and $f({\Bbb R}\setminus {\Bbb Q}) \subseteq {\Bbb Q}$.

My attempt: I was trying to use the sequential definition of continuity. Consider $a \in \Bbb R$ then we have a seqn ${x_n}$ of rational numbers converging to $a$ and we have a seqn ${y_n}$ of irrational numbers converging to $a$. Then what will be $f(a)$? I was thinking that in one way $f(a) \in \Bbb Q$ and on the other way $ f(a) \in {\Bbb R}\setminus {\Bbb Q}$ . But I am wrong $\{f(x_n)\} \subseteq {\Bbb R}\setminus {\Bbb Q}$ and $\{f(y_n)\} \subseteq {\Bbb Q}$ still $f(a)$ can be anywhere.

Is there any way to fix my attempt or any other possible idea?

  • 2
    $\begingroup$ Hint: suppose $f$ is nonconstant, and let $a,b$ be two of its values. Then $f$ should take uncountably many irrational values between $a,b$. $\endgroup$ – Wojowu Jun 16 '19 at 22:11
  • $\begingroup$ @Wojowu In fact you don't have to suppose $f$ is nonconstant, it is a consequence of the assumptions. $\endgroup$ – TSF Jun 16 '19 at 22:14
  • $\begingroup$ @TonyS.F. My argument would require considering two cases, constant vs nonconstant. The former is immediate though. $\endgroup$ – Wojowu Jun 16 '19 at 22:20

There is a nice proof of this fact, which doesn't use cardinality. Assume such $f:\Bbb R\to \Bbb R$ exists. You can do two modifications to $f$ which wont change the property that $f(\Bbb Q) \subseteq {\Bbb R}\setminus {\Bbb Q}$ and $f({\Bbb R}\setminus {\Bbb Q}) \subseteq {\Bbb Q}$:

  • You can add a rationnal number to $f$, i.e take $\tilde{f}$ defined by $\tilde{f}(x)=f(x)+p/q$.

  • You can multiply $f$ by a rational number, i.e take $\tilde{f}$ defined by $\tilde{f}(x)=(p/q)\times f(x)$.

Now define $g=f\vert_{[0,1]}$. Then $g$ is continuous and bounded. By adding a "big" rational number to $f$ you can assume $g\geq 0$. By multiplying $f$ by a "small" positive rational number you can also assume $g\leq 1$. Finally you have found $g:[0,1]\to [0,1]$ which is continuous and send rational numbers to irrational and conversely. But this is not possible, as $g$ must have a fixed point.

  • $\begingroup$ You said “$g$ is continuous and bounded”. What’s $g$? $\endgroup$ – Lubin Jun 16 '19 at 23:26
  • $\begingroup$ @Lubin It was not at the right place I edited my answer $\endgroup$ – Adam Chalumeau Jun 16 '19 at 23:27
  • $\begingroup$ Why does $g$ have a fixed point? Is it immediate? $\endgroup$ – Ri-Li Jun 16 '19 at 23:45
  • $\begingroup$ @Hunter It's a "classical result", just apply the intermediate value theorem to the continuous function $x\mapsto g(x)-x$. See here. $\endgroup$ – Adam Chalumeau Jun 16 '19 at 23:47

Not the answer you're looking for? Browse other questions tagged or ask your own question.