Solution (source code)

= Solution

A reduced word is either the empty word or a product
$$
u_1u_2\cdots u_n
$$
in which every syllable $u_i$ is a nonidentity element of $G$ or $H$, and consecutive syllables belong to different factors.

Let $\mathcal W$ be the set of reduced words. Each $g\in G$ acts on the right of $\mathcal W$: if the last syllable lies in $H$, append $g$; if it lies in $G$, multiply it by $g$ and delete it when the product is the identity. Define the action of each $h\in H$ analogously. These rules give genuine actions of the two factors by <permutation>[permutations] of $\mathcal W$, hence an action of the <free group> $F(X\sqcup Y)$. Every relation in $R\sqcup S$ acts trivially, so the action factors through the displayed presentation of $G*H$.

The element represented by a reduced word $w$ sends the empty word to $w$. Therefore two reduced words representing the same element induce the same permutation and have the same value on the empty word. They must be identical. This proves the <normal form theorem for a free product>.