Theorem: Batteries.HashMap.Imp.modify_size
File: .lake/packages/batteries/Batteries/Data/HashMap/WF.lean

Proof steps:
state_before: α : Type u_1
β : Type u_2
f : α → β → β
inst✝¹ : BEq α
inst✝ : Hashable α
m : Imp α β
k : α
h : m.size = m.buckets.size
⊢ (m.modify k f).size = (m.modify k f).buckets.size
state_after: α : Type u_1
β : Type u_2
f : α → β → β
inst✝¹ : BEq α
inst✝ : Hashable α
m : Imp α β
k : α
h : m.size = m.buckets.size
⊢ m.size =
    ((m.buckets.update (mkIdx ⋯ (hash k).toUSize).val AssocList.nil ⋯).update (mkIdx ⋯ (hash k).toUSize).val
        (AssocList.modify k f m.buckets.val[(mkIdx ⋯ (hash k).toUSize).val.toNat]) ⋯).size
tactic: dsimp [modify, cond]
state_before: α : Type u_1
β : Type u_2
f : α → β → β
inst✝¹ : BEq α
inst✝ : Hashable α
m : Imp α β
k : α
h : m.size = m.buckets.size
⊢ m.size =
    ((m.buckets.update (mkIdx ⋯ (hash k).toUSize).val AssocList.nil ⋯).update (mkIdx ⋯ (hash k).toUSize).val
        (AssocList.modify k f m.buckets.val[(mkIdx ⋯ (hash k).toUSize).val.toNat]) ⋯).size
state_after: α : Type u_1
β : Type u_2
f : α → β → β
inst✝¹ : BEq α
inst✝ : Hashable α
m : Imp α β
k : α
h : m.size = m.buckets.size
⊢ m.size =
    (m.buckets.update (mkIdx ⋯ (hash k).toUSize).val
        (AssocList.modify k f m.buckets.val[(mkIdx ⋯ (hash k).toUSize).val.toNat]) ⋯).size
tactic: rw [Buckets.update_update]
state_before: α : Type u_1
β : Type u_2
f : α → β → β
inst✝¹ : BEq α
inst✝ : Hashable α
m : Imp α β
k : α
h : m.size = m.buckets.size
⊢ m.size =
    (m.buckets.update (mkIdx ⋯ (hash k).toUSize).val
        (AssocList.modify k f m.buckets.val[(mkIdx ⋯ (hash k).toUSize).val.toNat]) ⋯).size
state_after: α : Type u_1
β : Type u_2
f : α → β → β
inst✝¹ : BEq α
inst✝ : Hashable α
m : Imp α β
k : α
h : m.size = m.buckets.size
⊢ Nat.sum (List.map (fun x => x.toList.length) m.buckets.val.data) =
    Nat.sum
      (List.map (fun x => x.toList.length)
        (m.buckets.update (mkIdx ⋯ (hash k).toUSize).val
              (AssocList.modify k f m.buckets.val[(mkIdx ⋯ (hash k).toUSize).val.toNat]) ⋯).val.data)
tactic: simp only [h, Buckets.size]
state_before: α : Type u_1
β : Type u_2
f : α → β → β
inst✝¹ : BEq α
inst✝ : Hashable α
m : Imp α β
k : α
h : m.size = m.buckets.size
⊢ Nat.sum (List.map (fun x => x.toList.length) m.buckets.val.data) =
    Nat.sum
      (List.map (fun x => x.toList.length)
        (m.buckets.update (mkIdx ⋯ (hash k).toUSize).val
              (AssocList.modify k f m.buckets.val[(mkIdx ⋯ (hash k).toUSize).val.toNat]) ⋯).val.data)
state_after: α : Type u_1
β : Type u_2
f : α → β → β
inst✝¹ : BEq α
inst✝ : Hashable α
m : Imp α β
k : α
h : m.size = m.buckets.size
w✝¹ w✝ : List (AssocList α β)
h₁ : m.buckets.val.data = w✝¹ ++ m.buckets.val[(mkIdx ⋯ (hash k).toUSize).val] :: w✝
left✝ : w✝¹.length = (mkIdx ⋯ (hash k).toUSize).val.toNat
eq :
  (m.buckets.update (mkIdx ⋯ (hash k).toUSize).val
          (AssocList.modify k f m.buckets.val[(mkIdx ⋯ (hash k).toUSize).val.toNat]) ⋯).val.data =
    w✝¹ ++ AssocList.modify k f m.buckets.val[(mkIdx ⋯ (hash k).toUSize).val.toNat] :: w✝
⊢ Nat.sum (List.map (fun x => x.toList.length) m.buckets.val.data) =
    Nat.sum
      (List.map (fun x => x.toList.length)
        (w✝¹ ++ AssocList.modify k f m.buckets.val[(mkIdx ⋯ (hash k).toUSize).val.toNat] :: w✝))
tactic: refine have ⟨_, _, h₁, _, eq⟩ := Buckets.exists_of_update ..; eq ▸ ?_
state_before: α : Type u_1
β : Type u_2
f : α → β → β
inst✝¹ : BEq α
inst✝ : Hashable α
m : Imp α β
k : α
h : m.size = m.buckets.size
w✝¹ w✝ : List (AssocList α β)
h₁ : m.buckets.val.data = w✝¹ ++ m.buckets.val[(mkIdx ⋯ (hash k).toUSize).val] :: w✝
left✝ : w✝¹.length = (mkIdx ⋯ (hash k).toUSize).val.toNat
eq :
  (m.buckets.update (mkIdx ⋯ (hash k).toUSize).val
          (AssocList.modify k f m.buckets.val[(mkIdx ⋯ (hash k).toUSize).val.toNat]) ⋯).val.data =
    w✝¹ ++ AssocList.modify k f m.buckets.val[(mkIdx ⋯ (hash k).toUSize).val.toNat] :: w✝
⊢ Nat.sum (List.map (fun x => x.toList.length) m.buckets.val.data) =
    Nat.sum
      (List.map (fun x => x.toList.length)
        (w✝¹ ++ AssocList.modify k f m.buckets.val[(mkIdx ⋯ (hash k).toUSize).val.toNat] :: w✝))
state_after: no goals
tactic: simp [h, h₁, Buckets.size_eq]