TITLE: When is the product of $n$ subgroups a subgroup?
QUESTION [29 upvotes]: Let $G$ be any group. It's a well-known result that if $H, K$ are subgroups of $G$, then $HK$ is a subgroup itself if and only if $HK = KH$.
Now, I've always wondered about a generalization of this result, something along the lines of:
Theorem: If $H_1, \ldots, H_n$ are subgroups of $G$, then $H_1H_2\dots{H_n}$ is a subgroup if and only if ($\star$) holds, where $(\star)$ is some condition on $H_1, \ldots, H_n$, preferably related to how the smaller products $H_{m_1}\ldots{}H_{m_k}$, for $k < n$, behave.
Question 1: Is there such a theorem?
I do know, and its easy to prove, that if $H_iH_j = H_jH_i$ for every $i, j$, then the big product is a group, but this is not satisfying since it's far from necessary (just take one of the groups to be $G$, and you need no commutativity at all). Also, I've been told that there is no really satisfactory answer; if that is indeed the case, then my question would be why? In particular:
Question 2: Are there really problematic counterexamples where you can see that the behavior of the smaller products has nothing to do with the big product, so that no such a theorem can ever exist?
I would appreciate even an answer for the particular case $n = 3$.
Thanks.

REPLY [2 votes]: It seems your desired theorem would look like this: If $A, B, C$ are subgroups of  $G$, then $A B C$ is a subgroup iff $\Phi_1(A,B)\land\Phi_2(B,C)\land\Phi_3(C,A)$ (where the $\Phi_i$ is some predicate in two variables).
Let's have a look at $\Phi_1$ first.
Clearly, "$\Phi_1(A,B):\iff AB\mathrm{\ is\ a\ group}$" would be too strong. Hence $\Phi_1(A,B)$ may be true in cases wheer $AB$ is not a group.
But how can $A B$ fail to be a group? Either there is $x\in A B$ with $x^{-1}\notin AB$ or there are $x,y\in AB$ with $xy\notin AB$. For $ABC$ to be a group there must exist a $z\in AB$ such that $x^{-1}=z c$ or $x y = z c$ for some $c\in C$, respectively. All composites in $ABAB$, all inverses are in $BA\subseteq ABAB$, hence we need $ABAB\subseteq  ABC$. Unless $ABAB\subseteq AB$ (i.e unless $AB$ is a group), this condition clearly depends on $C$.
Therefore such $\Phi_1$ cannot exist.
The same argument applies to $\Phi_2$ and with slight modifications for $\Phi_3$.
One could also argue simply that for subgroups $X, Y$ such that $XY$ is not a group, we have that $XYG$, $XGY$ and $GXY$ are groups, hence all $\Phi_i(X,Y)$ must be true. But $XY1$, $X1Y$ and $1XY$ are not groups, hence some $\Phi_i$ with one argument $=1$ must be false. But that can't be because a product where two factors are the trivial group is a group.