# Orders

## Creation

Order(B::Array{nf_elem, 1}, check::Bool = true) -> NfOrd

Returns the order with $\mathbf Z$-basis $B$. If check is set, it is checked whether $B$ defines an order.

Order(K::AnticNumberField, A::FakeFmpqMat, check::Bool = true) -> NfOrd

Returns the order which has basis matrix $A$ with respect to the power basis of $K$. If check is set, it is checked whether $A$ defines an order.

EquationOrder(K::AnticNumberField) -> NfOrd

Returns the equation of the number field $K$.

### Example

julia> Qx, x = PolynomialRing(QQ, "x");

julia> K, a = NumberField(x^2 - 2, "a");

julia> O = EquationOrder(K)
Order of Number field over Rational Field with defining polynomial x^2 - 2
with Z-basis [1,a]

Note

Internally there is a difference between arbitary orders and maximal orders. An order will be treated as a maximal order, that is, as the ring of integers, if it was computed in the following way.

maximal_order(K::AnticNumberField) -> NfMaxOrd
ring_of_integers(K::AnticNumberField) -> NfMaxOrd

Returns the maximal order of $K$.

maximal_order(K::AnticNumberField, primes::Array{fmpz, 1}) -> NfMaxOrd
maximal_order(K::AnticNumberField, primes::Array{Integer, 1}) -> NfMaxOrd
ring_of_integers(K::AnticNumberField, primes::Array{fmpz, 1}) -> NfMaxOrd
ring_of_integers(K::AnticNumberField, primes::Array{Integer, 1}) -> NfMaxOrd

Assuming that primes contains all the prime numbers at which the equation order $\mathbf{Z}[\alpha]$ of $K = \mathbf{Q}(\alpha)$ is not maximal (e.g. primes may contain all prime divisors of the discriminant of $\mathbf Z[\alpha]$), this function returns the maximal order of $K$.

make_maximal(O::NfOrd) -> NfMaxOrd

Assuming that $\mathcal O$ is an order, this function returns the same order as a maximal order.

julia> Qx, x = PolynomialRing(QQ, "x");

julia> K, a = NumberField(x^2 - 2, "a");

julia> R = EquationOrder(K)
Order of Number field over Rational Field with defining polynomial x^2 - 2
with Z-basis [1,a]

julia> S = make_maximal(R)
Maximal order of Number field over Rational Field with defining polynomial x^2 - 2
with basis [1,a]

julia> T = maximal_order(K)
Maximal order of Number field over Rational Field with defining polynomial x^2 - 2
with basis [1,a]

julia> basis_mat(S) == basis_mat(T)
true

## Basic properties

signature(O::NfOrd) -> Tuple{Int, Int}

Returns the signature of the ambient number field of $\mathcal O$.

degree(O::NfOrd) -> Int

Returns the degree of $\mathcal O$.

norm_change_const(O::NfOrd) -> (Float64, Float64)

Returns $(c_1, c_2) \in \mathbf R_{>0}^2$ such that for all $x = \sum_{i=1}^d x_i \omega_i \in \mathcal O$ we have $T_2(x) \leq c_1 \cdot \sum_i^d x_i^2$ and $\sum_i^d x_i^2 \leq c_2 \cdot T_2(x)$, where $(\omega_i)_i$ is the $\mathbf Z$-basis of $\mathcal O$.

isequationorder(O::NfOrd) -> Bool

Returns whether $\mathcal O$ is the equation order.

nf(O::NfOrd) -> AnticNumberField

Returns the ambient number field of $\mathcal O$.

basis(O::NfOrd) -> Array{NfOrdElem, 1}

Returns the $\mathbf Z$-basis of $\mathcal O$.

basis_mat(O::NfOrd) -> FakeFmpqMat

Returns the basis matrix of $\mathcal O$ with respect to the power basis of the ambient number field.

basis_mat_inv(O::NfOrd) -> FakeFmpqMat

Returns the inverse of the basis matrix of $\mathcal O$.

discriminant(O::NfOrd) -> fmpz

Returns the discriminant of $\mathcal O$.

gen_index(O::NfOrd) -> fmpq

Generalized index of $\mathcal O$ with respect to the ambient equation order $\mathbf Z[\alpha]$.

