Theorem: Batteries.RBNode.Ordered.balLeft
File: .lake/packages/batteries/Batteries/Data/RBMap/WF.lean

tactic: unfold balLeft
state_before: α : Type u_1
cmp : α → α → Ordering
l : RBNode α
v : α
r : RBNode α
lv : All (fun x => cmpLT cmp x v) l
vr : All (fun x => cmpLT cmp v x) r
hl : Ordered cmp l
hr : Ordered cmp r
⊢ Ordered cmp (l.balLeft v r)
state_after: α : Type u_1
cmp : α → α → Ordering
l : RBNode α
v : α
r : RBNode α
lv : All (fun x => cmpLT cmp x v) l
vr : All (fun x => cmpLT cmp v x) r
hl : Ordered cmp l
hr : Ordered cmp r
⊢ Ordered cmp
    (match l with
    | node red a x b => node red (node black a x b) v r
    | l =>
      match r with
      | node black a y b => l.balance2 v (node red a y b)
      | node red (node black a y b) z c => node red (node black l v a) y (b.balance2 z c.setRed)
      | r => node red l v r)

tactic: split
state_before: α : Type u_1
cmp : α → α → Ordering
l : RBNode α
v : α
r : RBNode α
lv : All (fun x => cmpLT cmp x v) l
vr : All (fun x => cmpLT cmp v x) r
hl : Ordered cmp l
hr : Ordered cmp r
⊢ Ordered cmp
    (match l with
    | node red a x b => node red (node black a x b) v r
    | l =>
      match r with
      | node black a y b => l.balance2 v (node red a y b)
      | node red (node black a y b) z c => node red (node black l v a) y (b.balance2 z c.setRed)
      | r => node red l v r)
state_after: case h_1
α : Type u_1
cmp : α → α → Ordering
v : α
r : RBNode α
vr : All (fun x => cmpLT cmp v x) r
hr : Ordered cmp r
l✝ a✝ : RBNode α
x✝ : α
b✝ : RBNode α
lv : All (fun x => cmpLT cmp x v) (node red a✝ x✝ b✝)
hl : Ordered cmp (node red a✝ x✝ b✝)
⊢ Ordered cmp (node red (node black a✝ x✝ b✝) v r)

case h_2
α : Type u_1
cmp : α → α → Ordering
l : RBNode α
v : α
r : RBNode α
lv : All (fun x => cmpLT cmp x v) l
vr : All (fun x => cmpLT cmp v x) r
hl : Ordered cmp l
hr : Ordered cmp r
l✝ : RBNode α
x✝ : ∀ (a : RBNode α) (x : α) (b : RBNode α), l = node red a x b → False
⊢ Ordered cmp
    (match r with
    | node black a y b => l.balance2 v (node red a y b)
    | node red (node black a y b) z c => node red (node black l v a) y (b.balance2 z c.setRed)
    | r => node red l v r)

tactic: split
state_before: case h_2
α : Type u_1
cmp : α → α → Ordering
l : RBNode α
v : α
r : RBNode α
lv : All (fun x => cmpLT cmp x v) l
vr : All (fun x => cmpLT cmp v x) r
hl : Ordered cmp l
hr : Ordered cmp r
l✝ : RBNode α
x✝ : ∀ (a : RBNode α) (x : α) (b : RBNode α), l = node red a x b → False
⊢ Ordered cmp
    (match r with
    | node black a y b => l.balance2 v (node red a y b)
    | node red (node black a y b) z c => node red (node black l v a) y (b.balance2 z c.setRed)
    | r => node red l v r)
state_after: case h_2.h_1
α : Type u_1
cmp : α → α → Ordering
l : RBNode α
v : α
lv : All (fun x => cmpLT cmp x v) l
hl : Ordered cmp l
l✝ : RBNode α
x✝ : ∀ (a : RBNode α) (x : α) (b : RBNode α), l = node red a x b → False
r✝ a✝ : RBNode α
y✝ : α
b✝ : RBNode α
vr : All (fun x => cmpLT cmp v x) (node black a✝ y✝ b✝)
hr : Ordered cmp (node black a✝ y✝ b✝)
⊢ Ordered cmp (l.balance2 v (node red a✝ y✝ b✝))

case h_2.h_2
α : Type u_1
cmp : α → α → Ordering
l : RBNode α
v : α
lv : All (fun x => cmpLT cmp x v) l
hl : Ordered cmp l
l✝ : RBNode α
x✝ : ∀ (a : RBNode α) (x : α) (b : RBNode α), l = node red a x b → False
r✝ a✝ : RBNode α
y✝ : α
b✝ : RBNode α
z✝ : α
c✝ : RBNode α
vr : All (fun x => cmpLT cmp v x) (node red (node black a✝ y✝ b✝) z✝ c✝)
hr : Ordered cmp (node red (node black a✝ y✝ b✝) z✝ c✝)
⊢ Ordered cmp (node red (node black l v a✝) y✝ (b✝.balance2 z✝ c✝.setRed))

