α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
l r : RBNode α
hl : Balanced l c₁ n
hr : Balanced r c₂ n
⊢ RedRed (c₁ = black → c₂ ≠ black)
    (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))
    n
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
l r : RBNode α
hl : Balanced l c₁ n
hr : Balanced r c₂ n
⊢ RedRed (c₁ = black → c₂ ≠ black) (append l r) n
unfold append
case h_1
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
r : RBNode α
hr : Balanced r c₂ n
x✝¹ x✝ : RBNode α
hl : Balanced nil c₁ n
⊢ RedRed (c₁ = black → c₂ ≠ black) r n

case h_2
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
l : RBNode α
hl : Balanced l c₁ n
x✝² x✝¹ : RBNode α
x✝ : l = nil → False
hr : Balanced nil c₂ n
⊢ RedRed (c₁ = black → c₂ ≠ black) l n

case h_3
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝² x✝¹ a✝ : RBNode α
x✝ : α
b✝ c✝ : RBNode α
y✝ : α
d✝ : RBNode α
hl : Balanced (node red a✝ x✝ b✝) c₁ n
hr : Balanced (node red c✝ y✝ d✝) c₂ n
⊢ RedRed (c₁ = black → c₂ ≠ black)
    (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✝))
    n

case h_4
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝² x✝¹ a✝ : RBNode α
x✝ : α
b✝ c✝ : RBNode α
y✝ : α
d✝ : RBNode α
hl : Balanced (node black a✝ x✝ b✝) c₁ n
hr : Balanced (node black c✝ y✝ d✝) c₂ n
⊢ RedRed (c₁ = black → c₂ ≠ black)
    (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✝))
    n

case h_5
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝² x✝¹ l✝ : RBNode α
v✝ : α
r✝ b✝ : RBNode α
x✝ : α
c✝ : RBNode α
hl : Balanced (node black l✝ v✝ r✝) c₁ n
hr : Balanced (node red b✝ x✝ c✝) c₂ n
⊢ RedRed (c₁ = black → c₂ ≠ black) (node red (append (node black l✝ v✝ r✝) b✝) x✝ c✝) n

case h_6
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝² x✝¹ a✝ : RBNode α
x✝ : α
b✝ l✝ : RBNode α
v✝ : α
r✝ : RBNode α
hl : Balanced (node red a✝ x✝ b✝) c₁ n
hr : Balanced (node black l✝ v✝ r✝) c₂ n
⊢ RedRed (c₁ = black → c₂ ≠ black) (node red a✝ x✝ (append b✝ (node black l✝ v✝ r✝))) n
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
l r : RBNode α
hl : Balanced l c₁ n
hr : Balanced r c₂ n
⊢ RedRed (c₁ = black → c₂ ≠ black)
    (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))
    n
split
no goals
case h_1
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
r : RBNode α
hr : Balanced r c₂ n
x✝¹ x✝ : RBNode α
hl : Balanced nil c₁ n
⊢ RedRed (c₁ = black → c₂ ≠ black) r n
exact .balanced hr
no goals
case h_2
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
l : RBNode α
hl : Balanced l c₁ n
x✝² x✝¹ : RBNode α
x✝ : l = nil → False
hr : Balanced nil c₂ n
⊢ RedRed (c₁ = black → c₂ ≠ black) l n
exact .balanced hl
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝² x✝¹ a✝ : RBNode α
x✝ : α
b c : RBNode α
y✝ : α
d✝ : RBNode α
hl : Balanced (node red a✝ x✝ b) c₁ n
hr : Balanced (node red c y✝ d✝) c₂ n
ha : Balanced a✝ black n
hb : Balanced b black n
⊢ RedRed (red = black → c₂ ≠ black)
    (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✝))
    n
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝² x✝¹ a✝ : RBNode α
x✝ : α
b c : RBNode α
y✝ : α
d✝ : RBNode α
hl : Balanced (node red a✝ x✝ b) c₁ n
hr : Balanced (node red c y✝ d✝) c₂ n
⊢ RedRed (c₁ = black → c₂ ≠ black)
    (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✝))
    n
have .red ha hb := hl
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝² x✝¹ a✝ : RBNode α
x✝ : α
b c : RBNode α
y✝ : α
d✝ : RBNode α
hl : Balanced (node red a✝ x✝ b) c₁ n
hr : Balanced (node red c y✝ d✝) c₂ n
ha : Balanced a✝ black n
hb : Balanced b black n
hc : Balanced c black n
hd : Balanced d✝ black n
⊢ RedRed (red = black → red ≠ black)
    (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✝))
    n
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝² x✝¹ a✝ : RBNode α
x✝ : α
b c : RBNode α
y✝ : α
d✝ : RBNode α
hl : Balanced (node red a✝ x✝ b) c₁ n
hr : Balanced (node red c y✝ d✝) c₂ n
ha : Balanced a✝ black n
hb : Balanced b black n
⊢ RedRed (red = black → c₂ ≠ black)
    (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✝))
    n
have .red hc hd := hr
case h_1
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝³ x✝² a✝¹ : RBNode α
x✝¹ : α
b c : RBNode α
y✝ : α
d✝ : RBNode α
hl : Balanced (node red a✝¹ x✝¹ b) c₁ n
hr : Balanced (node red c y✝ d✝) c₂ n
ha : Balanced a✝¹ black n
hb : Balanced b black n
hc : Balanced c black n
hd : Balanced d✝ black n
w✝ : RBColor
IH : Balanced (append b c) w✝ n
l✝ a✝ : RBNode α
x✝ : α
b✝ : RBNode α
heq✝ : append b c = node red a✝ x✝ b✝
⊢ RedRed (red = black → red ≠ black) (node red (node red a✝¹ x✝¹ a✝) x✝ (node red b✝ y✝ d✝)) n

