# Quadratic spaces with isometry

We call *quadratic space with isometry* any pair $(V, f)$ consisting of a non-degenerate quadratic space $V$ together with an isometry $f\in O(V)$. We refer to the section about Spaces of the documentation for new users.

Note that currently, we support only rational quadratic forms, i.e. quadratic spaces defined over $\mathbb{Q}$.

In Oscar, such a pair is encoded by the type called `QuadSpaceWithIsom`

:

`QuadSpaceWithIsom`

— Type`QuadSpaceWithIsom`

A container type for pairs $(V, f)$ consisting of a rational quadratic space $V$ of type `QuadSpace`

and an isometry $f$ given as a `QQMatrix`

representing the action on the standard basis of $V$.

We store the order of $f$ too, which can finite or infinite.

To construct an object of type `QuadSpaceWithIsom`

, see the set of functions called `quadratic_space_with_isometry`

**Examples**

```
julia> V = quadratic_space(QQ, 4);
julia> quadratic_space_with_isometry(V, neg=true)
Quadratic space of dimension 4
with isometry of finite order 2
given by
[-1 0 0 0]
[ 0 -1 0 0]
[ 0 0 -1 0]
[ 0 0 0 -1]
julia> L = root_lattice(:E, 6);
julia> V = ambient_space(L);
julia> f = matrix(QQ, 6, 6, [ 1 2 3 2 1 1;
-1 -2 -2 -2 -1 -1;
0 1 0 0 0 0;
1 0 0 0 0 0;
-1 -1 -1 0 0 -1;
0 0 1 1 0 1]);
julia> Vf = quadratic_space_with_isometry(V, f)
Quadratic space of dimension 6
with isometry of finite order 8
given by
[ 1 2 3 2 1 1]
[-1 -2 -2 -2 -1 -1]
[ 0 1 0 0 0 0]
[ 1 0 0 0 0 0]
[-1 -1 -1 0 0 -1]
[ 0 0 1 1 0 1]
```

It is seen as a triple $(V, f, n)$ where $n$ is the order of $f$. We actually support isometries of finite and infinite order. In the case where $f$ is of infinite order, then `n = PosInf`

. If $V$ has rank 0, then any isometry $f$ of $V$ is trivial and we set by default `n = -1`

.

Given a quadratic space with isometry $(V, f)$, we provide the following accessors to the elements of the previously described triple:

`isometry`

— Method`isometry(Vf::QuadSpaceWithIsom) -> QQMatrix`

Given a quadratic space with isometry $(V, f)$, return the underlying isometry $f$.

**Examples**

```
julia> V = quadratic_space(QQ, 2);
julia> Vf = quadratic_space_with_isometry(V; neg = true);
julia> isometry(Vf)
[-1 0]
[ 0 -1]
```

`order_of_isometry`

— Method`order_of_isometry(Vf::QuadSpaceWithIsom) -> IntExt`

Given a quadratic space with isometry $(V, f)$, return the order of the underlying isometry $f$.

**Examples**

```
julia> V = quadratic_space(QQ, 2);
julia> Vf = quadratic_space_with_isometry(V; neg = true);
julia> order_of_isometry(Vf) == 2
true
```

`space`

— Method`space(Vf::QuadSpaceWithIsom) -> QuadSpace`

Given a quadratic space with isometry $(V, f)$, return the underlying space $V$.

**Examples**

```
julia> V = quadratic_space(QQ, 2);
julia> Vf = quadratic_space_with_isometry(V; neg = true);
julia> space(Vf) === V
true
```

The main purpose of the definition of such objects is to define a contextual ambient space for quadratic lattices endowed with an isometry. Indeed, as we will see in the next section, *lattices with isometry* are attached to an ambient quadratic space with an isometry inducing the one on the lattice.

## Constructors

For simplicity, we have gathered the main constructors for objects of type `QuadSpaceWithIsom`

under the same name `quadratic_space_with_isometry`

. The user has then the choice on the parameters depending on what they intend to do:

`quadratic_space_with_isometry`

— Method```
quadratic_space_with_isometry(V:QuadSpace, f::QQMatrix; check::Bool = false)
-> QuadSpaceWithIsom
```

