---
title: "Ideal Operations"
canonical: "https://docs.magma-maths.org/v2.30-1/GlobalFields/AlgebraicFunctionFields/ideal-op.html"
source: "https://docs.magma-maths.org/v2.30-1/GlobalFields/AlgebraicFunctionFields/ideal-op.md"
part: "Global Fields"
chapter: "Algebraic Function Fields"
breadcrumbs:
  - {"title": "Magma Handbook", "source": "https://docs.magma-maths.org/v2.30-1/index.md"}
  - {"title": "Global Fields", "source": "https://docs.magma-maths.org/v2.30-1/GlobalFields/index-global-fields.md"}
  - {"title": "Algebraic Function Fields", "source": "https://docs.magma-maths.org/v2.30-1/GlobalFields/AlgebraicFunctionFields/index-algebraic-function-fields.md"}
prev: {"title": "Ideals in OM Representation", "source": "https://docs.magma-maths.org/v2.30-1/GlobalFields/AlgebraicFunctionFields/ideal-rep.md"}
next: {"title": "Divisors in OM representation", "source": "https://docs.magma-maths.org/v2.30-1/GlobalFields/AlgebraicFunctionFields/divisors-in-om-representation.md"}
intrinsics:
  - {"name": "pIntegralBasis", "signature": "pIntegralBasis(I, p): OMIdl, RngElt -> SeqEnum"}
  - {"name": "SIntegralBasis", "signature": "SIntegralBasis(I, S): OMIdl, SeqEnum -> SeqEnum"}
  - {"name": "SIntegralBasis", "signature": "SIntegralBasis(I, S): RngOrdFracIdl, [RngIntElt] -> SeqEnum"}
  - {"name": "SIntegralBasis", "signature": "SIntegralBasis(I, S): RngFunOrdIdl, [RngUPolElt] -> SeqEnum"}
  - {"name": "Basis", "signature": "Basis(I): OMIdl -> SeqEnum"}
  - {"name": "TwoElement", "signature": "TwoElement(I): OMIdl -> FldArithElt, FldArithElt"}
  - {"name": "Norm", "signature": "Norm(I): OMIdl -> RngElt"}
  - {"name": "Valuation", "signature": "Valuation(alpha, P : parameters): FldArithElt, OMIdl -> RngIntElt, FldElt"}
  - {"name": "Valuation", "signature": "Valuation(alpha, P : parameters): FldRatElt, OMIdl -> RngIntElt, FldElt"}
  - {"name": "Valuation", "signature": "Valuation(alpha, P : parameters): RngIntElt, OMIdl -> RngIntElt, FldElt"}
  - {"name": "Valuation", "signature": "Valuation(alpha, P : parameters): RngUPolElt, OMIdl -> RngIntElt, FldElt"}
  - {"name": "Valuation", "signature": "Valuation(I, P): OMIdl, OMIdl -> RngIntElt"}
  - {"name": "mod", "signature": "a mod P: FldArithElt, OMIdl -> FldArithElt"}
  - {"name": "Reduction", "signature": "Reduction(a, P): FldArithElt, OMIdl -> FldArithElt"}
  - {"name": "Reduction", "signature": "Reduction(a, P, m): FldArithElt, OMIdl, RngIntElt -> [FldArithElt]"}
  - {"name": "Factorization", "signature": "Factorization(I): OMIdl -> SeqEnum"}
  - {"name": "Factorisation", "signature": "Factorisation(I): OMIdl -> SeqEnum"}
  - {"name": "ResidueField", "signature": "ResidueField(I): OMIdl -> Fld"}
  - {"name": "Degree", "signature": "Degree(I): OMIdl -> RngIntElt"}
examples:
  - "ex-70e335"
  - "ex-fbb1be"
  - "ex-7d7ba3"
---

# Ideal Operations

<a id="function-pintegralbasis-omidl-rngelt"></a>
## `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$.

<a id="function-sintegralbasis-omidl-seqenum"></a>
## `SIntegralBasis(I, S): OMIdl, SeqEnum -> SeqEnum`

<a id="function-sintegralbasis-rngordfracidl-rngintelt"></a>
## `SIntegralBasis(I, S): RngOrdFracIdl, [RngIntElt] -> SeqEnum`

<a id="function-sintegralbasis-rngfunordidl-rngupolelt"></a>
## `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$.

<a id="function-basis-omidl"></a>
## `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.

<a id="example-ex-70e335"></a>
## `Example: Integral Basis of an OM Ideal (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
]
```

<a id="function-twoelement-omidl"></a>
## `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$.

<a id="function-norm-omidl"></a>
## `Norm(I): OMIdl -> RngElt`

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

<a id="function-valuation-fldarithelt-omidl"></a>
## `Valuation(alpha, P : parameters): FldArithElt, OMIdl -> RngIntElt, FldElt`

<a id="function-valuation-fldratelt-omidl"></a>
## `Valuation(alpha, P : parameters): FldRatElt, OMIdl -> RngIntElt, FldElt`

<a id="function-valuation-rngintelt-omidl"></a>
## `Valuation(alpha, P : parameters): RngIntElt, OMIdl -> RngIntElt, FldElt`

<a id="function-valuation-rngupolelt-omidl"></a>
## `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)}$.

<a id="function-valuation-omidl-omidl"></a>
## `Valuation(I, P): OMIdl, OMIdl -> RngIntElt`

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

<a id="operation-operation-mod-fldarithelt-omidl-fldarithelt"></a>
## `a mod P: FldArithElt, OMIdl -> FldArithElt`

<a id="function-reduction-fldarithelt-omidl"></a>
## `Reduction(a, P): FldArithElt, OMIdl -> FldArithElt`

<a id="function-reduction-fldarithelt-omidl-rngintelt"></a>
## `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$.

<a id="function-factorization-omidl"></a>
## `Factorization(I): OMIdl -> SeqEnum`

<a id="function-factorisation-omidl"></a>
## `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}$.

<a id="example-ex-fbb1be"></a>
## `Example: Creating an OM Ideal (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
```

<a id="function-residuefield-omidl"></a>
## `ResidueField(I): OMIdl -> Fld`

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

<a id="function-degree-omidl"></a>
## `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.

<a id="example-ex-7d7ba3"></a>
## `Example: Degree and Residue Field of OM Ideals (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
```
