linear_algebra.quadratic_form.basic
⟷
Mathlib.LinearAlgebra.QuadraticForm.Basic
The following section lists changes to this file in mathlib3 and mathlib4 that occured after the initial port. Most recent changes are shown first. Hovering over a commit will show all commits associated with the same mathlib3 commit.
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(last sync)
@@ -706,7 +706,7 @@ variables [invertible (2 : R₁)]
/-- `associated` is the linear map that sends a quadratic form over a commutative ring to its
associated symmetric bilinear form. -/
-abbreviation associated : quadratic_form R₁ M →ₗ[R₁] bilin_form R₁ M :=
+@[reducible] def associated : quadratic_form R₁ M →ₗ[R₁] bilin_form R₁ M :=
associated_hom R₁
@[simp] lemma associated_lin_mul_lin (f g : M →ₗ[R₁] R₁) :
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(first ported)
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -1095,7 +1095,7 @@ def Anisotropic (Q : QuadraticForm R M) : Prop :=
#print QuadraticForm.not_anisotropic_iff_exists /-
theorem not_anisotropic_iff_exists (Q : QuadraticForm R M) :
¬Anisotropic Q ↔ ∃ (x : _) (_ : x ≠ 0), Q x = 0 := by
- simp only [anisotropic, Classical.not_forall, exists_prop, and_comm']
+ simp only [anisotropic, Classical.not_forall, exists_prop, and_comm]
#align quadratic_form.not_anisotropic_iff_exists QuadraticForm.not_anisotropic_iff_exists
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -328,7 +328,7 @@ theorem polar_add_left (x x' y : M) : polar Q (x + x') y = polar Q x y + polar Q
theorem polar_smul_left (a : R) (x y : M) : polar Q (a • x) y = a * polar Q x y :=
by
obtain ⟨B, h⟩ := Q.exists_companion
- simp_rw [polar, h, Q.map_smul, BilinForm.smul_left, sub_sub, add_sub_cancel_left]
+ simp_rw [polar, h, Q.map_smul, LinearMap.BilinForm.smul_left, sub_sub, add_sub_cancel_left]
#align quadratic_form.polar_smul_left QuadraticForm.polar_smul_left
-/
@@ -441,7 +441,7 @@ def ofPolar (to_fun : M → R) (to_fun_smul : ∀ (a : R) (x : M), to_fun (a •
#print QuadraticForm.choose_exists_companion /-
/-- In a ring the companion bilinear form is unique and equal to `quadratic_form.polar`. -/
theorem choose_exists_companion : Q.exists_companion.some = polarBilin Q :=
- BilinForm.ext fun x y => by
+ LinearMap.BilinForm.ext fun x y => by
rw [polar_bilin_apply, polar, Q.exists_companion.some_spec, sub_sub, add_sub_cancel_left]
#align quadratic_form.some_exists_companion QuadraticForm.choose_exists_companion
-/
@@ -486,7 +486,8 @@ end SMul
instance : Zero (QuadraticForm R M) :=
⟨{ toFun := fun x => 0
toFun_smul := fun a x => by simp only [MulZeroClass.mul_zero]
- exists_companion' := ⟨0, fun x y => by simp only [add_zero, BilinForm.zero_apply]⟩ }⟩
+ exists_companion' :=
+ ⟨0, fun x y => by simp only [add_zero, LinearMap.BilinForm.zero_apply]⟩ }⟩
#print QuadraticForm.coeFn_zero /-
@[simp]
@@ -513,7 +514,7 @@ instance : Add (QuadraticForm R M) :=
let ⟨B, h⟩ := Q.exists_companion
let ⟨B', h'⟩ := Q'.exists_companion
⟨B + B', fun x y => by
- simp_rw [Pi.add_apply, h, h', BilinForm.add_apply, add_add_add_comm]⟩ }⟩
+ simp_rw [Pi.add_apply, h, h', LinearMap.BilinForm.add_apply, add_add_add_comm]⟩ }⟩
#print QuadraticForm.coeFn_add /-
@[simp]
@@ -598,7 +599,7 @@ instance : Neg (QuadraticForm R M) :=
toFun_smul := fun a x => by simp only [Pi.neg_apply, map_smul, mul_neg]
exists_companion' :=
let ⟨B, h⟩ := Q.exists_companion
- ⟨-B, fun x y => by simp_rw [Pi.neg_apply, h, BilinForm.neg_apply, neg_add]⟩ }⟩
+ ⟨-B, fun x y => by simp_rw [Pi.neg_apply, h, LinearMap.BilinForm.neg_apply, neg_add]⟩ }⟩
#print QuadraticForm.coeFn_neg /-
@[simp]
@@ -651,7 +652,7 @@ def comp (Q : QuadraticForm R N) (f : M →ₗ[R] N) : QuadraticForm R M
toFun_smul a x := by simp only [map_smul, f.map_smul]
exists_companion' :=
let ⟨B, h⟩ := Q.exists_companion
- ⟨B.comp f f, fun x y => by simp_rw [f.map_add, h, BilinForm.comp_apply]⟩
+ ⟨B.comp f f, fun x y => by simp_rw [f.map_add, h, LinearMap.BilinForm.comp_apply]⟩
#align quadratic_form.comp QuadraticForm.comp
-/
@@ -689,7 +690,9 @@ def linMulLin (f g : M →ₗ[R] R) : QuadraticForm R M
toFun := f * g
toFun_smul a x := by
simp only [smul_eq_mul, RingHom.id_apply, Pi.mul_apply, LinearMap.map_smulₛₗ]; ring
- exists_companion' := ⟨BilinForm.linMulLin f g + BilinForm.linMulLin g f, fun x y => by simp; ring⟩
+ exists_companion' :=
+ ⟨LinearMap.BilinForm.linMulLin f g + LinearMap.BilinForm.linMulLin g f, fun x y => by simp;
+ ring⟩
#align quadratic_form.lin_mul_lin QuadraticForm.linMulLin
-/
@@ -778,7 +781,8 @@ def LinearMap.BilinForm.toQuadraticForm (B : BilinForm R M) : QuadraticForm R M
where
toFun x := B x x
toFun_smul a x := by simp only [mul_assoc, smul_right, smul_left]
- exists_companion' := ⟨B + BilinForm.flipHom ℕ B, fun x y => by simp [add_add_add_comm, add_comm]⟩
+ exists_companion' :=
+ ⟨B + LinearMap.BilinForm.flipHom ℕ B, fun x y => by simp [add_add_add_comm, add_comm]⟩
#align bilin_form.to_quadratic_form LinearMap.BilinForm.toQuadraticForm
-/
@@ -931,8 +935,8 @@ def associatedHom : QuadraticForm R M →ₗ[S] BilinForm R M
((· • ·) : Submonoid.center R → BilinForm R M → BilinForm R M)
⟨⅟ 2, fun x => (Commute.one_right x).bit0_right.invOf_right⟩ Q.polarBilin
map_add' Q Q' := by ext;
- simp only [BilinForm.add_apply, BilinForm.smul_apply, coe_fn_mk, polar_bilin_apply, polar_add,
- coe_fn_add, smul_add]
+ simp only [LinearMap.BilinForm.add_apply, BilinForm.smul_apply, coe_fn_mk, polar_bilin_apply,
+ polar_add, coe_fn_add, smul_add]
map_smul' s Q := by ext;
simp only [RingHom.id_apply, polar_smul, smul_comm s, polar_bilin_apply, coe_fn_mk, coe_fn_smul,
BilinForm.smul_apply]
@@ -958,7 +962,8 @@ theorem associated_isSymm : (associatedHom S Q).IsSymm := fun x y => by
@[simp]
theorem associated_comp {N : Type v} [AddCommGroup N] [Module R N] (f : N →ₗ[R] M) :
associatedHom S (Q.comp f) = (associatedHom S Q).comp f f := by ext;
- simp only [QuadraticForm.comp_apply, BilinForm.comp_apply, associated_apply, LinearMap.map_add]
+ simp only [QuadraticForm.comp_apply, LinearMap.BilinForm.comp_apply, associated_apply,
+ LinearMap.map_add]
#align quadratic_form.associated_comp QuadraticForm.associated_comp
-/
@@ -971,7 +976,7 @@ theorem associated_toQuadraticForm (B : BilinForm R M) (x y : M) :
#print QuadraticForm.associated_left_inverse /-
theorem associated_left_inverse (h : B₁.IsSymm) : associatedHom S B₁.toQuadraticForm = B₁ :=
- BilinForm.ext fun x y => by
+ LinearMap.BilinForm.ext fun x y => by
rw [associated_to_quadratic_form, is_symm.eq h x y, ← two_mul, ← mul_assoc, invOf_mul_self,
one_mul]
#align quadratic_form.associated_left_inverse QuadraticForm.associated_left_inverse
@@ -1020,7 +1025,8 @@ abbrev associated' : QuadraticForm R M →ₗ[ℤ] BilinForm R M :=
#print QuadraticForm.canLift /-
/-- Symmetric bilinear forms can be lifted to quadratic forms -/
-instance canLift : CanLift (BilinForm R M) (QuadraticForm R M) (associatedHom ℕ) BilinForm.IsSymm
+instance canLift :
+ CanLift (BilinForm R M) (QuadraticForm R M) (associatedHom ℕ) LinearMap.BilinForm.IsSymm
where prf B hB := ⟨B.toQuadraticForm, associated_left_inverse _ hB⟩
#align quadratic_form.can_lift QuadraticForm.canLift
-/
@@ -1059,12 +1065,13 @@ def associated : QuadraticForm R₁ M →ₗ[R₁] BilinForm R₁ M :=
#print QuadraticForm.associated_linMulLin /-
@[simp]
theorem associated_linMulLin (f g : M →ₗ[R₁] R₁) :
- (linMulLin f g).Associated = ⅟ (2 : R₁) • (BilinForm.linMulLin f g + BilinForm.linMulLin g f) :=
+ (linMulLin f g).Associated =
+ ⅟ (2 : R₁) • (LinearMap.BilinForm.linMulLin f g + LinearMap.BilinForm.linMulLin g f) :=
by
ext;
- simp only [smul_add, Algebra.id.smul_eq_mul, BilinForm.linMulLin_apply,
- QuadraticForm.linMulLin_apply, BilinForm.smul_apply, associated_apply, BilinForm.add_apply,
- LinearMap.map_add]
+ simp only [smul_add, Algebra.id.smul_eq_mul, LinearMap.BilinForm.linMulLin_apply,
+ QuadraticForm.linMulLin_apply, BilinForm.smul_apply, associated_apply,
+ LinearMap.BilinForm.add_apply, LinearMap.map_add]
ring
#align quadratic_form.associated_lin_mul_lin QuadraticForm.associated_linMulLin
-/
@@ -1233,7 +1240,8 @@ theorem QuadraticForm.toMatrix'_smul (a : R₁) (Q : QuadraticForm R₁ (n → R
theorem QuadraticForm.isSymm_toMatrix' (Q : QuadraticForm R₁ (n → R₁)) : Q.toMatrix'.IsSymm :=
by
ext i j
- rw [to_matrix', BilinForm.toMatrix'_apply, BilinForm.toMatrix'_apply, associated_is_symm]
+ rw [to_matrix', LinearMap.BilinForm.toMatrix'_apply, LinearMap.BilinForm.toMatrix'_apply,
+ associated_is_symm]
#align quadratic_form.is_symm_to_matrix' QuadraticForm.isSymm_toMatrix'
-/
@@ -1253,7 +1261,7 @@ open scoped Matrix
@[simp]
theorem toMatrix'_comp (Q : QuadraticForm R₁ (m → R₁)) (f : (n → R₁) →ₗ[R₁] m → R₁) :
(Q.comp f).toMatrix' = f.toMatrix'ᵀ ⬝ Q.toMatrix' ⬝ f.toMatrix' := by ext;
- simp only [QuadraticForm.associated_comp, BilinForm.toMatrix'_comp, to_matrix']
+ simp only [QuadraticForm.associated_comp, LinearMap.BilinForm.toMatrix'_comp, to_matrix']
#align quadratic_form.to_matrix'_comp QuadraticForm.toMatrix'_comp
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -3,7 +3,7 @@ Copyright (c) 2020 Anne Baanen. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Anne Baanen, Kexing Ying, Eric Wieser
-/
-import Algebra.Invertible
+import Algebra.Invertible.Defs
import LinearAlgebra.Matrix.Determinant
import LinearAlgebra.Matrix.BilinearForm
import LinearAlgebra.Matrix.Symmetric
@@ -328,7 +328,7 @@ theorem polar_add_left (x x' y : M) : polar Q (x + x') y = polar Q x y + polar Q
theorem polar_smul_left (a : R) (x y : M) : polar Q (a • x) y = a * polar Q x y :=
by
obtain ⟨B, h⟩ := Q.exists_companion
- simp_rw [polar, h, Q.map_smul, BilinForm.smul_left, sub_sub, add_sub_cancel']
+ simp_rw [polar, h, Q.map_smul, BilinForm.smul_left, sub_sub, add_sub_cancel_left]
#align quadratic_form.polar_smul_left QuadraticForm.polar_smul_left
-/
@@ -434,7 +434,7 @@ def ofPolar (to_fun : M → R) (to_fun_smul : ∀ (a : R) (x : M), to_fun (a •
bilin_add_right := fun x y z => by simp_rw [polar_comm _ x, polar_add_left]
bilin_smul_right := fun r x y => by
simp_rw [polar_comm _ x, polar_smul_left, smul_eq_mul] },
- fun x y => by rw [BilinForm.coeFn_mk, polar, sub_sub, add_sub_cancel'_right]⟩ }
+ fun x y => by rw [BilinForm.coeFn_mk, polar, sub_sub, add_sub_cancel]⟩ }
#align quadratic_form.of_polar QuadraticForm.ofPolar
-/
@@ -442,7 +442,7 @@ def ofPolar (to_fun : M → R) (to_fun_smul : ∀ (a : R) (x : M), to_fun (a •
/-- In a ring the companion bilinear form is unique and equal to `quadratic_form.polar`. -/
theorem choose_exists_companion : Q.exists_companion.some = polarBilin Q :=
BilinForm.ext fun x y => by
- rw [polar_bilin_apply, polar, Q.exists_companion.some_spec, sub_sub, add_sub_cancel']
+ rw [polar_bilin_apply, polar, Q.exists_companion.some_spec, sub_sub, add_sub_cancel_left]
#align quadratic_form.some_exists_companion QuadraticForm.choose_exists_companion
-/
@@ -880,7 +880,7 @@ variable {B : BilinForm R M}
#print LinearMap.BilinForm.polar_toQuadraticForm /-
theorem LinearMap.BilinForm.polar_toQuadraticForm (x y : M) :
polar (fun x => B x x) x y = B x y + B y x := by
- simp only [add_assoc, add_sub_cancel', add_right, polar, add_left_inj, add_neg_cancel_left,
+ simp only [add_assoc, add_sub_cancel_left, add_right, polar, add_left_inj, add_neg_cancel_left,
add_left, sub_eq_add_neg _ (B y y), add_comm (B y x) _]
#align bilin_form.polar_to_quadratic_form LinearMap.BilinForm.polar_toQuadraticForm
-/
@@ -982,7 +982,7 @@ theorem toQuadraticForm_associated : (associatedHom S Q).toQuadraticForm = Q :=
QuadraticForm.ext fun x =>
calc
(associatedHom S Q).toQuadraticForm x = ⅟ 2 * (Q x + Q x) := by
- simp only [add_assoc, add_sub_cancel', one_mul, to_quadratic_form_apply, add_mul,
+ simp only [add_assoc, add_sub_cancel_left, one_mul, to_quadratic_form_apply, add_mul,
associated_apply, map_add_self, bit0]
_ = Q x := by rw [← two_mul (Q x), ← mul_assoc, invOf_mul_self, one_mul]
#align quadratic_form.to_quadratic_form_associated QuadraticForm.toQuadraticForm_associated
@@ -1084,7 +1084,7 @@ def Anisotropic (Q : QuadraticForm R M) : Prop :=
#align quadratic_form.anisotropic QuadraticForm.Anisotropic
-/
-/- ./././Mathport/Syntax/Translate/Basic.lean:641:2: warning: expanding binder collection (x «expr ≠ » 0) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:642:2: warning: expanding binder collection (x «expr ≠ » 0) -/
#print QuadraticForm.not_anisotropic_iff_exists /-
theorem not_anisotropic_iff_exists (Q : QuadraticForm R M) :
¬Anisotropic Q ↔ ∃ (x : _) (_ : x ≠ 0), Q x = 0 := by
@@ -1127,7 +1127,7 @@ variable {R₂ : Type u} [OrderedRing R₂] [AddCommMonoid M] [Module R₂ M]
variable {Q₂ : QuadraticForm R₂ M}
-/- ./././Mathport/Syntax/Translate/Basic.lean:641:2: warning: expanding binder collection (x «expr ≠ » 0) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:642:2: warning: expanding binder collection (x «expr ≠ » 0) -/
#print QuadraticForm.PosDef /-
/-- A positive definite quadratic form is positive on nonzero vectors. -/
def PosDef (Q₂ : QuadraticForm R₂ M) : Prop :=
@@ -1360,7 +1360,7 @@ theorem LinearMap.BilinForm.exists_orthogonal_basis [hK : Invertible (2 : K)] {B
intro y
refine' ⟨-B x y / B x x, fun z hz => _⟩
obtain ⟨c, rfl⟩ := Submodule.mem_span_singleton.1 hz
- rw [is_ortho, smul_left, add_right, smul_right, div_mul_cancel _ hx, add_neg_self,
+ rw [is_ortho, smul_left, add_right, smul_right, div_mul_cancel₀ _ hx, add_neg_self,
MulZeroClass.mul_zero])
refine' ⟨b, _⟩
· rw [Basis.coe_mkFinCons]
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -1154,7 +1154,7 @@ theorem PosDef.anisotropic {Q : QuadraticForm R₂ M} (hQ : Q.PosDef) : Q.Anisot
by_contradiction fun hx =>
lt_irrefl (0 : R₂) <| by
have := hQ _ hx
- rw [hQx] at this
+ rw [hQx] at this
exact this
#align quadratic_form.pos_def.anisotropic QuadraticForm.PosDef.anisotropic
-/
@@ -1338,11 +1338,11 @@ theorem LinearMap.BilinForm.exists_orthogonal_basis [hK : Invertible (2 : K)] {B
-- either the bilinear form is trivial or we can pick a non-null `x`
obtain rfl | hB₁ := eq_or_ne B 0
· let b := FiniteDimensional.finBasis K V
- rw [hd] at b
+ rw [hd] at b
refine' ⟨b, fun i j hij => rfl⟩
obtain ⟨x, hx⟩ := exists_bilin_form_self_ne_zero hB₁ hB₂
rw [← Submodule.finrank_add_eq_of_isCompl (is_compl_span_singleton_orthogonal hx).symm,
- finrank_span_singleton (ne_zero_of_not_is_ortho_self x hx)] at hd
+ finrank_span_singleton (ne_zero_of_not_is_ortho_self x hx)] at hd
let B' := B.restrict (B.orthogonal <| K ∙ x)
obtain ⟨v', hv₁⟩ := ih (B.restrict_symm hB₂ _ : B'.is_symm) (Nat.succ.inj hd)
-- concatenate `x` with the basis obtained by induction
@@ -1350,10 +1350,10 @@ theorem LinearMap.BilinForm.exists_orthogonal_basis [hK : Invertible (2 : K)] {B
Basis.mkFinCons x v'
(by
rintro c y hy hc
- rw [add_eq_zero_iff_neg_eq] at hc
- rw [← hc, Submodule.neg_mem_iff] at hy
+ rw [add_eq_zero_iff_neg_eq] at hc
+ rw [← hc, Submodule.neg_mem_iff] at hy
have := (is_compl_span_singleton_orthogonal hx).Disjoint
- rw [Submodule.disjoint_def] at this
+ rw [Submodule.disjoint_def] at this
have := this (c • x) (Submodule.smul_mem _ _ <| Submodule.mem_span_singleton_self _) hy
exact (smul_eq_zero.1 this).resolve_right fun h => hx <| h.symm ▸ zero_left _)
(by
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -772,98 +772,101 @@ variable [Semiring R] [AddCommMonoid M] [Module R M]
variable {B : BilinForm R M}
-#print BilinForm.toQuadraticForm /-
+#print LinearMap.BilinForm.toQuadraticForm /-
/-- A bilinear form gives a quadratic form by applying the argument twice. -/
-def toQuadraticForm (B : BilinForm R M) : QuadraticForm R M
+def LinearMap.BilinForm.toQuadraticForm (B : BilinForm R M) : QuadraticForm R M
where
toFun x := B x x
toFun_smul a x := by simp only [mul_assoc, smul_right, smul_left]
exists_companion' := ⟨B + BilinForm.flipHom ℕ B, fun x y => by simp [add_add_add_comm, add_comm]⟩
-#align bilin_form.to_quadratic_form BilinForm.toQuadraticForm
+#align bilin_form.to_quadratic_form LinearMap.BilinForm.toQuadraticForm
-/
-#print BilinForm.toQuadraticForm_apply /-
+#print LinearMap.BilinForm.toQuadraticForm_apply /-
@[simp]
-theorem toQuadraticForm_apply (B : BilinForm R M) (x : M) : B.toQuadraticForm x = B x x :=
+theorem LinearMap.BilinForm.toQuadraticForm_apply (B : BilinForm R M) (x : M) :
+ B.toQuadraticForm x = B x x :=
rfl
-#align bilin_form.to_quadratic_form_apply BilinForm.toQuadraticForm_apply
+#align bilin_form.to_quadratic_form_apply LinearMap.BilinForm.toQuadraticForm_apply
-/
section
variable (R M)
-#print BilinForm.toQuadraticForm_zero /-
+#print LinearMap.BilinForm.toQuadraticForm_zero /-
@[simp]
-theorem toQuadraticForm_zero : (0 : BilinForm R M).toQuadraticForm = 0 :=
+theorem LinearMap.BilinForm.toQuadraticForm_zero : (0 : BilinForm R M).toQuadraticForm = 0 :=
rfl
-#align bilin_form.to_quadratic_form_zero BilinForm.toQuadraticForm_zero
+#align bilin_form.to_quadratic_form_zero LinearMap.BilinForm.toQuadraticForm_zero
-/
end
-#print BilinForm.toQuadraticForm_add /-
+#print LinearMap.BilinForm.toQuadraticForm_add /-
@[simp]
-theorem toQuadraticForm_add (B₁ B₂ : BilinForm R M) :
+theorem LinearMap.BilinForm.toQuadraticForm_add (B₁ B₂ : BilinForm R M) :
(B₁ + B₂).toQuadraticForm = B₁.toQuadraticForm + B₂.toQuadraticForm :=
rfl
-#align bilin_form.to_quadratic_form_add BilinForm.toQuadraticForm_add
+#align bilin_form.to_quadratic_form_add LinearMap.BilinForm.toQuadraticForm_add
-/
-#print BilinForm.toQuadraticForm_smul /-
+#print LinearMap.BilinForm.toQuadraticForm_smul /-
@[simp]
-theorem toQuadraticForm_smul [Monoid S] [DistribMulAction S R] [SMulCommClass S R R] (a : S)
- (B : BilinForm R M) : (a • B).toQuadraticForm = a • B.toQuadraticForm :=
+theorem LinearMap.BilinForm.toQuadraticForm_smul [Monoid S] [DistribMulAction S R]
+ [SMulCommClass S R R] (a : S) (B : BilinForm R M) :
+ (a • B).toQuadraticForm = a • B.toQuadraticForm :=
rfl
-#align bilin_form.to_quadratic_form_smul BilinForm.toQuadraticForm_smul
+#align bilin_form.to_quadratic_form_smul LinearMap.BilinForm.toQuadraticForm_smul
-/
section
variable (R M)
-#print BilinForm.toQuadraticFormAddMonoidHom /-
+#print LinearMap.BilinForm.toQuadraticFormAddMonoidHom /-
/-- `bilin_form.to_quadratic_form` as an additive homomorphism -/
@[simps]
-def toQuadraticFormAddMonoidHom : BilinForm R M →+ QuadraticForm R M
+def LinearMap.BilinForm.toQuadraticFormAddMonoidHom : BilinForm R M →+ QuadraticForm R M
where
- toFun := toQuadraticForm
- map_zero' := toQuadraticForm_zero _ _
- map_add' := toQuadraticForm_add
-#align bilin_form.to_quadratic_form_add_monoid_hom BilinForm.toQuadraticFormAddMonoidHom
+ toFun := LinearMap.BilinForm.toQuadraticForm
+ map_zero' := LinearMap.BilinForm.toQuadraticForm_zero _ _
+ map_add' := LinearMap.BilinForm.toQuadraticForm_add
+#align bilin_form.to_quadratic_form_add_monoid_hom LinearMap.BilinForm.toQuadraticFormAddMonoidHom
-/
end
-#print BilinForm.toQuadraticForm_list_sum /-
+#print LinearMap.BilinForm.toQuadraticForm_list_sum /-
@[simp]
-theorem toQuadraticForm_list_sum (B : List (BilinForm R M)) :
- B.Sum.toQuadraticForm = (B.map toQuadraticForm).Sum :=
- map_list_sum (toQuadraticFormAddMonoidHom R M) B
-#align bilin_form.to_quadratic_form_list_sum BilinForm.toQuadraticForm_list_sum
+theorem LinearMap.BilinForm.toQuadraticForm_list_sum (B : List (BilinForm R M)) :
+ B.Sum.toQuadraticForm = (B.map LinearMap.BilinForm.toQuadraticForm).Sum :=
+ map_list_sum (LinearMap.BilinForm.toQuadraticFormAddMonoidHom R M) B
+#align bilin_form.to_quadratic_form_list_sum LinearMap.BilinForm.toQuadraticForm_list_sum
-/
-#print BilinForm.toQuadraticForm_multiset_sum /-
+#print LinearMap.BilinForm.toQuadraticForm_multiset_sum /-
@[simp]
-theorem toQuadraticForm_multiset_sum (B : Multiset (BilinForm R M)) :
- B.Sum.toQuadraticForm = (B.map toQuadraticForm).Sum :=
- map_multiset_sum (toQuadraticFormAddMonoidHom R M) B
-#align bilin_form.to_quadratic_form_multiset_sum BilinForm.toQuadraticForm_multiset_sum
+theorem LinearMap.BilinForm.toQuadraticForm_multiset_sum (B : Multiset (BilinForm R M)) :
+ B.Sum.toQuadraticForm = (B.map LinearMap.BilinForm.toQuadraticForm).Sum :=
+ map_multiset_sum (LinearMap.BilinForm.toQuadraticFormAddMonoidHom R M) B
+#align bilin_form.to_quadratic_form_multiset_sum LinearMap.BilinForm.toQuadraticForm_multiset_sum
-/
-#print BilinForm.toQuadraticForm_sum /-
+#print LinearMap.BilinForm.toQuadraticForm_sum /-
@[simp]
-theorem toQuadraticForm_sum {ι : Type _} (s : Finset ι) (B : ι → BilinForm R M) :
- (∑ i in s, B i).toQuadraticForm = ∑ i in s, (B i).toQuadraticForm :=
- map_sum (toQuadraticFormAddMonoidHom R M) B s
-#align bilin_form.to_quadratic_form_sum BilinForm.toQuadraticForm_sum
+theorem LinearMap.BilinForm.toQuadraticForm_sum {ι : Type _} (s : Finset ι)
+ (B : ι → BilinForm R M) : (∑ i in s, B i).toQuadraticForm = ∑ i in s, (B i).toQuadraticForm :=
+ map_sum (LinearMap.BilinForm.toQuadraticFormAddMonoidHom R M) B s
+#align bilin_form.to_quadratic_form_sum LinearMap.BilinForm.toQuadraticForm_sum
-/
-#print BilinForm.toQuadraticForm_eq_zero /-
+#print LinearMap.BilinForm.toQuadraticForm_eq_zero /-
@[simp]
-theorem toQuadraticForm_eq_zero {B : BilinForm R M} : B.toQuadraticForm = 0 ↔ B.IsAlt :=
+theorem LinearMap.BilinForm.toQuadraticForm_eq_zero {B : BilinForm R M} :
+ B.toQuadraticForm = 0 ↔ B.IsAlt :=
QuadraticForm.ext_iff
-#align bilin_form.to_quadratic_form_eq_zero BilinForm.toQuadraticForm_eq_zero
+#align bilin_form.to_quadratic_form_eq_zero LinearMap.BilinForm.toQuadraticForm_eq_zero
-/
end Semiring
@@ -874,26 +877,28 @@ variable [Ring R] [AddCommGroup M] [Module R M]
variable {B : BilinForm R M}
-#print BilinForm.polar_toQuadraticForm /-
-theorem polar_toQuadraticForm (x y : M) : polar (fun x => B x x) x y = B x y + B y x := by
+#print LinearMap.BilinForm.polar_toQuadraticForm /-
+theorem LinearMap.BilinForm.polar_toQuadraticForm (x y : M) :
+ polar (fun x => B x x) x y = B x y + B y x := by
simp only [add_assoc, add_sub_cancel', add_right, polar, add_left_inj, add_neg_cancel_left,
add_left, sub_eq_add_neg _ (B y y), add_comm (B y x) _]
-#align bilin_form.polar_to_quadratic_form BilinForm.polar_toQuadraticForm
+#align bilin_form.polar_to_quadratic_form LinearMap.BilinForm.polar_toQuadraticForm
-/
-#print BilinForm.toQuadraticForm_neg /-
+#print LinearMap.BilinForm.toQuadraticForm_neg /-
@[simp]
-theorem toQuadraticForm_neg (B : BilinForm R M) : (-B).toQuadraticForm = -B.toQuadraticForm :=
+theorem LinearMap.BilinForm.toQuadraticForm_neg (B : BilinForm R M) :
+ (-B).toQuadraticForm = -B.toQuadraticForm :=
rfl
-#align bilin_form.to_quadratic_form_neg BilinForm.toQuadraticForm_neg
+#align bilin_form.to_quadratic_form_neg LinearMap.BilinForm.toQuadraticForm_neg
-/
-#print BilinForm.toQuadraticForm_sub /-
+#print LinearMap.BilinForm.toQuadraticForm_sub /-
@[simp]
-theorem toQuadraticForm_sub (B₁ B₂ : BilinForm R M) :
+theorem LinearMap.BilinForm.toQuadraticForm_sub (B₁ B₂ : BilinForm R M) :
(B₁ - B₂).toQuadraticForm = B₁.toQuadraticForm - B₂.toQuadraticForm :=
rfl
-#align bilin_form.to_quadratic_form_sub BilinForm.toQuadraticForm_sub
+#align bilin_form.to_quadratic_form_sub LinearMap.BilinForm.toQuadraticForm_sub
-/
end Ring
@@ -987,7 +992,8 @@ theorem toQuadraticForm_associated : (associatedHom S Q).toQuadraticForm = Q :=
-- note: usually `right_inverse` lemmas are named the other way around, but this is consistent
-- with historical naming in this file.
theorem associated_rightInverse :
- Function.RightInverse (associatedHom S) (BilinForm.toQuadraticForm : _ → QuadraticForm R M) :=
+ Function.RightInverse (associatedHom S)
+ (LinearMap.BilinForm.toQuadraticForm : _ → QuadraticForm R M) :=
fun Q => toQuadraticForm_associated S Q
#align quadratic_form.associated_right_inverse QuadraticForm.associated_rightInverse
-/
@@ -1099,16 +1105,16 @@ section Ring
variable [Ring R] [AddCommGroup M] [Module R M]
-#print QuadraticForm.nondegenerate_of_anisotropic /-
+#print QuadraticForm.separatingLeft_of_anisotropic /-
/-- The associated bilinear form of an anisotropic quadratic form is nondegenerate. -/
-theorem nondegenerate_of_anisotropic [Invertible (2 : R)] (Q : QuadraticForm R M)
+theorem separatingLeft_of_anisotropic [Invertible (2 : R)] (Q : QuadraticForm R M)
(hB : Q.Anisotropic) : Q.associated'.Nondegenerate :=
by
intro x hx
refine' hB _ _
rw [← hx x]
exact (associated_eq_self_apply _ _ x).symm
-#align quadratic_form.nondegenerate_of_anisotropic QuadraticForm.nondegenerate_of_anisotropic
+#align quadratic_form.nondegenerate_of_anisotropic QuadraticForm.separatingLeft_of_anisotropic
-/
end Ring
@@ -1290,28 +1296,28 @@ section Semiring
variable [Semiring R] [AddCommMonoid M] [Module R M]
-#print BilinForm.nondegenerate_of_anisotropic /-
+#print LinearMap.BilinForm.separatingLeft_of_anisotropic /-
/-- A bilinear form is nondegenerate if the quadratic form it is associated with is anisotropic. -/
-theorem nondegenerate_of_anisotropic {B : BilinForm R M} (hB : B.toQuadraticForm.Anisotropic) :
- B.Nondegenerate := fun x hx => hB _ (hx x)
-#align bilin_form.nondegenerate_of_anisotropic BilinForm.nondegenerate_of_anisotropic
+theorem LinearMap.BilinForm.separatingLeft_of_anisotropic {B : BilinForm R M}
+ (hB : B.toQuadraticForm.Anisotropic) : B.Nondegenerate := fun x hx => hB _ (hx x)
+#align bilin_form.nondegenerate_of_anisotropic LinearMap.BilinForm.separatingLeft_of_anisotropic
-/
end Semiring
variable [Ring R] [AddCommGroup M] [Module R M]
-#print BilinForm.exists_bilinForm_self_ne_zero /-
+#print LinearMap.BilinForm.exists_bilinForm_self_ne_zero /-
/-- 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 exists_bilinForm_self_ne_zero [htwo : Invertible (2 : R)] {B : BilinForm R M} (hB₁ : B ≠ 0)
- (hB₂ : B.IsSymm) : ∃ x, ¬B.IsOrtho x x :=
+theorem LinearMap.BilinForm.exists_bilinForm_self_ne_zero [htwo : Invertible (2 : R)]
+ {B : BilinForm R M} (hB₁ : B ≠ 0) (hB₂ : B.IsSymm) : ∃ x, ¬B.IsOrtho x x :=
by
lift B to QuadraticForm R M using hB₂ with Q
obtain ⟨x, hx⟩ := QuadraticForm.exists_quadraticForm_ne_zero hB₁
exact ⟨x, fun h => hx (Q.associated_eq_self_apply ℕ x ▸ h)⟩
-#align bilin_form.exists_bilin_form_self_ne_zero BilinForm.exists_bilinForm_self_ne_zero
+#align bilin_form.exists_bilin_form_self_ne_zero LinearMap.BilinForm.exists_bilinForm_self_ne_zero
-/
open FiniteDimensional
@@ -1320,11 +1326,11 @@ variable {V : Type u} {K : Type v} [Field K] [AddCommGroup V] [Module K V]
variable [FiniteDimensional K V]
-#print BilinForm.exists_orthogonal_basis /-
+#print LinearMap.BilinForm.exists_orthogonal_basis /-
/-- 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`. -/
-theorem exists_orthogonal_basis [hK : Invertible (2 : K)] {B : BilinForm K V} (hB₂ : B.IsSymm) :
- ∃ v : Basis (Fin (finrank K V)) K V, B.IsOrthoᵢ v :=
+theorem LinearMap.BilinForm.exists_orthogonal_basis [hK : Invertible (2 : K)] {B : BilinForm K V}
+ (hB₂ : B.IsSymm) : ∃ v : Basis (Fin (finrank K V)) K V, B.IsOrthoᵢ v :=
by
induction' hd : finrank K V with d ih generalizing V
· exact ⟨basisOfFinrankZero hd, fun _ _ _ => zero_left _⟩
@@ -1366,7 +1372,7 @@ theorem exists_orthogonal_basis [hK : Invertible (2 : K)] {B : BilinForm K V} (h
exact (v' j).Prop _ (Submodule.mem_span_singleton_self x)
· exact (v' i).Prop _ (Submodule.mem_span_singleton_self x)
· exact hv₁ (ne_of_apply_ne _ hij)
-#align bilin_form.exists_orthogonal_basis BilinForm.exists_orthogonal_basis
+#align bilin_form.exists_orthogonal_basis LinearMap.BilinForm.exists_orthogonal_basis
-/
end BilinForm
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -161,12 +161,12 @@ variable [Semiring R] [AddCommMonoid M] [Module R M]
variable {Q Q' : QuadraticForm R M}
-#print QuadraticForm.instDFunLike /-
-instance instDFunLike : DFunLike (QuadraticForm R M) M fun _ => R
+#print QuadraticForm.instFunLike /-
+instance instFunLike : DFunLike (QuadraticForm R M) M fun _ => R
where
coe := toFun
coe_injective' x y h := by cases x <;> cases y <;> congr
-#align quadratic_form.fun_like QuadraticForm.instDFunLike
+#align quadratic_form.fun_like QuadraticForm.instFunLike
-/
/-- Helper instance for when there's too many metavariables to apply
@@ -278,7 +278,7 @@ theorem map_zero : Q 0 = 0 := by
#print QuadraticForm.zeroHomClass /-
instance zeroHomClass : ZeroHomClass (QuadraticForm R M) M R :=
- { QuadraticForm.instDFunLike with map_zero := map_zero }
+ { QuadraticForm.instFunLike with map_zero := map_zero }
#align quadratic_form.zero_hom_class QuadraticForm.zeroHomClass
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -155,18 +155,18 @@ structure QuadraticForm (R : Type u) (M : Type v) [Semiring R] [AddCommMonoid M]
namespace QuadraticForm
-section FunLike
+section DFunLike
variable [Semiring R] [AddCommMonoid M] [Module R M]
variable {Q Q' : QuadraticForm R M}
-#print QuadraticForm.funLike /-
-instance funLike : FunLike (QuadraticForm R M) M fun _ => R
+#print QuadraticForm.instDFunLike /-
+instance instDFunLike : DFunLike (QuadraticForm R M) M fun _ => R
where
coe := toFun
coe_injective' x y h := by cases x <;> cases y <;> congr
-#align quadratic_form.fun_like QuadraticForm.funLike
+#align quadratic_form.fun_like QuadraticForm.instDFunLike
-/
/-- Helper instance for when there's too many metavariables to apply
@@ -192,19 +192,19 @@ variable {Q}
#print QuadraticForm.ext /-
@[ext]
theorem ext (H : ∀ x : M, Q x = Q' x) : Q = Q' :=
- FunLike.ext _ _ H
+ DFunLike.ext _ _ H
#align quadratic_form.ext QuadraticForm.ext
-/
#print QuadraticForm.congr_fun /-
theorem congr_fun (h : Q = Q') (x : M) : Q x = Q' x :=
- FunLike.congr_fun h _
+ DFunLike.congr_fun h _
#align quadratic_form.congr_fun QuadraticForm.congr_fun
-/
#print QuadraticForm.ext_iff /-
theorem ext_iff : Q = Q' ↔ ∀ x, Q x = Q' x :=
- FunLike.ext_iff
+ DFunLike.ext_iff
#align quadratic_form.ext_iff QuadraticForm.ext_iff
-/
@@ -228,11 +228,11 @@ theorem coe_copy (Q : QuadraticForm R M) (Q' : M → R) (h : Q' = ⇑Q) : ⇑(Q.
#print QuadraticForm.copy_eq /-
theorem copy_eq (Q : QuadraticForm R M) (Q' : M → R) (h : Q' = ⇑Q) : Q.copy Q' h = Q :=
- FunLike.ext' h
+ DFunLike.ext' h
#align quadratic_form.copy_eq QuadraticForm.copy_eq
-/
-end FunLike
+end DFunLike
section Semiring
@@ -278,7 +278,7 @@ theorem map_zero : Q 0 = 0 := by
#print QuadraticForm.zeroHomClass /-
instance zeroHomClass : ZeroHomClass (QuadraticForm R M) M R :=
- { QuadraticForm.funLike with map_zero := map_zero }
+ { QuadraticForm.instDFunLike with map_zero := map_zero }
#align quadratic_form.zero_hom_class QuadraticForm.zeroHomClass
-/
@@ -530,7 +530,7 @@ theorem add_apply (Q Q' : QuadraticForm R M) (x : M) : (Q + Q') x = Q x + Q' x :
-/
instance : AddCommMonoid (QuadraticForm R M) :=
- FunLike.coe_injective.AddCommMonoid _ coeFn_zero coeFn_add fun _ _ => coeFn_smul _ _
+ DFunLike.coe_injective.AddCommMonoid _ coeFn_zero coeFn_add fun _ _ => coeFn_smul _ _
#print QuadraticForm.coeFnAddMonoidHom /-
/-- `@coe_fn (quadratic_form R M)` as an `add_monoid_hom`.
@@ -632,7 +632,7 @@ theorem sub_apply (Q Q' : QuadraticForm R M) (x : M) : (Q - Q') x = Q x - Q' x :
-/
instance : AddCommGroup (QuadraticForm R M) :=
- FunLike.coe_injective.AddCommGroup _ coeFn_zero coeFn_add coeFn_neg coeFn_sub
+ DFunLike.coe_injective.AddCommGroup _ coeFn_zero coeFn_add coeFn_neg coeFn_sub
(fun _ _ => coeFn_smul _ _) fun _ _ => coeFn_smul _ _
end RingOperators
mathlib commit https://github.com/leanprover-community/mathlib/commit/b1abe23ae96fef89ad30d9f4362c307f72a55010
@@ -1024,7 +1024,7 @@ instance canLift : CanLift (BilinForm R M) (QuadraticForm R M) (associatedHom
bilinear form is non-zero, i.e. there exists `x` such that `Q x ≠ 0`. -/
theorem exists_quadraticForm_ne_zero {Q : QuadraticForm R M} (hB₁ : Q.associated' ≠ 0) :
∃ x, Q x ≠ 0 := by
- rw [← not_forall]
+ rw [← Classical.not_forall]
intro h
apply hB₁
rw [(QuadraticForm.ext h : Q = 0), LinearMap.map_zero]
@@ -1082,7 +1082,7 @@ def Anisotropic (Q : QuadraticForm R M) : Prop :=
#print QuadraticForm.not_anisotropic_iff_exists /-
theorem not_anisotropic_iff_exists (Q : QuadraticForm R M) :
¬Anisotropic Q ↔ ∃ (x : _) (_ : x ≠ 0), Q x = 0 := by
- simp only [anisotropic, not_forall, exists_prop, and_comm']
+ simp only [anisotropic, Classical.not_forall, exists_prop, and_comm']
#align quadratic_form.not_anisotropic_iff_exists QuadraticForm.not_anisotropic_iff_exists
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/ce64cd319bb6b3e82f31c2d38e79080d377be451
@@ -3,10 +3,10 @@ Copyright (c) 2020 Anne Baanen. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Anne Baanen, Kexing Ying, Eric Wieser
-/
-import Mathbin.Algebra.Invertible
-import Mathbin.LinearAlgebra.Matrix.Determinant
-import Mathbin.LinearAlgebra.Matrix.BilinearForm
-import Mathbin.LinearAlgebra.Matrix.Symmetric
+import Algebra.Invertible
+import LinearAlgebra.Matrix.Determinant
+import LinearAlgebra.Matrix.BilinearForm
+import LinearAlgebra.Matrix.Symmetric
#align_import linear_algebra.quadratic_form.basic from "leanprover-community/mathlib"@"d11f435d4e34a6cea0a1797d6b625b0c170be845"
@@ -1078,7 +1078,7 @@ def Anisotropic (Q : QuadraticForm R M) : Prop :=
#align quadratic_form.anisotropic QuadraticForm.Anisotropic
-/
-/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (x «expr ≠ » 0) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:641:2: warning: expanding binder collection (x «expr ≠ » 0) -/
#print QuadraticForm.not_anisotropic_iff_exists /-
theorem not_anisotropic_iff_exists (Q : QuadraticForm R M) :
¬Anisotropic Q ↔ ∃ (x : _) (_ : x ≠ 0), Q x = 0 := by
@@ -1121,7 +1121,7 @@ variable {R₂ : Type u} [OrderedRing R₂] [AddCommMonoid M] [Module R₂ M]
variable {Q₂ : QuadraticForm R₂ M}
-/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (x «expr ≠ » 0) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:641:2: warning: expanding binder collection (x «expr ≠ » 0) -/
#print QuadraticForm.PosDef /-
/-- A positive definite quadratic form is positive on nonzero vectors. -/
def PosDef (Q₂ : QuadraticForm R₂ M) : Prop :=
mathlib commit https://github.com/leanprover-community/mathlib/commit/001ffdc42920050657fd45bd2b8bfbec8eaaeb29
@@ -874,11 +874,11 @@ variable [Ring R] [AddCommGroup M] [Module R M]
variable {B : BilinForm R M}
-#print BilinForm.polar_to_quadratic_form /-
-theorem polar_to_quadratic_form (x y : M) : polar (fun x => B x x) x y = B x y + B y x := by
+#print BilinForm.polar_toQuadraticForm /-
+theorem polar_toQuadraticForm (x y : M) : polar (fun x => B x x) x y = B x y + B y x := by
simp only [add_assoc, add_sub_cancel', add_right, polar, add_left_inj, add_neg_cancel_left,
add_left, sub_eq_add_neg _ (B y y), add_comm (B y x) _]
-#align bilin_form.polar_to_quadratic_form BilinForm.polar_to_quadratic_form
+#align bilin_form.polar_to_quadratic_form BilinForm.polar_toQuadraticForm
-/
#print BilinForm.toQuadraticForm_neg /-
mathlib commit https://github.com/leanprover-community/mathlib/commit/442a83d738cb208d3600056c489be16900ba701d
@@ -1153,15 +1153,15 @@ theorem PosDef.anisotropic {Q : QuadraticForm R₂ M} (hQ : Q.PosDef) : Q.Anisot
#align quadratic_form.pos_def.anisotropic QuadraticForm.PosDef.anisotropic
-/
-#print QuadraticForm.posDefOfNonneg /-
-theorem posDefOfNonneg {Q : QuadraticForm R₂ M} (h : ∀ x, 0 ≤ Q x) (h0 : Q.Anisotropic) :
+#print QuadraticForm.posDef_of_nonneg /-
+theorem posDef_of_nonneg {Q : QuadraticForm R₂ M} (h : ∀ x, 0 ≤ Q x) (h0 : Q.Anisotropic) :
PosDef Q := fun x hx => lt_of_le_of_ne (h x) (Ne.symm fun hQx => hx <| h0 _ hQx)
-#align quadratic_form.pos_def_of_nonneg QuadraticForm.posDefOfNonneg
+#align quadratic_form.pos_def_of_nonneg QuadraticForm.posDef_of_nonneg
-/
#print QuadraticForm.posDef_iff_nonneg /-
theorem posDef_iff_nonneg {Q : QuadraticForm R₂ M} : PosDef Q ↔ (∀ x, 0 ≤ Q x) ∧ Q.Anisotropic :=
- ⟨fun h => ⟨h.NonNeg, h.Anisotropic⟩, fun ⟨n, a⟩ => posDefOfNonneg n a⟩
+ ⟨fun h => ⟨h.NonNeg, h.Anisotropic⟩, fun ⟨n, a⟩ => posDef_of_nonneg n a⟩
#align quadratic_form.pos_def_iff_nonneg QuadraticForm.posDef_iff_nonneg
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/32a7e535287f9c73f2e4d2aef306a39190f0b504
@@ -576,7 +576,7 @@ end Sum
instance [Monoid S] [DistribMulAction S R] [SMulCommClass S R R] :
DistribMulAction S (QuadraticForm R M)
where
- mul_smul a b Q := ext fun x => by simp only [smul_apply, mul_smul]
+ hMul_smul a b Q := ext fun x => by simp only [smul_apply, mul_smul]
one_smul Q := ext fun x => by simp only [QuadraticForm.smul_apply, one_smul]
smul_add a Q Q' := by ext; simp only [add_apply, smul_apply, smul_add]
smul_zero a := by ext; simp only [zero_apply, smul_apply, smul_zero]
mathlib commit https://github.com/leanprover-community/mathlib/commit/d11f435d4e34a6cea0a1797d6b625b0c170be845
@@ -8,7 +8,7 @@ import Mathbin.LinearAlgebra.Matrix.Determinant
import Mathbin.LinearAlgebra.Matrix.BilinearForm
import Mathbin.LinearAlgebra.Matrix.Symmetric
-#align_import linear_algebra.quadratic_form.basic from "leanprover-community/mathlib"@"36938f775671ff28bea1c0310f1608e4afbb22e0"
+#align_import linear_algebra.quadratic_form.basic from "leanprover-community/mathlib"@"d11f435d4e34a6cea0a1797d6b625b0c170be845"
/-!
# Quadratic forms
@@ -1044,7 +1044,8 @@ variable [Invertible (2 : R₁)]
-- the more general `associated_hom` and place it in the previous section.
/-- `associated` is the linear map that sends a quadratic form over a commutative ring to its
associated symmetric bilinear form. -/
-abbrev associated : QuadraticForm R₁ M →ₗ[R₁] BilinForm R₁ M :=
+@[reducible]
+def associated : QuadraticForm R₁ M →ₗ[R₁] BilinForm R₁ M :=
associatedHom R₁
#align quadratic_form.associated QuadraticForm.associated
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/8ea5598db6caeddde6cb734aa179cc2408dbd345
@@ -2,17 +2,14 @@
Copyright (c) 2020 Anne Baanen. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Anne Baanen, Kexing Ying, Eric Wieser
-
-! This file was ported from Lean 3 source module linear_algebra.quadratic_form.basic
-! leanprover-community/mathlib commit 36938f775671ff28bea1c0310f1608e4afbb22e0
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Mathbin.Algebra.Invertible
import Mathbin.LinearAlgebra.Matrix.Determinant
import Mathbin.LinearAlgebra.Matrix.BilinearForm
import Mathbin.LinearAlgebra.Matrix.Symmetric
+#align_import linear_algebra.quadratic_form.basic from "leanprover-community/mathlib"@"36938f775671ff28bea1c0310f1608e4afbb22e0"
+
/-!
# Quadratic forms
@@ -1080,7 +1077,7 @@ def Anisotropic (Q : QuadraticForm R M) : Prop :=
#align quadratic_form.anisotropic QuadraticForm.Anisotropic
-/
-/- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (x «expr ≠ » 0) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (x «expr ≠ » 0) -/
#print QuadraticForm.not_anisotropic_iff_exists /-
theorem not_anisotropic_iff_exists (Q : QuadraticForm R M) :
¬Anisotropic Q ↔ ∃ (x : _) (_ : x ≠ 0), Q x = 0 := by
@@ -1123,7 +1120,7 @@ variable {R₂ : Type u} [OrderedRing R₂] [AddCommMonoid M] [Module R₂ M]
variable {Q₂ : QuadraticForm R₂ M}
-/- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (x «expr ≠ » 0) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (x «expr ≠ » 0) -/
#print QuadraticForm.PosDef /-
/-- A positive definite quadratic form is positive on nonzero vectors. -/
def PosDef (Q₂ : QuadraticForm R₂ M) : Prop :=
mathlib commit https://github.com/leanprover-community/mathlib/commit/2a0ce625dbb0ffbc7d1316597de0b25c1ec75303
@@ -1228,7 +1228,7 @@ theorem QuadraticForm.toMatrix'_smul (a : R₁) (Q : QuadraticForm R₁ (n → R
#print QuadraticForm.isSymm_toMatrix' /-
theorem QuadraticForm.isSymm_toMatrix' (Q : QuadraticForm R₁ (n → R₁)) : Q.toMatrix'.IsSymm :=
by
- ext (i j)
+ ext i j
rw [to_matrix', BilinForm.toMatrix'_apply, BilinForm.toMatrix'_apply, associated_is_symm]
#align quadratic_form.is_symm_to_matrix' QuadraticForm.isSymm_toMatrix'
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/9fb8964792b4237dac6200193a0d533f1b3f7423
@@ -96,22 +96,31 @@ def polar (f : M → R) (x y : M) :=
#align quadratic_form.polar QuadraticForm.polar
-/
+#print QuadraticForm.polar_add /-
theorem polar_add (f g : M → R) (x y : M) : polar (f + g) x y = polar f x y + polar g x y := by
simp only [polar, Pi.add_apply]; abel
#align quadratic_form.polar_add QuadraticForm.polar_add
+-/
+#print QuadraticForm.polar_neg /-
theorem polar_neg (f : M → R) (x y : M) : polar (-f) x y = -polar f x y := by
simp only [polar, Pi.neg_apply, sub_eq_add_neg, neg_add]
#align quadratic_form.polar_neg QuadraticForm.polar_neg
+-/
+#print QuadraticForm.polar_smul /-
theorem polar_smul [Monoid S] [DistribMulAction S R] (f : M → R) (s : S) (x y : M) :
polar (s • f) x y = s • polar f x y := by simp only [polar, Pi.smul_apply, smul_sub]
#align quadratic_form.polar_smul QuadraticForm.polar_smul
+-/
+#print QuadraticForm.polar_comm /-
theorem polar_comm (f : M → R) (x y : M) : polar f x y = polar f y x := by
rw [polar, polar, add_comm, sub_sub, sub_sub, add_comm (f x) (f y)]
#align quadratic_form.polar_comm QuadraticForm.polar_comm
+-/
+#print QuadraticForm.polar_add_left_iff /-
/-- Auxiliary lemma to express bilinearity of `quadratic_form.polar` without subtraction. -/
theorem polar_add_left_iff {f : M → R} {x x' y : M} :
polar f (x + x') y = polar f x y + polar f x' y ↔
@@ -123,11 +132,14 @@ theorem polar_add_left_iff {f : M → R} {x x' y : M} :
rw [add_comm y x, add_right_comm _ _ (f (x + y)), add_comm _ (f (x + y)),
add_right_comm (f (x + y)), add_left_inj]
#align quadratic_form.polar_add_left_iff QuadraticForm.polar_add_left_iff
+-/
+#print QuadraticForm.polar_comp /-
theorem polar_comp {F : Type _} [Ring S] [AddMonoidHomClass F R S] (f : M → R) (g : F) (x y : M) :
polar (g ∘ f) x y = g (polar f x y) := by
simp only [polar, Pi.smul_apply, Function.comp_apply, map_sub]
#align quadratic_form.polar_comp QuadraticForm.polar_comp
+-/
end QuadraticForm
@@ -167,29 +179,37 @@ instance : CoeFun (QuadraticForm R M) fun _ => M → R :=
variable (Q)
+#print QuadraticForm.toFun_eq_coe /-
/-- The `simp` normal form for a quadratic form is `coe_fn`, not `to_fun`. -/
@[simp]
theorem toFun_eq_coe : Q.toFun = ⇑Q :=
rfl
#align quadratic_form.to_fun_eq_coe QuadraticForm.toFun_eq_coe
+-/
-- this must come after the coe_to_fun definition
initialize_simps_projections QuadraticForm (toFun → apply)
variable {Q}
+#print QuadraticForm.ext /-
@[ext]
theorem ext (H : ∀ x : M, Q x = Q' x) : Q = Q' :=
FunLike.ext _ _ H
#align quadratic_form.ext QuadraticForm.ext
+-/
+#print QuadraticForm.congr_fun /-
theorem congr_fun (h : Q = Q') (x : M) : Q x = Q' x :=
FunLike.congr_fun h _
#align quadratic_form.congr_fun QuadraticForm.congr_fun
+-/
+#print QuadraticForm.ext_iff /-
theorem ext_iff : Q = Q' ↔ ∀ x, Q x = Q' x :=
FunLike.ext_iff
#align quadratic_form.ext_iff QuadraticForm.ext_iff
+-/
#print QuadraticForm.copy /-
/-- Copy of a `quadratic_form` with a new `to_fun` equal to the old one. Useful to fix definitional
@@ -202,14 +222,18 @@ protected def copy (Q : QuadraticForm R M) (Q' : M → R) (h : Q' = ⇑Q) : Quad
#align quadratic_form.copy QuadraticForm.copy
-/
+#print QuadraticForm.coe_copy /-
@[simp]
theorem coe_copy (Q : QuadraticForm R M) (Q' : M → R) (h : Q' = ⇑Q) : ⇑(Q.copy Q' h) = Q' :=
rfl
#align quadratic_form.coe_copy QuadraticForm.coe_copy
+-/
+#print QuadraticForm.copy_eq /-
theorem copy_eq (Q : QuadraticForm R M) (Q' : M → R) (h : Q' = ⇑Q) : Q.copy Q' h = Q :=
FunLike.ext' h
#align quadratic_form.copy_eq QuadraticForm.copy_eq
+-/
end FunLike
@@ -219,14 +243,19 @@ variable [Semiring R] [AddCommMonoid M] [Module R M]
variable (Q : QuadraticForm R M)
+#print QuadraticForm.map_smul /-
theorem map_smul (a : R) (x : M) : Q (a • x) = a * a * Q x :=
Q.toFun_smul a x
#align quadratic_form.map_smul QuadraticForm.map_smul
+-/
+#print QuadraticForm.exists_companion /-
theorem exists_companion : ∃ B : BilinForm R M, ∀ x y, Q (x + y) = Q x + Q y + B x y :=
Q.exists_companion'
#align quadratic_form.exists_companion QuadraticForm.exists_companion
+-/
+#print QuadraticForm.map_add_add_add_map /-
theorem map_add_add_add_map (x y z : M) :
Q (x + y + z) + (Q x + Q y + Q z) = Q (x + y) + Q (y + z) + Q (z + x) :=
by
@@ -235,24 +264,33 @@ theorem map_add_add_add_map (x y z : M) :
simp [h]
abel
#align quadratic_form.map_add_add_add_map QuadraticForm.map_add_add_add_map
+-/
+#print QuadraticForm.map_add_self /-
theorem map_add_self (x : M) : Q (x + x) = 4 * Q x := by rw [← one_smul R x, ← add_smul, map_smul];
norm_num
#align quadratic_form.map_add_self QuadraticForm.map_add_self
+-/
+#print QuadraticForm.map_zero /-
@[simp]
theorem map_zero : Q 0 = 0 := by
rw [← @zero_smul R _ _ _ _ (0 : M), map_smul, MulZeroClass.zero_mul, MulZeroClass.zero_mul]
#align quadratic_form.map_zero QuadraticForm.map_zero
+-/
+#print QuadraticForm.zeroHomClass /-
instance zeroHomClass : ZeroHomClass (QuadraticForm R M) M R :=
{ QuadraticForm.funLike with map_zero := map_zero }
#align quadratic_form.zero_hom_class QuadraticForm.zeroHomClass
+-/
+#print QuadraticForm.map_smul_of_tower /-
theorem map_smul_of_tower [CommSemiring S] [Algebra S R] [Module S M] [IsScalarTower S R M] (a : S)
(x : M) : Q (a • x) = (a * a) • Q x := by
rw [← IsScalarTower.algebraMap_smul R a x, map_smul, ← RingHom.map_mul, Algebra.smul_def]
#align quadratic_form.map_smul_of_tower QuadraticForm.map_smul_of_tower
+-/
end Semiring
@@ -262,72 +300,98 @@ variable [Ring R] [CommRing R₁] [AddCommGroup M]
variable [Module R M] (Q : QuadraticForm R M)
+#print QuadraticForm.map_neg /-
@[simp]
theorem map_neg (x : M) : Q (-x) = Q x := by
rw [← @neg_one_smul R _ _ _ _ x, map_smul, neg_one_mul, neg_neg, one_mul]
#align quadratic_form.map_neg QuadraticForm.map_neg
+-/
+#print QuadraticForm.map_sub /-
theorem map_sub (x y : M) : Q (x - y) = Q (y - x) := by rw [← neg_sub, map_neg]
#align quadratic_form.map_sub QuadraticForm.map_sub
+-/
+#print QuadraticForm.polar_zero_left /-
@[simp]
theorem polar_zero_left (y : M) : polar Q 0 y = 0 := by
simp only [polar, zero_add, QuadraticForm.map_zero, sub_zero, sub_self]
#align quadratic_form.polar_zero_left QuadraticForm.polar_zero_left
+-/
+#print QuadraticForm.polar_add_left /-
@[simp]
theorem polar_add_left (x x' y : M) : polar Q (x + x') y = polar Q x y + polar Q x' y :=
polar_add_left_iff.mpr <| Q.map_add_add_add_map x x' y
#align quadratic_form.polar_add_left QuadraticForm.polar_add_left
+-/
+#print QuadraticForm.polar_smul_left /-
@[simp]
theorem polar_smul_left (a : R) (x y : M) : polar Q (a • x) y = a * polar Q x y :=
by
obtain ⟨B, h⟩ := Q.exists_companion
simp_rw [polar, h, Q.map_smul, BilinForm.smul_left, sub_sub, add_sub_cancel']
#align quadratic_form.polar_smul_left QuadraticForm.polar_smul_left
+-/
+#print QuadraticForm.polar_neg_left /-
@[simp]
theorem polar_neg_left (x y : M) : polar Q (-x) y = -polar Q x y := by
rw [← neg_one_smul R x, polar_smul_left, neg_one_mul]
#align quadratic_form.polar_neg_left QuadraticForm.polar_neg_left
+-/
+#print QuadraticForm.polar_sub_left /-
@[simp]
theorem polar_sub_left (x x' y : M) : polar Q (x - x') y = polar Q x y - polar Q x' y := by
rw [sub_eq_add_neg, sub_eq_add_neg, polar_add_left, polar_neg_left]
#align quadratic_form.polar_sub_left QuadraticForm.polar_sub_left
+-/
+#print QuadraticForm.polar_zero_right /-
@[simp]
theorem polar_zero_right (y : M) : polar Q y 0 = 0 := by
simp only [add_zero, polar, QuadraticForm.map_zero, sub_self]
#align quadratic_form.polar_zero_right QuadraticForm.polar_zero_right
+-/
+#print QuadraticForm.polar_add_right /-
@[simp]
theorem polar_add_right (x y y' : M) : polar Q x (y + y') = polar Q x y + polar Q x y' := by
rw [polar_comm Q x, polar_comm Q x, polar_comm Q x, polar_add_left]
#align quadratic_form.polar_add_right QuadraticForm.polar_add_right
+-/
+#print QuadraticForm.polar_smul_right /-
@[simp]
theorem polar_smul_right (a : R) (x y : M) : polar Q x (a • y) = a * polar Q x y := by
rw [polar_comm Q x, polar_comm Q x, polar_smul_left]
#align quadratic_form.polar_smul_right QuadraticForm.polar_smul_right
+-/
+#print QuadraticForm.polar_neg_right /-
@[simp]
theorem polar_neg_right (x y : M) : polar Q x (-y) = -polar Q x y := by
rw [← neg_one_smul R y, polar_smul_right, neg_one_mul]
#align quadratic_form.polar_neg_right QuadraticForm.polar_neg_right
+-/
+#print QuadraticForm.polar_sub_right /-
@[simp]
theorem polar_sub_right (x y y' : M) : polar Q x (y - y') = polar Q x y - polar Q x y' := by
rw [sub_eq_add_neg, sub_eq_add_neg, polar_add_right, polar_neg_right]
#align quadratic_form.polar_sub_right QuadraticForm.polar_sub_right
+-/
+#print QuadraticForm.polar_self /-
@[simp]
theorem polar_self (x : M) : polar Q x x = 2 * Q x :=
by
rw [polar, map_add_self, sub_sub, sub_eq_iff_eq_add, ← two_mul, ← two_mul, ← mul_assoc]
norm_num
#align quadratic_form.polar_self QuadraticForm.polar_self
+-/
#print QuadraticForm.polarBilin /-
/-- `quadratic_form.polar` as a bilinear form -/
@@ -343,16 +407,21 @@ def polarBilin : BilinForm R M where
variable [CommSemiring S] [Algebra S R] [Module S M] [IsScalarTower S R M]
+#print QuadraticForm.polar_smul_left_of_tower /-
@[simp]
theorem polar_smul_left_of_tower (a : S) (x y : M) : polar Q (a • x) y = a • polar Q x y := by
rw [← IsScalarTower.algebraMap_smul R a x, polar_smul_left, Algebra.smul_def]
#align quadratic_form.polar_smul_left_of_tower QuadraticForm.polar_smul_left_of_tower
+-/
+#print QuadraticForm.polar_smul_right_of_tower /-
@[simp]
theorem polar_smul_right_of_tower (a : S) (x y : M) : polar Q x (a • y) = a • polar Q x y := by
rw [← IsScalarTower.algebraMap_smul R a y, polar_smul_right, Algebra.smul_def]
#align quadratic_form.polar_smul_right_of_tower QuadraticForm.polar_smul_right_of_tower
+-/
+#print QuadraticForm.ofPolar /-
/-- An alternative constructor to `quadratic_form.mk`, for rings where `polar` can be used. -/
@[simps]
def ofPolar (to_fun : M → R) (to_fun_smul : ∀ (a : R) (x : M), to_fun (a • x) = a * a * to_fun x)
@@ -370,12 +439,15 @@ def ofPolar (to_fun : M → R) (to_fun_smul : ∀ (a : R) (x : M), to_fun (a •
simp_rw [polar_comm _ x, polar_smul_left, smul_eq_mul] },
fun x y => by rw [BilinForm.coeFn_mk, polar, sub_sub, add_sub_cancel'_right]⟩ }
#align quadratic_form.of_polar QuadraticForm.ofPolar
+-/
+#print QuadraticForm.choose_exists_companion /-
/-- In a ring the companion bilinear form is unique and equal to `quadratic_form.polar`. -/
theorem choose_exists_companion : Q.exists_companion.some = polarBilin Q :=
BilinForm.ext fun x y => by
rw [polar_bilin_apply, polar, Q.exists_companion.some_spec, sub_sub, add_sub_cancel']
#align quadratic_form.some_exists_companion QuadraticForm.choose_exists_companion
+-/
end Ring
@@ -398,15 +470,19 @@ instance : SMul S (QuadraticForm R M) :=
let ⟨B, h⟩ := Q.exists_companion
⟨a • B, by simp [h]⟩ }⟩
+#print QuadraticForm.coeFn_smul /-
@[simp]
theorem coeFn_smul (a : S) (Q : QuadraticForm R M) : ⇑(a • Q) = a • Q :=
rfl
#align quadratic_form.coe_fn_smul QuadraticForm.coeFn_smul
+-/
+#print QuadraticForm.smul_apply /-
@[simp]
theorem smul_apply (a : S) (Q : QuadraticForm R M) (x : M) : (a • Q) x = a • Q x :=
rfl
#align quadratic_form.smul_apply QuadraticForm.smul_apply
+-/
end SMul
@@ -415,15 +491,19 @@ instance : Zero (QuadraticForm R M) :=
toFun_smul := fun a x => by simp only [MulZeroClass.mul_zero]
exists_companion' := ⟨0, fun x y => by simp only [add_zero, BilinForm.zero_apply]⟩ }⟩
+#print QuadraticForm.coeFn_zero /-
@[simp]
theorem coeFn_zero : ⇑(0 : QuadraticForm R M) = 0 :=
rfl
#align quadratic_form.coe_fn_zero QuadraticForm.coeFn_zero
+-/
+#print QuadraticForm.zero_apply /-
@[simp]
theorem zero_apply (x : M) : (0 : QuadraticForm R M) x = 0 :=
rfl
#align quadratic_form.zero_apply QuadraticForm.zero_apply
+-/
instance : Inhabited (QuadraticForm R M) :=
⟨0⟩
@@ -438,19 +518,24 @@ instance : Add (QuadraticForm R M) :=
⟨B + B', fun x y => by
simp_rw [Pi.add_apply, h, h', BilinForm.add_apply, add_add_add_comm]⟩ }⟩
+#print QuadraticForm.coeFn_add /-
@[simp]
theorem coeFn_add (Q Q' : QuadraticForm R M) : ⇑(Q + Q') = Q + Q' :=
rfl
#align quadratic_form.coe_fn_add QuadraticForm.coeFn_add
+-/
+#print QuadraticForm.add_apply /-
@[simp]
theorem add_apply (Q Q' : QuadraticForm R M) (x : M) : (Q + Q') x = Q x + Q' x :=
rfl
#align quadratic_form.add_apply QuadraticForm.add_apply
+-/
instance : AddCommMonoid (QuadraticForm R M) :=
FunLike.coe_injective.AddCommMonoid _ coeFn_zero coeFn_add fun _ _ => coeFn_smul _ _
+#print QuadraticForm.coeFnAddMonoidHom /-
/-- `@coe_fn (quadratic_form R M)` as an `add_monoid_hom`.
This API mirrors `add_monoid_hom.coe_fn`. -/
@@ -461,26 +546,33 @@ def coeFnAddMonoidHom : QuadraticForm R M →+ M → R
map_zero' := coeFn_zero
map_add' := coeFn_add
#align quadratic_form.coe_fn_add_monoid_hom QuadraticForm.coeFnAddMonoidHom
+-/
+#print QuadraticForm.evalAddMonoidHom /-
/-- Evaluation on a particular element of the module `M` is an additive map over quadratic forms. -/
@[simps apply]
def evalAddMonoidHom (m : M) : QuadraticForm R M →+ R :=
(Pi.evalAddMonoidHom _ m).comp coeFnAddMonoidHom
#align quadratic_form.eval_add_monoid_hom QuadraticForm.evalAddMonoidHom
+-/
section Sum
+#print QuadraticForm.coeFn_sum /-
@[simp]
theorem coeFn_sum {ι : Type _} (Q : ι → QuadraticForm R M) (s : Finset ι) :
⇑(∑ i in s, Q i) = ∑ i in s, Q i :=
(coeFnAddMonoidHom : _ →+ M → R).map_sum Q s
#align quadratic_form.coe_fn_sum QuadraticForm.coeFn_sum
+-/
+#print QuadraticForm.sum_apply /-
@[simp]
theorem sum_apply {ι : Type _} (Q : ι → QuadraticForm R M) (s : Finset ι) (x : M) :
(∑ i in s, Q i) x = ∑ i in s, Q i x :=
(evalAddMonoidHom x : _ →+ R).map_sum Q s
#align quadratic_form.sum_apply QuadraticForm.sum_apply
+-/
end Sum
@@ -511,28 +603,36 @@ instance : Neg (QuadraticForm R M) :=
let ⟨B, h⟩ := Q.exists_companion
⟨-B, fun x y => by simp_rw [Pi.neg_apply, h, BilinForm.neg_apply, neg_add]⟩ }⟩
+#print QuadraticForm.coeFn_neg /-
@[simp]
theorem coeFn_neg (Q : QuadraticForm R M) : ⇑(-Q) = -Q :=
rfl
#align quadratic_form.coe_fn_neg QuadraticForm.coeFn_neg
+-/
+#print QuadraticForm.neg_apply /-
@[simp]
theorem neg_apply (Q : QuadraticForm R M) (x : M) : (-Q) x = -Q x :=
rfl
#align quadratic_form.neg_apply QuadraticForm.neg_apply
+-/
instance : Sub (QuadraticForm R M) :=
⟨fun Q Q' => (Q + -Q').copy (Q - Q') (sub_eq_add_neg _ _)⟩
+#print QuadraticForm.coeFn_sub /-
@[simp]
theorem coeFn_sub (Q Q' : QuadraticForm R M) : ⇑(Q - Q') = Q - Q' :=
rfl
#align quadratic_form.coe_fn_sub QuadraticForm.coeFn_sub
+-/
+#print QuadraticForm.sub_apply /-
@[simp]
theorem sub_apply (Q Q' : QuadraticForm R M) (x : M) : (Q - Q') x = Q x - Q' x :=
rfl
#align quadratic_form.sub_apply QuadraticForm.sub_apply
+-/
instance : AddCommGroup (QuadraticForm R M) :=
FunLike.coe_injective.AddCommGroup _ coeFn_zero coeFn_add coeFn_neg coeFn_sub
@@ -558,10 +658,12 @@ def comp (Q : QuadraticForm R N) (f : M →ₗ[R] N) : QuadraticForm R M
#align quadratic_form.comp QuadraticForm.comp
-/
+#print QuadraticForm.comp_apply /-
@[simp]
theorem comp_apply (Q : QuadraticForm R N) (f : M →ₗ[R] N) (x : M) : (Q.comp f) x = Q (f x) :=
rfl
#align quadratic_form.comp_apply QuadraticForm.comp_apply
+-/
#print LinearMap.compQuadraticForm /-
/-- Compose a quadratic form with a linear function on the left. -/
@@ -594,28 +696,36 @@ def linMulLin (f g : M →ₗ[R] R) : QuadraticForm R M
#align quadratic_form.lin_mul_lin QuadraticForm.linMulLin
-/
+#print QuadraticForm.linMulLin_apply /-
@[simp]
theorem linMulLin_apply (f g : M →ₗ[R] R) (x) : linMulLin f g x = f x * g x :=
rfl
#align quadratic_form.lin_mul_lin_apply QuadraticForm.linMulLin_apply
+-/
+#print QuadraticForm.add_linMulLin /-
@[simp]
theorem add_linMulLin (f g h : M →ₗ[R] R) : linMulLin (f + g) h = linMulLin f h + linMulLin g h :=
ext fun x => add_mul _ _ _
#align quadratic_form.add_lin_mul_lin QuadraticForm.add_linMulLin
+-/
+#print QuadraticForm.linMulLin_add /-
@[simp]
theorem linMulLin_add (f g h : M →ₗ[R] R) : linMulLin f (g + h) = linMulLin f g + linMulLin f h :=
ext fun x => mul_add _ _ _
#align quadratic_form.lin_mul_lin_add QuadraticForm.linMulLin_add
+-/
variable {N : Type v} [AddCommMonoid N] [Module R N]
+#print QuadraticForm.linMulLin_comp /-
@[simp]
theorem linMulLin_comp (f g : M →ₗ[R] R) (h : N →ₗ[R] M) :
(linMulLin f g).comp h = linMulLin (f.comp h) (g.comp h) :=
rfl
#align quadratic_form.lin_mul_lin_comp QuadraticForm.linMulLin_comp
+-/
variable {n : Type _}
@@ -634,10 +744,12 @@ def proj (i j : n) : QuadraticForm R (n → R) :=
#align quadratic_form.proj QuadraticForm.proj
-/
+#print QuadraticForm.proj_apply /-
@[simp]
theorem proj_apply (i j : n) (x : n → R) : proj i j x = x i * x j :=
rfl
#align quadratic_form.proj_apply QuadraticForm.proj_apply
+-/
end CommRing
@@ -673,38 +785,47 @@ def toQuadraticForm (B : BilinForm R M) : QuadraticForm R M
#align bilin_form.to_quadratic_form BilinForm.toQuadraticForm
-/
+#print BilinForm.toQuadraticForm_apply /-
@[simp]
theorem toQuadraticForm_apply (B : BilinForm R M) (x : M) : B.toQuadraticForm x = B x x :=
rfl
#align bilin_form.to_quadratic_form_apply BilinForm.toQuadraticForm_apply
+-/
section
variable (R M)
+#print BilinForm.toQuadraticForm_zero /-
@[simp]
theorem toQuadraticForm_zero : (0 : BilinForm R M).toQuadraticForm = 0 :=
rfl
#align bilin_form.to_quadratic_form_zero BilinForm.toQuadraticForm_zero
+-/
end
+#print BilinForm.toQuadraticForm_add /-
@[simp]
theorem toQuadraticForm_add (B₁ B₂ : BilinForm R M) :
(B₁ + B₂).toQuadraticForm = B₁.toQuadraticForm + B₂.toQuadraticForm :=
rfl
#align bilin_form.to_quadratic_form_add BilinForm.toQuadraticForm_add
+-/
+#print BilinForm.toQuadraticForm_smul /-
@[simp]
theorem toQuadraticForm_smul [Monoid S] [DistribMulAction S R] [SMulCommClass S R R] (a : S)
(B : BilinForm R M) : (a • B).toQuadraticForm = a • B.toQuadraticForm :=
rfl
#align bilin_form.to_quadratic_form_smul BilinForm.toQuadraticForm_smul
+-/
section
variable (R M)
+#print BilinForm.toQuadraticFormAddMonoidHom /-
/-- `bilin_form.to_quadratic_form` as an additive homomorphism -/
@[simps]
def toQuadraticFormAddMonoidHom : BilinForm R M →+ QuadraticForm R M
@@ -713,31 +834,40 @@ def toQuadraticFormAddMonoidHom : BilinForm R M →+ QuadraticForm R M
map_zero' := toQuadraticForm_zero _ _
map_add' := toQuadraticForm_add
#align bilin_form.to_quadratic_form_add_monoid_hom BilinForm.toQuadraticFormAddMonoidHom
+-/
end
+#print BilinForm.toQuadraticForm_list_sum /-
@[simp]
theorem toQuadraticForm_list_sum (B : List (BilinForm R M)) :
B.Sum.toQuadraticForm = (B.map toQuadraticForm).Sum :=
map_list_sum (toQuadraticFormAddMonoidHom R M) B
#align bilin_form.to_quadratic_form_list_sum BilinForm.toQuadraticForm_list_sum
+-/
+#print BilinForm.toQuadraticForm_multiset_sum /-
@[simp]
theorem toQuadraticForm_multiset_sum (B : Multiset (BilinForm R M)) :
B.Sum.toQuadraticForm = (B.map toQuadraticForm).Sum :=
map_multiset_sum (toQuadraticFormAddMonoidHom R M) B
#align bilin_form.to_quadratic_form_multiset_sum BilinForm.toQuadraticForm_multiset_sum
+-/
+#print BilinForm.toQuadraticForm_sum /-
@[simp]
theorem toQuadraticForm_sum {ι : Type _} (s : Finset ι) (B : ι → BilinForm R M) :
(∑ i in s, B i).toQuadraticForm = ∑ i in s, (B i).toQuadraticForm :=
map_sum (toQuadraticFormAddMonoidHom R M) B s
#align bilin_form.to_quadratic_form_sum BilinForm.toQuadraticForm_sum
+-/
+#print BilinForm.toQuadraticForm_eq_zero /-
@[simp]
theorem toQuadraticForm_eq_zero {B : BilinForm R M} : B.toQuadraticForm = 0 ↔ B.IsAlt :=
QuadraticForm.ext_iff
#align bilin_form.to_quadratic_form_eq_zero BilinForm.toQuadraticForm_eq_zero
+-/
end Semiring
@@ -747,21 +877,27 @@ variable [Ring R] [AddCommGroup M] [Module R M]
variable {B : BilinForm R M}
+#print BilinForm.polar_to_quadratic_form /-
theorem polar_to_quadratic_form (x y : M) : polar (fun x => B x x) x y = B x y + B y x := by
simp only [add_assoc, add_sub_cancel', add_right, polar, add_left_inj, add_neg_cancel_left,
add_left, sub_eq_add_neg _ (B y y), add_comm (B y x) _]
#align bilin_form.polar_to_quadratic_form BilinForm.polar_to_quadratic_form
+-/
+#print BilinForm.toQuadraticForm_neg /-
@[simp]
theorem toQuadraticForm_neg (B : BilinForm R M) : (-B).toQuadraticForm = -B.toQuadraticForm :=
rfl
#align bilin_form.to_quadratic_form_neg BilinForm.toQuadraticForm_neg
+-/
+#print BilinForm.toQuadraticForm_sub /-
@[simp]
theorem toQuadraticForm_sub (B₁ B₂ : BilinForm R M) :
(B₁ - B₂).toQuadraticForm = B₁.toQuadraticForm - B₂.toQuadraticForm :=
rfl
#align bilin_form.to_quadratic_form_sub BilinForm.toQuadraticForm_sub
+-/
end Ring
@@ -779,6 +915,7 @@ variable (S) [CommSemiring S] [Algebra S R]
variable [Invertible (2 : R)] {B₁ : BilinForm R M}
+#print QuadraticForm.associatedHom /-
/-- `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`.
@@ -798,35 +935,47 @@ def associatedHom : QuadraticForm R M →ₗ[S] BilinForm R M
simp only [RingHom.id_apply, polar_smul, smul_comm s, polar_bilin_apply, coe_fn_mk, coe_fn_smul,
BilinForm.smul_apply]
#align quadratic_form.associated_hom QuadraticForm.associatedHom
+-/
variable (Q : QuadraticForm R M) (S)
+#print QuadraticForm.associated_apply /-
@[simp]
theorem associated_apply (x y : M) : associatedHom S Q x y = ⅟ 2 * (Q (x + y) - Q x - Q y) :=
rfl
#align quadratic_form.associated_apply QuadraticForm.associated_apply
+-/
+#print QuadraticForm.associated_isSymm /-
theorem associated_isSymm : (associatedHom S Q).IsSymm := fun x y => by
simp only [associated_apply, add_comm, add_left_comm, sub_eq_add_neg]
#align quadratic_form.associated_is_symm QuadraticForm.associated_isSymm
+-/
+#print QuadraticForm.associated_comp /-
@[simp]
theorem associated_comp {N : Type v} [AddCommGroup N] [Module R N] (f : N →ₗ[R] M) :
associatedHom S (Q.comp f) = (associatedHom S Q).comp f f := by ext;
simp only [QuadraticForm.comp_apply, BilinForm.comp_apply, associated_apply, LinearMap.map_add]
#align quadratic_form.associated_comp QuadraticForm.associated_comp
+-/
+#print QuadraticForm.associated_toQuadraticForm /-
theorem associated_toQuadraticForm (B : BilinForm R M) (x y : M) :
associatedHom S B.toQuadraticForm x y = ⅟ 2 * (B x y + B y x) := by
simp only [associated_apply, ← polar_to_quadratic_form, polar, to_quadratic_form_apply]
#align quadratic_form.associated_to_quadratic_form QuadraticForm.associated_toQuadraticForm
+-/
+#print QuadraticForm.associated_left_inverse /-
theorem associated_left_inverse (h : B₁.IsSymm) : associatedHom S B₁.toQuadraticForm = B₁ :=
BilinForm.ext fun x y => by
rw [associated_to_quadratic_form, is_symm.eq h x y, ← two_mul, ← mul_assoc, invOf_mul_self,
one_mul]
#align quadratic_form.associated_left_inverse QuadraticForm.associated_left_inverse
+-/
+#print QuadraticForm.toQuadraticForm_associated /-
theorem toQuadraticForm_associated : (associatedHom S Q).toQuadraticForm = Q :=
QuadraticForm.ext fun x =>
calc
@@ -835,14 +984,18 @@ theorem toQuadraticForm_associated : (associatedHom S Q).toQuadraticForm = Q :=
associated_apply, map_add_self, bit0]
_ = Q x := by rw [← two_mul (Q x), ← mul_assoc, invOf_mul_self, one_mul]
#align quadratic_form.to_quadratic_form_associated QuadraticForm.toQuadraticForm_associated
+-/
+#print QuadraticForm.associated_rightInverse /-
-- note: usually `right_inverse` lemmas are named the other way around, but this is consistent
-- with historical naming in this file.
theorem associated_rightInverse :
Function.RightInverse (associatedHom S) (BilinForm.toQuadraticForm : _ → QuadraticForm R M) :=
fun Q => toQuadraticForm_associated S Q
#align quadratic_form.associated_right_inverse QuadraticForm.associated_rightInverse
+-/
+#print QuadraticForm.associated_eq_self_apply /-
theorem associated_eq_self_apply (x : M) : associatedHom S Q x x = Q x :=
by
rw [associated_apply, map_add_self]
@@ -852,18 +1005,24 @@ theorem associated_eq_self_apply (x : M) : associatedHom S Q x x = Q x :=
abel
simp only [← mul_assoc, one_mul, invOf_mul_self]
#align quadratic_form.associated_eq_self_apply QuadraticForm.associated_eq_self_apply
+-/
+#print QuadraticForm.associated' /-
/-- `associated'` is the `ℤ`-linear map that sends a quadratic form on a module `M` over `R` to its
associated symmetric bilinear form. -/
abbrev associated' : QuadraticForm R M →ₗ[ℤ] BilinForm R M :=
associatedHom ℤ
#align quadratic_form.associated' QuadraticForm.associated'
+-/
+#print QuadraticForm.canLift /-
/-- Symmetric bilinear forms can be lifted to quadratic forms -/
instance canLift : CanLift (BilinForm R M) (QuadraticForm R M) (associatedHom ℕ) BilinForm.IsSymm
where prf B hB := ⟨B.toQuadraticForm, associated_left_inverse _ hB⟩
#align quadratic_form.can_lift QuadraticForm.canLift
+-/
+#print QuadraticForm.exists_quadraticForm_ne_zero /-
/-- 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`. -/
theorem exists_quadraticForm_ne_zero {Q : QuadraticForm R M} (hB₁ : Q.associated' ≠ 0) :
@@ -873,6 +1032,7 @@ theorem exists_quadraticForm_ne_zero {Q : QuadraticForm R M} (hB₁ : Q.associat
apply hB₁
rw [(QuadraticForm.ext h : Q = 0), LinearMap.map_zero]
#align quadratic_form.exists_quadratic_form_ne_zero QuadraticForm.exists_quadraticForm_ne_zero
+-/
end AssociatedHom
@@ -882,6 +1042,7 @@ variable [CommRing R₁] [AddCommGroup M] [Module R₁ M]
variable [Invertible (2 : R₁)]
+#print QuadraticForm.associated /-
-- Note: When possible, rather than writing lemmas about `associated`, write a lemma applying to
-- the more general `associated_hom` and place it in the previous section.
/-- `associated` is the linear map that sends a quadratic form over a commutative ring to its
@@ -889,7 +1050,9 @@ associated symmetric bilinear form. -/
abbrev associated : QuadraticForm R₁ M →ₗ[R₁] BilinForm R₁ M :=
associatedHom R₁
#align quadratic_form.associated QuadraticForm.associated
+-/
+#print QuadraticForm.associated_linMulLin /-
@[simp]
theorem associated_linMulLin (f g : M →ₗ[R₁] R₁) :
(linMulLin f g).Associated = ⅟ (2 : R₁) • (BilinForm.linMulLin f g + BilinForm.linMulLin g f) :=
@@ -900,6 +1063,7 @@ theorem associated_linMulLin (f g : M →ₗ[R₁] R₁) :
LinearMap.map_add]
ring
#align quadratic_form.associated_lin_mul_lin QuadraticForm.associated_linMulLin
+-/
end Associated
@@ -917,15 +1081,19 @@ def Anisotropic (Q : QuadraticForm R M) : Prop :=
-/
/- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (x «expr ≠ » 0) -/
+#print QuadraticForm.not_anisotropic_iff_exists /-
theorem not_anisotropic_iff_exists (Q : QuadraticForm R M) :
¬Anisotropic Q ↔ ∃ (x : _) (_ : x ≠ 0), Q x = 0 := by
simp only [anisotropic, not_forall, exists_prop, and_comm']
#align quadratic_form.not_anisotropic_iff_exists QuadraticForm.not_anisotropic_iff_exists
+-/
+#print QuadraticForm.Anisotropic.eq_zero_iff /-
theorem Anisotropic.eq_zero_iff {Q : QuadraticForm R M} (h : Anisotropic Q) {x : M} :
Q x = 0 ↔ x = 0 :=
⟨h x, fun h => h.symm ▸ map_zero Q⟩
#align quadratic_form.anisotropic.eq_zero_iff QuadraticForm.Anisotropic.eq_zero_iff
+-/
end Semiring
@@ -933,6 +1101,7 @@ section Ring
variable [Ring R] [AddCommGroup M] [Module R M]
+#print QuadraticForm.nondegenerate_of_anisotropic /-
/-- The associated bilinear form of an anisotropic quadratic form is nondegenerate. -/
theorem nondegenerate_of_anisotropic [Invertible (2 : R)] (Q : QuadraticForm R M)
(hB : Q.Anisotropic) : Q.associated'.Nondegenerate :=
@@ -942,6 +1111,7 @@ theorem nondegenerate_of_anisotropic [Invertible (2 : R)] (Q : QuadraticForm R M
rw [← hx x]
exact (associated_eq_self_apply _ _ x).symm
#align quadratic_form.nondegenerate_of_anisotropic QuadraticForm.nondegenerate_of_anisotropic
+-/
end Ring
@@ -961,16 +1131,21 @@ def PosDef (Q₂ : QuadraticForm R₂ M) : Prop :=
#align quadratic_form.pos_def QuadraticForm.PosDef
-/
+#print QuadraticForm.PosDef.smul /-
theorem PosDef.smul {R} [LinearOrderedCommRing R] [Module R M] {Q : QuadraticForm R M}
(h : PosDef Q) {a : R} (a_pos : 0 < a) : PosDef (a • Q) := fun x hx => mul_pos a_pos (h x hx)
#align quadratic_form.pos_def.smul QuadraticForm.PosDef.smul
+-/
variable {n : Type _}
+#print QuadraticForm.PosDef.nonneg /-
theorem PosDef.nonneg {Q : QuadraticForm R₂ M} (hQ : PosDef Q) (x : M) : 0 ≤ Q x :=
(eq_or_ne x 0).elim (fun h => h.symm ▸ (map_zero Q).symm.le) fun h => (hQ _ h).le
#align quadratic_form.pos_def.nonneg QuadraticForm.PosDef.nonneg
+-/
+#print QuadraticForm.PosDef.anisotropic /-
theorem PosDef.anisotropic {Q : QuadraticForm R₂ M} (hQ : Q.PosDef) : Q.Anisotropic := fun x hQx =>
by_contradiction fun hx =>
lt_irrefl (0 : R₂) <| by
@@ -978,23 +1153,32 @@ theorem PosDef.anisotropic {Q : QuadraticForm R₂ M} (hQ : Q.PosDef) : Q.Anisot
rw [hQx] at this
exact this
#align quadratic_form.pos_def.anisotropic QuadraticForm.PosDef.anisotropic
+-/
+#print QuadraticForm.posDefOfNonneg /-
theorem posDefOfNonneg {Q : QuadraticForm R₂ M} (h : ∀ x, 0 ≤ Q x) (h0 : Q.Anisotropic) :
PosDef Q := fun x hx => lt_of_le_of_ne (h x) (Ne.symm fun hQx => hx <| h0 _ hQx)
#align quadratic_form.pos_def_of_nonneg QuadraticForm.posDefOfNonneg
+-/
+#print QuadraticForm.posDef_iff_nonneg /-
theorem posDef_iff_nonneg {Q : QuadraticForm R₂ M} : PosDef Q ↔ (∀ x, 0 ≤ Q x) ∧ Q.Anisotropic :=
⟨fun h => ⟨h.NonNeg, h.Anisotropic⟩, fun ⟨n, a⟩ => posDefOfNonneg n a⟩
#align quadratic_form.pos_def_iff_nonneg QuadraticForm.posDef_iff_nonneg
+-/
+#print QuadraticForm.PosDef.add /-
theorem PosDef.add (Q Q' : QuadraticForm R₂ M) (hQ : PosDef Q) (hQ' : PosDef Q') :
PosDef (Q + Q') := fun x hx => add_pos (hQ x hx) (hQ' x hx)
#align quadratic_form.pos_def.add QuadraticForm.PosDef.add
+-/
+#print QuadraticForm.linMulLinSelfPosDef /-
theorem linMulLinSelfPosDef {R} [LinearOrderedCommRing R] [Module R M] (f : M →ₗ[R] R)
(hf : LinearMap.ker f = ⊥) : PosDef (linMulLin f f) := fun x hx =>
mul_self_pos.2 fun h => hx <| LinearMap.ker_eq_bot'.mp hf _ h
#align quadratic_form.lin_mul_lin_self_pos_def QuadraticForm.linMulLinSelfPosDef
+-/
end PosDef
@@ -1025,23 +1209,29 @@ def Matrix.toQuadraticForm' (M : Matrix n n R₁) : QuadraticForm R₁ (n → R
variable [Invertible (2 : R₁)]
+#print QuadraticForm.toMatrix' /-
/-- A matrix representation of the quadratic form. -/
def QuadraticForm.toMatrix' (Q : QuadraticForm R₁ (n → R₁)) : Matrix n n R₁ :=
Q.Associated.toMatrix'
#align quadratic_form.to_matrix' QuadraticForm.toMatrix'
+-/
open QuadraticForm
+#print QuadraticForm.toMatrix'_smul /-
theorem QuadraticForm.toMatrix'_smul (a : R₁) (Q : QuadraticForm R₁ (n → R₁)) :
(a • Q).toMatrix' = a • Q.toMatrix' := by
simp only [to_matrix', LinearEquiv.map_smul, LinearMap.map_smul]
#align quadratic_form.to_matrix'_smul QuadraticForm.toMatrix'_smul
+-/
+#print QuadraticForm.isSymm_toMatrix' /-
theorem QuadraticForm.isSymm_toMatrix' (Q : QuadraticForm R₁ (n → R₁)) : Q.toMatrix'.IsSymm :=
by
ext (i j)
rw [to_matrix', BilinForm.toMatrix'_apply, BilinForm.toMatrix'_apply, associated_is_symm]
#align quadratic_form.is_symm_to_matrix' QuadraticForm.isSymm_toMatrix'
+-/
end
@@ -1055,30 +1245,38 @@ variable {m : Type w} [DecidableEq m] [Fintype m]
open scoped Matrix
+#print QuadraticForm.toMatrix'_comp /-
@[simp]
theorem toMatrix'_comp (Q : QuadraticForm R₁ (m → R₁)) (f : (n → R₁) →ₗ[R₁] m → R₁) :
(Q.comp f).toMatrix' = f.toMatrix'ᵀ ⬝ Q.toMatrix' ⬝ f.toMatrix' := by ext;
simp only [QuadraticForm.associated_comp, BilinForm.toMatrix'_comp, to_matrix']
#align quadratic_form.to_matrix'_comp QuadraticForm.toMatrix'_comp
+-/
section Discriminant
variable {Q : QuadraticForm R₁ (n → R₁)}
+#print QuadraticForm.discr /-
/-- The discriminant of a quadratic form generalizes the discriminant of a quadratic polynomial. -/
def discr (Q : QuadraticForm R₁ (n → R₁)) : R₁ :=
Q.toMatrix'.det
#align quadratic_form.discr QuadraticForm.discr
+-/
+#print QuadraticForm.discr_smul /-
theorem discr_smul (a : R₁) : (a • Q).discr = a ^ Fintype.card n * Q.discr := by
simp only [discr, to_matrix'_smul, Matrix.det_smul]
#align quadratic_form.discr_smul QuadraticForm.discr_smul
+-/
+#print QuadraticForm.discr_comp /-
theorem discr_comp (f : (n → R₁) →ₗ[R₁] n → R₁) :
(Q.comp f).discr = f.toMatrix'.det * f.toMatrix'.det * Q.discr := by
simp only [Matrix.det_transpose, mul_left_comm, QuadraticForm.toMatrix'_comp, mul_comm,
Matrix.det_mul, discr]
#align quadratic_form.discr_comp QuadraticForm.discr_comp
+-/
end Discriminant
@@ -1094,15 +1292,18 @@ section Semiring
variable [Semiring R] [AddCommMonoid M] [Module R M]
+#print BilinForm.nondegenerate_of_anisotropic /-
/-- A bilinear form is nondegenerate if the quadratic form it is associated with is anisotropic. -/
theorem nondegenerate_of_anisotropic {B : BilinForm R M} (hB : B.toQuadraticForm.Anisotropic) :
B.Nondegenerate := fun x hx => hB _ (hx x)
#align bilin_form.nondegenerate_of_anisotropic BilinForm.nondegenerate_of_anisotropic
+-/
end Semiring
variable [Ring R] [AddCommGroup M] [Module R M]
+#print BilinForm.exists_bilinForm_self_ne_zero /-
/-- 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`. -/
@@ -1113,6 +1314,7 @@ theorem exists_bilinForm_self_ne_zero [htwo : Invertible (2 : R)] {B : BilinForm
obtain ⟨x, hx⟩ := QuadraticForm.exists_quadraticForm_ne_zero hB₁
exact ⟨x, fun h => hx (Q.associated_eq_self_apply ℕ x ▸ h)⟩
#align bilin_form.exists_bilin_form_self_ne_zero BilinForm.exists_bilinForm_self_ne_zero
+-/
open FiniteDimensional
@@ -1120,6 +1322,7 @@ variable {V : Type u} {K : Type v} [Field K] [AddCommGroup V] [Module K V]
variable [FiniteDimensional K V]
+#print BilinForm.exists_orthogonal_basis /-
/-- 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`. -/
theorem exists_orthogonal_basis [hK : Invertible (2 : K)] {B : BilinForm K V} (hB₂ : B.IsSymm) :
@@ -1166,6 +1369,7 @@ theorem exists_orthogonal_basis [hK : Invertible (2 : K)] {B : BilinForm K V} (h
· exact (v' i).Prop _ (Submodule.mem_span_singleton_self x)
· exact hv₁ (ne_of_apply_ne _ hij)
#align bilin_form.exists_orthogonal_basis BilinForm.exists_orthogonal_basis
+-/
end BilinForm
@@ -1186,15 +1390,18 @@ noncomputable def basisRepr (Q : QuadraticForm R M) (v : Basis ι R M) : Quadrat
#align quadratic_form.basis_repr QuadraticForm.basisRepr
-/
+#print QuadraticForm.basisRepr_apply /-
@[simp]
theorem basisRepr_apply (Q : QuadraticForm R M) (w : ι → R) :
Q.basis_repr v w = Q (∑ i : ι, w i • v i) := by rw [← v.equiv_fun_symm_apply]; rfl
#align quadratic_form.basis_repr_apply QuadraticForm.basisRepr_apply
+-/
section
variable (R₁)
+#print QuadraticForm.weightedSumSquares /-
/-- 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
@@ -1203,15 +1410,19 @@ def weightedSumSquares [Monoid S] [DistribMulAction S R₁] [SMulCommClass S R
QuadraticForm R₁ (ι → R₁) :=
∑ i : ι, w i • proj i i
#align quadratic_form.weighted_sum_squares QuadraticForm.weightedSumSquares
+-/
end
+#print QuadraticForm.weightedSumSquares_apply /-
@[simp]
theorem weightedSumSquares_apply [Monoid S] [DistribMulAction S R₁] [SMulCommClass S R₁ R₁]
(w : ι → S) (v : ι → R₁) : weightedSumSquares R₁ w v = ∑ i : ι, w i • (v i * v i) :=
QuadraticForm.sum_apply _ _ _
#align quadratic_form.weighted_sum_squares_apply QuadraticForm.weightedSumSquares_apply
+-/
+#print QuadraticForm.basisRepr_eq_of_iIsOrtho /-
/-- On an orthogonal basis, the basis representation of `Q` is just a sum of squares. -/
theorem basisRepr_eq_of_iIsOrtho {R₁ M} [CommRing R₁] [AddCommGroup M] [Module R₁ M]
[Invertible (2 : R₁)] (Q : QuadraticForm R₁ M) (v : Basis ι R₁ M)
@@ -1226,6 +1437,7 @@ theorem basisRepr_eq_of_iIsOrtho {R₁ M} [CommRing R₁] [AddCommGroup M] [Modu
rw [smul_left, smul_right, show associated_hom R₁ Q (v j) (v i) = 0 from hv₂ hij.symm,
MulZeroClass.mul_zero, MulZeroClass.mul_zero]
#align quadratic_form.basis_repr_eq_of_is_Ortho QuadraticForm.basisRepr_eq_of_iIsOrtho
+-/
end QuadraticForm
mathlib commit https://github.com/leanprover-community/mathlib/commit/7e5137f579de09a059a5ce98f364a04e221aabf0
@@ -834,7 +834,6 @@ theorem toQuadraticForm_associated : (associatedHom S Q).toQuadraticForm = Q :=
simp only [add_assoc, add_sub_cancel', one_mul, to_quadratic_form_apply, add_mul,
associated_apply, map_add_self, bit0]
_ = Q x := by rw [← two_mul (Q x), ← mul_assoc, invOf_mul_self, one_mul]
-
#align quadratic_form.to_quadratic_form_associated QuadraticForm.toQuadraticForm_associated
-- note: usually `right_inverse` lemmas are named the other way around, but this is consistent
mathlib commit https://github.com/leanprover-community/mathlib/commit/31c24aa72e7b3e5ed97a8412470e904f82b81004
@@ -917,7 +917,7 @@ def Anisotropic (Q : QuadraticForm R M) : Prop :=
#align quadratic_form.anisotropic QuadraticForm.Anisotropic
-/
-/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (x «expr ≠ » 0) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (x «expr ≠ » 0) -/
theorem not_anisotropic_iff_exists (Q : QuadraticForm R M) :
¬Anisotropic Q ↔ ∃ (x : _) (_ : x ≠ 0), Q x = 0 := by
simp only [anisotropic, not_forall, exists_prop, and_comm']
@@ -954,7 +954,7 @@ variable {R₂ : Type u} [OrderedRing R₂] [AddCommMonoid M] [Module R₂ M]
variable {Q₂ : QuadraticForm R₂ M}
-/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (x «expr ≠ » 0) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (x «expr ≠ » 0) -/
#print QuadraticForm.PosDef /-
/-- A positive definite quadratic form is positive on nonzero vectors. -/
def PosDef (Q₂ : QuadraticForm R₂ M) : Prop :=
mathlib commit https://github.com/leanprover-community/mathlib/commit/58a272265b5e05f258161260dd2c5d247213cbd3
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Anne Baanen, Kexing Ying, Eric Wieser
! This file was ported from Lean 3 source module linear_algebra.quadratic_form.basic
-! leanprover-community/mathlib commit 11b92770e4d49ff3982504c4dab918ac0887fe33
+! leanprover-community/mathlib commit 36938f775671ff28bea1c0310f1608e4afbb22e0
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
@@ -16,6 +16,9 @@ import Mathbin.LinearAlgebra.Matrix.Symmetric
/-!
# 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`
mathlib commit https://github.com/leanprover-community/mathlib/commit/13361559d66b84f80b6d5a1c4a26aa5054766725
@@ -83,6 +83,7 @@ variable [Ring R] [CommRing R₁] [AddCommGroup M]
namespace QuadraticForm
+#print QuadraticForm.polar /-
/-- 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
@@ -90,6 +91,7 @@ Source of this name: https://en.wikipedia.org/wiki/Quadratic_form#Generalization
def polar (f : M → R) (x y : M) :=
f (x + y) - f x - f y
#align quadratic_form.polar QuadraticForm.polar
+-/
theorem polar_add (f g : M → R) (x y : M) : polar (f + g) x y = polar f x y + polar g x y := by
simp only [polar, Pi.add_apply]; abel
@@ -128,6 +130,7 @@ end QuadraticForm
end Polar
+#print QuadraticForm /-
/-- A quadratic form over a module.
For a more familiar constructor when `R` is a ring, see `quadratic_form.of_polar`. -/
@@ -136,6 +139,7 @@ structure QuadraticForm (R : Type u) (M : Type v) [Semiring R] [AddCommMonoid M]
toFun_smul : ∀ (a : R) (x : M), to_fun (a • x) = a * a * to_fun x
exists_companion' : ∃ B : BilinForm R M, ∀ x y, to_fun (x + y) = to_fun x + to_fun y + B x y
#align quadratic_form QuadraticForm
+-/
namespace QuadraticForm
@@ -145,11 +149,13 @@ variable [Semiring R] [AddCommMonoid M] [Module R M]
variable {Q Q' : QuadraticForm R M}
+#print QuadraticForm.funLike /-
instance funLike : FunLike (QuadraticForm R M) M fun _ => R
where
coe := toFun
coe_injective' x y h := by cases x <;> cases y <;> congr
#align quadratic_form.fun_like QuadraticForm.funLike
+-/
/-- Helper instance for when there's too many metavariables to apply
`fun_like.has_coe_to_fun` directly. -/
@@ -182,6 +188,7 @@ theorem ext_iff : Q = Q' ↔ ∀ x, Q x = Q' x :=
FunLike.ext_iff
#align quadratic_form.ext_iff QuadraticForm.ext_iff
+#print QuadraticForm.copy /-
/-- Copy of a `quadratic_form` with a new `to_fun` equal to the old one. Useful to fix definitional
equalities. -/
protected def copy (Q : QuadraticForm R M) (Q' : M → R) (h : Q' = ⇑Q) : QuadraticForm R M
@@ -190,6 +197,7 @@ protected def copy (Q : QuadraticForm R M) (Q' : M → R) (h : Q' = ⇑Q) : Quad
toFun_smul := h.symm ▸ Q.toFun_smul
exists_companion' := h.symm ▸ Q.exists_companion'
#align quadratic_form.copy QuadraticForm.copy
+-/
@[simp]
theorem coe_copy (Q : QuadraticForm R M) (Q' : M → R) (h : Q' = ⇑Q) : ⇑(Q.copy Q' h) = Q' :=
@@ -318,6 +326,7 @@ theorem polar_self (x : M) : polar Q x x = 2 * Q x :=
norm_num
#align quadratic_form.polar_self QuadraticForm.polar_self
+#print QuadraticForm.polarBilin /-
/-- `quadratic_form.polar` as a bilinear form -/
@[simps]
def polarBilin : BilinForm R M where
@@ -327,6 +336,7 @@ def polarBilin : BilinForm R M where
bilin_add_right x y z := by simp_rw [polar_comm _ x, polar_add_left Q]
bilin_smul_right r x y := by simp_rw [polar_comm _ x, polar_smul_left Q]
#align quadratic_form.polar_bilin QuadraticForm.polarBilin
+-/
variable [CommSemiring S] [Algebra S R] [Module S M] [IsScalarTower S R M]
@@ -533,6 +543,7 @@ variable [Semiring R] [AddCommMonoid M] [Module R M]
variable {N : Type v} [AddCommMonoid N] [Module R N]
+#print QuadraticForm.comp /-
/-- Compose the quadratic form with a linear function. -/
def comp (Q : QuadraticForm R N) (f : M →ₗ[R] N) : QuadraticForm R M
where
@@ -542,12 +553,14 @@ def comp (Q : QuadraticForm R N) (f : M →ₗ[R] N) : QuadraticForm R M
let ⟨B, h⟩ := Q.exists_companion
⟨B.comp f f, fun x y => by simp_rw [f.map_add, h, BilinForm.comp_apply]⟩
#align quadratic_form.comp QuadraticForm.comp
+-/
@[simp]
theorem comp_apply (Q : QuadraticForm R N) (f : M →ₗ[R] N) (x : M) : (Q.comp f) x = Q (f x) :=
rfl
#align quadratic_form.comp_apply QuadraticForm.comp_apply
+#print LinearMap.compQuadraticForm /-
/-- Compose a quadratic form with a linear function on the left. -/
@[simps (config := { simpRhs := true })]
def LinearMap.compQuadraticForm {S : Type _} [CommSemiring S] [Algebra S R] [Module S M]
@@ -559,6 +572,7 @@ def LinearMap.compQuadraticForm {S : Type _} [CommSemiring S] [Algebra S R] [Mod
let ⟨B, h⟩ := Q.exists_companion
⟨f.compBilinForm B, fun x y => by simp_rw [h, f.map_add, LinearMap.compBilinForm_apply]⟩
#align linear_map.comp_quadratic_form LinearMap.compQuadraticForm
+-/
end Comp
@@ -566,6 +580,7 @@ section CommRing
variable [CommSemiring R] [AddCommMonoid M] [Module R M]
+#print QuadraticForm.linMulLin /-
/-- The product of linear forms is a quadratic form. -/
def linMulLin (f g : M →ₗ[R] R) : QuadraticForm R M
where
@@ -574,6 +589,7 @@ def linMulLin (f g : M →ₗ[R] R) : QuadraticForm R M
simp only [smul_eq_mul, RingHom.id_apply, Pi.mul_apply, LinearMap.map_smulₛₗ]; ring
exists_companion' := ⟨BilinForm.linMulLin f g + BilinForm.linMulLin g f, fun x y => by simp; ring⟩
#align quadratic_form.lin_mul_lin QuadraticForm.linMulLin
+-/
@[simp]
theorem linMulLin_apply (f g : M →ₗ[R] R) (x) : linMulLin f g x = f x * g x :=
@@ -600,16 +616,20 @@ theorem linMulLin_comp (f g : M →ₗ[R] R) (h : N →ₗ[R] M) :
variable {n : Type _}
+#print QuadraticForm.sq /-
/-- `sq` is the quadratic form mapping the vector `x : R₁` to `x * x` -/
@[simps]
def sq : QuadraticForm R R :=
linMulLin LinearMap.id LinearMap.id
#align quadratic_form.sq QuadraticForm.sq
+-/
+#print QuadraticForm.proj /-
/-- `proj i j` is the quadratic form mapping the vector `x : n → R₁` to `x i * x j` -/
def proj (i j : n) : QuadraticForm R (n → R) :=
linMulLin (@LinearMap.proj _ _ _ (fun _ => R) _ _ i) (@LinearMap.proj _ _ _ (fun _ => R) _ _ j)
#align quadratic_form.proj QuadraticForm.proj
+-/
@[simp]
theorem proj_apply (i j : n) (x : n → R) : proj i j x = x i * x j :=
@@ -640,6 +660,7 @@ variable [Semiring R] [AddCommMonoid M] [Module R M]
variable {B : BilinForm R M}
+#print BilinForm.toQuadraticForm /-
/-- A bilinear form gives a quadratic form by applying the argument twice. -/
def toQuadraticForm (B : BilinForm R M) : QuadraticForm R M
where
@@ -647,6 +668,7 @@ def toQuadraticForm (B : BilinForm R M) : QuadraticForm R M
toFun_smul a x := by simp only [mul_assoc, smul_right, smul_left]
exists_companion' := ⟨B + BilinForm.flipHom ℕ B, fun x y => by simp [add_add_add_comm, add_comm]⟩
#align bilin_form.to_quadratic_form BilinForm.toQuadraticForm
+-/
@[simp]
theorem toQuadraticForm_apply (B : BilinForm R M) (x : M) : B.toQuadraticForm x = B x x :=
@@ -885,10 +907,12 @@ section Semiring
variable [Semiring R] [AddCommMonoid M] [Module R M]
+#print QuadraticForm.Anisotropic /-
/-- An anisotropic quadratic form is zero only on zero vectors. -/
def Anisotropic (Q : QuadraticForm R M) : Prop :=
∀ x, Q x = 0 → x = 0
#align quadratic_form.anisotropic QuadraticForm.Anisotropic
+-/
/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (x «expr ≠ » 0) -/
theorem not_anisotropic_iff_exists (Q : QuadraticForm R M) :
@@ -928,10 +952,12 @@ variable {R₂ : Type u} [OrderedRing R₂] [AddCommMonoid M] [Module R₂ M]
variable {Q₂ : QuadraticForm R₂ M}
/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (x «expr ≠ » 0) -/
+#print QuadraticForm.PosDef /-
/-- A positive definite quadratic form is positive on nonzero vectors. -/
def PosDef (Q₂ : QuadraticForm R₂ M) : Prop :=
∀ (x) (_ : x ≠ 0), 0 < Q₂ x
#align quadratic_form.pos_def QuadraticForm.PosDef
+-/
theorem PosDef.smul {R} [LinearOrderedCommRing R] [Module R M] {Q : QuadraticForm R M}
(h : PosDef Q) {a : R} (a_pos : 0 < a) : PosDef (a • Q) := fun x hx => mul_pos a_pos (h x hx)
@@ -988,10 +1014,12 @@ variable {n : Type w} [Fintype n] [DecidableEq n]
variable [CommRing R₁] [AddCommMonoid M] [Module R₁ M]
+#print Matrix.toQuadraticForm' /-
/-- `M.to_quadratic_form` is the map `λ x, col x ⬝ M ⬝ row x` as a quadratic form. -/
def Matrix.toQuadraticForm' (M : Matrix n n R₁) : QuadraticForm R₁ (n → R₁) :=
M.toBilin'.toQuadraticForm
#align matrix.to_quadratic_form' Matrix.toQuadraticForm'
+-/
variable [Invertible (2 : R₁)]
@@ -1149,10 +1177,12 @@ variable [Module R M] [Module R M₁]
variable {ι : Type _} [Fintype ι] {v : Basis ι R M}
+#print QuadraticForm.basisRepr /-
/-- Given a quadratic form `Q` and a basis, `basis_repr` is the basis representation of `Q`. -/
noncomputable def basisRepr (Q : QuadraticForm R M) (v : Basis ι R M) : QuadraticForm R (ι → R) :=
Q.comp v.equivFun.symm
#align quadratic_form.basis_repr QuadraticForm.basisRepr
+-/
@[simp]
theorem basisRepr_apply (Q : QuadraticForm R M) (w : ι → R) :
mathlib commit https://github.com/leanprover-community/mathlib/commit/cca40788df1b8755d5baf17ab2f27dacc2e17acb
@@ -892,7 +892,7 @@ def Anisotropic (Q : QuadraticForm R M) : Prop :=
/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (x «expr ≠ » 0) -/
theorem not_anisotropic_iff_exists (Q : QuadraticForm R M) :
- ¬Anisotropic Q ↔ ∃ (x : _)(_ : x ≠ 0), Q x = 0 := by
+ ¬Anisotropic Q ↔ ∃ (x : _) (_ : x ≠ 0), Q x = 0 := by
simp only [anisotropic, not_forall, exists_prop, and_comm']
#align quadratic_form.not_anisotropic_iff_exists QuadraticForm.not_anisotropic_iff_exists
@@ -947,7 +947,7 @@ theorem PosDef.anisotropic {Q : QuadraticForm R₂ M} (hQ : Q.PosDef) : Q.Anisot
by_contradiction fun hx =>
lt_irrefl (0 : R₂) <| by
have := hQ _ hx
- rw [hQx] at this
+ rw [hQx] at this
exact this
#align quadratic_form.pos_def.anisotropic QuadraticForm.PosDef.anisotropic
@@ -1101,11 +1101,11 @@ theorem exists_orthogonal_basis [hK : Invertible (2 : K)] {B : BilinForm K V} (h
-- either the bilinear form is trivial or we can pick a non-null `x`
obtain rfl | hB₁ := eq_or_ne B 0
· let b := FiniteDimensional.finBasis K V
- rw [hd] at b
+ rw [hd] at b
refine' ⟨b, fun i j hij => rfl⟩
obtain ⟨x, hx⟩ := exists_bilin_form_self_ne_zero hB₁ hB₂
rw [← Submodule.finrank_add_eq_of_isCompl (is_compl_span_singleton_orthogonal hx).symm,
- finrank_span_singleton (ne_zero_of_not_is_ortho_self x hx)] at hd
+ finrank_span_singleton (ne_zero_of_not_is_ortho_self x hx)] at hd
let B' := B.restrict (B.orthogonal <| K ∙ x)
obtain ⟨v', hv₁⟩ := ih (B.restrict_symm hB₂ _ : B'.is_symm) (Nat.succ.inj hd)
-- concatenate `x` with the basis obtained by induction
@@ -1113,10 +1113,10 @@ theorem exists_orthogonal_basis [hK : Invertible (2 : K)] {B : BilinForm K V} (h
Basis.mkFinCons x v'
(by
rintro c y hy hc
- rw [add_eq_zero_iff_neg_eq] at hc
- rw [← hc, Submodule.neg_mem_iff] at hy
+ rw [add_eq_zero_iff_neg_eq] at hc
+ rw [← hc, Submodule.neg_mem_iff] at hy
have := (is_compl_span_singleton_orthogonal hx).Disjoint
- rw [Submodule.disjoint_def] at this
+ rw [Submodule.disjoint_def] at this
have := this (c • x) (Submodule.smul_mem _ _ <| Submodule.mem_span_singleton_self _) hy
exact (smul_eq_zero.1 this).resolve_right fun h => hx <| h.symm ▸ zero_left _)
(by
mathlib commit https://github.com/leanprover-community/mathlib/commit/917c3c072e487b3cccdbfeff17e75b40e45f66cb
@@ -75,7 +75,7 @@ variable {S : Type _}
variable {R R₁ : Type _} {M : Type _}
-open BigOperators
+open scoped BigOperators
section Polar
@@ -1023,7 +1023,7 @@ variable [CommRing R₁] [DecidableEq n] [Invertible (2 : R₁)]
variable {m : Type w} [DecidableEq m] [Fintype m]
-open Matrix
+open scoped Matrix
@[simp]
theorem toMatrix'_comp (Q : QuadraticForm R₁ (m → R₁)) (f : (n → R₁) →ₗ[R₁] m → R₁) :
mathlib commit https://github.com/leanprover-community/mathlib/commit/917c3c072e487b3cccdbfeff17e75b40e45f66cb
@@ -91,10 +91,8 @@ def polar (f : M → R) (x y : M) :=
f (x + y) - f x - f y
#align quadratic_form.polar QuadraticForm.polar
-theorem polar_add (f g : M → R) (x y : M) : polar (f + g) x y = polar f x y + polar g x y :=
- by
- simp only [polar, Pi.add_apply]
- abel
+theorem polar_add (f g : M → R) (x y : M) : polar (f + g) x y = polar f x y + polar g x y := by
+ simp only [polar, Pi.add_apply]; abel
#align quadratic_form.polar_add QuadraticForm.polar_add
theorem polar_neg (f : M → R) (x y : M) : polar (-f) x y = -polar f x y := by
@@ -227,9 +225,7 @@ theorem map_add_add_add_map (x y z : M) :
abel
#align quadratic_form.map_add_add_add_map QuadraticForm.map_add_add_add_map
-theorem map_add_self (x : M) : Q (x + x) = 4 * Q x :=
- by
- rw [← one_smul R x, ← add_smul, map_smul]
+theorem map_add_self (x : M) : Q (x + x) = 4 * Q x := by rw [← one_smul R x, ← add_smul, map_smul];
norm_num
#align quadratic_form.map_add_self QuadraticForm.map_add_self
@@ -480,21 +476,13 @@ instance [Monoid S] [DistribMulAction S R] [SMulCommClass S R R] :
where
mul_smul a b Q := ext fun x => by simp only [smul_apply, mul_smul]
one_smul Q := ext fun x => by simp only [QuadraticForm.smul_apply, one_smul]
- smul_add a Q Q' := by
- ext
- simp only [add_apply, smul_apply, smul_add]
- smul_zero a := by
- ext
- simp only [zero_apply, smul_apply, smul_zero]
+ smul_add a Q Q' := by ext; simp only [add_apply, smul_apply, smul_add]
+ smul_zero a := by ext; simp only [zero_apply, smul_apply, smul_zero]
instance [Semiring S] [Module S R] [SMulCommClass S R R] : Module S (QuadraticForm R M)
where
- zero_smul Q := by
- ext
- simp only [zero_apply, smul_apply, zero_smul]
- add_smul a b Q := by
- ext
- simp only [add_apply, smul_apply, add_smul]
+ zero_smul Q := by ext; simp only [zero_apply, smul_apply, zero_smul]
+ add_smul a b Q := by ext; simp only [add_apply, smul_apply, add_smul]
end SemiringOperators
@@ -582,15 +570,9 @@ variable [CommSemiring R] [AddCommMonoid M] [Module R M]
def linMulLin (f g : M →ₗ[R] R) : QuadraticForm R M
where
toFun := f * g
- toFun_smul a x :=
- by
- simp only [smul_eq_mul, RingHom.id_apply, Pi.mul_apply, LinearMap.map_smulₛₗ]
- ring
- exists_companion' :=
- ⟨BilinForm.linMulLin f g + BilinForm.linMulLin g f, fun x y =>
- by
- simp
- ring⟩
+ toFun_smul a x := by
+ simp only [smul_eq_mul, RingHom.id_apply, Pi.mul_apply, LinearMap.map_smulₛₗ]; ring
+ exists_companion' := ⟨BilinForm.linMulLin f g + BilinForm.linMulLin g f, fun x y => by simp; ring⟩
#align quadratic_form.lin_mul_lin QuadraticForm.linMulLin
@[simp]
@@ -784,12 +766,10 @@ def associatedHom : QuadraticForm R M →ₗ[S] BilinForm R M
toFun Q :=
((· • ·) : Submonoid.center R → BilinForm R M → BilinForm R M)
⟨⅟ 2, fun x => (Commute.one_right x).bit0_right.invOf_right⟩ Q.polarBilin
- map_add' Q Q' := by
- ext
+ map_add' Q Q' := by ext;
simp only [BilinForm.add_apply, BilinForm.smul_apply, coe_fn_mk, polar_bilin_apply, polar_add,
coe_fn_add, smul_add]
- map_smul' s Q := by
- ext
+ map_smul' s Q := by ext;
simp only [RingHom.id_apply, polar_smul, smul_comm s, polar_bilin_apply, coe_fn_mk, coe_fn_smul,
BilinForm.smul_apply]
#align quadratic_form.associated_hom QuadraticForm.associatedHom
@@ -807,9 +787,7 @@ theorem associated_isSymm : (associatedHom S Q).IsSymm := fun x y => by
@[simp]
theorem associated_comp {N : Type v} [AddCommGroup N] [Module R N] (f : N →ₗ[R] M) :
- associatedHom S (Q.comp f) = (associatedHom S Q).comp f f :=
- by
- ext
+ associatedHom S (Q.comp f) = (associatedHom S Q).comp f f := by ext;
simp only [QuadraticForm.comp_apply, BilinForm.comp_apply, associated_apply, LinearMap.map_add]
#align quadratic_form.associated_comp QuadraticForm.associated_comp
@@ -892,7 +870,7 @@ abbrev associated : QuadraticForm R₁ M →ₗ[R₁] BilinForm R₁ M :=
theorem associated_linMulLin (f g : M →ₗ[R₁] R₁) :
(linMulLin f g).Associated = ⅟ (2 : R₁) • (BilinForm.linMulLin f g + BilinForm.linMulLin g f) :=
by
- ext
+ ext;
simp only [smul_add, Algebra.id.smul_eq_mul, BilinForm.linMulLin_apply,
QuadraticForm.linMulLin_apply, BilinForm.smul_apply, associated_apply, BilinForm.add_apply,
LinearMap.map_add]
@@ -1049,9 +1027,7 @@ open Matrix
@[simp]
theorem toMatrix'_comp (Q : QuadraticForm R₁ (m → R₁)) (f : (n → R₁) →ₗ[R₁] m → R₁) :
- (Q.comp f).toMatrix' = f.toMatrix'ᵀ ⬝ Q.toMatrix' ⬝ f.toMatrix' :=
- by
- ext
+ (Q.comp f).toMatrix' = f.toMatrix'ᵀ ⬝ Q.toMatrix' ⬝ f.toMatrix' := by ext;
simp only [QuadraticForm.associated_comp, BilinForm.toMatrix'_comp, to_matrix']
#align quadratic_form.to_matrix'_comp QuadraticForm.toMatrix'_comp
@@ -1180,10 +1156,7 @@ noncomputable def basisRepr (Q : QuadraticForm R M) (v : Basis ι R M) : Quadrat
@[simp]
theorem basisRepr_apply (Q : QuadraticForm R M) (w : ι → R) :
- Q.basis_repr v w = Q (∑ i : ι, w i • v i) :=
- by
- rw [← v.equiv_fun_symm_apply]
- rfl
+ Q.basis_repr v w = Q (∑ i : ι, w i • v i) := by rw [← v.equiv_fun_symm_apply]; rfl
#align quadratic_form.basis_repr_apply QuadraticForm.basisRepr_apply
section
@@ -1216,8 +1189,7 @@ theorem basisRepr_eq_of_iIsOrtho {R₁ M} [CommRing R₁] [AddCommGroup M] [Modu
rw [basis_repr_apply, ← @associated_eq_self_apply R₁, sum_left, weighted_sum_squares_apply]
refine' sum_congr rfl fun j hj => _
rw [← @associated_eq_self_apply R₁, sum_right, sum_eq_single_of_mem j hj]
- · rw [smul_left, smul_right, smul_eq_mul]
- ring
+ · rw [smul_left, smul_right, smul_eq_mul]; ring
· intro i _ hij
rw [smul_left, smul_right, show associated_hom R₁ Q (v j) (v i) = 0 from hv₂ hij.symm,
MulZeroClass.mul_zero, MulZeroClass.mul_zero]
mathlib commit https://github.com/leanprover-community/mathlib/commit/8d33f09cd7089ecf074b4791907588245aec5d1b
@@ -1103,7 +1103,7 @@ on a module `M` over a ring `R` with invertible `2`, i.e. there exists some
theorem exists_bilinForm_self_ne_zero [htwo : Invertible (2 : R)] {B : BilinForm R M} (hB₁ : B ≠ 0)
(hB₂ : B.IsSymm) : ∃ x, ¬B.IsOrtho x x :=
by
- lift B to QuadraticForm R M using hB₂
+ lift B to QuadraticForm R M using hB₂ with Q
obtain ⟨x, hx⟩ := QuadraticForm.exists_quadraticForm_ne_zero hB₁
exact ⟨x, fun h => hx (Q.associated_eq_self_apply ℕ x ▸ h)⟩
#align bilin_form.exists_bilin_form_self_ne_zero BilinForm.exists_bilinForm_self_ne_zero
mathlib commit https://github.com/leanprover-community/mathlib/commit/75e7fca56381d056096ce5d05e938f63a6567828
@@ -801,9 +801,9 @@ theorem associated_apply (x y : M) : associatedHom S Q x y = ⅟ 2 * (Q (x + y)
rfl
#align quadratic_form.associated_apply QuadraticForm.associated_apply
-theorem associatedIsSymm : (associatedHom S Q).IsSymm := fun x y => by
+theorem associated_isSymm : (associatedHom S Q).IsSymm := fun x y => by
simp only [associated_apply, add_comm, add_left_comm, sub_eq_add_neg]
-#align quadratic_form.associated_is_symm QuadraticForm.associatedIsSymm
+#align quadratic_form.associated_is_symm QuadraticForm.associated_isSymm
@[simp]
theorem associated_comp {N : Type v} [AddCommGroup N] [Module R N] (f : N →ₗ[R] M) :
@@ -930,14 +930,14 @@ section Ring
variable [Ring R] [AddCommGroup M] [Module R M]
/-- The associated bilinear form of an anisotropic quadratic form is nondegenerate. -/
-theorem nondegenerateOfAnisotropic [Invertible (2 : R)] (Q : QuadraticForm R M)
+theorem nondegenerate_of_anisotropic [Invertible (2 : R)] (Q : QuadraticForm R M)
(hB : Q.Anisotropic) : Q.associated'.Nondegenerate :=
by
intro x hx
refine' hB _ _
rw [← hx x]
exact (associated_eq_self_apply _ _ x).symm
-#align quadratic_form.nondegenerate_of_anisotropic QuadraticForm.nondegenerateOfAnisotropic
+#align quadratic_form.nondegenerate_of_anisotropic QuadraticForm.nondegenerate_of_anisotropic
end Ring
@@ -1089,9 +1089,9 @@ section Semiring
variable [Semiring R] [AddCommMonoid M] [Module R M]
/-- A bilinear form is nondegenerate if the quadratic form it is associated with is anisotropic. -/
-theorem nondegenerateOfAnisotropic {B : BilinForm R M} (hB : B.toQuadraticForm.Anisotropic) :
+theorem nondegenerate_of_anisotropic {B : BilinForm R M} (hB : B.toQuadraticForm.Anisotropic) :
B.Nondegenerate := fun x hx => hB _ (hx x)
-#align bilin_form.nondegenerate_of_anisotropic BilinForm.nondegenerateOfAnisotropic
+#align bilin_form.nondegenerate_of_anisotropic BilinForm.nondegenerate_of_anisotropic
end Semiring
@@ -1103,7 +1103,7 @@ on a module `M` over a ring `R` with invertible `2`, i.e. there exists some
theorem exists_bilinForm_self_ne_zero [htwo : Invertible (2 : R)] {B : BilinForm R M} (hB₁ : B ≠ 0)
(hB₂ : B.IsSymm) : ∃ x, ¬B.IsOrtho x x :=
by
- lift B to QuadraticForm R M using hB₂ with Q
+ lift B to QuadraticForm R M using hB₂
obtain ⟨x, hx⟩ := QuadraticForm.exists_quadraticForm_ne_zero hB₁
exact ⟨x, fun h => hx (Q.associated_eq_self_apply ℕ x ▸ h)⟩
#align bilin_form.exists_bilin_form_self_ne_zero BilinForm.exists_bilinForm_self_ne_zero
@@ -1208,7 +1208,7 @@ theorem weightedSumSquares_apply [Monoid S] [DistribMulAction S R₁] [SMulCommC
#align quadratic_form.weighted_sum_squares_apply QuadraticForm.weightedSumSquares_apply
/-- On an orthogonal basis, the basis representation of `Q` is just a sum of squares. -/
-theorem basisRepr_eq_of_isOrthoCat {R₁ M} [CommRing R₁] [AddCommGroup M] [Module R₁ M]
+theorem basisRepr_eq_of_iIsOrtho {R₁ M} [CommRing R₁] [AddCommGroup M] [Module R₁ M]
[Invertible (2 : R₁)] (Q : QuadraticForm R₁ M) (v : Basis ι R₁ M)
(hv₂ : (associated Q).IsOrthoᵢ v) : Q.basis_repr v = weightedSumSquares _ fun i => Q (v i) :=
by
@@ -1221,7 +1221,7 @@ theorem basisRepr_eq_of_isOrthoCat {R₁ M} [CommRing R₁] [AddCommGroup M] [Mo
· intro i _ hij
rw [smul_left, smul_right, show associated_hom R₁ Q (v j) (v i) = 0 from hv₂ hij.symm,
MulZeroClass.mul_zero, MulZeroClass.mul_zero]
-#align quadratic_form.basis_repr_eq_of_is_Ortho QuadraticForm.basisRepr_eq_of_isOrthoCat
+#align quadratic_form.basis_repr_eq_of_is_Ortho QuadraticForm.basisRepr_eq_of_iIsOrtho
end QuadraticForm
mathlib commit https://github.com/leanprover-community/mathlib/commit/730c6d4cab72b9d84fcfb9e95e8796e9cd8f40ba
@@ -786,12 +786,12 @@ def associatedHom : QuadraticForm R M →ₗ[S] BilinForm R M
⟨⅟ 2, fun x => (Commute.one_right x).bit0_right.invOf_right⟩ Q.polarBilin
map_add' Q Q' := by
ext
- simp only [BilinForm.add_apply, BilinForm.smul_apply, [anonymous], polar_bilin_apply, polar_add,
+ simp only [BilinForm.add_apply, BilinForm.smul_apply, coe_fn_mk, polar_bilin_apply, polar_add,
coe_fn_add, smul_add]
map_smul' s Q := by
ext
- simp only [RingHom.id_apply, polar_smul, smul_comm s, polar_bilin_apply, [anonymous],
- coe_fn_smul, BilinForm.smul_apply]
+ simp only [RingHom.id_apply, polar_smul, smul_comm s, polar_bilin_apply, coe_fn_mk, coe_fn_smul,
+ BilinForm.smul_apply]
#align quadratic_form.associated_hom QuadraticForm.associatedHom
variable (Q : QuadraticForm R M) (S)
mathlib commit https://github.com/leanprover-community/mathlib/commit/dd6388c44e6f6b4547070b887c5905d5cfe6c9f8
@@ -1117,7 +1117,7 @@ variable [FiniteDimensional K 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`. -/
theorem exists_orthogonal_basis [hK : Invertible (2 : K)] {B : BilinForm K V} (hB₂ : B.IsSymm) :
- ∃ v : Basis (Fin (finrank K V)) K V, B.IsOrthoCat v :=
+ ∃ v : Basis (Fin (finrank K V)) K V, B.IsOrthoᵢ v :=
by
induction' hd : finrank K V with d ih generalizing V
· exact ⟨basisOfFinrankZero hd, fun _ _ _ => zero_left _⟩
@@ -1210,7 +1210,7 @@ theorem weightedSumSquares_apply [Monoid S] [DistribMulAction S R₁] [SMulCommC
/-- On an orthogonal basis, the basis representation of `Q` is just a sum of squares. -/
theorem basisRepr_eq_of_isOrthoCat {R₁ M} [CommRing R₁] [AddCommGroup M] [Module R₁ M]
[Invertible (2 : R₁)] (Q : QuadraticForm R₁ M) (v : Basis ι R₁ M)
- (hv₂ : (associated Q).IsOrthoCat v) : Q.basis_repr v = weightedSumSquares _ fun i => Q (v i) :=
+ (hv₂ : (associated Q).IsOrthoᵢ v) : Q.basis_repr v = weightedSumSquares _ fun i => Q (v i) :=
by
ext w
rw [basis_repr_apply, ← @associated_eq_self_apply R₁, sum_left, weighted_sum_squares_apply]
mathlib commit https://github.com/leanprover-community/mathlib/commit/3180fab693e2cee3bff62675571264cb8778b212
@@ -234,7 +234,8 @@ theorem map_add_self (x : M) : Q (x + x) = 4 * Q x :=
#align quadratic_form.map_add_self QuadraticForm.map_add_self
@[simp]
-theorem map_zero : Q 0 = 0 := by rw [← @zero_smul R _ _ _ _ (0 : M), map_smul, zero_mul, zero_mul]
+theorem map_zero : Q 0 = 0 := by
+ rw [← @zero_smul R _ _ _ _ (0 : M), map_smul, MulZeroClass.zero_mul, MulZeroClass.zero_mul]
#align quadratic_form.map_zero QuadraticForm.map_zero
instance zeroHomClass : ZeroHomClass (QuadraticForm R M) M R :=
@@ -402,7 +403,7 @@ end SMul
instance : Zero (QuadraticForm R M) :=
⟨{ toFun := fun x => 0
- toFun_smul := fun a x => by simp only [mul_zero]
+ toFun_smul := fun a x => by simp only [MulZeroClass.mul_zero]
exists_companion' := ⟨0, fun x y => by simp only [add_zero, BilinForm.zero_apply]⟩ }⟩
@[simp]
@@ -1147,7 +1148,7 @@ theorem exists_orthogonal_basis [hK : Invertible (2 : K)] {B : BilinForm K V} (h
refine' ⟨-B x y / B x x, fun z hz => _⟩
obtain ⟨c, rfl⟩ := Submodule.mem_span_singleton.1 hz
rw [is_ortho, smul_left, add_right, smul_right, div_mul_cancel _ hx, add_neg_self,
- mul_zero])
+ MulZeroClass.mul_zero])
refine' ⟨b, _⟩
· rw [Basis.coe_mkFinCons]
intro j i
@@ -1218,8 +1219,8 @@ theorem basisRepr_eq_of_isOrthoCat {R₁ M} [CommRing R₁] [AddCommGroup M] [Mo
· rw [smul_left, smul_right, smul_eq_mul]
ring
· intro i _ hij
- rw [smul_left, smul_right, show associated_hom R₁ Q (v j) (v i) = 0 from hv₂ hij.symm, mul_zero,
- mul_zero]
+ rw [smul_left, smul_right, show associated_hom R₁ Q (v j) (v i) = 0 from hv₂ hij.symm,
+ MulZeroClass.mul_zero, MulZeroClass.mul_zero]
#align quadratic_form.basis_repr_eq_of_is_Ortho QuadraticForm.basisRepr_eq_of_isOrthoCat
end QuadraticForm
mathlib commit https://github.com/leanprover-community/mathlib/commit/4c586d291f189eecb9d00581aeb3dd998ac34442
@@ -911,7 +911,7 @@ def Anisotropic (Q : QuadraticForm R M) : Prop :=
∀ x, Q x = 0 → x = 0
#align quadratic_form.anisotropic QuadraticForm.Anisotropic
-/- ./././Mathport/Syntax/Translate/Basic.lean:628:2: warning: expanding binder collection (x «expr ≠ » 0) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (x «expr ≠ » 0) -/
theorem not_anisotropic_iff_exists (Q : QuadraticForm R M) :
¬Anisotropic Q ↔ ∃ (x : _)(_ : x ≠ 0), Q x = 0 := by
simp only [anisotropic, not_forall, exists_prop, and_comm']
@@ -948,7 +948,7 @@ variable {R₂ : Type u} [OrderedRing R₂] [AddCommMonoid M] [Module R₂ M]
variable {Q₂ : QuadraticForm R₂ M}
-/- ./././Mathport/Syntax/Translate/Basic.lean:628:2: warning: expanding binder collection (x «expr ≠ » 0) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (x «expr ≠ » 0) -/
/-- A positive definite quadratic form is positive on nonzero vectors. -/
def PosDef (Q₂ : QuadraticForm R₂ M) : Prop :=
∀ (x) (_ : x ≠ 0), 0 < Q₂ x
mathlib commit https://github.com/leanprover-community/mathlib/commit/bd9851ca476957ea4549eb19b40e7b5ade9428cc
Generalize MulActionHom
so that it allows two different monoids acting, related by a morphism. This is inspired by the treatment of (semi)linear maps in mathlib, and allows to refactor them.
Let M
, N
, X
, Y
be types, with SMul M X
and SMul N Y
, and let φ : M → N
be a map.
MulActionHom φ X Y
, the type of equivariant functions from X
to Y
, consists of functions f : X → Y
such that f (m • x) = (φ m) • (f x)
for all m : M
and x : X
.Assume that we have Monoid M
, Monoid N
and that φ : M →* N
. For A
, B
by types with AddMonoid A
and AddMonoid B
, endowed with DistribMulAction M A
and DistribMulAction M B
:
DistribMulActionHom φ A B
is the type of equivariant additive monoid homomorphisms from A
to B
.Similarly, when R
and S
are types with Semiring R
, Semiring S
, MulSemiringAction M R
and MulSemiringAction N S
SMulSemiringHom φ R S
is the type of equivariant ring homomorphisms
from R
to S
.The above types have corresponding classes:
MulActionHomClass F φ X Y
states that F
is a type of bundled X → Y
homs which are φ
-equivariantDistribMulActionHomClass F φ A B
states that F
is a type of bundled A → B
homs preserving the additive monoid structure and φ
-equivariantSMulSemiringHomClass F φ R S
states that F
is a type of bundled R → S
homs preserving the ring structure and φ
-equivariantWe introduce the following notation to code equivariant maps
(the subscript index ₑ
is for equivariant) :
X →ₑ[φ] Y
is MulActionHom φ X Y
.A →ₑ+[φ] B
is DistribMulActionHom φ A B
.R →ₑ+*[φ] S
is MulSemiringActionHom φ R S
.When M = N
and φ = MonoidHom.id M
, we provide the backward compatible notation :
X →[M] Y
is MulActionHom ([@id](https://github.com/id) M) X Y
A →+[M] B
is DistribMulActionHom (MonoidHom.id M) A B
R →+*[M] S
is MulSemiringActionHom (MonoidHom.id M) R S
This more general definition is propagated all over mathlib, in particular to LinearMap
.
The treatment of composition of equivariant maps is inspired by that of semilinear maps. We provide classes CompTriple
and MonoidHom.CompTriple
of “composable triples`, and various instances for them.
@@ -657,7 +657,7 @@ variable [CommSemiring R] [AddCommMonoid M] [AddCommMonoid N] [Module R M] [Modu
def toQuadraticForm (B : BilinForm R M) : QuadraticForm R M where
toFun x := B x x
toFun_smul a x := by
- simp only [SMulHomClass.map_smul, LinearMap.smul_apply, smul_eq_mul, mul_assoc]
+ simp only [_root_.map_smul, LinearMap.smul_apply, smul_eq_mul, mul_assoc]
exists_companion' := ⟨B + B.flip,
fun x y => by simp only [map_add, LinearMap.add_apply, LinearMap.flip_apply]; abel⟩
#align bilin_form.to_quadratic_form LinearMap.BilinForm.toQuadraticForm
mul
-div
cancellation lemmas (#11530)
Lemma names around cancellation of multiplication and division are a mess.
This PR renames a handful of them according to the following table (each big row contains the multiplicative statement, then the three rows contain the GroupWithZero
lemma name, the Group
lemma, the AddGroup
lemma name).
| Statement | New name | Old name | |
@@ -276,7 +276,7 @@ theorem polar_add_left (x x' y : M) : polar Q (x + x') y = polar Q x y + polar Q
@[simp]
theorem polar_smul_left (a : R) (x y : M) : polar Q (a • x) y = a * polar Q x y := by
obtain ⟨B, h⟩ := Q.exists_companion
- simp_rw [polar, h, Q.map_smul, LinearMap.map_smul₂, sub_sub, add_sub_cancel', smul_eq_mul]
+ simp_rw [polar, h, Q.map_smul, LinearMap.map_smul₂, sub_sub, add_sub_cancel_left, smul_eq_mul]
#align quadratic_form.polar_smul_left QuadraticForm.polar_smul_left
@[simp]
@@ -352,14 +352,14 @@ def ofPolar (toFun : M → R) (toFun_smul : ∀ (a : R) (x : M), toFun (a • x)
(fun _ _ _ ↦ by rw [polar_comm, polar_smul_left, polar_comm]),
fun _ _ ↦ by
simp only [LinearMap.mk₂_apply]
- rw [polar, sub_sub, add_sub_cancel'_right]⟩ }
+ rw [polar, sub_sub, add_sub_cancel]⟩ }
#align quadratic_form.of_polar QuadraticForm.ofPolar
/-- In a ring the companion bilinear form is unique and equal to `QuadraticForm.polar`. -/
theorem choose_exists_companion : Q.exists_companion.choose = polarBilin Q :=
LinearMap.ext₂ fun x y => by
rw [polarBilin_apply_apply, polar, Q.exists_companion.choose_spec, sub_sub,
- add_sub_cancel']
+ add_sub_cancel_left]
#align quadratic_form.some_exists_companion QuadraticForm.choose_exists_companion
end CommRing
@@ -763,7 +763,7 @@ theorem toQuadraticForm_sub (B₁ B₂ : BilinForm R M) :
#align bilin_form.to_quadratic_form_sub LinearMap.BilinForm.toQuadraticForm_sub
theorem polar_toQuadraticForm (x y : M) : polar (toQuadraticForm B) x y = B x y + B y x := by
- simp only [toQuadraticForm_apply, add_assoc, add_sub_cancel', add_apply, polar, add_left_inj,
+ simp only [toQuadraticForm_apply, add_assoc, add_sub_cancel_left, add_apply, polar, add_left_inj,
add_neg_cancel_left, map_add, sub_eq_add_neg _ (B y y), add_comm (B y x) _]
#align bilin_form.polar_to_quadratic_form LinearMap.BilinForm.polar_toQuadraticForm
@@ -866,7 +866,7 @@ theorem associated_left_inverse (h : B₁.IsSymm) : associatedHom S B₁.toQuadr
-- Porting note: moved from below to golf the next theorem
theorem associated_eq_self_apply (x : M) : associatedHom S Q x x = Q x := by
rw [associated_apply, map_add_self, ← three_add_one_eq_four, ← two_add_one_eq_three,
- add_mul, add_mul, one_mul, add_sub_cancel, add_sub_cancel, invOf_mul_self_assoc]
+ add_mul, add_mul, one_mul, add_sub_cancel_right, add_sub_cancel_right, invOf_mul_self_assoc]
#align quadratic_form.associated_eq_self_apply QuadraticForm.associated_eq_self_apply
theorem toQuadraticForm_associated : (associatedHom S Q).toQuadraticForm = Q :=
@@ -1244,7 +1244,7 @@ theorem exists_orthogonal_basis [hK : Invertible (2 : K)] {B : BilinForm K V} (h
refine' ⟨-B x y / B x x, fun z hz => _⟩
obtain ⟨c, rfl⟩ := Submodule.mem_span_singleton.1 hz
rw [IsOrtho, map_smul, smul_apply, map_add, map_smul, smul_eq_mul, smul_eq_mul,
- div_mul_cancel _ hx, add_neg_self, mul_zero])
+ div_mul_cancel₀ _ hx, add_neg_self, mul_zero])
refine' ⟨b, _⟩
· rw [Basis.coe_mkFinCons]
intro j i
Empty lines were removed by executing the following Python script twice
import os
import re
# Loop through each file in the repository
for dir_path, dirs, files in os.walk('.'):
for filename in files:
if filename.endswith('.lean'):
file_path = os.path.join(dir_path, filename)
# Open the file and read its contents
with open(file_path, 'r') as file:
content = file.read()
# Use a regular expression to replace sequences of "variable" lines separated by empty lines
# with sequences without empty lines
modified_content = re.sub(r'(variable.*\n)\n(variable(?! .* in))', r'\1\2', content)
# Write the modified content back to the file
with open(file_path, 'w') as file:
file.write(modified_content)
@@ -77,7 +77,6 @@ quadratic form, homogeneous polynomial, quadratic polynomial
universe u v w
variable {S T : Type*}
-
variable {R : Type*} {M N : Type*}
open BigOperators
@@ -152,7 +151,6 @@ namespace QuadraticForm
section DFunLike
variable [CommSemiring R] [AddCommMonoid M] [Module R M]
-
variable {Q Q' : QuadraticForm R M}
instance instFunLike : FunLike (QuadraticForm R M) M R where
@@ -213,7 +211,6 @@ end DFunLike
section CommSemiring
variable [CommSemiring R] [AddCommMonoid M] [Module R M]
-
variable (Q : QuadraticForm R M)
theorem map_smul (a : R) (x : M) : Q (a • x) = a * a * Q x :=
@@ -256,7 +253,6 @@ end CommSemiring
section CommRing
variable [CommRing R] [AddCommGroup M]
-
variable [Module R M] (Q : QuadraticForm R M)
@[simp]
@@ -546,7 +542,6 @@ end RingOperators
section Comp
variable [CommSemiring R] [AddCommMonoid M] [Module R M]
-
variable [AddCommMonoid N] [Module R N]
/-- Compose the quadratic form with a linear function. -/
@@ -754,7 +749,6 @@ section Ring
open QuadraticForm
variable [CommRing R] [AddCommGroup M] [Module R M]
-
variable {B : BilinForm R M}
@[simp]
@@ -814,9 +808,7 @@ open LinearMap.BilinForm
section AssociatedHom
variable [CommRing R] [AddCommGroup M] [Module R M]
-
variable (S) [CommSemiring S] [Algebra S R]
-
variable [Invertible (2 : R)] {B₁ : BilinForm R M}
/-- `associatedHom` is the map that sends a quadratic form on a module `M` over `R` to its
@@ -917,7 +909,6 @@ end AssociatedHom
section Associated
variable [CommSemiring S] [CommRing R] [AddCommGroup M] [Algebra S R] [Module R M]
-
variable [Invertible (2 : R)]
-- Note: When possible, rather than writing lemmas about `associated`, write a lemma applying to
@@ -1054,7 +1045,6 @@ end Anisotropic
section PosDef
variable {R₂ : Type u} [OrderedCommRing R₂] [AddCommMonoid M] [Module R₂ M]
-
variable {Q₂ : QuadraticForm R₂ M}
/-- A positive definite quadratic form is positive on nonzero vectors. -/
@@ -1113,7 +1103,6 @@ The determinant of the matrix is the discriminant of the quadratic form.
-/
variable {n : Type w} [Fintype n] [DecidableEq n]
-
variable [CommRing R] [AddCommMonoid M] [Module R M]
/-- `M.toQuadraticForm'` is the map `fun x ↦ col x * M * row x` as a quadratic form. -/
@@ -1146,9 +1135,7 @@ end
namespace QuadraticForm
variable {n : Type w} [Fintype n]
-
variable [CommRing R] [DecidableEq n] [Invertible (2 : R)]
-
variable {m : Type w} [DecidableEq m] [Fintype m]
open Matrix
@@ -1220,7 +1207,6 @@ theorem exists_bilinForm_self_ne_zero [htwo : Invertible (2 : R)] {B : BilinForm
open FiniteDimensional
variable {V : Type u} {K : Type v} [Field K] [AddCommGroup V] [Module K V]
-
variable [FiniteDimensional K V]
/-- Given a symmetric bilinear form `B` on some vector space `V` over a field `K`
@@ -1280,7 +1266,6 @@ namespace QuadraticForm
open Finset
variable [CommSemiring R] [AddCommMonoid M] [Module R M]
-
variable {ι : Type*}
/-- Given a quadratic form `Q` and a basis, `basisRepr` is the basis representation of `Q`. -/
λ
by fun
(#11301)
Per the style guidelines, λ
is disallowed in mathlib.
This is close to exhaustive; I left some tactic code alone when it seemed to me that tactic could be upstreamed soon.
Notes
=>
to ↦
.Mathlib/Order/SupClosed
.λ x,
, which I also replaced.@@ -352,9 +352,9 @@ def ofPolar (toFun : M → R) (toFun_smul : ∀ (a : R) (x : M), toFun (a • x)
{ toFun
toFun_smul
exists_companion' := ⟨LinearMap.mk₂ R (polar toFun) (polar_add_left) (polar_smul_left)
- (fun x _ _ => by simp_rw [polar_comm _ x, polar_add_left])
- (fun _ _ _ => by rw [polar_comm, polar_smul_left, polar_comm]),
- fun _ _ => by
+ (fun x _ _ ↦ by simp_rw [polar_comm _ x, polar_add_left])
+ (fun _ _ _ ↦ by rw [polar_comm, polar_smul_left, polar_comm]),
+ fun _ _ ↦ by
simp only [LinearMap.mk₂_apply]
rw [polar, sub_sub, add_sub_cancel'_right]⟩ }
#align quadratic_form.of_polar QuadraticForm.ofPolar
@@ -571,7 +571,7 @@ def _root_.LinearMap.compQuadraticForm [CommSemiring S] [Algebra S R] [Module S
toFun_smul b x := by simp only [Q.map_smul_of_tower b x, f.map_smul, smul_eq_mul]
exists_companion' :=
let ⟨B, h⟩ := Q.exists_companion
- ⟨(B.restrictScalars₁₂ S).compr₂ f, fun x y => by
+ ⟨(B.restrictScalars₁₂ S S).compr₂ f, fun x y => by
simp_rw [h, f.map_add, LinearMap.compr₂_apply, LinearMap.restrictScalars₁₂_apply_apply]⟩
#align linear_map.comp_quadratic_form LinearMap.compQuadraticForm
@@ -798,7 +798,7 @@ theorem compQuadraticForm_polar (f : R →ₗ[S] S) (Q : QuadraticForm R M) (x y
theorem compQuadraticForm_polarBilin (f : R →ₗ[S] S) (Q : QuadraticForm R M) :
(f.compQuadraticForm Q).polarBilin =
- (Q.polarBilin.restrictScalars₁₂ S).compr₂ f :=
+ (Q.polarBilin.restrictScalars₁₂ S S).compr₂ f :=
ext₂ <| compQuadraticForm_polar _ _
end Ring
Homogenises porting notes via capitalisation and addition of whitespace.
It makes the following changes:
@@ -237,7 +237,7 @@ theorem map_add_self (x : M) : Q (x + x) = 4 * Q x := by
norm_num
#align quadratic_form.map_add_self QuadraticForm.map_add_self
--- porting note: removed @[simp] because it is superseded by `ZeroHomClass.map_zero`
+-- Porting note: removed @[simp] because it is superseded by `ZeroHomClass.map_zero`
theorem map_zero : Q 0 = 0 := by
rw [← @zero_smul R _ _ _ _ (0 : M), map_smul, zero_mul, zero_mul]
#align quadratic_form.map_zero QuadraticForm.map_zero
@@ -871,7 +871,7 @@ theorem associated_left_inverse (h : B₁.IsSymm) : associatedHom S B₁.toQuadr
invOf_mul_self, one_mul]
#align quadratic_form.associated_left_inverse QuadraticForm.associated_left_inverse
--- porting note: moved from below to golf the next theorem
+-- Porting note: moved from below to golf the next theorem
theorem associated_eq_self_apply (x : M) : associatedHom S Q x x = Q x := by
rw [associated_apply, map_add_self, ← three_add_one_eq_four, ← two_add_one_eq_three,
add_mul, add_mul, one_mul, add_sub_cancel, add_sub_cancel, invOf_mul_self_assoc]
BilinForm
with a scalar valued bi LinearMap
(#10238)
Following on from #10097, which converted the companion of a quadratic form with a bilinear map, this PR replaces a number of results about quadratic forms and bilinear forms with results about quadratic forms and scalar valued bilinear maps. The long term aim is to be able to consider quadratic maps.
The main change is to LinearAlgebra/QuadraticForm/Basic
, but this necessitates changes throughout LinearAlgebra/QuadraticForm/
. Minor changes are also required elsewhere:
LinearAlgebra/CliffordAlgebra/
LinearAlgebra/Matrix/PosDef
LinearAlgebra/SesquilinearForm
Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Christopher Hoskin <christopher.hoskin@overleaf.com>
@@ -4,9 +4,8 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Anne Baanen, Kexing Ying, Eric Wieser
-/
import Mathlib.LinearAlgebra.Matrix.Determinant
-import Mathlib.LinearAlgebra.Matrix.BilinearForm
+import Mathlib.LinearAlgebra.Matrix.SesquilinearForm
import Mathlib.LinearAlgebra.Matrix.Symmetric
-import Mathlib.LinearAlgebra.BilinearForm.Orthogonal
#align_import linear_algebra.quadratic_form.basic from "leanprover-community/mathlib"@"d11f435d4e34a6cea0a1797d6b625b0c170be845"
@@ -45,7 +44,7 @@ and composition with linear maps `f`, `Q.comp f x = Q (f x)`.
* `QuadraticForm.associated_rightInverse`: in a commutative ring where 2 has
an inverse, there is a correspondence between quadratic forms and symmetric
bilinear forms
- * `BilinForm.exists_orthogonal_basis`: There exists an orthogonal basis with
+ * `LinearMap.BilinForm.exists_orthogonal_basis`: There exists an orthogonal basis with
respect to any nondegenerate, symmetric bilinear form `B`.
## Notation
@@ -83,6 +82,8 @@ variable {R : Type*} {M N : Type*}
open BigOperators
+open LinearMap (BilinForm)
+
section Polar
variable [CommRing R] [AddCommGroup M]
@@ -143,7 +144,7 @@ structure QuadraticForm (R : Type u) (M : Type v) [CommSemiring R] [AddCommMonoi
toFun : M → R
toFun_smul : ∀ (a : R) (x : M), toFun (a • x) = a * a * toFun x
exists_companion' :
- ∃ B : LinearMap.BilinForm R M, ∀ x y, toFun (x + y) = toFun x + toFun y + B x y
+ ∃ B : BilinForm R M, ∀ x y, toFun (x + y) = toFun x + toFun y + B x y
#align quadratic_form QuadraticForm
namespace QuadraticForm
@@ -219,7 +220,7 @@ theorem map_smul (a : R) (x : M) : Q (a • x) = a * a * Q x :=
Q.toFun_smul a x
#align quadratic_form.map_smul QuadraticForm.map_smul
-theorem exists_companion : ∃ B : LinearMap.BilinForm R M, ∀ x y, Q (x + y) = Q x + Q y + B x y :=
+theorem exists_companion : ∃ B : BilinForm R M, ∀ x y, Q (x + y) = Q x + Q y + B x y :=
Q.exists_companion'
#align quadratic_form.exists_companion QuadraticForm.exists_companion
@@ -323,21 +324,12 @@ theorem polar_self (x : M) : polar Q x x = 2 * Q x := by
norm_num
#align quadratic_form.polar_self QuadraticForm.polar_self
-/-- `QuadraticForm.polar` as a bilinear form -/
-@[simps]
-def polarBilin : BilinForm R M where
- bilin := polar Q
- bilin_add_left := polar_add_left Q
- bilin_smul_left := polar_smul_left Q
- bilin_add_right x y z := by simp_rw [polar_comm _ x, polar_add_left Q]
- bilin_smul_right r x y := by simp_rw [polar_comm _ x, polar_smul_left Q]
-#align quadratic_form.polar_bilin QuadraticForm.polarBilin
-
/-- `QuadraticForm.polar` as a bilinear map -/
@[simps!]
-def polarLinearMap₂ : LinearMap.BilinForm R M :=
+def polarBilin : BilinForm R M :=
LinearMap.mk₂ R (polar Q) (polar_add_left Q) (polar_smul_left Q) (polar_add_right Q)
(polar_smul_right Q)
+#align quadratic_form.polar_bilin QuadraticForm.polarBilin
variable [CommSemiring S] [Algebra S R] [Module S M] [IsScalarTower S R M]
@@ -368,9 +360,9 @@ def ofPolar (toFun : M → R) (toFun_smul : ∀ (a : R) (x : M), toFun (a • x)
#align quadratic_form.of_polar QuadraticForm.ofPolar
/-- In a ring the companion bilinear form is unique and equal to `QuadraticForm.polar`. -/
-theorem choose_exists_companion : Q.exists_companion.choose = polarLinearMap₂ Q :=
+theorem choose_exists_companion : Q.exists_companion.choose = polarBilin Q :=
LinearMap.ext₂ fun x y => by
- rw [polarLinearMap₂_apply_apply, polar, Q.exists_companion.choose_spec, sub_sub,
+ rw [polarBilin_apply_apply, polar, Q.exists_companion.choose_spec, sub_sub,
add_sub_cancel']
#align quadratic_form.some_exists_companion QuadraticForm.choose_exists_companion
@@ -656,6 +648,8 @@ forms to bilinear forms giving this identification is called the `associated`
quadratic form.
-/
+namespace LinearMap
+
namespace BilinForm
open QuadraticForm
@@ -665,27 +659,23 @@ section Semiring
variable [CommSemiring R] [AddCommMonoid M] [AddCommMonoid N] [Module R M] [Module R N]
/-- A bilinear map into `R` gives a quadratic form by applying the argument twice. -/
-def _root_.LinearMap.toQuadraticForm (B : LinearMap.BilinForm R M) : QuadraticForm R M where
+def toQuadraticForm (B : BilinForm R M) : QuadraticForm R M where
toFun x := B x x
toFun_smul a x := by
simp only [SMulHomClass.map_smul, LinearMap.smul_apply, smul_eq_mul, mul_assoc]
exists_companion' := ⟨B + B.flip,
fun x y => by simp only [map_add, LinearMap.add_apply, LinearMap.flip_apply]; abel⟩
+#align bilin_form.to_quadratic_form LinearMap.BilinForm.toQuadraticForm
variable {B : BilinForm R M}
-/-- A bilinear form gives a quadratic form by applying the argument twice. -/
-def toQuadraticForm (B : BilinForm R M) : QuadraticForm R M :=
- B.toLin.toQuadraticForm
-#align bilin_form.to_quadratic_form BilinForm.toQuadraticForm
-
@[simp]
theorem toQuadraticForm_apply (B : BilinForm R M) (x : M) : B.toQuadraticForm x = B x x :=
rfl
-#align bilin_form.to_quadratic_form_apply BilinForm.toQuadraticForm_apply
+#align bilin_form.to_quadratic_form_apply LinearMap.BilinForm.toQuadraticForm_apply
theorem toQuadraticForm_comp_same (B : BilinForm R N) (f : M →ₗ[R] N) :
- (B.comp f f).toQuadraticForm = B.toQuadraticForm.comp f := rfl
+ BilinForm.toQuadraticForm (B.compl₁₂ f f) = B.toQuadraticForm.comp f := rfl
section
@@ -694,7 +684,7 @@ variable (R M)
@[simp]
theorem toQuadraticForm_zero : (0 : BilinForm R M).toQuadraticForm = 0 :=
rfl
-#align bilin_form.to_quadratic_form_zero BilinForm.toQuadraticForm_zero
+#align bilin_form.to_quadratic_form_zero LinearMap.BilinForm.toQuadraticForm_zero
end
@@ -702,30 +692,31 @@ end
theorem toQuadraticForm_add (B₁ B₂ : BilinForm R M) :
(B₁ + B₂).toQuadraticForm = B₁.toQuadraticForm + B₂.toQuadraticForm :=
rfl
-#align bilin_form.to_quadratic_form_add BilinForm.toQuadraticForm_add
+#align bilin_form.to_quadratic_form_add LinearMap.BilinForm.toQuadraticForm_add
@[simp]
theorem toQuadraticForm_smul [Monoid S] [DistribMulAction S R] [SMulCommClass S R R]
(a : S) (B : BilinForm R M) :
+ letI := SMulCommClass.symm S R R
(a • B).toQuadraticForm = a • B.toQuadraticForm :=
rfl
-#align bilin_form.to_quadratic_form_smul BilinForm.toQuadraticForm_smul
+#align bilin_form.to_quadratic_form_smul LinearMap.BilinForm.toQuadraticForm_smul
section
variable (S R M)
-/-- `BilinForm.toQuadraticForm` as an additive homomorphism -/
+/-- `LinearMap.BilinForm.toQuadraticForm` as an additive homomorphism -/
@[simps]
def toQuadraticFormAddMonoidHom : BilinForm R M →+ QuadraticForm R M where
toFun := toQuadraticForm
map_zero' := toQuadraticForm_zero _ _
map_add' := toQuadraticForm_add
-#align bilin_form.to_quadratic_form_add_monoid_hom BilinForm.toQuadraticFormAddMonoidHom
+#align bilin_form.to_quadratic_form_add_monoid_hom LinearMap.BilinForm.toQuadraticFormAddMonoidHom
-/-- `BilinForm.toQuadraticForm` as a linear map -/
+/-- `LinearMap.BilinForm.toQuadraticForm` as a linear map -/
@[simps!]
-def toQuadraticFormLinearMap [Semiring S] [Module S R] [SMulCommClass S R R] :
+def toQuadraticFormLinearMap [Semiring S] [Module S R] [SMulCommClass S R R] [SMulCommClass R S R] :
BilinForm R M →ₗ[S] QuadraticForm R M where
toFun := toQuadraticForm
map_smul' := toQuadraticForm_smul
@@ -737,29 +728,31 @@ end
theorem toQuadraticForm_list_sum (B : List (BilinForm R M)) :
B.sum.toQuadraticForm = (B.map toQuadraticForm).sum :=
map_list_sum (toQuadraticFormAddMonoidHom R M) B
-#align bilin_form.to_quadratic_form_list_sum BilinForm.toQuadraticForm_list_sum
+#align bilin_form.to_quadratic_form_list_sum LinearMap.BilinForm.toQuadraticForm_list_sum
@[simp]
theorem toQuadraticForm_multiset_sum (B : Multiset (BilinForm R M)) :
B.sum.toQuadraticForm = (B.map toQuadraticForm).sum :=
map_multiset_sum (toQuadraticFormAddMonoidHom R M) B
-#align bilin_form.to_quadratic_form_multiset_sum BilinForm.toQuadraticForm_multiset_sum
+#align bilin_form.to_quadratic_form_multiset_sum LinearMap.BilinForm.toQuadraticForm_multiset_sum
@[simp]
theorem toQuadraticForm_sum {ι : Type*} (s : Finset ι) (B : ι → BilinForm R M) :
(∑ i in s, B i).toQuadraticForm = ∑ i in s, (B i).toQuadraticForm :=
map_sum (toQuadraticFormAddMonoidHom R M) B s
-#align bilin_form.to_quadratic_form_sum BilinForm.toQuadraticForm_sum
+#align bilin_form.to_quadratic_form_sum LinearMap.BilinForm.toQuadraticForm_sum
@[simp]
theorem toQuadraticForm_eq_zero {B : BilinForm R M} : B.toQuadraticForm = 0 ↔ B.IsAlt :=
QuadraticForm.ext_iff
-#align bilin_form.to_quadratic_form_eq_zero BilinForm.toQuadraticForm_eq_zero
+#align bilin_form.to_quadratic_form_eq_zero LinearMap.BilinForm.toQuadraticForm_eq_zero
end Semiring
section Ring
+open QuadraticForm
+
variable [CommRing R] [AddCommGroup M] [Module R M]
variable {B : BilinForm R M}
@@ -767,21 +760,21 @@ variable {B : BilinForm R M}
@[simp]
theorem toQuadraticForm_neg (B : BilinForm R M) : (-B).toQuadraticForm = -B.toQuadraticForm :=
rfl
-#align bilin_form.to_quadratic_form_neg BilinForm.toQuadraticForm_neg
+#align bilin_form.to_quadratic_form_neg LinearMap.BilinForm.toQuadraticForm_neg
@[simp]
theorem toQuadraticForm_sub (B₁ B₂ : BilinForm R M) :
(B₁ - B₂).toQuadraticForm = B₁.toQuadraticForm - B₂.toQuadraticForm :=
rfl
-#align bilin_form.to_quadratic_form_sub BilinForm.toQuadraticForm_sub
+#align bilin_form.to_quadratic_form_sub LinearMap.BilinForm.toQuadraticForm_sub
theorem polar_toQuadraticForm (x y : M) : polar (toQuadraticForm B) x y = B x y + B y x := by
- simp only [toQuadraticForm_apply, add_assoc, add_sub_cancel', add_right, polar, add_left_inj,
- add_neg_cancel_left, add_left, sub_eq_add_neg _ (B y y), add_comm (B y x) _]
-#align bilin_form.polar_to_quadratic_form BilinForm.polar_toQuadraticForm
+ simp only [toQuadraticForm_apply, add_assoc, add_sub_cancel', add_apply, polar, add_left_inj,
+ add_neg_cancel_left, map_add, sub_eq_add_neg _ (B y y), add_comm (B y x) _]
+#align bilin_form.polar_to_quadratic_form LinearMap.BilinForm.polar_toQuadraticForm
-theorem polarBilin_toQuadraticForm : polarBilin (toQuadraticForm B) = B + flip' B :=
- BilinForm.ext polar_toQuadraticForm
+theorem polarBilin_toQuadraticForm : polarBilin (toQuadraticForm B) = B + B.flip :=
+ ext₂ polar_toQuadraticForm
@[simp] theorem _root_.QuadraticForm.toQuadraticForm_polarBilin (Q : QuadraticForm R M) :
toQuadraticForm (polarBilin Q) = 2 • Q :=
@@ -796,24 +789,27 @@ variable [CommRing S] [Algebra S R] [Module S M] [IsScalarTower S R M]
variable [AddCommGroup N] [Module R N]
theorem _root_.QuadraticForm.polarBilin_comp (Q : QuadraticForm R N) (f : M →ₗ[R] N) :
- polarBilin (Q.comp f) = BilinForm.comp (polarBilin Q) f f :=
- BilinForm.ext fun x y => by simp [polar]
+ polarBilin (Q.comp f) = compl₁₂ (polarBilin Q) f f :=
+ ext₂ fun x y => by simp [polar]
-theorem _root_.LinearMap.compQuadraticForm_polar (f : R →ₗ[S] S) (Q : QuadraticForm R M) (x y : M) :
+theorem compQuadraticForm_polar (f : R →ₗ[S] S) (Q : QuadraticForm R M) (x y : M) :
polar (f.compQuadraticForm Q) x y = f (polar Q x y) := by
simp [polar]
-theorem _root_.LinearMap.compQuadraticForm_polarBilin (f : R →ₗ[S] S) (Q : QuadraticForm R M) :
- (f.compQuadraticForm Q).polarBilin = f.compBilinForm Q.polarBilin :=
- ext <| LinearMap.compQuadraticForm_polar _ _
+theorem compQuadraticForm_polarBilin (f : R →ₗ[S] S) (Q : QuadraticForm R M) :
+ (f.compQuadraticForm Q).polarBilin =
+ (Q.polarBilin.restrictScalars₁₂ S).compr₂ f :=
+ ext₂ <| compQuadraticForm_polar _ _
end Ring
end BilinForm
+end LinearMap
+
namespace QuadraticForm
-open BilinForm
+open LinearMap.BilinForm
section AssociatedHom
@@ -835,8 +831,8 @@ def associatedHom : QuadraticForm R M →ₗ[S] BilinForm R M :=
-- it behind to make a future refactor to a *correct* non-commutative version easier in future.
(⟨⅟2, Set.invOf_mem_center (Set.ofNat_mem_center _ _)⟩ : Submonoid.center R) •
{ toFun := polarBilin
- map_add' := fun _x _y => BilinForm.ext <| polar_add _ _
- map_smul' := fun _c _x => BilinForm.ext <| polar_smul _ _ }
+ map_add' := fun _x _y => LinearMap.ext₂ <| polar_add _ _
+ map_smul' := fun _c _x => LinearMap.ext₂ <| polar_smul _ _ }
#align quadratic_form.associated_hom QuadraticForm.associatedHom
variable (Q : QuadraticForm R M)
@@ -852,25 +848,27 @@ theorem associated_apply (x y : M) : associatedHom S Q x y = ⅟ 2 * (Q (x + y)
rw [← smul_mul_assoc, two_nsmul, invOf_two_add_invOf_two, one_mul, polar]
theorem associated_isSymm : (associatedHom S Q).IsSymm := fun x y => by
- simp only [associated_apply, add_comm, add_left_comm, sub_eq_add_neg, add_assoc]
+ simp only [associated_apply, sub_eq_add_neg, add_assoc, map_mul, RingHom.id_apply, map_add,
+ _root_.map_neg, add_comm, add_left_comm]
#align quadratic_form.associated_is_symm QuadraticForm.associated_isSymm
@[simp]
theorem associated_comp [AddCommGroup N] [Module R N] (f : N →ₗ[R] M) :
- associatedHom S (Q.comp f) = (associatedHom S Q).comp f f := by
+ associatedHom S (Q.comp f) = (associatedHom S Q).compl₁₂ f f := by
ext
- simp only [QuadraticForm.comp_apply, BilinForm.comp_apply, associated_apply, LinearMap.map_add]
+ simp only [associated_apply, comp_apply, map_add, LinearMap.compl₁₂_apply]
#align quadratic_form.associated_comp QuadraticForm.associated_comp
theorem associated_toQuadraticForm (B : BilinForm R M) (x y : M) :
associatedHom S B.toQuadraticForm x y = ⅟ 2 * (B x y + B y x) := by
- simp only [associated_apply, ← polar_toQuadraticForm, polar]
+ simp only [associated_apply, toQuadraticForm_apply, map_add, add_apply, ← polar_toQuadraticForm,
+ polar._eq_1]
#align quadratic_form.associated_to_quadratic_form QuadraticForm.associated_toQuadraticForm
theorem associated_left_inverse (h : B₁.IsSymm) : associatedHom S B₁.toQuadraticForm = B₁ :=
- BilinForm.ext fun x y => by
- rw [associated_toQuadraticForm, h.eq x y, ← two_mul, ← mul_assoc, invOf_mul_self,
- one_mul]
+ LinearMap.ext₂ fun x y => by
+ rw [associated_toQuadraticForm, ← h.eq, RingHom.id_apply, ← two_mul, ← mul_assoc,
+ invOf_mul_self, one_mul]
#align quadratic_form.associated_left_inverse QuadraticForm.associated_left_inverse
-- porting note: moved from below to golf the next theorem
@@ -886,7 +884,7 @@ theorem toQuadraticForm_associated : (associatedHom S Q).toQuadraticForm = Q :=
-- note: usually `rightInverse` lemmas are named the other way around, but this is consistent
-- with historical naming in this file.
theorem associated_rightInverse :
- Function.RightInverse (associatedHom S) (BilinForm.toQuadraticForm : _ → QuadraticForm R M) :=
+ Function.RightInverse (associatedHom S) (toQuadraticForm : _ → QuadraticForm R M) :=
fun Q => toQuadraticForm_associated S Q
#align quadratic_form.associated_right_inverse QuadraticForm.associated_rightInverse
@@ -898,7 +896,7 @@ abbrev associated' : QuadraticForm R M →ₗ[ℤ] BilinForm R M :=
/-- Symmetric bilinear forms can be lifted to quadratic forms -/
instance canLift :
- CanLift (BilinForm R M) (QuadraticForm R M) (associatedHom ℕ) BilinForm.IsSymm where
+ CanLift (BilinForm R M) (QuadraticForm R M) (associatedHom ℕ) LinearMap.IsSymm where
prf B hB := ⟨B.toQuadraticForm, associated_left_inverse _ hB⟩
#align quadratic_form.can_lift QuadraticForm.canLift
@@ -935,20 +933,21 @@ theorem coe_associatedHom :
⇑(associatedHom S : QuadraticForm R M →ₗ[S] BilinForm R M) = associated :=
rfl
+open LinearMap in
@[simp]
theorem associated_linMulLin (f g : M →ₗ[R] R) :
associated (R := R) (linMulLin f g) =
- ⅟ (2 : R) • (BilinForm.linMulLin f g + BilinForm.linMulLin g f) := by
+ ⅟ (2 : R) • ((mul R R).compl₁₂ f g + (mul R R).compl₁₂ g f) := by
ext
- simp only [smul_add, Algebra.id.smul_eq_mul, BilinForm.linMulLin_apply,
- QuadraticForm.linMulLin_apply, BilinForm.smul_apply, associated_apply, BilinForm.add_apply,
- LinearMap.map_add]
- ring
+ simp only [associated_apply, linMulLin_apply, map_add, smul_add, LinearMap.add_apply,
+ LinearMap.smul_apply, compl₁₂_apply, mul_apply', smul_eq_mul]
+ ring_nf
#align quadratic_form.associated_lin_mul_lin QuadraticForm.associated_linMulLin
+open LinearMap in
@[simp]
-lemma associated_sq : associated (R := R) sq = LinearMap.toBilin (LinearMap.mul R R) :=
- (associated_linMulLin (LinearMap.id) (LinearMap.id)).trans <|
+lemma associated_sq : associated (R := R) sq = mul R R :=
+ (associated_linMulLin (id) (id)).trans <|
by simp only [smul_add, invOf_two_smul_add_invOf_two_smul]; rfl
end Associated
@@ -981,13 +980,13 @@ theorem isOrtho_comm {x y : M} : IsOrtho Q x y ↔ IsOrtho Q y x := by simp_rw [
alias ⟨IsOrtho.symm, _⟩ := isOrtho_comm
-theorem _root_.BilinForm.toQuadraticForm_isOrtho [IsCancelAdd R]
+theorem _root_.LinearMap.BilinForm.toQuadraticForm_isOrtho [IsCancelAdd R]
[NoZeroDivisors R] [CharZero R] {B : BilinForm R M} {x y : M} (h : B.IsSymm):
B.toQuadraticForm.IsOrtho x y ↔ B.IsOrtho x y := by
letI : AddCancelMonoid R := { ‹IsCancelAdd R›, (inferInstanceAs <| AddCommMonoid R) with }
- simp_rw [isOrtho_def, BilinForm.isOrtho_def, toQuadraticForm_apply, bilin_add_left,
- bilin_add_right, add_comm _ (B y y), add_add_add_comm _ _ (B y y), add_comm (B y y)]
- rw [add_right_eq_self (a := B x x + B y y), h, add_self_eq_zero (R := R)]
+ simp_rw [isOrtho_def, LinearMap.isOrtho_def, toQuadraticForm_apply, map_add,
+ LinearMap.add_apply, add_comm _ (B y y), add_add_add_comm _ _ (B y y), add_comm (B y y)]
+ rw [add_right_eq_self (a := B x x + B y y), ← h, RingHom.id_apply, add_self_eq_zero]
end CommSemiring
@@ -996,7 +995,8 @@ variable [CommRing R] [AddCommGroup M] [Module R M] {Q : QuadraticForm R M}
@[simp]
theorem isOrtho_polarBilin {x y : M} : Q.polarBilin.IsOrtho x y ↔ IsOrtho Q x y := by
- simp_rw [isOrtho_def, BilinForm.isOrtho_def, polarBilin_apply, polar, sub_sub, sub_eq_zero]
+ simp_rw [isOrtho_def, LinearMap.isOrtho_def, polarBilin_apply_apply, polar, sub_sub,
+ sub_eq_zero]
theorem IsOrtho.polar_eq_zero {x y : M} (h : IsOrtho Q x y) : polar Q x y = 0 :=
isOrtho_polarBilin.mpr h
@@ -1004,7 +1004,7 @@ theorem IsOrtho.polar_eq_zero {x y : M} (h : IsOrtho Q x y) : polar Q x y = 0 :=
@[simp]
theorem associated_isOrtho [Invertible (2 : R)] {x y : M} :
Q.associated.IsOrtho x y ↔ Q.IsOrtho x y := by
- simp_rw [isOrtho_def, BilinForm.isOrtho_def, associated_apply, invOf_mul_eq_iff_eq_mul_left,
+ simp_rw [isOrtho_def, LinearMap.isOrtho_def, associated_apply, invOf_mul_eq_iff_eq_mul_left,
mul_zero, sub_sub, sub_eq_zero]
end CommRing
@@ -1039,13 +1039,13 @@ section Ring
variable [CommRing R] [AddCommGroup M] [Module R M]
/-- The associated bilinear form of an anisotropic quadratic form is nondegenerate. -/
-theorem nondegenerate_of_anisotropic [Invertible (2 : R)] (Q : QuadraticForm R M)
+theorem separatingLeft_of_anisotropic [Invertible (2 : R)] (Q : QuadraticForm R M)
(hB : Q.Anisotropic) :
-- Porting note: added implicit argument
- (QuadraticForm.associated' (R := R) Q).Nondegenerate := fun x hx ↦ hB _ <| by
+ (QuadraticForm.associated' (R := R) Q).SeparatingLeft := fun x hx ↦ hB _ <| by
rw [← hx x]
exact (associated_eq_self_apply _ _ x).symm
-#align quadratic_form.nondegenerate_of_anisotropic QuadraticForm.nondegenerate_of_anisotropic
+#align quadratic_form.nondegenerate_of_anisotropic QuadraticForm.separatingLeft_of_anisotropic
end Ring
@@ -1118,14 +1118,14 @@ variable [CommRing R] [AddCommMonoid M] [Module R M]
/-- `M.toQuadraticForm'` is the map `fun x ↦ col x * M * row x` as a quadratic form. -/
def Matrix.toQuadraticForm' (M : Matrix n n R) : QuadraticForm R (n → R) :=
- M.toBilin'.toQuadraticForm
+ LinearMap.BilinForm.toQuadraticForm (Matrix.toLinearMap₂' M)
#align matrix.to_quadratic_form' Matrix.toQuadraticForm'
variable [Invertible (2 : R)]
/-- A matrix representation of the quadratic form. -/
def QuadraticForm.toMatrix' (Q : QuadraticForm R (n → R)) : Matrix n n R :=
- BilinForm.toMatrix' (associated (R := R) Q)
+ LinearMap.toMatrix₂' (associated (R := R) Q)
#align quadratic_form.to_matrix' QuadraticForm.toMatrix'
open QuadraticForm
@@ -1137,8 +1137,8 @@ theorem QuadraticForm.toMatrix'_smul (a : R) (Q : QuadraticForm R (n → R)) :
theorem QuadraticForm.isSymm_toMatrix' (Q : QuadraticForm R (n → R)) : Q.toMatrix'.IsSymm := by
ext i j
- rw [toMatrix', Matrix.transpose_apply, BilinForm.toMatrix'_apply, BilinForm.toMatrix'_apply,
- associated_isSymm]
+ rw [toMatrix', Matrix.transpose_apply, LinearMap.toMatrix₂'_apply, LinearMap.toMatrix₂'_apply,
+ ← associated_isSymm, RingHom.id_apply, associated_apply]
#align quadratic_form.is_symm_to_matrix' QuadraticForm.isSymm_toMatrix'
end
@@ -1157,7 +1157,8 @@ open Matrix
theorem toMatrix'_comp (Q : QuadraticForm R (m → R)) (f : (n → R) →ₗ[R] m → R) :
(Q.comp f).toMatrix' = (LinearMap.toMatrix' f)ᵀ * Q.toMatrix' * (LinearMap.toMatrix' f) := by
ext
- simp only [QuadraticForm.associated_comp, BilinForm.toMatrix'_comp, toMatrix']
+ simp only [QuadraticForm.associated_comp, LinearMap.toMatrix₂'_compl₁₂, toMatrix']
+
#align quadratic_form.to_matrix'_comp QuadraticForm.toMatrix'_comp
section Discriminant
@@ -1187,16 +1188,20 @@ namespace QuadraticForm
end QuadraticForm
+namespace LinearMap
+
namespace BilinForm
section Semiring
variable [CommSemiring R] [AddCommMonoid M] [Module R M]
-/-- A bilinear form is nondegenerate if the quadratic form it is associated with is anisotropic. -/
-theorem nondegenerate_of_anisotropic {B : BilinForm R M} (hB : B.toQuadraticForm.Anisotropic) :
- B.Nondegenerate := fun x hx => hB _ (hx x)
-#align bilin_form.nondegenerate_of_anisotropic BilinForm.nondegenerate_of_anisotropic
+/--
+A bilinear form is separating left if the quadratic form it is associated with is anisotropic.
+-/
+theorem separatingLeft_of_anisotropic {B : BilinForm R M} (hB : B.toQuadraticForm.Anisotropic) :
+ B.SeparatingLeft := fun x hx => hB _ (hx x)
+#align bilin_form.nondegenerate_of_anisotropic LinearMap.BilinForm.separatingLeft_of_anisotropic
end Semiring
@@ -1205,12 +1210,12 @@ variable [CommRing R] [AddCommGroup M] [Module R M]
/-- 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 exists_bilinForm_self_ne_zero [htwo : Invertible (2 : R)] {B : BilinForm R M} (hB₁ : B ≠ 0)
- (hB₂ : B.IsSymm) : ∃ x, ¬B.IsOrtho x x := by
+theorem exists_bilinForm_self_ne_zero [htwo : Invertible (2 : R)] {B : BilinForm R M}
+ (hB₁ : B ≠ 0) (hB₂ : B.IsSymm) : ∃ x, ¬B.IsOrtho x x := by
lift B to QuadraticForm R M using hB₂ with Q
obtain ⟨x, hx⟩ := QuadraticForm.exists_quadraticForm_ne_zero hB₁
exact ⟨x, fun h => hx (Q.associated_eq_self_apply ℕ x ▸ h)⟩
-#align bilin_form.exists_bilin_form_self_ne_zero BilinForm.exists_bilinForm_self_ne_zero
+#align bilin_form.exists_bilin_form_self_ne_zero LinearMap.BilinForm.exists_bilinForm_self_ne_zero
open FiniteDimensional
@@ -1221,10 +1226,10 @@ variable [FiniteDimensional K 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`. -/
theorem exists_orthogonal_basis [hK : Invertible (2 : K)] {B : BilinForm K V} (hB₂ : B.IsSymm) :
- ∃ v : Basis (Fin (finrank K V)) K V, B.iIsOrtho v := by
+ ∃ v : Basis (Fin (finrank K V)) K V, B.IsOrthoᵢ v := by
induction' hd : finrank K V with d ih generalizing V
· simp_rw [Nat.zero_eq]
- exact ⟨basisOfFinrankZero hd, fun _ _ _ => zero_left _⟩
+ exact ⟨basisOfFinrankZero hd, fun _ _ _ => map_zero _⟩
haveI := finrank_pos_iff.1 (hd.symm ▸ Nat.succ_pos d : 0 < finrank K V)
-- either the bilinear form is trivial or we can pick a non-null `x`
obtain rfl | hB₁ := eq_or_ne B 0
@@ -1233,9 +1238,10 @@ theorem exists_orthogonal_basis [hK : Invertible (2 : K)] {B : BilinForm K V} (h
exact ⟨b, fun i j _ => rfl⟩
obtain ⟨x, hx⟩ := exists_bilinForm_self_ne_zero hB₁ hB₂
rw [← Submodule.finrank_add_eq_of_isCompl (isCompl_span_singleton_orthogonal hx).symm,
- finrank_span_singleton (ne_zero_of_not_isOrtho_self x hx)] at hd
- let B' := B.restrict (B.orthogonal <| K ∙ x)
- obtain ⟨v', hv₁⟩ := ih (hB₂.restrict _ : B'.IsSymm) (Nat.succ.inj hd)
+ finrank_span_singleton (ne_zero_of_map hx)] at hd
+ let B' := B.domRestrict₁₂ (Submodule.orthogonalBilin (K ∙ x) B )
+ (Submodule.orthogonalBilin (K ∙ x) B )
+ obtain ⟨v', hv₁⟩ := ih (hB₂.domRestrict _ : B'.IsSymm) (Nat.succ.inj hd)
-- concatenate `x` with the basis obtained by induction
let b :=
Basis.mkFinCons x v'
@@ -1246,30 +1252,32 @@ theorem exists_orthogonal_basis [hK : Invertible (2 : K)] {B : BilinForm K V} (h
have := (isCompl_span_singleton_orthogonal hx).disjoint
rw [Submodule.disjoint_def] at this
have := this (c • x) (Submodule.smul_mem _ _ <| Submodule.mem_span_singleton_self _) hy
- exact (smul_eq_zero.1 this).resolve_right fun h => hx <| h.symm ▸ zero_left _)
+ exact (smul_eq_zero.1 this).resolve_right fun h => hx <| h.symm ▸ map_zero _)
(by
intro y
refine' ⟨-B x y / B x x, fun z hz => _⟩
obtain ⟨c, rfl⟩ := Submodule.mem_span_singleton.1 hz
- rw [IsOrtho, smul_left, add_right, smul_right, div_mul_cancel _ hx, add_neg_self,
- mul_zero])
+ rw [IsOrtho, map_smul, smul_apply, map_add, map_smul, smul_eq_mul, smul_eq_mul,
+ div_mul_cancel _ hx, add_neg_self, mul_zero])
refine' ⟨b, _⟩
· rw [Basis.coe_mkFinCons]
intro j i
refine' Fin.cases _ (fun i => _) i <;> refine' Fin.cases _ (fun j => _) j <;> intro hij <;>
simp only [Function.onFun, Fin.cons_zero, Fin.cons_succ, Function.comp_apply]
· exact (hij rfl).elim
- · rw [IsOrtho, hB₂]
+ · rw [IsOrtho, ← hB₂]
exact (v' j).prop _ (Submodule.mem_span_singleton_self x)
· exact (v' i).prop _ (Submodule.mem_span_singleton_self x)
· exact hv₁ (ne_of_apply_ne _ hij)
-#align bilin_form.exists_orthogonal_basis BilinForm.exists_orthogonal_basis
+#align bilin_form.exists_orthogonal_basis LinearMap.BilinForm.exists_orthogonal_basis
end BilinForm
+end LinearMap
+
namespace QuadraticForm
-open Finset BilinForm
+open Finset
variable [CommSemiring R] [AddCommMonoid M] [Module R M]
@@ -1315,16 +1323,18 @@ theorem weightedSumSquares_apply [Monoid S] [DistribMulAction S R] [SMulCommClas
/-- On an orthogonal basis, the basis representation of `Q` is just a sum of squares. -/
theorem basisRepr_eq_of_iIsOrtho {R M} [CommRing R] [AddCommGroup M] [Module R M]
[Invertible (2 : R)] (Q : QuadraticForm R M) (v : Basis ι R M)
- (hv₂ : (associated (R := R) Q).iIsOrtho v) :
+ (hv₂ : (associated (R := R) Q).IsOrthoᵢ v) :
Q.basisRepr v = weightedSumSquares _ fun i => Q (v i) := by
ext w
- rw [basisRepr_apply, ← @associated_eq_self_apply R, sum_left, weightedSumSquares_apply]
+ rw [basisRepr_apply, ← @associated_eq_self_apply R, map_sum, weightedSumSquares_apply]
refine' sum_congr rfl fun j hj => _
- rw [← @associated_eq_self_apply R, sum_right, sum_eq_single_of_mem j hj]
- · rw [smul_left, smul_right, smul_eq_mul]
+ rw [← @associated_eq_self_apply R, LinearMap.map_sum₂, sum_eq_single_of_mem j hj]
+ · rw [LinearMap.map_smul, LinearMap.map_smul₂, smul_eq_mul, associated_apply, smul_eq_mul,
+ smul_eq_mul]
ring
· intro i _ hij
- rw [smul_left, smul_right, show associatedHom R Q (v j) (v i) = 0 from hv₂ hij.symm,
+ rw [LinearMap.map_smul, LinearMap.map_smul₂,
+ show associatedHom R Q (v i) (v j) = 0 from hv₂ hij, smul_eq_mul, smul_eq_mul,
mul_zero, mul_zero]
set_option linter.uppercaseLean3 false in
#align quadratic_form.basis_repr_eq_of_is_Ortho QuadraticForm.basisRepr_eq_of_iIsOrtho
refine
s (#10762)
I replaced a few "terminal" refine/refine'
s with exact
.
The strategy was very simple-minded: essentially any refine
whose following line had smaller indentation got replaced by exact
and then I cleaned up the mess.
This PR certainly leaves some further terminal refine
s, but maybe the current change is beneficial.
@@ -1230,7 +1230,7 @@ theorem exists_orthogonal_basis [hK : Invertible (2 : K)] {B : BilinForm K V} (h
obtain rfl | hB₁ := eq_or_ne B 0
· let b := FiniteDimensional.finBasis K V
rw [hd] at b
- refine' ⟨b, fun i j _ => rfl⟩
+ exact ⟨b, fun i j _ => rfl⟩
obtain ⟨x, hx⟩ := exists_bilinForm_self_ne_zero hB₁ hB₂
rw [← Submodule.finrank_add_eq_of_isCompl (isCompl_span_singleton_orthogonal hx).symm,
finrank_span_singleton (ne_zero_of_not_isOrtho_self x hx)] at hd
Turns out that this follows trivially from the previous counterexample.
Perhaps there's a slicker proof that doesn't go via Clifford algebras at all, but it seemed worth recording this one anyway.
@@ -79,7 +79,7 @@ universe u v w
variable {S T : Type*}
-variable {R : Type*} {M : Type*}
+variable {R : Type*} {M N : Type*}
open BigOperators
@@ -555,7 +555,7 @@ section Comp
variable [CommSemiring R] [AddCommMonoid M] [Module R M]
-variable {N : Type v} [AddCommMonoid N] [Module R N]
+variable [AddCommMonoid N] [Module R N]
/-- Compose the quadratic form with a linear function. -/
def comp (Q : QuadraticForm R N) (f : M →ₗ[R] N) : QuadraticForm R M where
@@ -617,7 +617,7 @@ theorem linMulLin_add (f g h : M →ₗ[R] R) : linMulLin f (g + h) = linMulLin
ext fun _ => mul_add _ _ _
#align quadratic_form.lin_mul_lin_add QuadraticForm.linMulLin_add
-variable {N : Type v} [AddCommMonoid N] [Module R N]
+variable [AddCommMonoid N] [Module R N]
@[simp]
theorem linMulLin_comp (f g : M →ₗ[R] R) (h : N →ₗ[R] M) :
@@ -662,7 +662,7 @@ open QuadraticForm
section Semiring
-variable [CommSemiring R] [AddCommMonoid M] [Module R M]
+variable [CommSemiring R] [AddCommMonoid M] [AddCommMonoid N] [Module R M] [Module R N]
/-- A bilinear map into `R` gives a quadratic form by applying the argument twice. -/
def _root_.LinearMap.toQuadraticForm (B : LinearMap.BilinForm R M) : QuadraticForm R M where
@@ -684,6 +684,9 @@ theorem toQuadraticForm_apply (B : BilinForm R M) (x : M) : B.toQuadraticForm x
rfl
#align bilin_form.to_quadratic_form_apply BilinForm.toQuadraticForm_apply
+theorem toQuadraticForm_comp_same (B : BilinForm R N) (f : M →ₗ[R] N) :
+ (B.comp f f).toQuadraticForm = B.toQuadraticForm.comp f := rfl
+
section
variable (R M)
@@ -789,7 +792,6 @@ theorem _root_.QuadraticForm.polarBilin_injective (h : IsUnit (2 : R)) :
fun Q₁ Q₂ h₁₂ => QuadraticForm.ext fun x => h.mul_left_cancel <| by
simpa using DFunLike.congr_fun (congr_arg toQuadraticForm h₁₂) x
-variable {N : Type v}
variable [CommRing S] [Algebra S R] [Module S M] [IsScalarTower S R M]
variable [AddCommGroup N] [Module R N]
@@ -854,7 +856,7 @@ theorem associated_isSymm : (associatedHom S Q).IsSymm := fun x y => by
#align quadratic_form.associated_is_symm QuadraticForm.associated_isSymm
@[simp]
-theorem associated_comp {N : Type v} [AddCommGroup N] [Module R N] (f : N →ₗ[R] M) :
+theorem associated_comp [AddCommGroup N] [Module R N] (f : N →ₗ[R] M) :
associatedHom S (Q.comp f) = (associatedHom S Q).comp f f := by
ext
simp only [QuadraticForm.comp_apply, BilinForm.comp_apply, associated_apply, LinearMap.map_add]
LinearMap.BilinForm
alias (#10632)
This is one of the steps in #10553.
Once we eliminate _root_.BilinForm
, we can drop the LinearMap.
prefix.
Requested on Zulip by me (2021), [by @kmill](https://leanprover.zulipchat.com/#narrow/stream/116395-maths/topic/.60bilinear_form.60/near/310675731) (2022), and perhaps one or two other places.
Co-authored-by: Christopher Hoskin <christopher.hoskin@gmail.com>
@@ -142,7 +142,8 @@ structure QuadraticForm (R : Type u) (M : Type v) [CommSemiring R] [AddCommMonoi
where
toFun : M → R
toFun_smul : ∀ (a : R) (x : M), toFun (a • x) = a * a * toFun x
- exists_companion' : ∃ B : M →ₗ[R] M →ₗ[R] R, ∀ x y, toFun (x + y) = toFun x + toFun y + B x y
+ exists_companion' :
+ ∃ B : LinearMap.BilinForm R M, ∀ x y, toFun (x + y) = toFun x + toFun y + B x y
#align quadratic_form QuadraticForm
namespace QuadraticForm
@@ -218,7 +219,7 @@ theorem map_smul (a : R) (x : M) : Q (a • x) = a * a * Q x :=
Q.toFun_smul a x
#align quadratic_form.map_smul QuadraticForm.map_smul
-theorem exists_companion : ∃ B : M →ₗ[R] M →ₗ[R] R, ∀ x y, Q (x + y) = Q x + Q y + B x y :=
+theorem exists_companion : ∃ B : LinearMap.BilinForm R M, ∀ x y, Q (x + y) = Q x + Q y + B x y :=
Q.exists_companion'
#align quadratic_form.exists_companion QuadraticForm.exists_companion
@@ -334,7 +335,7 @@ def polarBilin : BilinForm R M where
/-- `QuadraticForm.polar` as a bilinear map -/
@[simps!]
-def polarLinearMap₂ : M →ₗ[R] M →ₗ[R] R :=
+def polarLinearMap₂ : LinearMap.BilinForm R M :=
LinearMap.mk₂ R (polar Q) (polar_add_left Q) (polar_smul_left Q) (polar_add_right Q)
(polar_smul_right Q)
@@ -664,7 +665,7 @@ section Semiring
variable [CommSemiring R] [AddCommMonoid M] [Module R M]
/-- A bilinear map into `R` gives a quadratic form by applying the argument twice. -/
-def _root_.LinearMap.toQuadraticForm (B : M →ₗ[R] M →ₗ[R] R) : QuadraticForm R M where
+def _root_.LinearMap.toQuadraticForm (B : LinearMap.BilinForm R M) : QuadraticForm R M where
toFun x := B x x
toFun_smul a x := by
simp only [SMulHomClass.map_smul, LinearMap.smul_apply, smul_eq_mul, mul_assoc]
@@ -1270,20 +1270,23 @@ open Finset BilinForm
variable [CommSemiring R] [AddCommMonoid M] [Module R M]
-variable {ι : Type*} [Fintype ι] {v : Basis ι R M}
+variable {ι : Type*}
/-- Given a quadratic form `Q` and a basis, `basisRepr` is the basis representation of `Q`. -/
-noncomputable def basisRepr (Q : QuadraticForm R M) (v : Basis ι R M) : QuadraticForm R (ι → R) :=
+noncomputable def basisRepr [Finite ι] (Q : QuadraticForm R M) (v : Basis ι R M) :
+ QuadraticForm R (ι → R) :=
Q.comp v.equivFun.symm
#align quadratic_form.basis_repr QuadraticForm.basisRepr
@[simp]
-theorem basisRepr_apply (Q : QuadraticForm R M) (w : ι → R) :
+theorem basisRepr_apply [Fintype ι] {v : Basis ι R M} (Q : QuadraticForm R M) (w : ι → R) :
Q.basisRepr v w = Q (∑ i : ι, w i • v i) := by
rw [← v.equivFun_symm_apply]
rfl
#align quadratic_form.basis_repr_apply QuadraticForm.basisRepr_apply
+variable [Fintype ι] {v : Basis ι R M}
+
section
variable (R)
@@ -382,7 +382,7 @@ variable [CommSemiring R] [AddCommMonoid M] [Module R M]
section SMul
variable [Monoid S] [Monoid T] [DistribMulAction S R] [DistribMulAction T R]
-variable [SMulCommClass R S R] [SMulCommClass S R R] [SMulCommClass T R R] [SMulCommClass R T R]
+variable [SMulCommClass S R R] [SMulCommClass T R R]
/-- `QuadraticForm R M` inherits the scalar action from any algebra over `R`.
@@ -393,6 +393,7 @@ instance : SMul S (QuadraticForm R M) :=
toFun_smul := fun b x => by rw [Pi.smul_apply, map_smul, Pi.smul_apply, mul_smul_comm]
exists_companion' :=
let ⟨B, h⟩ := Q.exists_companion
+ letI := SMulCommClass.symm S R R
⟨a • B, by simp [h]⟩ }⟩
@[simp]
@@ -486,7 +487,7 @@ theorem sum_apply {ι : Type*} (Q : ι → QuadraticForm R M) (s : Finset ι) (x
end Sum
-instance [Monoid S] [DistribMulAction S R] [SMulCommClass S R R] [SMulCommClass R S R] :
+instance [Monoid S] [DistribMulAction S R] [SMulCommClass S R R] :
DistribMulAction S (QuadraticForm R M) where
mul_smul a b Q := ext fun x => by simp only [smul_apply, mul_smul]
one_smul Q := ext fun x => by simp only [QuadraticForm.smul_apply, one_smul]
@@ -497,7 +498,7 @@ instance [Monoid S] [DistribMulAction S R] [SMulCommClass S R R] [SMulCommClass
ext
simp only [zero_apply, smul_apply, smul_zero]
-instance [Semiring S] [Module S R] [SMulCommClass S R R] [SMulCommClass R S R] :
+instance [Semiring S] [Module S R] [SMulCommClass S R R] :
Module S (QuadraticForm R M) where
zero_smul Q := by
ext
@@ -577,9 +578,8 @@ def _root_.LinearMap.compQuadraticForm [CommSemiring S] [Algebra S R] [Module S
toFun_smul b x := by simp only [Q.map_smul_of_tower b x, f.map_smul, smul_eq_mul]
exists_companion' :=
let ⟨B, h⟩ := Q.exists_companion
- ⟨(LinearMap.restrictScalars S (LinearMap.restrictScalars S B.flip).flip).compr₂ f, fun x y => by
- simp_rw [h, f.map_add]
- rfl⟩
+ ⟨(B.restrictScalars₁₂ S).compr₂ f, fun x y => by
+ simp_rw [h, f.map_add, LinearMap.compr₂_apply, LinearMap.restrictScalars₁₂_apply_apply]⟩
#align linear_map.comp_quadratic_form LinearMap.compQuadraticForm
end Comp
@@ -595,9 +595,9 @@ def linMulLin (f g : M →ₗ[R] R) : QuadraticForm R M where
simp only [smul_eq_mul, RingHom.id_apply, Pi.mul_apply, LinearMap.map_smulₛₗ]
ring
exists_companion' :=
- ⟨LinearMap.linMulLin f g + LinearMap.linMulLin g f, fun x y => by
- simp only [Pi.mul_apply, map_add, LinearMap.linMulLin, LinearMap.add_apply,
- LinearMap.mk₂_apply]
+ ⟨(LinearMap.mul R R).compl₁₂ f g + (LinearMap.mul R R).compl₁₂ g f, fun x y => by
+ simp only [Pi.mul_apply, map_add, LinearMap.compl₁₂_apply, LinearMap.mul_apply',
+ LinearMap.add_apply]
ring_nf⟩
#align quadratic_form.lin_mul_lin QuadraticForm.linMulLin
@@ -664,7 +664,7 @@ section Semiring
variable [CommSemiring R] [AddCommMonoid M] [Module R M]
/-- A bilinear map into `R` gives a quadratic form by applying the argument twice. -/
-def _root_.LinearMap.toQuadraticForm (B: M →ₗ[R] M →ₗ[R] R) : QuadraticForm R M where
+def _root_.LinearMap.toQuadraticForm (B : M →ₗ[R] M →ₗ[R] R) : QuadraticForm R M where
toFun x := B x x
toFun_smul a x := by
simp only [SMulHomClass.map_smul, LinearMap.smul_apply, smul_eq_mul, mul_assoc]
@@ -702,7 +702,7 @@ theorem toQuadraticForm_add (B₁ B₂ : BilinForm R M) :
@[simp]
theorem toQuadraticForm_smul [Monoid S] [DistribMulAction S R] [SMulCommClass S R R]
- [SMulCommClass R S R] (a : S) (B : BilinForm R M) :
+ (a : S) (B : BilinForm R M) :
(a • B).toQuadraticForm = a • B.toQuadraticForm :=
rfl
#align bilin_form.to_quadratic_form_smul BilinForm.toQuadraticForm_smul
@@ -721,7 +721,7 @@ def toQuadraticFormAddMonoidHom : BilinForm R M →+ QuadraticForm R M where
/-- `BilinForm.toQuadraticForm` as a linear map -/
@[simps!]
-def toQuadraticFormLinearMap [Semiring S] [Module S R] [SMulCommClass S R R] [SMulCommClass R S R] :
+def toQuadraticFormLinearMap [Semiring S] [Module S R] [SMulCommClass S R R] :
BilinForm R M →ₗ[S] QuadraticForm R M where
toFun := toQuadraticForm
map_smul' := toQuadraticForm_smul
@@ -1292,8 +1292,8 @@ variable (R)
The weights are applied using `•`; typically this definition is used either with `S = R` or
`[Algebra S R]`, although this is stated more generally. -/
-def weightedSumSquares [Monoid S] [DistribMulAction S R] [SMulCommClass S R R] [SMulCommClass R S R]
- (w : ι → S) : QuadraticForm R (ι → R) :=
+def weightedSumSquares [Monoid S] [DistribMulAction S R] [SMulCommClass S R R] (w : ι → S) :
+ QuadraticForm R (ι → R) :=
∑ i : ι, w i • proj i i
#align quadratic_form.weighted_sum_squares QuadraticForm.weightedSumSquares
@@ -1301,7 +1301,7 @@ end
@[simp]
theorem weightedSumSquares_apply [Monoid S] [DistribMulAction S R] [SMulCommClass S R R]
- [SMulCommClass R S R] (w : ι → S) (v : ι → R) :
+ (w : ι → S) (v : ι → R) :
weightedSumSquares R w v = ∑ i : ι, w i • (v i * v i) :=
QuadraticForm.sum_apply _ _ _
#align quadratic_form.weighted_sum_squares_apply QuadraticForm.weightedSumSquares_apply
The FunLike hierarchy is very big and gets scanned through each time we need a coercion (via the CoeFun
instance). It looks like unbundled inheritance suits Lean 4 better here. The only class that still extends FunLike
is EquivLike
, since that has a custom coe_injective'
field that is easier to implement. All other classes should take FunLike
or EquivLike
as a parameter.
Previously, morphism classes would be Type
-valued and extend FunLike
:
/-- `MyHomClass F A B` states that `F` is a type of `MyClass.op`-preserving morphisms.
You should extend this class when you extend `MyHom`. -/
class MyHomClass (F : Type*) (A B : outParam <| Type*) [MyClass A] [MyClass B]
extends FunLike F A B :=
(map_op : ∀ (f : F) (x y : A), f (MyClass.op x y) = MyClass.op (f x) (f y))
After this PR, they should be Prop
-valued and take FunLike
as a parameter:
/-- `MyHomClass F A B` states that `F` is a type of `MyClass.op`-preserving morphisms.
You should extend this class when you extend `MyHom`. -/
class MyHomClass (F : Type*) (A B : outParam <| Type*) [MyClass A] [MyClass B]
[FunLike F A B] : Prop :=
(map_op : ∀ (f : F) (x y : A), f (MyClass.op x y) = MyClass.op (f x) (f y))
(Note that A B
stay marked as outParam
even though they are not purely required to be so due to the FunLike
parameter already filling them in. This is required to see through type synonyms, which is important in the category theory library. Also, I think keeping them as outParam
is slightly faster.)
Similarly, MyEquivClass
should take EquivLike
as a parameter.
As a result, every mention of [MyHomClass F A B]
should become [FunLike F A B] [MyHomClass F A B]
.
While overall this gives some great speedups, there are some cases that are noticeably slower. In particular, a failing application of a lemma such as map_mul
is more expensive. This is due to suboptimal processing of arguments. For example:
variable [FunLike F M N] [Mul M] [Mul N] (f : F) (x : M) (y : M)
theorem map_mul [MulHomClass F M N] : f (x * y) = f x * f y
example [AddHomClass F A B] : f (x * y) = f x * f y := map_mul f _ _
Before this PR, applying map_mul f
gives the goals [Mul ?M] [Mul ?N] [MulHomClass F ?M ?N]
. Since M
and N
are out_param
s, [MulHomClass F ?M ?N]
is synthesized first, supplies values for ?M
and ?N
and then the Mul M
and Mul N
instances can be found.
After this PR, the goals become [FunLike F ?M ?N] [Mul ?M] [Mul ?N] [MulHomClass F ?M ?N]
. Now [FunLike F ?M ?N]
is synthesized first, supplies values for ?M
and ?N
and then the Mul M
and Mul N
instances can be found, before trying MulHomClass F M N
which fails. Since the Mul
hierarchy is very big, this can be slow to fail, especially when there is no such Mul
instance.
A long-term but harder to achieve solution would be to specify the order in which instance goals get solved. For example, we'd like to change the arguments to map_mul
to look like [FunLike F M N] [Mul M] [Mul N] [highPriority <| MulHomClass F M N]
because MulHomClass
fails or succeeds much faster than the others.
As a consequence, the simpNF
linter is much slower since by design it tries and fails to apply many map_
lemmas. The same issue occurs a few times in existing calls to simp [map_mul]
, where map_mul
is tried "too soon" and fails. Thanks to the speedup of leanprover/lean4#2478 the impact is very limited, only in files that already were close to the timeout.
simp
not firing sometimesThis affects map_smulₛₗ
and related definitions. For simp
lemmas Lean apparently uses a slightly different mechanism to find instances, so that rw
can find every argument to map_smulₛₗ
successfully but simp
can't: leanprover/lean4#3701.
Especially in the category theory library, we might sometimes have a type A
which is also accessible as a synonym (Bundled A hA).1
. Instance synthesis doesn't always work if we have f : A →* B
but x * y : (Bundled A hA).1
or vice versa. This seems to be mostly fixed by keeping A B
as outParam
s in MulHomClass F A B
. (Presumably because Lean will do a definitional check A =?= (Bundled A hA).1
instead of using the syntax in the discrimination tree.)
The timeouts can be worked around for now by specifying which map_mul
we mean, either as map_mul f
for some explicit f
, or as e.g. MonoidHomClass.map_mul
.
map_smulₛₗ
not firing as simp
lemma can be worked around by going back to the pre-FunLike situation and making LinearMap.map_smulₛₗ
a simp
lemma instead of the generic map_smulₛₗ
. Writing simp [map_smulₛₗ _]
also works.
Co-authored-by: Matthew Ballard <matt@mrb.email> Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Scott Morrison <scott@tqft.net> Co-authored-by: Anne Baanen <Vierkantor@users.noreply.github.com>
@@ -125,7 +125,7 @@ theorem polar_add_left_iff {f : M → R} {x x' y : M} :
add_right_comm (f (x + y)), add_left_inj]
#align quadratic_form.polar_add_left_iff QuadraticForm.polar_add_left_iff
-theorem polar_comp {F : Type*} [CommRing S] [AddMonoidHomClass F R S]
+theorem polar_comp {F : Type*} [CommRing S] [FunLike F R S] [AddMonoidHomClass F R S]
(f : M → R) (g : F) (x y : M) :
polar (g ∘ f) x y = g (polar f x y) := by
simp only [polar, Pi.smul_apply, Function.comp_apply, map_sub]
@@ -240,8 +240,8 @@ theorem map_zero : Q 0 = 0 := by
rw [← @zero_smul R _ _ _ _ (0 : M), map_smul, zero_mul, zero_mul]
#align quadratic_form.map_zero QuadraticForm.map_zero
-instance zeroHomClass : ZeroHomClass (QuadraticForm R M) M R :=
- { QuadraticForm.instFunLike with map_zero := map_zero }
+instance zeroHomClass : ZeroHomClass (QuadraticForm R M) M R where
+ map_zero := map_zero
#align quadratic_form.zero_hom_class QuadraticForm.zeroHomClass
theorem map_smul_of_tower [CommSemiring S] [Algebra S R] [Module S M] [IsScalarTower S R M] (a : S)
This PR replaces the companion (B : BilinForm R M)
of a quadratic form with a bilinear map (B : M →ₗ[R] M →ₗ[R] R)
.
This is intended as a baby step towards generalising quadratic forms to quadratic maps. In the future we could allow for companion bilinear or even sesquilinear maps into an R
-module.
Co-authored-by: Christopher Hoskin <mans0954@users.noreply.github.com> Co-authored-by: Christopher Hoskin <christopher.hoskin@overleaf.com>
@@ -142,7 +142,7 @@ structure QuadraticForm (R : Type u) (M : Type v) [CommSemiring R] [AddCommMonoi
where
toFun : M → R
toFun_smul : ∀ (a : R) (x : M), toFun (a • x) = a * a * toFun x
- exists_companion' : ∃ B : BilinForm R M, ∀ x y, toFun (x + y) = toFun x + toFun y + B x y
+ exists_companion' : ∃ B : M →ₗ[R] M →ₗ[R] R, ∀ x y, toFun (x + y) = toFun x + toFun y + B x y
#align quadratic_form QuadraticForm
namespace QuadraticForm
@@ -218,7 +218,7 @@ theorem map_smul (a : R) (x : M) : Q (a • x) = a * a * Q x :=
Q.toFun_smul a x
#align quadratic_form.map_smul QuadraticForm.map_smul
-theorem exists_companion : ∃ B : BilinForm R M, ∀ x y, Q (x + y) = Q x + Q y + B x y :=
+theorem exists_companion : ∃ B : M →ₗ[R] M →ₗ[R] R, ∀ x y, Q (x + y) = Q x + Q y + B x y :=
Q.exists_companion'
#align quadratic_form.exists_companion QuadraticForm.exists_companion
@@ -226,7 +226,7 @@ theorem map_add_add_add_map (x y z : M) :
Q (x + y + z) + (Q x + Q y + Q z) = Q (x + y) + Q (y + z) + Q (z + x) := by
obtain ⟨B, h⟩ := Q.exists_companion
rw [add_comm z x]
- simp only [h, BilinForm.add_left]
+ simp only [h, map_add, LinearMap.add_apply]
abel
#align quadratic_form.map_add_add_add_map QuadraticForm.map_add_add_add_map
@@ -278,7 +278,7 @@ theorem polar_add_left (x x' y : M) : polar Q (x + x') y = polar Q x y + polar Q
@[simp]
theorem polar_smul_left (a : R) (x y : M) : polar Q (a • x) y = a * polar Q x y := by
obtain ⟨B, h⟩ := Q.exists_companion
- simp_rw [polar, h, Q.map_smul, BilinForm.smul_left, sub_sub, add_sub_cancel']
+ simp_rw [polar, h, Q.map_smul, LinearMap.map_smul₂, sub_sub, add_sub_cancel', smul_eq_mul]
#align quadratic_form.polar_smul_left QuadraticForm.polar_smul_left
@[simp]
@@ -332,6 +332,12 @@ def polarBilin : BilinForm R M where
bilin_smul_right r x y := by simp_rw [polar_comm _ x, polar_smul_left Q]
#align quadratic_form.polar_bilin QuadraticForm.polarBilin
+/-- `QuadraticForm.polar` as a bilinear map -/
+@[simps!]
+def polarLinearMap₂ : M →ₗ[R] M →ₗ[R] R :=
+ LinearMap.mk₂ R (polar Q) (polar_add_left Q) (polar_smul_left Q) (polar_add_right Q)
+ (polar_smul_right Q)
+
variable [CommSemiring S] [Algebra S R] [Module S M] [IsScalarTower S R M]
@[simp]
@@ -352,20 +358,19 @@ def ofPolar (toFun : M → R) (toFun_smul : ∀ (a : R) (x : M), toFun (a • x)
QuadraticForm R M :=
{ toFun
toFun_smul
- exists_companion' :=
- ⟨{ bilin := polar toFun
- bilin_add_left := polar_add_left
- bilin_smul_left := polar_smul_left
- bilin_add_right := fun x y z => by simp_rw [polar_comm _ x, polar_add_left]
- bilin_smul_right := fun r x y => by
- simp_rw [polar_comm _ x, polar_smul_left, smul_eq_mul] },
- fun x y => by rw [BilinForm.coeFn_mk, polar, sub_sub, add_sub_cancel'_right]⟩ }
+ exists_companion' := ⟨LinearMap.mk₂ R (polar toFun) (polar_add_left) (polar_smul_left)
+ (fun x _ _ => by simp_rw [polar_comm _ x, polar_add_left])
+ (fun _ _ _ => by rw [polar_comm, polar_smul_left, polar_comm]),
+ fun _ _ => by
+ simp only [LinearMap.mk₂_apply]
+ rw [polar, sub_sub, add_sub_cancel'_right]⟩ }
#align quadratic_form.of_polar QuadraticForm.ofPolar
/-- In a ring the companion bilinear form is unique and equal to `QuadraticForm.polar`. -/
-theorem choose_exists_companion : Q.exists_companion.choose = polarBilin Q :=
- BilinForm.ext fun x y => by
- rw [polarBilin_apply, polar, Q.exists_companion.choose_spec, sub_sub, add_sub_cancel']
+theorem choose_exists_companion : Q.exists_companion.choose = polarLinearMap₂ Q :=
+ LinearMap.ext₂ fun x y => by
+ rw [polarLinearMap₂_apply_apply, polar, Q.exists_companion.choose_spec, sub_sub,
+ add_sub_cancel']
#align quadratic_form.some_exists_companion QuadraticForm.choose_exists_companion
end CommRing
@@ -377,7 +382,7 @@ variable [CommSemiring R] [AddCommMonoid M] [Module R M]
section SMul
variable [Monoid S] [Monoid T] [DistribMulAction S R] [DistribMulAction T R]
-variable [SMulCommClass S R R] [SMulCommClass T R R]
+variable [SMulCommClass R S R] [SMulCommClass S R R] [SMulCommClass T R R] [SMulCommClass R T R]
/-- `QuadraticForm R M` inherits the scalar action from any algebra over `R`.
@@ -411,7 +416,7 @@ end SMul
instance : Zero (QuadraticForm R M) :=
⟨{ toFun := fun _ => 0
toFun_smul := fun a _ => by simp only [mul_zero]
- exists_companion' := ⟨0, fun _ _ => by simp only [add_zero, BilinForm.zero_apply]⟩ }⟩
+ exists_companion' := ⟨0, fun _ _ => by simp only [add_zero, LinearMap.zero_apply]⟩ }⟩
@[simp]
theorem coeFn_zero : ⇑(0 : QuadraticForm R M) = 0 :=
@@ -434,7 +439,7 @@ instance : Add (QuadraticForm R M) :=
let ⟨B, h⟩ := Q.exists_companion
let ⟨B', h'⟩ := Q'.exists_companion
⟨B + B', fun x y => by
- simp_rw [Pi.add_apply, h, h', BilinForm.add_apply, add_add_add_comm]⟩ }⟩
+ simp_rw [Pi.add_apply, h, h', LinearMap.add_apply, add_add_add_comm]⟩ }⟩
@[simp]
theorem coeFn_add (Q Q' : QuadraticForm R M) : ⇑(Q + Q') = Q + Q' :=
@@ -481,7 +486,7 @@ theorem sum_apply {ι : Type*} (Q : ι → QuadraticForm R M) (s : Finset ι) (x
end Sum
-instance [Monoid S] [DistribMulAction S R] [SMulCommClass S R R] :
+instance [Monoid S] [DistribMulAction S R] [SMulCommClass S R R] [SMulCommClass R S R] :
DistribMulAction S (QuadraticForm R M) where
mul_smul a b Q := ext fun x => by simp only [smul_apply, mul_smul]
one_smul Q := ext fun x => by simp only [QuadraticForm.smul_apply, one_smul]
@@ -492,7 +497,8 @@ instance [Monoid S] [DistribMulAction S R] [SMulCommClass S R R] :
ext
simp only [zero_apply, smul_apply, smul_zero]
-instance [Semiring S] [Module S R] [SMulCommClass S R R] : Module S (QuadraticForm R M) where
+instance [Semiring S] [Module S R] [SMulCommClass S R R] [SMulCommClass R S R] :
+ Module S (QuadraticForm R M) where
zero_smul Q := by
ext
simp only [zero_apply, smul_apply, zero_smul]
@@ -512,7 +518,7 @@ instance : Neg (QuadraticForm R M) :=
toFun_smul := fun a x => by simp only [Pi.neg_apply, map_smul, mul_neg]
exists_companion' :=
let ⟨B, h⟩ := Q.exists_companion
- ⟨-B, fun x y => by simp_rw [Pi.neg_apply, h, BilinForm.neg_apply, neg_add]⟩ }⟩
+ ⟨-B, fun x y => by simp_rw [Pi.neg_apply, h, LinearMap.neg_apply, neg_add]⟩ }⟩
@[simp]
theorem coeFn_neg (Q : QuadraticForm R M) : ⇑(-Q) = -Q :=
@@ -555,7 +561,7 @@ def comp (Q : QuadraticForm R N) (f : M →ₗ[R] N) : QuadraticForm R M where
toFun_smul a x := by simp only [map_smul, f.map_smul]
exists_companion' :=
let ⟨B, h⟩ := Q.exists_companion
- ⟨B.comp f f, fun x y => by simp_rw [f.map_add, h, BilinForm.comp_apply]⟩
+ ⟨B.compl₁₂ f f, fun x y => by simp_rw [f.map_add]; exact h (f x) (f y)⟩
#align quadratic_form.comp QuadraticForm.comp
@[simp]
@@ -571,7 +577,9 @@ def _root_.LinearMap.compQuadraticForm [CommSemiring S] [Algebra S R] [Module S
toFun_smul b x := by simp only [Q.map_smul_of_tower b x, f.map_smul, smul_eq_mul]
exists_companion' :=
let ⟨B, h⟩ := Q.exists_companion
- ⟨f.compBilinForm B, fun x y => by simp_rw [h, f.map_add, LinearMap.compBilinForm_apply]⟩
+ ⟨(LinearMap.restrictScalars S (LinearMap.restrictScalars S B.flip).flip).compr₂ f, fun x y => by
+ simp_rw [h, f.map_add]
+ rfl⟩
#align linear_map.comp_quadratic_form LinearMap.compQuadraticForm
end Comp
@@ -587,9 +595,10 @@ def linMulLin (f g : M →ₗ[R] R) : QuadraticForm R M where
simp only [smul_eq_mul, RingHom.id_apply, Pi.mul_apply, LinearMap.map_smulₛₗ]
ring
exists_companion' :=
- ⟨BilinForm.linMulLin f g + BilinForm.linMulLin g f, fun x y => by
- simp only [Pi.mul_apply, map_add, BilinForm.add_apply, BilinForm.linMulLin_apply]
- ring⟩
+ ⟨LinearMap.linMulLin f g + LinearMap.linMulLin g f, fun x y => by
+ simp only [Pi.mul_apply, map_add, LinearMap.linMulLin, LinearMap.add_apply,
+ LinearMap.mk₂_apply]
+ ring_nf⟩
#align quadratic_form.lin_mul_lin QuadraticForm.linMulLin
@[simp]
@@ -654,13 +663,19 @@ section Semiring
variable [CommSemiring R] [AddCommMonoid M] [Module R M]
+/-- A bilinear map into `R` gives a quadratic form by applying the argument twice. -/
+def _root_.LinearMap.toQuadraticForm (B: M →ₗ[R] M →ₗ[R] R) : QuadraticForm R M where
+ toFun x := B x x
+ toFun_smul a x := by
+ simp only [SMulHomClass.map_smul, LinearMap.smul_apply, smul_eq_mul, mul_assoc]
+ exists_companion' := ⟨B + B.flip,
+ fun x y => by simp only [map_add, LinearMap.add_apply, LinearMap.flip_apply]; abel⟩
+
variable {B : BilinForm R M}
/-- A bilinear form gives a quadratic form by applying the argument twice. -/
-def toQuadraticForm (B : BilinForm R M) : QuadraticForm R M where
- toFun x := B x x
- toFun_smul a x := by simp only [mul_assoc, smul_right, smul_left]
- exists_companion' := ⟨B + BilinForm.flipHom ℕ B, fun x y => by simp [add_add_add_comm, add_comm]⟩
+def toQuadraticForm (B : BilinForm R M) : QuadraticForm R M :=
+ B.toLin.toQuadraticForm
#align bilin_form.to_quadratic_form BilinForm.toQuadraticForm
@[simp]
@@ -686,8 +701,9 @@ theorem toQuadraticForm_add (B₁ B₂ : BilinForm R M) :
#align bilin_form.to_quadratic_form_add BilinForm.toQuadraticForm_add
@[simp]
-theorem toQuadraticForm_smul [Monoid S] [DistribMulAction S R] [SMulCommClass S R R] (a : S)
- (B : BilinForm R M) : (a • B).toQuadraticForm = a • B.toQuadraticForm :=
+theorem toQuadraticForm_smul [Monoid S] [DistribMulAction S R] [SMulCommClass S R R]
+ [SMulCommClass R S R] (a : S) (B : BilinForm R M) :
+ (a • B).toQuadraticForm = a • B.toQuadraticForm :=
rfl
#align bilin_form.to_quadratic_form_smul BilinForm.toQuadraticForm_smul
@@ -705,7 +721,7 @@ def toQuadraticFormAddMonoidHom : BilinForm R M →+ QuadraticForm R M where
/-- `BilinForm.toQuadraticForm` as a linear map -/
@[simps!]
-def toQuadraticFormLinearMap [Semiring S] [Module S R] [SMulCommClass S R R] :
+def toQuadraticFormLinearMap [Semiring S] [Module S R] [SMulCommClass S R R] [SMulCommClass R S R] :
BilinForm R M →ₗ[S] QuadraticForm R M where
toFun := toQuadraticForm
map_smul' := toQuadraticForm_smul
@@ -1276,8 +1292,8 @@ variable (R)
The weights are applied using `•`; typically this definition is used either with `S = R` or
`[Algebra S R]`, although this is stated more generally. -/
-def weightedSumSquares [Monoid S] [DistribMulAction S R] [SMulCommClass S R R] (w : ι → S) :
- QuadraticForm R (ι → R) :=
+def weightedSumSquares [Monoid S] [DistribMulAction S R] [SMulCommClass S R R] [SMulCommClass R S R]
+ (w : ι → S) : QuadraticForm R (ι → R) :=
∑ i : ι, w i • proj i i
#align quadratic_form.weighted_sum_squares QuadraticForm.weightedSumSquares
@@ -1285,7 +1301,8 @@ end
@[simp]
theorem weightedSumSquares_apply [Monoid S] [DistribMulAction S R] [SMulCommClass S R R]
- (w : ι → S) (v : ι → R) : weightedSumSquares R w v = ∑ i : ι, w i • (v i * v i) :=
+ [SMulCommClass R S R] (w : ι → S) (v : ι → R) :
+ weightedSumSquares R w v = ∑ i : ι, w i • (v i * v i) :=
QuadraticForm.sum_apply _ _ _
#align quadratic_form.weighted_sum_squares_apply QuadraticForm.weightedSumSquares_apply
FunLike
(#9833)
This follows up from #9785, which renamed FunLike
to DFunLike
, by introducing a new abbreviation FunLike F α β := DFunLike F α (fun _ => β)
, to make the non-dependent use of FunLike
easier.
I searched for the pattern DFunLike.*fun
and DFunLike.*λ
in all files to replace expressions of the form DFunLike F α (fun _ => β)
with FunLike F α β
. I did this everywhere except for extends
clauses for two reasons: it would conflict with #8386, and more importantly extends
must directly refer to a structure with no unfolding of def
s or abbrev
s.
@@ -153,10 +153,10 @@ variable [CommSemiring R] [AddCommMonoid M] [Module R M]
variable {Q Q' : QuadraticForm R M}
-instance instDFunLike : DFunLike (QuadraticForm R M) M fun _ => R where
+instance instFunLike : FunLike (QuadraticForm R M) M R where
coe := toFun
coe_injective' x y h := by cases x; cases y; congr
-#align quadratic_form.fun_like QuadraticForm.instDFunLike
+#align quadratic_form.fun_like QuadraticForm.instFunLike
/-- Helper instance for when there's too many metavariables to apply
`DFunLike.hasCoeToFun` directly. -/
@@ -241,7 +241,7 @@ theorem map_zero : Q 0 = 0 := by
#align quadratic_form.map_zero QuadraticForm.map_zero
instance zeroHomClass : ZeroHomClass (QuadraticForm R M) M R :=
- { QuadraticForm.instDFunLike with map_zero := map_zero }
+ { QuadraticForm.instFunLike with map_zero := map_zero }
#align quadratic_form.zero_hom_class QuadraticForm.zeroHomClass
theorem map_smul_of_tower [CommSemiring S] [Algebra S R] [Module S M] [IsScalarTower S R M] (a : S)
FunLike
to DFunLike
(#9785)
This prepares for the introduction of a non-dependent synonym of FunLike, which helps a lot with keeping #8386 readable.
This is entirely search-and-replace in 680197f combined with manual fixes in 4145626, e900597 and b8428f8. The commands that generated this change:
sed -i 's/\bFunLike\b/DFunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean
sed -i 's/\btoFunLike\b/toDFunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean
sed -i 's/import Mathlib.Data.DFunLike/import Mathlib.Data.FunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean
sed -i 's/\bHom_FunLike\b/Hom_DFunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean
sed -i 's/\binstFunLike\b/instDFunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean
sed -i 's/\bfunLike\b/instDFunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean
sed -i 's/\btoo many metavariables to apply `fun_like.has_coe_to_fun`/too many metavariables to apply `DFunLike.hasCoeToFun`/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean
Co-authored-by: Anne Baanen <Vierkantor@users.noreply.github.com>
@@ -147,25 +147,25 @@ structure QuadraticForm (R : Type u) (M : Type v) [CommSemiring R] [AddCommMonoi
namespace QuadraticForm
-section FunLike
+section DFunLike
variable [CommSemiring R] [AddCommMonoid M] [Module R M]
variable {Q Q' : QuadraticForm R M}
-instance funLike : FunLike (QuadraticForm R M) M fun _ => R where
+instance instDFunLike : DFunLike (QuadraticForm R M) M fun _ => R where
coe := toFun
coe_injective' x y h := by cases x; cases y; congr
-#align quadratic_form.fun_like QuadraticForm.funLike
+#align quadratic_form.fun_like QuadraticForm.instDFunLike
/-- Helper instance for when there's too many metavariables to apply
-`FunLike.hasCoeToFun` directly. -/
+`DFunLike.hasCoeToFun` directly. -/
instance : CoeFun (QuadraticForm R M) fun _ => M → R :=
- ⟨FunLike.coe⟩
+ ⟨DFunLike.coe⟩
variable (Q)
-/-- The `simp` normal form for a quadratic form is `FunLike.coe`, not `toFun`. -/
+/-- The `simp` normal form for a quadratic form is `DFunLike.coe`, not `toFun`. -/
@[simp]
theorem toFun_eq_coe : Q.toFun = ⇑Q :=
rfl
@@ -178,15 +178,15 @@ variable {Q}
@[ext]
theorem ext (H : ∀ x : M, Q x = Q' x) : Q = Q' :=
- FunLike.ext _ _ H
+ DFunLike.ext _ _ H
#align quadratic_form.ext QuadraticForm.ext
theorem congr_fun (h : Q = Q') (x : M) : Q x = Q' x :=
- FunLike.congr_fun h _
+ DFunLike.congr_fun h _
#align quadratic_form.congr_fun QuadraticForm.congr_fun
theorem ext_iff : Q = Q' ↔ ∀ x, Q x = Q' x :=
- FunLike.ext_iff
+ DFunLike.ext_iff
#align quadratic_form.ext_iff QuadraticForm.ext_iff
/-- Copy of a `QuadraticForm` with a new `toFun` equal to the old one. Useful to fix definitional
@@ -203,10 +203,10 @@ theorem coe_copy (Q : QuadraticForm R M) (Q' : M → R) (h : Q' = ⇑Q) : ⇑(Q.
#align quadratic_form.coe_copy QuadraticForm.coe_copy
theorem copy_eq (Q : QuadraticForm R M) (Q' : M → R) (h : Q' = ⇑Q) : Q.copy Q' h = Q :=
- FunLike.ext' h
+ DFunLike.ext' h
#align quadratic_form.copy_eq QuadraticForm.copy_eq
-end FunLike
+end DFunLike
section CommSemiring
@@ -241,7 +241,7 @@ theorem map_zero : Q 0 = 0 := by
#align quadratic_form.map_zero QuadraticForm.map_zero
instance zeroHomClass : ZeroHomClass (QuadraticForm R M) M R :=
- { QuadraticForm.funLike with map_zero := map_zero }
+ { QuadraticForm.instDFunLike with map_zero := map_zero }
#align quadratic_form.zero_hom_class QuadraticForm.zeroHomClass
theorem map_smul_of_tower [CommSemiring S] [Algebra S R] [Module S M] [IsScalarTower S R M] (a : S)
@@ -447,14 +447,14 @@ theorem add_apply (Q Q' : QuadraticForm R M) (x : M) : (Q + Q') x = Q x + Q' x :
#align quadratic_form.add_apply QuadraticForm.add_apply
instance : AddCommMonoid (QuadraticForm R M) :=
- FunLike.coe_injective.addCommMonoid _ coeFn_zero coeFn_add fun _ _ => coeFn_smul _ _
+ DFunLike.coe_injective.addCommMonoid _ coeFn_zero coeFn_add fun _ _ => coeFn_smul _ _
/-- `@CoeFn (QuadraticForm R M)` as an `AddMonoidHom`.
This API mirrors `AddMonoidHom.coeFn`. -/
@[simps apply]
def coeFnAddMonoidHom : QuadraticForm R M →+ M → R where
- toFun := FunLike.coe
+ toFun := DFunLike.coe
map_zero' := coeFn_zero
map_add' := coeFn_add
#align quadratic_form.coe_fn_add_monoid_hom QuadraticForm.coeFnAddMonoidHom
@@ -538,7 +538,7 @@ theorem sub_apply (Q Q' : QuadraticForm R M) (x : M) : (Q - Q') x = Q x - Q' x :
#align quadratic_form.sub_apply QuadraticForm.sub_apply
instance : AddCommGroup (QuadraticForm R M) :=
- FunLike.coe_injective.addCommGroup _ coeFn_zero coeFn_add coeFn_neg coeFn_sub
+ DFunLike.coe_injective.addCommGroup _ coeFn_zero coeFn_add coeFn_neg coeFn_sub
(fun _ _ => coeFn_smul _ _) fun _ _ => coeFn_smul _ _
end RingOperators
@@ -770,7 +770,7 @@ theorem polarBilin_toQuadraticForm : polarBilin (toQuadraticForm B) = B + flip'
theorem _root_.QuadraticForm.polarBilin_injective (h : IsUnit (2 : R)) :
Function.Injective (polarBilin : QuadraticForm R M → _) :=
fun Q₁ Q₂ h₁₂ => QuadraticForm.ext fun x => h.mul_left_cancel <| by
- simpa using FunLike.congr_fun (congr_arg toQuadraticForm h₁₂) x
+ simpa using DFunLike.congr_fun (congr_arg toQuadraticForm h₁₂) x
variable {N : Type v}
variable [CommRing S] [Algebra S R] [Module S M] [IsScalarTower S R M]
@@ -817,7 +817,7 @@ def associatedHom : QuadraticForm R M →ₗ[S] BilinForm R M :=
(⟨⅟2, Set.invOf_mem_center (Set.ofNat_mem_center _ _)⟩ : Submonoid.center R) •
{ toFun := polarBilin
map_add' := fun _x _y => BilinForm.ext <| polar_add _ _
- map_smul' := fun _c _x => BilinForm.ext <| polar_smul _ _ }
+ map_smul' := fun _c _x => BilinForm.ext <| polar_smul _ _ }
#align quadratic_form.associated_hom QuadraticForm.associatedHom
variable (Q : QuadraticForm R M)
@@ -401,10 +401,10 @@ theorem smul_apply (a : S) (Q : QuadraticForm R M) (x : M) : (a • Q) x = a •
#align quadratic_form.smul_apply QuadraticForm.smul_apply
instance [SMulCommClass S T R] : SMulCommClass S T (QuadraticForm R M) where
- smul_comm _s _t _q := ext <| fun _ => smul_comm _ _ _
+ smul_comm _s _t _q := ext fun _ => smul_comm _ _ _
instance [SMul S T] [IsScalarTower S T R] : IsScalarTower S T (QuadraticForm R M) where
- smul_assoc _s _t _q := ext <| fun _ => smul_assoc _ _ _
+ smul_assoc _s _t _q := ext fun _ => smul_assoc _ _ _
end SMul
@@ -765,7 +765,7 @@ theorem polarBilin_toQuadraticForm : polarBilin (toQuadraticForm B) = B + flip'
@[simp] theorem _root_.QuadraticForm.toQuadraticForm_polarBilin (Q : QuadraticForm R M) :
toQuadraticForm (polarBilin Q) = 2 • Q :=
- QuadraticForm.ext <| fun x => (polar_self _ x).trans <| by simp
+ QuadraticForm.ext fun x => (polar_self _ x).trans <| by simp
theorem _root_.QuadraticForm.polarBilin_injective (h : IsUnit (2 : R)) :
Function.Injective (polarBilin : QuadraticForm R M → _) :=
@@ -778,7 +778,7 @@ variable [AddCommGroup N] [Module R N]
theorem _root_.QuadraticForm.polarBilin_comp (Q : QuadraticForm R N) (f : M →ₗ[R] N) :
polarBilin (Q.comp f) = BilinForm.comp (polarBilin Q) f f :=
- BilinForm.ext <| fun x y => by simp [polar]
+ BilinForm.ext fun x y => by simp [polar]
theorem _root_.LinearMap.compQuadraticForm_polar (f : R →ₗ[S] S) (Q : QuadraticForm R M) (x y : M) :
polar (f.compQuadraticForm Q) x y = f (polar Q x y) := by
QuadraticForm.IsOrtho
as Q (x + y) = Q x + Q y
(#9141)
This includes some basic API, and the connection with BilinForm.IsOrtho
.
The motivation for this definition are the results about vectors commuting in a clifford algebra.
@@ -37,6 +37,7 @@ and composition with linear maps `f`, `Q.comp f x = Q (f x)`.
* `QuadraticForm.PosDef`: positive definite quadratic forms
* `QuadraticForm.Anisotropic`: anisotropic quadratic forms
* `QuadraticForm.discr`: discriminant of a quadratic form
+ * `QuadraticForm.IsOrtho`: orthogonality of vectors with respect to a quadratic form.
## Main statements
@@ -933,6 +934,64 @@ lemma associated_sq : associated (R := R) sq = LinearMap.toBilin (LinearMap.mul
end Associated
+section IsOrtho
+
+/-! ### Orthogonality -/
+
+section CommSemiring
+variable [CommSemiring R] [AddCommMonoid M] [Module R M] {Q : QuadraticForm R M}
+
+/-- The proposition that two elements of a quadratic form space are orthogonal. -/
+def IsOrtho (Q : QuadraticForm R M) (x y : M) : Prop :=
+ Q (x + y) = Q x + Q y
+
+theorem isOrtho_def {Q : QuadraticForm R M} {x y : M} : Q.IsOrtho x y ↔ Q (x + y) = Q x + Q y :=
+ Iff.rfl
+
+theorem IsOrtho.all (x y : M) : IsOrtho (0 : QuadraticForm R M) x y := (zero_add _).symm
+
+theorem IsOrtho.zero_left (x : M) : IsOrtho Q (0 : M) x := by simp [isOrtho_def]
+
+theorem IsOrtho.zero_right (x : M) : IsOrtho Q x (0 : M) := by simp [isOrtho_def]
+
+theorem ne_zero_of_not_isOrtho_self {Q : QuadraticForm R M} (x : M) (hx₁ : ¬Q.IsOrtho x x) :
+ x ≠ 0 :=
+ fun hx₂ => hx₁ (hx₂.symm ▸ .zero_left _)
+
+theorem isOrtho_comm {x y : M} : IsOrtho Q x y ↔ IsOrtho Q y x := by simp_rw [isOrtho_def, add_comm]
+
+alias ⟨IsOrtho.symm, _⟩ := isOrtho_comm
+
+theorem _root_.BilinForm.toQuadraticForm_isOrtho [IsCancelAdd R]
+ [NoZeroDivisors R] [CharZero R] {B : BilinForm R M} {x y : M} (h : B.IsSymm):
+ B.toQuadraticForm.IsOrtho x y ↔ B.IsOrtho x y := by
+ letI : AddCancelMonoid R := { ‹IsCancelAdd R›, (inferInstanceAs <| AddCommMonoid R) with }
+ simp_rw [isOrtho_def, BilinForm.isOrtho_def, toQuadraticForm_apply, bilin_add_left,
+ bilin_add_right, add_comm _ (B y y), add_add_add_comm _ _ (B y y), add_comm (B y y)]
+ rw [add_right_eq_self (a := B x x + B y y), h, add_self_eq_zero (R := R)]
+
+end CommSemiring
+
+section CommRing
+variable [CommRing R] [AddCommGroup M] [Module R M] {Q : QuadraticForm R M}
+
+@[simp]
+theorem isOrtho_polarBilin {x y : M} : Q.polarBilin.IsOrtho x y ↔ IsOrtho Q x y := by
+ simp_rw [isOrtho_def, BilinForm.isOrtho_def, polarBilin_apply, polar, sub_sub, sub_eq_zero]
+
+theorem IsOrtho.polar_eq_zero {x y : M} (h : IsOrtho Q x y) : polar Q x y = 0 :=
+ isOrtho_polarBilin.mpr h
+
+@[simp]
+theorem associated_isOrtho [Invertible (2 : R)] {x y : M} :
+ Q.associated.IsOrtho x y ↔ Q.IsOrtho x y := by
+ simp_rw [isOrtho_def, BilinForm.isOrtho_def, associated_apply, invOf_mul_eq_iff_eq_mul_left,
+ mul_zero, sub_sub, sub_eq_zero]
+
+end CommRing
+
+end IsOrtho
+
section Anisotropic
section Semiring
LinearAlgebra.BilinearForm
. (#8879)
Also renamed BilinearForm.restrictSymm
to BilinearForm.IsSymm.restrict
.
@@ -6,6 +6,7 @@ Authors: Anne Baanen, Kexing Ying, Eric Wieser
import Mathlib.LinearAlgebra.Matrix.Determinant
import Mathlib.LinearAlgebra.Matrix.BilinearForm
import Mathlib.LinearAlgebra.Matrix.Symmetric
+import Mathlib.LinearAlgebra.BilinearForm.Orthogonal
#align_import linear_algebra.quadratic_form.basic from "leanprover-community/mathlib"@"d11f435d4e34a6cea0a1797d6b625b0c170be845"
@@ -1156,7 +1157,7 @@ theorem exists_orthogonal_basis [hK : Invertible (2 : K)] {B : BilinForm K V} (h
rw [← Submodule.finrank_add_eq_of_isCompl (isCompl_span_singleton_orthogonal hx).symm,
finrank_span_singleton (ne_zero_of_not_isOrtho_self x hx)] at hd
let B' := B.restrict (B.orthogonal <| K ∙ x)
- obtain ⟨v', hv₁⟩ := ih (B.restrictSymm hB₂ _ : B'.IsSymm) (Nat.succ.inj hd)
+ obtain ⟨v', hv₁⟩ := ih (hB₂.restrict _ : B'.IsSymm) (Nat.succ.inj hd)
-- concatenate `x` with the basis obtained by induction
let b :=
Basis.mkFinCons x v'
@@ -468,13 +468,13 @@ section Sum
@[simp]
theorem coeFn_sum {ι : Type*} (Q : ι → QuadraticForm R M) (s : Finset ι) :
⇑(∑ i in s, Q i) = ∑ i in s, ⇑(Q i) :=
- (coeFnAddMonoidHom : QuadraticForm R M →+ M → R).map_sum Q s
+ map_sum coeFnAddMonoidHom Q s
#align quadratic_form.coe_fn_sum QuadraticForm.coeFn_sum
@[simp]
theorem sum_apply {ι : Type*} (Q : ι → QuadraticForm R M) (s : Finset ι) (x : M) :
(∑ i in s, Q i) x = ∑ i in s, Q i x :=
- (evalAddMonoidHom x : _ →+ R).map_sum Q s
+ map_sum (evalAddMonoidHom x : _ →+ R) Q s
#align quadratic_form.sum_apply QuadraticForm.sum_apply
end Sum
@@ -828,7 +828,7 @@ theorem associated_apply (x y : M) : associatedHom S Q x y = ⅟ 2 * (Q (x + y)
@[simp] theorem two_nsmul_associated : 2 • associatedHom S Q = Q.polarBilin := by
ext
dsimp
- rw [←smul_mul_assoc, two_nsmul, invOf_two_add_invOf_two, one_mul, polar]
+ rw [← smul_mul_assoc, two_nsmul, invOf_two_add_invOf_two, one_mul, polar]
theorem associated_isSymm : (associatedHom S Q).IsSymm := fun x y => by
simp only [associated_apply, add_comm, add_left_comm, sub_eq_add_neg, add_assoc]
The change from @[reducible] def
to abbreviation
is meaningless in Lean 4 (in lean3 it was to force the generation of equation lemmas).
At any rate we already use abbrev
:
@@ -7,7 +7,7 @@ import Mathlib.LinearAlgebra.Matrix.Determinant
import Mathlib.LinearAlgebra.Matrix.BilinearForm
import Mathlib.LinearAlgebra.Matrix.Symmetric
-#align_import linear_algebra.quadratic_form.basic from "leanprover-community/mathlib"@"11b92770e4d49ff3982504c4dab918ac0887fe33"
+#align_import linear_algebra.quadratic_form.basic from "leanprover-community/mathlib"@"d11f435d4e34a6cea0a1797d6b625b0c170be845"
/-!
# Quadratic forms
Removes nonterminal simps on lines looking like simp [...]
@@ -224,7 +224,7 @@ theorem map_add_add_add_map (x y z : M) :
Q (x + y + z) + (Q x + Q y + Q z) = Q (x + y) + Q (y + z) + Q (z + x) := by
obtain ⟨B, h⟩ := Q.exists_companion
rw [add_comm z x]
- simp [h]
+ simp only [h, BilinForm.add_left]
abel
#align quadratic_form.map_add_add_add_map QuadraticForm.map_add_add_add_map
As discussed on Zulip, this generalization seems nonsensical as currently implemented.
There are sensible ways to make this generalization, but they are much larger refactors, and in the meantime the current generalization is useless anyway.
@@ -13,14 +13,15 @@ import Mathlib.LinearAlgebra.Matrix.Symmetric
# Quadratic forms
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:
+A quadratic form on a commutative ring `R` is a map `Q : M → R` such that:
+
* `QuadraticForm.map_smul`: `Q (a • x) = a * a * Q x`
* `QuadraticForm.polar_add_left`, `QuadraticForm.polar_add_right`,
`QuadraticForm.polar_smul_left`, `QuadraticForm.polar_smul_right`:
the map `QuadraticForm.polar Q := fun 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
+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`.
@@ -47,13 +48,20 @@ and composition with linear maps `f`, `Q.comp f x = Q (f x)`.
## Notation
-In this file, the variable `R` is used when a `Ring` structure is sufficient and
-`R₁` is used when specifically a `CommRing` 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 `CommRing`.
+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](https://leanprover.zulipchat.com/#narrow/stream/116395-maths/topic/Quadratic.20Maps/near/395529867)
+has some further discusion.
+
## References
* https://en.wikipedia.org/wiki/Quadratic_form
@@ -69,13 +77,13 @@ universe u v w
variable {S T : Type*}
-variable {R R₁ : Type*} {M : Type*}
+variable {R : Type*} {M : Type*}
open BigOperators
section Polar
-variable [Ring R] [CommRing R₁] [AddCommGroup M]
+variable [CommRing R] [AddCommGroup M]
namespace QuadraticForm
@@ -115,7 +123,8 @@ theorem polar_add_left_iff {f : M → R} {x x' y : M} :
add_right_comm (f (x + y)), add_left_inj]
#align quadratic_form.polar_add_left_iff QuadraticForm.polar_add_left_iff
-theorem polar_comp {F : Type*} [Ring S] [AddMonoidHomClass F R S] (f : M → R) (g : F) (x y : M) :
+theorem polar_comp {F : Type*} [CommRing S] [AddMonoidHomClass F R S]
+ (f : M → R) (g : F) (x y : M) :
polar (g ∘ f) x y = g (polar f x y) := by
simp only [polar, Pi.smul_apply, Function.comp_apply, map_sub]
#align quadratic_form.polar_comp QuadraticForm.polar_comp
@@ -127,7 +136,8 @@ end Polar
/-- A quadratic form over a module.
For a more familiar constructor when `R` is a ring, see `QuadraticForm.ofPolar`. -/
-structure QuadraticForm (R : Type u) (M : Type v) [Semiring R] [AddCommMonoid M] [Module R M] where
+structure QuadraticForm (R : Type u) (M : Type v) [CommSemiring R] [AddCommMonoid M] [Module R M]
+ where
toFun : M → R
toFun_smul : ∀ (a : R) (x : M), toFun (a • x) = a * a * toFun x
exists_companion' : ∃ B : BilinForm R M, ∀ x y, toFun (x + y) = toFun x + toFun y + B x y
@@ -137,7 +147,7 @@ namespace QuadraticForm
section FunLike
-variable [Semiring R] [AddCommMonoid M] [Module R M]
+variable [CommSemiring R] [AddCommMonoid M] [Module R M]
variable {Q Q' : QuadraticForm R M}
@@ -196,9 +206,9 @@ theorem copy_eq (Q : QuadraticForm R M) (Q' : M → R) (h : Q' = ⇑Q) : Q.copy
end FunLike
-section Semiring
+section CommSemiring
-variable [Semiring R] [AddCommMonoid M] [Module R M]
+variable [CommSemiring R] [AddCommMonoid M] [Module R M]
variable (Q : QuadraticForm R M)
@@ -237,11 +247,11 @@ theorem map_smul_of_tower [CommSemiring S] [Algebra S R] [Module S M] [IsScalarT
rw [← IsScalarTower.algebraMap_smul R a x, map_smul, ← RingHom.map_mul, Algebra.smul_def]
#align quadratic_form.map_smul_of_tower QuadraticForm.map_smul_of_tower
-end Semiring
+end CommSemiring
-section Ring
+section CommRing
-variable [Ring R] [CommRing R₁] [AddCommGroup M]
+variable [CommRing R] [AddCommGroup M]
variable [Module R M] (Q : QuadraticForm R M)
@@ -356,11 +366,11 @@ theorem choose_exists_companion : Q.exists_companion.choose = polarBilin Q :=
rw [polarBilin_apply, polar, Q.exists_companion.choose_spec, sub_sub, add_sub_cancel']
#align quadratic_form.some_exists_companion QuadraticForm.choose_exists_companion
-end Ring
+end CommRing
section SemiringOperators
-variable [Semiring R] [AddCommMonoid M] [Module R M]
+variable [CommSemiring R] [AddCommMonoid M] [Module R M]
section SMul
@@ -369,7 +379,7 @@ variable [SMulCommClass S R R] [SMulCommClass T R R]
/-- `QuadraticForm R M` inherits the scalar action from any algebra over `R`.
-When `R` is commutative, this provides an `R`-action via `Algebra.id`. -/
+This provides an `R`-action via `Algebra.id`. -/
instance : SMul S (QuadraticForm R M) :=
⟨fun a Q =>
{ toFun := a • ⇑Q
@@ -492,7 +502,7 @@ end SemiringOperators
section RingOperators
-variable [Ring R] [AddCommGroup M] [Module R M]
+variable [CommRing R] [AddCommGroup M] [Module R M]
instance : Neg (QuadraticForm R M) :=
⟨fun Q =>
@@ -533,7 +543,7 @@ end RingOperators
section Comp
-variable [Semiring R] [AddCommMonoid M] [Module R M]
+variable [CommSemiring R] [AddCommMonoid M] [Module R M]
variable {N : Type v} [AddCommMonoid N] [Module R N]
@@ -605,13 +615,13 @@ theorem linMulLin_comp (f g : M →ₗ[R] R) (h : N →ₗ[R] M) :
variable {n : Type*}
-/-- `sq` is the quadratic form mapping the vector `x : R₁` to `x * x` -/
+/-- `sq` is the quadratic form mapping the vector `x : R` to `x * x` -/
@[simps!]
def sq : QuadraticForm R R :=
linMulLin LinearMap.id LinearMap.id
#align quadratic_form.sq QuadraticForm.sq
-/-- `proj i j` is the quadratic form mapping the vector `x : n → R₁` to `x i * x j` -/
+/-- `proj i j` is the quadratic form mapping the vector `x : n → R` to `x i * x j` -/
def proj (i j : n) : QuadraticForm R (n → R) :=
linMulLin (@LinearMap.proj _ _ _ (fun _ => R) _ _ i) (@LinearMap.proj _ _ _ (fun _ => R) _ _ j)
#align quadratic_form.proj QuadraticForm.proj
@@ -640,7 +650,7 @@ open QuadraticForm
section Semiring
-variable [Semiring R] [AddCommMonoid M] [Module R M]
+variable [CommSemiring R] [AddCommMonoid M] [Module R M]
variable {B : BilinForm R M}
@@ -728,7 +738,7 @@ end Semiring
section Ring
-variable [Ring R] [AddCommGroup M] [Module R M]
+variable [CommRing R] [AddCommGroup M] [Module R M]
variable {B : BilinForm R M}
@@ -786,7 +796,7 @@ open BilinForm
section AssociatedHom
-variable [Ring R] [CommRing R₁] [AddCommGroup M] [Module R M] [Module R₁ M]
+variable [CommRing R] [AddCommGroup M] [Module R M]
variable (S) [CommSemiring S] [Algebra S R]
@@ -800,6 +810,8 @@ Over a commutative ring, use `QuadraticForm.associated`, which gives an `R`-line
general ring with no nontrivial distinguished commutative subring, use `QuadraticForm.associated'`,
which gives an additive homomorphism (or more precisely a `ℤ`-linear map.) -/
def associatedHom : QuadraticForm R M →ₗ[S] BilinForm R M :=
+ -- TODO: this `center` stuff is vertigial from an incorrect non-commutative version, but we leave
+ -- it behind to make a future refactor to a *correct* non-commutative version easier in future.
(⟨⅟2, Set.invOf_mem_center (Set.ofNat_mem_center _ _)⟩ : Submonoid.center R) •
{ toFun := polarBilin
map_add' := fun _x _y => BilinForm.ext <| polar_add _ _
@@ -885,27 +897,27 @@ end AssociatedHom
section Associated
-variable [CommSemiring S] [CommRing R₁] [AddCommGroup M] [Algebra S R₁] [Module R₁ M]
+variable [CommSemiring S] [CommRing R] [AddCommGroup M] [Algebra S R] [Module R M]
-variable [Invertible (2 : R₁)]
+variable [Invertible (2 : R)]
-- Note: When possible, rather than writing lemmas about `associated`, write a lemma applying to
-- the more general `associatedHom` and place it in the previous section.
/-- `associated` is the linear map that sends a quadratic form over a commutative ring to its
associated symmetric bilinear form. -/
-abbrev associated : QuadraticForm R₁ M →ₗ[R₁] BilinForm R₁ M :=
- associatedHom R₁
+abbrev associated : QuadraticForm R M →ₗ[R] BilinForm R M :=
+ associatedHom R
#align quadratic_form.associated QuadraticForm.associated
variable (S) in
theorem coe_associatedHom :
- ⇑(associatedHom S : QuadraticForm R₁ M →ₗ[S] BilinForm R₁ M) = associated :=
+ ⇑(associatedHom S : QuadraticForm R M →ₗ[S] BilinForm R M) = associated :=
rfl
@[simp]
-theorem associated_linMulLin (f g : M →ₗ[R₁] R₁) :
- associated (R₁ := R₁) (linMulLin f g) =
- ⅟ (2 : R₁) • (BilinForm.linMulLin f g + BilinForm.linMulLin g f) := by
+theorem associated_linMulLin (f g : M →ₗ[R] R) :
+ associated (R := R) (linMulLin f g) =
+ ⅟ (2 : R) • (BilinForm.linMulLin f g + BilinForm.linMulLin g f) := by
ext
simp only [smul_add, Algebra.id.smul_eq_mul, BilinForm.linMulLin_apply,
QuadraticForm.linMulLin_apply, BilinForm.smul_apply, associated_apply, BilinForm.add_apply,
@@ -914,7 +926,7 @@ theorem associated_linMulLin (f g : M →ₗ[R₁] R₁) :
#align quadratic_form.associated_lin_mul_lin QuadraticForm.associated_linMulLin
@[simp]
-lemma associated_sq : associated (R₁ := R₁) sq = LinearMap.toBilin (LinearMap.mul R₁ R₁) :=
+lemma associated_sq : associated (R := R) sq = LinearMap.toBilin (LinearMap.mul R R) :=
(associated_linMulLin (LinearMap.id) (LinearMap.id)).trans <|
by simp only [smul_add, invOf_two_smul_add_invOf_two_smul]; rfl
@@ -924,7 +936,7 @@ section Anisotropic
section Semiring
-variable [Semiring R] [AddCommMonoid M] [Module R M]
+variable [CommSemiring R] [AddCommMonoid M] [Module R M]
/-- An anisotropic quadratic form is zero only on zero vectors. -/
def Anisotropic (Q : QuadraticForm R M) : Prop :=
@@ -945,7 +957,7 @@ end Semiring
section Ring
-variable [Ring R] [AddCommGroup M] [Module R M]
+variable [CommRing R] [AddCommGroup M] [Module R M]
/-- The associated bilinear form of an anisotropic quadratic form is nondegenerate. -/
theorem nondegenerate_of_anisotropic [Invertible (2 : R)] (Q : QuadraticForm R M)
@@ -962,7 +974,7 @@ end Anisotropic
section PosDef
-variable {R₂ : Type u} [OrderedRing R₂] [AddCommMonoid M] [Module R₂ M]
+variable {R₂ : Type u} [OrderedCommRing R₂] [AddCommMonoid M] [Module R₂ M]
variable {Q₂ : QuadraticForm R₂ M}
@@ -1023,28 +1035,28 @@ The determinant of the matrix is the discriminant of the quadratic form.
variable {n : Type w} [Fintype n] [DecidableEq n]
-variable [CommRing R₁] [AddCommMonoid M] [Module R₁ M]
+variable [CommRing R] [AddCommMonoid M] [Module R M]
/-- `M.toQuadraticForm'` is the map `fun x ↦ col x * M * row x` as a quadratic form. -/
-def Matrix.toQuadraticForm' (M : Matrix n n R₁) : QuadraticForm R₁ (n → R₁) :=
+def Matrix.toQuadraticForm' (M : Matrix n n R) : QuadraticForm R (n → R) :=
M.toBilin'.toQuadraticForm
#align matrix.to_quadratic_form' Matrix.toQuadraticForm'
-variable [Invertible (2 : R₁)]
+variable [Invertible (2 : R)]
/-- A matrix representation of the quadratic form. -/
-def QuadraticForm.toMatrix' (Q : QuadraticForm R₁ (n → R₁)) : Matrix n n R₁ :=
- BilinForm.toMatrix' (associated (R₁ := R₁) Q)
+def QuadraticForm.toMatrix' (Q : QuadraticForm R (n → R)) : Matrix n n R :=
+ BilinForm.toMatrix' (associated (R := R) Q)
#align quadratic_form.to_matrix' QuadraticForm.toMatrix'
open QuadraticForm
-theorem QuadraticForm.toMatrix'_smul (a : R₁) (Q : QuadraticForm R₁ (n → R₁)) :
+theorem QuadraticForm.toMatrix'_smul (a : R) (Q : QuadraticForm R (n → R)) :
(a • Q).toMatrix' = a • Q.toMatrix' := by
simp only [toMatrix', LinearEquiv.map_smul, LinearMap.map_smul]
#align quadratic_form.to_matrix'_smul QuadraticForm.toMatrix'_smul
-theorem QuadraticForm.isSymm_toMatrix' (Q : QuadraticForm R₁ (n → R₁)) : Q.toMatrix'.IsSymm := by
+theorem QuadraticForm.isSymm_toMatrix' (Q : QuadraticForm R (n → R)) : Q.toMatrix'.IsSymm := by
ext i j
rw [toMatrix', Matrix.transpose_apply, BilinForm.toMatrix'_apply, BilinForm.toMatrix'_apply,
associated_isSymm]
@@ -1056,14 +1068,14 @@ namespace QuadraticForm
variable {n : Type w} [Fintype n]
-variable [CommRing R₁] [DecidableEq n] [Invertible (2 : R₁)]
+variable [CommRing R] [DecidableEq n] [Invertible (2 : R)]
variable {m : Type w} [DecidableEq m] [Fintype m]
open Matrix
@[simp]
-theorem toMatrix'_comp (Q : QuadraticForm R₁ (m → R₁)) (f : (n → R₁) →ₗ[R₁] m → R₁) :
+theorem toMatrix'_comp (Q : QuadraticForm R (m → R)) (f : (n → R) →ₗ[R] m → R) :
(Q.comp f).toMatrix' = (LinearMap.toMatrix' f)ᵀ * Q.toMatrix' * (LinearMap.toMatrix' f) := by
ext
simp only [QuadraticForm.associated_comp, BilinForm.toMatrix'_comp, toMatrix']
@@ -1071,18 +1083,18 @@ theorem toMatrix'_comp (Q : QuadraticForm R₁ (m → R₁)) (f : (n → R₁)
section Discriminant
-variable {Q : QuadraticForm R₁ (n → R₁)}
+variable {Q : QuadraticForm R (n → R)}
/-- The discriminant of a quadratic form generalizes the discriminant of a quadratic polynomial. -/
-def discr (Q : QuadraticForm R₁ (n → R₁)) : R₁ :=
+def discr (Q : QuadraticForm R (n → R)) : R :=
Q.toMatrix'.det
#align quadratic_form.discr QuadraticForm.discr
-theorem discr_smul (a : R₁) : (a • Q).discr = a ^ Fintype.card n * Q.discr := by
+theorem discr_smul (a : R) : (a • Q).discr = a ^ Fintype.card n * Q.discr := by
simp only [discr, toMatrix'_smul, Matrix.det_smul]
#align quadratic_form.discr_smul QuadraticForm.discr_smul
-theorem discr_comp (f : (n → R₁) →ₗ[R₁] n → R₁) :
+theorem discr_comp (f : (n → R) →ₗ[R] n → R) :
(Q.comp f).discr = f.toMatrix'.det * f.toMatrix'.det * Q.discr := by
simp only [Matrix.det_transpose, mul_left_comm, QuadraticForm.toMatrix'_comp, mul_comm,
Matrix.det_mul, discr]
@@ -1100,7 +1112,7 @@ namespace BilinForm
section Semiring
-variable [Semiring R] [AddCommMonoid M] [Module R M]
+variable [CommSemiring R] [AddCommMonoid M] [Module R M]
/-- A bilinear form is nondegenerate if the quadratic form it is associated with is anisotropic. -/
theorem nondegenerate_of_anisotropic {B : BilinForm R M} (hB : B.toQuadraticForm.Anisotropic) :
@@ -1109,7 +1121,7 @@ theorem nondegenerate_of_anisotropic {B : BilinForm R M} (hB : B.toQuadraticForm
end Semiring
-variable [Ring R] [AddCommGroup M] [Module R M]
+variable [CommRing R] [AddCommGroup M] [Module R M]
/-- 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
@@ -1180,9 +1192,7 @@ namespace QuadraticForm
open Finset BilinForm
-variable {M₁ : Type*} [Semiring R] [CommSemiring R₁] [AddCommMonoid M] [AddCommMonoid M₁]
-
-variable [Module R M] [Module R M₁]
+variable [CommSemiring R] [AddCommMonoid M] [Module R M]
variable {ι : Type*} [Fintype ι] {v : Basis ι R M}
@@ -1200,38 +1210,38 @@ theorem basisRepr_apply (Q : QuadraticForm R M) (w : ι → R) :
section
-variable (R₁)
+variable (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. -/
-def weightedSumSquares [Monoid S] [DistribMulAction S R₁] [SMulCommClass S R₁ R₁] (w : ι → S) :
- QuadraticForm R₁ (ι → R₁) :=
+The weights are applied using `•`; typically this definition is used either with `S = R` or
+`[Algebra S R]`, although this is stated more generally. -/
+def weightedSumSquares [Monoid S] [DistribMulAction S R] [SMulCommClass S R R] (w : ι → S) :
+ QuadraticForm R (ι → R) :=
∑ i : ι, w i • proj i i
#align quadratic_form.weighted_sum_squares QuadraticForm.weightedSumSquares
end
@[simp]
-theorem weightedSumSquares_apply [Monoid S] [DistribMulAction S R₁] [SMulCommClass S R₁ R₁]
- (w : ι → S) (v : ι → R₁) : weightedSumSquares R₁ w v = ∑ i : ι, w i • (v i * v i) :=
+theorem weightedSumSquares_apply [Monoid S] [DistribMulAction S R] [SMulCommClass S R R]
+ (w : ι → S) (v : ι → R) : weightedSumSquares R w v = ∑ i : ι, w i • (v i * v i) :=
QuadraticForm.sum_apply _ _ _
#align quadratic_form.weighted_sum_squares_apply QuadraticForm.weightedSumSquares_apply
/-- On an orthogonal basis, the basis representation of `Q` is just a sum of squares. -/
-theorem basisRepr_eq_of_iIsOrtho {R₁ M} [CommRing R₁] [AddCommGroup M] [Module R₁ M]
- [Invertible (2 : R₁)] (Q : QuadraticForm R₁ M) (v : Basis ι R₁ M)
- (hv₂ : (associated (R₁ := R₁) Q).iIsOrtho v) :
+theorem basisRepr_eq_of_iIsOrtho {R M} [CommRing R] [AddCommGroup M] [Module R M]
+ [Invertible (2 : R)] (Q : QuadraticForm R M) (v : Basis ι R M)
+ (hv₂ : (associated (R := R) Q).iIsOrtho v) :
Q.basisRepr v = weightedSumSquares _ fun i => Q (v i) := by
ext w
- rw [basisRepr_apply, ← @associated_eq_self_apply R₁, sum_left, weightedSumSquares_apply]
+ rw [basisRepr_apply, ← @associated_eq_self_apply R, sum_left, weightedSumSquares_apply]
refine' sum_congr rfl fun j hj => _
- rw [← @associated_eq_self_apply R₁, sum_right, sum_eq_single_of_mem j hj]
+ rw [← @associated_eq_self_apply R, sum_right, sum_eq_single_of_mem j hj]
· rw [smul_left, smul_right, smul_eq_mul]
ring
· intro i _ hij
- rw [smul_left, smul_right, show associatedHom R₁ Q (v j) (v i) = 0 from hv₂ hij.symm,
+ rw [smul_left, smul_right, show associatedHom R Q (v j) (v i) = 0 from hv₂ hij.symm,
mul_zero, mul_zero]
set_option linter.uppercaseLean3 false in
#align quadratic_form.basis_repr_eq_of_is_Ortho QuadraticForm.basisRepr_eq_of_iIsOrtho
@@ -576,7 +576,7 @@ def linMulLin (f g : M →ₗ[R] R) : QuadraticForm R M where
ring
exists_companion' :=
⟨BilinForm.linMulLin f g + BilinForm.linMulLin g f, fun x y => by
- simp
+ simp only [Pi.mul_apply, map_add, BilinForm.add_apply, BilinForm.linMulLin_apply]
ring⟩
#align quadratic_form.lin_mul_lin QuadraticForm.linMulLin
@@ -751,7 +751,22 @@ theorem polar_toQuadraticForm (x y : M) : polar (toQuadraticForm B) x y = B x y
theorem polarBilin_toQuadraticForm : polarBilin (toQuadraticForm B) = B + flip' B :=
BilinForm.ext polar_toQuadraticForm
+@[simp] theorem _root_.QuadraticForm.toQuadraticForm_polarBilin (Q : QuadraticForm R M) :
+ toQuadraticForm (polarBilin Q) = 2 • Q :=
+ QuadraticForm.ext <| fun x => (polar_self _ x).trans <| by simp
+
+theorem _root_.QuadraticForm.polarBilin_injective (h : IsUnit (2 : R)) :
+ Function.Injective (polarBilin : QuadraticForm R M → _) :=
+ fun Q₁ Q₂ h₁₂ => QuadraticForm.ext fun x => h.mul_left_cancel <| by
+ simpa using FunLike.congr_fun (congr_arg toQuadraticForm h₁₂) x
+
+variable {N : Type v}
variable [CommRing S] [Algebra S R] [Module S M] [IsScalarTower S R M]
+variable [AddCommGroup N] [Module R N]
+
+theorem _root_.QuadraticForm.polarBilin_comp (Q : QuadraticForm R N) (f : M →ₗ[R] N) :
+ polarBilin (Q.comp f) = BilinForm.comp (polarBilin Q) f f :=
+ BilinForm.ext <| fun x y => by simp [polar]
theorem _root_.LinearMap.compQuadraticForm_polar (f : R →ₗ[S] S) (Q : QuadraticForm R M) (x y : M) :
polar (f.compQuadraticForm Q) x y = f (polar Q x y) := by
This also adds a handful of missing lemmas about Set.center
for inverses and numeric literals.
@@ -553,7 +553,7 @@ theorem comp_apply (Q : QuadraticForm R N) (f : M →ₗ[R] N) (x : M) : (Q.comp
/-- Compose a quadratic form with a linear function on the left. -/
@[simps (config := { simpRhs := true })]
-def _root_.LinearMap.compQuadraticForm {S : Type*} [CommSemiring S] [Algebra S R] [Module S M]
+def _root_.LinearMap.compQuadraticForm [CommSemiring S] [Algebra S R] [Module S M]
[IsScalarTower S R M] (f : R →ₗ[S] S) (Q : QuadraticForm R M) : QuadraticForm S M where
toFun x := f (Q x)
toFun_smul b x := by simp only [Q.map_smul_of_tower b x, f.map_smul, smul_eq_mul]
@@ -732,11 +732,6 @@ variable [Ring R] [AddCommGroup M] [Module R M]
variable {B : BilinForm R M}
-theorem polar_to_quadratic_form (x y : M) : polar (fun x => B x x) x y = B x y + B y x := by
- simp only [add_assoc, add_sub_cancel', add_right, polar, add_left_inj, add_neg_cancel_left,
- add_left, sub_eq_add_neg _ (B y y), add_comm (B y x) _]
-#align bilin_form.polar_to_quadratic_form BilinForm.polar_to_quadratic_form
-
@[simp]
theorem toQuadraticForm_neg (B : BilinForm R M) : (-B).toQuadraticForm = -B.toQuadraticForm :=
rfl
@@ -748,6 +743,24 @@ theorem toQuadraticForm_sub (B₁ B₂ : BilinForm R M) :
rfl
#align bilin_form.to_quadratic_form_sub BilinForm.toQuadraticForm_sub
+theorem polar_toQuadraticForm (x y : M) : polar (toQuadraticForm B) x y = B x y + B y x := by
+ simp only [toQuadraticForm_apply, add_assoc, add_sub_cancel', add_right, polar, add_left_inj,
+ add_neg_cancel_left, add_left, sub_eq_add_neg _ (B y y), add_comm (B y x) _]
+#align bilin_form.polar_to_quadratic_form BilinForm.polar_toQuadraticForm
+
+theorem polarBilin_toQuadraticForm : polarBilin (toQuadraticForm B) = B + flip' B :=
+ BilinForm.ext polar_toQuadraticForm
+
+variable [CommRing S] [Algebra S R] [Module S M] [IsScalarTower S R M]
+
+theorem _root_.LinearMap.compQuadraticForm_polar (f : R →ₗ[S] S) (Q : QuadraticForm R M) (x y : M) :
+ polar (f.compQuadraticForm Q) x y = f (polar Q x y) := by
+ simp [polar]
+
+theorem _root_.LinearMap.compQuadraticForm_polarBilin (f : R →ₗ[S] S) (Q : QuadraticForm R M) :
+ (f.compQuadraticForm Q).polarBilin = f.compBilinForm Q.polarBilin :=
+ ext <| LinearMap.compQuadraticForm_polar _ _
+
end Ring
end BilinForm
@@ -771,18 +784,11 @@ 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.) -/
-def associatedHom : QuadraticForm R M →ₗ[S] BilinForm R M where
- toFun Q :=
- (⟨⅟ 2, fun x => (Commute.ofNat_right x 2).invOf_right⟩ : Submonoid.center R) • Q.polarBilin
- map_add' Q Q' := by
- ext
- simp only [BilinForm.add_apply, BilinForm.smul_apply, coeFn_mk, polarBilin_apply, polar_add,
- coeFn_add, smul_add]
- map_smul' s Q := by
- ext
- -- porting note: added type annotations
- simp only [RingHom.id_apply, polar_smul, smul_comm s (_ : Submonoid.center R) (_ : R),
- polarBilin_apply, coeFn_mk, coeFn_smul, BilinForm.smul_apply]
+def associatedHom : QuadraticForm R M →ₗ[S] BilinForm R M :=
+ (⟨⅟2, Set.invOf_mem_center (Set.ofNat_mem_center _ _)⟩ : Submonoid.center R) •
+ { toFun := polarBilin
+ map_add' := fun _x _y => BilinForm.ext <| polar_add _ _
+ map_smul' := fun _c _x => BilinForm.ext <| polar_smul _ _ }
#align quadratic_form.associated_hom QuadraticForm.associatedHom
variable (Q : QuadraticForm R M)
@@ -792,6 +798,11 @@ theorem associated_apply (x y : M) : associatedHom S Q x y = ⅟ 2 * (Q (x + y)
rfl
#align quadratic_form.associated_apply QuadraticForm.associated_apply
+@[simp] theorem two_nsmul_associated : 2 • associatedHom S Q = Q.polarBilin := by
+ ext
+ dsimp
+ rw [←smul_mul_assoc, two_nsmul, invOf_two_add_invOf_two, one_mul, polar]
+
theorem associated_isSymm : (associatedHom S Q).IsSymm := fun x y => by
simp only [associated_apply, add_comm, add_left_comm, sub_eq_add_neg, add_assoc]
#align quadratic_form.associated_is_symm QuadraticForm.associated_isSymm
@@ -805,7 +816,7 @@ theorem associated_comp {N : Type v} [AddCommGroup N] [Module R N] (f : N →ₗ
theorem associated_toQuadraticForm (B : BilinForm R M) (x y : M) :
associatedHom S B.toQuadraticForm x y = ⅟ 2 * (B x y + B y x) := by
- simp only [associated_apply, ← polar_to_quadratic_form, polar, toQuadraticForm_apply]
+ simp only [associated_apply, ← polar_toQuadraticForm, polar]
#align quadratic_form.associated_to_quadratic_form QuadraticForm.associated_toQuadraticForm
theorem associated_left_inverse (h : B₁.IsSymm) : associatedHom S B₁.toQuadraticForm = B₁ :=
@@ -859,7 +870,7 @@ end AssociatedHom
section Associated
-variable [CommRing R₁] [AddCommGroup M] [Module R₁ M]
+variable [CommSemiring S] [CommRing R₁] [AddCommGroup M] [Algebra S R₁] [Module R₁ M]
variable [Invertible (2 : R₁)]
@@ -871,6 +882,11 @@ abbrev associated : QuadraticForm R₁ M →ₗ[R₁] BilinForm R₁ M :=
associatedHom R₁
#align quadratic_form.associated QuadraticForm.associated
+variable (S) in
+theorem coe_associatedHom :
+ ⇑(associatedHom S : QuadraticForm R₁ M →ₗ[S] BilinForm R₁ M) = associated :=
+ rfl
+
@[simp]
theorem associated_linMulLin (f g : M →ₗ[R₁] R₁) :
associated (R₁ := R₁) (linMulLin f g) =
@@ -838,8 +838,9 @@ abbrev associated' : QuadraticForm R M →ₗ[ℤ] BilinForm R M :=
#align quadratic_form.associated' QuadraticForm.associated'
/-- Symmetric bilinear forms can be lifted to quadratic forms -/
-instance canLift : CanLift (BilinForm R M) (QuadraticForm R M) (associatedHom ℕ) BilinForm.IsSymm
- where prf B hB := ⟨B.toQuadraticForm, associated_left_inverse _ hB⟩
+instance canLift :
+ CanLift (BilinForm R M) (QuadraticForm R M) (associatedHom ℕ) BilinForm.IsSymm where
+ prf B hB := ⟨B.toQuadraticForm, associated_left_inverse _ hB⟩
#align quadratic_form.can_lift QuadraticForm.canLift
/-- There exists a non-null vector with respect to any quadratic form `Q` whose associated
@@ -630,7 +630,7 @@ end QuadraticForm
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`
+forms to bilinear forms giving this identification is called the `associated`
quadratic form.
-/
@@ -773,8 +773,7 @@ general ring with no nontrivial distinguished commutative subring, use `Quadrati
which gives an additive homomorphism (or more precisely a `ℤ`-linear map.) -/
def associatedHom : QuadraticForm R M →ₗ[S] BilinForm R M where
toFun Q :=
- ((· • ·) : Submonoid.center R → BilinForm R M → BilinForm R M)
- ⟨⅟ 2, fun x => (Commute.ofNat_right x 2).invOf_right⟩ Q.polarBilin
+ (⟨⅟ 2, fun x => (Commute.ofNat_right x 2).invOf_right⟩ : Submonoid.center R) • Q.polarBilin
map_add' Q Q' := by
ext
simp only [BilinForm.add_apply, BilinForm.smul_apply, coeFn_mk, polarBilin_apply, polar_add,
@@ -832,7 +831,7 @@ theorem associated_rightInverse :
fun Q => toQuadraticForm_associated S Q
#align quadratic_form.associated_right_inverse QuadraticForm.associated_rightInverse
-/-- `Associated'` is the `ℤ`-linear map that sends a quadratic form on a module `M` over `R` to its
+/-- `associated'` is the `ℤ`-linear map that sends a quadratic form on a module `M` over `R` to its
associated symmetric bilinear form. -/
abbrev associated' : QuadraticForm R M →ₗ[ℤ] BilinForm R M :=
associatedHom ℤ
@@ -958,12 +957,12 @@ theorem PosDef.anisotropic {Q : QuadraticForm R₂ M} (hQ : Q.PosDef) : Q.Anisot
exact this
#align quadratic_form.pos_def.anisotropic QuadraticForm.PosDef.anisotropic
-theorem posDefOfNonneg {Q : QuadraticForm R₂ M} (h : ∀ x, 0 ≤ Q x) (h0 : Q.Anisotropic) :
+theorem posDef_of_nonneg {Q : QuadraticForm R₂ M} (h : ∀ x, 0 ≤ Q x) (h0 : Q.Anisotropic) :
PosDef Q := fun x hx => lt_of_le_of_ne (h x) (Ne.symm fun hQx => hx <| h0 _ hQx)
-#align quadratic_form.pos_def_of_nonneg QuadraticForm.posDefOfNonneg
+#align quadratic_form.pos_def_of_nonneg QuadraticForm.posDef_of_nonneg
theorem posDef_iff_nonneg {Q : QuadraticForm R₂ M} : PosDef Q ↔ (∀ x, 0 ≤ Q x) ∧ Q.Anisotropic :=
- ⟨fun h => ⟨h.nonneg, h.anisotropic⟩, fun ⟨n, a⟩ => posDefOfNonneg n a⟩
+ ⟨fun h => ⟨h.nonneg, h.anisotropic⟩, fun ⟨n, a⟩ => posDef_of_nonneg n a⟩
#align quadratic_form.pos_def_iff_nonneg QuadraticForm.posDef_iff_nonneg
theorem PosDef.add (Q Q' : QuadraticForm R₂ M) (hQ : PosDef Q) (hQ' : PosDef Q') :
@@ -3,7 +3,6 @@ Copyright (c) 2020 Anne Baanen. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Anne Baanen, Kexing Ying, Eric Wieser
-/
-import Mathlib.Algebra.Invertible
import Mathlib.LinearAlgebra.Matrix.Determinant
import Mathlib.LinearAlgebra.Matrix.BilinearForm
import Mathlib.LinearAlgebra.Matrix.Symmetric
@@ -883,6 +883,11 @@ theorem associated_linMulLin (f g : M →ₗ[R₁] R₁) :
ring
#align quadratic_form.associated_lin_mul_lin QuadraticForm.associated_linMulLin
+@[simp]
+lemma associated_sq : associated (R₁ := R₁) sq = LinearMap.toBilin (LinearMap.mul R₁ R₁) :=
+ (associated_linMulLin (LinearMap.id) (LinearMap.id)).trans <|
+ by simp only [smul_add, invOf_two_smul_add_invOf_two_smul]; rfl
+
end Associated
section Anisotropic
⬝
notation in favor of HMul
(#6487)
The main difficulty here is that *
has a slightly difference precedence to ⬝
. notably around smul
and neg
.
The other annoyance is that ↑U ⬝ A ⬝ ↑U⁻¹ : Matrix m m 𝔸
now has to be written U.val * A * (U⁻¹).val
in order to typecheck.
A downside of this change to consider: if you have a goal of A * (B * C) = (A * B) * C
, mul_assoc
now gives the illusion of matching, when in fact Matrix.mul_assoc
is needed. Previously the distinct symbol made it easy to avoid this mistake.
On the flipside, there is now no need to rewrite by Matrix.mul_eq_mul
all the time (indeed, the lemma is now removed).
@@ -990,7 +990,7 @@ variable {n : Type w} [Fintype n] [DecidableEq n]
variable [CommRing R₁] [AddCommMonoid M] [Module R₁ M]
-/-- `M.toQuadraticForm'` is the map `fun x ↦ col x ⬝ M ⬝ row x` as a quadratic form. -/
+/-- `M.toQuadraticForm'` is the map `fun x ↦ col x * M * row x` as a quadratic form. -/
def Matrix.toQuadraticForm' (M : Matrix n n R₁) : QuadraticForm R₁ (n → R₁) :=
M.toBilin'.toQuadraticForm
#align matrix.to_quadratic_form' Matrix.toQuadraticForm'
@@ -1029,7 +1029,7 @@ open Matrix
@[simp]
theorem toMatrix'_comp (Q : QuadraticForm R₁ (m → R₁)) (f : (n → R₁) →ₗ[R₁] m → R₁) :
- (Q.comp f).toMatrix' = (LinearMap.toMatrix' f)ᵀ ⬝ Q.toMatrix' ⬝ (LinearMap.toMatrix' f) := by
+ (Q.comp f).toMatrix' = (LinearMap.toMatrix' f)ᵀ * Q.toMatrix' * (LinearMap.toMatrix' f) := by
ext
simp only [QuadraticForm.associated_comp, BilinForm.toMatrix'_comp, toMatrix']
#align quadratic_form.to_matrix'_comp QuadraticForm.toMatrix'_comp
Type _
and Sort _
(#6499)
We remove all possible occurences of Type _
and Sort _
in favor of Type*
and Sort*
.
This has nice performance benefits.
@@ -68,9 +68,9 @@ quadratic form, homogeneous polynomial, quadratic polynomial
universe u v w
-variable {S T : Type _}
+variable {S T : Type*}
-variable {R R₁ : Type _} {M : Type _}
+variable {R R₁ : Type*} {M : Type*}
open BigOperators
@@ -116,7 +116,7 @@ theorem polar_add_left_iff {f : M → R} {x x' y : M} :
add_right_comm (f (x + y)), add_left_inj]
#align quadratic_form.polar_add_left_iff QuadraticForm.polar_add_left_iff
-theorem polar_comp {F : Type _} [Ring S] [AddMonoidHomClass F R S] (f : M → R) (g : F) (x y : M) :
+theorem polar_comp {F : Type*} [Ring S] [AddMonoidHomClass F R S] (f : M → R) (g : F) (x y : M) :
polar (g ∘ f) x y = g (polar f x y) := by
simp only [polar, Pi.smul_apply, Function.comp_apply, map_sub]
#align quadratic_form.polar_comp QuadraticForm.polar_comp
@@ -457,13 +457,13 @@ def evalAddMonoidHom (m : M) : QuadraticForm R M →+ R :=
section Sum
@[simp]
-theorem coeFn_sum {ι : Type _} (Q : ι → QuadraticForm R M) (s : Finset ι) :
+theorem coeFn_sum {ι : Type*} (Q : ι → QuadraticForm R M) (s : Finset ι) :
⇑(∑ i in s, Q i) = ∑ i in s, ⇑(Q i) :=
(coeFnAddMonoidHom : QuadraticForm R M →+ M → R).map_sum Q s
#align quadratic_form.coe_fn_sum QuadraticForm.coeFn_sum
@[simp]
-theorem sum_apply {ι : Type _} (Q : ι → QuadraticForm R M) (s : Finset ι) (x : M) :
+theorem sum_apply {ι : Type*} (Q : ι → QuadraticForm R M) (s : Finset ι) (x : M) :
(∑ i in s, Q i) x = ∑ i in s, Q i x :=
(evalAddMonoidHom x : _ →+ R).map_sum Q s
#align quadratic_form.sum_apply QuadraticForm.sum_apply
@@ -554,7 +554,7 @@ theorem comp_apply (Q : QuadraticForm R N) (f : M →ₗ[R] N) (x : M) : (Q.comp
/-- Compose a quadratic form with a linear function on the left. -/
@[simps (config := { simpRhs := true })]
-def _root_.LinearMap.compQuadraticForm {S : Type _} [CommSemiring S] [Algebra S R] [Module S M]
+def _root_.LinearMap.compQuadraticForm {S : Type*} [CommSemiring S] [Algebra S R] [Module S M]
[IsScalarTower S R M] (f : R →ₗ[S] S) (Q : QuadraticForm R M) : QuadraticForm S M where
toFun x := f (Q x)
toFun_smul b x := by simp only [Q.map_smul_of_tower b x, f.map_smul, smul_eq_mul]
@@ -604,7 +604,7 @@ theorem linMulLin_comp (f g : M →ₗ[R] R) (h : N →ₗ[R] M) :
rfl
#align quadratic_form.lin_mul_lin_comp QuadraticForm.linMulLin_comp
-variable {n : Type _}
+variable {n : Type*}
/-- `sq` is the quadratic form mapping the vector `x : R₁` to `x * x` -/
@[simps!]
@@ -715,7 +715,7 @@ theorem toQuadraticForm_multiset_sum (B : Multiset (BilinForm R M)) :
#align bilin_form.to_quadratic_form_multiset_sum BilinForm.toQuadraticForm_multiset_sum
@[simp]
-theorem toQuadraticForm_sum {ι : Type _} (s : Finset ι) (B : ι → BilinForm R M) :
+theorem toQuadraticForm_sum {ι : Type*} (s : Finset ι) (B : ι → BilinForm R M) :
(∑ i in s, B i).toQuadraticForm = ∑ i in s, (B i).toQuadraticForm :=
map_sum (toQuadraticFormAddMonoidHom R M) B s
#align bilin_form.to_quadratic_form_sum BilinForm.toQuadraticForm_sum
@@ -940,7 +940,7 @@ theorem PosDef.smul {R} [LinearOrderedCommRing R] [Module R M] {Q : QuadraticFor
(h : PosDef Q) {a : R} (a_pos : 0 < a) : PosDef (a • Q) := fun x hx => mul_pos a_pos (h x hx)
#align quadratic_form.pos_def.smul QuadraticForm.PosDef.smul
-variable {n : Type _}
+variable {n : Type*}
theorem PosDef.nonneg {Q : QuadraticForm R₂ M} (hQ : PosDef Q) (x : M) : 0 ≤ Q x :=
(eq_or_ne x 0).elim (fun h => h.symm ▸ (map_zero Q).symm.le) fun h => (hQ _ h).le
@@ -1145,11 +1145,11 @@ namespace QuadraticForm
open Finset BilinForm
-variable {M₁ : Type _} [Semiring R] [CommSemiring R₁] [AddCommMonoid M] [AddCommMonoid M₁]
+variable {M₁ : Type*} [Semiring R] [CommSemiring R₁] [AddCommMonoid M] [AddCommMonoid M₁]
variable [Module R M] [Module R M₁]
-variable {ι : Type _} [Fintype ι] {v : Basis ι R M}
+variable {ι : Type*} [Fintype ι] {v : Basis ι R M}
/-- Given a quadratic form `Q` and a basis, `basisRepr` is the basis representation of `Q`. -/
noncomputable def basisRepr (Q : QuadraticForm R M) (v : Basis ι R M) : QuadraticForm R (ι → R) :=
This is needed to state that the base change of a quadratic form is itself a linear operation.
Also adds a linear version of BilinForm.toQuadraticForm
, and cleans up some docstrings that had been mangled by fix-comments.py
@@ -68,7 +68,7 @@ quadratic form, homogeneous polynomial, quadratic polynomial
universe u v w
-variable {S : Type _}
+variable {S T : Type _}
variable {R R₁ : Type _} {M : Type _}
@@ -365,7 +365,8 @@ variable [Semiring R] [AddCommMonoid M] [Module R M]
section SMul
-variable [Monoid S] [DistribMulAction S R] [SMulCommClass S R R]
+variable [Monoid S] [Monoid T] [DistribMulAction S R] [DistribMulAction T R]
+variable [SMulCommClass S R R] [SMulCommClass T R R]
/-- `QuadraticForm R M` inherits the scalar action from any algebra over `R`.
@@ -388,6 +389,12 @@ theorem smul_apply (a : S) (Q : QuadraticForm R M) (x : M) : (a • Q) x = a •
rfl
#align quadratic_form.smul_apply QuadraticForm.smul_apply
+instance [SMulCommClass S T R] : SMulCommClass S T (QuadraticForm R M) where
+ smul_comm _s _t _q := ext <| fun _ => smul_comm _ _ _
+
+instance [SMul S T] [IsScalarTower S T R] : IsScalarTower S T (QuadraticForm R M) where
+ smul_assoc _s _t _q := ext <| fun _ => smul_assoc _ _ _
+
end SMul
instance : Zero (QuadraticForm R M) :=
@@ -675,7 +682,7 @@ theorem toQuadraticForm_smul [Monoid S] [DistribMulAction S R] [SMulCommClass S
section
-variable (R M)
+variable (S R M)
/-- `BilinForm.toQuadraticForm` as an additive homomorphism -/
@[simps]
@@ -685,6 +692,14 @@ def toQuadraticFormAddMonoidHom : BilinForm R M →+ QuadraticForm R M where
map_add' := toQuadraticForm_add
#align bilin_form.to_quadratic_form_add_monoid_hom BilinForm.toQuadraticFormAddMonoidHom
+/-- `BilinForm.toQuadraticForm` as a linear map -/
+@[simps!]
+def toQuadraticFormLinearMap [Semiring S] [Module S R] [SMulCommClass S R R] :
+ BilinForm R M →ₗ[S] QuadraticForm R M where
+ toFun := toQuadraticForm
+ map_smul' := toQuadraticForm_smul
+ map_add' := toQuadraticForm_add
+
end
@[simp]
@@ -754,9 +769,9 @@ variable [Invertible (2 : R)] {B₁ : BilinForm R M}
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.) -/
+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.) -/
def associatedHom : QuadraticForm R M →ₗ[S] BilinForm R M where
toFun Q :=
((· • ·) : Submonoid.center R → BilinForm R M → BilinForm R M)
@@ -850,7 +865,7 @@ variable [CommRing R₁] [AddCommGroup M] [Module R₁ M]
variable [Invertible (2 : R₁)]
-- Note: When possible, rather than writing lemmas about `associated`, write a lemma applying to
--- the more general `AssociatedHom` and place it in the previous section.
+-- the more general `associatedHom` and place it in the previous section.
/-- `associated` is the linear map that sends a quadratic form over a commutative ring to its
associated symmetric bilinear form. -/
abbrev associated : QuadraticForm R₁ M →ₗ[R₁] BilinForm R₁ M :=
@@ -2,17 +2,14 @@
Copyright (c) 2020 Anne Baanen. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Anne Baanen, Kexing Ying, Eric Wieser
-
-! This file was ported from Lean 3 source module linear_algebra.quadratic_form.basic
-! leanprover-community/mathlib commit 11b92770e4d49ff3982504c4dab918ac0887fe33
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Mathlib.Algebra.Invertible
import Mathlib.LinearAlgebra.Matrix.Determinant
import Mathlib.LinearAlgebra.Matrix.BilinearForm
import Mathlib.LinearAlgebra.Matrix.Symmetric
+#align_import linear_algebra.quadratic_form.basic from "leanprover-community/mathlib"@"11b92770e4d49ff3982504c4dab918ac0887fe33"
+
/-!
# Quadratic forms
ext
(#5258)
Co-authored-by: Xavier Roblot <46200072+xroblot@users.noreply.github.com> Co-authored-by: Joël Riou <joel.riou@universite-paris-saclay.fr> Co-authored-by: Riccardo Brasca <riccardo.brasca@gmail.com> Co-authored-by: Yury G. Kudryashov <urkud@urkud.name> Co-authored-by: Scott Morrison <scott.morrison@anu.edu.au> Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Jeremy Tan Jie Rui <reddeloostw@gmail.com> Co-authored-by: Pol'tta / Miyahara Kō <pol_tta@outlook.jp> Co-authored-by: Jason Yuen <jason_yuen2007@hotmail.com> Co-authored-by: Mario Carneiro <di.gama@gmail.com> Co-authored-by: Jireh Loreaux <loreaujy@gmail.com> Co-authored-by: Ruben Van de Velde <65514131+Ruben-VandeVelde@users.noreply.github.com> Co-authored-by: Kyle Miller <kmill31415@gmail.com> Co-authored-by: Heather Macbeth <25316162+hrmacbeth@users.noreply.github.com> Co-authored-by: Jujian Zhang <jujian.zhang1998@outlook.com> Co-authored-by: Yaël Dillies <yael.dillies@gmail.com>
@@ -998,7 +998,7 @@ theorem QuadraticForm.toMatrix'_smul (a : R₁) (Q : QuadraticForm R₁ (n → R
#align quadratic_form.to_matrix'_smul QuadraticForm.toMatrix'_smul
theorem QuadraticForm.isSymm_toMatrix' (Q : QuadraticForm R₁ (n → R₁)) : Q.toMatrix'.IsSymm := by
- ext (i j)
+ ext i j
rw [toMatrix', Matrix.transpose_apply, BilinForm.toMatrix'_apply, BilinForm.toMatrix'_apply,
associated_isSymm]
#align quadratic_form.is_symm_to_matrix' QuadraticForm.isSymm_toMatrix'
@@ -21,7 +21,7 @@ A quadratic form on a ring `R` is a map `Q : M → R` such that:
* `QuadraticForm.map_smul`: `Q (a • x) = a * a * Q x`
* `QuadraticForm.polar_add_left`, `QuadraticForm.polar_add_right`,
`QuadraticForm.polar_smul_left`, `QuadraticForm.polar_smul_right`:
- the map `QuadraticForm.polar Q := λ x y, Q (x + y) - Q x - Q y` is bilinear.
+ the map `QuadraticForm.polar Q := fun 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
@@ -978,7 +978,7 @@ variable {n : Type w} [Fintype n] [DecidableEq n]
variable [CommRing R₁] [AddCommMonoid M] [Module R₁ M]
-/-- `M.toQuadraticForm'` is the map `λ x, col x ⬝ M ⬝ row x` as a quadratic form. -/
+/-- `M.toQuadraticForm'` is the map `fun x ↦ col x ⬝ M ⬝ row x` as a quadratic form. -/
def Matrix.toQuadraticForm' (M : Matrix n n R₁) : QuadraticForm R₁ (n → R₁) :=
M.toBilin'.toQuadraticForm
#align matrix.to_quadratic_form' Matrix.toQuadraticForm'
The unported dependencies are