Theorem: CategoryTheory.hasInitial_of_weakly_initial_and_hasWideEqualizers
File: Mathlib/CategoryTheory/Limits/Constructions/WeaklyInitial.lean

tactic: let endos := T ⟶ T
state_before: C : Type u
inst✝¹ : Category C
inst✝ : HasWideEqualizers C
T : C
hT : ∀ (X : C), Nonempty (T ⟶ X)
⊢ HasInitial C

tactic: let i := wideEqualizer.ι (id : endos → endos)
state_before: C : Type u
inst✝¹ : Category C
inst✝ : HasWideEqualizers C
T : C
hT : ∀ (X : C), Nonempty (T ⟶ X)
endos : Type v := T ⟶ T
⊢ HasInitial C

tactic: haveI : Nonempty endos := ⟨𝟙 _⟩
state_before: C : Type u
inst✝¹ : Category C
inst✝ : HasWideEqualizers C
T : C
hT : ∀ (X : C), Nonempty (T ⟶ X)
endos : Type v := T ⟶ T
i : wideEqualizer id ⟶ T := wideEqualizer.ι id
⊢ HasInitial C

tactic: have : ∀ X : C, Unique (wideEqualizer (id : endos → endos) ⟶ X) := by
  intro X
  refine' ⟨⟨i ≫ Classical.choice (hT X)⟩, fun a => _⟩
  let E := equalizer a (i ≫ Classical.choice (hT _))
  let e : E ⟶ wideEqualizer id := equalizer.ι _ _
  let h : T ⟶ E := Classical.choice (hT E)
  have : ((i ≫ h) ≫ e) ≫ i = i ≫ 𝟙 _ := by
    rw [Category.assoc, Category.assoc]
    apply wideEqualizer.condition (id : endos → endos) (h ≫ e ≫ i)
  rw [Category.comp_id, cancel_mono_id i] at this
  haveI : IsSplitEpi e := IsSplitEpi.mk' ⟨i ≫ h, this⟩
  rw [← cancel_epi e]
  apply equalizer.condition
state_before: C : Type u
inst✝¹ : Category C
inst✝ : HasWideEqualizers C
T : C
hT : ∀ (X : C), Nonempty (T ⟶ X)
endos : Type v := T ⟶ T
i : wideEqualizer id ⟶ T := wideEqualizer.ι id
this : Nonempty endos
⊢ HasInitial C

tactic: exact hasInitial_of_unique (wideEqualizer (id : endos → endos))
state_before: C : Type u
inst✝¹ : Category C
inst✝ : HasWideEqualizers C
T : C
hT : ∀ (X : C), Nonempty (T ⟶ X)
endos : Type v := T ⟶ T
i : wideEqualizer id ⟶ T := wideEqualizer.ι id
this✝ : Nonempty endos
this : (X : C) → Unique (wideEqualizer id ⟶ X)
⊢ HasInitial C

tactic: intro X
state_before: C : Type u
inst✝¹ : Category C
inst✝ : HasWideEqualizers C
T : C
hT : ∀ (X : C), Nonempty (T ⟶ X)
endos : Type v := T ⟶ T
i : wideEqualizer id ⟶ T := wideEqualizer.ι id
this : Nonempty endos
⊢ (X : C) → Unique (wideEqualizer id ⟶ X)

tactic: refine' ⟨⟨i ≫ Classical.choice (hT X)⟩, fun a => _⟩
state_before: C : Type u
inst✝¹ : Category C
inst✝ : HasWideEqualizers C
T : C
hT : ∀ (X : C), Nonempty (T ⟶ X)
endos : Type v := T ⟶ T
i : wideEqualizer id ⟶ T := wideEqualizer.ι id
this : Nonempty endos
X : C
⊢ Unique (wideEqualizer id ⟶ X)

