-- Mathlib/CategoryTheory/Limits/Shapes/Types.lean
theorem binaryCofan_isColimit_iff {X Y : Type u} (c : BinaryCofan X Y) :
    Nonempty (IsColimit c) ↔
      Injective c.inl ∧ Injective c.inr ∧ IsCompl (Set.range c.inl) (Set.range c.inr)

Proof state:
case mp.intro
X Y : Type u
c : BinaryCofan X Y
h : IsColimit c
⊢ Injective (Sum.inl ≫ (h.coconePointUniqueUpToIso (binaryCoproductColimit X Y)).inv) ∧
    Injective (Sum.inr ≫ (h.coconePointUniqueUpToIso (binaryCoproductColimit X Y)).inv) ∧
      IsCompl (Set.range (Sum.inl ≫ (h.coconePointUniqueUpToIso (binaryCoproductColimit X Y)).inv))
        (Set.range (Sum.inr ≫ (h.coconePointUniqueUpToIso (binaryCoproductColimit X Y)).inv))

Tactic:
refine
  ⟨(h.coconePointUniqueUpToIso (binaryCoproductColimit X Y)).symm.toEquiv.injective.comp
      Sum.inl_injective,
    (h.coconePointUniqueUpToIso (binaryCoproductColimit X Y)).symm.toEquiv.injective.comp
      Sum.inr_injective, ?_⟩

Result:
case mp.intro
X Y : Type u
c : BinaryCofan X Y
h : IsColimit c
⊢ IsCompl (Set.range (Sum.inl ≫ (h.coconePointUniqueUpToIso (binaryCoproductColimit X Y)).inv))
    (Set.range (Sum.inr ≫ (h.coconePointUniqueUpToIso (binaryCoproductColimit X Y)).inv))

Proof state:
case mpr.intro.intro.refine_1
X Y : Type u
c : BinaryCofan X Y
h₁ : Injective c.inl
h₂ : Injective c.inr
h₃ : IsCompl (Set.range c.inl) (Set.range c.inr)
this :
  ∀ (x : ((Functor.const (Discrete WalkingPair)).obj c.pt).obj { as := left }),
    x ∈ Set.range c.inl ∨ x ∈ Set.range c.inr
T : Type u
f : X ⟶ T
g : Y ⟶ T
x : c.pt
⊢ T

Tactic:
exact
  if h : x ∈ Set.range c.inl then f ((Equiv.ofInjective _ h₁).symm ⟨x, h⟩)
  else g ((Equiv.ofInjective _ h₂).symm ⟨x, (this x).resolve_left h⟩)

Result:
no goals

Proof state:
case mp.intro
X Y : Type u
c : BinaryCofan X Y
h : IsColimit c
⊢ Injective
      ((binaryCoproductCocone X Y).ι.app { as := left } ≫
        (h.coconePointUniqueUpToIso (binaryCoproductColimit X Y)).inv) ∧
    Injective
        ((binaryCoproductCocone X Y).ι.app { as := right } ≫
          (h.coconePointUniqueUpToIso (binaryCoproductColimit X Y)).inv) ∧
      IsCompl
        (Set.range
          ((binaryCoproductCocone X Y).ι.app { as := left } ≫
            (h.coconePointUniqueUpToIso (binaryCoproductColimit X Y)).inv))
        (Set.range
          ((binaryCoproductCocone X Y).ι.app { as := right } ≫
            (h.coconePointUniqueUpToIso (binaryCoproductColimit X Y)).inv))

Tactic:
dsimp [binaryCoproductCocone]

Result:
case mp.intro
X Y : Type u
c : BinaryCofan X Y
h : IsColimit c
⊢ Injective (Sum.inl ≫ (h.coconePointUniqueUpToIso (binaryCoproductColimit X Y)).inv) ∧
    Injective (Sum.inr ≫ (h.coconePointUniqueUpToIso (binaryCoproductColimit X Y)).inv) ∧
      IsCompl (Set.range (Sum.inl ≫ (h.coconePointUniqueUpToIso (binaryCoproductColimit X Y)).inv))
        (Set.range (Sum.inr ≫ (h.coconePointUniqueUpToIso (binaryCoproductColimit X Y)).inv))

Proof state:
case mp.intro
X Y : Type u
c : BinaryCofan X Y
h : IsColimit c
⊢ (h.coconePointUniqueUpToIso (binaryCoproductColimit X Y)).inv '' Set.range Sum.inl =
    ⇑(h.coconePointUniqueUpToIso (binaryCoproductColimit X Y)).symm.toEquiv '' (Set.range Sum.inr)ᶜ

Tactic:
simp

Result:
no goals

Proof state:
case mpr.intro.intro.refine_2.h
X Y : Type u
c : BinaryCofan X Y
h₁ : Injective c.inl
h₂ : Injective c.inr
h₃ : IsCompl (Set.range c.inl) (Set.range c.inr)
this :
  ∀ (x : ((Functor.const (Discrete WalkingPair)).obj c.pt).obj { as := left }),
    x ∈ Set.range c.inl ∨ x ∈ Set.range c.inr
T : Type u
f : X ⟶ T
g : Y ⟶ T
x : (pair X Y).obj { as := left }
⊢ (if h : c.inl x ∈ Set.range c.inl then f ((Equiv.ofInjective c.inl h₁).symm ⟨c.inl x, h⟩)
    else g ((Equiv.ofInjective c.inr h₂).symm ⟨c.inl x, ⋯⟩)) =
    f x

Tactic:
simp [h₁.eq_iff]

Result:
no goals

