l3lab/ntp-mathlib huggingface dataset:
instance : Preadditive (Free R C) where
  homGroup X Y := Finsupp.addCommGroup
  add_comp X Y Z f f' g := by
    dsimp [CategoryTheory.categoryFree]
    rw [Finsupp.sum_add_index'] <;> · 

Proof state:
case h_add
R : Type u_1
inst✝¹ : CommRing R
C : Type u
inst✝ : Category.{v, u} C
X Y Z : Free R C
f f' : X ⟶ Y
g : Y ⟶ Z
⊢ ∀ (a : X ⟶ Y) (b₁ b₂ : R),
    (sum g fun g' t => fun₀ | a ≫ g' => (b₁ + b₂) * t) =
      (sum g fun g' t => fun₀ | a ≫ g' => b₁ * t) + sum g fun g' t => fun₀ | a ≫ g' => b₂ * t

Next tactic:
simp [add_mul]
instance : Preadditive (Free R C) where
  homGroup X Y := Finsupp.addCommGroup
  add_comp X Y Z f f' g := by
    dsimp [CategoryTheory.categoryFree]
    rw [Finsupp.sum_add_index'] <;> · simp [add_mul]
  comp_add X Y Z f g g' := by
    

Proof state:
R : Type u_1
inst✝¹ : CommRing R
C : Type u
inst✝ : Category.{v, u} C
X Y Z : Free R C
f : X ⟶ Y
g g' : Y ⟶ Z
⊢ f ≫ (g + g') = f ≫ g + f ≫ g'

Next tactic:
dsimp [CategoryTheory.categoryFree]
instance : Preadditive (Free R C) where
  homGroup X Y := Finsupp.addCommGroup
  add_comp X Y Z f f' g := by
    dsimp [CategoryTheory.categoryFree]
    rw [Finsupp.sum_add_index'] <;> · simp [add_mul]
  comp_add X Y Z f g g' := by
    dsimp [CategoryTheory.categoryFree]
    

Proof state:
R : Type u_1
inst✝¹ : CommRing R
C : Type u
inst✝ : Category.{v, u} C
X Y Z : Free R C
f : X ⟶ Y
g g' : Y ⟶ Z
⊢ (sum f fun f' s => sum (g + g') fun g' t => fun₀ | f' ≫ g' => s * t) =
    (sum f fun f' s => sum g fun g' t => fun₀ | f' ≫ g' => s * t) +
      sum f fun f' s => sum g' fun g' t => fun₀ | f' ≫ g' => s * t

Next tactic:
rw [← Finsupp.sum_add]
instance : Preadditive (Free R C) where
  homGroup X Y := Finsupp.addCommGroup
  add_comp X Y Z f f' g := by
    dsimp [CategoryTheory.categoryFree]
    rw [Finsupp.sum_add_index'] <;> · simp [add_mul]
  comp_add X Y Z f g g' := by
    dsimp [CategoryTheory.categoryFree]
    rw [← Finsupp.sum_add]
    

Proof state:
R : Type u_1
inst✝¹ : CommRing R
C : Type u
inst✝ : Category.{v, u} C
X Y Z : Free R C
f : X ⟶ Y
g g' : Y ⟶ Z
⊢ (sum f fun f' s => sum (g + g') fun g' t => fun₀ | f' ≫ g' => s * t) =
    sum f fun a b => (sum g fun g' t => fun₀ | a ≫ g' => b * t) + sum g' fun g' t => fun₀ | a ≫ g' => b * t

Next tactic:
congr
instance : Preadditive (Free R C) where
  homGroup X Y := Finsupp.addCommGroup
  add_comp X Y Z f f' g := by
    dsimp [CategoryTheory.categoryFree]
    rw [Finsupp.sum_add_index'] <;> · simp [add_mul]
  comp_add X Y Z f g g' := by
    dsimp [CategoryTheory.categoryFree]
    rw [← Finsupp.sum_add]
    congr; 

Proof state:
case e_g
R : Type u_1
inst✝¹ : CommRing R
C : Type u
inst✝ : Category.{v, u} C
X Y Z : Free R C
f : X ⟶ Y
g g' : Y ⟶ Z
⊢ (fun f' s => sum (g + g') fun g' t => fun₀ | f' ≫ g' => s * t) = fun a b =>
    (sum g fun g' t => fun₀ | a ≫ g' => b * t) + sum g' fun g' t => fun₀ | a ≫ g' => b * t

Next tactic:
ext r h
instance : Preadditive (Free R C) where
  homGroup X Y := Finsupp.addCommGroup
  add_comp X Y Z f f' g := by
    dsimp [CategoryTheory.categoryFree]
    rw [Finsupp.sum_add_index'] <;> · simp [add_mul]
  comp_add X Y Z f g g' := by
    dsimp [CategoryTheory.categoryFree]
    rw [← Finsupp.sum_add]
    congr; ext r h
    

Proof state:
case e_g.h.h.h
R : Type u_1
inst✝¹ : CommRing R
C : Type u
inst✝ : Category.{v, u} C
X Y Z : Free R C
f : X ⟶ Y
g g' : Y ⟶ Z
r : X ⟶ Y
h : R
a✝ : X ⟶ Z
⊢ (sum (g + g') fun g' t => fun₀ | r ≫ g' => h * t) a✝ =
    ((sum g fun g' t => fun₀ | r ≫ g' => h * t) + sum g' fun g' t => fun₀ | r ≫ g' => h * t) a✝

Next tactic:
rw [Finsupp.sum_add_index']
instance : Preadditive (Free R C) where
  homGroup X Y := Finsupp.addCommGroup
  add_comp X Y Z f f' g := by
    dsimp [CategoryTheory.categoryFree]
    rw [Finsupp.sum_add_index'] <;> · simp [add_mul]
  comp_add X Y Z f g g' := by
    dsimp [CategoryTheory.categoryFree]
    rw [← Finsupp.sum_add]
    congr; ext r h
    rw [Finsupp.sum_add_index'] <;> · 

Proof state:
case e_g.h.h.h.h_zero
R : Type u_1
inst✝¹ : CommRing R
C : Type u
inst✝ : Category.{v, u} C
X Y Z : Free R C
f : X ⟶ Y
g g' : Y ⟶ Z
r : X ⟶ Y
h : R
a✝ : X ⟶ Z
⊢ ∀ (a : Y ⟶ Z), (fun₀ | r ≫ a => h * 0) = 0

Next tactic:
simp [mul_add]
instance : Preadditive (Free R C) where
  homGroup X Y := Finsupp.addCommGroup
  add_comp X Y Z f f' g := by
    dsimp [CategoryTheory.categoryFree]
    rw [Finsupp.sum_add_index'] <;> · simp [add_mul]
  comp_add X Y Z f g g' := by
    dsimp [CategoryTheory.categoryFree]
    rw [← Finsupp.sum_add]
    congr; ext r h
    rw [Finsupp.sum_add_index'] <;> · 

Proof state:
case e_g.h.h.h.h_add
R : Type u_1
inst✝¹ : CommRing R
C : Type u
inst✝ : Category.{v, u} C
X Y Z : Free R C
f : X ⟶ Y
g g' : Y ⟶ Z
r : X ⟶ Y
h : R
a✝ : X ⟶ Z
⊢ ∀ (a : Y ⟶ Z) (b₁ b₂ : R), (fun₀ | r ≫ a => h * (b₁ + b₂)) = (fun₀ | r ≫ a => h * b₁) + fun₀ | r ≫ a => h * b₂

Next tactic:
simp [mul_add]
instance : Linear R (Free R C) where
  homModule X Y := Finsupp.module _ R
  smul_comp X Y Z r f g := by
    

Proof state:
R : Type u_1
inst✝¹ : CommRing R
C : Type u
inst✝ : Category.{v, u} C
X Y Z : Free R C
r : R
f : X ⟶ Y
g : Y ⟶ Z
⊢ (r • f) ≫ g = r • f ≫ g

Next tactic:
dsimp [CategoryTheory.categoryFree]
instance : Linear R (Free R C) where
  homModule X Y := Finsupp.module _ R
  smul_comp X Y Z r f g := by
    dsimp [CategoryTheory.categoryFree]
    

Proof state:
R : Type u_1
inst✝¹ : CommRing R
C : Type u
inst✝ : Category.{v, u} C
X Y Z : Free R C
r : R
f : X ⟶ Y
g : Y ⟶ Z
⊢ (sum (r • f) fun f' s => sum g fun g' t => fun₀ | f' ≫ g' => s * t) =
    r • sum f fun f' s => sum g fun g' t => fun₀ | f' ≫ g' => s * t

Next tactic:
rw [Finsupp.sum_smul_index]
instance : Linear R (Free R C) where
  homModule X Y := Finsupp.module _ R
  smul_comp X Y Z r f g := by
    dsimp [CategoryTheory.categoryFree]
    rw [Finsupp.sum_smul_index] <;> 

Proof state:
R : Type u_1
inst✝¹ : CommRing R
C : Type u
inst✝ : Category.{v, u} C
X Y Z : Free R C
r : R
f : X ⟶ Y
g : Y ⟶ Z
⊢ (sum f fun i a => sum g fun g' t => fun₀ | i ≫ g' => r * a * t) =
    r • sum f fun f' s => sum g fun g' t => fun₀ | f' ≫ g' => s * t

Next tactic:
simp [Finsupp.smul_sum, mul_assoc]
instance : Linear R (Free R C) where
  homModule X Y := Finsupp.module _ R
  smul_comp X Y Z r f g := by
    dsimp [CategoryTheory.categoryFree]
    rw [Finsupp.sum_smul_index] <;> 

Proof state:
R : Type u_1
inst✝¹ : CommRing R
C : Type u
inst✝ : Category.{v, u} C
X Y Z : Free R C
r : R
f : X ⟶ Y
g : Y ⟶ Z
⊢ ∀ (i : X ⟶ Y), (sum g fun g' t => fun₀ | i ≫ g' => 0 * t) = 0

Next tactic:
simp [Finsupp.smul_sum, mul_assoc]
instance : Linear R (Free R C) where
  homModule X Y := Finsupp.module _ R
  smul_comp X Y Z r f g := by
    dsimp [CategoryTheory.categoryFree]
    rw [Finsupp.sum_smul_index] <;> simp [Finsupp.smul_sum, mul_assoc]
  comp_smul X Y Z f r g := by
    

Proof state:
R : Type u_1
inst✝¹ : CommRing R
C : Type u
inst✝ : Category.{v, u} C
X Y Z : Free R C
f : X ⟶ Y
r : R
g : Y ⟶ Z
⊢ f ≫ (r • g) = r • f ≫ g

Next tactic:
dsimp [CategoryTheory.categoryFree]
instance : Linear R (Free R C) where
  homModule X Y := Finsupp.module _ R
  smul_comp X Y Z r f g := by
    dsimp [CategoryTheory.categoryFree]
    rw [Finsupp.sum_smul_index] <;> simp [Finsupp.smul_sum, mul_assoc]
  comp_smul X Y Z f r g := by
    dsimp [CategoryTheory.categoryFree]
    

Proof state:
R : Type u_1
inst✝¹ : CommRing R
C : Type u
inst✝ : Category.{v, u} C
X Y Z : Free R C
f : X ⟶ Y
r : R
g : Y ⟶ Z
⊢ (sum f fun f' s => sum (r • g) fun g' t => fun₀ | f' ≫ g' => s * t) =
    r • sum f fun f' s => sum g fun g' t => fun₀ | f' ≫ g' => s * t

Next tactic:
simp_rw [Finsupp.smul_sum]
instance : Linear R (Free R C) where
  homModule X Y := Finsupp.module _ R
  smul_comp X Y Z r f g := by
    dsimp [CategoryTheory.categoryFree]
    rw [Finsupp.sum_smul_index] <;> simp [Finsupp.smul_sum, mul_assoc]
  comp_smul X Y Z f r g := by
    dsimp [CategoryTheory.categoryFree]
    simp_rw [Finsupp.smul_sum]
    

Proof state:
R : Type u_1
inst✝¹ : CommRing R
C : Type u
inst✝ : Category.{v, u} C
X Y Z : Free R C
f : X ⟶ Y
r : R
g : Y ⟶ Z
⊢ (sum f fun f' s => sum (r • g) fun g' t => fun₀ | f' ≫ g' => s * t) =
    sum f fun a b => sum g fun a_1 b_1 => r • fun₀ | a ≫ a_1 => b * b_1

Next tactic:
congr
instance : Linear R (Free R C) where
  homModule X Y := Finsupp.module _ R
  smul_comp X Y Z r f g := by
    dsimp [CategoryTheory.categoryFree]
    rw [Finsupp.sum_smul_index] <;> simp [Finsupp.smul_sum, mul_assoc]
  comp_smul X Y Z f r g := by
    dsimp [CategoryTheory.categoryFree]
    simp_rw [Finsupp.smul_sum]
    congr; 

Proof state:
case e_g
R : Type u_1
inst✝¹ : CommRing R
C : Type u
inst✝ : Category.{v, u} C
X Y Z : Free R C
f : X ⟶ Y
r : R
g : Y ⟶ Z
⊢ (fun f' s => sum (r • g) fun g' t => fun₀ | f' ≫ g' => s * t) = fun a b =>
    sum g fun a_1 b_1 => r • fun₀ | a ≫ a_1 => b * b_1

Next tactic:
ext h s
instance : Linear R (Free R C) where
  homModule X Y := Finsupp.module _ R
  smul_comp X Y Z r f g := by
    dsimp [CategoryTheory.categoryFree]
    rw [Finsupp.sum_smul_index] <;> simp [Finsupp.smul_sum, mul_assoc]
  comp_smul X Y Z f r g := by
    dsimp [CategoryTheory.categoryFree]
    simp_rw [Finsupp.smul_sum]
    congr; ext h s
    

Proof state:
case e_g.h.h.h
R : Type u_1
inst✝¹ : CommRing R
C : Type u
inst✝ : Category.{v, u} C
X Y Z : Free R C
f : X ⟶ Y
r : R
g : Y ⟶ Z
h : X ⟶ Y
s : R
a✝ : X ⟶ Z
⊢ (sum (r • g) fun g' t => fun₀ | h ≫ g' => s * t) a✝ = (sum g fun a b => r • fun₀ | h ≫ a => s * b) a✝

Next tactic:
rw [Finsupp.sum_smul_index]
instance : Linear R (Free R C) where
  homModule X Y := Finsupp.module _ R
  smul_comp X Y Z r f g := by
    dsimp [CategoryTheory.categoryFree]
    rw [Finsupp.sum_smul_index] <;> simp [Finsupp.smul_sum, mul_assoc]
  comp_smul X Y Z f r g := by
    dsimp [CategoryTheory.categoryFree]
    simp_rw [Finsupp.smul_sum]
    congr; ext h s
    rw [Finsupp.sum_smul_index] <;> 

Proof state:
case e_g.h.h.h
R : Type u_1
inst✝¹ : CommRing R
C : Type u
inst✝ : Category.{v, u} C
X Y Z : Free R C
f : X ⟶ Y
r : R
g : Y ⟶ Z
h : X ⟶ Y
s : R
a✝ : X ⟶ Z
⊢ (sum g fun i a => fun₀ | h ≫ i => s * (r * a)) a✝ = (sum g fun a b => r • fun₀ | h ≫ a => s * b) a✝

Next tactic:
simp [Finsupp.smul_sum, mul_left_comm]
instance : Linear R (Free R C) where
  homModule X Y := Finsupp.module _ R
  smul_comp X Y Z r f g := by
    dsimp [CategoryTheory.categoryFree]
    rw [Finsupp.sum_smul_index] <;> simp [Finsupp.smul_sum, mul_assoc]
  comp_smul X Y Z f r g := by
    dsimp [CategoryTheory.categoryFree]
    simp_rw [Finsupp.smul_sum]
    congr; ext h s
    rw [Finsupp.sum_smul_index] <;> 

Proof state:
case e_g.h.h.h
R : Type u_1
inst✝¹ : CommRing R
C : Type u
inst✝ : Category.{v, u} C
X Y Z : Free R C
f : X ⟶ Y
r : R
g : Y ⟶ Z
h : X ⟶ Y
s : R
a✝ : X ⟶ Z
⊢ ∀ (i : Y ⟶ Z), (fun₀ | h ≫ i => s * 0) = 0

Next tactic:
simp [Finsupp.smul_sum, mul_left_comm]
theorem single_comp_single {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) (r s : R) :
    (single f r ≫ single g s : Free.of R X ⟶ Free.of R Z) = single (f ≫ g) (r * s) := by
  

Proof state:
R : Type u_1
inst✝¹ : CommRing R
C : Type u
inst✝ : Category.{v, u} C
X Y Z : C
f : X ⟶ Y
g : Y ⟶ Z
r s : R
⊢ ((fun₀ | f => r) ≫ fun₀ | g => s) = fun₀ | f ≫ g => r * s

Next tactic:
dsimp [CategoryTheory.categoryFree]
theorem single_comp_single {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z) (r s : R) :
    (single f r ≫ single g s : Free.of R X ⟶ Free.of R Z) = single (f ≫ g) (r * s) := by
  dsimp [CategoryTheory.categoryFree]; 

Proof state:
R : Type u_1
inst✝¹ : CommRing R
C : Type u
inst✝ : Category.{v, u} C
X Y Z : C
f : X ⟶ Y
g : Y ⟶ Z
r s : R
⊢ (sum (fun₀ | f => r) fun f' s_1 => sum (fun₀ | g => s) fun g' t => fun₀ | f' ≫ g' => s_1 * t) = fun₀ | f ≫ g => r * s

Next tactic:
simp
/-- A category embeds into its `R`-linear completion.
-/
@[simps]
def embedding : C ⥤ Free R C where
  obj X := X
  map {X Y} f := Finsupp.single f 1
  map_id X := rfl
  map_comp {X Y Z} f g := by
    -- Porting note: simp used to be able to close this goal
    

Proof state:
R : Type u_1
inst✝¹ : CommRing R
C : Type u
inst✝ : Category.{v, u} C
X Y Z : C
f : X ⟶ Y
g : Y ⟶ Z
⊢ { obj := fun X => X, map := fun {X Y} f => fun₀ | f => 1 }.map (f ≫ g) =
    { obj := fun X => X, map := fun {X Y} f => fun₀ | f => 1 }.map f ≫
      { obj := fun X => X, map := fun {X Y} f => fun₀ | f => 1 }.map g

Next tactic:
dsimp only []
/-- A category embeds into its `R`-linear completion.
-/
@[simps]
def embedding : C ⥤ Free R C where
  obj X := X
  map {X Y} f := Finsupp.single f 1
  map_id X := rfl
  map_comp {X Y Z} f g := by
    -- Porting note: simp used to be able to close this goal
    dsimp only []
    

Proof state:
R : Type u_1
inst✝¹ : CommRing R
C : Type u
inst✝ : Category.{v, u} C
X Y Z : C
f : X ⟶ Y
g : Y ⟶ Z
⊢ (fun₀ | f ≫ g => 1) = (fun₀ | f => 1) ≫ fun₀ | g => 1

Next tactic:
rw [single_comp_single, one_mul]
/-- A functor to an `R`-linear category lifts to a functor from its `R`-linear completion.
-/
@[simps]
def lift (F : C ⥤ D) : Free R C ⥤ D where
  obj X := F.obj X
  map {X Y} f := f.sum fun f' r => r • F.map f'
  map_id := by 

Proof state:
R : Type u_1
inst✝⁴ : CommRing R
C : Type u
inst✝³ : Category.{v, u} C
D : Type u
inst✝² : Category.{v, u} D
inst✝¹ : Preadditive D
inst✝ : Linear R D
F : C ⥤ D
⊢ ∀ (X : Free R C),
    { obj := fun X => F.obj X, map := fun {X Y} f => sum f fun f' r => r • F.map f' }.map (𝟙 X) =
      𝟙 ({ obj := fun X => F.obj X, map := fun {X Y} f => sum f fun f' r => r • F.map f' }.obj X)

Next tactic:
dsimp [CategoryTheory.categoryFree]
/-- A functor to an `R`-linear category lifts to a functor from its `R`-linear completion.
-/
@[simps]
def lift (F : C ⥤ D) : Free R C ⥤ D where
  obj X := F.obj X
  map {X Y} f := f.sum fun f' r => r • F.map f'
  map_id := by dsimp [CategoryTheory.categoryFree]; 

Proof state:
R : Type u_1
inst✝⁴ : CommRing R
C : Type u
inst✝³ : Category.{v, u} C
D : Type u
inst✝² : Category.{v, u} D
inst✝¹ : Preadditive D
inst✝ : Linear R D
F : C ⥤ D
⊢ ∀ (X : Free R C), (sum (fun₀ | 𝟙 X => 1) fun f' r => r • F.map f') = 𝟙 (F.obj X)

Next tactic:
simp
/-- A functor to an `R`-linear category lifts to a functor from its `R`-linear completion.
-/
@[simps]
def lift (F : C ⥤ D) : Free R C ⥤ D where
  obj X := F.obj X
  map {X Y} f := f.sum fun f' r => r • F.map f'
  map_id := by dsimp [CategoryTheory.categoryFree]; simp
  map_comp {X Y Z} f g := by
    

Proof state:
R : Type u_1
inst✝⁴ : CommRing R
C : Type u
inst✝³ : Category.{v, u} C
D : Type u
inst✝² : Category.{v, u} D
inst✝¹ : Preadditive D
inst✝ : Linear R D
F : C ⥤ D
X Y Z : Free R C
f : X ⟶ Y
g : Y ⟶ Z
⊢ { obj := fun X => F.obj X, map := fun {X Y} f => sum f fun f' r => r • F.map f' }.map (f ≫ g) =
    { obj := fun X => F.obj X, map := fun {X Y} f => sum f fun f' r => r • F.map f' }.map f ≫
      { obj := fun X => F.obj X, map := fun {X Y} f => sum f fun f' r => r • F.map f' }.map g

Next tactic:
apply Finsupp.induction_linear f
/-- A functor to an `R`-linear category lifts to a functor from its `R`-linear completion.
-/
@[simps]
def lift (F : C ⥤ D) : Free R C ⥤ D where
  obj X := F.obj X
  map {X Y} f := f.sum fun f' r => r • F.map f'
  map_id := by dsimp [CategoryTheory.categoryFree]; simp
  map_comp {X Y Z} f g := by
    apply Finsupp.induction_linear f
    · -- Porting note: simp used to be able to close this goal
      

Proof state:
case h0
R : Type u_1
inst✝⁴ : CommRing R
C : Type u
inst✝³ : Category.{v, u} C
D : Type u
inst✝² : Category.{v, u} D
inst✝¹ : Preadditive D
inst✝ : Linear R D
F : C ⥤ D
X Y Z : Free R C
f : X ⟶ Y
g : Y ⟶ Z
⊢ { obj := fun X => F.obj X, map := fun {X Y} f => sum f fun f' r => r • F.map f' }.map (0 ≫ g) =
    { obj := fun X => F.obj X, map := fun {X Y} f => sum f fun f' r => r • F.map f' }.map 0 ≫
      { obj := fun X => F.obj X, map := fun {X Y} f => sum f fun f' r => r • F.map f' }.map g

Next tactic:
dsimp
/-- A functor to an `R`-linear category lifts to a functor from its `R`-linear completion.
-/
@[simps]
def lift (F : C ⥤ D) : Free R C ⥤ D where
  obj X := F.obj X
  map {X Y} f := f.sum fun f' r => r • F.map f'
  map_id := by dsimp [CategoryTheory.categoryFree]; simp
  map_comp {X Y Z} f g := by
    apply Finsupp.induction_linear f
    · -- Porting note: simp used to be able to close this goal
      dsimp
      

Proof state:
case h0
R : Type u_1
inst✝⁴ : CommRing R
C : Type u
inst✝³ : Category.{v, u} C
D : Type u
inst✝² : Category.{v, u} D
inst✝¹ : Preadditive D
inst✝ : Linear R D
F : C ⥤ D
X Y Z : Free R C
f : X ⟶ Y
g : Y ⟶ Z
⊢ (sum (0 ≫ g) fun f' r => r • F.map f') = 0 ≫ sum g fun f' r => r • F.map f'

Next tactic:
rw [Limits.zero_comp, sum_zero_index, Limits.zero_comp]
/-- A functor to an `R`-linear category lifts to a functor from its `R`-linear completion.
-/
@[simps]
def lift (F : C ⥤ D) : Free R C ⥤ D where
  obj X := F.obj X
  map {X Y} f := f.sum fun f' r => r • F.map f'
  map_id := by dsimp [CategoryTheory.categoryFree]; simp
  map_comp {X Y Z} f g := by
    apply Finsupp.induction_linear f
    · -- Porting note: simp used to be able to close this goal
      dsimp
      rw [Limits.zero_comp, sum_zero_index, Limits.zero_comp]
    · 

Proof state:
case hadd
R : Type u_1
inst✝⁴ : CommRing R
C : Type u
inst✝³ : Category.{v, u} C
D : Type u
inst✝² : Category.{v, u} D
inst✝¹ : Preadditive D
inst✝ : Linear R D
F : C ⥤ D
X Y Z : Free R C
f : X ⟶ Y
g : Y ⟶ Z
⊢ ∀ (f g_1 : (X ⟶ Y) →₀ R),
    { obj := fun X => F.obj X, map := fun {X Y} f => sum f fun f' r => r • F.map f' }.map (f ≫ g) =
        { obj := fun X => F.obj X, map := fun {X Y} f => sum f fun f' r => r • F.map f' }.map f ≫
          { obj := fun X => F.obj X, map := fun {X Y} f => sum f fun f' r => r • F.map f' }.map g →
      { obj := fun X => F.obj X, map := fun {X Y} f => sum f fun f' r => r • F.map f' }.map (g_1 ≫ g) =
          { obj := fun X => F.obj X, map := fun {X Y} f => sum f fun f' r => r • F.map f' }.map g_1 ≫
            { obj := fun X => F.obj X, map := fun {X Y} f => sum f fun f' r => r • F.map f' }.map g →
        { obj := fun X => F.obj X, map := fun {X Y} f => sum f fun f' r => r • F.map f' }.map ((f + g_1) ≫ g) =
          { obj := fun X => F.obj X, map := fun {X Y} f => sum f fun f' r => r • F.map f' }.map (f + g_1) ≫
            { obj := fun X => F.obj X, map := fun {X Y} f => sum f fun f' r => r • F.map f' }.map g

Next tactic:
intro f₁ f₂ w₁ w₂
/-- A functor to an `R`-linear category lifts to a functor from its `R`-linear completion.
-/
@[simps]
def lift (F : C ⥤ D) : Free R C ⥤ D where
  obj X := F.obj X
  map {X Y} f := f.sum fun f' r => r • F.map f'
  map_id := by dsimp [CategoryTheory.categoryFree]; simp
  map_comp {X Y Z} f g := by
    apply Finsupp.induction_linear f
    · -- Porting note: simp used to be able to close this goal
      dsimp
      rw [Limits.zero_comp, sum_zero_index, Limits.zero_comp]
    · intro f₁ f₂ w₁ w₂
      

Proof state:
case hadd
R : Type u_1
inst✝⁴ : CommRing R
C : Type u
inst✝³ : Category.{v, u} C
D : Type u
inst✝² : Category.{v, u} D
inst✝¹ : Preadditive D
inst✝ : Linear R D
F : C ⥤ D
X Y Z : Free R C
f : X ⟶ Y
g : Y ⟶ Z
f₁ f₂ : (X ⟶ Y) →₀ R
w₁ :
  { obj := fun X => F.obj X, map := fun {X Y} f => sum f fun f' r => r • F.map f' }.map (f₁ ≫ g) =
    { obj := fun X => F.obj X, map := fun {X Y} f => sum f fun f' r => r • F.map f' }.map f₁ ≫
      { obj := fun X => F.obj X, map := fun {X Y} f => sum f fun f' r => r • F.map f' }.map g
w₂ :
  { obj := fun X => F.obj X, map := fun {X Y} f => sum f fun f' r => r • F.map f' }.map (f₂ ≫ g) =
    { obj := fun X => F.obj X, map := fun {X Y} f => sum f fun f' r => r • F.map f' }.map f₂ ≫
      { obj := fun X => F.obj X, map := fun {X Y} f => sum f fun f' r => r • F.map f' }.map g
⊢ { obj := fun X => F.obj X, map := fun {X Y} f => sum f fun f' r => r • F.map f' }.map ((f₁ + f₂) ≫ g) =
    { obj := fun X => F.obj X, map := fun {X Y} f => sum f fun f' r => r • F.map f' }.map (f₁ + f₂) ≫
      { obj := fun X => F.obj X, map := fun {X Y} f => sum f fun f' r => r • F.map f' }.map g

Next tactic:
rw [add_comp]
/-- A functor to an `R`-linear category lifts to a functor from its `R`-linear completion.
-/
@[simps]
def lift (F : C ⥤ D) : Free R C ⥤ D where
  obj X := F.obj X
  map {X Y} f := f.sum fun f' r => r • F.map f'
  map_id := by dsimp [CategoryTheory.categoryFree]; simp
  map_comp {X Y Z} f g := by
    apply Finsupp.induction_linear f
    · -- Porting note: simp used to be able to close this goal
      dsimp
      rw [Limits.zero_comp, sum_zero_index, Limits.zero_comp]
    · intro f₁ f₂ w₁ w₂
      rw [add_comp]
      

Proof state:
case hadd
R : Type u_1
inst✝⁴ : CommRing R
C : Type u
inst✝³ : Category.{v, u} C
D : Type u
inst✝² : Category.{v, u} D
inst✝¹ : Preadditive D
inst✝ : Linear R D
F : C ⥤ D
X Y Z : Free R C
f : X ⟶ Y
g : Y ⟶ Z
f₁ f₂ : (X ⟶ Y) →₀ R
w₁ :
  { obj := fun X => F.obj X, map := fun {X Y} f => sum f fun f' r => r • F.map f' }.map (f₁ ≫ g) =
    { obj := fun X => F.obj X, map := fun {X Y} f => sum f fun f' r => r • F.map f' }.map f₁ ≫
      { obj := fun X => F.obj X, map := fun {X Y} f => sum f fun f' r => r • F.map f' }.map g
w₂ :
  { obj := fun X => F.obj X, map := fun {X Y} f => sum f fun f' r => r • F.map f' }.map (f₂ ≫ g) =
    { obj := fun X => F.obj X, map := fun {X Y} f => sum f fun f' r => r • F.map f' }.map f₂ ≫
      { obj := fun X => F.obj X, map := fun {X Y} f => sum f fun f' r => r • F.map f' }.map g
⊢ { obj := fun X => F.obj X, map := fun {X Y} f => sum f fun f' r => r • F.map f' }.map (f₁ ≫ g + f₂ ≫ g) =
    { obj := fun X => F.obj X, map := fun {X Y} f => sum f fun f' r => r • F.map f' }.map (f₁ + f₂) ≫
      { obj := fun X => F.obj X, map := fun {X Y} f => sum f fun f' r => r • F.map f' }.map g

Next tactic:
dsimp at *
/-- A functor to an `R`-linear category lifts to a functor from its `R`-linear completion.
-/
@[simps]
def lift (F : C ⥤ D) : Free R C ⥤ D where
  obj X := F.obj X
  map {X Y} f := f.sum fun f' r => r • F.map f'
  map_id := by dsimp [CategoryTheory.categoryFree]; simp
  map_comp {X Y Z} f g := by
    apply Finsupp.induction_linear f
    · -- Porting note: simp used to be able to close this goal
      dsimp
      rw [Limits.zero_comp, sum_zero_index, Limits.zero_comp]
    · intro f₁ f₂ w₁ w₂
      rw [add_comp]
      dsimp at *
      

Proof state:
case hadd
R : Type u_1
inst✝⁴ : CommRing R
C : Type u
inst✝³ : Category.{v, u} C
D : Type u
inst✝² : Category.{v, u} D
inst✝¹ : Preadditive D
inst✝ : Linear R D
F : C ⥤ D
X Y Z : Free R C
f : X ⟶ Y
g : Y ⟶ Z
f₁ f₂ : (X ⟶ Y) →₀ R
w₁ : (sum (f₁ ≫ g) fun f' r => r • F.map f') = (sum f₁ fun f' r => r • F.map f') ≫ sum g fun f' r => r • F.map f'
w₂ : (sum (f₂ ≫ g) fun f' r => r • F.map f') = (sum f₂ fun f' r => r • F.map f') ≫ sum g fun f' r => r • F.map f'
⊢ (sum (f₁ ≫ g + f₂ ≫ g) fun f' r => r • F.map f') =
    (sum (f₁ + f₂) fun f' r => r • F.map f') ≫ sum g fun f' r => r • F.map f'

Next tactic:
rw [Finsupp.sum_add_index', Finsupp.sum_add_index']
/-- A functor to an `R`-linear category lifts to a functor from its `R`-linear completion.
-/
@[simps]
def lift (F : C ⥤ D) : Free R C ⥤ D where
  obj X := F.obj X
  map {X Y} f := f.sum fun f' r => r • F.map f'
  map_id := by dsimp [CategoryTheory.categoryFree]; simp
  map_comp {X Y Z} f g := by
    apply Finsupp.induction_linear f
    · -- Porting note: simp used to be able to close this goal
      dsimp
      rw [Limits.zero_comp, sum_zero_index, Limits.zero_comp]
    · intro f₁ f₂ w₁ w₂
      rw [add_comp]
      dsimp at *
      rw [Finsupp.sum_add_index', Finsupp.sum_add_index']
      · 

Proof state:
case hadd
R : Type u_1
inst✝⁴ : CommRing R
C : Type u
inst✝³ : Category.{v, u} C
D : Type u
inst✝² : Category.{v, u} D
inst✝¹ : Preadditive D
inst✝ : Linear R D
F : C ⥤ D
X Y Z : Free R C
f : X ⟶ Y
g : Y ⟶ Z
f₁ f₂ : (X ⟶ Y) →₀ R
w₁ : (sum (f₁ ≫ g) fun f' r => r • F.map f') = (sum f₁ fun f' r => r • F.map f') ≫ sum g fun f' r => r • F.map f'
w₂ : (sum (f₂ ≫ g) fun f' r => r • F.map f') = (sum f₂ fun f' r => r • F.map f') ≫ sum g fun f' r => r • F.map f'
⊢ ((sum (f₁ ≫ g) fun f' r => r • F.map f') + sum (f₂ ≫ g) fun f' r => r • F.map f') =
    ((sum f₁ fun f' r => r • F.map f') + sum f₂ fun f' r => r • F.map f') ≫ sum g fun f' r => r • F.map f'

Next tactic:
simp only [w₁, w₂, add_comp]