Given a quadratic space $V$ and a matrix $f$, if $f$ defines an isometry of $V$ of order $n$ (possibly infinite), return the corresponding quadratic space with isometry pair $(V, f)$.

**Examples**

```
julia> V = quadratic_space(QQ, QQ[ 2 -1;
-1 2])
Quadratic space of dimension 2
over rational field
with gram matrix
[ 2 -1]
[-1 2]
julia> f = matrix(QQ, 2, 2, [1 1;
0 -1])
[1 1]
[0 -1]
julia> Vf = quadratic_space_with_isometry(V, f)
Quadratic space of dimension 2
with isometry of finite order 2
given by
[1 1]
[0 -1]
```

`quadratic_space_with_isometry`

— Method`quadratic_space_with_isometry(V::QuadSpace; neg::Bool = false) -> QuadSpaceWithIsom`

Given a quadratic space $V$, return the quadratic space with isometry pair $(V, f)$ where $f$ is represented by the identity matrix.

If `neg`

is set to `true`

, then the isometry $f$ is negative the identity on $V$.

**Examples**

```
julia> V = quadratic_space(QQ, QQ[ 2 -1;
-1 2])
Quadratic space of dimension 2
over rational field
with gram matrix
[ 2 -1]
[-1 2]
julia> Vf = quadratic_space_with_isometry(V)
Quadratic space of dimension 2
with isometry of finite order 1
given by
[1 0]
[0 1]
```

By default, the first constructor always checks whether the matrix defines an isometry of the quadratic space. We recommend not to disable this parameter to avoid any complications. Note however that in the rank 0 case, the checks are avoided since all isometries are necessarily trivial.

## Attributes and first operations

Given a quadratic space with isometry $Vf := (V, f)$, one has access to most of the attributes of $V$ and $f$ by calling the similar functions on the pair $(V, f)$ itself. For instance, in order to know the rank of $V$, one can simply call `rank(Vf)`

. Here is a list of what are the current accessible attributes:

`characteristic_polynomial`

— Method`characteristic_polynomial(Vf::QuadSpaceWithIsom) -> QQPolyRingElem`

Given a quadratic space with isometry $(V, f)$, return the characteristic polynomial of the underlying isometry $f$.

**Examples**

```
julia> V = quadratic_space(QQ, 2);
julia> Vf = quadratic_space_with_isometry(V; neg = true);
julia> characteristic_polynomial(Vf)
x^2 + 2*x + 1
```

`det`

— Method`det(Vf::QuadSpaceWithIsom) -> QQFieldElem`

Given a quadratic space with isometry $(V, f)$, return the determinant of the underlying space $V$.

**Examples**

```
julia> V = quadratic_space(QQ, 2);
julia> Vf = quadratic_space_with_isometry(V; neg = true);
julia> is_one(det(Vf))
true
```

`diagonal`

— Method`diagonal(Vf::QuadSpaceWithIsom) -> Vector{QQFieldElem}`

Given a quadratic space with isometry $(V, f)$, return the diagonal of the underlying space $V$.

**Examples**

```
julia> V = quadratic_space(QQ, 2);
julia> Vf = quadratic_space_with_isometry(V; neg = true);
julia> diagonal(Vf)
2-element Vector{QQFieldElem}:
1
1
```

`dim`

— Method`dim(Vf::QuadSpaceWithIsom) -> Integer`

Given a quadratic space with isometry $(V, f)$, return the dimension of the underlying space of $V$.

**Examples**

```
julia> V = quadratic_space(QQ, 2);
julia> Vf = quadratic_space_with_isometry(V; neg = true);
julia> dim(Vf) == 2
true
```

`discriminant`

— Method`discriminant(Vf::QuadSpaceWithIsom) -> QQFieldElem`

Given a quadratic space with isometry $(V, f)$, return the discriminant of the underlying space $V$.

**Examples**

```
julia> V = quadratic_space(QQ, 2);
julia> Vf = quadratic_space_with_isometry(V; neg = true);
julia> discriminant(Vf)
-1
```

`gram_matrix`

— Method`gram_matrix(Vf::QuadSpaceWithIsom) -> QQMatrix`

