# Isometry in compact metric space

Let $(M,d)$ be a compact metric space and $f: M \rightarrow M$ a continuous function. I'm trying to prove that if $d(f(x),f(y)) \geq d(x,y)$ for every $x,y \in M$, then $f$ is an isometry. This is how far I could get: Since $f$ is a continuous function, the set $\{(x,y) \in M \times M : d(f(x),f(y)) = d(x,y)\}$ is closed, and hence compact. By symmetry, it is of the form $N \times N$. Thus, $N$ (with the metric induced by $M$) is a compact metric space such that $d(f(x),f(y)) = d(x,y)$ for every $x,y \in N$. I already know that this implies that the restriction of $f$ to $N$ is an isometry of $N$, but how to prove that the open set $M \setminus N$ is empty?

-
Hint: suppose $x,y\in M$ are such that $d(fx,fy)>d(x,y)$. By induction, get a sequence of points $z_n$ such that $d(z_n,y)>d(z_{n-1},y)$ for all $n$. Combine with compactness of $M$. –  wildildildlife Jul 14 '11 at 13:06
A good exercise as a follow-up: prove that $f$ must also be surjective. –  Mark Jul 14 '11 at 16:18
You can find a common subsequence: Find $h(n)$ so that $a_{h(n)}$ converges. The sequence $b_{h(n)}$ has a convergent subsequence, which can be defined by the function $g(n)$, and $a_{g(n)}$ converges since it is a subsequence of a convergent sequence. –  yasmar Feb 21 '12 at 7:58