# Algebraic numbers and algebraic functions

If I have a continuous function $$f : \bar{\mathbb{Q}} \to \mathbb{Q}$$, where $$\bar{\mathbb{Q}}$$ denotes the set of algebraic numbers, how could I show that this function has to be constant?

I was trying to prove it in the following way: I assume my function not to be constant. Then, I can always find an $$y \in \bar{\mathbb{Q}} \setminus \mathbb{Q}$$ from the range of my function $$f$$ (due to denseness), and then while bringing back the point $$y$$ via the prei-image of my function $$f$$, I would get a point in $$\bar{\mathbb{Q}}$$ (I can't convince myself if this is true completely), which then would bring me to a contradiction. I am not sure if my last argument holds true. Any help or reading suggestion about algebraic numbers, would help me a lot.

• What topology are you using for $\overline\Bbb Q$? For example if you have an embedding of $\overline\Bbb Q$ into $\Bbb C$ and you use the subspace topology, then $f(z) = \Im z$ is a counterexample. – Greg Martin Aug 14 at 17:34
• Usual topology @GregMartin – b.omega Aug 14 at 17:48
• More generally any polynomial with algebraic coefficients is continuous, and even continuous for all the possible nonarchimedean topologies too. – user208649 Aug 14 at 19:17
• @TokenToucan But the range of the function shall be contained in $\mathbb{Q}$, not in $\overline{\mathbb{Q}}$. – Daniel Fischer Aug 14 at 19:39
• @DanielFischer ahh didn't spot that! – user208649 Aug 14 at 19:46

The claim is actually false. Proffering the following counterexample $$f(x)=\begin{cases}1,&\ \text{if the real part of x is greater than \pi, and}\\ 0,&\ \text{otherwise.}\end{cases}$$
• First I tried to prove the claim when the domain is $\Bbb{Q}(\sqrt2)$. Then I came up with the same counterexample using $\sqrt3$ instead of $\pi$. After a few more minutes I saw the light. – Jyrki Lahtonen Aug 17 at 9:33