Theorem: Batteries.RBNode.mem_insert
File: .lake/packages/batteries/Batteries/Data/RBMap/Lemmas.lean

tactic: refine ⟨fun h => ?_, fun | .inl ⟨h₁, h₂⟩ => ?_ | .inr h => ?_⟩
state_before: α : Type u_1
cmp : α → α → Ordering
c : RBColor
n : Nat
v' v : α
inst✝ : TransCmp cmp
t : RBNode α
ht : t.Balanced c n
ht₂ : Ordered cmp t
⊢ v' ∈ insert cmp t v ↔ v' ∈ t ∧ find? (cmp v) t ≠ some v' ∨ v' = v
state_after: case refine_1
α : Type u_1
cmp : α → α → Ordering
c : RBColor
n : Nat
v' v : α
inst✝ : TransCmp cmp
t : RBNode α
ht : t.Balanced c n
ht₂ : Ordered cmp t
h : v' ∈ insert cmp t v
⊢ v' ∈ t ∧ find? (cmp v) t ≠ some v' ∨ v' = v

case refine_2
α : Type u_1
cmp : α → α → Ordering
c : RBColor
n : Nat
v' v : α
inst✝ : TransCmp cmp
t : RBNode α
ht : t.Balanced c n
ht₂ : Ordered cmp t
h₁ : v' ∈ t
h₂ : find? (cmp v) t ≠ some v'
⊢ v' ∈ insert cmp t v

case refine_3
α : Type u_1
cmp : α → α → Ordering
c : RBColor
n : Nat
v' v : α
inst✝ : TransCmp cmp
t : RBNode α
ht : t.Balanced c n
ht₂ : Ordered cmp t
h : v' = v
⊢ v' ∈ insert cmp t v

tactic: let ⟨_, _, h₁, h₂⟩ := exists_insert_toList_zoom_nil ht e
state_before: α : Type u_1
cmp : α → α → Ordering
c : RBColor
n : Nat
v' v : α
inst✝ : TransCmp cmp
t : RBNode α
ht : t.Balanced c n
ht₂ : Ordered cmp t
h : v' ∈ insert cmp t v
p : Path α
e : zoom (cmp v) t = (nil, p)
⊢ v' ∈ t ∧ find? (cmp v) t ≠ some v' ∨ v' = v
state_after: α : Type u_1
cmp : α → α → Ordering
c : RBColor
n : Nat
v' v : α
inst✝ : TransCmp cmp
t : RBNode α
ht : t.Balanced c n
ht₂ : Ordered cmp t
h : v' ∈ insert cmp t v
p : Path α
e : zoom (cmp v) t = (nil, p)
w✝¹ w✝ : List α
h₁ : t.toList = w✝¹ ++ w✝
h₂ : (insert cmp t v).toList = w✝¹ ++ v :: w✝
⊢ v' ∈ t ∧ find? (cmp v) t ≠ some v' ∨ v' = v

tactic: simp [← mem_toList, h₂] at h
state_before: α : Type u_1
cmp : α → α → Ordering
c : RBColor
n : Nat
v' v : α
inst✝ : TransCmp cmp
t : RBNode α
ht : t.Balanced c n
ht₂ : Ordered cmp t
h : v' ∈ insert cmp t v
p : Path α
e : zoom (cmp v) t = (nil, p)
w✝¹ w✝ : List α
h₁ : t.toList = w✝¹ ++ w✝
h₂ : (insert cmp t v).toList = w✝¹ ++ v :: w✝
⊢ v' ∈ t ∧ find? (cmp v) t ≠ some v' ∨ v' = v
state_after: α : Type u_1
cmp : α → α → Ordering
c : RBColor
n : Nat
v' v : α
inst✝ : TransCmp cmp
t : RBNode α
ht : t.Balanced c n
ht₂ : Ordered cmp t
p : Path α
e : zoom (cmp v) t = (nil, p)
w✝¹ w✝ : List α
h₁ : t.toList = w✝¹ ++ w✝
h₂ : (insert cmp t v).toList = w✝¹ ++ v :: w✝
h : v' ∈ w✝¹ ∨ v' = v ∨ v' ∈ w✝
⊢ v' ∈ t ∧ find? (cmp v) t ≠ some v' ∨ v' = v

