no goals
case nil
α : Type u_1
c : RBColor
n : Nat
cmp : α → α → Ordering
v : α
t : RBNode α
⊢ RedRed (isRed nil = red) (ins cmp v nil) 0
exact .balanced (.red .nil .nil)
case red
α : Type u_1
c : RBColor
n✝ : Nat
cmp : α → α → Ordering
v : α
t a : RBNode α
n : Nat
b : RBNode α
x : α
hl : Balanced a black n
hr : Balanced b black n
ihl : RedRed (isRed a = red) (ins cmp v a) n
ihr : RedRed (isRed b = red) (ins cmp v b) n
⊢ RedRed (isRed (node red a x b) = red)
    (match cmp v x with
    | Ordering.lt => node red (ins cmp v a) x b
    | Ordering.gt => node red a x (ins cmp v b)
    | Ordering.eq => node red a v b)
    n
case red
α : Type u_1
c : RBColor
n✝ : Nat
cmp : α → α → Ordering
v : α
t a : RBNode α
n : Nat
b : RBNode α
x : α
hl : Balanced a black n
hr : Balanced b black n
ihl : RedRed (isRed a = red) (ins cmp v a) n
ihr : RedRed (isRed b = red) (ins cmp v b) n
⊢ RedRed (isRed (node red a x b) = red) (ins cmp v (node red a x b)) n
unfold ins
case red.h_1
α : Type u_1
c : RBColor
n✝ : Nat
cmp : α → α → Ordering
v : α
t a : RBNode α
n : Nat
b : RBNode α
x : α
hl : Balanced a black n
hr : Balanced b black n
ihl : RedRed (isRed a = red) (ins cmp v a) n
ihr : RedRed (isRed b = red) (ins cmp v b) n
x✝ : Ordering
heq✝ : cmp v x = Ordering.lt
⊢ RedRed (isRed (node red a x b) = red) (node red (ins cmp v a) x b) n

case red.h_2
α : Type u_1
c : RBColor
n✝ : Nat
cmp : α → α → Ordering
v : α
t a : RBNode α
n : Nat
b : RBNode α
x : α
hl : Balanced a black n
hr : Balanced b black n
ihl : RedRed (isRed a = red) (ins cmp v a) n
ihr : RedRed (isRed b = red) (ins cmp v b) n
x✝ : Ordering
heq✝ : cmp v x = Ordering.gt
⊢ RedRed (isRed (node red a x b) = red) (node red a x (ins cmp v b)) n

case red.h_3
α : Type u_1
c : RBColor
n✝ : Nat
cmp : α → α → Ordering
v : α
t a : RBNode α
n : Nat
b : RBNode α
x : α
hl : Balanced a black n
hr : Balanced b black n
ihl : RedRed (isRed a = red) (ins cmp v a) n
ihr : RedRed (isRed b = red) (ins cmp v b) n
x✝ : Ordering
heq✝ : cmp v x = Ordering.eq
⊢ RedRed (isRed (node red a x b) = red) (node red a v b) n
case red
α : Type u_1
c : RBColor
n✝ : Nat
cmp : α → α → Ordering
v : α
t a : RBNode α
n : Nat
b : RBNode α
x : α
hl : Balanced a black n
hr : Balanced b black n
ihl : RedRed (isRed a = red) (ins cmp v a) n
ihr : RedRed (isRed b = red) (ins cmp v b) n
⊢ RedRed (isRed (node red a x b) = red)
    (match cmp v x with
    | Ordering.lt => node red (ins cmp v a) x b
    | Ordering.gt => node red a x (ins cmp v b)
    | Ordering.eq => node red a v b)
    n
