l3lab/ntp-mathlib huggingface dataset:
/-- The unbundled `directLimit` of modules is a colimit
in the sense of `CategoryTheory`. -/
@[simps]
def directLimitIsColimit [IsDirected ι (· ≤ ·)] : IsColimit (directLimitCocone G f)
    where
  desc s :=
    DirectLimit.lift R ι G f s.ι.app fun i j h x => by
      rw [← s.w (homOfLE h)]
      rfl
  fac s i := by
    apply LinearMap.ext
    intro x
    dsimp only [directLimitCocone, CategoryStruct.comp]
    

Proof state:
case h
R : Type u
inst✝⁷ : Ring R
J : Type v
inst✝⁶ : SmallCategory J
ι : Type v
dec_ι : DecidableEq ι
inst✝⁵ : Preorder ι
G : ι → Type v
inst✝⁴ : (i : ι) → AddCommGroup (G i)
inst✝³ : (i : ι) → Module R (G i)
f : (i j : ι) → i ≤ j → G i →ₗ[R] G j
inst✝² : DirectedSystem G fun i j h => ⇑(f i j h)
inst✝¹ : DecidableEq ι
inst✝ : IsDirected ι fun x x_1 => x ≤ x_1
s : Cocone (directLimitDiagram G f)
i : ι
x : ↑((directLimitDiagram G f).obj i)
⊢ (LinearMap.comp
        (DirectLimit.lift R ι G f s.ι.app
          (_ : ∀ (i j : ι) (h : i ≤ j) (x : G i), (s.ι.app j) ((f i j h) x) = (s.ι.app i) x))
        (DirectLimit.of R ι G f i))
      x =
    (s.ι.app i) x

Next tactic:
rw [LinearMap.comp_apply]
/-- The unbundled `directLimit` of modules is a colimit
in the sense of `CategoryTheory`. -/
@[simps]
def directLimitIsColimit [IsDirected ι (· ≤ ·)] : IsColimit (directLimitCocone G f)
    where
  desc s :=
    DirectLimit.lift R ι G f s.ι.app fun i j h x => by
      rw [← s.w (homOfLE h)]
      rfl
  fac s i := by
    apply LinearMap.ext
    intro x
    dsimp only [directLimitCocone, CategoryStruct.comp]
    rw [LinearMap.comp_apply]
    

Proof state:
case h
R : Type u
inst✝⁷ : Ring R
J : Type v
inst✝⁶ : SmallCategory J
ι : Type v
dec_ι : DecidableEq ι
inst✝⁵ : Preorder ι
G : ι → Type v
inst✝⁴ : (i : ι) → AddCommGroup (G i)
inst✝³ : (i : ι) → Module R (G i)
f : (i j : ι) → i ≤ j → G i →ₗ[R] G j
inst✝² : DirectedSystem G fun i j h => ⇑(f i j h)
inst✝¹ : DecidableEq ι
inst✝ : IsDirected ι fun x x_1 => x ≤ x_1
s : Cocone (directLimitDiagram G f)
i : ι
x : ↑((directLimitDiagram G f).obj i)
⊢ (DirectLimit.lift R ι G f s.ι.app (_ : ∀ (i j : ι) (h : i ≤ j) (x : G i), (s.ι.app j) ((f i j h) x) = (s.ι.app i) x))
      ((DirectLimit.of R ι G f i) x) =
    (s.ι.app i) x

Next tactic:
apply DirectLimit.lift_of
/-- The unbundled `directLimit` of modules is a colimit
in the sense of `CategoryTheory`. -/
@[simps]
def directLimitIsColimit [IsDirected ι (· ≤ ·)] : IsColimit (directLimitCocone G f)
    where
  desc s :=
    DirectLimit.lift R ι G f s.ι.app fun i j h x => by
      rw [← s.w (homOfLE h)]
      rfl
  fac s i := by
    apply LinearMap.ext
    intro x
    dsimp only [directLimitCocone, CategoryStruct.comp]
    rw [LinearMap.comp_apply]
    apply DirectLimit.lift_of
  uniq s m h := by
    