tactic: rw [← or_assoc, or_right_comm] at h
state_before: α : Type u_1
cmp : α → α → Ordering
c : RBColor
n : Nat
v' v : α
inst✝ : TransCmp cmp
t : RBNode α
ht : t.Balanced c n
ht₂ : Ordered cmp t
p : Path α
e : zoom (cmp v) t = (nil, p)
w✝¹ w✝ : List α
h₁ : t.toList = w✝¹ ++ w✝
h₂ : (insert cmp t v).toList = w✝¹ ++ v :: w✝
h : v' ∈ w✝¹ ∨ v' = v ∨ v' ∈ w✝
⊢ v' ∈ t ∧ find? (cmp v) t ≠ some v' ∨ v' = v
state_after: α : Type u_1
cmp : α → α → Ordering
c : RBColor
n : Nat
v' v : α
inst✝ : TransCmp cmp
t : RBNode α
ht : t.Balanced c n
ht₂ : Ordered cmp t
p : Path α
e : zoom (cmp v) t = (nil, p)
w✝¹ w✝ : List α
h₁ : t.toList = w✝¹ ++ w✝
h₂ : (insert cmp t v).toList = w✝¹ ++ v :: w✝
h : (v' ∈ w✝¹ ∨ v' ∈ w✝) ∨ v' = v
⊢ v' ∈ t ∧ find? (cmp v) t ≠ some v' ∨ v' = v

tactic: refine h.imp_left fun h => ?_
state_before: α : Type u_1
cmp : α → α → Ordering
c : RBColor
n : Nat
v' v : α
inst✝ : TransCmp cmp
t : RBNode α
ht : t.Balanced c n
ht₂ : Ordered cmp t
p : Path α
e : zoom (cmp v) t = (nil, p)
w✝¹ w✝ : List α
h₁ : t.toList = w✝¹ ++ w✝
h₂ : (insert cmp t v).toList = w✝¹ ++ v :: w✝
h : (v' ∈ w✝¹ ∨ v' ∈ w✝) ∨ v' = v
⊢ v' ∈ t ∧ find? (cmp v) t ≠ some v' ∨ v' = v
state_after: α : Type u_1
cmp : α → α → Ordering
c : RBColor
n : Nat
v' v : α
inst✝ : TransCmp cmp
t : RBNode α
ht : t.Balanced c n
ht₂ : Ordered cmp t
p : Path α
e : zoom (cmp v) t = (nil, p)
w✝¹ w✝ : List α
h₁ : t.toList = w✝¹ ++ w✝
h₂ : (insert cmp t v).toList = w✝¹ ++ v :: w✝
h✝ : (v' ∈ w✝¹ ∨ v' ∈ w✝) ∨ v' = v
h : v' ∈ w✝¹ ∨ v' ∈ w✝
⊢ v' ∈ t ∧ find? (cmp v) t ≠ some v'

tactic: simp [← mem_toList, h₁, h]
state_before: α : Type u_1
cmp : α → α → Ordering
c : RBColor
n : Nat
v' v : α
inst✝ : TransCmp cmp
t : RBNode α
ht : t.Balanced c n
ht₂ : Ordered cmp t
p : Path α
e : zoom (cmp v) t = (nil, p)
w✝¹ w✝ : List α
h₁ : t.toList = w✝¹ ++ w✝
h₂ : (insert cmp t v).toList = w✝¹ ++ v :: w✝
h✝ : (v' ∈ w✝¹ ∨ v' ∈ w✝) ∨ v' = v
h : v' ∈ w✝¹ ∨ v' ∈ w✝
⊢ v' ∈ t ∧ find? (cmp v) t ≠ some v'
state_after: α : Type u_1
cmp : α → α → Ordering
c : RBColor
n : Nat
v' v : α
inst✝ : TransCmp cmp
t : RBNode α
ht : t.Balanced c n
ht₂ : Ordered cmp t
p : Path α
e : zoom (cmp v) t = (nil, p)
w✝¹ w✝ : List α
h₁ : t.toList = w✝¹ ++ w✝
h₂ : (insert cmp t v).toList = w✝¹ ++ v :: w✝
h✝ : (v' ∈ w✝¹ ∨ v' ∈ w✝) ∨ v' = v
h : v' ∈ w✝¹ ∨ v' ∈ w✝
⊢ ¬find? (cmp v) t = some v'

