[proofplan]
We prove [uniform continuity](/page/Uniform%20Continuity) of the composition directly from the $\varepsilon$-$\delta$ definition. Given a tolerance in $Z$, uniform continuity of $g$ gives a tolerance in $Y$. Uniform continuity of $f$ then gives a single tolerance in $X$ that forces the images under $f$ to be close enough for the estimate for $g$ to apply.
[/proofplan]
custom_env
admin
[step:Choose the intermediate tolerance from uniform continuity of $g$]
Define the composition map
\begin{align*}
h:X\to Z,\qquad h(x)=g(f(x)) \text{ for every } x\in X.
\end{align*}
Let $\varepsilon>0$. Since $g:Y\to Z$ is uniformly continuous, there exists $\eta>0$ such that for all $y_1,y_2\in Y$,
\begin{align*}
d_Y(y_1,y_2)<\eta \implies d_Z(g(y_1),g(y_2))<\varepsilon.
\end{align*}
[/step]
custom_env
admin
[step:Use uniform continuity of $f$ with the intermediate tolerance]Since $\eta>0$ and $f:X\to Y$ is uniformly continuous, there exists $\delta>0$ such that for all $x_1,x_2\in X$,
\begin{align*}
d_X(x_1,x_2)<\delta \implies d_Y(f(x_1),f(x_2))<\eta.
\end{align*}[/step]
custom_env
admin
[guided]The number $\eta$ is the amount of closeness in $Y$ required in order for $g$ to produce $\varepsilon$-closeness in $Z$. Because uniform continuity of $f$ works for every positive tolerance in $Y$, and because the previous step gives $\eta>0$, we may apply uniform continuity of $f$ with this specific tolerance $\eta$.
Thus there exists $\delta>0$ such that for every pair $x_1,x_2\in X$,
\begin{align*}
d_X(x_1,x_2)<\delta \implies d_Y(f(x_1),f(x_2))<\eta.
\end{align*}
The important point is that this $\delta$ depends only on $\eta$, and hence ultimately only on $\varepsilon$, not on the particular points $x_1$ and $x_2$. This is exactly the uniform part of uniform continuity.[/guided]
custom_env
admin
[step:Combine the two estimates to prove uniform continuity of the composition]
Let $x_1,x_2\in X$ satisfy $d_X(x_1,x_2)<\delta$. By the choice of $\delta$,
\begin{align*}
d_Y(f(x_1),f(x_2))<\eta.
\end{align*}
Applying the choice of $\eta$ with $y_1=f(x_1)$ and $y_2=f(x_2)$ gives
\begin{align*}
d_Z(g(f(x_1)),g(f(x_2)))<\varepsilon.
\end{align*}
Since $h(x)=g(f(x))$ for every $x\in X$, this says
\begin{align*}
d_Z(h(x_1),h(x_2))<\varepsilon.
\end{align*}
Therefore, for every $\varepsilon>0$ there exists $\delta>0$ such that for all $x_1,x_2\in X$,
\begin{align*}
d_X(x_1,x_2)<\delta \implies d_Z(h(x_1),h(x_2))<\varepsilon.
\end{align*}
Hence $h=g\circ f:X\to Z$ is uniformly continuous.
[/step]