Theorem: Std.RBNode.Ordered.memP_iff_find?
File: Std/Data/RBMap/Lemmas.lean

tactic: refine ⟨fun H => ?_, fun ⟨x, h⟩ => find?_some_memP h⟩
state_before: α : Type u_1
cmp : α → α → Ordering
cut : α → Ordering
t : RBNode α
inst✝¹ : TransCmp cmp
inst✝ : IsCut cmp cut
ht : Ordered cmp t
⊢ MemP cut t ↔ ∃ x, x ∈ find? cut t

tactic: cases H
state_before: case nil
α : Type u_1
cmp : α → α → Ordering
cut : α → Ordering
inst✝¹ : TransCmp cmp
inst✝ : IsCut cmp cut
ht : Ordered cmp nil
H : MemP cut nil
⊢ False

tactic: let ⟨lx, xr, hl, hr⟩ := ht
state_before: case node
α : Type u_1
cmp : α → α → Ordering
cut : α → Ordering
inst✝¹ : TransCmp cmp
inst✝ : IsCut cmp cut
c✝ : RBColor
l : RBNode α
v✝ : α
r : RBNode α
ihl : Ordered cmp l → MemP cut l → ∃ x, x ∈ find? cut l
ihr : Ordered cmp r → MemP cut r → ∃ x, x ∈ find? cut r
ht : Ordered cmp (node c✝ l v✝ r)
H : MemP cut (node c✝ l v✝ r)
⊢ ∃ x,
    (match cut v✝ with
      | Ordering.lt => find? cut l
      | Ordering.gt => find? cut r
      | Ordering.eq => some v✝) =
      some x

tactic: split
state_before: case node
α : Type u_1
cmp : α → α → Ordering
cut : α → Ordering
inst✝¹ : TransCmp cmp
inst✝ : IsCut cmp cut
c✝ : RBColor
l : RBNode α
v✝ : α
r : RBNode α
ihl : Ordered cmp l → MemP cut l → ∃ x, x ∈ find? cut l
ihr : Ordered cmp r → MemP cut r → ∃ x, x ∈ find? cut r
ht : Ordered cmp (node c✝ l v✝ r)
H : MemP cut (node c✝ l v✝ r)
lx : All (fun x => cmpLT cmp x v✝) l
xr : All (fun x => cmpLT cmp v✝ x) r
hl : Ordered cmp l
hr : Ordered cmp r
⊢ ∃ x,
    (match cut v✝ with
      | Ordering.lt => find? cut l
      | Ordering.gt => find? cut r
      | Ordering.eq => some v✝) =
      some x

tactic: refine ihl hl ?_
state_before: α : Type u_1
cmp : α → α → Ordering
cut : α → Ordering
inst✝¹ : TransCmp cmp
inst✝ : IsCut cmp cut
c✝ : RBColor
l : RBNode α
v✝ : α
r : RBNode α
ihl : Ordered cmp l → MemP cut l → ∃ x, x ∈ find? cut l
ihr : Ordered cmp r → MemP cut r → ∃ x, x ∈ find? cut r
ht : Ordered cmp (node c✝ l v✝ r)
H : MemP cut (node c✝ l v✝ r)
lx : All (fun x => cmpLT cmp x v✝) l
xr : All (fun x => cmpLT cmp v✝ x) r
hl : Ordered cmp l
hr : Ordered cmp r
x✝ : Ordering
ev : cut v✝ = Ordering.lt
⊢ ∃ x, find? cut l = some x

tactic: rcases H with ev' | hx | hx
state_before: α : Type u_1
cmp : α → α → Ordering
cut : α → Ordering
inst✝¹ : TransCmp cmp
inst✝ : IsCut cmp cut
c✝ : RBColor
l : RBNode α
v✝ : α
r : RBNode α
ihl : Ordered cmp l → MemP cut l → ∃ x, x ∈ find? cut l
ihr : Ordered cmp r → MemP cut r → ∃ x, x ∈ find? cut r
ht : Ordered cmp (node c✝ l v✝ r)
H : MemP cut (node c✝ l v✝ r)
lx : All (fun x => cmpLT cmp x v✝) l
xr : All (fun x => cmpLT cmp v✝ x) r
hl : Ordered cmp l
hr : Ordered cmp r
x✝ : Ordering
ev : cut v✝ = Ordering.lt
⊢ MemP cut l

tactic: cases ev.symm.trans ev'
state_before: case inl
α : Type u_1
cmp : α → α → Ordering
cut : α → Ordering
inst✝¹ : TransCmp cmp
inst✝ : IsCut cmp cut
c✝ : RBColor
l : RBNode α
v✝ : α
r : RBNode α
ihl : Ordered cmp l → MemP cut l → ∃ x, x ∈ find? cut l
ihr : Ordered cmp r → MemP cut r → ∃ x, x ∈ find? cut r
ht : Ordered cmp (node c✝ l v✝ r)
lx : All (fun x => cmpLT cmp x v✝) l
xr : All (fun x => cmpLT cmp v✝ x) r
hl : Ordered cmp l
hr : Ordered cmp r
x✝ : Ordering
ev : cut v✝ = Ordering.lt
ev' : cut v✝ = Ordering.eq
⊢ MemP cut l

