α : Type u_1
p : Prop
n : Nat
c : RBColor
l : RBNode α
v : α
r : RBNode α
hl : RedRed p l n
hr : Balanced r c n
⊢ ∃ c,
    Balanced
      (match l, v, r with
      | node red (node red a x b) y c, z, d => node red (node black a x b) y (node black c z d)
      | node red a x (node red b y c), z, d => node red (node black a x b) y (node black c z d)
      | a, x, b => node black a x b)
      c (n + 1)
α : Type u_1
p : Prop
n : Nat
c : RBColor
l : RBNode α
v : α
r : RBNode α
hl : RedRed p l n
hr : Balanced r c n
⊢ ∃ c, Balanced (balance1 l v r) c (n + 1)
unfold balance1
case h_1
α : Type u_1
p : Prop
n : Nat
c : RBColor
v : α
r : RBNode α
hr : Balanced r c n
x✝³ : RBNode α
x✝² : α
x✝¹ a✝ : RBNode α
x✝ : α
b✝ : RBNode α
y✝ : α
c✝ : RBNode α
hl : RedRed p (node red (node red a✝ x✝ b✝) y✝ c✝) n
⊢ ∃ c, Balanced (node red (node black a✝ x✝ b✝) y✝ (node black c✝ v r)) c (n + 1)

case h_2
α : Type u_1
p : Prop
n : Nat
c : RBColor
v : α
r : RBNode α
hr : Balanced r c n
x✝⁴ : RBNode α
x✝³ : α
x✝² a✝ : RBNode α
x✝¹ : α
b✝ : RBNode α
y✝ : α
c✝ : RBNode α
x✝ : ∀ (a : RBNode α) (x : α) (b : RBNode α), a✝ = node red a x b → False
hl : RedRed p (node red a✝ x✝¹ (node red b✝ y✝ c✝)) n
⊢ ∃ c, Balanced (node red (node black a✝ x✝¹ b✝) y✝ (node black c✝ v r)) c (n + 1)

case h_3
α : Type u_1
p : Prop
n : Nat
c : RBColor
l : RBNode α
v : α
r : RBNode α
hl : RedRed p l n
hr : Balanced r c n
x✝⁴ : RBNode α
x✝³ : α
x✝² : RBNode α
x✝¹ : ∀ (a : RBNode α) (x : α) (b : RBNode α) (y : α) (c : RBNode α), l = node red (node red a x b) y c → False
x✝ : ∀ (a : RBNode α) (x : α) (b : RBNode α) (y : α) (c : RBNode α), l = node red a x (node red b y c) → False
⊢ ∃ c, Balanced (node black l v r) c (n + 1)
α : Type u_1
p : Prop
n : Nat
c : RBColor
l : RBNode α
v : α
r : RBNode α
hl : RedRed p l n
hr : Balanced r c n
⊢ ∃ c,
    Balanced
      (match l, v, r with
      | node red (node red a x b) y c, z, d => node red (node black a x b) y (node black c z d)
      | node red a x (node red b y c), z, d => node red (node black a x b) y (node black c z d)
      | a, x, b => node black a x b)
      c (n + 1)
