When must the subgroup of a product be the product of subgroups? Twist on a common problem. It is well-known that the following statement is false, using $G = G_1 = G_2$ and considering the subgroup $\{ (g,g) : g \in G \} \le G_1 \times G_2$:

For any groups $G_1$ and $G_2$, any subgroup of $G_1 \times G_2$ must be of the form $H_1 \times H_2$ for some subgroups $H_i \le G_i$.

Is there a way to characterize the pairs $(G_1,G_2)$ for which it is true?
 A: To spill the beans: this happens if and only if both $G_1$ and $G_2$ are torsion groups, and for every $x\in G_1$ and $y\in G_2$, $\gcd(|x|,|y|)=1$.
Once you figure out the statement one can prove it directly, as I do below; but I arrived at it using my favorite "hammer" to deal with subgroups of $G_1\times G_2$, Goursat's Lemma. So I leave the development that led to the result below.

The subgroups of $G_1\times G_2$ are described by Goursat's Lemma. Each such subgroup corresponds to a $5$-tuple $(H_1,N_1,H_2,N_2,\varphi)$, where

*

*$H_i$ is a subgroup of $G_i$, $i=1,2$.

*$N_i\triangleleft H_i$, $i=1,2$.

*$\varphi$ is an isomorphism $\varphi\colon \frac{H_1}{N_1}\to \frac{H_2}{N_2}$.

Such a tuple corresponds to the subgroup
$$\{ (x,y)\in G_1\times G_2\mid x\in H_1, y\in H_2, \varphi(xN_1)=yN_2\}.$$
So the question is: when will such a subgroup be equal to $H_1\times H_2$? That will happen if and only if $\varphi(xN_1)=yN_2$ for every $x\in H_1$ and every $y\in H_2$. This in turn means that $N_1=H_1$ and $N_2=H_2$.
If $G$ is a group, Let us denote by $\mathbf{HS}(G)$ the class of all groups that are isomorphic to a homomorphic image of a subgroup of $G$ (that is, isomorphic to $H/N$ for some $H\leq G$ and $N\triangleleft H$).
Thus, we have:

Theorem. Let $G_1$ and $G_2$ be two groups. The following are equivalent:

*

*Every subgroup of $G_1\times G_2$ is equal to $H_1\times H_2$ for some $H_1\leq G_1$ and $H_2\leq G_2$.

*The only group that the classes $\mathbf{HS}(G_1)$ and $\mathbf{HS}(G_2)$ have in common is the trivial group.


For finite groups, the condition is very strong:

Corollary 1. Let $G_1$ and $G_2$ be two finite groups. The following are equivalent:

*

*Every subgroup of $G_1\times G_2$ is equal to $H_1\times H_2$ for some $H_1\leq G_1$ and $H_2\leq G_2$.

*$\gcd(|G_1|,|G_2|)=1$.


Proof. Since the order of an element of $\mathbf{HS}(G)$ divides the order of $G$ when $G$ is finite, condition 2 implies condition 2 of the theorem. If $|G_1|$ and $|G_2|$ are not relatively prime, let $p$ be a prime dividing both, and let $x\in G_1$, $y\in G_2$ be elements of order $p$. The subgroup $\langle (x,y)\rangle$ is cyclic of order $p$ with both projections nontrivial, and so it is not of the form described in 1. $\Box$

Corollary 2. Let $G_1$ and $G_2$ be nontrivial groups, and assume that $G_1$ is infinite.

*

*If $G_1$ is not torsion, then there are subgroups of $G_1\times G_2$ that are not of the form $H_1\times H_2$ with $H_i\leq G_i$.

*If both $G_1$ and $G_2$ are torsion, then every subgroup of $G_1\times G_2$ is of the form $H_1\times H_2$ with $H_i\leq G_i$ if and only if there is no prime $p$ such that both $G_1$ and $G_2$ have elements of order $p$. Equivalently, if $x\in G_1$ and $y\in G_2$, then $\gcd(|x|,|y|)=1$.


Proof. 1. Let $x\in G_1$ be of infinite order. Let $y\in G_2$ be an arbitrary nontrivial element. Then there is a quotient of $\langle x\rangle$ isomorphic $\langle y\rangle$, and the conclusion follows from the theorem.


