Theorem: Std.RBNode.Path.zoom_del
File: Std/Data/RBMap/Alter.lean

tactic: unfold RBNode.del
state_before: α : Type u_1
cut : α → Ordering
path : Path α
t' : RBNode α
path' : Path α
t : RBNode α
⊢ zoom cut t path = (t', path') →
    del path (RBNode.del cut t)
        (match t with
        | node c l v r => c
        | x => red) =
      del path' (delRoot t')
        (match t' with
        | node c l v r => c
        | x => red)

tactic: split <;> simp [zoom]
state_before: α : Type u_1
cut : α → Ordering
path : Path α
t' : RBNode α
path' : Path α
t : RBNode α
⊢ zoom cut t path = (t', path') →
    del path
        (match t with
        | nil => nil
        | node c a y b =>
          match cut y with
          | Ordering.lt =>
            match isBlack a with
            | black => balLeft (RBNode.del cut a) y b
            | red => node red (RBNode.del cut a) y b
          | Ordering.gt =>
            match isBlack b with
            | black => balRight a y (RBNode.del cut b)
            | red => node red a y (RBNode.del cut b)
          | Ordering.eq => append a b)
        (match t with
        | node c l v r => c
        | x => red) =
      del path' (delRoot t')
        (match t' with
        | node c l v r => c
        | x => red)

tactic: intro | rfl, rfl => rfl
state_before: case h_1
α : Type u_1
cut : α → Ordering
path : Path α
t' : RBNode α
path' : Path α
x✝ : RBNode α
⊢ nil = t' →
    path = path' →
      del path nil red =
        del path' (delRoot t')
          (match t' with
          | node c l v r => c
          | x => red)

tactic: rfl
state_before: α : Type u_1
cut : α → Ordering
path : Path α
t' : RBNode α
path' : Path α
x✝² : RBNode α
x✝¹ : nil = t'
x✝ : path = path'
⊢ del path nil red =
    del path (delRoot nil)
      (match nil with
      | node c l v r => c
      | x => red)

tactic: split
state_before: α : Type u_1
cut : α → Ordering
path : Path α
t' : RBNode α
path' : Path α
x✝ : RBNode α
c : RBColor
a : RBNode α
y : α
b : RBNode α
⊢ (match cut y with
      | Ordering.lt => zoom cut a (left c path y b)
      | Ordering.gt => zoom cut b (right c a y path)
      | Ordering.eq => (node c a y b, path)) =
      (t', path') →
    del path
        (match cut y with
        | Ordering.lt =>
          match isBlack a with
          | black => balLeft (RBNode.del cut a) y b
          | red => node red (RBNode.del cut a) y b
        | Ordering.gt =>
          match isBlack b with
          | black => balRight a y (RBNode.del cut b)
          | red => node red a y (RBNode.del cut b)
        | Ordering.eq => append a b)
        c =
      del path' (delRoot t')
        (match t' with
        | node c l v r => c
        | x => red)

tactic: have IH := @zoom_del (t := a)
state_before: case h_1
α : Type u_1
cut : α → Ordering
path : Path α
t' : RBNode α
path' : Path α
x✝¹ : RBNode α
c : RBColor
a : RBNode α
y : α
b : RBNode α
x✝ : Ordering
heq✝ : cut y = Ordering.lt
⊢ zoom cut a (left c path y b) = (t', path') →
    del path
        (match isBlack a with
        | black => balLeft (RBNode.del cut a) y b
        | red => node red (RBNode.del cut a) y b)
        c =
      del path' (delRoot t')
        (match t' with
        | node c l v r => c
        | x => red)

tactic: match a with
| nil => intro | rfl => rfl
| node black .. | node red .. => apply IH
state_before: case h_1
α : Type u_1
cut : α → Ordering
path : Path α
t' : RBNode α
path' : Path α
x✝¹ : RBNode α
c : RBColor
a : RBNode α
y : α
b : RBNode α
x✝ : Ordering
heq✝ : cut y = Ordering.lt
IH :
  ∀ (cut : α → Ordering) (path : Path α) (t' : RBNode α) (path' : Path α),
    zoom cut a path = (t', path') →
      del path (RBNode.del cut a)
          (match a with
          | node c l v r => c
          | x => red) =
        del path' (delRoot t')
          (match t' with
          | node c l v r => c
          | x => red)
⊢ zoom cut a (left c path y b) = (t', path') →
    del path
        (match isBlack a with
        | black => balLeft (RBNode.del cut a) y b
        | red => node red (RBNode.del cut a) y b)
        c =
      del path' (delRoot t')
        (match t' with
        | node c l v r => c
        | x => red)

