Theorem: Std.RBNode.Balanced.del
File: Std/Data/RBMap/WF.lean

tactic: exact ⟨_, .nil⟩
state_before: case nil
α : Type u_1
c : RBColor
n : Nat
cut : α → Ordering
t : RBNode α
⊢ DelProp (isBlack nil) (del cut nil) 0

tactic: refine ⟨_, rfl, ?_⟩
state_before: case black
α : Type u_1
c : RBColor
n✝ : Nat
cut : α → Ordering
t a : RBNode α
c₁✝ : RBColor
n : Nat
b : RBNode α
c₂✝ : RBColor
v✝ : α
ha : Balanced a c₁✝ n
hb : Balanced b c₂✝ n
iha : DelProp (isBlack a) (del cut a) n
ihb : DelProp (isBlack b) (del cut b) n
⊢ DelProp (isBlack (node black a v✝ b)) (del cut (node black a v✝ b)) (n + 1)

tactic: unfold del
state_before: case black
α : Type u_1
c : RBColor
n✝ : Nat
cut : α → Ordering
t a : RBNode α
c₁✝ : RBColor
n : Nat
b : RBNode α
c₂✝ : RBColor
v✝ : α
ha : Balanced a c₁✝ n
hb : Balanced b c₂✝ n
iha : DelProp (isBlack a) (del cut a) n
ihb : DelProp (isBlack b) (del cut b) n
⊢ RedRed True (del cut (node black a v✝ b)) n

tactic: split
state_before: case black
α : Type u_1
c : RBColor
n✝ : Nat
cut : α → Ordering
t a : RBNode α
c₁✝ : RBColor
n : Nat
b : RBNode α
c₂✝ : RBColor
v✝ : α
ha : Balanced a c₁✝ n
hb : Balanced b c₂✝ n
iha : DelProp (isBlack a) (del cut a) n
ihb : DelProp (isBlack b) (del cut b) n
⊢ RedRed True
    (match cut v✝ with
    | Ordering.lt =>
      match isBlack a with
      | black => balLeft (del cut a) v✝ b
      | red => node red (del cut a) v✝ b
    | Ordering.gt =>
      match isBlack b with
      | black => balRight a v✝ (del cut b)
      | red => node red a v✝ (del cut b)
    | Ordering.eq => append a b)
    n

tactic: exact match a, n, iha with
| .nil, _, ⟨c, ha⟩ | .node red .., _, ⟨c, ha⟩ => .redred ⟨⟩ ha hb
| .node black .., _, ⟨n, rfl, ha⟩ => (hb.balLeft ha).imp fun _ => ⟨⟩
state_before: case black.h_1
α : Type u_1
c : RBColor
n✝ : Nat
cut : α → Ordering
t a : RBNode α
c₁✝ : RBColor
n : Nat
b : RBNode α
c₂✝ : RBColor
v✝ : α
ha : Balanced a c₁✝ n
hb : Balanced b c₂✝ n
iha : DelProp (isBlack a) (del cut a) n
ihb : DelProp (isBlack b) (del cut b) n
x✝ : Ordering
heq✝ : cut v✝ = Ordering.lt
⊢ RedRed True
    (match isBlack a with
    | black => balLeft (del cut a) v✝ b
    | red => node red (del cut a) v✝ b)
    n

tactic: exact match b, n, ihb with
| .nil, _, ⟨c, hb⟩ | .node .red .., _, ⟨c, hb⟩ => .redred ⟨⟩ ha hb
| .node black .., _, ⟨n, rfl, hb⟩ => (ha.balRight hb).imp fun _ => ⟨⟩
state_before: case black.h_2
α : Type u_1
c : RBColor
n✝ : Nat
cut : α → Ordering
t a : RBNode α
c₁✝ : RBColor
n : Nat
b : RBNode α
c₂✝ : RBColor
v✝ : α
ha : Balanced a c₁✝ n
hb : Balanced b c₂✝ n
iha : DelProp (isBlack a) (del cut a) n
ihb : DelProp (isBlack b) (del cut b) n
x✝ : Ordering
heq✝ : cut v✝ = Ordering.gt
⊢ RedRed True
    (match isBlack b with
    | black => balRight a v✝ (del cut b)
    | red => node red a v✝ (del cut b))
    n

