Theorem: Combinatorics.Line.exists_mono_in_high_dimension'
File: Mathlib/Combinatorics/HalesJewett.lean

tactic: rw [← lc x, Line.map_apply]
state_before: α α' : Type u
e : α ≃ α'
κ : Type (max v u)
x✝¹ : Finite κ
ι : Type
x✝ : Fintype ι
h : ∀ (C : (ι → α) → κ), ∃ l, IsMono C l
C : (ι → α') → κ
l : Line α ι
c : κ
lc : ∀ (x : α), (fun v => C (↑e ∘ v)) ((fun x i => Option.getD (idxFun l i) x) x) = c
x : α
⊢ C ((fun x i => Option.getD (idxFun (map (↑e) l) i) x) (↑e x)) = c

tactic: intro κ _
state_before: ⊢ ∀ (κ : Type (max v u)) [inst : Finite κ], ∃ ι x, ∀ (C : (ι → PEmpty) → κ), ∃ l, IsMono C l

tactic: by_cases h : Nonempty κ
state_before: κ : Type (max v u)
inst✝ : Finite κ
⊢ ∃ ι x, ∀ (C : (ι → PEmpty) → κ), ∃ l, IsMono C l

tactic: refine' ⟨Unit, inferInstance, fun C => ⟨default, Classical.arbitrary _, PEmpty.rec⟩⟩
state_before: case pos
κ : Type (max v u)
inst✝ : Finite κ
h : Nonempty κ
⊢ ∃ ι x, ∀ (C : (ι → PEmpty) → κ), ∃ l, IsMono C l

tactic: exact ⟨Empty, inferInstance, fun C => (h ⟨C (Empty.rec)⟩).elim⟩
state_before: case neg
κ : Type (max v u)
inst✝ : Finite κ
h : ¬Nonempty κ
⊢ ∃ ι x, ∀ (C : (ι → PEmpty) → κ), ∃ l, IsMono C l

tactic: intro α _ ihα κ _
state_before: ⊢ ∀ {α : Type u} [inst : Fintype α],
    (∀ (κ : Type (max v u)) [inst : Finite κ], ∃ ι x, ∀ (C : (ι → α) → κ), ∃ l, IsMono C l) →
      ∀ (κ : Type (max v u)) [inst : Finite κ], ∃ ι x, ∀ (C : (ι → Option α) → κ), ∃ l, IsMono C l

tactic: cases nonempty_fintype κ
state_before: α : Type u
inst✝¹ : Fintype α
ihα : ∀ (κ : Type (max v u)) [inst : Finite κ], ∃ ι x, ∀ (C : (ι → α) → κ), ∃ l, IsMono C l
κ : Type (max v u)
inst✝ : Finite κ
⊢ ∃ ι x, ∀ (C : (ι → Option α) → κ), ∃ l, IsMono C l

tactic: by_cases h : Nonempty α
state_before: case intro
α : Type u
inst✝¹ : Fintype α
ihα : ∀ (κ : Type (max v u)) [inst : Finite κ], ∃ ι x, ∀ (C : (ι → α) → κ), ∃ l, IsMono C l
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
⊢ ∃ ι x, ∀ (C : (ι → Option α) → κ), ∃ l, IsMono C l

tactic: suffices key :
  ∀ r : ℕ,
    ∃ (ι : Type)(_ : Fintype ι),
      ∀ C : (ι → Option α) → κ,
        (∃ s : ColorFocused C, Multiset.card s.lines = r) ∨ ∃ l, IsMono C l
state_before: case pos
α : Type u
inst✝¹ : Fintype α
ihα : ∀ (κ : Type (max v u)) [inst : Finite κ], ∃ ι x, ∀ (C : (ι → α) → κ), ∃ l, IsMono C l
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h : Nonempty α
⊢ ∃ ι x, ∀ (C : (ι → Option α) → κ), ∃ l, IsMono C l

tactic: intro r
state_before: case key
α : Type u
inst✝¹ : Fintype α
ihα : ∀ (κ : Type (max v u)) [inst : Finite κ], ∃ ι x, ∀ (C : (ι → α) → κ), ∃ l, IsMono C l
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h : Nonempty α
⊢ ∀ (r : ℕ), ∃ ι x, ∀ (C : (ι → Option α) → κ), (∃ s, ↑Multiset.card s.lines = r) ∨ ∃ l, IsMono C l

tactic: induction' r with r ihr
state_before: case key
α : Type u
inst✝¹ : Fintype α
ihα : ∀ (κ : Type (max v u)) [inst : Finite κ], ∃ ι x, ∀ (C : (ι → α) → κ), ∃ l, IsMono C l
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h : Nonempty α
r : ℕ
⊢ ∃ ι x, ∀ (C : (ι → Option α) → κ), (∃ s, ↑Multiset.card s.lines = r) ∨ ∃ l, IsMono C l

tactic: obtain ⟨ι, _inst, hι⟩ := ihr
state_before: case key.succ
α : Type u
inst✝¹ : Fintype α
ihα : ∀ (κ : Type (max v u)) [inst : Finite κ], ∃ ι x, ∀ (C : (ι → α) → κ), ∃ l, IsMono C l
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h : Nonempty α
r : ℕ
ihr : ∃ ι x, ∀ (C : (ι → Option α) → κ), (∃ s, ↑Multiset.card s.lines = r) ∨ ∃ l, IsMono C l
⊢ ∃ ι x, ∀ (C : (ι → Option α) → κ), (∃ s, ↑Multiset.card s.lines = Nat.succ r) ∨ ∃ l, IsMono C l

tactic: specialize ihα ((ι → Option α) → κ)
state_before: case key.succ.intro.intro
α : Type u
inst✝¹ : Fintype α
ihα : ∀ (κ : Type (max v u)) [inst : Finite κ], ∃ ι x, ∀ (C : (ι → α) → κ), ∃ l, IsMono C l
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h : Nonempty α
r : ℕ
ι : Type
_inst : Fintype ι
hι : ∀ (C : (ι → Option α) → κ), (∃ s, ↑Multiset.card s.lines = r) ∨ ∃ l, IsMono C l
⊢ ∃ ι x, ∀ (C : (ι → Option α) → κ), (∃ s, ↑Multiset.card s.lines = Nat.succ r) ∨ ∃ l, IsMono C l

tactic: obtain ⟨ι', _inst, hι'⟩ := ihα
state_before: case key.succ.intro.intro
α : Type u
inst✝¹ : Fintype α
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h : Nonempty α
r : ℕ
ι : Type
_inst : Fintype ι
hι : ∀ (C : (ι → Option α) → κ), (∃ s, ↑Multiset.card s.lines = r) ∨ ∃ l, IsMono C l
ihα : ∃ ι_1 x, ∀ (C : (ι_1 → α) → (ι → Option α) → κ), ∃ l, IsMono C l
⊢ ∃ ι x, ∀ (C : (ι → Option α) → κ), (∃ s, ↑Multiset.card s.lines = Nat.succ r) ∨ ∃ l, IsMono C l

tactic: refine' ⟨Sum ι ι', inferInstance, _⟩
state_before: case key.succ.intro.intro.intro.intro
α : Type u
inst✝¹ : Fintype α
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h : Nonempty α
r : ℕ
ι : Type
_inst✝ : Fintype ι
hι : ∀ (C : (ι → Option α) → κ), (∃ s, ↑Multiset.card s.lines = r) ∨ ∃ l, IsMono C l
ι' : Type
_inst : Fintype ι'
hι' : ∀ (C : (ι' → α) → (ι → Option α) → κ), ∃ l, IsMono C l
⊢ ∃ ι x, ∀ (C : (ι → Option α) → κ), (∃ s, ↑Multiset.card s.lines = Nat.succ r) ∨ ∃ l, IsMono C l