case h_2
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝³ x✝² a✝ : RBNode α
x✝¹ : α
b c : RBNode α
y✝ : α
d✝ : RBNode α
hl : Balanced (node red a✝ x✝¹ b) c₁ n
hr : Balanced (node red c y✝ d✝) c₂ n
ha : Balanced a✝ black n
hb : Balanced b black n
hc : Balanced c black n
hd : Balanced d✝ black n
w✝ : RBColor
IH : Balanced (append b c) w✝ n
l✝ : RBNode α
x✝ : ∀ (a : RBNode α) (x : α) (b_1 : RBNode α), append b c = node red a x b_1 → False
⊢ RedRed (red = black → red ≠ black) (node red a✝ x✝¹ (node red (append b c) y✝ d✝)) n
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝² x✝¹ a✝ : RBNode α
x✝ : α
b c : RBNode α
y✝ : α
d✝ : RBNode α
hl : Balanced (node red a✝ x✝ b) c₁ n
hr : Balanced (node red c y✝ d✝) c₂ n
ha : Balanced a✝ black n
hb : Balanced b black n
hc : Balanced c black n
hd : Balanced d✝ black n
w✝ : RBColor
IH : Balanced (append b c) w✝ n
⊢ RedRed (red = black → red ≠ black)
    (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✝))
    n
split
no goals
case h_1
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝³ x✝² a✝¹ : RBNode α
x✝¹ : α
b c : RBNode α
y✝ : α
d✝ : RBNode α
hl : Balanced (node red a✝¹ x✝¹ b) c₁ n
hr : Balanced (node red c y✝ d✝) c₂ n
ha : Balanced a✝¹ black n
hb : Balanced b black n
hc : Balanced c black n
hd : Balanced d✝ black n
w✝ : RBColor
IH : Balanced (append b c) w✝ n
l✝ a✝ : RBNode α
x✝ : α
b✝ : RBNode α
heq✝ : append b c = node red a✝ x✝ b✝
⊢ RedRed (red = black → red ≠ black) (node red (node red a✝¹ x✝¹ a✝) x✝ (node red b✝ y✝ d✝)) n
next e =>
have .red hb' hc' := e ▸ IH
exact .redred (fun.) (.red ha hb') (.red hc' hd)
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝³ x✝² a✝¹ : RBNode α
x✝¹ : α
b c : RBNode α
y✝ : α
d✝ : RBNode α
hl : Balanced (node red a✝¹ x✝¹ b) c₁ n
hr : Balanced (node red c y✝ d✝) c₂ n
ha : Balanced a✝¹ black n
hb : Balanced b black n
hc : Balanced c black n
hd : Balanced d✝ black n
l✝ a✝ : RBNode α
x✝ : α
b✝ : RBNode α
e : append b c = node red a✝ x✝ b✝
hb' : Balanced a✝ black n
hc' : Balanced b✝ black n
IH : Balanced (append b c) red n
⊢ RedRed (red = black → red ≠ black) (node red (node red a✝¹ x✝¹ a✝) x✝ (node red b✝ y✝ d✝)) n
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝³ x✝² a✝¹ : RBNode α
x✝¹ : α
b c : RBNode α
y✝ : α
d✝ : RBNode α
hl : Balanced (node red a✝¹ x✝¹ b) c₁ n
hr : Balanced (node red c y✝ d✝) c₂ n
ha : Balanced a✝¹ black n
hb : Balanced b black n
hc : Balanced c black n
hd : Balanced d✝ black n
w✝ : RBColor
IH : Balanced (append b c) w✝ n
l✝ a✝ : RBNode α
x✝ : α
b✝ : RBNode α
e : append b c = node red a✝ x✝ b✝
⊢ RedRed (red = black → red ≠ black) (node red (node red a✝¹ x✝¹ a✝) x✝ (node red b✝ y✝ d✝)) n
have .red hb' hc' := e ▸ IH
no goals
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝³ x✝² a✝¹ : RBNode α
x✝¹ : α
b c : RBNode α
y✝ : α
d✝ : RBNode α
hl : Balanced (node red a✝¹ x✝¹ b) c₁ n
hr : Balanced (node red c y✝ d✝) c₂ n
ha : Balanced a✝¹ black n
hb : Balanced b black n
hc : Balanced c black n
hd : Balanced d✝ black n
l✝ a✝ : RBNode α
x✝ : α
b✝ : RBNode α
e : append b c = node red a✝ x✝ b✝
hb' : Balanced a✝ black n
hc' : Balanced b✝ black n
IH : Balanced (append b c) red n
⊢ RedRed (red = black → red ≠ black) (node red (node red a✝¹ x✝¹ a✝) x✝ (node red b✝ y✝ d✝)) n
exact .redred (fun.) (.red ha hb') (.red hc' hd)
no goals
case h_2
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝³ x✝² a✝ : RBNode α
x✝¹ : α
b c : RBNode α
y✝ : α
d✝ : RBNode α
hl : Balanced (node red a✝ x✝¹ b) c₁ n
hr : Balanced (node red c y✝ d✝) c₂ n
ha : Balanced a✝ black n
hb : Balanced b black n
hc : Balanced c black n
hd : Balanced d✝ black n
w✝ : RBColor
IH : Balanced (append b c) w✝ n
l✝ : RBNode α
x✝ : ∀ (a : RBNode α) (x : α) (b_1 : RBNode α), append b c = node red a x b_1 → False
⊢ RedRed (red = black → red ≠ black) (node red a✝ x✝¹ (node red (append b c) y✝ d✝)) n
next bcc _ H =>
match bcc, append b c, IH, H with
| black, _, IH, _ => exact .redred (fun.) ha (.red IH hd)
| red, _, .red .., H => cases H _ _ _ rfl
no goals
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝² x✝¹ a✝ : RBNode α
x✝ : α
b c : RBNode α
y✝ : α
d✝ : RBNode α
hl : Balanced (node red a✝ x✝ b) c₁ n
hr : Balanced (node red c y✝ d✝) c₂ n
ha : Balanced a✝ black n
hb : Balanced b black n
hc : Balanced c black n
hd : Balanced d✝ black n
bcc : RBColor
IH : Balanced (append b c) bcc n
l✝ : RBNode α
H : ∀ (a : RBNode α) (x : α) (b_1 : RBNode α), append b c = node red a x b_1 → False
⊢ RedRed (red = black → red ≠ black) (node red a✝ x✝ (node red (append b c) y✝ d✝)) n
match bcc, append b c, IH, H with
| black, _, IH, _ => exact .redred (fun.) ha (.red IH hd)
| red, _, .red .., H => cases H _ _ _ rfl
no goals
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝⁴ x✝³ a✝ : RBNode α
x✝² : α
b c : RBNode α
y✝ : α
d✝ : RBNode α
hl : Balanced (node red a✝ x✝² b) c₁ n
hr : Balanced (node red c y✝ d✝) c₂ n
ha : Balanced a✝ black n
hb : Balanced b black n
hc : Balanced c black n
hd : Balanced d✝ black n
bcc : RBColor
IH✝ : Balanced (append b c) bcc n
l✝ : RBNode α
H : ∀ (a : RBNode α) (x : α) (b_1 : RBNode α), append b c = node red a x b_1 → False
x✝¹ : RBNode α
IH : Balanced x✝¹ black n
x✝ : ∀ (a : RBNode α) (x : α) (b : RBNode α), x✝¹ = node red a x b → False
⊢ RedRed (red = black → red ≠ black) (node red a✝ x✝² (node red x✝¹ y✝ d✝)) n
exact .redred (fun.) ha (.red IH hd)
no goals
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝³ x✝² a✝² : RBNode α
x✝¹ : α
b c : RBNode α
y✝¹ : α
d✝ : RBNode α
hl : Balanced (node red a✝² x✝¹ b) c₁ n
hr : Balanced (node red c y✝¹ d✝) c₂ n
ha : Balanced a✝² black n
hb : Balanced b black n
hc : Balanced c black n
hd : Balanced d✝ black n
bcc : RBColor
IH : Balanced (append b c) bcc n
l✝ : RBNode α
H✝ : ∀ (a : RBNode α) (x : α) (b_1 : RBNode α), append b c = node red a x b_1 → False
x✝ y✝ : RBNode α
v✝ : α
a✝¹ : Balanced x✝ black n
a✝ : Balanced y✝ black n
H : ∀ (a : RBNode α) (x : α) (b : RBNode α), node red x✝ v✝ y✝ = node red a x b → False
⊢ RedRed (red = black → red ≠ black) (node red a✝² x✝¹ (node red (node red x✝ v✝ y✝) y✝¹ d✝)) n
cases H _ _ _ rfl
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝² x✝¹ a✝ : RBNode α
x✝ : α
b c : RBNode α
y✝ : α
d✝ : RBNode α
hl : Balanced (node black a✝ x✝ b) c₁ n
c₁✝ : RBColor
n✝ : Nat
c₂✝ : RBColor
ha : Balanced a✝ c₁✝ n✝
hb : Balanced b c₂✝ n✝
hr : Balanced (node black c y✝ d✝) c₂ (n✝ + 1)
⊢ RedRed (black = black → c₂ ≠ black)
    (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✝))
    (n✝ + 1)
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝² x✝¹ a✝ : RBNode α
x✝ : α
b c : RBNode α
y✝ : α
d✝ : RBNode α
hl : Balanced (node black a✝ x✝ b) c₁ n
hr : Balanced (node black c y✝ d✝) c₂ n
⊢ RedRed (c₁ = black → c₂ ≠ black)
    (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✝))
    n
