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

tactic: simp only [reinsertAux, Array.data_length, Array.ugetElem_eq_getElem, Buckets.size_eq,
  Nat.succ_eq_add_one]
state_before: α : Type u_1
β : Type u_2
inst✝ : Hashable α
data : Buckets α β
a : α
b : β
⊢ (reinsertAux data a b).size = data.size.succ
state_after: α : Type u_1
β : Type u_2
inst✝ : Hashable α
data : Buckets α β
a : α
b : β
⊢ Nat.sum
      (List.map (fun x => x.toList.length)
        (data.update (mkIdx ⋯ (hash a).toUSize).val (AssocList.cons a b data.val[(mkIdx ⋯ (hash a).toUSize).val.toNat])
              ⋯).val.data) =
    Nat.sum (List.map (fun x => x.toList.length) data.val.data) + 1

tactic: refine have ⟨l₁, l₂, h₁, _, eq⟩ := Buckets.exists_of_update ..; eq ▸ ?_
state_before: α : Type u_1
β : Type u_2
inst✝ : Hashable α
data : Buckets α β
a : α
b : β
⊢ Nat.sum
      (List.map (fun x => x.toList.length)
        (data.update (mkIdx ⋯ (hash a).toUSize).val (AssocList.cons a b data.val[(mkIdx ⋯ (hash a).toUSize).val.toNat])
              ⋯).val.data) =
    Nat.sum (List.map (fun x => x.toList.length) data.val.data) + 1
state_after: α : Type u_1
β : Type u_2
inst✝ : Hashable α
data : Buckets α β
a : α
b : β
l₁ l₂ : List (AssocList α β)
h₁ : data.val.data = l₁ ++ data.val[(mkIdx ⋯ (hash a).toUSize).val] :: l₂
left✝ : l₁.length = (mkIdx ⋯ (hash a).toUSize).val.toNat
eq :
  (data.update (mkIdx ⋯ (hash a).toUSize).val (AssocList.cons a b data.val[(mkIdx ⋯ (hash a).toUSize).val.toNat])
          ⋯).val.data =
    l₁ ++ AssocList.cons a b data.val[(mkIdx ⋯ (hash a).toUSize).val.toNat] :: l₂
⊢ Nat.sum
      (List.map (fun x => x.toList.length)
        (l₁ ++ AssocList.cons a b data.val[(mkIdx ⋯ (hash a).toUSize).val.toNat] :: l₂)) =
    Nat.sum (List.map (fun x => x.toList.length) data.val.data) + 1

tactic: simp [h₁, Nat.succ_add]
state_before: α : Type u_1
β : Type u_2
inst✝ : Hashable α
data : Buckets α β
a : α
b : β
l₁ l₂ : List (AssocList α β)
h₁ : data.val.data = l₁ ++ data.val[(mkIdx ⋯ (hash a).toUSize).val] :: l₂
left✝ : l₁.length = (mkIdx ⋯ (hash a).toUSize).val.toNat
eq :
  (data.update (mkIdx ⋯ (hash a).toUSize).val (AssocList.cons a b data.val[(mkIdx ⋯ (hash a).toUSize).val.toNat])
          ⋯).val.data =
    l₁ ++ AssocList.cons a b data.val[(mkIdx ⋯ (hash a).toUSize).val.toNat] :: l₂
⊢ Nat.sum
      (List.map (fun x => x.toList.length)
        (l₁ ++ AssocList.cons a b data.val[(mkIdx ⋯ (hash a).toUSize).val.toNat] :: l₂)) =
    Nat.sum (List.map (fun x => x.toList.length) data.val.data) + 1
state_after: α : Type u_1
β : Type u_2
inst✝ : Hashable α
data : Buckets α β
a : α
b : β
l₁ l₂ : List (AssocList α β)
h₁ : data.val.data = l₁ ++ data.val[(mkIdx ⋯ (hash a).toUSize).val] :: l₂
left✝ : l₁.length = (mkIdx ⋯ (hash a).toUSize).val.toNat
eq :
  (data.update (mkIdx ⋯ (hash a).toUSize).val (AssocList.cons a b data.val[(mkIdx ⋯ (hash a).toUSize).val.toNat])
          ⋯).val.data =
    l₁ ++ AssocList.cons a b data.val[(mkIdx ⋯ (hash a).toUSize).val.toNat] :: l₂
⊢ Nat.sum (List.map (fun x => x.toList.length) l₁) +
      (data.val[(mkIdx ⋯ (hash a).toUSize).val.toNat].toList.length + Nat.sum (List.map (fun x => x.toList.length) l₂) +
        1) =
    Nat.sum (List.map (fun x => x.toList.length) l₁) +
        (data.val[(mkIdx ⋯ (hash a).toUSize).val.toNat].toList.length +
          Nat.sum (List.map (fun x => x.toList.length) l₂)) +
      1

tactic: rfl
state_before: α : Type u_1
β : Type u_2
inst✝ : Hashable α
data : Buckets α β
a : α
b : β
l₁ l₂ : List (AssocList α β)
h₁ : data.val.data = l₁ ++ data.val[(mkIdx ⋯ (hash a).toUSize).val] :: l₂
left✝ : l₁.length = (mkIdx ⋯ (hash a).toUSize).val.toNat
eq :
  (data.update (mkIdx ⋯ (hash a).toUSize).val (AssocList.cons a b data.val[(mkIdx ⋯ (hash a).toUSize).val.toNat])
          ⋯).val.data =
    l₁ ++ AssocList.cons a b data.val[(mkIdx ⋯ (hash a).toUSize).val.toNat] :: l₂
⊢ Nat.sum (List.map (fun x => x.toList.length) l₁) +
      (data.val[(mkIdx ⋯ (hash a).toUSize).val.toNat].toList.length + Nat.sum (List.map (fun x => x.toList.length) l₂) +
        1) =
    Nat.sum (List.map (fun x => x.toList.length) l₁) +
        (data.val[(mkIdx ⋯ (hash a).toUSize).val.toNat].toList.length +
          Nat.sum (List.map (fun x => x.toList.length) l₂)) +
      1
state_after: no goals