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?

• And where did you use uniform continuity? – José Carlos Santos Jan 23 at 18:10
• "Since I have balls on Q with finite length" What balls? Are you talking about $f^{-1}(B(n,\epsilon))$? Those aren't nescessarily balls and they aren't nescessarily of finite length. – fleablood Jan 23 at 19:07

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 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$$.
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.
• You do have to formalize it a bit, though. For instance, all the things I said above technically also apply to $\mathbb Q\cap[(-\infty,0)\cup(1,\infty)]$, but the statement is clearly false for functions on that set. You could define an equivalence relation on all those intervals, for instance, by saying that two intervals of that length are related if they overlap, and then extend the relation to be transitive. And then you can prove that a) all such intervals are related, and b) $f$ tales the same value on related intervals. – Vercassivelaunos Jan 23 at 20:25