Homeomorphic images of $X$ and $\operatorname{int} D^n$ in $X \sqcup_f D^n$ From Lackenby's notes on Topology and Groups,

Let $X$ be a space, and let $f: S^{n-1}\to X$ be a map. Then the space obtained by attaching an $n$-cell to $X$ along $f$ is defined to be the quotient of the disjoint union $X \sqcup D^n$ such that, for each point $x \in X$, $f^{−1}(x)$ and $x$ are all identified to a point. It is denoted by
$X \sqcup_f D^n$.


The author makes the following claim (paraphrased), which I want to prove:

Claim: There are homeomorphic images of $X$ and $\operatorname{int} D^n$ in $X \sqcup_f D^n$. There is also an induced map $\phi: D^n\to X \sqcup_f D^n$. $\phi$ need not be injective.

My work: Firstly, I will define $\phi$ by $\phi(t) = [t]$ for all $t\in D^n$. Note that $[t] = [f(t)]$ for all $t\in S^{n-1}$.

*

*For the homeomorphic copy of $X$ in $X \sqcup_f D^n$, do the following. Define $g: X\to X \sqcup_f D^n$ by $g(t) = [t]$ for all $t\in X$, and consider the restriction $g_0: X\to g(X)$. I claim that $g_0$ is a homeomorphism. Certainly $g_0$ is surjective. $g_0$ is also injective since for all $t_1\ne t_2$, $t_1,t_2\in X$, $[t_1]\ne [t_2]$ (by definition of $\sim$). I am struggling to show continuity of $g_0$ and $g_0^{-1}$.


*For the homeomorphic copy of $\operatorname{int}D^n$ in $X \sqcup_f D^n$, define $h: \operatorname{int}D^n\to X \sqcup_f D^n$ as $h(t) = [t]$ for all $t\in \operatorname{int}D^n$. Consider $h_0: \operatorname{int}D^n\to h(\operatorname{int}D^n)$. By definition of $\sim$, for all $t_1\ne t_2$, $t_1,t_2\in \operatorname{int}D^n$, $[t_1]\ne [t_2]$. So, $h_0$ is bijective. I need to show continuity of $h_0$ and $h_0^{-1}$.
Thank you for your help!
 A: The maps $g$ and $\phi$ are certainly continuous because they have the form $g = p \circ i_X$ and $\phi = p \circ i_{D^n}$, where $p : X \sqcup D^n \to  X \sqcup_f D^n$ is the quotient map and $i_X : X \to  X \sqcup D^n$ and $i_{D^n} : D^n \to  X \sqcup D^n$ are the canonical embeddings.
For $y \in D^n$ and $\xi \in X$ we have $\phi(y) = g(\xi)$ if and only if $y \in S^{n-1}$ and $f(y) = \xi$: In fact, $\phi(y) = g(\xi)$ means that $y$ and $\xi$ lie in the same equivalence class in $X \sqcup_f D^n$. Since $y$ and $\xi$ lie in distinct summands of $X \sqcup D^n$, this means that $y \in f^{-1}(\xi) \subset S^{n-1}$ and $f(y) = \xi$.

*

*Let us show that $g$ is a closed map; this will prove that $g_0 : X \to g(X)$ is also a closed map and thus a homeomorphism:
Let $C \subset X$ be closed. We have to show that $g(C)$ is closed in $X \sqcup_f D^n$. Since $p$ is a quotient map, it suffices to show that $p^{-1}(g(C))$ is closed in $X \sqcup D^n$. But $p^{-1}(g(C)) = C \sqcup f^{-1}(C)$ which is closed in $X \sqcup D^n$.


*Let us show that $h = \phi \mid_{\operatorname{int}D^n}$ is an open map; this will prove that $h_0 : \operatorname{int}D^n \to h(\operatorname{int}D^n)$ is also an open map and thus a homeomorphism:
Let $U \subset \operatorname{int}D^n$ be open. We have to show that $h(U) = \phi(U)$ is open in $X \sqcup_f D^n$. Since $p$ is a quotient map, it suffices to show that $p^{-1}(\phi(U))$ is open in $X \sqcup D^n$. But $p^{-1}(\phi(U))) = i_{D^n}(U)$ which is open in $X \sqcup D^n$.
Update: Why is $p^{-1}(g(C)) = C \sqcup f^{-1}(C)$?
Let $w \in X \sqcup D^n$, i.e. either $w = i_X(\xi)$ with a unique $\xi \in X$ or $w = i_{D^n}(y)$ with a unique $y \in D^n$. We have $w \in p^{-1}(g(C))$ iff $p(w) \in g(C)$.

*

*Let $w \in C \sqcup f^{-1}(C)$. Case 1. $w = i_X(\xi)$ with $\xi \in C$. Then $p(w) = p(i_X(\xi)) = g(\xi)$, thus $p(w) \in g(C)$. Case 2. $w = i_{D^n}(y)$ with $y \in f^{-1}(C) \subset S^{n-1} \subset D^n$ (which implies in particular $f(y) \in C$). Then $p(w) = \phi(y) = g(f(y))\in g(C)$.


*Let $p(w) \in g(C)$. Case 1. $w = i_X(\xi)$ with $\xi \in X$. Then $p(w) = p(i_X(\xi)) = g(\xi)$, thus $g(\xi) \in g(C)$. Since $g$ is injective, we conclude that $\xi \in C$. Hence $w \in i_X(C) \subset C \sqcup f^{-1}(C)$. Case 2. $w = i_{D^n}(y)$ with $y \in  D^n$. Then $p(w) = \phi(y) \in g(C)$, i.e. $\phi(y) = g(\xi)$ for some $\xi \in C$. But this means $y \in S^{n-1}$ and $f(y) = \xi$, i.e. $y \in f^{-1}(C)$. Hence $w = i_{D^n}(y) \in i_{D^n}(f^{-1}(C)) \subset C \sqcup f^{-1}(C)$.
