Skip to content

Commit 2d11c66

Browse files
committed
chore(LinearAlgebra/QuadraticForm): scalar tower instances and cleanup (#6433)
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`
1 parent 003e3ca commit 2d11c66

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

Mathlib/LinearAlgebra/QuadraticForm/Basic.lean

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ quadratic form, homogeneous polynomial, quadratic polynomial
6868

6969
universe u v w
7070

71-
variable {S : Type _}
71+
variable {S T : Type _}
7272

7373
variable {R R₁ : Type _} {M : Type _}
7474

@@ -365,7 +365,8 @@ variable [Semiring R] [AddCommMonoid M] [Module R M]
365365

366366
section SMul
367367

368-
variable [Monoid S] [DistribMulAction S R] [SMulCommClass S R R]
368+
variable [Monoid S] [Monoid T] [DistribMulAction S R] [DistribMulAction T R]
369+
variable [SMulCommClass S R R] [SMulCommClass T R R]
369370

370371
/-- `QuadraticForm R M` inherits the scalar action from any algebra over `R`.
371372
@@ -388,6 +389,12 @@ theorem smul_apply (a : S) (Q : QuadraticForm R M) (x : M) : (a • Q) x = a •
388389
rfl
389390
#align quadratic_form.smul_apply QuadraticForm.smul_apply
390391

392+
instance [SMulCommClass S T R] : SMulCommClass S T (QuadraticForm R M) where
393+
smul_comm _s _t _q := ext <| fun _ => smul_comm _ _ _
394+
395+
instance [SMul S T] [IsScalarTower S T R] : IsScalarTower S T (QuadraticForm R M) where
396+
smul_assoc _s _t _q := ext <| fun _ => smul_assoc _ _ _
397+
391398
end SMul
392399

393400
instance : Zero (QuadraticForm R M) :=
@@ -675,7 +682,7 @@ theorem toQuadraticForm_smul [Monoid S] [DistribMulAction S R] [SMulCommClass S
675682

676683
section
677684

678-
variable (R M)
685+
variable (S R M)
679686

680687
/-- `BilinForm.toQuadraticForm` as an additive homomorphism -/
681688
@[simps]
@@ -685,6 +692,14 @@ def toQuadraticFormAddMonoidHom : BilinForm R M →+ QuadraticForm R M where
685692
map_add' := toQuadraticForm_add
686693
#align bilin_form.to_quadratic_form_add_monoid_hom BilinForm.toQuadraticFormAddMonoidHom
687694

695+
/-- `BilinForm.toQuadraticForm` as a linear map -/
696+
@[simps!]
697+
def toQuadraticFormLinearMap [Semiring S] [Module S R] [SMulCommClass S R R] :
698+
BilinForm R M →ₗ[S] QuadraticForm R M where
699+
toFun := toQuadraticForm
700+
map_smul' := toQuadraticForm_smul
701+
map_add' := toQuadraticForm_add
702+
688703
end
689704

690705
@[simp]
@@ -754,9 +769,9 @@ variable [Invertible (2 : R)] {B₁ : BilinForm R M}
754769
associated symmetric bilinear form. As provided here, this has the structure of an `S`-linear map
755770
where `S` is a commutative subring of `R`.
756771
757-
Over a commutative ring, use `Associated`, which gives an `R`-linear map. Over a general ring with
758-
no nontrivial distinguished commutative subring, use `Associated'`, which gives an additive
759-
homomorphism (or more precisely a `ℤ`-linear map.) -/
772+
Over a commutative ring, use `QuadraticForm.associated`, which gives an `R`-linear map. Over a
773+
general ring with no nontrivial distinguished commutative subring, use `QuadraticForm.associated'`,
774+
which gives an additive homomorphism (or more precisely a `ℤ`-linear map.) -/
760775
def associatedHom : QuadraticForm R M →ₗ[S] BilinForm R M where
761776
toFun Q :=
762777
((· • ·) : Submonoid.center R → BilinForm R M → BilinForm R M)
@@ -850,7 +865,7 @@ variable [CommRing R₁] [AddCommGroup M] [Module R₁ M]
850865
variable [Invertible (2 : R₁)]
851866

852867
-- Note: When possible, rather than writing lemmas about `associated`, write a lemma applying to
853-
-- the more general `AssociatedHom` and place it in the previous section.
868+
-- the more general `associatedHom` and place it in the previous section.
854869
/-- `associated` is the linear map that sends a quadratic form over a commutative ring to its
855870
associated symmetric bilinear form. -/
856871
abbrev associated : QuadraticForm R₁ M →ₗ[R₁] BilinForm R₁ M :=

0 commit comments

Comments
 (0)