l3lab/ntp-mathlib huggingface dataset:
/-- If a function is monotone and is bounded on a set `s`, then it admits a monotone extension to
the whole space. -/
theorem MonotoneOn.exists_monotone_extension (h : MonotoneOn f s) (hl : BddBelow (f '' s))
    (hu : BddAbove (f '' s)) : ∃ g : α → β, Monotone g ∧ EqOn f g s := by
  classical
    /- The extension is defined by `f x = f a` for `x ≤ a`, and `f x` is the supremum of the values
      of `f` to the left of `x` for `x ≥ a`. -/
    rcases hl with ⟨a, ha⟩
    have hu' : ∀ x, BddAbove (f '' (Iic x ∩ s)) := fun x =>
      hu.mono (image_subset _ (inter_subset_right _ _))
    let g : α → β := fun x => if Disjoint (Iic x) s then a else sSup (f '' (Iic x ∩ s))
    have hgs : EqOn f g s := by
      intro x hx
      simp only []
      have : IsGreatest (Iic x ∩ s) x := ⟨⟨right_mem_Iic, hx⟩, fun y hy => hy.1⟩
      rw [if_neg this.nonempty.not_disjoint,
        ((h.mono <| inter_subset_right _ _).map_isGreatest this).csSup_eq]
    refine' ⟨g, fun x y hxy => _, hgs⟩
    by_cases hx : Disjoint (Iic x) s <;> by_cases hy : Disjoint (Iic y) s <;>
      simp only [if_pos, if_neg, not_false_iff, *, refl]
    · rcases not_disjoint_iff_nonempty_inter.1 hy with ⟨z, hz⟩
      exact le_csSup_of_le (hu' _) (mem_image_of_mem _ hz) (ha <| mem_image_of_mem _ hz.2)
    · exact (hx <| hy.mono_left <| Iic_subset_Iic.2 hxy).elim
    · rw [not_disjoint_iff_nonempty_inter] at hx hy
      

Proof state:
case neg
α : Type u_1
β : Type u_2
inst✝¹ : LinearOrder α
inst✝ : ConditionallyCompleteLinearOrder β
f : α → β
s : Set α
a✝ b : α
h : MonotoneOn f s
hu : BddAbove (f '' s)
a : β
ha : a ∈ lowerBounds (f '' s)
hu' : ∀ (x : α), BddAbove (f '' (Iic x ∩ s))
g : α → β := fun x => if Disjoint (Iic x) s then a else sSup (f '' (Iic x ∩ s))
hgs : EqOn f g s
x y : α
hxy : x ≤ y
hx : Set.Nonempty (Iic x ∩ s)
hy : Set.Nonempty (Iic y ∩ s)
⊢ sSup (f '' (Iic x ∩ s)) ≤ sSup (f '' (Iic y ∩ s))

Next tactic:
refine' csSup_le_csSup (hu' _) (hx.image _) (image_subset _ _)
/-- If a function is monotone and is bounded on a set `s`, then it admits a monotone extension to
the whole space. -/
theorem MonotoneOn.exists_monotone_extension (h : MonotoneOn f s) (hl : BddBelow (f '' s))
    (hu : BddAbove (f '' s)) : ∃ g : α → β, Monotone g ∧ EqOn f g s := by
  classical
    /- The extension is defined by `f x = f a` for `x ≤ a`, and `f x` is the supremum of the values
      of `f` to the left of `x` for `x ≥ a`. -/
    rcases hl with ⟨a, ha⟩
    have hu' : ∀ x, BddAbove (f '' (Iic x ∩ s)) := fun x =>
      hu.mono (image_subset _ (inter_subset_right _ _))
    let g : α → β := fun x => if Disjoint (Iic x) s then a else sSup (f '' (Iic x ∩ s))
    have hgs : EqOn f g s := by
      intro x hx
      simp only []
      have : IsGreatest (Iic x ∩ s) x := ⟨⟨right_mem_Iic, hx⟩, fun y hy => hy.1⟩
      rw [if_neg this.nonempty.not_disjoint,
        ((h.mono <| inter_subset_right _ _).map_isGreatest this).csSup_eq]
    refine' ⟨g, fun x y hxy => _, hgs⟩
    by_cases hx : Disjoint (Iic x) s <;> by_cases hy : Disjoint (Iic y) s <;>
      simp only [if_pos, if_neg, not_false_iff, *, refl]
    · rcases not_disjoint_iff_nonempty_inter.1 hy with ⟨z, hz⟩
      exact le_csSup_of_le (hu' _) (mem_image_of_mem _ hz) (ha <| mem_image_of_mem _ hz.2)
    · exact (hx <| hy.mono_left <| Iic_subset_Iic.2 hxy).elim
    · rw [not_disjoint_iff_nonempty_inter] at hx hy
      refine' csSup_le_csSup (hu' _) (hx.image _) (image_subset _ _)
      