index(O::NfOrd) -> fmpz

Assuming that the order $\mathcal O$ contains the ambient equation order $\mathbf Z[\alpha]$, this function returns the index $[ \mathcal O : \mathbf ZZ]$.

is_index_divisor(O::NfOrd, d::fmpz) -> Bool
is_index_divisor(O::NfOrd, d::Int) -> Bool

Returns whether $d$ is a divisor of the index of $\mathcal O$.

minkowski_mat(O::NfOrd, abs_tol::Int = 64) -> arb_mat

Returns the Minkowski matrix of $\mathcal O$. Thus if $\mathcal O$ has degree $d$, then the result is a matrix in $\operatorname{Mat}_{d\times d}(\mathbf R)$. The entries of the matrix are real balls of type arb with radius less then 2^-abs_tol.

in(a::nf_elem, O::NfOrd) -> Bool

Checks whether $a$ lies in $\mathcal O$.

den(a::nf_elem, O::NfOrd) -> fmpz

Returns the smallest positive integer $k$ such that $k \cdot a$ lies in O.

+(R::NfOrd, S::NfOrd) -> NfOrd

Given two orders $R$, $S$ of $K$, this function returns the smallest order containing both $R$ and $S$. It is assumed that $R$, $S$ contain the ambient equation order and have coprime index.

poverorder(O::NfOrd, p::fmpz) -> NfOrd
poverorder(O::NfOrd, p::Integer) -> NfOrd

This function tries to find an order that is locally larger than $\mathcal O$ at the prime $p$: If $p$ divides the index $[ \mathcal O_K : \mathcal O]$, this function will return an order $\tilde{\mathcal O}$ such that $v_p([ \mathcal O_K : \tilde{\mathcal O}]) < v_p([ \mathcal O_K : \mathcal O])$. Otherwise $\mathcal O$ is returned.

pmaximal_overorder(O::NfOrd, p::fmpz) -> NfOrd
pmaximal_overorder(O::NfOrd, p::Integer) -> NfOrd

This function finds a $p$-maximal order $\tilde{\mathcal O}$ containing $\mathcal O$. That is, the index $[ \mathcal O_K : \tilde{\mathcal O}]$ is not dividible by $p$.

## Elements

### Creation

call(O::NfOrd, a::nf_elem, check::Bool = true) -> NfOrdElem

Given an element $a$ of the ambient number field of $\mathcal O$, this function coerces the element into $\mathcal O$. It will be checked that $a$ is contained in $\mathcal O$ if and only if check is true.

call(O::NfOrd, a::Union{fmpz, Integer}) -> NfOrdElem

Given an element $a$ of type fmpz or Integer, this function coerces the element into $\mathcal O$. It will be checked that $a$ is contained in $\mathcal O$ if and only if check is true.

call(O::NfOrd, arr::Array{fmpz, 1})

Returns the element of $\mathcal O$ with coefficient vector arr.

call{T <: Integer}(O::NfOrd, arr::Array{T, 1})

Returns the element of $\mathcal O$ with coefficient vector arr.

call(O::NfOrd) -> NfOrdElem

This function constructs a new element of $\mathcal O$ which is set to $0$.

### Basic properties

parent(a::NfOrdElem) -> NfOrd

Returns the order of which $a$ is an element.

elem_in_nf(a::NfOrdElem) -> nf_elem

Returns the element $a$ considered as an element of the ambient number field.

elem_in_basis(a::NfOrdElem) -> Array{fmpz, 1}

Returns the coefficient vector of $a$.

discriminant(B::Array{NfOrdElem, 1}) -> fmpz

Returns the discriminant of the family $B$.

==(x::NfOrdElem, y::NfOrdElem) -> Bool

Returns whether $x$ and $y$ are equal.

zero(O::NfOrd) -> NfOrdElem

Returns the zero element of $\mathcal O$.

one(O::NfOrd) -> NfOrdElem

Returns the zero element of $\mathcal O$.

iszero(a::NfOrd) -> Bool

Tests if $a$ is one.

isone(a::NfOrd) -> Bool

Tests if $a$ is one.

### Arithmetic

-(x::NfOrdElem) -> NfOrdElem

Returns the additive inverse of $x$.

+(x::NfOrdElem, y::NfOrdElem) -> NfOrdElem