Proof state:
R : Type u
inst✝⁷ : Ring R
J : Type v
inst✝⁶ : SmallCategory J
ι : Type v
dec_ι : DecidableEq ι
inst✝⁵ : Preorder ι
G : ι → Type v
inst✝⁴ : (i : ι) → AddCommGroup (G i)
inst✝³ : (i : ι) → Module R (G i)
f : (i j : ι) → i ≤ j → G i →ₗ[R] G j
inst✝² : DirectedSystem G fun i j h => ⇑(f i j h)
inst✝¹ : DecidableEq ι
inst✝ : IsDirected ι fun x x_1 => x ≤ x_1
s : Cocone (directLimitDiagram G f)
m : (directLimitCocone G f).pt ⟶ s.pt
h : ∀ (j : ι), (directLimitCocone G f).ι.app j ≫ m = s.ι.app j
⊢ m =
    (fun s =>
        DirectLimit.lift R ι G f s.ι.app
          (_ : ∀ (i j : ι) (h : i ≤ j) (x : G i), (s.ι.app j) ((f i j h) x) = (s.ι.app i) x))
      s

Next tactic:
have :
      s.ι.app = fun i =>
        LinearMap.comp m (DirectLimit.of R ι (fun i => G i) (fun i j H => f i j H) i) := by
      funext i
      rw [← h]
      rfl
/-- The unbundled `directLimit` of modules is a colimit
in the sense of `CategoryTheory`. -/
@[simps]
def directLimitIsColimit [IsDirected ι (· ≤ ·)] : IsColimit (directLimitCocone G f)
    where
  desc s :=
    DirectLimit.lift R ι G f s.ι.app fun i j h x => by
      rw [← s.w (homOfLE h)]
      rfl
  fac s i := by
    apply LinearMap.ext
    intro x
    dsimp only [directLimitCocone, CategoryStruct.comp]
    rw [LinearMap.comp_apply]
    apply DirectLimit.lift_of
  uniq s m h := by
    have :
      s.ι.app = fun i =>
        LinearMap.comp m (DirectLimit.of R ι (fun i => G i) (fun i j H => f i j H) i) := by
      

Proof state:
R : Type u
inst✝⁷ : Ring R
J : Type v
inst✝⁶ : SmallCategory J
ι : Type v
dec_ι : DecidableEq ι
inst✝⁵ : Preorder ι
G : ι → Type v
inst✝⁴ : (i : ι) → AddCommGroup (G i)
inst✝³ : (i : ι) → Module R (G i)
f : (i j : ι) → i ≤ j → G i →ₗ[R] G j
inst✝² : DirectedSystem G fun i j h => ⇑(f i j h)
inst✝¹ : DecidableEq ι
inst✝ : IsDirected ι fun x x_1 => x ≤ x_1
s : Cocone (directLimitDiagram G f)
m : (directLimitCocone G f).pt ⟶ s.pt
h : ∀ (j : ι), (directLimitCocone G f).ι.app j ≫ m = s.ι.app j
⊢ s.ι.app = fun i => m ∘ₗ DirectLimit.of R ι (fun i => G i) (fun i j H => f i j H) i

Next tactic:
funext i
/-- The unbundled `directLimit` of modules is a colimit
in the sense of `CategoryTheory`. -/
@[simps]
def directLimitIsColimit [IsDirected ι (· ≤ ·)] : IsColimit (directLimitCocone G f)
    where
  desc s :=
    DirectLimit.lift R ι G f s.ι.app fun i j h x => by
      rw [← s.w (homOfLE h)]
      rfl
  fac s i := by
    apply LinearMap.ext
    intro x
    dsimp only [directLimitCocone, CategoryStruct.comp]
    rw [LinearMap.comp_apply]
    apply DirectLimit.lift_of
  uniq s m h := by
    have :
      s.ι.app = fun i =>
        LinearMap.comp m (DirectLimit.of R ι (fun i => G i) (fun i j H => f i j H) i) := by
      funext i
      

