Theorem: Batteries.BinomialHeap.Imp.Heap.realSize_deleteMin
File: .lake/packages/batteries/Batteries/Data/BinomialHeap/Basic.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')
⊢ s.realSize = s'.realSize + 1
state_after: case cons.refl
α : Type u_1
le : α → α → Bool
r : Nat
a : α
c : HeapNode α
s : Heap α
⊢ (cons r a c s).realSize =
    (merge le (findMin le (cons r a c) s { before := id, val := a, node := c, next := s }).node.toHeap
          ((findMin le (cons r a c) s { before := id, val := a, node := c, next := s }).before
            (findMin le (cons r a c) s { before := id, val := a, node := c, next := s }).next)).realSize +
      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 α
⊢ (cons r a c s).realSize =
    (merge le (findMin le (cons r a c) s { before := id, val := a, node := c, next := s }).node.toHeap
          ((findMin le (cons r a c) s { before := id, val := a, node := c, next := s }).before
            (findMin le (cons r a c) s { before := id, val := a, node := c, next := s }).next)).realSize +
      1
state_after: case cons.refl
α : Type u_1
le : α → α → Bool
r : Nat
a : α
c : HeapNode α
s : Heap α
this :
  Batteries.BinomialHeap.Imp.FindMin.HasSize
    (findMin le (cons r a c) s { before := id, val := a, node := c, next := s }) (c.realSize + s.realSize + 1)
⊢ (cons r a c s).realSize =
    (merge le (findMin le (cons r a c) s { before := id, val := a, node := c, next := s }).node.toHeap
          ((findMin le (cons r a c) s { before := id, val := a, node := c, next := s }).before
            (findMin le (cons r a c) s { before := id, val := a, node := c, next := s }).next)).realSize +
      1

tactic: revert this
state_before: case cons.refl
α : Type u_1
le : α → α → Bool
r : Nat
a : α
c : HeapNode α
s : Heap α
this :
  Batteries.BinomialHeap.Imp.FindMin.HasSize
    (findMin le (cons r a c) s { before := id, val := a, node := c, next := s }) (c.realSize + s.realSize + 1)
⊢ (cons r a c s).realSize =
    (merge le (findMin le (cons r a c) s { before := id, val := a, node := c, next := s }).node.toHeap
          ((findMin le (cons r a c) s { before := id, val := a, node := c, next := s }).before
            (findMin le (cons r a c) s { before := id, val := a, node := c, next := s }).next)).realSize +
      1
state_after: case cons.refl
α : Type u_1
le : α → α → Bool
r : Nat
a : α
c : HeapNode α
s : Heap α
⊢ Batteries.BinomialHeap.Imp.FindMin.HasSize
      (findMin le (cons r a c) s { before := id, val := a, node := c, next := s }) (c.realSize + s.realSize + 1) →
    (cons r a c s).realSize =
      (merge le (findMin le (cons r a c) s { before := id, val := a, node := c, next := s }).node.toHeap
            ((findMin le (cons r a c) s { before := id, val := a, node := c, next := s }).before
              (findMin le (cons r a c) s { before := id, val := a, node := c, next := s }).next)).realSize +
        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 α
⊢ Batteries.BinomialHeap.Imp.FindMin.HasSize
      (findMin le (cons r a c) s { before := id, val := a, node := c, next := s }) (c.realSize + s.realSize + 1) →
    (cons r a c s).realSize =
      (merge le (findMin le (cons r a c) s { before := id, val := a, node := c, next := s }).node.toHeap
            ((findMin le (cons r a c) s { before := id, val := a, node := c, next := s }).before
              (findMin le (cons r a c) s { before := id, val := a, node := c, next := s }).next)).realSize +
        1
state_after: no goals

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

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

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 α
⊢ Batteries.BinomialHeap.Imp.FindMin.HasSize { before := before, val := val, node := node, next := next }
      (c.realSize + s.realSize + 1) →
    (cons r a c s).realSize =
      (merge le { before := before, val := val, node := node, next := next }.node.toHeap
            ({ before := before, val := val, node := node, next := next }.before
              { before := before, val := val, node := node, next := next }.next)).realSize +
        1
state_after: α : 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 α), ({ before := before, val := val, node := node, next := next }.before s).realSize = m + s.realSize
ih₂ :
  c.realSize + s.realSize + 1 =
    m + { before := before, val := val, node := node, next := next }.node.realSize +
        { before := before, val := val, node := node, next := next }.next.realSize +
      1
⊢ (cons r a c s).realSize =
    (merge le { before := before, val := val, node := node, next := next }.node.toHeap
          ({ before := before, val := val, node := node, next := next }.before
            { before := before, val := val, node := node, next := next }.next)).realSize +
      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 α), ({ before := before, val := val, node := node, next := next }.before s).realSize = m + s.realSize
ih₂ :
  c.realSize + s.realSize + 1 =
    m + { before := before, val := val, node := node, next := next }.node.realSize +
        { before := before, val := val, node := node, next := next }.next.realSize +
      1
⊢ (cons r a c s).realSize =
    (merge le { before := before, val := val, node := node, next := next }.node.toHeap
          ({ before := before, val := val, node := node, next := next }.before
            { before := before, val := val, node := node, next := next }.next)).realSize +
      1
state_after: α : 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 α), (before s).realSize = m + s.realSize
ih₂ : c.realSize + s.realSize + 1 = m + node.realSize + next.realSize + 1
⊢ (cons r a c s).realSize =
    (merge le { before := before, val := val, node := node, next := next }.node.toHeap
          ({ before := before, val := val, node := node, next := next }.before
            { before := before, val := val, node := node, next := next }.next)).realSize +
      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 α), (before s).realSize = m + s.realSize
ih₂ : c.realSize + s.realSize + 1 = m + node.realSize + next.realSize + 1
⊢ (cons r a c s).realSize =
    (merge le { before := before, val := val, node := node, next := next }.node.toHeap
          ({ before := before, val := val, node := node, next := next }.before
            { before := before, val := val, node := node, next := next }.next)).realSize +
      1
state_after: α : 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 α), (before s).realSize = m + s.realSize
ih₂ : c.realSize + s.realSize + 1 = m + node.realSize + next.realSize + 1
⊢ m + node.realSize + next.realSize + 1 =
    (merge le { before := before, val := val, node := node, next := next }.node.toHeap
          ({ before := before, val := val, node := node, next := next }.before
            { before := before, val := val, node := node, next := next }.next)).realSize +
      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 α), (before s).realSize = m + s.realSize
ih₂ : c.realSize + s.realSize + 1 = m + node.realSize + next.realSize + 1
⊢ m + node.realSize + next.realSize + 1 =
    (merge le { before := before, val := val, node := node, next := next }.node.toHeap
          ({ before := before, val := val, node := node, next := next }.before
            { before := before, val := val, node := node, next := next }.next)).realSize +
      1
state_after: no goals