# Homeomorphism group of compact metric space $K$ is $G_{\delta}$ in $C(K,K)$

Let $(K,d)$ be a compact metric space and denote $\ C(K,K):=\{ f:K \to K \ ; \space f \space \text{is continuous} \}$. Endow the set $C(K,K)$ with the supremum metric $\ \rho (f,g):=\mathrm{sup} \ \{ d(f(x),g(x)) \ ; \ x \in K \}$.

I'd like to show that the group of homeomorphisms of $(K,d)$ is a $G_{\delta}$ subset of the metric space $( C(K,K),\rho)$.

I managed to show that it is enough to prove that the set $\{ f \in C(K,K) \ ; \space f \space \text{is injective} \}$ is $G_{\delta}$, but then I got stuck.

I'll appreciate any help.

Let $H$ be the set of homeomorphisms in $C(K,K)$. For $f\in H$, let $\{U_n(f)\}$ be a countable nested collection of open [in $C(K,K)$] metric balls around $f$. We will shrink the radii later. For now, let's say $r_n(f)$ is the radius of $U_n(f)$.
If we set $$U_n =\bigcap_{f\in H} U_n(f)$$ then we want to show $H=\cap U_n$. One direction is easy, so we show the other.
Let $g\in \cap U_n$. Then we have a sequence $\{f_n\}$ with $g\in U_n(f_n)$. Let's insist that $r_n(f)<\frac{1}{n}$, so that $\{f_n\}$ is a Cauchy sequence with $f_n\rightarrow g$.
Since inversion is continuous on $H$, we can further shrink $r_n(f)$ [dependent on $f$] such that $$\rho(f,\alpha)<2r_n(f)\implies \rho(f^{-1},\alpha^{-1}<\frac{1}{n}$$
This ensures $\{f_n^{-1}\}$ is also Cauchy, and thus $f_n^{-1}\rightarrow h\in C(K,K)$. But composition is continuous, so \begin{align*} f_n\circ f_n^{-1} &\rightarrow g\circ h\\ f_n^{-1}\circ f_n &\rightarrow h\circ g \end{align*} Since the left-hand sides are constantly the identity map, we see $h=g^{-1}$, and so $g\in H$, and we're done.