# 37.8 The 2-Groups Library

The library of 2-groups contains all the 2-groups of size dividing 256. There are a total of 58760 such groups, 1 of size 2, 2 of size 4, 5 of size 8, 14 of size 16, 51 of size 32, 267 of size 64, 2328 of size 128, and 56092 of size 256.

`AllTwoGroups( fun1, val1, fun2, val2, ... )`

`AllTwoGroups` returns the list of all the 2-groups that have the properties given as arguments. Each property is specified by passing a pair of arguments, the first is a function that can be applied to each group, the second is either a single value or a list of values that the function must return in order to select that group.

```    gap> l := AllTwoGroups( Size, 256, Rank, 3, pClass, 2 );
[ Group( a1, a2, a3, a4, a5, a6, a7, a8 ),
Group( a1, a2, a3, a4, a5, a6, a7, a8 ),
Group( a1, a2, a3, a4, a5, a6, a7, a8 ),
Group( a1, a2, a3, a4, a5, a6, a7, a8 ) ]
gap> List( l, g -> Length( ConjugacyClasses( g ) ) );
[ 112, 88, 88, 88 ] ```

`OneTwoGroup( fun1, val1, fun2, val2, ... )`

`OneTwoGroup` returns a single 2-group that has the properties given as arguments. Each property is specified by passing a pair of arguments, the first is a function that can be applied to each group, the second is either a single value or a list of values that the function must return in order to select that group.

```    gap> g := OneTwoGroup( Size, [64..128], Rank, [2..3], pClass, 5 );
#I  size restricted to [ 64, 128 ]
Group( a1, a2, a3, a4, a5, a6 )
gap> Size( g );
64
gap> Rank( g );
2 ```

`AllTwoGroups` and `OneTwoGroup` recognize the following functions and handle them usually very efficiently. `Size`, `Rank` for the rank of the Frattini quotient of the group, and `pClass` for the exponent-p class of the group. Note that `Rank` and `pClass` are dummy functions that can be used only in this context, i.e., they can not be applied to arbitrary groups.

`TwoGroup( size, nr )`

`TwoGroup` returns the nr-th group of size size. The group is returned as a finite polycyclic group (see Finite Polycyclic Groups). `TwoGroup` will signal an error if size is not a power of 2 between 2 and 256, or nr is larger than the number of groups of size size.

Within each size the following criteria have been used, in turn, to determine the index position of a group in the list

1:
increasing generator number;

2:
increasing exponent-2 class;

3:
the position of its parent in the list of groups of appropriate size;

4:
the list in which the Newman and O'Brien implementation of the p-group generation algorithm outputs the immediate descendants of a group.

```    gap> g := TwoGroup( 32, 45 );
Group( a1, a2, a3, a4, a5 )
gap> Rank( g );
4
gap> pClass( g );
2
gap> g.abstractRelators;
[ a1^2*a5^-1, a2^2, a2^-1*a1^-1*a2*a1, a3^2, a3^-1*a1^-1*a3*a1,
a3^-1*a2^-1*a3*a2, a4^2, a4^-1*a1^-1*a4*a1, a4^-1*a2^-1*a4*a2,
a4^-1*a3^-1*a4*a3, a5^2, a5^-1*a1^-1*a5*a1, a5^-1*a2^-1*a5*a2,
a5^-1*a3^-1*a5*a3, a5^-1*a4^-1*a5*a4 ] ```

Apart from the usual components described in Group Records, the group records returned by the above functions have the following components.

`rank`:

rank of Frattini quotient of G.

`pclass`:

exponent-p class of G.

`abstractGenerators`:

a list of abstract generators of G (see AbstractGenerator).

`abstractRelators`:

a list of relators of G stored as words in the abstract generators.

Descriptions of the algorithms used in constructing the library data may be found in citeOBr90,OBr91. Using these techniques, a library was first prepared in 1987 by M.F.~Newman and E.A.~O'Brien; a partial description may be found in NO89.

The library was brought into the GAP format by Werner Nickel, Alice Niemeyer, and E.A.~O'Brien.

GAP 3.4.4
April 1997