algebra.category.Module.change_of_rings ⟷ Mathlib.Algebra.Category.ModuleCat.ChangeOfRings

This file has been ported!

Changes since the initial port

The following section lists changes to this file in mathlib3 and mathlib4 that occured after the initial port. Most recent changes are shown first. Hovering over a commit will show all commits associated with the same mathlib3 commit.

Changes in mathlib3

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(last sync)

Changes in mathlib3port

mathlib3
mathlib3port
Diff
@@ -91,7 +91,7 @@ def ModuleCat.restrictScalars {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S]
 -/
 
 instance {R : Type u₁} {S : Type uβ‚‚} [CommRing R] [CommRing S] (f : R β†’+* S) :
-    CategoryTheory.Faithful (ModuleCat.restrictScalars.{v} f)
+    CategoryTheory.Functor.Faithful (ModuleCat.restrictScalars.{v} f)
     where map_injective' _ _ _ _ h :=
     LinearMap.ext fun x => by simpa only using DFunLike.congr_fun h x
 
Diff
@@ -3,8 +3,8 @@ Copyright (c) 2022 Jujian Zhang. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Jujian Zhang
 -/
-import Algebra.Category.Module.Basic
-import RingTheory.TensorProduct
+import Algebra.Category.ModuleCat.Basic
+import LinearAlgebra.TensorProduct.Tower
 
 #align_import algebra.category.Module.change_of_rings from "leanprover-community/mathlib"@"1a51edf13debfcbe223fa06b1cb353b9ed9751cc"
 
Diff
@@ -563,7 +563,7 @@ def ModuleCat.ExtendRestrictScalarsAdj.homEquiv {X Y} :
     Β· simp only [map_zero]
     Β· erw [TensorProduct.lift.tmul]
       simp only [LinearMap.coe_mk]
-      change S at x 
+      change S at x
       erw [← LinearMap.map_smul, extend_scalars.smul_tmul, mul_one x]
     Β· rw [map_add, map_add, ih1, ih2]
   right_inv g := by
Diff
@@ -93,7 +93,7 @@ def ModuleCat.restrictScalars {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S]
 instance {R : Type u₁} {S : Type uβ‚‚} [CommRing R] [CommRing S] (f : R β†’+* S) :
     CategoryTheory.Faithful (ModuleCat.restrictScalars.{v} f)
     where map_injective' _ _ _ _ h :=
-    LinearMap.ext fun x => by simpa only using FunLike.congr_fun h x
+    LinearMap.ext fun x => by simpa only using DFunLike.congr_fun h x
 
 #print ModuleCat.restrictScalars.map_apply /-
 @[simp]
Diff
@@ -3,8 +3,8 @@ Copyright (c) 2022 Jujian Zhang. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Jujian Zhang
 -/
-import Mathbin.Algebra.Category.Module.Basic
-import Mathbin.RingTheory.TensorProduct
+import Algebra.Category.Module.Basic
+import RingTheory.TensorProduct
 
 #align_import algebra.category.Module.change_of_rings from "leanprover-community/mathlib"@"1a51edf13debfcbe223fa06b1cb353b9ed9751cc"
 
Diff
@@ -53,75 +53,80 @@ variable {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] (f : R β†’+* S)
 
 variable (M : ModuleCat.{v} S)
 
-#print CategoryTheory.ModuleCat.RestrictScalars.obj' /-
+#print ModuleCat.RestrictScalars.obj' /-
 /-- Any `S`-module M is also an `R`-module via a ring homomorphism `f : R ⟢ S` by defining
     `r β€’ m := f r β€’ m` (`module.comp_hom`). This is called restriction of scalars. -/
-def obj' : ModuleCat R where
+def ModuleCat.RestrictScalars.obj' : ModuleCat R
+    where
   carrier := M
   isModule := Module.compHom M f
-#align category_theory.Module.restrict_scalars.obj' CategoryTheory.ModuleCat.RestrictScalars.obj'
+#align category_theory.Module.restrict_scalars.obj' ModuleCat.RestrictScalars.obj'
 -/
 
-#print CategoryTheory.ModuleCat.RestrictScalars.map' /-
+#print ModuleCat.RestrictScalars.map' /-
 /-- Given an `S`-linear map `g : M β†’ M'` between `S`-modules, `g` is also `R`-linear between `M` and
 `M'` by means of restriction of scalars.
 -/
