l3lab/ntp-mathlib huggingface dataset:
theorem coeff_mul_add_of_le_natDegree_of_eq_ite {d df dg : ℕ} {a b : R} {f g : R[X]}
    (h_mul_left : natDegree f ≤ df) (h_mul_right : natDegree g ≤ dg)
    (h_mul_left : f.coeff df = a) (h_mul_right : g.coeff dg = b) (ddf : df + dg ≤ d) :
    (f * g).coeff d = if d = df + dg then a * b else 0 := by
  split_ifs with h
  · subst h_mul_left h_mul_right h
    exact coeff_mul_of_natDegree_le ‹_› ‹_›
  · apply coeff_eq_zero_of_natDegree_lt
    

Proof state:
case neg.h
R : Type u_1
inst✝ : Semiring R
d df dg : ℕ
a b : R
f g : R[X]
h_mul_left✝ : natDegree f ≤ df
h_mul_right✝ : natDegree g ≤ dg
h_mul_left : coeff f df = a
h_mul_right : coeff g dg = b
ddf : df + dg ≤ d
h : ¬d = df + dg
⊢ natDegree (f * g) < d

Next tactic:
apply lt_of_le_of_lt ?_ (lt_of_le_of_ne ddf ?_)
theorem coeff_mul_add_of_le_natDegree_of_eq_ite {d df dg : ℕ} {a b : R} {f g : R[X]}
    (h_mul_left : natDegree f ≤ df) (h_mul_right : natDegree g ≤ dg)
    (h_mul_left : f.coeff df = a) (h_mul_right : g.coeff dg = b) (ddf : df + dg ≤ d) :
    (f * g).coeff d = if d = df + dg then a * b else 0 := by
  split_ifs with h
  · subst h_mul_left h_mul_right h
    exact coeff_mul_of_natDegree_le ‹_› ‹_›
  · apply coeff_eq_zero_of_natDegree_lt
    apply lt_of_le_of_lt ?_ (lt_of_le_of_ne ddf ?_)
    · 

Proof state:
R : Type u_1
inst✝ : Semiring R
d df dg : ℕ
a b : R
f g : R[X]
h_mul_left✝ : natDegree f ≤ df
h_mul_right✝ : natDegree g ≤ dg
h_mul_left : coeff f df = a
h_mul_right : coeff g dg = b
ddf : df + dg ≤ d
h : ¬d = df + dg
⊢ natDegree (f * g) ≤ df + dg

Next tactic:
exact natDegree_mul_le_of_le ‹_› ‹_›
theorem coeff_mul_add_of_le_natDegree_of_eq_ite {d df dg : ℕ} {a b : R} {f g : R[X]}
    (h_mul_left : natDegree f ≤ df) (h_mul_right : natDegree g ≤ dg)
    (h_mul_left : f.coeff df = a) (h_mul_right : g.coeff dg = b) (ddf : df + dg ≤ d) :
    (f * g).coeff d = if d = df + dg then a * b else 0 := by
  split_ifs with h
  · subst h_mul_left h_mul_right h
    exact coeff_mul_of_natDegree_le ‹_› ‹_›
  · apply coeff_eq_zero_of_natDegree_lt
    apply lt_of_le_of_lt ?_ (lt_of_le_of_ne ddf ?_)
    · exact natDegree_mul_le_of_le ‹_› ‹_›
    · 

Proof state:
R : Type u_1
inst✝ : Semiring R
d df dg : ℕ
a b : R
f g : R[X]
h_mul_left✝ : natDegree f ≤ df
h_mul_right✝ : natDegree g ≤ dg
h_mul_left : coeff f df = a
h_mul_right : coeff g dg = b
ddf : df + dg ≤ d
h : ¬d = df + dg
⊢ df + dg ≠ d

Next tactic:
exact ne_comm.mp h
theorem coeff_pow_of_natDegree_le_of_eq_ite' [Semiring R] {m n o : ℕ} {a : R} {p : R[X]}
    (h_pow : natDegree p ≤ n) (h_exp : m * n ≤ o) (h_pow_bas : coeff p n = a) :
    coeff (p ^ m) o = if o = m * n then a ^ m else 0 := by
  

Proof state:
R : Type u_1
inst✝¹ inst✝ : Semiring R
m n o : ℕ
a : R
p : R[X]
h_pow : natDegree p ≤ n
h_exp : m * n ≤ o
h_pow_bas : coeff p n = a
⊢ coeff (p ^ m) o = if o = m * n then a ^ m else 0