split
no goals
case red.h_1
α : Type u_1
c : RBColor
n✝ : Nat
cmp : α → α → Ordering
v : α
t a : RBNode α
n : Nat
b : RBNode α
x : α
hl : Balanced a black n
hr : Balanced b black n
ihl : RedRed (isRed a = red) (ins cmp v a) n
ihr : RedRed (isRed b = red) (ins cmp v b) n
x✝ : Ordering
heq✝ : cmp v x = Ordering.lt
⊢ RedRed (isRed (node red a x b) = red) (node red (ins cmp v a) x b) n
match ins cmp v a, ihl with
| _, .balanced .nil => exact .balanced (.red .nil hr)
| _, .balanced (.red ha hb) => exact .redred rfl (.red ha hb) hr
| _, .balanced (.black ha hb) => exact .balanced (.red (.black ha hb) hr)
| _, .redred h .. => cases hl <;> cases h
no goals
α : Type u_1
c : RBColor
n✝ : Nat
cmp : α → α → Ordering
v : α
t a : RBNode α
n : Nat
b : RBNode α
x : α
ihl : RedRed (isRed a = red) (ins cmp v a) n
x✝ : Ordering
heq✝ : cmp v x = Ordering.lt
hl : Balanced a black 0
hr : Balanced b black 0
ihr : RedRed (isRed b = red) (ins cmp v b) 0
⊢ RedRed (isRed (node red a x b) = red) (node red nil x b) 0
exact .balanced (.red .nil hr)
no goals
α : Type u_1
c : RBColor
n✝¹ : Nat
cmp : α → α → Ordering
v : α
t a : RBNode α
n✝ : Nat
b : RBNode α
x : α
ihl : RedRed (isRed a = red) (ins cmp v a) n✝
x✝ : Ordering
heq✝ : cmp v x = Ordering.lt
n : Nat
l✝ : RBNode α
v✝ : α
r✝ : RBNode α
ha : Balanced l✝ black n
hb : Balanced r✝ black n
hl : Balanced a black n
hr : Balanced b black n
ihr : RedRed (isRed b = red) (ins cmp v b) n
⊢ RedRed (isRed (node red a x b) = red) (node red (node red l✝ v✝ r✝) x b) n
exact .redred rfl (.red ha hb) hr
no goals
α : Type u_1
c : RBColor
n✝¹ : Nat
cmp : α → α → Ordering
v : α
t a : RBNode α
n : Nat
b : RBNode α
x : α
ihl : RedRed (isRed a = red) (ins cmp v a) n
x✝ : Ordering
heq✝ : cmp v x = Ordering.lt
l✝ : RBNode α
v✝ : α
r✝ : RBNode α
n✝ : Nat
c₁✝ c₂✝ : RBColor
ha : Balanced l✝ c₁✝ n✝
hb : Balanced r✝ c₂✝ n✝
hl : Balanced a black (n✝ + 1)
hr : Balanced b black (n✝ + 1)
ihr : RedRed (isRed b = red) (ins cmp v b) (n✝ + 1)
⊢ RedRed (isRed (node red a x b) = red) (node red (node black l✝ v✝ r✝) x b) (n✝ + 1)
exact .balanced (.red (.black ha hb) hr)
no goals
α : Type u_1
c : RBColor
n✝¹ : Nat
cmp : α → α → Ordering
v : α
t a : RBNode α
n✝ : Nat
b : RBNode α
x : α
ihl : RedRed (isRed a = red) (ins cmp v a) n✝
x✝¹ : Ordering
heq✝ : cmp v x = Ordering.lt
n : Nat
a✝² : RBNode α
c₁✝ : RBColor
b✝ : RBNode α
c₂✝ : RBColor
x✝ : α
h : isRed a = red
a✝¹ : Balanced a✝² c₁✝ n
a✝ : Balanced b✝ c₂✝ n
hl : Balanced a black n
hr : Balanced b black n
ihr : RedRed (isRed b = red) (ins cmp v b) n
⊢ RedRed (isRed (node red a x b) = red) (node red (node red a✝² x✝ b✝) x b) n
cases hl <;> cases h
no goals
case red.h_2
α : Type u_1
c : RBColor
n✝ : Nat
cmp : α → α → Ordering
v : α
t a : RBNode α
n : Nat
b : RBNode α
x : α
hl : Balanced a black n
hr : Balanced b black n
ihl : RedRed (isRed a = red) (ins cmp v a) n
ihr : RedRed (isRed b = red) (ins cmp v b) n
x✝ : Ordering
heq✝ : cmp v x = Ordering.gt
⊢ RedRed (isRed (node red a x b) = red) (node red a x (ins cmp v b)) n
match ins cmp v b, ihr with
| _, .balanced .nil => exact .balanced (.red hl .nil)
| _, .balanced (.red ha hb) => exact .redred rfl hl (.red ha hb)
| _, .balanced (.black ha hb) => exact .balanced (.red hl (.black ha hb))
| _, .redred h .. => cases hr <;> cases h
no goals
α : Type u_1
c : RBColor
n✝ : Nat
cmp : α → α → Ordering
v : α
t a : RBNode α
n : Nat
b : RBNode α
x : α
ihr : RedRed (isRed b = red) (ins cmp v b) n
x✝ : Ordering
heq✝ : cmp v x = Ordering.gt
hl : Balanced a black 0
hr : Balanced b black 0
ihl : RedRed (isRed a = red) (ins cmp v a) 0
⊢ RedRed (isRed (node red a x b) = red) (node red a x nil) 0
exact .balanced (.red hl .nil)
no goals
α : Type u_1
c : RBColor
n✝¹ : Nat
cmp : α → α → Ordering
v : α
t a : RBNode α
n✝ : Nat
b : RBNode α
x : α
ihr : RedRed (isRed b = red) (ins cmp v b) n✝
x✝ : Ordering
heq✝ : cmp v x = Ordering.gt
n : Nat
l✝ : RBNode α
v✝ : α
r✝ : RBNode α
ha : Balanced l✝ black n
hb : Balanced r✝ black n
hl : Balanced a black n
hr : Balanced b black n
ihl : RedRed (isRed a = red) (ins cmp v a) n
⊢ RedRed (isRed (node red a x b) = red) (node red a x (node red l✝ v✝ r✝)) n
exact .redred rfl hl (.red ha hb)
no goals
α : Type u_1
c : RBColor
n✝¹ : Nat
cmp : α → α → Ordering
v : α
t a : RBNode α
n : Nat
b : RBNode α
x : α
ihr : RedRed (isRed b = red) (ins cmp v b) n
x✝ : Ordering
heq✝ : cmp v x = Ordering.gt
l✝ : RBNode α
v✝ : α
r✝ : RBNode α
n✝ : Nat
c₁✝ c₂✝ : RBColor
ha : Balanced l✝ c₁✝ n✝
hb : Balanced r✝ c₂✝ n✝
hl : Balanced a black (n✝ + 1)
hr : Balanced b black (n✝ + 1)
ihl : RedRed (isRed a = red) (ins cmp v a) (n✝ + 1)
⊢ RedRed (isRed (node red a x b) = red) (node red a x (node black l✝ v✝ r✝)) (n✝ + 1)
exact .balanced (.red hl (.black ha hb))
no goals
α : Type u_1
c : RBColor
n✝¹ : Nat
cmp : α → α → Ordering
v : α
t a : RBNode α
n✝ : Nat
b : RBNode α
x : α
ihr : RedRed (isRed b = red) (ins cmp v b) n✝
x✝¹ : Ordering
heq✝ : cmp v x = Ordering.gt
n : Nat
a✝² : RBNode α
c₁✝ : RBColor
b✝ : RBNode α
c₂✝ : RBColor
x✝ : α
h : isRed b = red
a✝¹ : Balanced a✝² c₁✝ n
a✝ : Balanced b✝ c₂✝ n
hl : Balanced a black n
hr : Balanced b black n
ihl : RedRed (isRed a = red) (ins cmp v a) n
⊢ RedRed (isRed (node red a x b) = red) (node red a x (node red a✝² x✝ b✝)) n
cases hr <;> cases h
no goals
case red.h_3
α : Type u_1
c : RBColor
n✝ : Nat
cmp : α → α → Ordering
v : α
t a : RBNode α
n : Nat
b : RBNode α
x : α
hl : Balanced a black n
hr : Balanced b black n
ihl : RedRed (isRed a = red) (ins cmp v a) n
ihr : RedRed (isRed b = red) (ins cmp v b) n
x✝ : Ordering
heq✝ : cmp v x = Ordering.eq
⊢ RedRed (isRed (node red a x b) = red) (node red a v b) n
exact .balanced (.red hl hr)
case black
α : Type u_1
c : RBColor
n✝ : Nat
cmp : α → α → Ordering
v : α
t a : RBNode α
ca : RBColor
n : Nat
b : RBNode α
cb : RBColor
x : α
hl : Balanced a ca n
hr : Balanced b cb n
ihl : RedRed (isRed a = red) (ins cmp v a) n
ihr : RedRed (isRed b = red) (ins cmp v b) n
⊢ RedRed (isRed (node black a x b) = red)
    (match cmp v x with
    | Ordering.lt => balance1 (ins cmp v a) x b
    | Ordering.gt => balance2 a x (ins cmp v b)
    | Ordering.eq => node black a v b)
    (n + 1)