Given a quadratic space with isometry $(V, f)$, return the Gram matrix of the underlying space $V$ with respect to its standard basis.

**Examples**

```
julia> V = quadratic_space(QQ, 2);
julia> Vf = quadratic_space_with_isometry(V; neg = true);
julia> is_one(gram_matrix(Vf))
true
```

`is_definite`

— Method`is_definite(Vf::QuadSpaceWithIsom) -> Bool`

Given a quadratic space with isometry $(V, f)$, return whether the underlying space $V$ is definite.

**Examples**

```
julia> V = quadratic_space(QQ, 2);
julia> Vf = quadratic_space_with_isometry(V; neg = true);
julia> is_definite(Vf)
true
```

`is_positive_definite`

— Method`is_positive_definite(Vf::QuadSpaceWithIsom) -> Bool`

Given a quadratic space with isometry $(V, f)$, return whether the underlying space $V$ is positive definite.

**Examples**

```
julia> V = quadratic_space(QQ, 2);
julia> Vf = quadratic_space_with_isometry(V; neg = true);
julia> is_positive_definite(Vf)
true
```

`is_negative_definite`

— Method`is_negative_definite(Vf::QuadSpaceWithIsom) -> Bool`

Given a quadratic space with isometry $(V, f)$, return whether the underlying space $V$ is negative definite.

**Examples**

```
julia> V = quadratic_space(QQ, 2);
julia> Vf = quadratic_space_with_isometry(V; neg = true);
julia> is_negative_definite(Vf)
false
```

`minimal_polynomial`

— Method`minimal_polynomial(Vf::QuadSpaceWithIsom) -> QQPolyRingElem`

Given a quadratic space with isometry $(V, f)$, return the minimal polynomial of the underlying isometry $f$.

**Examples**

```
julia> V = quadratic_space(QQ, 2);
julia> Vf = quadratic_space_with_isometry(V; neg = true);
julia> minimal_polynomial(Vf)
x + 1
```

`rank`

— Method`rank(Vf::QuadSpaceWithIsom) -> Integer`

Given a quadratic space with isometry $(V, f)$, return the rank of the underlying space $V$.

**Examples**

```
julia> V = quadratic_space(QQ, 2);
julia> Vf = quadratic_space_with_isometry(V; neg = true);
julia> rank(Vf) == 2
true
```

`signature_tuple`

— Method`signature_tuple(Vf::QuadSpaceWithIsom) -> Tuple{Int, Int, Int}`

Given a quadratic space with isometry $(V, f)$, return the signature tuple of the underlying space $V$.

**Examples**

```
julia> V = quadratic_space(QQ, 2);
julia> Vf = quadratic_space_with_isometry(V; neg = true);
julia> signature_tuple(Vf)
(2, 0, 0)
```

Similarly, some basic operations on quadratic spaces and matrices are available for quadratic spaces with isometry.

`^`

— Method`^(Vf::QuadSpaceWithIsom, n::Int) -> QuadSpaceWithIsom`

Given a quadratic space with isometry $(V, f)$ and an integer $n$, return the pair $(V, f^n)$.

**Examples**

```
julia> V = quadratic_space(QQ, QQ[ 2 -1;
-1 2])
Quadratic space of dimension 2
over rational field
with gram matrix
[ 2 -1]
[-1 2]
julia> f = matrix(QQ, 2, 2, [1 1;
0 -1])
[1 1]
[0 -1]
julia> Vf = quadratic_space_with_isometry(V, f)
Quadratic space of dimension 2
with isometry of finite order 2
given by
[1 1]
[0 -1]
julia> Vf^2
Quadratic space of dimension 2
with isometry of finite order 1
given by
[1 0]
[0 1]
```

`biproduct`

— Method```
biproduct(x::Vector{QuadSpaceWithIsom}) -> QuadSpaceWithIsom, Vector{AbstractSpaceMor}, Vector{AbstractSpaceMor}
biproduct(x::Vararg{QuadSpaceWithIsom}) -> QuadSpaceWithIsom, Vector{AbstractSpaceMor}, Vector{AbstractSpaceMor}
```