Next tactic:
split_ifs with h
theorem coeff_pow_of_natDegree_le_of_eq_ite' [Semiring R] {m n o : ℕ} {a : R} {p : R[X]}
    (h_pow : natDegree p ≤ n) (h_exp : m * n ≤ o) (h_pow_bas : coeff p n = a) :
    coeff (p ^ m) o = if o = m * n then a ^ m else 0 := by
  split_ifs with h
  · 

Proof state:
case pos
R : Type u_1
inst✝¹ inst✝ : Semiring R
m n o : ℕ
a : R
p : R[X]
h_pow : natDegree p ≤ n
h_exp : m * n ≤ o
h_pow_bas : coeff p n = a
h : o = m * n
⊢ coeff (p ^ m) o = a ^ m

Next tactic:
subst h h_pow_bas
theorem coeff_pow_of_natDegree_le_of_eq_ite' [Semiring R] {m n o : ℕ} {a : R} {p : R[X]}
    (h_pow : natDegree p ≤ n) (h_exp : m * n ≤ o) (h_pow_bas : coeff p n = a) :
    coeff (p ^ m) o = if o = m * n then a ^ m else 0 := by
  split_ifs with h
  · subst h h_pow_bas
    

Proof state:
case pos
R : Type u_1
inst✝¹ inst✝ : Semiring R
m n : ℕ
p : R[X]
h_pow : natDegree p ≤ n
h_exp : m * n ≤ m * n
⊢ coeff (p ^ m) (m * n) = coeff p n ^ m

Next tactic:
exact coeff_pow_of_natDegree_le ‹_›
theorem coeff_pow_of_natDegree_le_of_eq_ite' [Semiring R] {m n o : ℕ} {a : R} {p : R[X]}
    (h_pow : natDegree p ≤ n) (h_exp : m * n ≤ o) (h_pow_bas : coeff p n = a) :
    coeff (p ^ m) o = if o = m * n then a ^ m else 0 := by
  split_ifs with h
  · subst h h_pow_bas
    exact coeff_pow_of_natDegree_le ‹_›
  · 

Proof state:
case neg
R : Type u_1
inst✝¹ inst✝ : Semiring R
m n o : ℕ
a : R
p : R[X]
h_pow : natDegree p ≤ n
h_exp : m * n ≤ o
h_pow_bas : coeff p n = a
h : ¬o = m * n
⊢ coeff (p ^ m) o = 0

Next tactic:
apply coeff_eq_zero_of_natDegree_lt
theorem coeff_pow_of_natDegree_le_of_eq_ite' [Semiring R] {m n o : ℕ} {a : R} {p : R[X]}
    (h_pow : natDegree p ≤ n) (h_exp : m * n ≤ o) (h_pow_bas : coeff p n = a) :
    coeff (p ^ m) o = if o = m * n then a ^ m else 0 := by
  split_ifs with h
  · subst h h_pow_bas
    exact coeff_pow_of_natDegree_le ‹_›
  · apply coeff_eq_zero_of_natDegree_lt
    

Proof state:
case neg.h
R : Type u_1
inst✝¹ inst✝ : Semiring R
m n o : ℕ
a : R
p : R[X]
h_pow : natDegree p ≤ n
h_exp : m * n ≤ o
h_pow_bas : coeff p n = a
h : ¬o = m * n
⊢ natDegree (p ^ m) < o

Next tactic:
apply lt_of_le_of_lt ?_ (lt_of_le_of_ne ‹_› ?_)
theorem coeff_pow_of_natDegree_le_of_eq_ite' [Semiring R] {m n o : ℕ} {a : R} {p : R[X]}
    (h_pow : natDegree p ≤ n) (h_exp : m * n ≤ o) (h_pow_bas : coeff p n = a) :
    coeff (p ^ m) o = if o = m * n then a ^ m else 0 := by
  split_ifs with h
  · subst h h_pow_bas
    exact coeff_pow_of_natDegree_le ‹_›
  · apply coeff_eq_zero_of_natDegree_lt
    apply lt_of_le_of_lt ?_ (lt_of_le_of_ne ‹_› ?_)
    · 