tactic: intro | rfl => rfl
state_before: α : Type u_1
cut : α → Ordering
path : Path α
t' : RBNode α
path' : Path α
x✝¹ : RBNode α
c : RBColor
a : RBNode α
y : α
b : RBNode α
x✝ : Ordering
heq✝ : cut y = Ordering.lt
IH :
  ∀ (cut : α → Ordering) (path : Path α) (t' : RBNode α) (path' : Path α),
    zoom cut nil path = (t', path') →
      del path (RBNode.del cut nil)
          (match nil with
          | node c l v r => c
          | x => red) =
        del path' (delRoot t')
          (match t' with
          | node c l v r => c
          | x => red)
⊢ zoom cut nil (left c path y b) = (t', path') →
    del path
        (match isBlack nil with
        | black => balLeft (RBNode.del cut nil) y b
        | red => node red (RBNode.del cut nil) y b)
        c =
      del path' (delRoot t')
        (match t' with
        | node c l v r => c
        | x => red)

tactic: rfl
state_before: α : Type u_1
cut : α → Ordering
path : Path α
t' : RBNode α
path' : Path α
x✝² : RBNode α
c : RBColor
a : RBNode α
y : α
b : RBNode α
x✝¹ : Ordering
heq✝ : cut y = Ordering.lt
IH :
  ∀ (cut : α → Ordering) (path : Path α) (t' : RBNode α) (path' : Path α),
    zoom cut nil path = (t', path') →
      del path (RBNode.del cut nil)
          (match nil with
          | node c l v r => c
          | x => red) =
        del path' (delRoot t')
          (match t' with
          | node c l v r => c
          | x => red)
x✝ : zoom cut nil (left c path y b) = (t', path')
⊢ del path
      (match isBlack nil with
      | black => balLeft (RBNode.del cut nil) y b
      | red => node red (RBNode.del cut nil) y b)
      c =
    del (left c path y b) (delRoot nil)
      (match nil with
      | node c l v r => c
      | x => red)

tactic: apply IH
state_before: α : Type u_1
cut : α → Ordering
path : Path α
t' : RBNode α
path' : Path α
x✝¹ : RBNode α
c : RBColor
a : RBNode α
y : α
b : RBNode α
x✝ : Ordering
heq✝ : cut y = Ordering.lt
l✝ : RBNode α
v✝ : α
r✝ : RBNode α
IH :
  ∀ (cut : α → Ordering) (path : Path α) (t' : RBNode α) (path' : Path α),
    zoom cut (node red l✝ v✝ r✝) path = (t', path') →
      del path (RBNode.del cut (node red l✝ v✝ r✝))
          (match node red l✝ v✝ r✝ with
          | node c l v r => c
          | x => red) =
        del path' (delRoot t')
          (match t' with
          | node c l v r => c
          | x => red)
⊢ zoom cut (node red l✝ v✝ r✝) (left c path y b) = (t', path') →
    del path
        (match isBlack (node red l✝ v✝ r✝) with
        | black => balLeft (RBNode.del cut (node red l✝ v✝ r✝)) y b
        | red => node red (RBNode.del cut (node red l✝ v✝ r✝)) y b)
        c =
      del path' (delRoot t')
        (match t' with
        | node c l v r => c
        | x => red)

tactic: have IH := @zoom_del (t := b)
state_before: case h_2
α : Type u_1
cut : α → Ordering
path : Path α
t' : RBNode α
path' : Path α
x✝¹ : RBNode α
c : RBColor
a : RBNode α
y : α
b : RBNode α
x✝ : Ordering
heq✝ : cut y = Ordering.gt
⊢ zoom cut b (right c a y path) = (t', path') →
    del path
        (match isBlack b with
        | black => balRight a y (RBNode.del cut b)
        | red => node red a y (RBNode.del cut b))
        c =
      del path' (delRoot t')
        (match t' with
        | node c l v r => c
        | x => red)

tactic: match b with
| nil => intro | rfl => rfl
| node black .. | node red .. => apply IH
state_before: case h_2
α : Type u_1
cut : α → Ordering
path : Path α
t' : RBNode α
path' : Path α
x✝¹ : RBNode α
c : RBColor
a : RBNode α
y : α
b : RBNode α
x✝ : Ordering
heq✝ : cut y = Ordering.gt
IH :
  ∀ (cut : α → Ordering) (path : Path α) (t' : RBNode α) (path' : Path α),
    zoom cut b path = (t', path') →
      del path (RBNode.del cut b)
          (match b with
          | node c l v r => c
          | x => red) =
        del path' (delRoot t')
          (match t' with
          | node c l v r => c
          | x => red)