have .black ha hb := hl
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝² x✝¹ a✝ : RBNode α
x✝ : α
b c : RBNode α
y✝ : α
d✝ : RBNode α
hl : Balanced (node black a✝ x✝ b) c₁ n
c₁✝¹ : RBColor
n✝ : Nat
c₂✝¹ : RBColor
ha : Balanced a✝ c₁✝¹ n✝
hb : Balanced b c₂✝¹ n✝
hr : Balanced (node black c y✝ d✝) c₂ (n✝ + 1)
c₁✝ c₂✝ : RBColor
hc : Balanced c c₁✝ n✝
hd : Balanced d✝ c₂✝ n✝
⊢ RedRed (black = black → black ≠ black)
    (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✝))
    (n✝ + 1)
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝² x✝¹ a✝ : RBNode α
x✝ : α
b c : RBNode α
y✝ : α
d✝ : RBNode α
hl : Balanced (node black a✝ x✝ b) c₁ n
c₁✝ : RBColor
n✝ : Nat
c₂✝ : RBColor
ha : Balanced a✝ c₁✝ n✝
hb : Balanced b c₂✝ n✝
hr : Balanced (node black c y✝ d✝) c₂ (n✝ + 1)
⊢ RedRed (black = black → c₂ ≠ black)
    (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✝))
    (n✝ + 1)
have .black hc hd := hr
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝² x✝¹ a✝ : RBNode α
x✝ : α
b c : RBNode α
y✝ : α
d✝ : RBNode α
hl : Balanced (node black a✝ x✝ b) c₁ n
c₁✝¹ : RBColor
n✝ : Nat
c₂✝¹ : RBColor
ha : Balanced a✝ c₁✝¹ n✝
hb : Balanced b c₂✝¹ n✝
hr : Balanced (node black c y✝ d✝) c₂ (n✝ + 1)
c₁✝ c₂✝ : RBColor
hc : Balanced c c₁✝ n✝
hd : Balanced d✝ c₂✝ n✝
IH : RedRed (c₂✝¹ = black → c₁✝ ≠ black) (append b c) n✝
⊢ RedRed (black = black → black ≠ black)
    (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✝))
    (n✝ + 1)
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝² x✝¹ a✝ : RBNode α
x✝ : α
b c : RBNode α
y✝ : α
d✝ : RBNode α
hl : Balanced (node black a✝ x✝ b) c₁ n
c₁✝¹ : RBColor
n✝ : Nat
c₂✝¹ : RBColor
ha : Balanced a✝ c₁✝¹ n✝
hb : Balanced b c₂✝¹ n✝
hr : Balanced (node black c y✝ d✝) c₂ (n✝ + 1)
c₁✝ c₂✝ : RBColor
hc : Balanced c c₁✝ n✝
hd : Balanced d✝ c₂✝ n✝
⊢ RedRed (black = black → black ≠ black)
    (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✝))
    (n✝ + 1)