tactic: let E := equalizer a (i ≫ Classical.choice (hT _))
state_before: C : Type u
inst✝¹ : Category C
inst✝ : HasWideEqualizers C
T : C
hT : ∀ (X : C), Nonempty (T ⟶ X)
endos : Type v := T ⟶ T
i : wideEqualizer id ⟶ T := wideEqualizer.ι id
this : Nonempty endos
X : C
a : wideEqualizer id ⟶ X
⊢ a = default

tactic: let e : E ⟶ wideEqualizer id := equalizer.ι _ _
state_before: C : Type u
inst✝¹ : Category C
inst✝ : HasWideEqualizers C
T : C
hT : ∀ (X : C), Nonempty (T ⟶ X)
endos : Type v := T ⟶ T
i : wideEqualizer id ⟶ T := wideEqualizer.ι id
this : Nonempty endos
X : C
a : wideEqualizer id ⟶ X
E : C := equalizer a (i ≫ Classical.choice (_ : Nonempty (T ⟶ X)))
⊢ a = default

tactic: let h : T ⟶ E := Classical.choice (hT E)
state_before: C : Type u
inst✝¹ : Category C
inst✝ : HasWideEqualizers C
T : C
hT : ∀ (X : C), Nonempty (T ⟶ X)
endos : Type v := T ⟶ T
i : wideEqualizer id ⟶ T := wideEqualizer.ι id
this : Nonempty endos
X : C
a : wideEqualizer id ⟶ X
E : C := equalizer a (i ≫ Classical.choice (_ : Nonempty (T ⟶ X)))
e : E ⟶ wideEqualizer id := equalizer.ι a (i ≫ Classical.choice (_ : Nonempty (T ⟶ X)))
⊢ a = default

tactic: have : ((i ≫ h) ≫ e) ≫ i = i ≫ 𝟙 _ := by
  rw [Category.assoc, Category.assoc]
  apply wideEqualizer.condition (id : endos → endos) (h ≫ e ≫ i)
state_before: C : Type u
inst✝¹ : Category C
inst✝ : HasWideEqualizers C
T : C
hT : ∀ (X : C), Nonempty (T ⟶ X)
endos : Type v := T ⟶ T
i : wideEqualizer id ⟶ T := wideEqualizer.ι id
this : Nonempty endos
X : C
a : wideEqualizer id ⟶ X
E : C := equalizer a (i ≫ Classical.choice (_ : Nonempty (T ⟶ X)))
e : E ⟶ wideEqualizer id := equalizer.ι a (i ≫ Classical.choice (_ : Nonempty (T ⟶ X)))
h : T ⟶ E := Classical.choice (_ : Nonempty (T ⟶ E))
⊢ a = default

tactic: rw [Category.comp_id, cancel_mono_id i] at this
state_before: C : Type u
inst✝¹ : Category C
inst✝ : HasWideEqualizers C
T : C
hT : ∀ (X : C), Nonempty (T ⟶ X)
endos : Type v := T ⟶ T
i : wideEqualizer id ⟶ T := wideEqualizer.ι id
this✝ : Nonempty endos
X : C
a : wideEqualizer id ⟶ X
E : C := equalizer a (i ≫ Classical.choice (_ : Nonempty (T ⟶ X)))
e : E ⟶ wideEqualizer id := equalizer.ι a (i ≫ Classical.choice (_ : Nonempty (T ⟶ X)))
h : T ⟶ E := Classical.choice (_ : Nonempty (T ⟶ E))
this : ((i ≫ h) ≫ e) ≫ i = i ≫ 𝟙 T
⊢ a = default

tactic: haveI : IsSplitEpi e := IsSplitEpi.mk' ⟨i ≫ h, this⟩
state_before: C : Type u
inst✝¹ : Category C
inst✝ : HasWideEqualizers C
T : C
hT : ∀ (X : C), Nonempty (T ⟶ X)
endos : Type v := T ⟶ T
i : wideEqualizer id ⟶ T := wideEqualizer.ι id
this✝ : Nonempty endos
X : C
a : wideEqualizer id ⟶ X
E : C := equalizer a (i ≫ Classical.choice (_ : Nonempty (T ⟶ X)))
e : E ⟶ wideEqualizer id := equalizer.ι a (i ≫ Classical.choice (_ : Nonempty (T ⟶ X)))
h : T ⟶ E := Classical.choice (_ : Nonempty (T ⟶ E))
this : (i ≫ h) ≫ e = 𝟙 (wideEqualizer id)
⊢ a = default

