Let $X,Y$ be topological spaces, $A\subset X$ and $f:A\rightarrow Y$ a continuous mapping. Define $$R:=\{z\in(X\sqcup Y)\times(X\sqcup Y)\ |\ (\exists x\in A)(\text{pr}_1(z)=(0,x)\land\text{pr}_2(z)=(1,f(x)))\}.$$ Clearly $R\subset(X\sqcup Y)\times(X\sqcup Y)$. Let $\sim$ be the equivalence relation on $X\sqcup Y$ generated by $R$. Write $X\cup_f Y:=(X\sqcup Y)/R$ and let $\pi:X\sqcup Y\rightarrow X\cup_f Y$ be the canonical surjection.
How can I show that $$\pi(0,x)=f^{-1}(\{f(x)\})\sqcup\{f(x)\}$$ for all $x\in A$?
Attempt: Let $z\in X\sqcup Y$ and $x\in X$ such that $\pi(z)=\pi(0,x)$. There exists $n\in\mathbb{N}$ and $\alpha\in(X\sqcup Y)^{[0,n]}$ such that $\alpha_0=(0,x)$, $\alpha_n=z$ and $$(\alpha_i,\alpha_{i+1})\in R\text{ or }(\alpha_{i+1},\alpha_i)\in R$$ for all $i\in[0,n-1]$. On the other hand, we have $\pi(1,f(x))=\pi(0,x)$. How to proceed from here? Any suggestions?
Edit: $X\sqcup Y:=\{0\}\times X\cup\{1\}\times Y$.
Your equivalence relation $\sim$ is generated by the basic relation $$z \equiv z' \text{ iff there exists } a \in A \text{ such that } z = (0,a), z '= (1,f(a)) .$$ $z \equiv z$ is only possible if $z \in \{0\} \times A$ ("$z$ has type $0$") and $z ' \in \{1\} \times f(A)$ ("$z'$ has type $1$"). Note that the concept of type is only defined for points of $A^* = \{0\} \times A \cup \{1\} \times f(A)$.
By a chain we mean a finite sequence of points $(z_1, \ldots, z_n)$ such that
Thus $z \sim z'$ iff there exists a chain $(z_1, \ldots, z_n)$ such that $z = z_1, z' = z_n$. Note that for $n = 1$ we get $z \sim z$. Also observe that if $(z_1, \ldots, z_n)$ is a chain from $z$ to $z'$, then the reverse sequence $(z_n, \ldots, z_1)$ is a chain from $z'$ to $z$.
By definition of $\equiv$ each chain of length $n > 1$ must alternate between points of type $0$ and points of type $1$. Thus the equivalence class of each $z \in \{0\} \times (X \setminus A) \cup \{1\} \times (Y \setminus f(A)) = X \sqcup Y \setminus A^*$ is a singleton. Only equivalences classes of points $z \in A^*$ may contain more than one element. Note that each chain between two points of the same type must have odd length, each chain between two points of different type must have even length.
By a simple chain of type $1$ we mean a chain of length $3$ such that $z_1, z_3$ have type $1$. Write $z_1 = (1,b), z_3 = (1,b')$ with $b, b' \in f(A)$. The intermediate point $z_2$ must have the form $z_2 = (0,a)$ with $a \in A$. We have $z_2 \equiv z_1$, i.e. $b = f(a)$ and $z_2 \equiv z_3$, i.e. $b' = f(a)$. Thus $z_1 = z_3$.
Now let us denote by a chain of type $1$ any chain of length $n \ge 3$ such that $z_1, z_n$ have type $1$. Thus $n = 2m+1$. In each subchain $z_{2i-1}, z_{2i}, z_{2i+1}$, $i = 1,\ldots, m$, the points $z_{2i-1},z_{2i+1}$ have type $1$, thus $z_{2i-1} =z_{2i+1}$. We conclude that $z_1 = z_n$.
Now let us consider an arbitrary chain $(z_1,\ldots, z_n)$ of length $n > 3$. There are the follwing cases:
$z_1, z_n$ have type $1$. Then $z_1 = z_n$.
$z_1$ has type $1$ and $z_n$ has type $0$. Then $(z_1,\ldots, z_{n-1})$ has type $1$, i.e. $z_1 = z_{n-1}$, and $z_n \equiv z_{n-1}$. Thus $z_n \equiv z_1$.
$z_1$ has type $0$ and $z_n$ has type $1$. Then $(z_2,\ldots, z_n)$ has type $1$, i.e. $z_2 = z_n$, and $z_1 \equiv z_2$. Thus $z_1 \equiv z_n$.
$z_1, z_n$ have type $0$. Then $(z_2,\ldots, z_{n-1})$ has type $1$, i.e. $z_2 = z_{n-1}$, and $z_1 \equiv z_2$, $z_n \equiv z_{n-1}$. Thus we get a length $3$ chain $(z_1,z_2,z_n)$. We have $z_1 =(0,a), z_n = (0,a')$ with $a, a' \in A$. The intermediate point $z_2 = (1,b)$ must satisfy $z_1 \equiv z_2$, i.e. $b = f(a)$ and $z_3 \equiv z_2$, i.e. $b = f(a')$. Thus we get $f(a) = f(a')$.
This gives us a very transparent description of $\sim$. In fact, $z \sim z'$ means that either
Therefore the equivalence class of $(0,a)$ with $a \in A$ is $$\pi(0,a) = \{(0,a') \mid a' \in A, f(a) = f(a') \} \cup \{(1,f(a))\} = \{0\} \times f^{-1}(f(a)) \cup \{1\} \times \{f(a)\} \\ = f^{-1}(f(a)) \sqcup \{f(a)\}.$$ The equivalence class of $(1,b)$ with $b \in f(A)$ is $$\pi(1,b) = f^{-1}(b)) \sqcup \{b\}.$$ All other equivalence classes are singletons.