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

tactic: unfold append
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 (append l 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, r with
    | nil, x => x
    | x, nil => x
    | node red a x b, node red c y d =>
      match append b c with
      | node red b' z c' => node red (node red a x b') z (node red c' y d)
      | bc => node red a x (node red bc y d)
    | node black a x b, node black c y d =>
      match append b c with
      | node red b' z c' => node red (node black a x b') z (node black c' y d)
      | bc => balLeft a x (node black bc y d)
    | a@h:(node black l v r), node red b x c => node red (append a b) x c
    | node red a x b, c@h:(node black l v r) => node red a x (append b c))

tactic: exact 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
x✝¹ x✝ : RBNode α
lv : All (fun x => cmpLT cmp x v) nil
hl : Ordered cmp nil
⊢ Ordered cmp r

tactic: exact hl
state_before: case h_2
α : Type u_1
cmp : α → α → Ordering
l : RBNode α
v : α
lv : All (fun x => cmpLT cmp x v) l
hl : Ordered cmp l
x✝² x✝¹ : RBNode α
x✝ : l = nil → False
vr : All (fun x => cmpLT cmp v x) nil
hr : Ordered cmp nil
⊢ Ordered cmp l

tactic: have ⟨xv, _, bv⟩ := lv
state_before: case h_3
α : Type u_1
cmp : α → α → Ordering
v : α
x✝² x✝¹ a✝ : RBNode α
x✝ : α
b✝ c✝ : RBNode α
y✝ : α
d✝ : RBNode α
lv : All (fun x => cmpLT cmp x v) (node red a✝ x✝ b✝)
hl : Ordered cmp (node red a✝ x✝ b✝)
vr : All (fun x => cmpLT cmp v x) (node red c✝ y✝ d✝)
hr : Ordered cmp (node red c✝ y✝ d✝)
⊢ Ordered cmp
    (match append b✝ c✝ with
    | node red b' z c' => node red (node red a✝ x✝ b') z (node red c' y✝ d✝)
    | bc => node red a✝ x✝ (node red bc y✝ d✝))

tactic: have ⟨ax, xb, ha, hb⟩ := hl
state_before: case h_3
α : Type u_1
cmp : α → α → Ordering
v : α
x✝² x✝¹ a✝ : RBNode α
x✝ : α
b✝ c✝ : RBNode α
y✝ : α
d✝ : RBNode α
lv : All (fun x => cmpLT cmp x v) (node red a✝ x✝ b✝)
hl : Ordered cmp (node red a✝ x✝ b✝)
vr : All (fun x => cmpLT cmp v x) (node red c✝ y✝ d✝)
hr : Ordered cmp (node red c✝ y✝ d✝)
xv : (fun x => cmpLT cmp x v) x✝
left✝ : All (fun x => cmpLT cmp x v) a✝
bv : All (fun x => cmpLT cmp x v) b✝
⊢ Ordered cmp
    (match append b✝ c✝ with
    | node red b' z c' => node red (node red a✝ x✝ b') z (node red c' y✝ d✝)
    | bc => node red a✝ x✝ (node red bc y✝ d✝))

tactic: have ⟨vy, vc, _⟩ := vr
state_before: case h_3
α : Type u_1
cmp : α → α → Ordering
v : α
x✝² x✝¹ a✝ : RBNode α
x✝ : α
b✝ c✝ : RBNode α
y✝ : α
d✝ : RBNode α
lv : All (fun x => cmpLT cmp x v) (node red a✝ x✝ b✝)
hl : Ordered cmp (node red a✝ x✝ b✝)
vr : All (fun x => cmpLT cmp v x) (node red c✝ y✝ d✝)
hr : Ordered cmp (node red c✝ y✝ d✝)
xv : (fun x => cmpLT cmp x v) x✝
left✝ : All (fun x => cmpLT cmp x v) a✝
bv : All (fun x => cmpLT cmp x v) b✝
ax : All (fun x => cmpLT cmp x x✝) a✝
xb : All (fun x => cmpLT cmp x✝ x) b✝
ha : Ordered cmp a✝
hb : Ordered cmp b✝
⊢ Ordered cmp
    (match append b✝ c✝ with
    | node red b' z c' => node red (node red a✝ x✝ b') z (node red c' y✝ d✝)
    | bc => node red a✝ x✝ (node red bc y✝ d✝))

tactic: have ⟨cy, yd, hc, hd⟩ := hr
state_before: case h_3
α : Type u_1
cmp : α → α → Ordering
v : α
x✝² x✝¹ a✝ : RBNode α
x✝ : α
b✝ c✝ : RBNode α
y✝ : α
d✝ : RBNode α
lv : All (fun x => cmpLT cmp x v) (node red a✝ x✝ b✝)
hl : Ordered cmp (node red a✝ x✝ b✝)
vr : All (fun x => cmpLT cmp v x) (node red c✝ y✝ d✝)
hr : Ordered cmp (node red c✝ y✝ d✝)
xv : (fun x => cmpLT cmp x v) x✝
left✝ : All (fun x => cmpLT cmp x v) a✝
bv : All (fun x => cmpLT cmp x v) b✝
ax : All (fun x => cmpLT cmp x x✝) a✝
xb : All (fun x => cmpLT cmp x✝ x) b✝
ha : Ordered cmp a✝
hb : Ordered cmp b✝
vy : (fun x => cmpLT cmp v x) y✝
vc : All (fun x => cmpLT cmp v x) c✝
right✝ : All (fun x => cmpLT cmp v x) d✝
⊢ Ordered cmp
    (match append b✝ c✝ with
    | node red b' z c' => node red (node red a✝ x✝ b') z (node red c' y✝ d✝)
    | bc => node red a✝ x✝ (node red bc y✝ d✝))

tactic: have : _ ∧ _ ∧ _ := ⟨hb.append bv vc hc, xb.append (xv.trans_l vc), (vy.trans_r bv).append cy⟩
state_before: case h_3
α : Type u_1
cmp : α → α → Ordering
v : α
x✝² x✝¹ a✝ : RBNode α
x✝ : α
b✝ c✝ : RBNode α
y✝ : α
d✝ : RBNode α
lv : All (fun x => cmpLT cmp x v) (node red a✝ x✝ b✝)
hl : Ordered cmp (node red a✝ x✝ b✝)
vr : All (fun x => cmpLT cmp v x) (node red c✝ y✝ d✝)
hr : Ordered cmp (node red c✝ y✝ d✝)
xv : (fun x => cmpLT cmp x v) x✝
left✝ : All (fun x => cmpLT cmp x v) a✝
bv : All (fun x => cmpLT cmp x v) b✝
ax : All (fun x => cmpLT cmp x x✝) a✝
xb : All (fun x => cmpLT cmp x✝ x) b✝
ha : Ordered cmp a✝
hb : Ordered cmp b✝
vy : (fun x => cmpLT cmp v x) y✝
vc : All (fun x => cmpLT cmp v x) c✝
right✝ : All (fun x => cmpLT cmp v x) d✝
cy : All (fun x => cmpLT cmp x y✝) c✝
yd : All (fun x => cmpLT cmp y✝ x) d✝
hc : Ordered cmp c✝
hd : Ordered cmp d✝
⊢ Ordered cmp
    (match append b✝ c✝ with
    | node red b' z c' => node red (node red a✝ x✝ b') z (node red c' y✝ d✝)
    | bc => node red a✝ x✝ (node red bc y✝ d✝))

