Find all continuous functions $f: \mathbb{R}\to \mathbb{R}$ such that $$f(x)-f(y)\in \mathbb{Q}\quad \text{ for all }\quad x-y\in\mathbb{Q}$$
I found a solution here which is this:
By translation we may assume $f(0)=0$. Fix $a\in {\bf Q}$ and let $g(x):=f(x+a)-f(x)$ then $g$ is continuous and $g:{\bf R}\rightarrow {\bf Q}$. Hence $g$ is constant, its value is $f(a)$ hence $f(x+a)=f(x)+f(a)$ when $a\in {\bf Q}$. Then also $f(a+b)=f(a)+f(b)$ when $a,b\in {\bf Q}$. Then $f(x)=kx$ on ${\bf Q}$, hence $f(x)=kx$ on ${\bf R}$. The only extra condition is $k\in {\bf Q}$. The orginal problem has solutions $f(x)=kx+l$ where $k\in{\bf Q},l\in {\bf R}$.
- How did they assume $f(0)=0$?
- How did they conclude that $g(x)$ is a constant function?
- Not a doubt, but what could have been the thought process/motivation behind taking such $g(x)$ in such a way?