Hot to Use GAP



0. Preliminary
1. Install
2. Launch and Quit
3. Basics
4. Read and Write
5. Notation
6. Group operations
7. Examples


0. Preliminary

GAP is a program for computer group theory. Another useful reference is ATLAS.

1. Install

Download the file and follow the instruction together with README. Alternatively, one can use the GAP interface in SageMath.

2. Launch and Quit

Open Terminal, go to the GAP folder and type

./gap

or

sh bin/gap.sh

Note that, even thought SHELL knows the path to GAP, one cannot launch it ourside its main folder (at least in OSX). To finish the session, type

gap> quit;

3. Basics

  • A sentence must finish with ";", and a line can contain several sentences. The line is evaluated immediately by typing RETURN.
  • No output is displayed for the sentence ending with ";;".
  • GAP neglects spaces, RETURN without ";", and all words after "#".
  • GAP is sensitive to upper and lower cases.
  • To show manual, type e.g. gap> ?Gcd
  • To complement a command, type TAB once or twice.
  • To recycle the last output, use "last" as in Print(last);
  • All calculation of GAP is exact. No decimals can be used.

4. Read and Write

It is not possible to call GAP from an external program such as Mathematica; see the discussion here. An alternative option is to use GAP inside SageMath, but you may need to rewrite the code. Therefore, in order to run the GAP code as it is, one must always launch GAP from Terminal (in OSX).

Reading: To read the file stored in "./prog/code.txt", type

Read("filename");

Note that Read() returns no output. No results will be displayed.
If one wants to read the content without evaluating it, type

Exec("cat filename");

Writing: There are a few ways to write out the results. The first way is to type

PrintTo("filename", ...);
AppendTo("filename", ...);

Note that PrintTo() deletes the existing contents. The second way is to type

LogTo("filename");
LogTo();

This command writes out all standard outputs between two LogTo()'s. Note that Read() generates no standard output, so LogTo() gives nothing. If you want to distinguish the input and output of GAP, type

InputLogTo("filename");
OutputLogTo("filename");

5. Notation

Some some algebraic numbers can be used, such as

  • ER(x); square-root of x
  • E(n); n-th root of unity
  • CF(n); cyclotomic fields, i.e. E(n) with rational coefficients

[1..10] means the list of integers from 1 to 10. [2,4,..10] means even integers from 2 to 10.

One gets the element of a list L by L[2].

One gets the generator of a finitely presented group G by G.1. More generally, one gets the member of a record in this way,

    gap> r:=rec(a:=1,b:=2);
    gap> r.a;
    gap> r.("a");

See Accessing Record Elements for details.

In GAP, a Set (or a proper set) is a sorted list without empty elements or duplicates. The Set is useful for complicated operations. However, sometimes GAP does not check if the data in Set is indeed a proper set. If ambiguous, one should apply IsSet().

6. Group operations

A permutation is defined by lists of numbers inside round brackets, or by PermList(),

c := (2,3)(4,5);
c := PermList([1,3,2,5,4]);

We can apply a permutation to a list by Permuted(),

gap> Permuted([1..6],c);
[1,3,2,5,4,6]

We can define a symmetric group by specifying a list of generators or by name,

s6 := Group( (1,2,3,4,5,6), (1,2) );
s6 := SymmetricGroup(6);

We can obtain the generators of this group by

a := s6.1;
b := s6.2;
GeneratorsOfGroup(s6);

Note that symmetric group has only two generators, so s6.3 returns an error. We can obtain all the group elements by

Elements(s6);

We can define group multiplication in several ways. The left (or right) action is denoted by x*y,

gap> a*b;
(2,3,4,5,6)
gap> b*a;
(1,3,4,5,6)

The permutation acts on a list by

gap> OnTuples([1..6], (1,2,3,4,5,6));
[2,3,4,5,6,1]
gap> Permuted([1..6], (1,2,3,4,5,6)^-1);
[2,3,4,5,6,1]
gap> PermList(Permuted([1..6], (1,2,3,4,5,6)^-1));
(1,2,3,4,5,6)

The product permutation acts by (x*y).list = y.(x.list), whichever OnTuples() or Permuted() is used.

gap> OnTuples([1..6], (1,2)*(1,2,3,4,5,6));
[3,2,4,5,6,1]
gap> OnTuples(OnTuples([1..6], (1,2)),(1,2,3,4,5,6));
[3,2,4,5,6,1]
gap> PermList(last);
(1,3,4,5,6)
gap> Permuted([1..6], (1,2)*(1,2,3,4,5,6));
[6,2,1,3,4,5]
gap> Permuted(Permuted([1..6], (1,2)), (1,2,3,4,5,6));
[6,2,1,3,4,5]
gap> PermList(last);
(1,6,5,4,3)

The adjoint action is denoted by y^x = x-1*y*x,

gap> a^b;
(1,3,4,5,6,2)
gap> b^a;
(2,3)
gap> a^-1*b*a;
(2,3)

GAP can deal with various properties of a group. However, it is not so useful for studying the properties of two groups G and H. If G is a symmetric group of order n, one can replace G by a list of n numbers, and use GAP functions for H.

7. Examples

Some GAP codes are found here. Also SsgeMath has implemented Group Algebra.