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

Prove: If $f,g:S^{n-1} \to X$ are homotopic maps, then $X\sqcup_fD^n$ and $X\sqcup_gD^n$ are homotopy equivalent.

I think it can be proved by showing they are both deformation retracts of $X\sqcup_H(D^n\times I)$ where $H$ is the homotopy between $f$ and $g$.

However, I have difficult in proving that the deformation retracts are continuous map. In fact, I have difficulty in representing a map in quotient spaces like $X\sqcup_fD^n$. I think a map from $X\sqcup_fD^n$ to $W$ can be represented by two maps: $m_1: X\to W$, $m_2: D^n\to W$, where for $x\in S^{n-1}$, $m_1\circ f(x)=m_2\circ i(x)$.

Then I construct the deformation retract this way: $m_1: X\to X$. For $x\in H(S^{n-1},t)$, $m_1(x)=H(S^{n-1},0)$, otherwise $m_1(x)=x$.

$m_2: D^n\times I\to D^n\times {0}$: $m_2((D^n,t))=(D^n,0)$.

It is easy to verify that $m_1$ and $m_2$ define a map from $X\sqcup_H(D^n\times I)$ to $X\sqcup_fD^n$. As long as this is a continous map, obvioulsy then we find a deformation retract. But it seems such a map is not continous?


$\require{AMScd}$ 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_H 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)

\begin{CD} A @>f>> B\\@ViVV @VV\tilde iV\\ X @>>\tilde f> X\cup_f B \end{CD} gives rise to a pushout square \begin{CD} A\times I @>f>> B \times I\\@ViVV @VV\tilde iV\\ X\times I @>>\tilde f> (X\cup_f B)\times I \end{CD}

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