Exercise:
Let $f(x)$ be continuous for $0 \leq x \leq 1$. Suppose further that $f(x)$ assumes rational values only and that $f(x) = \frac{1}{2}$ when $x = \frac{1}{2}$. Prove that $f(x) = \frac{1}{2}$ everywhere.
Attempt:
Suppose $f(\frac{1}{2} + \delta_1) = p \neq \frac{1}{2}$ is rational.
There is a irrational number $q$ that is between $\frac{1}{2}$ and $p$.
For $f$ to be continuous, there must be a $f(\frac{1}{2} + \delta_2) = q$ where $\delta_2<\delta_1$.
But, by $f$'s definition, it contains no irrational numbers.
So, the only other option is that $f(\frac{1}{2} + \delta_1) = \frac{1}{2}$.
Request:
Is my proof correct? If not, where and why'd I go wrong?