Theorem: Set.chainHeight_union_eq
File: Mathlib/Order/Height.lean

tactic: cases h : t.chainHeight
state_before: α : Type u_1
β : Type ?u.43133
s✝ t✝ : Set α
inst✝ : Preorder α
s t : Set α
H : ∀ (a : α), a ∈ s → ∀ (b : α), b ∈ t → a < b
⊢ chainHeight (s ∪ t) = chainHeight s + chainHeight t

tactic: apply le_antisymm
state_before: case some
α : Type u_1
β : Type ?u.43133
s✝ t✝ : Set α
inst✝ : Preorder α
s t : Set α
H : ∀ (a : α), a ∈ s → ∀ (b : α), b ∈ t → a < b
val✝ : ℕ
h : chainHeight t = some val✝
⊢ chainHeight (s ∪ t) = chainHeight s + some val✝

tactic: rw [WithTop.some_eq_coe, ← add_zero (s ∪ t).chainHeight, ← WithTop.coe_zero,
  ENat.some_eq_coe, chainHeight_add_le_chainHeight_add]
state_before: case some.a
α : Type u_1
β : Type ?u.43133
s✝ t✝ : Set α
inst✝ : Preorder α
s t : Set α
H : ∀ (a : α), a ∈ s → ∀ (b : α), b ∈ t → a < b
val✝ : ℕ
h : chainHeight t = some val✝
⊢ chainHeight s + some val✝ ≤ chainHeight (s ∪ t)

tactic: intro l hl
state_before: case some.a
α : Type u_1
β : Type ?u.43133
s✝ t✝ : Set α
inst✝ : Preorder α
s t : Set α
H : ∀ (a : α), a ∈ s → ∀ (b : α), b ∈ t → a < b
val✝ : ℕ
h : chainHeight t = some val✝
⊢ ∀ (l : List α), l ∈ subchain s → ∃ l', l' ∈ subchain (s ∪ t) ∧ length l + val✝ ≤ length l' + 0

tactic: obtain ⟨l', hl', rfl⟩ := exists_chain_of_le_chainHeight t h.symm.le
state_before: case some.a
α : Type u_1
β : Type ?u.43133
s✝ t✝ : Set α
inst✝ : Preorder α
s t : Set α
H : ∀ (a : α), a ∈ s → ∀ (b : α), b ∈ t → a < b
val✝ : ℕ
h : chainHeight t = some val✝
l : List α
hl : l ∈ subchain s
⊢ ∃ l', l' ∈ subchain (s ∪ t) ∧ length l + val✝ ≤ length l' + 0

