l3lab/ntp-mathlib huggingface dataset:
/-- Shows that `|v - Aₙ / Bₙ| ≤ 1 / (bₙ * Bₙ * Bₙ)`. This bound is worse than the one shown in
`GCF.abs_sub_convergents_le`, but sometimes it is easier to apply and sufficient for one's use case.
 -/
theorem abs_sub_convergents_le' {b : K}
    (nth_part_denom_eq : (of v).partialDenominators.get? n = some b) :
    |v - (of v).convergents n| ≤ 1 / (b * (of v).denominators n * (of v).denominators n) := by
  have not_terminated_at_n : ¬(of v).TerminatedAt n := by
    simp [terminatedAt_iff_part_denom_none, nth_part_denom_eq]
  refine' (abs_sub_convergents_le not_terminated_at_n).trans _
  -- One can show that `0 < (GeneralizedContinuedFraction.of v).denominators n` but it's easier
  -- to consider the case `(GeneralizedContinuedFraction.of v).denominators n = 0`.
  rcases (zero_le_of_denom (K := K)).eq_or_gt with
    ((hB : (GeneralizedContinuedFraction.of v).denominators n = 0) | hB)
  · simp only [hB, mul_zero, zero_mul, div_zero, le_refl]
  · 

Proof state:
case inr
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
b : K
nth_part_denom_eq : Stream'.Seq.get? (partialDenominators (of v)) n = some b
not_terminated_at_n : ¬TerminatedAt (of v) n
hB : 0 < denominators (of v) n
⊢ 1 / (denominators (of v) n * denominators (of v) (n + 1)) ≤ 1 / (b * denominators (of v) n * denominators (of v) n)

Next tactic:
apply one_div_le_one_div_of_le
/-- Shows that `|v - Aₙ / Bₙ| ≤ 1 / (bₙ * Bₙ * Bₙ)`. This bound is worse than the one shown in
`GCF.abs_sub_convergents_le`, but sometimes it is easier to apply and sufficient for one's use case.
 -/
theorem abs_sub_convergents_le' {b : K}
    (nth_part_denom_eq : (of v).partialDenominators.get? n = some b) :
    |v - (of v).convergents n| ≤ 1 / (b * (of v).denominators n * (of v).denominators n) := by
  have not_terminated_at_n : ¬(of v).TerminatedAt n := by
    simp [terminatedAt_iff_part_denom_none, nth_part_denom_eq]
  refine' (abs_sub_convergents_le not_terminated_at_n).trans _
  -- One can show that `0 < (GeneralizedContinuedFraction.of v).denominators n` but it's easier
  -- to consider the case `(GeneralizedContinuedFraction.of v).denominators n = 0`.
  rcases (zero_le_of_denom (K := K)).eq_or_gt with
    ((hB : (GeneralizedContinuedFraction.of v).denominators n = 0) | hB)
  · simp only [hB, mul_zero, zero_mul, div_zero, le_refl]
  · apply one_div_le_one_div_of_le
    · 

Proof state:
case inr.ha
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
b : K
nth_part_denom_eq : Stream'.Seq.get? (partialDenominators (of v)) n = some b
not_terminated_at_n : ¬TerminatedAt (of v) n
hB : 0 < denominators (of v) n
⊢ 0 < b * denominators (of v) n * denominators (of v) n

Next tactic:
have : 0 < b := zero_lt_one.trans_le (of_one_le_get?_part_denom nth_part_denom_eq)
/-- Shows that `|v - Aₙ / Bₙ| ≤ 1 / (bₙ * Bₙ * Bₙ)`. This bound is worse than the one shown in
`GCF.abs_sub_convergents_le`, but sometimes it is easier to apply and sufficient for one's use case.
 -/