case h_2.h_3
α : Type u_1
cmp : α → α → Ordering
l : RBNode α
v : α
r : RBNode α
lv : All (fun x => cmpLT cmp x v) l
vr : All (fun x => cmpLT cmp v x) r
hl : Ordered cmp l
hr : Ordered cmp r
l✝ : RBNode α
x✝² : ∀ (a : RBNode α) (x : α) (b : RBNode α), l = node red a x b → False
r✝ : RBNode α
x✝¹ : ∀ (a : RBNode α) (y : α) (b : RBNode α), r = node black a y b → False
x✝ : ∀ (a : RBNode α) (y : α) (b : RBNode α) (z : α) (c : RBNode α), r = node red (node black a y b) z c → False
⊢ Ordered cmp (node red l v r)

tactic: exact ⟨lv, vr, hl, hr⟩
state_before: case h_1
α : Type u_1
cmp : α → α → Ordering
v : α
r : RBNode α
vr : All (fun x => cmpLT cmp v x) r
hr : Ordered cmp r
l✝ a✝ : RBNode α
x✝ : α
b✝ : RBNode α
lv : All (fun x => cmpLT cmp x v) (node red a✝ x✝ b✝)
hl : Ordered cmp (node red a✝ x✝ b✝)
⊢ Ordered cmp (node red (node black a✝ x✝ b✝) v r)
state_after: no goals

tactic: exact hl.balance2 lv vr hr
state_before: case h_2.h_1
α : Type u_1
cmp : α → α → Ordering
l : RBNode α
v : α
lv : All (fun x => cmpLT cmp x v) l
hl : Ordered cmp l
l✝ : RBNode α
x✝ : ∀ (a : RBNode α) (x : α) (b : RBNode α), l = node red a x b → False
r✝ a✝ : RBNode α
y✝ : α
b✝ : RBNode α
vr : All (fun x => cmpLT cmp v x) (node black a✝ y✝ b✝)
hr : Ordered cmp (node black a✝ y✝ b✝)
⊢ Ordered cmp (l.balance2 v (node red a✝ y✝ b✝))
state_after: no goals

tactic: have ⟨vy, va, _⟩ := vr.2.1
state_before: case h_2.h_2
α : Type u_1
cmp : α → α → Ordering
l : RBNode α
v : α
lv : All (fun x => cmpLT cmp x v) l
hl : Ordered cmp l
l✝ : RBNode α
x✝ : ∀ (a : RBNode α) (x : α) (b : RBNode α), l = node red a x b → False
r✝ a✝ : RBNode α
y✝ : α
b✝ : RBNode α
z✝ : α
c✝ : RBNode α
vr : All (fun x => cmpLT cmp v x) (node red (node black a✝ y✝ b✝) z✝ c✝)
hr : Ordered cmp (node red (node black a✝ y✝ b✝) z✝ c✝)
⊢ Ordered cmp (node red (node black l v a✝) y✝ (b✝.balance2 z✝ c✝.setRed))
state_after: case h_2.h_2
α : Type u_1
cmp : α → α → Ordering
l : RBNode α
v : α
lv : All (fun x => cmpLT cmp x v) l
hl : Ordered cmp l
l✝ : RBNode α
x✝ : ∀ (a : RBNode α) (x : α) (b : RBNode α), l = node red a x b → False
r✝ a✝ : RBNode α
y✝ : α
b✝ : RBNode α
z✝ : α
c✝ : RBNode α
vr : All (fun x => cmpLT cmp v x) (node red (node black a✝ y✝ b✝) z✝ c✝)
hr : Ordered cmp (node red (node black a✝ y✝ b✝) z✝ c✝)
vy : (fun x => cmpLT cmp v x) y✝
va : All (fun x => cmpLT cmp v x) a✝
right✝ : All (fun x => cmpLT cmp v x) b✝
⊢ Ordered cmp (node red (node black l v a✝) y✝ (b✝.balance2 z✝ c✝.setRed))

