I would like an alternate solution and proof verification for the following problem:
Find all continuous functions $f:\mathbb R \rightarrow \mathbb R$ so that if $x-y$ is rational then $f(x)-f(y)$ is rational.
My solution:
Given $r\in \mathbb Q$ let $g(x)=f(x+r)-f(x)$. $g(x)$ is continuous since $f(x)$ and $f(x+r)$ are continuous, the latter because $f(x+r)$ is the composition of the continuous functions $f$ and $x+r$, the claim follows from the fact the subtraction of two continuous functions is continuous.
Suppose $g(x)\neq g(y)$ Pick $z$ irrational between $g(x)$ and $g(y)$ exclusive, by the intermediate value there is a $c$ so that $g(c)=z$, that is $f(c)-f(c-r)$ is irrational while $c+r-c=r$ is rational, a contradiction, therefore $g(x)$ is constant.
We prove if $f(0)$ and $f(1)$ are given then the function $f$ is uniquely determined, proof: given a rational number $a$ take $k$ and $l$ positive integers so that $ka=l$.
On the one hand $f(l)=f(0)+l(f(1)-f(0))$, the proof is simple by induction, f(1)=f(0)+f(1)-f(0) clearly. $f(n+1)-f(n)=f(1)-f(0)$ since $f(x+1)-f(x)$ is constant and so from here:
$f(n+1)=f(n)+f(1)-f(0)=f(0)+n(f(1)-f(0))+f(1)-f(0)=$ $f(0)+n+1(f(1)-f(0))$ by induction hypothesis.
Analogously $f(ka)=f(0)+k(f(a)-f(0))$ and since $l=ka$ we obtain $f(0)+k(f(a)-f(0))=f(0)+l(f(1)-f(0))$ from here $f(a)-f(0)=(f(1)-f(0))\frac{l}{k}$. Therefore the function is uniquely determined for all rational numbers. And hence also for all real numbers, this is because if $f$ and $h$ are continuous with $f(x)=h(x)$ for all rational $x$ then $h=f$, otherwise there would be an $x_0$ with $f(x_0)-g(x_0)\neq 0$, by continuity there is $\delta>0$ so that $f(x)-g(x)\neq 0$ for $x\in (x_0-\delta,x_0+\delta)$, this is impossible because there is a rational number in that interval.
So given $a=f(0)$ and $b=f(1)-f(0)$ the function is uniquely determined, of course $f(1)-f(0)$ must be rational. Notice that $f(x)=bx+a$ works, and hence these are the only functions that work. Just to be clear, the functions we want are $bx+a$ with $b\in \mathbb Q,a\in\mathbb R$
Than you very much in advance, regards.
The solution is correct. I would do it only slightly differently, and more briefly:
First, for any $r\in\mathbb Q$ the function $x\mapsto f(x+r)-f(x)$ only takes rational values and is continuous, so it must be constant; call it $c_r$. A simple iteration gives $f(x+kr)-f(x)=kc_r$ for any $k\in\mathbb Z$. For the different constants $c_r$ to be compatible with this relation, we must in fact have $c_{kr}=kc_r$ for all $k\in\mathbb Z$. But now also $c_{kr/q}=kc_{r/q}=k\frac1qc_{qr/q}=\frac kq c_r$ for all $k\in\mathbb Z$ and $q\in\mathbb Z\setminus\{0\}$. We have thus found that $f(x+p)-f(x)=pc_1$ for all $p\in\mathbb Q$. Putting $x=0$ gives $f(p)=f(0)+pc_1$ for all rationals $p$. The rationals are dense and $f$ is continuous, so $f(p)=f(0)+pc_1$ for any $p\in\mathbb R$. The number $f(0)$ is real and $c_1$ is rational numbers; on the other hand any function of this form does clearly satisfy the condition.