# recognition of symmetric groups in GAP

In GAP (https://www.gap-system.org), there is a function IsSymmetricGroup, which tells you whether a subgroup of $S_n$ generated by given permutations is all of the $S_n$. It looks like it takes virtually no time, even in large examples I tried ($n=50$). What is the method behind this function? Is it so easy to recognise symmetric groups?

On a related note, suppose that we know that $\sigma_1$, ..., $\sigma_k$ generate $S_n$. Are there some economic algorithms to write some standard generators of $S_n$, e.g. the adjacent transpositions, in terms of these sigmas?

• The beauty about GAP is that it's open source, so you can just look up the code. A quick grep of the source code shows the command is defined in the file 'grpnames.gi' in the lib folder. It seems to check whether the derived subgroup is an alternating group using the command 'IsAlternatingGroup', which is defined in the same file. Nov 17, 2017 at 15:39
• As far as I can tell from the source its general method for an arbitrary group $G$ is as follows: see if $G$ is finite, see if $[G,G]$ is simple by determining normal closures of conjugacy classes, see if $G \cong \mathrm{A}_n$ with $n\in \{5,6\}$ by ad-hoc methods, now check if $|G| = n!/2$ for some $n\geqslant 7$, then by CFSG we have $G \cong \mathrm{A}_n$. Checkout the command 'IsomorphismTypeInfoFiniteSimpleGroup' in 'grp.gi'. Nov 17, 2017 at 16:02
• @JayTaylor I don't think that the program could possibly compute the order of the group directly, without knowing the answer. All the groups I have been working with are too big for that. It is more plausible that an algorithm like Igor Rivin describes in his answer is used. Nov 17, 2017 at 17:27
• The function IsSymmetricGroup checks whether a group is isomorphic to some symmetric group (so may return true even for a matrix group). The function IsNaturalSymmetricGroup checks whether a given subgroup is in fact all of $S_n$. But for a subgroup of $S_n$, IsSymmetricGroup first invokes IsNaturalSymmetricGroup... The implementation of the latter function is in the file 'gpprmsya.gi', and Igor Rivin's answer seems to be rather accurate: Check transitivity, and try to find randomly a $p$-cycle with $n/2 < p < n-2$. Nov 17, 2017 at 22:22
• (A comment in the GAP-code refers to Seress, Permutation group algorithms, Section 10.2.) Nov 17, 2017 at 22:26

The method (I assume) uses Jordan's theorem, which says that an primitive subgroup of $$S_n$$ with a cycle of prime order (at most $$n-2,$$ if memory serves) is either $$A_n$$ or $$S_n.$$ You rule out $$A_n$$ by looking at the generators, you show transitivity by randomly generating an $$n$$-cycle (of which there are a lot, so it does not take long to find one, there are other ways, too), and you show primitivity by finding a permutation which has a $$p$$ cycle for $$n/2 < p < n-1$$ (raising it to a power, you just get the $$p$$-cycle. There are lots of such, so basically generating a few thousand elements will do the trick. Notice that if, after generating the few thousand elements you DO NOT find the sorts of elements you want, the group is almost surely NOT the symmetric group (but the NO answer will be probabilistic, while the YES answer will be deterministic).
• Deciding between $A_n$ and $S_n$ is not a matter of luck: just check whether any of the given generators is odd. Nov 17, 2017 at 15:47
• @Igor Rivin you wrote that "You rule out $A_n$ by randomly generating an odd permutation". But for a subgroup generated by a given subset $S$ of $S_n$, the subgroup is contained in $A_n$ iff $S$ is, which can be tested without "randomly generating" anything. Nov 17, 2017 at 18:00
• If $p=2^r-1$ is a Mersenne prime, then the image of the embedding of $PGL_2({\mathbf F}_{2^r})$ in $S_{p+2}$ determined by the natural action on $1$-spaces contains a $p$-cycle. So, it seems that you need a cycle of prime order at most $n-3$. Nov 17, 2017 at 22:17