tactic: split
state_before: case h_3
α : Type u_1
cmp : α → α → Ordering
v : α
x✝² x✝¹ a✝ : RBNode α
x✝ : α
b✝ c✝ : RBNode α
y✝ : α
d✝ : RBNode α
lv : All (fun x => cmpLT cmp x v) (node red a✝ x✝ b✝)
hl : Ordered cmp (node red a✝ x✝ b✝)
vr : All (fun x => cmpLT cmp v x) (node red c✝ y✝ d✝)
hr : Ordered cmp (node red c✝ y✝ d✝)
xv : (fun x => cmpLT cmp x v) x✝
left✝ : All (fun x => cmpLT cmp x v) a✝
bv : All (fun x => cmpLT cmp x v) b✝
ax : All (fun x => cmpLT cmp x x✝) a✝
xb : All (fun x => cmpLT cmp x✝ x) b✝
ha : Ordered cmp a✝
hb : Ordered cmp b✝
vy : (fun x => cmpLT cmp v x) y✝
vc : All (fun x => cmpLT cmp v x) c✝
right✝ : All (fun x => cmpLT cmp v x) d✝
cy : All (fun x => cmpLT cmp x y✝) c✝
yd : All (fun x => cmpLT cmp y✝ x) d✝
hc : Ordered cmp c✝
hd : Ordered cmp d✝
this :
  Ordered cmp (append b✝ c✝) ∧
    All (fun x => cmpLT cmp x✝ x) (append b✝ c✝) ∧ All (fun x => cmpLT cmp x y✝) (append b✝ c✝)
⊢ Ordered cmp
    (match append b✝ c✝ with
    | node red b' z c' => node red (node red a✝ x✝ b') z (node red c' y✝ d✝)
    | bc => node red a✝ x✝ (node red bc y✝ d✝))

tactic: next H =>
have ⟨⟨b'z, c'z, hb', hc'⟩, ⟨xz, xb', _⟩, zy, _, c'y⟩ := H ▸ this
have az := xz.trans_r ax; have zd := zy.trans_l yd
exact ⟨⟨xz, az, b'z⟩, ⟨zy, c'z, zd⟩, ⟨ax, xb', ha, hb'⟩, c'y, yd, hc', hd⟩
state_before: case h_3.h_1
α : Type u_1
cmp : α → α → Ordering
v : α
x✝³ x✝² a✝¹ : RBNode α
x✝¹ : α
b✝¹ c✝ : RBNode α
y✝ : α
d✝ : RBNode α
lv : All (fun x => cmpLT cmp x v) (node red a✝¹ x✝¹ b✝¹)
hl : Ordered cmp (node red a✝¹ x✝¹ b✝¹)
vr : All (fun x => cmpLT cmp v x) (node red c✝ y✝ d✝)
hr : Ordered cmp (node red c✝ y✝ d✝)
xv : (fun x => cmpLT cmp x v) x✝¹
left✝ : All (fun x => cmpLT cmp x v) a✝¹
bv : All (fun x => cmpLT cmp x v) b✝¹
ax : All (fun x => cmpLT cmp x x✝¹) a✝¹
xb : All (fun x => cmpLT cmp x✝¹ x) b✝¹
ha : Ordered cmp a✝¹
hb : Ordered cmp b✝¹
vy : (fun x => cmpLT cmp v x) y✝
vc : All (fun x => cmpLT cmp v x) c✝
right✝ : All (fun x => cmpLT cmp v x) d✝
cy : All (fun x => cmpLT cmp x y✝) c✝
yd : All (fun x => cmpLT cmp y✝ x) d✝
hc : Ordered cmp c✝
hd : Ordered cmp d✝
this :
  Ordered cmp (append b✝¹ c✝) ∧
    All (fun x => cmpLT cmp x✝¹ x) (append b✝¹ c✝) ∧ All (fun x => cmpLT cmp x y✝) (append b✝¹ c✝)
l✝ a✝ : RBNode α
x✝ : α
b✝ : RBNode α
heq✝ : append b✝¹ c✝ = node red a✝ x✝ b✝
⊢ Ordered cmp (node red (node red a✝¹ x✝¹ a✝) x✝ (node red b✝ y✝ d✝))

tactic: have ⟨⟨b'z, c'z, hb', hc'⟩, ⟨xz, xb', _⟩, zy, _, c'y⟩ := H ▸ this
state_before: α : Type u_1
cmp : α → α → Ordering
v : α
x✝³ x✝² a✝¹ : RBNode α
x✝¹ : α
b✝¹ c✝ : RBNode α
y✝ : α
d✝ : RBNode α
lv : All (fun x => cmpLT cmp x v) (node red a✝¹ x✝¹ b✝¹)
hl : Ordered cmp (node red a✝¹ x✝¹ b✝¹)
vr : All (fun x => cmpLT cmp v x) (node red c✝ y✝ d✝)
hr : Ordered cmp (node red c✝ y✝ d✝)
xv : (fun x => cmpLT cmp x v) x✝¹
left✝ : All (fun x => cmpLT cmp x v) a✝¹
bv : All (fun x => cmpLT cmp x v) b✝¹
ax : All (fun x => cmpLT cmp x x✝¹) a✝¹
xb : All (fun x => cmpLT cmp x✝¹ x) b✝¹
ha : Ordered cmp a✝¹
hb : Ordered cmp b✝¹
vy : (fun x => cmpLT cmp v x) y✝
vc : All (fun x => cmpLT cmp v x) c✝
right✝ : All (fun x => cmpLT cmp v x) d✝
cy : All (fun x => cmpLT cmp x y✝) c✝
yd : All (fun x => cmpLT cmp y✝ x) d✝
hc : Ordered cmp c✝
hd : Ordered cmp d✝
this :
  Ordered cmp (append b✝¹ c✝) ∧
    All (fun x => cmpLT cmp x✝¹ x) (append b✝¹ c✝) ∧ All (fun x => cmpLT cmp x y✝) (append b✝¹ c✝)
l✝ a✝ : RBNode α
x✝ : α
b✝ : RBNode α
H : append b✝¹ c✝ = node red a✝ x✝ b✝
⊢ Ordered cmp (node red (node red a✝¹ x✝¹ a✝) x✝ (node red b✝ y✝ d✝))

tactic: have az := xz.trans_r ax
state_before: α : Type u_1
cmp : α → α → Ordering
v : α
x✝³ x✝² a✝¹ : RBNode α
x✝¹ : α
b✝¹ c✝ : RBNode α
y✝ : α
d✝ : RBNode α
lv : All (fun x => cmpLT cmp x v) (node red a✝¹ x✝¹ b✝¹)
hl : Ordered cmp (node red a✝¹ x✝¹ b✝¹)
vr : All (fun x => cmpLT cmp v x) (node red c✝ y✝ d✝)
hr : Ordered cmp (node red c✝ y✝ d✝)
xv : (fun x => cmpLT cmp x v) x✝¹
left✝¹ : All (fun x => cmpLT cmp x v) a✝¹
bv : All (fun x => cmpLT cmp x v) b✝¹
ax : All (fun x => cmpLT cmp x x✝¹) a✝¹
xb : All (fun x => cmpLT cmp x✝¹ x) b✝¹
ha : Ordered cmp a✝¹
hb : Ordered cmp b✝¹
vy : (fun x => cmpLT cmp v x) y✝
vc : All (fun x => cmpLT cmp v x) c✝
right✝¹ : All (fun x => cmpLT cmp v x) d✝
cy : All (fun x => cmpLT cmp x y✝) c✝
yd : All (fun x => cmpLT cmp y✝ x) d✝
hc : Ordered cmp c✝
hd : Ordered cmp d✝
this :
  Ordered cmp (append b✝¹ c✝) ∧
    All (fun x => cmpLT cmp x✝¹ x) (append b✝¹ c✝) ∧ All (fun x => cmpLT cmp x y✝) (append b✝¹ c✝)
