# Lattices

## Creation of lattices

### Inside a given ambient space

latticeMethod
lattice(V::AbsSpace) -> AbsLat

Given an ambient space V, return the lattice with the standard basis matrix. If V is hermitian (resp. quadratic) then the output is a hermitian (resp. quadratic) lattice.

latticeMethod
lattice(V::AbsSpace, B::PMat ; check::Bool = true) -> AbsLat

Given an ambient space V and a pseudo-matrix B, return the lattice spanned by the pseudo-matrix B inside V. If V is hermitian (resp. quadratic) then the output is a hermitian (resp. quadratic) lattice.

By default, B is checked to be of full rank. This test can be disabled by setting check to false.

latticeMethod
lattice(V::AbsSpace, basis::MatElem ; check::Bool = true) -> AbsLat

Given an ambient space V and a matrix basis, return the lattice spanned by the rows of basis inside V. If V is hermitian (resp. quadratic) then the output is a hermitian (resp. quadratic) lattice.

By default, basis is checked to be of full rank. This test can be disabled by setting check to false.

latticeMethod
lattice(V::AbsSpace, gens::Vector) -> AbsLat

Given an ambient space V and a list of generators gens, return the lattice spanned by gens in V. If V is hermitian (resp. quadratic) then the output is a hermitian (resp. quadratic) lattice.

If gens is empty, the function returns the zero lattice in V.

### Quadratic lattice over a number field

quadratic_latticeMethod
quadratic_lattice(K::Field ; gram::MatElem) -> QuadLat

Given a matrix gram and a field K, return the free quadratic lattice inside the quadratic space over K with Gram matrix gram.

quadratic_latticeMethod
quadratic_lattice(K::Field, B::PMat ; gram = nothing,
check:::Bool = true) -> QuadLat

Given a pseudo-matrix B with entries in a field K return the quadratic lattice spanned by the pseudo-matrix B inside the quadratic space over K with Gram matrix gram.

If gram is not supplied, the Gram matrix of the ambient space will be the identity matrix over K of size the number of columns of B.

By default, B is checked to be of full rank. This test can be disabled by setting check to false.

quadratic_latticeMethod
quadratic_lattice(K::Field, basis::MatElem ; gram = nothing,
check::Bool = true) -> QuadLat

Given a matrix basis and a field K, return the quadratic lattice spanned by the rows of basis inside the quadratic space over K with Gram matrix gram.

If gram is not supplied, the Gram matrix of the ambient space will be the identity matrix over K of size the number of columns of basis.

By default, basis is checked to be of full rank. This test can be disabled by setting check to false.

quadratic_latticeMethod
quadratic_lattice(K::Field, gens::Vector ; gram = nothing) -> QuadLat

Given a list of vectors gens and a field K, return the quadratic lattice spanned by the elements of gens inside the quadratic space over K with Gram matrix gram.

If gram is not supplied, the Gram matrix of the ambient space will be the identity matrix over K of size the length of the elements of gens.

If gens is empty, gram must be supplied and the function returns the zero lattice in the quadratic space over K with gram matrix gram.

### Hermitian lattice over a degree 2 extension

hermitian_latticeMethod
hermitian_lattice(E::NumField ; gram::MatElem) -> HermLat

Given a matrix gram and a number field E of degree 2, return the free hermitian lattice inside the hermitian space over E with Gram matrix gram.

hermitian_latticeMethod
hermitian_lattice(E::NumField, B::PMat ; gram = nothing,
check::Bool = true) -> HermLat

Given a pseudo-matrix B with entries in a number field E of degree 2, return the hermitian lattice spanned by the pseudo-matrix B inside the hermitian space over E with Gram matrix gram.

If gram is not supplied, the Gram matrix of the ambient space will be the identity matrix over E of size the number of columns of B.

By default, B is checked to be of full rank. This test can be disabled by setting check to false.

hermitian_latticeMethod
hermitian_lattice(E::NumField, basis::MatElem ; gram = nothing,
check::Bool = true) -> HermLat

Given a matrix basis and a number field E of degree 2, return the hermitian lattice spanned by the rows of basis inside the hermitian space over E with Gram matrix gram.

If gram is not supplied, the Gram matrix of the ambient space will be the identity matrix over E of size the number of columns of basis.

By default, basis is checked to be of full rank. This test can be disabled by setting check to false.

hermitian_latticeMethod
hermitian_lattice(E::NumField, gens::Vector ; gram = nothing) -> HermLat

Given a list of vectors gens and a number field E of degree 2, return the hermitian lattice spanned by the elements of gens inside the hermitian space over E with Gram matrix gram.

If gram is not supplied, the Gram matrix of the ambient space will be the identity matrix over E of size the length of the elements of gens.

If gens is empty, gram must be supplied and the function returns the zero lattice in the hermitan space over E with Gram matrix gram.

#### Examples

The two following examples will be used all along this section:

julia> K, a = rationals_as_number_field();julia> Kt, t = K["t"];julia> g = t^2 + 7;julia> E, b = NumberField(g, "b");julia> D = matrix(K, 3, 3, [2, 0, 0, 0, 2, 0, 0, 0, 2]);julia> gens = Vector{nf_elem}[map(K, [1, 1, 0]), map(K, [1, 0, 1]), map(K, [2, 0, 0])];julia> Lquad = quadratic_lattice(K, gens, gram = D)Quadratic lattice of rank 3 and degree 3
over
Maximal order of Number field over Rational Field with defining polynomial x - 1
with basis nf_elem[1]julia> D = matrix(E, 4, 4, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);julia> gens = Vector{Hecke.NfRelElem{nf_elem}}[map(E, [2, -1, 0, 0]), map(E, [-3, 0, -1, 0]), map(E, [0, 0, 0, -1]), map(E, [b, 0, 0, 0])];julia> Lherm = hermitian_lattice(E, gens, gram = D)Hermitian lattice of rank 4 and degree 4
over
Relative maximal order with pseudo-basis (1) * 1//1 * <1, 1>, (b + 1) * 1//2 * <1, 1>

