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$?

Suppose that $HK$ is a subgroup. Then for every $x\in HK$ there exists $h\in H, k\in K$ such as $x=hk$. But $x^{-1}$ is in $HK$ too, and $x^{-1}=(hk)^{-1}=k^{-1}h^{-1}\in KH$, therefore $HK\subseteq KH$. Conversely, for $k\in K$ and $h\in H$ we have $k\in HK$ and $h\in HK$. Since $HK$ is a subgroup we get $kh\in HK$, so $KH\subseteq HK$.
Now suppose $HK=KH$.
1° $e\in H, e\in K$ so $e\in HK$.
2° For $x,y\in HK$ there exists $h_x,h_y\in H$ and $k_x,k_y\in K$ such that $x=h_xk_x$ and $y=h_yk_y$, so $xy=h_xk_xh_yk_y$, but $KH=HK$ so you can find $h\in H, k\in K$ such as $k_xh_y=hk$ and therefore $xy=h_xhkk_y\in HK$.
3° Let $x=hk$. Then $x^{-1}=k^{-1}h^{-1}\in KH$, but since $KH=HK$, $x^{-1}\in HK$.
So $HK$ is a subgroup.