split
case h_1
α : Type u_1
p : Prop
n : Nat
c : RBColor
v : α
r : RBNode α
hr : Balanced r c n
x✝³ : RBNode α
x✝² : α
x✝¹ a✝¹ : RBNode α
x✝ : α
b✝ : RBNode α
y✝ : α
c✝ : RBNode α
hl : RedRed p (node red (node red a✝¹ x✝ b✝) y✝ c✝) n
c₂✝ : RBColor
a✝ : p
ha : Balanced a✝¹ black n
hb : Balanced b✝ black n
hc : Balanced c✝ c₂✝ n
⊢ ∃ c, Balanced (node red (node black a✝¹ x✝ b✝) y✝ (node black c✝ v r)) c (n + 1)
case h_1
α : Type u_1
p : Prop
n : Nat
c : RBColor
v : α
r : RBNode α
hr : Balanced r c n
x✝³ : RBNode α
x✝² : α
x✝¹ a✝ : RBNode α
x✝ : α
b✝ : RBNode α
y✝ : α
c✝ : RBNode α
hl : RedRed p (node red (node red a✝ x✝ b✝) y✝ c✝) n
⊢ ∃ c, Balanced (node red (node black a✝ x✝ b✝) y✝ (node black c✝ v r)) c (n + 1)
have .redred _ (.red ha hb) hc := hl
no goals
case h_1
α : Type u_1
p : Prop
n : Nat
c : RBColor
v : α
r : RBNode α
hr : Balanced r c n
x✝³ : RBNode α
x✝² : α
x✝¹ a✝¹ : RBNode α
x✝ : α
b✝ : RBNode α
y✝ : α
c✝ : RBNode α
hl : RedRed p (node red (node red a✝¹ x✝ b✝) y✝ c✝) n
c₂✝ : RBColor
a✝ : p
ha : Balanced a✝¹ black n
hb : Balanced b✝ black n
hc : Balanced c✝ c₂✝ n
⊢ ∃ c, Balanced (node red (node black a✝¹ x✝ b✝) y✝ (node black c✝ v r)) c (n + 1)
exact ⟨_, .red (.black ha hb) (.black hc hr)⟩
case h_2
α : Type u_1
p : Prop
n : Nat
c : RBColor
v : α
r : RBNode α
hr : Balanced r c n
x✝⁴ : RBNode α
x✝³ : α
x✝² a✝¹ : RBNode α
x✝¹ : α
b✝ : RBNode α
y✝ : α
c✝ : RBNode α
x✝ : ∀ (a : RBNode α) (x : α) (b : RBNode α), a✝¹ = node red a x b → False
hl : RedRed p (node red a✝¹ x✝¹ (node red b✝ y✝ c✝)) n
c₁✝ : RBColor
a✝ : p
ha : Balanced a✝¹ c₁✝ n
hb : Balanced b✝ black n
hc : Balanced c✝ black n
⊢ ∃ c, Balanced (node red (node black a✝¹ x✝¹ b✝) y✝ (node black c✝ v r)) c (n + 1)
case h_2
α : Type u_1
p : Prop
n : Nat
c : RBColor
v : α
r : RBNode α
hr : Balanced r c n
x✝⁴ : RBNode α
x✝³ : α
x✝² a✝ : RBNode α
x✝¹ : α
b✝ : RBNode α
y✝ : α
c✝ : RBNode α
x✝ : ∀ (a : RBNode α) (x : α) (b : RBNode α), a✝ = node red a x b → False
hl : RedRed p (node red a✝ x✝¹ (node red b✝ y✝ c✝)) n
⊢ ∃ c, Balanced (node red (node black a✝ x✝¹ b✝) y✝ (node black c✝ v r)) c (n + 1)
have .redred _ ha (.red hb hc) := hl
no goals
case h_2
α : Type u_1
p : Prop
n : Nat
c : RBColor
v : α
r : RBNode α
hr : Balanced r c n
x✝⁴ : RBNode α
x✝³ : α
x✝² a✝¹ : RBNode α
x✝¹ : α
b✝ : RBNode α
y✝ : α
c✝ : RBNode α
x✝ : ∀ (a : RBNode α) (x : α) (b : RBNode α), a✝¹ = node red a x b → False
hl : RedRed p (node red a✝¹ x✝¹ (node red b✝ y✝ c✝)) n
c₁✝ : RBColor
a✝ : p
ha : Balanced a✝¹ c₁✝ n
hb : Balanced b✝ black n
hc : Balanced c✝ black n
⊢ ∃ c, Balanced (node red (node black a✝¹ x✝¹ b✝) y✝ (node black c✝ v r)) c (n + 1)
exact ⟨_, .red (.black ha hb) (.black hc hr)⟩
no goals
case h_3
α : Type u_1
p : Prop
n : Nat
c : RBColor
l : RBNode α
v : α
r : RBNode α
hl : RedRed p l n
hr : Balanced r c n
x✝⁴ : RBNode α
x✝³ : α
x✝² : RBNode α
x✝¹ : ∀ (a : RBNode α) (x : α) (b : RBNode α) (y : α) (c : RBNode α), l = node red (node red a x b) y c → False
x✝ : ∀ (a : RBNode α) (x : α) (b : RBNode α) (y : α) (c : RBNode α), l = node red a x (node red b y c) → False
⊢ ∃ c, Balanced (node black l v r) c (n + 1)
next H1 H2 => match hl with
| .balanced hl => exact ⟨_, .black hl hr⟩
| .redred _ (c₁ := black) (c₂ := black) ha hb => exact ⟨_, .black (.red ha hb) hr⟩
| .redred _ (c₁ := red) (.red ..) _ => cases H1 _ _ _ _ _ rfl
| .redred _ (c₂ := red) _ (.red ..) => cases H2 _ _ _ _ _ rfl
no goals
α : Type u_1
p : Prop
n : Nat
c : RBColor
l : RBNode α
v : α
r : RBNode α
hl : RedRed p l n
hr : Balanced r c n
x✝² : RBNode α
x✝¹ : α
x✝ : RBNode α
H1 : ∀ (a : RBNode α) (x : α) (b : RBNode α) (y : α) (c : RBNode α), l = node red (node red a x b) y c → False
H2 : ∀ (a : RBNode α) (x : α) (b : RBNode α) (y : α) (c : RBNode α), l = node red a x (node red b y c) → False
⊢ ∃ c, Balanced (node black l v r) c (n + 1)
match hl with
| .balanced hl => exact ⟨_, .black hl hr⟩
| .redred _ (c₁ := black) (c₂ := black) ha hb => exact ⟨_, .black (.red ha hb) hr⟩
| .redred _ (c₁ := red) (.red ..) _ => cases H1 _ _ _ _ _ rfl
| .redred _ (c₂ := red) _ (.red ..) => cases H2 _ _ _ _ _ rfl
no goals
α : Type u_1
p : Prop
n : Nat
c : RBColor
l✝ : RBNode α
v : α
r : RBNode α
hl✝ : RedRed p l✝ n
hr : Balanced r c n
x✝² : RBNode α
x✝¹ : α
x✝ l : RBNode α
c✝ : RBColor
hl : Balanced l c✝ n
H1 : ∀ (a : RBNode α) (x : α) (b : RBNode α) (y : α) (c : RBNode α), l = node red (node red a x b) y c → False
H2 : ∀ (a : RBNode α) (x : α) (b : RBNode α) (y : α) (c : RBNode α), l = node red a x (node red b y c) → False
⊢ ∃ c, Balanced (node black l v r) c (n + 1)
exact ⟨_, .black hl hr⟩
no goals
α : Type u_1
p : Prop
n : Nat
c : RBColor
l : RBNode α
v : α
r : RBNode α
hl : RedRed p l n
hr : Balanced r c n
x✝³ : RBNode α
x✝² : α
x✝¹ a✝¹ b✝ : RBNode α
x✝ : α
a✝ : p
ha : Balanced a✝¹ black n
hb : Balanced b✝ black n
H1 :
  ∀ (a : RBNode α) (x : α) (b : RBNode α) (y : α) (c : RBNode α),
    node red a✝¹ x✝ b✝ = node red (node red a x b) y c → False
