Uniform convergence of functions, Spring 2002

The question I have in mind is (see here, page 60, the solution is at page 297):

Assume $f_{n}$ is a sequence of functions from a metric space $X$ to $Y$. Suppose $f_{n}\rightarrow f$ uniformly and has inverse $g_{n}$. Now assume $f$’s inverse $g$ is uniformly continuous on $Y$. Prove that $g_{n}\rightarrow g$ uniformly.

I could not prove it using standard techniques as I do not know how to bound $|g_{n}(y)-g(y)|$ when $n$ becomes very large. The authors argue that the convergence of $g_{n}(y)\rightarrow g(y)$ is similar to $f(g_{n}(y))\rightarrow f(g(y))$ because the mapping by a uniformly convergent function series keeps uniform convergence. Thus they give the following argument that $$d(f(g(y)),f(g_{n}(y)))=d(y,f(g_{n}(y)))\le d(y,f_{n}(g_{n}(y)))+d(f_{n}(g_{n}(y)),f(g_{n}(y)))=d(f_{n}(g_{n}(y)),f(g_{n}(y)))$$

So since $f_{n}\rightarrow f$ uniformly by hypothesis the statement is proved. My question is: Is the step of substituting $|g_{n}(y)-g(y)|$ by $|f(g(y))-f(g_{n}(y))|$ really justified? I could not get the “keep uniform convergence” thing the author is talking about. But I also could not come up with a better proof.

Solutions Collecting From Web of "Uniform convergence of functions, Spring 2002"

If $h_n\colon S\to S’$ converges uniformly to $h$ on $S$ and $\varphi\colon S’\to S”$ is uniformly continuous on $S$, fix $\varepsilon>0$. There is a $\delta>0$ such that if $d_{S’}(x,y)\leq \delta$ then $d_{S”}(\varphi(x),\varphi(y))\leq\varepsilon)$. Now, we use the fact that there is an integer $n_0$ such that for all $n\geq n_0$, we have
$$\sup_{x\in S}d_S(h_n(x),h(x))\leq \delta.$$
Then
$$\sup_{x\in S}d_S(\varphi(h_n(x)),\varphi(h(x)))\leq\varepsilon.$$
Now, we apply this result with $\varphi=g$ and $h_n:=f\circ g_n$.