Here is Prob. 6, Sec. 28, in the book Topology by James R. Munkres, 2nd edition:
Let $(X, d)$ be a metric space. If $f \colon X \to X$ satisfies the condition $$ d \big( f(x), f(y) \big) = d(x, y) $$ for all $x, y \in X$, then $f$ is called an isometry of $X$. Show that if $f$ is an isometry and $X$ is compact, then $f$ is bijective and hence a homeomorphism. [Hint: If $a \not\in f(X)$, choose $\varepsilon$ so that the $\varepsilon$-neighborhood of $a$ is disjoint from $f(X)$. Set $x_1 = a$, and $x_{n+1} = f\left( x_n \right)$ in general. Show that $d \left( x_n, x_m \right) \geq \varepsilon$ for $n \neq m$.]
My Attempt:
Let $(X, d)$ be a compact metric space and let $f \colon (X, d) \to (X, d)$ be a mapping such that $$ d \big( f(x), f(y) \big) = d(x, y) \tag{0} $$ for all $x, y \in X$.
Note that $f$ is continuous (in fact uniformly continuous) on $X$, for given any real number $\varepsilon > 0$, if we choose any real number $\delta$ such that $0 < \delta \leq \varepsilon$, then from (0) above we find that $$ d(x, y) = d \big( f(x), f(y) \big) < \varepsilon $$ whenever $x, y \in X$ satisfy $$ d(x, y) < \delta. $$
We first show that $f$ is injective. Let $x$ and $y$ be any points of $X$ such that $f(x) = f(y)$. Then using the given condition (0) above we obtain $$ d(x, y) = d \big( f(x), f(y) \big) = 0, $$ and hence $x = y$. Therefore $f$ is injective.
We now show that $f$ is also surjective. Let us suppose, if possible that, $$f(X) \subsetneqq X. \tag{1} $$
As $f \colon X \to X$ is continuous and as $X$ is compact (relative to the topology determined by the metric $d$ on $X$), so the image $f(X)$ is also compact, by Theorem 26.5 in Munkres.
Now as $f(X)$ is a compact subspace of $X$ and as $X$ (relative to the metric topology determined by metric $d$ on $X$) is Hausdorff, so we can conclude that $f(X)$ is closed in $X$, by Theorem 26.3 in Munkres.
As $f(X)$ is closed in $X$, so $X \setminus f(X)$ is open in $X$.
As $f(X) \subsetneqq X$ by (1) above, so we have $$ X \setminus f(X) \neq \emptyset. $$ Thus $X \setminus f(X)$ is a nonempty open set in the metric space $(X, d)$.
Let $a$ be any point in $X \setminus f(X)$. Then as $X \setminus f(X)$ is open in $X$ and as $a \in X \setminus f(X)$, so there exists a real number $\varepsilon > 0$ such that $$ B_d ( a, \varepsilon ) \subset \big( X \setminus f(X) \big), \tag{2} $$ where $$ B_d (a, \varepsilon ) \colon= \big\{ \, x \in X \colon d(x, a) < \varepsilon \, \big\}. \tag{Definition 0} $$ [Please refer to Sec. 20 in Munkres.] That is, if $x \in X$ and $d(x, a) < \varepsilon$, then that $x$ would be in $X \setminus f(X)$ also; in other words, for any point $x \in f(X)$, we must have $$ d(x, a) \geq \varepsilon. \tag{2*} $$
Let us put $$ x_1 \colon= a. \tag{Definition 1} $$ and $$x_2 \colon= f\left( x_1 \right). \tag{Definition 2} $$ Then as $x_2 \in f(X)$, so in view of (2*) above, we must have $$ d \left( x_1, x_2 \right) \geq \varepsilon \tag{3} $$
Now suppose $n \in \mathbb{N}$ is given such that $x_n$ has been chosen. Let us put $$ x_{n+1} \colon= f \left( x_n \right). \tag{Definition 3} $$
In this way we obtain a sequence $\left( x_n \right)_{n \in \mathbb{N} }$ in the metric space $(X, d)$.
For every $n \in \mathbb{N}$ such that $n > 1$, as $x_n \in f(X)$, so from (2*) we must have $$ d \left( x_n, x_1 \right) = d \left( x_n, a \right) \geq \varepsilon. \tag{3*} $$
Let $m$ and $n$ be any two distinct natural numbers. First suppose that $m > n > 1$. Then from (2) above we obtain $$ d \left( x_m, x_n \right) = d \big( f\left(x_{m-1}\right), f\left( x_{n-1} \right) \big) = \ldots = d \left( x_{m-n+1}, x_1 \right) = d \big( f\left( x_{m-n} \right), a \big) \geq \varepsilon; $$ that is, $$ d \left( x_m, x_n \right) \geq \varepsilon. \tag{4} $$ Here we have used the fact that $$ f \left( x_{m-n} \right) \in f(X). $$ Interchanging the roles of $m$ and $n$ in the above reasoning, we find that (4) also holds if $m < n$.
Thus from (3), (3*), and (4) above, we can conclude that, for any natural numbers $m$ and $n$ such that $m \neq n$, we have the inequality $$ d \left( x_m, x_n \right) \geq \varepsilon. \tag{4*} $$
If $\left( x_{n_k} \right)_{k \in \mathbb{N} }$ be any subsequence of $\left( x_n \right)_{n \in \mathbb{N}}$, where $\left( n_k \right)_{k \in \mathbb{N} }$ is a strictly increasing sequence of natural numbers, then in view of (4*) above, we see that $\left( x_{n_k} \right)_{k \in \mathbb{N} }$ cannot be Cauchy and hence cannot be convergent in $(X, d)$. Therefore $\left( x_n \right)_{n \in \mathbb{N} }$ cannot have any convergent subsequence.
But as $(X, d)$ is compact, so it is also sequentially compact, by virtue of Theorem 28.2 in Munkres. This implies that the sequence $\left( x_n \right)_{n \in \mathbb{N} }$ in $(X, d)$ must have a convergent subsequence.
Thus we have a contradiction. Therefore our supposition that (1) above holds is wrong. So $f(X) = X$, and $f$ is surjective.
Hence $f \colon (X, d) \to (X, d)$ is a continuous bijective mapping.
Moreover, $(X, d)$ is a compact Hausdorff space. Note that $(X, d)$ is compact by our hypothesis and every metric space is Hausdorff w.r.t the metric topology.
Therefore, $f \colon X \to X$ being a bijective continuous mapping of the compact topological space $(X, d)$ onto the Hausdorrf space $(X, d)$, is a homeomorphism, by virtue of Theorem 26.6 in Munkres.
Is this proof correct in each and every detail? If so, is it clear and detailed enough in each and every step therein? If not, then where are the problems?
Last but not least, is my notation correct and rigorous enough, especially my usage of the term "compact" for the metric space $(X, d)$?