TITLE: Let $(X,d)$ be a compact metric space. Let $f: X \to X$ be such that $d(f(x),f(y)) = d(x,y)$ for all $x,y \in X$. Show that $f $ is onto (surjective).
QUESTION [8 upvotes]: Let $(X,d)$ be a compact metric space. Let $f: X \to X$ be such that $d(f(x),f(y)) = d(x,y)$ for all $x,y \in X$. Show that $f $ is onto (surjective).
If $f$ is not onto then there exist a $p \in X$ such that there does not exist any $y \in X$ such that $f(y) =p$. Then there exist $x \in X$ such that $d(p,f(x)) = d(p,x)$.
I am finding difficulty to do the proof please help!!
Is the result true if $X$ is not compact??

REPLY [4 votes]: Suppose $f$ is not onto. Pick $x \in X \setminus f[X]$. Then let $\epsilon > 0$ be such that $\epsilon < d(x, f[X])$. $X$ can be covered by finitely many open sets of diameter $< \epsilon$, by compactness. Let $N$ be the smallest size of such a covering, and $\mathcal{U} = \{O_1,\ldots,O_N\}$ a witnessing cover. If $x \in O_i$, then $f[X]$ does not intersect $O_i$, so $f[X]$ is already covered by $\mathcal{U} \setminus \{O_i\}$, which has $N-1$ elements. Then $\{f^{-1}[O_j]: j \neq i \}$ covers $X$, consists of open sets, and the isometry property guarantees that all diameters are $< \epsilon$. This contradicts the minimality of $N$, contradiction.