Theorem: Std.RBNode.Ordered.balRight
File: Std/Data/RBMap/WF.lean

tactic: unfold balRight
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 (balRight 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 r with
    | node red b y c => node red l v (node black b y c)
    | r =>
      match l with
      | node black a x b => balance1 (node red a x b) v r
      | node red a x (node black b y c) => node red (balance1 (setRed a) x b) y (node black c v r)
      | l => 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 α), r = node red a x b → False
⊢ Ordered cmp
    (match l with
    | node black a x b => balance1 (node red a x b) v r
    | node red a x (node black b y c) => node red (balance1 (setRed a) x b) y (node black c v r)
    | l => node red l v r)

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

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

tactic: have ⟨yv, _, cv⟩ := lv.2.2
state_before: case h_2.h_2
α : Type u_1
cmp : α → α → Ordering
v : α
r : RBNode α
vr : All (fun x => cmpLT cmp v x) r
hr : Ordered cmp r
l✝¹ : RBNode α
x✝¹ : ∀ (a : RBNode α) (x : α) (b : RBNode α), r = node red a x b → False
l✝ a✝ : RBNode α
x✝ : α
b✝ : RBNode α
y✝ : α
c✝ : RBNode α
lv : All (fun x => cmpLT cmp x v) (node red a✝ x✝ (node black b✝ y✝ c✝))
hl : Ordered cmp (node red a✝ x✝ (node black b✝ y✝ c✝))
⊢ Ordered cmp (node red (balance1 (setRed a✝) x✝ b✝) y✝ (node black c✝ v r))

tactic: have ⟨ax, ⟨xy, xb, _⟩, ha, by_, yc, hb, hc⟩ := hl
state_before: case h_2.h_2
α : Type u_1
cmp : α → α → Ordering
v : α
r : RBNode α
vr : All (fun x => cmpLT cmp v x) r
hr : Ordered cmp r
l✝¹ : RBNode α
x✝¹ : ∀ (a : RBNode α) (x : α) (b : RBNode α), r = node red a x b → False
l✝ a✝ : RBNode α
x✝ : α
b✝ : RBNode α
y✝ : α
c✝ : RBNode α
lv : All (fun x => cmpLT cmp x v) (node red a✝ x✝ (node black b✝ y✝ c✝))
hl : Ordered cmp (node red a✝ x✝ (node black b✝ y✝ c✝))
yv : (fun x => cmpLT cmp x v) y✝
left✝ : All (fun x => cmpLT cmp x v) b✝
cv : All (fun x => cmpLT cmp x v) c✝
⊢ Ordered cmp (node red (balance1 (setRed a✝) x✝ b✝) y✝ (node black c✝ v r))

tactic: exact ⟨balance1_All.2 ⟨xy, (xy.trans_r ax).setRed, by_⟩, ⟨yv, yc, yv.trans_l vr⟩,
  (Ordered.setRed.2 ha).balance1 ax.setRed xb hb, cv, vr, hc, hr⟩
state_before: case h_2.h_2
α : Type u_1
cmp : α → α → Ordering
v : α
r : RBNode α
vr : All (fun x => cmpLT cmp v x) r
hr : Ordered cmp r
l✝¹ : RBNode α
x✝¹ : ∀ (a : RBNode α) (x : α) (b : RBNode α), r = node red a x b → False
l✝ a✝ : RBNode α
x✝ : α
b✝ : RBNode α
y✝ : α
c✝ : RBNode α
lv : All (fun x => cmpLT cmp x v) (node red a✝ x✝ (node black b✝ y✝ c✝))
hl : Ordered cmp (node red a✝ x✝ (node black b✝ y✝ c✝))
yv : (fun x => cmpLT cmp x v) y✝
left✝ : All (fun x => cmpLT cmp x v) b✝
cv : All (fun x => cmpLT cmp x v) c✝
ax : All (fun x => cmpLT cmp x x✝) a✝
xy : (fun x => cmpLT cmp x✝ x) y✝
xb : All (fun x => cmpLT cmp x✝ x) b✝
right✝ : All (fun x => cmpLT cmp x✝ x) c✝
ha : Ordered cmp a✝
by_ : All (fun x => cmpLT cmp x y✝) b✝
yc : All (fun x => cmpLT cmp y✝ x) c✝
hb : Ordered cmp b✝
hc : Ordered cmp c✝
⊢ Ordered cmp (node red (balance1 (setRed a✝) x✝ b✝) y✝ (node black c✝ v r))

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 α), r = node red a x b → False
l✝ : RBNode α
x✝¹ : ∀ (a : RBNode α) (x : α) (b : RBNode α), l = node black a x b → False
x✝ : ∀ (a : RBNode α) (x : α) (b : RBNode α) (y : α) (c : RBNode α), l = node red a x (node black b y c) → False
⊢ Ordered cmp (node red l v r)