Solution (source code)

= Solution

If $fg\simeq1_Y$ and $hf\simeq1_X$, composing homotopies gives
$$
h\simeq h(fg)\simeq(hf)g\simeq g.
$$
Thus $gf\simeq hf\simeq1_X$, while $fg\simeq1_Y$ already holds, so $g$ is a <homotopy inverse> of $f$.

More generally let $a:Y\to Y$ be a <homotopy inverse> of $fg$ and $b:X\to X$ one of $hf$. Then $g'=ga$ satisfies $fg'\simeq1_Y$, and $h'=bh$ satisfies $h'f\simeq1_X$. The first argument applies. Hence \b[the separate one-sided hypotheses imply that $f$ is a <homotopy equivalence>], as expressed by <separate homotopy inverses combine into a homotopy equivalence>.