# Proving a loop is non-trivial using van Kampen's theorem

So I want to prove the following statement in algebraic topology.

Let $X=A \cup B$ be a topological space with $A$, $B$, and $A \cap B$ being open and path-connected. Suppose $\gamma$ is a loop in $A\cap B$, and $\gamma$ is not homotopic to the trivial loop in both $A$ and $B$. Then $\gamma$ is not homotopic to the trivial loop in $X$.

I think it can be derived from van Kampen's theorem, which states that in this case $\pi_1(X)=\pi_1(A) {\Large{*}} \pi_1(B)/N$, where $N$ is the the normal subgroup generated by $\alpha_{A} \alpha_{B}^{-1}$, where $\alpha$ is a loop in $A \cap B$, $\alpha_{A}$ is the homotopic class of $\alpha$ in $A$.

So I feel that what the quotient does is just identifying $\alpha_A$ with $\alpha_B$ for any $\alpha$ in $A\cap B$, and nothing else. Thus if $\alpha$ is origianlly non trivial in both $A$ and $B$, it should still be non trivial in $X$. But I could not write it down in a concrete way...

Group-theoretically, consider the amalgamated free product $(\langle a\rangle *\langle b\rangle)/N$ where $N$ is the normal closure of the subgroup $\langle ab,ab^{-1}\rangle$. The product is isomorphic to $\mathbb{Z}/2\mathbb{Z}$ since $a=b$ and $a^2=1$. The word $a^2$ is non-trivial in the "intersection" and on "either side," which I will make precise by a topological construction.
Start with a wedge $S^1\vee S^1$ with $x$ and $y$ the generator loops of the fundamental group around each circle. On one side, attach a disk along $xy$, and on the other side attach a disk along $xy^{-1}$. This defines a space $X$. Let $A$ be an open neighborhood containing the first disk, the wedge, and a little of the second disk. Let $B$ be the same, but reversing the roles of the first and second disks.
$A\cap B$ deformation retracts onto the wedge of circles, so its fundamental group is $\langle x,y\rangle$. The fundamental group of $A$ is free and generated by a loop $a$, and the inclusion map induces $x\mapsto a$, $y\mapsto a^{-1}$. The fundamental group of $B$ is free and generated by a loop $b$, and $x\mapsto b$, $y\mapsto b$ is the induced map for the inclusion.
The loop $x^2$ is nontrivial in both $A$ and $B$ (where it is $a^2$ and $b^2$, respectively). Yet in $X$, $$x^2=xa=xy^{-1}=xb^{-1}=xx^{-1}=1$$ by going back and forth between the spaces.