Prove or disprove:
There exists a continuous function $f:\mathbb{R} \to \mathbb{R}$ which satisfies the following property:
For each $x\in \mathbb{R}$, $f(x)$ is rational if and only if $f(x+1)$ is irrational.
I can prove that such a function does not exist if you add the additional condition of differentiability. But not sure how to do it otherwise. My current mode of attack is to use the uncountability of irrationals vs the countability of rationals argument but to no avail. Any help?
Suppose $f$ exists, then $g(x) = f(x) + f(x + 1)$ is continuous but $g(\mathbb{R}) \subseteq \mathbb{Q}^c$. So $g$ is a constant function. Denote $g(x) = c \ (x \in \mathbb{R})$.
It is apparent that $f$ is not a constant function. Suppose $a, b \in f(\mathbb{R})$ and $a < b$. Note that $f$ is continuous, then $\mathbb{Q}^c \cap [a, b] \subseteq [a, b] \subseteq f(\mathbb{R})$. Thus for any $c' \in \mathbb{Q}^c \cap [a, b]$, there is $c - c' \in \mathbb{Q}$, which implies $\mathbb{Q}^c \cap [a, b]$ is a countable set, a contradiction.