Given a collection of quadratic spaces with isometries $(V_1, f_1), \ldots, (V_n, f_n)$, return the quadratic space with isometry $(V, f)$ together with the injections $V_i \to V$ and the projections $V \to V_i$, where $V$ is the biproduct $V := V_1 \oplus \ldots \oplus V_n$ and $f$ is the isometry of $V$ induced by the diagonal actions of the $f_i$'s.

For objects of type `QuadSpaceWithIsom`

, finite direct sums and finite direct products agree and they are therefore called biproducts. If one wants to obtain $(V, f)$ as a direct sum with the injections $V_i \to V$, one should call `direct_sum(x)`

. If one wants to obtain $(V, f)$ as a direct product with the projections $V \to V_i$, one should call `direct_product(x)`

.

**Examples**

```
julia> V1 = quadratic_space(QQ, QQ[2 5;
5 6])
Quadratic space of dimension 2
over rational field
with gram matrix
[2 5]
[5 6]
julia> Vf1 = quadratic_space_with_isometry(V1, neg=true)
Quadratic space of dimension 2
with isometry of finite order 2
given by
[-1 0]
[ 0 -1]
julia> V2 = quadratic_space(QQ, QQ[ 2 -1;
-1 2])
Quadratic space of dimension 2
over rational field
with gram matrix
[ 2 -1]
[-1 2]
julia> f = matrix(QQ, 2, 2, [1 1;
0 -1])
[1 1]
[0 -1]
julia> Vf2 = quadratic_space_with_isometry(V2, f)
Quadratic space of dimension 2
with isometry of finite order 2
given by
[1 1]
[0 -1]
julia> Vf3, inj, proj = biproduct(Vf1, Vf2)
(Quadratic space with isometry of finite order 2, AbstractSpaceMor[Map: quadratic space -> quadratic space, Map: quadratic space -> quadratic space], AbstractSpaceMor[Map: quadratic space -> quadratic space, Map: quadratic space -> quadratic space])
julia> Vf3
Quadratic space of dimension 4
with isometry of finite order 2
given by
[-1 0 0 0]
[ 0 -1 0 0]
[ 0 0 1 1]
[ 0 0 0 -1]
julia> space(Vf3)
Quadratic space of dimension 4
over rational field
with gram matrix
[2 5 0 0]
[5 6 0 0]
[0 0 2 -1]
[0 0 -1 2]
julia> matrix(compose(inj[1], proj[1]))
[1 0]
[0 1]
julia> matrix(compose(inj[1], proj[2]))
[0 0]
[0 0]
```

`direct_product`

— Method```
direct_product(algebras::StructureConstantAlgebra...; task::Symbol = :sum)
-> StructureConstantAlgebra, Vector{AbsAlgAssMor}, Vector{AbsAlgAssMor}
direct_product(algebras::Vector{StructureConstantAlgebra}; task::Symbol = :sum)
-> StructureConstantAlgebra, Vector{AbsAlgAssMor}, Vector{AbsAlgAssMor}
```

Returns the algebra $A = A_1 \times \cdots \times A_k$. `task`

can be ":sum", ":prod", ":both" or ":none" and determines which canonical maps are computed as well: ":sum" for the injections, ":prod" for the projections.

`direct_product(F::FreeMod{T}...; task::Symbol = :prod) where T`

Given free modules $F_1\dots F_n$, say, return the direct product $\prod_{i=1}^n F_i$.

Additionally, return

- a vector containing the canonical projections $\prod_{i=1}^n F_i\to F_i$ if
`task = :prod`

(default), - a vector containing the canonical injections $F_i\to\prod_{i=1}^n F_i$ if
`task = :sum`

, - two vectors containing the canonical projections and injections, respectively, if
`task = :both`

, - none of the above maps if
`task = :none`

.

`direct_product(M::ModuleFP{T}...; task::Symbol = :prod) where T`

Given modules $M_1\dots M_n$, say, return the direct product $\prod_{i=1}^n M_i$.

Additionally, return

- a vector containing the canonical projections $\prod_{i=1}^n M_i\to M_i$ if
`task = :prod`

(default), - a vector containing the canonical injections $M_i\to\prod_{i=1}^n M_i$ if
`task = :sum`

, - two vectors containing the canonical projections and injections, respectively, if
`task = :both`

, - none of the above maps if
`task = :none`