case black
α : Type u_1
c : RBColor
n✝ : Nat
cmp : α → α → Ordering
v : α
t a : RBNode α
ca : RBColor
n : Nat
b : RBNode α
cb : RBColor
x : α
hl : Balanced a ca n
hr : Balanced b cb n
ihl : RedRed (isRed a = red) (ins cmp v a) n
ihr : RedRed (isRed b = red) (ins cmp v b) n
⊢ RedRed (isRed (node black a x b) = red) (ins cmp v (node black a x b)) (n + 1)
unfold ins
case black.h_1
α : Type u_1
c : RBColor
n✝ : Nat
cmp : α → α → Ordering
v : α
t a : RBNode α
ca : RBColor
n : Nat
b : RBNode α
cb : RBColor
x : α
hl : Balanced a ca n
hr : Balanced b cb n
ihl : RedRed (isRed a = red) (ins cmp v a) n
ihr : RedRed (isRed b = red) (ins cmp v b) n
x✝ : Ordering
heq✝ : cmp v x = Ordering.lt
⊢ RedRed (isRed (node black a x b) = red) (balance1 (ins cmp v a) x b) (n + 1)

case black.h_2
α : Type u_1
c : RBColor
n✝ : Nat
cmp : α → α → Ordering
v : α
t a : RBNode α
ca : RBColor
n : Nat
b : RBNode α
cb : RBColor
x : α
hl : Balanced a ca n
hr : Balanced b cb n
ihl : RedRed (isRed a = red) (ins cmp v a) n
ihr : RedRed (isRed b = red) (ins cmp v b) n
x✝ : Ordering
heq✝ : cmp v x = Ordering.gt
⊢ RedRed (isRed (node black a x b) = red) (balance2 a x (ins cmp v b)) (n + 1)