theorem abs_sub_convergents_le' {b : K}
    (nth_part_denom_eq : (of v).partialDenominators.get? n = some b) :
    |v - (of v).convergents n| ≤ 1 / (b * (of v).denominators n * (of v).denominators n) := by
  have not_terminated_at_n : ¬(of v).TerminatedAt n := by
    simp [terminatedAt_iff_part_denom_none, nth_part_denom_eq]
  refine' (abs_sub_convergents_le not_terminated_at_n).trans _
  -- One can show that `0 < (GeneralizedContinuedFraction.of v).denominators n` but it's easier
  -- to consider the case `(GeneralizedContinuedFraction.of v).denominators n = 0`.
  rcases (zero_le_of_denom (K := K)).eq_or_gt with
    ((hB : (GeneralizedContinuedFraction.of v).denominators n = 0) | hB)
  · simp only [hB, mul_zero, zero_mul, div_zero, le_refl]
  · apply one_div_le_one_div_of_le
    · have : 0 < b := zero_lt_one.trans_le (of_one_le_get?_part_denom nth_part_denom_eq)
      

Proof state:
case inr.ha
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
b : K
nth_part_denom_eq : Stream'.Seq.get? (partialDenominators (of v)) n = some b
not_terminated_at_n : ¬TerminatedAt (of v) n
hB : 0 < denominators (of v) n
this : 0 < b
⊢ 0 < b * denominators (of v) n * denominators (of v) n

Next tactic:
apply_rules [mul_pos]
/-- Shows that `|v - Aₙ / Bₙ| ≤ 1 / (bₙ * Bₙ * Bₙ)`. This bound is worse than the one shown in
`GCF.abs_sub_convergents_le`, but sometimes it is easier to apply and sufficient for one's use case.
 -/
theorem abs_sub_convergents_le' {b : K}
    (nth_part_denom_eq : (of v).partialDenominators.get? n = some b) :
    |v - (of v).convergents n| ≤ 1 / (b * (of v).denominators n * (of v).denominators n) := by
  have not_terminated_at_n : ¬(of v).TerminatedAt n := by
    simp [terminatedAt_iff_part_denom_none, nth_part_denom_eq]
  refine' (abs_sub_convergents_le not_terminated_at_n).trans _
  -- One can show that `0 < (GeneralizedContinuedFraction.of v).denominators n` but it's easier
  -- to consider the case `(GeneralizedContinuedFraction.of v).denominators n = 0`.
  rcases (zero_le_of_denom (K := K)).eq_or_gt with
    ((hB : (GeneralizedContinuedFraction.of v).denominators n = 0) | hB)
  · simp only [hB, mul_zero, zero_mul, div_zero, le_refl]
  · apply one_div_le_one_div_of_le
    · have : 0 < b := zero_lt_one.trans_le (of_one_le_get?_part_denom nth_part_denom_eq)
      apply_rules [mul_pos]
    · 

Proof state:
case inr.h
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
b : K
nth_part_denom_eq : Stream'.Seq.get? (partialDenominators (of v)) n = some b
not_terminated_at_n : ¬TerminatedAt (of v) n
hB : 0 < denominators (of v) n
⊢ b * denominators (of v) n * denominators (of v) n ≤ denominators (of v) n * denominators (of v) (n + 1)

Next tactic:
conv_rhs => rw [mul_comm]
/-- Shows that `|v - Aₙ / Bₙ| ≤ 1 / (bₙ * Bₙ * Bₙ)`. This bound is worse than the one shown in
`GCF.abs_sub_convergents_le`, but sometimes it is easier to apply and sufficient for one's use case.
 -/
theorem abs_sub_convergents_le' {b : K}
    (nth_part_denom_eq : (of v).partialDenominators.get? n = some b) :
    |v - (of v).convergents n| ≤ 1 / (b * (of v).denominators n * (of v).denominators n) := by
  have not_terminated_at_n : ¬(of v).TerminatedAt n := by
    simp [terminatedAt_iff_part_denom_none, nth_part_denom_eq]
  refine' (abs_sub_convergents_le not_terminated_at_n).trans _
  -- One can show that `0 < (GeneralizedContinuedFraction.of v).denominators n` but it's easier
  -- to consider the case `(GeneralizedContinuedFraction.of v).denominators n = 0`.
  rcases (zero_le_of_denom (K := K)).eq_or_gt with
    ((hB : (GeneralizedContinuedFraction.of v).denominators n = 0) | hB)
  · simp only [hB, mul_zero, zero_mul, div_zero, le_refl]
  · apply one_div_le_one_div_of_le
    · have : 0 < b := zero_lt_one.trans_le (of_one_le_get?_part_denom nth_part_denom_eq)
      apply_rules [mul_pos]
    · conv_rhs => 

