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

tactic: match e : zoom (cmp v) t with
| (nil, p) =>
  let ⟨_, _, h₁, h₂⟩ := exists_insert_toList_zoom_nil ht e
  simp [← mem_toList, h₁] at h
  simp [← mem_toList, h₂]; cases h <;> simp [*]
| (node .., p) =>
  let ⟨_, _, h₁, h₂⟩ := exists_insert_toList_zoom_node ht e
  simp [← mem_toList, h₁] at h
  simp [← mem_toList, h₂]; rcases h with h|h|h <;> simp [*]
  exact .inr (Path.zoom_zoomed₁ e)
state_before: α : Type u_1
c : RBColor
n : Nat
v' : α
cmp : α → α → Ordering
v : α
t : RBNode α
ht : t.Balanced c n
h : v' ∈ t
⊢ v' ∈ insert cmp t v ∨ cmp v v' = Ordering.eq
state_after: no goals

tactic: let ⟨_, _, h₁, h₂⟩ := exists_insert_toList_zoom_nil ht e
state_before: α : Type u_1
c : RBColor
n : Nat
v' : α
cmp : α → α → Ordering
v : α
t : RBNode α
ht : t.Balanced c n
h : v' ∈ t
p : Path α
e : zoom (cmp v) t = (nil, p)
⊢ v' ∈ insert cmp t v ∨ cmp v v' = Ordering.eq
state_after: α : Type u_1
c : RBColor
n : Nat
v' : α
cmp : α → α → Ordering
v : α
t : RBNode α
ht : t.Balanced c n
h : v' ∈ 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✝
⊢ v' ∈ insert cmp t v ∨ cmp v v' = Ordering.eq

tactic: simp [← mem_toList, h₁] at h
state_before: α : Type u_1
c : RBColor
n : Nat
v' : α
cmp : α → α → Ordering
v : α
t : RBNode α
ht : t.Balanced c n
h : v' ∈ 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✝
⊢ v' ∈ insert cmp t v ∨ cmp v v' = Ordering.eq
state_after: α : Type u_1
c : RBColor
n : Nat
v' : α
cmp : α → α → Ordering
v : α
t : RBNode α
ht : t.Balanced c n
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' ∈ insert cmp t v ∨ cmp v v' = Ordering.eq

tactic: simp [← mem_toList, h₂]
state_before: α : Type u_1
c : RBColor
n : Nat
v' : α
cmp : α → α → Ordering
v : α
t : RBNode α
ht : t.Balanced c n
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' ∈ insert cmp t v ∨ cmp v v' = Ordering.eq
state_after: α : Type u_1
c : RBColor
n : Nat
v' : α
cmp : α → α → Ordering
v : α
t : RBNode α
ht : t.Balanced c n
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' ∈ w✝¹ ∨ v' = v ∨ v' ∈ w✝) ∨ cmp v v' = Ordering.eq

tactic: cases h <;> simp [*]
state_before: α : Type u_1
c : RBColor
n : Nat
v' : α
cmp : α → α → Ordering
v : α
t : RBNode α
ht : t.Balanced c n
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' ∈ w✝¹ ∨ v' = v ∨ v' ∈ w✝) ∨ cmp v v' = Ordering.eq
state_after: no goals

tactic: let ⟨_, _, h₁, h₂⟩ := exists_insert_toList_zoom_node ht e
state_before: α : Type u_1
c : RBColor
n : Nat
v' : α
cmp : α → α → Ordering
v : α
t : RBNode α
ht : t.Balanced c n
h : v' ∈ t
c✝ : RBColor
l✝ : RBNode α
v✝ : α
r✝ : RBNode α
p : Path α
e : zoom (cmp v) t = (node c✝ l✝ v✝ r✝, p)
⊢ v' ∈ insert cmp t v ∨ cmp v v' = Ordering.eq
state_after: α : Type u_1
c : RBColor
n : Nat
v' : α
cmp : α → α → Ordering
v : α
t : RBNode α
ht : t.Balanced c n
h : v' ∈ 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✝
⊢ v' ∈ insert cmp t v ∨ cmp v v' = Ordering.eq

tactic: simp [← mem_toList, h₁] at h
state_before: α : Type u_1
c : RBColor
n : Nat
v' : α
cmp : α → α → Ordering
v : α
t : RBNode α
ht : t.Balanced c n
h : v' ∈ 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✝
⊢ v' ∈ insert cmp t v ∨ cmp v v' = Ordering.eq
state_after: α : Type u_1
c : RBColor
n : Nat
v' : α
cmp : α → α → Ordering
v : α
t : RBNode α
ht : t.Balanced c n
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' ∈ insert cmp t v ∨ cmp v v' = Ordering.eq

tactic: simp [← mem_toList, h₂]
state_before: α : Type u_1
c : RBColor
n : Nat
v' : α
cmp : α → α → Ordering
v : α
t : RBNode α
ht : t.Balanced c n
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' ∈ insert cmp t v ∨ cmp v v' = Ordering.eq
state_after: α : Type u_1
c : RBColor
n : Nat
v' : α
cmp : α → α → Ordering
v : α
t : RBNode α
ht : t.Balanced c n
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✝) ∨ cmp v v' = Ordering.eq

tactic: rcases h with h|h|h <;> simp [*]
state_before: α : Type u_1
c : RBColor
n : Nat
v' : α
cmp : α → α → Ordering
v : α
t : RBNode α
ht : t.Balanced c n
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✝) ∨ cmp v v' = Ordering.eq
state_after: case inr.inl
α : Type u_1
c : RBColor
n : Nat
v' : α
cmp : α → α → Ordering
v : α
t : RBNode α
ht : t.Balanced c n
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✝ = v ∨ v✝ ∈ w✝) ∨ cmp v v✝ = Ordering.eq

tactic: exact .inr (Path.zoom_zoomed₁ e)
state_before: case inr.inl
α : Type u_1
c : RBColor
n : Nat
v' : α
cmp : α → α → Ordering
v : α
t : RBNode α
ht : t.Balanced c n
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✝ = v ∨ v✝ ∈ w✝) ∨ cmp v v✝ = Ordering.eq
state_after: no goals