Let $f:K\to K$ with $\|f(x)-f(y)\|\geq ||x-y||$ for all $x,y$. Show that equality holds and that $f$ is surjective. [duplicate]

We'll prove the statement for $K$ compact metric space.

Let $\epsilon >0$. The compact space $K$ can be covered by finitely many open balls $B(y_i, \epsilon/2)$, $i=1, \ldots m_{\epsilon}$. Therefore, there exist at most $m_{\epsilon}$ points in $K$, any two at distance at least $\epsilon$. Let $n_{\epsilon}$ be the largest number $n$ so that there exist $n$ points $x_1$, $\ldots$, $x_n$ in $K$ with $d(x_i, x_j) \ge \epsilon$ for all $i\ne j$. Let $\mathcal{K}_{\epsilon} \subset K^{n_{\epsilon}}$ be the set of all such $n_{\epsilon}$-uples ${\bf x}\colon =(x_1, \ldots, x_{n_{\epsilon}})$. It is clear that $\mathcal{K}_{\epsilon}$ is compact. Define the function $F \colon \mathcal{K}_{\epsilon}\to [0, \infty)$, $$F (x_1, \ldots, x_{n_{\epsilon}})= \sum_{i< j} d(x_i, x_j)$$

Clearly, $F$ is continuous. Let ${\bf x}$ be a point of maximum. Since $d(f(x_i), f(x_j) ) \ge d(x_i, x_j)$, it follows that $(f(x_1), \ldots, f(x_{n_\epsilon}))$ is also in $\mathcal{K}_{\epsilon}$ and moreover, $d(f(x_i), f(x_j) ) = d(x_i, x_j)$ for all $i$, $j$. We are almost done.

Consider now $y$, $z$ in $K$. There exist $i$, $j$ so that $d(f(x_i), f(y))< \epsilon$ and $d(f(x_j), f(z))< \epsilon$. Therefore, $d(f(y), f(z)) < d(f(x_i), f(x_j)) + 2 \epsilon$. Now, we also have $d(x_i, y) \le d(f(x_i), f(y))$ and $d(x_j, z)\le d(f(x_j), f(z))$. Therefore, $d(x_i, y)$, $d(x_j, z) < \epsilon$. Therefore, $d(x_i, x_j) < d(y,z) + 2 \epsilon$.

Summing up

\begin{eqnarray} d(f(y), f(z)) &< &d(f(x_i), f(x_j)) + 2 \epsilon\\ d(x_i, x_j) &< &d(y,z) + 2 \epsilon\\ d(f(x_i), f(x_j)) &= &d(x_i, x_j) \end{eqnarray}

Therefore, $d(f(y), f(z)) < d(y,z) + 4 \epsilon$.

Since $\epsilon$ was arbitrary, we get $d(f(x), f(y))\le d(x,y)$.

Obs: The proof of @Harald Hanche-Olsen: here gave me the idea to consider $\epsilon$ -nets; thanks to @David Mitra: for the hint.

$\bf{Added:}$

It is not hard to find examples of isometries of totally bounded but non-compact metric spaces $K$ that are not surjective. Take for instance $K = (e^{i n \theta})_{n \in \mathbb{N}}$, where $\frac{\theta}{\pi} \in \mathbb{R} \backslash \mathbb{Q}$, like $((.6+ .8 i)^n)_{n \in \mathbb{N}}$. However, I could not find examples of totally bounded metric spaces with expansive maps $f$ that are not isometries. It turns out that there are none. So we'll show that $f$ is an isometry if we only assume $K$ totally bounded .

Again we consider $\epsilon$-nets. The gauge function for an $\epsilon$-net is now $$G(x_1, \ldots,x_n) \colon = \prod_{i< j} d(x_i, x_j)$$ bounded above by $\text{diam}(K)^{n_{\epsilon}}$. Let $p$ the supremum of $G$ for all possible elements in $\mathcal{K}_{\epsilon}$. The function $G$ may not achieve its supremum $g$ since $K$ is apriori not assumed compact. However, let ${\bf x}= (x_1, \ldots, x_{n_{\epsilon}})$ in $\mathcal{K}_{\epsilon}$ so that $G({\bf x}) \ge \frac{1}{1+\epsilon} g$. It is easy to see that this implies $$d(x_i, x_j) \le d(f(x_i),f(x_j)) \le (1+\epsilon) d(x_i, x_j)$$

for all $i$,$j$. Again, let $y$, $z$ in $K$ and $i$, $j$ so that $d(f(x_i), y) < \epsilon$ and $d(f(x_j), z) < \epsilon$. Like before, we show that $$d(f(y), f(z)) \le (1+\epsilon) ( d(y,z) + 2 \epsilon) + 2 \epsilon$$

done.