Proof state:
case h
R : Type u
inst✝⁷ : Ring R
J : Type v
inst✝⁶ : SmallCategory J
ι : Type v
dec_ι : DecidableEq ι
inst✝⁵ : Preorder ι
G : ι → Type v
inst✝⁴ : (i : ι) → AddCommGroup (G i)
inst✝³ : (i : ι) → Module R (G i)
f : (i j : ι) → i ≤ j → G i →ₗ[R] G j
inst✝² : DirectedSystem G fun i j h => ⇑(f i j h)
inst✝¹ : DecidableEq ι
inst✝ : IsDirected ι fun x x_1 => x ≤ x_1
s : Cocone (directLimitDiagram G f)
m : (directLimitCocone G f).pt ⟶ s.pt
h : ∀ (j : ι), (directLimitCocone G f).ι.app j ≫ m = s.ι.app j
i : ι
⊢ s.ι.app i = m ∘ₗ DirectLimit.of R ι (fun i => G i) (fun i j H => f i j H) i

Next tactic:
rw [← h]
/-- The unbundled `directLimit` of modules is a colimit
in the sense of `CategoryTheory`. -/
@[simps]
def directLimitIsColimit [IsDirected ι (· ≤ ·)] : IsColimit (directLimitCocone G f)
    where
  desc s :=
    DirectLimit.lift R ι G f s.ι.app fun i j h x => by
      rw [← s.w (homOfLE h)]
      rfl
  fac s i := by
    apply LinearMap.ext
    intro x
    dsimp only [directLimitCocone, CategoryStruct.comp]
    rw [LinearMap.comp_apply]
    apply DirectLimit.lift_of
  uniq s m h := by
    have :
      s.ι.app = fun i =>
        LinearMap.comp m (DirectLimit.of R ι (fun i => G i) (fun i j H => f i j H) i) := by
      funext i
      rw [← h]
      

Proof state:
case h
R : Type u
inst✝⁷ : Ring R
J : Type v
inst✝⁶ : SmallCategory J
ι : Type v
dec_ι : DecidableEq ι
inst✝⁵ : Preorder ι
G : ι → Type v
inst✝⁴ : (i : ι) → AddCommGroup (G i)
inst✝³ : (i : ι) → Module R (G i)
f : (i j : ι) → i ≤ j → G i →ₗ[R] G j
inst✝² : DirectedSystem G fun i j h => ⇑(f i j h)
inst✝¹ : DecidableEq ι
inst✝ : IsDirected ι fun x x_1 => x ≤ x_1
s : Cocone (directLimitDiagram G f)
m : (directLimitCocone G f).pt ⟶ s.pt
h : ∀ (j : ι), (directLimitCocone G f).ι.app j ≫ m = s.ι.app j
i : ι
⊢ (directLimitCocone G f).ι.app i ≫ m = m ∘ₗ DirectLimit.of R ι (fun i => G i) (fun i j H => f i j H) i

Next tactic:
rfl
/-- The unbundled `directLimit` of modules is a colimit
in the sense of `CategoryTheory`. -/
@[simps]
def directLimitIsColimit [IsDirected ι (· ≤ ·)] : IsColimit (directLimitCocone G f)
    where
  desc s :=
    DirectLimit.lift R ι G f s.ι.app fun i j h x => by
      rw [← s.w (homOfLE h)]
      rfl
  fac s i := by
    apply LinearMap.ext
    intro x
    dsimp only [directLimitCocone, CategoryStruct.comp]
    rw [LinearMap.comp_apply]
    apply DirectLimit.lift_of
  uniq s m h := by
    have :
      s.ι.app = fun i =>
        LinearMap.comp m (DirectLimit.of R ι (fun i => G i) (fun i j H => f i j H) i) := by
      funext i
      rw [← h]
      rfl
    