tactic: refine' ⟨l ++ l', ⟨Chain'.append hl.1 hl'.1 fun x hx y hy ↦ _, fun i hi ↦ _⟩, by simp⟩
state_before: case some.a.intro.intro
α : Type u_1
β : Type ?u.43133
s✝ t✝ : Set α
inst✝ : Preorder α
s t : Set α
H : ∀ (a : α), a ∈ s → ∀ (b : α), b ∈ t → a < b
l : List α
hl : l ∈ subchain s
l' : List α
hl' : l' ∈ subchain t
h : chainHeight t = some (length l')
⊢ ∃ l'_1, l'_1 ∈ subchain (s ∪ t) ∧ length l + length l' ≤ length l'_1 + 0

tactic: rw [WithTop.none_eq_top, add_top, eq_top_iff, ← WithTop.none_eq_top, ← h]
state_before: case none
α : Type u_1
β : Type ?u.43133
s✝ t✝ : Set α
inst✝ : Preorder α
s t : Set α
H : ∀ (a : α), a ∈ s → ∀ (b : α), b ∈ t → a < b
h : chainHeight t = none
⊢ chainHeight (s ∪ t) = chainHeight s + none

tactic: exact Set.chainHeight_mono (Set.subset_union_right _ _)
state_before: case none
α : Type u_1
β : Type ?u.43133
s✝ t✝ : Set α
inst✝ : Preorder α
s t : Set α
H : ∀ (a : α), a ∈ s → ∀ (b : α), b ∈ t → a < b
h : chainHeight t = none
⊢ chainHeight t ≤ chainHeight (s ∪ t)

tactic: rw [← h]
state_before: case some.a
α : Type u_1
β : Type ?u.43133
s✝ t✝ : Set α
inst✝ : Preorder α
s t : Set α
H : ∀ (a : α), a ∈ s → ∀ (b : α), b ∈ t → a < b
val✝ : ℕ
h : chainHeight t = some val✝
⊢ chainHeight (s ∪ t) ≤ chainHeight s + some val✝

tactic: exact chainHeight_union_le
state_before: case some.a
α : Type u_1
β : Type ?u.43133
s✝ t✝ : Set α
inst✝ : Preorder α
s t : Set α
H : ∀ (a : α), a ∈ s → ∀ (b : α), b ∈ t → a < b
val✝ : ℕ
h : chainHeight t = some val✝
⊢ chainHeight (s ∪ t) ≤ chainHeight s + chainHeight t

tactic: simp
state_before: α : Type u_1
β : Type ?u.43133
s✝ t✝ : Set α
inst✝ : Preorder α
s t : Set α
H : ∀ (a : α), a ∈ s → ∀ (b : α), b ∈ t → a < b
l : List α
hl : l ∈ subchain s
l' : List α
hl' : l' ∈ subchain t
h : chainHeight t = some (length l')
⊢ length l + length l' ≤ length (l ++ l') + 0

tactic: exact H x (hl.2 _ <| mem_of_mem_getLast? hx) y (hl'.2 _ <| mem_of_mem_head? hy)
state_before: case some.a.intro.intro.refine'_1
α : Type u_1
β : Type ?u.43133
s✝ t✝ : Set α
inst✝ : Preorder α
s t : Set α
H : ∀ (a : α), a ∈ s → ∀ (b : α), b ∈ t → a < b
l : List α
hl : l ∈ subchain s
l' : List α
hl' : l' ∈ subchain t
h : chainHeight t = some (length l')
x : α
hx : x ∈ getLast? l
y : α
hy : y ∈ head? l'
⊢ x < y

tactic: rw [mem_append] at hi
state_before: case some.a.intro.intro.refine'_2
α : Type u_1
β : Type ?u.43133
s✝ t✝ : Set α
inst✝ : Preorder α
s t : Set α
H : ∀ (a : α), a ∈ s → ∀ (b : α), b ∈ t → a < b
l : List α
hl : l ∈ subchain s
l' : List α
hl' : l' ∈ subchain t
h : chainHeight t = some (length l')
i : α
hi : i ∈ l ++ l'
⊢ i ∈ s ∪ t

tactic: cases' hi with hi hi
state_before: case some.a.intro.intro.refine'_2
α : Type u_1
β : Type ?u.43133
s✝ t✝ : Set α
inst✝ : Preorder α
s t : Set α
H : ∀ (a : α), a ∈ s → ∀ (b : α), b ∈ t → a < b
l : List α
hl : l ∈ subchain s
l' : List α
hl' : l' ∈ subchain t
h : chainHeight t = some (length l')
i : α
hi : i ∈ l ∨ i ∈ l'
⊢ i ∈ s ∪ t

tactic: exacts [Or.inl (hl.2 _ hi), Or.inr (hl'.2 _ hi)]
state_before: case some.a.intro.intro.refine'_2.inl
α : Type u_1
β : Type ?u.43133
s✝ t✝ : Set α
inst✝ : Preorder α
s t : Set α
H : ∀ (a : α), a ∈ s → ∀ (b : α), b ∈ t → a < b
l : List α
hl : l ∈ subchain s
l' : List α
hl' : l' ∈ subchain t
h : chainHeight t = some (length l')
i : α
hi : i ∈ l
⊢ i ∈ s ∪ t

case some.a.intro.intro.refine'_2.inr
α : Type u_1
β : Type ?u.43133
s✝ t✝ : Set α
inst✝ : Preorder α
s t : Set α
H : ∀ (a : α), a ∈ s → ∀ (b : α), b ∈ t → a < b
l : List α
hl : l ∈ subchain s
l' : List α
hl' : l' ∈ subchain t
h : chainHeight t = some (length l')
i : α
hi : i ∈ l'
⊢ i ∈ s ∪ t