l✝ a✝ : RBNode α
x✝ : α
b✝ : RBNode α
H : append b✝¹ c✝ = node red a✝ x✝ b✝
b'z : All (fun x => cmpLT cmp x x✝) a✝
c'z : All (fun x => cmpLT cmp x✝ x) b✝
hb' : Ordered cmp a✝
hc' : Ordered cmp b✝
xz : (fun x => cmpLT cmp x✝¹ x) x✝
xb' : All (fun x => cmpLT cmp x✝¹ x) a✝
right✝ : All (fun x => cmpLT cmp x✝¹ x) b✝
zy : (fun x => cmpLT cmp x y✝) x✝
left✝ : All (fun x => cmpLT cmp x y✝) a✝
c'y : All (fun x => cmpLT cmp x y✝) b✝
⊢ Ordered cmp (node red (node red a✝¹ x✝¹ a✝) x✝ (node red b✝ y✝ d✝))

tactic: have zd := zy.trans_l yd
state_before: α : Type u_1
cmp : α → α → Ordering
v : α
x✝³ x✝² a✝¹ : RBNode α
x✝¹ : α
b✝¹ c✝ : RBNode α
y✝ : α
d✝ : RBNode α
lv : All (fun x => cmpLT cmp x v) (node red a✝¹ x✝¹ b✝¹)
hl : Ordered cmp (node red a✝¹ x✝¹ b✝¹)
vr : All (fun x => cmpLT cmp v x) (node red c✝ y✝ d✝)
hr : Ordered cmp (node red c✝ y✝ d✝)
xv : (fun x => cmpLT cmp x v) x✝¹
left✝¹ : All (fun x => cmpLT cmp x v) a✝¹
bv : All (fun x => cmpLT cmp x v) b✝¹
ax : All (fun x => cmpLT cmp x x✝¹) a✝¹
xb : All (fun x => cmpLT cmp x✝¹ x) b✝¹
ha : Ordered cmp a✝¹
hb : Ordered cmp b✝¹
vy : (fun x => cmpLT cmp v x) y✝
vc : All (fun x => cmpLT cmp v x) c✝
right✝¹ : All (fun x => cmpLT cmp v x) d✝
cy : All (fun x => cmpLT cmp x y✝) c✝
yd : All (fun x => cmpLT cmp y✝ x) d✝
hc : Ordered cmp c✝
hd : Ordered cmp d✝
this :
  Ordered cmp (append b✝¹ c✝) ∧
    All (fun x => cmpLT cmp x✝¹ x) (append b✝¹ c✝) ∧ All (fun x => cmpLT cmp x y✝) (append b✝¹ c✝)
l✝ a✝ : RBNode α
x✝ : α
b✝ : RBNode α
H : append b✝¹ c✝ = node red a✝ x✝ b✝
b'z : All (fun x => cmpLT cmp x x✝) a✝
c'z : All (fun x => cmpLT cmp x✝ x) b✝
hb' : Ordered cmp a✝
hc' : Ordered cmp b✝
xz : (fun x => cmpLT cmp x✝¹ x) x✝
xb' : All (fun x => cmpLT cmp x✝¹ x) a✝
right✝ : All (fun x => cmpLT cmp x✝¹ x) b✝
zy : (fun x => cmpLT cmp x y✝) x✝
left✝ : All (fun x => cmpLT cmp x y✝) a✝
c'y : All (fun x => cmpLT cmp x y✝) b✝
az : All (fun x => cmpLT cmp x x✝) a✝¹
⊢ Ordered cmp (node red (node red a✝¹ x✝¹ a✝) x✝ (node red b✝ y✝ d✝))

tactic: exact ⟨⟨xz, az, b'z⟩, ⟨zy, c'z, zd⟩, ⟨ax, xb', ha, hb'⟩, c'y, yd, hc', hd⟩
state_before: α : Type u_1
cmp : α → α → Ordering
v : α
x✝³ x✝² a✝¹ : RBNode α
x✝¹ : α
b✝¹ c✝ : RBNode α
y✝ : α
d✝ : RBNode α
lv : All (fun x => cmpLT cmp x v) (node red a✝¹ x✝¹ b✝¹)
hl : Ordered cmp (node red a✝¹ x✝¹ b✝¹)
vr : All (fun x => cmpLT cmp v x) (node red c✝ y✝ d✝)
hr : Ordered cmp (node red c✝ y✝ d✝)
xv : (fun x => cmpLT cmp x v) x✝¹
left✝¹ : All (fun x => cmpLT cmp x v) a✝¹
bv : All (fun x => cmpLT cmp x v) b✝¹
ax : All (fun x => cmpLT cmp x x✝¹) a✝¹
xb : All (fun x => cmpLT cmp x✝¹ x) b✝¹
ha : Ordered cmp a✝¹
hb : Ordered cmp b✝¹
vy : (fun x => cmpLT cmp v x) y✝
vc : All (fun x => cmpLT cmp v x) c✝
right✝¹ : All (fun x => cmpLT cmp v x) d✝
cy : All (fun x => cmpLT cmp x y✝) c✝
yd : All (fun x => cmpLT cmp y✝ x) d✝
hc : Ordered cmp c✝
hd : Ordered cmp d✝
this :
  Ordered cmp (append b✝¹ c✝) ∧
    All (fun x => cmpLT cmp x✝¹ x) (append b✝¹ c✝) ∧ All (fun x => cmpLT cmp x y✝) (append b✝¹ c✝)
l✝ a✝ : RBNode α
x✝ : α
b✝ : RBNode α
H : append b✝¹ c✝ = node red a✝ x✝ b✝
b'z : All (fun x => cmpLT cmp x x✝) a✝
c'z : All (fun x => cmpLT cmp x✝ x) b✝
hb' : Ordered cmp a✝
hc' : Ordered cmp b✝
xz : (fun x => cmpLT cmp x✝¹ x) x✝
xb' : All (fun x => cmpLT cmp x✝¹ x) a✝
right✝ : All (fun x => cmpLT cmp x✝¹ x) b✝
zy : (fun x => cmpLT cmp x y✝) x✝
left✝ : All (fun x => cmpLT cmp x y✝) a✝
c'y : All (fun x => cmpLT cmp x y✝) b✝
az : All (fun x => cmpLT cmp x x✝) a✝¹
zd : All (fun x => cmpLT cmp x✝ x) d✝
⊢ Ordered cmp (node red (node red a✝¹ x✝¹ a✝) x✝ (node red b✝ y✝ d✝))

tactic: have ⟨hbc, xbc, bcy⟩ := this
state_before: case h_3.h_2
α : Type u_1
cmp : α → α → Ordering
v : α
x✝³ x✝² a✝ : RBNode α
x✝¹ : α
b✝ c✝ : RBNode α
y✝ : α
d✝ : RBNode α
lv : All (fun x => cmpLT cmp x v) (node red a✝ x✝¹ b✝)
hl : Ordered cmp (node red a✝ x✝¹ b✝)
vr : All (fun x => cmpLT cmp v x) (node red c✝ y✝ d✝)
hr : Ordered cmp (node red c✝ y✝ d✝)
xv : (fun x => cmpLT cmp x v) x✝¹
left✝ : All (fun x => cmpLT cmp x v) a✝
bv : All (fun x => cmpLT cmp x v) b✝
ax : All (fun x => cmpLT cmp x x✝¹) a✝
xb : All (fun x => cmpLT cmp x✝¹ x) b✝
ha : Ordered cmp a✝
hb : Ordered cmp b✝
vy : (fun x => cmpLT cmp v x) y✝
vc : All (fun x => cmpLT cmp v x) c✝
right✝ : All (fun x => cmpLT cmp v x) d✝
cy : All (fun x => cmpLT cmp x y✝) c✝
yd : All (fun x => cmpLT cmp y✝ x) d✝
hc : Ordered cmp c✝
hd : Ordered cmp d✝
this :
  Ordered cmp (append b✝ c✝) ∧
    All (fun x => cmpLT cmp x✝¹ x) (append b✝ c✝) ∧ All (fun x => cmpLT cmp x y✝) (append b✝ c✝)
