Let $X$ be a compact metric space with metric $d$ and let $f \in C (X, X)$ and such that $d (f(a ),f(b))\ge d (a, b)$ for all $a$ and $b$ in $X.$ Show that $d(f(a), f(b)) = d(a, b)$ for all $a$ and $b$ in $X.$
My attempt:
$X$ is compact implies that $f(X)$ is also compact, since $f$ is continuous. Also, $f$ is uniformly continuous.
On the contrary, let us assume that there exists a pair of points $(x,y) \in X^2$ such that $d (f(x ),f(y)) > d (x, y).$ Since, $X$ is compact, diameter of $X$ is finite, say $M.$ And there exits points $x_0,y_0 \in X$ such that $d(x_0,y_0)=M.$
Suppose that $(x_0,y_0)=(x,y),$ we are done with the contradiction that $d (f(x_0 ),f(y_0)) > d (x_0, y_0)>M,$ since diameter of $f(X) \subseteq X$ is atmost M.
Now we are left with the case where $d(x,y) < M.$
I am stuck here. Please help. Thanks in advance.
I am skipping some of the details that are easy to fill. Also, I use sup instead of max but it does not matter for this proof. The set $f(X)$ is a compact subset of X. Hence, $\sup_{(x,y)\in X^2} d(f(x),f(y))\leq \sup_{(x,y)\in X^2} d(x,y)$. Observe that $X^2$ is also compact and the left hand side is supremum taken over a subset of $X^2$, so the sup cannot dominate.
However, from the property of the metric in the question it also follows that $\sup_{(x,y)\in X^2} d(f(x),f(y))\geq \sup_{(x,y)\in X^2} d(x,y)$.
So, $\sup_{(x,y)\in X^2} d(f(x),f(y))= \sup_{(x,y)\in X^2} d(x,y)$ must hold.
In fact, for any closed subset $A$ of $X^2$ we must have, $\sup_{(x,y)\in A} d(f(x),f(y))= \sup_{(x,y)\in A} d(x,y)$ must hold.
If there is some $a,b \in X$ such that $d(f(a),f(b))> d(a,b)$ we simply define the closed set $A=\{(x,y):d(x,y)\leq d(a,b)\}$ and note that $\sup_{(x,y)\in A} d(x,y)=d(a,b)<d(f(a),f(b))\leq \sup_{(x,y)\in A} d(f(x),f(y))$. This contradiction completes the argument.