-def map' {M M' : ModuleCat.{v} S} (g : M ⟢ M') : obj' f M ⟢ obj' f M' :=
+def ModuleCat.RestrictScalars.map' {M M' : ModuleCat.{v} S} (g : M ⟢ M') :
+    ModuleCat.RestrictScalars.obj' f M ⟢ ModuleCat.RestrictScalars.obj' f M' :=
   { g with map_smul' := fun r => g.map_smul (f r) }
-#align category_theory.Module.restrict_scalars.map' CategoryTheory.ModuleCat.RestrictScalars.map'
+#align category_theory.Module.restrict_scalars.map' ModuleCat.RestrictScalars.map'
 -/
 
 end RestrictScalars
 
-#print CategoryTheory.ModuleCat.restrictScalars /-
+#print ModuleCat.restrictScalars /-
 /-- The restriction of scalars operation is functorial. For any `f : R β†’+* S` a ring homomorphism,
 * an `S`-module `M` can be considered as `R`-module by `r β€’ m = f r β€’ m`
 * an `S`-linear map is also `R`-linear
 -/
-def restrictScalars {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] (f : R β†’+* S) :
+def ModuleCat.restrictScalars {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] (f : R β†’+* S) :
     ModuleCat.{v} S β₯€ ModuleCat.{v} R
     where
-  obj := RestrictScalars.obj' f
-  map _ _ := RestrictScalars.map' f
+  obj := ModuleCat.RestrictScalars.obj' f
+  map _ _ := ModuleCat.RestrictScalars.map' f
   map_id' _ := LinearMap.ext fun m => rfl
   map_comp' _ _ _ g h := LinearMap.ext fun m => rfl
-#align category_theory.Module.restrict_scalars CategoryTheory.ModuleCat.restrictScalars
+#align category_theory.Module.restrict_scalars ModuleCat.restrictScalars
 -/
 
 instance {R : Type u₁} {S : Type uβ‚‚} [CommRing R] [CommRing S] (f : R β†’+* S) :
-    CategoryTheory.Faithful (restrictScalars.{v} f)
+    CategoryTheory.Faithful (ModuleCat.restrictScalars.{v} f)
     where map_injective' _ _ _ _ h :=
     LinearMap.ext fun x => by simpa only using FunLike.congr_fun h x
 
-#print CategoryTheory.ModuleCat.restrictScalars.map_apply /-
+#print ModuleCat.restrictScalars.map_apply /-
 @[simp]
-theorem restrictScalars.map_apply {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] (f : R β†’+* S)
-    {M M' : ModuleCat.{v} S} (g : M ⟢ M') (x) : (restrictScalars f).map g x = g x :=
+theorem ModuleCat.restrictScalars.map_apply {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S]
+    (f : R β†’+* S) {M M' : ModuleCat.{v} S} (g : M ⟢ M') (x) :
+    (ModuleCat.restrictScalars f).map g x = g x :=
   rfl
-#align category_theory.Module.restrict_scalars.map_apply CategoryTheory.ModuleCat.restrictScalars.map_apply
+#align category_theory.Module.restrict_scalars.map_apply ModuleCat.restrictScalars.map_apply
 -/
 
-#print CategoryTheory.ModuleCat.restrictScalars.smul_def /-
+#print ModuleCat.restrictScalars.smul_def /-
 @[simp]
-theorem restrictScalars.smul_def {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] (f : R β†’+* S)
-    {M : ModuleCat.{v} S} (r : R) (m : (restrictScalars f).obj M) : r β€’ m = (f r β€’ m : M) :=
+theorem ModuleCat.restrictScalars.smul_def {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S]
+    (f : R β†’+* S) {M : ModuleCat.{v} S} (r : R) (m : (ModuleCat.restrictScalars f).obj M) :
+    r β€’ m = (f r β€’ m : M) :=
   rfl
-#align category_theory.Module.restrict_scalars.smul_def CategoryTheory.ModuleCat.restrictScalars.smul_def
+#align category_theory.Module.restrict_scalars.smul_def ModuleCat.restrictScalars.smul_def
 -/
 
-#print CategoryTheory.ModuleCat.restrictScalars.smul_def' /-
-theorem restrictScalars.smul_def' {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] (f : R β†’+* S)
-    {M : ModuleCat.{v} S} (r : R) (m : M) : (r β€’ m : (restrictScalars f).obj M) = (f r β€’ m : M) :=
+#print ModuleCat.restrictScalars.smul_def' /-
+theorem ModuleCat.restrictScalars.smul_def' {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S]
+    (f : R β†’+* S) {M : ModuleCat.{v} S} (r : R) (m : M) :
+    (r β€’ m : (ModuleCat.restrictScalars f).obj M) = (f r β€’ m : M) :=
   rfl
-#align category_theory.Module.restrict_scalars.smul_def' CategoryTheory.ModuleCat.restrictScalars.smul_def'
+#align category_theory.Module.restrict_scalars.smul_def' ModuleCat.restrictScalars.smul_def'
 -/
 
-#print CategoryTheory.ModuleCat.sMulCommClass_mk /-
-instance (priority := 100) sMulCommClass_mk {R : Type u₁} {S : Type uβ‚‚} [Ring R] [CommRing S]
-    (f : R β†’+* S) (M : Type v) [AddCommGroup M] [Module S M] :
-    @SMulCommClass R S M (RestrictScalars.obj' f (ModuleCat.mk M)).isModule.toSMul _
+#print ModuleCat.sMulCommClass_mk /-
+instance (priority := 100) ModuleCat.sMulCommClass_mk {R : Type u₁} {S : Type uβ‚‚} [Ring R]
+    [CommRing S] (f : R β†’+* S) (M : Type v) [AddCommGroup M] [Module S M] :
+    @SMulCommClass R S M (ModuleCat.RestrictScalars.obj' f (ModuleCat.mk M)).isModule.toSMul _
     where smul_comm r s m := (by simp [← mul_smul, mul_comm] : f r β€’ s β€’ m = s β€’ f r β€’ m)
-#align category_theory.Module.smul_comm_class_mk CategoryTheory.ModuleCat.sMulCommClass_mk
+#align category_theory.Module.smul_comm_class_mk ModuleCat.sMulCommClass_mk
 -/
 
 namespace ExtendScalars
@@ -145,62 +150,67 @@ open scoped ChangeOfRings
 
 variable (M : ModuleCat.{v} R)
 
-#print CategoryTheory.ModuleCat.ExtendScalars.obj' /-
+#print ModuleCat.ExtendScalars.obj' /-
 /-- Extension of scalars turn an `R`-module into `S`-module by M ↦ S ⨂ M
 -/
-def obj' : ModuleCat S :=
-  ⟨TensorProduct R ((restrictScalars f).obj ⟨S⟩) M⟩
-#align category_theory.Module.extend_scalars.obj' CategoryTheory.ModuleCat.ExtendScalars.obj'
+def ModuleCat.ExtendScalars.obj' : ModuleCat S :=
+  ⟨TensorProduct R ((ModuleCat.restrictScalars f).obj ⟨S⟩) M⟩
+#align category_theory.Module.extend_scalars.obj' ModuleCat.ExtendScalars.obj'
 -/
 
-#print CategoryTheory.ModuleCat.ExtendScalars.map' /-
+#print ModuleCat.ExtendScalars.map' /-
 /-- Extension of scalars is a functor where an `R`-module `M` is sent to `S βŠ— M` and
 `l : M1 ⟢ M2` is sent to `s βŠ— m ↦ s βŠ— l m`
 -/
-def map' {M1 M2 : ModuleCat.{v} R} (l : M1 ⟢ M2) : obj' f M1 ⟢ obj' f M2 :=
+def ModuleCat.ExtendScalars.map' {M1 M2 : ModuleCat.{v} R} (l : M1 ⟢ M2) :
+    ModuleCat.ExtendScalars.obj' f M1 ⟢ ModuleCat.ExtendScalars.obj' f M2 :=
   by-- The "by apply" part makes this require 75% fewer heartbeats to process (#16371).
   apply @LinearMap.baseChange R S M1 M2 _ _ ((algebraMap S _).comp f).toAlgebra _ _ _ _ l
-#align category_theory.Module.extend_scalars.map' CategoryTheory.ModuleCat.ExtendScalars.map'
+#align category_theory.Module.extend_scalars.map' ModuleCat.ExtendScalars.map'
 -/
 
-#print CategoryTheory.ModuleCat.ExtendScalars.map'_id /-
-theorem map'_id {M : ModuleCat.{v} R} : map' f (πŸ™ M) = πŸ™ _ :=
-  LinearMap.ext fun x : obj' f M =>
+#print ModuleCat.ExtendScalars.map'_id /-
+theorem ModuleCat.ExtendScalars.map'_id {M : ModuleCat.{v} R} :
+    ModuleCat.ExtendScalars.map' f (πŸ™ M) = πŸ™ _ :=
+  LinearMap.ext fun x : ModuleCat.ExtendScalars.obj' f M =>
     by
     dsimp only [map', ModuleCat.id_apply]
     induction' x using TensorProduct.induction_on with _ _ m s ihx ihy
     Β· simp only [map_zero]
     Β· rw [LinearMap.baseChange_tmul, ModuleCat.id_apply]
     Β· rw [map_add, ihx, ihy]
-#align category_theory.Module.extend_scalars.map'_id CategoryTheory.ModuleCat.ExtendScalars.map'_id
+#align category_theory.Module.extend_scalars.map'_id ModuleCat.ExtendScalars.map'_id
 -/
 
-#print CategoryTheory.ModuleCat.ExtendScalars.map'_comp /-
-theorem map'_comp {M₁ Mβ‚‚ M₃ : ModuleCat.{v} R} (l₁₂ : M₁ ⟢ Mβ‚‚) (l₂₃ : Mβ‚‚ ⟢ M₃) :
-    map' f (l₁₂ ≫ l₂₃) = map' f l₁₂ ≫ map' f l₂₃ :=
-  LinearMap.ext fun x : obj' f M₁ => by
+#print ModuleCat.ExtendScalars.map'_comp /-
+theorem ModuleCat.ExtendScalars.map'_comp {M₁ Mβ‚‚ M₃ : ModuleCat.{v} R} (l₁₂ : M₁ ⟢ Mβ‚‚)
+    (l₂₃ : Mβ‚‚ ⟢ M₃) :
+    ModuleCat.ExtendScalars.map' f (l₁₂ ≫ l₂₃) =
+      ModuleCat.ExtendScalars.map' f l₁₂ ≫ ModuleCat.ExtendScalars.map' f l₂₃ :=
+  LinearMap.ext fun x : ModuleCat.ExtendScalars.obj' f M₁ =>
+    by
     dsimp only [map']
     induction' x using TensorProduct.induction_on with _ _ x y ihx ihy
     Β· rfl
     Β· rfl
     Β· simp only [map_add, ihx, ihy]
-#align category_theory.Module.extend_scalars.map'_comp CategoryTheory.ModuleCat.ExtendScalars.map'_comp
+#align category_theory.Module.extend_scalars.map'_comp ModuleCat.ExtendScalars.map'_comp
 -/
 
 end ExtendScalars
 
-#print CategoryTheory.ModuleCat.extendScalars /-
+#print ModuleCat.extendScalars /-
 /-- Extension of scalars is a functor where an `R`-module `M` is sent to `S βŠ— M` and
 `l : M1 ⟢ M2` is sent to `s βŠ— m ↦ s βŠ— l m`
 -/
-def extendScalars {R : Type u₁} {S : Type uβ‚‚} [CommRing R] [CommRing S] (f : R β†’+* S) :
+def ModuleCat.extendScalars {R : Type u₁} {S : Type uβ‚‚} [CommRing R] [CommRing S] (f : R β†’+* S) :
     ModuleCat.{v} R β₯€ ModuleCat.{max v uβ‚‚} S
     where
-  obj M := ExtendScalars.obj' f M
-  map M1 M2 l := ExtendScalars.map' f l
-  map_id' _ := ExtendScalars.map'_id f
-  map_comp' _ _ _ := ExtendScalars.map'_comp f
-#align category_theory.Module.extend_scalars CategoryTheory.ModuleCat.extendScalars
+  obj M := ModuleCat.ExtendScalars.obj' f M
+  map M1 M2 l := ModuleCat.ExtendScalars.map' f l
+  map_id' _ := ModuleCat.ExtendScalars.map'_id f
+  map_comp' _ _ _ := ModuleCat.ExtendScalars.map'_comp f
+#align category_theory.Module.extend_scalars ModuleCat.extendScalars
 -/
 
 namespace ExtendScalars
@@ -209,20 +219,20 @@ open scoped ChangeOfRings
 
 variable {R : Type u₁} {S : Type uβ‚‚} [CommRing R] [CommRing S] (f : R β†’+* S)
 
-#print CategoryTheory.ModuleCat.ExtendScalars.smul_tmul /-
+#print ModuleCat.ExtendScalars.smul_tmul /-
 @[simp]
-protected theorem smul_tmul {M : ModuleCat.{v} R} (s s' : S) (m : M) :
-    s β€’ (s'βŠ—β‚œ[R,f]m : (extendScalars f).obj M) = (s * s')βŠ—β‚œ[R,f]m :=
+protected theorem ModuleCat.ExtendScalars.smul_tmul {M : ModuleCat.{v} R} (s s' : S) (m : M) :
+    s β€’ (s'βŠ—β‚œ[R,f]m : (ModuleCat.extendScalars f).obj M) = (s * s')βŠ—β‚œ[R,f]m :=
   rfl
-#align category_theory.Module.extend_scalars.smul_tmul CategoryTheory.ModuleCat.ExtendScalars.smul_tmul
+#align category_theory.Module.extend_scalars.smul_tmul ModuleCat.ExtendScalars.smul_tmul
 -/
 
-#print CategoryTheory.ModuleCat.ExtendScalars.map_tmul /-
+#print ModuleCat.ExtendScalars.map_tmul /-
 @[simp]
-theorem map_tmul {M M' : ModuleCat.{v} R} (g : M ⟢ M') (s : S) (m : M) :
-    (extendScalars f).map g (sβŠ—β‚œ[R,f]m) = sβŠ—β‚œ[R,f]g m :=
+theorem ModuleCat.ExtendScalars.map_tmul {M M' : ModuleCat.{v} R} (g : M ⟢ M') (s : S) (m : M) :
+    (ModuleCat.extendScalars f).map g (sβŠ—β‚œ[R,f]m) = sβŠ—β‚œ[R,f]g m :=
   rfl
-#align category_theory.Module.extend_scalars.map_tmul CategoryTheory.ModuleCat.ExtendScalars.map_tmul
+#align category_theory.Module.extend_scalars.map_tmul ModuleCat.ExtendScalars.map_tmul
 -/
 
 end ExtendScalars
@@ -236,126 +246,128 @@ section Unbundled
 variable (M : Type v) [AddCommMonoid M] [Module R M]
 
 -- We use `S'` to denote `S` viewed as `R`-module, via the map `f`.
-local notation "S'" => (restrictScalars f).obj ⟨S⟩
+local notation "S'" => (ModuleCat.restrictScalars f).obj ⟨S⟩
 
-#print CategoryTheory.ModuleCat.CoextendScalars.hasSMul /-
+#print ModuleCat.CoextendScalars.hasSMul /-
 /-- Given an `R`-module M, consider Hom(S, M) -- the `R`-linear maps between S (as an `R`-module by
  means of restriction of scalars) and M. `S` acts on Hom(S, M) by `s β€’ g = x ↦ g (x β€’ s)`
  -/
-instance hasSMul : SMul S <| S' β†’β‚—[R] M
+instance ModuleCat.CoextendScalars.hasSMul : SMul S <| S' β†’β‚—[R] M
     where smul s g :=
     { toFun := fun s' : S => g (s' * s : S)
       map_add' := fun x y : S => by simp [add_mul, map_add]
       map_smul' := fun r (t : S) => by
         rw [RingHom.id_apply, @RestrictScalars.smul_def _ _ _ _ f ⟨S⟩, ← LinearMap.map_smul,
           @RestrictScalars.smul_def _ _ _ _ f ⟨S⟩, smul_eq_mul, smul_eq_mul, mul_assoc] }
-#align category_theory.Module.coextend_scalars.has_smul CategoryTheory.ModuleCat.CoextendScalars.hasSMul
+#align category_theory.Module.coextend_scalars.has_smul ModuleCat.CoextendScalars.hasSMul
 -/
 
-#print CategoryTheory.ModuleCat.CoextendScalars.smul_apply' /-
+#print ModuleCat.CoextendScalars.smul_apply' /-
 @[simp]
-theorem smul_apply' (s : S) (g : S' β†’β‚—[R] M) (s' : S) :
-    @SMul.smul _ _ (CoextendScalars.hasSMul f _) s g s' = g (s' * s : S) :=
+theorem ModuleCat.CoextendScalars.smul_apply' (s : S) (g : S' β†’β‚—[R] M) (s' : S) :
+    @SMul.smul _ _ (ModuleCat.CoextendScalars.hasSMul f _) s g s' = g (s' * s : S) :=
   rfl
-#align category_theory.Module.coextend_scalars.smul_apply' CategoryTheory.ModuleCat.CoextendScalars.smul_apply'
+#align category_theory.Module.coextend_scalars.smul_apply' ModuleCat.CoextendScalars.smul_apply'
 -/
 
-#print CategoryTheory.ModuleCat.CoextendScalars.mulAction /-
-instance mulAction : MulAction S <| S' β†’β‚—[R] M :=
+#print ModuleCat.CoextendScalars.mulAction /-
+instance ModuleCat.CoextendScalars.mulAction : MulAction S <| S' β†’β‚—[R] M :=
   {
-    CoextendScalars.hasSMul f
+    ModuleCat.CoextendScalars.hasSMul f
       _ with
     one_smul := fun g => LinearMap.ext fun s : S => by simp
     hMul_smul := fun (s t : S) g => LinearMap.ext fun x : S => by simp [mul_assoc] }
-#align category_theory.Module.coextend_scalars.mul_action CategoryTheory.ModuleCat.CoextendScalars.mulAction
+#align category_theory.Module.coextend_scalars.mul_action ModuleCat.CoextendScalars.mulAction
 -/
 
-#print CategoryTheory.ModuleCat.CoextendScalars.distribMulAction /-
-instance distribMulAction : DistribMulAction S <| S' β†’β‚—[R] M :=
+#print ModuleCat.CoextendScalars.distribMulAction /-
+instance ModuleCat.CoextendScalars.distribMulAction : DistribMulAction S <| S' β†’β‚—[R] M :=
   {
-    CoextendScalars.mulAction f
+    ModuleCat.CoextendScalars.mulAction f
       _ with
     smul_add := fun s g h => LinearMap.ext fun t : S => by simp
     smul_zero := fun s => LinearMap.ext fun t : S => by simp }
-#align category_theory.Module.coextend_scalars.distrib_mul_action CategoryTheory.ModuleCat.CoextendScalars.distribMulAction
+#align category_theory.Module.coextend_scalars.distrib_mul_action ModuleCat.CoextendScalars.distribMulAction
 -/
 
-#print CategoryTheory.ModuleCat.CoextendScalars.isModule /-
+#print ModuleCat.CoextendScalars.isModule /-
 /-- `S` acts on Hom(S, M) by `s β€’ g = x ↦ g (x β€’ s)`, this action defines an `S`-module structure on
 Hom(S, M).
  -/
-instance isModule : Module S <| S' β†’β‚—[R] M :=
+instance ModuleCat.CoextendScalars.isModule : Module S <| S' β†’β‚—[R] M :=
   {
-    CoextendScalars.distribMulAction f
+    ModuleCat.CoextendScalars.distribMulAction f
       _ with
     add_smul := fun s1 s2 g => LinearMap.ext fun x : S => by simp [mul_add]
     zero_smul := fun g => LinearMap.ext fun x : S => by simp }
-#align category_theory.Module.coextend_scalars.is_module CategoryTheory.ModuleCat.CoextendScalars.isModule
+#align category_theory.Module.coextend_scalars.is_module ModuleCat.CoextendScalars.isModule
 -/
 
 end Unbundled
 
 variable (M : ModuleCat.{v} R)
 
-#print CategoryTheory.ModuleCat.CoextendScalars.obj' /-
+#print ModuleCat.CoextendScalars.obj' /-
 /-- If `M` is an `R`-module, then the set of `R`-linear maps `S β†’β‚—[R] M` is an `S`-module with
 scalar multiplication defined by `s β€’ l := x ↦ l (x β€’ s)`-/
-def obj' : ModuleCat S :=
-  ⟨(restrictScalars f).obj ⟨S⟩ β†’β‚—[R] M⟩
-#align category_theory.Module.coextend_scalars.obj' CategoryTheory.ModuleCat.CoextendScalars.obj'
+def ModuleCat.CoextendScalars.obj' : ModuleCat S :=
+  ⟨(ModuleCat.restrictScalars f).obj ⟨S⟩ β†’β‚—[R] M⟩
+#align category_theory.Module.coextend_scalars.obj' ModuleCat.CoextendScalars.obj'
 -/
 
-instance : CoeFun (obj' f M) fun g => S β†’ M where coe g := g.toFun
+instance : CoeFun (ModuleCat.CoextendScalars.obj' f M) fun g => S β†’ M where coe g := g.toFun
 
-#print CategoryTheory.ModuleCat.CoextendScalars.map' /-
+#print ModuleCat.CoextendScalars.map' /-
 /-- If `M, M'` are `R`-modules, then any `R`-linear map `g : M ⟢ M'` induces an `S`-linear map
 `(S β†’β‚—[R] M) ⟢ (S β†’β‚—[R] M')` defined by `h ↦ g ∘ h`-/
 @[simps]
-def map' {M M' : ModuleCat R} (g : M ⟢ M') : obj' f M ⟢ obj' f M'
+def ModuleCat.CoextendScalars.map' {M M' : ModuleCat R} (g : M ⟢ M') :
+    ModuleCat.CoextendScalars.obj' f M ⟢ ModuleCat.CoextendScalars.obj' f M'
     where
   toFun h := g.comp h
   map_add' _ _ := LinearMap.comp_add _ _ _
   map_smul' s h := LinearMap.ext fun t : S => by simpa only [smul_apply']
-#align category_theory.Module.coextend_scalars.map' CategoryTheory.ModuleCat.CoextendScalars.map'
+#align category_theory.Module.coextend_scalars.map' ModuleCat.CoextendScalars.map'
 -/
 
 end CoextendScalars
 
-#print CategoryTheory.ModuleCat.coextendScalars /-
+#print ModuleCat.coextendScalars /-
 /--
 For any rings `R, S` and a ring homomorphism `f : R β†’+* S`, there is a functor from `R`-module to
 `S`-module defined by `M ↦ (S β†’β‚—[R] M)` where `S` is considered as an `R`-module via restriction of
 scalars and `g : M ⟢ M'` is sent to `h ↦ g ∘ h`.
 -/
-def coextendScalars {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] (f : R β†’+* S) :
-    ModuleCat R β₯€ ModuleCat S where
-  obj := CoextendScalars.obj' f
-  map _ _ := CoextendScalars.map' f
+def ModuleCat.coextendScalars {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] (f : R β†’+* S) :
+    ModuleCat R β₯€ ModuleCat S
+    where
+  obj := ModuleCat.CoextendScalars.obj' f
+  map _ _ := ModuleCat.CoextendScalars.map' f
   map_id' M := LinearMap.ext fun h => LinearMap.ext fun x => rfl
   map_comp' _ _ _ g h := LinearMap.ext fun h => LinearMap.ext fun x => rfl
-#align category_theory.Module.coextend_scalars CategoryTheory.ModuleCat.coextendScalars
+#align category_theory.Module.coextend_scalars ModuleCat.coextendScalars
 -/
 
 namespace CoextendScalars
 
 variable {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] (f : R β†’+* S)
 
-instance (M : ModuleCat R) : CoeFun ((coextendScalars f).obj M) fun g => S β†’ M :=
-  (inferInstance : CoeFun (CoextendScalars.obj' f M) _)
+instance (M : ModuleCat R) : CoeFun ((ModuleCat.coextendScalars f).obj M) fun g => S β†’ M :=
+  (inferInstance : CoeFun (ModuleCat.CoextendScalars.obj' f M) _)
 
-#print CategoryTheory.ModuleCat.CoextendScalars.smul_apply /-
-theorem smul_apply (M : ModuleCat R) (g : (coextendScalars f).obj M) (s s' : S) :
-    (s β€’ g) s' = g (s' * s) :=
+#print ModuleCat.CoextendScalars.smul_apply /-
+theorem ModuleCat.CoextendScalars.smul_apply (M : ModuleCat R)
+    (g : (ModuleCat.coextendScalars f).obj M) (s s' : S) : (s β€’ g) s' = g (s' * s) :=
   rfl
-#align category_theory.Module.coextend_scalars.smul_apply CategoryTheory.ModuleCat.CoextendScalars.smul_apply
+#align category_theory.Module.coextend_scalars.smul_apply ModuleCat.CoextendScalars.smul_apply
 -/
 
-#print CategoryTheory.ModuleCat.CoextendScalars.map_apply /-
+#print ModuleCat.CoextendScalars.map_apply /-
 @[simp]
-theorem map_apply {M M' : ModuleCat R} (g : M ⟢ M') (x) (s : S) :
-    (coextendScalars f).map g x s = g (x s) :=
+theorem ModuleCat.CoextendScalars.map_apply {M M' : ModuleCat R} (g : M ⟢ M') (x) (s : S) :
+    (ModuleCat.coextendScalars f).map g x s = g (x s) :=
   rfl
-#align category_theory.Module.coextend_scalars.map_apply CategoryTheory.ModuleCat.CoextendScalars.map_apply
+#align category_theory.Module.coextend_scalars.map_apply ModuleCat.CoextendScalars.map_apply
 -/
 
 end CoextendScalars
@@ -364,13 +376,13 @@ namespace RestrictionCoextensionAdj
 
 variable {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] (f : R β†’+* S)
 
-#print CategoryTheory.ModuleCat.RestrictionCoextensionAdj.HomEquiv.fromRestriction /-
+#print ModuleCat.RestrictionCoextensionAdj.HomEquiv.fromRestriction /-
 /-- Given `R`-module X and `S`-module Y, any `g : (restrict_of_scalars f).obj Y ⟢ X`
 corresponds to `Y ⟢ (coextend_scalars f).obj X` by sending `y ↦ (s ↦ g (s β€’ y))`
 -/
 @[simps]
-def HomEquiv.fromRestriction {X Y} (g : (restrictScalars f).obj Y ⟢ X) :
-    Y ⟢ (coextendScalars f).obj X
+def ModuleCat.RestrictionCoextensionAdj.HomEquiv.fromRestriction {X Y}
+    (g : (ModuleCat.restrictScalars f).obj Y ⟢ X) : Y ⟢ (ModuleCat.coextendScalars f).obj X
     where
   toFun := fun y : Y =>
     { toFun := fun s : S => g <| (s β€’ y : Y)
@@ -383,15 +395,16 @@ def HomEquiv.fromRestriction {X Y} (g : (restrictScalars f).obj Y ⟢ X) :
       rw [LinearMap.add_apply, LinearMap.coe_mk, LinearMap.coe_mk, LinearMap.coe_mk, smul_add,
         map_add]
   map_smul' s y := LinearMap.ext fun t : S => by simp [mul_smul]
-#align category_theory.Module.restriction_coextension_adj.hom_equiv.from_restriction CategoryTheory.ModuleCat.RestrictionCoextensionAdj.HomEquiv.fromRestriction
+#align category_theory.Module.restriction_coextension_adj.hom_equiv.from_restriction ModuleCat.RestrictionCoextensionAdj.HomEquiv.fromRestriction
 -/
 
-#print CategoryTheory.ModuleCat.RestrictionCoextensionAdj.HomEquiv.toRestriction /-
+#print ModuleCat.RestrictionCoextensionAdj.HomEquiv.toRestriction /-
 /-- Given `R`-module X and `S`-module Y, any `g : Y ⟢ (coextend_scalars f).obj X`
 corresponds to `(restrict_scalars f).obj Y ⟢ X` by `y ↦ g y 1`
 -/
 @[simps]
-def HomEquiv.toRestriction {X Y} (g : Y ⟢ (coextendScalars f).obj X) : (restrictScalars f).obj Y ⟢ X
+def ModuleCat.RestrictionCoextensionAdj.HomEquiv.toRestriction {X Y}
+    (g : Y ⟢ (ModuleCat.coextendScalars f).obj X) : (ModuleCat.restrictScalars f).obj Y ⟢ X
     where
   toFun := fun y : Y => (g y).toFun (1 : S)
   map_add' x y := by simp only [g.map_add, LinearMap.toFun_eq_coe, LinearMap.add_apply]
@@ -399,16 +412,17 @@ def HomEquiv.toRestriction {X Y} (g : Y ⟢ (coextendScalars f).obj X) : (restri
     rw [LinearMap.toFun_eq_coe, LinearMap.toFun_eq_coe, RingHom.id_apply, ← LinearMap.map_smul,
       RestrictScalars.smul_def f r y, @RestrictScalars.smul_def _ _ _ _ f ⟨S⟩, smul_eq_mul, mul_one,
       LinearMap.map_smul, coextend_scalars.smul_apply, one_mul]
-#align category_theory.Module.restriction_coextension_adj.hom_equiv.to_restriction CategoryTheory.ModuleCat.RestrictionCoextensionAdj.HomEquiv.toRestriction
+#align category_theory.Module.restriction_coextension_adj.hom_equiv.to_restriction ModuleCat.RestrictionCoextensionAdj.HomEquiv.toRestriction
 -/
 
-#print CategoryTheory.ModuleCat.RestrictionCoextensionAdj.unit' /-
+#print ModuleCat.RestrictionCoextensionAdj.unit' /-
 /--
 The natural transformation from identity functor to the composition of restriction and coextension
 of scalars.
 -/
 @[simps]
-protected def unit' : 𝟭 (ModuleCat S) ⟢ restrictScalars f β‹™ coextendScalars f
+protected def ModuleCat.RestrictionCoextensionAdj.unit' :
+    𝟭 (ModuleCat S) ⟢ ModuleCat.restrictScalars f β‹™ ModuleCat.coextendScalars f
     where
   app Y :=
     { toFun := fun y : Y =>
@@ -423,55 +437,57 @@ protected def unit' : 𝟭 (ModuleCat S) ⟢ restrictScalars f β‹™ coextendScala
       map_smul' := fun s (y : Y) => LinearMap.ext fun t : S => by simp [mul_smul] }
   naturality' Y Y' g :=
     LinearMap.ext fun y : Y => LinearMap.ext fun s : S => by simp [coextend_scalars.map_apply]
-#align category_theory.Module.restriction_coextension_adj.unit' CategoryTheory.ModuleCat.RestrictionCoextensionAdj.unit'
+#align category_theory.Module.restriction_coextension_adj.unit' ModuleCat.RestrictionCoextensionAdj.unit'
 -/
 
-#print CategoryTheory.ModuleCat.RestrictionCoextensionAdj.counit' /-
+#print ModuleCat.RestrictionCoextensionAdj.counit' /-
 /-- The natural transformation from the composition of coextension and restriction of scalars to
 identity functor.
 -/
 @[simps]
-protected def counit' : coextendScalars f β‹™ restrictScalars f ⟢ 𝟭 (ModuleCat R)
+protected def ModuleCat.RestrictionCoextensionAdj.counit' :
+    ModuleCat.coextendScalars f β‹™ ModuleCat.restrictScalars f ⟢ 𝟭 (ModuleCat R)
     where
   app X :=
     { toFun := fun g => g.toFun (1 : S)
       map_add' := fun x1 x2 => by simp [LinearMap.toFun_eq_coe]
-      map_smul' := fun r (g : (restrictScalars f).obj ((coextendScalars f).obj X)) =>
+      map_smul' :=
+        fun r (g : (ModuleCat.restrictScalars f).obj ((ModuleCat.coextendScalars f).obj X)) =>
         by
         simp only [LinearMap.toFun_eq_coe, RingHom.id_apply]
         rw [RestrictScalars.smul_def f, coextend_scalars.smul_apply, one_mul, ← LinearMap.map_smul,
           @RestrictScalars.smul_def _ _ _ _ f ⟨S⟩, smul_eq_mul, mul_one] }
   naturality' X X' g := LinearMap.ext fun h => by simp [coextend_scalars.map_apply]
-#align category_theory.Module.restriction_coextension_adj.counit' CategoryTheory.ModuleCat.RestrictionCoextensionAdj.counit'
+#align category_theory.Module.restriction_coextension_adj.counit' ModuleCat.RestrictionCoextensionAdj.counit'
 -/
 
 end RestrictionCoextensionAdj
 
-#print CategoryTheory.ModuleCat.restrictCoextendScalarsAdj /-
+#print ModuleCat.restrictCoextendScalarsAdj /-
 /-- Restriction of scalars is left adjoint to coextension of scalars. -/
 @[simps]
-def restrictCoextendScalarsAdj {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] (f : R β†’+* S) :
-    restrictScalars f ⊣ coextendScalars f
+def ModuleCat.restrictCoextendScalarsAdj {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S]
+    (f : R β†’+* S) : ModuleCat.restrictScalars f ⊣ ModuleCat.coextendScalars f
     where
   homEquiv X Y :=
-    { toFun := RestrictionCoextensionAdj.HomEquiv.fromRestriction f
-      invFun := RestrictionCoextensionAdj.HomEquiv.toRestriction f
+    { toFun := ModuleCat.RestrictionCoextensionAdj.HomEquiv.fromRestriction f
+      invFun := ModuleCat.RestrictionCoextensionAdj.HomEquiv.toRestriction f
       left_inv := fun g => LinearMap.ext fun x : X => by simp
       right_inv := fun g => LinearMap.ext fun x => LinearMap.ext fun s : S => by simp }
-  Unit := RestrictionCoextensionAdj.unit' f
-  counit := RestrictionCoextensionAdj.counit' f
+  Unit := ModuleCat.RestrictionCoextensionAdj.unit' f
+  counit := ModuleCat.RestrictionCoextensionAdj.counit' f
   homEquiv_unit X Y g := LinearMap.ext fun y => rfl
   homEquiv_counit Y X g := LinearMap.ext fun y : Y => by simp
-#align category_theory.Module.restrict_coextend_scalars_adj CategoryTheory.ModuleCat.restrictCoextendScalarsAdj
+#align category_theory.Module.restrict_coextend_scalars_adj ModuleCat.restrictCoextendScalarsAdj
 -/
 
 instance {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] (f : R β†’+* S) :
-    CategoryTheory.IsLeftAdjoint (restrictScalars f) :=
-  ⟨_, restrictCoextendScalarsAdj f⟩
+    CategoryTheory.IsLeftAdjoint (ModuleCat.restrictScalars f) :=
+  ⟨_, ModuleCat.restrictCoextendScalarsAdj f⟩
 
 instance {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] (f : R β†’+* S) :
-    CategoryTheory.IsRightAdjoint (coextendScalars f) :=
-  ⟨_, restrictCoextendScalarsAdj f⟩
+    CategoryTheory.IsRightAdjoint (ModuleCat.coextendScalars f) :=
+  ⟨_, ModuleCat.restrictCoextendScalarsAdj f⟩
 
 namespace ExtendRestrictScalarsAdj
 
@@ -481,15 +497,15 @@ open TensorProduct
 
 variable {R : Type u₁} {S : Type uβ‚‚} [CommRing R] [CommRing S] (f : R β†’+* S)
 
-#print CategoryTheory.ModuleCat.ExtendRestrictScalarsAdj.HomEquiv.toRestrictScalars /-
+#print ModuleCat.ExtendRestrictScalarsAdj.HomEquiv.toRestrictScalars /-
 /--
 Given `R`-module X and `S`-module Y and a map `g : (extend_scalars f).obj X ⟢ Y`, i.e. `S`-linear
 map `S ⨂ X β†’ Y`, there is a `X ⟢ (restrict_scalars f).obj Y`, i.e. `R`-linear map `X ⟢ Y` by
 `x ↦ g (1 βŠ— x)`.
 -/
 @[simps]
-def HomEquiv.toRestrictScalars {X Y} (g : (extendScalars f).obj X ⟢ Y) :
-    X ⟢ (restrictScalars f).obj Y
+def ModuleCat.ExtendRestrictScalarsAdj.HomEquiv.toRestrictScalars {X Y}
+    (g : (ModuleCat.extendScalars f).obj X ⟢ Y) : X ⟢ (ModuleCat.restrictScalars f).obj Y
     where
   toFun x := g <| (1 : S)βŠ—β‚œ[R,f]x
   map_add' _ _ := by rw [tmul_add, map_add]
@@ -498,18 +514,18 @@ def HomEquiv.toRestrictScalars {X Y} (g : (extendScalars f).obj X ⟢ Y) :
     letI : Module R Y := Module.compHom Y f
     rw [RingHom.id_apply, RestrictScalars.smul_def, ← LinearMap.map_smul, tmul_smul]
     congr
-#align category_theory.Module.extend_restrict_scalars_adj.hom_equiv.to_restrict_scalars CategoryTheory.ModuleCat.ExtendRestrictScalarsAdj.HomEquiv.toRestrictScalars
+#align category_theory.Module.extend_restrict_scalars_adj.hom_equiv.to_restrict_scalars ModuleCat.ExtendRestrictScalarsAdj.HomEquiv.toRestrictScalars
 -/
 
-#print CategoryTheory.ModuleCat.ExtendRestrictScalarsAdj.HomEquiv.fromExtendScalars /-
+#print ModuleCat.ExtendRestrictScalarsAdj.HomEquiv.fromExtendScalars /-
 /--
 Given `R`-module X and `S`-module Y and a map `X ⟢ (restrict_scalars f).obj Y`, i.e `R`-linear map
 `X ⟢ Y`, there is a map `(extend_scalars f).obj X ⟢ Y`, i.e  `S`-linear map `S ⨂ X β†’ Y` by
 `s βŠ— x ↦ s β€’ g x`.
 -/
 @[simps]
-def HomEquiv.fromExtendScalars {X Y} (g : X ⟢ (restrictScalars f).obj Y) :
-    (extendScalars f).obj X ⟢ Y :=
+def ModuleCat.ExtendRestrictScalarsAdj.HomEquiv.fromExtendScalars {X Y}
+    (g : X ⟢ (ModuleCat.restrictScalars f).obj Y) : (ModuleCat.extendScalars f).obj X ⟢ Y :=
   by
   letI m1 : Module R S := Module.compHom S f; letI m2 : Module R Y := Module.compHom Y f
   refine' ⟨fun z => TensorProduct.lift ⟨fun s => ⟨_, _, _⟩, _, _⟩ z, _, _⟩
@@ -528,18 +544,19 @@ def HomEquiv.fromExtendScalars {X Y} (g : X ⟢ (restrictScalars f).obj Y) :
     Β· simp only [smul_zero, map_zero]
     Β· simp only [LinearMap.coe_mk, extend_scalars.smul_tmul, lift.tmul, ← mul_smul]
     Β· rw [smul_add, map_add, ih1, ih2, map_add, smul_add]
-#align category_theory.Module.extend_restrict_scalars_adj.hom_equiv.from_extend_scalars CategoryTheory.ModuleCat.ExtendRestrictScalarsAdj.HomEquiv.fromExtendScalars
+#align category_theory.Module.extend_restrict_scalars_adj.hom_equiv.from_extend_scalars ModuleCat.ExtendRestrictScalarsAdj.HomEquiv.fromExtendScalars
 -/
 
-#print CategoryTheory.ModuleCat.ExtendRestrictScalarsAdj.homEquiv /-
+#print ModuleCat.ExtendRestrictScalarsAdj.homEquiv /-
 /-- Given `R`-module X and `S`-module Y, `S`-linear linear maps `(extend_scalars f).obj X ⟢ Y`
 bijectively correspond to `R`-linear maps `X ⟢ (restrict_scalars f).obj Y`.
 -/
 @[simps]
-def homEquiv {X Y} : ((extendScalars f).obj X ⟢ Y) ≃ (X ⟢ (restrictScalars f).obj Y)
+def ModuleCat.ExtendRestrictScalarsAdj.homEquiv {X Y} :
+    ((ModuleCat.extendScalars f).obj X ⟢ Y) ≃ (X ⟢ (ModuleCat.restrictScalars f).obj Y)
     where
-  toFun := HomEquiv.toRestrictScalars f
-  invFun := HomEquiv.fromExtendScalars f
+  toFun := ModuleCat.ExtendRestrictScalarsAdj.HomEquiv.toRestrictScalars f
+  invFun := ModuleCat.ExtendRestrictScalarsAdj.HomEquiv.fromExtendScalars f
   left_inv g := by
     ext z
     induction' z using TensorProduct.induction_on with x s z1 z2 ih1 ih2
@@ -554,41 +571,44 @@ def homEquiv {X Y} : ((extendScalars f).obj X ⟢ Y) ≃ (X ⟢ (restrictScalars
     rw [hom_equiv.to_restrict_scalars_apply, hom_equiv.from_extend_scalars_apply, lift.tmul,
       LinearMap.coe_mk, LinearMap.coe_mk]
     convert one_smul _ _
-#align category_theory.Module.extend_restrict_scalars_adj.hom_equiv CategoryTheory.ModuleCat.ExtendRestrictScalarsAdj.homEquiv
+#align category_theory.Module.extend_restrict_scalars_adj.hom_equiv ModuleCat.ExtendRestrictScalarsAdj.homEquiv
 -/
 
-#print CategoryTheory.ModuleCat.ExtendRestrictScalarsAdj.Unit.map /-
+#print ModuleCat.ExtendRestrictScalarsAdj.Unit.map /-
 /--
 For any `R`-module X, there is a natural `R`-linear map from `X` to `X ⨂ S` by sending `x ↦ x βŠ— 1`
 -/
 @[simps]
-def Unit.map {X} : X ⟢ (extendScalars f β‹™ restrictScalars f).obj X
+def ModuleCat.ExtendRestrictScalarsAdj.Unit.map {X} :
+    X ⟢ (ModuleCat.extendScalars f β‹™ ModuleCat.restrictScalars f).obj X
     where
   toFun x := (1 : S)βŠ—β‚œ[R,f]x
   map_add' x x' := by rw [TensorProduct.tmul_add]
   map_smul' r x := by letI m1 : Module R S := Module.compHom S f; tidy
-#align category_theory.Module.extend_restrict_scalars_adj.unit.map CategoryTheory.ModuleCat.ExtendRestrictScalarsAdj.Unit.map
+#align category_theory.Module.extend_restrict_scalars_adj.unit.map ModuleCat.ExtendRestrictScalarsAdj.Unit.map
 -/
 
-#print CategoryTheory.ModuleCat.ExtendRestrictScalarsAdj.unit /-
+#print ModuleCat.ExtendRestrictScalarsAdj.unit /-
 /--
 The natural transformation from identity functor on `R`-module to the composition of extension and
 restriction of scalars.
 -/
 @[simps]
-def unit : 𝟭 (ModuleCat R) ⟢ extendScalars f β‹™ restrictScalars f
+def ModuleCat.ExtendRestrictScalarsAdj.unit :
+    𝟭 (ModuleCat R) ⟢ ModuleCat.extendScalars f β‹™ ModuleCat.restrictScalars f
     where
-  app _ := Unit.map f
+  app _ := ModuleCat.ExtendRestrictScalarsAdj.Unit.map f
   naturality' X X' g := by tidy
-#align category_theory.Module.extend_restrict_scalars_adj.unit CategoryTheory.ModuleCat.ExtendRestrictScalarsAdj.unit
+#align category_theory.Module.extend_restrict_scalars_adj.unit ModuleCat.ExtendRestrictScalarsAdj.unit
 -/
 
-#print CategoryTheory.ModuleCat.ExtendRestrictScalarsAdj.Counit.map /-
+#print ModuleCat.ExtendRestrictScalarsAdj.Counit.map /-
 /-- For any `S`-module Y, there is a natural `R`-linear map from `S ⨂ Y` to `Y` by
 `s βŠ— y ↦ s β€’ y`
 -/
 @[simps]
-def Counit.map {Y} : (restrictScalars f β‹™ extendScalars f).obj Y ⟢ Y :=
+def ModuleCat.ExtendRestrictScalarsAdj.Counit.map {Y} :
+    (ModuleCat.restrictScalars f β‹™ ModuleCat.extendScalars f).obj Y ⟢ Y :=
   by
   letI m1 : Module R S := Module.compHom S f
   letI m2 : Module R Y := Module.compHom Y f
@@ -607,17 +627,18 @@ def Counit.map {Y} : (restrictScalars f β‹™ extendScalars f).obj Y ⟢ Y :=
     Β· simp only [smul_zero, map_zero]
     Β· simp only [extend_scalars.smul_tmul, LinearMap.coe_mk, TensorProduct.lift.tmul, mul_smul]
     Β· rw [smul_add, map_add, map_add, ih1, ih2, smul_add]
-#align category_theory.Module.extend_restrict_scalars_adj.counit.map CategoryTheory.ModuleCat.ExtendRestrictScalarsAdj.Counit.map
+#align category_theory.Module.extend_restrict_scalars_adj.counit.map ModuleCat.ExtendRestrictScalarsAdj.Counit.map
 -/
 
-#print CategoryTheory.ModuleCat.ExtendRestrictScalarsAdj.counit /-
+#print ModuleCat.ExtendRestrictScalarsAdj.counit /-
 /-- The natural transformation from the composition of restriction and extension of scalars to the
 identity functor on `S`-module.
 -/
 @[simps]
-def counit : restrictScalars f β‹™ extendScalars f ⟢ 𝟭 (ModuleCat S)
+def ModuleCat.ExtendRestrictScalarsAdj.counit :
+    ModuleCat.restrictScalars f β‹™ ModuleCat.extendScalars f ⟢ 𝟭 (ModuleCat S)
     where
-  app _ := Counit.map f
+  app _ := ModuleCat.ExtendRestrictScalarsAdj.Counit.map f
   naturality' Y Y' g := by
     ext z; induction z using TensorProduct.induction_on
     Β· simp only [map_zero]
@@ -626,22 +647,22 @@ def counit : restrictScalars f β‹™ extendScalars f ⟢ 𝟭 (ModuleCat S)
         extend_scalars.map_tmul, restrict_scalars.map_apply, counit.map_apply, lift.tmul,
         LinearMap.coe_mk, CategoryTheory.Functor.id_map, LinearMap.map_smulβ‚›β‚—, RingHom.id_apply]
     Β· simp only [map_add, *]
-#align category_theory.Module.extend_restrict_scalars_adj.counit CategoryTheory.ModuleCat.ExtendRestrictScalarsAdj.counit
+#align category_theory.Module.extend_restrict_scalars_adj.counit ModuleCat.ExtendRestrictScalarsAdj.counit
 -/
 
 end ExtendRestrictScalarsAdj
 
-#print CategoryTheory.ModuleCat.extendRestrictScalarsAdj /-
+#print ModuleCat.extendRestrictScalarsAdj /-
 /-- Given commutative rings `R, S` and a ring hom `f : R β†’+* S`, the extension and restriction of
 scalars by `f` are adjoint to each other.
 -/
 @[simps]
-def extendRestrictScalarsAdj {R : Type u₁} {S : Type uβ‚‚} [CommRing R] [CommRing S] (f : R β†’+* S) :
-    extendScalars f ⊣ restrictScalars f
+def ModuleCat.extendRestrictScalarsAdj {R : Type u₁} {S : Type uβ‚‚} [CommRing R] [CommRing S]
+    (f : R β†’+* S) : ModuleCat.extendScalars f ⊣ ModuleCat.restrictScalars f
     where
-  homEquiv _ _ := ExtendRestrictScalarsAdj.homEquiv f
-  Unit := ExtendRestrictScalarsAdj.unit f
-  counit := ExtendRestrictScalarsAdj.counit f
+  homEquiv _ _ := ModuleCat.ExtendRestrictScalarsAdj.homEquiv f
+  Unit := ModuleCat.ExtendRestrictScalarsAdj.unit f
+  counit := ModuleCat.ExtendRestrictScalarsAdj.counit f
   homEquiv_unit X Y g := LinearMap.ext fun x => by simp
   homEquiv_counit X Y g :=
     LinearMap.ext fun x => by
@@ -653,16 +674,16 @@ def extendRestrictScalarsAdj {R : Type u₁} {S : Type uβ‚‚} [CommRing R] [CommR
           extend_restrict_scalars_adj.counit_app, ModuleCat.coe_comp, Function.comp_apply,
           extend_scalars.map_tmul, extend_restrict_scalars_adj.counit.map_apply]
       Β· simp only [map_add, *]
-#align category_theory.Module.extend_restrict_scalars_adj CategoryTheory.ModuleCat.extendRestrictScalarsAdj
+#align category_theory.Module.extend_restrict_scalars_adj ModuleCat.extendRestrictScalarsAdj
 -/
 
 instance {R : Type u₁} {S : Type uβ‚‚} [CommRing R] [CommRing S] (f : R β†’+* S) :
-    CategoryTheory.IsLeftAdjoint (extendScalars f) :=
-  ⟨_, extendRestrictScalarsAdj f⟩
+    CategoryTheory.IsLeftAdjoint (ModuleCat.extendScalars f) :=
+  ⟨_, ModuleCat.extendRestrictScalarsAdj f⟩
 
 instance {R : Type u₁} {S : Type uβ‚‚} [CommRing R] [CommRing S] (f : R β†’+* S) :
-    CategoryTheory.IsRightAdjoint (restrictScalars f) :=
-  ⟨_, extendRestrictScalarsAdj f⟩
+    CategoryTheory.IsRightAdjoint (ModuleCat.restrictScalars f) :=
+  ⟨_, ModuleCat.extendRestrictScalarsAdj f⟩
 
 end CategoryTheory.Module
 
Diff
@@ -266,7 +266,7 @@ instance mulAction : MulAction S <| S' β†’β‚—[R] M :=
     CoextendScalars.hasSMul f
       _ with
     one_smul := fun g => LinearMap.ext fun s : S => by simp
-    mul_smul := fun (s t : S) g => LinearMap.ext fun x : S => by simp [mul_assoc] }
+    hMul_smul := fun (s t : S) g => LinearMap.ext fun x : S => by simp [mul_assoc] }
 #align category_theory.Module.coextend_scalars.mul_action CategoryTheory.ModuleCat.CoextendScalars.mulAction
 -/
 
Diff
@@ -2,15 +2,12 @@
 Copyright (c) 2022 Jujian Zhang. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Jujian Zhang
-
-! This file was ported from Lean 3 source module algebra.category.Module.change_of_rings
-! leanprover-community/mathlib commit 1a51edf13debfcbe223fa06b1cb353b9ed9751cc
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathbin.Algebra.Category.Module.Basic
 import Mathbin.RingTheory.TensorProduct
 
+#align_import algebra.category.Module.change_of_rings from "leanprover-community/mathlib"@"1a51edf13debfcbe223fa06b1cb353b9ed9751cc"
+
 /-!
 # Change Of Rings
 
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Jujian Zhang
 
 ! This file was ported from Lean 3 source module algebra.category.Module.change_of_rings
-! leanprover-community/mathlib commit 56b71f0b55c03f70332b862e65c3aa1aa1249ca1
+! leanprover-community/mathlib commit 1a51edf13debfcbe223fa06b1cb353b9ed9751cc
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -14,6 +14,9 @@ import Mathbin.RingTheory.TensorProduct
 /-!
 # Change Of Rings
 
+> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
+> Any changes to this file require a corresponding PR to mathlib4.
+
 ## Main definitions
 
 * `category_theory.Module.restrict_scalars`: given rings `R, S` and a ring homomorphism `R ⟢ S`,
Diff
@@ -53,22 +53,27 @@ variable {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] (f : R β†’+* S)
 
 variable (M : ModuleCat.{v} S)
 
+#print CategoryTheory.ModuleCat.RestrictScalars.obj' /-
 /-- Any `S`-module M is also an `R`-module via a ring homomorphism `f : R ⟢ S` by defining
     `r β€’ m := f r β€’ m` (`module.comp_hom`). This is called restriction of scalars. -/
 def obj' : ModuleCat R where
   carrier := M
   isModule := Module.compHom M f
-#align category_theory.Module.restrict_scalars.obj' CategoryTheory.Module.RestrictScalars.obj'
+#align category_theory.Module.restrict_scalars.obj' CategoryTheory.ModuleCat.RestrictScalars.obj'
+-/
 
+#print CategoryTheory.ModuleCat.RestrictScalars.map' /-
 /-- Given an `S`-linear map `g : M β†’ M'` between `S`-modules, `g` is also `R`-linear between `M` and
 `M'` by means of restriction of scalars.
 -/
 def map' {M M' : ModuleCat.{v} S} (g : M ⟢ M') : obj' f M ⟢ obj' f M' :=
   { g with map_smul' := fun r => g.map_smul (f r) }
-#align category_theory.Module.restrict_scalars.map' CategoryTheory.Module.RestrictScalars.map'
+#align category_theory.Module.restrict_scalars.map' CategoryTheory.ModuleCat.RestrictScalars.map'
+-/
 
 end RestrictScalars
 
+#print CategoryTheory.ModuleCat.restrictScalars /-
 /-- The restriction of scalars operation is functorial. For any `f : R β†’+* S` a ring homomorphism,
 * an `S`-module `M` can be considered as `R`-module by `r β€’ m = f r β€’ m`
 * an `S`-linear map is also `R`-linear
@@ -80,35 +85,44 @@ def restrictScalars {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] (f : R β†’
   map _ _ := RestrictScalars.map' f
   map_id' _ := LinearMap.ext fun m => rfl
   map_comp' _ _ _ g h := LinearMap.ext fun m => rfl
-#align category_theory.Module.restrict_scalars CategoryTheory.Module.restrictScalars
+#align category_theory.Module.restrict_scalars CategoryTheory.ModuleCat.restrictScalars
+-/
 
 instance {R : Type u₁} {S : Type uβ‚‚} [CommRing R] [CommRing S] (f : R β†’+* S) :
     CategoryTheory.Faithful (restrictScalars.{v} f)
     where map_injective' _ _ _ _ h :=
     LinearMap.ext fun x => by simpa only using FunLike.congr_fun h x
 
+#print CategoryTheory.ModuleCat.restrictScalars.map_apply /-
 @[simp]
 theorem restrictScalars.map_apply {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] (f : R β†’+* S)
     {M M' : ModuleCat.{v} S} (g : M ⟢ M') (x) : (restrictScalars f).map g x = g x :=
   rfl
-#align category_theory.Module.restrict_scalars.map_apply CategoryTheory.Module.restrictScalars.map_apply
+#align category_theory.Module.restrict_scalars.map_apply CategoryTheory.ModuleCat.restrictScalars.map_apply
+-/
 
+#print CategoryTheory.ModuleCat.restrictScalars.smul_def /-
 @[simp]
 theorem restrictScalars.smul_def {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] (f : R β†’+* S)
     {M : ModuleCat.{v} S} (r : R) (m : (restrictScalars f).obj M) : r β€’ m = (f r β€’ m : M) :=
   rfl
-#align category_theory.Module.restrict_scalars.smul_def CategoryTheory.Module.restrictScalars.smul_def
+#align category_theory.Module.restrict_scalars.smul_def CategoryTheory.ModuleCat.restrictScalars.smul_def
+-/
 
+#print CategoryTheory.ModuleCat.restrictScalars.smul_def' /-
 theorem restrictScalars.smul_def' {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] (f : R β†’+* S)
     {M : ModuleCat.{v} S} (r : R) (m : M) : (r β€’ m : (restrictScalars f).obj M) = (f r β€’ m : M) :=
   rfl
-#align category_theory.Module.restrict_scalars.smul_def' CategoryTheory.Module.restrictScalars.smul_def'
+#align category_theory.Module.restrict_scalars.smul_def' CategoryTheory.ModuleCat.restrictScalars.smul_def'
+-/
 
+#print CategoryTheory.ModuleCat.sMulCommClass_mk /-
 instance (priority := 100) sMulCommClass_mk {R : Type u₁} {S : Type uβ‚‚} [Ring R] [CommRing S]
     (f : R β†’+* S) (M : Type v) [AddCommGroup M] [Module S M] :
     @SMulCommClass R S M (RestrictScalars.obj' f (ModuleCat.mk M)).isModule.toSMul _
     where smul_comm r s m := (by simp [← mul_smul, mul_comm] : f r β€’ s β€’ m = s β€’ f r β€’ m)
-#align category_theory.Module.smul_comm_class_mk CategoryTheory.Module.sMulCommClass_mk
+#align category_theory.Module.smul_comm_class_mk CategoryTheory.ModuleCat.sMulCommClass_mk
+-/
 
 namespace ExtendScalars
 
@@ -131,20 +145,25 @@ open scoped ChangeOfRings
 
 variable (M : ModuleCat.{v} R)
 
+#print CategoryTheory.ModuleCat.ExtendScalars.obj' /-
 /-- Extension of scalars turn an `R`-module into `S`-module by M ↦ S ⨂ M
 -/
 def obj' : ModuleCat S :=
   ⟨TensorProduct R ((restrictScalars f).obj ⟨S⟩) M⟩
-#align category_theory.Module.extend_scalars.obj' CategoryTheory.Module.ExtendScalars.obj'
+#align category_theory.Module.extend_scalars.obj' CategoryTheory.ModuleCat.ExtendScalars.obj'
+-/
 
+#print CategoryTheory.ModuleCat.ExtendScalars.map' /-
 /-- Extension of scalars is a functor where an `R`-module `M` is sent to `S βŠ— M` and
 `l : M1 ⟢ M2` is sent to `s βŠ— m ↦ s βŠ— l m`
 -/
 def map' {M1 M2 : ModuleCat.{v} R} (l : M1 ⟢ M2) : obj' f M1 ⟢ obj' f M2 :=
   by-- The "by apply" part makes this require 75% fewer heartbeats to process (#16371).
   apply @LinearMap.baseChange R S M1 M2 _ _ ((algebraMap S _).comp f).toAlgebra _ _ _ _ l
-#align category_theory.Module.extend_scalars.map' CategoryTheory.Module.ExtendScalars.map'
+#align category_theory.Module.extend_scalars.map' CategoryTheory.ModuleCat.ExtendScalars.map'
+-/
 
+#print CategoryTheory.ModuleCat.ExtendScalars.map'_id /-
 theorem map'_id {M : ModuleCat.{v} R} : map' f (πŸ™ M) = πŸ™ _ :=
   LinearMap.ext fun x : obj' f M =>
     by
@@ -153,8 +172,10 @@ theorem map'_id {M : ModuleCat.{v} R} : map' f (πŸ™ M) = πŸ™ _ :=
     Β· simp only [map_zero]
     Β· rw [LinearMap.baseChange_tmul, ModuleCat.id_apply]
     Β· rw [map_add, ihx, ihy]
-#align category_theory.Module.extend_scalars.map'_id CategoryTheory.Module.ExtendScalars.map'_id
+#align category_theory.Module.extend_scalars.map'_id CategoryTheory.ModuleCat.ExtendScalars.map'_id
+-/
 
+#print CategoryTheory.ModuleCat.ExtendScalars.map'_comp /-
 theorem map'_comp {M₁ Mβ‚‚ M₃ : ModuleCat.{v} R} (l₁₂ : M₁ ⟢ Mβ‚‚) (l₂₃ : Mβ‚‚ ⟢ M₃) :
     map' f (l₁₂ ≫ l₂₃) = map' f l₁₂ ≫ map' f l₂₃ :=
   LinearMap.ext fun x : obj' f M₁ => by
@@ -163,10 +184,12 @@ theorem map'_comp {M₁ Mβ‚‚ M₃ : ModuleCat.{v} R} (l₁₂ : M₁ ⟢ Mβ‚‚) (
     Β· rfl
     Β· rfl
     Β· simp only [map_add, ihx, ihy]
-#align category_theory.Module.extend_scalars.map'_comp CategoryTheory.Module.ExtendScalars.map'_comp
+#align category_theory.Module.extend_scalars.map'_comp CategoryTheory.ModuleCat.ExtendScalars.map'_comp
+-/
 
 end ExtendScalars
 
+#print CategoryTheory.ModuleCat.extendScalars /-
 /-- Extension of scalars is a functor where an `R`-module `M` is sent to `S βŠ— M` and
 `l : M1 ⟢ M2` is sent to `s βŠ— m ↦ s βŠ— l m`
 -/
@@ -177,7 +200,8 @@ def extendScalars {R : Type u₁} {S : Type uβ‚‚} [CommRing R] [CommRing S] (f :
   map M1 M2 l := ExtendScalars.map' f l
   map_id' _ := ExtendScalars.map'_id f
   map_comp' _ _ _ := ExtendScalars.map'_comp f
-#align category_theory.Module.extend_scalars CategoryTheory.Module.extendScalars
+#align category_theory.Module.extend_scalars CategoryTheory.ModuleCat.extendScalars
+-/
 
 namespace ExtendScalars
 
@@ -185,17 +209,21 @@ open scoped ChangeOfRings
 
 variable {R : Type u₁} {S : Type uβ‚‚} [CommRing R] [CommRing S] (f : R β†’+* S)
 
+#print CategoryTheory.ModuleCat.ExtendScalars.smul_tmul /-
 @[simp]
 protected theorem smul_tmul {M : ModuleCat.{v} R} (s s' : S) (m : M) :
     s β€’ (s'βŠ—β‚œ[R,f]m : (extendScalars f).obj M) = (s * s')βŠ—β‚œ[R,f]m :=
   rfl
-#align category_theory.Module.extend_scalars.smul_tmul CategoryTheory.Module.extendScalars.smul_tmul
+#align category_theory.Module.extend_scalars.smul_tmul CategoryTheory.ModuleCat.ExtendScalars.smul_tmul
+-/
 
+#print CategoryTheory.ModuleCat.ExtendScalars.map_tmul /-
 @[simp]
 theorem map_tmul {M M' : ModuleCat.{v} R} (g : M ⟢ M') (s : S) (m : M) :
     (extendScalars f).map g (sβŠ—β‚œ[R,f]m) = sβŠ—β‚œ[R,f]g m :=
   rfl
-#align category_theory.Module.extend_scalars.map_tmul CategoryTheory.Module.extendScalars.map_tmul
+#align category_theory.Module.extend_scalars.map_tmul CategoryTheory.ModuleCat.ExtendScalars.map_tmul
+-/
 
 end ExtendScalars
 
@@ -210,40 +238,49 @@ variable (M : Type v) [AddCommMonoid M] [Module R M]
 -- We use `S'` to denote `S` viewed as `R`-module, via the map `f`.
 local notation "S'" => (restrictScalars f).obj ⟨S⟩
 
+#print CategoryTheory.ModuleCat.CoextendScalars.hasSMul /-
 /-- Given an `R`-module M, consider Hom(S, M) -- the `R`-linear maps between S (as an `R`-module by
  means of restriction of scalars) and M. `S` acts on Hom(S, M) by `s β€’ g = x ↦ g (x β€’ s)`
  -/
-instance hasSmul : SMul S <| S' β†’β‚—[R] M
+instance hasSMul : SMul S <| S' β†’β‚—[R] M
     where smul s g :=
     { toFun := fun s' : S => g (s' * s : S)
       map_add' := fun x y : S => by simp [add_mul, map_add]
       map_smul' := fun r (t : S) => by
         rw [RingHom.id_apply, @RestrictScalars.smul_def _ _ _ _ f ⟨S⟩, ← LinearMap.map_smul,
           @RestrictScalars.smul_def _ _ _ _ f ⟨S⟩, smul_eq_mul, smul_eq_mul, mul_assoc] }
-#align category_theory.Module.coextend_scalars.has_smul CategoryTheory.Module.CoextendScalars.hasSmul
+#align category_theory.Module.coextend_scalars.has_smul CategoryTheory.ModuleCat.CoextendScalars.hasSMul
+-/
 
+#print CategoryTheory.ModuleCat.CoextendScalars.smul_apply' /-
 @[simp]
 theorem smul_apply' (s : S) (g : S' β†’β‚—[R] M) (s' : S) :
-    @SMul.smul _ _ (CoextendScalars.hasSmul f _) s g s' = g (s' * s : S) :=
+    @SMul.smul _ _ (CoextendScalars.hasSMul f _) s g s' = g (s' * s : S) :=
   rfl
-#align category_theory.Module.coextend_scalars.smul_apply' CategoryTheory.Module.CoextendScalars.smul_apply'
+#align category_theory.Module.coextend_scalars.smul_apply' CategoryTheory.ModuleCat.CoextendScalars.smul_apply'
+-/
 
+#print CategoryTheory.ModuleCat.CoextendScalars.mulAction /-
 instance mulAction : MulAction S <| S' β†’β‚—[R] M :=
   {
-    CoextendScalars.hasSmul f
+    CoextendScalars.hasSMul f
       _ with
     one_smul := fun g => LinearMap.ext fun s : S => by simp
     mul_smul := fun (s t : S) g => LinearMap.ext fun x : S => by simp [mul_assoc] }
-#align category_theory.Module.coextend_scalars.mul_action CategoryTheory.Module.CoextendScalars.mulAction
+#align category_theory.Module.coextend_scalars.mul_action CategoryTheory.ModuleCat.CoextendScalars.mulAction
+-/
 
+#print CategoryTheory.ModuleCat.CoextendScalars.distribMulAction /-
 instance distribMulAction : DistribMulAction S <| S' β†’β‚—[R] M :=
   {
     CoextendScalars.mulAction f
       _ with
     smul_add := fun s g h => LinearMap.ext fun t : S => by simp
     smul_zero := fun s => LinearMap.ext fun t : S => by simp }
-#align category_theory.Module.coextend_scalars.distrib_mul_action CategoryTheory.Module.CoextendScalars.distribMulAction
+#align category_theory.Module.coextend_scalars.distrib_mul_action CategoryTheory.ModuleCat.CoextendScalars.distribMulAction
+-/
 
+#print CategoryTheory.ModuleCat.CoextendScalars.isModule /-
 /-- `S` acts on Hom(S, M) by `s β€’ g = x ↦ g (x β€’ s)`, this action defines an `S`-module structure on
 Hom(S, M).
  -/
@@ -253,20 +290,24 @@ instance isModule : Module S <| S' β†’β‚—[R] M :=
       _ with
     add_smul := fun s1 s2 g => LinearMap.ext fun x : S => by simp [mul_add]
     zero_smul := fun g => LinearMap.ext fun x : S => by simp }
-#align category_theory.Module.coextend_scalars.is_module CategoryTheory.Module.CoextendScalars.isModule
+#align category_theory.Module.coextend_scalars.is_module CategoryTheory.ModuleCat.CoextendScalars.isModule
+-/
 
 end Unbundled
 
 variable (M : ModuleCat.{v} R)
 
+#print CategoryTheory.ModuleCat.CoextendScalars.obj' /-
 /-- If `M` is an `R`-module, then the set of `R`-linear maps `S β†’β‚—[R] M` is an `S`-module with
 scalar multiplication defined by `s β€’ l := x ↦ l (x β€’ s)`-/
 def obj' : ModuleCat S :=
   ⟨(restrictScalars f).obj ⟨S⟩ β†’β‚—[R] M⟩
-#align category_theory.Module.coextend_scalars.obj' CategoryTheory.Module.CoextendScalars.obj'
+#align category_theory.Module.coextend_scalars.obj' CategoryTheory.ModuleCat.CoextendScalars.obj'
+-/
 
 instance : CoeFun (obj' f M) fun g => S β†’ M where coe g := g.toFun
 
+#print CategoryTheory.ModuleCat.CoextendScalars.map' /-
 /-- If `M, M'` are `R`-modules, then any `R`-linear map `g : M ⟢ M'` induces an `S`-linear map
 `(S β†’β‚—[R] M) ⟢ (S β†’β‚—[R] M')` defined by `h ↦ g ∘ h`-/
 @[simps]
@@ -275,10 +316,12 @@ def map' {M M' : ModuleCat R} (g : M ⟢ M') : obj' f M ⟢ obj' f M'
   toFun h := g.comp h
   map_add' _ _ := LinearMap.comp_add _ _ _
   map_smul' s h := LinearMap.ext fun t : S => by simpa only [smul_apply']
-#align category_theory.Module.coextend_scalars.map' CategoryTheory.Module.CoextendScalars.map'
+#align category_theory.Module.coextend_scalars.map' CategoryTheory.ModuleCat.CoextendScalars.map'
+-/
 
 end CoextendScalars
 
+#print CategoryTheory.ModuleCat.coextendScalars /-
 /--
 For any rings `R, S` and a ring homomorphism `f : R β†’+* S`, there is a functor from `R`-module to
 `S`-module defined by `M ↦ (S β†’β‚—[R] M)` where `S` is considered as an `R`-module via restriction of
@@ -290,7 +333,8 @@ def coextendScalars {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] (f : R β†’
   map _ _ := CoextendScalars.map' f
   map_id' M := LinearMap.ext fun h => LinearMap.ext fun x => rfl
   map_comp' _ _ _ g h := LinearMap.ext fun h => LinearMap.ext fun x => rfl
-#align category_theory.Module.coextend_scalars CategoryTheory.Module.coextendScalars
+#align category_theory.Module.coextend_scalars CategoryTheory.ModuleCat.coextendScalars
+-/
 
 namespace CoextendScalars
 
@@ -299,16 +343,20 @@ variable {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] (f : R β†’+* S)
 instance (M : ModuleCat R) : CoeFun ((coextendScalars f).obj M) fun g => S β†’ M :=
   (inferInstance : CoeFun (CoextendScalars.obj' f M) _)
 
+#print CategoryTheory.ModuleCat.CoextendScalars.smul_apply /-
 theorem smul_apply (M : ModuleCat R) (g : (coextendScalars f).obj M) (s s' : S) :
     (s β€’ g) s' = g (s' * s) :=
   rfl
-#align category_theory.Module.coextend_scalars.smul_apply CategoryTheory.Module.coextendScalars.smul_apply
+#align category_theory.Module.coextend_scalars.smul_apply CategoryTheory.ModuleCat.CoextendScalars.smul_apply
+-/
 
+#print CategoryTheory.ModuleCat.CoextendScalars.map_apply /-
 @[simp]
 theorem map_apply {M M' : ModuleCat R} (g : M ⟢ M') (x) (s : S) :
     (coextendScalars f).map g x s = g (x s) :=
   rfl
-#align category_theory.Module.coextend_scalars.map_apply CategoryTheory.Module.coextendScalars.map_apply
+#align category_theory.Module.coextend_scalars.map_apply CategoryTheory.ModuleCat.CoextendScalars.map_apply
+-/
 
 end CoextendScalars
 
@@ -316,6 +364,7 @@ namespace RestrictionCoextensionAdj
 
 variable {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] (f : R β†’+* S)
 
+#print CategoryTheory.ModuleCat.RestrictionCoextensionAdj.HomEquiv.fromRestriction /-
 /-- Given `R`-module X and `S`-module Y, any `g : (restrict_of_scalars f).obj Y ⟢ X`
 corresponds to `Y ⟢ (coextend_scalars f).obj X` by sending `y ↦ (s ↦ g (s β€’ y))`
 -/
@@ -334,8 +383,10 @@ def HomEquiv.fromRestriction {X Y} (g : (restrictScalars f).obj Y ⟢ X) :
       rw [LinearMap.add_apply, LinearMap.coe_mk, LinearMap.coe_mk, LinearMap.coe_mk, smul_add,
         map_add]
   map_smul' s y := LinearMap.ext fun t : S => by simp [mul_smul]
-#align category_theory.Module.restriction_coextension_adj.hom_equiv.from_restriction CategoryTheory.Module.RestrictionCoextensionAdj.HomEquiv.fromRestriction
+#align category_theory.Module.restriction_coextension_adj.hom_equiv.from_restriction CategoryTheory.ModuleCat.RestrictionCoextensionAdj.HomEquiv.fromRestriction
+-/
 
+#print CategoryTheory.ModuleCat.RestrictionCoextensionAdj.HomEquiv.toRestriction /-
 /-- Given `R`-module X and `S`-module Y, any `g : Y ⟢ (coextend_scalars f).obj X`
 corresponds to `(restrict_scalars f).obj Y ⟢ X` by `y ↦ g y 1`
 -/
@@ -348,8 +399,10 @@ def HomEquiv.toRestriction {X Y} (g : Y ⟢ (coextendScalars f).obj X) : (restri
     rw [LinearMap.toFun_eq_coe, LinearMap.toFun_eq_coe, RingHom.id_apply, ← LinearMap.map_smul,
       RestrictScalars.smul_def f r y, @RestrictScalars.smul_def _ _ _ _ f ⟨S⟩, smul_eq_mul, mul_one,
       LinearMap.map_smul, coextend_scalars.smul_apply, one_mul]
-#align category_theory.Module.restriction_coextension_adj.hom_equiv.to_restriction CategoryTheory.Module.RestrictionCoextensionAdj.HomEquiv.toRestriction
+#align category_theory.Module.restriction_coextension_adj.hom_equiv.to_restriction CategoryTheory.ModuleCat.RestrictionCoextensionAdj.HomEquiv.toRestriction
+-/
 
+#print CategoryTheory.ModuleCat.RestrictionCoextensionAdj.unit' /-
 /--
 The natural transformation from identity functor to the composition of restriction and coextension
 of scalars.
@@ -370,8 +423,10 @@ protected def unit' : 𝟭 (ModuleCat S) ⟢ restrictScalars f β‹™ coextendScala
       map_smul' := fun s (y : Y) => LinearMap.ext fun t : S => by simp [mul_smul] }
   naturality' Y Y' g :=
     LinearMap.ext fun y : Y => LinearMap.ext fun s : S => by simp [coextend_scalars.map_apply]
-#align category_theory.Module.restriction_coextension_adj.unit' CategoryTheory.Module.RestrictionCoextensionAdj.unit'
+#align category_theory.Module.restriction_coextension_adj.unit' CategoryTheory.ModuleCat.RestrictionCoextensionAdj.unit'
+-/
 
+#print CategoryTheory.ModuleCat.RestrictionCoextensionAdj.counit' /-
 /-- The natural transformation from the composition of coextension and restriction of scalars to
 identity functor.
 -/
@@ -387,10 +442,12 @@ protected def counit' : coextendScalars f β‹™ restrictScalars f ⟢ 𝟭 (Module
         rw [RestrictScalars.smul_def f, coextend_scalars.smul_apply, one_mul, ← LinearMap.map_smul,
           @RestrictScalars.smul_def _ _ _ _ f ⟨S⟩, smul_eq_mul, mul_one] }
   naturality' X X' g := LinearMap.ext fun h => by simp [coextend_scalars.map_apply]
-#align category_theory.Module.restriction_coextension_adj.counit' CategoryTheory.Module.RestrictionCoextensionAdj.counit'
+#align category_theory.Module.restriction_coextension_adj.counit' CategoryTheory.ModuleCat.RestrictionCoextensionAdj.counit'
+-/
 
 end RestrictionCoextensionAdj
 
+#print CategoryTheory.ModuleCat.restrictCoextendScalarsAdj /-
 /-- Restriction of scalars is left adjoint to coextension of scalars. -/
 @[simps]
 def restrictCoextendScalarsAdj {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] (f : R β†’+* S) :
@@ -405,7 +462,8 @@ def restrictCoextendScalarsAdj {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S]
   counit := RestrictionCoextensionAdj.counit' f
   homEquiv_unit X Y g := LinearMap.ext fun y => rfl
   homEquiv_counit Y X g := LinearMap.ext fun y : Y => by simp
-#align category_theory.Module.restrict_coextend_scalars_adj CategoryTheory.Module.restrictCoextendScalarsAdj
+#align category_theory.Module.restrict_coextend_scalars_adj CategoryTheory.ModuleCat.restrictCoextendScalarsAdj
+-/
 
 instance {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] (f : R β†’+* S) :
     CategoryTheory.IsLeftAdjoint (restrictScalars f) :=
@@ -423,6 +481,7 @@ open TensorProduct
 
 variable {R : Type u₁} {S : Type uβ‚‚} [CommRing R] [CommRing S] (f : R β†’+* S)
 
+#print CategoryTheory.ModuleCat.ExtendRestrictScalarsAdj.HomEquiv.toRestrictScalars /-
 /--
 Given `R`-module X and `S`-module Y and a map `g : (extend_scalars f).obj X ⟢ Y`, i.e. `S`-linear
 map `S ⨂ X β†’ Y`, there is a `X ⟢ (restrict_scalars f).obj Y`, i.e. `R`-linear map `X ⟢ Y` by
@@ -439,8 +498,10 @@ def HomEquiv.toRestrictScalars {X Y} (g : (extendScalars f).obj X ⟢ Y) :
     letI : Module R Y := Module.compHom Y f
     rw [RingHom.id_apply, RestrictScalars.smul_def, ← LinearMap.map_smul, tmul_smul]
     congr
-#align category_theory.Module.extend_restrict_scalars_adj.hom_equiv.to_restrict_scalars CategoryTheory.Module.ExtendRestrictScalarsAdj.HomEquiv.toRestrictScalars
+#align category_theory.Module.extend_restrict_scalars_adj.hom_equiv.to_restrict_scalars CategoryTheory.ModuleCat.ExtendRestrictScalarsAdj.HomEquiv.toRestrictScalars
+-/
 
+#print CategoryTheory.ModuleCat.ExtendRestrictScalarsAdj.HomEquiv.fromExtendScalars /-
 /--
 Given `R`-module X and `S`-module Y and a map `X ⟢ (restrict_scalars f).obj Y`, i.e `R`-linear map
 `X ⟢ Y`, there is a map `(extend_scalars f).obj X ⟢ Y`, i.e  `S`-linear map `S ⨂ X β†’ Y` by
@@ -467,8 +528,10 @@ def HomEquiv.fromExtendScalars {X Y} (g : X ⟢ (restrictScalars f).obj Y) :
     Β· simp only [smul_zero, map_zero]
     Β· simp only [LinearMap.coe_mk, extend_scalars.smul_tmul, lift.tmul, ← mul_smul]
     Β· rw [smul_add, map_add, ih1, ih2, map_add, smul_add]
-#align category_theory.Module.extend_restrict_scalars_adj.hom_equiv.from_extend_scalars CategoryTheory.Module.ExtendRestrictScalarsAdj.HomEquiv.fromExtendScalars
+#align category_theory.Module.extend_restrict_scalars_adj.hom_equiv.from_extend_scalars CategoryTheory.ModuleCat.ExtendRestrictScalarsAdj.HomEquiv.fromExtendScalars
+-/
 
+#print CategoryTheory.ModuleCat.ExtendRestrictScalarsAdj.homEquiv /-
 /-- Given `R`-module X and `S`-module Y, `S`-linear linear maps `(extend_scalars f).obj X ⟢ Y`
 bijectively correspond to `R`-linear maps `X ⟢ (restrict_scalars f).obj Y`.
 -/
@@ -491,8 +554,10 @@ def homEquiv {X Y} : ((extendScalars f).obj X ⟢ Y) ≃ (X ⟢ (restrictScalars
     rw [hom_equiv.to_restrict_scalars_apply, hom_equiv.from_extend_scalars_apply, lift.tmul,
       LinearMap.coe_mk, LinearMap.coe_mk]
     convert one_smul _ _
-#align category_theory.Module.extend_restrict_scalars_adj.hom_equiv CategoryTheory.Module.ExtendRestrictScalarsAdj.homEquiv
+#align category_theory.Module.extend_restrict_scalars_adj.hom_equiv CategoryTheory.ModuleCat.ExtendRestrictScalarsAdj.homEquiv
+-/
 
+#print CategoryTheory.ModuleCat.ExtendRestrictScalarsAdj.Unit.map /-
 /--
 For any `R`-module X, there is a natural `R`-linear map from `X` to `X ⨂ S` by sending `x ↦ x βŠ— 1`
 -/
@@ -502,8 +567,10 @@ def Unit.map {X} : X ⟢ (extendScalars f β‹™ restrictScalars f).obj X
   toFun x := (1 : S)βŠ—β‚œ[R,f]x
   map_add' x x' := by rw [TensorProduct.tmul_add]
   map_smul' r x := by letI m1 : Module R S := Module.compHom S f; tidy
-#align category_theory.Module.extend_restrict_scalars_adj.unit.map CategoryTheory.Module.ExtendRestrictScalarsAdj.Unit.map
+#align category_theory.Module.extend_restrict_scalars_adj.unit.map CategoryTheory.ModuleCat.ExtendRestrictScalarsAdj.Unit.map
+-/
 
+#print CategoryTheory.ModuleCat.ExtendRestrictScalarsAdj.unit /-
 /--
 The natural transformation from identity functor on `R`-module to the composition of extension and
 restriction of scalars.
@@ -513,8 +580,10 @@ def unit : 𝟭 (ModuleCat R) ⟢ extendScalars f β‹™ restrictScalars f
     where
   app _ := Unit.map f
   naturality' X X' g := by tidy
-#align category_theory.Module.extend_restrict_scalars_adj.unit CategoryTheory.Module.ExtendRestrictScalarsAdj.unit
+#align category_theory.Module.extend_restrict_scalars_adj.unit CategoryTheory.ModuleCat.ExtendRestrictScalarsAdj.unit
+-/
 
+#print CategoryTheory.ModuleCat.ExtendRestrictScalarsAdj.Counit.map /-
 /-- For any `S`-module Y, there is a natural `R`-linear map from `S ⨂ Y` to `Y` by
 `s βŠ— y ↦ s β€’ y`
 -/
@@ -538,8 +607,10 @@ def Counit.map {Y} : (restrictScalars f β‹™ extendScalars f).obj Y ⟢ Y :=
     Β· simp only [smul_zero, map_zero]
     Β· simp only [extend_scalars.smul_tmul, LinearMap.coe_mk, TensorProduct.lift.tmul, mul_smul]
     Β· rw [smul_add, map_add, map_add, ih1, ih2, smul_add]
-#align category_theory.Module.extend_restrict_scalars_adj.counit.map CategoryTheory.Module.ExtendRestrictScalarsAdj.Counit.map
+#align category_theory.Module.extend_restrict_scalars_adj.counit.map CategoryTheory.ModuleCat.ExtendRestrictScalarsAdj.Counit.map
+-/
 
+#print CategoryTheory.ModuleCat.ExtendRestrictScalarsAdj.counit /-
 /-- The natural transformation from the composition of restriction and extension of scalars to the
 identity functor on `S`-module.
 -/
@@ -555,10 +626,12 @@ def counit : restrictScalars f β‹™ extendScalars f ⟢ 𝟭 (ModuleCat S)
         extend_scalars.map_tmul, restrict_scalars.map_apply, counit.map_apply, lift.tmul,
         LinearMap.coe_mk, CategoryTheory.Functor.id_map, LinearMap.map_smulβ‚›β‚—, RingHom.id_apply]
     Β· simp only [map_add, *]
-#align category_theory.Module.extend_restrict_scalars_adj.counit CategoryTheory.Module.ExtendRestrictScalarsAdj.counit
+#align category_theory.Module.extend_restrict_scalars_adj.counit CategoryTheory.ModuleCat.ExtendRestrictScalarsAdj.counit
+-/
 
 end ExtendRestrictScalarsAdj
 
+#print CategoryTheory.ModuleCat.extendRestrictScalarsAdj /-
 /-- Given commutative rings `R, S` and a ring hom `f : R β†’+* S`, the extension and restriction of
 scalars by `f` are adjoint to each other.
 -/
@@ -580,7 +653,8 @@ def extendRestrictScalarsAdj {R : Type u₁} {S : Type uβ‚‚} [CommRing R] [CommR
           extend_restrict_scalars_adj.counit_app, ModuleCat.coe_comp, Function.comp_apply,
           extend_scalars.map_tmul, extend_restrict_scalars_adj.counit.map_apply]
       Β· simp only [map_add, *]
-#align category_theory.Module.extend_restrict_scalars_adj CategoryTheory.Module.extendRestrictScalarsAdj
+#align category_theory.Module.extend_restrict_scalars_adj CategoryTheory.ModuleCat.extendRestrictScalarsAdj
+-/
 
 instance {R : Type u₁} {S : Type uβ‚‚} [CommRing R] [CommRing S] (f : R β†’+* S) :
     CategoryTheory.IsLeftAdjoint (extendScalars f) :=
Diff
@@ -120,7 +120,6 @@ section Unbundled
 
 variable (M : Type v) [AddCommMonoid M] [Module R M]
 
--- mathport name: Β«expr βŠ—β‚œ[ , ] Β»
 -- This notation is necessary because we need to reason about `s βŠ—β‚œ m` where `s : S` and `m : M`;
 -- without this notation, one need to work with `s : (restrict_scalars f).obj ⟨S⟩`.
 scoped[ChangeOfRings]
@@ -208,7 +207,6 @@ section Unbundled
 
 variable (M : Type v) [AddCommMonoid M] [Module R M]
 
--- mathport name: exprS'
 -- We use `S'` to denote `S` viewed as `R`-module, via the map `f`.
 local notation "S'" => (restrictScalars f).obj ⟨S⟩
 
Diff
@@ -455,14 +455,14 @@ def HomEquiv.fromExtendScalars {X Y} (g : X ⟢ (restrictScalars f).obj Y) :
   letI m1 : Module R S := Module.compHom S f; letI m2 : Module R Y := Module.compHom Y f
   refine' ⟨fun z => TensorProduct.lift ⟨fun s => ⟨_, _, _⟩, _, _⟩ z, _, _⟩
   Β· exact fun x => s β€’ g x
-  Β· intros ; rw [map_add, smul_add]
-  Β· intros ; rw [RingHom.id_apply, smul_comm, ← LinearMap.map_smul]
-  Β· intros ; ext; simp only [LinearMap.coe_mk, LinearMap.add_apply]; rw [← add_smul]
-  Β· intros ; ext
+  Β· intros; rw [map_add, smul_add]
+  Β· intros; rw [RingHom.id_apply, smul_comm, ← LinearMap.map_smul]
+  Β· intros; ext; simp only [LinearMap.coe_mk, LinearMap.add_apply]; rw [← add_smul]
+  Β· intros; ext
     simp only [LinearMap.coe_mk, RingHom.id_apply, LinearMap.smul_apply, RestrictScalars.smul_def,
       smul_eq_mul]
     convert mul_smul _ _ _
-  Β· intros ; rw [map_add]
+  Β· intros; rw [map_add]
   Β· intro r z
     rw [RingHom.id_apply]
     induction' z using TensorProduct.induction_on with x y x y ih1 ih2
@@ -485,7 +485,7 @@ def homEquiv {X Y} : ((extendScalars f).obj X ⟢ Y) ≃ (X ⟢ (restrictScalars
     Β· simp only [map_zero]
     Β· erw [TensorProduct.lift.tmul]
       simp only [LinearMap.coe_mk]
-      change S at x
+      change S at x 
       erw [← LinearMap.map_smul, extend_scalars.smul_tmul, mul_one x]
     Β· rw [map_add, map_add, ih1, ih2]
   right_inv g := by
@@ -526,14 +526,14 @@ def Counit.map {Y} : (restrictScalars f β‹™ extendScalars f).obj Y ⟢ Y :=
   letI m1 : Module R S := Module.compHom S f
   letI m2 : Module R Y := Module.compHom Y f
   refine' ⟨TensorProduct.lift ⟨fun s : S => ⟨fun y : Y => s β€’ y, smul_add _, _⟩, _, _⟩, _, _⟩
-  Β· intros ;
+  Β· intros;
     rw [RingHom.id_apply, RestrictScalars.smul_def, ← mul_smul, mul_comm, mul_smul,
       RestrictScalars.smul_def]
-  Β· intros ; ext; simp only [LinearMap.add_apply, LinearMap.coe_mk, add_smul]
-  Β· intros ; ext
+  Β· intros; ext; simp only [LinearMap.add_apply, LinearMap.coe_mk, add_smul]
+  Β· intros; ext
     simpa only [RingHom.id_apply, LinearMap.smul_apply, LinearMap.coe_mk,
       @RestrictScalars.smul_def _ _ _ _ f ⟨S⟩, smul_eq_mul, mul_smul]
-  Β· intros ; rw [map_add]
+  Β· intros; rw [map_add]
   Β· intro s z
     rw [RingHom.id_apply]
     induction' z using TensorProduct.induction_on with x s' z1 z2 ih1 ih2
Diff
@@ -128,7 +128,7 @@ scoped[ChangeOfRings]
 
 end Unbundled
 
-open ChangeOfRings
+open scoped ChangeOfRings
 
 variable (M : ModuleCat.{v} R)
 
@@ -182,7 +182,7 @@ def extendScalars {R : Type u₁} {S : Type uβ‚‚} [CommRing R] [CommRing S] (f :
 
 namespace ExtendScalars
 
-open ChangeOfRings
+open scoped ChangeOfRings
 
 variable {R : Type u₁} {S : Type uβ‚‚} [CommRing R] [CommRing S] (f : R β†’+* S)
 
@@ -419,7 +419,7 @@ instance {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] (f : R β†’+* S) :
 
 namespace ExtendRestrictScalarsAdj
 
-open ChangeOfRings
+open scoped ChangeOfRings
 
 open TensorProduct
 
Diff
@@ -455,21 +455,14 @@ def HomEquiv.fromExtendScalars {X Y} (g : X ⟢ (restrictScalars f).obj Y) :
   letI m1 : Module R S := Module.compHom S f; letI m2 : Module R Y := Module.compHom Y f
   refine' ⟨fun z => TensorProduct.lift ⟨fun s => ⟨_, _, _⟩, _, _⟩ z, _, _⟩
   Β· exact fun x => s β€’ g x
-  Β· intros
-    rw [map_add, smul_add]
-  Β· intros
-    rw [RingHom.id_apply, smul_comm, ← LinearMap.map_smul]
-  Β· intros
-    ext
-    simp only [LinearMap.coe_mk, LinearMap.add_apply]
-    rw [← add_smul]
-  Β· intros
-    ext
+  Β· intros ; rw [map_add, smul_add]
+  Β· intros ; rw [RingHom.id_apply, smul_comm, ← LinearMap.map_smul]
+  Β· intros ; ext; simp only [LinearMap.coe_mk, LinearMap.add_apply]; rw [← add_smul]
+  Β· intros ; ext
     simp only [LinearMap.coe_mk, RingHom.id_apply, LinearMap.smul_apply, RestrictScalars.smul_def,
       smul_eq_mul]
     convert mul_smul _ _ _
-  Β· intros
-    rw [map_add]
+  Β· intros ; rw [map_add]
   Β· intro r z
     rw [RingHom.id_apply]
     induction' z using TensorProduct.induction_on with x y x y ih1 ih2
@@ -510,9 +503,7 @@ def Unit.map {X} : X ⟢ (extendScalars f β‹™ restrictScalars f).obj X
     where
   toFun x := (1 : S)βŠ—β‚œ[R,f]x
   map_add' x x' := by rw [TensorProduct.tmul_add]
-  map_smul' r x := by
-    letI m1 : Module R S := Module.compHom S f
-    tidy
+  map_smul' r x := by letI m1 : Module R S := Module.compHom S f; tidy
 #align category_theory.Module.extend_restrict_scalars_adj.unit.map CategoryTheory.Module.ExtendRestrictScalarsAdj.Unit.map
 
 /--
@@ -535,18 +526,14 @@ def Counit.map {Y} : (restrictScalars f β‹™ extendScalars f).obj Y ⟢ Y :=
   letI m1 : Module R S := Module.compHom S f
   letI m2 : Module R Y := Module.compHom Y f
   refine' ⟨TensorProduct.lift ⟨fun s : S => ⟨fun y : Y => s β€’ y, smul_add _, _⟩, _, _⟩, _, _⟩
-  Β· intros
+  Β· intros ;
     rw [RingHom.id_apply, RestrictScalars.smul_def, ← mul_smul, mul_comm, mul_smul,
       RestrictScalars.smul_def]
-  Β· intros
-    ext
-    simp only [LinearMap.add_apply, LinearMap.coe_mk, add_smul]
-  Β· intros
-    ext
+  Β· intros ; ext; simp only [LinearMap.add_apply, LinearMap.coe_mk, add_smul]
+  Β· intros ; ext
     simpa only [RingHom.id_apply, LinearMap.smul_apply, LinearMap.coe_mk,
       @RestrictScalars.smul_def _ _ _ _ f ⟨S⟩, smul_eq_mul, mul_smul]
-  Β· intros
-    rw [map_add]
+  Β· intros ; rw [map_add]
   Β· intro s z
     rw [RingHom.id_apply]
     induction' z using TensorProduct.induction_on with x s' z1 z2 ih1 ih2
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Jujian Zhang
 
 ! This file was ported from Lean 3 source module algebra.category.Module.change_of_rings
-! leanprover-community/mathlib commit 403190b5419b3f03f1a2893ad9352ca7f7d8bff6
+! leanprover-community/mathlib commit 56b71f0b55c03f70332b862e65c3aa1aa1249ca1
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -25,10 +25,16 @@ import Mathbin.RingTheory.TensorProduct
   module structure is defined by `s β€’ (s' βŠ— m) := (s * s') βŠ— m` and `R`-linear map `l : M ⟢ M'`
   is sent to `S`-linear map `s βŠ— m ↦ s βŠ— l m : S ⨂ M ⟢ S ⨂ M'`.
 
+* `category_theory.Module.coextend_scalars`: given rings `R, S` and a ring homomorphism `R ⟢ S`
+  then `coextend_scalars : Module R β₯€ Module S` is defined by `M ↦ (S β†’β‚—[R] M)` where `S` is seen as
+  `R-module` by restriction of scalars and `l ↦ l ∘ _`.
+
 ## Main results
 
 * `category_theory.Module.extend_restrict_scalars_adj`: given commutative rings `R, S` and a ring
   homomorphism `f : R β†’+* S`, the extension and restriction of scalars by `f` are adjoint functors.
+* `category_theory.Module.restrict_coextend_scalars_adj`: given rings `R, S` and a ring homomorphism
+  `f : R ⟢ S` then `coextend_scalars f` is the right adjoint of `restrict_scalars f`.
 
 ## List of notations
 Let `R, S` be rings and `f : R β†’+* S`
@@ -194,6 +200,223 @@ theorem map_tmul {M M' : ModuleCat.{v} R} (g : M ⟢ M') (s : S) (m : M) :
 
 end ExtendScalars
 
+namespace CoextendScalars
+
+variable {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] (f : R β†’+* S)
+
+section Unbundled
+
+variable (M : Type v) [AddCommMonoid M] [Module R M]
+
+-- mathport name: exprS'
+-- We use `S'` to denote `S` viewed as `R`-module, via the map `f`.
+local notation "S'" => (restrictScalars f).obj ⟨S⟩
+
+/-- Given an `R`-module M, consider Hom(S, M) -- the `R`-linear maps between S (as an `R`-module by
+ means of restriction of scalars) and M. `S` acts on Hom(S, M) by `s β€’ g = x ↦ g (x β€’ s)`
+ -/
+instance hasSmul : SMul S <| S' β†’β‚—[R] M
+    where smul s g :=
+    { toFun := fun s' : S => g (s' * s : S)
+      map_add' := fun x y : S => by simp [add_mul, map_add]
+      map_smul' := fun r (t : S) => by
+        rw [RingHom.id_apply, @RestrictScalars.smul_def _ _ _ _ f ⟨S⟩, ← LinearMap.map_smul,
+          @RestrictScalars.smul_def _ _ _ _ f ⟨S⟩, smul_eq_mul, smul_eq_mul, mul_assoc] }
+#align category_theory.Module.coextend_scalars.has_smul CategoryTheory.Module.CoextendScalars.hasSmul
+
+@[simp]
+theorem smul_apply' (s : S) (g : S' β†’β‚—[R] M) (s' : S) :
+    @SMul.smul _ _ (CoextendScalars.hasSmul f _) s g s' = g (s' * s : S) :=
+  rfl
+#align category_theory.Module.coextend_scalars.smul_apply' CategoryTheory.Module.CoextendScalars.smul_apply'
+
+instance mulAction : MulAction S <| S' β†’β‚—[R] M :=
+  {
+    CoextendScalars.hasSmul f
+      _ with
+    one_smul := fun g => LinearMap.ext fun s : S => by simp
+    mul_smul := fun (s t : S) g => LinearMap.ext fun x : S => by simp [mul_assoc] }
+#align category_theory.Module.coextend_scalars.mul_action CategoryTheory.Module.CoextendScalars.mulAction
+
+instance distribMulAction : DistribMulAction S <| S' β†’β‚—[R] M :=
+  {
+    CoextendScalars.mulAction f
+      _ with
+    smul_add := fun s g h => LinearMap.ext fun t : S => by simp
+    smul_zero := fun s => LinearMap.ext fun t : S => by simp }
+#align category_theory.Module.coextend_scalars.distrib_mul_action CategoryTheory.Module.CoextendScalars.distribMulAction
+
+/-- `S` acts on Hom(S, M) by `s β€’ g = x ↦ g (x β€’ s)`, this action defines an `S`-module structure on
+Hom(S, M).
+ -/
+instance isModule : Module S <| S' β†’β‚—[R] M :=
+  {
+    CoextendScalars.distribMulAction f
+      _ with
+    add_smul := fun s1 s2 g => LinearMap.ext fun x : S => by simp [mul_add]
+    zero_smul := fun g => LinearMap.ext fun x : S => by simp }
+#align category_theory.Module.coextend_scalars.is_module CategoryTheory.Module.CoextendScalars.isModule
+
+end Unbundled
+
+variable (M : ModuleCat.{v} R)
+
+/-- If `M` is an `R`-module, then the set of `R`-linear maps `S β†’β‚—[R] M` is an `S`-module with
+scalar multiplication defined by `s β€’ l := x ↦ l (x β€’ s)`-/
+def obj' : ModuleCat S :=
+  ⟨(restrictScalars f).obj ⟨S⟩ β†’β‚—[R] M⟩
+#align category_theory.Module.coextend_scalars.obj' CategoryTheory.Module.CoextendScalars.obj'
+
+instance : CoeFun (obj' f M) fun g => S β†’ M where coe g := g.toFun
+
+/-- If `M, M'` are `R`-modules, then any `R`-linear map `g : M ⟢ M'` induces an `S`-linear map
+`(S β†’β‚—[R] M) ⟢ (S β†’β‚—[R] M')` defined by `h ↦ g ∘ h`-/
+@[simps]
+def map' {M M' : ModuleCat R} (g : M ⟢ M') : obj' f M ⟢ obj' f M'
+    where
+  toFun h := g.comp h
+  map_add' _ _ := LinearMap.comp_add _ _ _
+  map_smul' s h := LinearMap.ext fun t : S => by simpa only [smul_apply']
+#align category_theory.Module.coextend_scalars.map' CategoryTheory.Module.CoextendScalars.map'
+
+end CoextendScalars
+
+/--
+For any rings `R, S` and a ring homomorphism `f : R β†’+* S`, there is a functor from `R`-module to
+`S`-module defined by `M ↦ (S β†’β‚—[R] M)` where `S` is considered as an `R`-module via restriction of
+scalars and `g : M ⟢ M'` is sent to `h ↦ g ∘ h`.
+-/
+def coextendScalars {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] (f : R β†’+* S) :
+    ModuleCat R β₯€ ModuleCat S where
+  obj := CoextendScalars.obj' f
+  map _ _ := CoextendScalars.map' f
+  map_id' M := LinearMap.ext fun h => LinearMap.ext fun x => rfl
+  map_comp' _ _ _ g h := LinearMap.ext fun h => LinearMap.ext fun x => rfl
+#align category_theory.Module.coextend_scalars CategoryTheory.Module.coextendScalars
+
+namespace CoextendScalars
+
+variable {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] (f : R β†’+* S)
+
+instance (M : ModuleCat R) : CoeFun ((coextendScalars f).obj M) fun g => S β†’ M :=
+  (inferInstance : CoeFun (CoextendScalars.obj' f M) _)
+
+theorem smul_apply (M : ModuleCat R) (g : (coextendScalars f).obj M) (s s' : S) :
+    (s β€’ g) s' = g (s' * s) :=
+  rfl
+#align category_theory.Module.coextend_scalars.smul_apply CategoryTheory.Module.coextendScalars.smul_apply
+
+@[simp]
+theorem map_apply {M M' : ModuleCat R} (g : M ⟢ M') (x) (s : S) :
+    (coextendScalars f).map g x s = g (x s) :=
+  rfl
+#align category_theory.Module.coextend_scalars.map_apply CategoryTheory.Module.coextendScalars.map_apply
+
+end CoextendScalars
+
+namespace RestrictionCoextensionAdj
+
+variable {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] (f : R β†’+* S)
+
+/-- Given `R`-module X and `S`-module Y, any `g : (restrict_of_scalars f).obj Y ⟢ X`
+corresponds to `Y ⟢ (coextend_scalars f).obj X` by sending `y ↦ (s ↦ g (s β€’ y))`
+-/
+@[simps]
+def HomEquiv.fromRestriction {X Y} (g : (restrictScalars f).obj Y ⟢ X) :
+    Y ⟢ (coextendScalars f).obj X
+    where
+  toFun := fun y : Y =>
+    { toFun := fun s : S => g <| (s β€’ y : Y)
+      map_add' := fun s1 s2 : S => by simp [add_smul]
+      map_smul' := fun r (s : S) => by
+        rw [RingHom.id_apply, ← g.map_smul, @RestrictScalars.smul_def _ _ _ _ f ⟨S⟩, smul_eq_mul,
+          mul_smul, @RestrictScalars.smul_def _ _ _ _ f Y] }
+  map_add' := fun y1 y2 : Y =>
+    LinearMap.ext fun s : S => by
+      rw [LinearMap.add_apply, LinearMap.coe_mk, LinearMap.coe_mk, LinearMap.coe_mk, smul_add,
+        map_add]
+  map_smul' s y := LinearMap.ext fun t : S => by simp [mul_smul]
+#align category_theory.Module.restriction_coextension_adj.hom_equiv.from_restriction CategoryTheory.Module.RestrictionCoextensionAdj.HomEquiv.fromRestriction
+
+/-- Given `R`-module X and `S`-module Y, any `g : Y ⟢ (coextend_scalars f).obj X`
+corresponds to `(restrict_scalars f).obj Y ⟢ X` by `y ↦ g y 1`
+-/
+@[simps]
+def HomEquiv.toRestriction {X Y} (g : Y ⟢ (coextendScalars f).obj X) : (restrictScalars f).obj Y ⟢ X
+    where
+  toFun := fun y : Y => (g y).toFun (1 : S)
+  map_add' x y := by simp only [g.map_add, LinearMap.toFun_eq_coe, LinearMap.add_apply]
+  map_smul' r (y : Y) := by
+    rw [LinearMap.toFun_eq_coe, LinearMap.toFun_eq_coe, RingHom.id_apply, ← LinearMap.map_smul,
+      RestrictScalars.smul_def f r y, @RestrictScalars.smul_def _ _ _ _ f ⟨S⟩, smul_eq_mul, mul_one,
+      LinearMap.map_smul, coextend_scalars.smul_apply, one_mul]
+#align category_theory.Module.restriction_coextension_adj.hom_equiv.to_restriction CategoryTheory.Module.RestrictionCoextensionAdj.HomEquiv.toRestriction
+
+/--
+The natural transformation from identity functor to the composition of restriction and coextension
+of scalars.
+-/
+@[simps]
+protected def unit' : 𝟭 (ModuleCat S) ⟢ restrictScalars f β‹™ coextendScalars f
+    where
+  app Y :=
+    { toFun := fun y : Y =>
+        { toFun := fun s : S => (s β€’ y : Y)
+          map_add' := fun s s' => add_smul _ _ _
+          map_smul' := fun r (s : S) => by
+            rw [RingHom.id_apply, @RestrictScalars.smul_def _ _ _ _ f ⟨S⟩, smul_eq_mul, mul_smul,
+              RestrictScalars.smul_def f] }
+      map_add' := fun y1 y2 =>
+        LinearMap.ext fun s : S => by
+          rw [LinearMap.add_apply, LinearMap.coe_mk, LinearMap.coe_mk, LinearMap.coe_mk, smul_add]
+      map_smul' := fun s (y : Y) => LinearMap.ext fun t : S => by simp [mul_smul] }
+  naturality' Y Y' g :=
+    LinearMap.ext fun y : Y => LinearMap.ext fun s : S => by simp [coextend_scalars.map_apply]
+#align category_theory.Module.restriction_coextension_adj.unit' CategoryTheory.Module.RestrictionCoextensionAdj.unit'
+
+/-- The natural transformation from the composition of coextension and restriction of scalars to
+identity functor.
+-/
+@[simps]
+protected def counit' : coextendScalars f β‹™ restrictScalars f ⟢ 𝟭 (ModuleCat R)
+    where
+  app X :=
+    { toFun := fun g => g.toFun (1 : S)
+      map_add' := fun x1 x2 => by simp [LinearMap.toFun_eq_coe]
+      map_smul' := fun r (g : (restrictScalars f).obj ((coextendScalars f).obj X)) =>
+        by
+        simp only [LinearMap.toFun_eq_coe, RingHom.id_apply]
+        rw [RestrictScalars.smul_def f, coextend_scalars.smul_apply, one_mul, ← LinearMap.map_smul,
+          @RestrictScalars.smul_def _ _ _ _ f ⟨S⟩, smul_eq_mul, mul_one] }
+  naturality' X X' g := LinearMap.ext fun h => by simp [coextend_scalars.map_apply]
+#align category_theory.Module.restriction_coextension_adj.counit' CategoryTheory.Module.RestrictionCoextensionAdj.counit'
+
+end RestrictionCoextensionAdj
+
+/-- Restriction of scalars is left adjoint to coextension of scalars. -/
+@[simps]
+def restrictCoextendScalarsAdj {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] (f : R β†’+* S) :
+    restrictScalars f ⊣ coextendScalars f
+    where
+  homEquiv X Y :=
+    { toFun := RestrictionCoextensionAdj.HomEquiv.fromRestriction f
+      invFun := RestrictionCoextensionAdj.HomEquiv.toRestriction f
+      left_inv := fun g => LinearMap.ext fun x : X => by simp
+      right_inv := fun g => LinearMap.ext fun x => LinearMap.ext fun s : S => by simp }
+  Unit := RestrictionCoextensionAdj.unit' f
+  counit := RestrictionCoextensionAdj.counit' f
+  homEquiv_unit X Y g := LinearMap.ext fun y => rfl
+  homEquiv_counit Y X g := LinearMap.ext fun y : Y => by simp
+#align category_theory.Module.restrict_coextend_scalars_adj CategoryTheory.Module.restrictCoextendScalarsAdj
+
+instance {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] (f : R β†’+* S) :
+    CategoryTheory.IsLeftAdjoint (restrictScalars f) :=
+  ⟨_, restrictCoextendScalarsAdj f⟩
+
+instance {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] (f : R β†’+* S) :
+    CategoryTheory.IsRightAdjoint (coextendScalars f) :=
+  ⟨_, restrictCoextendScalarsAdj f⟩
+
 namespace ExtendRestrictScalarsAdj
 
 open ChangeOfRings
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Jujian Zhang
 
 ! This file was ported from Lean 3 source module algebra.category.Module.change_of_rings
-! leanprover-community/mathlib commit 8f66240cab125b938b327d3850169d490cfbcdd8
+! leanprover-community/mathlib commit 403190b5419b3f03f1a2893ad9352ca7f7d8bff6
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -25,6 +25,11 @@ import Mathbin.RingTheory.TensorProduct
   module structure is defined by `s β€’ (s' βŠ— m) := (s * s') βŠ— m` and `R`-linear map `l : M ⟢ M'`
   is sent to `S`-linear map `s βŠ— m ↦ s βŠ— l m : S ⨂ M ⟢ S ⨂ M'`.
 
+## Main results
+
+* `category_theory.Module.extend_restrict_scalars_adj`: given commutative rings `R, S` and a ring
+  homomorphism `f : R β†’+* S`, the extension and restriction of scalars by `f` are adjoint functors.
+
 ## List of notations
 Let `R, S` be rings and `f : R β†’+* S`
 * if `M` is an `R`-module, `s : S` and `m : M`, then `s βŠ—β‚œ[R, f] m` is the pure tensor
@@ -71,6 +76,11 @@ def restrictScalars {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] (f : R β†’
   map_comp' _ _ _ g h := LinearMap.ext fun m => rfl
 #align category_theory.Module.restrict_scalars CategoryTheory.Module.restrictScalars
 
+instance {R : Type u₁} {S : Type uβ‚‚} [CommRing R] [CommRing S] (f : R β†’+* S) :
+    CategoryTheory.Faithful (restrictScalars.{v} f)
+    where map_injective' _ _ _ _ h :=
+    LinearMap.ext fun x => by simpa only using FunLike.congr_fun h x
+
 @[simp]
 theorem restrictScalars.map_apply {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] (f : R β†’+* S)
     {M M' : ModuleCat.{v} S} (g : M ⟢ M') (x) : (restrictScalars f).map g x = g x :=
@@ -184,5 +194,193 @@ theorem map_tmul {M M' : ModuleCat.{v} R} (g : M ⟢ M') (s : S) (m : M) :
 
 end ExtendScalars
 
+namespace ExtendRestrictScalarsAdj
+
+open ChangeOfRings
+
+open TensorProduct
+
+variable {R : Type u₁} {S : Type uβ‚‚} [CommRing R] [CommRing S] (f : R β†’+* S)
+
+/--
+Given `R`-module X and `S`-module Y and a map `g : (extend_scalars f).obj X ⟢ Y`, i.e. `S`-linear
+map `S ⨂ X β†’ Y`, there is a `X ⟢ (restrict_scalars f).obj Y`, i.e. `R`-linear map `X ⟢ Y` by
+`x ↦ g (1 βŠ— x)`.
+-/
+@[simps]
+def HomEquiv.toRestrictScalars {X Y} (g : (extendScalars f).obj X ⟢ Y) :
+    X ⟢ (restrictScalars f).obj Y
+    where
+  toFun x := g <| (1 : S)βŠ—β‚œ[R,f]x
+  map_add' _ _ := by rw [tmul_add, map_add]
+  map_smul' r x := by
+    letI : Module R S := Module.compHom S f
+    letI : Module R Y := Module.compHom Y f
+    rw [RingHom.id_apply, RestrictScalars.smul_def, ← LinearMap.map_smul, tmul_smul]
+    congr
+#align category_theory.Module.extend_restrict_scalars_adj.hom_equiv.to_restrict_scalars CategoryTheory.Module.ExtendRestrictScalarsAdj.HomEquiv.toRestrictScalars
+
+/--
+Given `R`-module X and `S`-module Y and a map `X ⟢ (restrict_scalars f).obj Y`, i.e `R`-linear map
+`X ⟢ Y`, there is a map `(extend_scalars f).obj X ⟢ Y`, i.e  `S`-linear map `S ⨂ X β†’ Y` by
+`s βŠ— x ↦ s β€’ g x`.
+-/
+@[simps]
+def HomEquiv.fromExtendScalars {X Y} (g : X ⟢ (restrictScalars f).obj Y) :
+    (extendScalars f).obj X ⟢ Y :=
+  by
+  letI m1 : Module R S := Module.compHom S f; letI m2 : Module R Y := Module.compHom Y f
+  refine' ⟨fun z => TensorProduct.lift ⟨fun s => ⟨_, _, _⟩, _, _⟩ z, _, _⟩
+  Β· exact fun x => s β€’ g x
+  Β· intros
+    rw [map_add, smul_add]
+  Β· intros
+    rw [RingHom.id_apply, smul_comm, ← LinearMap.map_smul]
+  Β· intros
+    ext
+    simp only [LinearMap.coe_mk, LinearMap.add_apply]
+    rw [← add_smul]
+  Β· intros
+    ext
+    simp only [LinearMap.coe_mk, RingHom.id_apply, LinearMap.smul_apply, RestrictScalars.smul_def,
+      smul_eq_mul]
+    convert mul_smul _ _ _
+  Β· intros
+    rw [map_add]
+  Β· intro r z
+    rw [RingHom.id_apply]
+    induction' z using TensorProduct.induction_on with x y x y ih1 ih2
+    Β· simp only [smul_zero, map_zero]
+    Β· simp only [LinearMap.coe_mk, extend_scalars.smul_tmul, lift.tmul, ← mul_smul]
+    Β· rw [smul_add, map_add, ih1, ih2, map_add, smul_add]
+#align category_theory.Module.extend_restrict_scalars_adj.hom_equiv.from_extend_scalars CategoryTheory.Module.ExtendRestrictScalarsAdj.HomEquiv.fromExtendScalars
+
+/-- Given `R`-module X and `S`-module Y, `S`-linear linear maps `(extend_scalars f).obj X ⟢ Y`
+bijectively correspond to `R`-linear maps `X ⟢ (restrict_scalars f).obj Y`.
+-/
+@[simps]
+def homEquiv {X Y} : ((extendScalars f).obj X ⟢ Y) ≃ (X ⟢ (restrictScalars f).obj Y)
+    where
+  toFun := HomEquiv.toRestrictScalars f
+  invFun := HomEquiv.fromExtendScalars f
+  left_inv g := by
+    ext z
+    induction' z using TensorProduct.induction_on with x s z1 z2 ih1 ih2
+    Β· simp only [map_zero]
+    Β· erw [TensorProduct.lift.tmul]
+      simp only [LinearMap.coe_mk]
+      change S at x
+      erw [← LinearMap.map_smul, extend_scalars.smul_tmul, mul_one x]
+    Β· rw [map_add, map_add, ih1, ih2]
+  right_inv g := by
+    ext
+    rw [hom_equiv.to_restrict_scalars_apply, hom_equiv.from_extend_scalars_apply, lift.tmul,
+      LinearMap.coe_mk, LinearMap.coe_mk]
+    convert one_smul _ _
+#align category_theory.Module.extend_restrict_scalars_adj.hom_equiv CategoryTheory.Module.ExtendRestrictScalarsAdj.homEquiv
+
+/--
+For any `R`-module X, there is a natural `R`-linear map from `X` to `X ⨂ S` by sending `x ↦ x βŠ— 1`
+-/
+@[simps]
+def Unit.map {X} : X ⟢ (extendScalars f β‹™ restrictScalars f).obj X
+    where
+  toFun x := (1 : S)βŠ—β‚œ[R,f]x
+  map_add' x x' := by rw [TensorProduct.tmul_add]
+  map_smul' r x := by
+    letI m1 : Module R S := Module.compHom S f
+    tidy
+#align category_theory.Module.extend_restrict_scalars_adj.unit.map CategoryTheory.Module.ExtendRestrictScalarsAdj.Unit.map
+
+/--
+The natural transformation from identity functor on `R`-module to the composition of extension and
+restriction of scalars.
+-/
+@[simps]
+def unit : 𝟭 (ModuleCat R) ⟢ extendScalars f β‹™ restrictScalars f
+    where
+  app _ := Unit.map f
+  naturality' X X' g := by tidy
+#align category_theory.Module.extend_restrict_scalars_adj.unit CategoryTheory.Module.ExtendRestrictScalarsAdj.unit
+
+/-- For any `S`-module Y, there is a natural `R`-linear map from `S ⨂ Y` to `Y` by
+`s βŠ— y ↦ s β€’ y`
+-/
+@[simps]
+def Counit.map {Y} : (restrictScalars f β‹™ extendScalars f).obj Y ⟢ Y :=
+  by
+  letI m1 : Module R S := Module.compHom S f
+  letI m2 : Module R Y := Module.compHom Y f
+  refine' ⟨TensorProduct.lift ⟨fun s : S => ⟨fun y : Y => s β€’ y, smul_add _, _⟩, _, _⟩, _, _⟩
+  Β· intros
+    rw [RingHom.id_apply, RestrictScalars.smul_def, ← mul_smul, mul_comm, mul_smul,
+      RestrictScalars.smul_def]
+  Β· intros
+    ext
+    simp only [LinearMap.add_apply, LinearMap.coe_mk, add_smul]
+  Β· intros
+    ext
+    simpa only [RingHom.id_apply, LinearMap.smul_apply, LinearMap.coe_mk,
+      @RestrictScalars.smul_def _ _ _ _ f ⟨S⟩, smul_eq_mul, mul_smul]
+  Β· intros
+    rw [map_add]
+  Β· intro s z
+    rw [RingHom.id_apply]
+    induction' z using TensorProduct.induction_on with x s' z1 z2 ih1 ih2
+    Β· simp only [smul_zero, map_zero]
+    Β· simp only [extend_scalars.smul_tmul, LinearMap.coe_mk, TensorProduct.lift.tmul, mul_smul]
+    Β· rw [smul_add, map_add, map_add, ih1, ih2, smul_add]
+#align category_theory.Module.extend_restrict_scalars_adj.counit.map CategoryTheory.Module.ExtendRestrictScalarsAdj.Counit.map
+
+/-- The natural transformation from the composition of restriction and extension of scalars to the
+identity functor on `S`-module.
+-/
+@[simps]
+def counit : restrictScalars f β‹™ extendScalars f ⟢ 𝟭 (ModuleCat S)
+    where
+  app _ := Counit.map f
+  naturality' Y Y' g := by
+    ext z; induction z using TensorProduct.induction_on
+    Β· simp only [map_zero]
+    Β·
+      simp only [CategoryTheory.Functor.comp_map, ModuleCat.coe_comp, Function.comp_apply,
+        extend_scalars.map_tmul, restrict_scalars.map_apply, counit.map_apply, lift.tmul,
+        LinearMap.coe_mk, CategoryTheory.Functor.id_map, LinearMap.map_smulβ‚›β‚—, RingHom.id_apply]
+    Β· simp only [map_add, *]
+#align category_theory.Module.extend_restrict_scalars_adj.counit CategoryTheory.Module.ExtendRestrictScalarsAdj.counit
+
+end ExtendRestrictScalarsAdj
+
+/-- Given commutative rings `R, S` and a ring hom `f : R β†’+* S`, the extension and restriction of
+scalars by `f` are adjoint to each other.
+-/
+@[simps]
+def extendRestrictScalarsAdj {R : Type u₁} {S : Type uβ‚‚} [CommRing R] [CommRing S] (f : R β†’+* S) :
+    extendScalars f ⊣ restrictScalars f
+    where
+  homEquiv _ _ := ExtendRestrictScalarsAdj.homEquiv f
+  Unit := ExtendRestrictScalarsAdj.unit f
+  counit := ExtendRestrictScalarsAdj.counit f
+  homEquiv_unit X Y g := LinearMap.ext fun x => by simp
+  homEquiv_counit X Y g :=
+    LinearMap.ext fun x => by
+      induction x using TensorProduct.induction_on
+      Β· simp only [map_zero]
+      Β·
+        simp only [extend_restrict_scalars_adj.hom_equiv_symm_apply, LinearMap.coe_mk,
+          extend_restrict_scalars_adj.hom_equiv.from_extend_scalars_apply, TensorProduct.lift.tmul,
+          extend_restrict_scalars_adj.counit_app, ModuleCat.coe_comp, Function.comp_apply,
+          extend_scalars.map_tmul, extend_restrict_scalars_adj.counit.map_apply]
+      Β· simp only [map_add, *]
+#align category_theory.Module.extend_restrict_scalars_adj CategoryTheory.Module.extendRestrictScalarsAdj
+
+instance {R : Type u₁} {S : Type uβ‚‚} [CommRing R] [CommRing S] (f : R β†’+* S) :
+    CategoryTheory.IsLeftAdjoint (extendScalars f) :=
+  ⟨_, extendRestrictScalarsAdj f⟩
+
+instance {R : Type u₁} {S : Type uβ‚‚} [CommRing R] [CommRing S] (f : R β†’+* S) :
+    CategoryTheory.IsRightAdjoint (restrictScalars f) :=
+  ⟨_, extendRestrictScalarsAdj f⟩
+
 end CategoryTheory.Module
 

Changes in mathlib4

mathlib3
mathlib4
feat(Algebra/Category/ModuleCat): the category of presheaves of modules has limits (#12264)

Co-authored-by: JoΓ«l Riou <37772949+joelriou@users.noreply.github.com> Co-authored-by: Christian Merten <christian@merten.dev>

Diff
@@ -4,6 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Jujian Zhang
 -/
 import Mathlib.Algebra.Category.ModuleCat.EpiMono
+import Mathlib.Algebra.Category.ModuleCat.Limits
 import Mathlib.RingTheory.TensorProduct.Basic
 
 #align_import algebra.category.Module.change_of_rings from "leanprover-community/mathlib"@"56b71f0b55c03f70332b862e65c3aa1aa1249ca1"
@@ -44,7 +45,7 @@ suppress_compilation
 
 set_option linter.uppercaseLean3 false -- Porting note: Module
 
-open CategoryTheory
+open CategoryTheory Limits
 
 namespace ModuleCat
 
@@ -174,6 +175,18 @@ identity functor. -/
 def restrictScalarsId' : ModuleCat.restrictScalars.{v} f β‰… 𝟭 _ :=
     NatIso.ofComponents <| fun M ↦ restrictScalarsId'App f hf M
 
+@[reassoc]
+lemma restrictScalarsId'App_hom_naturality {M N : ModuleCat R} (Ο† : M ⟢ N) :
+    (restrictScalars f).map Ο† ≫ (restrictScalarsId'App f hf N).hom =
+      (restrictScalarsId'App f hf M).hom ≫ Ο† :=
+  (restrictScalarsId' f hf).hom.naturality Ο†
+
+@[reassoc]
+lemma restrictScalarsId'App_inv_naturality {M N : ModuleCat R} (Ο† : M ⟢ N) :
+    Ο† ≫ (restrictScalarsId'App f hf N).inv =
+      (restrictScalarsId'App f hf M).inv ≫ (restrictScalars f).map Ο† :=
+  (restrictScalarsId' f hf).inv.naturality Ο†
+
 variable (R)
 
 /-- The restriction of scalars by the identity morphisms identify to the
@@ -209,6 +222,20 @@ def restrictScalarsComp' :
       ModuleCat.restrictScalars g β‹™ ModuleCat.restrictScalars f :=
   NatIso.ofComponents <| fun M ↦ restrictScalarsComp'App f g gf hgf M
 
+@[reassoc]
+lemma restrictScalarsComp'App_hom_naturality {M N : ModuleCat R₃} (Ο† : M ⟢ N) :
+    (restrictScalars gf).map Ο† ≫ (restrictScalarsComp'App f g gf hgf N).hom =
+      (restrictScalarsComp'App f g gf hgf M).hom ≫
+        (restrictScalars f).map ((restrictScalars g).map Ο†) :=
+  (restrictScalarsComp' f g gf hgf).hom.naturality Ο†
+
+@[reassoc]
+lemma restrictScalarsComp'App_inv_naturality {M N : ModuleCat R₃} (Ο† : M ⟢ N) :
+    (restrictScalars f).map ((restrictScalars g).map Ο†) ≫
+        (restrictScalarsComp'App f g gf hgf N).inv =
+      (restrictScalarsComp'App f g gf hgf M).inv ≫ (restrictScalars gf).map Ο† :=
+  (restrictScalarsComp' f g gf hgf).inv.naturality Ο†
+
 /-- The restriction of scalars by a composition of ring morphisms identify to the
 composition of the restriction of scalars functors. -/
 abbrev restrictScalarsComp := restrictScalarsComp'.{v} f g _ rfl
@@ -831,4 +858,13 @@ instance {R : Type u₁} {S : Type uβ‚‚} [CommRing R] [CommRing S] (f : R β†’+*
     CategoryTheory.IsRightAdjoint (restrictScalars f) :=
   ⟨_, extendRestrictScalarsAdj f⟩
 
+noncomputable instance preservesLimitRestrictScalars
+    {R : Type*} {S : Type*} [Ring R] [Ring S] (f : R β†’+* S) {J : Type*} [Category J]
+    (F : J β₯€ ModuleCat.{v} S) [Small.{v} (F β‹™ forget _).sections] :
+    PreservesLimit F (restrictScalars f) :=
+  ⟨fun {c} hc => by
+    have : Small.{v} ((F β‹™ restrictScalars f) β‹™ forget _).sections := by assumption
+    have hc' := isLimitOfPreserves (forgetβ‚‚ _ AddCommGroupCat) hc
+    exact isLimitOfReflects (forgetβ‚‚ _ AddCommGroupCat) hc'⟩
+
 end ModuleCat
chore: superfluous parentheses part 2 (#12131)

Co-authored-by: Moritz Firsching <firsching@google.com>

Diff
@@ -224,7 +224,7 @@ instance restrictScalarsIsEquivalenceOfRingEquiv {R S} [Ring R] [Ring S] (e : R
   counitIso := NatIso.ofComponents (fun M ↦ LinearEquiv.toModuleIso'
     { __ := AddEquiv.refl M
       map_smul' := fun r m ↦ congr_arg (Β· β€’ (_ : M)) (e.left_inv r)}) (by intros; rfl)
-  functor_unitIso_comp := (by intros; rfl)
+  functor_unitIso_comp := by intros; rfl
 
 open TensorProduct
 
chore(CategoryTheory): move Full, Faithful, EssSurj, IsEquivalence and ReflectsIsomorphisms to the Functor namespace (#11985)

These notions on functors are now Functor.Full, Functor.Faithful, Functor.EssSurj, Functor.IsEquivalence, Functor.ReflectsIsomorphisms. Deprecated aliases are introduced for the previous names.

Diff
@@ -84,7 +84,7 @@ def restrictScalars {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] (f : R β†’
 #align category_theory.Module.restrict_scalars ModuleCat.restrictScalars
 
 instance {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] (f : R β†’+* S) :
-    CategoryTheory.Faithful (restrictScalars.{v} f) where
+    (restrictScalars.{v} f).Faithful where
   map_injective h :=
     LinearMap.ext fun x => by simpa only using DFunLike.congr_fun h x
 
@@ -216,7 +216,7 @@ abbrev restrictScalarsComp := restrictScalarsComp'.{v} f g _ rfl
 end
 
 instance restrictScalarsIsEquivalenceOfRingEquiv {R S} [Ring R] [Ring S] (e : R ≃+* S) :
-    IsEquivalence (ModuleCat.restrictScalars e.toRingHom) where
+    (ModuleCat.restrictScalars e.toRingHom).IsEquivalence where
   inverse := ModuleCat.restrictScalars e.symm
   unitIso := NatIso.ofComponents (fun M ↦ LinearEquiv.toModuleIso'
     { __ := AddEquiv.refl M
perf(Algebra.Category.ModuleCat.ChangeOfRings): some speedups (#11545)

Squeezing dsimps/aesop_cats etc.

Diff
@@ -218,12 +218,13 @@ end
 instance restrictScalarsIsEquivalenceOfRingEquiv {R S} [Ring R] [Ring S] (e : R ≃+* S) :
     IsEquivalence (ModuleCat.restrictScalars e.toRingHom) where
   inverse := ModuleCat.restrictScalars e.symm
-  unitIso := NatIso.ofComponents fun M ↦ LinearEquiv.toModuleIso'
+  unitIso := NatIso.ofComponents (fun M ↦ LinearEquiv.toModuleIso'
     { __ := AddEquiv.refl M
-      map_smul' := fun s m ↦ congr_arg (Β· β€’ m) (e.right_inv s).symm }
-  counitIso := NatIso.ofComponents fun M ↦ LinearEquiv.toModuleIso'
+      map_smul' := fun s m ↦ congr_arg (Β· β€’ m) (e.right_inv s).symm }) (by intros; rfl)
+  counitIso := NatIso.ofComponents (fun M ↦ LinearEquiv.toModuleIso'
     { __ := AddEquiv.refl M
-      map_smul' := fun r m ↦ congr_arg (Β· β€’ (_ : M)) (e.left_inv r) }
+      map_smul' := fun r m ↦ congr_arg (Β· β€’ (_ : M)) (e.left_inv r)}) (by intros; rfl)
+  functor_unitIso_comp := (by intros; rfl)
 
 open TensorProduct
 
@@ -448,9 +449,12 @@ def HomEquiv.fromRestriction {X : ModuleCat R} {Y : ModuleCat S}
   map_add' := fun y1 y2 : Y =>
     LinearMap.ext fun s : S => by
       -- Porting note: double dsimp seems odd
-      dsimp
+      dsimp only [id_eq, eq_mpr_eq_cast, AddHom.toFun_eq_coe, AddHom.coe_mk, RingHom.id_apply,
+        RingHom.toMonoidHom_eq_coe, OneHom.toFun_eq_coe,
+        MonoidHom.toOneHom_coe, MonoidHom.coe_coe, ZeroHom.coe_mk, smul_eq_mul, cast_eq,
+        LinearMap.coe_mk]
       rw [LinearMap.add_apply, LinearMap.coe_mk, LinearMap.coe_mk]
-      dsimp
+      dsimp only [AddHom.coe_mk]
       rw [smul_add, map_add]
   map_smul' := fun (s : S) (y : Y) => LinearMap.ext fun t : S => by
       -- Porting note: used to be simp [mul_smul]
@@ -485,14 +489,17 @@ def app' (Y : ModuleCat S) : Y β†’β‚—[S] (restrictScalars f β‹™ coextendScalars
       { toFun := fun s : S => (s β€’ y : Y)
         map_add' := fun s s' => add_smul _ _ _
         map_smul' := fun r (s : S) => by
-          dsimp
+          dsimp only [AddHom.toFun_eq_coe, AddHom.coe_mk, RingHom.id_apply]
           erw [smul_eq_mul, mul_smul]
           simp }
     map_add' := fun y1 y2 =>
       LinearMap.ext fun s : S => by
         -- Porting note: double dsimp seems odd
         set_option tactic.skipAssignedInstances false in
-        dsimp
+        dsimp only [AddHom.toFun_eq_coe, AddHom.coe_mk, RingHom.id_apply,
+          RingHom.toMonoidHom_eq_coe, OneHom.toFun_eq_coe, MonoidHom.toOneHom_coe,
+          MonoidHom.coe_coe, ZeroHom.coe_mk, smul_eq_mul, id_eq, eq_mpr_eq_cast, cast_eq,
+          Functor.comp_obj]
         rw [LinearMap.add_apply, LinearMap.coe_mk, LinearMap.coe_mk, LinearMap.coe_mk]
         dsimp
         rw [smul_add]
@@ -621,7 +628,10 @@ def HomEquiv.evalAt {X : ModuleCat R} {Y : ModuleCat S} (s : S)
     X β†’β‚—[R] Y :=
   @LinearMap.mk _ _ _ _ (RingHom.id R) X Y _ _ _ (_)
     { toFun := fun x => s β€’ (g x : Y)
-      map_add' := by intros; dsimp; rw [map_add,smul_add] }
+      map_add' := by
+        intros
+        dsimp only
+        rw [map_add,smul_add] }
     (by
       intros r x
       rw [AddHom.toFun_eq_coe, AddHom.coe_mk, RingHom.id_apply,
@@ -641,7 +651,7 @@ def HomEquiv.fromExtendScalars {X Y} (g : X ⟢ (restrictScalars f).obj Y) :
     {toFun := fun s => HomEquiv.evalAt f s g, map_add' := fun (s₁ sβ‚‚ : S) => ?_,
       map_smul' := fun (r : R) (s : S) => ?_}
     Β· ext
-      dsimp
+      dsimp only [evalAt_apply, LinearMap.add_apply]
       rw [← add_smul]
     Β· ext x
       apply mul_smul (f r) s (g x)
chore: remove mathport name: <expression> lines (#11928)

Quoting [@digama0](https://github.com/digama0):

These were actually never meant to go in the file, they are basically debugging information and only useful on significantly broken mathport files. You can safely remove all of them.

Diff
@@ -233,7 +233,6 @@ section ModuleCat.Unbundled
 
 variable (M : Type v) [AddCommMonoid M] [Module R M]
 
--- mathport name: Β«expr βŠ—β‚œ[ , ] Β»
 -- This notation is necessary because we need to reason about `s βŠ—β‚œ m` where `s : S` and `m : M`;
 -- without this notation, one need to work with `s : (restrictScalars f).obj ⟨S⟩`.
 scoped[ChangeOfRings]
@@ -324,7 +323,6 @@ section Unbundled
 
 variable (M : Type v) [AddCommMonoid M] [Module R M]
 
--- mathport name: exprS'
 -- We use `S'` to denote `S` viewed as `R`-module, via the map `f`.
 -- Porting note: this seems to cause problems related to lack of reducibility
 -- local notation "S'" => (restrictScalars f).obj ⟨S⟩
chore(Algebra/Category/MonCat): improve definitional properties in restrict scalars (#11597)

Replaces two usages of subst by an explicit construction in ChangeOfRings.

Diff
@@ -153,19 +153,26 @@ section
 
 variable {R : Type u₁} [Ring R] (f : R β†’+* R) (hf : f = RingHom.id R)
 
-/-- The restriction of scalars by a ring morphism that is the identity identify to the
-identity functor. -/
-def restrictScalarsId' : ModuleCat.restrictScalars.{v} f β‰… 𝟭 _ := by subst hf; rfl
+/-- For a `R`-module `M`, the restriction of scalars of `M` by the identity morphisms identifies
+to `M`. -/
+def restrictScalarsId'App (M : ModuleCat R) : (restrictScalars f).obj M β‰… M :=
+  LinearEquiv.toModuleIso' <|
+    @AddEquiv.toLinearEquiv _ _ _ _ _ _ (((restrictScalars f).obj M).isModule) _
+      (by rfl) (fun r x ↦ by subst hf; rfl)
+
+lemma restrictScalarsId'App_hom_apply (M : ModuleCat R) (x : M) :
+    (restrictScalarsId'App f hf M).hom x = x :=
+  rfl
 
--- This lemma has always been bad, but lean4#2644 made `simp` start noticing
-@[simp, nolint simpNF]
-lemma restrictScalarsId'_inv_apply (M : ModuleCat R) (x : M) :
-    (restrictScalarsId' f hf).inv.app M x = x := by subst hf; rfl
+lemma restrictScalarsId'App_inv_apply (M : ModuleCat R) (x : M) :
+    (restrictScalarsId'App f hf M).inv x = x :=
+  rfl
 
--- This lemma has always been bad, but lean4#2644 made `simp` start noticing
-@[simp, nolint simpNF]
-lemma restrictScalarsId'_hom_apply (M : ModuleCat R) (x : M) :
-    (restrictScalarsId' f hf).hom.app M x = x := by subst hf; rfl
+/-- The restriction of scalars by a ring morphism that is the identity identify to the
+identity functor. -/
+@[simps! hom_app inv_app]
+def restrictScalarsId' : ModuleCat.restrictScalars.{v} f β‰… 𝟭 _ :=
+    NatIso.ofComponents <| fun M ↦ restrictScalarsId'App f hf M
 
 variable (R)
 
@@ -180,21 +187,27 @@ section
 variable {R₁ : Type u₁} {Rβ‚‚ : Type uβ‚‚} {R₃ : Type u₃} [Ring R₁] [Ring Rβ‚‚] [Ring R₃]
   (f : R₁ β†’+* Rβ‚‚) (g : Rβ‚‚ β†’+* R₃) (gf : R₁ β†’+* R₃) (hgf : gf = g.comp f)
 
+/-- For each `R₃`-module `M`, restriction of scalars of `M` by a composition of ring morphisms
+identifies to successively restricting scalars. -/
+def restrictScalarsComp'App (M : ModuleCat R₃) :
+    (restrictScalars gf).obj M β‰… (restrictScalars f).obj ((restrictScalars g).obj M) :=
+  (AddEquiv.toLinearEquiv (by rfl) (fun r x ↦ by subst hgf; rfl)).toModuleIso'
+
+lemma restrictScalarsComp'App_hom_apply (M : ModuleCat R₃) (x : M) :
+    (restrictScalarsComp'App f g gf hgf M).hom x = x :=
+  rfl
+
+lemma restrictScalarsComp'App_inv_apply (M : ModuleCat R₃) (x : M) :
+    (restrictScalarsComp'App f g gf hgf M).inv x = x :=
+  rfl
+
 /-- The restriction of scalars by a composition of ring morphisms identify to the
 composition of the restriction of scalars functors. -/
+@[simps! hom_app inv_app]
 def restrictScalarsComp' :
     ModuleCat.restrictScalars.{v} gf β‰…
-      ModuleCat.restrictScalars g β‹™ ModuleCat.restrictScalars f := by subst hgf; rfl
-
--- This lemma has always been bad, but lean4#2644 made `simp` start noticing
-@[simp, nolint simpNF]
-lemma restrictScalarsComp'_hom_apply (M : ModuleCat R₃) (x : M) :
-    (restrictScalarsComp' f g gf hgf).hom.app M x = x := by subst hgf; rfl
-
--- This lemma has always been bad, but lean4#2644 made `simp` start noticing
-@[simp, nolint simpNF]
-lemma restrictScalarsComp'_inv_apply (M : ModuleCat R₃) (x : M) :
-    (restrictScalarsComp' f g gf hgf).inv.app M x = x := by subst hgf; rfl
+      ModuleCat.restrictScalars g β‹™ ModuleCat.restrictScalars f :=
+  NatIso.ofComponents <| fun M ↦ restrictScalarsComp'App f g gf hgf M
 
 /-- The restriction of scalars by a composition of ring morphisms identify to the
 composition of the restriction of scalars functors. -/
chore(*): remove empty lines between variable statements (#11418)

Empty lines were removed by executing the following Python script twice

import os
import re


# Loop through each file in the repository
for dir_path, dirs, files in os.walk('.'):
  for filename in files:
    if filename.endswith('.lean'):
      file_path = os.path.join(dir_path, filename)

      # Open the file and read its contents
      with open(file_path, 'r') as file:
        content = file.read()

      # Use a regular expression to replace sequences of "variable" lines separated by empty lines
      # with sequences without empty lines
      modified_content = re.sub(r'(variable.*\n)\n(variable(?! .* in))', r'\1\2', content)

      # Write the modified content back to the file
      with open(file_path, 'w') as file:
        file.write(modified_content)
Diff
@@ -53,7 +53,6 @@ universe v u₁ uβ‚‚ u₃
 namespace RestrictScalars
 
 variable {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] (f : R β†’+* S)
-
 variable (M : ModuleCat.{v} S)
 
 /-- Any `S`-module M is also an `R`-module via a ring homomorphism `f : R ⟢ S` by defining
Acl/reorg tensor product (#11282)

Move:

  • Mathlib/Algebra/Module/DirectLimitAndTensorProduct.lean to LinearAlgebra/TensorProduct/DirectLimit.lean
  • Mathlib/LinearAlgebra/TensorProduct to Mathlib/LinearAlgebra.TensorProduct.Basic.lean
  • Mathlib/RingTheory/TensorProduct to Mathlib/RingTheory/TensorProduct/Basic.lean.

This follows suggestions 1, 2, 3 of

https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/Tensor.20Products.20of.20modules.20and.20rings/near/424605543

Co-authored-by: Antoine Chambert-Loir <antoine.chambert-loir@math.univ-paris-diderot.fr>

Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Jujian Zhang
 -/
 import Mathlib.Algebra.Category.ModuleCat.EpiMono
-import Mathlib.RingTheory.TensorProduct
+import Mathlib.RingTheory.TensorProduct.Basic
 
 #align_import algebra.category.Module.change_of_rings from "leanprover-community/mathlib"@"56b71f0b55c03f70332b862e65c3aa1aa1249ca1"
 
chore: move Mathlib to v4.7.0-rc1 (#11162)

This is a very large PR, but it has been reviewed piecemeal already in PRs to the bump/v4.7.0 branch as we update to intermediate nightlies.

Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Kyle Miller <kmill31415@gmail.com> Co-authored-by: damiano <adomani@gmail.com>

Diff
@@ -481,6 +481,7 @@ def app' (Y : ModuleCat S) : Y β†’β‚—[S] (restrictScalars f β‹™ coextendScalars
     map_add' := fun y1 y2 =>
       LinearMap.ext fun s : S => by
         -- Porting note: double dsimp seems odd
+        set_option tactic.skipAssignedInstances false in
         dsimp
         rw [LinearMap.add_apply, LinearMap.coe_mk, LinearMap.coe_mk, LinearMap.coe_mk]
         dsimp
@@ -795,7 +796,7 @@ def extendRestrictScalarsAdj {R : Type u₁} {S : Type uβ‚‚} [CommRing R] [CommR
         rw [Function.comp_apply, ExtendRestrictScalarsAdj.counit_app]
         -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
         erw [ExtendRestrictScalarsAdj.Counit.map_apply]
-        dsimp
+        set_option tactic.skipAssignedInstances false in dsimp
         rw [TensorProduct.lift.tmul]
         rfl
       Β· rw [map_add,map_add]
chore: classify previously simp porting notes (#10789)

Classifies by adding issue number (#10745) to porting note claiming anything semantically equivalent to was simp.

Related merged PR: #10746.

Diff
@@ -500,7 +500,7 @@ protected def unit' : 𝟭 (ModuleCat S) ⟢ restrictScalars f β‹™ coextendScala
   app Y := app' f Y
   naturality Y Y' g :=
     LinearMap.ext fun y : Y => LinearMap.ext fun s : S => by
-      -- Porting note: previously simp [CoextendScalars.map_apply]
+      -- Porting note (#10745): previously simp [CoextendScalars.map_apply]
       simp only [ModuleCat.coe_comp, Functor.id_map, Functor.id_obj, Functor.comp_obj,
         Functor.comp_map]
       rw [coe_comp, coe_comp, Function.comp, Function.comp]
@@ -545,12 +545,12 @@ def restrictCoextendScalarsAdj {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S]
     { toFun := RestrictionCoextensionAdj.HomEquiv.fromRestriction.{u₁,uβ‚‚,v} f
       invFun := RestrictionCoextensionAdj.HomEquiv.toRestriction.{u₁,uβ‚‚,v} f
       left_inv := fun g => LinearMap.ext fun x : X => by
-        -- Porting note: once just simp
+        -- Porting note (#10745): once just simp
         rw [RestrictionCoextensionAdj.HomEquiv.toRestriction_apply, AddHom.toFun_eq_coe,
           LinearMap.coe_toAddHom, RestrictionCoextensionAdj.HomEquiv.fromRestriction_apply_apply,
           one_smul]
       right_inv := fun g => LinearMap.ext fun x => LinearMap.ext fun s : S => by
-        -- Porting note: once just simp
+        -- Porting note (#10745): once just simp
         rw [RestrictionCoextensionAdj.HomEquiv.fromRestriction_apply_apply,
           RestrictionCoextensionAdj.HomEquiv.toRestriction_apply, AddHom.toFun_eq_coe,
           LinearMap.coe_toAddHom, LinearMap.map_smulβ‚›β‚—, RingHom.id_apply,
@@ -559,7 +559,7 @@ def restrictCoextendScalarsAdj {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S]
   counit := RestrictionCoextensionAdj.counit'.{u₁,uβ‚‚,v} f
   homEquiv_unit := LinearMap.ext fun y => rfl
   homEquiv_counit := fun {X Y g} => LinearMap.ext <| by
-    -- Porting note: previously simp [RestrictionCoextensionAdj.counit']
+    -- Porting note (#10745): previously simp [RestrictionCoextensionAdj.counit']
     intro x; dsimp
     rw [coe_comp, Function.comp]
     change _ = (((restrictScalars f).map g) x).toFun (1 : S)
chore: remove detrital heartbeat bumps (#10191)

With multiple changes, it is a good time to check if existing set_option maxHeartbeats and set_option synthInstance.maxHeartbeats remain necessary. This brings the number of files with such down from 23 to 9. Most are straight deletions though I did change one proof.

Diff
@@ -420,8 +420,6 @@ namespace RestrictionCoextensionAdj
 
 variable {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] (f : R β†’+* S)
 
--- Porting note: too much time
-set_option maxHeartbeats 500000 in
 /-- Given `R`-module X and `S`-module Y, any `g : (restrictScalars f).obj Y ⟢ X`
 corresponds to `Y ⟢ (coextendScalars f).obj X` by sending `y ↦ (s ↦ g (s β€’ y))`
 -/
@@ -446,8 +444,8 @@ def HomEquiv.fromRestriction {X : ModuleCat R} {Y : ModuleCat S}
       rw [smul_add, map_add]
   map_smul' := fun (s : S) (y : Y) => LinearMap.ext fun t : S => by
       -- Porting note: used to be simp [mul_smul]
-      rw [RingHom.id_apply, LinearMap.coe_mk, ModuleCat.CoextendScalars.smul_apply',
-        LinearMap.coe_mk]
+      simp only [LinearMap.coe_mk, AddHom.coe_mk, RingHom.id_apply]
+      rw [ModuleCat.CoextendScalars.smul_apply', LinearMap.coe_mk]
       dsimp
       rw [mul_smul]
 #align category_theory.Module.restriction_coextension_adj.hom_equiv.from_restriction ModuleCat.RestrictionCoextensionAdj.HomEquiv.fromRestriction
chore(*): rename FunLike to DFunLike (#9785)

This prepares for the introduction of a non-dependent synonym of FunLike, which helps a lot with keeping #8386 readable.

This is entirely search-and-replace in 680197f combined with manual fixes in 4145626, e900597 and b8428f8. The commands that generated this change:

sed -i 's/\bFunLike\b/DFunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean
sed -i 's/\btoFunLike\b/toDFunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean
sed -i 's/import Mathlib.Data.DFunLike/import Mathlib.Data.FunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean
sed -i 's/\bHom_FunLike\b/Hom_DFunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean     
sed -i 's/\binstFunLike\b/instDFunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean
sed -i 's/\bfunLike\b/instDFunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean
sed -i 's/\btoo many metavariables to apply `fun_like.has_coe_to_fun`/too many metavariables to apply `DFunLike.hasCoeToFun`/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean

Co-authored-by: Anne Baanen <Vierkantor@users.noreply.github.com>

Diff
@@ -87,7 +87,7 @@ def restrictScalars {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] (f : R β†’
 instance {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] (f : R β†’+* S) :
     CategoryTheory.Faithful (restrictScalars.{v} f) where
   map_injective h :=
-    LinearMap.ext fun x => by simpa only using FunLike.congr_fun h x
+    LinearMap.ext fun x => by simpa only using DFunLike.congr_fun h x
 
 instance {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] (f : R β†’+* S) :
     (restrictScalars.{v} f).PreservesMonomorphisms where
chore(*): drop $/<| before fun (#9361)

Subset of #9319

Diff
@@ -129,7 +129,7 @@ instance (priority := 100) sMulCommClass_mk {R : Type u₁} {S : Type uβ‚‚} [Rin
     haveI : SMul R M := (RestrictScalars.obj' f (ModuleCat.mk M)).isModule.toSMul
     SMulCommClass R S M :=
   @SMulCommClass.mk R S M (_) _
-   <| fun r s m => (by simp [← mul_smul, mul_comm] : f r β€’ s β€’ m = s β€’ f r β€’ m)
+   fun r s m => (by simp [← mul_smul, mul_comm] : f r β€’ s β€’ m = s β€’ f r β€’ m)
 #align category_theory.Module.smul_comm_class_mk ModuleCat.sMulCommClass_mk
 
 /-- Semilinear maps `M β†’β‚›β‚—[f] N` identify to
feat: UnivLE version of EnoughInjectives in ModuleCat (#8734)

Co-authored-by: Junyan Xu <junyanxu.math@gmail.com>

Diff
@@ -203,6 +203,16 @@ abbrev restrictScalarsComp := restrictScalarsComp'.{v} f g _ rfl
 
 end
 
+instance restrictScalarsIsEquivalenceOfRingEquiv {R S} [Ring R] [Ring S] (e : R ≃+* S) :
+    IsEquivalence (ModuleCat.restrictScalars e.toRingHom) where
+  inverse := ModuleCat.restrictScalars e.symm
+  unitIso := NatIso.ofComponents fun M ↦ LinearEquiv.toModuleIso'
+    { __ := AddEquiv.refl M
+      map_smul' := fun s m ↦ congr_arg (Β· β€’ m) (e.right_inv s).symm }
+  counitIso := NatIso.ofComponents fun M ↦ LinearEquiv.toModuleIso'
+    { __ := AddEquiv.refl M
+      map_smul' := fun r m ↦ congr_arg (Β· β€’ (_ : M)) (e.left_inv r) }
+
 open TensorProduct
 
 variable {R : Type u₁} {S : Type uβ‚‚} [CommRing R] [CommRing S] (f : R β†’+* S)
chore: space after ← (#8178)

Co-authored-by: Moritz Firsching <firsching@google.com>

Diff
@@ -455,7 +455,7 @@ def HomEquiv.toRestriction {X Y} (g : Y ⟢ (coextendScalars f).obj X) : (restri
     rw [← LinearMap.map_smul]
     erw [smul_eq_mul, mul_one, LinearMap.map_smul]
     -- Porting note: should probably change CoeFun for obj above
-    rw [← LinearMap.coe_toAddHom, ←AddHom.toFun_eq_coe]
+    rw [← LinearMap.coe_toAddHom, ← AddHom.toFun_eq_coe]
     rw [CoextendScalars.smul_apply (s := f r) (g := g y) (s' := 1), one_mul]
     simp
 #align category_theory.Module.restriction_coextension_adj.hom_equiv.to_restriction ModuleCat.RestrictionCoextensionAdj.HomEquiv.toRestriction
@@ -496,7 +496,7 @@ protected def unit' : 𝟭 (ModuleCat S) ⟢ restrictScalars f β‹™ coextendScala
       simp only [ModuleCat.coe_comp, Functor.id_map, Functor.id_obj, Functor.comp_obj,
         Functor.comp_map]
       rw [coe_comp, coe_comp, Function.comp, Function.comp]
-      conv_rhs => rw [← LinearMap.coe_toAddHom, ←AddHom.toFun_eq_coe]
+      conv_rhs => rw [← LinearMap.coe_toAddHom, ← AddHom.toFun_eq_coe]
       erw [CoextendScalars.map_apply, AddHom.toFun_eq_coe, LinearMap.coe_toAddHom,
         restrictScalars.map_apply f]
       change s β€’ (g y) = g (s β€’ y)
@@ -515,9 +515,9 @@ protected def counit' : coextendScalars f β‹™ restrictScalars f ⟢ 𝟭 (Module
         rw [LinearMap.add_apply]
       map_smul' := fun r (g : (restrictScalars f).obj ((coextendScalars f).obj X)) => by
         dsimp
-        rw [← LinearMap.coe_toAddHom, ←AddHom.toFun_eq_coe]
+        rw [← LinearMap.coe_toAddHom, ← AddHom.toFun_eq_coe]
         rw [CoextendScalars.smul_apply (s := f r) (g := g) (s' := 1), one_mul, ← LinearMap.map_smul]
-        rw [← LinearMap.coe_toAddHom, ←AddHom.toFun_eq_coe]
+        rw [← LinearMap.coe_toAddHom, ← AddHom.toFun_eq_coe]
         congr
         change f r = (f r) β€’ (1 : S)
         rw [smul_eq_mul (a := f r) (a' := 1), mul_one] }
@@ -680,7 +680,7 @@ def Unit.map {X} : X ⟢ (extendScalars f β‹™ restrictScalars f).obj X where
   map_smul' r x := by
     letI m1 : Module R S := Module.compHom S f
     -- Porting note: used to be rfl
-    dsimp; rw [←TensorProduct.smul_tmul,TensorProduct.smul_tmul']
+    dsimp; rw [← TensorProduct.smul_tmul,TensorProduct.smul_tmul']
 #align category_theory.Module.extend_restrict_scalars_adj.unit.map ModuleCat.ExtendRestrictScalarsAdj.Unit.map
 
 /--
@@ -706,7 +706,7 @@ def Counit.map {Y} : (restrictScalars f β‹™ extendScalars f).obj Y ⟢ Y := by
   Β· intros r y
     dsimp
     change s β€’ f r β€’ y = f r β€’ s β€’ y
-    rw [←mul_smul, mul_comm, mul_smul]
+    rw [← mul_smul, mul_comm, mul_smul]
   Β· intros s₁ sβ‚‚
     ext y
     change (s₁ + sβ‚‚) β€’ y = s₁ β€’ y + sβ‚‚ β€’ y
feat: category of $R$-modules has enough injectives (#7392)

Co-authored-by: Junyan Xu <junyanxumath@gmail.com>

Diff
@@ -3,7 +3,7 @@ Copyright (c) 2022 Jujian Zhang. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Jujian Zhang
 -/
-import Mathlib.Algebra.Category.ModuleCat.Basic
+import Mathlib.Algebra.Category.ModuleCat.EpiMono
 import Mathlib.RingTheory.TensorProduct
 
 #align_import algebra.category.Module.change_of_rings from "leanprover-community/mathlib"@"56b71f0b55c03f70332b862e65c3aa1aa1249ca1"
@@ -84,11 +84,15 @@ def restrictScalars {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] (f : R β†’
   map_comp _ _ := LinearMap.ext fun _ => rfl
 #align category_theory.Module.restrict_scalars ModuleCat.restrictScalars
 
-instance {R : Type u₁} {S : Type uβ‚‚} [CommRing R] [CommRing S] (f : R β†’+* S) :
+instance {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] (f : R β†’+* S) :
     CategoryTheory.Faithful (restrictScalars.{v} f) where
   map_injective h :=
     LinearMap.ext fun x => by simpa only using FunLike.congr_fun h x
 
+instance {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] (f : R β†’+* S) :
+    (restrictScalars.{v} f).PreservesMonomorphisms where
+  preserves _ h := by rwa [mono_iff_injective] at h ⊒
+
 -- Porting note: this should be automatic
 instance {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] {f : R β†’+* S}
     {M : ModuleCat.{v} S} : Module R <| (restrictScalars f).obj M :=
chore: bump to v4.3.0-rc2 (#8366)

PR contents

This is the supremum of

along with some minor fixes from failures on nightly-testing as Mathlib master is merged into it.

Note that some PRs for changes that are already compatible with the current toolchain and will be necessary have already been split out: #8380.

I am hopeful that in future we will be able to progressively merge adaptation PRs into a bump/v4.X.0 branch, so we never end up with a "big merge" like this. However one of these adaptation PRs (#8056) predates my new scheme for combined CI, and it wasn't possible to keep that PR viable in the meantime.

Lean PRs involved in this bump

In particular this includes adjustments for the Lean PRs

leanprover/lean4#2778

We can get rid of all the

local macro_rules | `($x ^ $y) => `(HPow.hPow $x $y) -- Porting note: See issue [lean4#2220](https://github.com/leanprover/lean4/pull/2220)

macros across Mathlib (and in any projects that want to write natural number powers of reals).

leanprover/lean4#2722

Changes the default behaviour of simp to (config := {decide := false}). This makes simp (and consequentially norm_num) less powerful, but also more consistent, and less likely to blow up in long failures. This requires a variety of changes: changing some previously by simp or norm_num to decide or rfl, or adding (config := {decide := true}).

leanprover/lean4#2783

This changed the behaviour of simp so that simp [f] will only unfold "fully applied" occurrences of f. The old behaviour can be recovered with simp (config := { unfoldPartialApp := true }). We may in future add a syntax for this, e.g. simp [!f]; please provide feedback! In the meantime, we have made the following changes:

  • switching to using explicit lemmas that have the intended level of application
  • (config := { unfoldPartialApp := true }) in some places, to recover the old behaviour
  • Using @[eqns] to manually adjust the equation lemmas for a particular definition, recovering the old behaviour just for that definition. See #8371, where we do this for Function.comp and Function.flip.

This change in Lean may require further changes down the line (e.g. adding the !f syntax, and/or upstreaming the special treatment for Function.comp and Function.flip, and/or removing this special treatment). Please keep an open and skeptical mind about these changes!

Co-authored-by: leanprover-community-mathlib4-bot <leanprover-community-mathlib4-bot@users.noreply.github.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Mauricio Collares <mauricio@collares.org>

Diff
@@ -124,8 +124,6 @@ instance (priority := 100) sMulCommClass_mk {R : Type u₁} {S : Type uβ‚‚} [Rin
     (f : R β†’+* S) (M : Type v) [I : AddCommGroup M] [Module S M] :
     haveI : SMul R M := (RestrictScalars.obj' f (ModuleCat.mk M)).isModule.toSMul
     SMulCommClass R S M :=
-  -- Porting note: cannot synth SMul R M
-  have : SMul R M := (RestrictScalars.obj' f (ModuleCat.mk M)).isModule.toSMul
   @SMulCommClass.mk R S M (_) _
    <| fun r s m => (by simp [← mul_smul, mul_comm] : f r β€’ s β€’ m = s β€’ f r β€’ m)
 #align category_theory.Module.smul_comm_class_mk ModuleCat.sMulCommClass_mk
perf(FunLike.Basic): beta reduce CoeFun.coe (#7905)

This eliminates (fun a ↦ Ξ²) Ξ± in the type when applying a FunLike.

Co-authored-by: Matthew Ballard <matt@mrb.email> Co-authored-by: Eric Wieser <wieser.eric@gmail.com>

Diff
@@ -333,8 +333,8 @@ instance mulAction : MulAction S <| (restrictScalars f).obj ⟨S⟩ β†’β‚—[R] M
 
 instance distribMulAction : DistribMulAction S <| (restrictScalars f).obj ⟨S⟩ β†’β‚—[R] M :=
   { CoextendScalars.mulAction f _ with
-    smul_add := fun s g h => LinearMap.ext fun t : S => by simp
-    smul_zero := fun s => LinearMap.ext fun t : S => by simp }
+    smul_add := fun s g h => LinearMap.ext fun _ : S => by simp
+    smul_zero := fun s => LinearMap.ext fun _ : S => by simp }
 #align category_theory.Module.coextend_scalars.distrib_mul_action ModuleCat.CoextendScalars.distribMulAction
 
 /-- `S` acts on Hom(S, M) by `s β€’ g = x ↦ g (x β€’ s)`, this action defines an `S`-module structure on
@@ -586,8 +586,7 @@ def HomEquiv.toRestrictScalars {X Y} (g : (extendScalars f).obj X ⟢ Y) :
     letI : Module R S := Module.compHom S f
     letI : Module R Y := Module.compHom Y f
     dsimp
-    rw [RestrictScalars.smul_def, ← LinearMap.map_smul]
-    erw [tmul_smul]
+    erw [RestrictScalars.smul_def, ← LinearMap.map_smul, tmul_smul]
     congr
 #align category_theory.Module.extend_restrict_scalars_adj.hom_equiv.to_restrict_scalars ModuleCat.ExtendRestrictScalarsAdj.HomEquiv.toRestrictScalars
 
@@ -658,6 +657,7 @@ def homEquiv {X Y} :
       change S at x
       dsimp
       erw [← LinearMap.map_smul, ExtendScalars.smul_tmul, mul_one x]
+      rfl
     Β· rw [map_add, map_add, ih1, ih2]
   right_inv g := by
     letI m1 : Module R S := Module.compHom S f; letI m2 : Module R Y := Module.compHom Y f
refactor: add explicit equation lemmas for comp and flip (#8371)

This will mostly be a no-op in the current version of Lean, but will override the new behavior from leanprover/lean4#2783.

Once consequence of this is that rw [comp] no longer uses "smart unfolding"; it introduces a non-beta reduced term if the composition was applied. As a result, these places need to use rw [comp_apply] instead. My claim is that this is no big deal.

This is split from the lean bump PR #8023, targeting master, to make clear what the fallout is.

Diff
@@ -747,7 +747,7 @@ def counit : restrictScalars.{max v uβ‚‚,u₁,uβ‚‚} f β‹™ extendScalars f ⟢ 
     induction' z using TensorProduct.induction_on with s' y z₁ zβ‚‚ ih₁ ihβ‚‚
     Β· rw [map_zero, map_zero]
     Β· dsimp
-      rw [ModuleCat.coe_comp, ModuleCat.coe_comp,Function.comp,Function.comp,
+      rw [ModuleCat.coe_comp, ModuleCat.coe_comp, Function.comp_apply, Function.comp_apply,
         ExtendScalars.map_tmul, restrictScalars.map_apply]
       -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
       erw [Counit.map_apply]
@@ -771,7 +771,7 @@ def extendRestrictScalarsAdj {R : Type u₁} {S : Type uβ‚‚} [CommRing R] [CommR
   counit := ExtendRestrictScalarsAdj.counit.{v,u₁,uβ‚‚} f
   homEquiv_unit {X Y g} := LinearMap.ext fun x => by
     dsimp
-    rw [ModuleCat.coe_comp, Function.comp, restrictScalars.map_apply]
+    rw [ModuleCat.coe_comp, Function.comp_apply, restrictScalars.map_apply]
     rfl
   homEquiv_counit {X Y g} := LinearMap.ext fun x => by
       -- Porting note: once again reminding Lean of the instances
Revert "chore: revert #7703 (#7710)"

This reverts commit f3695eb2.

Diff
@@ -156,11 +156,13 @@ variable {R : Type u₁} [Ring R] (f : R β†’+* R) (hf : f = RingHom.id R)
 identity functor. -/
 def restrictScalarsId' : ModuleCat.restrictScalars.{v} f β‰… 𝟭 _ := by subst hf; rfl
 
-@[simp]
+-- This lemma has always been bad, but lean4#2644 made `simp` start noticing
+@[simp, nolint simpNF]
 lemma restrictScalarsId'_inv_apply (M : ModuleCat R) (x : M) :
     (restrictScalarsId' f hf).inv.app M x = x := by subst hf; rfl
 
-@[simp]
+-- This lemma has always been bad, but lean4#2644 made `simp` start noticing
+@[simp, nolint simpNF]
 lemma restrictScalarsId'_hom_apply (M : ModuleCat R) (x : M) :
     (restrictScalarsId' f hf).hom.app M x = x := by subst hf; rfl
 
@@ -182,11 +184,14 @@ composition of the restriction of scalars functors. -/
 def restrictScalarsComp' :
     ModuleCat.restrictScalars.{v} gf β‰…
       ModuleCat.restrictScalars g β‹™ ModuleCat.restrictScalars f := by subst hgf; rfl
-@[simp]
+
+-- This lemma has always been bad, but lean4#2644 made `simp` start noticing
+@[simp, nolint simpNF]
 lemma restrictScalarsComp'_hom_apply (M : ModuleCat R₃) (x : M) :
     (restrictScalarsComp' f g gf hgf).hom.app M x = x := by subst hgf; rfl
 
-@[simp]
+-- This lemma has always been bad, but lean4#2644 made `simp` start noticing
+@[simp, nolint simpNF]
 lemma restrictScalarsComp'_inv_apply (M : ModuleCat R₃) (x : M) :
     (restrictScalarsComp' f g gf hgf).inv.app M x = x := by subst hgf; rfl
 
@@ -743,8 +748,10 @@ def counit : restrictScalars.{max v uβ‚‚,u₁,uβ‚‚} f β‹™ extendScalars f ⟢ 
     Β· rw [map_zero, map_zero]
     Β· dsimp
       rw [ModuleCat.coe_comp, ModuleCat.coe_comp,Function.comp,Function.comp,
-        ExtendScalars.map_tmul, restrictScalars.map_apply, Counit.map_apply, Counit.map_apply,
-        lift.tmul, lift.tmul, LinearMap.coe_mk, LinearMap.coe_mk]
+        ExtendScalars.map_tmul, restrictScalars.map_apply]
+      -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
+      erw [Counit.map_apply]
+      rw [lift.tmul, LinearMap.coe_mk, LinearMap.coe_mk]
       set s' : S := s'
       change s' β€’ g y = g (s' β€’ y)
       rw [map_smul]
@@ -772,8 +779,12 @@ def extendRestrictScalarsAdj {R : Type u₁} {S : Type uβ‚‚} [CommRing R] [CommR
       letI m2 : Module R Y := Module.compHom Y f
       induction' x using TensorProduct.induction_on with s x _ _ _ _
       Β· rw [map_zero, map_zero]
-      Β· rw [ExtendRestrictScalarsAdj.homEquiv_symm_apply, ModuleCat.coe_comp, Function.comp_apply,
-          ExtendRestrictScalarsAdj.counit_app, ExtendRestrictScalarsAdj.Counit.map_apply]
+      Β· rw [ExtendRestrictScalarsAdj.homEquiv_symm_apply]
+        -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
+        erw [ModuleCat.coe_comp]
+        rw [Function.comp_apply, ExtendRestrictScalarsAdj.counit_app]
+        -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
+        erw [ExtendRestrictScalarsAdj.Counit.map_apply]
         dsimp
         rw [TensorProduct.lift.tmul]
         rfl
chore: revert #7703 (#7710)

This reverts commit 26eb2b0a.

Diff
@@ -156,13 +156,11 @@ variable {R : Type u₁} [Ring R] (f : R β†’+* R) (hf : f = RingHom.id R)
 identity functor. -/
 def restrictScalarsId' : ModuleCat.restrictScalars.{v} f β‰… 𝟭 _ := by subst hf; rfl
 
--- This lemma has always been bad, but lean4#2644 made `simp` start noticing
-@[simp, nolint simpNF]
+@[simp]
 lemma restrictScalarsId'_inv_apply (M : ModuleCat R) (x : M) :
     (restrictScalarsId' f hf).inv.app M x = x := by subst hf; rfl
 
--- This lemma has always been bad, but lean4#2644 made `simp` start noticing
-@[simp, nolint simpNF]
+@[simp]
 lemma restrictScalarsId'_hom_apply (M : ModuleCat R) (x : M) :
     (restrictScalarsId' f hf).hom.app M x = x := by subst hf; rfl
 
@@ -184,14 +182,11 @@ composition of the restriction of scalars functors. -/
 def restrictScalarsComp' :
     ModuleCat.restrictScalars.{v} gf β‰…
       ModuleCat.restrictScalars g β‹™ ModuleCat.restrictScalars f := by subst hgf; rfl
-
--- This lemma has always been bad, but lean4#2644 made `simp` start noticing
-@[simp, nolint simpNF]
+@[simp]
 lemma restrictScalarsComp'_hom_apply (M : ModuleCat R₃) (x : M) :
     (restrictScalarsComp' f g gf hgf).hom.app M x = x := by subst hgf; rfl
 
--- This lemma has always been bad, but lean4#2644 made `simp` start noticing
-@[simp, nolint simpNF]
+@[simp]
 lemma restrictScalarsComp'_inv_apply (M : ModuleCat R₃) (x : M) :
     (restrictScalarsComp' f g gf hgf).inv.app M x = x := by subst hgf; rfl
 
@@ -748,10 +743,8 @@ def counit : restrictScalars.{max v uβ‚‚,u₁,uβ‚‚} f β‹™ extendScalars f ⟢ 
     Β· rw [map_zero, map_zero]
     Β· dsimp
       rw [ModuleCat.coe_comp, ModuleCat.coe_comp,Function.comp,Function.comp,
-        ExtendScalars.map_tmul, restrictScalars.map_apply]
-      -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
-      erw [Counit.map_apply]
-      rw [lift.tmul, LinearMap.coe_mk, LinearMap.coe_mk]
+        ExtendScalars.map_tmul, restrictScalars.map_apply, Counit.map_apply, Counit.map_apply,
+        lift.tmul, lift.tmul, LinearMap.coe_mk, LinearMap.coe_mk]
       set s' : S := s'
       change s' β€’ g y = g (s' β€’ y)
       rw [map_smul]
@@ -779,12 +772,8 @@ def extendRestrictScalarsAdj {R : Type u₁} {S : Type uβ‚‚} [CommRing R] [CommR
       letI m2 : Module R Y := Module.compHom Y f
       induction' x using TensorProduct.induction_on with s x _ _ _ _
       Β· rw [map_zero, map_zero]
-      Β· rw [ExtendRestrictScalarsAdj.homEquiv_symm_apply]
-        -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
-        erw [ModuleCat.coe_comp]
-        rw [Function.comp_apply, ExtendRestrictScalarsAdj.counit_app]
-        -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
-        erw [ExtendRestrictScalarsAdj.Counit.map_apply]
+      Β· rw [ExtendRestrictScalarsAdj.homEquiv_symm_apply, ModuleCat.coe_comp, Function.comp_apply,
+          ExtendRestrictScalarsAdj.counit_app, ExtendRestrictScalarsAdj.Counit.map_apply]
         dsimp
         rw [TensorProduct.lift.tmul]
         rfl
chore: bump toolchain to v4.2.0-rc2 (#7703)

This includes all the changes from #7606.

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -156,11 +156,13 @@ variable {R : Type u₁} [Ring R] (f : R β†’+* R) (hf : f = RingHom.id R)
 identity functor. -/
 def restrictScalarsId' : ModuleCat.restrictScalars.{v} f β‰… 𝟭 _ := by subst hf; rfl
 
-@[simp]
+-- This lemma has always been bad, but lean4#2644 made `simp` start noticing
+@[simp, nolint simpNF]
 lemma restrictScalarsId'_inv_apply (M : ModuleCat R) (x : M) :
     (restrictScalarsId' f hf).inv.app M x = x := by subst hf; rfl
 
-@[simp]
+-- This lemma has always been bad, but lean4#2644 made `simp` start noticing
+@[simp, nolint simpNF]
 lemma restrictScalarsId'_hom_apply (M : ModuleCat R) (x : M) :
     (restrictScalarsId' f hf).hom.app M x = x := by subst hf; rfl
 
@@ -182,11 +184,14 @@ composition of the restriction of scalars functors. -/
 def restrictScalarsComp' :
     ModuleCat.restrictScalars.{v} gf β‰…
       ModuleCat.restrictScalars g β‹™ ModuleCat.restrictScalars f := by subst hgf; rfl
-@[simp]
+
+-- This lemma has always been bad, but lean4#2644 made `simp` start noticing
+@[simp, nolint simpNF]
 lemma restrictScalarsComp'_hom_apply (M : ModuleCat R₃) (x : M) :
     (restrictScalarsComp' f g gf hgf).hom.app M x = x := by subst hgf; rfl
 
-@[simp]
+-- This lemma has always been bad, but lean4#2644 made `simp` start noticing
+@[simp, nolint simpNF]
 lemma restrictScalarsComp'_inv_apply (M : ModuleCat R₃) (x : M) :
     (restrictScalarsComp' f g gf hgf).inv.app M x = x := by subst hgf; rfl
 
@@ -743,8 +748,10 @@ def counit : restrictScalars.{max v uβ‚‚,u₁,uβ‚‚} f β‹™ extendScalars f ⟢ 
     Β· rw [map_zero, map_zero]
     Β· dsimp
       rw [ModuleCat.coe_comp, ModuleCat.coe_comp,Function.comp,Function.comp,
-        ExtendScalars.map_tmul, restrictScalars.map_apply, Counit.map_apply, Counit.map_apply,
-        lift.tmul, lift.tmul, LinearMap.coe_mk, LinearMap.coe_mk]
+        ExtendScalars.map_tmul, restrictScalars.map_apply]
+      -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
+      erw [Counit.map_apply]
+      rw [lift.tmul, LinearMap.coe_mk, LinearMap.coe_mk]
       set s' : S := s'
       change s' β€’ g y = g (s' β€’ y)
       rw [map_smul]
@@ -772,8 +779,12 @@ def extendRestrictScalarsAdj {R : Type u₁} {S : Type uβ‚‚} [CommRing R] [CommR
       letI m2 : Module R Y := Module.compHom Y f
       induction' x using TensorProduct.induction_on with s x _ _ _ _
       Β· rw [map_zero, map_zero]
-      Β· rw [ExtendRestrictScalarsAdj.homEquiv_symm_apply, ModuleCat.coe_comp, Function.comp_apply,
-          ExtendRestrictScalarsAdj.counit_app, ExtendRestrictScalarsAdj.Counit.map_apply]
+      Β· rw [ExtendRestrictScalarsAdj.homEquiv_symm_apply]
+        -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
+        erw [ModuleCat.coe_comp]
+        rw [Function.comp_apply, ExtendRestrictScalarsAdj.counit_app]
+        -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
+        erw [ExtendRestrictScalarsAdj.Counit.map_apply]
         dsimp
         rw [TensorProduct.lift.tmul]
         rfl
feat: use suppress_compilation in tensor products (#7504)

More principled version of #7281.

Diff
@@ -40,6 +40,8 @@ Let `R, S` be rings and `f : R β†’+* S`
   `s βŠ— m : S βŠ—[R, f] M`.
 -/
 
+suppress_compilation
+
 set_option linter.uppercaseLean3 false -- Porting note: Module
 
 open CategoryTheory
chore: another non-class instance (#7250)

Following https://github.com/leanprover-community/mathlib4/pull/7245, https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/isClass.3F.20panic!/near/391779504.

There is one exception that it is unclear how to fix, it seems lean makes the internal declarations in a block of mutual instances also instances perhaps? Seeing as it is internal I hope it won't cause too much trouble

Diff
@@ -120,7 +120,7 @@ theorem restrictScalars.smul_def' {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring
 
 instance (priority := 100) sMulCommClass_mk {R : Type u₁} {S : Type uβ‚‚} [Ring R] [CommRing S]
     (f : R β†’+* S) (M : Type v) [I : AddCommGroup M] [Module S M] :
-    have : SMul R M := (RestrictScalars.obj' f (ModuleCat.mk M)).isModule.toSMul
+    haveI : SMul R M := (RestrictScalars.obj' f (ModuleCat.mk M)).isModule.toSMul
     SMulCommClass R S M :=
   -- Porting note: cannot synth SMul R M
   have : SMul R M := (RestrictScalars.obj' f (ModuleCat.mk M)).isModule.toSMul
perf: remove overspecified fields (#6965)

This removes redundant field values of the form add := add for smaller terms and less unfolding during unification.

A list of all files containing a structure instance of the form { a1, ... with x1 := val, ... } where some xi is a field of some aj was generated by modifying the structure instance elaboration algorithm to print such overlaps to stdout in a custom toolchain.

Using that toolchain, I went through each file on the list and attempted to remove algebraic fields that overlapped and were redundant, eg add := add and not toFun (though some other ones did creep in). If things broke (which was the case in a couple of cases), I did not push further and reverted.

It is possible that pushing harder and trying to remove all redundant overlaps will yield further improvements.

Diff
@@ -448,7 +448,7 @@ def HomEquiv.toRestriction {X Y} (g : Y ⟢ (coextendScalars f).obj X) : (restri
     -- Porting note: should probably change CoeFun for obj above
     rw [← LinearMap.coe_toAddHom, ←AddHom.toFun_eq_coe]
     rw [CoextendScalars.smul_apply (s := f r) (g := g y) (s' := 1), one_mul]
-    rw [AddHom.toFun_eq_coe, LinearMap.coe_toAddHom]
+    simp
 #align category_theory.Module.restriction_coextension_adj.hom_equiv.to_restriction ModuleCat.RestrictionCoextensionAdj.HomEquiv.toRestriction
 
 -- Porting note: add to address timeout in unit'
@@ -459,7 +459,8 @@ def app' (Y : ModuleCat S) : Y β†’β‚—[S] (restrictScalars f β‹™ coextendScalars
         map_add' := fun s s' => add_smul _ _ _
         map_smul' := fun r (s : S) => by
           dsimp
-          erw [smul_eq_mul, mul_smul] }
+          erw [smul_eq_mul, mul_smul]
+          simp }
     map_add' := fun y1 y2 =>
       LinearMap.ext fun s : S => by
         -- Porting note: double dsimp seems odd
feat(Algebra/Category/ModuleCat): composition of restriction of scalar functors (#6915)

This PR studies the behaviour of restriction of scalars functors with respect to composition.

Diff
@@ -13,25 +13,25 @@ import Mathlib.RingTheory.TensorProduct
 
 ## Main definitions
 
-* `CategoryTheory.ModuleCat.restrictScalars`: given rings `R, S` and a ring homomorphism `R ⟢ S`,
+* `ModuleCat.restrictScalars`: given rings `R, S` and a ring homomorphism `R ⟢ S`,
   then `restrictScalars : ModuleCat S β₯€ ModuleCat R` is defined by `M ↦ M` where an `S`-module `M`
   is seen as an `R`-module by `r β€’ m := f r β€’ m` and `S`-linear map `l : M ⟢ M'` is `R`-linear as
   well.
 
-* `CategoryTheory.ModuleCat.extendScalars`: given **commutative** rings `R, S` and ring homomorphism
+* `ModuleCat.extendScalars`: given **commutative** rings `R, S` and ring homomorphism
   `f : R ⟢ S`, then `extendScalars : ModuleCat R β₯€ ModuleCat S` is defined by `M ↦ S ⨂ M` where the
   module structure is defined by `s β€’ (s' βŠ— m) := (s * s') βŠ— m` and `R`-linear map `l : M ⟢ M'`
   is sent to `S`-linear map `s βŠ— m ↦ s βŠ— l m : S ⨂ M ⟢ S ⨂ M'`.
 
-* `CategoryTheory.ModuleCat.coextendScalars`: given rings `R, S` and a ring homomorphism `R ⟢ S`
+* `ModuleCat.coextendScalars`: given rings `R, S` and a ring homomorphism `R ⟢ S`
   then `coextendScalars : ModuleCat R β₯€ ModuleCat S` is defined by `M ↦ (S β†’β‚—[R] M)` where `S` is
   seen as an `R`-module by restriction of scalars and `l ↦ l ∘ _`.
 
 ## Main results
 
-* `CategoryTheory.ModuleCat.extendRestrictScalarsAdj`: given commutative rings `R, S` and a ring
+* `ModuleCat.extendRestrictScalarsAdj`: given commutative rings `R, S` and a ring
   homomorphism `f : R β†’+* S`, the extension and restriction of scalars by `f` are adjoint functors.
-* `CategoryTheory.ModuleCat.restrictCoextendScalarsAdj`: given rings `R, S` and a ring homomorphism
+* `ModuleCat.restrictCoextendScalarsAdj`: given rings `R, S` and a ring homomorphism
   `f : R ⟢ S` then `coextendScalars f` is the right adjoint of `restrictScalars f`.
 
 ## List of notations
@@ -42,9 +42,11 @@ Let `R, S` be rings and `f : R β†’+* S`
 
 set_option linter.uppercaseLean3 false -- Porting note: Module
 
-namespace CategoryTheory.ModuleCat
+open CategoryTheory
 
-universe v u₁ uβ‚‚
+namespace ModuleCat
+
+universe v u₁ uβ‚‚ u₃
 
 namespace RestrictScalars
 
@@ -57,14 +59,14 @@ variable (M : ModuleCat.{v} S)
 def obj' : ModuleCat R where
   carrier := M
   isModule := Module.compHom M f
-#align category_theory.Module.restrict_scalars.obj' CategoryTheory.ModuleCat.RestrictScalars.obj'
+#align category_theory.Module.restrict_scalars.obj' ModuleCat.RestrictScalars.obj'
 
 /-- Given an `S`-linear map `g : M β†’ M'` between `S`-modules, `g` is also `R`-linear between `M` and
 `M'` by means of restriction of scalars.
 -/
 def map' {M M' : ModuleCat.{v} S} (g : M ⟢ M') : obj' f M ⟢ obj' f M' :=
   { g with map_smul' := fun r => g.map_smul (f r) }
-#align category_theory.Module.restrict_scalars.map' CategoryTheory.ModuleCat.RestrictScalars.map'
+#align category_theory.Module.restrict_scalars.map' ModuleCat.RestrictScalars.map'
 
 end RestrictScalars
 
@@ -78,7 +80,7 @@ def restrictScalars {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] (f : R β†’
   map := RestrictScalars.map' f
   map_id _ := LinearMap.ext fun _ => rfl
   map_comp _ _ := LinearMap.ext fun _ => rfl
-#align category_theory.Module.restrict_scalars CategoryTheory.ModuleCat.restrictScalars
+#align category_theory.Module.restrict_scalars ModuleCat.restrictScalars
 
 instance {R : Type u₁} {S : Type uβ‚‚} [CommRing R] [CommRing S] (f : R β†’+* S) :
     CategoryTheory.Faithful (restrictScalars.{v} f) where
@@ -99,13 +101,13 @@ instance {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] {f : R β†’+* S}
 theorem restrictScalars.map_apply {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] (f : R β†’+* S)
     {M M' : ModuleCat.{v} S} (g : M ⟢ M') (x) : (restrictScalars f).map g x = g x :=
   rfl
-#align category_theory.Module.restrict_scalars.map_apply CategoryTheory.ModuleCat.restrictScalars.map_apply
+#align category_theory.Module.restrict_scalars.map_apply ModuleCat.restrictScalars.map_apply
 
 @[simp]
 theorem restrictScalars.smul_def {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] (f : R β†’+* S)
     {M : ModuleCat.{v} S} (r : R) (m : (restrictScalars f).obj M) : r β€’ m = (f r β€’ m : M) :=
   rfl
-#align category_theory.Module.restrict_scalars.smul_def CategoryTheory.ModuleCat.restrictScalars.smul_def
+#align category_theory.Module.restrict_scalars.smul_def ModuleCat.restrictScalars.smul_def
 
 theorem restrictScalars.smul_def' {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] (f : R β†’+* S)
     {M : ModuleCat.{v} S} (r : R) (m : M) :
@@ -113,7 +115,7 @@ theorem restrictScalars.smul_def' {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring
     let m' : (restrictScalars f).obj M := m
     (r β€’ m' : (restrictScalars f).obj M) = (f r β€’ m : M) :=
   rfl
-#align category_theory.Module.restrict_scalars.smul_def' CategoryTheory.ModuleCat.restrictScalars.smul_def'
+#align category_theory.Module.restrict_scalars.smul_def' ModuleCat.restrictScalars.smul_def'
 
 
 instance (priority := 100) sMulCommClass_mk {R : Type u₁} {S : Type uβ‚‚} [Ring R] [CommRing S]
@@ -124,13 +126,79 @@ instance (priority := 100) sMulCommClass_mk {R : Type u₁} {S : Type uβ‚‚} [Rin
   have : SMul R M := (RestrictScalars.obj' f (ModuleCat.mk M)).isModule.toSMul
   @SMulCommClass.mk R S M (_) _
    <| fun r s m => (by simp [← mul_smul, mul_comm] : f r β€’ s β€’ m = s β€’ f r β€’ m)
-#align category_theory.Module.smul_comm_class_mk CategoryTheory.ModuleCat.sMulCommClass_mk
+#align category_theory.Module.smul_comm_class_mk ModuleCat.sMulCommClass_mk
+
+/-- Semilinear maps `M β†’β‚›β‚—[f] N` identify to
+morphisms `M ⟢ (ModuleCat.restrictScalars f).obj N`. -/
+@[simps]
+def semilinearMapAddEquiv {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] (f : R β†’+* S)
+    (M : ModuleCat.{v} R) (N : ModuleCat.{v} S) :
+    (M β†’β‚›β‚—[f] N) ≃+ (M ⟢ (ModuleCat.restrictScalars f).obj N) where
+  toFun g :=
+    { toFun := g
+      map_add' := by simp
+      map_smul' := by simp }
+  invFun g :=
+    { toFun := g
+      map_add' := by simp
+      map_smul' := g.map_smul }
+  left_inv g := rfl
+  right_inv g := rfl
+  map_add' g₁ gβ‚‚ := rfl
+
+section
+
+variable {R : Type u₁} [Ring R] (f : R β†’+* R) (hf : f = RingHom.id R)
+
+/-- The restriction of scalars by a ring morphism that is the identity identify to the
+identity functor. -/
+def restrictScalarsId' : ModuleCat.restrictScalars.{v} f β‰… 𝟭 _ := by subst hf; rfl
+
+@[simp]
+lemma restrictScalarsId'_inv_apply (M : ModuleCat R) (x : M) :
+    (restrictScalarsId' f hf).inv.app M x = x := by subst hf; rfl
+
+@[simp]
+lemma restrictScalarsId'_hom_apply (M : ModuleCat R) (x : M) :
+    (restrictScalarsId' f hf).hom.app M x = x := by subst hf; rfl
+
+variable (R)
+
+/-- The restriction of scalars by the identity morphisms identify to the
+identity functor. -/
+abbrev restrictScalarsId := restrictScalarsId'.{v} (RingHom.id R) rfl
+
+end
+
+section
+
+variable {R₁ : Type u₁} {Rβ‚‚ : Type uβ‚‚} {R₃ : Type u₃} [Ring R₁] [Ring Rβ‚‚] [Ring R₃]
+  (f : R₁ β†’+* Rβ‚‚) (g : Rβ‚‚ β†’+* R₃) (gf : R₁ β†’+* R₃) (hgf : gf = g.comp f)
+
+/-- The restriction of scalars by a composition of ring morphisms identify to the
+composition of the restriction of scalars functors. -/
+def restrictScalarsComp' :
+    ModuleCat.restrictScalars.{v} gf β‰…
+      ModuleCat.restrictScalars g β‹™ ModuleCat.restrictScalars f := by subst hgf; rfl
+@[simp]
+lemma restrictScalarsComp'_hom_apply (M : ModuleCat R₃) (x : M) :
+    (restrictScalarsComp' f g gf hgf).hom.app M x = x := by subst hgf; rfl
+
+@[simp]
+lemma restrictScalarsComp'_inv_apply (M : ModuleCat R₃) (x : M) :
+    (restrictScalarsComp' f g gf hgf).inv.app M x = x := by subst hgf; rfl
+
+/-- The restriction of scalars by a composition of ring morphisms identify to the
+composition of the restriction of scalars functors. -/
+abbrev restrictScalarsComp := restrictScalarsComp'.{v} f g _ rfl
+
+end
 
 open TensorProduct
 
 variable {R : Type u₁} {S : Type uβ‚‚} [CommRing R] [CommRing S] (f : R β†’+* S)
 
-section CategoryTheory.ModuleCat.Unbundled
+section ModuleCat.Unbundled
 
 variable (M : Type v) [AddCommMonoid M] [Module R M]
 
@@ -152,7 +220,7 @@ variable (M : ModuleCat.{v} R)
 -/
 def obj' : ModuleCat S :=
   ⟨TensorProduct R ((restrictScalars f).obj ⟨S⟩) M⟩
-#align category_theory.Module.extend_scalars.obj' CategoryTheory.ModuleCat.ExtendScalars.obj'
+#align category_theory.Module.extend_scalars.obj' ModuleCat.ExtendScalars.obj'
 
 /-- Extension of scalars is a functor where an `R`-module `M` is sent to `S βŠ— M` and
 `l : M1 ⟢ M2` is sent to `s βŠ— m ↦ s βŠ— l m`
@@ -160,7 +228,7 @@ def obj' : ModuleCat S :=
 def map' {M1 M2 : ModuleCat.{v} R} (l : M1 ⟢ M2) : obj' f M1 ⟢ obj' f M2 :=
   by-- The "by apply" part makes this require 75% fewer heartbeats to process (#16371).
   apply @LinearMap.baseChange R S M1 M2 _ _ ((algebraMap S _).comp f).toAlgebra _ _ _ _ l
-#align category_theory.Module.extend_scalars.map' CategoryTheory.ModuleCat.ExtendScalars.map'
+#align category_theory.Module.extend_scalars.map' ModuleCat.ExtendScalars.map'
 
 theorem map'_id {M : ModuleCat.{v} R} : map' f (πŸ™ M) = πŸ™ _ :=
   LinearMap.ext fun x : obj' f M => by
@@ -172,7 +240,7 @@ theorem map'_id {M : ModuleCat.{v} R} : map' f (πŸ™ M) = πŸ™ _ :=
     Β· -- Porting note: issues with synthesizing Algebra R S
       erw [@LinearMap.baseChange_tmul R S M M _ _ (_), ModuleCat.id_apply]
     Β· rw [map_add, ihx, ihy]
-#align category_theory.Module.extend_scalars.map'_id CategoryTheory.ModuleCat.ExtendScalars.map'_id
+#align category_theory.Module.extend_scalars.map'_id ModuleCat.ExtendScalars.map'_id
 
 theorem map'_comp {M₁ Mβ‚‚ M₃ : ModuleCat.{v} R} (l₁₂ : M₁ ⟢ Mβ‚‚) (l₂₃ : Mβ‚‚ ⟢ M₃) :
     map' f (l₁₂ ≫ l₂₃) = map' f l₁₂ ≫ map' f l₂₃ :=
@@ -182,7 +250,7 @@ theorem map'_comp {M₁ Mβ‚‚ M₃ : ModuleCat.{v} R} (l₁₂ : M₁ ⟢ Mβ‚‚) (
     Β· rfl
     Β· rfl
     Β· rw [map_add, map_add, ihx, ihy] -- Porting note: simp again failing where rw succeeds
-#align category_theory.Module.extend_scalars.map'_comp CategoryTheory.ModuleCat.ExtendScalars.map'_comp
+#align category_theory.Module.extend_scalars.map'_comp ModuleCat.ExtendScalars.map'_comp
 
 end ExtendScalars
 
@@ -195,7 +263,7 @@ def extendScalars {R : Type u₁} {S : Type uβ‚‚} [CommRing R] [CommRing S] (f :
   map l := ExtendScalars.map' f l
   map_id _ := ExtendScalars.map'_id f
   map_comp := ExtendScalars.map'_comp f
-#align category_theory.Module.extend_scalars CategoryTheory.ModuleCat.extendScalars
+#align category_theory.Module.extend_scalars ModuleCat.extendScalars
 
 namespace ExtendScalars
 
@@ -207,13 +275,13 @@ variable {R : Type u₁} {S : Type uβ‚‚} [CommRing R] [CommRing S] (f : R β†’+*
 protected theorem smul_tmul {M : ModuleCat.{v} R} (s s' : S) (m : M) :
     s β€’ (s'βŠ—β‚œ[R,f]m : (extendScalars f).obj M) = (s * s')βŠ—β‚œ[R,f]m :=
   rfl
-#align category_theory.Module.extend_scalars.smul_tmul CategoryTheory.ModuleCat.ExtendScalars.smul_tmul
+#align category_theory.Module.extend_scalars.smul_tmul ModuleCat.ExtendScalars.smul_tmul
 
 @[simp]
 theorem map_tmul {M M' : ModuleCat.{v} R} (g : M ⟢ M') (s : S) (m : M) :
     (extendScalars f).map g (sβŠ—β‚œ[R,f]m) = sβŠ—β‚œ[R,f]g m :=
   rfl
-#align category_theory.Module.extend_scalars.map_tmul CategoryTheory.ModuleCat.ExtendScalars.map_tmul
+#align category_theory.Module.extend_scalars.map_tmul ModuleCat.ExtendScalars.map_tmul
 
 end ExtendScalars
 
@@ -242,25 +310,25 @@ instance hasSMul : SMul S <| (restrictScalars f).obj ⟨S⟩ β†’β‚—[R] M where
         dsimp
         rw [← LinearMap.map_smul]
         erw [smul_eq_mul, smul_eq_mul, mul_assoc] }
-#align category_theory.Module.coextend_scalars.has_smul CategoryTheory.ModuleCat.CoextendScalars.hasSMul
+#align category_theory.Module.coextend_scalars.has_smul ModuleCat.CoextendScalars.hasSMul
 
 @[simp]
 theorem smul_apply' (s : S) (g : (restrictScalars f).obj ⟨S⟩ β†’β‚—[R] M) (s' : S) :
     (s β€’ g) s' = g (s' * s : S) :=
   rfl
-#align category_theory.Module.coextend_scalars.smul_apply' CategoryTheory.ModuleCat.CoextendScalars.smul_apply'
+#align category_theory.Module.coextend_scalars.smul_apply' ModuleCat.CoextendScalars.smul_apply'
 
 instance mulAction : MulAction S <| (restrictScalars f).obj ⟨S⟩ β†’β‚—[R] M :=
   { CoextendScalars.hasSMul f _ with
     one_smul := fun g => LinearMap.ext fun s : S => by simp
     mul_smul := fun (s t : S) g => LinearMap.ext fun x : S => by simp [mul_assoc] }
-#align category_theory.Module.coextend_scalars.mul_action CategoryTheory.ModuleCat.CoextendScalars.mulAction
+#align category_theory.Module.coextend_scalars.mul_action ModuleCat.CoextendScalars.mulAction
 
 instance distribMulAction : DistribMulAction S <| (restrictScalars f).obj ⟨S⟩ β†’β‚—[R] M :=
   { CoextendScalars.mulAction f _ with
     smul_add := fun s g h => LinearMap.ext fun t : S => by simp
     smul_zero := fun s => LinearMap.ext fun t : S => by simp }
-#align category_theory.Module.coextend_scalars.distrib_mul_action CategoryTheory.ModuleCat.CoextendScalars.distribMulAction
+#align category_theory.Module.coextend_scalars.distrib_mul_action ModuleCat.CoextendScalars.distribMulAction
 
 /-- `S` acts on Hom(S, M) by `s β€’ g = x ↦ g (x β€’ s)`, this action defines an `S`-module structure on
 Hom(S, M).
@@ -269,7 +337,7 @@ instance isModule : Module S <| (restrictScalars f).obj ⟨S⟩ β†’β‚—[R] M :=
   { CoextendScalars.distribMulAction f _ with
     add_smul := fun s1 s2 g => LinearMap.ext fun x : S => by simp [mul_add, LinearMap.map_add]
     zero_smul := fun g => LinearMap.ext fun x : S => by simp [LinearMap.map_zero] }
-#align category_theory.Module.coextend_scalars.is_module CategoryTheory.ModuleCat.CoextendScalars.isModule
+#align category_theory.Module.coextend_scalars.is_module ModuleCat.CoextendScalars.isModule
 
 end Unbundled
 
@@ -279,7 +347,7 @@ variable (M : ModuleCat.{v} R)
 scalar multiplication defined by `s β€’ l := x ↦ l (x β€’ s)`-/
 def obj' : ModuleCat S :=
   ⟨(restrictScalars f).obj ⟨S⟩ β†’β‚—[R] M⟩
-#align category_theory.Module.coextend_scalars.obj' CategoryTheory.ModuleCat.CoextendScalars.obj'
+#align category_theory.Module.coextend_scalars.obj' ModuleCat.CoextendScalars.obj'
 
 instance : CoeFun (obj' f M) fun _ => S β†’ M where coe g := g.toFun
 
@@ -291,7 +359,7 @@ def map' {M M' : ModuleCat R} (g : M ⟢ M') : obj' f M ⟢ obj' f M' where
   map_add' _ _ := LinearMap.comp_add _ _ _
   map_smul' s h := LinearMap.ext fun t : S => by dsimp; rw [smul_apply',smul_apply']; simp
   -- Porting note: smul_apply' not working in simp
-#align category_theory.Module.coextend_scalars.map' CategoryTheory.ModuleCat.CoextendScalars.map'
+#align category_theory.Module.coextend_scalars.map' ModuleCat.CoextendScalars.map'
 
 end CoextendScalars
 
@@ -306,7 +374,7 @@ def coextendScalars {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] (f : R β†’
   map := CoextendScalars.map' f
   map_id _ := LinearMap.ext fun _ => LinearMap.ext fun _ => rfl
   map_comp _ _ := LinearMap.ext fun _ => LinearMap.ext fun _ => rfl
-#align category_theory.Module.coextend_scalars CategoryTheory.ModuleCat.coextendScalars
+#align category_theory.Module.coextend_scalars ModuleCat.coextendScalars
 
 namespace CoextendScalars
 
@@ -319,13 +387,13 @@ instance (M : ModuleCat R) : CoeFun ((coextendScalars f).obj M) fun _ => S β†’ M
 theorem smul_apply (M : ModuleCat R) (g : (coextendScalars f).obj M) (s s' : S) :
     (s β€’ g) s' = g (s' * s) :=
   rfl
-#align category_theory.Module.coextend_scalars.smul_apply CategoryTheory.ModuleCat.CoextendScalars.smul_apply
+#align category_theory.Module.coextend_scalars.smul_apply ModuleCat.CoextendScalars.smul_apply
 
 @[simp]
 theorem map_apply {M M' : ModuleCat R} (g : M ⟢ M') (x) (s : S) :
     (coextendScalars f).map g x s = g (x s) :=
   rfl
-#align category_theory.Module.coextend_scalars.map_apply CategoryTheory.ModuleCat.CoextendScalars.map_apply
+#align category_theory.Module.coextend_scalars.map_apply ModuleCat.CoextendScalars.map_apply
 
 end CoextendScalars
 
@@ -359,11 +427,11 @@ def HomEquiv.fromRestriction {X : ModuleCat R} {Y : ModuleCat S}
       rw [smul_add, map_add]
   map_smul' := fun (s : S) (y : Y) => LinearMap.ext fun t : S => by
       -- Porting note: used to be simp [mul_smul]
-      rw [RingHom.id_apply, LinearMap.coe_mk, CategoryTheory.ModuleCat.CoextendScalars.smul_apply',
+      rw [RingHom.id_apply, LinearMap.coe_mk, ModuleCat.CoextendScalars.smul_apply',
         LinearMap.coe_mk]
       dsimp
       rw [mul_smul]
-#align category_theory.Module.restriction_coextension_adj.hom_equiv.from_restriction CategoryTheory.ModuleCat.RestrictionCoextensionAdj.HomEquiv.fromRestriction
+#align category_theory.Module.restriction_coextension_adj.hom_equiv.from_restriction ModuleCat.RestrictionCoextensionAdj.HomEquiv.fromRestriction
 
 /-- Given `R`-module X and `S`-module Y, any `g : Y ⟢ (coextendScalars f).obj X`
 corresponds to `(restrictScalars f).obj Y ⟢ X` by `y ↦ g y 1`
@@ -381,9 +449,10 @@ def HomEquiv.toRestriction {X Y} (g : Y ⟢ (coextendScalars f).obj X) : (restri
     rw [← LinearMap.coe_toAddHom, ←AddHom.toFun_eq_coe]
     rw [CoextendScalars.smul_apply (s := f r) (g := g y) (s' := 1), one_mul]
     rw [AddHom.toFun_eq_coe, LinearMap.coe_toAddHom]
-#align category_theory.Module.restriction_coextension_adj.hom_equiv.to_restriction CategoryTheory.ModuleCat.RestrictionCoextensionAdj.HomEquiv.toRestriction
+#align category_theory.Module.restriction_coextension_adj.hom_equiv.to_restriction ModuleCat.RestrictionCoextensionAdj.HomEquiv.toRestriction
 
 -- Porting note: add to address timeout in unit'
+/-- Auxiliary definition for `unit'` -/
 def app' (Y : ModuleCat S) : Y β†’β‚—[S] (restrictScalars f β‹™ coextendScalars f).obj Y :=
   { toFun := fun y : Y =>
       { toFun := fun s : S => (s β€’ y : Y)
@@ -422,7 +491,7 @@ protected def unit' : 𝟭 (ModuleCat S) ⟢ restrictScalars f β‹™ coextendScala
         restrictScalars.map_apply f]
       change s β€’ (g y) = g (s β€’ y)
       rw [map_smul]
-#align category_theory.Module.restriction_coextension_adj.unit' CategoryTheory.ModuleCat.RestrictionCoextensionAdj.unit'
+#align category_theory.Module.restriction_coextension_adj.unit' ModuleCat.RestrictionCoextensionAdj.unit'
 
 /-- The natural transformation from the composition of coextension and restriction of scalars to
 identity functor.
@@ -445,7 +514,7 @@ protected def counit' : coextendScalars f β‹™ restrictScalars f ⟢ 𝟭 (Module
   naturality X X' g := LinearMap.ext fun h => by
     rw [ModuleCat.coe_comp]
     rfl
-#align category_theory.Module.restriction_coextension_adj.counit' CategoryTheory.ModuleCat.RestrictionCoextensionAdj.counit'
+#align category_theory.Module.restriction_coextension_adj.counit' ModuleCat.RestrictionCoextensionAdj.counit'
 
 end RestrictionCoextensionAdj
 
@@ -477,7 +546,7 @@ def restrictCoextendScalarsAdj {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S]
     rw [coe_comp, Function.comp]
     change _ = (((restrictScalars f).map g) x).toFun (1 : S)
     rw [AddHom.toFun_eq_coe, LinearMap.coe_toAddHom, restrictScalars.map_apply]
-#align category_theory.Module.restrict_coextend_scalars_adj CategoryTheory.ModuleCat.restrictCoextendScalarsAdj
+#align category_theory.Module.restrict_coextend_scalars_adj ModuleCat.restrictCoextendScalarsAdj
 
 instance {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] (f : R β†’+* S) :
     CategoryTheory.IsLeftAdjoint (restrictScalars f) :=
@@ -512,7 +581,7 @@ def HomEquiv.toRestrictScalars {X Y} (g : (extendScalars f).obj X ⟢ Y) :
     rw [RestrictScalars.smul_def, ← LinearMap.map_smul]
     erw [tmul_smul]
     congr
-#align category_theory.Module.extend_restrict_scalars_adj.hom_equiv.to_restrict_scalars CategoryTheory.ModuleCat.ExtendRestrictScalarsAdj.HomEquiv.toRestrictScalars
+#align category_theory.Module.extend_restrict_scalars_adj.hom_equiv.to_restrict_scalars ModuleCat.ExtendRestrictScalarsAdj.HomEquiv.toRestrictScalars
 
 -- Porting note: forced to break apart fromExtendScalars due to timeouts
 /--
@@ -561,7 +630,7 @@ def HomEquiv.fromExtendScalars {X Y} (g : X ⟢ (restrictScalars f).obj Y) :
       change (s * s') β€’ (g x) = s β€’ s' β€’ (g x)
       rw [mul_smul]
     Β· rw [smul_add, map_add, ih1, ih2, map_add, smul_add]
-#align category_theory.Module.extend_restrict_scalars_adj.hom_equiv.from_extend_scalars CategoryTheory.ModuleCat.ExtendRestrictScalarsAdj.HomEquiv.fromExtendScalars
+#align category_theory.Module.extend_restrict_scalars_adj.hom_equiv.from_extend_scalars ModuleCat.ExtendRestrictScalarsAdj.HomEquiv.fromExtendScalars
 
 /-- Given `R`-module X and `S`-module Y, `S`-linear linear maps `(extendScalars f).obj X ⟢ Y`
 bijectively correspond to `R`-linear maps `X ⟢ (restrictScalars f).obj Y`.
@@ -589,7 +658,7 @@ def homEquiv {X Y} :
       LinearMap.coe_mk, LinearMap.coe_mk]
     dsimp
     rw [one_smul]
-#align category_theory.Module.extend_restrict_scalars_adj.hom_equiv CategoryTheory.ModuleCat.ExtendRestrictScalarsAdj.homEquiv
+#align category_theory.Module.extend_restrict_scalars_adj.hom_equiv ModuleCat.ExtendRestrictScalarsAdj.homEquiv
 
 /--
 For any `R`-module X, there is a natural `R`-linear map from `X` to `X ⨂ S` by sending `x ↦ x βŠ— 1`
@@ -602,7 +671,7 @@ def Unit.map {X} : X ⟢ (extendScalars f β‹™ restrictScalars f).obj X where
     letI m1 : Module R S := Module.compHom S f
     -- Porting note: used to be rfl
     dsimp; rw [←TensorProduct.smul_tmul,TensorProduct.smul_tmul']
-#align category_theory.Module.extend_restrict_scalars_adj.unit.map CategoryTheory.ModuleCat.ExtendRestrictScalarsAdj.Unit.map
+#align category_theory.Module.extend_restrict_scalars_adj.unit.map ModuleCat.ExtendRestrictScalarsAdj.Unit.map
 
 /--
 The natural transformation from identity functor on `R`-module to the composition of extension and
@@ -611,7 +680,7 @@ restriction of scalars.
 @[simps]
 def unit : 𝟭 (ModuleCat R) ⟢ extendScalars f β‹™ restrictScalars.{max v uβ‚‚,u₁,uβ‚‚} f where
   app _ := Unit.map.{u₁,uβ‚‚,v} f
-#align category_theory.Module.extend_restrict_scalars_adj.unit CategoryTheory.ModuleCat.ExtendRestrictScalarsAdj.unit
+#align category_theory.Module.extend_restrict_scalars_adj.unit ModuleCat.ExtendRestrictScalarsAdj.unit
 
 /-- For any `S`-module Y, there is a natural `R`-linear map from `S ⨂ Y` to `Y` by
 `s βŠ— y ↦ s β€’ y`
@@ -648,7 +717,7 @@ def Counit.map {Y} : (restrictScalars f β‹™ extendScalars f).obj Y ⟢ Y := by
       change (s * s') β€’ y = s β€’ s' β€’ y
       rw [mul_smul]
     Β· rw [smul_add, map_add, map_add, ih1, ih2, smul_add]
-#align category_theory.Module.extend_restrict_scalars_adj.counit.map CategoryTheory.ModuleCat.ExtendRestrictScalarsAdj.Counit.map
+#align category_theory.Module.extend_restrict_scalars_adj.counit.map ModuleCat.ExtendRestrictScalarsAdj.Counit.map
 
 -- Porting note: this file has to probably be reworked when
 -- coercions and instance synthesis are fixed for concrete categories
@@ -678,7 +747,7 @@ def counit : restrictScalars.{max v uβ‚‚,u₁,uβ‚‚} f β‹™ extendScalars f ⟢ 
       rw [map_smul]
     Β· rw [map_add,map_add]
       congr 1
-#align category_theory.Module.extend_restrict_scalars_adj.counit CategoryTheory.ModuleCat.ExtendRestrictScalarsAdj.counit
+#align category_theory.Module.extend_restrict_scalars_adj.counit ModuleCat.ExtendRestrictScalarsAdj.counit
 end ExtendRestrictScalarsAdj
 
 /-- Given commutative rings `R, S` and a ring hom `f : R β†’+* S`, the extension and restriction of
@@ -707,7 +776,7 @@ def extendRestrictScalarsAdj {R : Type u₁} {S : Type uβ‚‚} [CommRing R] [CommR
         rfl
       Β· rw [map_add,map_add]
         congr 1
-#align category_theory.Module.extend_restrict_scalars_adj CategoryTheory.ModuleCat.extendRestrictScalarsAdj
+#align category_theory.Module.extend_restrict_scalars_adj ModuleCat.extendRestrictScalarsAdj
 
 instance {R : Type u₁} {S : Type uβ‚‚} [CommRing R] [CommRing S] (f : R β†’+* S) :
     CategoryTheory.IsLeftAdjoint (extendScalars f) :=
@@ -717,4 +786,4 @@ instance {R : Type u₁} {S : Type uβ‚‚} [CommRing R] [CommRing S] (f : R β†’+*
     CategoryTheory.IsRightAdjoint (restrictScalars f) :=
   ⟨_, extendRestrictScalarsAdj f⟩
 
-end CategoryTheory.ModuleCat
+end ModuleCat
chore: update/remove heart beat bumps (#6860)

We clean up heart beat bumps after #6474.

Diff
@@ -334,7 +334,7 @@ namespace RestrictionCoextensionAdj
 variable {R : Type u₁} {S : Type uβ‚‚} [Ring R] [Ring S] (f : R β†’+* S)
 
 -- Porting note: too much time
-set_option maxHeartbeats 600000 in
+set_option maxHeartbeats 500000 in
 /-- Given `R`-module X and `S`-module Y, any `g : (restrictScalars f).obj Y ⟢ X`
 corresponds to `Y ⟢ (coextendScalars f).obj X` by sending `y ↦ (s ↦ g (s β€’ y))`
 -/
chore: tidy various files (#6838)
Diff
@@ -14,17 +14,18 @@ import Mathlib.RingTheory.TensorProduct
 ## Main definitions
 
 * `CategoryTheory.ModuleCat.restrictScalars`: given rings `R, S` and a ring homomorphism `R ⟢ S`,
-  then `restrictScalars : Module S β₯€ Module R` is defined by `M ↦ M` where `M : S-module` is seen
-  as `R-module` by `r β€’ m := f r β€’ m` and `S`-linear map `l : M ⟢ M'` is `R`-linear as well.
+  then `restrictScalars : ModuleCat S β₯€ ModuleCat R` is defined by `M ↦ M` where an `S`-module `M`
+  is seen as an `R`-module by `r β€’ m := f r β€’ m` and `S`-linear map `l : M ⟢ M'` is `R`-linear as
+  well.
 
 * `CategoryTheory.ModuleCat.extendScalars`: given **commutative** rings `R, S` and ring homomorphism
-  `f : R ⟢ S`, then `extendScalars : Module R β₯€ Module S` is defined by `M ↦ S ⨂ M` where the
+  `f : R ⟢ S`, then `extendScalars : ModuleCat R β₯€ ModuleCat S` is defined by `M ↦ S ⨂ M` where the
   module structure is defined by `s β€’ (s' βŠ— m) := (s * s') βŠ— m` and `R`-linear map `l : M ⟢ M'`
   is sent to `S`-linear map `s βŠ— m ↦ s βŠ— l m : S ⨂ M ⟢ S ⨂ M'`.
 
 * `CategoryTheory.ModuleCat.coextendScalars`: given rings `R, S` and a ring homomorphism `R ⟢ S`
-  then `coextendScalars : Module R β₯€ Module S` is defined by `M ↦ (S β†’β‚—[R] M)` where `S` is seen as
-  `R-module` by restriction of scalars and `l ↦ l ∘ _`.
+  then `coextendScalars : ModuleCat R β₯€ ModuleCat S` is defined by `M ↦ (S β†’β‚—[R] M)` where `S` is
+  seen as an `R`-module by restriction of scalars and `l ↦ l ∘ _`.
 
 ## Main results
 
@@ -530,7 +531,7 @@ def HomEquiv.evalAt {X : ModuleCat R} {Y : ModuleCat S} (s : S)
         LinearMap.map_smul, smul_comm r s (g x : Y)] )
 
 /--
-Given `R`-module X and `S`-module Y and a map `X ⟢ (restrict_scalars f).obj Y`, i.e `R`-linear map
+Given `R`-module X and `S`-module Y and a map `X ⟢ (restrictScalars f).obj Y`, i.e `R`-linear map
 `X ⟢ Y`, there is a map `(extend_scalars f).obj X ⟢ Y`, i.e `S`-linear map `S ⨂ X β†’ Y` by
 `s βŠ— x ↦ s β€’ g x`.
 -/
chore: remove unused simps (#6632)

Co-authored-by: Eric Wieser <wieser.eric@gmail.com>

Diff
@@ -544,7 +544,6 @@ def HomEquiv.fromExtendScalars {X Y} (g : X ⟢ (restrictScalars f).obj Y) :
       map_smul' := fun (r : R) (s : S) => ?_}
     Β· ext
       dsimp
-      simp only [LinearMap.coe_mk, LinearMap.add_apply]
       rw [← add_smul]
     Β· ext x
       apply mul_smul (f r) s (g x)
chore: script to replace headers with #align_import statements (#5979)

Open in Gitpod

Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -2,15 +2,12 @@
 Copyright (c) 2022 Jujian Zhang. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Jujian Zhang
-
-! This file was ported from Lean 3 source module algebra.category.Module.change_of_rings
-! leanprover-community/mathlib commit 56b71f0b55c03f70332b862e65c3aa1aa1249ca1
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathlib.Algebra.Category.ModuleCat.Basic
 import Mathlib.RingTheory.TensorProduct
 
+#align_import algebra.category.Module.change_of_rings from "leanprover-community/mathlib"@"56b71f0b55c03f70332b862e65c3aa1aa1249ca1"
+
 /-!
 # Change Of Rings
 
chore: cleanup whitespace (#5988)

Grepping for [^ .:{-] [^ :] and reviewing the results. Once I started I couldn't stop. :-)

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -386,7 +386,7 @@ def HomEquiv.toRestriction {X Y} (g : Y ⟢ (coextendScalars f).obj X) : (restri
 #align category_theory.Module.restriction_coextension_adj.hom_equiv.to_restriction CategoryTheory.ModuleCat.RestrictionCoextensionAdj.HomEquiv.toRestriction
 
 -- Porting note: add to address timeout in unit'
-def app' (Y : ModuleCat S) : Y β†’β‚—[S] (restrictScalars f β‹™  coextendScalars f).obj Y :=
+def app' (Y : ModuleCat S) : Y β†’β‚—[S] (restrictScalars f β‹™ coextendScalars f).obj Y :=
   { toFun := fun y : Y =>
       { toFun := fun s : S => (s β€’ y : Y)
         map_add' := fun s s' => add_smul _ _ _
@@ -522,7 +522,7 @@ The map `S β†’ X β†’β‚—[R] Y` given by `fun s x => s β€’ (g x)`
 -/
 @[simps]
 def HomEquiv.evalAt {X : ModuleCat R} {Y : ModuleCat S} (s : S)
-    (g : X ⟢  (restrictScalars f).obj Y) : have : Module R Y := Module.compHom Y f
+    (g : X ⟢ (restrictScalars f).obj Y) : have : Module R Y := Module.compHom Y f
     X β†’β‚—[R] Y :=
   @LinearMap.mk _ _ _ _ (RingHom.id R) X Y _ _ _ (_)
     { toFun := fun x => s β€’ (g x : Y)
@@ -534,7 +534,7 @@ def HomEquiv.evalAt {X : ModuleCat R} {Y : ModuleCat S} (s : S)
 
 /--
 Given `R`-module X and `S`-module Y and a map `X ⟢ (restrict_scalars f).obj Y`, i.e `R`-linear map
-`X ⟢ Y`, there is a map `(extend_scalars f).obj X ⟢ Y`, i.e  `S`-linear map `S ⨂ X β†’ Y` by
+`X ⟢ Y`, there is a map `(extend_scalars f).obj X ⟢ Y`, i.e `S`-linear map `S ⨂ X β†’ Y` by
 `s βŠ— x ↦ s β€’ g x`.
 -/
 @[simps apply]
@@ -721,4 +721,3 @@ instance {R : Type u₁} {S : Type uβ‚‚} [CommRing R] [CommRing S] (f : R β†’+*
   ⟨_, extendRestrictScalarsAdj f⟩
 
 end CategoryTheory.ModuleCat
-
feat: port Algebra.Category.Module.ChangeOfRings (#4300)

Co-authored-by: Calvin Lee <calvins.lee@utah.edu> Co-authored-by: Jeremy Tan Jie Rui <reddeloostw@gmail.com>

Dependencies 10 + 613

614 files ported (98.4%)
246971 lines ported (98.6%)
Show graph

The unported dependencies are