Proof state:
case neg
α : Type u_1
β : Type u_2
inst✝¹ : LinearOrder α
inst✝ : ConditionallyCompleteLinearOrder β
f : α → β
s : Set α
a✝ b : α
h : MonotoneOn f s
hu : BddAbove (f '' s)
a : β
ha : a ∈ lowerBounds (f '' s)
hu' : ∀ (x : α), BddAbove (f '' (Iic x ∩ s))
g : α → β := fun x => if Disjoint (Iic x) s then a else sSup (f '' (Iic x ∩ s))
hgs : EqOn f g s
x y : α
hxy : x ≤ y
hx : Set.Nonempty (Iic x ∩ s)
hy : Set.Nonempty (Iic y ∩ s)
⊢ Iic x ∩ s ⊆ Iic y ∩ s

Next tactic:
exact inter_subset_inter_left _ (Iic_subset_Iic.2 hxy)
/-- A natural transformation between functors `Karoubi C ⥤ D` is determined
by its value on objects coming from `C`. -/
theorem natTrans_eq {F G : Karoubi C ⥤ D} (φ : F ⟶ G) (P : Karoubi C) :
    φ.app P = F.map (decompId_i P) ≫ φ.app P.X ≫ G.map (decompId_p P) := by
  

Proof state:
C : Type u_1
D : Type u_2
E : Type u_3
inst✝² : Category.{u_4, u_1} C
inst✝¹ : Category.{u_5, u_2} D
inst✝ : Category.{?u.41, u_3} E
F G : Karoubi C ⥤ D
φ : F ⟶ G
P : Karoubi C
⊢ φ.app P = F.map (decompId_i P) ≫ φ.app (Karoubi.mk P.X (𝟙 P.X)) ≫ G.map (decompId_p P)

Next tactic:
rw [← φ.naturality, ← assoc, ← F.map_comp]
/-- A natural transformation between functors `Karoubi C ⥤ D` is determined
by its value on objects coming from `C`. -/
theorem natTrans_eq {F G : Karoubi C ⥤ D} (φ : F ⟶ G) (P : Karoubi C) :
    φ.app P = F.map (decompId_i P) ≫ φ.app P.X ≫ G.map (decompId_p P) := by
  rw [← φ.naturality, ← assoc, ← F.map_comp]
  

Proof state:
C : Type u_1
D : Type u_2
E : Type u_3
inst✝² : Category.{u_4, u_1} C
inst✝¹ : Category.{u_5, u_2} D
inst✝ : Category.{?u.41, u_3} E
F G : Karoubi C ⥤ D
φ : F ⟶ G
P : Karoubi C
⊢ φ.app P = F.map (decompId_i P ≫ decompId_p P) ≫ φ.app P

Next tactic:
conv_lhs => rw [← id_comp (φ.app P), ← F.map_id]
/-- A natural transformation between functors `Karoubi C ⥤ D` is determined
by its value on objects coming from `C`. -/
theorem natTrans_eq {F G : Karoubi C ⥤ D} (φ : F ⟶ G) (P : Karoubi C) :
    φ.app P = F.map (decompId_i P) ≫ φ.app P.X ≫ G.map (decompId_p P) := by
  rw [← φ.naturality, ← assoc, ← F.map_comp]
  conv_lhs => 

Proof state:
C : Type u_1
D : Type u_2
E : Type u_3
inst✝² : Category.{u_4, u_1} C
inst✝¹ : Category.{u_5, u_2} D
inst✝ : Category.{?u.41, u_3} E
F G : Karoubi C ⥤ D
φ : F ⟶ G
P : Karoubi C
| φ.app P

Next tactic:
rw [← id_comp (φ.app P), ← F.map_id]
/-- A natural transformation between functors `Karoubi C ⥤ D` is determined
by its value on objects coming from `C`. -/
theorem natTrans_eq {F G : Karoubi C ⥤ D} (φ : F ⟶ G) (P : Karoubi C) :
    φ.app P = F.map (decompId_i P) ≫ φ.app P.X ≫ G.map (decompId_p P) := by
  rw [← φ.naturality, ← assoc, ← F.map_comp]
  conv_lhs => rw [← id_comp (φ.app P), ← F.map_id]
  

Proof state:
C : Type u_1
D : Type u_2
E : Type u_3
inst✝² : Category.{u_4, u_1} C
inst✝¹ : Category.{u_5, u_2} D
inst✝ : Category.{?u.41, u_3} E
F G : Karoubi C ⥤ D
φ : F ⟶ G
P : Karoubi C
⊢ F.map (𝟙 P) ≫ φ.app P = F.map (decompId_i P ≫ decompId_p P) ≫ φ.app P

