@@ -6,6 +6,7 @@ Authors: Kevin Buzzard, Kim Morrison, Jakob von Raumer
66import Mathlib.Algebra.Category.ModuleCat.Basic
77import Mathlib.LinearAlgebra.TensorProduct.Associator
88import Mathlib.CategoryTheory.Monoidal.Linear
9+ import Mathlib.CategoryTheory.Monoidal.Transport
910
1011/-!
1112# The monoidal category structure on R-modules
@@ -31,9 +32,9 @@ universe v w x u
3132
3233open CategoryTheory
3334
34- namespace ModuleCat
35+ namespace SemimoduleCat
3536
36- variable {R : Type u} [CommRing R]
37+ variable {R : Type u} [CommSemiring R]
3738
3839namespace MonoidalCategory
3940
@@ -45,34 +46,34 @@ open TensorProduct
4546attribute [local ext] TensorProduct.ext
4647
4748/-- (implementation) tensor product of R-modules -/
48- def tensorObj (M N : ModuleCat R) : ModuleCat R :=
49- ModuleCat .of R (M ⊗[R] N)
49+ def tensorObj (M N : SemimoduleCat R) : SemimoduleCat R :=
50+ SemimoduleCat .of R (M ⊗[R] N)
5051
5152/-- (implementation) tensor product of morphisms R-modules -/
52- def tensorHom {M N M' N' : ModuleCat R} (f : M ⟶ N) (g : M' ⟶ N') :
53+ def tensorHom {M N M' N' : SemimoduleCat R} (f : M ⟶ N) (g : M' ⟶ N') :
5354 tensorObj M M' ⟶ tensorObj N N' :=
5455 ofHom <| TensorProduct.map f.hom g.hom
5556
5657/-- (implementation) left whiskering for R-modules -/
57- def whiskerLeft (M : ModuleCat R) {N₁ N₂ : ModuleCat R} (f : N₁ ⟶ N₂) :
58+ def whiskerLeft (M : SemimoduleCat R) {N₁ N₂ : SemimoduleCat R} (f : N₁ ⟶ N₂) :
5859 tensorObj M N₁ ⟶ tensorObj M N₂ :=
5960 ofHom <| f.hom.lTensor M
6061
6162/-- (implementation) right whiskering for R-modules -/
62- def whiskerRight {M₁ M₂ : ModuleCat R} (f : M₁ ⟶ M₂) (N : ModuleCat R) :
63+ def whiskerRight {M₁ M₂ : SemimoduleCat R} (f : M₁ ⟶ M₂) (N : SemimoduleCat R) :
6364 tensorObj M₁ N ⟶ tensorObj M₂ N :=
6465 ofHom <| f.hom.rTensor N
6566
66- theorem id_tensorHom_id (M N : ModuleCat R) :
67- tensorHom (𝟙 M) (𝟙 N) = 𝟙 (ModuleCat .of R (M ⊗ N)) := by
67+ theorem id_tensorHom_id (M N : SemimoduleCat R) :
68+ tensorHom (𝟙 M) (𝟙 N) = 𝟙 (SemimoduleCat .of R (M ⊗ N)) := by
6869 ext : 1
6970 -- Porting note (https://github.com/leanprover-community/mathlib4/issues/11041): even with high priority `ext` fails to find this.
7071 apply TensorProduct.ext
7172 rfl
7273
7374@[deprecated (since := "2025-07-14")] alias tensor_id := id_tensorHom_id
7475
75- theorem tensorHom_comp_tensorHom {X₁ Y₁ Z₁ X₂ Y₂ Z₂ : ModuleCat R} (f₁ : X₁ ⟶ Y₁) (f₂ : X₂ ⟶ Y₂)
76+ theorem tensorHom_comp_tensorHom {X₁ Y₁ Z₁ X₂ Y₂ Z₂ : SemimoduleCat R} (f₁ : X₁ ⟶ Y₁) (f₂ : X₂ ⟶ Y₂)
7677 (g₁ : Y₁ ⟶ Z₁) (g₂ : Y₂ ⟶ Z₂) :
7778 tensorHom f₁ f₂ ≫ tensorHom g₁ g₂ = tensorHom (f₁ ≫ g₁) (f₂ ≫ g₂) := by
7879 ext : 1
@@ -81,30 +82,30 @@ theorem tensorHom_comp_tensorHom {X₁ Y₁ Z₁ X₂ Y₂ Z₂ : ModuleCat R} (
8182 rfl
8283
8384/-- (implementation) the associator for R-modules -/
84- def associator (M : ModuleCat .{v} R) (N : ModuleCat .{w} R) (K : ModuleCat .{x} R) :
85+ def associator (M : SemimoduleCat .{v} R) (N : SemimoduleCat .{w} R) (K : SemimoduleCat .{x} R) :
8586 tensorObj (tensorObj M N) K ≅ tensorObj M (tensorObj N K) :=
86- (TensorProduct.assoc R M N K).toModuleIso
87+ (TensorProduct.assoc R M N K).toModuleIsoₛ
8788
8889/-- (implementation) the left unitor for R-modules -/
89- def leftUnitor (M : ModuleCat .{u} R) : ModuleCat .of R (R ⊗[R] M) ≅ M :=
90- (TensorProduct.lid R M).toModuleIso
90+ def leftUnitor (M : SemimoduleCat .{u} R) : SemimoduleCat .of R (R ⊗[R] M) ≅ M :=
91+ (TensorProduct.lid R M).toModuleIsoₛ
9192
9293/-- (implementation) the right unitor for R-modules -/
93- def rightUnitor (M : ModuleCat .{u} R) : ModuleCat .of R (M ⊗[R] R) ≅ M :=
94- (TensorProduct.rid R M).toModuleIso
94+ def rightUnitor (M : SemimoduleCat .{u} R) : SemimoduleCat .of R (M ⊗[R] R) ≅ M :=
95+ (TensorProduct.rid R M).toModuleIsoₛ
9596
9697@[simps -isSimp]
97- instance instMonoidalCategoryStruct : MonoidalCategoryStruct (ModuleCat .{u} R) where
98+ instance instMonoidalCategoryStruct : MonoidalCategoryStruct (SemimoduleCat .{u} R) where
9899 tensorObj := tensorObj
99100 whiskerLeft := whiskerLeft
100101 whiskerRight := whiskerRight
101- tensorHom f g := ofHom <| TensorProduct.map f.hom g.hom
102- tensorUnit := ModuleCat .of R R
102+ tensorHom := tensorHom
103+ tensorUnit := SemimoduleCat .of R R
103104 associator := associator
104105 leftUnitor := leftUnitor
105106 rightUnitor := rightUnitor
106107
107- theorem associator_naturality {X₁ X₂ X₃ Y₁ Y₂ Y₃ : ModuleCat R} (f₁ : X₁ ⟶ Y₁) (f₂ : X₂ ⟶ Y₂)
108+ theorem associator_naturality {X₁ X₂ X₃ Y₁ Y₂ Y₃ : SemimoduleCat R} (f₁ : X₁ ⟶ Y₁) (f₂ : X₂ ⟶ Y₂)
108109 (f₃ : X₃ ⟶ Y₃) :
109110 tensorHom (tensorHom f₁ f₂) f₃ ≫ (associator Y₁ Y₂ Y₃).hom =
110111 (associator X₁ X₂ X₃).hom ≫ tensorHom f₁ (tensorHom f₂ f₃) := by
@@ -113,7 +114,7 @@ theorem associator_naturality {X₁ X₂ X₃ Y₁ Y₂ Y₃ : ModuleCat R} (f
113114 intro x y z
114115 rfl
115116
116- theorem pentagon (W X Y Z : ModuleCat R) :
117+ theorem pentagon (W X Y Z : SemimoduleCat R) :
117118 whiskerRight (associator W X Y).hom Z ≫
118119 (associator W (tensorObj X Y) Z).hom ≫ whiskerLeft W (associator X Y Z).hom =
119120 (associator (tensorObj W X) Y Z).hom ≫ (associator W X (tensorObj Y Z)).hom := by
@@ -122,8 +123,8 @@ theorem pentagon (W X Y Z : ModuleCat R) :
122123 intro w x y z
123124 rfl
124125
125- theorem leftUnitor_naturality {M N : ModuleCat R} (f : M ⟶ N) :
126- tensorHom (𝟙 (ModuleCat .of R R)) f ≫ (leftUnitor N).hom = (leftUnitor M).hom ≫ f := by
126+ theorem leftUnitor_naturality {M N : SemimoduleCat R} (f : M ⟶ N) :
127+ tensorHom (𝟙 (SemimoduleCat .of R R)) f ≫ (leftUnitor N).hom = (leftUnitor M).hom ≫ f := by
127128 ext : 1
128129 -- Porting note (https://github.com/leanprover-community/mathlib4/issues/11041): broken ext
129130 apply TensorProduct.ext
@@ -133,8 +134,8 @@ theorem leftUnitor_naturality {M N : ModuleCat R} (f : M ⟶ N) :
133134 rw [LinearMap.map_smul]
134135 rfl
135136
136- theorem rightUnitor_naturality {M N : ModuleCat R} (f : M ⟶ N) :
137- tensorHom f (𝟙 (ModuleCat .of R R)) ≫ (rightUnitor N).hom = (rightUnitor M).hom ≫ f := by
137+ theorem rightUnitor_naturality {M N : SemimoduleCat R} (f : M ⟶ N) :
138+ tensorHom f (𝟙 (SemimoduleCat .of R R)) ≫ (rightUnitor N).hom = (rightUnitor M).hom ≫ f := by
138139 ext : 1
139140 -- Porting note (https://github.com/leanprover-community/mathlib4/issues/11041): broken ext
140141 apply TensorProduct.ext
@@ -144,8 +145,8 @@ theorem rightUnitor_naturality {M N : ModuleCat R} (f : M ⟶ N) :
144145 rw [LinearMap.map_smul]
145146 rfl
146147
147- theorem triangle (M N : ModuleCat .{u} R) :
148- (associator M (ModuleCat .of R R) N).hom ≫ tensorHom (𝟙 M) (leftUnitor N).hom =
148+ theorem triangle (M N : SemimoduleCat .{u} R) :
149+ (associator M (SemimoduleCat .of R R) N).hom ≫ tensorHom (𝟙 M) (leftUnitor N).hom =
149150 tensorHom (rightUnitor M).hom (𝟙 N) := by
150151 ext : 1
151152 apply TensorProduct.ext_threefold
@@ -156,7 +157,7 @@ end MonoidalCategory
156157
157158open MonoidalCategory
158159
159- instance monoidalCategory : MonoidalCategory (ModuleCat .{u} R) := MonoidalCategory.ofTensorHom
160+ instance monoidalCategory : MonoidalCategory (SemimoduleCat .{u} R) := MonoidalCategory.ofTensorHom
160161 (id_tensorHom_id := fun M N ↦ id_tensorHom_id M N)
161162 (tensorHom_comp_tensorHom := fun f g h ↦ MonoidalCategory.tensorHom_comp_tensorHom f g h)
162163 (associator_naturality := fun f g h ↦ MonoidalCategory.associator_naturality f g h)
@@ -165,6 +166,161 @@ instance monoidalCategory : MonoidalCategory (ModuleCat.{u} R) := MonoidalCatego
165166 (pentagon := fun M N K L ↦ pentagon M N K L)
166167 (triangle := fun M N ↦ triangle M N)
167168
169+ /-- Remind ourselves that the monoidal unit, being just `R`, is still a commutative semiring. -/
170+ instance : CommSemiring ((𝟙_ (SemimoduleCat.{u} R) : SemimoduleCat.{u} R) : Type u) :=
171+ inferInstanceAs <| CommSemiring R
172+
173+ theorem hom_tensorHom {K L M N : SemimoduleCat.{u} R} (f : K ⟶ L) (g : M ⟶ N) :
174+ (f ⊗ₘ g).hom = TensorProduct.map f.hom g.hom :=
175+ rfl
176+
177+ theorem hom_whiskerLeft (L : SemimoduleCat.{u} R) {M N : SemimoduleCat.{u} R} (f : M ⟶ N) :
178+ (L ◁ f).hom = f.hom.lTensor L :=
179+ rfl
180+
181+ theorem hom_whiskerRight {L M : SemimoduleCat.{u} R} (f : L ⟶ M) (N : SemimoduleCat.{u} R) :
182+ (f ▷ N).hom = f.hom.rTensor N :=
183+ rfl
184+
185+ theorem hom_hom_leftUnitor {M : SemimoduleCat.{u} R} :
186+ (λ_ M).hom.hom = (TensorProduct.lid _ _).toLinearMap :=
187+ rfl
188+
189+ theorem hom_inv_leftUnitor {M : SemimoduleCat.{u} R} :
190+ (λ_ M).inv.hom = (TensorProduct.lid _ _).symm.toLinearMap :=
191+ rfl
192+
193+ theorem hom_hom_rightUnitor {M : SemimoduleCat.{u} R} :
194+ (ρ_ M).hom.hom = (TensorProduct.rid _ _).toLinearMap :=
195+ rfl
196+
197+ theorem hom_inv_rightUnitor {M : SemimoduleCat.{u} R} :
198+ (ρ_ M).inv.hom = (TensorProduct.rid _ _).symm.toLinearMap :=
199+ rfl
200+
201+ theorem hom_hom_associator {M N K : SemimoduleCat.{u} R} :
202+ (α_ M N K).hom.hom = (TensorProduct.assoc _ _ _ _).toLinearMap :=
203+ rfl
204+
205+ theorem hom_inv_associator {M N K : SemimoduleCat.{u} R} :
206+ (α_ M N K).inv.hom = (TensorProduct.assoc _ _ _ _).symm.toLinearMap :=
207+ rfl
208+
209+ namespace MonoidalCategory
210+
211+ @[simp]
212+ theorem tensorHom_tmul {K L M N : SemimoduleCat.{u} R} (f : K ⟶ L) (g : M ⟶ N) (k : K) (m : M) :
213+ (f ⊗ₘ g) (k ⊗ₜ m) = f k ⊗ₜ g m :=
214+ rfl
215+
216+ @[simp]
217+ theorem whiskerLeft_apply (L : SemimoduleCat.{u} R) {M N : SemimoduleCat.{u} R} (f : M ⟶ N)
218+ (l : L) (m : M) :
219+ (L ◁ f) (l ⊗ₜ m) = l ⊗ₜ f m :=
220+ rfl
221+
222+ @[simp]
223+ theorem whiskerRight_apply {L M : SemimoduleCat.{u} R} (f : L ⟶ M) (N : SemimoduleCat.{u} R)
224+ (l : L) (n : N) :
225+ (f ▷ N) (l ⊗ₜ n) = f l ⊗ₜ n :=
226+ rfl
227+
228+ @[simp]
229+ theorem leftUnitor_hom_apply {M : SemimoduleCat.{u} R} (r : R) (m : M) :
230+ ((λ_ M).hom : 𝟙_ (SemimoduleCat R) ⊗ M ⟶ M) (r ⊗ₜ[R] m) = r • m :=
231+ TensorProduct.lid_tmul m r
232+
233+ @[simp]
234+ theorem leftUnitor_inv_apply {M : SemimoduleCat.{u} R} (m : M) :
235+ ((λ_ M).inv : M ⟶ 𝟙_ (SemimoduleCat.{u} R) ⊗ M) m = 1 ⊗ₜ[R] m :=
236+ TensorProduct.lid_symm_apply m
237+
238+ @[simp]
239+ theorem rightUnitor_hom_apply {M : SemimoduleCat.{u} R} (m : M) (r : R) :
240+ ((ρ_ M).hom : M ⊗ 𝟙_ (SemimoduleCat R) ⟶ M) (m ⊗ₜ r) = r • m :=
241+ TensorProduct.rid_tmul m r
242+
243+ @[simp]
244+ theorem rightUnitor_inv_apply {M : SemimoduleCat.{u} R} (m : M) :
245+ ((ρ_ M).inv : M ⟶ M ⊗ 𝟙_ (SemimoduleCat.{u} R)) m = m ⊗ₜ[R] 1 :=
246+ TensorProduct.rid_symm_apply m
247+
248+ @[simp]
249+ theorem associator_hom_apply {M N K : SemimoduleCat.{u} R} (m : M) (n : N) (k : K) :
250+ ((α_ M N K).hom : (M ⊗ N) ⊗ K ⟶ M ⊗ N ⊗ K) (m ⊗ₜ n ⊗ₜ k) = m ⊗ₜ (n ⊗ₜ k) :=
251+ rfl
252+
253+ @[simp]
254+ theorem associator_inv_apply {M N K : SemimoduleCat.{u} R} (m : M) (n : N) (k : K) :
255+ ((α_ M N K).inv : M ⊗ N ⊗ K ⟶ (M ⊗ N) ⊗ K) (m ⊗ₜ (n ⊗ₜ k)) = m ⊗ₜ n ⊗ₜ k :=
256+ rfl
257+
258+ variable {M₁ M₂ M₃ M₄ : SemimoduleCat.{u} R}
259+
260+ section
261+
262+ variable (f : M₁ → M₂ → M₃) (h₁ : ∀ m₁ m₂ n, f (m₁ + m₂) n = f m₁ n + f m₂ n)
263+ (h₂ : ∀ (a : R) m n, f (a • m) n = a • f m n)
264+ (h₃ : ∀ m n₁ n₂, f m (n₁ + n₂) = f m n₁ + f m n₂)
265+ (h₄ : ∀ (a : R) m n, f m (a • n) = a • f m n)
266+
267+ /-- Construct for morphisms from the tensor product of two objects in `SemimoduleCat`. -/
268+ def tensorLift : M₁ ⊗ M₂ ⟶ M₃ :=
269+ ofHom <| TensorProduct.lift (LinearMap.mk₂ R f h₁ h₂ h₃ h₄)
270+
271+ @[simp]
272+ lemma tensorLift_tmul (m : M₁) (n : M₂) :
273+ tensorLift f h₁ h₂ h₃ h₄ (m ⊗ₜ n) = f m n := rfl
274+
275+ end
276+
277+ lemma tensor_ext {f g : M₁ ⊗ M₂ ⟶ M₃} (h : ∀ m n, f.hom (m ⊗ₜ n) = g.hom (m ⊗ₜ n)) :
278+ f = g :=
279+ hom_ext <| TensorProduct.ext (by ext; apply h)
280+
281+ /-- Extensionality lemma for morphisms from a module of the form `(M₁ ⊗ M₂) ⊗ M₃`. -/
282+ lemma tensor_ext₃' {f g : (M₁ ⊗ M₂) ⊗ M₃ ⟶ M₄}
283+ (h : ∀ m₁ m₂ m₃, f (m₁ ⊗ₜ m₂ ⊗ₜ m₃) = g (m₁ ⊗ₜ m₂ ⊗ₜ m₃)) :
284+ f = g :=
285+ hom_ext <| TensorProduct.ext_threefold h
286+
287+ /-- Extensionality lemma for morphisms from a module of the form `M₁ ⊗ (M₂ ⊗ M₃)`. -/
288+ lemma tensor_ext₃ {f g : M₁ ⊗ (M₂ ⊗ M₃) ⟶ M₄}
289+ (h : ∀ m₁ m₂ m₃, f (m₁ ⊗ₜ (m₂ ⊗ₜ m₃)) = g (m₁ ⊗ₜ (m₂ ⊗ₜ m₃))) :
290+ f = g := by
291+ rw [← cancel_epi (α_ _ _ _).hom]
292+ exact tensor_ext₃' h
293+
294+ end MonoidalCategory
295+
296+ end SemimoduleCat
297+
298+ namespace ModuleCat
299+
300+ variable {R : Type u} [CommRing R]
301+
302+ @[simps -isSimp]
303+ instance MonoidalCategory.instMonoidalCategoryStruct :
304+ MonoidalCategoryStruct (ModuleCat.{u} R) where
305+ tensorObj M N := of R (TensorProduct R M N)
306+ whiskerLeft M _ _ f := ofHom <| f.hom.lTensor M
307+ whiskerRight f M := ofHom <| f.hom.rTensor M
308+ tensorHom f g := ofHom <| TensorProduct.map f.hom g.hom
309+ tensorUnit := of R R
310+ associator M N K := (TensorProduct.assoc R M N K).toModuleIso
311+ leftUnitor M := (TensorProduct.lid R M).toModuleIso
312+ rightUnitor M := (TensorProduct.rid R M).toModuleIso
313+
314+ instance monoidalCategory : MonoidalCategory (ModuleCat.{u} R) :=
315+ Monoidal.induced equivalenceSemimoduleCat.functor
316+ { μIso _ _ := .refl _
317+ εIso := .refl _
318+ associator_eq _ _ _ := by ext1; exact TensorProduct.ext (TensorProduct.ext rfl)
319+ leftUnitor_eq _ := by ext1; exact TensorProduct.ext rfl
320+ rightUnitor_eq _ := by ext1; exact TensorProduct.ext rfl }
321+
322+ open MonoidalCategory
323+
168324/-- Remind ourselves that the monoidal unit, being just `R`, is still a commutative ring. -/
169325instance : CommRing ((𝟙_ (ModuleCat.{u} R) : ModuleCat.{u} R) : Type u) :=
170326 inferInstanceAs <| CommRing R
0 commit comments