Note that the format used here is the one given by the internal function Hecke.to_hecke() which prints REPL commands to get back the input lattice.

julia> K, a = rationals_as_number_field();julia> Kt, t = K["t"];julia> g = t^2 + 7;julia> E, b = NumberField(g, "b");julia> D = matrix(E, 4, 4, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);julia> gens = Vector{Hecke.NfRelElem{nf_elem}}[map(E, [2, -1, 0, 0]), map(E, [-3, 0, -1, 0]), map(E, [0, 0, 0, -1]), map(E, [b, 0, 0, 0])];julia> Lherm = hermitian_lattice(E, gens, gram = D);julia> Hecke.to_hecke(Lherm)Qx, x = PolynomialRing(FlintQQ, "x")
f = x - 1
K, a = NumberField(f, "a", cached = false)
Kt, t = PolynomialRing(K, "t")
g = t^2 + 7
E, b = NumberField(g, "b", cached = false)
D = matrix(E, 4, 4, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1])
gens = Vector{Hecke.NfRelElem{nf_elem}}[map(E, [2, -1, 0, 0]), map(E, [-3, 0, -1, 0]), map(E, [0, 0, 0, -1]), map(E, [b, 0, 0, 0])]
L = hermitian_lattice(E, gens, gram = D)

Finally, one can access some databases in which are stored several quadratic and hermitian lattices. Up to now, these are not automatically available while running Hecke. It can nonethelss be used in the following way:

julia> qld = Hecke.quadratic_lattice_database()Quadratic lattices of rank >= 3 with class number 1 or 2
Author: Markus Kirschmer
Source: http://www.math.rwth-aachen.de/~Markus.Kirschmer/forms/
Version: 0.0.1
Number of lattices: 30250julia> lattice(qld, 1)Quadratic lattice of rank 3 and degree 3
over
Maximal order of Number field over Rational Field with defining polynomial x - 1
with basis nf_elem[1]julia> hlb = Hecke.hermitian_lattice_database()Hermitian lattices of rank >= 3 with class number 1 or 2
Author: Markus Kirschmer
Source: http://www.math.rwth-aachen.de/~Markus.Kirschmer/forms/
Version: 0.0.1
Number of lattices: 570julia> lattice(hlb, 426)Hermitian lattice of rank 4 and degree 4
over
Relative maximal order with pseudo-basis (1) * 1//1 * <1, 1>, (b + 1) * 1//2 * <1, 1>

## Ambient space and rational span

ambient_spaceMethod
ambient_space(L::AbsLat) -> AbsSpace

Return the ambient space of the lattice L. If the ambient space is not known, an error is raised.

rational_spanMethod
rational_span(L::AbsLat) -> AbsSpace

Return the rational span of the lattice L.

diagonal_of_rational_spanMethod
diagonal_of_rational_span(L::AbsLat) -> Vector

Return the diagonal of the rational span of the lattice L.

### Examples

julia> K, a = rationals_as_number_field();julia> Kt, t = K["t"];julia> g = t^2 + 7;julia> E, b = NumberField(g, "b");julia> D = matrix(K, 3, 3, [2, 0, 0, 0, 2, 0, 0, 0, 2]);julia> gens = Vector{nf_elem}[map(K, [1, 1, 0]), map(K, [1, 0, 1]), map(K, [2, 0, 0])];julia> Lquad = quadratic_lattice(K, gens, gram = D);julia> D = matrix(E, 4, 4, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);julia> gens = Vector{Hecke.NfRelElem{nf_elem}}[map(E, [2, -1, 0, 0]), map(E, [-3, 0, -1, 0]), map(E, [0, 0, 0, -1]), map(E, [b, 0, 0, 0])];julia> Lherm = hermitian_lattice(E, gens, gram = D);julia> ambient_space(Lherm)Hermitian space over
Relative number field with defining polynomial t^2 + 7
over Number field over Rational Field with defining polynomial x - 1
with Gram matrix
[1 0 0 0; 0 1 0 0; 0 0 1 0; 0 0 0 1]julia> rational_span(Lquad)Quadratic space over
Number field over Rational Field with defining polynomial x - 1
with Gram matrix
[2 2 2; 2 4 2; 2 2 4]julia> basis_matrix_of_rational_span(Lherm)[1   0   0   0]
[5   1   0   0]
[3   0   1   0]
[0   0   0   1]julia> gram_matrix_of_rational_span(Lherm)[1    5    3   0]
[5   26   15   0]
[3   15   10   0]
[0    0    0   1]julia> diagonal_of_rational_span(Lquad)3-element Vector{nf_elem}:
2
2
2

## Rational equivalence

hasse_invariantMethod
hasse_invariant(L::AbsLat, p::Union{InfPlc, NfOrdIdl}) -> Int

Return the Hasse invariant of the rational span of the lattice L at the place p. The lattice must be quadratic.

witt_invariantMethod
witt_invariant(L::AbsLat, p::Union{InfPlc, NfOrdIdl}) -> Int

Return the Witt invariant of the rational span of the lattice L at the place p. The lattice must be quadratic.

is_rationally_isometricMethod
is_rationally_isometric(L::AbsLat, M::AbsLat, p::Union{InfPlc, NfAbsOrdIdl})
-> Bool

Return whether the rational spans of the lattices L and M are isometric over the completion at the place p.

is_rationally_isometricMethod
is_rationally_isometric(L::AbsLat, M::AbsLat) -> Bool

Return whether the rational spans of the lattices L and M are isometric.

### Examples

For now and for the rest of this section, the examples will include the new lattice Lquad2 which is quadratic. Moreover, all the completions are going to be done at the prime ideal $p = 7*\mathcal O_K$.