Proof state:
R : Type u_1
inst✝¹ inst✝ : Semiring R
m n o : ℕ
a : R
p : R[X]
h_pow : natDegree p ≤ n
h_exp : m * n ≤ o
h_pow_bas : coeff p n = a
h : ¬o = m * n
⊢ natDegree (p ^ m) ≤ m * n

Next tactic:
exact natDegree_pow_le_of_le m ‹_›
theorem coeff_pow_of_natDegree_le_of_eq_ite' [Semiring R] {m n o : ℕ} {a : R} {p : R[X]}
    (h_pow : natDegree p ≤ n) (h_exp : m * n ≤ o) (h_pow_bas : coeff p n = a) :
    coeff (p ^ m) o = if o = m * n then a ^ m else 0 := by
  split_ifs with h
  · subst h h_pow_bas
    exact coeff_pow_of_natDegree_le ‹_›
  · apply coeff_eq_zero_of_natDegree_lt
    apply lt_of_le_of_lt ?_ (lt_of_le_of_ne ‹_› ?_)
    · exact natDegree_pow_le_of_le m ‹_›
    · 

Proof state:
R : Type u_1
inst✝¹ inst✝ : Semiring R
m n o : ℕ
a : R
p : R[X]
h_pow : natDegree p ≤ n
h_exp : m * n ≤ o
h_pow_bas : coeff p n = a
h : ¬o = m * n
⊢ m * n ≠ o

Next tactic:
exact Iff.mp ne_comm h
/--  The following two lemmas should be viewed as a hand-made "congr"-lemmas.
They achieve the following goals.
* They introduce *two* fresh metavariables replacing the given one `deg`,
  one for the `natDegree ≤` computation and one for the `coeff =` computation.
  This helps `compute_degree`, since it does not "pre-estimate" the degree,
  but it "picks it up along the way".
* They split checking the inequality `coeff p n ≠ 0` into the task of
  finding a value `c` for the `coeff` and then
  proving that this value is non-zero by `coeff_ne_zero`.
-/
theorem natDegree_eq_of_le_of_coeff_ne_zero' {deg m o : ℕ} {c : R} {p : R[X]}
    (h_natDeg_le : natDegree p ≤ m) (coeff_eq : coeff p o = c)
    (coeff_ne_zero : c ≠ 0) (deg_eq_deg : m = deg) (coeff_eq_deg : o = deg) :
    natDegree p = deg := by
  

Proof state:
R : Type u_1
inst✝ : Semiring R
deg m o : ℕ
c : R
p : R[X]
h_natDeg_le : natDegree p ≤ m
coeff_eq : coeff p o = c
coeff_ne_zero : c ≠ 0
deg_eq_deg : m = deg
coeff_eq_deg : o = deg
⊢ natDegree p = deg

Next tactic:
subst coeff_eq deg_eq_deg coeff_eq_deg
/--  The following two lemmas should be viewed as a hand-made "congr"-lemmas.
They achieve the following goals.
* They introduce *two* fresh metavariables replacing the given one `deg`,
  one for the `natDegree ≤` computation and one for the `coeff =` computation.
  This helps `compute_degree`, since it does not "pre-estimate" the degree,
  but it "picks it up along the way".
* They split checking the inequality `coeff p n ≠ 0` into the task of
  finding a value `c` for the `coeff` and then
  proving that this value is non-zero by `coeff_ne_zero`.
-/
theorem natDegree_eq_of_le_of_coeff_ne_zero' {deg m o : ℕ} {c : R} {p : R[X]}
    (h_natDeg_le : natDegree p ≤ m) (coeff_eq : coeff p o = c)
    (coeff_ne_zero : c ≠ 0) (deg_eq_deg : m = deg) (coeff_eq_deg : o = deg) :
    natDegree p = deg := by
  subst coeff_eq deg_eq_deg coeff_eq_deg
  

Proof state:
R : Type u_1
inst✝ : Semiring R
o : ℕ
p : R[X]
coeff_ne_zero : coeff p o ≠ 0
h_natDeg_le : natDegree p ≤ o
⊢ natDegree p = o