l✝ : RBNode α
x✝ : ∀ (a : RBNode α) (x : α) (b : RBNode α), append b✝ c✝ = node red a x b → False
⊢ Ordered cmp (node red a✝ x✝¹ (node red (append b✝ c✝) y✝ d✝))

tactic: have xy := xv.trans vy
state_before: case h_3.h_2
α : Type u_1
cmp : α → α → Ordering
v : α
x✝³ x✝² a✝ : RBNode α
x✝¹ : α
b✝ c✝ : RBNode α
y✝ : α
d✝ : RBNode α
lv : All (fun x => cmpLT cmp x v) (node red a✝ x✝¹ b✝)
hl : Ordered cmp (node red a✝ x✝¹ b✝)
vr : All (fun x => cmpLT cmp v x) (node red c✝ y✝ d✝)
hr : Ordered cmp (node red c✝ y✝ d✝)
xv : (fun x => cmpLT cmp x v) x✝¹
left✝ : All (fun x => cmpLT cmp x v) a✝
bv : All (fun x => cmpLT cmp x v) b✝
ax : All (fun x => cmpLT cmp x x✝¹) a✝
xb : All (fun x => cmpLT cmp x✝¹ x) b✝
ha : Ordered cmp a✝
hb : Ordered cmp b✝
vy : (fun x => cmpLT cmp v x) y✝
vc : All (fun x => cmpLT cmp v x) c✝
right✝ : All (fun x => cmpLT cmp v x) d✝
cy : All (fun x => cmpLT cmp x y✝) c✝
yd : All (fun x => cmpLT cmp y✝ x) d✝
hc : Ordered cmp c✝
hd : Ordered cmp d✝
this :
  Ordered cmp (append b✝ c✝) ∧
    All (fun x => cmpLT cmp x✝¹ x) (append b✝ c✝) ∧ All (fun x => cmpLT cmp x y✝) (append b✝ c✝)
l✝ : RBNode α
x✝ : ∀ (a : RBNode α) (x : α) (b : RBNode α), append b✝ c✝ = node red a x b → False
hbc : Ordered cmp (append b✝ c✝)
xbc : All (fun x => cmpLT cmp x✝¹ x) (append b✝ c✝)
bcy : All (fun x => cmpLT cmp x y✝) (append b✝ c✝)
⊢ Ordered cmp (node red a✝ x✝¹ (node red (append b✝ c✝) y✝ d✝))

tactic: exact ⟨ax, ⟨xy, xbc, xy.trans_l yd⟩, ha, bcy, yd, hbc, hd⟩
state_before: case h_3.h_2
α : Type u_1
cmp : α → α → Ordering
v : α
x✝³ x✝² a✝ : RBNode α
x✝¹ : α
b✝ c✝ : RBNode α
y✝ : α
d✝ : RBNode α
lv : All (fun x => cmpLT cmp x v) (node red a✝ x✝¹ b✝)
hl : Ordered cmp (node red a✝ x✝¹ b✝)
vr : All (fun x => cmpLT cmp v x) (node red c✝ y✝ d✝)
hr : Ordered cmp (node red c✝ y✝ d✝)
xv : (fun x => cmpLT cmp x v) x✝¹
left✝ : All (fun x => cmpLT cmp x v) a✝
bv : All (fun x => cmpLT cmp x v) b✝
ax : All (fun x => cmpLT cmp x x✝¹) a✝
xb : All (fun x => cmpLT cmp x✝¹ x) b✝
ha : Ordered cmp a✝
hb : Ordered cmp b✝
vy : (fun x => cmpLT cmp v x) y✝
vc : All (fun x => cmpLT cmp v x) c✝
right✝ : All (fun x => cmpLT cmp v x) d✝
cy : All (fun x => cmpLT cmp x y✝) c✝
yd : All (fun x => cmpLT cmp y✝ x) d✝
hc : Ordered cmp c✝
hd : Ordered cmp d✝
this :
  Ordered cmp (append b✝ c✝) ∧
    All (fun x => cmpLT cmp x✝¹ x) (append b✝ c✝) ∧ All (fun x => cmpLT cmp x y✝) (append b✝ c✝)
l✝ : RBNode α
x✝ : ∀ (a : RBNode α) (x : α) (b : RBNode α), append b✝ c✝ = node red a x b → False
hbc : Ordered cmp (append b✝ c✝)
xbc : All (fun x => cmpLT cmp x✝¹ x) (append b✝ c✝)
bcy : All (fun x => cmpLT cmp x y✝) (append b✝ c✝)
xy : cmpLT cmp x✝¹ y✝
⊢ Ordered cmp (node red a✝ x✝¹ (node red (append b✝ c✝) y✝ d✝))

tactic: have ⟨xv, _, bv⟩ := lv
state_before: case h_4
α : Type u_1
cmp : α → α → Ordering
v : α
x✝² x✝¹ a✝ : RBNode α
x✝ : α
b✝ c✝ : RBNode α
y✝ : α
d✝ : RBNode α
lv : All (fun x => cmpLT cmp x v) (node black a✝ x✝ b✝)
hl : Ordered cmp (node black a✝ x✝ b✝)
vr : All (fun x => cmpLT cmp v x) (node black c✝ y✝ d✝)
hr : Ordered cmp (node black c✝ y✝ d✝)
⊢ Ordered cmp
    (match append b✝ c✝ with
    | node red b' z c' => node red (node black a✝ x✝ b') z (node black c' y✝ d✝)
    | bc => balLeft a✝ x✝ (node black bc y✝ d✝))

tactic: have ⟨ax, xb, ha, hb⟩ := hl
state_before: case h_4
α : Type u_1
cmp : α → α → Ordering
v : α
x✝² x✝¹ a✝ : RBNode α
x✝ : α
b✝ c✝ : RBNode α
y✝ : α
d✝ : RBNode α
lv : All (fun x => cmpLT cmp x v) (node black a✝ x✝ b✝)
hl : Ordered cmp (node black a✝ x✝ b✝)
vr : All (fun x => cmpLT cmp v x) (node black c✝ y✝ d✝)
hr : Ordered cmp (node black c✝ y✝ d✝)
xv : (fun x => cmpLT cmp x v) x✝
left✝ : All (fun x => cmpLT cmp x v) a✝
bv : All (fun x => cmpLT cmp x v) b✝
⊢ Ordered cmp
    (match append b✝ c✝ with
    | node red b' z c' => node red (node black a✝ x✝ b') z (node black c' y✝ d✝)
    | bc => balLeft a✝ x✝ (node black bc y✝ d✝))