Proof state:
R : Type u
inst✝⁷ : Ring R
J : Type v
inst✝⁶ : SmallCategory J
ι : Type v
dec_ι : DecidableEq ι
inst✝⁵ : Preorder ι
G : ι → Type v
inst✝⁴ : (i : ι) → AddCommGroup (G i)
inst✝³ : (i : ι) → Module R (G i)
f : (i j : ι) → i ≤ j → G i →ₗ[R] G j
inst✝² : DirectedSystem G fun i j h => ⇑(f i j h)
inst✝¹ : DecidableEq ι
inst✝ : IsDirected ι fun x x_1 => x ≤ x_1
s : Cocone (directLimitDiagram G f)
m : (directLimitCocone G f).pt ⟶ s.pt
h : ∀ (j : ι), (directLimitCocone G f).ι.app j ≫ m = s.ι.app j
this : s.ι.app = fun i => m ∘ₗ DirectLimit.of R ι (fun i => G i) (fun i j H => f i j H) i
⊢ m =
    (fun s =>
        DirectLimit.lift R ι G f s.ι.app
          (_ : ∀ (i j : ι) (h : i ≤ j) (x : G i), (s.ι.app j) ((f i j h) x) = (s.ι.app i) x))
      s

Next tactic:
apply LinearMap.ext
/-- The unbundled `directLimit` of modules is a colimit
in the sense of `CategoryTheory`. -/
@[simps]
def directLimitIsColimit [IsDirected ι (· ≤ ·)] : IsColimit (directLimitCocone G f)
    where
  desc s :=
    DirectLimit.lift R ι G f s.ι.app fun i j h x => by
      rw [← s.w (homOfLE h)]
      rfl
  fac s i := by
    apply LinearMap.ext
    intro x
    dsimp only [directLimitCocone, CategoryStruct.comp]
    rw [LinearMap.comp_apply]
    apply DirectLimit.lift_of
  uniq s m h := by
    have :
      s.ι.app = fun i =>
        LinearMap.comp m (DirectLimit.of R ι (fun i => G i) (fun i j H => f i j H) i) := by
      funext i
      rw [← h]
      rfl
    apply LinearMap.ext
    

Proof state:
case h
R : Type u
inst✝⁷ : Ring R
J : Type v
inst✝⁶ : SmallCategory J
ι : Type v
dec_ι : DecidableEq ι
inst✝⁵ : Preorder ι
G : ι → Type v
inst✝⁴ : (i : ι) → AddCommGroup (G i)
inst✝³ : (i : ι) → Module R (G i)
f : (i j : ι) → i ≤ j → G i →ₗ[R] G j
inst✝² : DirectedSystem G fun i j h => ⇑(f i j h)
inst✝¹ : DecidableEq ι
inst✝ : IsDirected ι fun x x_1 => x ≤ x_1
s : Cocone (directLimitDiagram G f)
m : (directLimitCocone G f).pt ⟶ s.pt
h : ∀ (j : ι), (directLimitCocone G f).ι.app j ≫ m = s.ι.app j
this : s.ι.app = fun i => m ∘ₗ DirectLimit.of R ι (fun i => G i) (fun i j H => f i j H) i
⊢ ∀ (x : ↑(directLimitCocone G f).pt),
    m x =
      ((fun s =>
            DirectLimit.lift R ι G f s.ι.app
              (_ : ∀ (i j : ι) (h : i ≤ j) (x : G i), (s.ι.app j) ((f i j h) x) = (s.ι.app i) x))
          s)
        x