Proof state:
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
b : K
nth_part_denom_eq : Stream'.Seq.get? (partialDenominators (of v)) n = some b
not_terminated_at_n : ¬TerminatedAt (of v) n
hB : 0 < denominators (of v) n
| denominators (of v) n * denominators (of v) (n + 1)

Next tactic:
rw [mul_comm]
/-- Shows that `|v - Aₙ / Bₙ| ≤ 1 / (bₙ * Bₙ * Bₙ)`. This bound is worse than the one shown in
`GCF.abs_sub_convergents_le`, but sometimes it is easier to apply and sufficient for one's use case.
 -/
theorem abs_sub_convergents_le' {b : K}
    (nth_part_denom_eq : (of v).partialDenominators.get? n = some b) :
    |v - (of v).convergents n| ≤ 1 / (b * (of v).denominators n * (of v).denominators n) := by
  have not_terminated_at_n : ¬(of v).TerminatedAt n := by
    simp [terminatedAt_iff_part_denom_none, nth_part_denom_eq]
  refine' (abs_sub_convergents_le not_terminated_at_n).trans _
  -- One can show that `0 < (GeneralizedContinuedFraction.of v).denominators n` but it's easier
  -- to consider the case `(GeneralizedContinuedFraction.of v).denominators n = 0`.
  rcases (zero_le_of_denom (K := K)).eq_or_gt with
    ((hB : (GeneralizedContinuedFraction.of v).denominators n = 0) | hB)
  · simp only [hB, mul_zero, zero_mul, div_zero, le_refl]
  · apply one_div_le_one_div_of_le
    · have : 0 < b := zero_lt_one.trans_le (of_one_le_get?_part_denom nth_part_denom_eq)
      apply_rules [mul_pos]
    · conv_rhs => rw [mul_comm]
      

Proof state:
case inr.h
K : Type u_1
v : K
n : ℕ
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
b : K
nth_part_denom_eq : Stream'.Seq.get? (partialDenominators (of v)) n = some b
not_terminated_at_n : ¬TerminatedAt (of v) n
hB : 0 < denominators (of v) n
⊢ b * denominators (of v) n * denominators (of v) n ≤ denominators (of v) (n + 1) * denominators (of v) n

Next tactic:
exact mul_le_mul_of_nonneg_right (le_of_succ_get?_denom nth_part_denom_eq) hB.le
theorem zero_union_range_succ : {0} ∪ range succ = univ := by
  

Proof state:
⊢ {0} ∪ range succ = univ

Next tactic:
ext n
theorem zero_union_range_succ : {0} ∪ range succ = univ := by
  ext n
  

Proof state:
case h
n : ℕ
⊢ n ∈ {0} ∪ range succ ↔ n ∈ univ

Next tactic:
cases n
theorem zero_union_range_succ : {0} ∪ range succ = univ := by
  ext n
  cases n <;> 

Proof state:
case h.zero
⊢ zero ∈ {0} ∪ range succ ↔ zero ∈ univ

Next tactic:
simp
theorem zero_union_range_succ : {0} ∪ range succ = univ := by
  ext n
  cases n <;> 

Proof state:
case h.succ
n✝ : ℕ
⊢ succ n✝ ∈ {0} ∪ range succ ↔ succ n✝ ∈ univ

Next tactic:
simp
@[simp]
protected theorem range_succ : range succ = { i | 0 < i } := by
  

Proof state:
⊢ range succ = {i | 0 < i}

Next tactic:
ext (_ | i)
@[simp]
protected theorem range_succ : range succ = { i | 0 < i } := by
  ext (_ | i) <;> 

Proof state:
case h.zero
⊢ zero ∈ range succ ↔ zero ∈ {i | 0 < i}

Next tactic:
simp [succ_pos, succ_ne_zero, Set.mem_setOf]
@[simp]
protected theorem range_succ : range succ = { i | 0 < i } := by
  ext (_ | i) <;> 

Proof state:
case h.succ
i : ℕ
⊢ succ i ∈ range succ ↔ succ i ∈ {i | 0 < i}

Next tactic:
simp [succ_pos, succ_ne_zero, Set.mem_setOf]
theorem range_of_succ (f : ℕ → α) : {f 0} ∪ range (f ∘ succ) = range f := by
  