⊢ zoom cut b (right c a y path) = (t', path') →
    del path
        (match isBlack b with
        | black => balRight a y (RBNode.del cut b)
        | red => node red a y (RBNode.del cut b))
        c =
      del path' (delRoot t')
        (match t' with
        | node c l v r => c
        | x => red)

tactic: intro | rfl => rfl
state_before: α : Type u_1
cut : α → Ordering
path : Path α
t' : RBNode α
path' : Path α
x✝¹ : RBNode α
c : RBColor
a : RBNode α
y : α
b : RBNode α
x✝ : Ordering
heq✝ : cut y = Ordering.gt
IH :
  ∀ (cut : α → Ordering) (path : Path α) (t' : RBNode α) (path' : Path α),
    zoom cut nil path = (t', path') →
      del path (RBNode.del cut nil)
          (match nil with
          | node c l v r => c
          | x => red) =
        del path' (delRoot t')
          (match t' with
          | node c l v r => c
          | x => red)
⊢ zoom cut nil (right c a y path) = (t', path') →
    del path
        (match isBlack nil with
        | black => balRight a y (RBNode.del cut nil)
        | red => node red a y (RBNode.del cut nil))
        c =
      del path' (delRoot t')
        (match t' with
        | node c l v r => c
        | x => red)

tactic: rfl
state_before: α : Type u_1
cut : α → Ordering
path : Path α
t' : RBNode α
path' : Path α
x✝² : RBNode α
c : RBColor
a : RBNode α
y : α
b : RBNode α
x✝¹ : Ordering
heq✝ : cut y = Ordering.gt
IH :
  ∀ (cut : α → Ordering) (path : Path α) (t' : RBNode α) (path' : Path α),
    zoom cut nil path = (t', path') →
      del path (RBNode.del cut nil)
          (match nil with
          | node c l v r => c
          | x => red) =
        del path' (delRoot t')
          (match t' with
          | node c l v r => c
          | x => red)
x✝ : zoom cut nil (right c a y path) = (t', path')
⊢ del path
      (match isBlack nil with
      | black => balRight a y (RBNode.del cut nil)
      | red => node red a y (RBNode.del cut nil))
      c =
    del (right c a y path) (delRoot nil)
      (match nil with
      | node c l v r => c
      | x => red)

tactic: apply IH
state_before: α : Type u_1
cut : α → Ordering
path : Path α
t' : RBNode α
path' : Path α
x✝¹ : RBNode α
c : RBColor
a : RBNode α
y : α
b : RBNode α
x✝ : Ordering
heq✝ : cut y = Ordering.gt
l✝ : RBNode α
v✝ : α
r✝ : RBNode α
IH :
  ∀ (cut : α → Ordering) (path : Path α) (t' : RBNode α) (path' : Path α),
    zoom cut (node red l✝ v✝ r✝) path = (t', path') →
      del path (RBNode.del cut (node red l✝ v✝ r✝))
          (match node red l✝ v✝ r✝ with
          | node c l v r => c
          | x => red) =
        del path' (delRoot t')
          (match t' with
          | node c l v r => c
          | x => red)
⊢ zoom cut (node red l✝ v✝ r✝) (right c a y path) = (t', path') →
    del path
        (match isBlack (node red l✝ v✝ r✝) with
        | black => balRight a y (RBNode.del cut (node red l✝ v✝ r✝))
        | red => node red a y (RBNode.del cut (node red l✝ v✝ r✝)))
        c =
      del path' (delRoot t')
        (match t' with
        | node c l v r => c
        | x => red)

tactic: intro | rfl => rfl
state_before: case h_3
α : Type u_1
cut : α → Ordering
path : Path α
t' : RBNode α
path' : Path α
x✝¹ : RBNode α
c : RBColor
a : RBNode α
y : α
b : RBNode α
x✝ : Ordering
heq✝ : cut y = Ordering.eq
⊢ (node c a y b, path) = (t', path') →
    del path (append a b) c =
      del path' (delRoot t')
        (match t' with
        | node c l v r => c
        | x => red)

tactic: rfl
state_before: α : Type u_1
cut : α → Ordering
path : Path α
t' : RBNode α
path' : Path α
x✝² : RBNode α
c : RBColor
a : RBNode α
y : α
b : RBNode α
x✝¹ : Ordering
heq✝ : cut y = Ordering.eq
x✝ : (node c a y b, path) = (t', path')
⊢ del path (append a b) c =
    del path (delRoot (node c a y b))
      (match node c a y b with
      | node c l v r => c
      | x => red)