Introduction to GAP

Lecture 2

GAP Days Spring 2025,

April 7-11, 2025,
Vrije Universiteit Brussel, Belgium

Ilaria Colazzo
University of Leeds (UK)

  • A permutation of a set is a bijection on .
  • The set of all permutations on a given set is the symmetric group and it is denoted by .
  • If is a finite set, say , and we don't need to put emphasis on in particualr, we speak of the symmetric group on elements and we denote it by .
  • A subgroup of a symmetric group is called a permutation group.
GAP Days Spring 2025 | Ilaria Colazzo | Introduction to GAP |
  • We will use permutation groups to explain some built-in functions. Such as
    • Group that allows us to define a group given its generators.
    • Order that returns the number of elements in a group, which is also known as the group order.
    • Elements that returns a list of all elements in the group.
    • MultiplicationTable that generates the multiplication table of the group.
    • IsAbelian that returns true if the group is abelian false otherwise.
    • One that returns the identity of the group.
    • Inverse that returns the inverse of an element in a particular group.
GAP Days Spring 2025 | Ilaria Colazzo | Introduction to GAP |
  • Let's start creating a group spanned by two permutations in .
gap> G := Group((1, 2, 3), (1, 2));
Group([ (1,2,3), (1,2) ])
  • We want to check that G is the whole symmetric group .
gap> G = SymmetricGroup(3);
true
  • Now, let's recover some known properties of the group.

  • Recall that the order of is , let's check this for G.

gap> Order(G);
6
GAP Days Spring 2025 | Ilaria Colazzo | Introduction to GAP |
  • GAP can also give us the list of all elements in G:
gap> Elements(G);
[ (), (2,3), (1,2), (1,2,3), (1,3,2), (1,3) ]
  • We can also ask GAP to compute the multiplication table.
gap> MultiplicationTable(G);
[ [ 1, 2, 3, 4, 5, 6 ], [ 2, 1, 4, 3, 6, 5 ], [ 3, 5, 1, 6, 2, 4 ],
  [ 4, 6, 2, 5, 1, 3 ], [ 5, 3, 6, 1, 4, 2 ], [ 6, 4, 5, 2, 3, 1 ] ]
GAP Days Spring 2025 | Ilaria Colazzo | Introduction to GAP |
  • It was quite hard to read, we can use ShowMultiplicationTable to get the multiplication table in a readable format.

gap> ShowMultiplicationTable(G);
*       | ()      (2,3)   (1,2)   (1,2,3) (1,3,2) (1,3)
--------+------------------------------------------------
()      | ()      (2,3)   (1,2)   (1,2,3) (1,3,2) (1,3)
(2,3)   | (2,3)   ()      (1,2,3) (1,2)   (1,3)   (1,3,2)
(1,2)   | (1,2)   (1,3,2) ()      (1,3)   (2,3)   (1,2,3)
(1,2,3) | (1,2,3) (1,3)   (2,3)   (1,3,2) ()      (1,2)
(1,3,2) | (1,3,2) (1,2)   (1,3)   ()      (1,2,3) (2,3)
(1,3)   | (1,3)   (1,2,3) (1,3,2) (2,3)   (1,2)   ()
GAP Days Spring 2025 | Ilaria Colazzo | Introduction to GAP |
  • We can check if the group is abelian.
gap> IsAbelian(G);
false
  • We can ask for the identity of the group.
gap> One(G);
()
  • We can compute the inverse of a given element.
gap> g1 := Elements(G)[4];
(1,2,3)
gap> Inverse(g1);
(1,3,2)
GAP Days Spring 2025 | Ilaria Colazzo | Introduction to GAP |

The natural action of permutation groups

  • Permutation groups naturally acts on sets.
    [ 📝 In Lecture 3, we will talk more about group actions.]

  • A moved point is any element that is not fixed by all the permutations in the group. In other words, a number remains unchanged by every permutation in the group, it is not considered a moved point.

  • The function MovedPoint gives the list of moved points.