Proof state:
case mp.intro
X Y : Type u
c : BinaryCofan X Y
h : IsColimit c
⊢ IsCompl (Set.range (Sum.inl ≫ (h.coconePointUniqueUpToIso (binaryCoproductColimit X Y)).inv))
    (Set.range (Sum.inr ≫ (h.coconePointUniqueUpToIso (binaryCoproductColimit X Y)).inv))

Tactic:
rw [types_comp, Set.range_comp, ← eq_compl_iff_isCompl, types_comp, Set.range_comp _ Sum.inr]

Result:
case mp.intro
X Y : Type u
c : BinaryCofan X Y
h : IsColimit c
⊢ (h.coconePointUniqueUpToIso (binaryCoproductColimit X Y)).inv '' Set.range Sum.inl =
    ((h.coconePointUniqueUpToIso (binaryCoproductColimit X Y)).inv '' Set.range Sum.inr)ᶜ

Proof state:
case mpr.intro.intro.refine_3
X Y : Type u
c : BinaryCofan X Y
h₁ : Injective c.inl
h₂ : Injective c.inr
h₃ : IsCompl (Set.range c.inl) (Set.range c.inr)
this :
  ∀ (x : ((Functor.const (Discrete WalkingPair)).obj c.pt).obj { as := left }),
    x ∈ Set.range c.inl ∨ x ∈ Set.range c.inr
T : Type u
f : X ⟶ T
g : Y ⟶ T
⊢ (c.inr ≫ fun x =>
      if h : x ∈ Set.range c.inl then f ((Equiv.ofInjective c.inl h₁).symm ⟨x, h⟩)
      else g ((Equiv.ofInjective c.inr h₂).symm ⟨x, ⋯⟩)) =
    g

Tactic:
funext x

Result:
case mpr.intro.intro.refine_3.h
X Y : Type u
c : BinaryCofan X Y
h₁ : Injective c.inl
h₂ : Injective c.inr
h₃ : IsCompl (Set.range c.inl) (Set.range c.inr)
this :
  ∀ (x : ((Functor.const (Discrete WalkingPair)).obj c.pt).obj { as := left }),
    x ∈ Set.range c.inl ∨ x ∈ Set.range c.inr
T : Type u
f : X ⟶ T
g : Y ⟶ T
x : (pair X Y).obj { as := right }
⊢ (c.inr ≫ fun x =>
        if h : x ∈ Set.range c.inl then f ((Equiv.ofInjective c.inl h₁).symm ⟨x, h⟩)
        else g ((Equiv.ofInjective c.inr h₂).symm ⟨x, ⋯⟩))
      x =
    g x

Proof state:
case mpr.intro.intro
X Y : Type u
c : BinaryCofan X Y
h₁ : Injective c.inl
h₂ : Injective c.inr
h₃ : IsCompl (Set.range c.inl) (Set.range c.inr)
this :
  ∀ (x : ((Functor.const (Discrete WalkingPair)).obj c.pt).obj { as := left }),
    x ∈ Set.range c.inl ∨ x ∈ Set.range c.inr
⊢ Nonempty (IsColimit c)

Tactic:
refine ⟨BinaryCofan.IsColimit.mk _ ?_ ?_ ?_ ?_⟩

Result:
case mpr.intro.intro.refine_1
X Y : Type u
c : BinaryCofan X Y
h₁ : Injective c.inl
h₂ : Injective c.inr
h₃ : IsCompl (Set.range c.inl) (Set.range c.inr)
this :
  ∀ (x : ((Functor.const (Discrete WalkingPair)).obj c.pt).obj { as := left }),
    x ∈ Set.range c.inl ∨ x ∈ Set.range c.inr
⊢ {T : Type u} → (X ⟶ T) → (Y ⟶ T) → (c.pt ⟶ T)

case mpr.intro.intro.refine_2
X Y : Type u
c : BinaryCofan X Y
h₁ : Injective c.inl
h₂ : Injective c.inr
h₃ : IsCompl (Set.range c.inl) (Set.range c.inr)
this :
  ∀ (x : ((Functor.const (Discrete WalkingPair)).obj c.pt).obj { as := left }),
    x ∈ Set.range c.inl ∨ x ∈ Set.range c.inr
⊢ ∀ {T : Type u} (f : X ⟶ T) (g : Y ⟶ T), c.inl ≫ ?mpr.intro.intro.refine_1 f g = f

case mpr.intro.intro.refine_3
X Y : Type u
c : BinaryCofan X Y
h₁ : Injective c.inl
h₂ : Injective c.inr
h₃ : IsCompl (Set.range c.inl) (Set.range c.inr)
this :
  ∀ (x : ((Functor.const (Discrete WalkingPair)).obj c.pt).obj { as := left }),
    x ∈ Set.range c.inl ∨ x ∈ Set.range c.inr
⊢ ∀ {T : Type u} (f : X ⟶ T) (g : Y ⟶ T), c.inr ≫ ?mpr.intro.intro.refine_1 f g = g

case mpr.intro.intro.refine_4
X Y : Type u
c : BinaryCofan X Y
h₁ : Injective c.inl
h₂ : Injective c.inr
h₃ : IsCompl (Set.range c.inl) (Set.range c.inr)
this :
  ∀ (x : ((Functor.const (Discrete WalkingPair)).obj c.pt).obj { as := left }),
    x ∈ Set.range c.inl ∨ x ∈ Set.range c.inr
⊢ ∀ {T : Type u} (f : X ⟶ T) (g : Y ⟶ T) (m : c.pt ⟶ T),
    c.inl ≫ m = f → c.inr ≫ m = g → m = ?mpr.intro.intro.refine_1 f g