Skip to content

Commit 2cd05f0

Browse files
committed
feat(LinearAlgebra/QuadraticForm/Basic): more lemmas (#7196)
This also adds a handful of missing lemmas about `Set.center` for inverses and numeric literals.
1 parent 57a494b commit 2cd05f0

3 files changed

Lines changed: 77 additions & 24 deletions

File tree

Mathlib/GroupTheory/Subsemigroup/Center.lean

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Eric Wieser, Jireh Loreaux
55
-/
66
import Mathlib.Algebra.Ring.Defs
7+
import Mathlib.Algebra.Group.Commute.Units
8+
import Mathlib.Algebra.Invertible.Basic
79
import Mathlib.GroupTheory.Subsemigroup.Operations
10+
import Mathlib.Data.Int.Cast.Lemmas
811

912
#align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353"
1013

@@ -56,6 +59,19 @@ theorem one_mem_center [MulOneClass M] : (1 : M) ∈ Set.center M := by simp [me
5659
theorem zero_mem_center [MulZeroClass M] : (0 : M) ∈ Set.center M := by simp [mem_center_iff]
5760
#align set.zero_mem_center Set.zero_mem_center
5861

62+
@[simp]
63+
theorem natCast_mem_center [NonAssocSemiring M] (n : ℕ) : (n : M) ∈ Set.center M :=
64+
(Nat.commute_cast · _)
65+
66+
@[simp]
67+
theorem ofNat_mem_center [NonAssocSemiring M] (n : ℕ) [n.AtLeastTwo] :
68+
OfNat.ofNat n ∈ Set.center M :=
69+
natCast_mem_center M n
70+
71+
@[simp]
72+
theorem intCast_mem_center [NonAssocRing M] (n : ℤ) : (n : M) ∈ Set.center M :=
73+
(Int.commute_cast · _)
74+
5975
variable {M}
6076

6177
@[to_additive (attr := simp) add_mem_addCenter]
@@ -100,14 +116,23 @@ theorem center_units_eq [GroupWithZero M] : Set.center Mˣ = ((↑) : Mˣ → M)
100116
Subset.antisymm center_units_subset subset_center_units
101117
#align set.center_units_eq Set.center_units_eq
102118

119+
@[simp]
120+
theorem units_inv_mem_center [Monoid M] {a : Mˣ} (ha : ↑a ∈ Set.center M) :
121+
↑a⁻¹ ∈ Set.center M :=
122+
(Commute.units_inv_right <| ha ·)
123+
124+
@[simp]
125+
theorem invOf_mem_center [Monoid M] {a : M} [Invertible a] (ha : a ∈ Set.center M) :
126+
⅟a ∈ Set.center M :=
127+
(Commute.invOf_right <| ha ·)
128+
103129
@[simp]
104130
theorem inv_mem_center₀ [GroupWithZero M] {a : M} (ha : a ∈ Set.center M) : a⁻¹ ∈ Set.center M := by
105131
obtain rfl | ha0 := eq_or_ne a 0
106132
· rw [inv_zero]
107133
exact zero_mem_center M
108-
rcases IsUnit.mk0 _ ha0 with ⟨a, rfl⟩
109-
rw [← Units.val_inv_eq_inv_val]
110-
exact center_units_subset (inv_mem_center (subset_center_units ha))
134+
· lift a to Mˣ using IsUnit.mk0 _ ha0
135+
simpa only [Units.val_inv_eq_inv_val] using units_inv_mem_center ha
111136
#align set.inv_mem_center₀ Set.inv_mem_center₀
112137

113138
@[to_additive (attr := simp) sub_mem_addCenter]

Mathlib/LinearAlgebra/QuadraticForm/Basic.lean

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ theorem comp_apply (Q : QuadraticForm R N) (f : M →ₗ[R] N) (x : M) : (Q.comp
553553

554554
/-- Compose a quadratic form with a linear function on the left. -/
555555
@[simps (config := { simpRhs := true })]
556-
def _root_.LinearMap.compQuadraticForm {S : Type*} [CommSemiring S] [Algebra S R] [Module S M]
556+
def _root_.LinearMap.compQuadraticForm [CommSemiring S] [Algebra S R] [Module S M]
557557
[IsScalarTower S R M] (f : R →ₗ[S] S) (Q : QuadraticForm R M) : QuadraticForm S M where
558558
toFun x := f (Q x)
559559
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]
732732

733733
variable {B : BilinForm R M}
734734

735-
theorem polar_to_quadratic_form (x y : M) : polar (fun x => B x x) x y = B x y + B y x := by
736-
simp only [add_assoc, add_sub_cancel', add_right, polar, add_left_inj, add_neg_cancel_left,
737-
add_left, sub_eq_add_neg _ (B y y), add_comm (B y x) _]
738-
#align bilin_form.polar_to_quadratic_form BilinForm.polar_to_quadratic_form
739-
740735
@[simp]
741736
theorem toQuadraticForm_neg (B : BilinForm R M) : (-B).toQuadraticForm = -B.toQuadraticForm :=
742737
rfl
@@ -748,6 +743,24 @@ theorem toQuadraticForm_sub (B₁ B₂ : BilinForm R M) :
748743
rfl
749744
#align bilin_form.to_quadratic_form_sub BilinForm.toQuadraticForm_sub
750745

746+
theorem polar_toQuadraticForm (x y : M) : polar (toQuadraticForm B) x y = B x y + B y x := by
747+
simp only [toQuadraticForm_apply, add_assoc, add_sub_cancel', add_right, polar, add_left_inj,
748+
add_neg_cancel_left, add_left, sub_eq_add_neg _ (B y y), add_comm (B y x) _]
749+
#align bilin_form.polar_to_quadratic_form BilinForm.polar_toQuadraticForm
750+
751+
theorem polarBilin_toQuadraticForm : polarBilin (toQuadraticForm B) = B + flip' B :=
752+
BilinForm.ext polar_toQuadraticForm
753+
754+
variable [CommRing S] [Algebra S R] [Module S M] [IsScalarTower S R M]
755+
756+
theorem _root_.LinearMap.compQuadraticForm_polar (f : R →ₗ[S] S) (Q : QuadraticForm R M) (x y : M) :
757+
polar (f.compQuadraticForm Q) x y = f (polar Q x y) := by
758+
simp [polar]
759+
760+
theorem _root_.LinearMap.compQuadraticForm_polarBilin (f : R →ₗ[S] S) (Q : QuadraticForm R M) :
761+
(f.compQuadraticForm Q).polarBilin = f.compBilinForm Q.polarBilin :=
762+
ext <| LinearMap.compQuadraticForm_polar _ _
763+
751764
end Ring
752765

753766
end BilinForm
@@ -771,18 +784,11 @@ where `S` is a commutative subring of `R`.
771784
Over a commutative ring, use `QuadraticForm.associated`, which gives an `R`-linear map. Over a
772785
general ring with no nontrivial distinguished commutative subring, use `QuadraticForm.associated'`,
773786
which gives an additive homomorphism (or more precisely a `ℤ`-linear map.) -/
774-
def associatedHom : QuadraticForm R M →ₗ[S] BilinForm R M where
775-
toFun Q :=
776-
(⟨⅟ 2, fun x => (Commute.ofNat_right x 2).invOf_right⟩ : Submonoid.center R) • Q.polarBilin
777-
map_add' Q Q' := by
778-
ext
779-
simp only [BilinForm.add_apply, BilinForm.smul_apply, coeFn_mk, polarBilin_apply, polar_add,
780-
coeFn_add, smul_add]
781-
map_smul' s Q := by
782-
ext
783-
-- porting note: added type annotations
784-
simp only [RingHom.id_apply, polar_smul, smul_comm s (_ : Submonoid.center R) (_ : R),
785-
polarBilin_apply, coeFn_mk, coeFn_smul, BilinForm.smul_apply]
787+
def associatedHom : QuadraticForm R M →ₗ[S] BilinForm R M :=
788+
(⟨⅟2, Set.invOf_mem_center (Set.ofNat_mem_center _ _)⟩ : Submonoid.center R) •
789+
{ toFun := polarBilin
790+
map_add' := fun _x _y => BilinForm.ext <| polar_add _ _
791+
map_smul' := fun _c _x => BilinForm.ext <| polar_smul _ _ }
786792
#align quadratic_form.associated_hom QuadraticForm.associatedHom
787793

788794
variable (Q : QuadraticForm R M)
@@ -792,6 +798,11 @@ theorem associated_apply (x y : M) : associatedHom S Q x y = ⅟ 2 * (Q (x + y)
792798
rfl
793799
#align quadratic_form.associated_apply QuadraticForm.associated_apply
794800

801+
@[simp] theorem two_nsmul_associated : 2 • associatedHom S Q = Q.polarBilin := by
802+
ext
803+
dsimp
804+
rw [←smul_mul_assoc, two_nsmul, invOf_two_add_invOf_two, one_mul, polar]
805+
795806
theorem associated_isSymm : (associatedHom S Q).IsSymm := fun x y => by
796807
simp only [associated_apply, add_comm, add_left_comm, sub_eq_add_neg, add_assoc]
797808
#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 →ₗ
805816

806817
theorem associated_toQuadraticForm (B : BilinForm R M) (x y : M) :
807818
associatedHom S B.toQuadraticForm x y = ⅟ 2 * (B x y + B y x) := by
808-
simp only [associated_apply, ← polar_to_quadratic_form, polar, toQuadraticForm_apply]
819+
simp only [associated_apply, ← polar_toQuadraticForm, polar]
809820
#align quadratic_form.associated_to_quadratic_form QuadraticForm.associated_toQuadraticForm
810821

811822
theorem associated_left_inverse (h : B₁.IsSymm) : associatedHom S B₁.toQuadraticForm = B₁ :=
@@ -859,7 +870,7 @@ end AssociatedHom
859870

860871
section Associated
861872

862-
variable [CommRing R₁] [AddCommGroup M] [Module R₁ M]
873+
variable [CommSemiring S] [CommRing R₁] [AddCommGroup M] [Algebra S R₁] [Module R₁ M]
863874

864875
variable [Invertible (2 : R₁)]
865876

@@ -871,6 +882,11 @@ abbrev associated : QuadraticForm R₁ M →ₗ[R₁] BilinForm R₁ M :=
871882
associatedHom R₁
872883
#align quadratic_form.associated QuadraticForm.associated
873884

885+
variable (S) in
886+
theorem coe_associatedHom :
887+
⇑(associatedHom S : QuadraticForm R₁ M →ₗ[S] BilinForm R₁ M) = associated :=
888+
rfl
889+
874890
@[simp]
875891
theorem associated_linMulLin (f g : M →ₗ[R₁] R₁) :
876892
associated (R₁ := R₁) (linMulLin f g) =

Mathlib/LinearAlgebra/QuadraticForm/TensorProduct.lean

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ theorem associated_tmul [Invertible (2 : A)] (Q₁ : QuadraticForm A M₁) (Q₂
6969
dsimp
7070
convert associated_left_inverse A ((associated_isSymm A Q₁).tmul (associated_isSymm R Q₂))
7171

72+
theorem polarBilin_tmul [Invertible (2 : A)] (Q₁ : QuadraticForm A M₁) (Q₂ : QuadraticForm R M₂) :
73+
polarBilin (Q₁.tmul Q₂) = ⅟(2 : A) • (polarBilin Q₁).tmul (polarBilin Q₂) := by
74+
simp_rw [←two_nsmul_associated A, ←two_nsmul_associated R, BilinForm.tmul, map_smul, tmul_smul,
75+
←smul_tmul', map_nsmul, associated_tmul]
76+
rw [smul_comm (_ : A) (_ : ℕ), ← smul_assoc, two_smul _ (_ : A), invOf_two_add_invOf_two,
77+
one_smul]
78+
7279
variable (A) in
7380
/-- The base change of a quadratic form. -/
7481
protected def baseChange (Q : QuadraticForm R M₂) : QuadraticForm A (A ⊗[R] M₂) :=
@@ -79,12 +86,17 @@ theorem baseChange_tmul (Q : QuadraticForm R M₂) (a : A) (m₂ : M₂) :
7986
Q.baseChange A (a ⊗ₜ m₂) = Q m₂ • (a * a) :=
8087
tensorDistrib_tmul _ _ _ _
8188

82-
8389
theorem associated_baseChange [Invertible (2 : A)] (Q : QuadraticForm R M₂) :
8490
associated (R₁ := A) (Q.baseChange A) = (associated (R₁ := R) Q).baseChange A := by
8591
dsimp only [QuadraticForm.baseChange, BilinForm.baseChange]
8692
rw [associated_tmul (QuadraticForm.sq (R := A)) Q, associated_sq]
8793

94+
theorem polarBilin_baseChange [Invertible (2 : A)] (Q : QuadraticForm R M₂) :
95+
polarBilin (Q.baseChange A) = (polarBilin Q).baseChange A := by
96+
rw [QuadraticForm.baseChange, BilinForm.baseChange, polarBilin_tmul, BilinForm.tmul,
97+
←LinearMap.map_smul, smul_tmul', ←two_nsmul_associated R, coe_associatedHom, associated_sq,
98+
smul_comm, ← smul_assoc, two_smul, invOf_two_add_invOf_two, one_smul]
99+
88100
end CommRing
89101

90102
end QuadraticForm

0 commit comments

Comments
 (0)