tactic: exact (ha.append hb).imp fun _ => ⟨⟩
state_before: case black.h_3
α : Type u_1
c : RBColor
n✝ : Nat
cut : α → Ordering
t a : RBNode α
c₁✝ : RBColor
n : Nat
b : RBNode α
c₂✝ : RBColor
v✝ : α
ha : Balanced a c₁✝ n
hb : Balanced b c₂✝ n
iha : DelProp (isBlack a) (del cut a) n
ihb : DelProp (isBlack b) (del cut b) n
x✝ : Ordering
heq✝ : cut v✝ = Ordering.eq
⊢ RedRed True (append a b) n

tactic: unfold del
state_before: case red
α : Type u_1
c : RBColor
n✝ : Nat
cut : α → Ordering
t a : RBNode α
n : Nat
b : RBNode α
v✝ : α
ha : Balanced a black n
hb : Balanced b black n
iha : DelProp (isBlack a) (del cut a) n
ihb : DelProp (isBlack b) (del cut b) n
⊢ DelProp (isBlack (node red a v✝ b)) (del cut (node red a v✝ b)) n

tactic: split
state_before: case red
α : Type u_1
c : RBColor
n✝ : Nat
cut : α → Ordering
t a : RBNode α
n : Nat
b : RBNode α
v✝ : α
ha : Balanced a black n
hb : Balanced b black n
iha : DelProp (isBlack a) (del cut a) n
ihb : DelProp (isBlack b) (del cut b) n
⊢ DelProp (isBlack (node red a v✝ b))
    (match cut v✝ with
    | Ordering.lt =>
      match isBlack a with
      | black => balLeft (del cut a) v✝ b
      | red => node red (del cut a) v✝ b
    | Ordering.gt =>
      match isBlack b with
      | black => balRight a v✝ (del cut b)
      | red => node red a v✝ (del cut b)
    | Ordering.eq => append a b)
    n

tactic: exact match a, n, iha with
| .nil, _, _ => ⟨_, .red ha hb⟩
| .node black .., _, ⟨n, rfl, ha⟩ => (hb.balLeft ha).of_false (fun.)
state_before: case red.h_1
α : Type u_1
c : RBColor
n✝ : Nat
cut : α → Ordering
t a : RBNode α
n : Nat
b : RBNode α
v✝ : α
ha : Balanced a black n
hb : Balanced b black n
iha : DelProp (isBlack a) (del cut a) n
ihb : DelProp (isBlack b) (del cut b) n
x✝ : Ordering
heq✝ : cut v✝ = Ordering.lt
⊢ DelProp (isBlack (node red a v✝ b))
    (match isBlack a with
    | black => balLeft (del cut a) v✝ b
    | red => node red (del cut a) v✝ b)
    n

tactic: exact match b, n, ihb with
| .nil, _, _ => ⟨_, .red ha hb⟩
| .node black .., _, ⟨n, rfl, hb⟩ => (ha.balRight hb).of_false (fun.)
state_before: case red.h_2
α : Type u_1
c : RBColor
n✝ : Nat
cut : α → Ordering
t a : RBNode α
n : Nat
b : RBNode α
v✝ : α
ha : Balanced a black n
hb : Balanced b black n
iha : DelProp (isBlack a) (del cut a) n
ihb : DelProp (isBlack b) (del cut b) n
x✝ : Ordering
heq✝ : cut v✝ = Ordering.gt
⊢ DelProp (isBlack (node red a v✝ b))
    (match isBlack b with
    | black => balRight a v✝ (del cut b)
    | red => node red a v✝ (del cut b))
    n