Skip to content

Commit 922e827

Browse files
committed
chore(LinearAlgebra/QuadraticForm): fixups to #10097 (#10167)
I didn't get a chance to review #10097 before it was merged; this contains some minor fixups. This removes `LinearMap.linMulLin`, as it can be recovered easily via `LinearMap.mul`.
1 parent 2ae084b commit 922e827

File tree

3 files changed

+35
-22
lines changed

3 files changed

+35
-22
lines changed

Mathlib/Algebra/Algebra/Bilinear.lean

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,26 @@ open TensorProduct Module
2222

2323
namespace LinearMap
2424

25+
section RestrictScalars
26+
27+
variable
28+
(R : Type*) {A M N P : Type*}
29+
[CommSemiring R] [CommSemiring A]
30+
[AddCommMonoid M] [AddCommMonoid N] [AddCommMonoid P]
31+
[Algebra R A]
32+
[Module R M] [Module R N] [Module R P]
33+
[Module A M] [Module A N] [Module A P]
34+
[IsScalarTower R A M] [IsScalarTower R A N] [IsScalarTower R A P]
35+
36+
/-- A version of `LinearMap.restrictScalars` for bilinear maps.
37+
38+
The double subscript in the name is to match `LinearMap.compl₁₂`. -/
39+
@[simps!]
40+
def restrictScalars₁₂ (f : M →ₗ[A] N →ₗ[A] P) : M →ₗ[R] N →ₗ[R] P :=
41+
(f.flip.restrictScalars _).flip.restrictScalars _
42+
43+
end RestrictScalars
44+
2545
section NonUnitalNonAssoc
2646

2747
variable (R A : Type*) [CommSemiring R] [NonUnitalNonAssocSemiring A] [Module R A]

Mathlib/LinearAlgebra/BilinearMap.lean

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -404,13 +404,6 @@ abbrev _root_.Submodule.restrictBilinear (p : Submodule R M) (f : M →ₗ[R] M
404404
p →ₗ[R] p →ₗ[R] R :=
405405
f.compl₁₂ p.subtype p.subtype
406406

407-
/-- `linMulLin f g` is the bilinear form mapping `x` and `y` to `f x * g y` -/
408-
def linMulLin (f g : M →ₗ[R] R) : M →ₗ[R] M →ₗ[R] R :=
409-
LinearMap.mk₂ R (fun x y => f x * g y) (fun x y z => by simp only [map_add, add_mul])
410-
(fun _ _ => by simp only [SMulHomClass.map_smul, smul_eq_mul, mul_assoc, forall_const])
411-
(fun _ _ _ => by simp only [map_add, mul_add])
412-
(fun _ _ => by simp only [SMulHomClass.map_smul, smul_eq_mul, mul_left_comm, forall_const])
413-
414407
end CommSemiring
415408

416409
section CommRing

Mathlib/LinearAlgebra/QuadraticForm/Basic.lean

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ variable [CommSemiring R] [AddCommMonoid M] [Module R M]
382382
section SMul
383383

384384
variable [Monoid S] [Monoid T] [DistribMulAction S R] [DistribMulAction T R]
385-
variable [SMulCommClass R S R] [SMulCommClass S R R] [SMulCommClass T R R] [SMulCommClass R T R]
385+
variable [SMulCommClass S R R] [SMulCommClass T R R]
386386

387387
/-- `QuadraticForm R M` inherits the scalar action from any algebra over `R`.
388388
@@ -393,6 +393,7 @@ instance : SMul S (QuadraticForm R M) :=
393393
toFun_smul := fun b x => by rw [Pi.smul_apply, map_smul, Pi.smul_apply, mul_smul_comm]
394394
exists_companion' :=
395395
let ⟨B, h⟩ := Q.exists_companion
396+
letI := SMulCommClass.symm S R R
396397
⟨a • B, by simp [h]⟩ }⟩
397398