have IH := hb.append hc
case h_1
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝³ x✝² a✝¹ : RBNode α
x✝¹ : α
b c : RBNode α
y✝ : α
d✝ : RBNode α
hl : Balanced (node black a✝¹ x✝¹ b) c₁ n
c₁✝¹ : RBColor
n✝ : Nat
c₂✝¹ : RBColor
ha : Balanced a✝¹ c₁✝¹ n✝
hb : Balanced b c₂✝¹ n✝
hr : Balanced (node black c y✝ d✝) c₂ (n✝ + 1)
c₁✝ c₂✝ : RBColor
hc : Balanced c c₁✝ n✝
hd : Balanced d✝ c₂✝ n✝
IH : RedRed (c₂✝¹ = black → c₁✝ ≠ black) (append b c) n✝
l✝ a✝ : RBNode α
x✝ : α
b✝ : RBNode α
heq✝ : append b c = node red a✝ x✝ b✝
⊢ RedRed (black = black → black ≠ black) (node red (node black a✝¹ x✝¹ a✝) x✝ (node black b✝ y✝ d✝)) (n✝ + 1)

case h_2
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝³ x✝² a✝ : RBNode α
x✝¹ : α
b c : RBNode α
y✝ : α
d✝ : RBNode α
hl : Balanced (node black a✝ x✝¹ b) c₁ n
c₁✝¹ : RBColor
n✝ : Nat
c₂✝¹ : RBColor
ha : Balanced a✝ c₁✝¹ n✝
hb : Balanced b c₂✝¹ n✝
hr : Balanced (node black c y✝ d✝) c₂ (n✝ + 1)
c₁✝ c₂✝ : RBColor
hc : Balanced c c₁✝ n✝
hd : Balanced d✝ c₂✝ n✝
IH : RedRed (c₂✝¹ = black → c₁✝ ≠ black) (append b c) n✝
l✝ : RBNode α
x✝ : ∀ (a : RBNode α) (x : α) (b_1 : RBNode α), append b c = node red a x b_1 → False
⊢ RedRed (black = black → black ≠ black) (balLeft a✝ x✝¹ (node black (append b c) y✝ d✝)) (n✝ + 1)
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝² x✝¹ a✝ : RBNode α
x✝ : α
b c : RBNode α
y✝ : α
d✝ : RBNode α
hl : Balanced (node black a✝ x✝ b) c₁ n
c₁✝¹ : RBColor
n✝ : Nat
c₂✝¹ : RBColor
ha : Balanced a✝ c₁✝¹ n✝
hb : Balanced b c₂✝¹ n✝
hr : Balanced (node black c y✝ d✝) c₂ (n✝ + 1)
c₁✝ c₂✝ : RBColor
hc : Balanced c c₁✝ n✝
hd : Balanced d✝ c₂✝ n✝
IH : RedRed (c₂✝¹ = black → c₁✝ ≠ black) (append b c) n✝
⊢ RedRed (black = black → black ≠ black)
    (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✝))
    (n✝ + 1)
split
no goals
case h_1
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝³ x✝² a✝¹ : RBNode α
x✝¹ : α
b c : RBNode α
y✝ : α
d✝ : RBNode α
hl : Balanced (node black a✝¹ x✝¹ b) c₁ n
c₁✝¹ : RBColor
n✝ : Nat
c₂✝¹ : RBColor
ha : Balanced a✝¹ c₁✝¹ n✝
hb : Balanced b c₂✝¹ n✝
hr : Balanced (node black c y✝ d✝) c₂ (n✝ + 1)
c₁✝ c₂✝ : RBColor
hc : Balanced c c₁✝ n✝
hd : Balanced d✝ c₂✝ n✝
IH : RedRed (c₂✝¹ = black → c₁✝ ≠ black) (append b c) n✝
l✝ a✝ : RBNode α
x✝ : α
b✝ : RBNode α
heq✝ : append b c = node red a✝ x✝ b✝
⊢ RedRed (black = black → black ≠ black) (node red (node black a✝¹ x✝¹ a✝) x✝ (node black b✝ y✝ d✝)) (n✝ + 1)
next e => match e ▸ IH with
| .balanced (.red hb' hc') | .redred _ hb' hc' =>
  exact .balanced (.red (.black ha hb') (.black hc' hd))