Proof state:
α : Type u_1
f : ℕ → α
⊢ {f 0} ∪ range (f ∘ succ) = range f

Next tactic:
rw [← image_singleton, range_comp, ← image_union, zero_union_range_succ, image_univ]
theorem range_rec {α : Type*} (x : α) (f : ℕ → α → α) :
    (Set.range fun n => Nat.rec x f n : Set α) =
      {x} ∪ Set.range fun n => Nat.rec (f 0 x) (f ∘ succ) n := by
  

Proof state:
α✝ : Type u_1
α : Type u_2
x : α
f : ℕ → α → α
⊢ (range fun n => rec x f n) = {x} ∪ range fun n => rec (f 0 x) (f ∘ succ) n

Next tactic:
convert (range_of_succ (fun n => Nat.rec x f n : ℕ → α)).symm using 4
theorem range_rec {α : Type*} (x : α) (f : ℕ → α → α) :
    (Set.range fun n => Nat.rec x f n : Set α) =
      {x} ∪ Set.range fun n => Nat.rec (f 0 x) (f ∘ succ) n := by
  convert (range_of_succ (fun n => Nat.rec x f n : ℕ → α)).symm using 4
  

Proof state:
case h.e'_3.h.e'_4.h.e'_3.h
α✝ : Type u_1
α : Type u_2
x : α
f : ℕ → α → α
x✝ : ℕ
⊢ rec (f 0 x) (f ∘ succ) x✝ = ((fun n => rec x f n) ∘ succ) x✝

Next tactic:
dsimp
theorem range_rec {α : Type*} (x : α) (f : ℕ → α → α) :
    (Set.range fun n => Nat.rec x f n : Set α) =
      {x} ∪ Set.range fun n => Nat.rec (f 0 x) (f ∘ succ) n := by
  convert (range_of_succ (fun n => Nat.rec x f n : ℕ → α)).symm using 4
  dsimp
  

Proof state:
case h.e'_3.h.e'_4.h.e'_3.h
α✝ : Type u_1
α : Type u_2
x : α
f : ℕ → α → α
x✝ : ℕ
⊢ rec (f 0 x) (f ∘ succ) x✝ = f x✝ (rec x f x✝)

Next tactic:
rename_i n
theorem range_rec {α : Type*} (x : α) (f : ℕ → α → α) :
    (Set.range fun n => Nat.rec x f n : Set α) =
      {x} ∪ Set.range fun n => Nat.rec (f 0 x) (f ∘ succ) n := by
  convert (range_of_succ (fun n => Nat.rec x f n : ℕ → α)).symm using 4
  dsimp
  rename_i n
  

Proof state:
case h.e'_3.h.e'_4.h.e'_3.h
α✝ : Type u_1
α : Type u_2
x : α
f : ℕ → α → α
n : ℕ
⊢ rec (f 0 x) (f ∘ succ) n = f n (rec x f n)

Next tactic:
induction' n with n ihn
theorem range_rec {α : Type*} (x : α) (f : ℕ → α → α) :
    (Set.range fun n => Nat.rec x f n : Set α) =
      {x} ∪ Set.range fun n => Nat.rec (f 0 x) (f ∘ succ) n := by
  convert (range_of_succ (fun n => Nat.rec x f n : ℕ → α)).symm using 4
  dsimp
  rename_i n
  induction' n with n ihn
  · 

Proof state:
case h.e'_3.h.e'_4.h.e'_3.h.zero
α✝ : Type u_1
α : Type u_2
x : α
f : ℕ → α → α
⊢ rec (f 0 x) (f ∘ succ) zero = f zero (rec x f zero)

Next tactic:
rfl
theorem range_rec {α : Type*} (x : α) (f : ℕ → α → α) :
    (Set.range fun n => Nat.rec x f n : Set α) =
      {x} ∪ Set.range fun n => Nat.rec (f 0 x) (f ∘ succ) n := by
  convert (range_of_succ (fun n => Nat.rec x f n : ℕ → α)).symm using 4
  dsimp
  rename_i n
  induction' n with n ihn
  · rfl
  · 

