Why is such function continuous? Can anyone help me see why the function $f: \bar{\mathbb{Q}} \to \mathbb{Q} $ where $\bar{\mathbb{Q}}$ denotes the set of algebraic numbers,
$$f(x)=\begin{cases}1,&\ \text{if the real part of $x$ is greater than $\pi$, and}\\
0,&\ \text{otherwise.}\end{cases}$$
is continuous?

Note that $z \in \mathbb C$ is algebraic over $\mathbb Q$ if and only if $Re(z), Im(z)$ are algebraic over $\mathbb Q$. Now, to show that $f$ is continuous we need only show that $f^{-1}[0]$ and $f^{-1}[1]$ are closed. Indeed, $f^{-1}[1]$ is precisely those $z \in \overline{\mathbb Q}$ such that $Re(z) > \pi$. Since $Re(z)$ is algebraic and $\pi$ is transcendental, $Re(z) > \pi$ iff $Re(z) \geq \pi$. Now, let $S \subseteq \mathbb C$ be defined as $\{z \in \mathbb C : Re(z) \geq \pi\}$. The map $Re: \mathbb C \longrightarrow \mathbb R$ is just projection, so it is continuous. Thus, $S = Re^{-1}[[\pi, \infty)]$ is closed. Furthermore, as discussed, $S \cap \overline{\mathbb Q} = f^{-1}[1]$. Then as $S$ is closed in $\mathbb C$, $S \cap \overline{\mathbb Q} = f^{-1}[1]$ is closed in the subspace topology.
$f^{-1}[0]$ consists of $Re(z) \leq \pi$ so essentially the same argument shows $f^{-1}[0]$ is closed. Hence, $f$ is continuous.
