# Ideal Operations

## `pIntegralBasis(I, p): OMIdl, RngElt -> SeqEnum`

Given an ideal $I$ in OM representation and a prime element $p$ in the field containing $I$, compute a $p$-integral basis for $I$.

## `SIntegralBasis(I, S): OMIdl, SeqEnum -> SeqEnum`

## `SIntegralBasis(I, S): RngOrdFracIdl, [RngIntElt] -> SeqEnum`

## `SIntegralBasis(I, S): RngFunOrdIdl, [RngUPolElt] -> SeqEnum`

Given an ideal $I$ in either representation and a sequence $S$ of primes in the field containing $I$, compute an $S$-integral basis of $I$ for the given set of primes $S$.

## `Basis(I): OMIdl -> SeqEnum`

```magma
HNF      : BoolElt                    Default: false
Separated: BoolElt                    Default: false
```

Given an ideal $I$ in OM representation, return a basis for $I$.

If `HNF` is set to `true` a triangular basis in Hermite form is returned.

If `Separated` is set to `true` the basis will be returned as a sequence of numerators and denominators.

## `Example: Om Ideal Op (ex-a203ed)`

```magma
> Ax<x> := PolynomialRing(Integers());
> f := x^4 + 12*x^3 + 54*x^2 + 108*x + 89;
> L := NumberField(f);
> p := 2;
> I := OMRepresentation(L,[L.1,p^12]);
> pIntegralBasis(I,p);
[
    1,
    L.1 + 1,
    1/2*(L.1^2 + 2*L.1 + 1),
    1/4*(L.1^3 + 3*L.1^2 + 3*L.1 + 1)
]
> pIntegralBasis(I,p:HNF:=true); // In HNF
[
    1,
    L.1,
    1/2*(L.1^2 + 1),
    1/4*(L.1^3 + L.1^2 + 3*L.1 + 3)
]
> Basis(I);
[
    1,
    L.1 + 1,
    1/2*(L.1^2 + 2*L.1 + 1),
    1/4*(L.1^3 + 3*L.1^2 + 3*L.1 + 1)
]
> Basis(I : HNF := true);
[
    1,
    L.1,
    1/2*(L.1^2 + 1),
    1/4*(L.1^3 + L.1^2 + 3*L.1 + 3)
]

```

## `TwoElement(I): OMIdl -> FldArithElt, FldArithElt`

Given an ideal $I$ in OM representation, return $a, b$ such that $e = a*e_1 + b*e_2$ for some $e_1, e_2$ for all $e \in I$.

## `Norm(I): OMIdl -> RngElt`

Given an ideal $I$ in OM representation, compute the norm of $I$.

## `Valuation(alpha, P : parameters): FldArithElt, OMIdl -> RngIntElt, FldElt`

## `Valuation(alpha, P : parameters): FldRatElt, OMIdl -> RngIntElt, FldElt`

## `Valuation(alpha, P : parameters): RngIntElt, OMIdl -> RngIntElt, FldElt`

## `Valuation(alpha, P : parameters): RngUPolElt, OMIdl -> RngIntElt, FldElt`

```magma
RED    : BoolElt                    Default: false,
MoreSFL: BoolElt                    Default: false
```

Compute the $P$-valuation $v$ of $\alpha$ at the prime ideal $P$.

Setting the parameter `MoreSFL` to `true` selects a single factor lifting algorithm. Setting the parameter `RED` to `true` returns also the class of $\alpha$ in $P^v/P^{(v+1)}$.

## `Valuation(I, P): OMIdl, OMIdl -> RngIntElt`

Given ideals $I$ and $P$ in OM representation, return the valuation of $I$ at $P$.

## `a mod P: FldArithElt, OMIdl -> FldArithElt`

## `Reduction(a, P): FldArithElt, OMIdl -> FldArithElt`

## `Reduction(a, P, m): FldArithElt, OMIdl, RngIntElt -> [FldArithElt]`

Given an element $a$ of the field containing the prime ideal $P$, which is in OM representation, return $a'$ such that $a = a' + I$ and $a' \in P^0/P$.

If $m > 0$ is given then a sequence of length $m$ of elements in $P^0/P$ is returned representing the local expansion of $a$ at $P$ up to precision $m$.

## `Factorization(I): OMIdl -> SeqEnum`

## `Factorisation(I): OMIdl -> SeqEnum`

Given an ideal $I$ in OM representation returns a sequence of tuples of primes $P_i$ and exponents $e_i$ such that $I = \prod_i P_i^{e_i}$.

## `Example: Om Ideal Ops (ex-b5c67b)`

```magma
> Ax<x> := PolynomialRing(Integers());
> f := x^5 + 343*x^4 + 49*x^3 + 343*x^2 + 7*x + 6;
> L := NumberField(f);
> I := OMRepresentation(L,[1/L.1^2,12]);
> I;
OM ideal of the field Number Field with defining polynomial x^5 + 343*x^4 +
49*x^3 + 343*x^2 + 7*x + 6 over the Rational Field
generated by [
1/36*(7*$.1^4 + 2395*$.1^3 - 1715*$.1^2 + 2107*$.1 - 2009),
12
]

> TwoElement(I);
1
1/36*(91*L.1^4 + 211*L.1^3 + 169*L.1^2 + 175*L.1 + 55)
> Norm(I);
1/36
> Factorization(I);
[
    <OM prime ideal over   2
    of Number Field with defining polynomial x^5 + 343*x^4 + 49*x^3 + 343*x^2 +
    7*x + 6 over the Rational Field
    having residual degree   1
    and ramification index   1
    Last phi polynomial is   x, -2>,
    <OM prime ideal over   3
    of Number Field with defining polynomial x^5 + 343*x^4 + 49*x^3 + 343*x^2 +
    7*x + 6 over the Rational Field
    having residual degree   1
    and ramification index   1
    Last phi polynomial is   x, -2>
]
> Valuation(I, L`PrimeIdeals[2][1]);
-2
> Valuation(I, L`PrimeIdeals[3][1]);
-2

```

## `ResidueField(I): OMIdl -> Fld`

Given an ideal $I$ in OM representation returns the field $P^0/P$.

## `Example: Om Ideals Deg Res (ex-7694e8)`

```magma
> Ax<x> := PolynomialRing(Integers());
> f := x^5 + 343*x^4 + 49*x^3 + 343*x^2 + 7*x + 6;
> L := NumberField(f);
> p := 7;
> Montes(L,p);
> L`PrimeIdeals[p];
[
    OM prime ideal over   7
    of Number Field with defining polynomial x^5 + 343*x^4 + 49*x^3 + 343*x^2 +
    7*x + 6 over the Rational Field
    having residual degree   1
    and ramification index   1
    Last phi polynomial is x + 6,
    OM prime ideal over   7
    of Number Field with defining polynomial x^5 + 343*x^4 + 49*x^3 + 343*x^2 +
    7*x + 6 over the Rational Field
    having residual degree   4
    and ramification index   1
    Last phi polynomial is x^4 + x^3 + x^2 + x + 1
]
> ResidueField($1[2]);
Finite field of size 7^4

```