Next tactic:
intro x
/-- The unbundled `directLimit` of modules is a colimit
in the sense of `CategoryTheory`. -/
@[simps]
def directLimitIsColimit [IsDirected ι (· ≤ ·)] : IsColimit (directLimitCocone G f)
    where
  desc s :=
    DirectLimit.lift R ι G f s.ι.app fun i j h x => by
      rw [← s.w (homOfLE h)]
      rfl
  fac s i := by
    apply LinearMap.ext
    intro x
    dsimp only [directLimitCocone, CategoryStruct.comp]
    rw [LinearMap.comp_apply]
    apply DirectLimit.lift_of
  uniq s m h := by
    have :
      s.ι.app = fun i =>
        LinearMap.comp m (DirectLimit.of R ι (fun i => G i) (fun i j H => f i j H) i) := by
      funext i
      rw [← h]
      rfl
    apply LinearMap.ext
    intro x
    

Proof state:
case h
R : Type u
inst✝⁷ : Ring R
J : Type v
inst✝⁶ : SmallCategory J
ι : Type v
dec_ι : DecidableEq ι
inst✝⁵ : Preorder ι
G : ι → Type v
inst✝⁴ : (i : ι) → AddCommGroup (G i)
inst✝³ : (i : ι) → Module R (G i)
f : (i j : ι) → i ≤ j → G i →ₗ[R] G j
inst✝² : DirectedSystem G fun i j h => ⇑(f i j h)
inst✝¹ : DecidableEq ι
inst✝ : IsDirected ι fun x x_1 => x ≤ x_1
s : Cocone (directLimitDiagram G f)
m : (directLimitCocone G f).pt ⟶ s.pt
h : ∀ (j : ι), (directLimitCocone G f).ι.app j ≫ m = s.ι.app j
this : s.ι.app = fun i => m ∘ₗ DirectLimit.of R ι (fun i => G i) (fun i j H => f i j H) i
x : ↑(directLimitCocone G f).pt
⊢ m x =
    ((fun s =>
          DirectLimit.lift R ι G f s.ι.app
            (_ : ∀ (i j : ι) (h : i ≤ j) (x : G i), (s.ι.app j) ((f i j h) x) = (s.ι.app i) x))
        s)
      x

Next tactic:
simp only [this]
/-- The unbundled `directLimit` of modules is a colimit
in the sense of `CategoryTheory`. -/
@[simps]
def directLimitIsColimit [IsDirected ι (· ≤ ·)] : IsColimit (directLimitCocone G f)
    where
  desc s :=
    DirectLimit.lift R ι G f s.ι.app fun i j h x => by
      rw [← s.w (homOfLE h)]
      rfl
  fac s i := by
    apply LinearMap.ext
    intro x
    dsimp only [directLimitCocone, CategoryStruct.comp]
    rw [LinearMap.comp_apply]
    apply DirectLimit.lift_of
  uniq s m h := by
    have :
      s.ι.app = fun i =>
        LinearMap.comp m (DirectLimit.of R ι (fun i => G i) (fun i j H => f i j H) i) := by
      funext i
      rw [← h]
      rfl
    apply LinearMap.ext
    intro x
    simp only [this]
    

Proof state:
case h
R : Type u
inst✝⁷ : Ring R
J : Type v
inst✝⁶ : SmallCategory J
ι : Type v
dec_ι : DecidableEq ι
inst✝⁵ : Preorder ι
G : ι → Type v
inst✝⁴ : (i : ι) → AddCommGroup (G i)
inst✝³ : (i : ι) → Module R (G i)
f : (i j : ι) → i ≤ j → G i →ₗ[R] G j
inst✝² : DirectedSystem G fun i j h => ⇑(f i j h)
inst✝¹ : DecidableEq ι
inst✝ : IsDirected ι fun x x_1 => x ≤ x_1
s : Cocone (directLimitDiagram G f)
m : (directLimitCocone G f).pt ⟶ s.pt
h : ∀ (j : ι), (directLimitCocone G f).ι.app j ≫ m = s.ι.app j
this : s.ι.app = fun i => m ∘ₗ DirectLimit.of R ι (fun i => G i) (fun i j H => f i j H) i
x : ↑(directLimitCocone G f).pt
⊢ m x =
    (DirectLimit.lift R ι G f (fun i => m ∘ₗ DirectLimit.of R ι (fun i => G i) (fun i j H => f i j H) i)
        (_ :
          ∀ (i j : ι) (hij : i ≤ j) (x : G i),
            ((fun i => m ∘ₗ DirectLimit.of R ι (fun i => G i) (fun i j H => f i j H) i) j) ((f i j hij) x) =
              ((fun i => m ∘ₗ DirectLimit.of R ι (fun i => G i) (fun i j H => f i j H) i) i) x))
      x

