No cont function $f\colon\mathbb{R}\to\mathbb{R}$ with $f(x)$ rational $\iff f(x+1)$ irrational.

Prove that there are no continuous functions $f\colon \mathbb{R} \to \mathbb{R}$ with the property:

For any $x \in \mathbb{R}$, $f(x)$ is a rational number if and only if $f(x+1)$ is an irrational number.

Source: 6th University of Rochester Math Olympiad.


Solution 1:

Suppose $f$ were such a beast. Then

$$g(x) = f(x+1) - f(x)$$

defines a continuous function on $\mathbb{R}$ that takes only irrational values. By the intermediate value theorem and the denseness of $\mathbb{Q}$ in $\mathbb{R}$, $g$ must be constant, say $g \equiv c$.

Let $x_0 \in \mathbb{R}$ with $f(x_0) \in \mathbb{Q}$. Then $f(x_0+2) - f(x_0) = 2c\in \mathbb{Q}$, contradicting the irrationality of $c$.