# Extensions

It is a well known classical theorem that $p$-adic fields admit only finitely many different extensions of bounded degree (in contrast to number fields which have an infinite number of extensions of any degree). In his thesis, Pauli [[Pauli, 2001](../../references.md#cite-pauli-diss)] developed explicit methods to enumerate those extensions.

## `AllExtensions(R, n): RngPad, RngIntElt -> [RngPad]`

## `AllExtensions(R, n): FldPad, RngIntElt -> [RngPad]`

```magma
E     : RngIntElt                    Default: 0
F     : RngIntElt                    Default: 0
Galois: BoolElt                      Default: false
vD    : RngIntElt                    Default: -1
j     : RngIntElt                    Default: -1
```

Given a $p$-adic ring or field $R$ and some positive integer $n$, compute all the extensions of $R$ of degree $n$. At least one extension is given in every isomorphism class. The optional parameters can be used to impose restrictions on the fields returned. Note that $j$ and $vD$ must be unspecified (as $-1$) when $F\neq 1$ or when $E$ and $F$ are both not given.

The optional parameters can be used to limit the extensions in various ways:

**`E`**
specifies the ramification index. $0$ implies no restriction.

**`F`**
specifies the inertia degree, $0$ implies no restriction.

**`vD`**
specifies the valuation of the discriminant, $-1$ implies no restriction.

**`j`**
specifies the valuation of the discriminant via the formula $vD := n+j-1$.

**`Galois`**
when set to `true`, limits the extensions to only list normal extensions.

## `NumberOfExtensions(R, n): RngPad, RngIntElt -> RngIntElt`

```magma
E     : RngIntElt                    Default: 0
F     : RngIntElt                    Default: 0
Galois: BoolElt                      Default: false
vD    : RngIntElt                    Default: -1
j     : RngIntElt                    Default: -1
```

Given a $p$-adic ring or field $R$ and some positive integer $n$, compute the number of extensions of $R$ of degree $n$. Similarly to the above function, the optional parameters can be used to impose restrictions on the fields returned. Note that $j$ and $vD$ must be unspecified (as $-1$) when $F\neq 1$ or when $E$ and $F$ are both not given.

Note that the count will not be the same as `AllExtensions`, as the latter need only be up to isomorphism.

## `OreConditions(R, n, j): RngPad, RngIntElt, RngIntElt -> BoolElt`

## `OreConditions(R, n, j): FldPad, RngIntElt, RngIntElt -> BoolElt`

Given a $p$-adic ring or field $R$ and positive integers $n$ and $j$, test if there exist totally ramified extensions of $R$ of degree $n$ with discriminant valuation $n+j-1$.

## `Example: All Extensions (ex-ea2536)`

We follow Examples 9.1 and 9.2 from [[Pauli and Roblot, 2001](../../references.md#cite-pauli-roblot)].

There are 54 (totally ramified) extensions of degree 9 and discriminant $3^{9+4-1}$ over ${{\mathbb{Q}}}_3$. There are six generating polynomials, each defining nine isomorphism classes. The possible (nontrivial) subfields of these have degree 3 and $j_0=1$, of which there are two defining polynomials each with three isomorphism classes. Each of these degree 3 fields then admits two extensions with $j_1=1$, which give six isomorphism classes. This gives a total of 27 degree 9 extensions that have a subfield of degree 3.

```magma
> R := pAdicRing(3,20);
> _<x> := PolynomialRing(R); // for printing
> NumberOfExtensions(R,9 : F:=1,j:=4);
54
> A9 := AllExtensions(R,9 : F:=1,j:=4);
> [DefiningPolynomial(a) : a in A9];
[ x^9 + 3*x^4 + 3, x^9 + 6*x^4 + 3,
  x^9 + 3*x^4 + 3*x^3 + 3, x^9 + 6*x^4 + 3*x^3 + 3,
  x^9 + 3*x^4 + 6*x^3 + 3, x^9 + 6*x^4 + 6*x^3 + 3 ]
> A3 := AllExtensions(R,3 : F:=1,j:=1);
> NumberOfExtensions(A3[1],3 : F:=1,j:=1);
6
> [DefiningPolynomial(a) : a in A3];
[ x^3 + 3*x + 3, x^3 + 6*x + 3 ]
> _<pi> := A3[1];
> _<y> := PolynomialRing(A3[1]);
> B3 := AllExtensions(A3[1],3 : F:=1,j:=1);
> [DefiningPolynomial(f) : f in B3];
[ y^3 + pi*y + pi, y^3 + 2*pi*y + pi ]

```

The other example concerns degree 10 extensions of ${{\mathbb{Q}}}_5$. Here there are 1818 total extensions, of which 1 is unramified and 2 have ramification degree 2, while 605 have ramification degree 5 and 1210 are totally ramified. With ramification degree 5, there are 145 defining polynomials over the unramified quadratic field, split into five $j$-groupings. As noted in [[Pauli and Roblot, 2001](../../references.md#cite-pauli-roblot)], there is a further splitting in the $j=4$ grouping. Similarly, there are 145 defining polynomials over either of the two tamely ramified extensions of degree 2 over ${{\mathbb{Q}}}_5$. The resulting fields are in fact isomorphic in pairs, but the `AllExtensions` function still lists both fields in each pair. So it returns 438 fields (1+2+145+290) rather than the stated 293 isomorphism classes (1+2+145+145).

```magma
> R := pAdicRing(5,20);
> NumberOfExtensions(R,10);
1818
> [NumberOfExtensions(R,10 : E:=e) : e in Divisors(10)];
[ 1, 2, 605, 1210 ]
> U := UnramifiedExtension(R,2);
> [#AllExtensions(U,5 : E:=5,j:=j0) : j0 in [1..5]];
[ 24, 24, 24, 48, 25 ]
> // compare the above/below to (#K)/N in Pauli-Roblot
> [#AllExtensions(R,10 : E:=10,j:=j0): j0 in [1..10]];
[ 8, 8, 8, 16, 0, 40, 40, 80, 40, 50 ] // twice P-R

```
