real analysis on function continuity and rational numbers Let $f: \mathbb{Q}\rightarrow\mathbb{Z}$ be continuous. Let $S$ be the set of $x \in\mathbb{Q} $ such that $f(x)=1$. Suppose that $S$ is bounded above, and let $y$ be the sup of $S$ (in the real numbers). 

Show that $y \notin\mathbb{Q}$.

I tried to assume that $y \in \mathbb{Q},$ then $f(y)=1$ for sure. But, how can I get contradiction?
 A: Let $f$ be a function from the set of rationals, $\mathbb{Q}$, to the set of integers, $\mathbb{Z}$. That is,
$$f:\mathbb{Q}\to\mathbb{Z}$$
Let $S$ be the set of every rational that gets mapped to $1$ by $f$. That is,
$$S=\{x\in\mathbb{Q}:f(x)=1\}$$
If $f$ is continuous and $S$ is bounded above, then $\sup\limits_{\mathbb{R}}S$ is not a rational number.
Proof. Assume the following:
(i) $f$ is continuous.
(ii) $S$ is bounded above.
If $S$ is empty, then $\sup S$ does not exist. Therefore $\sup S$ is not a rational number; to say otherwise implies existence. Henceforth $S$ is nonempty.
Because $S$ is nonempty and (ii) bounded above, $\sup S$ exists (by the least upper bound property of the real numbers). Define $y\overset{\text{def}}{=}\sup S$.
By contradiction, suppose $y$ is a rational number. By (i), $f$ is continuous at $y$. Therefore for each $\epsilon>0$, there exists $\delta>0$ such that for each $x\in\mathbb{Q}$, if $|x-y|<\delta$, then $|f(x)-f(y)|<\epsilon$.
Define $\epsilon\overset{\text{def}}{=}1/2$. Therefore there exists $\delta>0$ such that for each $x\in\mathbb{Q}$, if $|x-y|<\delta$, then $|f(x)-f(y)|<1/2$. Therefore for each $x\in\mathbb{Q}$, if $|x-y|<\delta$, then $f(x)=f(y)$ (because $f$ maps to $\mathbb{Z}$).
By the density of the rational numbers in the reals, there exists a rational number $z_1$ such that
$$y<z_1<y+\delta$$
Therefore
$$f(y)=f(z_1)$$
Because $y=\sup S$, there exists $z_0\in S$ such that
$$y-\delta<z_0\le y$$
Therefore
$$f(y)=f(z_0)$$
Recall $z_0\in S$. Therefore $f(z_0)=1$. Therefore $f(y)=1$. Therefore $f(z_1)=1$. Therefore $z_1\in S$.
Recall $y$ is an upper bound of $S$. Because $y<z_1$ and $z_1\in S$, $y$ is not an upper bound of $S$ (a contradiction).
As a result, $y$ is not a rational number.$\square$
Sorry for the many paragraphs, but I risked brevity for conceptual understanding. Brevity should only be used after understanding has been reached. This is why I do not use logic notion when answering questions. I hope I achieved my goal of having you understand the logic behind the proof. Any questions can be directed in the comments section.
A: Suppose by contradiction $y \in \mathbb{Q}$, then for any $x \in \mathbb{Q}$ with $x > y$ you have $f(x) \neq 1$. In particular, since on $\mathbb{Q}$ the function takes values in $\mathbb{Z}$, for any $x \in \mathbb{Q}$ with $x > y$ you have $|f(y) - f(x)| \geq 1$. Then for any sequence $a_{n} \to y$ with $a_{n} \in \mathbb{Q}$ and $a_n > y$ you have that $f(a_n)$ does not converge to 1.
A: Since $\{1\}$ is open in $Z$ so $S=f^{-1}\{1\}$ is open in $Q$. Which means that if $S$ is non-empty and $t \in S$ then there is a $t_1 > t$ with $t_1 \in S$ so any element of $S$ cannot be supremum of $S$.