tactic: have ⟨vy, vc, _⟩ := vr
state_before: case h_4
α : Type u_1
cmp : α → α → Ordering
v : α
x✝² x✝¹ a✝ : RBNode α
x✝ : α
b✝ c✝ : RBNode α
y✝ : α
d✝ : RBNode α
lv : All (fun x => cmpLT cmp x v) (node black a✝ x✝ b✝)
hl : Ordered cmp (node black a✝ x✝ b✝)
vr : All (fun x => cmpLT cmp v x) (node black c✝ y✝ d✝)
hr : Ordered cmp (node black c✝ y✝ d✝)
xv : (fun x => cmpLT cmp x v) x✝
left✝ : All (fun x => cmpLT cmp x v) a✝
bv : All (fun x => cmpLT cmp x v) b✝
ax : All (fun x => cmpLT cmp x x✝) a✝
xb : All (fun x => cmpLT cmp x✝ x) b✝
ha : Ordered cmp a✝
hb : Ordered cmp b✝
⊢ Ordered cmp
    (match append b✝ c✝ with
    | node red b' z c' => node red (node black a✝ x✝ b') z (node black c' y✝ d✝)
    | bc => balLeft a✝ x✝ (node black bc y✝ d✝))

tactic: have ⟨cy, yd, hc, hd⟩ := hr
state_before: case h_4
α : Type u_1
cmp : α → α → Ordering
v : α
x✝² x✝¹ a✝ : RBNode α
x✝ : α
b✝ c✝ : RBNode α
y✝ : α
d✝ : RBNode α
lv : All (fun x => cmpLT cmp x v) (node black a✝ x✝ b✝)
hl : Ordered cmp (node black a✝ x✝ b✝)
vr : All (fun x => cmpLT cmp v x) (node black c✝ y✝ d✝)
hr : Ordered cmp (node black c✝ y✝ d✝)
xv : (fun x => cmpLT cmp x v) x✝
left✝ : All (fun x => cmpLT cmp x v) a✝
bv : All (fun x => cmpLT cmp x v) b✝
ax : All (fun x => cmpLT cmp x x✝) a✝
xb : All (fun x => cmpLT cmp x✝ x) b✝
ha : Ordered cmp a✝
hb : Ordered cmp b✝
vy : (fun x => cmpLT cmp v x) y✝
vc : All (fun x => cmpLT cmp v x) c✝
right✝ : All (fun x => cmpLT cmp v x) d✝
⊢ Ordered cmp
    (match append b✝ c✝ with
    | node red b' z c' => node red (node black a✝ x✝ b') z (node black c' y✝ d✝)
    | bc => balLeft a✝ x✝ (node black bc y✝ d✝))

tactic: have : _ ∧ _ ∧ _ := ⟨hb.append bv vc hc, xb.append (xv.trans_l vc), (vy.trans_r bv).append cy⟩
state_before: case h_4
α : Type u_1
cmp : α → α → Ordering
v : α
x✝² x✝¹ a✝ : RBNode α
x✝ : α
b✝ c✝ : RBNode α
y✝ : α
d✝ : RBNode α
lv : All (fun x => cmpLT cmp x v) (node black a✝ x✝ b✝)
hl : Ordered cmp (node black a✝ x✝ b✝)
vr : All (fun x => cmpLT cmp v x) (node black c✝ y✝ d✝)
hr : Ordered cmp (node black c✝ y✝ d✝)
xv : (fun x => cmpLT cmp x v) x✝
left✝ : All (fun x => cmpLT cmp x v) a✝
bv : All (fun x => cmpLT cmp x v) b✝
ax : All (fun x => cmpLT cmp x x✝) a✝
xb : All (fun x => cmpLT cmp x✝ x) b✝
ha : Ordered cmp a✝
hb : Ordered cmp b✝
vy : (fun x => cmpLT cmp v x) y✝
vc : All (fun x => cmpLT cmp v x) c✝
right✝ : All (fun x => cmpLT cmp v x) d✝
cy : All (fun x => cmpLT cmp x y✝) c✝
yd : All (fun x => cmpLT cmp y✝ x) d✝
hc : Ordered cmp c✝
hd : Ordered cmp d✝
⊢ Ordered cmp
    (match append b✝ c✝ with
    | node red b' z c' => node red (node black a✝ x✝ b') z (node black c' y✝ d✝)
    | bc => balLeft a✝ x✝ (node black bc y✝ d✝))

tactic: split
state_before: case h_4
α : Type u_1
cmp : α → α → Ordering
v : α
x✝² x✝¹ a✝ : RBNode α
x✝ : α
b✝ c✝ : RBNode α
y✝ : α
d✝ : RBNode α
lv : All (fun x => cmpLT cmp x v) (node black a✝ x✝ b✝)
hl : Ordered cmp (node black a✝ x✝ b✝)
vr : All (fun x => cmpLT cmp v x) (node black c✝ y✝ d✝)
hr : Ordered cmp (node black c✝ y✝ d✝)
xv : (fun x => cmpLT cmp x v) x✝
left✝ : All (fun x => cmpLT cmp x v) a✝
bv : All (fun x => cmpLT cmp x v) b✝
ax : All (fun x => cmpLT cmp x x✝) a✝
xb : All (fun x => cmpLT cmp x✝ x) b✝
ha : Ordered cmp a✝
hb : Ordered cmp b✝
vy : (fun x => cmpLT cmp v x) y✝
vc : All (fun x => cmpLT cmp v x) c✝
right✝ : All (fun x => cmpLT cmp v x) d✝
cy : All (fun x => cmpLT cmp x y✝) c✝
yd : All (fun x => cmpLT cmp y✝ x) d✝
hc : Ordered cmp c✝
hd : Ordered cmp d✝
this :
  Ordered cmp (append b✝ c✝) ∧
    All (fun x => cmpLT cmp x✝ x) (append b✝ c✝) ∧ All (fun x => cmpLT cmp x y✝) (append b✝ c✝)
⊢ Ordered cmp
    (match append b✝ c✝ with
    | node red b' z c' => node red (node black a✝ x✝ b') z (node black c' y✝ d✝)
    | bc => balLeft a✝ x✝ (node black bc y✝ d✝))

tactic: next H =>
have ⟨⟨b'z, c'z, hb', hc'⟩, ⟨xz, xb', _⟩, zy, _, c'y⟩ := H ▸ this
have az := xz.trans_r ax; have zd := zy.trans_l yd
exact ⟨⟨xz, az, b'z⟩, ⟨zy, c'z, zd⟩, ⟨ax, xb', ha, hb'⟩, c'y, yd, hc', hd⟩
state_before: case h_4.h_1
α : Type u_1
cmp : α → α → Ordering
v : α
x✝³ x✝² a✝¹ : RBNode α
x✝¹ : α
b✝¹ c✝ : RBNode α
y✝ : α
d✝ : RBNode α
lv : All (fun x => cmpLT cmp x v) (node black a✝¹ x✝¹ b✝¹)
hl : Ordered cmp (node black a✝¹ x✝¹ b✝¹)
vr : All (fun x => cmpLT cmp v x) (node black c✝ y✝ d✝)
hr : Ordered cmp (node black c✝ y✝ d✝)
xv : (fun x => cmpLT cmp x v) x✝¹
left✝ : All (fun x => cmpLT cmp x v) a✝¹
bv : All (fun x => cmpLT cmp x v) b✝¹
ax : All (fun x => cmpLT cmp x x✝¹) a✝¹
xb : All (fun x => cmpLT cmp x✝¹ x) b✝¹
ha : Ordered cmp a✝¹
hb : Ordered cmp b✝¹
vy : (fun x => cmpLT cmp v x) y✝
vc : All (fun x => cmpLT cmp v x) c✝
right✝ : All (fun x => cmpLT cmp v x) d✝
cy : All (fun x => cmpLT cmp x y✝) c✝
yd : All (fun x => cmpLT cmp y✝ x) d✝
hc : Ordered cmp c✝
hd : Ordered cmp d✝
this :
  Ordered cmp (append b✝¹ c✝) ∧
    All (fun x => cmpLT cmp x✝¹ x) (append b✝¹ c✝) ∧ All (fun x => cmpLT cmp x y✝) (append b✝¹ c✝)