no goals
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝³ x✝² a✝¹ : RBNode α
x✝¹ : α
b c : RBNode α
y✝ : α
d✝ : RBNode α
hl : Balanced (node black a✝¹ x✝¹ b) c₁ n
c₁✝¹ : RBColor
n✝ : Nat
c₂✝¹ : RBColor
ha : Balanced a✝¹ c₁✝¹ n✝
hb : Balanced b c₂✝¹ n✝
hr : Balanced (node black c y✝ d✝) c₂ (n✝ + 1)
c₁✝ c₂✝ : RBColor
hc : Balanced c c₁✝ n✝
hd : Balanced d✝ c₂✝ n✝
IH : RedRed (c₂✝¹ = black → c₁✝ ≠ black) (append b c) n✝
l✝ a✝ : RBNode α
x✝ : α
b✝ : RBNode α
e : append b c = node red a✝ x✝ b✝
⊢ RedRed (black = black → black ≠ black) (node red (node black a✝¹ x✝¹ a✝) x✝ (node black b✝ y✝ d✝)) (n✝ + 1)
match e ▸ IH with
| .balanced (.red hb' hc') | .redred _ hb' hc' =>
exact .balanced (.red (.black ha hb') (.black hc' hd))
no goals
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝³ x✝² a✝² : RBNode α
x✝¹ : α
b c : RBNode α
y✝ : α
d✝ : RBNode α
hl : Balanced (node black a✝² x✝¹ b) c₁ n
c₁✝² : RBColor
n✝ : Nat
c₂✝² : RBColor
ha : Balanced a✝² c₁✝² n✝
hb : Balanced b c₂✝² n✝
hr : Balanced (node black c y✝ d✝) c₂ (n✝ + 1)
c₁✝¹ c₂✝¹ : RBColor
hc : Balanced c c₁✝¹ n✝
hd : Balanced d✝ c₂✝¹ n✝
IH : RedRed (c₂✝² = black → c₁✝¹ ≠ black) (append b c) n✝
l✝ a✝¹ : RBNode α
x✝ : α
b✝ : RBNode α
e : append b c = node red a✝¹ x✝ b✝
c₁✝ c₂✝ : RBColor
a✝ : c₂✝² = black → c₁✝¹ ≠ black
hb' : Balanced a✝¹ c₁✝ n✝
hc' : Balanced b✝ c₂✝ n✝
⊢ RedRed (black = black → black ≠ black) (node red (node black a✝² x✝¹ a✝¹) x✝ (node black b✝ y✝ d✝)) (n✝ + 1)
exact .balanced (.red (.black ha hb') (.black hc' hd))
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝³ x✝² a✝ : RBNode α
x✝¹ : α
b c : RBNode α
y✝ : α
d✝ : RBNode α
hl : Balanced (node black a✝ x✝¹ b) c₁ n
c₁✝¹ : RBColor
n✝ : Nat
c₂✝¹ : RBColor
ha : Balanced a✝ c₁✝¹ n✝
hb : Balanced b c₂✝¹ n✝
hr : Balanced (node black c y✝ d✝) c₂ (n✝ + 1)
c₁✝ c₂✝ : RBColor
hc : Balanced c c₁✝ n✝
hd : Balanced d✝ c₂✝ n✝
IH : RedRed (c₂✝¹ = black → c₁✝ ≠ black) (append b c) n✝
l✝ : RBNode α
H : ∀ (a : RBNode α) (x : α) (b_1 : RBNode α), append b c = node red a x b_1 → False
bc : RBNode α
c✝ : RBColor
hbc : Balanced bc c✝ n✝
x✝ : ∀ (a : RBNode α) (x : α) (b : RBNode α), bc = node red a x b → False
⊢ RedRed (black = black → black ≠ black)
    (match a✝ with
    | node red a x b => node red (node black a x b) x✝¹ (node black bc y✝ d✝)
    | l =>
      match node black bc y✝ d✝ with
      | node black a y b => balance2 l x✝¹ (node red a y b)
      | node red (node black a y b) z c => node red (node black l x✝¹ a) y (balance2 b z (setRed c))
      | r => node red l x✝¹ r)
    (n✝ + 1)
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝³ x✝² a✝ : RBNode α
x✝¹ : α
b c : RBNode α
y✝ : α
d✝ : RBNode α
hl : Balanced (node black a✝ x✝¹ b) c₁ n
c₁✝¹ : RBColor
n✝ : Nat
c₂✝¹ : RBColor
ha : Balanced a✝ c₁✝¹ n✝
hb : Balanced b c₂✝¹ n✝
hr : Balanced (node black c y✝ d✝) c₂ (n✝ + 1)
c₁✝ c₂✝ : RBColor
hc : Balanced c c₁✝ n✝
hd : Balanced d✝ c₂✝ n✝
IH : RedRed (c₂✝¹ = black → c₁✝ ≠ black) (append b c) n✝
l✝ : RBNode α
H : ∀ (a : RBNode α) (x : α) (b_1 : RBNode α), append b c = node red a x b_1 → False
bc : RBNode α
c✝ : RBColor
hbc : Balanced bc c✝ n✝
x✝ : ∀ (a : RBNode α) (x : α) (b : RBNode α), bc = node red a x b → False
⊢ RedRed (black = black → black ≠ black) (balLeft a✝ x✝¹ (node black bc y✝ d✝)) (n✝ + 1)
unfold balLeft
case h_1
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝⁴ x✝³ : RBNode α
x✝² : α
b c : RBNode α
y✝ : α
d✝ : RBNode α
c₁✝¹ : RBColor
n✝ : Nat
c₂✝¹ : RBColor
hb : Balanced b c₂✝¹ n✝
hr : Balanced (node black c y✝ d✝) c₂ (n✝ + 1)
c₁✝ c₂✝ : RBColor
hc : Balanced c c₁✝ n✝
hd : Balanced d✝ c₂✝ n✝
IH : RedRed (c₂✝¹ = black → c₁✝ ≠ black) (append b c) n✝
l✝¹ : RBNode α
H : ∀ (a : RBNode α) (x : α) (b_1 : RBNode α), append b c = node red a x b_1 → False
bc : RBNode α
c✝ : RBColor
hbc : Balanced bc c✝ n✝
x✝¹ : ∀ (a : RBNode α) (x : α) (b : RBNode α), bc = node red a x b → False
l✝ a✝ : RBNode α
x✝ : α
b✝ : RBNode α
hl : Balanced (node black (node red a✝ x✝ b✝) x✝² b) c₁ n
ha : Balanced (node red a✝ x✝ b✝) c₁✝¹ n✝
⊢ RedRed (black = black → black ≠ black) (node red (node black a✝ x✝ b✝) x✝² (node black bc y✝ d✝)) (n✝ + 1)

case h_2
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝⁴ x✝³ a✝ : RBNode α
x✝² : α
b c : RBNode α
y✝ : α
d✝ : RBNode α
hl : Balanced (node black a✝ x✝² b) c₁ n
c₁✝¹ : RBColor
n✝ : Nat
c₂✝¹ : RBColor
ha : Balanced a✝ c₁✝¹ n✝
hb : Balanced b c₂✝¹ n✝
hr : Balanced (node black c y✝ d✝) c₂ (n✝ + 1)
c₁✝ c₂✝ : RBColor
hc : Balanced c c₁✝ n✝
hd : Balanced d✝ c₂✝ n✝
IH : RedRed (c₂✝¹ = black → c₁✝ ≠ black) (append b c) n✝
l✝¹ : RBNode α
H : ∀ (a : RBNode α) (x : α) (b_1 : RBNode α), append b c = node red a x b_1 → False
bc : RBNode α
c✝ : RBColor
hbc : Balanced bc c✝ n✝
x✝¹ : ∀ (a : RBNode α) (x : α) (b : RBNode α), bc = node red a x b → False
l✝ : RBNode α
x✝ : ∀ (a : RBNode α) (x : α) (b : RBNode α), a✝ = node red a x b → False
⊢ RedRed (black = black → black ≠ black)
    (match node black bc y✝ d✝ with
    | node black a y b => balance2 a✝ x✝² (node red a y b)
    | node red (node black a y b) z c => node red (node black a✝ x✝² a) y (balance2 b z (setRed c))
    | r => node red a✝ x✝² r)
    (n✝ + 1)
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝³ x✝² a✝ : RBNode α
x✝¹ : α
b c : RBNode α
y✝ : α
d✝ : RBNode α
hl : Balanced (node black a✝ x✝¹ b) c₁ n
c₁✝¹ : RBColor
n✝ : Nat
c₂✝¹ : RBColor
ha : Balanced a✝ c₁✝¹ n✝
hb : Balanced b c₂✝¹ n✝
hr : Balanced (node black c y✝ d✝) c₂ (n✝ + 1)
c₁✝ c₂✝ : RBColor
hc : Balanced c c₁✝ n✝
hd : Balanced d✝ c₂✝ n✝
IH : RedRed (c₂✝¹ = black → c₁✝ ≠ black) (append b c) n✝
l✝ : RBNode α
H : ∀ (a : RBNode α) (x : α) (b_1 : RBNode α), append b c = node red a x b_1 → False
bc : RBNode α
c✝ : RBColor
hbc : Balanced bc c✝ n✝
x✝ : ∀ (a : RBNode α) (x : α) (b : RBNode α), bc = node red a x b → False
⊢ RedRed (black = black → black ≠ black)
    (match a✝ with
    | node red a x b => node red (node black a x b) x✝¹ (node black bc y✝ d✝)
    | l =>
      match node black bc y✝ d✝ with
      | node black a y b => balance2 l x✝¹ (node red a y b)
      | node red (node black a y b) z c => node red (node black l x✝¹ a) y (balance2 b z (setRed c))
      | r => node red l x✝¹ r)
    (n✝ + 1)