tactic: rw [find?_eq_zoom, e]
state_before: α : Type u_1
cmp : α → α → Ordering
c : RBColor
n : Nat
v' v : α
inst✝ : TransCmp cmp
t : RBNode α
ht : t.Balanced c n
ht₂ : Ordered cmp t
p : Path α
e : zoom (cmp v) t = (nil, p)
w✝¹ w✝ : List α
h₁ : t.toList = w✝¹ ++ w✝
h₂ : (insert cmp t v).toList = w✝¹ ++ v :: w✝
h✝ : (v' ∈ w✝¹ ∨ v' ∈ w✝) ∨ v' = v
h : v' ∈ w✝¹ ∨ v' ∈ w✝
⊢ ¬find? (cmp v) t = some v'
state_after: α : Type u_1
cmp : α → α → Ordering
c : RBColor
n : Nat
v' v : α
inst✝ : TransCmp cmp
t : RBNode α
ht : t.Balanced c n
ht₂ : Ordered cmp t
p : Path α
e : zoom (cmp v) t = (nil, p)
w✝¹ w✝ : List α
h₁ : t.toList = w✝¹ ++ w✝
h₂ : (insert cmp t v).toList = w✝¹ ++ v :: w✝
h✝ : (v' ∈ w✝¹ ∨ v' ∈ w✝) ∨ v' = v
h : v' ∈ w✝¹ ∨ v' ∈ w✝
⊢ ¬(nil, p).fst.root? = some v'

tactic: nofun
state_before: α : Type u_1
cmp : α → α → Ordering
c : RBColor
n : Nat
v' v : α
inst✝ : TransCmp cmp
t : RBNode α
ht : t.Balanced c n
ht₂ : Ordered cmp t
p : Path α
e : zoom (cmp v) t = (nil, p)
w✝¹ w✝ : List α
h₁ : t.toList = w✝¹ ++ w✝
h₂ : (insert cmp t v).toList = w✝¹ ++ v :: w✝
h✝ : (v' ∈ w✝¹ ∨ v' ∈ w✝) ∨ v' = v
h : v' ∈ w✝¹ ∨ v' ∈ w✝
⊢ ¬(nil, p).fst.root? = some v'
state_after: no goals

tactic: let ⟨_, _, h₁, h₂⟩ := exists_insert_toList_zoom_node ht e
state_before: α : Type u_1
cmp : α → α → Ordering
c : RBColor
n : Nat
v' v : α
inst✝ : TransCmp cmp
t : RBNode α
ht : t.Balanced c n
ht₂ : Ordered cmp t
h : v' ∈ insert cmp t v
c✝ : RBColor
l✝ : RBNode α
v✝ : α
r✝ : RBNode α
p : Path α
e : zoom (cmp v) t = (node c✝ l✝ v✝ r✝, p)
⊢ v' ∈ t ∧ find? (cmp v) t ≠ some v' ∨ v' = v
state_after: α : Type u_1
cmp : α → α → Ordering
c : RBColor
n : Nat
v' v : α
inst✝ : TransCmp cmp
t : RBNode α
ht : t.Balanced c n
ht₂ : Ordered cmp t
h : v' ∈ insert cmp t v
c✝ : RBColor
l✝ : RBNode α
v✝ : α
r✝ : RBNode α
p : Path α
e : zoom (cmp v) t = (node c✝ l✝ v✝ r✝, p)
w✝¹ w✝ : List α
h₁ : t.toList = w✝¹ ++ v✝ :: w✝
h₂ : (insert cmp t v).toList = w✝¹ ++ v :: w✝
⊢ v' ∈ t ∧ find? (cmp v) t ≠ some v' ∨ v' = v

tactic: simp [← mem_toList, h₂] at h
state_before: α : Type u_1
cmp : α → α → Ordering
c : RBColor
n : Nat
v' v : α
inst✝ : TransCmp cmp
t : RBNode α
ht : t.Balanced c n
ht₂ : Ordered cmp t
h : v' ∈ insert cmp t v
c✝ : RBColor
l✝ : RBNode α
v✝ : α
r✝ : RBNode α
p : Path α
e : zoom (cmp v) t = (node c✝ l✝ v✝ r✝, p)
w✝¹ w✝ : List α
h₁ : t.toList = w✝¹ ++ v✝ :: w✝
h₂ : (insert cmp t v).toList = w✝¹ ++ v :: w✝
⊢ v' ∈ t ∧ find? (cmp v) t ≠ some v' ∨ v' = v
state_after: α : Type u_1
cmp : α → α → Ordering
c : RBColor
n : Nat
v' v : α
inst✝ : TransCmp cmp
t : RBNode α
ht : t.Balanced c n
ht₂ : Ordered cmp t
c✝ : RBColor
l✝ : RBNode α
v✝ : α
r✝ : RBNode α
p : Path α
e : zoom (cmp v) t = (node c✝ l✝ v✝ r✝, p)
w✝¹ w✝ : List α
h₁ : t.toList = w✝¹ ++ v✝ :: w✝
h₂ : (insert cmp t v).toList = w✝¹ ++ v :: w✝
h : v' ∈ w✝¹ ∨ v' = v ∨ v' ∈ w✝
⊢ v' ∈ t ∧ find? (cmp v) t ≠ some v' ∨ v' = v

