Topological embedding on adjunction space I'm (self) learning topology and I'm stuck on a passage of the proof of the following theorem:
let $X \bigcup_fY $ be the adjunction space formed by attaching Y to X along f. Let $q: X\sqcup Y \rightarrow X \sqcup Y / \sim $ the quotient map for the quotient topology on $ X \sqcup Y / \sim $. Then the restriction of $q$ to $X$ is a topological embedding.
First of all I guess that in the statement X is identified with its canonical injection image in $X \sqcup Y$.
Secondly the book I'm studying reports $q^{-1}(q(B)) \bigcap X = B$ and $q^{-1}(q(B)) \bigcap Y = f^{-1}(B)$ for a set B closed in $X$. To make sure I got this right we're considering $X$ as a subset of $X \sqcup Y $ with the disjoint union topology $\tau$, then we're endowing $X$ with the subspace topology inherited by $\tau$ and we're selecting a closed subset B wrt this subspace topology, right?
My question is how can I derive $q^{-1}(q(B)) \bigcap X = B$ and $q^{-1}(q(B)) \bigcap Y = f^{-1}(B)$.
It should boild down to the fact that $\sim$ is generated by $a \sim f(a)$ (where $a \in A$, a closed subset of $Y$, which is the domain of $f$) and so points in $A$ with the same image are identified.
I can't really go on from here, can somebody please make clear how the preceding statement is true?
Thank in advance!
 A: So lets do it formally. We have two topological spaces $X, Y$ and a continuous function $f:A\to X$ where $A\subseteq Y$.
When you work with the disjoint union people often do implicit steps, like $X\subseteq X\sqcup Y$. But what does it really mean? For that we need the definition of the disjoint union.
It goes like this:
$$X\sqcup Y:=(\{1\}\times X)\cup(\{2\}\times Y)$$
and the topology is generated by $\{1\}\times U$ and $\{2\}\times V$ for open $U\subseteq X$ and open $V\subseteq Y$. Now $X$ embeds to $X\sqcup Y$ via $x\mapsto (1,x)$ and $Y$ embeds to $X\sqcup Y$ via $y\mapsto (2,y)$. Thus we identify $X$ with $X'=\{1\}\times X$ and $Y$ with $Y'=\{2\}\times Y$.
Now the relation on $X\sqcup Y$ is generated by $(2, a)\sim (1, f(a))$ for $a\in A$.
Throught I will use apostrophe $A'$ to indicate image of $A$ in $X\sqcup Y$. Either via $x\mapsto (1,x)$ or $y\mapsto (2,y)$ map, so the apostrophe works only for subsets of either $X$ or $Y$. I hope it won't lead to confusion.

Back to the problem. Consider the quotient map $q:X\sqcup Y\to X\sqcup Y/\sim$. Let $B\subseteq X$ and consider $B'$ being a subset of $X'$ which is a subset of $X\sqcup Y$. You normally identify $B'$ with $B$.
What we want to show, formally, is that $q^{-1}(q(B'))\cap X'=B'$. So the "$\supseteq$" inclusion should be clear.
The other inclusion goes like this: let $v\in q^{-1}(q(B'))\cap X'$. This means $v=(1,x)$ for some $x\in X$ and $v\in q^{-1}(q(B'))$. Therefore $v\sim w$ for some $w\in B'$. By the definition of $\sim$ this implies that $v=(1,b)$ for some $b\in B$ or $v=(2,a)$ for some $a\in A$. But the last case is impossible since $v=(1,x)$. Therefore $v=(1,b)$ for some $b\in B$, i.e. $v\in B'$. This completes the proof. $\Box$

Now for the other equality. Again, we start with $B\subseteq X$, $B'\subseteq X'$ and $Y'=\{2\}\times Y$. Formally we want to show that
$$q^{-1}(q(B'))\cap Y'=f^{-1}(B)'=\{2\}\times f^{-1}(B)$$
Again, normally we identify $f^{-1}(B)$ with $f^{-1}(B)'$ but we want to do this formally.
So the "$\supseteq$" inclusion should be clear. If $b\in f^{-1}(B)$ then obviously $(2,b)\in Y'$. On the other hand since $f(b)\in B$ then $(2,b)\sim v$ for some $v\in B'$, precisely for $v=(1, f(b))$. Meaning $(2,b)\in q^{-1}(q(B'))$. This completes this inclusion. $\Box$
For the "$\subseteq$" inclusion consider element $w\in q^{-1}(q(B'))\cap Y'$. Since $w\in Y'$ then $w=(2,y)$ for some $y\in Y$. On the other hand $w\in q^{-1}(q(B'))$ meaning $w\sim v$ for some $v\in B'$. But $v=(1,b)$ for some $b\in B$. So we have this situation
$$(2,y)\sim (1,b)$$
By the definition of $\sim$ it follows that $b=f(y)$ and so $y\in f^{-1}(b)$. In particular $w\in f^{-1}(B)'$ which completes the proof. $\Box$

Final note: So I get it that this requires lots of other symbols, this weird $(1,x), (2,y)$ products and proofs/constructions become long. But that way we solve all possible problems and we avoid issues like: what is $X\sqcup X$? How can we distinguish one embedding $X\subseteq X\sqcup X$ from another? Once we grasp formalities we can be sure that our intuition leads us in a correct direction.
