-- 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 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 }
⊢ (if h : c.inr x ∈ Set.range c.inl then f ((Equiv.ofInjective c.inl h₁).symm ⟨c.inr x, h⟩)
    else g ((Equiv.ofInjective c.inr h₂).symm ⟨c.inr x, ⋯⟩)) =
    g x

Tactic:
simp only [Set.mem_range, Equiv.ofInjective_symm_apply,
  dite_eq_right_iff, forall_exists_index]

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 }
⊢ ∀ (x_1 : X) (h : c.inl x_1 = c.inr x), f ((Equiv.ofInjective c.inl h₁).symm ⟨c.inr x, ⋯⟩) = g x

Proof state:
case mpr
X Y : Type u
c : BinaryCofan X Y
⊢ Injective c.inl ∧ Injective c.inr ∧ IsCompl (Set.range c.inl) (Set.range c.inr) → Nonempty (IsColimit c)

Tactic:
rintro ⟨h₁, h₂, h₃⟩

Result:
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)
⊢ Nonempty (IsColimit c)

Proof state:
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)
⊢ ∀ (x : ((Functor.const (Discrete WalkingPair)).obj c.pt).obj { as := left }),
    x ∈ Set.range c.inl ∨ x ∈ (Set.range c.inl)ᶜ

Tactic:
exact fun _ => or_not

Result:
no goals

Proof state:
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 }
y : X
e : c.inl y = c.inr x
this : c.inr x ∈ Set.range c.inl ⊓ Set.range c.inr
⊢ f ((Equiv.ofInjective c.inl h₁).symm ⟨c.inr x, ⋯⟩) = g x

Tactic:
rw [disjoint_iff.mp h₃.1] at this

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 }
y : X
e : c.inl y = c.inr x
this : c.inr x ∈ ⊥
⊢ f ((Equiv.ofInjective c.inl h₁).symm ⟨c.inr x, ⋯⟩) = g x

Proof state:
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 = 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, ⋯⟩)

Tactic:
rintro T _ _ m rfl rfl

Result:
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
m : c.pt ⟶ T
⊢ m = fun x =>
    if h : x ∈ Set.range c.inl then (c.inl ≫ m) ((Equiv.ofInjective c.inl h₁).symm ⟨x, h⟩)
    else (c.inr ≫ m) ((Equiv.ofInjective c.inr h₂).symm ⟨x, ⋯⟩)

Proof state:
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 ≫ 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, ⋯⟩)) =
    f

Tactic:
funext x

Result:
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 }
⊢ (c.inl ≫ 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 =
    f x

Proof state:
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

Tactic:
dsimp

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 }
⊢ (if h : c.inr x ∈ Set.range c.inl then f ((Equiv.ofInjective c.inl h₁).symm ⟨c.inr x, h⟩)
    else g ((Equiv.ofInjective c.inr h₂).symm ⟨c.inr x, ⋯⟩)) =
    g x

Proof state:
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)

Tactic:
constructor

Result:
case mp
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)

case mpr
X Y : Type u
c : BinaryCofan X Y
⊢ Injective c.inl ∧ Injective c.inr ∧ IsCompl (Set.range c.inl) (Set.range c.inr) → Nonempty (IsColimit c)

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)).inv '' Set.range Sum.inr)ᶜ

Tactic:
erw [← Set.image_compl_eq
    (h.coconePointUniqueUpToIso (binaryCoproductColimit X Y)).symm.toEquiv.bijective]

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)).symm.toEquiv '' (Set.range Sum.inr)ᶜ