Next tactic:
apply Module.DirectLimit.lift_unique
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 

Proof state:
R : Type u₁
S : Type u₂
inst✝¹ : Ring R
inst✝ : Ring S
f : R →+* S
X✝ Y✝ : ModuleCat S
a₁✝ a₂✝ : X✝ ⟶ Y✝
h : (restrictScalars f).map a₁✝ = (restrictScalars f).map a₂✝
x : ↑X✝
⊢ a₁✝ x = a₂✝ x

Next tactic:
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 

Proof state:
R : Type u₁
S : Type u₂
inst✝¹ : Ring R
inst✝ : Ring S
f : R →+* S
X✝ Y✝ : ModuleCat S
x✝ : X✝ ⟶ Y✝
h : Mono x✝
⊢ Mono ((restrictScalars f).map x✝)

Next tactic:
rwa [mono_iff_injective] at h ⊢
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] :
    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 

Proof state:
R : Type u₁
S : Type u₂
inst✝² : Ring R
inst✝¹ : CommRing S
f : R →+* S
M : Type v
I : AddCommGroup M
inst✝ : Module S M
r : R
s : S
m : M
⊢ f r • s • m = s • f r • m

Next tactic:
simp [← mul_smul, mul_comm]
/-- 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 

Proof state:
R : Type u₁
S : Type u₂
inst✝¹ : Ring R
inst✝ : Ring S
f : R →+* S
M : ModuleCat R
N : ModuleCat S
g : ↑M →ₛₗ[f] ↑N
⊢ ∀ (x y : ↑M), g (x + y) = g x + g y

Next tactic:
simp
/-- 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 

