# There does not exist any continuous function $f : \mathbb R → \mathbb R$ such that $f(x)$ is rational if and only if $f(x + 1)$ is irrational

Prove that there does not exist any continuous function $f : \mathbb R → \mathbb R$ such that $f(x)$ is rational if and only if $f(x + 1)$ is irrational. What theorems can I use to prove the statement?

• Isn't $f(x+1)-f(x)$ always irrational? – Lord Shark the Unknown Apr 23 '18 at 5:53
• My first thought was a cardinality argument. My second thought is I'm about to crash, so maybe I'll look at this tomorrow and maybe not. – Michael Hardy Apr 23 '18 at 6:05

The two continuous functions $x\mapsto f(x)\pm f(x+1)$ take only irrational values, hence are both constant. Then their sum $2f$ is also constant - but the constant can neither be rational nor irrational.
• What if we rephrase the question as follows: $f:\mathbb R \to L,$ where $L$ is a linearly ordered set, so ordered that between any two elements of $L$ there is another, and $K\subseteq L$ and between any two elements of $L$ there is an element of $K,$ and $K$ is countable. And $L$ has the least-upper-bound property. And let us assume $|L|>1.$ And $f(x)\in K$ if and only if $f(x+1)\notin K.$ Can that happen? – Michael Hardy Apr 23 '18 at 6:28
• It looks like the continuity condition is not necessary. The solution above does not use such a property of $f(x)$, does it? – pabodu Apr 23 '18 at 13:20