Documentation

Mathlib.LinearAlgebra.QuadraticForm.Basic

Quadratic forms #

This file defines quadratic forms over a R-module M. A quadratic form on a commutative ring R is a map Q : M → R such that:

This notion generalizes to commutative 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 QuadraticForm.polar Q.

To build a QuadraticForm from the polar axioms, use QuadraticForm.ofPolar.

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 #

Main statements #

Notation #

In this file, the variable R is used when a CommSemiring structure is available.

The variable S is used when R itself has a action.

Implementation notes #

While the definition and many results make sense if we drop commutativity assumptions, the correct definition of a quadratic form in the noncommutative setting would require substantial refactors from the current version, such that $Q(rm) = rQ(m)r^$ for some suitable conjugation $r^$.

The Zulip thread has some further discusion.

References #

Tags #

quadratic form, homogeneous polynomial, quadratic polynomial

def QuadraticForm.polar {R : Type u_3} {M : Type u_4} [CommRing R] [AddCommGroup M] (f : MR) (x : M) (y : M) :
R

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
Instances For
    theorem QuadraticForm.polar_add {R : Type u_3} {M : Type u_4} [CommRing R] [AddCommGroup M] (f : MR) (g : MR) (x : M) (y : M) :
    theorem QuadraticForm.polar_neg {R : Type u_3} {M : Type u_4} [CommRing R] [AddCommGroup M] (f : MR) (x : M) (y : M) :
    theorem QuadraticForm.polar_smul {S : Type u_1} {R : Type u_3} {M : Type u_4} [CommRing R] [AddCommGroup M] [Monoid S] [DistribMulAction S R] (f : MR) (s : S) (x : M) (y : M) :
    theorem QuadraticForm.polar_comm {R : Type u_3} {M : Type u_4} [CommRing R] [AddCommGroup M] (f : MR) (x : M) (y : M) :
    theorem QuadraticForm.polar_add_left_iff {R : Type u_3} {M : Type u_4} [CommRing R] [AddCommGroup M] {f : MR} {x : M} {x' : M} {y : M} :
    QuadraticForm.polar f (x + x') y = QuadraticForm.polar f x y + QuadraticForm.polar f x' 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 QuadraticForm.polar without subtraction.

    theorem QuadraticForm.polar_comp {S : Type u_1} {R : Type u_3} {M : Type u_4} [CommRing R] [AddCommGroup M] {F : Type u_5} [CommRing S] [FunLike F R S] [AddMonoidHomClass F R S] (f : MR) (g : F) (x : M) (y : M) :
    structure QuadraticForm (R : Type u) (M : Type v) [CommSemiring R] [AddCommMonoid M] [Module R M] :
    Type (max u v)

    A quadratic form over a module.

    For a more familiar constructor when R is a ring, see QuadraticForm.ofPolar.

    • toFun : MR
    • toFun_smul : ∀ (a : R) (x : M), self.toFun (a x) = a * a * self.toFun x
    • exists_companion' : ∃ (B : M →ₗ[R] M →ₗ[R] R), ∀ (x y : M), self.toFun (x + y) = self.toFun x + self.toFun y + (B x) y
    Instances For
      instance QuadraticForm.instFunLike {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] :
      Equations
      • QuadraticForm.instFunLike = { coe := QuadraticForm.toFun, coe_injective' := (_ : ∀ (x y : QuadraticForm R M), x.toFun = y.toFunx = y) }
      instance QuadraticForm.instCoeFunQuadraticFormForAll {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] :
      CoeFun (QuadraticForm R M) fun (x : QuadraticForm R M) => MR

      Helper instance for when there's too many metavariables to apply DFunLike.hasCoeToFun directly.

      Equations
      • QuadraticForm.instCoeFunQuadraticFormForAll = { coe := DFunLike.coe }
      @[simp]
      theorem QuadraticForm.toFun_eq_coe {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] (Q : QuadraticForm R M) :
      Q.toFun = Q

      The simp normal form for a quadratic form is DFunLike.coe, not toFun.

      theorem QuadraticForm.ext {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] {Q : QuadraticForm R M} {Q' : QuadraticForm R M} (H : ∀ (x : M), Q x = Q' x) :
      Q = Q'
      theorem QuadraticForm.congr_fun {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] {Q : QuadraticForm R M} {Q' : QuadraticForm R M} (h : Q = Q') (x : M) :
      Q x = Q' x
      theorem QuadraticForm.ext_iff {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] {Q : QuadraticForm R M} {Q' : QuadraticForm R M} :
      Q = Q' ∀ (x : M), Q x = Q' x
      def QuadraticForm.copy {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] (Q : QuadraticForm R M) (Q' : MR) (h : Q' = Q) :

      Copy of a QuadraticForm with a new toFun equal to the old one. Useful to fix definitional equalities.

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For
        @[simp]
        theorem QuadraticForm.coe_copy {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] (Q : QuadraticForm R M) (Q' : MR) (h : Q' = Q) :
        (QuadraticForm.copy Q Q' h) = Q'
        theorem QuadraticForm.copy_eq {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] (Q : QuadraticForm R M) (Q' : MR) (h : Q' = Q) :
        theorem QuadraticForm.map_smul {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] (Q : QuadraticForm R M) (a : R) (x : M) :
        Q (a x) = a * a * Q x
        theorem QuadraticForm.exists_companion {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] (Q : QuadraticForm R M) :
        ∃ (B : M →ₗ[R] M →ₗ[R] R), ∀ (x y : M), Q (x + y) = Q x + Q y + (B x) y
        theorem QuadraticForm.map_add_add_add_map {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] (Q : QuadraticForm R M) (x : M) (y : M) (z : M) :
        Q (x + y + z) + (Q x + Q y + Q z) = Q (x + y) + Q (y + z) + Q (z + x)
        theorem QuadraticForm.map_add_self {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] (Q : QuadraticForm R M) (x : M) :
        Q (x + x) = 4 * Q x
        theorem QuadraticForm.map_zero {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] (Q : QuadraticForm R M) :
        Q 0 = 0
        instance QuadraticForm.zeroHomClass {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] :
        Equations
        theorem QuadraticForm.map_smul_of_tower {S : Type u_1} {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] (Q : QuadraticForm R M) [CommSemiring S] [Algebra S R] [Module S M] [IsScalarTower S R M] (a : S) (x : M) :
        Q (a x) = (a * a) Q x
        @[simp]
        theorem QuadraticForm.map_neg {R : Type u_3} {M : Type u_4} [CommRing R] [AddCommGroup M] [Module R M] (Q : QuadraticForm R M) (x : M) :
        Q (-x) = Q x
        theorem QuadraticForm.map_sub {R : Type u_3} {M : Type u_4} [CommRing R] [AddCommGroup M] [Module R M] (Q : QuadraticForm R M) (x : M) (y : M) :
        Q (x - y) = Q (y - x)
        @[simp]
        theorem QuadraticForm.polar_zero_left {R : Type u_3} {M : Type u_4} [CommRing R] [AddCommGroup M] [Module R M] (Q : QuadraticForm R M) (y : M) :
        QuadraticForm.polar (Q) 0 y = 0
        @[simp]
        theorem QuadraticForm.polar_add_left {R : Type u_3} {M : Type u_4} [CommRing R] [AddCommGroup M] [Module R M] (Q : QuadraticForm R M) (x : M) (x' : M) (y : M) :
        QuadraticForm.polar (Q) (x + x') y = QuadraticForm.polar (Q) x y + QuadraticForm.polar (Q) x' y
        @[simp]
        theorem QuadraticForm.polar_smul_left {R : Type u_3} {M : Type u_4} [CommRing R] [AddCommGroup M] [Module R M] (Q : QuadraticForm R M) (a : R) (x : M) (y : M) :
        QuadraticForm.polar (Q) (a x) y = a * QuadraticForm.polar (Q) x y
        @[simp]
        theorem QuadraticForm.polar_neg_left {R : Type u_3} {M : Type u_4} [CommRing R] [AddCommGroup M] [Module R M] (Q : QuadraticForm R M) (x : M) (y : M) :
        @[simp]
        theorem QuadraticForm.polar_sub_left {R : Type u_3} {M : Type u_4} [CommRing R] [AddCommGroup M] [Module R M] (Q : QuadraticForm R M) (x : M) (x' : M) (y : M) :
        QuadraticForm.polar (Q) (x - x') y = QuadraticForm.polar (Q) x y - QuadraticForm.polar (Q) x' y
        @[simp]
        theorem QuadraticForm.polar_zero_right {R : Type u_3} {M : Type u_4} [CommRing R] [AddCommGroup M] [Module R M] (Q : QuadraticForm R M) (y : M) :
        QuadraticForm.polar (Q) y 0 = 0
        @[simp]
        theorem QuadraticForm.polar_add_right {R : Type u_3} {M : Type u_4} [CommRing R] [AddCommGroup M] [Module R M] (Q : QuadraticForm R M) (x : M) (y : M) (y' : M) :
        QuadraticForm.polar (Q) x (y + y') = QuadraticForm.polar (Q) x y + QuadraticForm.polar (Q) x y'
        @[simp]
        theorem QuadraticForm.polar_smul_right {R : Type u_3} {M : Type u_4} [CommRing R] [AddCommGroup M] [Module R M] (Q : QuadraticForm R M) (a : R) (x : M) (y : M) :
        QuadraticForm.polar (Q) x (a y) = a * QuadraticForm.polar (Q) x y
        @[simp]
        theorem QuadraticForm.polar_neg_right {R : Type u_3} {M : Type u_4} [CommRing R] [AddCommGroup M] [Module R M] (Q : QuadraticForm R M) (x : M) (y : M) :
        @[simp]
        theorem QuadraticForm.polar_sub_right {R : Type u_3} {M : Type u_4} [CommRing R] [AddCommGroup M] [Module R M] (Q : QuadraticForm R M) (x : M) (y : M) (y' : M) :
        QuadraticForm.polar (Q) x (y - y') = QuadraticForm.polar (Q) x y - QuadraticForm.polar (Q) x y'
        @[simp]
        theorem QuadraticForm.polar_self {R : Type u_3} {M : Type u_4} [CommRing R] [AddCommGroup M] [Module R M] (Q : QuadraticForm R M) (x : M) :
        QuadraticForm.polar (Q) x x = 2 * Q x
        @[simp]
        theorem QuadraticForm.polarBilin_apply {R : Type u_3} {M : Type u_4} [CommRing R] [AddCommGroup M] [Module R M] (Q : QuadraticForm R M) (x : M) (y : M) :
        def QuadraticForm.polarBilin {R : Type u_3} {M : Type u_4} [CommRing R] [AddCommGroup M] [Module R M] (Q : QuadraticForm R M) :

        QuadraticForm.polar as a bilinear form

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          @[simp]
          theorem QuadraticForm.polarLinearMap₂_apply_apply {R : Type u_3} {M : Type u_4} [CommRing R] [AddCommGroup M] [Module R M] (Q : QuadraticForm R M) (m : M) (y : M) :
          def QuadraticForm.polarLinearMap₂ {R : Type u_3} {M : Type u_4} [CommRing R] [AddCommGroup M] [Module R M] (Q : QuadraticForm R M) :

          QuadraticForm.polar as a bilinear map

          Equations
          • One or more equations did not get rendered due to their size.
          Instances For
            @[simp]
            theorem QuadraticForm.polar_smul_left_of_tower {S : Type u_1} {R : Type u_3} {M : Type u_4} [CommRing R] [AddCommGroup M] [Module R M] (Q : QuadraticForm R M) [CommSemiring S] [Algebra S R] [Module S M] [IsScalarTower S R M] (a : S) (x : M) (y : M) :
            QuadraticForm.polar (Q) (a x) y = a QuadraticForm.polar (Q) x y
            @[simp]
            theorem QuadraticForm.polar_smul_right_of_tower {S : Type u_1} {R : Type u_3} {M : Type u_4} [CommRing R] [AddCommGroup M] [Module R M] (Q : QuadraticForm R M) [CommSemiring S] [Algebra S R] [Module S M] [IsScalarTower S R M] (a : S) (x : M) (y : M) :
            QuadraticForm.polar (Q) x (a y) = a QuadraticForm.polar (Q) x y
            @[simp]
            theorem QuadraticForm.ofPolar_apply {R : Type u_3} {M : Type u_4} [CommRing R] [AddCommGroup M] [Module R M] (toFun : MR) (toFun_smul : ∀ (a : R) (x : M), toFun (a x) = a * a * toFun x) (polar_add_left : ∀ (x x' y : M), QuadraticForm.polar toFun (x + x') y = QuadraticForm.polar toFun x y + QuadraticForm.polar toFun x' y) (polar_smul_left : ∀ (a : R) (x y : M), QuadraticForm.polar toFun (a x) y = a QuadraticForm.polar toFun x y) :
            ∀ (a : M), (QuadraticForm.ofPolar toFun toFun_smul polar_add_left polar_smul_left) a = toFun a
            def QuadraticForm.ofPolar {R : Type u_3} {M : Type u_4} [CommRing R] [AddCommGroup M] [Module R M] (toFun : MR) (toFun_smul : ∀ (a : R) (x : M), toFun (a x) = a * a * toFun x) (polar_add_left : ∀ (x x' y : M), QuadraticForm.polar toFun (x + x') y = QuadraticForm.polar toFun x y + QuadraticForm.polar toFun x' y) (polar_smul_left : ∀ (a : R) (x y : M), QuadraticForm.polar toFun (a x) y = a QuadraticForm.polar toFun x y) :

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

            Equations
            • One or more equations did not get rendered due to their size.
            Instances For
              theorem QuadraticForm.choose_exists_companion {R : Type u_3} {M : Type u_4} [CommRing R] [AddCommGroup M] [Module R M] (Q : QuadraticForm R M) :
              Exists.choose (_ : ∃ (B : M →ₗ[R] M →ₗ[R] R), ∀ (x y : M), Q (x + y) = Q x + Q y + (B x) y) = QuadraticForm.polarLinearMap₂ Q

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

              instance QuadraticForm.instSMulQuadraticForm {S : Type u_1} {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] [Monoid S] [DistribMulAction S R] [SMulCommClass S R R] :

              QuadraticForm R M inherits the scalar action from any algebra over R.

              This provides an R-action via Algebra.id.

              Equations
              • One or more equations did not get rendered due to their size.
              @[simp]
              theorem QuadraticForm.coeFn_smul {S : Type u_1} {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] [Monoid S] [DistribMulAction S R] [SMulCommClass S R R] (a : S) (Q : QuadraticForm R M) :
              (a Q) = a Q
              @[simp]
              theorem QuadraticForm.smul_apply {S : Type u_1} {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] [Monoid S] [DistribMulAction S R] [SMulCommClass S R R] (a : S) (Q : QuadraticForm R M) (x : M) :
              (a Q) x = a Q x
              Equations
              • One or more equations did not get rendered due to their size.
              @[simp]
              theorem QuadraticForm.coeFn_zero {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] :
              0 = 0
              @[simp]
              theorem QuadraticForm.zero_apply {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] (x : M) :
              0 x = 0
              Equations
              • QuadraticForm.instInhabitedQuadraticForm = { default := 0 }
              Equations
              • One or more equations did not get rendered due to their size.
              @[simp]
              theorem QuadraticForm.coeFn_add {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] (Q : QuadraticForm R M) (Q' : QuadraticForm R M) :
              (Q + Q') = Q + Q'
              @[simp]
              theorem QuadraticForm.add_apply {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] (Q : QuadraticForm R M) (Q' : QuadraticForm R M) (x : M) :
              (Q + Q') x = Q x + Q' x
              Equations
              • One or more equations did not get rendered due to their size.
              @[simp]
              theorem QuadraticForm.coeFnAddMonoidHom_apply {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] :
              ∀ (a : QuadraticForm R M) (a_1 : M), QuadraticForm.coeFnAddMonoidHom a a_1 = a a_1
              def QuadraticForm.coeFnAddMonoidHom {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] :
              QuadraticForm R M →+ MR

              @CoeFn (QuadraticForm R M) as an AddMonoidHom.

              This API mirrors AddMonoidHom.coeFn.

              Equations
              • QuadraticForm.coeFnAddMonoidHom = { toZeroHom := { toFun := DFunLike.coe, map_zero' := (_ : 0 = 0) }, map_add' := (_ : ∀ (Q Q' : QuadraticForm R M), (Q + Q') = Q + Q') }
              Instances For
                @[simp]
                theorem QuadraticForm.evalAddMonoidHom_apply {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] (m : M) :
                def QuadraticForm.evalAddMonoidHom {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] (m : M) :

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

                Equations
                Instances For
                  @[simp]
                  theorem QuadraticForm.coeFn_sum {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] {ι : Type u_5} (Q : ιQuadraticForm R M) (s : Finset ι) :
                  (Finset.sum s fun (i : ι) => Q i) = Finset.sum s fun (i : ι) => (Q i)
                  @[simp]
                  theorem QuadraticForm.sum_apply {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] {ι : Type u_5} (Q : ιQuadraticForm R M) (s : Finset ι) (x : M) :
                  (Finset.sum s fun (i : ι) => Q i) x = Finset.sum s fun (i : ι) => (Q i) x
                  Equations
                  • One or more equations did not get rendered due to their size.
                  Equations
                  Equations
                  • One or more equations did not get rendered due to their size.
                  @[simp]
                  theorem QuadraticForm.coeFn_neg {R : Type u_3} {M : Type u_4} [CommRing R] [AddCommGroup M] [Module R M] (Q : QuadraticForm R M) :
                  (-Q) = -Q
                  @[simp]
                  theorem QuadraticForm.neg_apply {R : Type u_3} {M : Type u_4} [CommRing R] [AddCommGroup M] [Module R M] (Q : QuadraticForm R M) (x : M) :
                  (-Q) x = -Q x
                  Equations
                  @[simp]
                  theorem QuadraticForm.coeFn_sub {R : Type u_3} {M : Type u_4} [CommRing R] [AddCommGroup M] [Module R M] (Q : QuadraticForm R M) (Q' : QuadraticForm R M) :
                  (Q - Q') = Q - Q'
                  @[simp]
                  theorem QuadraticForm.sub_apply {R : Type u_3} {M : Type u_4} [CommRing R] [AddCommGroup M] [Module R M] (Q : QuadraticForm R M) (Q' : QuadraticForm R M) (x : M) :
                  (Q - Q') x = Q x - Q' x
                  Equations
                  • One or more equations did not get rendered due to their size.
                  def QuadraticForm.comp {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] {N : Type v} [AddCommMonoid N] [Module R N] (Q : QuadraticForm R N) (f : M →ₗ[R] N) :

                  Compose the quadratic form with a linear function.

                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For
                    @[simp]
                    theorem QuadraticForm.comp_apply {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] {N : Type v} [AddCommMonoid N] [Module R N] (Q : QuadraticForm R N) (f : M →ₗ[R] N) (x : M) :
                    (QuadraticForm.comp Q f) x = Q (f x)
                    @[simp]
                    theorem LinearMap.compQuadraticForm_apply {S : Type u_1} {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] [CommSemiring S] [Algebra S R] [Module S M] [IsScalarTower S R M] (f : R →ₗ[S] S) (Q : QuadraticForm R M) (x : M) :
                    def LinearMap.compQuadraticForm {S : Type u_1} {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] [CommSemiring S] [Algebra S R] [Module S M] [IsScalarTower S R M] (f : R →ₗ[S] S) (Q : QuadraticForm R M) :

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

                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For
                      def QuadraticForm.linMulLin {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] (f : M →ₗ[R] R) (g : M →ₗ[R] R) :

                      The product of linear forms is a quadratic form.

                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For
                        @[simp]
                        theorem QuadraticForm.linMulLin_apply {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] (f : M →ₗ[R] R) (g : M →ₗ[R] R) (x : M) :
                        (QuadraticForm.linMulLin f g) x = f x * g x
                        @[simp]
                        @[simp]
                        @[simp]
                        theorem QuadraticForm.linMulLin_comp {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] {N : Type v} [AddCommMonoid N] [Module R N] (f : M →ₗ[R] R) (g : M →ₗ[R] R) (h : N →ₗ[R] M) :
                        @[simp]
                        theorem QuadraticForm.sq_apply {R : Type u_3} [CommSemiring R] (a : R) :
                        QuadraticForm.sq a = a * a

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

                        Equations
                        Instances For
                          def QuadraticForm.proj {R : Type u_3} [CommSemiring R] {n : Type u_5} (i : n) (j : n) :
                          QuadraticForm R (nR)

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

                          Equations
                          Instances For
                            @[simp]
                            theorem QuadraticForm.proj_apply {R : Type u_3} [CommSemiring R] {n : Type u_5} (i : n) (j : n) (x : nR) :
                            (QuadraticForm.proj i 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 LinearMap.toQuadraticForm {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] (B : M →ₗ[R] M →ₗ[R] R) :

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

                            Equations
                            • One or more equations did not get rendered due to their size.
                            Instances For
                              def BilinForm.toQuadraticForm {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] (B : BilinForm R M) :

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

                              Equations
                              Instances For
                                @[simp]
                                theorem BilinForm.toQuadraticForm_apply {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] (B : BilinForm R M) (x : M) :
                                (BilinForm.toQuadraticForm B) x = B.bilin x x
                                @[simp]

                                BilinForm.toQuadraticForm as an additive homomorphism

                                Equations
                                • One or more equations did not get rendered due to their size.
                                Instances For
                                  @[simp]
                                  theorem BilinForm.toQuadraticFormLinearMap_apply_apply (S : Type u_1) (R : Type u_3) (M : Type u_4) [CommSemiring R] [AddCommMonoid M] [Module R M] [Semiring S] [Module S R] [SMulCommClass S R R] (B : BilinForm R M) (x : M) :
                                  ((BilinForm.toQuadraticFormLinearMap S R M) B) x = B.bilin x x

                                  BilinForm.toQuadraticForm as a linear map

                                  Equations
                                  • One or more equations did not get rendered due to their size.
                                  Instances For
                                    @[simp]
                                    theorem BilinForm.toQuadraticForm_list_sum {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] (B : List (BilinForm R M)) :
                                    BilinForm.toQuadraticForm (List.sum B) = List.sum (List.map BilinForm.toQuadraticForm B)
                                    @[simp]
                                    @[simp]
                                    theorem BilinForm.toQuadraticForm_sum {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] {ι : Type u_5} (s : Finset ι) (B : ιBilinForm R M) :
                                    BilinForm.toQuadraticForm (Finset.sum s fun (i : ι) => B i) = Finset.sum s fun (i : ι) => BilinForm.toQuadraticForm (B i)
                                    @[simp]
                                    theorem BilinForm.polar_toQuadraticForm {R : Type u_3} {M : Type u_4} [CommRing R] [AddCommGroup M] [Module R M] {B : BilinForm R M} (x : M) (y : M) :
                                    QuadraticForm.polar ((BilinForm.toQuadraticForm B)) x y = B.bilin x y + B.bilin y x
                                    theorem QuadraticForm.polarBilin_injective {R : Type u_3} {M : Type u_4} [CommRing R] [AddCommGroup M] [Module R M] (h : IsUnit 2) :
                                    Function.Injective QuadraticForm.polarBilin
                                    theorem LinearMap.compQuadraticForm_polar {S : Type u_1} {R : Type u_3} {M : Type u_4} [CommRing R] [AddCommGroup M] [Module R M] [CommRing S] [Algebra S R] [Module S M] [IsScalarTower S R M] (f : R →ₗ[S] S) (Q : QuadraticForm R M) (x : M) (y : M) :
                                    def QuadraticForm.associatedHom (S : Type u_1) {R : Type u_3} {M : Type u_4} [CommRing R] [AddCommGroup M] [Module R M] [CommSemiring S] [Algebra S R] [Invertible 2] :

                                    associatedHom 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 QuadraticForm.associated, which gives an R-linear map. Over a general ring with no nontrivial distinguished commutative subring, use QuadraticForm.associated', which gives an additive homomorphism (or more precisely a -linear map.)

                                    Equations
                                    • One or more equations did not get rendered due to their size.
                                    Instances For
                                      @[simp]
                                      theorem QuadraticForm.associated_apply (S : Type u_1) {R : Type u_3} {M : Type u_4} [CommRing R] [AddCommGroup M] [Module R M] [CommSemiring S] [Algebra S R] [Invertible 2] (Q : QuadraticForm R M) (x : M) (y : M) :
                                      ((QuadraticForm.associatedHom S) Q).bilin x y = 2 * (Q (x + y) - Q x - Q y)
                                      @[simp]
                                      theorem QuadraticForm.associated_toQuadraticForm (S : Type u_1) {R : Type u_3} {M : Type u_4} [CommRing R] [AddCommGroup M] [Module R M] [CommSemiring S] [Algebra S R] [Invertible 2] (B : BilinForm R M) (x : M) (y : M) :
                                      ((QuadraticForm.associatedHom S) (BilinForm.toQuadraticForm B)).bilin x y = 2 * (B.bilin x y + B.bilin y x)
                                      theorem QuadraticForm.associated_eq_self_apply (S : Type u_1) {R : Type u_3} {M : Type u_4} [CommRing R] [AddCommGroup M] [Module R M] [CommSemiring S] [Algebra S R] [Invertible 2] (Q : QuadraticForm R M) (x : M) :
                                      ((QuadraticForm.associatedHom S) Q).bilin x x = Q x
                                      theorem QuadraticForm.associated_rightInverse (S : Type u_1) {R : Type u_3} {M : Type u_4} [CommRing R] [AddCommGroup M] [Module R M] [CommSemiring S] [Algebra S R] [Invertible 2] :
                                      Function.RightInverse ((QuadraticForm.associatedHom S)) BilinForm.toQuadraticForm
                                      @[inline, reducible]

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

                                      Equations
                                      Instances For
                                        instance QuadraticForm.canLift {R : Type u_3} {M : Type u_4} [CommRing R] [AddCommGroup M] [Module R M] [Invertible 2] :
                                        CanLift (BilinForm R M) (QuadraticForm R M) ((QuadraticForm.associatedHom )) BilinForm.IsSymm

                                        Symmetric bilinear forms can be lifted to quadratic forms

                                        Equations
                                        • One or more equations did not get rendered due to their size.
                                        theorem QuadraticForm.exists_quadraticForm_ne_zero {R : Type u_3} {M : Type u_4} [CommRing R] [AddCommGroup M] [Module R M] [Invertible 2] {Q : QuadraticForm R M} (hB₁ : QuadraticForm.associated' Q 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.

                                        @[inline, reducible]

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

                                        Equations
                                        Instances For
                                          theorem QuadraticForm.coe_associatedHom (S : Type u_1) {R : Type u_3} {M : Type u_4} [CommSemiring S] [CommRing R] [AddCommGroup M] [Algebra S R] [Module R M] [Invertible 2] :
                                          (QuadraticForm.associatedHom S) = QuadraticForm.associated
                                          @[simp]
                                          theorem QuadraticForm.associated_linMulLin {R : Type u_3} {M : Type u_4} [CommRing R] [AddCommGroup M] [Module R M] [Invertible 2] (f : M →ₗ[R] R) (g : M →ₗ[R] R) :
                                          QuadraticForm.associated (QuadraticForm.linMulLin f g) = 2 (BilinForm.linMulLin f g + BilinForm.linMulLin g f)
                                          @[simp]
                                          theorem QuadraticForm.associated_sq {R : Type u_3} [CommRing R] [Invertible 2] :
                                          QuadraticForm.associated QuadraticForm.sq = LinearMap.toBilin (LinearMap.mul R R)

                                          Orthogonality #

                                          def QuadraticForm.IsOrtho {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] (Q : QuadraticForm R M) (x : M) (y : M) :

                                          The proposition that two elements of a quadratic form space are orthogonal.

                                          Equations
                                          Instances For
                                            theorem QuadraticForm.isOrtho_def {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] {Q : QuadraticForm R M} {x : M} {y : M} :
                                            QuadraticForm.IsOrtho Q x y Q (x + y) = Q x + Q y
                                            theorem QuadraticForm.IsOrtho.all {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] (x : M) (y : M) :
                                            theorem QuadraticForm.IsOrtho.zero_left {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] {Q : QuadraticForm R M} (x : M) :
                                            theorem QuadraticForm.IsOrtho.zero_right {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] {Q : QuadraticForm R M} (x : M) :
                                            theorem QuadraticForm.ne_zero_of_not_isOrtho_self {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] {Q : QuadraticForm R M} (x : M) (hx₁ : ¬QuadraticForm.IsOrtho Q x x) :
                                            x 0
                                            theorem QuadraticForm.isOrtho_comm {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] {Q : QuadraticForm R M} {x : M} {y : M} :
                                            theorem QuadraticForm.IsOrtho.symm {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] {Q : QuadraticForm R M} {x : M} {y : M} :

                                            Alias of the forward direction of QuadraticForm.isOrtho_comm.

                                            @[simp]
                                            theorem QuadraticForm.IsOrtho.polar_eq_zero {R : Type u_3} {M : Type u_4} [CommRing R] [AddCommGroup M] [Module R M] {Q : QuadraticForm R M} {x : M} {y : M} (h : QuadraticForm.IsOrtho Q x y) :
                                            QuadraticForm.polar (Q) x y = 0
                                            @[simp]
                                            theorem QuadraticForm.associated_isOrtho {R : Type u_3} {M : Type u_4} [CommRing R] [AddCommGroup M] [Module R M] {Q : QuadraticForm R M} [Invertible 2] {x : M} {y : M} :
                                            BilinForm.IsOrtho (QuadraticForm.associated Q) x y QuadraticForm.IsOrtho Q x y
                                            def QuadraticForm.Anisotropic {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] (Q : QuadraticForm R M) :

                                            An anisotropic quadratic form is zero only on zero vectors.

                                            Equations
                                            Instances For
                                              theorem QuadraticForm.Anisotropic.eq_zero_iff {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] {Q : QuadraticForm R M} (h : QuadraticForm.Anisotropic Q) {x : M} :
                                              Q x = 0 x = 0
                                              theorem QuadraticForm.nondegenerate_of_anisotropic {R : Type u_3} {M : Type u_4} [CommRing R] [AddCommGroup M] [Module R M] [Invertible 2] (Q : QuadraticForm R M) (hB : QuadraticForm.Anisotropic Q) :
                                              BilinForm.Nondegenerate (QuadraticForm.associated' Q)

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

                                              def QuadraticForm.PosDef {M : Type u_4} {R₂ : Type u} [OrderedCommRing R₂] [AddCommMonoid M] [Module R₂ M] (Q₂ : QuadraticForm R₂ M) :

                                              A positive definite quadratic form is positive on nonzero vectors.

                                              Equations
                                              Instances For
                                                theorem QuadraticForm.PosDef.smul {M : Type u_4} [AddCommMonoid M] {R : Type u_5} [LinearOrderedCommRing R] [Module R M] {Q : QuadraticForm R M} (h : QuadraticForm.PosDef Q) {a : R} (a_pos : 0 < a) :
                                                theorem QuadraticForm.PosDef.nonneg {M : Type u_4} {R₂ : Type u} [OrderedCommRing R₂] [AddCommMonoid M] [Module R₂ M] {Q : QuadraticForm R₂ M} (hQ : QuadraticForm.PosDef Q) (x : M) :
                                                0 Q x
                                                theorem QuadraticForm.posDef_of_nonneg {M : Type u_4} {R₂ : Type u} [OrderedCommRing R₂] [AddCommMonoid M] [Module R₂ M] {Q : QuadraticForm R₂ M} (h : ∀ (x : M), 0 Q x) (h0 : QuadraticForm.Anisotropic Q) :
                                                theorem QuadraticForm.posDef_iff_nonneg {M : Type u_4} {R₂ : Type u} [OrderedCommRing R₂] [AddCommMonoid M] [Module R₂ M] {Q : QuadraticForm R₂ M} :
                                                theorem QuadraticForm.PosDef.add {M : Type u_4} {R₂ : Type u} [OrderedCommRing R₂] [AddCommMonoid M] [Module R₂ M] (Q : QuadraticForm R₂ M) (Q' : QuadraticForm R₂ M) (hQ : QuadraticForm.PosDef Q) (hQ' : QuadraticForm.PosDef Q') :

                                                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.toQuadraticForm' {R : Type u_3} {n : Type w} [Fintype n] [DecidableEq n] [CommRing R] (M : Matrix n n R) :
                                                QuadraticForm R (nR)

                                                M.toQuadraticForm' is the map fun x ↦ col x * M * row x as a quadratic form.

                                                Equations
                                                Instances For
                                                  def QuadraticForm.toMatrix' {R : Type u_3} {n : Type w} [Fintype n] [DecidableEq n] [CommRing R] [Invertible 2] (Q : QuadraticForm R (nR)) :
                                                  Matrix n n R

                                                  A matrix representation of the quadratic form.

                                                  Equations
                                                  Instances For
                                                    @[simp]
                                                    theorem QuadraticForm.toMatrix'_comp {R : Type u_3} {n : Type w} [Fintype n] [CommRing R] [DecidableEq n] [Invertible 2] {m : Type w} [DecidableEq m] [Fintype m] (Q : QuadraticForm R (mR)) (f : (nR) →ₗ[R] mR) :
                                                    QuadraticForm.toMatrix' (QuadraticForm.comp Q f) = Matrix.transpose (LinearMap.toMatrix' f) * QuadraticForm.toMatrix' Q * LinearMap.toMatrix' f
                                                    def QuadraticForm.discr {R : Type u_3} {n : Type w} [Fintype n] [CommRing R] [DecidableEq n] [Invertible 2] (Q : QuadraticForm R (nR)) :
                                                    R

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

                                                    Equations
                                                    Instances For
                                                      theorem QuadraticForm.discr_comp {R : Type u_3} {n : Type w} [Fintype n] [CommRing R] [DecidableEq n] [Invertible 2] {Q : QuadraticForm R (nR)} (f : (nR) →ₗ[R] nR) :
                                                      QuadraticForm.discr (QuadraticForm.comp Q f) = Matrix.det (LinearMap.toMatrix' f) * Matrix.det (LinearMap.toMatrix' f) * QuadraticForm.discr Q

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

                                                      theorem BilinForm.exists_bilinForm_self_ne_zero {R : Type u_3} {M : Type u_4} [CommRing R] [AddCommGroup M] [Module R M] [htwo : Invertible 2] {B : BilinForm R M} (hB₁ : B 0) (hB₂ : BilinForm.IsSymm B) :
                                                      ∃ (x : M), ¬BilinForm.IsOrtho B 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 BilinForm.exists_orthogonal_basis {V : Type u} {K : Type v} [Field K] [AddCommGroup V] [Module K V] [FiniteDimensional K V] [hK : Invertible 2] {B : BilinForm K V} (hB₂ : BilinForm.IsSymm B) :

                                                      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 QuadraticForm.basisRepr {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] {ι : Type u_5} [Fintype ι] (Q : QuadraticForm R M) (v : Basis ι R M) :
                                                      QuadraticForm R (ιR)

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

                                                      Equations
                                                      Instances For
                                                        @[simp]
                                                        theorem QuadraticForm.basisRepr_apply {R : Type u_3} {M : Type u_4} [CommSemiring R] [AddCommMonoid M] [Module R M] {ι : Type u_5} [Fintype ι] {v : Basis ι R M} (Q : QuadraticForm R M) (w : ιR) :
                                                        (QuadraticForm.basisRepr Q v) w = Q (Finset.sum Finset.univ fun (i : ι) => w i v i)
                                                        def QuadraticForm.weightedSumSquares {S : Type u_1} (R : Type u_3) [CommSemiring R] {ι : Type u_5} [Fintype ι] [Monoid S] [DistribMulAction S R] [SMulCommClass S R R] (w : ιS) :
                                                        QuadraticForm R (ι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
                                                        Instances For
                                                          @[simp]
                                                          theorem QuadraticForm.weightedSumSquares_apply {S : Type u_1} {R : Type u_3} [CommSemiring R] {ι : Type u_5} [Fintype ι] [Monoid S] [DistribMulAction S R] [SMulCommClass S R R] (w : ιS) (v : ιR) :
                                                          (QuadraticForm.weightedSumSquares R w) v = Finset.sum Finset.univ fun (i : ι) => w i (v i * v i)
                                                          theorem QuadraticForm.basisRepr_eq_of_iIsOrtho {ι : Type u_5} [Fintype ι] {R : Type u_6} {M : Type u_7} [CommRing R] [AddCommGroup M] [Module R M] [Invertible 2] (Q : QuadraticForm R M) (v : Basis ι R M) (hv₂ : BilinForm.iIsOrtho (QuadraticForm.associated Q) v) :

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