# 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-70e335)`

```magma
> k := GF(13);
> A<t> := PolynomialRing(k);
> Ax<x> := PolynomialRing(A);
> f := x^4 + (4*t + 4)*x^3 + (6*t^2 + 12*t + 6)*x^2 + (4*t^3 + 12*t^2 + 12*t
>                            + 4)*x + t^4 + 5*t^3 + 6*t^2 + 4*t + 1;
> L := FunctionField(f);
> p := t;
> I := OMRepresentation(L,[L.1,p^12]);
> pIntegralBasis(I,p);
[
    1,
    L.1 + 1,
    1/t*L.1^2 + 2/t*L.1 + 1/t,
    1/t^2*L.1^3 + 3/t^2*L.1^2 + 3/t^2*L.1 + 1/t^2
]
> pIntegralBasis(I,p:HNF:=true); // In HNF
[
    1,
    L.1,
    1/t*L.1^2 + 2/t*L.1 + 1/t,
    1/t^2*L.1^3 + 3/t^2*L.1^2 + 3/t^2*L.1 + 1/t^2
]

```

The $p$-integral basis is already the global basis :

```magma
> Basis(I);
[
    1,
    L.1 + 1,
    1/t*L.1^2 + 2/t*L.1 + 1/t,
    1/t^2*L.1^3 + 3/t^2*L.1^2 + 3/t^2*L.1 + 1/t^2
]
> Basis(I : HNF := true);
[
    1,
    L.1,
    1/t*L.1^2 + 2/t*L.1 + 1/t,
    1/t^2*L.1^3 + 3/t^2*L.1^2 + 3/t^2*L.1 + 1/t^2
]

```

## `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-fbb1be)`

```magma
> k := GF(13);
> A<t> := PolynomialRing(k);
> Ax<x> := PolynomialRing(A);
> f := x^5 + (t^2 + 2*t + 1)*x^4 + (t^4 + 4*t^3 + 6*t^2 + 4*t + 1)*x^3 + (t^3
>         + 3*t^2 + 3*t + 1)*x^2 + (t^4 + 4*t^3 + 6*t^2 + 4*t + 1)*x + t;
> L := FunctionField(f);
> I := OMRepresentation(L,[1/L.1^2,12]);
> I;
OM ideal of the field Algebraic function field defined over Univariate rational
function field over GF(13) by
x^5 + (t^2 + 2*t + 1)*x^4 + (t^4 + 4*t^3 + 6*t^2 + 4*t + 1)*x^3 + (t^3 + 3*t^2 +
3*t + 1)*x^2 + (t^4 + 4*t^3 + 6*t^2 + 4*t + 1)*x + t
generated by [
(t^4 + 4*t^3 + 6*t^2 + 4*t + 1)/t^2*$.1^4 + (t^6 + 6*t^5 + 2*t^4 + 7*t^3 + 2*t^2
+ 5*t + 1)/t^2*$.1^3 + (t^8 + 8*t^7 + 2*t^6 + 4*t^5 + 5*t^4 + 3*t^3 + 7*t +
1)/t^2*$.1^2 + (t^7 + 7*t^6 + 7*t^5 + 5*t^4 + 3*t^3 + 4*t^2 + 6*t + 1)/t^2*$.1 +
(t^8 + 8*t^7 + 2*t^6 + 4*t^5 + 4*t^4 + t^3 + 12*t^2 + 7*t + 1)/t^2,
12
]

> TwoElement(I);
1
(9*t^9 + t^7 + 3*t^6 + 11*t^4 + 2*t^3 + 9*t^2 + 4*t + 1)/t^2*L.1^4 + (4*t^12 +
    8*t^11 + 5*t^10 + 9*t^9 + 2*t^8 + 10*t^7 + 12*t^6 + 6*t^5 + 5*t^4 + 12*t^3 +
    4*t^2 + 5*t + 1)/t^2*L.1^3 + (4*t^11 + 10*t^9 + 11*t^8 + 6*t^7 + 7*t^6 +
    10*t^5 + 5*t^4 + 10*t^3 + 3*t^2 + 7*t + 1)/t^2*L.1^2 + (4*t^12 + 8*t^11 +
    5*t^10 + 2*t^8 + 3*t^7 + 5*t^6 + 8*t^5 + 10*t^4 + 6*t^3 + 7*t^2 + 6*t +
    1)/t^2*L.1 + (4*t^9 + 5*t^8 + 5*t^6 + 11*t^5 + 5*t^4 + 10*t^3 + 3*t^2 + 7*t
    + 1)/t^2
> Norm(I);
1/t^2
> Factorization(I);
[
    <OM prime ideal over   t
    of Algebraic function field defined over Univariate rational function field
    over GF(13) by
    x^5 + (t^2 + 2*t + 1)*x^4 + (t^4 + 4*t^3 + 6*t^2 + 4*t + 1)*x^3 + (t^3 +
    3*t^2 + 3*t + 1)*x^2 + (t^4 + 4*t^3 + 6*t^2 + 4*t + 1)*x + t
    having residual degree   1
    and ramification index   1
    Last phi polynomial is   x, -2>
]
> Montes(L, t+1);
> Valuation(I, L`PrimeIdeals[t][1]);
-2
> Valuation(I, L`PrimeIdeals[t+1][1]);
0

```

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

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

## `Degree(I): OMIdl -> RngIntElt`

Given a prime ideal $I$ in OM representation, contained in a function field, return the degree of the residue field over the constant field of the function field.

If $I$ is not prime then the degree of the first ideal in the factorization of $I$ is returned.

## `Example: Om Ideals Deg Res (ex-7d7ba3)`

```magma
> F<t> := FunctionField(Rationals());
> P<x> := PolynomialRing(F);
> L<a> := ext<F | x^2 + t>;
> Montes(L, Numerator(t)^2+1);
> L`PrimeIdeals[Numerator(t)^2+1];
[
    OM prime ideal over t^2 + 1
    of Algebraic function field defined over Univariate rational function field
    over Rational Field by
    x^2 + t
    having residual degree   2
    and ramification index   1
    Last phi polynomial is x^2 + t
]
> Degree($1[1]);
4
> ResidueField($2[1]);
Number Field with defining polynomial y^2 + $.1 over its ground field

```