Next tactic:
exact natDegree_eq_of_le_of_coeff_ne_zero ‹_› ‹_›
theorem degree_eq_of_le_of_coeff_ne_zero' {deg m o : WithBot ℕ} {c : R} {p : R[X]}
    (h_deg_le : degree p ≤ m) (coeff_eq : coeff p (WithBot.unbot' 0 deg) = c)
    (coeff_ne_zero : c ≠ 0) (deg_eq_deg : m = deg) (coeff_eq_deg : o = deg) :
    degree p = deg := by
  

Proof state:
R : Type u_1
inst✝ : Semiring R
deg m o : WithBot ℕ
c : R
p : R[X]
h_deg_le : degree p ≤ m
coeff_eq : coeff p (WithBot.unbot' 0 deg) = c
coeff_ne_zero : c ≠ 0
deg_eq_deg : m = deg
coeff_eq_deg : o = deg
⊢ degree p = deg

Next tactic:
subst coeff_eq coeff_eq_deg deg_eq_deg
theorem degree_eq_of_le_of_coeff_ne_zero' {deg m o : WithBot ℕ} {c : R} {p : R[X]}
    (h_deg_le : degree p ≤ m) (coeff_eq : coeff p (WithBot.unbot' 0 deg) = c)
    (coeff_ne_zero : c ≠ 0) (deg_eq_deg : m = deg) (coeff_eq_deg : o = deg) :
    degree p = deg := by
  subst coeff_eq coeff_eq_deg deg_eq_deg
  

Proof state:
R : Type u_1
inst✝ : Semiring R
m : WithBot ℕ
p : R[X]
h_deg_le : degree p ≤ m
coeff_ne_zero : coeff p (WithBot.unbot' 0 m) ≠ 0
⊢ degree p = m

Next tactic:
rcases eq_or_ne m ⊥ with rfl|hh
theorem degree_eq_of_le_of_coeff_ne_zero' {deg m o : WithBot ℕ} {c : R} {p : R[X]}
    (h_deg_le : degree p ≤ m) (coeff_eq : coeff p (WithBot.unbot' 0 deg) = c)
    (coeff_ne_zero : c ≠ 0) (deg_eq_deg : m = deg) (coeff_eq_deg : o = deg) :
    degree p = deg := by
  subst coeff_eq coeff_eq_deg deg_eq_deg
  rcases eq_or_ne m ⊥ with rfl|hh
  · 

Proof state:
case inl
R : Type u_1
inst✝ : Semiring R
p : R[X]
h_deg_le : degree p ≤ ⊥
coeff_ne_zero : coeff p (WithBot.unbot' 0 ⊥) ≠ 0
⊢ degree p = ⊥

Next tactic:
exact bot_unique h_deg_le
theorem degree_eq_of_le_of_coeff_ne_zero' {deg m o : WithBot ℕ} {c : R} {p : R[X]}
    (h_deg_le : degree p ≤ m) (coeff_eq : coeff p (WithBot.unbot' 0 deg) = c)
    (coeff_ne_zero : c ≠ 0) (deg_eq_deg : m = deg) (coeff_eq_deg : o = deg) :
    degree p = deg := by
  subst coeff_eq coeff_eq_deg deg_eq_deg
  rcases eq_or_ne m ⊥ with rfl|hh
  · exact bot_unique h_deg_le
  · 

Proof state:
case inr
R : Type u_1
inst✝ : Semiring R
m : WithBot ℕ
p : R[X]
h_deg_le : degree p ≤ m
coeff_ne_zero : coeff p (WithBot.unbot' 0 m) ≠ 0
hh : m ≠ ⊥
⊢ degree p = m

Next tactic:
obtain ⟨m, rfl⟩ := WithBot.ne_bot_iff_exists.mp hh
theorem degree_eq_of_le_of_coeff_ne_zero' {deg m o : WithBot ℕ} {c : R} {p : R[X]}
    (h_deg_le : degree p ≤ m) (coeff_eq : coeff p (WithBot.unbot' 0 deg) = c)
    (coeff_ne_zero : c ≠ 0) (deg_eq_deg : m = deg) (coeff_eq_deg : o = deg) :
    degree p = deg := by
  subst coeff_eq coeff_eq_deg deg_eq_deg
  rcases eq_or_ne m ⊥ with rfl|hh
  · exact bot_unique h_deg_le
  · obtain ⟨m, rfl⟩ := WithBot.ne_bot_iff_exists.mp hh
    

Proof state:
case inr.intro
R : Type u_1
inst✝ : Semiring R
p : R[X]
m : ℕ
h_deg_le : degree p ≤ ↑m
coeff_ne_zero : coeff p (WithBot.unbot' 0 ↑m) ≠ 0
hh : ↑m ≠ ⊥
⊢ degree p = ↑m

Next tactic:
exact degree_eq_of_le_of_coeff_ne_zero ‹_› ‹_›
theorem coeff_sub_of_eq {n : ℕ} {a b : R} {f g : R[X]} (hf : f.coeff n = a) (hg : g.coeff n = b) :
    (f - g).coeff n = a - b := by 

Proof state:
R : Type u_1
inst✝ : Ring R
n : ℕ
a b : R
f g : R[X]
hf : coeff f n = a
hg : coeff g n = b
⊢ coeff (f - g) n = a - b

Next tactic:
subst hf hg
theorem coeff_sub_of_eq {n : ℕ} {a b : R} {f g : R[X]} (hf : f.coeff n = a) (hg : g.coeff n = b) :
    (f - g).coeff n = a - b := by subst hf hg; 

Proof state:
R : Type u_1
inst✝ : Ring R
n : ℕ
f g : R[X]
⊢ coeff (f - g) n = coeff f n - coeff g n

Next tactic:
apply coeff_sub
theorem coeff_int_cast_ite {n : ℕ} {a : ℤ} : (Int.cast a : R[X]).coeff n = ite (n = 0) a 0 := by
  

Proof state:
R : Type u_1
inst✝ : Ring R
n : ℕ
a : ℤ
⊢ coeff (↑a) n = ↑(if n = 0 then a else 0)

Next tactic:
simp only [← C_eq_int_cast, coeff_C, Int.cast_ite, Int.cast_zero]
/-- The functor `Karoubi (HomologicalComplex C c) ⥤ HomologicalComplex (Karoubi C) c`,
on objects. -/
@[simps]
def obj (P : Karoubi (HomologicalComplex C c)) : HomologicalComplex (Karoubi C) c where
  X n :=
    ⟨P.X.X n, P.p.f n, by
      

Proof state:
C : Type u_1
inst✝¹ : Category.{?u.4031, u_1} C
inst✝ : Preadditive C
ι : Type u_2
c : ComplexShape ι
P : Karoubi (HomologicalComplex C c)
n : ι
⊢ HomologicalComplex.Hom.f P.p n ≫ HomologicalComplex.Hom.f P.p n = HomologicalComplex.Hom.f P.p n

Next tactic:
simpa only [HomologicalComplex.comp_f] using HomologicalComplex.congr_hom P.idem n
/-- The functor `Karoubi (HomologicalComplex C c) ⥤ HomologicalComplex (Karoubi C) c`,
on objects. -/
@[simps]
def obj (P : Karoubi (HomologicalComplex C c)) : HomologicalComplex (Karoubi C) c where
  X n :=
    ⟨P.X.X n, P.p.f n, by
      simpa only [HomologicalComplex.comp_f] using HomologicalComplex.congr_hom P.idem n⟩
  d i j := { f := P.p.f i ≫ P.X.d i j }
  shape i j hij := by 

Proof state:
C : Type u_1
inst✝¹ : Category.{?u.4031, u_1} C
inst✝ : Preadditive C
ι : Type u_2
c : ComplexShape ι
P : Karoubi (HomologicalComplex C c)
i j : ι
hij : ¬ComplexShape.Rel c i j
⊢ (fun i j => Hom.mk (HomologicalComplex.Hom.f P.p i ≫ HomologicalComplex.d P.X i j)) i j = 0

Next tactic:
simp only [hom_eq_zero_iff, P.X.shape i j hij, Limits.comp_zero]
/-- The functor `Karoubi (HomologicalComplex C c) ⥤ HomologicalComplex (Karoubi C) c`,
on objects. -/
@[simps]
def obj (P : Karoubi (HomologicalComplex C c)) : HomologicalComplex (Karoubi C) c where
  X n :=
    ⟨P.X.X n, P.p.f n, by
      simpa only [HomologicalComplex.comp_f] using HomologicalComplex.congr_hom P.idem n⟩
  d i j := { f := P.p.f i ≫ P.X.d i j }
  shape i j hij := by simp only [hom_eq_zero_iff, P.X.shape i j hij, Limits.comp_zero]; 

Proof state:
C : Type u_1
inst✝¹ : Category.{?u.4031, u_1} C
inst✝ : Preadditive C
ι : Type u_2
c : ComplexShape ι
P : Karoubi (HomologicalComplex C c)
i j : ι
hij : ¬ComplexShape.Rel c i j
⊢ HomologicalComplex.Hom.f P.p i ≫ HomologicalComplex.d P.X i j = 0

Next tactic:
aesop_cat
/-- The functor `HomologicalComplex (Karoubi C) c ⥤ Karoubi (HomologicalComplex C c)`,
on objects -/
@[simps]
def obj (K : HomologicalComplex (Karoubi C) c) : Karoubi (HomologicalComplex C c) where
  X :=
    { X := fun n => (K.X n).X
      d := fun i j => (K.d i j).f
      shape := fun i j hij => hom_eq_zero_iff.mp (K.shape i j hij)
      d_comp_d' := fun i j k _ _ => by
        

Proof state:
C : Type u_1
inst✝¹ : Category.{?u.12906, u_1} C
inst✝ : Preadditive C
ι : Type u_2
c : ComplexShape ι
K : HomologicalComplex (Karoubi C) c
i j k : ι
x✝¹ : ComplexShape.Rel c i j
x✝ : ComplexShape.Rel c j k
⊢ (fun i j => (HomologicalComplex.d K i j).f) i j ≫ (fun i j => (HomologicalComplex.d K i j).f) j k = 0

Next tactic:
simpa only [comp_f] using hom_eq_zero_iff.mp (K.d_comp_d i j k)
/-- The functor `HomologicalComplex (Karoubi C) c ⥤ Karoubi (HomologicalComplex C c)`,
on morphisms -/
@[simps]
def map {K L : HomologicalComplex (Karoubi C) c} (f : K ⟶ L) : obj K ⟶ obj L where
  f :=
    { f := fun n => (f.f n).f
      comm' := fun i j hij => by 

Proof state:
C : Type u_1
inst✝¹ : Category.{?u.18968, u_1} C
inst✝ : Preadditive C
ι : Type u_2
c : ComplexShape ι
K L : HomologicalComplex (Karoubi C) c
f : K ⟶ L
i j : ι
hij : ComplexShape.Rel c i j
⊢ (fun n => (HomologicalComplex.Hom.f f n).f) i ≫ HomologicalComplex.d (obj L).X i j =
    HomologicalComplex.d (obj K).X i j ≫ (fun n => (HomologicalComplex.Hom.f f n).f) j

Next tactic:
simpa only [comp_f] using hom_ext_iff.mp (f.comm' i j hij)
/-- The counit isomorphism of the equivalence
`Karoubi (HomologicalComplex C c) ≌ HomologicalComplex (Karoubi C) c`. -/
@[simps!]
def counitIso : inverse ⋙ functor ≅ 𝟭 (HomologicalComplex (Karoubi C) c) :=
  eqToIso (Functor.ext (fun P => HomologicalComplex.ext (by 

Proof state:
C : Type u_1
inst✝¹ : Category.{?u.24210, u_1} C
inst✝ : Preadditive C
ι : Type u_2
c : ComplexShape ι
P : HomologicalComplex (Karoubi C) c
⊢ ((inverse ⋙ functor).obj P).X = ((𝟭 (HomologicalComplex (Karoubi C) c)).obj P).X

Next tactic:
aesop_cat
/-- The counit isomorphism of the equivalence
`Karoubi (HomologicalComplex C c) ≌ HomologicalComplex (Karoubi C) c`. -/
@[simps!]
def counitIso : inverse ⋙ functor ≅ 𝟭 (HomologicalComplex (Karoubi C) c) :=
  eqToIso (Functor.ext (fun P => HomologicalComplex.ext (by aesop_cat) (by 

Proof state:
C : Type u_1
inst✝¹ : Category.{?u.24210, u_1} C
inst✝ : Preadditive C
ι : Type u_2
c : ComplexShape ι
P : HomologicalComplex (Karoubi C) c
⊢ ∀ (i j : ι),
    ComplexShape.Rel c i j →
      HomologicalComplex.d ((inverse ⋙ functor).obj P) i j ≫
          eqToHom
            (_ :
              HomologicalComplex.X ((inverse ⋙ functor).obj P) j =
                HomologicalComplex.X ((𝟭 (HomologicalComplex (Karoubi C) c)).obj P) j) =
        eqToHom
            (_ :
              HomologicalComplex.X ((inverse ⋙ functor).obj P) i =
                HomologicalComplex.X ((𝟭 (HomologicalComplex (Karoubi C) c)).obj P) i) ≫
          HomologicalComplex.d ((𝟭 (HomologicalComplex (Karoubi C) c)).obj P) i j

Next tactic:
aesop_cat
/-- The counit isomorphism of the equivalence
`Karoubi (HomologicalComplex C c) ≌ HomologicalComplex (Karoubi C) c`. -/
@[simps!]
def counitIso : inverse ⋙ functor ≅ 𝟭 (HomologicalComplex (Karoubi C) c) :=
  eqToIso (Functor.ext (fun P => HomologicalComplex.ext (by aesop_cat) (by aesop_cat))
    (by 

Proof state:
C : Type u_1
inst✝¹ : Category.{?u.24210, u_1} C
inst✝ : Preadditive C
ι : Type u_2
c : ComplexShape ι
⊢ ∀ (X Y : HomologicalComplex (Karoubi C) c) (f : X ⟶ Y),
    (inverse ⋙ functor).map f =
      eqToHom (_ : (inverse ⋙ functor).obj X = (𝟭 (HomologicalComplex (Karoubi C) c)).obj X) ≫
        (𝟭 (HomologicalComplex (Karoubi C) c)).map f ≫
          eqToHom (_ : (𝟭 (HomologicalComplex (Karoubi C) c)).obj Y = (inverse ⋙ functor).obj Y)

Next tactic:
aesop_cat
/-- The unit isomorphism of the equivalence
`Karoubi (HomologicalComplex C c) ≌ HomologicalComplex (Karoubi C) c`. -/
@[simps]
def unitIso : 𝟭 (Karoubi (HomologicalComplex C c)) ≅ functor ⋙ inverse where
  hom :=
    { app := fun P =>
        { f :=
            { f := fun n => P.p.f n
              comm' := fun i j _ => by
                

Proof state:
C : Type u_1
inst✝¹ : Category.{?u.36754, u_1} C
inst✝ : Preadditive C
ι : Type u_2
c : ComplexShape ι
P : Karoubi (HomologicalComplex C c)
i j : ι
x✝ : ComplexShape.Rel c i j
⊢ (fun n => HomologicalComplex.Hom.f P.p n) i ≫ HomologicalComplex.d ((functor ⋙ inverse).obj P).X i j =
    HomologicalComplex.d ((𝟭 (Karoubi (HomologicalComplex C c))).obj P).X i j ≫
      (fun n => HomologicalComplex.Hom.f P.p n) j

Next tactic:
dsimp
/-- The unit isomorphism of the equivalence
`Karoubi (HomologicalComplex C c) ≌ HomologicalComplex (Karoubi C) c`. -/
@[simps]
def unitIso : 𝟭 (Karoubi (HomologicalComplex C c)) ≅ functor ⋙ inverse where
  hom :=
    { app := fun P =>
        { f :=
            { f := fun n => P.p.f n
              comm' := fun i j _ => by
                dsimp
                

Proof state:
C : Type u_1
inst✝¹ : Category.{?u.36754, u_1} C
inst✝ : Preadditive C
ι : Type u_2
c : ComplexShape ι
P : Karoubi (HomologicalComplex C c)
i j : ι
x✝ : ComplexShape.Rel c i j
⊢ HomologicalComplex.Hom.f P.p i ≫ HomologicalComplex.Hom.f P.p i ≫ HomologicalComplex.d P.X i j =
    HomologicalComplex.d P.X i j ≫ HomologicalComplex.Hom.f P.p j

Next tactic:
simp only [HomologicalComplex.Hom.comm, HomologicalComplex.Hom.comm_assoc,
                  HomologicalComplex.p_idem]
/-- The unit isomorphism of the equivalence
`Karoubi (HomologicalComplex C c) ≌ HomologicalComplex (Karoubi C) c`. -/
@[simps]
def unitIso : 𝟭 (Karoubi (HomologicalComplex C c)) ≅ functor ⋙ inverse where
  hom :=
    { app := fun P =>
        { f :=
            { f := fun n => P.p.f n
              comm' := fun i j _ => by
                dsimp
                simp only [HomologicalComplex.Hom.comm, HomologicalComplex.Hom.comm_assoc,
                  HomologicalComplex.p_idem] }
          comm := by
            

Proof state:
C : Type u_1
inst✝¹ : Category.{?u.36754, u_1} C
inst✝ : Preadditive C
ι : Type u_2
c : ComplexShape ι
P : Karoubi (HomologicalComplex C c)
⊢ (HomologicalComplex.Hom.mk fun n => HomologicalComplex.Hom.f P.p n) =
    ((𝟭 (Karoubi (HomologicalComplex C c))).obj P).p ≫
      (HomologicalComplex.Hom.mk fun n => HomologicalComplex.Hom.f P.p n) ≫ ((functor ⋙ inverse).obj P).p

Next tactic:
ext n
/-- The unit isomorphism of the equivalence
`Karoubi (HomologicalComplex C c) ≌ HomologicalComplex (Karoubi C) c`. -/
@[simps]
def unitIso : 𝟭 (Karoubi (HomologicalComplex C c)) ≅ functor ⋙ inverse where
  hom :=
    { app := fun P =>
        { f :=
            { f := fun n => P.p.f n
              comm' := fun i j _ => by
                dsimp
                simp only [HomologicalComplex.Hom.comm, HomologicalComplex.Hom.comm_assoc,
                  HomologicalComplex.p_idem] }
          comm := by
            ext n
            

Proof state:
case h
C : Type u_1
inst✝¹ : Category.{?u.36754, u_1} C
inst✝ : Preadditive C
ι : Type u_2
c : ComplexShape ι
P : Karoubi (HomologicalComplex C c)
n : ι
⊢ HomologicalComplex.Hom.f (HomologicalComplex.Hom.mk fun n => HomologicalComplex.Hom.f P.p n) n =
    HomologicalComplex.Hom.f
      (((𝟭 (Karoubi (HomologicalComplex C c))).obj P).p ≫
        (HomologicalComplex.Hom.mk fun n => HomologicalComplex.Hom.f P.p n) ≫ ((functor ⋙ inverse).obj P).p)
      n

Next tactic:
dsimp
/-- The unit isomorphism of the equivalence
`Karoubi (HomologicalComplex C c) ≌ HomologicalComplex (Karoubi C) c`. -/
@[simps]
def unitIso : 𝟭 (Karoubi (HomologicalComplex C c)) ≅ functor ⋙ inverse where
  hom :=
    { app := fun P =>
        { f :=
            { f := fun n => P.p.f n
              comm' := fun i j _ => by
                dsimp
                simp only [HomologicalComplex.Hom.comm, HomologicalComplex.Hom.comm_assoc,
                  HomologicalComplex.p_idem] }
          comm := by
            ext n
            dsimp
            

Proof state:
case h
C : Type u_1
inst✝¹ : Category.{?u.36754, u_1} C
inst✝ : Preadditive C
ι : Type u_2
c : ComplexShape ι
P : Karoubi (HomologicalComplex C c)
n : ι
⊢ HomologicalComplex.Hom.f P.p n =
    HomologicalComplex.Hom.f P.p n ≫ HomologicalComplex.Hom.f P.p n ≫ HomologicalComplex.Hom.f P.p n

Next tactic:
simp only [HomologicalComplex.p_idem]
/-- The unit isomorphism of the equivalence
`Karoubi (HomologicalComplex C c) ≌ HomologicalComplex (Karoubi C) c`. -/
@[simps]
def unitIso : 𝟭 (Karoubi (HomologicalComplex C c)) ≅ functor ⋙ inverse where
  hom :=
    { app := fun P =>
        { f :=
            { f := fun n => P.p.f n
              comm' := fun i j _ => by
                dsimp
                simp only [HomologicalComplex.Hom.comm, HomologicalComplex.Hom.comm_assoc,
                  HomologicalComplex.p_idem] }
          comm := by
            ext n
            dsimp
            simp only [HomologicalComplex.p_idem] }
      naturality := fun P Q φ => by
        

Proof state:
C : Type u_1
inst✝¹ : Category.{?u.36754, u_1} C
inst✝ : Preadditive C
ι : Type u_2
c : ComplexShape ι
P Q : Karoubi (HomologicalComplex C c)
φ : P ⟶ Q
⊢ (𝟭 (Karoubi (HomologicalComplex C c))).map φ ≫
      (fun P => Hom.mk (HomologicalComplex.Hom.mk fun n => HomologicalComplex.Hom.f P.p n)) Q =
    (fun P => Hom.mk (HomologicalComplex.Hom.mk fun n => HomologicalComplex.Hom.f P.p n)) P ≫ (functor ⋙ inverse).map φ

Next tactic:
ext