-- Mathlib/.lake/packages/batteries/Batteries/Data/RBMap/Lemmas.lean
theorem zoom_del {t : RBNode α} :
    t.zoom cut path = (t', path') →
    path.del (t.del cut) (match t with | node c .. => c | _ => red) =
    path'.del t'.delRoot (match t' with | node c .. => c | _ => red)

Proof state:
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') →
    path.del
        (match a.isBlack with
        | black => (RBNode.del cut a).balLeft y b
        | red => node red (RBNode.del cut a) y b)
        c =
      path'.del t'.delRoot
        (match t' with
        | node c l v r => c
        | x => red)

Tactic:
have IH := @zoom_del (t := a)

Result:
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') →
      path.del (RBNode.del cut a)
          (match a with
          | node c l v r => c
          | x => red) =
        path'.del t'.delRoot
          (match t' with
          | node c l v r => c
          | x => red)
⊢ zoom cut a (left c path y b) = (t', path') →
    path.del
        (match a.isBlack with
        | black => (RBNode.del cut a).balLeft y b
        | red => node red (RBNode.del cut a) y b)
        c =
      path'.del t'.delRoot
        (match t' with
        | node c l v r => c
        | x => red)

Proof state:
α : 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') →
      path.del (RBNode.del cut nil)
          (match nil with
          | node c l v r => c
          | x => red) =
        path'.del t'.delRoot
          (match t' with
          | node c l v r => c
          | x => red)
⊢ zoom cut nil (right c a y path) = (t', path') →
    path.del
        (match nil.isBlack with
        | black => a.balRight y (RBNode.del cut nil)
        | red => node red a y (RBNode.del cut nil))
        c =
      path'.del t'.delRoot
        (match t' with
        | node c l v r => c
        | x => red)

Tactic:
intro | rfl => rfl

Result:
no goals

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

Tactic:
split <;> simp [zoom]

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

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

Proof state:
α : 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') →
    path.del
        (match cut y with
        | Ordering.lt =>
          match a.isBlack with
          | black => (RBNode.del cut a).balLeft y b
          | red => node red (RBNode.del cut a) y b
        | Ordering.gt =>
          match b.isBlack with
          | black => a.balRight y (RBNode.del cut b)
          | red => node red a y (RBNode.del cut b)
        | Ordering.eq => a.append b)
        c =
      path'.del t'.delRoot
        (match t' with
        | node c l v r => c
        | x => red)

Tactic:
split

Result:
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') →
    path.del
        (match a.isBlack with
        | black => (RBNode.del cut a).balLeft y b
        | red => node red (RBNode.del cut a) y b)
        c =
      path'.del t'.delRoot
        (match t' with
        | node c l v r => c
        | x => red)

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') →
    path.del
        (match b.isBlack with
        | black => a.balRight y (RBNode.del cut b)
        | red => node red a y (RBNode.del cut b))
        c =
      path'.del t'.delRoot
        (match t' with
        | node c l v r => c
        | x => red)

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') →
    path.del (a.append b) c =
      path'.del t'.delRoot
        (match t' with
        | node c l v r => c
        | x => red)

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

Tactic:
intro | rfl, rfl => rfl

Result:
no goals

Proof state:
α : 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') →
      path.del (RBNode.del cut nil)
          (match nil with
          | node c l v r => c
          | x => red) =
        path'.del t'.delRoot
          (match t' with
          | node c l v r => c
          | x => red)
x✝ : zoom cut nil (right c a y path) = (t', path')
⊢ path.del
      (match nil.isBlack with
      | black => a.balRight y (RBNode.del cut nil)
      | red => node red a y (RBNode.del cut nil))
      c =
    (right c a y path).del nil.delRoot
      (match nil with
      | node c l v r => c
      | x => red)

Tactic:
rfl

Result:
no goals