l✝ a✝ : RBNode α
x✝ : α
b✝ : RBNode α
heq✝ : append b✝¹ c✝ = node red a✝ x✝ b✝
⊢ Ordered cmp (node red (node black a✝¹ x✝¹ a✝) x✝ (node black b✝ y✝ d✝))

tactic: have ⟨⟨b'z, c'z, hb', hc'⟩, ⟨xz, xb', _⟩, zy, _, c'y⟩ := H ▸ this
state_before: α : Type u_1
cmp : α → α → Ordering
v : α
x✝³ x✝² a✝¹ : RBNode α
x✝¹ : α
b✝¹ c✝ : RBNode α
y✝ : α
d✝ : RBNode α
lv : All (fun x => cmpLT cmp x v) (node black a✝¹ x✝¹ b✝¹)
hl : Ordered cmp (node black a✝¹ x✝¹ b✝¹)
vr : All (fun x => cmpLT cmp v x) (node black c✝ y✝ d✝)
hr : Ordered cmp (node black c✝ y✝ d✝)
xv : (fun x => cmpLT cmp x v) x✝¹
left✝ : All (fun x => cmpLT cmp x v) a✝¹
bv : All (fun x => cmpLT cmp x v) b✝¹
ax : All (fun x => cmpLT cmp x x✝¹) a✝¹
xb : All (fun x => cmpLT cmp x✝¹ x) b✝¹
ha : Ordered cmp a✝¹
hb : Ordered cmp b✝¹
vy : (fun x => cmpLT cmp v x) y✝
vc : All (fun x => cmpLT cmp v x) c✝
right✝ : All (fun x => cmpLT cmp v x) d✝
cy : All (fun x => cmpLT cmp x y✝) c✝
yd : All (fun x => cmpLT cmp y✝ x) d✝
hc : Ordered cmp c✝
hd : Ordered cmp d✝
this :
  Ordered cmp (append b✝¹ c✝) ∧
    All (fun x => cmpLT cmp x✝¹ x) (append b✝¹ c✝) ∧ All (fun x => cmpLT cmp x y✝) (append b✝¹ c✝)
l✝ a✝ : RBNode α
x✝ : α
b✝ : RBNode α
H : append b✝¹ c✝ = node red a✝ x✝ b✝
⊢ Ordered cmp (node red (node black a✝¹ x✝¹ a✝) x✝ (node black b✝ y✝ d✝))

tactic: have az := xz.trans_r ax
state_before: α : Type u_1
cmp : α → α → Ordering
v : α
x✝³ x✝² a✝¹ : RBNode α
x✝¹ : α
b✝¹ c✝ : RBNode α
y✝ : α
d✝ : RBNode α
lv : All (fun x => cmpLT cmp x v) (node black a✝¹ x✝¹ b✝¹)
hl : Ordered cmp (node black a✝¹ x✝¹ b✝¹)
vr : All (fun x => cmpLT cmp v x) (node black c✝ y✝ d✝)
hr : Ordered cmp (node black c✝ y✝ d✝)
xv : (fun x => cmpLT cmp x v) x✝¹
left✝¹ : All (fun x => cmpLT cmp x v) a✝¹
bv : All (fun x => cmpLT cmp x v) b✝¹
ax : All (fun x => cmpLT cmp x x✝¹) a✝¹
xb : All (fun x => cmpLT cmp x✝¹ x) b✝¹
ha : Ordered cmp a✝¹
hb : Ordered cmp b✝¹
vy : (fun x => cmpLT cmp v x) y✝
vc : All (fun x => cmpLT cmp v x) c✝
right✝¹ : All (fun x => cmpLT cmp v x) d✝
cy : All (fun x => cmpLT cmp x y✝) c✝
yd : All (fun x => cmpLT cmp y✝ x) d✝
hc : Ordered cmp c✝
hd : Ordered cmp d✝
this :
  Ordered cmp (append b✝¹ c✝) ∧
    All (fun x => cmpLT cmp x✝¹ x) (append b✝¹ c✝) ∧ All (fun x => cmpLT cmp x y✝) (append b✝¹ c✝)
l✝ a✝ : RBNode α
x✝ : α
b✝ : RBNode α
H : append b✝¹ c✝ = node red a✝ x✝ b✝
b'z : All (fun x => cmpLT cmp x x✝) a✝
c'z : All (fun x => cmpLT cmp x✝ x) b✝
hb' : Ordered cmp a✝
hc' : Ordered cmp b✝
xz : (fun x => cmpLT cmp x✝¹ x) x✝
xb' : All (fun x => cmpLT cmp x✝¹ x) a✝
right✝ : All (fun x => cmpLT cmp x✝¹ x) b✝
zy : (fun x => cmpLT cmp x y✝) x✝
left✝ : All (fun x => cmpLT cmp x y✝) a✝
c'y : All (fun x => cmpLT cmp x y✝) b✝
⊢ Ordered cmp (node red (node black a✝¹ x✝¹ a✝) x✝ (node black b✝ y✝ d✝))

tactic: have zd := zy.trans_l yd
state_before: α : Type u_1
cmp : α → α → Ordering
v : α
x✝³ x✝² a✝¹ : RBNode α
x✝¹ : α
b✝¹ c✝ : RBNode α
y✝ : α
d✝ : RBNode α
lv : All (fun x => cmpLT cmp x v) (node black a✝¹ x✝¹ b✝¹)
hl : Ordered cmp (node black a✝¹ x✝¹ b✝¹)
vr : All (fun x => cmpLT cmp v x) (node black c✝ y✝ d✝)
hr : Ordered cmp (node black c✝ y✝ d✝)
xv : (fun x => cmpLT cmp x v) x✝¹
left✝¹ : All (fun x => cmpLT cmp x v) a✝¹
bv : All (fun x => cmpLT cmp x v) b✝¹
ax : All (fun x => cmpLT cmp x x✝¹) a✝¹
xb : All (fun x => cmpLT cmp x✝¹ x) b✝¹
ha : Ordered cmp a✝¹
hb : Ordered cmp b✝¹
vy : (fun x => cmpLT cmp v x) y✝
vc : All (fun x => cmpLT cmp v x) c✝
right✝¹ : All (fun x => cmpLT cmp v x) d✝
cy : All (fun x => cmpLT cmp x y✝) c✝
yd : All (fun x => cmpLT cmp y✝ x) d✝
hc : Ordered cmp c✝
hd : Ordered cmp d✝
this :
  Ordered cmp (append b✝¹ c✝) ∧
    All (fun x => cmpLT cmp x✝¹ x) (append b✝¹ c✝) ∧ All (fun x => cmpLT cmp x y✝) (append b✝¹ c✝)
l✝ a✝ : RBNode α
x✝ : α
b✝ : RBNode α
H : append b✝¹ c✝ = node red a✝ x✝ b✝
b'z : All (fun x => cmpLT cmp x x✝) a✝
c'z : All (fun x => cmpLT cmp x✝ x) b✝
hb' : Ordered cmp a✝
hc' : Ordered cmp b✝
xz : (fun x => cmpLT cmp x✝¹ x) x✝
xb' : All (fun x => cmpLT cmp x✝¹ x) a✝
right✝ : All (fun x => cmpLT cmp x✝¹ x) b✝
zy : (fun x => cmpLT cmp x y✝) x✝
left✝ : All (fun x => cmpLT cmp x y✝) a✝
c'y : All (fun x => cmpLT cmp x y✝) b✝
az : All (fun x => cmpLT cmp x x✝) a✝¹
⊢ Ordered cmp (node red (node black a✝¹ x✝¹ a✝) x✝ (node black b✝ y✝ d✝))

