TITLE: How to prove "Homotopy is an Equivalence Relation"
QUESTION [13 upvotes]: Reading Allen Hatchers book (available online via this link) on Algebraic Topology, it states on page 3 that homotopy type defines an equivalence relation. The symmetry and reflexiveness are immediately seen, but the transitivity requires a little work. So my question is basically if this is the way to do it:
My attempt
Assume $X\simeq Y$ and $Y\simeq Z$. We must show that $X\simeq Z$. We have functions
$$
\begin{align}
X\overset{f_1}{\longrightarrow}&Y\overset{f_2}{\longrightarrow}Z\\
X\overset{g_1}{\longleftarrow}&Y\overset{g_2}{\longleftarrow}Z
\end{align}
$$
where $f_1g_1,g_1f_1,f_2g_2$ and $g_2f_2$ are homotopic to identities in the relevant spaces.
I claim that $f=f_2f_1$ and $g=g_1g_2$ are homotopy equivalence maps for $X\simeq Z$. To see this consider:
$$
H(z,t)=
\begin{cases}
f_2\circ H_1(y,2t)\circ g_2,&\mbox{ for }t\in[0,0.5]\\
\quad\\
\quad\\
H_2(z,2t-1),&\mbox{ for }t\in[0.5,1]
\end{cases}
$$
where $H_1$ is a homotopy of $f_1g_1$ and $\mathbb{1}_Y$ whereas $H_2$ is a homotopy of $f_2g_2$ and $\mathbb{1}_Z$. Then $H(z,0)=fg$ and $H(z,1)=z$ so that $H$ is a homotopy of $fg$ and $\mathbb{1}_Z$. Of course one should check that $H$ depends continuously on $t$ especially for $t=0.5$ where $H(z,0.5)=f_2g_2$ by both definitions which will make that condition hold.
By very similar arguments it can be established that $gf\simeq\mathbb{1}_X$ and we are done.
Does this make sense and is it the way it is supposed to be carried out?

REPLY [6 votes]: Once you have shown that if $f\simeq f'$ and $g\simeq g'$, also $gf\simeq g'f'$, you can write
$$f_2f_1g_1g_2=f_2(f_1g_1)g_2\simeq f_2 1_Y g_2\simeq 1_Z$$
More generally, the property stated above can be expressed as "composition of homotopy classes is well defined by the formula $[g][f]=[gf]$". This means that the topological spaces with the classes of maps form a category $h\mathbf{Top}$, and two spaces are isomorphic in this category if they are homotopy equivalent. But "isomorphic to" is an equivalence relation.