Skip to content

Commit 09fe2f6

Browse files
committed
fix: generalize CommSemiring to Semiring for bilinear map composition
This file could do with further variable cleanup, but that's left for a later PR.
1 parent 9858d11 commit 09fe2f6

1 file changed

Lines changed: 53 additions & 44 deletions

File tree

Mathlib/LinearAlgebra/BilinearMap.lean

Lines changed: 53 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -220,21 +220,65 @@ theorem lflip_apply {R₀ : Type*} [Semiring R₀] [Module R₀ P] [SMulCommClas
220220

221221
end Semiring
222222

223+
section Semiring'
224+
225+
variable {R : Type*} [Semiring R] {R₂ : Type*} [Semiring R₂]
226+
variable {A : Type*} [Semiring A] {B : Type*} [Semiring B]
227+
variable {R₃ : Type*} [Semiring R₃] {R₄ : Type*} [Semiring R₄]
228+
variable {M : Type*} {N : Type*} {P : Type*} {Q : Type*}
229+
variable [AddCommMonoid M] [AddCommMonoid N] [AddCommMonoid P] [AddCommMonoid Q]
230+
variable [Module R M] [Module R₂ N] [Module R₃ P] [Module R₄ Q]
231+
variable {σ₁₂ : R →+* R₂} {σ₂₃ : R₂ →+* R₃} {σ₁₃ : R →+* R₃}
232+
variable {σ₄₂ : R₄ →+* R₂} {σ₄₃ : R₄ →+* R₃}
233+
variable [RingHomCompTriple σ₁₂ σ₂₃ σ₁₃] [RingHomCompTriple σ₄₂ σ₂₃ σ₄₃]
234+
variable {R₅ : Type*} [Semiring R₅] [Module R₅ P] [SMulCommClass R₃ R₅ P] {σ₁₅ : R →+* R₅}
235+
236+
variable (P σ₂₃ R₅)
237+
238+
/-- Composing a semilinear map `M → N` and a semilinear map `N → P` to form a semilinear map
239+
`M → P` is itself a linear map. -/
240+
def lcompₛₗ (f : M →ₛₗ[σ₁₂] N) : (N →ₛₗ[σ₂₃] P) →ₗ[R₅] M →ₛₗ[σ₁₃] P :=
241+
letI := SMulCommClass.symm
242+
flip <| LinearMap.comp (flip id) f
243+
244+
variable {P σ₂₃ R₅}
245+
246+
@[simp]
247+
theorem lcompₛₗ_apply (f : M →ₛₗ[σ₁₂] N) (g : N →ₛₗ[σ₂₃] P) (x : M) :
248+
lcompₛₗ P σ₂₃ R₅ f g x = g (f x) := rfl
249+
250+
/-- Composing a linear map `Q → N` and a bilinear map `M → N → P` to
251+
form a bilinear map `M → Q → P`. -/
252+
def compl₂ (h : M →ₛₗ[σ₁₅] N →ₛₗ[σ₂₃] P) (g : Q →ₛₗ[σ₄₂] N) : M →ₛₗ[σ₁₅] Q →ₛₗ[σ₄₃] P where
253+
toFun a := (lcompₛₗ P σ₂₃ R₅ g) (h a)
254+
map_add' _ _ := by
255+
simp [map_add]
256+
map_smul' _ _ := by
257+
simp only [LinearMap.map_smulₛₗ, lcompₛₗ]
258+
rfl
259+
260+
@[simp]
261+
theorem compl₂_apply (h : M →ₛₗ[σ₁₅] N →ₛₗ[σ₂₃] P) (g : Q →ₛₗ[σ₄₂] N) (m : M) (q : Q) :
262+
h.compl₂ g m q = h m (g q) := rfl
263+
264+
@[simp]
265+
theorem compl₂_id (h : M →ₛₗ[σ₁₅] N →ₛₗ[σ₂₃] P) : h.compl₂ LinearMap.id = h := by
266+
ext
267+
rw [compl₂_apply, id_coe, _root_.id]
268+
269+
end Semiring'
270+
223271
section CommSemiring
224272

225-
variable {R : Type*} [CommSemiring R] {R₂ : Type*} [CommSemiring R₂]
273+
variable {R : Type*} [CommSemiring R] {R₂ : Type*} [Semiring R₂]
226274
variable {A : Type*} [Semiring A] {B : Type*} [Semiring B]
227-
variable {R₃ : Type*} [CommSemiring R₃] {R₄ : Type*} [CommSemiring R₄]
228275
variable {M : Type*} {N : Type*} {P : Type*} {Q : Type*}
229276
variable {Mₗ : Type*} {Nₗ : Type*} {Pₗ : Type*} {Qₗ Qₗ' : Type*}
230277
variable [AddCommMonoid M] [AddCommMonoid N] [AddCommMonoid P] [AddCommMonoid Q]
231278
variable [AddCommMonoid Mₗ] [AddCommMonoid Nₗ] [AddCommMonoid Pₗ]
232279
variable [AddCommMonoid Qₗ] [AddCommMonoid Qₗ']
233-
variable [Module R M] [Module R₂ N] [Module R₃ P] [Module R₄ Q]
280+
variable [Module R M]
234281
variable [Module R Mₗ] [Module R Nₗ] [Module R Pₗ] [Module R Qₗ] [Module R Qₗ']
235-
variable {σ₁₂ : R →+* R₂} {σ₂₃ : R₂ →+* R₃} {σ₁₃ : R →+* R₃}
236-
variable {σ₄₂ : R₄ →+* R₂} {σ₄₃ : R₄ →+* R₃}
237-
variable [RingHomCompTriple σ₁₂ σ₂₃ σ₁₃] [RingHomCompTriple σ₄₂ σ₂₃ σ₄₃]
238282
variable (R)
239283

240284
/-- Create a bilinear map from a function that is linear in each component.
@@ -252,16 +296,13 @@ theorem mk₂_apply (f : M → Nₗ → Pₗ) {H1 H2 H3 H4} (m : M) (n : Nₗ) :
252296

253297
variable {R}
254298

255-
variable (f : M →ₛₗ[σ₁₃] N →ₛₗ[σ₂₃] P)
256299

257300
variable (A Pₗ)
258301
variable [Module A Pₗ] [SMulCommClass R A Pₗ]
259302

260303
/-- Composing a given linear map `M → N` with a linear map `N → P` as a linear map from
261304
`Nₗ →ₗ[R] Pₗ` to `M →ₗ[R] Pₗ`. -/
262-
def lcomp (f : M →ₗ[R] Nₗ) : (Nₗ →ₗ[R] Pₗ) →ₗ[A] M →ₗ[R] Pₗ :=
263-
letI := SMulCommClass.symm
264-
flip <| LinearMap.comp (flip id) f
305+
def lcomp (f : M →ₗ[R] Nₗ) : (Nₗ →ₗ[R] Pₗ) →ₗ[A] M →ₗ[R] Pₗ := lcompₛₗ Pₗ _ _ f
265306

266307
variable {A Pₗ}
267308

@@ -270,19 +311,6 @@ theorem lcomp_apply (f : M →ₗ[R] Nₗ) (g : Nₗ →ₗ[R] Pₗ) (x : M) : l
270311

271312
theorem lcomp_apply' (f : M →ₗ[R] Nₗ) (g : Nₗ →ₗ[R] Pₗ) : lcomp A Pₗ f g = g ∘ₗ f := rfl
272313

273-
variable (P σ₂₃)
274-
275-
/-- Composing a semilinear map `M → N` and a semilinear map `N → P` to form a semilinear map
276-
`M → P` is itself a linear map. -/
277-
def lcompₛₗ (f : M →ₛₗ[σ₁₂] N) : (N →ₛₗ[σ₂₃] P) →ₗ[R₃] M →ₛₗ[σ₁₃] P :=
278-
flip <| LinearMap.comp (flip id) f
279-
280-
variable {P σ₂₃}
281-
282-
@[simp]
283-
theorem lcompₛₗ_apply (f : M →ₛₗ[σ₁₂] N) (g : N →ₛₗ[σ₂₃] P) (x : M) :
284-
lcompₛₗ P σ₂₃ f g x = g (f x) := rfl
285-
286314
variable (R M Nₗ Pₗ)
287315

288316
/-- Composing linear maps as a bilinear map from `(M →ₗ[R] N) × (N →ₗ[R] P)` to `M →ₗ[R] P` -/
@@ -304,28 +332,9 @@ theorem llcomp_apply' (f : Nₗ →ₗ[R] Pₗ) (g : M →ₗ[R] Nₗ) : llcomp
304332

305333
end
306334

307-
/-- Composing a linear map `Q → N` and a bilinear map `M → N → P` to
308-
form a bilinear map `M → Q → P`. -/
309-
def compl₂ {R₅ : Type*} [CommSemiring R₅] [Module R₅ P] [SMulCommClass R₃ R₅ P] {σ₁₅ : R →+* R₅}
310-
(h : M →ₛₗ[σ₁₅] N →ₛₗ[σ₂₃] P) (g : Q →ₛₗ[σ₄₂] N) : M →ₛₗ[σ₁₅] Q →ₛₗ[σ₄₃] P where
311-
toFun a := (lcompₛₗ P σ₂₃ g) (h a)
312-
map_add' _ _ := by
313-
simp [map_add]
314-
map_smul' _ _ := by
315-
simp only [LinearMap.map_smulₛₗ, lcompₛₗ]
316-
rfl
317-
318-
@[simp]
319-
theorem compl₂_apply (g : Q →ₛₗ[σ₄₂] N) (m : M) (q : Q) : f.compl₂ g m q = f m (g q) := rfl
320-
321-
@[simp]
322-
theorem compl₂_id : f.compl₂ LinearMap.id = f := by
323-
ext
324-
rw [compl₂_apply, id_coe, _root_.id]
325-
326335
/-- Composing linear maps `Q → M` and `Q' → N` with a bilinear map `M → N → P` to
327336
form a bilinear map `Q → Q' → P`. -/
328-
def compl₁₂ {R₁ : Type*} [CommSemiring R₁] [Module R₂ N] [Module R₂ Pₗ] [Module R₁ Pₗ]
337+
def compl₁₂ {R₁ : Type*} [Semiring R₁] [Module R₂ N] [Module R₂ Pₗ] [Module R₁ Pₗ]
329338
[Module R₁ Mₗ] [SMulCommClass R₂ R₁ Pₗ] [Module R₁ Qₗ] [Module R₂ Qₗ']
330339
(f : Mₗ →ₗ[R₁] N →ₗ[R₂] Pₗ) (g : Qₗ →ₗ[R₁] Mₗ) (g' : Qₗ' →ₗ[R₂] N) :
331340
Qₗ →ₗ[R₁] Qₗ' →ₗ[R₂] Pₗ :=
@@ -444,7 +453,7 @@ open Function
444453
section restrictScalarsRange
445454

446455
variable {R S M P M' P' : Type*}
447-
[CommSemiring R] [CommSemiring S] [SMul S R]
456+
[Semiring R] [Semiring S] [SMul S R]
448457
[AddCommMonoid M] [Module R M] [AddCommMonoid P] [Module R P]
449458
[Module S M] [Module S P]
450459
[IsScalarTower S R M] [IsScalarTower S R P]

0 commit comments

Comments
 (0)