Next tactic:
congr
/-- A natural transformation between functors `Karoubi C ⥤ D` is determined
by its value on objects coming from `C`. -/
theorem natTrans_eq {F G : Karoubi C ⥤ D} (φ : F ⟶ G) (P : Karoubi C) :
    φ.app P = F.map (decompId_i P) ≫ φ.app P.X ≫ G.map (decompId_p P) := by
  rw [← φ.naturality, ← assoc, ← F.map_comp]
  conv_lhs => rw [← id_comp (φ.app P), ← F.map_id]
  congr
  

Proof state:
case e_a.e_a
C : Type u_1
D : Type u_2
E : Type u_3
inst✝² : Category.{u_4, u_1} C
inst✝¹ : Category.{u_5, u_2} D
inst✝ : Category.{?u.41, u_3} E
F G : Karoubi C ⥤ D
φ : F ⟶ G
P : Karoubi C
⊢ 𝟙 P = decompId_i P ≫ decompId_p P

Next tactic:
apply decompId
/-- The canonical extension of a functor `C ⥤ Karoubi D` to a functor
`Karoubi C ⥤ Karoubi D` -/
@[simps]
def obj (F : C ⥤ Karoubi D) : Karoubi C ⥤ Karoubi D where
  obj P :=
    ⟨(F.obj P.X).X, (F.map P.p).f, by 

Proof state:
C : Type u_1
D : Type u_2
E : Type u_3
inst✝² : Category.{?u.1642, u_1} C
inst✝¹ : Category.{?u.1646, u_2} D
inst✝ : Category.{?u.1650, u_3} E
F : C ⥤ Karoubi D
P : Karoubi C
⊢ (F.map P.p).f ≫ (F.map P.p).f = (F.map P.p).f

Next tactic:
simpa only [F.map_comp, hom_ext_iff] using F.congr_map P.idem
/-- The canonical extension of a functor `C ⥤ Karoubi D` to a functor
`Karoubi C ⥤ Karoubi D` -/
@[simps]
def obj (F : C ⥤ Karoubi D) : Karoubi C ⥤ Karoubi D where
  obj P :=
    ⟨(F.obj P.X).X, (F.map P.p).f, by simpa only [F.map_comp, hom_ext_iff] using F.congr_map P.idem⟩
  map f := ⟨(F.map f.f).f, by 

Proof state:
C : Type u_1
D : Type u_2
E : Type u_3
inst✝² : Category.{?u.1642, u_1} C
inst✝¹ : Category.{?u.1646, u_2} D
inst✝ : Category.{?u.1650, u_3} E
F : C ⥤ Karoubi D
X✝ Y✝ : Karoubi C
f : X✝ ⟶ Y✝
⊢ (F.map f.f).f =
    ((fun P => Karoubi.mk (F.obj P.X).X (F.map P.p).f) X✝).p ≫
      (F.map f.f).f ≫ ((fun P => Karoubi.mk (F.obj P.X).X (F.map P.p).f) Y✝).p