*If $G_1$ and $G_2$ have elements of order $p$, then the result follows as in Corollary 1. Otherwise, let $H_i\leq G_i$ and $N_i\triangleleft H_i$ with $H_1/N_1$ isomorphic to $H_2/N_2$. Every element of $H_1/N_1$ has order dividing the order of an element of $G_1$; every element of $H_2/N_2$ has order dividing the order of an element of $G_2$. But the orders of elements of $G_1$ and of $G_2$ are coprime, so both $H_1/N_1$ and $H_2/N_2$ are trivial. $\Box$
In summary the promised result:

Theorem. Let $G_1$ and $G_2$ be groups. Then every subgroup of $G_1\times G_2$ is of the form $H_1\times H_2$ with $H_i\leq G_i$ if and only if both $G_1$ and $G_2$ are torsion groups, and for every $x\in G_1$ and $y\in G_2$, $\gcd(|x|,|y|)=1$.

This follows directly from the development done above, but here is a direct, constructive, elementary proof that does not invoke Goursat's Lemma.
Proof. For the "if" directly, if $S$ is a subgroup of $G_1\times G_2$ and $(x,y)\in S$, then since $\gcd(|x|,|y|)=1$ there exist $a$ and $b$ such that $a\equiv 0\pmod{|x|}$, $a\equiv 1\pmod{|y|}$, and $b\equiv 1\pmod{|x|}$, $b\equiv 0\pmod{|y|}$. Then $(x,y)^a = (e,y)$ and $(x,y)^b=(x,e)$, so both $(x,e)$ and $(e,y)$ are in $S$. Thus, $S=\pi_1(S)\times\pi_2(S)$.
For the "only if" clause, let $x\in G_1$ and $y\in G_2$; we must prove they are both torsion elements and their orders are relatively prime. Without loss of generality assume that $x\neq e$ (if both are trivial, they desired conclusion follows). Consider the group $H=\langle (x,y)\rangle$. Because $H=H_1\times H_2$ for some subgroups $H_1\leq G_1$ and $H_2\leq G_2$, we must have $(x,e)\in H$. So there exists an integer $k$ such that $(x,y)^k = (x^k,y^k)=(x,e)$. In particular, $y$ is of finite order that divides $k$; and $x$ is also of finite order and $k$ is congruent to $1$ modulo the order of $x$.  That means that the order of $x$ is relatively prime to $k$, and hence to its divisor the order of $y$; so $x$ and $y$ are torsion elements and $\gcd(|x|,|y|)=1$, as claimed. $\Box$
A: Arturo Magidin's answer is long, and contains uses of Goursat's Lemma, which is always useful to know. A shorter proof, for those who need it direct, is below.
Let $G$ and $H$ be non-trivial groups, and consider $G\times H$. If $G$ is not torsion, let $x\in G$ have infinite order, and $1\neq y\in H$. Then $\langle xy\rangle$ is an infinite cyclic subgroup, clearly does not lie in either $G$ or $H$, and as it cannot be written as the product of two non-trivial groups, it must be a genuine diagonal subgroup.
Thus both $G$ and $H$ are torsion. If $G$ and $H$ contain elements $x$ and $y$ of the same prime order $p$, then $\langle xy\rangle$ is also not contained in $G$ or $H$ and cannot be decomposed into a direct product (as it is cyclic of prime order), so again we are done.
Thus $G$ and $H$ are torsion groups, and there are sets of primes $\pi$ and $\pi'$ such that $G$ is a $\pi$-group, $H$ is a $\pi'$-group, and $\pi\cap\pi'=\emptyset$ (a $\pi$-group is a group whose elements have order a product of primes in $\pi$, generalizing the concept of a $p$-group, and similarly a $\pi$-element for an element of order a multiple of numbers from $\pi$).
Now the answer is that it is a direct product. Let $X$ be a subgroup of $G\times H$, let $A$ be the collection of $\pi$-elements of $X$, and $B$ the $\pi'$-elements. If $g\in X$ then $g=ab$ where $a$ is a $\pi$-element and $b$ is a $\pi'$-element, by simply taking appropriate powers of $g$ and applying the Euclidean algorithm. Thus $X=AB$. Also, $A=X\cap G$ and $B=Y\cap H$, so both are subgroups and normalize one another. Thus $X=A\times B$ and we are done.
