# To prove or disprove existence of a continuous function $f$ on $\mathbb R$ satisfying $f(x)\in\mathbb Q$ iff $f(x+1)\in\mathbb R\setminus\mathbb Q$

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?

• For $f:\mathbb{R} \rightarrow \mathbb{R}$ there is no such function - there can't even be any irrational value in its image Commented Jan 25, 2018 at 11:59

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.
• Why do you go so far $$f(x+1) = -f(x)+c= f(x-1)=.....$$ Commented Jan 25, 2018 at 12:25
Since $f(x+1)-f(x)$ is continuous and takes only irrational values, it's a constant function; i.e., there is an irrational number $c$ such that $f(x+1)-f(x)=c$ for all $x.$ However, if we choose $a$ so that $f(a)$ is rational, then $2c=f(a+2)-f(a)$ is rational. Contradiction!
Assume such a function exists. let $f(x_1)$ be rational, then $f(x_1 + 1)$ has to be irrational and $f(x_1+2)$ must be rational. By I.V.P all the irrational numbers between $f(x_1)$ and $f(x_1 + 1)$ must be achieved between $x_1$ and $x_1+1$, implying uncountable points (dense as well) between $x_1+1$ and $x_1+2$ must achieve rational numbers, implying some rational number was achieved infinite number of times in compact interval. but since function is continuous, this can happen only if that value is achieved over an interval, implying all points in that interval which had to have irrational image( why?!), got mapped to a rational number. Hence a contradiction.