tactic: exact hx
state_before: case inr.inl
α : Type u_1
cmp : α → α → Ordering
cut : α → Ordering
inst✝¹ : TransCmp cmp
inst✝ : IsCut cmp cut
c✝ : RBColor
l : RBNode α
v✝ : α
r : RBNode α
ihl : Ordered cmp l → MemP cut l → ∃ x, x ∈ find? cut l
ihr : Ordered cmp r → MemP cut r → ∃ x, x ∈ find? cut r
ht : Ordered cmp (node c✝ l v✝ r)
lx : All (fun x => cmpLT cmp x v✝) l
xr : All (fun x => cmpLT cmp v✝ x) r
hl : Ordered cmp l
hr : Ordered cmp r
x✝ : Ordering
ev : cut v✝ = Ordering.lt
hx : Any (fun x => cut x = Ordering.eq) l
⊢ MemP cut l

tactic: have ⟨z, hz, ez⟩ := Any_def.1 hx
state_before: case inr.inr
α : Type u_1
cmp : α → α → Ordering
cut : α → Ordering
inst✝¹ : TransCmp cmp
inst✝ : IsCut cmp cut
c✝ : RBColor
l : RBNode α
v✝ : α
r : RBNode α
ihl : Ordered cmp l → MemP cut l → ∃ x, x ∈ find? cut l
ihr : Ordered cmp r → MemP cut r → ∃ x, x ∈ find? cut r
ht : Ordered cmp (node c✝ l v✝ r)
lx : All (fun x => cmpLT cmp x v✝) l
xr : All (fun x => cmpLT cmp v✝ x) r
hl : Ordered cmp l
hr : Ordered cmp r
x✝ : Ordering
ev : cut v✝ = Ordering.lt
hx : Any (fun x => cut x = Ordering.eq) r
⊢ MemP cut l

tactic: cases ez.symm.trans <| IsCut.lt_trans (All_def.1 xr _ hz).1 ev
state_before: case inr.inr
α : Type u_1
cmp : α → α → Ordering
cut : α → Ordering
inst✝¹ : TransCmp cmp
inst✝ : IsCut cmp cut
c✝ : RBColor
l : RBNode α
v✝ : α
r : RBNode α
ihl : Ordered cmp l → MemP cut l → ∃ x, x ∈ find? cut l
ihr : Ordered cmp r → MemP cut r → ∃ x, x ∈ find? cut r
ht : Ordered cmp (node c✝ l v✝ r)
lx : All (fun x => cmpLT cmp x v✝) l
xr : All (fun x => cmpLT cmp v✝ x) r
hl : Ordered cmp l
hr : Ordered cmp r
x✝ : Ordering
ev : cut v✝ = Ordering.lt
hx : Any (fun x => cut x = Ordering.eq) r
z : α
hz : z ∈ r
ez : cut z = Ordering.eq
⊢ MemP cut l

tactic: refine ihr hr ?_
state_before: α : Type u_1
cmp : α → α → Ordering
cut : α → Ordering
inst✝¹ : TransCmp cmp
inst✝ : IsCut cmp cut
c✝ : RBColor
l : RBNode α
v✝ : α
r : RBNode α
ihl : Ordered cmp l → MemP cut l → ∃ x, x ∈ find? cut l
ihr : Ordered cmp r → MemP cut r → ∃ x, x ∈ find? cut r
ht : Ordered cmp (node c✝ l v✝ r)
H : MemP cut (node c✝ l v✝ r)
lx : All (fun x => cmpLT cmp x v✝) l
xr : All (fun x => cmpLT cmp v✝ x) r
hl : Ordered cmp l
hr : Ordered cmp r
x✝ : Ordering
ev : cut v✝ = Ordering.gt
⊢ ∃ x, find? cut r = some x

tactic: rcases H with ev' | hx | hx
state_before: α : Type u_1
cmp : α → α → Ordering
cut : α → Ordering
inst✝¹ : TransCmp cmp
inst✝ : IsCut cmp cut
c✝ : RBColor
l : RBNode α
v✝ : α
r : RBNode α
ihl : Ordered cmp l → MemP cut l → ∃ x, x ∈ find? cut l
ihr : Ordered cmp r → MemP cut r → ∃ x, x ∈ find? cut r
ht : Ordered cmp (node c✝ l v✝ r)
H : MemP cut (node c✝ l v✝ r)
lx : All (fun x => cmpLT cmp x v✝) l
xr : All (fun x => cmpLT cmp v✝ x) r
hl : Ordered cmp l
hr : Ordered cmp r
x✝ : Ordering
ev : cut v✝ = Ordering.gt
⊢ MemP cut r

