Every uniformly continuous function $\mathbb Q\to \mathbb Z$ is constant. First of all, is continuity not enough?
Secondly, my attempt is since it is uniform continuous.
For $\epsilon=1/2$, for every ball on $\mathbb Z$
i.e. $B(n,\epsilon)\subset \mathbb Z$, with $B(n,\epsilon)\cap \mathbb Z=\{n\}$
on the inverse image $f^{-1}(B(n,\epsilon))$, $f$ is constant.
Since I have balls on $\mathbb Q$ with finite length, I can cover $\mathbb Q$ with infinitely many of them (centered at every rationals) and since every ball (interval) intersects and if two ball intersects their value under $f$ must be the same so I can conclude that $f$ is constant on whole $\mathbb Q$.
I believe the proof is correct (of course some details should be added), is there more elegant/clever way to prove it? Such as in the case for $f:\mathbb R\to \mathbb Z$ case using connectedness?
 A: If all you know about $f$ is that it's continuous, then $f$ may well fail to be constant. Take, for instance$$\begin{array}{rccc}f\colon&\Bbb Q&\longrightarrow&\Bbb Z\\&x&\mapsto&\begin{cases}0&\text{ if }x<\sqrt2\\1&\text{ otherwise.}\end{cases}\end{array}$$So, your proof cannot work, since it does not use uniform continuity.
Now, take an uniformly continuous function $f\colon\Bbb Q\longrightarrow\Bbb Z$. Suppose that there are numbers $a,b\in\Bbb Q$ such that $a<b$ and that $f(a)\ne f(b)$. Let $c=\sup\{x\in[a,b]\mid f(x)\ne f(b)\}$. There is a $\delta>0$ such that$$|x-y|<\delta\implies\bigl|f(x)-f(y)\bigr|<1.$$The interval $\left(c-\frac\delta2,c+\frac\delta2\right)$ contains rational numbers $x$ such that $f(x)=f(b)$ and contains rational numbers $y$ such that $f(y)\ne f(b)$. But this is impossible, since $|x-y|<\delta$ and $\bigl|f(x)-f(y)\bigr|\geqslant1$.
A: Less formal, more intuitive: If $f$ is uniformly continuous, then there is a $\delta>0$ such that $f$ varies by less than $1$ on all intervals of length $\delta$. But since it's a function to $\mathbb Z$, it then has to be constant on all those intervals. And since $\mathbb Q$ can be covered by overlapping intervals of that length, $f$ has to be constant in its entirety.
