Prove that $\langle H, K\rangle = HK$ This is a question from an exam I sat about two hours ago, and I still couldn't figure it out on the bus home so I've decided to ask for a clue here.
Let $G$ be a group, and $H, K \leq G$. Let $HK := \{hk: h\in H, k\in K\}$, and $KH := \{kh: h\in H, k\in K\}$. Suppose $HK = KH$.


*

*Show that $HK \leq G$. (This is fine)

*Show that $\langle H, K\rangle = HK$. (This wasn't fine!)


Showing that $HK \subset \langle H, K\rangle$ is trivial, but this was all I could write for the reverse set inclusion:
"Let $x \in \langle H, K\rangle$. Then $x = h_1^{n_1}k_1^{m_1}h_2^{n_2}k_2^{n_2}\cdots$. As $H$ and $K$ are closed under multiplication, for each $h_i, k_i$ we can find $s_i \in H, t_i \in K$ such that $s_i = h_i^{n_i}, t_i = k_i^{m_i}$, so that $x = s_1t_1s_2t_2\cdots$. Furthermore, we know that $HK = KH$, so for each $a\in H, b\in K$, we can find $\alpha \in H, \beta \in K$ such that $ab = \beta\alpha$. It follows by induction that $x = hk$ for some $h\in H, k\in K$, so $x \in HK$."
I'm unhappy with this because of the potential "infiniteness" of $x = h_1^{n_1}k_1^{m_1}h_2^{n_2}k_2^{n_2}\cdots$. I handwaved and said "by induction", but induction only proves that "$s_1t_1s_2t_2\cdots s_nt_n = hk$ for some $h, k$ for all $n \in \mathbb{N}$". This means it verifies that all elements of $\langle H, K\rangle$ with finitely many symbols is of the form $hk$, but not a situation like $x = hkhkhkhkhk\cdots$.
How could I have avoided this issue?

You're making this much harder than it needs to be. To show the reverse containment $\langle H,K \rangle \subseteq HK$, use the fact that $HK$ is a subgroup (which you proved in part 1), and clearly $HK$ contains $H$ and $K$.
Then observe that $\langle H,K \rangle$ is the intersection of all subgroups containing $H$ and $K$. Since $HK$ is one of those subgroups, we have $\langle H,K \rangle \subseteq HK$.
