Prove that $HK$ is a subgroup iff $HK=KH$. Let $H$ and $K$ be subgroups of a group $G$, and let $HK=\{hk: h
\in H, k \in K\}$, $KH=\{kh: k \in K, h \in H\}$. How can we prove that $HK$ is a subgroup iff $HK=KH$?
It is usually helpful to recall that $ L$ is a subgroup if and only if $ L^ 2=L $, $ L^{- 1}=  L $ and $  L\neq \varnothing$. 

If $HK$ is a subgroup, then $HK=(HK)^{-1}=K^{ -1}H^{-1}=KH$. Hence the condition is met. Conversely, 
$$ \begin{align}(HK)^{ -1} &amp;= K^{ -1}H^{-1}\\&amp;=KH =HK\text{, }\\(HK)(HK)=H(KH)K&amp;=\\H( HK)K&amp;=  H^2K^ 2=   HK\end{align} $$ and of course $ HK\neq \varnothing$. We made repeated use of the fact $ H $ and $ K $ are subgroups and $ H K = KH $.
HK is a group iff each hk has an inverse in HK iff  each k^-1 h^-1 is in HK  iff each kh is in HK (and similarly each hk is in KH) iff HK and KH are identical.