gap> g := Group((1,2,3,4), (1,2));
Group([ (1,2,3,4), (1,2) ])
gap> MovedPoints(g);
[ 1, 2, 3, 4 ]
GAP Days Spring 2025 | Ilaria Colazzo | Introduction to GAP |
  • We can use also
    • NrMovedPoints(g) for the total count of moved points.
    • LargestMovedPoint(g) for the highest-numbered moved point.
    • SmallestMovedPoint(g) for the lowest-numbered moved point.
gap> g:=Group((1,2,3,4), (1,2));
Group([ (1,2,3,4), (1,2) ])
gap> MovedPoints(g);
[ 1, 2, 3, 4 ]
gap> NrMovedPoints(g);
4
gap> LargestMovedPoint(g);
4
gap> SmallestMovedPoint(g);
1
GAP Days Spring 2025 | Ilaria Colazzo | Introduction to GAP |

Why permutation groups are important?

  • Any finite group can be represented as permutations of its own elements.
  • The key idea is that each element of a group defines a permutation by left multiplication.

Cayley’s Theorem. Every finite group is isomorphic to a subgroup of a symmetric group.

GAP Days Spring 2025 | Ilaria Colazzo | Introduction to GAP |

Cyclic groups

  • For let be the (multiplicative) cyclic group of order , i.e. the group of order generated by one element.
  • To construct cyclic groups in GAP, we use CyclicGroup.
  • With no extra arguments, this function returns an abstract presentation of a cyclic group.
gap> CyclicGroup(2);
<pc group of size 2 with 1 generator>
GAP Days Spring 2025 | Ilaria Colazzo | Introduction to GAP |
gap> C3 := CyclicGroup(3);
<pc group of size 3 with 1 generator>
gap> iso := IsomorphismPermGroup(C3);
[ f1 ] -> [ (1,2,3) ]
gap> Image(iso);
Group([ (1,2,3) ])
  • The function IsomorphismPermGroup gives us an isomorphism from to a subgroup of a subgroup of the symmetric group .
  • The function Image gives the image of such isomorphism, i.e. the cyclic group (as permutation group) generated by by the permutation .
GAP Days Spring 2025 | Ilaria Colazzo | Introduction to GAP |
  • We can add an extra argument to the function CyclicGroup to tell GAP which presentation we want.
  • Let us construct the cyclic group of size two as a permutation group and as a matrix group.
gap> CyclicGroup(IsPermGroup, 2);
Group([ (1,2) ])
gap> CyclicGroup(IsMatrixGroup, 2);
Group([ [ [ 0, 1 ], [ 1, 0 ] ] ])
  • A matrix group is a subgroup of the linear group for some .
GAP Days Spring 2025 | Ilaria Colazzo | Introduction to GAP |

Dihedral groups

  • For the dihedral group of order is the group

  • is the group of symmetries of a regular polygon.
                   
GAP Days Spring 2025 | Ilaria Colazzo | Introduction to GAP |
  • To construct dihedral groups we use DihedralGroup.
    • With no extra arguments, the function returns an abstract presentation of a dihedral group.
    • As we did for cyclic groups, we can construct dihedral groups as permutation groups using IsPermGroup.
GAP Days Spring 2025 | Ilaria Colazzo | Introduction to GAP |
  • Let's construct , compute its order and check whether it abelian or not.
gap> D6 := DihedralGroup(6);
<pc group of size 6 with 2 generators>
gap> Order(D6);
6
gap> IsAbelian(D6);
false
  • Now, let's use the filter IsPermGroup to construct the as a permutation group and let's display its elements.
gap> D6 := DihedralGroup(IsPermGroup, 6);
Group([ (1,2,3), (2,3) ])
gap> Elements(D6);
[ (), (2,3), (1,2), (1,2,3), (1,3,2), (1,3) ]
GAP Days Spring 2025 | Ilaria Colazzo | Introduction to GAP |

Symmetric groups and alternating groups

  • To construct the symmetric group we use SymmetricGroup.
  • To construct the alternating group, i.e. the group of even permutation, we use AlternatingGroup.
