Theorem: Batteries.RBNode.Balanced.append
File: .lake/packages/batteries/Batteries/Data/RBMap/WF.lean

Proof steps:
state_before: α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
l r : RBNode α
hl : l.Balanced c₁ n
hr : r.Balanced c₂ n
⊢ RedRed (c₁ = black → c₂ ≠ black) (l.append r) n
state_after: α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
l r : RBNode α
hl : l.Balanced c₁ n
hr : r.Balanced 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 b.append 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 b.append c with
      | node red b' z c' => node red (node black a x b') z (node black c' y d)
      | bc => a.balLeft x (node black bc y d)
    | a@h:(node black l v r), node red b x c => node red (a.append b) x c
    | node red a x b, c@h:(node black l v r) => node red a x (b.append c))
    n
tactic: unfold append
state_before: α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
l r : RBNode α
hl : l.Balanced c₁ n
hr : r.Balanced 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 b.append 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 b.append c with
      | node red b' z c' => node red (node black a x b') z (node black c' y d)
      | bc => a.balLeft x (node black bc y d)
    | a@h:(node black l v r), node red b x c => node red (a.append b) x c
    | node red a x b, c@h:(node black l v r) => node red a x (b.append c))
    n
state_after: case h_1
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
r : RBNode α
hr : r.Balanced c₂ n
x✝¹ x✝ : RBNode α
hl : nil.Balanced c₁ n
⊢ RedRed (c₁ = black → c₂ ≠ black) r n

case h_2
α : Type u_1
c₁ : RBColor
n : Nat
c₂ : RBColor
l : RBNode α
hl : l.Balanced c₁ n
x✝² x✝¹ : RBNode α
x✝ : l = nil → False
hr : nil.Balanced 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 : (node red a✝ x✝ b✝).Balanced c₁ n
hr : (node red c✝ y✝ d✝).Balanced c₂ n
⊢ RedRed (c₁ = black → c₂ ≠ black)
    (match b✝.append 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 : (node black a✝ x✝ b✝).Balanced c₁ n
hr : (node black c✝ y✝ d✝).Balanced c₂ n
⊢ RedRed (c₁ = black → c₂ ≠ black)
    (match b✝.append c✝ with
    | node red b' z c' => node red (node black a✝ x✝ b') z (node black c' y✝ d✝)
    | bc => a✝.balLeft 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 : (node black l✝ v✝ r✝).Balanced c₁ n
hr : (node red b✝ x✝ c✝).Balanced c₂ n
⊢ RedRed (c₁ = black → c₂ ≠ black) (node red ((node black l✝ v✝ r✝).append 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 : (node red a✝ x✝ b✝).Balanced c₁ n
hr : (node black l✝ v✝ r✝).Balanced c₂ n
⊢ RedRed (c₁ = black → c₂ ≠ black) (node red a✝ x✝ (b✝.append (node black l✝ v✝ r✝))) n
tactic: split