If $f: \mathbb{R} \to \mathbb{R}$ is continuous and $f(q)=0 \forall q \in \mathbb{Q}$, prove that $f(x)=0 \forall x \in \mathbb{R}$
Note: I have to prove this with the help of usual topology on $\mathbb{R}$ and without using the sequential criteria for continuity.
Here's my attempt:
From given definition of f, $f^{-1}(\{0\})=\mathbb{Q}$ at least.
But $\{0\}$ is closed in $\mathbb{R}$ and $\mathbb{Q}$ is not.
Continuous maps take closed sets to closed sets, so $f^{-1}(\{0\})$ must be a superset of $\mathbb{Q}$ which is closed.
The only such set if $\mathbb{R}$, so $f^{-1}(\{0\})=\mathbb{R}$, i.e. $f(x)=0 \forall x \in \mathbb{R}$
Is this correct?
The following is a well known result that holds for topological spaces $X,Y$:
Now, apply this theorem to $f$ and $g = 0$, and note that the rationals are dense in the reals (and that any metric space is Hausdorff)