Returns $x + y$.

-(x::NfOrdElem, y::NfOrdElem) -> NfOrdElem

Returns $x - y$.

*(x::NfOrdElem, y::NfOrdElem) -> NfOrdElem

Returns $x \cdot y$.

^(x::NfOrdElem, y::Union{fmpz, Int})

Returns $x^y$.

mod(a::NfOrdElem, m::Union{fmpz, Int}) -> NfOrdElem

Reduces the coefficient vector of $a$ modulo $m$ and returns the corresponding element. The coefficient vector of the result will have entries $x$ with $0 \leq x \leq m$.

powermod(a::NfOrdElem, i::fmpz, m::Integer) -> NfOrdElem

Returns the element $a^i$ modulo $m$.

### Miscallenous

representation_mat(a::NfOrdElem) -> fmpz_mat

Returns the representation matrix of the element $a$.

representation_mat(a::NfOrdElem, K::AnticNumberField) -> FakeFmpqMat

Returns the representation matrix of the element $a$ considered as an element of the ambient number field $K$. It is assumed that $K$ is the ambient number field of the order of $a$.

trace(a::NfOrdElem) -> fmpz

Returns the trace of $a$.

norm(a::NfOrdElem) -> fmpz

Returns the norm of $a$.

rand(O::NfOrd, n::Union{Integer, fmpz}) -> NfOrdElem

Computes a coefficient vector with entries uniformly distributed in $\{-n,\dotsc,-1,0,1,\dotsc,n\}$ and returns the corresponding element of the order $\mathcal O$.

minkowski_map(a::NfOrdElem, abs_tol::Int) -> Array{arb, 1}

Returns the image of $a$ under the Minkowski embedding. Every entry of the array returned is of type arb with radius less then 2^-abs_tol.

conjugates_arb(x::NfOrdElem, abs_tol::Int) -> Array{acb, 1}

Compute the the conjugates of x as elements of type acb. Recall that we order the complex conjugates $\sigma_{r+1}(x),...,\sigma_{r+2s}(x)$ such that $\sigma_{i}(x) = \overline{\sigma_{i + s}(x)}$ for $r + 2 \leq i \leq r + s$.

Every entry y of the array returned satisfies radius(real(y)) < 2^-abs_tol, radius(imag(y)) < 2^-abs_tol respectively.

conjugates_arb_log(x::NfOrdElem, abs_tol::Int) -> Array{arb, 1}

Returns the elements $(\log(\lvert \sigma_1(x) \rvert),\dotsc,\log(\lvert\sigma_r(x) \rvert), \dotsc,2\log(\lvert \sigma_{r+1}(x) \rvert),\dotsc, 2\log(\lvert \sigma_{r+s}(x)\rvert))$ as elements of type arb radius less then 2^-abs_tol.

t2(x::NfOrdElem, abs_tol::Int = 32) -> arb

Return the $T_2$-norm of $x$. The radius of the result will be less than 2^-abs_tol.

## Ideals

### Creation

ideal(O::NfOrd, a::Int) -> NfOrdIdl

Returns the ideal of $\mathcal O$ which is generated by $a$.

ideal(O::NfOrd, a::fmpz) -> NfOrdIdl

Returns the ideal of $\mathcal O$ which is generated by $a$.

ideal(O::NfOrd, A::fmpz_mat) -> NfOrdIdl

Assuming that $A$ is a $d \times d$ nonsingular integer matrix, this function returns the ideal $I$ given by $I = \bigoplus \mathbf Z \alpha_i$, where $(\alpha_1,\dotsc,\alpha_d) = (\omega_1,\dotsc,\omega_d) A^t$.

ideal(O::NfOrd, a::NfOrdElem) -> NfOrdIdl

Returns the ideal of $\mathcal O$ which is generated by $a$.

ring_of_multipliers(I::NfOrdIdl) -> NfOrdGen

Computes the order $(I : I)$, which is the set of all $x \in K$ with $xI \subseteq I$.

*(O::NfOrd, x::NfOrdElem) -> NfOrdIdl
*(x::NfOrdElem, O::NfOrd) -> NfOrdIdl

Returns the principal ideal $(x)$ of $\mathcal O$.

### Arithmetic

==(x::NfOrdIdl, y::NfOrdIdl)

