Theorem: Std.BinomialHeapImp.Heap.realSize_deleteMin
File: Std/Data/BinomialHeap.lean

tactic: cases s with cases eq | cons r a c s => ?_
state_before: α : Type u_1
le : α → α → Bool
a : α
s' s : Heap α
eq : deleteMin le s = some (a, s')
⊢ realSize s = realSize s' + 1

tactic: have : (s.findMin le (cons r a c) ⟨id, a, c, s⟩).HasSize (c.realSize + s.realSize + 1) :=
  Heap.realSize_findMin (c.realSize + 1) (by simp) (Nat.add_right_comm ..) ⟨0, by simp⟩
state_before: case cons.refl
α : Type u_1
le : α → α → Bool
r : Nat
a : α
c : HeapNode α
s : Heap α
⊢ realSize (cons r a c s) =
    realSize
        (merge le (HeapNode.toHeap (findMin le (cons r a c) s { before := id, val := a, node := c, next := s }).node)
          (FindMin.before (findMin le (cons r a c) s { before := id, val := a, node := c, next := s })
            (findMin le (cons r a c) s { before := id, val := a, node := c, next := s }).next)) +
      1

tactic: revert this
state_before: case cons.refl
α : Type u_1
le : α → α → Bool
r : Nat
a : α
c : HeapNode α
s : Heap α
this :
  Std.BinomialHeapImp.FindMin.HasSize (findMin le (cons r a c) s { before := id, val := a, node := c, next := s })
    (HeapNode.realSize c + realSize s + 1)
⊢ realSize (cons r a c s) =
    realSize
        (merge le (HeapNode.toHeap (findMin le (cons r a c) s { before := id, val := a, node := c, next := s }).node)
          (FindMin.before (findMin le (cons r a c) s { before := id, val := a, node := c, next := s })
            (findMin le (cons r a c) s { before := id, val := a, node := c, next := s }).next)) +
      1

tactic: match s.findMin le (cons r a c) ⟨id, a, c, s⟩ with
| { before, val, node, next } =>
  intro ⟨m, ih₁, ih₂⟩; dsimp only at ih₁ ih₂
  rw [realSize, Nat.add_right_comm, ih₂]
  simp only [realSize_merge, HeapNode.realSize_toHeap, ih₁, Nat.add_assoc, Nat.add_left_comm]
state_before: case cons.refl
α : Type u_1
le : α → α → Bool
r : Nat
a : α
c : HeapNode α
s : Heap α
⊢ Std.BinomialHeapImp.FindMin.HasSize (findMin le (cons r a c) s { before := id, val := a, node := c, next := s })
      (HeapNode.realSize c + realSize s + 1) →
    realSize (cons r a c s) =
      realSize
          (merge le (HeapNode.toHeap (findMin le (cons r a c) s { before := id, val := a, node := c, next := s }).node)
            (FindMin.before (findMin le (cons r a c) s { before := id, val := a, node := c, next := s })
              (findMin le (cons r a c) s { before := id, val := a, node := c, next := s }).next)) +
        1

tactic: simp
state_before: α : Type u_1
le : α → α → Bool
r : Nat
a : α
c : HeapNode α
s : Heap α
⊢ ∀ (s : Heap α), realSize (cons r a c s) = HeapNode.realSize c + 1 + realSize s

tactic: simp
state_before: α : Type u_1
le : α → α → Bool
r : Nat
a : α
c : HeapNode α
s : Heap α
⊢ (∀ (s_1 : Heap α),
      realSize (FindMin.before { before := id, val := a, node := c, next := s } s_1) = 0 + realSize s_1) ∧
    HeapNode.realSize c + realSize s + 1 =
      0 + HeapNode.realSize { before := id, val := a, node := c, next := s }.node +
          realSize { before := id, val := a, node := c, next := s }.next +
        1

tactic: intro ⟨m, ih₁, ih₂⟩
state_before: α : Type u_1
le : α → α → Bool
r : Nat
a : α
c : HeapNode α
s : Heap α
before : Heap α → Heap α
val : α
node : HeapNode α
next : Heap α
⊢ Std.BinomialHeapImp.FindMin.HasSize { before := before, val := val, node := node, next := next }
      (HeapNode.realSize c + realSize s + 1) →
    realSize (cons r a c s) =
      realSize
          (merge le (HeapNode.toHeap { before := before, val := val, node := node, next := next }.node)
            (FindMin.before { before := before, val := val, node := node, next := next }
              { before := before, val := val, node := node, next := next }.next)) +
        1

tactic: dsimp only at ih₁ ih₂
state_before: α : Type u_1
le : α → α → Bool
r : Nat
a : α
c : HeapNode α
s : Heap α
before : Heap α → Heap α
val : α
node : HeapNode α
next : Heap α
m : Nat
ih₁ :
  ∀ (s : Heap α),
    realSize (FindMin.before { before := before, val := val, node := node, next := next } s) = m + realSize s
ih₂ :
  HeapNode.realSize c + realSize s + 1 =
    m + HeapNode.realSize { before := before, val := val, node := node, next := next }.node +
        realSize { before := before, val := val, node := node, next := next }.next +
      1
⊢ realSize (cons r a c s) =
    realSize
        (merge le (HeapNode.toHeap { before := before, val := val, node := node, next := next }.node)
          (FindMin.before { before := before, val := val, node := node, next := next }
            { before := before, val := val, node := node, next := next }.next)) +
      1

tactic: rw [realSize, Nat.add_right_comm, ih₂]
state_before: α : Type u_1
le : α → α → Bool
r : Nat
a : α
c : HeapNode α
s : Heap α
before : Heap α → Heap α
val : α
node : HeapNode α
next : Heap α
m : Nat
ih₁ : ∀ (s : Heap α), realSize (before s) = m + realSize s
ih₂ : HeapNode.realSize c + realSize s + 1 = m + HeapNode.realSize node + realSize next + 1
⊢ realSize (cons r a c s) =
    realSize
        (merge le (HeapNode.toHeap { before := before, val := val, node := node, next := next }.node)
          (FindMin.before { before := before, val := val, node := node, next := next }
            { before := before, val := val, node := node, next := next }.next)) +
      1

tactic: simp only [realSize_merge, HeapNode.realSize_toHeap, ih₁, Nat.add_assoc, Nat.add_left_comm]
state_before: α : Type u_1
le : α → α → Bool
r : Nat
a : α
c : HeapNode α
s : Heap α
before : Heap α → Heap α
val : α
node : HeapNode α
next : Heap α
m : Nat
ih₁ : ∀ (s : Heap α), realSize (before s) = m + realSize s
ih₂ : HeapNode.realSize c + realSize s + 1 = m + HeapNode.realSize node + realSize next + 1
⊢ m + HeapNode.realSize node + realSize next + 1 =
    realSize
        (merge le (HeapNode.toHeap { before := before, val := val, node := node, next := next }.node)
          (FindMin.before { before := before, val := val, node := node, next := next }
            { before := before, val := val, node := node, next := next }.next)) +
      1