Proof state:
R : Type u₁
S : Type u₂
inst✝¹ : Ring R
inst✝ : Ring S
f : R →+* S
M : ModuleCat R
N : ModuleCat S
g : ↑M →ₛₗ[f] ↑N
⊢ ∀ (r : R) (x : ↑M),
    AddHom.toFun { toFun := ⇑g, map_add' := (_ : ∀ (a a_1 : ↑M), g (a + a_1) = g a + g a_1) } (r • x) =
      (RingHom.id R) r • AddHom.toFun { toFun := ⇑g, map_add' := (_ : ∀ (a a_1 : ↑M), g (a + a_1) = g a + g a_1) } x

Next tactic:
simp
/-- 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 

Proof state:
R : Type u₁
S : Type u₂
inst✝¹ : Ring R
inst✝ : Ring S
f : R →+* S
M : ModuleCat R
N : ModuleCat S
g : M ⟶ (restrictScalars f).obj N
⊢ ∀ (x y : ↑M), g (x + y) = g x + g y

Next tactic:
simp
/-- The restriction of scalars by a ring morphism that is the identity identify to the
identity functor. -/
def restrictScalarsId' : ModuleCat.restrictScalars.{v} f ≅ 𝟭 _ := by 

Proof state:
R : Type u₁
inst✝ : Ring R
f : R →+* R
hf : f = RingHom.id R
⊢ restrictScalars f ≅ 𝟭 (ModuleCat R)

Next tactic:
subst hf
/-- 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; 

Proof state:
R : Type u₁
inst✝ : Ring R
⊢ restrictScalars (RingHom.id R) ≅ 𝟭 (ModuleCat R)

Next tactic:
rfl
@[simp, nolint simpNF]
lemma restrictScalarsId'_inv_apply (M : ModuleCat R) (x : M) :
    (restrictScalarsId' f hf).inv.app M x = x := by 

Proof state:
R : Type u₁
inst✝ : Ring R
f : R →+* R
hf : f = RingHom.id R
M : ModuleCat R
x : ↑M
⊢ ((restrictScalarsId' f hf).inv.app M) x = x

Next tactic:
subst hf
@[simp, nolint simpNF]
lemma restrictScalarsId'_inv_apply (M : ModuleCat R) (x : M) :
    (restrictScalarsId' f hf).inv.app M x = x := by subst hf; 

Proof state:
R : Type u₁
inst✝ : Ring R
M : ModuleCat R
x : ↑M
⊢ ((restrictScalarsId' (RingHom.id R) (_ : RingHom.id R = RingHom.id R)).inv.app M) x = x

Next tactic:
rfl
@[simp, nolint simpNF]
lemma restrictScalarsId'_hom_apply (M : ModuleCat R) (x : M) :
    (restrictScalarsId' f hf).hom.app M x = x := by 

Proof state:
R : Type u₁
inst✝ : Ring R
f : R →+* R
hf : f = RingHom.id R
M : ModuleCat R
x : ↑M
⊢ ((restrictScalarsId' f hf).hom.app M) x = x

Next tactic:
subst hf
@[simp, nolint simpNF]
lemma restrictScalarsId'_hom_apply (M : ModuleCat R) (x : M) :
    (restrictScalarsId' f hf).hom.app M x = x := by subst hf; 

Proof state:
R : Type u₁
inst✝ : Ring R
M : ModuleCat R
x : ↑M
⊢ ((restrictScalarsId' (RingHom.id R) (_ : RingHom.id R = RingHom.id R)).hom.app M) x = x

Next tactic:
rfl
/-- 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 

Proof state:
R₁ : Type u₁
R₂ : Type u₂
R₃ : Type u₃
inst✝² : Ring R₁
inst✝¹ : Ring R₂
inst✝ : Ring R₃
f : R₁ →+* R₂
g : R₂ →+* R₃
gf : R₁ →+* R₃
hgf : gf = RingHom.comp g f
⊢ restrictScalars gf ≅ restrictScalars g ⋙ restrictScalars f

Next tactic:
subst hgf
/-- 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; 

Proof state:
R₁ : Type u₁
R₂ : Type u₂
R₃ : Type u₃
inst✝² : Ring R₁
inst✝¹ : Ring R₂
inst✝ : Ring R₃
f : R₁ →+* R₂
g : R₂ →+* R₃
⊢ restrictScalars (RingHom.comp g f) ≅ restrictScalars g ⋙ restrictScalars f

Next tactic:
rfl
@[simp, nolint simpNF]
lemma restrictScalarsComp'_hom_apply (M : ModuleCat R₃) (x : M) :
    (restrictScalarsComp' f g gf hgf).hom.app M x = x := by 

Proof state:
R₁ : Type u₁
R₂ : Type u₂
R₃ : Type u₃
inst✝² : Ring R₁
inst✝¹ : Ring R₂
inst✝ : Ring R₃
f : R₁ →+* R₂
g : R₂ →+* R₃
gf : R₁ →+* R₃
hgf : gf = RingHom.comp g f
M : ModuleCat R₃
x : ↑M
⊢ ((restrictScalarsComp' f g gf hgf).hom.app M) x = x

Next tactic:
subst hgf
@[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; 

Proof state:
R₁ : Type u₁
R₂ : Type u₂
R₃ : Type u₃
inst✝² : Ring R₁
inst✝¹ : Ring R₂
inst✝ : Ring R₃
f : R₁ →+* R₂
g : R₂ →+* R₃
M : ModuleCat R₃
x : ↑M
⊢ ((restrictScalarsComp' f g (RingHom.comp g f) (_ : RingHom.comp g f = RingHom.comp g f)).hom.app M) x = x

Next tactic:
rfl
@[simp, nolint simpNF]
lemma restrictScalarsComp'_inv_apply (M : ModuleCat R₃) (x : M) :
    (restrictScalarsComp' f g gf hgf).inv.app M x = x := by 

Proof state:
R₁ : Type u₁
R₂ : Type u₂
R₃ : Type u₃
inst✝² : Ring R₁
inst✝¹ : Ring R₂
inst✝ : Ring R₃
f : R₁ →+* R₂
g : R₂ →+* R₃
gf : R₁ →+* R₃
hgf : gf = RingHom.comp g f
M : ModuleCat R₃
x : ↑M
⊢ ((restrictScalarsComp' f g gf hgf).inv.app M) x = x

Next tactic:
subst hgf
@[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; 

Proof state:
R₁ : Type u₁
R₂ : Type u₂
R₃ : Type u₃
inst✝² : Ring R₁
inst✝¹ : Ring R₂
inst✝ : Ring R₃
f : R₁ →+* R₂
g : R₂ →+* R₃
M : ModuleCat R₃
x : ↑M
⊢ ((restrictScalarsComp' f g (RingHom.comp g f) (_ : RingHom.comp g f = RingHom.comp g f)).inv.app M) x = x

Next tactic:
rfl
/-- 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).
  

Proof state:
R : Type u₁
S : Type u₂
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
M M1 M2 : ModuleCat R
l : M1 ⟶ M2
⊢ obj' f M1 ⟶ obj' f M2

Next tactic:
apply @LinearMap.baseChange R S M1 M2 _ _ ((algebraMap S _).comp f).toAlgebra _ _ _ _ l
theorem map'_id {M : ModuleCat.{v} R} : map' f (𝟙 M) = 𝟙 _ :=
  LinearMap.ext fun x : obj' f M => by
    

Proof state:
R : Type u₁
S : Type u₂
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
M✝ M : ModuleCat R
x : ↑(obj' f M)
⊢ (map' f (𝟙 M)) x = (𝟙 (obj' f M)) x

Next tactic:
dsimp only [map']
theorem map'_id {M : ModuleCat.{v} R} : map' f (𝟙 M) = 𝟙 _ :=
  LinearMap.ext fun x : obj' f M => by
    dsimp only [map']
    -- Porting note: this got put in the dsimp by mathport
    

Proof state:
R : Type u₁
S : Type u₂
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
M✝ M : ModuleCat R
x : ↑(obj' f M)
⊢ (LinearMap.baseChange S (𝟙 M)) x = (𝟙 (obj' f M)) x

Next tactic:
rw [ModuleCat.id_apply]
theorem map'_id {M : ModuleCat.{v} R} : map' f (𝟙 M) = 𝟙 _ :=
  LinearMap.ext fun x : obj' f M => by
    dsimp only [map']
    -- Porting note: this got put in the dsimp by mathport
    rw [ModuleCat.id_apply]
    

Proof state:
R : Type u₁
S : Type u₂
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
M✝ M : ModuleCat R
x : ↑(obj' f M)
⊢ (LinearMap.baseChange S (𝟙 M)) x = x

Next tactic:
induction' x using TensorProduct.induction_on with _ _ m s ihx ihy
theorem map'_id {M : ModuleCat.{v} R} : map' f (𝟙 M) = 𝟙 _ :=
  LinearMap.ext fun x : obj' f M => by
    dsimp only [map']
    -- Porting note: this got put in the dsimp by mathport
    rw [ModuleCat.id_apply]
    induction' x using TensorProduct.induction_on with _ _ m s ihx ihy
    · 

Proof state:
case zero
R : Type u₁
S : Type u₂
inst✝¹ : CommRing R
inst✝ : CommRing S
f : R →+* S
M✝ M : ModuleCat R
⊢ (LinearMap.baseChange S (𝟙 M)) 0 = 0

Next tactic:
rw [map_zero]