GAP Days Spring 2025 | Ilaria Colazzo | Introduction to GAP |
  • Let's construct and .
  • We can us in to check if a permutation is an element of a group.
  • Let's use the function SignPerm to compute the sign of such permutations.
gap> S4 := SymmetricGroup(4);;
gap> A4 := AlternatingGroup(4);;
gap> (1,2,4) in S4;
true
gap> (1,2,4) in A4;
true
gap> SignPerm((1,2,4));
1
gap> (1,2,4,3) in S4;
true
gap> (1,2,4,3) in A4;
false
gap> SignPerm((1,2,4,3));
-1
GAP Days Spring 2025 | Ilaria Colazzo | Introduction to GAP |
  • A subgroup of is said to be normal if for all .
  • We can define a subgroup of a group in GAP using Subgroup
  • We can check if a given group is indeed a subgroup using IsSubgroup.
  • GAP can check if a subgroup is normal using the IsNormal function.
  • ⚠️ Caution! The function IsNormal(G, H) checks whether every element in normalises , but it does not check if is actually a subgroup of .
GAP Days Spring 2025 | Ilaria Colazzo | Introduction to GAP |
gap> S4 := SymmetricGroup(4);;
gap> A4 := AlternatingGroup(4);;
gap> IsSubgroup(S4,A4);
true
gap> IsNormal(S4,A4);
true
  • The subgroup of generated by is not normal in .
gap> H:=Group((1,2,3));;
gap> IsSubgroup(S4, H);
true
gap> IsNormal(S4, H);
false
gap> IsNormal(Group((1,2)), A4); # A4 is not a subgroup of Group((1,2))
true
GAP Days Spring 2025 | Ilaria Colazzo | Introduction to GAP |
  • If is normal in , then is a group, called the factor group.
  • If H is a normal subgroup of G we compute the factor group using the function FactorGroup(G,H) or simply typing G/H.
gap> FactorGroup(S4,A4);
Group([ f1 ])
gap> S4/A4;
<pc group with 1 generator>
gap> FactorGroup(S4,A4) = S4/A4;
true
GAP Days Spring 2025 | Ilaria Colazzo | Introduction to GAP |
  • Let us show that in there are two subgroups and such that is normal in , is normal in but is not normal in .
gap> D8 := DihedralGroup(IsPermGroup , 8);;
gap> H := Subgroup(D8 , [(1 ,2 ,3 ,4)^2 ,(2 ,4)]);;
gap> K := Subgroup(D8 , [(2 ,4)]);;
gap> IsSubgroup(H, K);
true
gap> IsNormal(H, K);
true
gap> IsSubgroup(D8, H);
true
gap> IsNormal(D8, H);
true
gap> IsSubgroup(D8, K);
true
gap> IsNormal(D8, K);
false
GAP Days Spring 2025 | Ilaria Colazzo | Introduction to GAP |
  • Let be a permutation group, i.e. is a subgroup of , for some .
  • For each the stabiliser of in is the subgroup of equal to .
  • The orbit of under is the subset .
  • The command Orbit(G,k) will give you the orbit of k under G.
  • The command Stabilizer(G,k) computes the subgroup of G that is the stabiliser of k.
GAP Days Spring 2025 | Ilaria Colazzo | Introduction to GAP |
gap> S8 := SymmetricGroup(8);;
gap> a := (1,2,3);;
gap> b := (7,8);;
gap> G := Subgroup(S8,[a,b]);
Group([ (1,2,3), (7,8) ])
gap> Orbit(G, 1);
[ 1, 2, 3 ]
gap> Orbit(G, 7);
[ 7, 8 ]
gap> Stabilizer(G, 1);
Group([ (7,8) ])
gap> Stabilizer(G, 7);
Group([ (1,2,3) ])
gap> Elements(Stabilizer(G, 7));
[ (), (1,2,3), (1,3,2) ]
  • We used Elements(Stabilizer(G,k)) to see all the elements in the stabiliser.
