Prove homotopic attaching maps give homotopy equivalent spaces by attaching a cell

There is a retraction of $D^n\times I\twoheadrightarrow D^n×\{0\}\cup S^{n-1}×I$ defined via $$r(x,t)=\begin{cases} \left(\frac{2x}{2-t},\ 0\right) &\text{, if }t\le2(1-||x||) \\ \left(\frac x{||x||},2-\frac{2-t}{||x||}\right)&\text{, if }t\ge2(1-||x||) \end{cases}$$ It is easy to prove that this map is well-defined and continuous and a retraction. Then $$d:D^n×I×I\to D^n×I\\ d(x,t,s)=sr(x,t)+(1-s)(x,t)$$ is a homotopy between the identity and $r$, so $r$ is a deformation retraction. But then $(D^n×I)\cup_F X$ deformation retracts onto $(D^n×\{0\}\cup S^{n-1}×I)\cup_H X=(D^n×\{0\})\cup_f X$

Note that a pushout square ($A,X$, and $B$ are arbitrary spaces)
enter image description here$\ $ gives rise to a pushout square$\ $ enter image description here

because the quotient map $q:X\sqcup B\to X\cup_f B$ induces a quotient map $q\times 1:X\times I\sqcup B\times I\to(X\cup_f B)\times I$.
This means that a pair of homotopies $F_t:X→Y$, $G_t:B→Y$, such that $F_ti=G_t f$ for all $t\in I$, induces a homotopy $H_t:X∪_f B→Y$
That's the reason why a deformation retraction on $D^n×I$ induces a deformation retraction on the pushout $(D^n×I)\cup_F X$

There is more general result: If $(X,A)$ is cofibered, then $X×I$ deformation retracts to $X×\{0\}\cup A×I$, so if $X$ is glued via two homotopic maps $f$ and $g$ to a space $B$, then $X\cup_f B$ and $X\cup_g B$ are homotopy equivalent.


This is also proved in Topology and Groupoids (as it was in the 1968 edition, "Elements of Modern Topology"); this has some pictures of the crucial mapping cylinder construction $M(f) \cup X$ which, if $i: A \to X$ is a cofibration, is a useful model of the adjunction space $B \cup _f X$ for $f: A \to B$. Here is a coloured picture of the homotopy as Fig 7.10:

hom