Eine aufbereitete Darstellung der Quelle

 
     
 
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung


Quelle  Signature.lean   Sprache: Lean

 

/-
Copyright (c) 2026 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/


module

public import Mathlib.LinearAlgebra.QuadraticForm.Radical

/-!
# Signature of a quadratic form

We define the signature of a quadratic form over a linearly ordered field, and show that it can be
computed from any sum-of-squares representation.

## Main results and definitions

* `QuadraticForm.sigPos`, `QuadraticForm.sigNeg`: for a quadratic form `Q`, the maximal dimension
  of a subspace on which `Q` is positive-definite (resp. negative-definite).
* `QuadraticForm.sigPos_of_equiv_weightedSumOfSquares`,
  `QuadraticForm.sigNeg_of_equiv_weightedSumOfSquares`: for any isomorphism from `Q` to a
  weighted sum of squares, `Q.sigPos` and `Q.sigNeg` are the number of positive and negative
  weights. (This is the uniqueness part of **Sylvester's law of inertia**; the existence is
  `QuadraticForm.equivalent_one_zero_neg_one_weighted_sum_squared` in file
  `Mathlib.LinearAlgebra.QuadraticForm.Real`.)

## Acknowledgements

This file is based on work carried out by Sina Keller, Philipp Schumann, and Nicolas Trutmann in
the course of their studies at ETH Zürich.
-/


open Finset QuadraticMap

public noncomputable section

variable {R M M' : Type*} [AddCommGroup M] [AddCommGroup M']

section LinearOrder