GAP Days Spring 2025 | Ilaria Colazzo | Introduction to GAP |
  • a group and subgroup of . For any ,
    • the set of left cosets (resp. set of right cosets) is (resp. )
    • The element is called coset representative of (resp. ).
  • We use (resp. ) to denote the number of elements in the set (resp. ).
  • We use RightCosets(G,H) to compute the list (set) of right cosets.
gap> S7 := SymmetricGroup(7);;
gap> A7 := AlternatingGroup(7);;
gap> RightCosets(S7,A7);
[ RightCoset(Alt( [ 1 .. 7 ] ),()), RightCoset(Alt( [ 1 .. 7 ] ),(6,7)) ]
GAP Days Spring 2025 | Ilaria Colazzo | Introduction to GAP |

Lagrange’s Theorem

Theorem. If is a finite group and is a subgroup of , then divides .
Moreover, the number of distinct left (right) cosets of in is .

  • Note that if is a normal subgroup of , is the order of the factor group .

  • Let's test the theorem for and .

gap> Order(S7)/Order(A7) = Size(RightCosets(S7,A7));
true
  • ⚠️ However, the converse is not true! In the tutorial session we will use GAP to find some counterexamples.
GAP Days Spring 2025 | Ilaria Colazzo | Introduction to GAP |
  • The centre of a group is the set of elements that commute with every element of . That is,

  • The centre is always a normal subgroup.

  • In GAP to compute the centre of a group we use Center.

gap> D6 := DihedralGroup(IsPermGroup, 12);;
gap> ZD6 := Center(D6);
Group([ (1,4)(2,5)(3,6) ])
gap> IsNormal(D6,ZD6);
true
GAP Days Spring 2025 | Ilaria Colazzo | Introduction to GAP |
  • Now let's use GAP to investigate the factor group .
gap> D6modZD6 := FactorGroup(D6, ZD6);
Group([ f1, f2 ])
gap> RightCosets(D6,ZD6);
[ RightCoset(Group([ (1,4)(2,5)(3,6) ]),()), RightCoset(Group(
   [ (1,4)(2,5)(3,6) ]),(2,6)(3,5)), RightCoset(Group([ (1,4)(2,5)(3,6) ]),
   (1,5,3)(2,6,4)), RightCoset(Group([ (1,4)(2,5)(3,6) ]),(1,5)(2,4)),
  RightCoset(Group([ (1,4)(2,5)(3,6) ]),(1,3,5)(2,4,6)), RightCoset(Group(
   [ (1,4)(2,5)(3,6) ]),(1,3)(4,6)) ]
gap> Size(last);
6
  • is a group of order 6.
  • Which one?
GAP Days Spring 2025 | Ilaria Colazzo | Introduction to GAP |
gap> IsAbelian(D6modZD6);
false
  • is not abelian, so cannot be isomorphic to the cyclic group.
  • Do we know another group of order ? The symmetric group .
gap> ordersS3 := List(Elements(S3), Order);;
gap> ordersD6modZD6 := List(Elements(S3), Order);;
gap> Collected(ordersS3);
[ [ 1, 1 ], [ 2, 3 ], [ 3, 2 ] ]
gap> Collected(ordersD6modZD6);
[ [ 1, 1 ], [ 2, 3 ], [ 3, 2 ] ]
  • Here the functionCollected returns a new list containing for each element k in the list, a list of length two [k, numberk], where numberk is the number of times k appears in the list.
GAP Days Spring 2025 | Ilaria Colazzo | Introduction to GAP |
  • So and are non-abelian groups of order with the same number of elements for each order.
  • Two groups that are isomorphic must have the same number of elements of each order.
  • ⚠️ The converse of this statement is false.
  • In this case is enough because there are only groups of order . We can use NrSmallGroups in the library SmallGroup to check the number (up to isomorphism) of groups of a given order.