tactic: exact ⟨⟨xz, az, b'z⟩, ⟨zy, c'z, zd⟩, ⟨ax, xb', ha, hb'⟩, c'y, yd, hc', hd⟩
state_before: α : Type u_1
cmp : α → α → Ordering
v : α
x✝³ x✝² a✝¹ : RBNode α
x✝¹ : α
b✝¹ c✝ : RBNode α
y✝ : α
d✝ : RBNode α
lv : All (fun x => cmpLT cmp x v) (node black a✝¹ x✝¹ b✝¹)
hl : Ordered cmp (node black a✝¹ x✝¹ b✝¹)
vr : All (fun x => cmpLT cmp v x) (node black c✝ y✝ d✝)
hr : Ordered cmp (node black c✝ y✝ d✝)
xv : (fun x => cmpLT cmp x v) x✝¹
left✝¹ : All (fun x => cmpLT cmp x v) a✝¹
bv : All (fun x => cmpLT cmp x v) b✝¹
ax : All (fun x => cmpLT cmp x x✝¹) a✝¹
xb : All (fun x => cmpLT cmp x✝¹ x) b✝¹
ha : Ordered cmp a✝¹
hb : Ordered cmp b✝¹
vy : (fun x => cmpLT cmp v x) y✝
vc : All (fun x => cmpLT cmp v x) c✝
right✝¹ : All (fun x => cmpLT cmp v x) d✝
cy : All (fun x => cmpLT cmp x y✝) c✝
yd : All (fun x => cmpLT cmp y✝ x) d✝
hc : Ordered cmp c✝
hd : Ordered cmp d✝
this :
  Ordered cmp (append b✝¹ c✝) ∧
    All (fun x => cmpLT cmp x✝¹ x) (append b✝¹ c✝) ∧ All (fun x => cmpLT cmp x y✝) (append b✝¹ c✝)
l✝ a✝ : RBNode α
x✝ : α
b✝ : RBNode α
H : append b✝¹ c✝ = node red a✝ x✝ b✝
b'z : All (fun x => cmpLT cmp x x✝) a✝
c'z : All (fun x => cmpLT cmp x✝ x) b✝
hb' : Ordered cmp a✝
hc' : Ordered cmp b✝
xz : (fun x => cmpLT cmp x✝¹ x) x✝
xb' : All (fun x => cmpLT cmp x✝¹ x) a✝
right✝ : All (fun x => cmpLT cmp x✝¹ x) b✝
zy : (fun x => cmpLT cmp x y✝) x✝
left✝ : All (fun x => cmpLT cmp x y✝) a✝
c'y : All (fun x => cmpLT cmp x y✝) b✝
az : All (fun x => cmpLT cmp x x✝) a✝¹
zd : All (fun x => cmpLT cmp x✝ x) d✝
⊢ Ordered cmp (node red (node black a✝¹ x✝¹ a✝) x✝ (node black b✝ y✝ d✝))

tactic: have ⟨hbc, xbc, bcy⟩ := this
state_before: case h_4.h_2
α : Type u_1
cmp : α → α → Ordering
v : α
x✝³ x✝² a✝ : RBNode α
x✝¹ : α
b✝ c✝ : RBNode α
y✝ : α
d✝ : RBNode α
lv : All (fun x => cmpLT cmp x v) (node black a✝ x✝¹ b✝)
hl : Ordered cmp (node black a✝ x✝¹ b✝)
vr : All (fun x => cmpLT cmp v x) (node black c✝ y✝ d✝)
hr : Ordered cmp (node black c✝ y✝ d✝)
xv : (fun x => cmpLT cmp x v) x✝¹
left✝ : All (fun x => cmpLT cmp x v) a✝
bv : All (fun x => cmpLT cmp x v) b✝
ax : All (fun x => cmpLT cmp x x✝¹) a✝
xb : All (fun x => cmpLT cmp x✝¹ x) b✝
ha : Ordered cmp a✝
hb : Ordered cmp b✝
vy : (fun x => cmpLT cmp v x) y✝
vc : All (fun x => cmpLT cmp v x) c✝
right✝ : All (fun x => cmpLT cmp v x) d✝
cy : All (fun x => cmpLT cmp x y✝) c✝
yd : All (fun x => cmpLT cmp y✝ x) d✝
hc : Ordered cmp c✝
hd : Ordered cmp d✝
this :
  Ordered cmp (append b✝ c✝) ∧
    All (fun x => cmpLT cmp x✝¹ x) (append b✝ c✝) ∧ All (fun x => cmpLT cmp x y✝) (append b✝ c✝)
l✝ : RBNode α
x✝ : ∀ (a : RBNode α) (x : α) (b : RBNode α), append b✝ c✝ = node red a x b → False
⊢ Ordered cmp (balLeft a✝ x✝¹ (node black (append b✝ c✝) y✝ d✝))

tactic: have xy := xv.trans vy
state_before: case h_4.h_2
α : Type u_1
cmp : α → α → Ordering
v : α
x✝³ x✝² a✝ : RBNode α
x✝¹ : α
b✝ c✝ : RBNode α
y✝ : α
d✝ : RBNode α
lv : All (fun x => cmpLT cmp x v) (node black a✝ x✝¹ b✝)
hl : Ordered cmp (node black a✝ x✝¹ b✝)
vr : All (fun x => cmpLT cmp v x) (node black c✝ y✝ d✝)
hr : Ordered cmp (node black c✝ y✝ d✝)
xv : (fun x => cmpLT cmp x v) x✝¹
left✝ : All (fun x => cmpLT cmp x v) a✝
bv : All (fun x => cmpLT cmp x v) b✝
ax : All (fun x => cmpLT cmp x x✝¹) a✝
xb : All (fun x => cmpLT cmp x✝¹ x) b✝
ha : Ordered cmp a✝
hb : Ordered cmp b✝
vy : (fun x => cmpLT cmp v x) y✝
vc : All (fun x => cmpLT cmp v x) c✝
right✝ : All (fun x => cmpLT cmp v x) d✝
cy : All (fun x => cmpLT cmp x y✝) c✝
yd : All (fun x => cmpLT cmp y✝ x) d✝
hc : Ordered cmp c✝
hd : Ordered cmp d✝
this :
  Ordered cmp (append b✝ c✝) ∧
    All (fun x => cmpLT cmp x✝¹ x) (append b✝ c✝) ∧ All (fun x => cmpLT cmp x y✝) (append b✝ c✝)
l✝ : RBNode α
x✝ : ∀ (a : RBNode α) (x : α) (b : RBNode α), append b✝ c✝ = node red a x b → False
hbc : Ordered cmp (append b✝ c✝)
xbc : All (fun x => cmpLT cmp x✝¹ x) (append b✝ c✝)
bcy : All (fun x => cmpLT cmp x y✝) (append b✝ c✝)
⊢ Ordered cmp (balLeft a✝ x✝¹ (node black (append b✝ c✝) y✝ d✝))

