# Cohomology and Extensions

## Cohomology

The facilities developed for group cohomology are described at length in Chapter [Cohomology and Extensions](../../FiniteGroups/CohomologyAndExtensions/index-cohomology-and-extensions.md#grpcohom-main). In this section descriptions of some basic intrinsics are repeated for convenience.

### `CohomologyModule(G, M): GrpPerm, ModGrp -> ModCoho`

### `CohomologyModule(G, M): GrpPC, ModGrp -> ModCoho`

Given a finite group $G$ and a $K[G]$-module $M$, where $K$ is a finite field, this intrinsic returns a *cohomology module* for the action of $G$. The group $G$ may be a finite permutation group, a finite matrix group, a conditioned PC-group, or any finitely presented group. Much of the Magma cohomology machinery requires a cohomology module to be defined in order to compute cohomology groups etc.

### `CohomologyGroup(CM, n): ModCoho, RngIntElt -> ModTupRng`

Given a cohomology module $CM$ for the group $G$ acting on the module $M$ and a non-negative integer $n$ taking one of the values $0$, $1$ or $2$, this function returns the cohomology group $H^n(G,M)$.

### `CohomologicalDimension(CM, n): ModCoho, RngIntElt -> RngIntElt`

Given a cohomology module $CM$ for the group $G$ acting on the module $M$ defined over a finite field $K$ and a non-negative integer $n$ taking one of the values $0$, $1$ or $2$, this function returns the dimension of $H^n(G,M)$ over $K$. Note that this function may only be applied to the module returned by a call to `CohomologyModule(G, M)`, where $M$ is a module over a finite field $K$. When $n = 2$, this function is faster and may be applied to much larger examples than `CohomologyGroup(CM, n)` but, unlike that function, it does not enable the user to compute with explicit extensions and two-cocycles.

### `CohomologicalDimension(M, n): ModGrp, n -> RngIntElt`

For $K[G]$-module $M$ (with $K$ a finite field and $G$ a finite group), compute and return the $K$-dimension of the cohomology group $H^n(G,M)$ for $n \ge 0$. For $n=0$ and 1, this is carried out by using the functions described in Chapter [Cohomology and Extensions](../../FiniteGroups/CohomologyAndExtensions/index-cohomology-and-extensions.md#grpcohom-main). For $n \ge 2$, it is done recursively using projective covers and dimension shifting to reduce to the case $n=1$. (In particular, for $n=2$, the method is different from that employed by the corresponding function for a cohomology module described in Chapter [Cohomology and Extensions](../../FiniteGroups/CohomologyAndExtensions/index-cohomology-and-extensions.md#grpcohom-main).)

### `CohomologicalDimensions(M, n): ModGrp, n -> RngIntElt`

For $K[G]$-module $M$ (with $K$ a finite field and $G$ a finite group), compute and return the sequence of $K$-dimensions of the cohomology groups $H^k(G,M)$ for $1 \le k \le n$. On account of the recursive method used, this is quicker than computing them individually.

### `Example: Cohomology Group (ex-047dc8)`

The simple group PSL$(3, 3)$ has an absolutely irreducible module of degree $7$ over GF$(3)$. We will compute its first and second cohomology groups.

```magma
> G := PSL(3, 3);
> Irrs := AbsolutelyIrreducibleModules(G, GF(3));
> M := Irrs[6];
> M;
GModule of dimension 7 over GF(3)
> CM := CohomologyModule(G, M);

> CohomologyGroup(CM, 1);
Full Vector space of degree 1 over GF(3)

> CohomologyGroup(CM, 2);
Full Vector space of degree 2 over GF(3)

```

All other absolutely irreducible modules for PSL$(3, 3)$ over GF$(3)$ have trivial first and second cohomology groups.

### `Example: Cohomological Dimension (ex-68a11a)`

We compute the cohomology of the irreducible modules for Alt(8) over the field of order 2 computed in the previous example.

```magma
> G := Alt(8);
> K := GF(2);
> irr :=  IrreducibleModules(G, K);
> time [ CohomologicalDimension(I, 1) : I in irr ];
[ 0, 0, 0, 1, 1, 1, 1, 0 ]
Time: 0.000
> time [ CohomologicalDimension(I, 2) : I in irr ];
[ 1, 1, 1, 0, 2, 0, 0, 0 ]
Time: 0.100
> time [ CohomologicalDimension(I, 3) : I in irr ];
[ 2, 1, 1, 1, 1, 1, 1, 0 ]
Time: 2.400
> time [ CohomologicalDimension(I, 4) : I in irr ];
[ 2, 1, 1, 2, 3, 2, 2, 0 ]
Time: 11.730
> time CohomologicalDimensions(irr[1], 6);
[ 0, 1, 2, 2, 3, 6 ]
Time: 14.240

```

## Extensions of Modules

For $K[G]$-modules $M$ and $N$ where $K$ is a finite field, the $K$-vector Ext$(M,N)$ of equivalence classes of $K[G]$-module extensions

$$
0 \rightarrow N \rightarrow L \rightarrow M \rightarrow 0
$$

of $N$ by $M$ can be computed, and the corresponding extensions $L$ constructed.

### `Ext(M, N): ModGrp, ModGrp -> ModTupFld`

Given $K[G]$-modules $M$ and $N$ where $K$ is a finite field, construct the $K$-vector space Ext$(M,N)$ of equivalence classes of $K[G]$-module extensions of $N$ by $M$.

### `Extension(M, N, e, r): ModGrp, ModGrp, ModTupFldElt, Map -> ModGrp, ModMatGrpElt, ModMatGrpElt`

Given $K[G]$-modules $M$ and $N$, where $K$ is a finite field, construct a $K[G]$-module extension $L$ of $N$ by $M$ corresponding to the element $e$ of $E$, where $E$ and $\phi$ must be the vector space and map returned by a previous call of `Ext(M,N)`. The insertion $N\rightarrow L$ and projection $L\rightarrow M$ are also returned.

### `MaximalExtension(M, N, E, r): ModGrp, ModGrp, ModTupFld, map -> ModGrp`

Let $M$ and $N$ be $K[G]$-modules, where $K$ is a finite field, and further let $E$ be the vector space and $r$ the map returned by a previous call of `Ext(M, N).` Construct the largest possible $K[G]$-module extension $L$ of a direct sum of copies of $N$ by $M$, such that none of the submodules of $L$ that are isomorphic to $N$ has a complement in $L$.

### `MaximalExtension(M, N): ModGrp, ModGrp -> ModGrp`

This is the same as `MaximalExtension(M, N, E, r)`, but `Ext(M,N)` is called from within the function.

### `MaximalExtension(~M, N): ModGrp, ModGrp`

A version of `MaximalExtension(M, N)` that replaces $M$ by the result.

### `Example: Module Extensions (ex-fa426a)`

```magma
> G := Alt(5);
> I := IrreducibleModules(G, GF(2));
> I;
[
    GModule of dimension 1 over GF(2),
    GModule of dimension 4 over GF(2),
    GModule of dimension 4 over GF(2)
]
> M1 := rep{M: M in I | Dimension(M) eq 1};
> M4 := rep{M: M in I | Dimension(M) eq 4 and not IsAbsolutelyIrreducible(M)};
> M4; assert not IsAbsolutelyIrreducible(M4);
GModule M of dimension 4 over GF(2)
> E, phi := Ext(M4, M1);
> E;
Full Vector space of degree 2 over GF(2)
> Extension(M4, M1, E.1, phi);
GModule of dimension 5 over GF(2)

[0 0 0 0 1]

[1 0 0 0]
[0 1 0 0]
[0 0 1 0]
[0 0 0 1]
[0 0 0 0]
> E := MaximalExtension(M4, M1);
> E;
GModule E of dimension 6 over GF(2)
> CompositionFactors(E);
[
    GModule of dimension 1 over GF(2),
    GModule of dimension 1 over GF(2),
    GModule of dimension 4 over GF(2)
]

```

### `LowDimensionalModules(G, K, n): Grp, Fld, RngIntElt -> SeqEnum`

Let $G$ be a permutation group, a matrix group or a group defined by a power-commutator presentation and let $K$ be a finite field. This intrinsic constructs a representative of each isomorphism class of $K[G]$-modules of dimension at most $n$. It computes them by systematically constructing extensions of modules, starting with the irreducibles
