Theorem: Std.RBNode.Balanced.zoom
File: Std/Data/RBMap/Alter.lean

tactic: cases e
state_before: α✝ : Type u_1
cut : α✝ → Ordering
t : RBNode α✝
path : Path α✝
t' : RBNode α✝
path' : Path α✝
c₀ : RBColor
n₀ : Nat
c : RBColor
n : Nat
hp : Path.Balanced c₀ n₀ path black 0
e : zoom cut nil path = (t', path')
⊢ ∃ c n, Balanced t' c n ∧ Path.Balanced c₀ n₀ path' c n

tactic: exact ⟨_, _, .nil, hp⟩
state_before: case refl
α✝ : Type u_1
cut : α✝ → Ordering
t : RBNode α✝
path : Path α✝
c₀ : RBColor
n₀ : Nat
c : RBColor
n : Nat
hp : Path.Balanced c₀ n₀ path black 0
⊢ ∃ c n, Balanced nil c n ∧ Path.Balanced c₀ n₀ path c n

tactic: unfold zoom
state_before: α✝ : Type u_1
cut : α✝ → Ordering
t : RBNode α✝
path : Path α✝
t' : RBNode α✝
path' : Path α✝
c₀ : RBColor
n₀ : Nat
c : RBColor
n✝ n : Nat
x✝ y✝ : RBNode α✝
v✝ : α✝
ha : Balanced x✝ black n
hb : Balanced y✝ black n
hp : Path.Balanced c₀ n₀ path red n
⊢ zoom cut (node red x✝ v✝ y✝) path = (t', path') → ∃ c n, Balanced t' c n ∧ Path.Balanced c₀ n₀ path' c n

tactic: split
state_before: α✝ : Type u_1
cut : α✝ → Ordering
t : RBNode α✝
path : Path α✝
t' : RBNode α✝
path' : Path α✝
c₀ : RBColor
n₀ : Nat
c : RBColor
n✝ n : Nat
x✝ y✝ : RBNode α✝
v✝ : α✝
ha : Balanced x✝ black n
hb : Balanced y✝ black n
hp : Path.Balanced c₀ n₀ path red n
⊢ (match cut v✝ with
      | Ordering.lt => zoom cut x✝ (left red path v✝ y✝)
      | Ordering.gt => zoom cut y✝ (right red x✝ v✝ path)
      | Ordering.eq => (node red x✝ v✝ y✝, path)) =
      (t', path') →
    ∃ c n, Balanced t' c n ∧ Path.Balanced c₀ n₀ path' c n

tactic: exact ha.zoom (.redL hb hp)
state_before: case h_1
α✝ : Type u_1
cut : α✝ → Ordering
t : RBNode α✝
path : Path α✝
t' : RBNode α✝
path' : Path α✝
c₀ : RBColor
n₀ : Nat
c : RBColor
n✝ n : Nat
x✝¹ y✝ : RBNode α✝
v✝ : α✝
ha : Balanced x✝¹ black n
hb : Balanced y✝ black n
hp : Path.Balanced c₀ n₀ path red n
x✝ : Ordering
heq✝ : cut v✝ = Ordering.lt
⊢ zoom cut x✝¹ (left red path v✝ y✝) = (t', path') → ∃ c n, Balanced t' c n ∧ Path.Balanced c₀ n₀ path' c n

tactic: exact hb.zoom (.redR ha hp)
state_before: case h_2
α✝ : Type u_1
cut : α✝ → Ordering
t : RBNode α✝
path : Path α✝
t' : RBNode α✝
path' : Path α✝
c₀ : RBColor
n₀ : Nat
c : RBColor
n✝ n : Nat
x✝¹ y✝ : RBNode α✝
v✝ : α✝
ha : Balanced x✝¹ black n
hb : Balanced y✝ black n
hp : Path.Balanced c₀ n₀ path red n
x✝ : Ordering
heq✝ : cut v✝ = Ordering.gt
⊢ zoom cut y✝ (right red x✝¹ v✝ path) = (t', path') → ∃ c n, Balanced t' c n ∧ Path.Balanced c₀ n₀ path' c n

