# Listing all subgroups

Here's how to show all subgroups of $S_4$ in GAP:

gap> AllSubgroups(SymmetricGroup(4));
[ Group(()), Group([ (1,2)(3,4) ]), Group([ (1,3)(2,4) ]), Group([ (1,4)(2,3) ]), Group([ (3,4) ]), Group([ (2,3) ]),
Group([ (2,4) ]), Group([ (1,2) ]), Group([ (1,3) ]), Group([ (1,4) ]), Group([ (2,4,3) ]), Group([ (1,3,2) ]),
Group([ (1,4,2) ]), Group([ (1,4,3) ]), Group([ (1,4)(2,3), (1,3)(2,4) ]), Group([ (3,4), (1,2)(3,4) ]),
Group([ (1,4), (1,4)(2,3) ]), Group([ (2,4), (1,3)(2,4) ]), Group([ (1,3,2,4), (1,2)(3,4) ]), Group([ (1,4,3,2), (1,
3)(2,4) ]), Group([ (1,2,4,3), (1,4)(2,3) ]), Group([ (3,4), (2,4,3) ]), Group([ (1,4), (1,4,3) ]),
Group([ (2,3), (1,3,2) ]), Group([ (1,2), (1,4,2) ]), Group([ (1,4)(2,3), (1,3)(2,4), (3,4) ]), Group([ (1,2)
(3,4), (1,3)(2,4), (1,4) ]), Group([ (1,2)(3,4), (1,4)(2,3), (2,4) ]), Group([ (1,4)(2,3), (1,3)(2,4), (2,4,3) ]),
Group([ (1,4)(2,3), (1,3)(2,4), (2,4,3), (3,4) ]) ]

In Mathematica I can display the elements of $S_4$:

In[2]:= GroupElements[SymmetricGroup[4]]

Out[2]= {Cycles[{}],Cycles[{{3,4}}],Cycles[{{2,3}}],Cycles[{{2,3,4}}],Cycles[{{2,4,3}}],Cycles[{{2,4}}],Cycles[{{1,2}}],Cycles[{{1,2},{3,4}}],Cycles[{{1,2,3}}],Cycles[{{1,2,3,4}}],Cycles[{{1,2,4,3}}],Cycles[{{1,2,4}}],Cycles[{{1,3,2}}],Cycles[{{1,3,4,2}}],Cycles[{{1,3}}],Cycles[{{1,3,4}}],Cycles[{{1,3},{2,4}}],Cycles[{{1,3,2,4}}],Cycles[{{1,4,3,2}}],Cycles[{{1,4,2}}],Cycles[{{1,4,3}}],Cycles[{{1,4}}],Cycles[{{1,4,2,3}}],Cycles[{{1,4},{2,3}}]}

What's a good approach for listing the subgroups in Mathematica?

• Unfortunately, the ClearAll["Global`*"]; FiniteGroupData[{"SymmetricGroup", 4}, "Subgroups"] command fails, outputting Missing["NotAvailable"]. May 10, 2018 at 20:14
• The command FiniteGroupData[{"SymmetricGroup", 4}, "Information"] says, in particular, "The symmetric group S_n of degree n is the group of all permutations on n symbols. S_n is therefore a permutation group of order n! and contains as subgroups every group of order n". Hope this would be useful. May 24, 2022 at 14:36

My solution is too too too slow, which is so slow that I can't stand it. But it does work when the group orders less than $$20$$. Such as the $$D_8$$ of order $$16$$

DeleteDuplicatesBy[
PermutationGroup /@ Subsets[GroupElements[DihedralGroup[8]]],
GroupElements] // Timing

{169.313,{PermutationGroup[{}],PermutationGroup[{Cycles[{{2,8},{3,7},{4,6}}]}],PermutationGroup[{Cycles[{{1,2},{3,8},{4,7},{5,6}}]}],PermutationGroup[{Cycles[{{1,2,3,4,5,6,7,8}}]}],PermutationGroup[{Cycles[{{1,3},{4,8},{5,7}}]}],PermutationGroup[{Cycles[{{1,3,5,7},{2,4,6,8}}]}],PermutationGroup[{Cycles[{{1,4},{2,3},{5,8},{6,7}}]}],PermutationGroup[{Cycles[{{1,5},{2,4},{6,8}}]}],PermutationGroup[{Cycles[{{1,5},{2,6},{3,7},{4,8}}]}],PermutationGroup[{Cycles[{{1,6},{2,5},{3,4},{7,8}}]}],PermutationGroup[{Cycles[{{1,7},{2,6},{3,5}}]}],PermutationGroup[{Cycles[{{1,8},{2,7},{3,6},{4,5}}]}],PermutationGroup[{Cycles[{{2,8},{3,7},{4,6}}],Cycles[{{1,2},{3,8},{4,7},{5,6}}]}],PermutationGroup[{Cycles[{{2,8},{3,7},{4,6}}],Cycles[{{1,3},{4,8},{5,7}}]}],PermutationGroup[{Cycles[{{2,8},{3,7},{4,6}}],Cycles[{{1,5},{2,4},{6,8}}]}],PermutationGroup[{Cycles[{{1,2},{3,8},{4,7},{5,6}}],Cycles[{{1,3,5,7},{2,4,6,8}}]}],PermutationGroup[{Cycles[{{1,2},{3,8},{4,7},{5,6}}],Cycles[{{1,5},{2,6},{3,7},{4,8}}]}],PermutationGroup[{Cycles[{{1,3},{4,8},{5,7}}],Cycles[{{1,5},{2,6},{3,7},{4,8}}]}],PermutationGroup[{Cycles[{{1,4},{2,3},{5,8},{6,7}}],Cycles[{{1,5},{2,6},{3,7},{4,8}}]}]}}

But this method obviously cannot get all subgroups of $$S_4$$, because I need to consider a combination of $$2^{24}=16777216$$ elements, which is unthinkable for me. There may be other specialized algorithms to do this.

Some things change to better. In version 13 on Windows 10

FiniteGroupData[{"SymmetricGroup",  4},"Subgroups"]

{"Trivial", {"CyclicGroup", 2}, {"CyclicGroup", 3}, {"CyclicGroup", 4}, "Vierergruppe", {"SymmetricGroup", 3}, {"AlternatingGroup", 4}, {"SymmetricGroup", 4}}

• Note that this is only a subset of the subgroups, not all of them. :)
– yode
May 24, 2022 at 13:28
• @yode: One may continue:FiniteGroupData[{"SymmetricGroup", 3}, "Subgroups"] which produces {"Trivial", {"CyclicGroup", 2}, {"CyclicGroup", 3}, {"SymmetricGroup", 3}} and FiniteGroupData["Vierergruppe", "Subgroups"] and FiniteGroupData[{"AlternatingGroup", 4}, "Subgroups"] and ... I leave the rest on your own. May 24, 2022 at 13:38
• Note all your subgroup of subgroups all in the subgroup list of $S_4$
– yode
May 24, 2022 at 16:27
• @yode: No, it is not true : FiniteGroupData[{"AlternatingGroup", 4}, "Subgroups"] results in {"Trivial", {"CyclicGroup", 2}, {"CyclicGroup", 3}, {"AbelianGroup", {2, 2}}, {"AlternatingGroup", 4}}. May 25, 2022 at 5:12
• FiniteGroupData returns a non-homogeneous group, but even if it is non-homogeneous, $S_4$ has 11 instead of 8 as the maple
– yode
May 28, 2022 at 17:18