julia> K, a = rationals_as_number_field();julia> D = matrix(K, 3, 3, [2, 0, 0, 0, 2, 0, 0, 0, 2]);julia> gens = Vector{nf_elem}[map(K, [1, 1, 0]), map(K, [1, 0, 1]), map(K, [2, 0, 0])];julia> Lquad = quadratic_lattice(K, gens, gram = D);julia> D = matrix(K, 3, 3, [2, 0, 0, 0, 2, 0, 0, 0, 2]);julia> gens = Vector{nf_elem}[map(K, [-35, 25, 0]), map(K, [30, 40, -20]), map(K, [5, 10, -5])];julia> Lquad2 = quadratic_lattice(K, gens, gram = D)Quadratic lattice of rank 3 and degree 3
over
Maximal order of Number field over Rational Field with defining polynomial x - 1
with basis nf_elem[1]julia> OK = maximal_order(K);julia> p = prime_decomposition(OK, 7)[1][1]<7, 7>
Norm: 7
Minimum: 7
principal generator 7
two normal wrt: 7julia> hasse_invariant(Lquad, p), witt_invariant(Lquad, p)(1, 1)julia> is_rationally_isometric(Lquad, Lquad2, p)truejulia> is_rationally_isometric(Lquad, Lquad2)true

## Attributes

Let $L$ be a lattice over $E/K$. We call a pseudo-basis of $L$ any sequence of pairs $(\mathfrak A_i, x_i)_{1 \leq i \leq n}$ where the $\mathfrak A_i$'s are fractional (left) ideals of $\mathcal O_E$ and $(x_i)_{1 \leq i \leq n}$ is a basis of the rational span of $L$, and such that

$$$L = \bigoplus_{i = 1}^n \mathfrak A_ix_i.$$$

Note that a pseudo-basis is not unique. Given a pseudo-basis $(\mathfrak A_i, x_i)_{1 \leq i \leq n}$ of $L$, we define the corresponding pseudo-matrix of $L$ to be the datum consisting of a list of coefficient ideals corresponding to the ideals $\mathfrak A_i$'s and a matrix whose rows are the coordinates of the $x_i$'s in the canonical basis of the ambient space of $L$ (conversely, given any such pseudo-matrix, one can define the corresponding pseudo-basis).

rankMethod
rank(L::AbsLat) -> Int

Return the rank of the underlying module of the lattice L.

degreeMethod
degree(L::AbsLat) -> Int

Return the dimension of the ambient space of the lattice L.

discriminantMethod
discriminant(L::AbsLat) -> NfOrdFracIdl