tactic: simp [← mem_toList, h₁]
state_before: α : Type u_1
cmp : α → α → Ordering
c : RBColor
n : Nat
v' v : α
inst✝ : TransCmp cmp
t : RBNode α
ht : t.Balanced c n
ht₂ : Ordered cmp t
c✝ : RBColor
l✝ : RBNode α
v✝ : α
r✝ : RBNode α
p : Path α
e : zoom (cmp v) t = (node c✝ l✝ v✝ r✝, p)
w✝¹ w✝ : List α
h₁ : t.toList = w✝¹ ++ v✝ :: w✝
h₂ : (insert cmp t v).toList = w✝¹ ++ v :: w✝
h : v' ∈ w✝¹ ∨ v' = v ∨ v' ∈ w✝
⊢ v' ∈ t ∧ find? (cmp v) t ≠ some v' ∨ v' = v
state_after: α : Type u_1
cmp : α → α → Ordering
c : RBColor
n : Nat
v' v : α
inst✝ : TransCmp cmp
t : RBNode α
ht : t.Balanced c n
ht₂ : Ordered cmp t
c✝ : RBColor
l✝ : RBNode α
v✝ : α
r✝ : RBNode α
p : Path α
e : zoom (cmp v) t = (node c✝ l✝ v✝ r✝, p)
w✝¹ w✝ : List α
h₁ : t.toList = w✝¹ ++ v✝ :: w✝
h₂ : (insert cmp t v).toList = w✝¹ ++ v :: w✝
h : v' ∈ w✝¹ ∨ v' = v ∨ v' ∈ w✝
⊢ (v' ∈ w✝¹ ∨ v' = v✝ ∨ v' ∈ w✝) ∧ ¬find? (cmp v) t = some v' ∨ v' = v

tactic: rw [or_left_comm] at h ⊢
state_before: α : Type u_1
cmp : α → α → Ordering
c : RBColor
n : Nat
v' v : α
inst✝ : TransCmp cmp
t : RBNode α
ht : t.Balanced c n
ht₂ : Ordered cmp t
c✝ : RBColor
l✝ : RBNode α
v✝ : α
r✝ : RBNode α
p : Path α
e : zoom (cmp v) t = (node c✝ l✝ v✝ r✝, p)
w✝¹ w✝ : List α
h₁ : t.toList = w✝¹ ++ v✝ :: w✝
h₂ : (insert cmp t v).toList = w✝¹ ++ v :: w✝
h : v' ∈ w✝¹ ∨ v' = v ∨ v' ∈ w✝
⊢ (v' ∈ w✝¹ ∨ v' = v✝ ∨ v' ∈ w✝) ∧ ¬find? (cmp v) t = some v' ∨ v' = v
state_after: α : Type u_1
cmp : α → α → Ordering
c : RBColor
n : Nat
v' v : α
inst✝ : TransCmp cmp
t : RBNode α
ht : t.Balanced c n
ht₂ : Ordered cmp t
c✝ : RBColor
l✝ : RBNode α
v✝ : α
r✝ : RBNode α
p : Path α
e : zoom (cmp v) t = (node c✝ l✝ v✝ r✝, p)
w✝¹ w✝ : List α
h₁ : t.toList = w✝¹ ++ v✝ :: w✝
h₂ : (insert cmp t v).toList = w✝¹ ++ v :: w✝
h : v' = v ∨ v' ∈ w✝¹ ∨ v' ∈ w✝
⊢ (v' = v✝ ∨ v' ∈ w✝¹ ∨ v' ∈ w✝) ∧ ¬find? (cmp v) t = some v' ∨ v' = v

tactic: rcases h with _|h <;> simp [*]
state_before: α : Type u_1
cmp : α → α → Ordering
c : RBColor
n : Nat
v' v : α
inst✝ : TransCmp cmp
t : RBNode α
ht : t.Balanced c n
ht₂ : Ordered cmp t
c✝ : RBColor
l✝ : RBNode α
v✝ : α
r✝ : RBNode α
p : Path α
e : zoom (cmp v) t = (node c✝ l✝ v✝ r✝, p)
w✝¹ w✝ : List α
h₁ : t.toList = w✝¹ ++ v✝ :: w✝
h₂ : (insert cmp t v).toList = w✝¹ ++ v :: w✝
h : v' = v ∨ v' ∈ w✝¹ ∨ v' ∈ w✝
⊢ (v' = v✝ ∨ v' ∈ w✝¹ ∨ v' ∈ w✝) ∧ ¬find? (cmp v) t = some v' ∨ v' = v
state_after: case inr
α : Type u_1
cmp : α → α → Ordering
c : RBColor
n : Nat
v' v : α
inst✝ : TransCmp cmp
t : RBNode α
ht : t.Balanced c n
ht₂ : Ordered cmp t
c✝ : RBColor
l✝ : RBNode α
v✝ : α
r✝ : RBNode α
p : Path α
e : zoom (cmp v) t = (node c✝ l✝ v✝ r✝, p)
w✝¹ w✝ : List α
h₁ : t.toList = w✝¹ ++ v✝ :: w✝
h₂ : (insert cmp t v).toList = w✝¹ ++ v :: w✝
h : v' ∈ w✝¹ ∨ v' ∈ w✝
⊢ ¬find? (cmp v) t = some v' ∨ v' = v

tactic: refine .inl fun h => ?_
state_before: case inr
α : Type u_1
cmp : α → α → Ordering
c : RBColor
n : Nat
v' v : α
inst✝ : TransCmp cmp
t : RBNode α
ht : t.Balanced c n
ht₂ : Ordered cmp t
c✝ : RBColor
l✝ : RBNode α
v✝ : α
r✝ : RBNode α
p : Path α
e : zoom (cmp v) t = (node c✝ l✝ v✝ r✝, p)
w✝¹ w✝ : List α
h₁ : t.toList = w✝¹ ++ v✝ :: w✝
h₂ : (insert cmp t v).toList = w✝¹ ++ v :: w✝
h : v' ∈ w✝¹ ∨ v' ∈ w✝
⊢ ¬find? (cmp v) t = some v' ∨ v' = v
state_after: case inr
α : Type u_1
cmp : α → α → Ordering
c : RBColor
n : Nat
v' v : α
inst✝ : TransCmp cmp
t : RBNode α
ht : t.Balanced c n
ht₂ : Ordered cmp t
c✝ : RBColor
l✝ : RBNode α
v✝ : α
r✝ : RBNode α
p : Path α
e : zoom (cmp v) t = (node c✝ l✝ v✝ r✝, p)
w✝¹ w✝ : List α
h₁ : t.toList = w✝¹ ++ v✝ :: w✝
h₂ : (insert cmp t v).toList = w✝¹ ++ v :: w✝
h✝ : v' ∈ w✝¹ ∨ v' ∈ w✝
h : find? (cmp v) t = some v'
⊢ False

tactic: rw [find?_eq_zoom, e] at h
state_before: case inr
α : Type u_1
cmp : α → α → Ordering
c : RBColor
n : Nat
v' v : α
inst✝ : TransCmp cmp
t : RBNode α
ht : t.Balanced c n
ht₂ : Ordered cmp t
c✝ : RBColor
l✝ : RBNode α
v✝ : α
r✝ : RBNode α
p : Path α
e : zoom (cmp v) t = (node c✝ l✝ v✝ r✝, p)
w✝¹ w✝ : List α
h₁ : t.toList = w✝¹ ++ v✝ :: w✝
h₂ : (insert cmp t v).toList = w✝¹ ++ v :: w✝
h✝ : v' ∈ w✝¹ ∨ v' ∈ w✝
h : find? (cmp v) t = some v'
⊢ False
state_after: case inr
α : Type u_1
cmp : α → α → Ordering
c : RBColor
n : Nat
v' v : α
inst✝ : TransCmp cmp
t : RBNode α
ht : t.Balanced c n
ht₂ : Ordered cmp t
c✝ : RBColor
l✝ : RBNode α
v✝ : α
r✝ : RBNode α
p : Path α
e : zoom (cmp v) t = (node c✝ l✝ v✝ r✝, p)
w✝¹ w✝ : List α
h₁ : t.toList = w✝¹ ++ v✝ :: w✝
h₂ : (insert cmp t v).toList = w✝¹ ++ v :: w✝
h✝ : v' ∈ w✝¹ ∨ v' ∈ w✝
h : (node c✝ l✝ v✝ r✝, p).fst.root? = some v'
⊢ False

tactic: cases h
state_before: case inr
α : Type u_1
cmp : α → α → Ordering
c : RBColor
n : Nat
v' v : α
inst✝ : TransCmp cmp
t : RBNode α
ht : t.Balanced c n
ht₂ : Ordered cmp t
c✝ : RBColor
l✝ : RBNode α
v✝ : α
r✝ : RBNode α
p : Path α
e : zoom (cmp v) t = (node c✝ l✝ v✝ r✝, p)
w✝¹ w✝ : List α
h₁ : t.toList = w✝¹ ++ v✝ :: w✝
h₂ : (insert cmp t v).toList = w✝¹ ++ v :: w✝
h✝ : v' ∈ w✝¹ ∨ v' ∈ w✝
h : (node c✝ l✝ v✝ r✝, p).fst.root? = some v'
⊢ False
state_after: case inr.refl
α : Type u_1
cmp : α → α → Ordering
c : RBColor
n : Nat
v' v : α
inst✝ : TransCmp cmp
t : RBNode α
ht : t.Balanced c n
ht₂ : Ordered cmp t
c✝ : RBColor
l✝ r✝ : RBNode α
p : Path α
w✝¹ w✝ : List α
h₂ : (insert cmp t v).toList = w✝¹ ++ v :: w✝
h : v' ∈ w✝¹ ∨ v' ∈ w✝
e : zoom (cmp v) t = (node c✝ l✝ v' r✝, p)
h₁ : t.toList = w✝¹ ++ v' :: w✝
⊢ False

tactic: suffices cmpLT cmp v' v' by cases OrientedCmp.cmp_refl.symm.trans this.1
state_before: case inr.refl
α : Type u_1
cmp : α → α → Ordering
c : RBColor
n : Nat
v' v : α
inst✝ : TransCmp cmp
t : RBNode α
ht : t.Balanced c n
ht₂ : Ordered cmp t
c✝ : RBColor
l✝ r✝ : RBNode α
p : Path α
w✝¹ w✝ : List α
h₂ : (insert cmp t v).toList = w✝¹ ++ v :: w✝
h : v' ∈ w✝¹ ∨ v' ∈ w✝
e : zoom (cmp v) t = (node c✝ l✝ v' r✝, p)
h₁ : t.toList = w✝¹ ++ v' :: w✝
⊢ False
state_after: case inr.refl
α : Type u_1
cmp : α → α → Ordering
c : RBColor
n : Nat
v' v : α
inst✝ : TransCmp cmp
t : RBNode α
ht : t.Balanced c n
ht₂ : Ordered cmp t
c✝ : RBColor
l✝ r✝ : RBNode α
p : Path α
w✝¹ w✝ : List α
h₂ : (insert cmp t v).toList = w✝¹ ++ v :: w✝
h : v' ∈ w✝¹ ∨ v' ∈ w✝
e : zoom (cmp v) t = (node c✝ l✝ v' r✝, p)
h₁ : t.toList = w✝¹ ++ v' :: w✝
⊢ cmpLT cmp v' v'

tactic: have := ht₂.toList_sorted
state_before: case inr.refl
α : Type u_1
cmp : α → α → Ordering
c : RBColor
n : Nat
v' v : α
inst✝ : TransCmp cmp
t : RBNode α
ht : t.Balanced c n
ht₂ : Ordered cmp t
c✝ : RBColor
l✝ r✝ : RBNode α
p : Path α
w✝¹ w✝ : List α
h₂ : (insert cmp t v).toList = w✝¹ ++ v :: w✝
h : v' ∈ w✝¹ ∨ v' ∈ w✝
e : zoom (cmp v) t = (node c✝ l✝ v' r✝, p)
h₁ : t.toList = w✝¹ ++ v' :: w✝
⊢ cmpLT cmp v' v'
state_after: case inr.refl
α : Type u_1
cmp : α → α → Ordering
c : RBColor
n : Nat
v' v : α
inst✝ : TransCmp cmp
t : RBNode α
ht : t.Balanced c n
ht₂ : Ordered cmp t
c✝ : RBColor
l✝ r✝ : RBNode α
p : Path α
w✝¹ w✝ : List α
h₂ : (insert cmp t v).toList = w✝¹ ++ v :: w✝
h : v' ∈ w✝¹ ∨ v' ∈ w✝
e : zoom (cmp v) t = (node c✝ l✝ v' r✝, p)
h₁ : t.toList = w✝¹ ++ v' :: w✝
this : List.Pairwise (cmpLT cmp) t.toList
⊢ cmpLT cmp v' v'

tactic: simp [h₁, List.pairwise_append] at this
state_before: case inr.refl
α : Type u_1
cmp : α → α → Ordering
c : RBColor
n : Nat
v' v : α
inst✝ : TransCmp cmp
t : RBNode α
ht : t.Balanced c n
ht₂ : Ordered cmp t
c✝ : RBColor
l✝ r✝ : RBNode α
p : Path α
w✝¹ w✝ : List α
h₂ : (insert cmp t v).toList = w✝¹ ++ v :: w✝
h : v' ∈ w✝¹ ∨ v' ∈ w✝
e : zoom (cmp v) t = (node c✝ l✝ v' r✝, p)
h₁ : t.toList = w✝¹ ++ v' :: w✝
this : List.Pairwise (cmpLT cmp) t.toList
⊢ cmpLT cmp v' v'
state_after: case inr.refl
α : Type u_1
cmp : α → α → Ordering
c : RBColor
n : Nat
v' v : α
inst✝ : TransCmp cmp
t : RBNode α
ht : t.Balanced c n
ht₂ : Ordered cmp t
c✝ : RBColor
l✝ r✝ : RBNode α
p : Path α
w✝¹ w✝ : List α
h₂ : (insert cmp t v).toList = w✝¹ ++ v :: w✝
h : v' ∈ w✝¹ ∨ v' ∈ w✝
e : zoom (cmp v) t = (node c✝ l✝ v' r✝, p)
h₁ : t.toList = w✝¹ ++ v' :: w✝
this :
  List.Pairwise (cmpLT cmp) w✝¹ ∧
    ((∀ (a' : α), a' ∈ w✝ → cmpLT cmp v' a') ∧ List.Pairwise (cmpLT cmp) w✝) ∧
      ∀ (a : α), a ∈ w✝¹ → cmpLT cmp a v' ∧ ∀ (a_2 : α), a_2 ∈ w✝ → cmpLT cmp a a_2
⊢ cmpLT cmp v' v'

tactic: cases OrientedCmp.cmp_refl.symm.trans this.1
state_before: α : Type u_1
cmp : α → α → Ordering
c : RBColor
n : Nat
v' v : α
inst✝ : TransCmp cmp
t : RBNode α
ht : t.Balanced c n
ht₂ : Ordered cmp t
c✝ : RBColor
l✝ r✝ : RBNode α
p : Path α
w✝¹ w✝ : List α
h₂ : (insert cmp t v).toList = w✝¹ ++ v :: w✝
h : v' ∈ w✝¹ ∨ v' ∈ w✝
e : zoom (cmp v) t = (node c✝ l✝ v' r✝, p)
h₁ : t.toList = w✝¹ ++ v' :: w✝
this : cmpLT cmp v' v'
⊢ False
state_after: no goals

tactic: exact (mem_insert_of_mem ht h₁).resolve_right fun h' => h₂ <| ht₂.find?_some.2 ⟨h₁, h'⟩
state_before: case refine_2
α : Type u_1
cmp : α → α → Ordering
c : RBColor
n : Nat
v' v : α
inst✝ : TransCmp cmp
t : RBNode α
ht : t.Balanced c n
ht₂ : Ordered cmp t
h₁ : v' ∈ t
h₂ : find? (cmp v) t ≠ some v'
⊢ v' ∈ insert cmp t v
state_after: no goals

tactic: exact h ▸ mem_insert_self ht
state_before: case refine_3
α : Type u_1
cmp : α → α → Ordering
c : RBColor
n : Nat
v' v : α
inst✝ : TransCmp cmp
t : RBNode α
ht : t.Balanced c n
ht₂ : Ordered cmp t
h : v' = v
⊢ v' ∈ insert cmp t v
state_after: no goals