Attaching space in topology I have some problem understanding the attaching space when learning topology. We know that
Let $X$ and $Y$ be two spaces, $A$ a subset of $Y$ , and $f: A\to Y$  a continuous map. The quotient space $$ X \bigcup\limits_{f}Y:= (X\bigsqcup Y)/[a \sim f(a),\,\,\forall a\in A]$$ 
is called the result of attaching or gluing the space Y to the space X via f. The map $f$ is the attaching map.
$X\bigsqcup Y$ space defined by $$X\bigsqcup Y = \{(x; X)\,\,|\,\,x\in X\} \bigcup \{(y; Y)\,\,|\,\,y\in Y\}.$$
I don't understand this $\sim$ relation. If $(x_1; x_2), (y_1; y_2)\in X\bigsqcup Y$ then
$$ (x_1; x_2) \sim (y_1; y_2)\leftrightarrow ??$$
Can you explain for me? Thank you very much!
 A: I’m assuming that $A$ is in fact a subset of $X$, not $Y$. 
Let’s simplify matters a little by assuming that $X$ and $Y$ are disjoint, so that we don’t have to form $X\sqcup Y$; I’ll return to the general case later. We have disjoint spaces $X$ and $Y$, a subset $A$ of $X$, and a continuous $f:A\to Y$. The idea is that we’re going to attach $Y$ to $X$ by ‘gluing’ $A$ to $f[A]$ in a manner determined by the function $f$. Specifically, we’ll glue each $x\in A$ to the corresponding point $f(x)\in f[A]$. Note that since $f$ need not be injective, some points of $f[A]$ may be glued to several different points in $A$; these points of $A$ then end up glued to one another as well.
This gluing is formally accomplished by defining an equivalence relation in such a way that each equivalence class consists of a set of points that are to be glued together. If $x\in X\setminus A$, we don’t want to glue $x$ to any other point, so we want $[x]$, the equivalence class of $x$, to be just $\{x\}$. The same goes for points of $Y\setminus f[A]$. If $x\in A$, however, we want to glue $x$ to $f(x)$ and to all other points $x'\in A$ such that $f(x')=f(x)$, so we want 
$$[x]=\{f(x)\}\cup\{x'\in A:f(x')=f(x)\}\;.$$
Similarly, for $y\in f[A]$ we want
$$[y]=\{y\}\cup f^{-1}[\{y\}]\;.$$
We do this by defining $\sim$ as follows: for $u,v\in X\cup Y$, $u\sim v$ if and only if one of the following is true:


*

*$u=v$;  

*$u\in A$ and $v=f(u)$;  

*$v\in A$ and $u=f(v)$;  

*$u,v\in A$ and $f(u)=f(v)$.


This all works fine if $X$ and $Y$ are disjoint, but of course they may not be, so in general we have to start by forming their disjoint union
$$\begin{align*}
X\sqcup Y&=(X\times\{X\})\cup(Y\times\{Y\})\\
&=\{\langle x,X\rangle:x\in X\}\cup\{\langle y,Y\rangle:y\in Y\}\;.
\end{align*}$$
The point here is that since $X\ne Y$, $\langle x,X\rangle\ne\langle y,Y\rangle$ no matter what $x$ and $y$ are, so the sets $X\times\{X\}$ and $Y\times\{Y\}$ really are disjoint, but on the other hand there are obvious bijections
$$X\to X\times\{X\}:x\mapsto\langle x,X\rangle$$
and 
$$Y\to Y\times\{Y\}:y\mapsto\langle y,Y\rangle$$
that allow us to transfer any kind of structure from $X$ to $X\times\{X\}$ and from $Y$ to $Y\times\{Y\}$. All we’ve done, really, is attach a label $X$ to each point of $X$ and a label $Y$ to each point of $Y$, so that even if some $z$ belongs to both $X$ and $Y$, the labelled points $\langle z,X\rangle$ and $\langle z,Y\rangle$ will be distinct. In particular, these maps become homeomorphisms if we take the topology on $X\times\{X\}$ to be 
$$\{U\times\{X\}:U\text{ is open in }X\}$$
and similarly for $Y\times\{Y\}$.
Now just define $\sim$ on $X\sqcup Y$ exactly as we did above for the $X\cup Y$ when $X$ and $Y$ are known to be disjoint: for $\langle u,W\rangle,\langle v,Z\rangle\in X\sqcup Y$ (where $u,v\in X\cup Y$ and $W,Z\in\{X,Y\}$), $\langle u,W\rangle\sim\langle v,Z\rangle$ if and only if one of the following is true:


*

*$\langle u,W\rangle=\langle v,Z\rangle$;  

*$u\in A$, $W=X$, $Z=Y$, and $v=f(u)$;  

*$v\in A$, $Z=X$, $W=Y$, and $u=f(v)$;  

*$u,v\in A$, $W=Z=X$, and $f(u)=f(v)$.

