# Generating $p$-groups

The $p$-central series of a group $G$ is the descending sequence of subgroups

$$
G= P_{0}(G) \geq \ldots \geq  P_{i-1}(G) \geq P_i(G) \geq \ldots \geq
$$

where $P_i(G)=[P_{i-1}(G),G]P_{i-1}(G)^p$ for $i\geq 1$.

If $P_c(G)=1$ and $c$ is the smallest such integer then $G$ has $p$*-class* $c$. A group with $p$-class $c$ is nilpotent and has nilpotency class at most $c$.

Let $G$ be a finite $p$-group with Frattini rank $d$ and class $c$. A group $H$ is a *descendant* of $G$ if $H$ has Frattini rank $d$ and the quotient $H/P_c(H)$ is isomorphic to $G$. A group is an *immediate descendant* of $G$ if it is a descendant of $G$ and has class $c+1$.

The $p$-group generation algorithm allows the construction of (immediate) descendants of a $p$-group. For a description of this algorithm, see [[Newman, 1977](../../references.md#cite-newman-pgrp-gen), [O'Brien, 1990](../../references.md#cite-obrien-pgroup)].

`SetVerbose ("GeneratepGroups", 1)` will provide information on the progress of the algorithm.

## `GeneratepGroups(p, d, c : parameters): RngIntElt, RngIntElt, RngIntElt -> [GrpPC], RngIntElt`

```magma
Exponent  : RngIntElt                      Default: 0
OrderBound: RngIntElt                      Default: 0
StepSizes : [RngIntElt]                    Default: []
All       : BoolElt                        Default: true
```

Generate all $d$-generator $p$-class at most $c$ $p$-groups.

All groups constructed satisfy the supplied exponent.

Given `OrderBound := n`, all groups constructed have order at most $p^n$.

Construct descendants of order $p^{(n + s)}$ of a group of order $p^n$ only for $s$ in `StepSizes`.

If `true`, return all groups. Otherwise, return only the capable groups (those which have descendants).

## `Descendants(G : parameters): GrpPC -> [GrpPC], RngIntElt`

## `Descendants(G, c : parameters): GrpPC, RngIntElt -> [GrpPC], RngIntElt`

Construct descendants of $G$ having $p$-class at most $c$; if $c$ is not supplied, it is assumed to be one larger than the $p$-class of $G$. This function supports the same variable arguments as `GeneratepGroups`.

## `Example: Generating P Groups (ex-3d4202)`

```magma
> G := DihedralGroup(GrpPC, 16);
> T := Descendants (G, 8);
> #T;
12
> H := T[5];
> H;
GrpPC : H of order 128 = 2^7
PC-Relations:
    H.1^2 = H.7,
    H.2^2 = H.3 * H.4,
    H.3^2 = H.4 * H.5,
    H.4^2 = H.5 * H.6,
    H.5^2 = H.6 * H.7,
    H.6^2 = H.7,
    H.2^H.1 = H.2 * H.3,
    H.3^H.1 = H.3 * H.4,
    H.4^H.1 = H.4 * H.5,
    H.5^H.1 = H.5 * H.6,
    H.6^H.1 = H.6 * H.7

```

## `Example: Generatep Groups (ex-e130f7)`

What is the soluble length of a 2-generator group of exponent 4? We construct the 2-generator 2-groups having exponent 4.

```magma
> T := GeneratepGroups(2, 2, 10: Exponent := 4);
> "The number of 2-generator exponent 4 groups is ", # T;
The number of 2-generator exponent 4 groups is  26

```

What are their soluble lengths?

```magma
> for i := 1 to #T do
>       "Group ", i, " has soluble length ", DerivedLength (T[i]);
> end for;
Group  1  has soluble length  1
Group  2  has soluble length  2
Group  3  has soluble length  2
Group  4  has soluble length  1
Group  5  has soluble length  2
Group  6  has soluble length  2
Group  7  has soluble length  2
Group  8  has soluble length  2
Group  9  has soluble length  2
Group  10  has soluble length  2
Group  11  has soluble length  2
Group  12  has soluble length  2
Group  13  has soluble length  2
Group  14  has soluble length  2
Group  15  has soluble length  2
Group  16  has soluble length  2
Group  17  has soluble length  2
Group  18  has soluble length  2
Group  19  has soluble length  2
Group  20  has soluble length  2
Group  21  has soluble length  3
Group  22  has soluble length  3
Group  23  has soluble length  3
Group  24  has soluble length  3
Group  25  has soluble length  3
Group  26  has soluble length  3

```

## `Example: Is Good (ex-4efc58)`

Can we find all 2-generator 3-groups of abundance zero? Such groups have order at most $3^5$. First, we define a function which checks the number of conjugacy classes of a group (to determine abundance).

```magma
> IsGoodGroup := function(G, k)
>
>    ncl := # Classes(G);
>
>    O := FactoredOrder(G);
>    p := O[1][1];
>    m := O[1][2];
>    n := Floor(m / 2);
>    e := m - n * 2;
>    Desired := n * (p^2 - 1) + p^e + k * (p - 1) * (p^2 - 1);
>
>    return (Desired eq ncl);
>
> end function;

```

Then, we generate the potential candidates and check each.

```magma
> a := GeneratepGroups (3, 2, 4 : OrderBound := 5);
> #a;
42
>
> for i := 1 to #a do
>        G := a[i];
>        if IsGoodGroup(G, 0) then
>           "Group ", i, " of order ", Order(G), " has abundance 0";
>        end if;
> end for;
Group  1  of order  9  has abundance 0
Group  3  of order  27  has abundance 0
Group  4  of order  27  has abundance 0
Group  11  of order  81  has abundance 0
Group  12  of order  81  has abundance 0
Group  13  of order  81  has abundance 0
Group  14  of order  81  has abundance 0
Group  40  of order  243  has abundance 0
Group  41  of order  243  has abundance 0
Group  42  of order  243  has abundance 0

```

## `ClassTwo(p, d : parameters): RngIntElt, RngIntElt -> SeqEnum`

## `ClassTwo(p, d, Step : parameters): RngIntElt, RngIntElt, SeqEnum -> SeqEnum`

## `ClassTwo(p, d, s : parameters): RngIntElt, RngIntElt, RngIntElt -> RngIntElt`

```magma
Exponent: RngIntElt                    Default: 0
```

Count the $d$-generator $p$-groups of $p$-class 2. If $s$ or $Step$ is supplied, then count only those of order $p^{(d + s)}$ or $p^{(d + m)}$ for $m \in Step$. In the first two invocations, the sequence returns a sequence of length $d \choose 2$, whose $m$-th entry is the number of groups of $p^{(d + m)}$. (Some additional entries may be deduced on the basis of duality.) The last invocation returns the number of groups of $p^{(d + s)}$. For details of the algorithm used see [[Eick and O'Brien, 1999](../../references.md#cite-eo-enum)].

If `Exponent` is `true`, count those groups which have exponent $p$. The directive `SetVerbose ("ClassTwo", 1)` will provide information on the progress of the algorithm.

## `Example: Class Two (ex-6ce143)`

Count the number of 3-generator p-class 2 5-groups.

```magma
> ClassTwo(5, 3);
[ 4, 19, 42, 19, 4, 1 ]

```

For example, the number of 3-generator 5-groups of order $5^6$ and $p$-class 2 is precisely 42.

Count the number of 4-generator $p$-class 2 5-groups of order $5^7$.

```magma
> ClassTwo(5, 4, 3);
6598

```