tactic: rw [← cancel_epi e]
state_before: C : Type u
inst✝¹ : Category C
inst✝ : HasWideEqualizers C
T : C
hT : ∀ (X : C), Nonempty (T ⟶ X)
endos : Type v := T ⟶ T
i : wideEqualizer id ⟶ T := wideEqualizer.ι id
this✝¹ : Nonempty endos
X : C
a : wideEqualizer id ⟶ X
E : C := equalizer a (i ≫ Classical.choice (_ : Nonempty (T ⟶ X)))
e : E ⟶ wideEqualizer id := equalizer.ι a (i ≫ Classical.choice (_ : Nonempty (T ⟶ X)))
h : T ⟶ E := Classical.choice (_ : Nonempty (T ⟶ E))
this✝ : (i ≫ h) ≫ e = 𝟙 (wideEqualizer id)
this : IsSplitEpi e
⊢ a = default

tactic: apply equalizer.condition
state_before: C : Type u
inst✝¹ : Category C
inst✝ : HasWideEqualizers C
T : C
hT : ∀ (X : C), Nonempty (T ⟶ X)
endos : Type v := T ⟶ T
i : wideEqualizer id ⟶ T := wideEqualizer.ι id
this✝¹ : Nonempty endos
X : C
a : wideEqualizer id ⟶ X
E : C := equalizer a (i ≫ Classical.choice (_ : Nonempty (T ⟶ X)))
e : E ⟶ wideEqualizer id := equalizer.ι a (i ≫ Classical.choice (_ : Nonempty (T ⟶ X)))
h : T ⟶ E := Classical.choice (_ : Nonempty (T ⟶ E))
this✝ : (i ≫ h) ≫ e = 𝟙 (wideEqualizer id)
this : IsSplitEpi e
⊢ e ≫ a = e ≫ default

tactic: rw [Category.assoc, Category.assoc]
state_before: C : Type u
inst✝¹ : Category C
inst✝ : HasWideEqualizers C
T : C
hT : ∀ (X : C), Nonempty (T ⟶ X)
endos : Type v := T ⟶ T
i : wideEqualizer id ⟶ T := wideEqualizer.ι id
this : Nonempty endos
X : C
a : wideEqualizer id ⟶ X
E : C := equalizer a (i ≫ Classical.choice (_ : Nonempty (T ⟶ X)))
e : E ⟶ wideEqualizer id := equalizer.ι a (i ≫ Classical.choice (_ : Nonempty (T ⟶ X)))
h : T ⟶ E := Classical.choice (_ : Nonempty (T ⟶ E))
⊢ ((i ≫ h) ≫ e) ≫ i = i ≫ 𝟙 T

tactic: apply wideEqualizer.condition (id : endos → endos) (h ≫ e ≫ i)
state_before: C : Type u
inst✝¹ : Category C
inst✝ : HasWideEqualizers C
T : C
hT : ∀ (X : C), Nonempty (T ⟶ X)
endos : Type v := T ⟶ T
i : wideEqualizer id ⟶ T := wideEqualizer.ι id
this : Nonempty endos
X : C
a : wideEqualizer id ⟶ X
E : C := equalizer a (i ≫ Classical.choice (_ : Nonempty (T ⟶ X)))
e : E ⟶ wideEqualizer id := equalizer.ι a (i ≫ Classical.choice (_ : Nonempty (T ⟶ X)))
h : T ⟶ E := Classical.choice (_ : Nonempty (T ⟶ E))
⊢ i ≫ h ≫ e ≫ i = i ≫ 𝟙 T