Help:Using GAP

This article is about how to use GAP (Groups, Algorithms and Programming) for computations involving groups, particularly finite groups.

Starting GAP
GAP runs best in a terminal/command line environment. On a UNIX machine where gap is installed, it can be run from the commandline with the command:

gap

This command opens GAP in interpreter mode.

Giving commands and assigning values
GAP embodies principles both of declarative programming and of imperative programming. A command in GAP could be an instruction to do something, but typically, it is just an assignment of a value.

Every GAP command produces an output value, which is displayed on the screen after the command is executed. In addition, a command can introduce new variables that can be used in future commands. For instance, consider the command:

CyclicGroup(23);

The sole effect of this command is to output the cyclic group of order 23. The group isn't output as a multiplication table; rather a somewhat cryiptic description is given.

The command:

G := CyclicGroup(23);

outputs the cyclic group of order 23, and also stores the information that $$G$$ equals this group. Thus, we can later use $$G$$ in place of writing the full expression.

$$G$$ in this case is a variable.

Auto-completion
If you are unsure of the spelling of a command, pressing "Tab" on a UNIX environment gives a list of possible completions. The first time you press the key, the command will be completed to whatever further number of letters are uniquely determined. The next time you press the tab key, a list of possible further completions is shown.

Functions are case-sensitive.

Invoking functions
GAP has a number of in-built functions, and one can invoke these functions by providing the parameters to the function in parentheses. For instance, consider the pair of lines:

G := DirectProduct(CyclicGroup(23), CyclicGroup(21)); IsAbelian(G);

The first line here assigns, to the variable $$G$$, the value which is the direct product of the cyclic groups of order 23 and 21. The output here is $$G$$ itself. The second line takes as input the group $$G$$, and outputs whether or not it is Abelian. The output here is either true or false (in this case, it's true).

Finite groups are stored as permutations
Finite groups are stored as subgroups of permutation groups. Most importantly, the same finite group could be stored in any number of different ways. Thus, if we define:

G := CyclicGroup(6); H := DirectProduct(CyclicGroup(2),CyclicGroup(3)); G = H;

Then the final answer is false. The groups are not equal, because their internal representations are not equal. To check whether the groups are isomorphic, the correct command is:

IsomorphismGroups(G,H);

This constructs an isomorphism if there exists one, and otherwise returns "false".

To define a finite group, one can usually describe it as a permutation group. For instance, suppose I want to define the group generated by the permutations:

$$(1,2,3)(4,5)$$

and:

$$(3,4,5,6,7)$$

Then the command is:

G := Group((1,2,3)(4,5), (3,4,5,6,7));

Construction techniques for finite groups
A permutation representation could be pretty unwieldy for finite groups, so there are many alternative commands to define finite groups that occur in practice. Some of these include:


 * CyclicGroup takes a positive integer parameter and constructs a cyclic group with that order
 * GL takes two parameters as input, and outputs the corresponding general linear group. For instance:

GL(2,3);

outputs the general linear group on the field of three elements, of order two.
 * Similar commands exist for special linear groups, orthogonal groups, unitary groups.
 * Commands like DirectProduct, SemidirectProduct, can be used to construct bigger groups from smaller ones.

Group Ids for finite groups
For finite groups of order upto 1000, there is a complete list of Group Ids. This is part of the "Small Groups" project. Commands related to this are:


 * IdGroup takes as input a finite group and outputs its Group Id. The Group Id is an ordered pair of integers. The first integer is the size of the group, and the second is its ID among groups of that size (the IDs are determined by a procedure).
 * SmallGroup takes as input two numbers and outputs a group with that pair as its Group Id.
 * AllSmallGroups takes one parameter and returns the list of all finite groups with that order. The list is in the order of Group Ids.

Testing properties
GAP has in-built commands for testing properties, that can be checked out at:

Category:GAP-testable properties


 * For testing group properties: The command is usually of the form IsCommandName and takes as input the group for which the property is being tested. For instance:

IsAbelian(G)

returns "true" if $$G$$ is an Abelian group and "false" if $$G$$ is a non-Abelian group.


 * For testing subgroup properties: The command is usually of the form IsCommandName and takes as input the pair of the group and the subgroup. For instance, we have:

IsNormalSubgroup(G,H)

returns "true" if $$H$$ is a normal subgroup of $$G$$ and "false" otherwise. Note that when $$H$$ is not a subgroup of $$G$$ it may still return "true" for other reasons (i.e. that $$G$$ normalizes $$H$$ inside whatever huge permutation group they're secretly embedded in).

Listing all groups/subgroups with a particular property
We can use a property test to filter out a list of groups, and return only those groups satisfying the property. For instance, suppose we need to determine all nilpotent groups of a particular order $$n$$. The command for that is:

Filtered(AllSmallGroups(n),IsNilpotent)

this filters the list of all groups of order $$n$$, against the criterion of being nilpotent.

Most finite groups have a lot of subgroups, so it is sometimes helpful to list only one representative of each conjugacy class. The following command creates a list of one representative of each conjugacy class.

List(ConjugacyClassesSubgroups(G),Representative)

This applies the Representative function to the list of conjugacy classes of subgroups of $$G$$. We can then filter this list based on whatever property we are interested in. For instance:

Filtered(List(ConjugacyClassesSubgroups(G),Representative),IsSubnormal)

filters out the list of all representatives of conjugacy classes of subgroups to return only the subnormal subgroups.

Listing conjugate subgroups
The command:

ConjugateSubgroups(G,H)

returns the list of all conjugate subgroups to $$H$$ in $$G$$.

Conjugation and automorphism
GAP uses right exponentiation for conjugation and for automorphisms. If $$G$$ is a group and $$a$$ is an automorphism of $$G$$, we write $$g^a$$ for the effect of $$a$$ on $$g$$. Actions are assumed to be on the right.