Return the discriminant of the lattice L, that is, the generalized index ideal $[L^\# : L]$.

base_fieldMethod
base_field(L::AbsLat) -> Field

Return the algebra over which the rational span of the lattice L is defined.

base_ringMethod
base_ring(L::AbsLat) -> Ring

Return the order over which the lattice L is defined.

fixed_fieldMethod
fixed_field(L::AbsLat) -> Field

Returns the fixed field of the involution of the lattice L.

fixed_ringMethod
fixed_ring(L::AbsLat) -> Ring

Return the maximal order in the fixed field of the lattice L.

involutionMethod
involution(L::AbsLat) -> Map

Return the involution of the rational span of the lattice L.

pseudo_matrixMethod
pseudo_matrix(L::AbsLat) -> PMat

Return a basis pseudo-matrix of the lattice L.

pseudo_basisMethod
pseudo_basis(L::AbsLat) -> Vector{Tuple{Vector, Ideal}}

Return a pseudo-basis of the lattice L.

coefficient_idealsMethod
coefficient_ideals(L::AbsLat) -> Vector{NfOrdIdl}

Return the coefficient ideals of a pseudo-basis of the lattice L.

absolute_basis_matrixMethod
absolute_basis_matrix(L::AbsLat) -> MatElem

Return a $\mathbf{Z}$-basis matrix of the lattice L.

absolute_basisMethod
absolute_basis(L::AbsLat) -> Vector

Return a $\mathbf{Z}$-basis of the lattice L.

generatorsMethod
generators(L::AbsLat; minimal = false) -> Vector{Vector}

Return a set of generators of the lattice L over the base ring of L.

If minimal == true, the number of generators is minimal. Note that computing minimal generators is expensive.

gram_matrix_of_generatorsMethod
gram_matrix_of_generators(L::AbsLat; minimal::Bool = false) -> MatElem

Return the Gram matrix of a generating set of the lattice L.

If minimal == true, then a minimal generating set is used. Note that computing minimal generators is expensive.

### Examples

julia> K, a = rationals_as_number_field();julia> Kt, t = K["t"];julia> g = t^2 + 7;julia> E, b = NumberField(g, "b");julia> D = matrix(E, 4, 4, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);julia> gens = Vector{Hecke.NfRelElem{nf_elem}}[map(E, [2, -1, 0, 0]), map(E, [-3, 0, -1, 0]), map(E, [0, 0, 0, -1]), map(E, [b, 0, 0, 0])];julia> Lherm = hermitian_lattice(E, gens, gram = D);julia> rank(Lherm), degree(Lherm)(4, 4)julia> discriminant(Lherm)Fractional ideal of
Relative maximal order with pseudo-basis (1) * 1//1 * <1, 1>, (b + 1) * 1//2 * <1, 1>
with basis pseudo-matrix
(1//1 * <7, 7>) * [1 0]
(1//2 * <7, 7>) * [0 1]julia> base_field(Lherm)Relative number field with defining polynomial t^2 + 7
over Number field over Rational Field with defining polynomial x - 1julia> base_ring(Lherm)Relative maximal order of Relative number field with defining polynomial t^2 + 7
over Number field over Rational Field with defining polynomial x - 1
with pseudo-basis
(1, 1//1 * <1, 1>)
(b + 1, 1//2 * <1, 1>)julia> fixed_field(Lherm)Number field over Rational Field with defining polynomial x - 1julia> fixed_ring(Lherm)Maximal order of Number field over Rational Field with defining polynomial x - 1
with basis nf_elem[1]julia> involution(Lherm)Map with following data
Domain:
=======
Relative number field with defining polynomial t^2 + 7
over Number field over Rational Field with defining polynomial x - 1
Codomain:
=========
Relative number field with defining polynomial t^2 + 7
over Number field over Rational Field with defining polynomial x - 1julia> pseudo_matrix(Lherm)Pseudo-matrix over Relative maximal order of Relative number field with defining polynomial t^2 + 7
over Number field over Rational Field with defining polynomial x - 1
with pseudo-basis
(1, 1//1 * <1, 1>)
(b + 1, 1//2 * <1, 1>)
Fractional ideal with row [1 0 0 0]
Fractional ideal with row [5 1 0 0]
Fractional ideal with row [3 0 1 0]
Fractional ideal with row [0 0 0 1]julia> pseudo_basis(Lherm)4-element Vector{Tuple{Vector{Hecke.NfRelElem{nf_elem}}, Hecke.NfRelOrdFracIdl{nf_elem, Hecke.NfAbsOrdFracIdl{AnticNumberField, nf_elem}, Hecke.NfRelElem{nf_elem}}}}:
([1, 0, 0, 0], Fractional ideal of
Relative maximal order with pseudo-basis (1) * 1//1 * <1, 1>, (b + 1) * 1//2 * <1, 1>
with basis pseudo-matrix
(1//1 * <7, 28>) * [1 0]
(1//2 * <1, 1>) * [6 1])
([5, 1, 0, 0], Fractional ideal of
Relative maximal order with pseudo-basis (1) * 1//1 * <1, 1>, (b + 1) * 1//2 * <1, 1>
with basis pseudo-matrix
(1//1 * <1, 1>) * [1 0]
(1//2 * <1, 1>) * [0 1])
([3, 0, 1, 0], Fractional ideal of
Relative maximal order with pseudo-basis (1) * 1//1 * <1, 1>, (b + 1) * 1//2 * <1, 1>
with basis pseudo-matrix
(1//1 * <1, 1>) * [1 0]
(1//2 * <1, 1>) * [0 1])
([0, 0, 0, 1], Fractional ideal of
Relative maximal order with pseudo-basis (1) * 1//1 * <1, 1>, (b + 1) * 1//2 * <1, 1>
with basis pseudo-matrix
(1//1 * <1, 1>) * [1 0]
(1//2 * <1, 1>) * [0 1])julia> coefficient_ideals(Lherm)4-element Vector{Hecke.NfRelOrdFracIdl{nf_elem, Hecke.NfAbsOrdFracIdl{AnticNumberField, nf_elem}, Hecke.NfRelElem{nf_elem}}}:
Fractional ideal of
Relative maximal order with pseudo-basis (1) * 1//1 * <1, 1>, (b + 1) * 1//2 * <1, 1>
with basis pseudo-matrix
(1//1 * <7, 28>) * [1 0]
(1//2 * <1, 1>) * [6 1]
Fractional ideal of
Relative maximal order with pseudo-basis (1) * 1//1 * <1, 1>, (b + 1) * 1//2 * <1, 1>
with basis pseudo-matrix
(1//1 * <1, 1>) * [1 0]
(1//2 * <1, 1>) * [0 1]
Fractional ideal of
Relative maximal order with pseudo-basis (1) * 1//1 * <1, 1>, (b + 1) * 1//2 * <1, 1>
with basis pseudo-matrix
(1//1 * <1, 1>) * [1 0]
(1//2 * <1, 1>) * [0 1]
Fractional ideal of
Relative maximal order with pseudo-basis (1) * 1//1 * <1, 1>, (b + 1) * 1//2 * <1, 1>
with basis pseudo-matrix
(1//1 * <1, 1>) * [1 0]
(1//2 * <1, 1>) * [0 1]julia> absolute_basis_matrix(Lherm)[            7               0               0               0]
[1//2*b + 7//2               0               0               0]
[            5               1               0               0]
[5//2*b + 5//2   1//2*b + 1//2               0               0]
[            3               0               1               0]
[3//2*b + 3//2               0   1//2*b + 1//2               0]
[            0               0               0               1]
[            0               0               0   1//2*b + 1//2]julia> absolute_basis(Lherm)8-element Vector{Vector{Hecke.NfRelElem{nf_elem}}}:
[7, 0, 0, 0]
[1//2*b + 7//2, 0, 0, 0]
[5, 1, 0, 0]
[5//2*b + 5//2, 1//2*b + 1//2, 0, 0]
[3, 0, 1, 0]
[3//2*b + 3//2, 0, 1//2*b + 1//2, 0]
[0, 0, 0, 1]
[0, 0, 0, 1//2*b + 1//2]julia> generators(Lherm)4-element Vector{Vector{Hecke.NfRelElem{nf_elem}}}:
[2, -1, 0, 0]
[-3, 0, -1, 0]
[0, 0, 0, -1]
[b, 0, 0, 0]julia> gram_matrix_of_generators(Lherm)[  5     -6   0   -2*b]
[ -6     10   0    3*b]
[  0      0   1      0]
[2*b   -3*b   0      7]

## Module operations

Let $L$ be a lattice over $E/K$ inside the space $(V, \Phi)$. The dual lattice of $L$ is defined to be the following lattice over $E/K$ in $(V, \Phi)$:

$$$L^{\#} = \left\{ x \in V \mid \Phi(x,L) \subseteq \mathcal O_E \right\}.$$$

For any fractional (left) ideal $\mathfrak a$ of $\mathcal O_E$, one can define the lattice $\mathfrak aL$ to be the lattice over $E/K$, in the same space $(V, \Phi)$, obtained by rescaling the coefficient ideals of a pseudo-basis of $L$ by $\mathfrak a$. In another flavour, for any non-zero element $a \in K$, one defines the rescaled lattice $L^a$ to be the lattice over $E/K$ with the same underlying module as $L$ (i.e. the same pseudo-bases) but in space $(V, a\Phi)$.

+Method
+(L::AbsLat, M::AbsLat) -> AbsLat

Return the sum of the lattices L and M.

The lattices L and M must have the same ambient space.

*Method
*(a::NumFieldElem, L::AbsLat) -> AbsLat

Return the lattice $aL$ inside the ambient space of the lattice L.

*Method
*(a::NumFieldOrdIdl, L::AbsLat) -> AbsLat

Return the lattice $aL$ inside the ambient space of the lattice L.

*Method
*(a::NumFieldOrdFracIdl, L::AbsLat) -> AbsLat

Return the lattice $aL$ inside the ambient space of the lattice L.

rescaleMethod
rescale(L::AbsLat, a::NumFieldElem) -> AbsLat

Return the rescaled lattice $L^a$. Note that this has a different ambient space than the lattice L.

dualMethod
dual(L::AbsLat) -> AbsLat

Return the dual lattice of the lattice L.

intersectMethod
intersect(L::AbsLat, M::AbsLat) -> AbsLat

Return the intersection of the lattices L and M.

The lattices L and M must have the same ambient space.

primitive_closureMethod
primitive_closure(M::AbsLat, N::AbsLat) -> AbsLat

Given two lattices M and N defined over a number field E, with $N \subseteq E\otimes M$, return the primitive closure $M \cap E\otimes N$ of N in M.

One can also use the alias saturate(L, M).

orthogonal_submoduleMethod
orthogonal_submodule(L::AbsLat, M::AbsLat) -> AbsLat

Return the largest submodule of L orthogonal to M.

### Examples

julia> K, a = rationals_as_number_field();julia> D = matrix(K, 3, 3, [2, 0, 0, 0, 2, 0, 0, 0, 2]);julia> gens = Vector{nf_elem}[map(K, [1, 1, 0]), map(K, [1, 0, 1]), map(K, [2, 0, 0])];julia> Lquad = quadratic_lattice(K, gens, gram = D);julia> D = matrix(K, 3, 3, [2, 0, 0, 0, 2, 0, 0, 0, 2]);julia> gens = Vector{nf_elem}[map(K, [-35, 25, 0]), map(K, [30, 40, -20]), map(K, [5, 10, -5])];julia> Lquad2 = quadratic_lattice(K, gens, gram = D);julia> OK = maximal_order(K);julia> p = prime_decomposition(OK, 7)[1][1];julia> pseudo_matrix(Lquad + Lquad2)Pseudo-matrix over Maximal order of Number field over Rational Field with defining polynomial x - 1
with basis nf_elem[1]
1//1 * <2, 2> with row [1 0 0]
1//1 * <1, 1> with row [1 1 0]
1//1 * <1, 1> with row [1 0 1]julia> pseudo_matrix(intersect(Lquad, Lquad2))Pseudo-matrix over Maximal order of Number field over Rational Field with defining polynomial x - 1
with basis nf_elem[1]
1//1 * <10, 10> with row [1 0 0]
1//1 * <25, 25> with row [1//5 1 0]
1//1 * <5, 5> with row [0 3 1]julia> pseudo_matrix(p*Lquad)Pseudo-matrix over Maximal order of Number field over Rational Field with defining polynomial x - 1
with basis nf_elem[1]
1//1 * <14, 126> with row [1 0 0]
1//1 * <7, 7> with row [1 1 0]
1//1 * <7, 7> with row [1 0 1]julia> ambient_space(rescale(Lquad,3*a))Quadratic space over
Number field over Rational Field with defining polynomial x - 1
with Gram matrix
[6 0 0; 0 6 0; 0 0 6]julia> pseudo_matrix(Lquad)Pseudo-matrix over Maximal order of Number field over Rational Field with defining polynomial x - 1
with basis nf_elem[1]
1//1 * <2, 2> with row [1 0 0]
1//1 * <1, 1> with row [1 1 0]
1//1 * <1, 1> with row [1 0 1]

## Invariants

Let $L$ be a lattice over $E/K$, in the space $(V, \Phi)$. We define:

• the norm $\mathfrak n(L)$ of $L$ to be the ideal of $\mathcal O_K$ generated by the squares $\left\{\Phi(x,x) \mid x \in L \right\}$;
• the scale $\mathfrak s(L)$ of $L$ to be the set $\Phi(L,L) = \left\{\Phi(x,y) \mid x,y \in L \right\}$;
• the volume $\mathfrak v(L)$ of $L$ to be the index ideal
$$$\lbrack L^{\#} \colon L \rbrack_{\mathcal O_E} := \langle \left\{ \sigma \mid \sigma \in \text{Hom}_{\mathcal O_E}(L^{\#}, L) \right\} \rangle_{\mathcal O_E}.$$$

Note that these are fractional ideals of $\mathcal O_E$.

normMethod
norm(L::AbsLat) -> NfOrdFracIdl

Return the norm of the lattice L. This is a fractional ideal of the fixed field of L.

scaleMethod
scale(L::AbsLat) -> NfOrdFracIdl

Return the scale of the lattice L.

volumeMethod
volume(L::AbsLat) -> NfOrdFracIdl

Return the volume of the lattice L.

### Examples

julia> K, a = rationals_as_number_field();julia> Kt, t = K["t"];julia> g = t^2 + 7;julia> E, b = NumberField(g, "b");julia> D = matrix(E, 4, 4, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);julia> gens = Vector{Hecke.NfRelElem{nf_elem}}[map(E, [2, -1, 0, 0]), map(E, [-3, 0, -1, 0]), map(E, [0, 0, 0, -1]), map(E, [b, 0, 0, 0])];julia> Lherm = hermitian_lattice(E, gens, gram = D);julia> norm(Lherm)1//1 * <1, 1>
Norm: 1
Minimum: 1
principal generator 1
basis_matrix
[1]
two normal wrt: 2julia> scale(Lherm)Fractional ideal of
Relative maximal order with pseudo-basis (1) * 1//1 * <1, 1>, (b + 1) * 1//2 * <1, 1>
with basis pseudo-matrix
(1//1 * <1, 1>) * [1 0]
(1//2 * <1, 1>) * [0 1]julia> volume(Lherm)Fractional ideal of
Relative maximal order with pseudo-basis (1) * 1//1 * <1, 1>, (b + 1) * 1//2 * <1, 1>
with basis pseudo-matrix
(1//1 * <7, 7>) * [1 0]
(1//2 * <7, 7>) * [0 1]

## Predicates

Let $L$ be a lattice over $E/K$. It is said to be integral if its scale is an integral ideal, i.e. it is contained in $\mathcal O_E$. Moreover, if $\mathfrak p$ is a prime ideal in $\mathcal O_K$, then $L$ is said to be modular (resp. locally modular at $\mathfrak p$) if there exists a fractional ideal $\mathfrak a$ of $\mathcal O_E$ (resp. an integer $v$) such that $\mathfrak aL^{\#} = L$ (resp. $\mathfrak p^vL_{\mathfrak p}^{\#} = L_{\mathfrak p}$).

is_integralMethod
is_integral(L::AbsLat) -> Bool

Return whether the lattice L is integral.

is_modularMethod
is_modular(L::AbsLat) -> Bool, NfOrdFracIdl

Return whether the lattice L is modular. In this case, the second returned value is a fractional ideal $\mathfrak a$ of the base algebra of L such that $\mathfrak a L^\# = L$, where $L^\#$ is the dual of L.

is_modularMethod
is_modular(L::AbsLat, p::NfOrdIdl) -> Bool, Int

Return whether the completion $L_{p}$ of the lattice L at the prime ideal p is modular. If it is the case the second returned value is an integer v such that $L_{p}$ is $p^v$-modular.

is_positive_definiteMethod
is_positive_definite(L::AbsLat) -> Bool

Return whether the rational span of the lattice L is positive definite.

is_negative_definiteMethod
is_negative_definite(L::AbsLat) -> Bool

Return whether the rational span of the lattice L is negative definite.

is_definiteMethod
is_definite(L::AbsLat) -> Bool

Return whether the rational span of the lattice L is definite.

can_scale_totally_positiveMethod
can_scale_totally_positive(L::AbsLat) -> Bool, NumFieldElem

Return whether there is a totally positive rescaled lattice of the lattice L. If so, the second returned value is an element $a$ such that $L^a$ is totally positive.

### Examples

julia> K, a = rationals_as_number_field();julia> Kt, t = K["t"];julia> g = t^2 + 7;julia> E, b = NumberField(g, "b");julia> D = matrix(E, 4, 4, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);julia> gens = Vector{Hecke.NfRelElem{nf_elem}}[map(E, [2, -1, 0, 0]), map(E, [-3, 0, -1, 0]), map(E, [0, 0, 0, -1]), map(E, [b, 0, 0, 0])];julia> Lherm = hermitian_lattice(E, gens, gram = D);julia> OK = maximal_order(K);julia> is_integral(Lherm)truejulia> is_modular(Lherm)[1]falsejulia> p = prime_decomposition(OK, 7)[1][1];julia> is_modular(Lherm, p)(false, 0)julia> is_positive_definite(Lherm)truejulia> can_scale_totally_positive(Lherm)(true, 1)

## Local properties

local_basis_matrixMethod
local_basis_matrix(L::AbsLat, p::NfOrdIdl; type = :any) -> MatElem

Given a prime ideal p and a lattice L, return a basis matrix of a lattice M such that $M_{p} = L_{p}$. Note that if p is an ideal in the base ring of L, the completions are taken at the minimum of p (which is an ideal in the base ring of the order of p).

• If type == :submodule, the lattice L will be a sublattice of M.
• If type == :supermodule, the lattice L will be a superlattice of M.
• If type == :any, there may not be any containment relation between M and L.
jordan_decompositionMethod
jordan_decomposition(L::AbsLat, p::NfOrdIdl)
-> Vector{MatElem}, Vector{MatElem}, Vector{Int}

Return a Jordan decomposition of the completion of the lattice L at a prime ideal p.

The returned value consists of three lists $(M_i)_i$, $(G_i)_i$ and $(s_i)_i$ of the same length $r$. The completions of the row spans of the matrices $M_i$ yield a Jordan decomposition of $L_{p}$ into modular sublattices $L_i$ with Gram matrices $G_i$ and scale of $p$-adic valuation $s_i$.

is_isotropicMethod
is_isotropic(L::AbsLat, p::Union{NfOrdIdl, InfPlc}) -> Bool

Return whether the completion of the lattice L at the place p is isotropic.

### Examples

julia> K, a = rationals_as_number_field();julia> D = matrix(K, 3, 3, [2, 0, 0, 0, 2, 0, 0, 0, 2]);julia> gens = Vector{nf_elem}[map(K, [1, 1, 0]), map(K, [1, 0, 1]), map(K, [2, 0, 0])];julia> Lquad = quadratic_lattice(K, gens, gram = D);julia> OK = maximal_order(K);julia> p = prime_decomposition(OK, 7)[1][1];julia> local_basis_matrix(Lquad, p)[1   0   0]
[1   1   0]
[1   0   1]julia> jordan_decomposition(Lquad, p)(AbstractAlgebra.Generic.MatSpaceElem{nf_elem}[[1 0 0; 0 1 0; 0 0 1]], AbstractAlgebra.Generic.MatSpaceElem{nf_elem}[[2 0 0; 0 2 0; 0 0 2]], [0])julia> is_isotropic(Lquad, p)true

## Automorphisms for definite lattices

Let $L$ and $L'$ be two lattices over the same extension $E/K$, inside their respective ambient spaces $(V, \Phi)$ and $(V', \Phi')$. Similarly to homomorphisms of spaces, we define a homomorphism of lattices from $L$ to $L'$ to be an $E$-module homomorphism $f \colon L \to L'$ such that for all $x,y \in L$, one has

$$$\Phi'(f(x), f(y)) = \Phi(x,y).$$$

Again, any automorphism of lattices is called an isometry and any monomorphism is called an embedding. We refer to the set of isometries from a lattice $L$ to itself as the automorphism group of $L$.

automorphism_group_orderMethod
automorphism_group_order(L::AbsLat) -> Int

Given a definite lattice L, return the order of the automorphism group of L.

automorphism_group_generatorsMethod
automorphism_group_generators(L::AbsLat; ambient_representation::Bool = true)
-> Vector{MatElem}

Given a definite lattice L, return generators for the automorphism group of L. If ambient_representation == true (the default), the transformations are represented with respect to the ambient space of L. Otherwise, the transformations are represented with respect to the (pseudo-)basis of L.

### Examples

julia> K, a = rationals_as_number_field();julia> Kt, t = K["t"];julia> g = t^2 + 7;julia> E, b = NumberField(g, "b");julia> D = matrix(K, 3, 3, [2, 0, 0, 0, 2, 0, 0, 0, 2]);julia> gens = Vector{nf_elem}[map(K, [1, 1, 0]), map(K, [1, 0, 1]), map(K, [2, 0, 0])];julia> Lquad = quadratic_lattice(K, gens, gram = D);julia> is_definite(Lquad)truejulia> automorphism_group_order(Lquad)48julia> automorphism_group_generators(Lquad)6-element Vector{AbstractAlgebra.Generic.MatSpaceElem{nf_elem}}:
[-1 0 0; 0 -1 0; 0 0 -1]
[1 0 0; 0 -1 0; 0 0 -1]
[1 0 0; 0 0 -1; 0 -1 0]
[0 -1 0; 0 0 -1; 1 0 0]
[1 0 0; 0 1 0; 0 0 -1]
[0 1 0; 1 0 0; 0 0 1]

## Isometry

is_isometricMethod
is_isometric(L::AbsLat, M::AbsLat) -> Bool

Return whether the lattices L and M are isometric.

is_isometric_with_isometryMethod
is_isometric_with_isometry(L::AbsLat, M::AbsLat; ambient_representation::Bool = true)
-> (Bool, MatElem)

Return whether the lattices L and M are isometric. If this is the case, the second returned value is an isometry T from L to M.

By default, that isometry is represented with respect to the bases of the ambient spaces, that is, $T V_M T^t = V_L$ where $V_L$ and $V_M$ are the Gram matrices of the ambient spaces of L and M respectively. If ambient_representation == false, then the isometry is represented with respect to the (pseudo-)bases of L and M, that is, $T G_M T^t = G_L$ where $G_M$ and $G_L$ are the Gram matrices of the (pseudo-)bases of L and M respectively.

is_locally_isometricMethod
is_locally_isometric(L::AbsLat, M::AbsLat, p::NfOrdIdl) -> Bool

Return whether the completions of the lattices L and M at the prime ideal p are isometric.

### Examples

julia> K, a = rationals_as_number_field();julia> D = matrix(K, 3, 3, [2, 0, 0, 0, 2, 0, 0, 0, 2]);julia> gens = Vector{nf_elem}[map(K, [1, 1, 0]), map(K, [1, 0, 1]), map(K, [2, 0, 0])];julia> Lquad = quadratic_lattice(K, gens, gram = D);julia> D = matrix(K, 3, 3, [2, 0, 0, 0, 2, 0, 0, 0, 2]);julia> gens = Vector{nf_elem}[map(K, [-35, 25, 0]), map(K, [30, 40, -20]), map(K, [5, 10, -5])];julia> Lquad2 = quadratic_lattice(K, gens, gram = D);julia> OK = maximal_order(K);julia> p = prime_decomposition(OK, 7)[1][1];julia> is_isometric(Lquad, Lquad2)falsejulia> is_locally_isometric(Lquad, Lquad2, p)true

## Maximal integral lattices

is_maximal_integralMethod
is_maximal_integral(L::AbsLat, p::NfOrdIdl) -> Bool, AbsLat

Given a lattice L and a prime ideal p of the fixed ring $\mathcal O_K$ of L, return whether the completion of L at p is maximal integral. If it is not the case, the second returned value is a lattice in the ambient space of L whose completion at p is a minimal overlattice of $L_p$.

is_maximal_integralMethod
is_maximal_integral(L::AbsLat) -> Bool, AbsLat

Given a lattice L, return whether L is maximal integral. If it is not, the second returned value is a minimal overlattice of L with integral norm.

is_maximalMethod
is_maximal(L::AbsLat, p::NfOrdIdl) -> Bool, AbsLat

Given a lattice L and a prime ideal p in the fixed ring $\mathcal O_K$ of L, check whether the norm of $L_p$ is integral and return whether L is maximal at p. If it is locally integral but not locally maximal, the second returned value is a lattice in the same ambient space of L whose completion at p has integral norm and is a proper overlattice of $L_p$.

maximal_integral_latticeMethod
maximal_integral_lattice(L::AbsLat, p::NfOrdIdl) -> AbsLat

Given a lattice L and a prime ideal p of the fixed ring $\mathcal O_K$ of L, return a lattice M in the ambient space of L which is maximal integral at p and which agrees with L locally at all the places different from p.

maximal_integral_latticeMethod
maximal_integral_lattice(L::AbsLat) -> AbsLat

Given a lattice L, return a lattice M in the ambient space of L which is maximal integral and which contains L.

maximal_integral_latticeMethod
maximal_integral_lattice(V::AbsSpace) -> AbsLat

Given a space V, return a lattice in V with integral norm and which is maximal in V satisfying this property.

### Examples

julia> K, a = rationals_as_number_field();julia> Kt, t = K["t"];julia> g = t^2 + 7;julia> E, b = NumberField(g, "b");julia> D = matrix(E, 4, 4, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);julia> gens = Vector{Hecke.NfRelElem{nf_elem}}[map(E, [2, -1, 0, 0]), map(E, [-3, 0, -1, 0]), map(E, [0, 0, 0, -1]), map(E, [b, 0, 0, 0])];julia> Lherm = hermitian_lattice(E, gens, gram = D);julia> OK = maximal_order(K);julia> p = prime_decomposition(OK, 7)[1][1];julia> is_maximal_integral(Lherm, p)(false, Hermitian lattice of rank 4 and degree 4
over
Relative maximal order with pseudo-basis (1) * 1//1 * <1, 1>, (b + 1) * 1//2 * <1, 1>)julia> is_maximal_integral(Lherm)(false, Hermitian lattice of rank 4 and degree 4
over
Relative maximal order with pseudo-basis (1) * 1//1 * <1, 1>, (b + 1) * 1//2 * <1, 1>)julia> is_maximal(Lherm, p)(false, Hermitian lattice of rank 4 and degree 4
over
Relative maximal order with pseudo-basis (1) * 1//1 * <1, 1>, (b + 1) * 1//2 * <1, 1>)julia> pseudo_basis(maximal_integral_lattice(Lherm, p))4-element Vector{Tuple{Vector{Hecke.NfRelElem{nf_elem}}, Hecke.NfRelOrdFracIdl{nf_elem, Hecke.NfAbsOrdFracIdl{AnticNumberField, nf_elem}, Hecke.NfRelElem{nf_elem}}}}:
([1, 0, 0, 0], Fractional ideal of
Relative maximal order with pseudo-basis (1) * 1//1 * <1, 1>, (b + 1) * 1//2 * <1, 1>
with basis pseudo-matrix
(1//1 * <1, 1>) * [1 0]
(1//2 * <1, 1>) * [0 1])
([0, 1, 0, 0], Fractional ideal of
Relative maximal order with pseudo-basis (1) * 1//1 * <1, 1>, (b + 1) * 1//2 * <1, 1>
with basis pseudo-matrix
(1//1 * <1, 1>) * [1 0]
(1//2 * <1, 1>) * [0 1])
([2, 4, 1, 0], Fractional ideal of
Relative maximal order with pseudo-basis (1) * 1//1 * <1, 1>, (b + 1) * 1//2 * <1, 1>
with basis pseudo-matrix
(1//1 * <1, 1>) * [1 0]
(1//14 * <1, 1>) * [6 1])
([3, 2, 0, 1], Fractional ideal of
Relative maximal order with pseudo-basis (1) * 1//1 * <1, 1>, (b + 1) * 1//2 * <1, 1>
with basis pseudo-matrix
(1//1 * <1, 1>) * [1 0]
(1//14 * <1, 1>) * [6 1])julia> pseudo_basis(maximal_integral_lattice(Lherm))4-element Vector{Tuple{Vector{Hecke.NfRelElem{nf_elem}}, Hecke.NfRelOrdFracIdl{nf_elem, Hecke.NfAbsOrdFracIdl{AnticNumberField, nf_elem}, Hecke.NfRelElem{nf_elem}}}}:
([1, 0, 0, 0], Fractional ideal of
Relative maximal order with pseudo-basis (1) * 1//1 * <1, 1>, (b + 1) * 1//2 * <1, 1>
with basis pseudo-matrix
(1//1 * <1, 1>) * [1 0]
(1//2 * <1, 1>) * [0 1])
([0, 1, 0, 0], Fractional ideal of
Relative maximal order with pseudo-basis (1) * 1//1 * <1, 1>, (b + 1) * 1//2 * <1, 1>
with basis pseudo-matrix
(1//1 * <1, 1>) * [1 0]
(1//2 * <1, 1>) * [0 1])
([2, 4, 1, 0], Fractional ideal of
Relative maximal order with pseudo-basis (1) * 1//1 * <1, 1>, (b + 1) * 1//2 * <1, 1>
with basis pseudo-matrix
(1//1 * <1, 1>) * [1 0]
(1//14 * <1, 1>) * [6 1])
([3, 2, 0, 1], Fractional ideal of
Relative maximal order with pseudo-basis (1) * 1//1 * <1, 1>, (b + 1) * 1//2 * <1, 1>
with basis pseudo-matrix
(1//1 * <1, 1>) * [1 0]
(1//14 * <1, 1>) * [6 1])julia> pseudo_basis(maximal_integral_lattice(ambient_space(Lherm)))4-element Vector{Tuple{Vector{Hecke.NfRelElem{nf_elem}}, Hecke.NfRelOrdFracIdl{nf_elem, Hecke.NfAbsOrdFracIdl{AnticNumberField, nf_elem}, Hecke.NfRelElem{nf_elem}}}}:
([1, 0, 0, 0], Fractional ideal of
Relative maximal order with pseudo-basis (1) * 1//1 * <1, 1>, (b + 1) * 1//2 * <1, 1>
with basis pseudo-matrix
(1//1 * <1, 1>) * [1 0]
(1//2 * <1, 1>) * [0 1])
([0, 1, 0, 0], Fractional ideal of
Relative maximal order with pseudo-basis (1) * 1//1 * <1, 1>, (b + 1) * 1//2 * <1, 1>
with basis pseudo-matrix
(1//1 * <1, 1>) * [1 0]
(1//2 * <1, 1>) * [0 1])
([4, 2, 1, 0], Fractional ideal of
Relative maximal order with pseudo-basis (1) * 1//1 * <1, 1>, (b + 1) * 1//2 * <1, 1>
with basis pseudo-matrix
(1//1 * <1, 1>) * [1 0]
(1//14 * <1, 1>) * [6 1])
([2, 3, 0, 1], Fractional ideal of
Relative maximal order with pseudo-basis (1) * 1//1 * <1, 1>, (b + 1) * 1//2 * <1, 1>
with basis pseudo-matrix
(1//1 * <1, 1>) * [1 0]
(1//14 * <1, 1>) * [6 1])