H2 :
  ∀ (a : RBNode α) (x : α) (b : RBNode α) (y : α) (c : RBNode α),
    node red a✝¹ x✝ b✝ = node red a x (node red b y c) → False
⊢ ∃ c, Balanced (node black (node red a✝¹ x✝ b✝) v r) c (n + 1)
exact ⟨_, .black (.red ha hb) hr⟩
no goals
α : Type u_1
p : Prop
n : Nat
c : RBColor
l : RBNode α
v : α
r : RBNode α
hl : RedRed p l n
hr : Balanced r c n
x✝³ : RBNode α
x✝² : α
x✝¹ l✝ : RBNode α
v✝ : α
r✝ b✝ : RBNode α
c₂✝ : RBColor
x✝ : α
a✝³ : p
a✝² : Balanced l✝ black n
a✝¹ : Balanced r✝ black n
a✝ : Balanced b✝ c₂✝ n
H1 :
  ∀ (a : RBNode α) (x : α) (b : RBNode α) (y : α) (c : RBNode α),
    node red (node red l✝ v✝ r✝) x✝ b✝ = node red (node red a x b) y c → False
H2 :
  ∀ (a : RBNode α) (x : α) (b : RBNode α) (y : α) (c : RBNode α),
    node red (node red l✝ v✝ r✝) x✝ b✝ = node red a x (node red b y c) → False
⊢ ∃ c, Balanced (node black (node red (node red l✝ v✝ r✝) x✝ b✝) v r) c (n + 1)
cases H1 _ _ _ _ _ rfl
no goals
α : Type u_1
p : Prop
n : Nat
c : RBColor
l : RBNode α
v : α
r : RBNode α
hl : RedRed p l n
hr : Balanced r c n
x✝³ : RBNode α
x✝² : α
x✝¹ a✝⁴ : RBNode α
c₁✝ : RBColor
l✝ : RBNode α
v✝ : α
r✝ : RBNode α
x✝ : α
a✝³ : p
a✝² : Balanced a✝⁴ c₁✝ n
a✝¹ : Balanced l✝ black n
a✝ : Balanced r✝ black n
H1 :
  ∀ (a : RBNode α) (x : α) (b : RBNode α) (y : α) (c : RBNode α),
    node red a✝⁴ x✝ (node red l✝ v✝ r✝) = node red (node red a x b) y c → False
H2 :
  ∀ (a : RBNode α) (x : α) (b : RBNode α) (y : α) (c : RBNode α),
    node red a✝⁴ x✝ (node red l✝ v✝ r✝) = node red a x (node red b y c) → False
⊢ ∃ c, Balanced (node black (node red a✝⁴ x✝ (node red l✝ v✝ r✝)) v r) c (n + 1)
cases H2 _ _ _ _ _ rfl