split
case h_1
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝⁴ x✝³ : RBNode α
x✝² : α
b c : RBNode α
y✝ : α
d✝ : RBNode α
c₁✝¹ : RBColor
n✝ : Nat
c₂✝¹ : RBColor
hb : Balanced b c₂✝¹ n✝
hr : Balanced (node black c y✝ d✝) c₂ (n✝ + 1)
c₁✝ c₂✝ : RBColor
hc : Balanced c c₁✝ n✝
hd : Balanced d✝ c₂✝ n✝
IH : RedRed (c₂✝¹ = black → c₁✝ ≠ black) (append b c) n✝
l✝¹ : RBNode α
H : ∀ (a : RBNode α) (x : α) (b_1 : RBNode α), append b c = node red a x b_1 → False
bc : RBNode α
c✝ : RBColor
hbc : Balanced bc c✝ n✝
x✝¹ : ∀ (a : RBNode α) (x : α) (b : RBNode α), bc = node red a x b → False
l✝ a✝ : RBNode α
x✝ : α
b✝ : RBNode α
hl : Balanced (node black (node red a✝ x✝ b✝) x✝² b) c₁ n
ha : Balanced (node red a✝ x✝ b✝) c₁✝¹ n✝
ha' : Balanced a✝ black n✝
hb' : Balanced b✝ black n✝
⊢ RedRed (black = black → black ≠ black) (node red (node black a✝ x✝ b✝) x✝² (node black bc y✝ d✝)) (n✝ + 1)
case h_1
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝⁴ x✝³ : RBNode α
x✝² : α
b c : RBNode α
y✝ : α
d✝ : RBNode α
c₁✝¹ : RBColor
n✝ : Nat
c₂✝¹ : RBColor
hb : Balanced b c₂✝¹ n✝
hr : Balanced (node black c y✝ d✝) c₂ (n✝ + 1)
c₁✝ c₂✝ : RBColor
hc : Balanced c c₁✝ n✝
hd : Balanced d✝ c₂✝ n✝
IH : RedRed (c₂✝¹ = black → c₁✝ ≠ black) (append b c) n✝
l✝¹ : RBNode α
H : ∀ (a : RBNode α) (x : α) (b_1 : RBNode α), append b c = node red a x b_1 → False
bc : RBNode α
c✝ : RBColor
hbc : Balanced bc c✝ n✝
x✝¹ : ∀ (a : RBNode α) (x : α) (b : RBNode α), bc = node red a x b → False
l✝ a✝ : RBNode α
x✝ : α
b✝ : RBNode α
hl : Balanced (node black (node red a✝ x✝ b✝) x✝² b) c₁ n
ha : Balanced (node red a✝ x✝ b✝) c₁✝¹ n✝
⊢ RedRed (black = black → black ≠ black) (node red (node black a✝ x✝ b✝) x✝² (node black bc y✝ d✝)) (n✝ + 1)
have .red ha' hb' := ha
no goals
case h_1
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝⁴ x✝³ : RBNode α
x✝² : α
b c : RBNode α
y✝ : α
d✝ : RBNode α
c₁✝¹ : RBColor
n✝ : Nat
c₂✝¹ : RBColor
hb : Balanced b c₂✝¹ n✝
hr : Balanced (node black c y✝ d✝) c₂ (n✝ + 1)
c₁✝ c₂✝ : RBColor
hc : Balanced c c₁✝ n✝
hd : Balanced d✝ c₂✝ n✝
IH : RedRed (c₂✝¹ = black → c₁✝ ≠ black) (append b c) n✝
l✝¹ : RBNode α
H : ∀ (a : RBNode α) (x : α) (b_1 : RBNode α), append b c = node red a x b_1 → False
bc : RBNode α
c✝ : RBColor
hbc : Balanced bc c✝ n✝
x✝¹ : ∀ (a : RBNode α) (x : α) (b : RBNode α), bc = node red a x b → False
l✝ a✝ : RBNode α
x✝ : α
b✝ : RBNode α
hl : Balanced (node black (node red a✝ x✝ b✝) x✝² b) c₁ n
ha : Balanced (node red a✝ x✝ b✝) c₁✝¹ n✝
ha' : Balanced a✝ black n✝
hb' : Balanced b✝ black n✝
⊢ RedRed (black = black → black ≠ black) (node red (node black a✝ x✝ b✝) x✝² (node black bc y✝ d✝)) (n✝ + 1)
exact .balanced (.red (.black ha' hb') (.black hbc hd))
no goals
case h_2
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝⁴ x✝³ a✝ : RBNode α
x✝² : α
b c : RBNode α
y✝ : α
d✝ : RBNode α
hl : Balanced (node black a✝ x✝² b) c₁ n
c₁✝¹ : RBColor
n✝ : Nat
c₂✝¹ : RBColor
ha : Balanced a✝ c₁✝¹ n✝
hb : Balanced b c₂✝¹ n✝
hr : Balanced (node black c y✝ d✝) c₂ (n✝ + 1)
c₁✝ c₂✝ : RBColor
hc : Balanced c c₁✝ n✝
hd : Balanced d✝ c₂✝ n✝
IH : RedRed (c₂✝¹ = black → c₁✝ ≠ black) (append b c) n✝
l✝¹ : RBNode α
H : ∀ (a : RBNode α) (x : α) (b_1 : RBNode α), append b c = node red a x b_1 → False
bc : RBNode α
c✝ : RBColor
hbc : Balanced bc c✝ n✝
x✝¹ : ∀ (a : RBNode α) (x : α) (b : RBNode α), bc = node red a x b → False
l✝ : RBNode α
x✝ : ∀ (a : RBNode α) (x : α) (b : RBNode α), a✝ = node red a x b → False
⊢ RedRed (black = black → black ≠ black)
    (match node black bc y✝ d✝ with
    | node black a y b => balance2 a✝ x✝² (node red a y b)
    | node red (node black a y b) z c => node red (node black a✝ x✝² a) y (balance2 b z (setRed c))
    | r => node red a✝ x✝² r)
    (n✝ + 1)
