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

Tactic:
intro y e

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

Proof state:
case mpr.intro.intro.refine_4.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
m : c.pt ⟶ T
x : c.pt
⊢ m 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, ⋯⟩)

Tactic:
dsimp

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

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 }
⊢ (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

Tactic:
dsimp

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 }
⊢ (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

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

Tactic:
rintro ⟨h⟩

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

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} → (X ⟶ T) → (Y ⟶ T) → (c.pt ⟶ T)

Tactic:
intro T f g x

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
f : X ⟶ T
g : Y ⟶ T
x : c.pt
⊢ T

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:
intro T f g

Result:
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

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
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, ⋯⟩)

Tactic:
funext x

Result:
case mpr.intro.intro.refine_4.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
m : c.pt ⟶ T
x : c.pt
⊢ m 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
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)

Tactic:
have : ∀ x, x ∈ Set.range c.inl ∨ x ∈ Set.range c.inr := by
  rw [eq_compl_iff_isCompl.mpr h₃.symm]
  exact fun _ => or_not

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)
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)