tactic: have ⟨⟨yz, _, bz⟩, zc, ⟨ay, yb, ha, hb⟩, hc⟩ := hr
state_before: case h_2.h_2
α : Type u_1
cmp : α → α → Ordering
l : RBNode α
v : α
lv : All (fun x => cmpLT cmp x v) l
hl : Ordered cmp l
l✝ : RBNode α
x✝ : ∀ (a : RBNode α) (x : α) (b : RBNode α), l = node red a x b → False
r✝ a✝ : RBNode α
y✝ : α
b✝ : RBNode α
z✝ : α
c✝ : RBNode α
vr : All (fun x => cmpLT cmp v x) (node red (node black a✝ y✝ b✝) z✝ c✝)
hr : Ordered cmp (node red (node black a✝ y✝ b✝) z✝ c✝)
vy : (fun x => cmpLT cmp v x) y✝
va : All (fun x => cmpLT cmp v x) a✝
right✝ : All (fun x => cmpLT cmp v x) b✝
⊢ Ordered cmp (node red (node black l v a✝) y✝ (b✝.balance2 z✝ c✝.setRed))
state_after: case h_2.h_2
α : Type u_1
cmp : α → α → Ordering
l : RBNode α
v : α
lv : All (fun x => cmpLT cmp x v) l
hl : Ordered cmp l
l✝ : RBNode α
x✝ : ∀ (a : RBNode α) (x : α) (b : RBNode α), l = node red a x b → False
r✝ a✝ : RBNode α
y✝ : α
b✝ : RBNode α
z✝ : α
c✝ : RBNode α
vr : All (fun x => cmpLT cmp v x) (node red (node black a✝ y✝ b✝) z✝ c✝)
hr : Ordered cmp (node red (node black a✝ y✝ b✝) z✝ c✝)
vy : (fun x => cmpLT cmp v x) y✝
va : All (fun x => cmpLT cmp v x) a✝
right✝ : All (fun x => cmpLT cmp v x) b✝
yz : (fun x => cmpLT cmp x z✝) y✝
left✝ : All (fun x => cmpLT cmp x z✝) a✝
bz : All (fun x => cmpLT cmp x z✝) b✝
zc : All (fun x => cmpLT cmp z✝ x) c✝
ay : All (fun x => cmpLT cmp x y✝) a✝
yb : All (fun x => cmpLT cmp y✝ x) b✝
ha : Ordered cmp a✝
hb : Ordered cmp b✝
hc : Ordered cmp c✝
⊢ Ordered cmp (node red (node black l v a✝) y✝ (b✝.balance2 z✝ c✝.setRed))

tactic: exact ⟨⟨vy, vy.trans_r lv, ay⟩, balance2_All.2 ⟨yz, yb, (yz.trans_l zc).setRed⟩,
  ⟨lv, va, hl, ha⟩, hb.balance2 bz zc.setRed (Ordered.setRed.2 hc)⟩
state_before: case h_2.h_2
α : Type u_1
cmp : α → α → Ordering
l : RBNode α
v : α
lv : All (fun x => cmpLT cmp x v) l
hl : Ordered cmp l
l✝ : RBNode α
x✝ : ∀ (a : RBNode α) (x : α) (b : RBNode α), l = node red a x b → False
r✝ a✝ : RBNode α
y✝ : α
b✝ : RBNode α
z✝ : α
c✝ : RBNode α
vr : All (fun x => cmpLT cmp v x) (node red (node black a✝ y✝ b✝) z✝ c✝)
hr : Ordered cmp (node red (node black a✝ y✝ b✝) z✝ c✝)
vy : (fun x => cmpLT cmp v x) y✝
va : All (fun x => cmpLT cmp v x) a✝
right✝ : All (fun x => cmpLT cmp v x) b✝
yz : (fun x => cmpLT cmp x z✝) y✝
left✝ : All (fun x => cmpLT cmp x z✝) a✝
bz : All (fun x => cmpLT cmp x z✝) b✝
zc : All (fun x => cmpLT cmp z✝ x) c✝
ay : All (fun x => cmpLT cmp x y✝) a✝
yb : All (fun x => cmpLT cmp y✝ x) b✝
ha : Ordered cmp a✝
hb : Ordered cmp b✝
hc : Ordered cmp c✝
⊢ Ordered cmp (node red (node black l v a✝) y✝ (b✝.balance2 z✝ c✝.setRed))
state_after: no goals

tactic: exact ⟨lv, vr, hl, hr⟩
state_before: case h_2.h_3
α : Type u_1
cmp : α → α → Ordering
l : RBNode α
v : α
r : RBNode α
lv : All (fun x => cmpLT cmp x v) l
vr : All (fun x => cmpLT cmp v x) r
hl : Ordered cmp l
hr : Ordered cmp r
l✝ : RBNode α
x✝² : ∀ (a : RBNode α) (x : α) (b : RBNode α), l = node red a x b → False
r✝ : RBNode α
x✝¹ : ∀ (a : RBNode α) (y : α) (b : RBNode α), r = node black a y b → False
x✝ : ∀ (a : RBNode α) (y : α) (b : RBNode α) (z : α) (c : RBNode α), r = node red (node black a y b) z c → False
⊢ Ordered cmp (node red l v r)
state_after: no goals