case black.h_3
α : Type u_1
c : RBColor
n✝ : Nat
cmp : α → α → Ordering
v : α
t a : RBNode α
ca : RBColor
n : Nat
b : RBNode α
cb : RBColor
x : α
hl : Balanced a ca n
hr : Balanced b cb n
ihl : RedRed (isRed a = red) (ins cmp v a) n
ihr : RedRed (isRed b = red) (ins cmp v b) n
x✝ : Ordering
heq✝ : cmp v x = Ordering.eq
⊢ RedRed (isRed (node black a x b) = red) (node black a v b) (n + 1)
case black
α : Type u_1
c : RBColor
n✝ : Nat
cmp : α → α → Ordering
v : α
t a : RBNode α
ca : RBColor
n : Nat
b : RBNode α
cb : RBColor
x : α
hl : Balanced a ca n
hr : Balanced b cb n
ihl : RedRed (isRed a = red) (ins cmp v a) n
ihr : RedRed (isRed b = red) (ins cmp v b) n
⊢ RedRed (isRed (node black a x b) = red)
    (match cmp v x with
    | Ordering.lt => balance1 (ins cmp v a) x b
    | Ordering.gt => balance2 a x (ins cmp v b)
    | Ordering.eq => node black a v b)
    (n + 1)
split
no goals
case black.h_1
α : Type u_1
c : RBColor
n✝ : Nat
cmp : α → α → Ordering
v : α
t a : RBNode α
ca : RBColor
n : Nat
b : RBNode α
cb : RBColor
x : α
hl : Balanced a ca n
hr : Balanced b cb n
ihl : RedRed (isRed a = red) (ins cmp v a) n
ihr : RedRed (isRed b = red) (ins cmp v b) n
x✝ : Ordering
heq✝ : cmp v x = Ordering.lt
⊢ RedRed (isRed (node black a x b) = red) (balance1 (ins cmp v a) x b) (n + 1)
exact have ⟨c, h⟩ := ihl.balance1 hr; .balanced h
no goals
case black.h_2
α : Type u_1
c : RBColor
n✝ : Nat
cmp : α → α → Ordering
v : α
t a : RBNode α
ca : RBColor
n : Nat
b : RBNode α
cb : RBColor
x : α
hl : Balanced a ca n
hr : Balanced b cb n
ihl : RedRed (isRed a = red) (ins cmp v a) n
ihr : RedRed (isRed b = red) (ins cmp v b) n
x✝ : Ordering
heq✝ : cmp v x = Ordering.gt
⊢ RedRed (isRed (node black a x b) = red) (balance2 a x (ins cmp v b)) (n + 1)
exact have ⟨c, h⟩ := ihr.balance2 hl; .balanced h
no goals
case black.h_3
α : Type u_1
c : RBColor
n✝ : Nat
cmp : α → α → Ordering
v : α
t a : RBNode α
ca : RBColor
n : Nat
b : RBNode α
cb : RBColor
x : α
hl : Balanced a ca n
hr : Balanced b cb n
ihl : RedRed (isRed a = red) (ins cmp v a) n
ihr : RedRed (isRed b = red) (ins cmp v b) n
x✝ : Ordering
heq✝ : cmp v x = Ordering.eq
⊢ RedRed (isRed (node black a x b) = red) (node black a v b) (n + 1)
exact .balanced (.black hl hr)