About the derivative of a function defined on rational numbers
Solution 1:
The desired version of the Mean Value Theorem is not generally true for functions $g:\mathbb Q\to \mathbb R$. To see that consider the function: $$g(x) = \begin{cases} 0, & \text{if $x<\pi$} \\ 1, & \text{if $x>\pi$} \end{cases}$$
That function has derivative $0$ everywhere (as it is locally constant) but it is not a constant.
To your problem:
We have $$|f(x)-f(y)|=|f(x)-f\left(\frac {x+y}2\right)+f\left(\frac {x+y}2\right)-f(y)|≤|f(x)-f\left(\frac {x+y}2\right)|+|f\left(\frac {x+y}2\right)-f(y)|$$ $$≤\frac {(x-y)^2}2$$
Repeat this using the stronger estimate to see that $$|f(x)-f(y)|≤\frac {(x-y)^2}4$$ and iterate to see that ($\forall n\in \mathbb N$) $$|f(x)-f(y)|≤\frac {(x-y)^2}{2^n}$$
And as $n\to \infty$ we see that $f(x)=f(y)$.