tactic: intro C
state_before: case key.succ.intro.intro.intro.intro
α : Type u
inst✝¹ : Fintype α
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h : Nonempty α
r : ℕ
ι : Type
_inst✝ : Fintype ι
hι : ∀ (C : (ι → Option α) → κ), (∃ s, ↑Multiset.card s.lines = r) ∨ ∃ l, IsMono C l
ι' : Type
_inst : Fintype ι'
hι' : ∀ (C : (ι' → α) → (ι → Option α) → κ), ∃ l, IsMono C l
⊢ ∀ (C : (ι ⊕ ι' → Option α) → κ), (∃ s, ↑Multiset.card s.lines = Nat.succ r) ∨ ∃ l, IsMono C l

tactic: specialize hι' fun v' v => C (Sum.elim v (some ∘ v'))
state_before: case key.succ.intro.intro.intro.intro
α : Type u
inst✝¹ : Fintype α
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h : Nonempty α
r : ℕ
ι : Type
_inst✝ : Fintype ι
hι : ∀ (C : (ι → Option α) → κ), (∃ s, ↑Multiset.card s.lines = r) ∨ ∃ l, IsMono C l
ι' : Type
_inst : Fintype ι'
hι' : ∀ (C : (ι' → α) → (ι → Option α) → κ), ∃ l, IsMono C l
C : (ι ⊕ ι' → Option α) → κ
⊢ (∃ s, ↑Multiset.card s.lines = Nat.succ r) ∨ ∃ l, IsMono C l

tactic: obtain ⟨l', C', hl'⟩ := hι'
state_before: case key.succ.intro.intro.intro.intro
α : Type u
inst✝¹ : Fintype α
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h : Nonempty α
r : ℕ
ι : Type
_inst✝ : Fintype ι
hι : ∀ (C : (ι → Option α) → κ), (∃ s, ↑Multiset.card s.lines = r) ∨ ∃ l, IsMono C l
ι' : Type
_inst : Fintype ι'
C : (ι ⊕ ι' → Option α) → κ
hι' : ∃ l, IsMono (fun v' v => C (Sum.elim v (some ∘ v'))) l
⊢ (∃ s, ↑Multiset.card s.lines = Nat.succ r) ∨ ∃ l, IsMono C l

tactic: have mono_of_mono : (∃ l, IsMono C' l) → ∃ l, IsMono C l := by
  rintro ⟨l, c, hl⟩
  refine' ⟨l.horizontal (some ∘ l' (Classical.arbitrary α)), c, fun x => _⟩
  rw [Line.horizontal_apply, ← hl, ← hl']
state_before: case key.succ.intro.intro.intro.intro.intro.intro
α : Type u
inst✝¹ : Fintype α
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h : Nonempty α
r : ℕ
ι : Type
_inst✝ : Fintype ι
hι : ∀ (C : (ι → Option α) → κ), (∃ s, ↑Multiset.card s.lines = r) ∨ ∃ l, IsMono C l
ι' : Type
_inst : Fintype ι'
C : (ι ⊕ ι' → Option α) → κ
l' : Line α ι'
C' : (ι → Option α) → κ
hl' : ∀ (x : α), (fun v' v => C (Sum.elim v (some ∘ v'))) ((fun x i => Option.getD (idxFun l' i) x) x) = C'
⊢ (∃ s, ↑Multiset.card s.lines = Nat.succ r) ∨ ∃ l, IsMono C l

tactic: specialize hι C'
state_before: case key.succ.intro.intro.intro.intro.intro.intro
α : Type u
inst✝¹ : Fintype α
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h : Nonempty α
r : ℕ
ι : Type
_inst✝ : Fintype ι
hι : ∀ (C : (ι → Option α) → κ), (∃ s, ↑Multiset.card s.lines = r) ∨ ∃ l, IsMono C l
ι' : Type
_inst : Fintype ι'
C : (ι ⊕ ι' → Option α) → κ
l' : Line α ι'
C' : (ι → Option α) → κ
hl' : ∀ (x : α), (fun v' v => C (Sum.elim v (some ∘ v'))) ((fun x i => Option.getD (idxFun l' i) x) x) = C'
mono_of_mono : (∃ l, IsMono C' l) → ∃ l, IsMono C l
⊢ (∃ s, ↑Multiset.card s.lines = Nat.succ r) ∨ ∃ l, IsMono C l

tactic: rcases hι with (⟨s, sr⟩ | h)
state_before: case key.succ.intro.intro.intro.intro.intro.intro
α : Type u
inst✝¹ : Fintype α
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h : Nonempty α
r : ℕ
ι : Type
_inst✝ : Fintype ι
ι' : Type
_inst : Fintype ι'
C : (ι ⊕ ι' → Option α) → κ
l' : Line α ι'
C' : (ι → Option α) → κ
hl' : ∀ (x : α), (fun v' v => C (Sum.elim v (some ∘ v'))) ((fun x i => Option.getD (idxFun l' i) x) x) = C'
mono_of_mono : (∃ l, IsMono C' l) → ∃ l, IsMono C l
hι : (∃ s, ↑Multiset.card s.lines = r) ∨ ∃ l, IsMono C' l
⊢ (∃ s, ↑Multiset.card s.lines = Nat.succ r) ∨ ∃ l, IsMono C l

tactic: on_goal 2 => exact Or.inr (mono_of_mono h)
state_before: case key.succ.intro.intro.intro.intro.intro.intro.inl.intro
α : Type u
inst✝¹ : Fintype α
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h : Nonempty α
r : ℕ
ι : Type
_inst✝ : Fintype ι
ι' : Type
_inst : Fintype ι'
C : (ι ⊕ ι' → Option α) → κ
l' : Line α ι'
C' : (ι → Option α) → κ
hl' : ∀ (x : α), (fun v' v => C (Sum.elim v (some ∘ v'))) ((fun x i => Option.getD (idxFun l' i) x) x) = C'
mono_of_mono : (∃ l, IsMono C' l) → ∃ l, IsMono C l
s : ColorFocused C'
sr : ↑Multiset.card s.lines = r
⊢ (∃ s, ↑Multiset.card s.lines = Nat.succ r) ∨ ∃ l, IsMono C l

case key.succ.intro.intro.intro.intro.intro.intro.inr
α : Type u
inst✝¹ : Fintype α
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h✝ : Nonempty α
r : ℕ
ι : Type
_inst✝ : Fintype ι
ι' : Type
_inst : Fintype ι'
C : (ι ⊕ ι' → Option α) → κ
l' : Line α ι'
C' : (ι → Option α) → κ
hl' : ∀ (x : α), (fun v' v => C (Sum.elim v (some ∘ v'))) ((fun x i => Option.getD (idxFun l' i) x) x) = C'
mono_of_mono : (∃ l, IsMono C' l) → ∃ l, IsMono C l
h : ∃ l, IsMono C' l
⊢ (∃ s, ↑Multiset.card s.lines = Nat.succ r) ∨ ∃ l, IsMono C l

tactic: by_cases h : ∃ p ∈ s.lines, (p : AlmostMono _).color = C' s.focus
state_before: case key.succ.intro.intro.intro.intro.intro.intro.inl.intro
α : Type u
inst✝¹ : Fintype α
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h : Nonempty α
r : ℕ
ι : Type
_inst✝ : Fintype ι
ι' : Type
_inst : Fintype ι'
C : (ι ⊕ ι' → Option α) → κ
l' : Line α ι'
C' : (ι → Option α) → κ
hl' : ∀ (x : α), (fun v' v => C (Sum.elim v (some ∘ v'))) ((fun x i => Option.getD (idxFun l' i) x) x) = C'
mono_of_mono : (∃ l, IsMono C' l) → ∃ l, IsMono C l
s : ColorFocused C'
sr : ↑Multiset.card s.lines = r
⊢ (∃ s, ↑Multiset.card s.lines = Nat.succ r) ∨ ∃ l, IsMono C l

tactic: refine' Or.inl ⟨⟨(s.lines.map _).cons ⟨(l'.map some).vertical s.focus, C' s.focus, fun x => _⟩,
        Sum.elim s.focus (l'.map some none), _, _⟩, _⟩
state_before: case neg
α : Type u
inst✝¹ : Fintype α
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h✝ : Nonempty α
r : ℕ
ι : Type
_inst✝ : Fintype ι
ι' : Type
_inst : Fintype ι'
C : (ι ⊕ ι' → Option α) → κ
l' : Line α ι'
C' : (ι → Option α) → κ
hl' : ∀ (x : α), (fun v' v => C (Sum.elim v (some ∘ v'))) ((fun x i => Option.getD (idxFun l' i) x) x) = C'
mono_of_mono : (∃ l, IsMono C' l) → ∃ l, IsMono C l
s : ColorFocused C'
sr : ↑Multiset.card s.lines = r
h : ¬∃ p, p ∈ s.lines ∧ p.color = C' s.focus
⊢ (∃ s, ↑Multiset.card s.lines = Nat.succ r) ∨ ∃ l, IsMono C l

tactic: refine' ⟨Unit, inferInstance, fun C => ⟨diagonal _ Unit, C fun _ => none, ?_⟩⟩
state_before: case neg
α : Type u
inst✝¹ : Fintype α
ihα : ∀ (κ : Type (max v u)) [inst : Finite κ], ∃ ι x, ∀ (C : (ι → α) → κ), ∃ l, IsMono C l
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h : ¬Nonempty α
⊢ ∃ ι x, ∀ (C : (ι → Option α) → κ), ∃ l, IsMono C l

tactic: rintro (_ | ⟨a⟩)
state_before: case neg
α : Type u
inst✝¹ : Fintype α
ihα : ∀ (κ : Type (max v u)) [inst : Finite κ], ∃ ι x, ∀ (C : (ι → α) → κ), ∃ l, IsMono C l
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h : ¬Nonempty α
C : (Unit → Option α) → κ
⊢ ∀ (x : Option α), C ((fun x i => Option.getD (idxFun (diagonal (Option α) Unit) i) x) x) = C fun x => none

tactic: rfl
state_before: case neg.none
α : Type u
inst✝¹ : Fintype α
ihα : ∀ (κ : Type (max v u)) [inst : Finite κ], ∃ ι x, ∀ (C : (ι → α) → κ), ∃ l, IsMono C l
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h : ¬Nonempty α
C : (Unit → Option α) → κ
⊢ C ((fun x i => Option.getD (idxFun (diagonal (Option α) Unit) i) x) none) = C fun x => none

tactic: exact (h ⟨a⟩).elim
state_before: case neg.some
α : Type u
inst✝¹ : Fintype α
ihα : ∀ (κ : Type (max v u)) [inst : Finite κ], ∃ ι x, ∀ (C : (ι → α) → κ), ∃ l, IsMono C l
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h : ¬Nonempty α
C : (Unit → Option α) → κ
a : α
⊢ C ((fun x i => Option.getD (idxFun (diagonal (Option α) Unit) i) x) (some a)) = C fun x => none

tactic: refine' ⟨Unit, inferInstance, fun C => ⟨diagonal _ Unit, C fun _ => none, ?_⟩⟩
state_before: case neg
α : Type u
inst✝¹ : Fintype α
ihα : ∀ (κ : Type (max v u)) [inst : Finite κ], ∃ ι x, ∀ (C : (ι → α) → κ), ∃ l, IsMono C l
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h : ¬Nonempty α
⊢ ∃ ι x, ∀ (C : (ι → Option α) → κ), ∃ l, IsMono C l

tactic: rintro (_ | ⟨a⟩)
state_before: case neg
α : Type u
inst✝¹ : Fintype α
ihα : ∀ (κ : Type (max v u)) [inst : Finite κ], ∃ ι x, ∀ (C : (ι → α) → κ), ∃ l, IsMono C l
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h : ¬Nonempty α
C : (Unit → Option α) → κ
⊢ ∀ (x : Option α), C ((fun x i => Option.getD (idxFun (diagonal (Option α) Unit) i) x) x) = C fun x => none

tactic: rfl
state_before: case neg.none
α : Type u
inst✝¹ : Fintype α
ihα : ∀ (κ : Type (max v u)) [inst : Finite κ], ∃ ι x, ∀ (C : (ι → α) → κ), ∃ l, IsMono C l
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h : ¬Nonempty α
C : (Unit → Option α) → κ
⊢ C ((fun x i => Option.getD (idxFun (diagonal (Option α) Unit) i) x) none) = C fun x => none

tactic: exact (h ⟨a⟩).elim
state_before: case neg.some
α : Type u
inst✝¹ : Fintype α
ihα : ∀ (κ : Type (max v u)) [inst : Finite κ], ∃ ι x, ∀ (C : (ι → α) → κ), ∃ l, IsMono C l
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h : ¬Nonempty α
C : (Unit → Option α) → κ
a : α
⊢ C ((fun x i => Option.getD (idxFun (diagonal (Option α) Unit) i) x) (some a)) = C fun x => none

tactic: obtain ⟨ι, _inst, hι⟩ := key (Fintype.card κ + 1)
state_before: case pos
α : Type u
inst✝¹ : Fintype α
ihα : ∀ (κ : Type (max v u)) [inst : Finite κ], ∃ ι x, ∀ (C : (ι → α) → κ), ∃ l, IsMono C l
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h : Nonempty α
key : ∀ (r : ℕ), ∃ ι x, ∀ (C : (ι → Option α) → κ), (∃ s, ↑Multiset.card s.lines = r) ∨ ∃ l, IsMono C l
⊢ ∃ ι x, ∀ (C : (ι → Option α) → κ), ∃ l, IsMono C l

tactic: refine' ⟨ι, _inst, fun C => (hι C).resolve_left _⟩
state_before: case pos.intro.intro
α : Type u
inst✝¹ : Fintype α
ihα : ∀ (κ : Type (max v u)) [inst : Finite κ], ∃ ι x, ∀ (C : (ι → α) → κ), ∃ l, IsMono C l
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h : Nonempty α
key : ∀ (r : ℕ), ∃ ι x, ∀ (C : (ι → Option α) → κ), (∃ s, ↑Multiset.card s.lines = r) ∨ ∃ l, IsMono C l
ι : Type
_inst : Fintype ι
hι : ∀ (C : (ι → Option α) → κ), (∃ s, ↑Multiset.card s.lines = Fintype.card κ + 1) ∨ ∃ l, IsMono C l
⊢ ∃ ι x, ∀ (C : (ι → Option α) → κ), ∃ l, IsMono C l

tactic: rintro ⟨s, sr⟩
state_before: case pos.intro.intro
α : Type u
inst✝¹ : Fintype α
ihα : ∀ (κ : Type (max v u)) [inst : Finite κ], ∃ ι x, ∀ (C : (ι → α) → κ), ∃ l, IsMono C l
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h : Nonempty α
key : ∀ (r : ℕ), ∃ ι x, ∀ (C : (ι → Option α) → κ), (∃ s, ↑Multiset.card s.lines = r) ∨ ∃ l, IsMono C l
ι : Type
_inst : Fintype ι
hι : ∀ (C : (ι → Option α) → κ), (∃ s, ↑Multiset.card s.lines = Fintype.card κ + 1) ∨ ∃ l, IsMono C l
C : (ι → Option α) → κ
⊢ ¬∃ s, ↑Multiset.card s.lines = Fintype.card κ + 1

tactic: apply Nat.not_succ_le_self (Fintype.card κ)
state_before: case pos.intro.intro.intro
α : Type u
inst✝¹ : Fintype α
ihα : ∀ (κ : Type (max v u)) [inst : Finite κ], ∃ ι x, ∀ (C : (ι → α) → κ), ∃ l, IsMono C l
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h : Nonempty α
key : ∀ (r : ℕ), ∃ ι x, ∀ (C : (ι → Option α) → κ), (∃ s, ↑Multiset.card s.lines = r) ∨ ∃ l, IsMono C l
ι : Type
_inst : Fintype ι
hι : ∀ (C : (ι → Option α) → κ), (∃ s, ↑Multiset.card s.lines = Fintype.card κ + 1) ∨ ∃ l, IsMono C l
C : (ι → Option α) → κ
s : ColorFocused C
sr : ↑Multiset.card s.lines = Fintype.card κ + 1
⊢ False

tactic: rw [← Nat.add_one, ← sr, ← Multiset.card_map, ← Finset.card_mk]
state_before: case pos.intro.intro.intro
α : Type u
inst✝¹ : Fintype α
ihα : ∀ (κ : Type (max v u)) [inst : Finite κ], ∃ ι x, ∀ (C : (ι → α) → κ), ∃ l, IsMono C l
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h : Nonempty α
key : ∀ (r : ℕ), ∃ ι x, ∀ (C : (ι → Option α) → κ), (∃ s, ↑Multiset.card s.lines = r) ∨ ∃ l, IsMono C l
ι : Type
_inst : Fintype ι
hι : ∀ (C : (ι → Option α) → κ), (∃ s, ↑Multiset.card s.lines = Fintype.card κ + 1) ∨ ∃ l, IsMono C l
C : (ι → Option α) → κ
s : ColorFocused C
sr : ↑Multiset.card s.lines = Fintype.card κ + 1
⊢ Nat.succ (Fintype.card κ) ≤ Fintype.card κ

tactic: exact Finset.card_le_univ ⟨_, s.distinct_colors⟩
state_before: case pos.intro.intro.intro
α : Type u
inst✝¹ : Fintype α
ihα : ∀ (κ : Type (max v u)) [inst : Finite κ], ∃ ι x, ∀ (C : (ι → α) → κ), ∃ l, IsMono C l
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h : Nonempty α
key : ∀ (r : ℕ), ∃ ι x, ∀ (C : (ι → Option α) → κ), (∃ s, ↑Multiset.card s.lines = r) ∨ ∃ l, IsMono C l
ι : Type
_inst : Fintype ι
hι : ∀ (C : (ι → Option α) → κ), (∃ s, ↑Multiset.card s.lines = Fintype.card κ + 1) ∨ ∃ l, IsMono C l
C : (ι → Option α) → κ
s : ColorFocused C
sr : ↑Multiset.card s.lines = Fintype.card κ + 1
⊢ Finset.card { val := Multiset.map ?pos.intro.intro.intro.f✝ s.lines, nodup := ?m.16325 } ≤ Fintype.card κ

α : Type u
inst✝¹ : Fintype α
ihα : ∀ (κ : Type (max v u)) [inst : Finite κ], ∃ ι x, ∀ (C : (ι → α) → κ), ∃ l, IsMono C l
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h : Nonempty α
key : ∀ (r : ℕ), ∃ ι x, ∀ (C : (ι → Option α) → κ), (∃ s, ↑Multiset.card s.lines = r) ∨ ∃ l, IsMono C l
ι : Type
_inst : Fintype ι
hι : ∀ (C : (ι → Option α) → κ), (∃ s, ↑Multiset.card s.lines = Fintype.card κ + 1) ∨ ∃ l, IsMono C l
C : (ι → Option α) → κ
s : ColorFocused C
sr : ↑Multiset.card s.lines = Fintype.card κ + 1
⊢ Type ?u.16322

case pos.intro.intro.intro.f
α : Type u
inst✝¹ : Fintype α
ihα : ∀ (κ : Type (max v u)) [inst : Finite κ], ∃ ι x, ∀ (C : (ι → α) → κ), ∃ l, IsMono C l
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h : Nonempty α
key : ∀ (r : ℕ), ∃ ι x, ∀ (C : (ι → Option α) → κ), (∃ s, ↑Multiset.card s.lines = r) ∨ ∃ l, IsMono C l
ι : Type
_inst : Fintype ι
hι : ∀ (C : (ι → Option α) → κ), (∃ s, ↑Multiset.card s.lines = Fintype.card κ + 1) ∨ ∃ l, IsMono C l
C : (ι → Option α) → κ
s : ColorFocused C
sr : ↑Multiset.card s.lines = Fintype.card κ + 1
⊢ AlmostMono C → ?m.16323

α : Type u
inst✝¹ : Fintype α
ihα : ∀ (κ : Type (max v u)) [inst : Finite κ], ∃ ι x, ∀ (C : (ι → α) → κ), ∃ l, IsMono C l
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h : Nonempty α
key : ∀ (r : ℕ), ∃ ι x, ∀ (C : (ι → Option α) → κ), (∃ s, ↑Multiset.card s.lines = r) ∨ ∃ l, IsMono C l
ι : Type
_inst : Fintype ι
hι : ∀ (C : (ι → Option α) → κ), (∃ s, ↑Multiset.card s.lines = Fintype.card κ + 1) ∨ ∃ l, IsMono C l
C : (ι → Option α) → κ
s : ColorFocused C
sr : ↑Multiset.card s.lines = Fintype.card κ + 1
⊢ Multiset.Nodup (Multiset.map ?pos.intro.intro.intro.f✝ s.lines)

case pos.intro.intro.intro.f
α : Type u
inst✝¹ : Fintype α
ihα : ∀ (κ : Type (max v u)) [inst : Finite κ], ∃ ι x, ∀ (C : (ι → α) → κ), ∃ l, IsMono C l
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h : Nonempty α
key : ∀ (r : ℕ), ∃ ι x, ∀ (C : (ι → Option α) → κ), (∃ s, ↑Multiset.card s.lines = r) ∨ ∃ l, IsMono C l
ι : Type
_inst : Fintype ι
hι : ∀ (C : (ι → Option α) → κ), (∃ s, ↑Multiset.card s.lines = Fintype.card κ + 1) ∨ ∃ l, IsMono C l
C : (ι → Option α) → κ
s : ColorFocused C
sr : ↑Multiset.card s.lines = Fintype.card κ + 1
⊢ AlmostMono C → ?m.16323

tactic: exact ⟨Empty, inferInstance, fun C => Or.inl ⟨default, Multiset.card_zero⟩⟩
state_before: case key.zero
α : Type u
inst✝¹ : Fintype α
ihα : ∀ (κ : Type (max v u)) [inst : Finite κ], ∃ ι x, ∀ (C : (ι → α) → κ), ∃ l, IsMono C l
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h : Nonempty α
⊢ ∃ ι x, ∀ (C : (ι → Option α) → κ), (∃ s, ↑Multiset.card s.lines = Nat.zero) ∨ ∃ l, IsMono C l

tactic: rintro ⟨l, c, hl⟩
state_before: α : Type u
inst✝¹ : Fintype α
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h : Nonempty α
r : ℕ
ι : Type
_inst✝ : Fintype ι
hι : ∀ (C : (ι → Option α) → κ), (∃ s, ↑Multiset.card s.lines = r) ∨ ∃ l, IsMono C l
ι' : Type
_inst : Fintype ι'
C : (ι ⊕ ι' → Option α) → κ
l' : Line α ι'
C' : (ι → Option α) → κ
hl' : ∀ (x : α), (fun v' v => C (Sum.elim v (some ∘ v'))) ((fun x i => Option.getD (idxFun l' i) x) x) = C'
⊢ (∃ l, IsMono C' l) → ∃ l, IsMono C l

tactic: refine' ⟨l.horizontal (some ∘ l' (Classical.arbitrary α)), c, fun x => _⟩
state_before: case intro.intro
α : Type u
inst✝¹ : Fintype α
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h : Nonempty α
r : ℕ
ι : Type
_inst✝ : Fintype ι
hι : ∀ (C : (ι → Option α) → κ), (∃ s, ↑Multiset.card s.lines = r) ∨ ∃ l, IsMono C l
ι' : Type
_inst : Fintype ι'
C : (ι ⊕ ι' → Option α) → κ
l' : Line α ι'
C' : (ι → Option α) → κ
hl' : ∀ (x : α), (fun v' v => C (Sum.elim v (some ∘ v'))) ((fun x i => Option.getD (idxFun l' i) x) x) = C'
l : Line (Option α) ι
c : κ
hl : ∀ (x : Option α), C' ((fun x i => Option.getD (idxFun l i) x) x) = c
⊢ ∃ l, IsMono C l

tactic: rw [Line.horizontal_apply, ← hl, ← hl']
state_before: case intro.intro
α : Type u
inst✝¹ : Fintype α
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h : Nonempty α
r : ℕ
ι : Type
_inst✝ : Fintype ι
hι : ∀ (C : (ι → Option α) → κ), (∃ s, ↑Multiset.card s.lines = r) ∨ ∃ l, IsMono C l
ι' : Type
_inst : Fintype ι'
C : (ι ⊕ ι' → Option α) → κ
l' : Line α ι'
C' : (ι → Option α) → κ
hl' : ∀ (x : α), (fun v' v => C (Sum.elim v (some ∘ v'))) ((fun x i => Option.getD (idxFun l' i) x) x) = C'
l : Line (Option α) ι
c : κ
hl : ∀ (x : Option α), C' ((fun x i => Option.getD (idxFun l i) x) x) = c
x : Option α
⊢ C
      ((fun x i =>
          Option.getD
            (idxFun (horizontal l (some ∘ (fun x i => Option.getD (idxFun l' i) x) (Classical.arbitrary α))) i) x)
        x) =
    c

tactic: exact Or.inr (mono_of_mono h)
state_before: case key.succ.intro.intro.intro.intro.intro.intro.inr
α : Type u
inst✝¹ : Fintype α
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h✝ : Nonempty α
r : ℕ
ι : Type
_inst✝ : Fintype ι
ι' : Type
_inst : Fintype ι'
C : (ι ⊕ ι' → Option α) → κ
l' : Line α ι'
C' : (ι → Option α) → κ
hl' : ∀ (x : α), (fun v' v => C (Sum.elim v (some ∘ v'))) ((fun x i => Option.getD (idxFun l' i) x) x) = C'
mono_of_mono : (∃ l, IsMono C' l) → ∃ l, IsMono C l
h : ∃ l, IsMono C' l
⊢ (∃ s, ↑Multiset.card s.lines = Nat.succ r) ∨ ∃ l, IsMono C l

tactic: exact Or.inr (mono_of_mono h)
state_before: case key.succ.intro.intro.intro.intro.intro.intro.inr
α : Type u
inst✝¹ : Fintype α
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h✝ : Nonempty α
r : ℕ
ι : Type
_inst✝ : Fintype ι
ι' : Type
_inst : Fintype ι'
C : (ι ⊕ ι' → Option α) → κ
l' : Line α ι'
C' : (ι → Option α) → κ
hl' : ∀ (x : α), (fun v' v => C (Sum.elim v (some ∘ v'))) ((fun x i => Option.getD (idxFun l' i) x) x) = C'
mono_of_mono : (∃ l, IsMono C' l) → ∃ l, IsMono C l
h : ∃ l, IsMono C' l
⊢ (∃ s, ↑Multiset.card s.lines = Nat.succ r) ∨ ∃ l, IsMono C l

tactic: obtain ⟨p, p_mem, hp⟩ := h
state_before: case pos
α : Type u
inst✝¹ : Fintype α
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h✝ : Nonempty α
r : ℕ
ι : Type
_inst✝ : Fintype ι
ι' : Type
_inst : Fintype ι'
C : (ι ⊕ ι' → Option α) → κ
l' : Line α ι'
C' : (ι → Option α) → κ
hl' : ∀ (x : α), (fun v' v => C (Sum.elim v (some ∘ v'))) ((fun x i => Option.getD (idxFun l' i) x) x) = C'
mono_of_mono : (∃ l, IsMono C' l) → ∃ l, IsMono C l
s : ColorFocused C'
sr : ↑Multiset.card s.lines = r
h : ∃ p, p ∈ s.lines ∧ p.color = C' s.focus
⊢ (∃ s, ↑Multiset.card s.lines = Nat.succ r) ∨ ∃ l, IsMono C l

tactic: refine' Or.inr (mono_of_mono ⟨p.line, p.color, _⟩)
state_before: case pos.intro.intro
α : Type u
inst✝¹ : Fintype α
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h : Nonempty α
r : ℕ
ι : Type
_inst✝ : Fintype ι
ι' : Type
_inst : Fintype ι'
C : (ι ⊕ ι' → Option α) → κ
l' : Line α ι'
C' : (ι → Option α) → κ
hl' : ∀ (x : α), (fun v' v => C (Sum.elim v (some ∘ v'))) ((fun x i => Option.getD (idxFun l' i) x) x) = C'
mono_of_mono : (∃ l, IsMono C' l) → ∃ l, IsMono C l
s : ColorFocused C'
sr : ↑Multiset.card s.lines = r
p : AlmostMono C'
p_mem : p ∈ s.lines
hp : p.color = C' s.focus
⊢ (∃ s, ↑Multiset.card s.lines = Nat.succ r) ∨ ∃ l, IsMono C l

tactic: rintro (_ | _)
state_before: case pos.intro.intro
α : Type u
inst✝¹ : Fintype α
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h : Nonempty α
r : ℕ
ι : Type
_inst✝ : Fintype ι
ι' : Type
_inst : Fintype ι'
C : (ι ⊕ ι' → Option α) → κ
l' : Line α ι'
C' : (ι → Option α) → κ
hl' : ∀ (x : α), (fun v' v => C (Sum.elim v (some ∘ v'))) ((fun x i => Option.getD (idxFun l' i) x) x) = C'
mono_of_mono : (∃ l, IsMono C' l) → ∃ l, IsMono C l
s : ColorFocused C'
sr : ↑Multiset.card s.lines = r
p : AlmostMono C'
p_mem : p ∈ s.lines
hp : p.color = C' s.focus
⊢ ∀ (x : Option α), C' ((fun x i => Option.getD (idxFun p.line i) x) x) = p.color

tactic: rw [hp, s.is_focused p p_mem]
state_before: case pos.intro.intro.none
α : Type u
inst✝¹ : Fintype α
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h : Nonempty α
r : ℕ
ι : Type
_inst✝ : Fintype ι
ι' : Type
_inst : Fintype ι'
C : (ι ⊕ ι' → Option α) → κ
l' : Line α ι'
C' : (ι → Option α) → κ
hl' : ∀ (x : α), (fun v' v => C (Sum.elim v (some ∘ v'))) ((fun x i => Option.getD (idxFun l' i) x) x) = C'
mono_of_mono : (∃ l, IsMono C' l) → ∃ l, IsMono C l
s : ColorFocused C'
sr : ↑Multiset.card s.lines = r
p : AlmostMono C'
p_mem : p ∈ s.lines
hp : p.color = C' s.focus
⊢ C' ((fun x i => Option.getD (idxFun p.line i) x) none) = p.color

case pos.intro.intro.some
α : Type u
inst✝¹ : Fintype α
κ : Type (max v u)
inst✝ : Finite κ
val✝¹ : Fintype κ
h : Nonempty α
r : ℕ
ι : Type
_inst✝ : Fintype ι
ι' : Type
_inst : Fintype ι'
C : (ι ⊕ ι' → Option α) → κ
l' : Line α ι'
C' : (ι → Option α) → κ
hl' : ∀ (x : α), (fun v' v => C (Sum.elim v (some ∘ v'))) ((fun x i => Option.getD (idxFun l' i) x) x) = C'
mono_of_mono : (∃ l, IsMono C' l) → ∃ l, IsMono C l
s : ColorFocused C'
sr : ↑Multiset.card s.lines = r
p : AlmostMono C'
p_mem : p ∈ s.lines
hp : p.color = C' s.focus
val✝ : α
⊢ C' ((fun x i => Option.getD (idxFun p.line i) x) (some val✝)) = p.color

tactic: apply p.has_color
state_before: case pos.intro.intro.some
α : Type u
inst✝¹ : Fintype α
κ : Type (max v u)
inst✝ : Finite κ
val✝¹ : Fintype κ
h : Nonempty α
r : ℕ
ι : Type
_inst✝ : Fintype ι
ι' : Type
_inst : Fintype ι'
C : (ι ⊕ ι' → Option α) → κ
l' : Line α ι'
C' : (ι → Option α) → κ
hl' : ∀ (x : α), (fun v' v => C (Sum.elim v (some ∘ v'))) ((fun x i => Option.getD (idxFun l' i) x) x) = C'
mono_of_mono : (∃ l, IsMono C' l) → ∃ l, IsMono C l
s : ColorFocused C'
sr : ↑Multiset.card s.lines = r
p : AlmostMono C'
p_mem : p ∈ s.lines
hp : p.color = C' s.focus
val✝ : α
⊢ C' ((fun x i => Option.getD (idxFun p.line i) x) (some val✝)) = p.color

tactic: refine' fun p => ⟨p.line.prod (l'.map some), p.color, fun x => _⟩
state_before: case neg.refine'_1
α : Type u
inst✝¹ : Fintype α
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h✝ : Nonempty α
r : ℕ
ι : Type
_inst✝ : Fintype ι
ι' : Type
_inst : Fintype ι'
C : (ι ⊕ ι' → Option α) → κ
l' : Line α ι'
C' : (ι → Option α) → κ
hl' : ∀ (x : α), (fun v' v => C (Sum.elim v (some ∘ v'))) ((fun x i => Option.getD (idxFun l' i) x) x) = C'
mono_of_mono : (∃ l, IsMono C' l) → ∃ l, IsMono C l
s : ColorFocused C'
sr : ↑Multiset.card s.lines = r
h : ¬∃ p, p ∈ s.lines ∧ p.color = C' s.focus
⊢ AlmostMono C' → AlmostMono C

tactic: rw [Line.prod_apply, Line.map_apply, ← p.has_color, ← congr_fun (hl' x)]
state_before: case neg.refine'_1
α : Type u
inst✝¹ : Fintype α
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h✝ : Nonempty α
r : ℕ
ι : Type
_inst✝ : Fintype ι
ι' : Type
_inst : Fintype ι'
C : (ι ⊕ ι' → Option α) → κ
l' : Line α ι'
C' : (ι → Option α) → κ
hl' : ∀ (x : α), (fun v' v => C (Sum.elim v (some ∘ v'))) ((fun x i => Option.getD (idxFun l' i) x) x) = C'
mono_of_mono : (∃ l, IsMono C' l) → ∃ l, IsMono C l
s : ColorFocused C'
sr : ↑Multiset.card s.lines = r
h : ¬∃ p, p ∈ s.lines ∧ p.color = C' s.focus
p : AlmostMono C'
x : α
⊢ C ((fun x i => Option.getD (idxFun (prod p.line (map some l')) i) x) (some x)) = p.color

tactic: rw [vertical_apply, ← congr_fun (hl' x), Line.map_apply]
state_before: case neg.refine'_2
α : Type u
inst✝¹ : Fintype α
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h✝ : Nonempty α
r : ℕ
ι : Type
_inst✝ : Fintype ι
ι' : Type
_inst : Fintype ι'
C : (ι ⊕ ι' → Option α) → κ
l' : Line α ι'
C' : (ι → Option α) → κ
hl' : ∀ (x : α), (fun v' v => C (Sum.elim v (some ∘ v'))) ((fun x i => Option.getD (idxFun l' i) x) x) = C'
mono_of_mono : (∃ l, IsMono C' l) → ∃ l, IsMono C l
s : ColorFocused C'
sr : ↑Multiset.card s.lines = r
h : ¬∃ p, p ∈ s.lines ∧ p.color = C' s.focus
x : α
⊢ C ((fun x i => Option.getD (idxFun (vertical s.focus (map some l')) i) x) (some x)) = C' s.focus

tactic: simp_rw [Multiset.mem_cons, Multiset.mem_map]
state_before: case neg.refine'_3
α : Type u
inst✝¹ : Fintype α
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h✝ : Nonempty α
r : ℕ
ι : Type
_inst✝ : Fintype ι
ι' : Type
_inst : Fintype ι'
C : (ι ⊕ ι' → Option α) → κ
l' : Line α ι'
C' : (ι → Option α) → κ
hl' : ∀ (x : α), (fun v' v => C (Sum.elim v (some ∘ v'))) ((fun x i => Option.getD (idxFun l' i) x) x) = C'
mono_of_mono : (∃ l, IsMono C' l) → ∃ l, IsMono C l
s : ColorFocused C'
sr : ↑Multiset.card s.lines = r
h : ¬∃ p, p ∈ s.lines ∧ p.color = C' s.focus
⊢ ∀ (p : AlmostMono C),
    p ∈
        { line := vertical s.focus (map some l'), color := C' s.focus,
            has_color :=
              (_ :
                ∀ (x : α),
                  C ((fun x i => Option.getD (idxFun (vertical s.focus (map some l')) i) x) (some x)) =
                    C' s.focus) } ::ₘ
          Multiset.map
            (fun p =>
              { line := prod p.line (map some l'), color := p.color,
                has_color :=
                  (_ :
                    ∀ (x : α),
                      C ((fun x i => Option.getD (idxFun (prod p.line (map some l')) i) x) (some x)) = p.color) })
            s.lines →
      (fun x i => Option.getD (idxFun p.line i) x) none =
        Sum.elim s.focus ((fun x i => Option.getD (idxFun (map some l') i) x) none)

tactic: rintro _ (rfl | ⟨q, hq, rfl⟩)
state_before: case neg.refine'_3
α : Type u
inst✝¹ : Fintype α
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h✝ : Nonempty α
r : ℕ
ι : Type
_inst✝ : Fintype ι
ι' : Type
_inst : Fintype ι'
C : (ι ⊕ ι' → Option α) → κ
l' : Line α ι'
C' : (ι → Option α) → κ
hl' : ∀ (x : α), (fun v' v => C (Sum.elim v (some ∘ v'))) ((fun x i => Option.getD (idxFun l' i) x) x) = C'
mono_of_mono : (∃ l, IsMono C' l) → ∃ l, IsMono C l
s : ColorFocused C'
sr : ↑Multiset.card s.lines = r
h : ¬∃ p, p ∈ s.lines ∧ p.color = C' s.focus
⊢ ∀ (p : AlmostMono C),
    (p =
          { line := vertical s.focus (map some l'), color := C' s.focus,
            has_color :=
              (_ :
                ∀ (x : α),
                  C ((fun x i => Option.getD (idxFun (vertical s.focus (map some l')) i) x) (some x)) = C' s.focus) } ∨
        ∃ a,
          a ∈ s.lines ∧
            { line := prod a.line (map some l'), color := a.color,
                has_color :=
                  (_ :
                    ∀ (x : α),
                      C ((fun x i => Option.getD (idxFun (prod a.line (map some l')) i) x) (some x)) = a.color) } =
              p) →
      (fun i => Option.getD (idxFun p.line i) none) =
        Sum.elim s.focus fun i => Option.getD (idxFun (map some l') i) none

tactic: simp only [vertical_apply]
state_before: case neg.refine'_3.inl
α : Type u
inst✝¹ : Fintype α
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h✝ : Nonempty α
r : ℕ
ι : Type
_inst✝ : Fintype ι
ι' : Type
_inst : Fintype ι'
C : (ι ⊕ ι' → Option α) → κ
l' : Line α ι'
C' : (ι → Option α) → κ
hl' : ∀ (x : α), (fun v' v => C (Sum.elim v (some ∘ v'))) ((fun x i => Option.getD (idxFun l' i) x) x) = C'
mono_of_mono : (∃ l, IsMono C' l) → ∃ l, IsMono C l
s : ColorFocused C'
sr : ↑Multiset.card s.lines = r
h : ¬∃ p, p ∈ s.lines ∧ p.color = C' s.focus
⊢ (fun i =>
      Option.getD
        (idxFun
          { line := vertical s.focus (map some l'), color := C' s.focus,
              has_color :=
                (_ :
                  ∀ (x : α),
                    C ((fun x i => Option.getD (idxFun (vertical s.focus (map some l')) i) x) (some x)) =
                      C' s.focus) }.line
          i)
        none) =
    Sum.elim s.focus fun i => Option.getD (idxFun (map some l') i) none

tactic: simp only [prod_apply, s.is_focused q hq]
state_before: case neg.refine'_3.inr.intro.intro
α : Type u
inst✝¹ : Fintype α
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h✝ : Nonempty α
r : ℕ
ι : Type
_inst✝ : Fintype ι
ι' : Type
_inst : Fintype ι'
C : (ι ⊕ ι' → Option α) → κ
l' : Line α ι'
C' : (ι → Option α) → κ
hl' : ∀ (x : α), (fun v' v => C (Sum.elim v (some ∘ v'))) ((fun x i => Option.getD (idxFun l' i) x) x) = C'
mono_of_mono : (∃ l, IsMono C' l) → ∃ l, IsMono C l
s : ColorFocused C'
sr : ↑Multiset.card s.lines = r
h : ¬∃ p, p ∈ s.lines ∧ p.color = C' s.focus
q : AlmostMono C'
hq : q ∈ s.lines
⊢ (fun i =>
      Option.getD
        (idxFun
          { line := prod q.line (map some l'), color := q.color,
              has_color :=
                (_ :
                  ∀ (x : α),
                    C ((fun x i => Option.getD (idxFun (prod q.line (map some l')) i) x) (some x)) = q.color) }.line
          i)
        none) =
    Sum.elim s.focus fun i => Option.getD (idxFun (map some l') i) none

tactic: rw [Multiset.map_cons, Multiset.map_map, Multiset.nodup_cons, Multiset.mem_map]
state_before: case neg.refine'_4
α : Type u
inst✝¹ : Fintype α
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h✝ : Nonempty α
r : ℕ
ι : Type
_inst✝ : Fintype ι
ι' : Type
_inst : Fintype ι'
C : (ι ⊕ ι' → Option α) → κ
l' : Line α ι'
C' : (ι → Option α) → κ
hl' : ∀ (x : α), (fun v' v => C (Sum.elim v (some ∘ v'))) ((fun x i => Option.getD (idxFun l' i) x) x) = C'
mono_of_mono : (∃ l, IsMono C' l) → ∃ l, IsMono C l
s : ColorFocused C'
sr : ↑Multiset.card s.lines = r
h : ¬∃ p, p ∈ s.lines ∧ p.color = C' s.focus
⊢ Multiset.Nodup
    (Multiset.map AlmostMono.color
      ({ line := vertical s.focus (map some l'), color := C' s.focus,
          has_color :=
            (_ :
              ∀ (x : α),
                C ((fun x i => Option.getD (idxFun (vertical s.focus (map some l')) i) x) (some x)) = C' s.focus) } ::ₘ
        Multiset.map
          (fun p =>
            { line := prod p.line (map some l'), color := p.color,
              has_color :=
                (_ :
                  ∀ (x : α),
                    C ((fun x i => Option.getD (idxFun (prod p.line (map some l')) i) x) (some x)) = p.color) })
          s.lines))

tactic: exact ⟨fun ⟨q, hq, he⟩ => h ⟨q, hq, he⟩, s.distinct_colors⟩
state_before: case neg.refine'_4
α : Type u
inst✝¹ : Fintype α
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h✝ : Nonempty α
r : ℕ
ι : Type
_inst✝ : Fintype ι
ι' : Type
_inst : Fintype ι'
C : (ι ⊕ ι' → Option α) → κ
l' : Line α ι'
C' : (ι → Option α) → κ
hl' : ∀ (x : α), (fun v' v => C (Sum.elim v (some ∘ v'))) ((fun x i => Option.getD (idxFun l' i) x) x) = C'
mono_of_mono : (∃ l, IsMono C' l) → ∃ l, IsMono C l
s : ColorFocused C'
sr : ↑Multiset.card s.lines = r
h : ¬∃ p, p ∈ s.lines ∧ p.color = C' s.focus
⊢ (¬∃ a,
        a ∈ s.lines ∧
          (AlmostMono.color ∘ fun p =>
                { line := prod p.line (map some l'), color := p.color,
                  has_color :=
                    (_ :
                      ∀ (x : α),
                        C ((fun x i => Option.getD (idxFun (prod p.line (map some l')) i) x) (some x)) = p.color) })
              a =
            { line := vertical s.focus (map some l'), color := C' s.focus,
                has_color :=
                  (_ :
                    ∀ (x : α),
                      C ((fun x i => Option.getD (idxFun (vertical s.focus (map some l')) i) x) (some x)) =
                        C' s.focus) }.color) ∧
    Multiset.Nodup
      (Multiset.map
        (AlmostMono.color ∘ fun p =>
          { line := prod p.line (map some l'), color := p.color,
            has_color :=
              (_ :
                ∀ (x : α), C ((fun x i => Option.getD (idxFun (prod p.line (map some l')) i) x) (some x)) = p.color) })
        s.lines)

tactic: rw [Multiset.card_cons, Multiset.card_map, sr]
state_before: case neg.refine'_5
α : Type u
inst✝¹ : Fintype α
κ : Type (max v u)
inst✝ : Finite κ
val✝ : Fintype κ
h✝ : Nonempty α
r : ℕ
ι : Type
_inst✝ : Fintype ι
ι' : Type
_inst : Fintype ι'
C : (ι ⊕ ι' → Option α) → κ
l' : Line α ι'
C' : (ι → Option α) → κ
hl' : ∀ (x : α), (fun v' v => C (Sum.elim v (some ∘ v'))) ((fun x i => Option.getD (idxFun l' i) x) x) = C'
mono_of_mono : (∃ l, IsMono C' l) → ∃ l, IsMono C l
s : ColorFocused C'
sr : ↑Multiset.card s.lines = r
h : ¬∃ p, p ∈ s.lines ∧ p.color = C' s.focus
⊢ ↑Multiset.card
      {
          lines :=
            { line := vertical s.focus (map some l'), color := C' s.focus,
                has_color :=
                  (_ :
                    ∀ (x : α),
                      C ((fun x i => Option.getD (idxFun (vertical s.focus (map some l')) i) x) (some x)) =
                        C' s.focus) } ::ₘ
              Multiset.map
                (fun p =>
                  { line := prod p.line (map some l'), color := p.color,
                    has_color :=
                      (_ :
                        ∀ (x : α),
                          C ((fun x i => Option.getD (idxFun (prod p.line (map some l')) i) x) (some x)) = p.color) })
                s.lines,
          focus := Sum.elim s.focus ((fun x i => Option.getD (idxFun (map some l') i) x) none),
          is_focused :=
            (_ :
              ∀ (p : AlmostMono C),
                p ∈
                    { line := vertical s.focus (map some l'), color := C' s.focus,
                        has_color :=
                          (_ :
                            ∀ (x : α),
                              C ((fun x i => Option.getD (idxFun (vertical s.focus (map some l')) i) x) (some x)) =
                                C' s.focus) } ::ₘ
                      Multiset.map
                        (fun p =>
                          { line := prod p.line (map some l'), color := p.color,
                            has_color :=
                              (_ :
                                ∀ (x : α),
                                  C ((fun x i => Option.getD (idxFun (prod p.line (map some l')) i) x) (some x)) =
                                    p.color) })
                        s.lines →
                  (fun x i => Option.getD (idxFun p.line i) x) none =
                    Sum.elim s.focus ((fun x i => Option.getD (idxFun (map some l') i) x) none)),
          distinct_colors :=
            (_ :
              Multiset.Nodup
                (Multiset.map AlmostMono.color
                  ({ line := vertical s.focus (map some l'), color := C' s.focus,
                      has_color :=
                        (_ :
                          ∀ (x : α),
                            C ((fun x i => Option.getD (idxFun (vertical s.focus (map some l')) i) x) (some x)) =
                              C' s.focus) } ::ₘ
                    Multiset.map
                      (fun p =>
                        { line := prod p.line (map some l'), color := p.color,
                          has_color :=
                            (_ :
                              ∀ (x : α),
                                C ((fun x i => Option.getD (idxFun (prod p.line (map some l')) i) x) (some x)) =
                                  p.color) })
                      s.lines))) }.lines =
    Nat.succ r