Theorem: Batteries.RBNode.Path.zoom_ins
File: .lake/packages/batteries/Batteries/Data/RBMap/Lemmas.lean

tactic: unfold RBNode.ins
state_before: α : Type u_1
v : α
path : Path α
t' : RBNode α
path' : Path α
t : RBNode α
cmp : α → α → Ordering
⊢ zoom (cmp v) t path = (t', path') → path.ins (RBNode.ins cmp v t) = path'.ins (setRoot v t')
state_after: α : Type u_1
v : α
path : Path α
t' : RBNode α
path' : Path α
t : RBNode α
cmp : α → α → Ordering
⊢ zoom (cmp v) t path = (t', path') →
    path.ins
        (match t with
        | nil => node red nil v nil
        | node red a y b =>
          match cmp v y with
          | Ordering.lt => node red (RBNode.ins cmp v a) y b
          | Ordering.gt => node red a y (RBNode.ins cmp v b)
          | Ordering.eq => node red a v b
        | node black a y b =>
          match cmp v y with
          | Ordering.lt => (RBNode.ins cmp v a).balance1 y b
          | Ordering.gt => a.balance2 y (RBNode.ins cmp v b)
          | Ordering.eq => node black a v b) =
      path'.ins (setRoot v t')

tactic: split <;> simp [zoom]
state_before: α : Type u_1
v : α
path : Path α
t' : RBNode α
path' : Path α
t : RBNode α
cmp : α → α → Ordering
⊢ zoom (cmp v) t path = (t', path') →
    path.ins
        (match t with
        | nil => node red nil v nil
        | node red a y b =>
          match cmp v y with
          | Ordering.lt => node red (RBNode.ins cmp v a) y b
          | Ordering.gt => node red a y (RBNode.ins cmp v b)
          | Ordering.eq => node red a v b
        | node black a y b =>
          match cmp v y with
          | Ordering.lt => (RBNode.ins cmp v a).balance1 y b
          | Ordering.gt => a.balance2 y (RBNode.ins cmp v b)
          | Ordering.eq => node black a v b) =
      path'.ins (setRoot v t')
state_after: case h_1
α : Type u_1
v : α
path : Path α
t' : RBNode α
path' : Path α
cmp : α → α → Ordering
x✝ : RBNode α
⊢ nil = t' → path = path' → path.ins (node red nil v nil) = path'.ins (setRoot v t')

case h_2
α : Type u_1
v : α
path : Path α
t' : RBNode α
path' : Path α
cmp : α → α → Ordering
x✝ a✝ : RBNode α
y✝ : α
b✝ : RBNode α
⊢ (match cmp v y✝ with
      | Ordering.lt => zoom (cmp v) a✝ (left red path y✝ b✝)
      | Ordering.gt => zoom (cmp v) b✝ (right red a✝ y✝ path)
      | Ordering.eq => (node red a✝ y✝ b✝, path)) =
      (t', path') →
    path.ins
        (match cmp v y✝ with
        | Ordering.lt => node red (RBNode.ins cmp v a✝) y✝ b✝
        | Ordering.gt => node red a✝ y✝ (RBNode.ins cmp v b✝)
        | Ordering.eq => node red a✝ v b✝) =
      path'.ins (setRoot v t')

case h_3
α : Type u_1
v : α
path : Path α
t' : RBNode α
path' : Path α
cmp : α → α → Ordering
x✝ a✝ : RBNode α
y✝ : α
b✝ : RBNode α
⊢ (match cmp v y✝ with
      | Ordering.lt => zoom (cmp v) a✝ (left black path y✝ b✝)
      | Ordering.gt => zoom (cmp v) b✝ (right black a✝ y✝ path)
      | Ordering.eq => (node black a✝ y✝ b✝, path)) =
      (t', path') →
    path.ins
        (match cmp v y✝ with
        | Ordering.lt => (RBNode.ins cmp v a✝).balance1 y✝ b✝
        | Ordering.gt => a✝.balance2 y✝ (RBNode.ins cmp v b✝)
        | Ordering.eq => node black a✝ v b✝) =
      path'.ins (setRoot v t')

tactic: intro | rfl, rfl => rfl
state_before: case h_1
α : Type u_1
v : α
path : Path α
t' : RBNode α
path' : Path α
cmp : α → α → Ordering
x✝ : RBNode α
⊢ nil = t' → path = path' → path.ins (node red nil v nil) = path'.ins (setRoot v t')
state_after: no goals

tactic: rfl
state_before: α : Type u_1
v : α
path : Path α
t' : RBNode α
path' : Path α
cmp : α → α → Ordering
x✝² : RBNode α
x✝¹ : nil = t'
x✝ : path = path'
⊢ path.ins (node red nil v nil) = path.ins (setRoot v nil)
state_after: no goals

