The Symmetries of the Triangle using GAP
A simple tutorial
One of my favourite tools to use as a math PhD student is called GAP, which stands for “Groups, Algorithms, Programming — a System for Computational Discrete Algebra.” This is an award winning open-source software project that is developed and maintained by mathematicians around the world, with a thirty year history and updated versions published more than once each year. Using GAP has brought math to life for me in a way that just reading or putting pen to paper never could. These days, when I learn something new in math, I usually try to construct it in GAP to get a tangible feel for it.
I run GAP from the command prompt of the Windows Subsystem for Linux and write and run more complicated scripts using VS Code.
Symmetries of the Triangle
Let’s begin with the symmetries of a triangle.
Let’s label the corners of our triangle 1, 2, and 3. To rotate the triangle, we need to send 1 to 2, 2 to 3, and 3 to 1. This is called a permutation on three points. In GAP we define permutations using the following syntax:
gap> sigma := (1,2,3);
(1,2,3)
gap> 1^sigma;
2
gap> 2^sigma;
3
gap> 3^sigma;
1
Here sigma
is the permutation (1,2,3)
which sends 1 to 2, 2 to 3, and 3 back to 1. The permutation sigma
is a rotation of the triangle. What about reflections? Let’s define a second permutation tau = (1,2)
than sends 1 to 2, 2 to 1 and fixes 3:
gap> tau := (1,2);
(1,2)
gap> 1^tau;
2
gap> 2^tau;
1
gap> 3^tau;
3
If a diagram helps, we can view these two permutations as follows, with sigma
on the left and tau
on the right.
It is possible to compose permutations. For instance, what if we first rotate the triangle, sigma
, and then reflect it using tau
. This gives us a new permutation:
gap> sigma*tau;
(2,3)
The permutation sigma*tau
is a new reflection fixing the point 1. A natural question to ask is this: what are all the possible permutations of the triangle that we can obtain using rotationsigma
and reflectiontau
?
In GAP it is very easy to answer this question. We construct a group of permutations:
gap> G := Group([sigma,tau]);
Group([ (1,2,3), (1,2) ])
gap> AsList(G);
[ (), (2,3), (1,2), (1,2,3), (1,3,2), (1,3) ]
Using the AsList
command allows us to view the list of permutations the make up the group generated by our original rotation and reflection, sigma
and tau
. But what is this group? Does it have a name? A helpful tool in GAP is the command StructureDescription
:
gap> StructureDescription(G);
"S3"
This tells us that our group G
is the Symmetric Group on three points, labeled S3
. The key to these descriptions is available in the extensive and helpful GAP documentation:
StructureDescription(<G>) ::=
1 ; trivial group
| C<size> ; cyclic group
| A<degree> ; alternating group
| S<degree> ; symmetric group
| D<size> ; dihedral group
| Q<size> ; quaternion group
| QD<size> ; quasidihedral group
| PSL(<n>,<q>) ; projective special linear group
| SL(<n>,<q>) ; special linear group
| GL(<n>,<q>) ; general linear group
| PSU(<n>,<q>) ; proj. special unitary group
| O(2<n>+1,<q>) ; orthogonal group, type B
| O+(2<n>,<q>) ; orthogonal group, type D
| O-(2<n>,<q>) ; orthogonal group, type 2D
| PSp(2<n>,<q>) ; proj. special symplectic group
| Sz(<q>) ; Suzuki group
| Ree(<q>) ; Ree group (type 2F or 2G)
| E(6,<q>) | E(7,<q>) | E(8,<q>) ; Lie group of exceptional type
| 2E(6,<q>) | F(4,<q>) | G(2,<q>)
| 3D(4,<q>) ; Steinberg triality group
| M11 | M12 | M22 | M23 | M24
| J1 | J2 | J3 | J4 | Co1 | Co2
| Co3 | Fi22 | Fi23 | Fi24' | Suz
| HS | McL | He | HN | Th | B
| M | ON | Ly | Ru ; sporadic simple group
| 2F(4,2)' ; Tits group
| PerfectGroup(<size>,<id>) ; the indicated group from the
; library of perfect groups
| A x B ; direct product
| N : H ; semidirect product
| C(G) . G/C(G) = G' . G/G' ; non-split extension
; (equal alternatives and
; trivial extensions omitted)
| Phi(G) . G/Phi(G) ; non-split extension:
; Frattini subgroup and
; Frattini factor group
Symmetric Groups
In the example above we’ve been working with the symmetric group on three points, labeled S3
in GAP. We can construct this group directly as follows:
gap> S := SymmetricGroup(3);
Sym( [ 1 .. 3 ] )
gap> AsList(S);
[ (), (2,3), (1,2), (1,2,3), (1,3,2), (1,3) ]
gap> S = G;
true
Let’s construct the symmetric group on four points instead:
gap> S := SymmetricGroup(4);
Sym( [ 1 .. 4 ] )
gap> AsList(S);
[ (), (3,4), (2,3), (2,3,4), (2,4,3), (2,4), (1,2), (1,2)(3,4), (1,2,3), (1,2,3,4), (1,2,4,3), (1,2,4), (1,3,2), (1,3,4,2), (1,3), (1,3,4), (1,3)(2,4), (1,3,2,4), (1,4,3,2), (1,4,2), (1,4,3), (1,4), (1,4,2,3), (1,4)(2,3) ]
gap> Size(S);
24
This structure has 24 permutations instead of the 6 we say previously. In fact, the symmetric group on n points always has n! permutations. Let’s list these numbers up to n = 20
using GAP:
gap> List([1..20], n -> Factorial(n));
[ 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800, 479001600, 6227020800, 87178291200, 1307674368000, 20922789888000, 355687428096000, 6402373705728000, 121645100408832000, 2432902008176640000 ]
We obtain the same list by computing the sizes of symmetric groups on n points:
gap> List([1..20], n -> Size(SymmetricGroup(n)));
[ 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800, 479001600, 6227020800, 87178291200, 1307674368000, 20922789888000, 355687428096000, 6402373705728000, 121645100408832000, 2432902008176640000 ]
Rather than checking that these lists match manually, we can do a comparison at each step of the way:
gap> List([1..20], n -> Factorial(n) = Size(SymmetricGroup(n)));
[ true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true ]
Or we can filter our list of symmetric groups and look for exceptions:
gap> Filtered([1..20], n -> Factorial(n) <> Size(SymmetricGroup(n)));
[ ]
Of course, the normal way to handle this material is to prove that the size of the symmetric group on n points is n!. But using GAP I can ask simple questions and check several cases without much effort. This can give me a better sense of what might turn out to be provable in the first place, and were to focus my efforts.
I hope this brief tutorial sparks an interest in using GAP. This has been a very basic example, and GAP has much more to offer for those who spend some time with it.