l3lab/ntp-mathlib huggingface dataset:
@[to_additive]
instance [LinearOrderedCancelCommMonoid α] {s : Submonoid α} :
    LinearOrderedCancelCommMonoid (Localization s) :=
  { Localization.orderedCancelCommMonoid with
    le_total := fun a b =>
      Localization.induction_on₂ a b fun _ _ => by
        

Proof state:
α : Type u_1
inst✝ : LinearOrderedCancelCommMonoid α
s : Submonoid α
src✝ : OrderedCancelCommMonoid (Localization s) := orderedCancelCommMonoid
a b : Localization s
x✝¹ x✝ : α × ↥s
⊢ mk x✝¹.1 x✝¹.2 ≤ mk x✝.1 x✝.2 ∨ mk x✝.1 x✝.2 ≤ mk x✝¹.1 x✝¹.2

Next tactic:
simp_rw [mk_le_mk]
@[to_additive]
instance [LinearOrderedCancelCommMonoid α] {s : Submonoid α} :
    LinearOrderedCancelCommMonoid (Localization s) :=
  { Localization.orderedCancelCommMonoid with
    le_total := fun a b =>
      Localization.induction_on₂ a b fun _ _ => by
        simp_rw [mk_le_mk]
        

Proof state:
α : Type u_1
inst✝ : LinearOrderedCancelCommMonoid α
s : Submonoid α
src✝ : OrderedCancelCommMonoid (Localization s) := orderedCancelCommMonoid
a b : Localization s
x✝¹ x✝ : α × ↥s
⊢ ↑x✝.2 * x✝¹.1 ≤ ↑x✝¹.2 * x✝.1 ∨ ↑x✝¹.2 * x✝.1 ≤ ↑x✝.2 * x✝¹.1

Next tactic:
exact le_total _ _
/-- An ingredient of Tannaka duality for rings:
A ring `R` is equivalent to
the endomorphisms of the additive forgetful functor `Module R ⥤ AddCommGroup`.
-/
def ringEquivEndForget₂ (R : Type u) [Ring R] :
    R ≃+* End (AdditiveFunctor.of (forget₂ (ModuleCat.{u} R) AddCommGroupCat.{u})) where
  toFun r :=
    { app := fun M =>
        @AddCommGroupCat.ofHom M.carrier M.carrier _ _ (DistribMulAction.toAddMonoidHom M r)
      naturality := fun M N f => by
        

Proof state:
R : Type u
inst✝ : Ring R
r : R
M N : ModuleCat R
f : M ⟶ N
⊢ (AdditiveFunctor.of (forget₂ (ModuleCat R) AddCommGroupCat)).obj.map f ≫
      (fun M => AddCommGroupCat.ofHom (DistribMulAction.toAddMonoidHom (↑M) r)) N =
    (fun M => AddCommGroupCat.ofHom (DistribMulAction.toAddMonoidHom (↑M) r)) M ≫
      (AdditiveFunctor.of (forget₂ (ModuleCat R) AddCommGroupCat)).obj.map f

Next tactic:
ext
/-- An ingredient of Tannaka duality for rings:
A ring `R` is equivalent to
the endomorphisms of the additive forgetful functor `Module R ⥤ AddCommGroup`.
-/
def ringEquivEndForget₂ (R : Type u) [Ring R] :
    R ≃+* End (AdditiveFunctor.of (forget₂ (ModuleCat.{u} R) AddCommGroupCat.{u})) where
  toFun r :=
    { app := fun M =>
        @AddCommGroupCat.ofHom M.carrier M.carrier _ _ (DistribMulAction.toAddMonoidHom M r)
      naturality := fun M N f => by
        ext
        

Proof state:
case w
R : Type u
inst✝ : Ring R
r : R
M N : ModuleCat R
f : M ⟶ N
x✝ : ↑((AdditiveFunctor.of (forget₂ (ModuleCat R) AddCommGroupCat)).obj.obj M)
⊢ ((AdditiveFunctor.of (forget₂ (ModuleCat R) AddCommGroupCat)).obj.map f ≫
        (fun M => AddCommGroupCat.ofHom (DistribMulAction.toAddMonoidHom (↑M) r)) N)
      x✝ =
    ((fun M => AddCommGroupCat.ofHom (DistribMulAction.toAddMonoidHom (↑M) r)) M ≫
        (AdditiveFunctor.of (forget₂ (ModuleCat R) AddCommGroupCat)).obj.map f)
      x✝

Next tactic:
exact (f.map_smul _ _).symm
/-- An ingredient of Tannaka duality for rings:
A ring `R` is equivalent to
the endomorphisms of the additive forgetful functor `Module R ⥤ AddCommGroup`.
-/
def ringEquivEndForget₂ (R : Type u) [Ring R] :
    R ≃+* End (AdditiveFunctor.of (forget₂ (ModuleCat.{u} R) AddCommGroupCat.{u})) where
  toFun r :=
    { app := fun M =>
        @AddCommGroupCat.ofHom M.carrier M.carrier _ _ (DistribMulAction.toAddMonoidHom M r)
      naturality := fun M N f => by
        ext
        exact (f.map_smul _ _).symm }
  invFun φ := φ.app (ModuleCat.of R R) (1 : R)
  left_inv := by
    

Proof state:
R : Type u
inst✝ : Ring R
⊢ Function.LeftInverse (fun φ => (φ.app (ModuleCat.of R R)) 1) fun r =>
    NatTrans.mk fun M => AddCommGroupCat.ofHom (DistribMulAction.toAddMonoidHom (↑M) r)

Next tactic:
intro r
/-- An ingredient of Tannaka duality for rings:
A ring `R` is equivalent to
the endomorphisms of the additive forgetful functor `Module R ⥤ AddCommGroup`.
-/
def ringEquivEndForget₂ (R : Type u) [Ring R] :
    R ≃+* End (AdditiveFunctor.of (forget₂ (ModuleCat.{u} R) AddCommGroupCat.{u})) where
  toFun r :=
    { app := fun M =>
        @AddCommGroupCat.ofHom M.carrier M.carrier _ _ (DistribMulAction.toAddMonoidHom M r)
      naturality := fun M N f => by
        ext
        exact (f.map_smul _ _).symm }
  invFun φ := φ.app (ModuleCat.of R R) (1 : R)
  left_inv := by
    intro r
    

Proof state:
R : Type u
inst✝ : Ring R
r : R
⊢ (fun φ => (φ.app (ModuleCat.of R R)) 1)
      ((fun r => NatTrans.mk fun M => AddCommGroupCat.ofHom (DistribMulAction.toAddMonoidHom (↑M) r)) r) =
    r

Next tactic:
simp
/-- An ingredient of Tannaka duality for rings:
A ring `R` is equivalent to
the endomorphisms of the additive forgetful functor `Module R ⥤ AddCommGroup`.
-/
def ringEquivEndForget₂ (R : Type u) [Ring R] :
    R ≃+* End (AdditiveFunctor.of (forget₂ (ModuleCat.{u} R) AddCommGroupCat.{u})) where
  toFun r :=
    { app := fun M =>
        @AddCommGroupCat.ofHom M.carrier M.carrier _ _ (DistribMulAction.toAddMonoidHom M r)
      naturality := fun M N f => by
        ext
        exact (f.map_smul _ _).symm }
  invFun φ := φ.app (ModuleCat.of R R) (1 : R)
  left_inv := by
    intro r
    simp
  right_inv := by
    

Proof state:
R : Type u
inst✝ : Ring R
⊢ Function.RightInverse (fun φ => (φ.app (ModuleCat.of R R)) 1) fun r =>
    NatTrans.mk fun M => AddCommGroupCat.ofHom (DistribMulAction.toAddMonoidHom (↑M) r)

Next tactic:
intro φ
/-- An ingredient of Tannaka duality for rings:
A ring `R` is equivalent to
the endomorphisms of the additive forgetful functor `Module R ⥤ AddCommGroup`.
-/
def ringEquivEndForget₂ (R : Type u) [Ring R] :
    R ≃+* End (AdditiveFunctor.of (forget₂ (ModuleCat.{u} R) AddCommGroupCat.{u})) where
  toFun r :=
    { app := fun M =>
        @AddCommGroupCat.ofHom M.carrier M.carrier _ _ (DistribMulAction.toAddMonoidHom M r)
      naturality := fun M N f => by
        ext
        exact (f.map_smul _ _).symm }
  invFun φ := φ.app (ModuleCat.of R R) (1 : R)
  left_inv := by
    intro r
    simp
  right_inv := by
    intro φ
    

Proof state:
R : Type u
inst✝ : Ring R
φ : End (AdditiveFunctor.of (forget₂ (ModuleCat R) AddCommGroupCat))
⊢ (fun r => NatTrans.mk fun M => AddCommGroupCat.ofHom (DistribMulAction.toAddMonoidHom (↑M) r))
      ((fun φ => (φ.app (ModuleCat.of R R)) 1) φ) =
    φ

Next tactic:
apply NatTrans.ext
/-- An ingredient of Tannaka duality for rings:
A ring `R` is equivalent to
the endomorphisms of the additive forgetful functor `Module R ⥤ AddCommGroup`.
-/
def ringEquivEndForget₂ (R : Type u) [Ring R] :
    R ≃+* End (AdditiveFunctor.of (forget₂ (ModuleCat.{u} R) AddCommGroupCat.{u})) where
  toFun r :=
    { app := fun M =>
        @AddCommGroupCat.ofHom M.carrier M.carrier _ _ (DistribMulAction.toAddMonoidHom M r)
      naturality := fun M N f => by
        ext
        exact (f.map_smul _ _).symm }
  invFun φ := φ.app (ModuleCat.of R R) (1 : R)
  left_inv := by
    intro r
    simp
  right_inv := by
    intro φ
    apply NatTrans.ext
    

Proof state:
case app
R : Type u
inst✝ : Ring R
φ : End (AdditiveFunctor.of (forget₂ (ModuleCat R) AddCommGroupCat))
⊢ ((fun r => NatTrans.mk fun M => AddCommGroupCat.ofHom (DistribMulAction.toAddMonoidHom (↑M) r))
        ((fun φ => (φ.app (ModuleCat.of R R)) 1) φ)).app =
    φ.app

Next tactic:
ext M (x : M)
/-- An ingredient of Tannaka duality for rings:
A ring `R` is equivalent to
the endomorphisms of the additive forgetful functor `Module R ⥤ AddCommGroup`.
-/
def ringEquivEndForget₂ (R : Type u) [Ring R] :
    R ≃+* End (AdditiveFunctor.of (forget₂ (ModuleCat.{u} R) AddCommGroupCat.{u})) where
  toFun r :=
    { app := fun M =>
        @AddCommGroupCat.ofHom M.carrier M.carrier _ _ (DistribMulAction.toAddMonoidHom M r)
      naturality := fun M N f => by
        ext
        exact (f.map_smul _ _).symm }
  invFun φ := φ.app (ModuleCat.of R R) (1 : R)
  left_inv := by
    intro r
    simp
  right_inv := by
    intro φ
    apply NatTrans.ext
    ext M (x : M)
    

Proof state:
case app.h.w
R : Type u
inst✝ : Ring R
φ : End (AdditiveFunctor.of (forget₂ (ModuleCat R) AddCommGroupCat))
M : ModuleCat R
x : ↑M
⊢ (((fun r => NatTrans.mk fun M => AddCommGroupCat.ofHom (DistribMulAction.toAddMonoidHom (↑M) r))
            ((fun φ => (φ.app (ModuleCat.of R R)) 1) φ)).app
        M)
      x =
    (φ.app M) x

Next tactic:
have w := congr_fun ((forget _).congr_map
      (φ.naturality (ModuleCat.asHomRight (LinearMap.toSpanSingleton R M x)))) (1 : R)
/-- An ingredient of Tannaka duality for rings:
A ring `R` is equivalent to
the endomorphisms of the additive forgetful functor `Module R ⥤ AddCommGroup`.
-/
def ringEquivEndForget₂ (R : Type u) [Ring R] :
    R ≃+* End (AdditiveFunctor.of (forget₂ (ModuleCat.{u} R) AddCommGroupCat.{u})) where
  toFun r :=
    { app := fun M =>
        @AddCommGroupCat.ofHom M.carrier M.carrier _ _ (DistribMulAction.toAddMonoidHom M r)
      naturality := fun M N f => by
        ext
        exact (f.map_smul _ _).symm }
  invFun φ := φ.app (ModuleCat.of R R) (1 : R)
  left_inv := by
    intro r
    simp
  right_inv := by
    intro φ
    apply NatTrans.ext
    ext M (x : M)
    have w := congr_fun ((forget _).congr_map
      (φ.naturality (ModuleCat.asHomRight (LinearMap.toSpanSingleton R M x)))) (1 : R)
    

Proof state:
case app.h.w
R : Type u
inst✝ : Ring R
φ : End (AdditiveFunctor.of (forget₂ (ModuleCat R) AddCommGroupCat))
M : ModuleCat R
x : ↑M
w :
  (forget AddCommGroupCat).map
      ((AdditiveFunctor.of (forget₂ (ModuleCat R) AddCommGroupCat)).obj.map
          (ModuleCat.asHomRight (LinearMap.toSpanSingleton R (↑M) x)) ≫
        φ.app M)
      1 =
    (forget AddCommGroupCat).map
      (φ.app (ModuleCat.of R R) ≫
        (AdditiveFunctor.of (forget₂ (ModuleCat R) AddCommGroupCat)).obj.map
          (ModuleCat.asHomRight (LinearMap.toSpanSingleton R (↑M) x)))
      1
⊢ (((fun r => NatTrans.mk fun M => AddCommGroupCat.ofHom (DistribMulAction.toAddMonoidHom (↑M) r))
            ((fun φ => (φ.app (ModuleCat.of R R)) 1) φ)).app
        M)
      x =
    (φ.app M) x

Next tactic:
exact w.symm.trans (congr_arg (φ.app M) (one_smul R x))
/-- An ingredient of Tannaka duality for rings:
A ring `R` is equivalent to
the endomorphisms of the additive forgetful functor `Module R ⥤ AddCommGroup`.
-/
def ringEquivEndForget₂ (R : Type u) [Ring R] :
    R ≃+* End (AdditiveFunctor.of (forget₂ (ModuleCat.{u} R) AddCommGroupCat.{u})) where
  toFun r :=
    { app := fun M =>
        @AddCommGroupCat.ofHom M.carrier M.carrier _ _ (DistribMulAction.toAddMonoidHom M r)
      naturality := fun M N f => by
        ext
        exact (f.map_smul _ _).symm }
  invFun φ := φ.app (ModuleCat.of R R) (1 : R)
  left_inv := by
    intro r
    simp
  right_inv := by
    intro φ
    apply NatTrans.ext
    ext M (x : M)
    have w := congr_fun ((forget _).congr_map
      (φ.naturality (ModuleCat.asHomRight (LinearMap.toSpanSingleton R M x)))) (1 : R)
    exact w.symm.trans (congr_arg (φ.app M) (one_smul R x))
  map_add' := by
    intros
    apply NatTrans.ext
    ext
    dsimp
    simp only [AddCommGroupCat.ofHom_apply, DistribMulAction.toAddMonoidHom_apply, add_smul]
    rfl
  map_mul' := by
    

Proof state:
R : Type u
inst✝ : Ring R
⊢ ∀ (x y : R),
    Equiv.toFun
        { toFun := fun r => NatTrans.mk fun M => AddCommGroupCat.ofHom (DistribMulAction.toAddMonoidHom (↑M) r),
          invFun := fun φ => (φ.app (ModuleCat.of R R)) 1, left_inv := (_ : ∀ (r : R), r * 1 = r),
          right_inv :=
            (_ :
              ∀ (φ : End (AdditiveFunctor.of (forget₂ (ModuleCat R) AddCommGroupCat))),
                (fun r => NatTrans.mk fun M => AddCommGroupCat.ofHom (DistribMulAction.toAddMonoidHom (↑M) r))
                    ((fun φ => (φ.app (ModuleCat.of R R)) 1) φ) =
                  φ) }
        (x * y) =
      Equiv.toFun
          { toFun := fun r => NatTrans.mk fun M => AddCommGroupCat.ofHom (DistribMulAction.toAddMonoidHom (↑M) r),
            invFun := fun φ => (φ.app (ModuleCat.of R R)) 1, left_inv := (_ : ∀ (r : R), r * 1 = r),
            right_inv :=
              (_ :
                ∀ (φ : End (AdditiveFunctor.of (forget₂ (ModuleCat R) AddCommGroupCat))),
                  (fun r => NatTrans.mk fun M => AddCommGroupCat.ofHom (DistribMulAction.toAddMonoidHom (↑M) r))
                      ((fun φ => (φ.app (ModuleCat.of R R)) 1) φ) =
                    φ) }
          x *
        Equiv.toFun
          { toFun := fun r => NatTrans.mk fun M => AddCommGroupCat.ofHom (DistribMulAction.toAddMonoidHom (↑M) r),
            invFun := fun φ => (φ.app (ModuleCat.of R R)) 1, left_inv := (_ : ∀ (r : R), r * 1 = r),
            right_inv :=
              (_ :
                ∀ (φ : End (AdditiveFunctor.of (forget₂ (ModuleCat R) AddCommGroupCat))),
                  (fun r => NatTrans.mk fun M => AddCommGroupCat.ofHom (DistribMulAction.toAddMonoidHom (↑M) r))
                      ((fun φ => (φ.app (ModuleCat.of R R)) 1) φ) =
                    φ) }
          y

Next tactic:
intros
/-- An ingredient of Tannaka duality for rings:
A ring `R` is equivalent to
the endomorphisms of the additive forgetful functor `Module R ⥤ AddCommGroup`.
-/
def ringEquivEndForget₂ (R : Type u) [Ring R] :
    R ≃+* End (AdditiveFunctor.of (forget₂ (ModuleCat.{u} R) AddCommGroupCat.{u})) where
  toFun r :=
    { app := fun M =>
        @AddCommGroupCat.ofHom M.carrier M.carrier _ _ (DistribMulAction.toAddMonoidHom M r)
      naturality := fun M N f => by
        ext
        exact (f.map_smul _ _).symm }
  invFun φ := φ.app (ModuleCat.of R R) (1 : R)
  left_inv := by
    intro r
    simp
  right_inv := by
    intro φ
    apply NatTrans.ext
    ext M (x : M)
    have w := congr_fun ((forget _).congr_map
      (φ.naturality (ModuleCat.asHomRight (LinearMap.toSpanSingleton R M x)))) (1 : R)
    exact w.symm.trans (congr_arg (φ.app M) (one_smul R x))
  map_add' := by
    intros
    apply NatTrans.ext
    ext
    dsimp
    simp only [AddCommGroupCat.ofHom_apply, DistribMulAction.toAddMonoidHom_apply, add_smul]
    rfl
  map_mul' := by
    intros
    

Proof state:
R : Type u
inst✝ : Ring R
x✝ y✝ : R
⊢ Equiv.toFun
      { toFun := fun r => NatTrans.mk fun M => AddCommGroupCat.ofHom (DistribMulAction.toAddMonoidHom (↑M) r),
        invFun := fun φ => (φ.app (ModuleCat.of R R)) 1, left_inv := (_ : ∀ (r : R), r * 1 = r),
        right_inv :=
          (_ :
            ∀ (φ : End (AdditiveFunctor.of (forget₂ (ModuleCat R) AddCommGroupCat))),
              (fun r => NatTrans.mk fun M => AddCommGroupCat.ofHom (DistribMulAction.toAddMonoidHom (↑M) r))
                  ((fun φ => (φ.app (ModuleCat.of R R)) 1) φ) =
                φ) }
      (x✝ * y✝) =
    Equiv.toFun
        { toFun := fun r => NatTrans.mk fun M => AddCommGroupCat.ofHom (DistribMulAction.toAddMonoidHom (↑M) r),
          invFun := fun φ => (φ.app (ModuleCat.of R R)) 1, left_inv := (_ : ∀ (r : R), r * 1 = r),
          right_inv :=
            (_ :
              ∀ (φ : End (AdditiveFunctor.of (forget₂ (ModuleCat R) AddCommGroupCat))),
                (fun r => NatTrans.mk fun M => AddCommGroupCat.ofHom (DistribMulAction.toAddMonoidHom (↑M) r))
                    ((fun φ => (φ.app (ModuleCat.of R R)) 1) φ) =
                  φ) }
        x✝ *
      Equiv.toFun
        { toFun := fun r => NatTrans.mk fun M => AddCommGroupCat.ofHom (DistribMulAction.toAddMonoidHom (↑M) r),
          invFun := fun φ => (φ.app (ModuleCat.of R R)) 1, left_inv := (_ : ∀ (r : R), r * 1 = r),
          right_inv :=
            (_ :
              ∀ (φ : End (AdditiveFunctor.of (forget₂ (ModuleCat R) AddCommGroupCat))),
                (fun r => NatTrans.mk fun M => AddCommGroupCat.ofHom (DistribMulAction.toAddMonoidHom (↑M) r))
                    ((fun φ => (φ.app (ModuleCat.of R R)) 1) φ) =
                  φ) }
        y✝

Next tactic:
apply NatTrans.ext
/-- An ingredient of Tannaka duality for rings:
A ring `R` is equivalent to
the endomorphisms of the additive forgetful functor `Module R ⥤ AddCommGroup`.
-/
def ringEquivEndForget₂ (R : Type u) [Ring R] :
    R ≃+* End (AdditiveFunctor.of (forget₂ (ModuleCat.{u} R) AddCommGroupCat.{u})) where
  toFun r :=
    { app := fun M =>
        @AddCommGroupCat.ofHom M.carrier M.carrier _ _ (DistribMulAction.toAddMonoidHom M r)
      naturality := fun M N f => by
        ext
        exact (f.map_smul _ _).symm }
  invFun φ := φ.app (ModuleCat.of R R) (1 : R)
  left_inv := by
    intro r
    simp
  right_inv := by
    intro φ
    apply NatTrans.ext
    ext M (x : M)
    have w := congr_fun ((forget _).congr_map
      (φ.naturality (ModuleCat.asHomRight (LinearMap.toSpanSingleton R M x)))) (1 : R)
    exact w.symm.trans (congr_arg (φ.app M) (one_smul R x))
  map_add' := by
    intros
    apply NatTrans.ext
    ext
    dsimp
    simp only [AddCommGroupCat.ofHom_apply, DistribMulAction.toAddMonoidHom_apply, add_smul]
    rfl
  map_mul' := by
    intros
    apply NatTrans.ext
    

Proof state:
case app
R : Type u
inst✝ : Ring R
x✝ y✝ : R
⊢ (Equiv.toFun
        { toFun := fun r => NatTrans.mk fun M => AddCommGroupCat.ofHom (DistribMulAction.toAddMonoidHom (↑M) r),
          invFun := fun φ => (φ.app (ModuleCat.of R R)) 1, left_inv := (_ : ∀ (r : R), r * 1 = r),
          right_inv :=
            (_ :
              ∀ (φ : End (AdditiveFunctor.of (forget₂ (ModuleCat R) AddCommGroupCat))),
                (fun r => NatTrans.mk fun M => AddCommGroupCat.ofHom (DistribMulAction.toAddMonoidHom (↑M) r))
                    ((fun φ => (φ.app (ModuleCat.of R R)) 1) φ) =
                  φ) }
        (x✝ * y✝)).app =
    (Equiv.toFun
          { toFun := fun r => NatTrans.mk fun M => AddCommGroupCat.ofHom (DistribMulAction.toAddMonoidHom (↑M) r),
            invFun := fun φ => (φ.app (ModuleCat.of R R)) 1, left_inv := (_ : ∀ (r : R), r * 1 = r),
            right_inv :=
              (_ :
                ∀ (φ : End (AdditiveFunctor.of (forget₂ (ModuleCat R) AddCommGroupCat))),
                  (fun r => NatTrans.mk fun M => AddCommGroupCat.ofHom (DistribMulAction.toAddMonoidHom (↑M) r))
                      ((fun φ => (φ.app (ModuleCat.of R R)) 1) φ) =
                    φ) }
          x✝ *
        Equiv.toFun
          { toFun := fun r => NatTrans.mk fun M => AddCommGroupCat.ofHom (DistribMulAction.toAddMonoidHom (↑M) r),
            invFun := fun φ => (φ.app (ModuleCat.of R R)) 1, left_inv := (_ : ∀ (r : R), r * 1 = r),
            right_inv :=
              (_ :
                ∀ (φ : End (AdditiveFunctor.of (forget₂ (ModuleCat R) AddCommGroupCat))),
                  (fun r => NatTrans.mk fun M => AddCommGroupCat.ofHom (DistribMulAction.toAddMonoidHom (↑M) r))
                      ((fun φ => (φ.app (ModuleCat.of R R)) 1) φ) =
                    φ) }
          y✝).app

Next tactic:
ext
/-- An ingredient of Tannaka duality for rings:
A ring `R` is equivalent to
the endomorphisms of the additive forgetful functor `Module R ⥤ AddCommGroup`.
-/
def ringEquivEndForget₂ (R : Type u) [Ring R] :
    R ≃+* End (AdditiveFunctor.of (forget₂ (ModuleCat.{u} R) AddCommGroupCat.{u})) where
  toFun r :=
    { app := fun M =>
        @AddCommGroupCat.ofHom M.carrier M.carrier _ _ (DistribMulAction.toAddMonoidHom M r)
      naturality := fun M N f => by
        ext
        exact (f.map_smul _ _).symm }
  invFun φ := φ.app (ModuleCat.of R R) (1 : R)
  left_inv := by
    intro r
    simp
  right_inv := by
    intro φ
    apply NatTrans.ext
    ext M (x : M)
    have w := congr_fun ((forget _).congr_map
      (φ.naturality (ModuleCat.asHomRight (LinearMap.toSpanSingleton R M x)))) (1 : R)
    exact w.symm.trans (congr_arg (φ.app M) (one_smul R x))
  map_add' := by
    intros
    apply NatTrans.ext
    ext
    dsimp
    simp only [AddCommGroupCat.ofHom_apply, DistribMulAction.toAddMonoidHom_apply, add_smul]
    rfl
  map_mul' := by
    intros
    apply NatTrans.ext
    ext
    

Proof state:
case app.h.w
R : Type u
inst✝ : Ring R
x✝² y✝ : R
x✝¹ : ModuleCat R
x✝ : ↑((AdditiveFunctor.of (forget₂ (ModuleCat R) AddCommGroupCat)).obj.obj x✝¹)
⊢ ((Equiv.toFun
            { toFun := fun r => NatTrans.mk fun M => AddCommGroupCat.ofHom (DistribMulAction.toAddMonoidHom (↑M) r),
              invFun := fun φ => (φ.app (ModuleCat.of R R)) 1, left_inv := (_ : ∀ (r : R), r * 1 = r),
              right_inv :=
                (_ :
                  ∀ (φ : End (AdditiveFunctor.of (forget₂ (ModuleCat R) AddCommGroupCat))),
                    (fun r => NatTrans.mk fun M => AddCommGroupCat.ofHom (DistribMulAction.toAddMonoidHom (↑M) r))
                        ((fun φ => (φ.app (ModuleCat.of R R)) 1) φ) =
                      φ) }
            (x✝² * y✝)).app
        x✝¹)
      x✝ =
    ((Equiv.toFun
              { toFun := fun r => NatTrans.mk fun M => AddCommGroupCat.ofHom (DistribMulAction.toAddMonoidHom (↑M) r),
                invFun := fun φ => (φ.app (ModuleCat.of R R)) 1, left_inv := (_ : ∀ (r : R), r * 1 = r),
                right_inv :=
                  (_ :
                    ∀ (φ : End (AdditiveFunctor.of (forget₂ (ModuleCat R) AddCommGroupCat))),
                      (fun r => NatTrans.mk fun M => AddCommGroupCat.ofHom (DistribMulAction.toAddMonoidHom (↑M) r))
                          ((fun φ => (φ.app (ModuleCat.of R R)) 1) φ) =
                        φ) }
              x✝² *
            Equiv.toFun
              { toFun := fun r => NatTrans.mk fun M => AddCommGroupCat.ofHom (DistribMulAction.toAddMonoidHom (↑M) r),
                invFun := fun φ => (φ.app (ModuleCat.of R R)) 1, left_inv := (_ : ∀ (r : R), r * 1 = r),
                right_inv :=
                  (_ :
                    ∀ (φ : End (AdditiveFunctor.of (forget₂ (ModuleCat R) AddCommGroupCat))),
                      (fun r => NatTrans.mk fun M => AddCommGroupCat.ofHom (DistribMulAction.toAddMonoidHom (↑M) r))
                          ((fun φ => (φ.app (ModuleCat.of R R)) 1) φ) =
                        φ) }
              y✝).app
        x✝¹)
      x✝

Next tactic:
dsimp
/-- An ingredient of Tannaka duality for rings:
A ring `R` is equivalent to
the endomorphisms of the additive forgetful functor `Module R ⥤ AddCommGroup`.
-/
def ringEquivEndForget₂ (R : Type u) [Ring R] :
    R ≃+* End (AdditiveFunctor.of (forget₂ (ModuleCat.{u} R) AddCommGroupCat.{u})) where
  toFun r :=
    { app := fun M =>
        @AddCommGroupCat.ofHom M.carrier M.carrier _ _ (DistribMulAction.toAddMonoidHom M r)
      naturality := fun M N f => by
        ext
        exact (f.map_smul _ _).symm }
  invFun φ := φ.app (ModuleCat.of R R) (1 : R)
  left_inv := by
    intro r
    simp
  right_inv := by
    intro φ
    apply NatTrans.ext
    ext M (x : M)
    have w := congr_fun ((forget _).congr_map
      (φ.naturality (ModuleCat.asHomRight (LinearMap.toSpanSingleton R M x)))) (1 : R)
    exact w.symm.trans (congr_arg (φ.app M) (one_smul R x))
  map_add' := by
    intros
    apply NatTrans.ext
    ext
    dsimp
    simp only [AddCommGroupCat.ofHom_apply, DistribMulAction.toAddMonoidHom_apply, add_smul]
    rfl
  map_mul' := by
    intros
    apply NatTrans.ext
    ext
    dsimp
    

Proof state:
case app.h.w
R : Type u
inst✝ : Ring R
x✝² y✝ : R
x✝¹ : ModuleCat R
x✝ : ↑((AdditiveFunctor.of (forget₂ (ModuleCat R) AddCommGroupCat)).obj.obj x✝¹)
⊢ (x✝² * y✝) • x✝ =
    (((NatTrans.mk fun M => AddCommGroupCat.ofHom (DistribMulAction.toAddMonoidHom (↑M) x✝²)) *
            NatTrans.mk fun M => AddCommGroupCat.ofHom (DistribMulAction.toAddMonoidHom (↑M) y✝)).app
        x✝¹)
      x✝

Next tactic:
simp only [AddCommGroupCat.ofHom_apply, DistribMulAction.toAddMonoidHom_apply, mul_smul]