Proof state:
case h.e'_3.h.e'_4.h.e'_3.h.succ
α✝ : Type u_1
α : Type u_2
x : α
f : ℕ → α → α
n : ℕ
ihn : rec (f 0 x) (f ∘ succ) n = f n (rec x f n)
⊢ rec (f 0 x) (f ∘ succ) (succ n) = f (succ n) (rec x f (succ n))

Next tactic:
dsimp at ihn ⊢
theorem range_rec {α : Type*} (x : α) (f : ℕ → α → α) :
    (Set.range fun n => Nat.rec x f n : Set α) =
      {x} ∪ Set.range fun n => Nat.rec (f 0 x) (f ∘ succ) n := by
  convert (range_of_succ (fun n => Nat.rec x f n : ℕ → α)).symm using 4
  dsimp
  rename_i n
  induction' n with n ihn
  · rfl
  · dsimp at ihn ⊢
    

Proof state:
case h.e'_3.h.e'_4.h.e'_3.h.succ
α✝ : Type u_1
α : Type u_2
x : α
f : ℕ → α → α
n : ℕ
ihn : rec (f 0 x) (f ∘ succ) n = f n (rec x f n)
⊢ f (succ n) (rec (f 0 x) (f ∘ succ) n) = f (succ n) (f n (rec x f n))

Next tactic:
rw [ihn]
instance addCommGroupObj (F : J ⥤ ModuleCatMax.{v, w, u} R) (j) :
    AddCommGroup ((F ⋙ forget (ModuleCat R)).obj j) := by
  

Proof state:
R : Type u
inst✝¹ : Ring R
J : Type v
inst✝ : SmallCategory J
F : J ⥤ ModuleCatMax R
j : J
⊢ AddCommGroup ((F ⋙ forget (ModuleCat R)).obj j)

Next tactic:
change AddCommGroup (F.obj j)
instance addCommGroupObj (F : J ⥤ ModuleCatMax.{v, w, u} R) (j) :
    AddCommGroup ((F ⋙ forget (ModuleCat R)).obj j) := by
  change AddCommGroup (F.obj j)
  

Proof state:
R : Type u
inst✝¹ : Ring R
J : Type v
inst✝ : SmallCategory J
F : J ⥤ ModuleCatMax R
j : J
⊢ AddCommGroup ↑(F.obj j)

Next tactic:
infer_instance
instance moduleObj (F : J ⥤ ModuleCatMax.{v, w, u} R) (j) :
    Module.{u, max v w} R ((F ⋙ forget (ModuleCat R)).obj j) := by
  

Proof state:
R : Type u
inst✝¹ : Ring R
J : Type v
inst✝ : SmallCategory J
F : J ⥤ ModuleCatMax R
j : J
⊢ Module R ((F ⋙ forget (ModuleCat R)).obj j)

Next tactic:
change Module R (F.obj j)
instance moduleObj (F : J ⥤ ModuleCatMax.{v, w, u} R) (j) :
    Module.{u, max v w} R ((F ⋙ forget (ModuleCat R)).obj j) := by
  change Module R (F.obj j)
  

Proof state:
R : Type u
inst✝¹ : Ring R
J : Type v
inst✝ : SmallCategory J
F : J ⥤ ModuleCatMax R
j : J
⊢ Module R ↑(F.obj j)