exact have ⟨c, h⟩ := RedRed.balance2 ha (.redred trivial hbc hd); .balanced h
no goals
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝³ x✝² a✝⁴ : RBNode α
x✝¹ : α
b c : RBNode α
y✝ : α
d✝ : RBNode α
hl : Balanced (node black a✝⁴ x✝¹ b) c₁ n
c₁✝² : RBColor
n✝ : Nat
c₂✝² : RBColor
ha : Balanced a✝⁴ c₁✝² n✝
hb : Balanced b c₂✝² n✝
hr : Balanced (node black c y✝ d✝) c₂ (n✝ + 1)
c₁✝¹ c₂✝¹ : RBColor
hc : Balanced c c₁✝¹ n✝
hd : Balanced d✝ c₂✝¹ n✝
IH : RedRed (c₂✝² = black → c₁✝¹ ≠ black) (append b c) n✝
l✝ : RBNode α
H✝ : ∀ (a : RBNode α) (x : α) (b_1 : RBNode α), append b c = node red a x b_1 → False
a✝³ : RBNode α
c₁✝ : RBColor
b✝ : RBNode α
c₂✝ : RBColor
x✝ : α
a✝² : c₂✝² = black → c₁✝¹ ≠ black
a✝¹ : Balanced a✝³ c₁✝ n✝
a✝ : Balanced b✝ c₂✝ n✝
H : ∀ (a : RBNode α) (x : α) (b : RBNode α), node red a✝³ x✝ b✝ = node red a x b → False
⊢ RedRed (black = black → black ≠ black) (balLeft a✝⁴ x✝¹ (node black (node red a✝³ x✝ b✝) y✝ d✝)) (n✝ + 1)
cases H _ _ _ rfl
case h_5
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝² x✝¹ l✝ : RBNode α
v✝ : α
r✝ b✝ : RBNode α
x✝ : α
c✝ : RBNode α
hl : Balanced (node black l✝ v✝ r✝) c₁ n
hr : Balanced (node red b✝ x✝ c✝) c₂ n
hc : Balanced b✝ black n
hd : Balanced c✝ black n
⊢ RedRed (c₁ = black → red ≠ black) (node red (append (node black l✝ v✝ r✝) b✝) x✝ c✝) n
case h_5
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝² x✝¹ l✝ : RBNode α
v✝ : α
r✝ b✝ : RBNode α
x✝ : α
c✝ : RBNode α
hl : Balanced (node black l✝ v✝ r✝) c₁ n
hr : Balanced (node red b✝ x✝ c✝) c₂ n
⊢ RedRed (c₁ = black → c₂ ≠ black) (node red (append (node black l✝ v✝ r✝) b✝) x✝ c✝) n
have .red hc hd := hr
case h_5
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝² x✝¹ l✝ : RBNode α
v✝ : α
r✝ b✝ : RBNode α
x✝ : α
c✝ : RBNode α
hl : Balanced (node black l✝ v✝ r✝) c₁ n
hr : Balanced (node red b✝ x✝ c✝) c₂ n
hc : Balanced b✝ black n
hd : Balanced c✝ black n
IH : RedRed (c₁ = black → black ≠ black) (append (node black l✝ v✝ r✝) b✝) n
⊢ RedRed (c₁ = black → red ≠ black) (node red (append (node black l✝ v✝ r✝) b✝) x✝ c✝) n
case h_5
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝² x✝¹ l✝ : RBNode α
v✝ : α
r✝ b✝ : RBNode α
x✝ : α
c✝ : RBNode α
hl : Balanced (node black l✝ v✝ r✝) c₁ n
hr : Balanced (node red b✝ x✝ c✝) c₂ n
hc : Balanced b✝ black n
hd : Balanced c✝ black n
⊢ RedRed (c₁ = black → red ≠ black) (node red (append (node black l✝ v✝ r✝) b✝) x✝ c✝) n
have IH := hl.append hc
case h_5
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝² x✝¹ l✝ : RBNode α
v✝ : α
r✝ b✝ : RBNode α
x✝ : α
c✝ : RBNode α
hl : Balanced (node black l✝ v✝ r✝) c₁ n
c₁✝ : RBColor
n✝ : Nat
c₂✝ : RBColor
ha : Balanced l✝ c₁✝ n✝
hb : Balanced r✝ c₂✝ n✝
hr : Balanced (node red b✝ x✝ c✝) c₂ (n✝ + 1)
hc : Balanced b✝ black (n✝ + 1)
hd : Balanced c✝ black (n✝ + 1)
IH : RedRed (black = black → black ≠ black) (append (node black l✝ v✝ r✝) b✝) (n✝ + 1)
⊢ RedRed (black = black → red ≠ black) (node red (append (node black l✝ v✝ r✝) b✝) x✝ c✝) (n✝ + 1)
case h_5
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝² x✝¹ l✝ : RBNode α
v✝ : α
r✝ b✝ : RBNode α
x✝ : α
c✝ : RBNode α
hl : Balanced (node black l✝ v✝ r✝) c₁ n
hr : Balanced (node red b✝ x✝ c✝) c₂ n
hc : Balanced b✝ black n
hd : Balanced c✝ black n
IH : RedRed (c₁ = black → black ≠ black) (append (node black l✝ v✝ r✝) b✝) n
⊢ RedRed (c₁ = black → red ≠ black) (node red (append (node black l✝ v✝ r✝) b✝) x✝ c✝) n
have .black ha hb := hl
no goals
case h_5
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝² x✝¹ l✝ : RBNode α
v✝ : α
r✝ b✝ : RBNode α
x✝ : α
c✝ : RBNode α
hl : Balanced (node black l✝ v✝ r✝) c₁ n
c₁✝ : RBColor
n✝ : Nat
c₂✝ : RBColor
ha : Balanced l✝ c₁✝ n✝
hb : Balanced r✝ c₂✝ n✝
hr : Balanced (node red b✝ x✝ c✝) c₂ (n✝ + 1)
hc : Balanced b✝ black (n✝ + 1)
hd : Balanced c✝ black (n✝ + 1)
IH✝ : RedRed (black = black → black ≠ black) (append (node black l✝ v✝ r✝) b✝) (n✝ + 1)
c : RBColor
IH : Balanced (append (node black l✝ v✝ r✝) b✝) c (n✝ + 1)
⊢ RedRed (black = black → red ≠ black) (node red (append (node black l✝ v✝ r✝) b✝) x✝ c✝) (n✝ + 1)
exact .redred (fun.) IH hd
case h_6
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝² x✝¹ a✝ : RBNode α
x✝ : α
b✝ l✝ : RBNode α
v✝ : α
r✝ : RBNode α
hl : Balanced (node red a✝ x✝ b✝) c₁ n
hr : Balanced (node black l✝ v✝ r✝) c₂ n
ha : Balanced a✝ black n
hb : Balanced b✝ black n
⊢ RedRed (red = black → c₂ ≠ black) (node red a✝ x✝ (append b✝ (node black l✝ v✝ r✝))) n
case h_6
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝² x✝¹ a✝ : RBNode α
x✝ : α
b✝ l✝ : RBNode α
v✝ : α
r✝ : RBNode α
hl : Balanced (node red a✝ x✝ b✝) c₁ n
hr : Balanced (node black l✝ v✝ r✝) c₂ n
⊢ RedRed (c₁ = black → c₂ ≠ black) (node red a✝ x✝ (append b✝ (node black l✝ v✝ r✝))) n
have .red ha hb := hl
case h_6
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝² x✝¹ a✝ : RBNode α
x✝ : α
b✝ l✝ : RBNode α
v✝ : α
r✝ : RBNode α
hl : Balanced (node red a✝ x✝ b✝) c₁ n
hr : Balanced (node black l✝ v✝ r✝) c₂ n
ha : Balanced a✝ black n
hb : Balanced b✝ black n
IH : RedRed (black = black → c₂ ≠ black) (append b✝ (node black l✝ v✝ r✝)) n
⊢ RedRed (red = black → c₂ ≠ black) (node red a✝ x✝ (append b✝ (node black l✝ v✝ r✝))) n
case h_6
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝² x✝¹ a✝ : RBNode α
x✝ : α
b✝ l✝ : RBNode α
v✝ : α
r✝ : RBNode α
hl : Balanced (node red a✝ x✝ b✝) c₁ n
hr : Balanced (node black l✝ v✝ r✝) c₂ n
ha : Balanced a✝ black n
hb : Balanced b✝ black n
⊢ RedRed (red = black → c₂ ≠ black) (node red a✝ x✝ (append b✝ (node black l✝ v✝ r✝))) n
have IH := hb.append hr
case h_6
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝² x✝¹ a✝ : RBNode α
x✝ : α
b✝ l✝ : RBNode α
v✝ : α
r✝ : RBNode α
hr : Balanced (node black l✝ v✝ r✝) c₂ n
c₁✝ : RBColor
n✝ : Nat
c₂✝ : RBColor
hc : Balanced l✝ c₁✝ n✝
hd : Balanced r✝ c₂✝ n✝
hl : Balanced (node red a✝ x✝ b✝) c₁ (n✝ + 1)
ha : Balanced a✝ black (n✝ + 1)
hb : Balanced b✝ black (n✝ + 1)
IH : RedRed (black = black → black ≠ black) (append b✝ (node black l✝ v✝ r✝)) (n✝ + 1)
⊢ RedRed (red = black → black ≠ black) (node red a✝ x✝ (append b✝ (node black l✝ v✝ r✝))) (n✝ + 1)
case h_6
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝² x✝¹ a✝ : RBNode α
x✝ : α
b✝ l✝ : RBNode α
v✝ : α
r✝ : RBNode α
hl : Balanced (node red a✝ x✝ b✝) c₁ n
hr : Balanced (node black l✝ v✝ r✝) c₂ n
ha : Balanced a✝ black n
hb : Balanced b✝ black n
IH : RedRed (black = black → c₂ ≠ black) (append b✝ (node black l✝ v✝ r✝)) n
⊢ RedRed (red = black → c₂ ≠ black) (node red a✝ x✝ (append b✝ (node black l✝ v✝ r✝))) n
have .black hc hd := hr
no goals
case h_6
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
x✝² x✝¹ a✝ : RBNode α
x✝ : α
b✝ l✝ : RBNode α
v✝ : α
r✝ : RBNode α
hr : Balanced (node black l✝ v✝ r✝) c₂ n
c₁✝ : RBColor
n✝ : Nat
c₂✝ : RBColor
hc : Balanced l✝ c₁✝ n✝
hd : Balanced r✝ c₂✝ n✝
hl : Balanced (node red a✝ x✝ b✝) c₁ (n✝ + 1)
ha : Balanced a✝ black (n✝ + 1)
hb : Balanced b✝ black (n✝ + 1)
IH✝ : RedRed (black = black → black ≠ black) (append b✝ (node black l✝ v✝ r✝)) (n✝ + 1)
c : RBColor
IH : Balanced (append b✝ (node black l✝ v✝ r✝)) c (n✝ + 1)
⊢ RedRed (red = black → black ≠ black) (node red a✝ x✝ (append b✝ (node black l✝ v✝ r✝))) (n✝ + 1)
exact .redred (fun.) ha IH