$(X, d)$ be an infinite compact metric space. Then there exists no function $f : X → X,$ satisfying $d(f(x), f(y)) > d(x, y)$ for all $x \neq y.$ [duplicate]
It is enough to prove that $f$ is bijective.
$f$ is injective for if not, there are $x\neq y$ s.t. $f(x)=f(y)\Rightarrow d(f(x),f(y))=0.$
If $f$ is continuous I think we can argue as follows: $f(X)$ is compact, and closed.
Now, assume $X\neq f(X)$. Then then is a point $x\in X\setminus f(X)$ s.t. $d(x,f(X))=a>0$. This follows because $f(X)$ is closed and $x\notin f(X)$.
Consider the sequence defined by $x_1=x$ and $x_n=f(x_{n-1})\in f(X)$ and extract a convergent subsequence $x_{n_k}\to y$. Of course, $y\in f(X)$ because $f(X)$ is closed.
But then, for all integers $k$, we have, for some integer $m$,
$d(f(x_{n_k}),f(x_{n_{k-1}}))\geq d(x_{n_k},x_{n_{k-1}})= d(f(x_{n_k-1}),f(x_{n_{k-1}-1}))\geq \cdots= \cdots \geq d(f(x_m),x)>a$, which implies that $f(x_{n_{k}})\not\to f(y)$, which contradicts the continuity of $f$.
Here is another approach that uses only very basic ideas:
Pick $x,y\in X$ and take $x_0=x, y_0=y$ and then $x_n=f(x_{n-1}), y_n=f(y_{n-1})$.
Then, for all integers $n$, we have
$\tag1 d(x,y)\leq \cdots \leq d(x_n,y_n)\leq d(x_{n+1},y_{n+1})\leq \cdots $
Now, there are convergent subsequences $x_{n_{k}}, y_{n_{k}}$ and these are of course, Cauchy.
Let $\epsilon >0$. Then, if $k$ is large enough,
$\tag2 d(x_{n_{k+1}-n_{k}},x)\leq d(x_{n_{k+1}},x_{n_{k}})<\epsilon$
and $\tag3 d(y_{n_{k+1}-n_{k}},y)\leq d(y_{n_{k+1}},y_{n_{k}})<\epsilon$
where we have used $(1)$ successively.
But now, using $(1), (2), (3)$ and the triangle inequality, we have
$\tag4 d(f(x),f(y))=d(x_1,y_1)\leq \cdots \leq d(x_{n_{k+1}-n_{k}},y_{n_{k+1}-n_{k}})\leq d(x_{n_{k+1}-n_{k}},x)+d(x,y)+d(y_{n_{k+1}-n_{k}},y)<d(x,y)+2\epsilon$
so $d(f(x),f(y))\leq d(x,y)$ and we are done.
The answer can be found in Theorem 1.6.15 of "A Course in Metric Geometry", by Burago, Burago and Ivanov.