# Divisors in OM representation

OM representations of ideals can be used to construct divisors without computing maximal orders which are required for the divisors of type `DivFunElt`.

For detailed information please see [[Bauch, 2014](../../references.md#cite-bauch-thesis), [Bauch, 2016](../../references.md#cite-bauch2016lattices)].

## Constructing Divisors in OM representation

### `OMDivisor(If, Ii): OMIdl, OMIdl -> OMDiv`

Given an ideal $If$ in OM representation whose function field is marked as finite and an ideal $Ii$ in OM representation whose function field is marked as infinite, return the divisor in OM representation whose support is the places associated to the prime ideals which divide either $If$ or $Ii$ with coefficients the negative of valuation of $If$ and $Ii$ at the prime ideals.

### `OMDivisor(I): OMIdl -> OMDiv`

Given an ideal $I$ in OM representation return the divisor in OM representation whose support is the places associated to the prime ideals which divide $I$ with coefficients the negative of the valuation of $I$ at the prime ideals.

### `OMDivisor(z): FldFunElt -> OMDiv`

Given a non zero element $z$ of a function field, return the principal divisor $\sum_P v_P(z) P$ in OM representation.

### `PoleDivisor(a): FldFunElt -> OMDiv`

Given a non zero element $a$ of a function field, return the divisor $\sum_{v_P(a)<0} -v_P(a) P$ in OM representation.

### `ZeroDivisor(a): FldFunElt -> OMDiv`

Given a non zero element $a$ of a function field, return the divisor $\sum_{v_P(a)>0} v_P(a) P$ in OM representation.

### `OMDivisorOfDegreeOne(F): FldFun -> OMDiv`

Given a global function field $F$ returns a divisor of $F$ having degree 1.

### `ReferenceDivisor(F): FldFun -> OMDiv`

Given a function field $F$, return, if set, the divisor $B$ in OM representation used to reduce a divisor $D$ of $F$ to $\tilde D$ such $D = \tilde D+kB + (a)$.

### `OMDivisor(D): DivFunElt -> OMDiv`

Given a divisor $D$ of a function field of type `DivFunElt` compute an OM representation of $D$.

### `Example: Om Div Constr (ex-42c816)`

```magma
> Fq := GF(13);
> A<t> := PolynomialRing(Fq);
> Ax<x> := PolynomialRing(A);
> f := x^5+(t+1)^16*x^4+ x^2+t^3*x+t^6;
> F := FunctionField(f);
> Montes(F,t);
> Ifin := F`PrimeIdeals[t,1];
> D := OMDivisor(Ifin);
> D;
Free repr. of divisor:  -1*P(t,1)
----------------------------------------
Ideal repr. of divisor:
Finite ideal = P(t,1)
Infinite ideal =
----------------------------------------

> Iinf := PrimesAtInfinity(F)[1];
> D := OMDivisor(Ifin,Iinf);
> D;
Free repr. of divisor:  -1*P(t,1)+( -1*P(1/t,1) )
----------------------------------------
Ideal repr. of divisor:
Finite ideal = P(t,1)
Infinite ideal = P(t,1)
----------------------------------------
> D := OMDivisor(F.1);
> D;
Principal divisor generated by: 12/t^6*$.1^4 + (12*t^16 + 10*t^15 + 10*t^14 +
12*t^13 + 12*t^3 + 10*t^2 + 10*t + 12)/t^6*$.1^3 + 12/t^6*$.1 + 12/t^3
----------------------------------------
Free repr. of divisor:  3*P(t,1)+ 3*P(t,2)+( 5*P(1/t,1)+ 5*P(1/t,2)+
-16*P(1/t,3) )
----------------------------------------
Ideal repr. of divisor:
Finite ideal = P(t,1)^-3*P(t,2)^-3
Infinite ideal = P(t,1)^-5*P(t,2)^-5*P(t,3)^16
----------------------------------------

> E := PoleDivisor(F.1);
> E;
Free repr. of divisor:  16*P(1/t,3)
----------------------------------------
Ideal repr. of divisor:
Finite ideal =
Infinite ideal = P(t,3)^-16
----------------------------------------

> C := ZeroDivisor(F.1);
> C;
Free repr. of divisor:  3*P(t,1)+ 3*P(t,2)+( 5*P(1/t,1)+ 5*P(1/t,2) )
----------------------------------------
Ideal repr. of divisor:
Finite ideal = P(t,1)^-3*P(t,2)^-3
Infinite ideal = P(t,1)^-5*P(t,2)^-5
----------------------------------------

> E  := Divisor(F.1);
> D  := OMDivisor(E);
> D;
Free repr. of divisor:  3*P(t,1)+ 3*P(t,2)+( 5*P(1/t,1)+ 5*P(1/t,2)+
-16*P(1/t,3) )
----------------------------------------
Ideal repr. of divisor:
Finite ideal = P(t,1)^-3*P(t,2)^-3
Infinite ideal = P(t,1)^-5*P(t,2)^-5*P(t,3)^16
----------------------------------------

```

## Arithmetic with Divisors in OM representation

### `k * D: RngIntElt, OMDiv -> OMDiv`

Given an integer $k$ and a divisor $D$ in OM representation return the scalar multiple $k D$.

### `D1 + D2: OMDiv, OMDiv -> OMDiv`

Given divisors $D1$ and $D2$ in OM representation return their sum also in OM representation.

### `D1 - D2: OMDiv, OMDiv -> OMDiv`

Given divisors $D1$ and $D2$ in OM representation return their difference also in OM representation.

### `GCD(D1, D2): OMDiv, OMDiv -> OMDiv`

### `Gcd(D1, D2): OMDiv, OMDiv -> OMDiv`

### `GreatestCommonDivisor(D1, D2): OMDiv, OMDiv -> OMDiv`

Given divisors $D1$ and $D2$ in OM representation return their GCD in OM representation.

### `Example: Om Div Arith (ex-31985e)`

```magma
> Fq := GF(13);
> A<t> := PolynomialRing(Fq);
> Ax<x> := PolynomialRing(A);
> f := x^5+(t+1)^16*x^4+ x^2+t^3*x+t^6;
> F := FunctionField(f);
> Montes(F,t);
> Ifin := F`PrimeIdeals[t,1];
> D := OMDivisor(Ifin);
> E := PoleDivisor(F.1);
> C := ZeroDivisor(F.1);
> D + E;
Free repr. of divisor:  -1*P(t,1)+( 16*P(1/t,3) )
----------------------------------------
Ideal repr. of divisor:
Finite ideal = P(t,1)
Infinite ideal = P(t,3)^-16
----------------------------------------

> D - C;
Free repr. of divisor:  -4*P(t,1)+ -3*P(t,2)+( -5*P(1/t,1)+ -5*P(1/t,2) )
----------------------------------------
Ideal repr. of divisor:
Finite ideal = P(t,1)^4*P(t,2)^3
Infinite ideal = P(t,1)^5*P(t,2)^5
----------------------------------------

> 5*C;
Free repr. of divisor:  15*P(t,1)+ 15*P(t,2)+( 25*P(1/t,1)+ 25*P(1/t,2) )
----------------------------------------
Ideal repr. of divisor:
Finite ideal = P(t,1)^-15*P(t,2)^-15
Infinite ideal = P(t,1)^-25*P(t,2)^-25
----------------------------------------
> GCD(D, C);
Free repr. of divisor:  -1*P(t,1)
----------------------------------------
Ideal repr. of divisor:
Finite ideal = P(t,1)
Infinite ideal =
----------------------------------------

> GCD(D, E);
Free repr. of divisor:
----------------------------------------
Ideal repr. of divisor:
Finite ideal =
Infinite ideal =
----------------------------------------

```

## Predicates on Divisors in OM representation

### `IsEffective(D): OMDiv -> BoolElt`

### `IsPositive(D): OMDiv -> BoolElt`

Given a divisor $D$ in OM representation, return whether the valuation of $D$ at every prime in its support is non negative.

### `IsPrincipal(D): OMDiv -> BoolElt`

Given a divisor $D$ in OM representation, return whether $D$ was constructed as the divisor of an element.

### `D1 eq D2: OMDiv, OMDiv -> BoolElt`

Given divisors $D1$ and $D2$ in OM representation, return whether they are equal.

### `Example: Om Div Pred (ex-c8e530)`

Continuing with the previous example :

```magma
> IsPrincipal(OMDivisor(F.1));
true
> IsPositive(OMDivisor(F.1));
false
> IsPositive(ZeroDivisor(F.1));
true
> ZeroDivisor(F.1) eq OMDivisor(F.1);
false

```

## Other Operations on Divisors in OM representation

### `Divisor(D): OMDiv -> DivFunElt`

Given a divisor $D$ in OM representation return a divisor of type `DivFunElt`.

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

Given a divisor $D$ in OM representation and a prime ideal $P$ in OM representation, return the valuation of $D$ at $P$.

### `Support(D): OMDiv -> [OMIdl], [RngIntElt]`

Given a divisor $D$ in OM representation, return a sequence of primes at which $D$ has non zero valuation and a sequence of the valuations that $D$ has at those primes.

### `Height(D): OMDiv -> RngIntElt`

### `CanonicalHeight(D): OMDiv -> RngIntElt`

Given a divisor $D$ in OM representation, return the sum of the products of the absolute values of the valuations returned by `Support` with the degree of the primes in the `Support` of $D$ and the maximum degree of the primes in the support of $D$.

### `Degree(D): OMDiv -> RngIntElt`

Given a divisor $D$ in OM representation, return the sum of the products of the valuations returned by `Support` with the degrees of the primes in the support of $D$.

### `Basis(D): OMDiv -> SeqEnum`

Given a divisor $D$ in OM representation, return a basis of the Riemann–Roch space of $D$.

### `Dimension(D): OMDiv -> RngIntElt`

Given a divisor $D$ in OM representation, return the dimension of its Riemann–Roch space.

### `ReducedBasis(D): OMDiv -> SeqEnum`

Given a divisor $D$ in OM representation returns a reduced basis for the lattice corresponding to $D$, that is, the lattice given by its finite ideal.

### `SemiReducedBasis(D): OMDiv -> SeqEnum`

Given a divisor $D$ in OM representation returns a semi-reduced basis for the lattice corresponding to $D$, that is, the lattice given by its finite ideal.

### `SuccessiveMinima(D): OMDiv -> SeqEnum`

Given a divisor $D$ in OM representation returns the successive minima of the lattice given by the finite ideal of $D$.

### `ApproximatedSuccessiveMinima(D): OMDiv -> SeqEnum`

Given a divisor $D$ in OM representation returns the ceiling of the successive minima of the lattice given by the finite ideal of $D$.

### `Example: Om Div Ops (ex-e8bf40)`

Continuing with the previous example :

```magma
> Montes(F, t);
> Ifin := F`PrimeIdeals[t,1];
> D := OMDivisor(Ifin);
> D;
Free repr. of divisor:  -1*P(t,1)
----------------------------------------
Ideal repr. of divisor:
Finite ideal = P(t,1)
Infinite ideal =
----------------------------------------

> Support(D);
[
    OM prime ideal over   t
    of Algebraic function field defined over Univariate rational function field
    over GF(13) by
    x^5 + (t^16 + 3*t^15 + 3*t^14 + t^13 + t^3 + 3*t^2 + 3*t + 1)*x^4 + x^2 +
    t^3*x + t^6
    having residual degree   1
    and ramification index   1
    Last phi polynomial is x + 10*t^3
]
[ -1 ]
> Height(D);
1 1
> Degree(D);
-1
> Basis(OMDivisor(F.1));
[
    12/t^6*F.1^4 + (12*t^16 + 10*t^15 + 10*t^14 + 12*t^13 + 12*t^3 + 10*t^2 +
        10*t + 12)/t^6*F.1^3 + 12/t^6*F.1 + 12/t^3
]
> Dimension(OMDivisor(F.1));
1
> ReducedBasis(OMDivisor(F.1));
[
    12/t^6*F.1^4 + (12*t^16 + 10*t^15 + 10*t^14 + 12*t^13 + 12*t^3 + 10*t^2 +
        10*t + 12)/t^6*F.1^3 + 12/t^6*F.1 + 12/t^3,
    1/t^3*F.1^3 + (t^16 + 3*t^15 + 3*t^14 + t^13 + t^3 + 3*t^2 + 3*t +
        1)/t^3*F.1^2 + 1/t^3,
    12*F.1^2 + (12*t^16 + 10*t^15 + 10*t^14 + 12*t^13 + 12*t^3 + 10*t^2 + 10*t +
        12)*F.1,
    F.1 + t^16 + 3*t^15 + 3*t^14 + t^13 + t^3 + 3*t^2 + 3*t + 1,
    F.1^2 + (t^16 + 3*t^15 + 3*t^14 + t^13 + t^3)*F.1 + 10*t^18 + t^17 + 7*t^16
        + 11*t^15 + 7*t^14 + 12*t^13 + 10*t^5 + t^4 + 7*t^3 + 11*t^2 + 7*t
]
> SemiReducedBasis(OMDivisor(F.1));
[
    12/t^6*F.1^4 + (12*t^16 + 10*t^15 + 10*t^14 + 12*t^13 + 12*t^3 + 10*t^2 +
        10*t + 12)/t^6*F.1^3 + 12/t^6*F.1 + 12/t^3,
    1/t^3*F.1^3 + (t^16 + 3*t^15 + 3*t^14 + t^13 + t^3 + 3*t^2 + 3*t +
        1)/t^3*F.1^2 + 1/t^3,
    12*F.1^2 + (12*t^16 + 10*t^15 + 10*t^14 + 12*t^13 + 12*t^3 + 10*t^2 + 10*t +
        12)*F.1,
    F.1 + t^16 + 3*t^15 + 3*t^14 + t^13 + t^3 + 3*t^2 + 3*t + 1,
    F.1^2 + (t^16 + 3*t^15 + 3*t^14 + t^13 + t^3)*F.1 + 10*t^18 + t^17 + 7*t^16
        + 11*t^15 + 7*t^14 + 12*t^13 + 10*t^5 + t^4 + 7*t^3 + 11*t^2 + 7*t
]
> SuccessiveMinima(OMDivisor(F.1));
[ 0, 11/2, 11, 27/2, 16 ]
> ApproximatedSuccessiveMinima(OMDivisor(F.1));
[ 0, 6, 11, 14, 16 ]

```