tactic: intro e
state_before: case h_3
α✝ : Type u_1
cut : α✝ → Ordering
t : RBNode α✝
path : Path α✝
t' : RBNode α✝
path' : Path α✝
c₀ : RBColor
n₀ : Nat
c : RBColor
n✝ n : Nat
x✝¹ y✝ : RBNode α✝
v✝ : α✝
ha : Balanced x✝¹ black n
hb : Balanced y✝ black n
hp : Path.Balanced c₀ n₀ path red n
x✝ : Ordering
heq✝ : cut v✝ = Ordering.eq
⊢ (node red x✝¹ v✝ y✝, path) = (t', path') → ∃ c n, Balanced t' c n ∧ Path.Balanced c₀ n₀ path' c n

tactic: cases e
state_before: case h_3
α✝ : Type u_1
cut : α✝ → Ordering
t : RBNode α✝
path : Path α✝
t' : RBNode α✝
path' : Path α✝
c₀ : RBColor
n₀ : Nat
c : RBColor
n✝ n : Nat
x✝¹ y✝ : RBNode α✝
v✝ : α✝
ha : Balanced x✝¹ black n
hb : Balanced y✝ black n
hp : Path.Balanced c₀ n₀ path red n
x✝ : Ordering
heq✝ : cut v✝ = Ordering.eq
e : (node red x✝¹ v✝ y✝, path) = (t', path')
⊢ ∃ c n, Balanced t' c n ∧ Path.Balanced c₀ n₀ path' c n

tactic: exact ⟨_, _, .red ha hb, hp⟩
state_before: case h_3.refl
α✝ : Type u_1
cut : α✝ → Ordering
t : RBNode α✝
path : Path α✝
c₀ : RBColor
n₀ : Nat
c : RBColor
n✝ n : Nat
x✝¹ y✝ : RBNode α✝
v✝ : α✝
ha : Balanced x✝¹ black n
hb : Balanced y✝ black n
hp : Path.Balanced c₀ n₀ path red n
x✝ : Ordering
heq✝ : cut v✝ = Ordering.eq
⊢ ∃ c n, Balanced (node red x✝¹ v✝ y✝) c n ∧ Path.Balanced c₀ n₀ path c n

tactic: unfold zoom
state_before: α✝ : Type u_1
cut : α✝ → Ordering
t : RBNode α✝
path : Path α✝
t' : RBNode α✝
path' : Path α✝
c₀ : RBColor
n₀ : Nat
c : RBColor
n : Nat
x✝ : RBNode α✝
c₁✝ : RBColor
n✝ : Nat
y✝ : RBNode α✝
c₂✝ : RBColor
v✝ : α✝
ha : Balanced x✝ c₁✝ n✝
hb : Balanced y✝ c₂✝ n✝
hp : Path.Balanced c₀ n₀ path black (n✝ + 1)
⊢ zoom cut (node black x✝ v✝ y✝) path = (t', path') → ∃ c n, Balanced t' c n ∧ Path.Balanced c₀ n₀ path' c n

tactic: split
state_before: α✝ : Type u_1
cut : α✝ → Ordering
t : RBNode α✝
path : Path α✝
t' : RBNode α✝
path' : Path α✝
c₀ : RBColor
n₀ : Nat
c : RBColor
n : Nat
x✝ : RBNode α✝
c₁✝ : RBColor
n✝ : Nat
y✝ : RBNode α✝
c₂✝ : RBColor
v✝ : α✝
ha : Balanced x✝ c₁✝ n✝
hb : Balanced y✝ c₂✝ n✝
hp : Path.Balanced c₀ n₀ path black (n✝ + 1)
⊢ (match cut v✝ with
      | Ordering.lt => zoom cut x✝ (left black path v✝ y✝)
      | Ordering.gt => zoom cut y✝ (right black x✝ v✝ path)
      | Ordering.eq => (node black x✝ v✝ y✝, path)) =
      (t', path') →
    ∃ c n, Balanced t' c n ∧ Path.Balanced c₀ n₀ path' c n

