Solution (source code)

= Solution
{c}

For $a\in A$, the element $a=ae$ belongs to both $A$ and $aA$. The assumed equal-or-disjoint property therefore gives $aA=A$.

If $a,b\in A$, then $ab\in aA=A$, so $A$ is closed under multiplication. Also $e\in A=aA$, so some $c\in A$ satisfies $ac=e$. Therefore $c=a^{-1}\in A$. Along with the given <identity element>, closure and existence of <inverse elements> establish that \b[$A$ is a <subgroup> of $G$]. This is the <subgroup test>. The proof even works without assuming that $G$ is finite.