prove the set of all functions such that $f:\mathbb{Z} \to \mathbb{Z}$ where $|f(x)-f(y)|=|x-y|$ form a group under composition Let f be a function $f:\mathbb{Z} \to \mathbb{Z}$ where $|f(x)-f(y)|=|x-y|$
prove that the set of all such functions forms a group under composition. 
I think this is the set of all linear functions, yes? since $f(x)=x+z$, $z\in \mathbb{Z}$, satisfies this property. It just 'shifts' this 'gap' in some direction along the number line. I assume this works: 
Let $a,b \in \mathbb{Z}$ then $|f(x)-f(y)|=|a+z-(b+z)|=|a-b+(z-z)|=|a-b|$
I think this has closure since the composition $f(g(x))=f(x+z)=x+2z$ where $2z \in \mathbb{Z}$ since $(Z,+)$ is itself a group. 
I am not really sure how to identify and prove the existence of the identity here since this is dealing with a set of functions. Any guidance/hints?  

And as a note - If you've noticed me posting abstract alg. questions over the past day or two it is because I am doing ever problem/exercise/proof given by our prof. over the course of the last month to prepare myself for an exam! None of these are assigned for grading. 
 A: Note that functions of the form $f(x)=a-x$ also satsify the contition.
But it seems to be a detour to want to describe exactly which functions are in the group. It's not too hard to show that it is exactly the functions of the form $a-x$ and $a+x$, but it's still a detour, and could be viewed as inelegant to have to split everything into these two cases (which multiply into four for composition) instead of working directly from the definition and avoiding the splitting completely.
If you can suppress your desire to know which functions you're talking about, it is easy to prove directly from the defining property that it $f$ and $g$ both have it, then $f\circ g$ has the same property -- and that if $f$ has the property then it is bijective, and its inverse must have the same property.

Aside proving that $f$ must be bijective: First, if $f(x)=f(y)$ then $|f(x)-f(y)|=0$ so $|x-y|=0$ which means that $x=y$. Thus we have shown that $f$ has to be injective. Now to show that $f$ is surjective, let $y$ be arbitrary and we must show that $y$ is in the range of $f$. Let $m=|f(0)-y|$. If $m=0$ then $y=f(0)$ and we're done. Otherwise each of $m$ and $-m$ must map to one of $f(0)+m$ and $f(0)-m$; since $f$ is injective they can't both map to the same one, so $f(0)+m$ and $f(0)-m$ are both in the range of $f$; one of them must be $y$ and we're done.

As always when we're talking about composition of functions, the identity element must be the identity function $f(x)=x$. (You'll need to show that it is in the group as defined, of course).
In principle you should also check that the operation is associative, but you get that for free when the operation is function composition; that is always associative no matter which functions we're speaking of.
Incidentally the group in question is known as the infinite dihedral group.
A: Call that set with composition $G$. Note that each element of $G$ must be a bijection in order to have well-defined operation.
Obviously identity function belongs to $G$.if $f,g\in G$ then
$$|f\circ g(x)-f\circ g(y)|=|f(g(x))-f(g(y))|=|g(x)-g(y)|=|x-y|$$ so $f\circ g\in G$.
 $$|x-y|=|f\circ f^{-1}(x)-f\circ f^{-1}(y)|=| f^{-1}(x)-f^{-1}(y)|$$
