TITLE: 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
QUESTION [8 upvotes]: 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?

REPLY [18 votes]: 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.