tactic: cases ev.symm.trans ev'
state_before: case inl
α : Type u_1
cmp : α → α → Ordering
cut : α → Ordering
inst✝¹ : TransCmp cmp
inst✝ : IsCut cmp cut
c✝ : RBColor
l : RBNode α
v✝ : α
r : RBNode α
ihl : Ordered cmp l → MemP cut l → ∃ x, x ∈ find? cut l
ihr : Ordered cmp r → MemP cut r → ∃ x, x ∈ find? cut r
ht : Ordered cmp (node c✝ l v✝ r)
lx : All (fun x => cmpLT cmp x v✝) l
xr : All (fun x => cmpLT cmp v✝ x) r
hl : Ordered cmp l
hr : Ordered cmp r
x✝ : Ordering
ev : cut v✝ = Ordering.gt
ev' : cut v✝ = Ordering.eq
⊢ MemP cut r

tactic: have ⟨z, hz, ez⟩ := Any_def.1 hx
state_before: case inr.inl
α : Type u_1
cmp : α → α → Ordering
cut : α → Ordering
inst✝¹ : TransCmp cmp
inst✝ : IsCut cmp cut
c✝ : RBColor
l : RBNode α
v✝ : α
r : RBNode α
ihl : Ordered cmp l → MemP cut l → ∃ x, x ∈ find? cut l
ihr : Ordered cmp r → MemP cut r → ∃ x, x ∈ find? cut r
ht : Ordered cmp (node c✝ l v✝ r)
lx : All (fun x => cmpLT cmp x v✝) l
xr : All (fun x => cmpLT cmp v✝ x) r
hl : Ordered cmp l
hr : Ordered cmp r
x✝ : Ordering
ev : cut v✝ = Ordering.gt
hx : Any (fun x => cut x = Ordering.eq) l
⊢ MemP cut r

tactic: cases ez.symm.trans <| IsCut.gt_trans (All_def.1 lx _ hz).1 ev
state_before: case inr.inl
α : Type u_1
cmp : α → α → Ordering
cut : α → Ordering
inst✝¹ : TransCmp cmp
inst✝ : IsCut cmp cut
c✝ : RBColor
l : RBNode α
v✝ : α
r : RBNode α
ihl : Ordered cmp l → MemP cut l → ∃ x, x ∈ find? cut l
ihr : Ordered cmp r → MemP cut r → ∃ x, x ∈ find? cut r
ht : Ordered cmp (node c✝ l v✝ r)
lx : All (fun x => cmpLT cmp x v✝) l
xr : All (fun x => cmpLT cmp v✝ x) r
hl : Ordered cmp l
hr : Ordered cmp r
x✝ : Ordering
ev : cut v✝ = Ordering.gt
hx : Any (fun x => cut x = Ordering.eq) l
z : α
hz : z ∈ l
ez : cut z = Ordering.eq
⊢ MemP cut r

tactic: exact hx
state_before: case inr.inr
α : Type u_1
cmp : α → α → Ordering
cut : α → Ordering
inst✝¹ : TransCmp cmp
inst✝ : IsCut cmp cut
c✝ : RBColor
l : RBNode α
v✝ : α
r : RBNode α
ihl : Ordered cmp l → MemP cut l → ∃ x, x ∈ find? cut l
ihr : Ordered cmp r → MemP cut r → ∃ x, x ∈ find? cut r
ht : Ordered cmp (node c✝ l v✝ r)
lx : All (fun x => cmpLT cmp x v✝) l
xr : All (fun x => cmpLT cmp v✝ x) r
hl : Ordered cmp l
hr : Ordered cmp r
x✝ : Ordering
ev : cut v✝ = Ordering.gt
hx : Any (fun x => cut x = Ordering.eq) r
⊢ MemP cut r

tactic: exact ⟨_, rfl⟩
state_before: case node.h_3
α : Type u_1
cmp : α → α → Ordering
cut : α → Ordering
inst✝¹ : TransCmp cmp
inst✝ : IsCut cmp cut
c✝ : RBColor
l : RBNode α
v✝ : α
r : RBNode α
ihl : Ordered cmp l → MemP cut l → ∃ x, x ∈ find? cut l
ihr : Ordered cmp r → MemP cut r → ∃ x, x ∈ find? cut r
ht : Ordered cmp (node c✝ l v✝ r)
H : MemP cut (node c✝ l v✝ r)
lx : All (fun x => cmpLT cmp x v✝) l
xr : All (fun x => cmpLT cmp v✝ x) r
hl : Ordered cmp l
hr : Ordered cmp r
x✝ : Ordering
heq✝ : cut v✝ = Ordering.eq
⊢ ∃ x, some v✝ = some x