Returns whether $x$ and $y$ are equal.

+(x::NfOrdIdl, y::NfOrdIdl)

Returns $x + y$.

*(x::NfOrdIdl, y::NfOrdIdl)

Returns $x \cdot y$.

intersection(x::NfOrdIdl, y::NfOrdIdl) -> NfOrdIdl
lcm(x::NfOrdIdl, y::NfOrdIdl) -> NfOrdIdl

Returns $x \cap y$.

### Miscaellenous

parent(I::NfOrdIdl) -> NfOrd

Returns the order of $I$.

basis(I::NfOrdIdl) -> Array{NfOrdElem, 1}

Returns the $\mathbf Z$-basis of $I$.

basis_mat(I::NfOrdIdl) -> fmpz_mat

Returns the basis matrix of $I$ with respect to the basis of the order.

minimum(I::NfOrdIdl) -> fmpz

Returns the minimum of $I$, that is, the minimum of $I \cap \mathbf Z_{\geq 0}$, where $\mathcal O$ is the order of $I$.

norm(I::NfOrdIdl) -> fmpz

Returns the norm of $I$, that is, the cardinality of $\mathcal O/I$, where $\mathcal O$ is the order of $I$.

in(x::NfOrdElem, y::NfOrdIdl)
in(x::nf_elem, y::NfOrdIdl)
in(x::fmpz, y::NfOrdIdl)

Returns whether $x$ is contained in $y$.

idempotents(x::NfOrdIdl, y::NfOrdIdl) -> NfOrdElem, NfOrdElem

Returns a tuple (e, f) consisting of elements e in x, f in y such that 1 = e + f.

If the ideals are not coprime, an error is raised.

mod(x::NfOrdElem, I::NfOrdIdl)

Returns the unique element $y$ of the ambient order of $x$ with $x \equiv y \bmod I$ and the following property: If $a_1,\dotsc,a_d \in \Z_{\geq 1}$ are the diagonal entries of the unique HNF basis matrix of $I$ and $(b_1,\dotsc,b_d)$ is the coefficient vector of $y$, then $0 \leq b_i < a_i$ for $1 \leq i \leq d$.

Given a prime number $p$, this function returns the $p$-radical $\sqrt{p\mathcal O}$ of $\mathcal O$, which is just $\{ x \in \mathcal O \mid \exists k \in \mathbf Z_{\geq 0} \colon x^k \in p\mathcal O \}$. It is not checked that $p$ is prime.

## Fractional ideals

### Creation

frac_ideal(O::NfOrd, A::fmpz_mat, b::fmpz) -> NfOrdFracIdl

Creates the fractional ideal of $\mathcal O$ with basis matrix $A/b$.

frac_ideal(O::NfOrd, A::FakeFmpqMat) -> NfOrdFracIdl

Creates the fractional ideal of $\mathcal O$ with basis matrix $A$.

frac_ideal(O::NfOrd, I::NfOrdIdl) -> NfOrdFracIdl

Turns the ideal $I$ into a fractional ideal of $\mathcal O$.

frac_ideal(O::NfOrd, I::NfOrdIdl, b::fmpz) -> NfOrdFracIdl

Creates the fractional ideal $I/b$ of $\mathcal O$.

frac_ideal(O::NfOrd, a::nf_elem) -> NfOrdFracIdl

Creates the principal fractional ideal $(a)$ of $\mathcal O$.

frac_ideal(O::NfOrd, a::NfOrdElem) -> NfOrdFracIdl

Creates the principal fractional ideal $(a)$ of $\mathcal O$.

### Arithmetic

==(x::NfOrdFracIdl, y::NfOrdFracIdl) -> Bool

Returns whether $x$ and $y$ are equal.

### Miscaellenous

basis_mat(I::NfOrdFracIdl) -> FakeFmpqMat

Returns the basis matrix of $I$ with respect to the basis of the order.

basis_mat_inv(I::NfOrdFracIdl) -> FakeFmpqMat

Returns the inverse of the basis matrix of $I$.

basis(I::NfOrdFracIdl) -> Array{nf_elem, 1}

Returns the $\mathbf Z$-basis of $I$.

norm(I::NfOrdFracIdl) -> fmpq

Returns the norm of $I$