.

```
direct_product(x::Vector{QuadSpaceWithIsom}) -> QuadSpaceWithIsom, Vector{AbstractSpaceMor}
direct_product(x::Vararg{QuadSpaceWithIsom}) -> QuadSpaceWithIsom, Vector{AbstractSpaceMor}
```

Given a collection of quadratic spaces with isometries $(V_1, f_1), \ldots, (V_n, f_n)$, return the quadratic space with isometry $(V, f)$ together with the projections $V \to V_i$, where $V$ is the direct product $V := V_1 \times \ldots \times V_n$ and $f$ is the isometry of $V$ induced by the diagonal actions of the $f_i$'s.

For objects of type `QuadSpaceWithIsom`

, finite direct sums and finite direct products agree and they are therefore called biproducts. If one wants to obtain $(V, f)$ as a direct sum with the injections $V_i \to V$, one should call `direct_sum(x)`

. If one wants to obtain $(V, f)$ as a biproduct with the injections $V_i \to V$ and the projections $V \to V_i$, one should call `biproduct(x)`

.

**Examples**

```
julia> V1 = quadratic_space(QQ, QQ[2 5;
5 6])
Quadratic space of dimension 2
over rational field
with gram matrix
[2 5]
[5 6]
julia> Vf1 = quadratic_space_with_isometry(V1, neg=true)
Quadratic space of dimension 2
with isometry of finite order 2
given by
[-1 0]
[ 0 -1]
julia> V2 = quadratic_space(QQ, QQ[ 2 -1;
-1 2])
Quadratic space of dimension 2
over rational field
with gram matrix
[ 2 -1]
[-1 2]
julia> f = matrix(QQ, 2, 2, [1 1;
0 -1])
[1 1]
[0 -1]
julia> Vf2 = quadratic_space_with_isometry(V2, f)
Quadratic space of dimension 2
with isometry of finite order 2
given by
[1 1]
[0 -1]
julia> Vf3, proj = direct_product(Vf1, Vf2)
(Quadratic space with isometry of finite order 2, AbstractSpaceMor[Map: quadratic space -> quadratic space, Map: quadratic space -> quadratic space])
julia> Vf3
Quadratic space of dimension 4
with isometry of finite order 2
given by
[-1 0 0 0]
[ 0 -1 0 0]
[ 0 0 1 1]
[ 0 0 0 -1]
julia> space(Vf3)
Quadratic space of dimension 4
over rational field
with gram matrix
[2 5 0 0]
[5 6 0 0]
[0 0 2 -1]
[0 0 -1 2]
```

`direct_sum`

— Method`direct_sum(g1::QuadSpaceCls, g2::QuadSpaceCls) -> QuadSpaceCls`

Return the isometry class of the direct sum of two representatives.

`direct_sum(M::ModuleFP{T}...; task::Symbol = :sum) where T`

Given modules $M_1\dots M_n$, say, return the direct sum $\bigoplus_{i=1}^n M_i$.

Additionally, return

- a vector containing the canonical injections $M_i\to\bigoplus_{i=1}^n M_i$ if
`task = :sum`

(default), - a vector containing the canonical projections $\bigoplus_{i=1}^n M_i\to M_i$ if
`task = :prod`

, - two vectors containing the canonical injections and projections, respectively, if
`task = :both`

, - none of the above maps if
`task = :none`

.

```
direct_sum(x::Vector{QuadSpaceWithIsom}) -> QuadSpaceWithIsom, Vector{AbstractSpaceMor}
direct_sum(x::Vararg{QuadSpaceWithIsom}) -> QuadSpaceWithIsom, Vector{AbstractSpaceMor}
```

Given a collection of quadratic spaces with isometries $(V_1, f_1), \ldots, (V_n, f_n)$, return the quadratic space with isometry $(V, f)$ together with the injections $V_i \to V$, where $V$ is the direct sum $V := V_1 \oplus \ldots \oplus V_n$ and $f$ is the isometry of $V$ induced by the diagonal actions of the $f_i$'s.

For objects of type `QuadSpaceWithIsom`

, finite direct sums and finite direct products agree and they are therefore called biproducts. If one wants to obtain $(V, f)$ as a direct product with the projections $V \to V_i$, one should call `direct_product(x)`