tactic: split
state_before: case h_3
α : Type u_1
v : α
path : Path α
t' : RBNode α
path' : Path α
cmp : α → α → Ordering
x✝ a✝ : RBNode α
y✝ : α
b✝ : RBNode α
⊢ (match cmp v y✝ with
      | Ordering.lt => zoom (cmp v) a✝ (left black path y✝ b✝)
      | Ordering.gt => zoom (cmp v) b✝ (right black a✝ y✝ path)
      | Ordering.eq => (node black a✝ y✝ b✝, path)) =
      (t', path') →
    path.ins
        (match cmp v y✝ with
        | Ordering.lt => (RBNode.ins cmp v a✝).balance1 y✝ b✝
        | Ordering.gt => a✝.balance2 y✝ (RBNode.ins cmp v b✝)
        | Ordering.eq => node black a✝ v b✝) =
      path'.ins (setRoot v t')
state_after: case h_3.h_1
α : Type u_1
v : α
path : Path α
t' : RBNode α
path' : Path α
cmp : α → α → Ordering
x✝¹ a✝ : RBNode α
y✝ : α
b✝ : RBNode α
x✝ : Ordering
heq✝ : cmp v y✝ = Ordering.lt
⊢ zoom (cmp v) a✝ (left black path y✝ b✝) = (t', path') →
    path.ins ((RBNode.ins cmp v a✝).balance1 y✝ b✝) = path'.ins (setRoot v t')

case h_3.h_2
α : Type u_1
v : α
path : Path α
t' : RBNode α
path' : Path α
cmp : α → α → Ordering
x✝¹ a✝ : RBNode α
y✝ : α
b✝ : RBNode α
x✝ : Ordering
heq✝ : cmp v y✝ = Ordering.gt
⊢ zoom (cmp v) b✝ (right black a✝ y✝ path) = (t', path') →
    path.ins (a✝.balance2 y✝ (RBNode.ins cmp v b✝)) = path'.ins (setRoot v t')

case h_3.h_3
α : Type u_1
v : α
path : Path α
t' : RBNode α
path' : Path α
cmp : α → α → Ordering
x✝¹ a✝ : RBNode α
y✝ : α
b✝ : RBNode α
x✝ : Ordering
heq✝ : cmp v y✝ = Ordering.eq
⊢ (node black a✝ y✝ b✝, path) = (t', path') → path.ins (node black a✝ v b✝) = path'.ins (setRoot v t')

tactic: exact zoom_ins
state_before: case h_3.h_1
α : Type u_1
v : α
path : Path α
t' : RBNode α
path' : Path α
cmp : α → α → Ordering
x✝¹ a✝ : RBNode α
y✝ : α
b✝ : RBNode α
x✝ : Ordering
heq✝ : cmp v y✝ = Ordering.lt
⊢ zoom (cmp v) a✝ (left black path y✝ b✝) = (t', path') →
    path.ins ((RBNode.ins cmp v a✝).balance1 y✝ b✝) = path'.ins (setRoot v t')
state_after: no goals

tactic: exact zoom_ins
state_before: case h_3.h_2
α : Type u_1
v : α
path : Path α
t' : RBNode α
path' : Path α
cmp : α → α → Ordering
x✝¹ a✝ : RBNode α
y✝ : α
b✝ : RBNode α
x✝ : Ordering
heq✝ : cmp v y✝ = Ordering.gt
⊢ zoom (cmp v) b✝ (right black a✝ y✝ path) = (t', path') →
    path.ins (a✝.balance2 y✝ (RBNode.ins cmp v b✝)) = path'.ins (setRoot v t')
state_after: no goals

tactic: intro | rfl => rfl
state_before: case h_3.h_3
α : Type u_1
v : α
path : Path α
t' : RBNode α
path' : Path α
cmp : α → α → Ordering
x✝¹ a✝ : RBNode α
y✝ : α
b✝ : RBNode α
x✝ : Ordering
heq✝ : cmp v y✝ = Ordering.eq
⊢ (node black a✝ y✝ b✝, path) = (t', path') → path.ins (node black a✝ v b✝) = path'.ins (setRoot v t')
state_after: no goals

tactic: rfl
state_before: α : Type u_1
v : α
path : Path α
t' : RBNode α
path' : Path α
cmp : α → α → Ordering
x✝² a✝ : RBNode α
y✝ : α
b✝ : RBNode α
x✝¹ : Ordering
heq✝ : cmp v y✝ = Ordering.eq
x✝ : (node black a✝ y✝ b✝, path) = (t', path')
⊢ path.ins (node black a✝ v b✝) = path.ins (setRoot v (node black a✝ y✝ b✝))
state_after: no goals