# mathlibdocumentation

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 map `quadratic_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 rings
• `quadratic_form.associated`: associated bilinear form
• `quadratic_form.pos_def`: positive definite quadratic forms
• `quadratic_form.anisotropic`: anisotropic quadratic forms
• `quadratic_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 forms
• `bilin_form.exists_orthogonal_basis`: There exists an orthogonal basis with respect to any nondegenerate, symmetric bilinear form `B`.

## 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.

## Tags #

def quadratic_form.polar {R : Type u_2} {M : Type u_4} [ring R] (f : M R) (x y : M) :
R

Up to a factor 2, `Q.polar` is the associated bilinear form for a quadratic form `Q`.

Equations
• y = f (x + y) - f x - f y
theorem quadratic_form.polar_add {R : Type u_2} {M : Type u_4} [ring R] (f g : M R) (x y : M) :
quadratic_form.polar (f + g) x y = y + y
theorem quadratic_form.polar_neg {R : Type u_2} {M : Type u_4} [ring R] (f : M R) (x y : M) :
y = - y
theorem quadratic_form.polar_smul {S : Type u_1} {R : Type u_2} {M : Type u_4} [ring R] [monoid S] [ R] (f : M R) (s : S) (x y : M) :
theorem quadratic_form.polar_comm {R : Type u_2} {M : Type u_4} [ring R] (f : M R) (x y : M) :
y = x
theorem quadratic_form.polar_add_left_iff {R : Type u_2} {M : Type u_4} [ring R] {f : M R} {x x' y : M} :
(x + x') y = y + y f (x + x' + y) + (f x + f x' + f y) = f (x + x') + f (x' + y) + f (y + x)

Auxiliary lemma to express bilinearity of `quadratic_form.polar` without subtraction.

theorem quadratic_form.polar_comp {S : Type u_1} {R : Type u_2} {M : Type u_4} [ring R] {F : Type u_3} [ring S] [ S] (f : M R) (g : F) (x y : M) :
structure quadratic_form (R : Type u) (M : Type v) [semiring R] [ M] :
Type (max u v)

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`
@[protected, instance]
def quadratic_form.fun_like {R : Type u_2} {M : Type u_4} [semiring R] [ M] :
fun_like M) M (λ (_x : M), R)
Equations
@[protected, instance]
def quadratic_form.has_coe_to_fun {R : Type u_2} {M : Type u_4} [semiring R] [ M] :
(λ (_x : M), M R)

Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun` directly.

Equations
@[simp]
theorem quadratic_form.to_fun_eq_coe {R : Type u_2} {M : Type u_4} [semiring R] [ M] (Q : M) :

The `simp` normal form for a quadratic form is `coe_fn`, not `to_fun`.

@[ext]
theorem quadratic_form.ext {R : Type u_2} {M : Type u_4} [semiring R] [ M] {Q Q' : M} (H : (x : M), Q x = Q' x) :
Q = Q'
theorem quadratic_form.congr_fun {R : Type u_2} {M : Type u_4} [semiring R] [ M] {Q Q' : M} (h : Q = Q') (x : M) :
Q x = Q' x
theorem quadratic_form.ext_iff {R : Type u_2} {M : Type u_4} [semiring R] [ M] {Q Q' : M} :
Q = Q' (x : M), Q x = Q' x
@[protected]
def quadratic_form.copy {R : Type u_2} {M : Type u_4} [semiring R] [ M] (Q : M) (Q' : M R) (h : Q' = Q) :

Copy of a `quadratic_form` with a new `to_fun` equal to the old one. Useful to fix definitional equalities.

Equations
@[simp]
theorem quadratic_form.coe_copy {R : Type u_2} {M : Type u_4} [semiring R] [ M] (Q : M) (Q' : M R) (h : Q' = Q) :
(Q.copy Q' h) = Q'
theorem quadratic_form.copy_eq {R : Type u_2} {M : Type u_4} [semiring R] [ M] (Q : M) (Q' : M R) (h : Q' = Q) :
Q.copy Q' h = Q
theorem quadratic_form.map_smul {R : Type u_2} {M : Type u_4} [semiring R] [ M] (Q : M) (a : R) (x : M) :
Q (a x) = a * a * Q x
theorem quadratic_form.exists_companion {R : Type u_2} {M : Type u_4} [semiring R] [ M] (Q : M) :
(B : M), (x y : M), Q (x + y) = Q x + Q y + B x y
theorem quadratic_form.map_add_add_add_map {R : Type u_2} {M : Type u_4} [semiring R] [ M] (Q : M) (x y z : M) :
Q (x + y + z) + (Q x + Q y + Q z) = Q (x + y) + Q (y + z) + Q (z + x)
theorem quadratic_form.map_add_self {R : Type u_2} {M : Type u_4} [semiring R] [ M] (Q : M) (x : M) :
Q (x + x) = 4 * Q x
@[simp]
theorem quadratic_form.map_zero {R : Type u_2} {M : Type u_4} [semiring R] [ M] (Q : M) :
Q 0 = 0
@[protected, instance]
def quadratic_form.zero_hom_class {R : Type u_2} {M : Type u_4} [semiring R] [ M] :
M R
Equations
theorem quadratic_form.map_smul_of_tower {S : Type u_1} {R : Type u_2} {M : Type u_4} [semiring R] [ M] (Q : M) [ R] [ M] [ M] (a : S) (x : M) :
Q (a x) = (a * a) Q x
@[simp]
theorem quadratic_form.map_neg {R : Type u_2} {M : Type u_4} [ring R] [ M] (Q : M) (x : M) :
Q (-x) = Q x
theorem quadratic_form.map_sub {R : Type u_2} {M : Type u_4} [ring R] [ M] (Q : M) (x y : M) :
Q (x - y) = Q (y - x)
@[simp]
theorem quadratic_form.polar_zero_left {R : Type u_2} {M : Type u_4} [ring R] [ M] (Q : M) (y : M) :
= 0
@[simp]
theorem quadratic_form.polar_add_left {R : Type u_2} {M : Type u_4} [ring R] [ M] (Q : M) (x x' y : M) :
(x + x') y = + y
@[simp]
theorem quadratic_form.polar_smul_left {R : Type u_2} {M : Type u_4} [ring R] [ M] (Q : M) (a : R) (x y : M) :
(a x) y = a *
@[simp]
theorem quadratic_form.polar_neg_left {R : Type u_2} {M : Type u_4} [ring R] [ M] (Q : M) (x y : M) :
y = -
@[simp]
theorem quadratic_form.polar_sub_left {R : Type u_2} {M : Type u_4} [ring R] [ M] (Q : M) (x x' y : M) :
(x - x') y = - y
@[simp]
theorem quadratic_form.polar_zero_right {R : Type u_2} {M : Type u_4} [ring R] [ M] (Q : M) (y : M) :
= 0
@[simp]
theorem quadratic_form.polar_add_right {R : Type u_2} {M : Type u_4} [ring R] [ M] (Q : M) (x y y' : M) :
(y + y') = + y'
@[simp]
theorem quadratic_form.polar_smul_right {R : Type u_2} {M : Type u_4} [ring R] [ M] (Q : M) (a : R) (x y : M) :
(a y) = a *
@[simp]
theorem quadratic_form.polar_neg_right {R : Type u_2} {M : Type u_4} [ring R] [ M] (Q : M) (x y : M) :
(-y) = -
@[simp]
theorem quadratic_form.polar_sub_right {R : Type u_2} {M : Type u_4} [ring R] [ M] (Q : M) (x y y' : M) :
(y - y') = - y'
@[simp]
theorem quadratic_form.polar_self {R : Type u_2} {M : Type u_4} [ring R] [ M] (Q : M) (x : M) :
= 2 * Q x
@[simp]
theorem quadratic_form.polar_bilin_apply {R : Type u_2} {M : Type u_4} [ring R] [ M] (Q : M) (x y : M) :
(Q.polar_bilin) x y =
def quadratic_form.polar_bilin {R : Type u_2} {M : Type u_4} [ring R] [ M] (Q : M) :
M

`quadratic_form.polar` as a bilinear form

Equations
@[simp]
theorem quadratic_form.polar_smul_left_of_tower {S : Type u_1} {R : Type u_2} {M : Type u_4} [ring R] [ M] (Q : M) [ R] [ M] [ M] (a : S) (x y : M) :
(a x) y = a
@[simp]
theorem quadratic_form.polar_smul_right_of_tower {S : Type u_1} {R : Type u_2} {M : Type u_4} [ring R] [ M] (Q : M) [ R] [ M] [ M] (a : S) (x y : M) :
(a y) = a
def quadratic_form.of_polar {R : Type u_2} {M : Type u_4} [ring R] [ M] (to_fun : M R) (to_fun_smul : (a : R) (x : M), to_fun (a x) = a * a * to_fun x) (polar_add_left : (x x' y : M), quadratic_form.polar to_fun (x + x') y = quadratic_form.polar to_fun x y + quadratic_form.polar to_fun x' y) (polar_smul_left : (a : R) (x y : M), quadratic_form.polar to_fun (a x) y = a quadratic_form.polar to_fun x y) :

An alternative constructor to `quadratic_form.mk`, for rings where `polar` can be used.

Equations
@[simp]
theorem quadratic_form.of_polar_apply {R : Type u_2} {M : Type u_4} [ring R] [ M] (to_fun : M R) (to_fun_smul : (a : R) (x : M), to_fun (a x) = a * a * to_fun x) (polar_add_left : (x x' y : M), quadratic_form.polar to_fun (x + x') y = quadratic_form.polar to_fun x y + quadratic_form.polar to_fun x' y) (polar_smul_left : (a : R) (x y : M), quadratic_form.polar to_fun (a x) y = a quadratic_form.polar to_fun x y) (ᾰ : M) :
theorem quadratic_form.some_exists_companion {R : Type u_2} {M : Type u_4} [ring R] [ M] (Q : M) :

In a ring the companion bilinear form is unique and equal to `quadratic_form.polar`.

@[protected, instance]
def quadratic_form.has_smul {S : Type u_1} {R : Type u_2} {M : Type u_4} [semiring R] [ M] [monoid S] [ R] [ R] :
M)

`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
@[simp]
theorem quadratic_form.coe_fn_smul {S : Type u_1} {R : Type u_2} {M : Type u_4} [semiring R] [ M] [monoid S] [ R] [ R] (a : S) (Q : M) :
(a Q) = a Q
@[simp]
theorem quadratic_form.smul_apply {S : Type u_1} {R : Type u_2} {M : Type u_4} [semiring R] [ M] [monoid S] [ R] [ R] (a : S) (Q : M) (x : M) :
(a Q) x = a Q x
@[protected, instance]
def quadratic_form.has_zero {R : Type u_2} {M : Type u_4} [semiring R] [ M] :
Equations
@[simp]
theorem quadratic_form.coe_fn_zero {R : Type u_2} {M : Type u_4} [semiring R] [ M] :
0 = 0
@[simp]
theorem quadratic_form.zero_apply {R : Type u_2} {M : Type u_4} [semiring R] [ M] (x : M) :
0 x = 0
@[protected, instance]
def quadratic_form.inhabited {R : Type u_2} {M : Type u_4} [semiring R] [ M] :
Equations
@[protected, instance]
def quadratic_form.has_add {R : Type u_2} {M : Type u_4} [semiring R] [ M] :
Equations
@[simp]
theorem quadratic_form.coe_fn_add {R : Type u_2} {M : Type u_4} [semiring R] [ M] (Q Q' : M) :
(Q + Q') = Q + Q'
@[simp]
theorem quadratic_form.add_apply {R : Type u_2} {M : Type u_4} [semiring R] [ M] (Q Q' : M) (x : M) :
(Q + Q') x = Q x + Q' x
@[protected, instance]
def quadratic_form.add_comm_monoid {R : Type u_2} {M : Type u_4} [semiring R] [ M] :
Equations
def quadratic_form.coe_fn_add_monoid_hom {R : Type u_2} {M : Type u_4} [semiring R] [ M] :
→+ M R

`@coe_fn (quadratic_form R M)` as an `add_monoid_hom`.

This API mirrors `add_monoid_hom.coe_fn`.

Equations
@[simp]
theorem quadratic_form.coe_fn_add_monoid_hom_apply {R : Type u_2} {M : Type u_4} [semiring R] [ M] (x : M) (ᾰ : M) :
@[simp]
theorem quadratic_form.eval_add_monoid_hom_apply {R : Type u_2} {M : Type u_4} [semiring R] [ M] (m : M) (ᾰ : M) :
def quadratic_form.eval_add_monoid_hom {R : Type u_2} {M : Type u_4} [semiring R] [ M] (m : M) :
→+ R

Evaluation on a particular element of the module `M` is an additive map over quadratic forms.

Equations
@[simp]
theorem quadratic_form.coe_fn_sum {R : Type u_2} {M : Type u_4} [semiring R] [ M] {ι : Type u_1} (Q : ι ) (s : finset ι) :
(s.sum (λ (i : ι), Q i)) = s.sum (λ (i : ι), (Q i))
@[simp]
theorem quadratic_form.sum_apply {R : Type u_2} {M : Type u_4} [semiring R] [ M] {ι : Type u_1} (Q : ι ) (s : finset ι) (x : M) :
(s.sum (λ (i : ι), Q i)) x = s.sum (λ (i : ι), (Q i) x)
@[protected, instance]
def quadratic_form.distrib_mul_action {S : Type u_1} {R : Type u_2} {M : Type u_4} [semiring R] [ M] [monoid S] [ R] [ R] :
M)
Equations
@[protected, instance]
def quadratic_form.module {S : Type u_1} {R : Type u_2} {M : Type u_4} [semiring R] [ M] [semiring S] [ R] [ R] :
M)
Equations
@[protected, instance]
def quadratic_form.has_neg {R : Type u_2} {M : Type u_4} [ring R] [ M] :
Equations
@[simp]
theorem quadratic_form.coe_fn_neg {R : Type u_2} {M : Type u_4} [ring R] [ M] (Q : M) :
@[simp]
theorem quadratic_form.neg_apply {R : Type u_2} {M : Type u_4} [ring R] [ M] (Q : M) (x : M) :
(-Q) x = -Q x
@[protected, instance]
def quadratic_form.has_sub {R : Type u_2} {M : Type u_4} [ring R] [ M] :
Equations
@[simp]
theorem quadratic_form.coe_fn_sub {R : Type u_2} {M : Type u_4} [ring R] [ M] (Q Q' : M) :
(Q - Q') = Q - Q'
@[simp]
theorem quadratic_form.sub_apply {R : Type u_2} {M : Type u_4} [ring R] [ M] (Q Q' : M) (x : M) :
(Q - Q') x = Q x - Q' x
@[protected, instance]
def quadratic_form.add_comm_group {R : Type u_2} {M : Type u_4} [ring R] [ M] :
Equations
def quadratic_form.comp {R : Type u_2} {M : Type u_4} [semiring R] [ M] {N : Type v} [ N] (Q : N) (f : M →ₗ[R] N) :

Compose the quadratic form with a linear function.

Equations
@[simp]
theorem quadratic_form.comp_apply {R : Type u_2} {M : Type u_4} [semiring R] [ M] {N : Type v} [ N] (Q : N) (f : M →ₗ[R] N) (x : M) :
(Q.comp f) x = Q (f x)
def linear_map.comp_quadratic_form {R : Type u_2} {M : Type u_4} [semiring R] [ M] {S : Type} [ R] [ M] [ M] (f : R →ₗ[S] S) (Q : M) :

Compose a quadratic form with a linear function on the left.

Equations
@[simp]
theorem linear_map.comp_quadratic_form_apply {R : Type u_2} {M : Type u_4} [semiring R] [ M] {S : Type} [ R] [ M] [ M] (f : R →ₗ[S] S) (Q : M) (x : M) :
def quadratic_form.lin_mul_lin {R : Type u_2} {M : Type u_4} [ M] (f g : M →ₗ[R] R) :

The product of linear forms is a quadratic form.

Equations
@[simp]
theorem quadratic_form.lin_mul_lin_apply {R : Type u_2} {M : Type u_4} [ M] (f g : M →ₗ[R] R) (x : M) :
x = f x * g x
@[simp]
theorem quadratic_form.add_lin_mul_lin {R : Type u_2} {M : Type u_4} [ M] (f g h : M →ₗ[R] R) :
@[simp]
theorem quadratic_form.lin_mul_lin_add {R : Type u_2} {M : Type u_4} [ M] (f g h : M →ₗ[R] R) :
@[simp]
theorem quadratic_form.lin_mul_lin_comp {R : Type u_2} {M : Type u_4} [ M] {N : Type v} [ N] (f g : M →ₗ[R] R) (h : N →ₗ[R] M) :
h = (g.comp h)
@[simp]
theorem quadratic_form.sq_apply {R : Type u_2} (ᾰ : R) :
= *
def quadratic_form.sq {R : Type u_2}  :

`sq` is the quadratic form mapping the vector `x : R₁` to `x * x`

Equations
def quadratic_form.proj {R : Type u_2} {n : Type u_5} (i j : n) :
(n R)

`proj i j` is the quadratic form mapping the vector `x : n → R₁` to `x i * x j`

Equations
@[simp]
theorem quadratic_form.proj_apply {R : Type u_2} {n : Type u_5} (i j : n) (x : n R) :
j) x = x i * x j

### 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.

def bilin_form.to_quadratic_form {R : Type u_2} {M : Type u_4} [semiring R] [ M] (B : M) :

A bilinear form gives a quadratic form by applying the argument twice.

Equations
@[simp]
theorem bilin_form.to_quadratic_form_apply {R : Type u_2} {M : Type u_4} [semiring R] [ M] (B : M) (x : M) :
@[simp]
theorem bilin_form.to_quadratic_form_zero (R : Type u_2) (M : Type u_4) [semiring R] [ M] :
@[simp]
theorem bilin_form.to_quadratic_form_add {R : Type u_2} {M : Type u_4} [semiring R] [ M] (B₁ B₂ : M) :
@[simp]
theorem bilin_form.to_quadratic_form_smul {S : Type u_1} {R : Type u_2} {M : Type u_4} [semiring R] [ M] [monoid S] [ R] [ R] (a : S) (B : M) :
def bilin_form.to_quadratic_form_add_monoid_hom (R : Type u_2) (M : Type u_4) [semiring R] [ M] :
M →+

`bilin_form.to_quadratic_form` as an additive homomorphism

Equations
@[simp]
theorem bilin_form.to_quadratic_form_add_monoid_hom_apply (R : Type u_2) (M : Type u_4) [semiring R] [ M] (B : M) :
@[simp]
theorem bilin_form.to_quadratic_form_list_sum {R : Type u_2} {M : Type u_4} [semiring R] [ M] (B : list M)) :
@[simp]
theorem bilin_form.to_quadratic_form_multiset_sum {R : Type u_2} {M : Type u_4} [semiring R] [ M] (B : multiset M)) :
@[simp]
theorem bilin_form.to_quadratic_form_sum {R : Type u_2} {M : Type u_4} [semiring R] [ M] {ι : Type u_1} (s : finset ι) (B : ι M) :
(s.sum (λ (i : ι), B i)).to_quadratic_form = s.sum (λ (i : ι), (B i).to_quadratic_form)
theorem bilin_form.polar_to_quadratic_form {R : Type u_2} {M : Type u_4} [ring R] [ M] {B : M} (x y : M) :
quadratic_form.polar (λ (x : M), B x x) x y = B x y + B y x
@[simp]
theorem bilin_form.to_quadratic_form_neg {R : Type u_2} {M : Type u_4} [ring R] [ M] (B : M) :
@[simp]
theorem bilin_form.to_quadratic_form_sub {R : Type u_2} {M : Type u_4} [ring R] [ M] (B₁ B₂ : M) :
def quadratic_form.associated_hom (S : Type u_1) {R : Type u_2} {M : Type u_4} [ring R] [ M] [ R] [invertible 2] :

`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
@[simp]
theorem quadratic_form.associated_apply (S : Type u_1) {R : Type u_2} {M : Type u_4} [ring R] [ M] [ R] [invertible 2] (Q : M) (x y : M) :
x y = 2 * (Q (x + y) - Q x - Q y)
theorem quadratic_form.associated_is_symm (S : Type u_1) {R : Type u_2} {M : Type u_4} [ring R] [ M] [ R] [invertible 2] (Q : M) :
@[simp]
theorem quadratic_form.associated_comp (S : Type u_1) {R : Type u_2} {M : Type u_4} [ring R] [ M] [ R] [invertible 2] (Q : M) {N : Type v} [ N] (f : N →ₗ[R] M) :
(Q.comp f) = .comp f f
theorem quadratic_form.associated_to_quadratic_form (S : Type u_1) {R : Type u_2} {M : Type u_4} [ring R] [ M] [ R] [invertible 2] (B : M) (x y : M) :
y = 2 * (B x y + B y x)
theorem quadratic_form.associated_left_inverse (S : Type u_1) {R : Type u_2} {M : Type u_4} [ring R] [ M] [ R] [invertible 2] {B₁ : M} (h : B₁.is_symm) :
theorem quadratic_form.to_quadratic_form_associated (S : Type u_1) {R : Type u_2} {M : Type u_4} [ring R] [ M] [ R] [invertible 2] (Q : M) :
theorem quadratic_form.associated_right_inverse (S : Type u_1) {R : Type u_2} {M : Type u_4} [ring R] [ M] [ R] [invertible 2] :
theorem quadratic_form.associated_eq_self_apply (S : Type u_1) {R : Type u_2} {M : Type u_4} [ring R] [ M] [ R] [invertible 2] (Q : M) (x : M) :
x x = Q x
@[reducible]
def quadratic_form.associated' {R : Type u_2} {M : Type u_4} [ring R] [ M] [invertible 2] :

`associated'` is the `ℤ`-linear map that sends a quadratic form on a module `M` over `R` to its associated symmetric bilinear form.

@[protected, instance]
def quadratic_form.can_lift {R : Type u_2} {M : Type u_4} [ring R] [ M] [invertible 2] :

Symmetric bilinear forms can be lifted to quadratic forms

Equations
theorem quadratic_form.exists_quadratic_form_ne_zero {R : Type u_2} {M : Type u_4} [ring R] [ M] [invertible 2] {Q : M} (hB₁ : 0) :
(x : M), Q x 0

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`.

@[reducible]
def quadratic_form.associated {R₁ : Type u_3} {M : Type u_4} [comm_ring R₁] [module R₁ M] [invertible 2] :
M →ₗ[R₁] M

`associated` is the linear map that sends a quadratic form over a commutative ring to its associated symmetric bilinear form.

@[simp]
theorem quadratic_form.associated_lin_mul_lin {R₁ : Type u_3} {M : Type u_4} [comm_ring R₁] [module R₁ M] [invertible 2] (f g : M →ₗ[R₁] R₁) :
def quadratic_form.anisotropic {R : Type u_2} {M : Type u_4} [semiring R] [ M] (Q : M) :
Prop

An anisotropic quadratic form is zero only on zero vectors.

Equations
theorem quadratic_form.not_anisotropic_iff_exists {R : Type u_2} {M : Type u_4} [semiring R] [ M] (Q : M) :
¬Q.anisotropic (x : M) (H : x 0), Q x = 0
theorem quadratic_form.anisotropic.eq_zero_iff {R : Type u_2} {M : Type u_4} [semiring R] [ M] {Q : M} (h : Q.anisotropic) {x : M} :
Q x = 0 x = 0
theorem quadratic_form.nondegenerate_of_anisotropic {R : Type u_2} {M : Type u_4} [ring R] [ M] [invertible 2] (Q : M) (hB : Q.anisotropic) :

The associated bilinear form of an anisotropic quadratic form is nondegenerate.

def quadratic_form.pos_def {M : Type u_4} {R₂ : Type u} [ordered_ring R₂] [module R₂ M] (Q₂ : M) :
Prop

A positive definite quadratic form is positive on nonzero vectors.

Equations
theorem quadratic_form.pos_def.smul {M : Type u_4} {R : Type u_1} [ M] {Q : M} (h : Q.pos_def) {a : R} (a_pos : 0 < a) :
(a Q).pos_def
theorem quadratic_form.pos_def.nonneg {M : Type u_4} {R₂ : Type u} [ordered_ring R₂] [module R₂ M] {Q : M} (hQ : Q.pos_def) (x : M) :
0 Q x
theorem quadratic_form.pos_def.anisotropic {M : Type u_4} {R₂ : Type u} [ordered_ring R₂] [module R₂ M] {Q : M} (hQ : Q.pos_def) :
theorem quadratic_form.pos_def_of_nonneg {M : Type u_4} {R₂ : Type u} [ordered_ring R₂] [module R₂ M] {Q : M} (h : (x : M), 0 Q x) (h0 : Q.anisotropic) :
theorem quadratic_form.pos_def_iff_nonneg {M : Type u_4} {R₂ : Type u} [ordered_ring R₂] [module R₂ M] {Q : M} :
Q.pos_def ( (x : M), 0 Q x) Q.anisotropic
theorem quadratic_form.pos_def.add {M : Type u_4} {R₂ : Type u} [ordered_ring R₂] [module R₂ M] (Q Q' : M) (hQ : Q.pos_def) (hQ' : Q'.pos_def) :
(Q + Q').pos_def
theorem quadratic_form.lin_mul_lin_self_pos_def {M : Type u_4} {R : Type u_1} [ M] (f : M →ₗ[R] R) (hf : = ) :

### 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.

def matrix.to_quadratic_form' {R₁ : Type u_3} {n : Type w} [fintype n] [decidable_eq n] [comm_ring R₁] (M : n R₁) :
(n R₁)

`M.to_quadratic_form` is the map `λ x, col x ⬝ M ⬝ row x` as a quadratic form.

Equations
def quadratic_form.to_matrix' {R₁ : Type u_3} {n : Type w} [fintype n] [decidable_eq n] [comm_ring R₁] [invertible 2] (Q : (n R₁)) :
n R₁

A matrix representation of the quadratic form.

Equations
theorem quadratic_form.to_matrix'_smul {R₁ : Type u_3} {n : Type w} [fintype n] [decidable_eq n] [comm_ring R₁] [invertible 2] (a : R₁) (Q : (n R₁)) :
theorem quadratic_form.is_symm_to_matrix' {R₁ : Type u_3} {n : Type w} [fintype n] [decidable_eq n] [comm_ring R₁] [invertible 2] (Q : (n R₁)) :
@[simp]
theorem quadratic_form.to_matrix'_comp {R₁ : Type u_3} {n : Type w} [fintype n] [comm_ring R₁] [decidable_eq n] [invertible 2] {m : Type w} [decidable_eq m] [fintype m] (Q : (m R₁)) (f : (n R₁) →ₗ[R₁] m R₁) :
def quadratic_form.discr {R₁ : Type u_3} {n : Type w} [fintype n] [comm_ring R₁] [decidable_eq n] [invertible 2] (Q : (n R₁)) :
R₁

The discriminant of a quadratic form generalizes the discriminant of a quadratic polynomial.

Equations
theorem quadratic_form.discr_smul {R₁ : Type u_3} {n : Type w} [fintype n] [comm_ring R₁] [decidable_eq n] [invertible 2] {Q : (n R₁)} (a : R₁) :
(a Q).discr = * Q.discr
theorem quadratic_form.discr_comp {R₁ : Type u_3} {n : Type w} [fintype n] [comm_ring R₁] [decidable_eq n] [invertible 2] {Q : (n R₁)} (f : (n R₁) →ₗ[R₁] n R₁) :
(Q.comp f).discr =
theorem bilin_form.nondegenerate_of_anisotropic {R : Type u_2} {M : Type u_4} [semiring R] [ M] {B : M} (hB : B.to_quadratic_form.anisotropic) :

A bilinear form is nondegenerate if the quadratic form it is associated with is anisotropic.

theorem bilin_form.exists_bilin_form_self_ne_zero {R : Type u_2} {M : Type u_4} [ring R] [ M] [htwo : invertible 2] {B : M} (hB₁ : B 0) (hB₂ : B.is_symm) :
(x : M), ¬B.is_ortho x x

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`.

theorem bilin_form.exists_orthogonal_basis {V : Type u} {K : Type v} [field K] [ V] [ V] [hK : invertible 2] {B : V} (hB₂ : B.is_symm) :
(v : basis (fin K V), B.is_Ortho v

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`.

noncomputable def quadratic_form.basis_repr {R : Type u_2} {M : Type u_4} [semiring R] [ M] {ι : Type u_6} [fintype ι] (Q : M) (v : R M) :
R)

Given a quadratic form `Q` and a basis, `basis_repr` is the basis representation of `Q`.

Equations
@[simp]
theorem quadratic_form.basis_repr_apply {R : Type u_2} {M : Type u_4} [semiring R] [ M] {ι : Type u_6} [fintype ι] {v : R M} (Q : M) (w : ι R) :
(Q.basis_repr v) w = Q (finset.univ.sum (λ (i : ι), w i v i))
def quadratic_form.weighted_sum_squares {S : Type u_1} (R₁ : Type u_3) [comm_semiring R₁] {ι : Type u_6} [fintype ι] [monoid S] [ R₁] [ R₁ R₁] (w : ι S) :
R₁)

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
@[simp]
theorem quadratic_form.weighted_sum_squares_apply {S : Type u_1} {R₁ : Type u_3} [comm_semiring R₁] {ι : Type u_6} [fintype ι] [monoid S] [ R₁] [ R₁ R₁] (w : ι S) (v : ι R₁) :
= finset.univ.sum (λ (i : ι), w i (v i * v i))
theorem quadratic_form.basis_repr_eq_of_is_Ortho {ι : Type u_6} [fintype ι] {R₁ : Type u_1} {M : Type u_2} [comm_ring R₁] [module R₁ M] [invertible 2] (Q : M) (v : R₁ M) (hv₂ : v) :
Q.basis_repr v = (λ (i : ι), Q (v i))

On an orthogonal basis, the basis representation of `Q` is just a sum of squares.