Two spaces homotopy equivalent to eachother, attaching maps, Algebraic Topology. I have a question regarding algebraic topology with which I was hoping someone could help me with. I've managed to show the following:
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 showed this by showing they were both deformation retracts of the same space, $Y=X\sqcup_F(D^n\times I)$ where $F$ is my homotopy between maps $f$ and $g$.
I feel like this result could help me with the following question:
Let $f:S^{n-1} \to X$ be a map and $g:X \to Y$ be a homotopy equivalence. Show that $X\sqcup_fD^n\simeq Y\sqcup_{f\circ g}D^n$.
Could I do this similarly as with my original problem. Since if $g$ is a homotopy equivalence between $X$ and $Y$, this tells me that $X\simeq Y$, so they are deformation retracts of a larger space, say Z. 
Would I then show $X\sqcup_f D^n$ and $Y\sqcup_{f\circ g}D^n$ are deformation retracts of some larger space $W=Z\sqcup_f (D^n\times I)$? 
If I retract $Z$ to $X$ and $(D^n\times I)$ to $(D^n\times ${$0$}$) \cup (S^{n-1}\times I)$, is it valid for me to apply my map $g$ and yield that $Y\sqcup_{f\circ g}D^n$ is a deformation retract of my larger space $W$?
Thanks in advance.
 A: Okay, here is my proof which took me a while to elaborate, but I think it's correct:
Note that $(D^n,S^{n-1})$ has the homotopy extension property (HEP). The salient point of my proof is a retraction of $B\times I\times I$ onto $(A\times I\times I)\ \cup\ (B\times\{0\}\times I)\ \cup\ (B\times I\times\{0\}),$ whenever $(B,A)$ has the HEP.
For $(s,t)\in I\times I$ let $s^*(s,t)=||(s,t)-d(s,t)||/||(1,1)-d(s,t)||$. Let $r$ be the retraction of $B\times I$ onto $A\times I\ \cup\ X\times\{0\}$ with coordinates $(r_x,r_s)$, and let $d:I\times I\ \longrightarrow\ I\times\{0\}\ \cup\ \{0\}\times I$ be a retraction. Now define $R:B\times I\times I\ \longrightarrow\ (A\times I\times I)\ \cup\ (B\times\{0\}\times I)\ \cup\ (B\times I\times\{0\})$, 
$(x,s,t)\mapsto(r_x(x,s^*),\ \ d(s,t)+r_s(x,s^*)\cdot[(1,1)-d(s,t)])$. It is not difficult to prove that $R$ is a well-defined retraction.
Two spaces are homotopy equivalent iff they are strong deformation retracts of a larger space, and this larger space can be chosen to be the mapping cylinder $M(g)=Y\cup X\times I$, where $(x,1)\sim g(x)$. Then you can glue $B\times I$ in a canonical way, by the map $f\times\text{Id}_I$. There are maps $X\times0\xleftarrow{\ \ r\ \ }M(f)\xrightarrow{g\circ p_X}Y$ where $r$ is a deformation retraction, meaning there is a $k:M(f)\times I\to M(f),\  k(-,1)=r,\  k(-,0)=\text{Id}_{M(f)}$, a homotopy from $r$ to the identity. The map $g\circ p_X$ is a retraction homotopic to the identity via the map $h$ such that $h(x,s,t)=(x,t+s-ts)$.
Let us define a map $K:(M(f)\cup_{f\times Id} B\times I)\times I\ \longrightarrow\ M(f)\cup_{f\times Id}B\times I$ whose restriction onto $B\times I\times I$ is defined in the following way: We have shown that $B\times I\times I$ retracts onto $A\times I\times I\ \cup\ B\times(\{0\}\times I\cup I\times\{0\})$ A map on the first term is given by $k\circ(f\times\text{Id}_I\times\text{Id}_I)$, and one on the second term by $(b,s,t)\mapsto(b,s)$. They coincide on the common domain, and so they induce a map $K':B\times I\times I\to M(f)\cup_{f\times Id}B\times I$. We then combine $K'$ with $k$ on the cylinder to obtain $K$. One can then check that this is a deformation retraction onto $X\times\{0\}\cup_{f\times 0}B\times\{0\}$.
What is left is to find a deformation retraction onto $Y\cup_{gf}B$. But this one can even be explicitly written down, and the formula is practically the same as for $h$.
A: For X and Y CW complexes, the statement that you are trying to prove is Theorem 1 of the following reference: "Topics in Combinatorial Differential Topology and Geometry" by Robin Forman: http://books.google.com/books?id=W_SPdwfPTw8C&pg=PA135&dq=Topics+in+Combinatorial+Differential+Topology+and+Geometry%22+by+Robin+Forman&hl=en&sa=X&ei=1BryU4LoCpPgsAT7hYGoAQ&ved=0CB4Q6AEwAA#v=onepage&q=Topics%20in%20Combinatorial%20Differential%20Topology%20and%20Geometry%22%20by%20Robin%20Forman&f=false.