variable [CommRing R] [LinearOrder R] [Module R M] (Q : QuadraticForm R M)
  [Module R M'] {Q' : QuadraticForm R M'} {V : Submodule R M}

section Equiv
variable {Q}

@[simp] lemma QuadraticMap.IsometryEquiv.map_posDef_iff (e : IsometryEquiv Q Q') :
    (Q'.restrict (V.map e.toLinearMap)).PosDef ↔ (Q.restrict V).PosDef := by
  simp [PosDef, -Submodule.mem_map_equiv]

@[simp] lemma QuadraticMap.IsometryEquiv.map_negDef_iff (e : IsometryEquiv Q Q') :
    ((-Q').restrict (V.map e.toLinearMap)).PosDef ↔ ((-Q).restrict V).PosDef := by
  simp [PosDef, -Submodule.mem_map_equiv]

end Equiv

open scoped Classical in
/-- For quadratic forms on finite-dimensional spaces, the maximal finrank of a positive-definite
subspace of `M`. (Defined as `0` if `M` is infinite-dimensional). -/

/-
Note the proof of nonemptiness needed for `max'` is a little fiddly since we are not assuming
`Nontrivial R`, and the `⊥` submodule of a module over the zero ring has finrank 1, not 0.
-/

def sigPos : ℕ := max' {r ∈ Iic (Module.finrank R M) |
    ∃ V : Submodule R M, Module.finrank R V = r ∧ (Q.restrict V).PosDef}
  ⟨Module.finrank R (⊥ : Submodule R M), by
    simp only [mem_filter, mem_Iic]
    refine ⟨?_, ⟨⊥, rfl, fun x hx' ↦ (hx' <| Subsingleton.elim x 0).elim⟩⟩
    nontriviality R
    simp [finrank_bot]⟩

lemma sigPos_le_finrank : sigPos Q ≤ Module.finrank R M := by
  classical
  exact mem_Iic.mp <| mem_of_mem_filter _ <| max'_mem _ _

/-- Defining property of `sigPos`. -/
lemma sigPos_isGreatest [Module.Finite R M] [StrongRankCondition R] : IsGreatest
    {r | ∃ V : Submodule R M, Module.finrank R V = r ∧ (Q.restrict V).PosDef} (sigPos Q) := by
  classical
  refine ⟨(mem_filter.mp <| max'_mem _ _).2, ?_⟩
  rintro _ ⟨V, rfl, hV⟩
  apply le_max'
  rw [mem_filter, mem_Iic]
  exact ⟨V.finrank_le, V, rfl, hV⟩

lemma exists_finrank_eq_sigPos_and_posDef [Module.Finite R M] [StrongRankCondition R] :
    ∃ V : Submodule R M, Module.finrank R V = sigPos Q ∧ (Q.restrict V).PosDef :=
  (sigPos_isGreatest Q).1

lemma le_sigPos_of_posDef [Module.Finite R M] [StrongRankCondition R]
    {V : Submodule R M} (hV : (Q.restrict V).PosDef) :
    Module.finrank R V ≤ sigPos Q :=
  (sigPos_isGreatest Q).2 ⟨V, by tauto⟩

/-- For quadratic forms on finite-dimensional spaces, the maximal finrank of a negative-definite
subspace of `M`. (Defined as `0` if `M` is infinite-dimensional). -/

def sigNeg : ℕ := sigPos (-Q)

/-- Defining property of `sigNeg`. -/
lemma sigNeg_isGreatest [Module.Finite R M] [StrongRankCondition R] : IsGreatest
    {r | ∃ V : Submodule R M, Module.finrank R V = r ∧ ((-Q).restrict V).PosDef} (sigNeg Q) :=
  sigPos_isGreatest (-Q)

lemma exists_finrank_eq_sigNeg_and_negDef [Module.Finite R M] [StrongRankCondition R] :
    ∃ V : Submodule R M, Module.finrank R V = sigNeg Q ∧ ((-Q).restrict V).PosDef :=
  exists_finrank_eq_sigPos_and_posDef (-Q)

lemma le_sigNeg_of_negDef [Module.Finite R M] [StrongRankCondition R]
    {V : Submodule R M} (hV : ((-Q).restrict V).PosDef) :
    Module.finrank R V ≤ sigNeg Q :=
  le_sigPos_of_posDef (-Q) hV

variable {Q}

@[simp] lemma sigPos_neg : sigPos (-Q) = sigNeg Q := by rfl -- `by` needed since def not exposed

@[simp] lemma sigNeg_neg : sigNeg (-Q) = sigPos Q := by rw [← sigPos_neg, neg_neg]

set_option backward.isDefEq.respectTransparency false in
lemma QuadraticMap.Equivalent.sigPos_eq (h : Equivalent Q Q') : sigPos Q = sigPos Q' := by
  obtain ⟨e⟩ := h
  unfold sigPos
  congr! with j
  · apply (Submodule.orderIsoMapComap e.toLinearEquiv).exists_congr
    intro V
    refine .and ?_ (IsometryEquiv.map_posDef_iff _).symm
    revert j
    rw [eq_iff_eq_cancel_right]
    exact (e.finrank_map_eq _).symm
  · exact e.toLinearEquiv.finrank_eq

lemma QuadraticMap.Equivalent.sigNeg_eq (h : Equivalent Q Q') : sigNeg Q = sigNeg Q' :=
  sigPos_eq <| match h with | ⟨e⟩ => ⟨e, by simp⟩

end LinearOrder

section Field
namespace QuadraticForm

variable {�� : Type*} [Field ��] [LinearOrder ��]
  [Module �� M] [Module �� M'] {Q : QuadraticForm �� M}

/-- Key lemma for Sylvester's law of inertia: the sum of `sigPos Q` and the dimension of any
negative-semidefinite subspace is bounded above by the dimension of the whole space. -/

lemma sigPos_add_finrank_le_of_nonpos [FiniteDimensional �� M]
    {V : Subspace �� M} (hV : ∀ x ∈ V, Q x ≤ 0) :
    sigPos Q + Module.finrank �� V ≤ Module.finrank �� M := by
  obtain ⟨Vp, hr, hVp⟩ := exists_finrank_eq_sigPos_and_posDef Q
  rw [← hr]
  apply Submodule.finrank_add_finrank_le_of_disjoint
  intro W hWp hWm
  rw [le_bot_iff, Submodule.eq_bot_iff]
  intro x hx
  by_contra hx'
  have := hVp ⟨x, hWp hx⟩ (by simpa using hx')
  have := hV x (hWm hx)
  grind [restrict_apply]

variable {ι : Type*} [Fintype ι] {w : ι → ��} [IsStrictOrderedRing ��]

private lemma posDef_spanSubset (s : Set ι) (hs : ∀ i ∈ s, 0 < w i) :
    (weightedSumSquares �� w).restrict (Pi.spanSubset �� s) |>.PosDef := by
  intro ⟨v, hv⟩ hv'
  rw [restrict_apply, weightedSumSquares_apply]
  apply sum_pos'
  · intro i _
    by_cases hi : i ∈ s
    · exact smul_nonneg (hs i hi).le (mul_self_nonneg _)
    · simp [Pi.mem_spanSubset_iff.mp hv i hi]
  · simp only [ne_eq, Submodule.mk_eq_zero, funext_iff, not_forall, Pi.zero_apply] at hv'
    obtain ⟨i, hi⟩ := hv'
    refine ⟨i, mem_univ _, ?_⟩
    have : i ∈ s := by
      contrapose hi
      exact Pi.mem_spanSubset_iff.mp hv i hi
    exact smul_pos (hs i this) (mul_self_pos.mpr hi)

private lemma negSemidef_spanSubset (s : Set ι) (hs : ∀ i ∈ s, w i ≤ 0) :
    ∀ x ∈ Pi.spanSubset �� s, (weightedSumSquares �� w) x ≤ 0 := by
  intro x hx
  simp only [weightedSumSquares_apply, smul_eq_mul]
  apply sum_nonpos
  intro i _
  by_cases hi : i ∈ s
  · exact mul_nonpos_of_nonpos_of_nonneg (hs i hi) (mul_self_nonneg _)
  · rw [Pi.mem_spanSubset_iff.mp hx i hi, mul_zero, mul_zero]

/-- Key lemma for Sylvester's law of inertia: compute the signature of a weighted sum of squares. -/
lemma sigPos_weightedSumSquares :
    sigPos (weightedSumSquares �� w) = {i | 0 < w i}.ncard := by
  let p : Set ι := {i | 0 < w i}
  let m : Set ι := {i | w i ≤ 0}
  convert_to sigPos _ = p.ncard
  have : p.ncard + m.ncard = Nat.card ι := by
    convert Set.ncard_add_ncard_compl p
    ext
    grind
  have : p.ncard ≤ sigPos (weightedSumSquares �� w) :=
    (sigPos_isGreatest _).2 ⟨Pi.spanSubset �� p, Pi.dim_spanSubset,
      posDef_spanSubset p (by grind)⟩
  suffices sigPos (weightedSumSquares �� w) + m.ncard ≤ Nat.card ι by lia
  simpa using sigPos_add_finrank_le_of_nonpos <| negSemidef_spanSubset m (fun _ hi ↦ hi)

lemma sigNeg_weightedSumSquares :
    sigNeg (weightedSumSquares �� w) = {i | w i < 0}.ncard := by
  simp only [sigNeg]
  convert sigPos_weightedSumSquares (w := -w) using 2
  · ext; simp
  · simp

private lemma sigPos_add_sigNeg_add_radical₁ :
    sigPos (weightedSumSquares �� w) + sigNeg (weightedSumSquares �� w) +
      Module.finrank �� (weightedSumSquares �� w).radical = Nat.card ι := by
  rw [radical_weightedSumSquares, sigPos_weightedSumSquares, sigNeg_weightedSumSquares,
    Pi.dim_spanSubset]
  calc {i | 0 < w i}.ncard + {i | w i < 0}.ncard + {i | w i = 0}.ncard
  _ = {i | 0 < w i}.ncard + {i | w i ≤ 0}.ncard := by
    rw [add_assoc, add_left_cancel_iff, ← Set.ncard_union_eq]
    · congr! 1
      ext
      grind
    · grind [disjoint_iff_ne]
  _ = Set.univ.ncard := by
    rw [← Set.ncard_union_eq]
    · congr! 1
      ext
      grind [le_iff_lt_or_eq]
    · grind [disjoint_iff_ne]
  _ = Nat.card ι := Set.ncard_univ _

lemma sigPos_add_sigNeg_add_radical [FiniteDimensional �� M] :
    sigPos Q + sigNeg Q + Module.finrank �� Q.radical = Module.finrank �� M := by
  have : Invertible (2 : ��) := invertibleOfNonzero (NeZero.ne _)
  obtain ⟨w, e⟩ := Q.equivalent_weightedSumSquares
  rw [e.sigPos_eq, e.sigNeg_eq, e.rank_radical_eq]
  convert QuadraticForm.sigPos_add_sigNeg_add_radical₁ (w := w)
  exact Eq.symm (Nat.card_fin (Module.finrank �� M))

/-- Uniqueness part of **Sylvester's law of inertia** (positive part):
for any weighted sum of squares equivalent to `Q`,
the number of strictly positive weights is equal to `sigPos Q`. -/

lemma sigPos_of_equiv_weightedSumSquares (hQ : Equivalent Q (weightedSumSquares �� w)) :
    sigPos Q = {i | 0 < w i}.ncard := by
  rw [hQ.sigPos_eq]
  exact sigPos_weightedSumSquares

/-- Uniqueness part of **Sylvester's law of inertia** (negative part):
for any weighted sum of squares equivalent to `Q`,
the number of strictly negative weights is equal to `sigNeg Q`. -/

lemma sigNeg_of_equiv_weightedSumSquares (hQ : Equivalent Q (weightedSumSquares �� w)) :
    sigNeg Q = {i | w i < 0}.ncard := by
  rw [hQ.sigNeg_eq]
  exact sigNeg_weightedSumSquares

end QuadraticForm

Messung
CHZG
9310010097

¤ Dauer der Verarbeitung: 0.6 Sekunden  ¤

*© Formatika GbR, Deutschland







                                                                                                                                                                                                                                                                                                                                                                                                     

 

Neuigkeiten

Aktuelles
Motto des Tages

Open Source Software


Gedichte
Musik
Bilder

Jenseits des Üblichen

Besucherstatistik

Besucherstatistik

Statistik
#Sources=1,188,115
#Domains=863,631