Compact metric space and homomorphism Let $X$ be a compact metric space and $f$ be a map $f: X \rightarrow X$ having the
property $d(f(x), f(y))=d(x, y)$ for all $x, y \in X(\text { isometry }) .$ Prove that $f$
is a homeomorphism.
Proof-trying. We need to show $f$ is a bijection, $f$ and $f^{-1}$ are continuos.
Since the function $f$ satisfies $d(f(x), f(y))=d(x, y)$ for all $x, y \in X$ we can say that the function is uniformly continuous.
$f$ is onto: Consider a point $p\in X$, and define the sequence $(x_n)_n$ inductively by setting $x_0=p$ and $x_{n+1}=f(x_n)$. Since $X$ is compact there exists a convergent sub-sequence $(x_{n_k})_k$. In particular we have
$$\lim_{k\to\infty}d(x_{n_{k+1}},x_{n_k})=0$$
That is
$$\lim_{k\to\infty}d(f^{n_{k+1}}(p),f^{n_{k}}(p))=0$$
Or, using the assumption
$$\lim_{k\to\infty}d(f^{n_{k+1}-n_k}(p),p)=0$$
Since $n_{k+1}-n_k\ge1$ the above result is equivalent to
$$\lim_{k\to\infty}d(f(y_k),p)=0\tag{1}$$
where $y_k=f^{n_{k+1}-n_k-1}(p)=x_{n_{k+1}-n_k-1}$. Now we can extract from $(y_k)_k$ a convergent sub-sequence $(y_{k_m})_m$ that converges to some $q\in X$, and $(1)$ then implies, (due to the continuity of $x\mapsto d(f(x),p)$), that
$$\lim_{m\to\infty}d(f(y_{k_m}),p)=d(f(q),p)=0$$
So $p=f(q)\in f(X)$. This proves that $f$ is onto.
My question is How can I show $f^{-1}$ is also continuous, and $f$ is one-to-one, may you help? Thanks...**
 A: 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.
$f$ is 1-1: If $f(x)=f(y)$ then 
$$0 = d(f(x),f(y))=d(x,y) \text{ so } x= y$$
And $f$ is indeed uniformly continuous. And as $f$ is bijective and an isometry, $f^{-1}$ is also an isometry and so also uniformly continuous. Or use that a continuous map on a compact space to a Hausdorff space is closed and a continuous closed bijection is a homeomorphism.
A: Since $f$ is an isometry, $f^{-1}$ is an isometry. Therefore, it is continuous.
And if $f(x)=f(y)$, then $d\bigl(f(x),f(y)\bigr)=0$. Therefore, $d(x,y)=0$, and so $x=y$.
A: To show that $f$ is onto, you can shorten your argument by using the fact that since  $X$ is compact so is $f(X)$ and since $p=lim f(y_k))$, $p\in f(X)$.