. If one wants to obtain $(V, f)$ as a biproduct with the injections $V_i \to V$ and the projections $V \to V_i$, one should call `biproduct(x)`

.

**Examples**

```
julia> V1 = quadratic_space(QQ, QQ[2 5;
5 6])
Quadratic space of dimension 2
over rational field
with gram matrix
[2 5]
[5 6]
julia> Vf1 = quadratic_space_with_isometry(V1, neg=true)
Quadratic space of dimension 2
with isometry of finite order 2
given by
[-1 0]
[ 0 -1]
julia> V2 = quadratic_space(QQ, QQ[ 2 -1;
-1 2])
Quadratic space of dimension 2
over rational field
with gram matrix
[ 2 -1]
[-1 2]
julia> f = matrix(QQ, 2, 2, [1 1;
0 -1])
[1 1]
[0 -1]
julia> Vf2 = quadratic_space_with_isometry(V2, f)
Quadratic space of dimension 2
with isometry of finite order 2
given by
[1 1]
[0 -1]
julia> Vf3, inj = direct_sum(Vf1, Vf2)
(Quadratic space with isometry of finite order 2, AbstractSpaceMor[Map: quadratic space -> quadratic space, Map: quadratic space -> quadratic space])
julia> Vf3
Quadratic space of dimension 4
with isometry of finite order 2
given by
[-1 0 0 0]
[ 0 -1 0 0]
[ 0 0 1 1]
[ 0 0 0 -1]
julia> space(Vf3)
Quadratic space of dimension 4
over rational field
with gram matrix
[2 5 0 0]
[5 6 0 0]
[0 0 2 -1]
[0 0 -1 2]
```

`rescale`

— Method`rescale(Vf::QuadSpaceWithIsom, a::RationalUnion)`

Given a quadratic space with isometry $(V, f)$, return the pair $(V^a, f$) where $V^a$ is the same space as $V$ with the associated quadratic form rescaled by $a$.

**Examples**

```
julia> V = quadratic_space(QQ, QQ[ 2 -1;
-1 2])
Quadratic space of dimension 2
over rational field
with gram matrix
[ 2 -1]
[-1 2]
julia> Vf = quadratic_space_with_isometry(V)
Quadratic space of dimension 2
with isometry of finite order 1
given by
[1 0]
[0 1]
julia> Vf2 = rescale(Vf, 1//2)
Quadratic space of dimension 2
with isometry of finite order 1
given by
[1 0]
[0 1]
julia> space(Vf2)
Quadratic space of dimension 2
over rational field
with gram matrix
[ 1 -1//2]
[-1//2 1]
```

## Spinor norm

Given a rational quadratic space $(V, \Phi)$, and given an integer $b\in\mathbb{Q}$, we define the *rational spinor norm* $\sigma$ on $(V, b\Phi)$ to be the group homomorphism

\[\sigma\colon O(V, b\Phi) = O(V, \Phi)\to \mathbb{Q}^\ast/(\mathbb{Q}^\ast)^2\]

defined as follows. For $f\in O(V, b\Phi)$, there exist elements $v_1,\ldots, v_r\in V$ where $1\leq r\leq \text{rank}(V)$ such that $f = \tau_{v_1}\circ\cdots\circ \tau_{v_r}$ is equal to the product of the associated reflections. We define

\[\sigma(f) := (-\frac{b\Phi(v_1, v_1)}{2})\cdots(-\frac{b\Phi(v_r,v_r)}{2}) \mod (\mathbb{Q}^{\ast})^2.\]

`rational_spinor_norm`

— Method`rational_spinor_norm(Vf::QuadSpaceWithIsom; b::Int = -1) -> QQFieldElem`

Given a rational quadratic space with isometry $(V, b, f)$, return the rational spinor norm of $f$.

If $\Phi$ is the form on $V$, then the spinor norm is computed with respect to $b\Phi$.

## Equality

We choose as a convention that two pairs $(V, f)$ and $(V', f')$ of quadratic spaces with isometries are *equal* if $V$ and $V'$ are the same space, and $f$ and $f'$ are represented by the same matrix with respect to the standard basis of $V = V'$.