tactic: exact ha.zoom (.blackL hb hp)
state_before: case h_1
α✝ : Type u_1
cut : α✝ → Ordering
t : RBNode α✝
path : Path α✝
t' : RBNode α✝
path' : Path α✝
c₀ : RBColor
n₀ : Nat
c : RBColor
n : Nat
x✝¹ : RBNode α✝
c₁✝ : RBColor
n✝ : Nat
y✝ : RBNode α✝
c₂✝ : RBColor
v✝ : α✝
ha : Balanced x✝¹ c₁✝ n✝
hb : Balanced y✝ c₂✝ n✝
hp : Path.Balanced c₀ n₀ path black (n✝ + 1)
x✝ : Ordering
heq✝ : cut v✝ = Ordering.lt
⊢ zoom cut x✝¹ (left black path v✝ y✝) = (t', path') → ∃ c n, Balanced t' c n ∧ Path.Balanced c₀ n₀ path' c n

tactic: exact hb.zoom (.blackR ha hp)
state_before: case h_2
α✝ : Type u_1
cut : α✝ → Ordering
t : RBNode α✝
path : Path α✝
t' : RBNode α✝
path' : Path α✝
c₀ : RBColor
n₀ : Nat
c : RBColor
n : Nat
x✝¹ : RBNode α✝
c₁✝ : RBColor
n✝ : Nat
y✝ : RBNode α✝
c₂✝ : RBColor
v✝ : α✝
ha : Balanced x✝¹ c₁✝ n✝
hb : Balanced y✝ c₂✝ n✝
hp : Path.Balanced c₀ n₀ path black (n✝ + 1)
x✝ : Ordering
heq✝ : cut v✝ = Ordering.gt
⊢ zoom cut y✝ (right black x✝¹ v✝ path) = (t', path') → ∃ c n, Balanced t' c n ∧ Path.Balanced c₀ n₀ path' c n

tactic: intro e
state_before: case h_3
α✝ : Type u_1
cut : α✝ → Ordering
t : RBNode α✝
path : Path α✝
t' : RBNode α✝
path' : Path α✝
c₀ : RBColor
n₀ : Nat
c : RBColor
n : Nat
x✝¹ : RBNode α✝
c₁✝ : RBColor
n✝ : Nat
y✝ : RBNode α✝
c₂✝ : RBColor
v✝ : α✝
ha : Balanced x✝¹ c₁✝ n✝
hb : Balanced y✝ c₂✝ n✝
hp : Path.Balanced c₀ n₀ path black (n✝ + 1)
x✝ : Ordering
heq✝ : cut v✝ = Ordering.eq
⊢ (node black x✝¹ v✝ y✝, path) = (t', path') → ∃ c n, Balanced t' c n ∧ Path.Balanced c₀ n₀ path' c n

tactic: cases e
state_before: case h_3
α✝ : Type u_1
cut : α✝ → Ordering
t : RBNode α✝
path : Path α✝
t' : RBNode α✝
path' : Path α✝
c₀ : RBColor
n₀ : Nat
c : RBColor
n : Nat
x✝¹ : RBNode α✝
c₁✝ : RBColor
n✝ : Nat
y✝ : RBNode α✝
c₂✝ : RBColor
v✝ : α✝
ha : Balanced x✝¹ c₁✝ n✝
hb : Balanced y✝ c₂✝ n✝
hp : Path.Balanced c₀ n₀ path black (n✝ + 1)
x✝ : Ordering
heq✝ : cut v✝ = Ordering.eq
e : (node black x✝¹ v✝ y✝, path) = (t', path')
⊢ ∃ c n, Balanced t' c n ∧ Path.Balanced c₀ n₀ path' c n

tactic: exact ⟨_, _, .black ha hb, hp⟩
state_before: case h_3.refl
α✝ : Type u_1
cut : α✝ → Ordering
t : RBNode α✝
path : Path α✝
c₀ : RBColor
n₀ : Nat
c : RBColor
n : Nat
x✝¹ : RBNode α✝
c₁✝ : RBColor
n✝ : Nat
y✝ : RBNode α✝
c₂✝ : RBColor
v✝ : α✝
ha : Balanced x✝¹ c₁✝ n✝
hb : Balanced y✝ c₂✝ n✝
hp : Path.Balanced c₀ n₀ path black (n✝ + 1)
x✝ : Ordering
heq✝ : cut v✝ = Ordering.eq
⊢ ∃ c n, Balanced (node black x✝¹ v✝ y✝) c n ∧ Path.Balanced c₀ n₀ path c n