If $(M,d)$ is a compact metric space and $f:M\rightarrow M$ is an isometry ($d(x,y)=d(f(x),f(y))$ for any $x,y\in M$), then $f$ is a homeomorphism 
If $(M,d)$  is a compact metric space and $f:M→M$  is an isometry ($d(x,y)=d(f(x),f(y))$ for any $x,y∈M$), then $f$ is a homeomorphism.

I proved that $f$ is continuous as its inverse, I proved that it is injective also. I couldn't prove that it is also surjective...
thanks for any advance.
 A: Let $x \in X$ and $x_n=f^n(x)$. Because $X$ is compact, $(x_n)$ has a subsequence converging to some $y$; in particular this subsequence is a Cauchy sequence. For all $\varepsilon>0$, there exist two integers $n<m$ such that $d(x_n,x_m)\leq \varepsilon$ hence $d(x,f(X)) \leq d(x_0,x_{m-n})=d(x_n,x_m) \leq \varepsilon$. Hence $d(x,f(X))=0$ i.e. $x \in f(X)$.
A: Another proof: Let $f: X \to X$ be a continuous function on (non-empty) compact and sequentialy compact topological space. Then we can define $X_0 = X$, $X_{n + 1} = f[X_n]$, $X' = \bigcap_{n < ω} X_n$. $X'$ is non-empty compact space, since it's an intersection of decreasing sequence of compacts. By sequential compactness $f: X' \to X'$ is onto. (For $x ∈ X'$ we can choose $x_n ∈ X_n$ such that $f(x_n) = x$, there is convergent subsequence $x_{n_k} \to y ∈ X'$ so $f(x_{n_k}) = x \to f(y)$ so $x = f(y)$.) Also for any $x ∈ X$ we can define $x_0 = x$, $x_{n + 1} = x_n$. Then $x_n \to X'$ in the sense that for any open $U ⊇ X'$, $x_n$ is eventually in $U$. (This is by the fact, that $x_n$ is eventually in any $X_n$ and by compactness.)
In our case ($X = M$) we have that $f: X' \to X'$ is homeomorphism and for any $x ∈ X$ $d(x_n, X') \to 0$ but also $d(f(x), X') = d(f(x), f[X']) = d(x, X')$ so $d(x_n, X')$ is constant and hence zero, so $x ∈ X'$.