Next tactic:
infer_instance
/-- The flat sections of a functor into `ModuleCat R` form a submodule of all sections.
-/
def sectionsSubmodule (F : J ⥤ ModuleCatMax.{v, w, u} R) : Submodule R (∀ j, F.obj j) :=
  { AddGroupCat.sectionsAddSubgroup.{v, w}
      (F ⋙ forget₂ (ModuleCat R) AddCommGroupCat.{max v w} ⋙
          forget₂ AddCommGroupCat AddGroupCat.{max v w}) with
    carrier := (F ⋙ forget (ModuleCat R)).sections
    smul_mem' := fun r s sh j j' f => by
      

Proof state:
R : Type u
inst✝¹ : Ring R
J : Type v
inst✝ : SmallCategory J
F : J ⥤ ModuleCatMax R
src✝ : AddSubgroup
  ((j : J) → ↑((F ⋙ forget₂ (ModuleCat R) AddCommGroupCat ⋙ forget₂ AddCommGroupCat AddGroupCat).obj j)) :=
  AddGroupCat.sectionsAddSubgroup (F ⋙ forget₂ (ModuleCat R) AddCommGroupCat ⋙ forget₂ AddCommGroupCat AddGroupCat)
r : R
s : (j : J) → ↑(F.obj j)
sh :
  s ∈
    {
          toAddSubsemigroup :=
            { carrier := Functor.sections (F ⋙ forget (ModuleCat R)),
              add_mem' :=
                (_ : ∀ {a b : (j : J) → ↑(F.obj j)}, a ∈ src✝.carrier → b ∈ src✝.carrier → a + b ∈ src✝.carrier) },
          zero_mem' :=
            (_ :
              ∀ {j j' : J} (f : j ⟶ j'),
                ((F ⋙ forget₂ (ModuleCat R) AddCommGroupCat ⋙ forget₂ AddCommGroupCat AddGroupCat) ⋙
                        forget AddGroupCat).map
                    f (OfNat.ofNat 0 j) =
                  OfNat.ofNat 0 j') }.toAddSubsemigroup.carrier
j j' : J
f : j ⟶ j'
⊢ (F ⋙ forget (ModuleCat R)).map f ((r • s) j) = (r • s) j'

Next tactic:
simp only [forget_map, Functor.comp_map, Pi.smul_apply, map_smul]
/-- The flat sections of a functor into `ModuleCat R` form a submodule of all sections.
-/
def sectionsSubmodule (F : J ⥤ ModuleCatMax.{v, w, u} R) : Submodule R (∀ j, F.obj j) :=
  { AddGroupCat.sectionsAddSubgroup.{v, w}
      (F ⋙ forget₂ (ModuleCat R) AddCommGroupCat.{max v w} ⋙
          forget₂ AddCommGroupCat AddGroupCat.{max v w}) with
    carrier := (F ⋙ forget (ModuleCat R)).sections
    smul_mem' := fun r s sh j j' f => by
      simp only [forget_map, Functor.comp_map, Pi.smul_apply, map_smul]
      

Proof state:
R : Type u
inst✝¹ : Ring R
J : Type v
inst✝ : SmallCategory J
F : J ⥤ ModuleCatMax R
src✝ : AddSubgroup
  ((j : J) → ↑((F ⋙ forget₂ (ModuleCat R) AddCommGroupCat ⋙ forget₂ AddCommGroupCat AddGroupCat).obj j)) :=
  AddGroupCat.sectionsAddSubgroup (F ⋙ forget₂ (ModuleCat R) AddCommGroupCat ⋙ forget₂ AddCommGroupCat AddGroupCat)
r : R
s : (j : J) → ↑(F.obj j)
sh :
  s ∈
    {
          toAddSubsemigroup :=
            { carrier := Functor.sections (F ⋙ forget (ModuleCat R)),
              add_mem' :=
                (_ : ∀ {a b : (j : J) → ↑(F.obj j)}, a ∈ src✝.carrier → b ∈ src✝.carrier → a + b ∈ src✝.carrier) },
          zero_mem' :=
            (_ :
              ∀ {j j' : J} (f : j ⟶ j'),
                ((F ⋙ forget₂ (ModuleCat R) AddCommGroupCat ⋙ forget₂ AddCommGroupCat AddGroupCat) ⋙
                        forget AddGroupCat).map
                    f (OfNat.ofNat 0 j) =
                  OfNat.ofNat 0 j') }.toAddSubsemigroup.carrier
j j' : J
f : j ⟶ j'
⊢ r • (F.map f) (s j) = r • s j'

Next tactic:
dsimp [Functor.sections] at sh
/-- The flat sections of a functor into `ModuleCat R` form a submodule of all sections.
-/
def sectionsSubmodule (F : J ⥤ ModuleCatMax.{v, w, u} R) : Submodule R (∀ j, F.obj j) :=
  { AddGroupCat.sectionsAddSubgroup.{v, w}
      (F ⋙ forget₂ (ModuleCat R) AddCommGroupCat.{max v w} ⋙
          forget₂ AddCommGroupCat AddGroupCat.{max v w}) with
    carrier := (F ⋙ forget (ModuleCat R)).sections
    smul_mem' := fun r s sh j j' f => by
      simp only [forget_map, Functor.comp_map, Pi.smul_apply, map_smul]
      dsimp [Functor.sections] at sh
      

Proof state:
R : Type u
inst✝¹ : Ring R
J : Type v
inst✝ : SmallCategory J
F : J ⥤ ModuleCatMax R
src✝ : AddSubgroup
  ((j : J) → ↑((F ⋙ forget₂ (ModuleCat R) AddCommGroupCat ⋙ forget₂ AddCommGroupCat AddGroupCat).obj j)) :=
  AddGroupCat.sectionsAddSubgroup (F ⋙ forget₂ (ModuleCat R) AddCommGroupCat ⋙ forget₂ AddCommGroupCat AddGroupCat)
r : R
s : (j : J) → ↑(F.obj j)
sh : s ∈ {u | ∀ {j j' : J} (f : j ⟶ j'), (F.map f) (u j) = u j'}
j j' : J
f : j ⟶ j'
⊢ r • (F.map f) (s j) = r • s j'

Next tactic:
rw [sh f]
instance limitAddCommMonoid (F : J ⥤ ModuleCatMax.{v, w, u} R) :
    AddCommMonoid (Types.limitCone.{v, w} (F ⋙ forget (ModuleCatMax.{v, w, u} R))).pt :=
  show AddCommMonoid (sectionsSubmodule F) by 

Proof state:
R : Type u
inst✝¹ : Ring R
J : Type v
inst✝ : SmallCategory J
F : J ⥤ ModuleCatMax R
⊢ AddCommMonoid ↥(sectionsSubmodule F)

Next tactic:
infer_instance
instance limitAddCommGroup (F : J ⥤ ModuleCatMax.{v, w, u} R) :
    AddCommGroup (Types.limitCone.{v, w} (F ⋙ forget (ModuleCatMax.{v, w, u} R))).pt :=
  show AddCommGroup (sectionsSubmodule F) by 

Proof state:
R : Type u
inst✝¹ : Ring R
J : Type v
inst✝ : SmallCategory J
F : J ⥤ ModuleCatMax R
⊢ AddCommGroup ↥(sectionsSubmodule F)

Next tactic:
infer_instance
instance limitModule (F : J ⥤ ModuleCatMax.{v, w, u} R) :
    Module R (Types.limitCone.{v, w} (F ⋙ forget (ModuleCat.{max v w} R))).pt :=
  show Module R (sectionsSubmodule F) by 

Proof state:
R : Type u
inst✝¹ : Ring R
J : Type v
inst✝ : SmallCategory J
F : J ⥤ ModuleCatMax R
⊢ Module R ↥(sectionsSubmodule F)

Next tactic:
infer_instance
/-- Witness that the limit cone in `ModuleCat R` is a limit cone.
(Internal use only; use the limits API.)
-/
def limitConeIsLimit (F : J ⥤ ModuleCatMax.{v, w, u} R) : IsLimit (limitCone.{v, w} F) := by
  

Proof state:
R : Type u
inst✝¹ : Ring R
J : Type v
inst✝ : SmallCategory J
F : J ⥤ ModuleCatMax R
⊢ IsLimit (limitCone F)

Next tactic:
refine' IsLimit.ofFaithful (forget (ModuleCat R)) (Types.limitConeIsLimit.{v, w} _)
    (fun s => ⟨⟨(Types.limitConeIsLimit.{v, w} _).lift ((forget (ModuleCat R)).mapCone s), _⟩, _⟩)
    (fun s => rfl)
/-- Witness that the limit cone in `ModuleCat R` is a limit cone.
(Internal use only; use the limits API.)
-/
def limitConeIsLimit (F : J ⥤ ModuleCatMax.{v, w, u} R) : IsLimit (limitCone.{v, w} F) := by
  refine' IsLimit.ofFaithful (forget (ModuleCat R)) (Types.limitConeIsLimit.{v, w} _)
    (fun s => ⟨⟨(Types.limitConeIsLimit.{v, w} _).lift ((forget (ModuleCat R)).mapCone s), _⟩, _⟩)
    (fun s => rfl)
  

Proof state:
case refine'_1
R : Type u
inst✝¹ : Ring R
J : Type v
inst✝ : SmallCategory J
F : J ⥤ ModuleCatMax R
s : Cone F
⊢ ∀ (x y : ↑s.pt),
    IsLimit.lift (Types.limitConeIsLimit (F ⋙ forget (ModuleCat R))) ((forget (ModuleCat R)).mapCone s) (x + y) =
      IsLimit.lift (Types.limitConeIsLimit (F ⋙ forget (ModuleCat R))) ((forget (ModuleCat R)).mapCone s) x +
        IsLimit.lift (Types.limitConeIsLimit (F ⋙ forget (ModuleCat R))) ((forget (ModuleCat R)).mapCone s) y
case refine'_2
R : Type u
inst✝¹ : Ring R
J : Type v
inst✝ : SmallCategory J
F : J ⥤ ModuleCatMax R
s : Cone F
⊢ ∀ (r : R) (x : ↑s.pt),
    AddHom.toFun
        { toFun := IsLimit.lift (Types.limitConeIsLimit (F ⋙ forget (ModuleCat R))) ((forget (ModuleCat R)).mapCone s),
          map_add' := ?refine'_1 }
        (r • x) =
      (RingHom.id R) r •
        AddHom.toFun
          {
            toFun :=
              IsLimit.lift (Types.limitConeIsLimit (F ⋙ forget (ModuleCat R))) ((forget (ModuleCat R)).mapCone s),
            map_add' := ?refine'_1 }
          x

Next tactic:
all_goals
    intros
    dsimp [Types.limitConeIsLimit]
    simp
    rfl
/-- Witness that the limit cone in `ModuleCat R` is a limit cone.
(Internal use only; use the limits API.)
-/
def limitConeIsLimit (F : J ⥤ ModuleCatMax.{v, w, u} R) : IsLimit (limitCone.{v, w} F) := by
  refine' IsLimit.ofFaithful (forget (ModuleCat R)) (Types.limitConeIsLimit.{v, w} _)
    (fun s => ⟨⟨(Types.limitConeIsLimit.{v, w} _).lift ((forget (ModuleCat R)).mapCone s), _⟩, _⟩)
    (fun s => rfl)
  all_goals
    

Proof state:
case refine'_1
R : Type u
inst✝¹ : Ring R
J : Type v
inst✝ : SmallCategory J
F : J ⥤ ModuleCatMax R
s : Cone F
⊢ ∀ (x y : ↑s.pt),
    IsLimit.lift (Types.limitConeIsLimit (F ⋙ forget (ModuleCat R))) ((forget (ModuleCat R)).mapCone s) (x + y) =
      IsLimit.lift (Types.limitConeIsLimit (F ⋙ forget (ModuleCat R))) ((forget (ModuleCat R)).mapCone s) x +
        IsLimit.lift (Types.limitConeIsLimit (F ⋙ forget (ModuleCat R))) ((forget (ModuleCat R)).mapCone s) y

Next tactic:
intros
/-- Witness that the limit cone in `ModuleCat R` is a limit cone.
(Internal use only; use the limits API.)
-/
def limitConeIsLimit (F : J ⥤ ModuleCatMax.{v, w, u} R) : IsLimit (limitCone.{v, w} F) := by
  refine' IsLimit.ofFaithful (forget (ModuleCat R)) (Types.limitConeIsLimit.{v, w} _)
    (fun s => ⟨⟨(Types.limitConeIsLimit.{v, w} _).lift ((forget (ModuleCat R)).mapCone s), _⟩, _⟩)
    (fun s => rfl)
  all_goals
    intros
    

Proof state:
case refine'_1
R : Type u
inst✝¹ : Ring R
J : Type v
inst✝ : SmallCategory J
F : J ⥤ ModuleCatMax R
s : Cone F
x✝ y✝ : ↑s.pt
⊢ IsLimit.lift (Types.limitConeIsLimit (F ⋙ forget (ModuleCat R))) ((forget (ModuleCat R)).mapCone s) (x✝ + y✝) =
    IsLimit.lift (Types.limitConeIsLimit (F ⋙ forget (ModuleCat R))) ((forget (ModuleCat R)).mapCone s) x✝ +
      IsLimit.lift (Types.limitConeIsLimit (F ⋙ forget (ModuleCat R))) ((forget (ModuleCat R)).mapCone s) y✝

Next tactic:
dsimp [Types.limitConeIsLimit]