Next tactic:
simpa only [F.map_comp, hom_ext_iff] using F.congr_map f.comm
/-- Extension of a natural transformation `φ` between functors
`C ⥤ karoubi D` to a natural transformation between the
extension of these functors to `karoubi C ⥤ karoubi D` -/
@[simps]
def map {F G : C ⥤ Karoubi D} (φ : F ⟶ G) : obj F ⟶ obj G where
  app P :=
    { f := (F.map P.p).f ≫ (φ.app P.X).f
      comm := by
        

Proof state:
C : Type u_1
D : Type u_2
E : Type u_3
inst✝² : Category.{?u.7431, u_1} C
inst✝¹ : Category.{?u.7435, u_2} D
inst✝ : Category.{?u.7439, u_3} E
F G : C ⥤ Karoubi D
φ : F ⟶ G
P : Karoubi C
⊢ (F.map P.p).f ≫ (φ.app P.X).f = ((obj F).obj P).p ≫ ((F.map P.p).f ≫ (φ.app P.X).f) ≫ ((obj G).obj P).p

Next tactic:
have h := φ.naturality P.p
/-- Extension of a natural transformation `φ` between functors
`C ⥤ karoubi D` to a natural transformation between the
extension of these functors to `karoubi C ⥤ karoubi D` -/
@[simps]
def map {F G : C ⥤ Karoubi D} (φ : F ⟶ G) : obj F ⟶ obj G where
  app P :=
    { f := (F.map P.p).f ≫ (φ.app P.X).f
      comm := by
        have h := φ.naturality P.p
        

Proof state:
C : Type u_1
D : Type u_2
E : Type u_3
inst✝² : Category.{?u.7431, u_1} C
inst✝¹ : Category.{?u.7435, u_2} D
inst✝ : Category.{?u.7439, u_3} E
F G : C ⥤ Karoubi D
φ : F ⟶ G
P : Karoubi C
h : F.map P.p ≫ φ.app P.X = φ.app P.X ≫ G.map P.p
⊢ (F.map P.p).f ≫ (φ.app P.X).f = ((obj F).obj P).p ≫ ((F.map P.p).f ≫ (φ.app P.X).f) ≫ ((obj G).obj P).p

Next tactic:
have h' := F.congr_map P.idem
/-- Extension of a natural transformation `φ` between functors
`C ⥤ karoubi D` to a natural transformation between the
extension of these functors to `karoubi C ⥤ karoubi D` -/
@[simps]
def map {F G : C ⥤ Karoubi D} (φ : F ⟶ G) : obj F ⟶ obj G where
  app P :=
    { f := (F.map P.p).f ≫ (φ.app P.X).f
      comm := by
        have h := φ.naturality P.p
        have h' := F.congr_map P.idem
        

Proof state:
C : Type u_1
D : Type u_2
E : Type u_3
inst✝² : Category.{?u.7431, u_1} C
inst✝¹ : Category.{?u.7435, u_2} D
inst✝ : Category.{?u.7439, u_3} E
F G : C ⥤ Karoubi D
φ : F ⟶ G
P : Karoubi C
h : F.map P.p ≫ φ.app P.X = φ.app P.X ≫ G.map P.p
h' : F.map (P.p ≫ P.p) = F.map P.p
⊢ (F.map P.p).f ≫ (φ.app P.X).f = ((obj F).obj P).p ≫ ((F.map P.p).f ≫ (φ.app P.X).f) ≫ ((obj G).obj P).p

Next tactic:
simp only [hom_ext_iff, Karoubi.comp_f, F.map_comp] at h h'
/-- Extension of a natural transformation `φ` between functors
`C ⥤ karoubi D` to a natural transformation between the
extension of these functors to `karoubi C ⥤ karoubi D` -/
@[simps]
def map {F G : C ⥤ Karoubi D} (φ : F ⟶ G) : obj F ⟶ obj G where
  app P :=
    { f := (F.map P.p).f ≫ (φ.app P.X).f
      comm := by
        have h := φ.naturality P.p
        have h' := F.congr_map P.idem
        simp only [hom_ext_iff, Karoubi.comp_f, F.map_comp] at h h'
        

Proof state:
C : Type u_1
D : Type u_2
E : Type u_3
inst✝² : Category.{?u.7431, u_1} C
inst✝¹ : Category.{?u.7435, u_2} D
inst✝ : Category.{?u.7439, u_3} E
F G : C ⥤ Karoubi D
φ : F ⟶ G
P : Karoubi C
h : (F.map P.p).f ≫ (φ.app P.X).f = (φ.app P.X).f ≫ (G.map P.p).f
h' : (F.map P.p).f ≫ (F.map P.p).f = (F.map P.p).f
⊢ (F.map P.p).f ≫ (φ.app P.X).f = ((obj F).obj P).p ≫ ((F.map P.p).f ≫ (φ.app P.X).f) ≫ ((obj G).obj P).p

Next tactic:
simp only [obj_obj_p, assoc, ← h]
/-- Extension of a natural transformation `φ` between functors
`C ⥤ karoubi D` to a natural transformation between the
extension of these functors to `karoubi C ⥤ karoubi D` -/
@[simps]
def map {F G : C ⥤ Karoubi D} (φ : F ⟶ G) : obj F ⟶ obj G where
  app P :=
    { f := (F.map P.p).f ≫ (φ.app P.X).f
      comm := by
        have h := φ.naturality P.p
        have h' := F.congr_map P.idem
        simp only [hom_ext_iff, Karoubi.comp_f, F.map_comp] at h h'
        simp only [obj_obj_p, assoc, ← h]
        

Proof state:
C : Type u_1
D : Type u_2
E : Type u_3
inst✝² : Category.{?u.7431, u_1} C
inst✝¹ : Category.{?u.7435, u_2} D
inst✝ : Category.{?u.7439, u_3} E
F G : C ⥤ Karoubi D
φ : F ⟶ G
P : Karoubi C
h : (F.map P.p).f ≫ (φ.app P.X).f = (φ.app P.X).f ≫ (G.map P.p).f
h' : (F.map P.p).f ≫ (F.map P.p).f = (F.map P.p).f
⊢ (F.map P.p).f ≫ (φ.app P.X).f = (F.map P.p).f ≫ (F.map P.p).f ≫ (F.map P.p).f ≫ (φ.app P.X).f

Next tactic:
slice_rhs 1 3 => rw [h', h']
/-- Extension of a natural transformation `φ` between functors
`C ⥤ karoubi D` to a natural transformation between the
extension of these functors to `karoubi C ⥤ karoubi D` -/
@[simps]
def map {F G : C ⥤ Karoubi D} (φ : F ⟶ G) : obj F ⟶ obj G where
  app P :=
    { f := (F.map P.p).f ≫ (φ.app P.X).f
      comm := by
        have h := φ.naturality P.p
        have h' := F.congr_map P.idem
        simp only [hom_ext_iff, Karoubi.comp_f, F.map_comp] at h h'
        simp only [obj_obj_p, assoc, ← h]
        slice_rhs 1 3 => 

Proof state:
case a
C : Type u_1
D : Type u_2
E : Type u_3
inst✝² : Category.{?u.7431, u_1} C
inst✝¹ : Category.{?u.7435, u_2} D
inst✝ : Category.{?u.7439, u_3} E
F G : C ⥤ Karoubi D
φ : F ⟶ G
P : Karoubi C
h : (F.map P.p).f ≫ (φ.app P.X).f = (φ.app P.X).f ≫ (G.map P.p).f
h' : (F.map P.p).f ≫ (F.map P.p).f = (F.map P.p).f
| (F.map P.p).f ≫ (F.map P.p).f ≫ (F.map P.p).f
case a
C : Type u_1
D : Type u_2
E : Type u_3
inst✝² : Category.{?u.7431, u_1} C
inst✝¹ : Category.{?u.7435, u_2} D
inst✝ : Category.{?u.7439, u_3} E
F G : C ⥤ Karoubi D
φ : F ⟶ G
P : Karoubi C
h : (F.map P.p).f ≫ (φ.app P.X).f = (φ.app P.X).f ≫ (G.map P.p).f
h' : (F.map P.p).f ≫ (F.map P.p).f = (F.map P.p).f
| (φ.app P.X).f

Next tactic:
rw [h', h']
/-- Extension of a natural transformation `φ` between functors
`C ⥤ karoubi D` to a natural transformation between the
extension of these functors to `karoubi C ⥤ karoubi D` -/
@[simps]
def map {F G : C ⥤ Karoubi D} (φ : F ⟶ G) : obj F ⟶ obj G where
  app P :=
    { f := (F.map P.p).f ≫ (φ.app P.X).f
      comm := by
        have h := φ.naturality P.p
        have h' := F.congr_map P.idem
        simp only [hom_ext_iff, Karoubi.comp_f, F.map_comp] at h h'
        simp only [obj_obj_p, assoc, ← h]
        slice_rhs 1 3 => rw [h', h'] }
  naturality _ _ f := by
    

Proof state:
C : Type u_1
D : Type u_2
E : Type u_3
inst✝² : Category.{?u.7431, u_1} C
inst✝¹ : Category.{?u.7435, u_2} D
inst✝ : Category.{?u.7439, u_3} E
F G : C ⥤ Karoubi D
φ : F ⟶ G
x✝¹ x✝ : Karoubi C
f : x✝¹ ⟶ x✝
⊢ (obj F).map f ≫ (fun P => Hom.mk ((F.map P.p).f ≫ (φ.app P.X).f)) x✝ =
    (fun P => Hom.mk ((F.map P.p).f ≫ (φ.app P.X).f)) x✝¹ ≫ (obj G).map f

Next tactic:
ext
/-- Extension of a natural transformation `φ` between functors
`C ⥤ karoubi D` to a natural transformation between the
extension of these functors to `karoubi C ⥤ karoubi D` -/
@[simps]
def map {F G : C ⥤ Karoubi D} (φ : F ⟶ G) : obj F ⟶ obj G where
  app P :=
    { f := (F.map P.p).f ≫ (φ.app P.X).f
      comm := by
        have h := φ.naturality P.p
        have h' := F.congr_map P.idem
        simp only [hom_ext_iff, Karoubi.comp_f, F.map_comp] at h h'
        simp only [obj_obj_p, assoc, ← h]
        slice_rhs 1 3 => rw [h', h'] }
  naturality _ _ f := by
    ext
    

Proof state:
case h
C : Type u_1
D : Type u_2
E : Type u_3
inst✝² : Category.{?u.7431, u_1} C
inst✝¹ : Category.{?u.7435, u_2} D
inst✝ : Category.{?u.7439, u_3} E
F G : C ⥤ Karoubi D
φ : F ⟶ G
x✝¹ x✝ : Karoubi C
f : x✝¹ ⟶ x✝
⊢ ((obj F).map f ≫ (fun P => Hom.mk ((F.map P.p).f ≫ (φ.app P.X).f)) x✝).f =
    ((fun P => Hom.mk ((F.map P.p).f ≫ (φ.app P.X).f)) x✝¹ ≫ (obj G).map f).f

Next tactic:
dsimp [obj]
/-- Extension of a natural transformation `φ` between functors
`C ⥤ karoubi D` to a natural transformation between the
extension of these functors to `karoubi C ⥤ karoubi D` -/
@[simps]
def map {F G : C ⥤ Karoubi D} (φ : F ⟶ G) : obj F ⟶ obj G where
  app P :=
    { f := (F.map P.p).f ≫ (φ.app P.X).f
      comm := by
        have h := φ.naturality P.p
        have h' := F.congr_map P.idem
        simp only [hom_ext_iff, Karoubi.comp_f, F.map_comp] at h h'
        simp only [obj_obj_p, assoc, ← h]
        slice_rhs 1 3 => rw [h', h'] }
  naturality _ _ f := by
    ext
    dsimp [obj]
    

Proof state:
case h
C : Type u_1
D : Type u_2
E : Type u_3
inst✝² : Category.{?u.7431, u_1} C
inst✝¹ : Category.{?u.7435, u_2} D
inst✝ : Category.{?u.7439, u_3} E
F G : C ⥤ Karoubi D
φ : F ⟶ G
x✝¹ x✝ : Karoubi C
f : x✝¹ ⟶ x✝
⊢ (F.map f.f).f ≫ (F.map x✝.p).f ≫ (φ.app x✝.X).f = ((F.map x✝¹.p).f ≫ (φ.app x✝¹.X).f) ≫ (G.map f.f).f

Next tactic:
have h := φ.naturality f.f
/-- Extension of a natural transformation `φ` between functors
`C ⥤ karoubi D` to a natural transformation between the
extension of these functors to `karoubi C ⥤ karoubi D` -/
@[simps]
def map {F G : C ⥤ Karoubi D} (φ : F ⟶ G) : obj F ⟶ obj G where
  app P :=
    { f := (F.map P.p).f ≫ (φ.app P.X).f
      comm := by
        have h := φ.naturality P.p
        have h' := F.congr_map P.idem
        simp only [hom_ext_iff, Karoubi.comp_f, F.map_comp] at h h'
        simp only [obj_obj_p, assoc, ← h]
        slice_rhs 1 3 => rw [h', h'] }
  naturality _ _ f := by
    ext
    dsimp [obj]
    have h := φ.naturality f.f
    

Proof state:
case h
C : Type u_1
D : Type u_2
E : Type u_3
inst✝² : Category.{?u.7431, u_1} C
inst✝¹ : Category.{?u.7435, u_2} D
inst✝ : Category.{?u.7439, u_3} E
F G : C ⥤ Karoubi D
φ : F ⟶ G
x✝¹ x✝ : Karoubi C
f : x✝¹ ⟶ x✝
h : F.map f.f ≫ φ.app x✝.X = φ.app x✝¹.X ≫ G.map f.f
⊢ (F.map f.f).f ≫ (F.map x✝.p).f ≫ (φ.app x✝.X).f = ((F.map x✝¹.p).f ≫ (φ.app x✝¹.X).f) ≫ (G.map f.f).f

Next tactic:
have h' := F.congr_map (comp_p f)
/-- Extension of a natural transformation `φ` between functors
`C ⥤ karoubi D` to a natural transformation between the
extension of these functors to `karoubi C ⥤ karoubi D` -/
@[simps]
def map {F G : C ⥤ Karoubi D} (φ : F ⟶ G) : obj F ⟶ obj G where
  app P :=
    { f := (F.map P.p).f ≫ (φ.app P.X).f
      comm := by
        have h := φ.naturality P.p
        have h' := F.congr_map P.idem
        simp only [hom_ext_iff, Karoubi.comp_f, F.map_comp] at h h'
        simp only [obj_obj_p, assoc, ← h]
        slice_rhs 1 3 => rw [h', h'] }
  naturality _ _ f := by
    ext
    dsimp [obj]
    have h := φ.naturality f.f
    have h' := F.congr_map (comp_p f)
    

Proof state:
case h
C : Type u_1
D : Type u_2
E : Type u_3
inst✝² : Category.{?u.7431, u_1} C
inst✝¹ : Category.{?u.7435, u_2} D
inst✝ : Category.{?u.7439, u_3} E
F G : C ⥤ Karoubi D
φ : F ⟶ G
x✝¹ x✝ : Karoubi C
f : x✝¹ ⟶ x✝
h : F.map f.f ≫ φ.app x✝.X = φ.app x✝¹.X ≫ G.map f.f
h' : F.map (f.f ≫ x✝.p) = F.map f.f
⊢ (F.map f.f).f ≫ (F.map x✝.p).f ≫ (φ.app x✝.X).f = ((F.map x✝¹.p).f ≫ (φ.app x✝¹.X).f) ≫ (G.map f.f).f

Next tactic:
have h'' := F.congr_map (p_comp f)
/-- Extension of a natural transformation `φ` between functors
`C ⥤ karoubi D` to a natural transformation between the
extension of these functors to `karoubi C ⥤ karoubi D` -/
@[simps]
def map {F G : C ⥤ Karoubi D} (φ : F ⟶ G) : obj F ⟶ obj G where
  app P :=
    { f := (F.map P.p).f ≫ (φ.app P.X).f
      comm := by
        have h := φ.naturality P.p
        have h' := F.congr_map P.idem
        simp only [hom_ext_iff, Karoubi.comp_f, F.map_comp] at h h'
        simp only [obj_obj_p, assoc, ← h]
        slice_rhs 1 3 => rw [h', h'] }
  naturality _ _ f := by
    ext
    dsimp [obj]
    have h := φ.naturality f.f
    have h' := F.congr_map (comp_p f)
    have h'' := F.congr_map (p_comp f)
    

Proof state:
case h
C : Type u_1
D : Type u_2
E : Type u_3
inst✝² : Category.{?u.7431, u_1} C
inst✝¹ : Category.{?u.7435, u_2} D
inst✝ : Category.{?u.7439, u_3} E
F G : C ⥤ Karoubi D
φ : F ⟶ G
x✝¹ x✝ : Karoubi C
f : x✝¹ ⟶ x✝
h : F.map f.f ≫ φ.app x✝.X = φ.app x✝¹.X ≫ G.map f.f
h' : F.map (f.f ≫ x✝.p) = F.map f.f
h'' : F.map (x✝¹.p ≫ f.f) = F.map f.f
⊢ (F.map f.f).f ≫ (F.map x✝.p).f ≫ (φ.app x✝.X).f = ((F.map x✝¹.p).f ≫ (φ.app x✝¹.X).f) ≫ (G.map f.f).f

Next tactic:
simp only [hom_ext_iff, Functor.map_comp, comp_f] at h h' h'' ⊢
/-- Extension of a natural transformation `φ` between functors
`C ⥤ karoubi D` to a natural transformation between the
extension of these functors to `karoubi C ⥤ karoubi D` -/
@[simps]
def map {F G : C ⥤ Karoubi D} (φ : F ⟶ G) : obj F ⟶ obj G where
  app P :=
    { f := (F.map P.p).f ≫ (φ.app P.X).f
      comm := by
        have h := φ.naturality P.p
        have h' := F.congr_map P.idem
        simp only [hom_ext_iff, Karoubi.comp_f, F.map_comp] at h h'
        simp only [obj_obj_p, assoc, ← h]
        slice_rhs 1 3 => rw [h', h'] }
  naturality _ _ f := by
    ext
    dsimp [obj]
    have h := φ.naturality f.f
    have h' := F.congr_map (comp_p f)
    have h'' := F.congr_map (p_comp f)
    simp only [hom_ext_iff, Functor.map_comp, comp_f] at h h' h'' ⊢
    

Proof state:
case h
C : Type u_1
D : Type u_2
E : Type u_3
inst✝² : Category.{?u.7431, u_1} C
inst✝¹ : Category.{?u.7435, u_2} D
inst✝ : Category.{?u.7439, u_3} E
F G : C ⥤ Karoubi D
φ : F ⟶ G
x✝¹ x✝ : Karoubi C
f : x✝¹ ⟶ x✝
h : (F.map f.f).f ≫ (φ.app x✝.X).f = (φ.app x✝¹.X).f ≫ (G.map f.f).f
h' : (F.map f.f).f ≫ (F.map x✝.p).f = (F.map f.f).f
h'' : (F.map x✝¹.p).f ≫ (F.map f.f).f = (F.map f.f).f
⊢ (F.map f.f).f ≫ (F.map x✝.p).f ≫ (φ.app x✝.X).f = ((F.map x✝¹.p).f ≫ (φ.app x✝¹.X).f) ≫ (G.map f.f).f

Next tactic:
slice_rhs 2 3 => rw [← h]
/-- Extension of a natural transformation `φ` between functors
`C ⥤ karoubi D` to a natural transformation between the
extension of these functors to `karoubi C ⥤ karoubi D` -/
@[simps]
def map {F G : C ⥤ Karoubi D} (φ : F ⟶ G) : obj F ⟶ obj G where
  app P :=
    { f := (F.map P.p).f ≫ (φ.app P.X).f
      comm := by
        have h := φ.naturality P.p
        have h' := F.congr_map P.idem
        simp only [hom_ext_iff, Karoubi.comp_f, F.map_comp] at h h'
        simp only [obj_obj_p, assoc, ← h]
        slice_rhs 1 3 => rw [h', h'] }
  naturality _ _ f := by
    ext
    dsimp [obj]
    have h := φ.naturality f.f
    have h' := F.congr_map (comp_p f)
    have h'' := F.congr_map (p_comp f)
    simp only [hom_ext_iff, Functor.map_comp, comp_f] at h h' h'' ⊢
    slice_rhs 2 3 => 

Proof state:
case a
C : Type u_1
D : Type u_2
E : Type u_3
inst✝² : Category.{?u.7431, u_1} C
inst✝¹ : Category.{?u.7435, u_2} D
inst✝ : Category.{?u.7439, u_3} E
F G : C ⥤ Karoubi D
φ : F ⟶ G
x✝¹ x✝ : Karoubi C
f : x✝¹ ⟶ x✝
h : (F.map f.f).f ≫ (φ.app x✝.X).f = (φ.app x✝¹.X).f ≫ (G.map f.f).f
h' : (F.map f.f).f ≫ (F.map x✝.p).f = (F.map f.f).f
h'' : (F.map x✝¹.p).f ≫ (F.map f.f).f = (F.map f.f).f
| (φ.app x✝¹.X).f ≫ (G.map f.f).f
case a
C : Type u_1
D : Type u_2
E : Type u_3
inst✝² : Category.{?u.7431, u_1} C
inst✝¹ : Category.{?u.7435, u_2} D
inst✝ : Category.{?u.7439, u_3} E
F G : C ⥤ Karoubi D
φ : F ⟶ G
x✝¹ x✝ : Karoubi C
f : x✝¹ ⟶ x✝
h : (F.map f.f).f ≫ (φ.app x✝.X).f = (φ.app x✝¹.X).f ≫ (G.map f.f).f
h' : (F.map f.f).f ≫ (F.map x✝.p).f = (F.map f.f).f
h'' : (F.map x✝¹.p).f ≫ (F.map f.f).f = (F.map f.f).f
| (F.map x✝¹.p).f

Next tactic:
rw [← h]
/-- Extension of a natural transformation `φ` between functors
`C ⥤ karoubi D` to a natural transformation between the
extension of these functors to `karoubi C ⥤ karoubi D` -/
@[simps]
def map {F G : C ⥤ Karoubi D} (φ : F ⟶ G) : obj F ⟶ obj G where
  app P :=
    { f := (F.map P.p).f ≫ (φ.app P.X).f
      comm := by
        have h := φ.naturality P.p
        have h' := F.congr_map P.idem
        simp only [hom_ext_iff, Karoubi.comp_f, F.map_comp] at h h'
        simp only [obj_obj_p, assoc, ← h]
        slice_rhs 1 3 => rw [h', h'] }
  naturality _ _ f := by
    ext
    dsimp [obj]
    have h := φ.naturality f.f
    have h' := F.congr_map (comp_p f)
    have h'' := F.congr_map (p_comp f)
    simp only [hom_ext_iff, Functor.map_comp, comp_f] at h h' h'' ⊢
    slice_rhs 2 3 => rw [← h]
    

Proof state:
case h
C : Type u_1
D : Type u_2
E : Type u_3
inst✝² : Category.{?u.7431, u_1} C
inst✝¹ : Category.{?u.7435, u_2} D
inst✝ : Category.{?u.7439, u_3} E
F G : C ⥤ Karoubi D
φ : F ⟶ G
x✝¹ x✝ : Karoubi C
f : x✝¹ ⟶ x✝
h : (F.map f.f).f ≫ (φ.app x✝.X).f = (φ.app x✝¹.X).f ≫ (G.map f.f).f
h' : (F.map f.f).f ≫ (F.map x✝.p).f = (F.map f.f).f
h'' : (F.map x✝¹.p).f ≫ (F.map f.f).f = (F.map f.f).f
⊢ (F.map f.f).f ≫ (F.map x✝.p).f ≫ (φ.app x✝.X).f = (F.map x✝¹.p).f ≫ (F.map f.f).f ≫ (φ.app x✝.X).f

Next tactic:
slice_lhs 1 2 => rw [h']