Quadratic forms #
THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.
This file defines quadratic forms over a R
-module M
.
A quadratic form on a ring R
is a map Q : M → R
such that:
quadratic_form.map_smul
:Q (a • x) = a * a * Q x
quadratic_form.polar_add_left
,quadratic_form.polar_add_right
,quadratic_form.polar_smul_left
,quadratic_form.polar_smul_right
: the mapquadratic_form.polar Q := λ x y, Q (x + y) - Q x - Q y
is bilinear.
This notion generalizes to semirings using the approach in [izhakian2016][] which requires that
there be a (possibly non-unique) companion bilinear form B
such that
∀ x y, Q (x + y) = Q x + Q y + B x y
. Over a ring, this B
is precisely quadratic_form.polar Q
.
To build a quadratic_form
from the polar
axioms, use quadratic_form.of_polar
.
Quadratic forms come with a scalar multiplication, (a • Q) x = Q (a • x) = a * a * Q x
,
and composition with linear maps f
, Q.comp f x = Q (f x)
.
Main definitions #
quadratic_form.of_polar
: a more familiar constructor that works on ringsquadratic_form.associated
: associated bilinear formquadratic_form.pos_def
: positive definite quadratic formsquadratic_form.anisotropic
: anisotropic quadratic formsquadratic_form.discr
: discriminant of a quadratic form
Main statements #
quadratic_form.associated_left_inverse
,quadratic_form.associated_right_inverse
: in a commutative ring where 2 has an inverse, there is a correspondence between quadratic forms and symmetric bilinear formsbilin_form.exists_orthogonal_basis
: There exists an orthogonal basis with respect to any nondegenerate, symmetric bilinear formB
.
Notation #
In this file, the variable R
is used when a ring
structure is sufficient and
R₁
is used when specifically a comm_ring
is required. This allows us to keep
[module R M]
and [module R₁ M]
assumptions in the variables without
confusion between *
from ring
and *
from comm_ring
.
The variable S
is used when R
itself has a •
action.
References #
- https://en.wikipedia.org/wiki/Quadratic_form
- https://en.wikipedia.org/wiki/Discriminant#Quadratic_forms
Tags #
quadratic form, homogeneous polynomial, quadratic polynomial
Up to a factor 2, Q.polar
is the associated bilinear form for a quadratic form Q
.
Source of this name: https://en.wikipedia.org/wiki/Quadratic_form#Generalization
Equations
- quadratic_form.polar f x y = f (x + y) - f x - f y
Auxiliary lemma to express bilinearity of quadratic_form.polar
without subtraction.
- to_fun : M → R
- to_fun_smul : ∀ (a : R) (x : M), self.to_fun (a • x) = a * a * self.to_fun x
- exists_companion' : ∃ (B : bilin_form R M), ∀ (x y : M), self.to_fun (x + y) = self.to_fun x + self.to_fun y + ⇑B x y
A quadratic form over a module.
For a more familiar constructor when R
is a ring, see quadratic_form.of_polar
.
Instances for quadratic_form
- quadratic_form.has_sizeof_inst
- quadratic_form.fun_like
- quadratic_form.has_coe_to_fun
- quadratic_form.zero_hom_class
- quadratic_form.has_smul
- quadratic_form.has_zero
- quadratic_form.inhabited
- quadratic_form.has_add
- quadratic_form.add_comm_monoid
- quadratic_form.distrib_mul_action
- quadratic_form.module
- quadratic_form.has_neg
- quadratic_form.has_sub
- quadratic_form.add_comm_group
- quadratic_form.can_lift
Equations
- quadratic_form.fun_like = {coe := quadratic_form.to_fun _inst_3, coe_injective' := _}
Helper instance for when there's too many metavariables to apply
fun_like.has_coe_to_fun
directly.
Equations
- quadratic_form.has_coe_to_fun = {coe := quadratic_form.to_fun _inst_3}
The simp
normal form for a quadratic form is coe_fn
, not to_fun
.
Copy of a quadratic_form
with a new to_fun
equal to the old one. Useful to fix definitional
equalities.
Equations
- Q.copy Q' h = {to_fun := Q', to_fun_smul := _, exists_companion' := _}
Equations
quadratic_form.polar
as a bilinear form
Equations
- Q.polar_bilin = {bilin := quadratic_form.polar ⇑Q, bilin_add_left := _, bilin_smul_left := _, bilin_add_right := _, bilin_smul_right := _}
An alternative constructor to quadratic_form.mk
, for rings where polar
can be used.
Equations
- quadratic_form.of_polar to_fun to_fun_smul polar_add_left polar_smul_left = {to_fun := to_fun, to_fun_smul := to_fun_smul, exists_companion' := _}
In a ring the companion bilinear form is unique and equal to quadratic_form.polar
.
quadratic_form R M
inherits the scalar action from any algebra over R
.
When R
is commutative, this provides an R
-action via algebra.id
.
Equations
- quadratic_form.has_smul = {smul := λ (a : S) (Q : quadratic_form R M), {to_fun := a • ⇑Q, to_fun_smul := _, exists_companion' := _}}
Equations
- quadratic_form.has_zero = {zero := {to_fun := λ (x : M), 0, to_fun_smul := _, exists_companion' := _}}
Equations
Equations
- quadratic_form.has_add = {add := λ (Q Q' : quadratic_form R M), {to_fun := ⇑Q + ⇑Q', to_fun_smul := _, exists_companion' := _}}
Equations
- quadratic_form.add_comm_monoid = function.injective.add_comm_monoid coe_fn quadratic_form.add_comm_monoid._proof_2 quadratic_form.coe_fn_zero quadratic_form.coe_fn_add quadratic_form.add_comm_monoid._proof_3
@coe_fn (quadratic_form R M)
as an add_monoid_hom
.
This API mirrors add_monoid_hom.coe_fn
.
Equations
Evaluation on a particular element of the module M
is an additive map over quadratic forms.
Equations
- quadratic_form.eval_add_monoid_hom m = (pi.eval_add_monoid_hom (λ (m : M), R) m).comp quadratic_form.coe_fn_add_monoid_hom
Equations
- quadratic_form.distrib_mul_action = {to_mul_action := {to_has_smul := quadratic_form.has_smul _inst_6, one_smul := _, mul_smul := _}, smul_zero := _, smul_add := _}
Equations
- quadratic_form.module = {to_distrib_mul_action := quadratic_form.distrib_mul_action _inst_6, add_smul := _, zero_smul := _}
Equations
- quadratic_form.has_neg = {neg := λ (Q : quadratic_form R M), {to_fun := -⇑Q, to_fun_smul := _, exists_companion' := _}}
Equations
- quadratic_form.add_comm_group = function.injective.add_comm_group coe_fn quadratic_form.add_comm_group._proof_3 quadratic_form.add_comm_group._proof_4 quadratic_form.add_comm_group._proof_5 quadratic_form.coe_fn_neg quadratic_form.coe_fn_sub quadratic_form.add_comm_group._proof_6 quadratic_form.add_comm_group._proof_7
Compose the quadratic form with a linear function.
Equations
- Q.comp f = {to_fun := λ (x : M), ⇑Q (⇑f x), to_fun_smul := _, exists_companion' := _}
Compose a quadratic form with a linear function on the left.
Equations
- f.comp_quadratic_form Q = {to_fun := λ (x : M), ⇑f (⇑Q x), to_fun_smul := _, exists_companion' := _}
The product of linear forms is a quadratic form.
Equations
- quadratic_form.lin_mul_lin f g = {to_fun := ⇑f * ⇑g, to_fun_smul := _, exists_companion' := _}
sq
is the quadratic form mapping the vector x : R₁
to x * x
proj i j
is the quadratic form mapping the vector x : n → R₁
to x i * x j
Equations
Associated bilinear forms #
Over a commutative ring with an inverse of 2, the theory of quadratic forms is
basically identical to that of symmetric bilinear forms. The map from quadratic
forms to bilinear forms giving this identification is called the associated
quadratic form.
A bilinear form gives a quadratic form by applying the argument twice.
Equations
- B.to_quadratic_form = {to_fun := λ (x : M), ⇑B x x, to_fun_smul := _, exists_companion' := _}
bilin_form.to_quadratic_form
as an additive homomorphism
Equations
- bilin_form.to_quadratic_form_add_monoid_hom R M = {to_fun := bilin_form.to_quadratic_form _inst_3, map_zero' := _, map_add' := _}
associated_hom
is the map that sends a quadratic form on a module M
over R
to its
associated symmetric bilinear form. As provided here, this has the structure of an S
-linear map
where S
is a commutative subring of R
.
Over a commutative ring, use associated
, which gives an R
-linear map. Over a general ring with
no nontrivial distinguished commutative subring, use associated'
, which gives an additive
homomorphism (or more precisely a ℤ
-linear map.)
Equations
- quadratic_form.associated_hom S = {to_fun := λ (Q : quadratic_form R M), ⟨⅟ 2 _inst_8, _⟩ • Q.polar_bilin, map_add' := _, map_smul' := _}
associated'
is the ℤ
-linear map that sends a quadratic form on a module M
over R
to its
associated symmetric bilinear form.
Symmetric bilinear forms can be lifted to quadratic forms
Equations
- quadratic_form.can_lift = {prf := _}
There exists a non-null vector with respect to any quadratic form Q
whose associated
bilinear form is non-zero, i.e. there exists x
such that Q x ≠ 0
.
associated
is the linear map that sends a quadratic form over a commutative ring to its
associated symmetric bilinear form.
An anisotropic quadratic form is zero only on zero vectors.
The associated bilinear form of an anisotropic quadratic form is nondegenerate.
A positive definite quadratic form is positive on nonzero vectors.
Quadratic forms and matrices #
Connect quadratic forms and matrices, in order to explicitly compute with them. The convention is twos out, so there might be a factor 2⁻¹ in the entries of the matrix. The determinant of the matrix is the discriminant of the quadratic form.
M.to_quadratic_form
is the map λ x, col x ⬝ M ⬝ row x
as a quadratic form.
Equations
A matrix representation of the quadratic form.
Equations
The discriminant of a quadratic form generalizes the discriminant of a quadratic polynomial.
Equations
- Q.discr = Q.to_matrix'.det
A bilinear form is nondegenerate if the quadratic form it is associated with is anisotropic.
There exists a non-null vector with respect to any symmetric, nonzero bilinear form B
on a module M
over a ring R
with invertible 2
, i.e. there exists some
x : M
such that B x x ≠ 0
.
Given a symmetric bilinear form B
on some vector space V
over a field K
in which 2
is invertible, there exists an orthogonal basis with respect to B
.
Given a quadratic form Q
and a basis, basis_repr
is the basis representation of Q
.
The weighted sum of squares with respect to some weight as a quadratic form.
The weights are applied using •
; typically this definition is used either with S = R₁
or
[algebra S R₁]
, although this is stated more generally.
Equations
- quadratic_form.weighted_sum_squares R₁ w = finset.univ.sum (λ (i : ι), w i • quadratic_form.proj i i)
On an orthogonal basis, the basis representation of Q
is just a sum of squares.