398399
@[simp]
@@ -486,7 +487,7 @@ theorem sum_apply {ι : Type*} (Q : ι → QuadraticForm R M) (s : Finset ι) (x
486487

487488
end Sum
488489

489-
instance [Monoid S] [DistribMulAction S R] [SMulCommClass S R R] [SMulCommClass R S R] :
490+
instance [Monoid S] [DistribMulAction S R] [SMulCommClass S R R] :
490491
DistribMulAction S (QuadraticForm R M) where
491492
mul_smul a b Q := ext fun x => by simp only [smul_apply, mul_smul]
492493
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
497498
ext
498499
simp only [zero_apply, smul_apply, smul_zero]
499500

500-
instance [Semiring S] [Module S R] [SMulCommClass S R R] [SMulCommClass R S R] :
501+
instance [Semiring S] [Module S R] [SMulCommClass S R R] :
501502
Module S (QuadraticForm R M) where
502503
zero_smul Q := by
503504
ext
@@ -577,9 +578,8 @@ def _root_.LinearMap.compQuadraticForm [CommSemiring S] [Algebra S R] [Module S
577578
toFun_smul b x := by simp only [Q.map_smul_of_tower b x, f.map_smul, smul_eq_mul]
578579
exists_companion' :=
579580
let ⟨B, h⟩ := Q.exists_companion
580-
⟨(LinearMap.restrictScalars S (LinearMap.restrictScalars S B.flip).flip).compr₂ f, fun x y => by
581-
simp_rw [h, f.map_add]
582-
rfl⟩
581+
⟨(B.restrictScalars₁₂ S).compr₂ f, fun x y => by
582+
simp_rw [h, f.map_add, LinearMap.compr₂_apply, LinearMap.restrictScalars₁₂_apply_apply]⟩
583583
#align linear_map.comp_quadratic_form LinearMap.compQuadraticForm
584584

585585
end Comp
@@ -595,9 +595,9 @@ def linMulLin (f g : M →ₗ[R] R) : QuadraticForm R M where
595595
simp only [smul_eq_mul, RingHom.id_apply, Pi.mul_apply, LinearMap.map_smulₛₗ]
596596
ring
597597
exists_companion' :=
598-
⟨LinearMap.linMulLin f g + LinearMap.linMulLin g f, fun x y => by
599-
simp only [Pi.mul_apply, map_add, LinearMap.linMulLin, LinearMap.add_apply,
600-
LinearMap.mk₂_apply]
598+
(LinearMap.mul R R).compl₁₂ f g + (LinearMap.mul R R).compl₁₂ g f, fun x y => by
599+
simp only [Pi.mul_apply, map_add, LinearMap.compl₁₂_apply, LinearMap.mul_apply',
600+
LinearMap.add_apply]
601601
ring_nf⟩
602602
#align quadratic_form.lin_mul_lin QuadraticForm.linMulLin
603603

@@ -664,7 +664,7 @@ section Semiring
664664
variable [CommSemiring R] [AddCommMonoid M] [Module R M]
665665

666666
/-- A bilinear map into `R` gives a quadratic form by applying the argument twice. -/
667-
def _root_.LinearMap.toQuadraticForm (B: M →ₗ[R] M →ₗ[R] R) : QuadraticForm R M where
667+
def _root_.LinearMap.toQuadraticForm (B : M →ₗ[R] M →ₗ[R] R) : QuadraticForm R M where
668668
toFun x := B x x
669669
toFun_smul a x := by
670670
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) :
702702

703703
@[simp]
704704
theorem toQuadraticForm_smul [Monoid S] [DistribMulAction S R] [SMulCommClass S R R]
705-
[SMulCommClass R S R] (a : S) (B : BilinForm R M) :
705+
(a : S) (B : BilinForm R M) :
706706
(a • B).toQuadraticForm = a • B.toQuadraticForm :=
707707
rfl
708708
#align bilin_form.to_quadratic_form_smul BilinForm.toQuadraticForm_smul
@@ -721,7 +721,7 @@ def toQuadraticFormAddMonoidHom : BilinForm R M →+ QuadraticForm R M where
721721

722722
/-- `BilinForm.toQuadraticForm` as a linear map -/
723723
@[simps!]
724-
def toQuadraticFormLinearMap [Semiring S] [Module S R] [SMulCommClass S R R] [SMulCommClass R S R] :
724+
def toQuadraticFormLinearMap [Semiring S] [Module S R] [SMulCommClass S R R] :
725725
BilinForm R M →ₗ[S] QuadraticForm R M where
726726
toFun := toQuadraticForm
727727
map_smul' := toQuadraticForm_smul
@@ -1292,16 +1292,16 @@ variable (R)
12921292
12931293
The weights are applied using `•`; typically this definition is used either with `S = R` or
12941294
`[Algebra S R]`, although this is stated more generally. -/
1295-
def weightedSumSquares [Monoid S] [DistribMulAction S R] [SMulCommClass S R R] [SMulCommClass R S R]
1296-
(w : ι → S) : QuadraticForm R (ι → R) :=
1295+
def weightedSumSquares [Monoid S] [DistribMulAction S R] [SMulCommClass S R R] (w : ι → S) :
1296+
QuadraticForm R (ι → R) :=
12971297
∑ i : ι, w i • proj i i
12981298
#align quadratic_form.weighted_sum_squares QuadraticForm.weightedSumSquares
12991299

13001300
end
13011301

13021302
@[simp]
13031303
theorem weightedSumSquares_apply [Monoid S] [DistribMulAction S R] [SMulCommClass S R R]
1304-
[SMulCommClass R S R] (w : ι → S) (v : ι → R) :
1304+
(w : ι → S) (v : ι → R) :
13051305
weightedSumSquares R w v = ∑ i : ι, w i • (v i * v i) :=
13061306
QuadraticForm.sum_apply _ _ _
13071307
#align quadratic_form.weighted_sum_squares_apply QuadraticForm.weightedSumSquares_apply

0 commit comments

Comments
 (0)