Theorem: Batteries.RBNode.Ordered.lowerBound?_greatest_lb
File: .lake/packages/batteries/Batteries/Data/RBMap/Lemmas.lean

tactic: intro h1 h2 h3 h4
state_before: α : Type u_1
cmp : α → α → Ordering
cut : α → Ordering
t : RBNode α
lb : Option α
x y : α
inst✝¹ : TransCmp cmp
inst✝ : IsCut cmp cut
h : Ordered cmp t
hlb : ∀ {x : α}, lb = some x → All (fun x_1 => cmpLT cmp x x_1) t
⊢ lowerBound? cut t lb = some x → y ∈ t → cut x = Ordering.gt → cmp x y = Ordering.lt → cut y = Ordering.lt
state_after: α : Type u_1
cmp : α → α → Ordering
cut : α → Ordering
t : RBNode α
lb : Option α
x y : α
inst✝¹ : TransCmp cmp
inst✝ : IsCut cmp cut
h : Ordered cmp t
hlb : ∀ {x : α}, lb = some x → All (fun x_1 => cmpLT cmp x x_1) t
h1 : lowerBound? cut t lb = some x
h2 : y ∈ t
h3 : cut x = Ordering.gt
h4 : cmp x y = Ordering.lt
⊢ cut y = Ordering.lt

tactic: rw [← reverse_reverse t, lowerBound?_reverse] at h1
state_before: α : Type u_1
cmp : α → α → Ordering
cut : α → Ordering
t : RBNode α
lb : Option α
x y : α
inst✝¹ : TransCmp cmp
inst✝ : IsCut cmp cut
h : Ordered cmp t
hlb : ∀ {x : α}, lb = some x → All (fun x_1 => cmpLT cmp x x_1) t
h1 : lowerBound? cut t lb = some x
h2 : y ∈ t
h3 : cut x = Ordering.gt
h4 : cmp x y = Ordering.lt
⊢ cut y = Ordering.lt
state_after: α : Type u_1
cmp : α → α → Ordering
cut : α → Ordering
t : RBNode α
lb : Option α
x y : α
inst✝¹ : TransCmp cmp
inst✝ : IsCut cmp cut
h : Ordered cmp t
hlb : ∀ {x : α}, lb = some x → All (fun x_1 => cmpLT cmp x x_1) t
h1 : upperBound? (fun x => (cut x).swap) t.reverse lb = some x
h2 : y ∈ t
h3 : cut x = Ordering.gt
h4 : cmp x y = Ordering.lt
⊢ cut y = Ordering.lt

tactic: rw [← Ordering.swap_inj] at h3 ⊢
state_before: α : Type u_1
cmp : α → α → Ordering
cut : α → Ordering
t : RBNode α
lb : Option α
x y : α
inst✝¹ : TransCmp cmp
inst✝ : IsCut cmp cut
h : Ordered cmp t
hlb : ∀ {x : α}, lb = some x → All (fun x_1 => cmpLT cmp x x_1) t
h1 : upperBound? (fun x => (cut x).swap) t.reverse lb = some x
h2 : y ∈ t
h3 : cut x = Ordering.gt
h4 : cmp x y = Ordering.lt
⊢ cut y = Ordering.lt
state_after: α : Type u_1
cmp : α → α → Ordering
cut : α → Ordering
t : RBNode α
lb : Option α
x y : α
inst✝¹ : TransCmp cmp
inst✝ : IsCut cmp cut
h : Ordered cmp t
hlb : ∀ {x : α}, lb = some x → All (fun x_1 => cmpLT cmp x x_1) t
h1 : upperBound? (fun x => (cut x).swap) t.reverse lb = some x
h2 : y ∈ t
h3 : (cut x).swap = Ordering.gt.swap
h4 : cmp x y = Ordering.lt
⊢ (cut y).swap = Ordering.lt.swap

tactic: revert h2 h3 h4
state_before: α : Type u_1
cmp : α → α → Ordering
cut : α → Ordering
t : RBNode α
lb : Option α
x y : α
inst✝¹ : TransCmp cmp
inst✝ : IsCut cmp cut
h : Ordered cmp t
hlb : ∀ {x : α}, lb = some x → All (fun x_1 => cmpLT cmp x x_1) t
h1 : upperBound? (fun x => (cut x).swap) t.reverse lb = some x
h2 : y ∈ t
h3 : (cut x).swap = Ordering.gt.swap
h4 : cmp x y = Ordering.lt
⊢ (cut y).swap = Ordering.lt.swap
state_after: α : Type u_1
cmp : α → α → Ordering
cut : α → Ordering
t : RBNode α
lb : Option α
x y : α
inst✝¹ : TransCmp cmp
inst✝ : IsCut cmp cut
h : Ordered cmp t
hlb : ∀ {x : α}, lb = some x → All (fun x_1 => cmpLT cmp x x_1) t
h1 : upperBound? (fun x => (cut x).swap) t.reverse lb = some x
⊢ y ∈ t → (cut x).swap = Ordering.gt.swap → cmp x y = Ordering.lt → (cut y).swap = Ordering.lt.swap

tactic: simpa [-Ordering.swap_inj] using
  h.reverse.upperBound?_least_ub (fun h => All.reverse.2 <| (hlb h).imp .flip) h1
state_before: α : Type u_1
cmp : α → α → Ordering
cut : α → Ordering
t : RBNode α
lb : Option α
x y : α
inst✝¹ : TransCmp cmp
inst✝ : IsCut cmp cut
h : Ordered cmp t
hlb : ∀ {x : α}, lb = some x → All (fun x_1 => cmpLT cmp x x_1) t
h1 : upperBound? (fun x => (cut x).swap) t.reverse lb = some x
⊢ y ∈ t → (cut x).swap = Ordering.gt.swap → cmp x y = Ordering.lt → (cut y).swap = Ordering.lt.swap
state_after: no goals