gap> NrSmallGroups(6);
2
GAP Days Spring 2025 | Ilaria Colazzo | Introduction to GAP |
  • The derived subgroup (or commutator subgroup) of a group is the subgroup
    generated by all commutators for .
  • We can compute the derived subgroup using DerivedSubgroup(G).
gap> D12 := DihedralGroup(IsPermGroup, 6);;
gap> D12D12 := DerivedSubgroup(D12);
Group([ (1,3,2) ])
  • The derived subgroup is important since it is the smallest subgroup that we can factor out to get an abelian group.
  • Such factor group is called the abelianisation of the group.
GAP Days Spring 2025 | Ilaria Colazzo | Introduction to GAP |
gap>  IsAbelian(GL2modD);
true
gap> ns:=NormalSubgroups(D12);;
gap> List(ns, sb -> IsAbelian(D12/sb));
[ true, true, false ]
gap> List(ns, Order);
[ 6, 3, 1 ]
gap> D6D6 = ns[2];
true
GAP Days Spring 2025 | Ilaria Colazzo | Introduction to GAP |
  • A group is perfect if it equals its own commutator subgroup, or equivalently, if the group has no non-trivial abelian quotients.
  • Let's use the function AllSmallGroups to find the smallest perfect group.
gap> n:=1;;
gap> found := false;;
gap> while found = false do
>   for g in AllSmallGroups(n) do
>      if Order(g) = Order(DerivedSubgroup(g)) then
>         found := true;
>         break;
>      fi;
>    od;
>    n:=n+1;
> od;
gap> Print(StructureDescription(g));
A5
GAP Days Spring 2025 | Ilaria Colazzo | Introduction to GAP |
  • In the definition of derived subgroup we consider the group generated by commutators.
  • Ore's conjecture: "If is a finite non-abelian simple group, then every element of is a commutator".
  • Liebeck, O’Brien, Shalev, and Tiep proved Ore's conjecture in 2010.

    🔖 Liebeck, M. W., O’Brien, E. A., Shalev, A., & Tiep, P. H. (2010). The Ore Conjecture. Journal of the European Mathematical Society, 12(4), 939–1008.

  • What about other perfect groups?
  • We can use GAP to make some experiment.
  • We need the functionCommutatorLength which returns the minimal such that each element in the derived subgroup can be written as a product of commutators.
GAP Days Spring 2025 | Ilaria Colazzo | Introduction to GAP |
  • If we find a perfect group such that this is greater than one we have our counterexample.
gap> n:=1;;
gap> found := false;;
gap> while found = false do
>   n:=n+1;
>   if NrPerfectGroups(n)>=1 then
>      for i in [1..NrPerfectGroups(n)] do
>         g:=PerfectGroup(n, i);
>         if CommutatorLength(g) > 1 then
>            found := true;
>            break;
>         fi;
>       od;
>   fi;
> od;
gap> Print(n, " ", i);
960 2
GAP Days Spring 2025 | Ilaria Colazzo | Introduction to GAP |
  • We can modify the previous code to look for the smallest example among all groups.
gap> n:=1;;
gap> found := false;;
gap> n:=n+1;
2
gap> while found = false do
>   n:=n+1;
>     for g in AllSmallGroups(n) do
>       if CommutatorLength(g) > 1 then
>          found := true;
>          break;
>       fi;
>     od;
> od;
gap> Print(IdSmallGroup(g));
[ 96, 3 ]
GAP Days Spring 2025 | Ilaria Colazzo | Introduction to GAP |
  • The fist example of a group in which not all elements of the derived subgroup are commutator is in Carmichael's book.

🔖 Carmichael, R. D. Introduction to the Theory of Groups of Finite Order. New York: Dover Publications, 1956.

  • Carmichael's example is a subgroup of generated by the following permutations:

  • Is true that this is the example we found?
  • Is it the same example?
  • Clearly no since the order of that Carmichael's group is .
GAP Days Spring 2025 | Ilaria Colazzo | Introduction to GAP |
  • We can modify our code to find an example of order .
