Theorem: Std.RBNode.Path.zoom_ins
File: Std/Data/RBMap/Alter.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') → ins path (RBNode.ins cmp v t) = ins path' (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') →
    ins path
        (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 => balance1 (RBNode.ins cmp v a) y b
          | Ordering.gt => balance2 a y (RBNode.ins cmp v b)
          | Ordering.eq => node black a v b) =
      ins path' (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' → ins path (node red nil v nil) = ins path' (setRoot v t')

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

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') →
    ins path
        (match cmp v y✝ with
        | Ordering.lt => balance1 (RBNode.ins cmp v a✝) y✝ b✝
        | Ordering.gt => balance2 a✝ y✝ (RBNode.ins cmp v b✝)
        | Ordering.eq => node black a✝ v b✝) =
      ins path' (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') →
    ins path (balance1 (RBNode.ins cmp v a✝) y✝ b✝) = ins path' (setRoot v t')

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') →
    ins path (balance2 a✝ y✝ (RBNode.ins cmp v b✝)) = ins path' (setRoot v t')

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') → ins path (node black a✝ v b✝) = ins path' (setRoot v t')

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')
⊢ ins path (node black a✝ v b✝) = ins path (setRoot v (node black a✝ y✝ b✝))