I am looking at the proof of theorem 1.1 of Keith Conrad notes on dihedral groups, which states the following:
Let $G$ be generated by elements $x$ and $y$ where $x^n = 1$ for some $n \geq 3$, $y^2 = 1$, and $yxy^{−1} = x^{−1}$. There is a surjective homomorphism $D_n \to G$, and if $G$ has order $2n$ then this homomorphism is an isomorphism.
Suppose the the two generators of the dihedral group are $r$ and $s$, with orders $n$ and 2, respectively. In the proof the author defines the function $f(r^js^k) = x^jy^k$ and states the following:
This function makes sense, since the only ambiguity in writing an element of $D_n$ as $r^js^k$ is that $j$ can change modulo $n$ and $k$ can change modulo $2$, which has no effect on the right side since $x^n=1$ and $y^2 = 1$.
I fail to see why this proves it is well defined. In particular, I cannot see why this implies that if I write the same element of $D_n$ with different representations then the image of both will coincide. For example, in the dihedral group $rsr = s$, but why can we affirm that $f(rsr) = f(s)$?
The whole point is that every element of $D_n$ looks like $r^js^k$. So it suffices to (i) describe $f$ on elements of $D_n$ when written that way and (ii) check if you write the same element as $r^js^k$ with different pairs of exponents, the resulting values of $x^jy^k$ are the same. That shows $f$ is well-defined on $D_n$. The file has been updated to clarify these points.