gap> for g in AllSmallGroups(256) do
>       if CommutatorLength(g) > 1 then
>          found := true;
>          break;
>       fi;
>     od;
gap> Print(IdSmallGroup(g));
[ 256, 23 ]
  • Now is SmallGroup(256, 23) the same example?
GAP Days Spring 2025 | Ilaria Colazzo | Introduction to GAP |

Isomorphisms

  • To study isomorphisms between finite groups one uses IsomorphismGroups.
  • This function returns fail if the groups are not isomorphic, or some isomorphism
    otherwise.
gap> S3 := SymmetricGroup(3);;
gap> C6 := CyclicGroup(6);;
gap> D6:= DihedralGroup(6);;
gap> IsomorphismGroups(S3, C6);
fail
gap> IsomorphismGroups(S3, D6);
[ (1,2,3), (1,2) ] -> [ f2, f1*f2 ]
GAP Days Spring 2025 | Ilaria Colazzo | Introduction to GAP |
  • We can write an easy function to test isomorphism.
gap> AreIsomorphic := function(g,h)
> return not IsomorphismGroups(g,h) = fail;
> end;
function( g, h ) ... end
gap> AreIsomorphic(S3, C6);
false
gap> AreIsomorphic(S3, D6);
true
GAP Days Spring 2025 | Ilaria Colazzo | Introduction to GAP |
  • We can use the function AreIsomorphic to test if SmallGroup(256,23) is indeed Carmichael's example.
  • Let's implement the group in GAP
a := (1 ,3)(2 ,4);;
b := (5 ,7)(6 ,8);;
c := (9 ,11)(10 ,12);;
d := (13 ,15)(14 ,16);;
e := (1 ,3)(5 ,7)(9 ,11);;
f := (1 ,2)(3 ,4)(13 ,15);;
g := (5 ,6)(7 ,8)(13 ,14)(15 ,16);;
h := (9 ,10)(11 ,12);;
CarEx := Group ([ a ,b ,c ,d ,e ,f ,g , h ]);;
GAP Days Spring 2025 | Ilaria Colazzo | Introduction to GAP |
  • Now check the isomorphism
gap> AreIsomorphic(SmallGroup(256,23), CarEx);
false
  • These means that there is more than one group of order such that there are elements in the derived subgroup that are not commutators.

Exercise.

  1. Can you modify th code to produce all groups of order such that there are elements in the derived subgroup that are not commutators.
  2. Which one is Carmichael's example?
GAP Days Spring 2025 | Ilaria Colazzo | Introduction to GAP |

📌 Key Commands (1) 📌

  • Group([gens]) – group via generators.
  • SymmetricGroup(n) - Symmetric group on elements.
  • AlternatingGroup(n) – Alternating group on .
  • CyclicGroup(n) – Cyclic group of order .
  • DihedralGroup(n) – Dihedral group of order .
  • IsomorphismPermGroup(G) – Isomorphism from group to a permutation group.
  • Subgroup(G, [gens]) – Creates a subgroup.
  • IsSubgroup(G, H) – Checks if is a subgroup of .
  • IsNormal(G, H) – Checks if H is a normal subgroup of G.
GAP Days Spring 2025 | Ilaria Colazzo | Introduction to GAP |

📌 Key Commands (2) 📌

  • FactorGroup(G, H) or G/H – Constructs the factor group.
  • Center(G) – Returns the centre of , .
  • RightCosets(G, H) – List of right cosets of in .
  • Orbit(G, k) – Orbit of point under group .
  • Stabilizer(G, k) – Subgroup fixing .
  • MovedPoints(G) – List of points moved by the group.
  • NrMovedPoints(G) – Number of moved points.
  • LargestMovedPoint(G), SmallestMovedPoint(G) – Extremes of moved points.
  • Collected(List) – Counts frequency of each unique item.
GAP Days Spring 2025 | Ilaria Colazzo | Introduction to GAP |

Thanks!

GAP Days Spring 2025 | Ilaria Colazzo | Introduction to GAP |