tactic: exact ha.balLeft ax ⟨xy, xbc, xy.trans_l yd⟩ ⟨bcy, yd, hbc, hd⟩
state_before: case h_4.h_2
α : Type u_1
cmp : α → α → Ordering
v : α
x✝³ x✝² a✝ : RBNode α
x✝¹ : α
b✝ c✝ : RBNode α
y✝ : α
d✝ : RBNode α
lv : All (fun x => cmpLT cmp x v) (node black a✝ x✝¹ b✝)
hl : Ordered cmp (node black a✝ x✝¹ b✝)
vr : All (fun x => cmpLT cmp v x) (node black c✝ y✝ d✝)
hr : Ordered cmp (node black c✝ y✝ d✝)
xv : (fun x => cmpLT cmp x v) x✝¹
left✝ : All (fun x => cmpLT cmp x v) a✝
bv : All (fun x => cmpLT cmp x v) b✝
ax : All (fun x => cmpLT cmp x x✝¹) a✝
xb : All (fun x => cmpLT cmp x✝¹ x) b✝
ha : Ordered cmp a✝
hb : Ordered cmp b✝
vy : (fun x => cmpLT cmp v x) y✝
vc : All (fun x => cmpLT cmp v x) c✝
right✝ : All (fun x => cmpLT cmp v x) d✝
cy : All (fun x => cmpLT cmp x y✝) c✝
yd : All (fun x => cmpLT cmp y✝ x) d✝
hc : Ordered cmp c✝
hd : Ordered cmp d✝
this :
  Ordered cmp (append b✝ c✝) ∧
    All (fun x => cmpLT cmp x✝¹ x) (append b✝ c✝) ∧ All (fun x => cmpLT cmp x y✝) (append b✝ c✝)
l✝ : RBNode α
x✝ : ∀ (a : RBNode α) (x : α) (b : RBNode α), append b✝ c✝ = node red a x b → False
hbc : Ordered cmp (append b✝ c✝)
xbc : All (fun x => cmpLT cmp x✝¹ x) (append b✝ c✝)
bcy : All (fun x => cmpLT cmp x y✝) (append b✝ c✝)
xy : cmpLT cmp x✝¹ y✝
⊢ Ordered cmp (balLeft a✝ x✝¹ (node black (append b✝ c✝) y✝ d✝))

tactic: have ⟨vx, vb, _⟩ := vr
state_before: case h_5
α : Type u_1
cmp : α → α → Ordering
v : α
x✝² x✝¹ l✝ : RBNode α
v✝ : α
r✝ b✝ : RBNode α
x✝ : α
c✝ : RBNode α
lv : All (fun x => cmpLT cmp x v) (node black l✝ v✝ r✝)
hl : Ordered cmp (node black l✝ v✝ r✝)
vr : All (fun x => cmpLT cmp v x) (node red b✝ x✝ c✝)
hr : Ordered cmp (node red b✝ x✝ c✝)
⊢ Ordered cmp (node red (append (node black l✝ v✝ r✝) b✝) x✝ c✝)

tactic: have ⟨bx, yc, hb, hc⟩ := hr
state_before: case h_5
α : Type u_1
cmp : α → α → Ordering
v : α
x✝² x✝¹ l✝ : RBNode α
v✝ : α
r✝ b✝ : RBNode α
x✝ : α
c✝ : RBNode α
lv : All (fun x => cmpLT cmp x v) (node black l✝ v✝ r✝)
hl : Ordered cmp (node black l✝ v✝ r✝)
vr : All (fun x => cmpLT cmp v x) (node red b✝ x✝ c✝)
hr : Ordered cmp (node red b✝ x✝ c✝)
vx : (fun x => cmpLT cmp v x) x✝
vb : All (fun x => cmpLT cmp v x) b✝
right✝ : All (fun x => cmpLT cmp v x) c✝
⊢ Ordered cmp (node red (append (node black l✝ v✝ r✝) b✝) x✝ c✝)

tactic: exact ⟨(vx.trans_r lv).append bx, yc, hl.append lv vb hb, hc⟩
state_before: case h_5
α : Type u_1
cmp : α → α → Ordering
v : α
x✝² x✝¹ l✝ : RBNode α
v✝ : α
r✝ b✝ : RBNode α
x✝ : α
c✝ : RBNode α
lv : All (fun x => cmpLT cmp x v) (node black l✝ v✝ r✝)
hl : Ordered cmp (node black l✝ v✝ r✝)
vr : All (fun x => cmpLT cmp v x) (node red b✝ x✝ c✝)
hr : Ordered cmp (node red b✝ x✝ c✝)
vx : (fun x => cmpLT cmp v x) x✝
vb : All (fun x => cmpLT cmp v x) b✝
right✝ : All (fun x => cmpLT cmp v x) c✝
bx : All (fun x => cmpLT cmp x x✝) b✝
yc : All (fun x => cmpLT cmp x✝ x) c✝
hb : Ordered cmp b✝
hc : Ordered cmp c✝
⊢ Ordered cmp (node red (append (node black l✝ v✝ r✝) b✝) x✝ c✝)

tactic: have ⟨xv, _, bv⟩ := lv
state_before: case h_6
α : Type u_1
cmp : α → α → Ordering
v : α
x✝² x✝¹ a✝ : RBNode α
x✝ : α
b✝ l✝ : RBNode α
v✝ : α
r✝ : RBNode α
lv : All (fun x => cmpLT cmp x v) (node red a✝ x✝ b✝)
hl : Ordered cmp (node red a✝ x✝ b✝)
vr : All (fun x => cmpLT cmp v x) (node black l✝ v✝ r✝)
hr : Ordered cmp (node black l✝ v✝ r✝)
⊢ Ordered cmp (node red a✝ x✝ (append b✝ (node black l✝ v✝ r✝)))

tactic: have ⟨ax, xb, ha, hb⟩ := hl
state_before: case h_6
α : Type u_1
cmp : α → α → Ordering
v : α
x✝² x✝¹ a✝ : RBNode α
x✝ : α
b✝ l✝ : RBNode α
v✝ : α
r✝ : RBNode α
lv : All (fun x => cmpLT cmp x v) (node red a✝ x✝ b✝)
hl : Ordered cmp (node red a✝ x✝ b✝)
vr : All (fun x => cmpLT cmp v x) (node black l✝ v✝ r✝)
hr : Ordered cmp (node black l✝ v✝ r✝)
xv : (fun x => cmpLT cmp x v) x✝
left✝ : All (fun x => cmpLT cmp x v) a✝
bv : All (fun x => cmpLT cmp x v) b✝
⊢ Ordered cmp (node red a✝ x✝ (append b✝ (node black l✝ v✝ r✝)))

tactic: exact ⟨ax, xb.append (xv.trans_l vr), ha, hb.append bv vr hr⟩
state_before: case h_6
α : Type u_1
cmp : α → α → Ordering
v : α
x✝² x✝¹ a✝ : RBNode α
x✝ : α
b✝ l✝ : RBNode α
v✝ : α
r✝ : RBNode α
lv : All (fun x => cmpLT cmp x v) (node red a✝ x✝ b✝)
hl : Ordered cmp (node red a✝ x✝ b✝)
vr : All (fun x => cmpLT cmp v x) (node black l✝ v✝ r✝)
hr : Ordered cmp (node black l✝ v✝ r✝)
xv : (fun x => cmpLT cmp x v) x✝
left✝ : All (fun x => cmpLT cmp x v) a✝
bv : All (fun x => cmpLT cmp x v) b✝
ax : All (fun x => cmpLT cmp x x✝) a✝
xb : All (fun x => cmpLT cmp x✝ x) b✝
ha : Ordered cmp a✝
hb : Ordered cmp b✝
⊢ Ordered cmp (node red a✝ x✝ (append b✝ (node black l✝ v✝ r✝)))