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

tactic: dsimp [modify, cond]
state_before: α : Type u_1
β : Type u_2
f : α → β → β
inst✝¹ : BEq α
inst✝ : Hashable α
m : Imp α β
k : α
h : m.buckets.WF
⊢ (m.modify k f).buckets.WF
state_after: α : Type u_1
β : Type u_2
f : α → β → β
inst✝¹ : BEq α
inst✝ : Hashable α
m : Imp α β
k : α
h : m.buckets.WF
⊢ ((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]) ⋯).WF

tactic: rw [Buckets.update_update]
state_before: α : Type u_1
β : Type u_2
f : α → β → β
inst✝¹ : BEq α
inst✝ : Hashable α
m : Imp α β
k : α
h : m.buckets.WF
⊢ ((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]) ⋯).WF
state_after: α : Type u_1
β : Type u_2
f : α → β → β
inst✝¹ : BEq α
inst✝ : Hashable α
m : Imp α β
k : α
h : m.buckets.WF
⊢ (m.buckets.update (mkIdx ⋯ (hash k).toUSize).val
      (AssocList.modify k f m.buckets.val[(mkIdx ⋯ (hash k).toUSize).val.toNat]) ⋯).WF

tactic: refine h.update (fun H => ?_) (fun H a h => ?_) <;> simp at h ⊢
state_before: α : Type u_1
β : Type u_2
f : α → β → β
inst✝¹ : BEq α
inst✝ : Hashable α
m : Imp α β
k : α
h : m.buckets.WF
⊢ (m.buckets.update (mkIdx ⋯ (hash k).toUSize).val
      (AssocList.modify k f m.buckets.val[(mkIdx ⋯ (hash k).toUSize).val.toNat]) ⋯).WF
state_after: case refine_1
α : Type u_1
β : Type u_2
f : α → β → β
inst✝³ : BEq α
inst✝² : Hashable α
m : Imp α β
k : α
h : m.buckets.WF
inst✝¹ : PartialEquivBEq α
inst✝ : LawfulHashable α
H : List.Pairwise (fun a b => ¬(a.fst == b.fst) = true) m.buckets.val[(mkIdx ⋯ (hash k).toUSize).val].toList
⊢ List.Pairwise (fun a b => ¬(a.fst == b.fst) = true)
    (List.replaceF (fun x => bif x.fst == k then some (k, f x.fst x.snd) else none)
      m.buckets.val[(mkIdx ⋯ (hash k).toUSize).val.toNat].toList)

case refine_2
α : Type u_1
β : Type u_2
f : α → β → β
inst✝¹ : BEq α
inst✝ : Hashable α
m : Imp α β
k : α
h✝ : m.buckets.WF
H :
  AssocList.All (fun k_1 x => ((hash k_1).toUSize % m.buckets.val.size).toNat = (mkIdx ⋯ (hash k).toUSize).val.toNat)
    m.buckets.val[(mkIdx ⋯ (hash k).toUSize).val]
a : α × β
h :
  a ∈
    List.replaceF (fun x => bif x.fst == k then some (k, f x.fst x.snd) else none)
      m.buckets.val[(mkIdx ⋯ (hash k).toUSize).val.toNat].toList
⊢ ((hash a.fst).toUSize % m.buckets.val.size).toNat = (mkIdx ⋯ (hash k).toUSize).val.toNat

tactic: exact pairwise_replaceF H
state_before: case refine_1
α : Type u_1
β : Type u_2
f : α → β → β
inst✝³ : BEq α
inst✝² : Hashable α
m : Imp α β
k : α
h : m.buckets.WF
inst✝¹ : PartialEquivBEq α
inst✝ : LawfulHashable α
H : List.Pairwise (fun a b => ¬(a.fst == b.fst) = true) m.buckets.val[(mkIdx ⋯ (hash k).toUSize).val].toList
⊢ List.Pairwise (fun a b => ¬(a.fst == b.fst) = true)
    (List.replaceF (fun x => bif x.fst == k then some (k, f x.fst x.snd) else none)
      m.buckets.val[(mkIdx ⋯ (hash k).toUSize).val.toNat].toList)
state_after: no goals

tactic: simp only [AssocList.All, Array.ugetElem_eq_getElem] at H h ⊢
state_before: case refine_2
α : Type u_1
β : Type u_2
f : α → β → β
inst✝¹ : BEq α
inst✝ : Hashable α
m : Imp α β
k : α
h✝ : m.buckets.WF
H :
  AssocList.All (fun k_1 x => ((hash k_1).toUSize % m.buckets.val.size).toNat = (mkIdx ⋯ (hash k).toUSize).val.toNat)
    m.buckets.val[(mkIdx ⋯ (hash k).toUSize).val]
a : α × β
h :
  a ∈
    List.replaceF (fun x => bif x.fst == k then some (k, f x.fst x.snd) else none)
      m.buckets.val[(mkIdx ⋯ (hash k).toUSize).val.toNat].toList
⊢ ((hash a.fst).toUSize % m.buckets.val.size).toNat = (mkIdx ⋯ (hash k).toUSize).val.toNat
state_after: case refine_2
α : Type u_1
β : Type u_2
f : α → β → β
inst✝¹ : BEq α
inst✝ : Hashable α
m : Imp α β
k : α
h✝ : m.buckets.WF
H :
  ∀ (a : α × β),
    a ∈ m.buckets.val[(mkIdx ⋯ (hash k).toUSize).val.toNat].toList →
      ((hash a.fst).toUSize % m.buckets.val.size).toNat = (mkIdx ⋯ (hash k).toUSize).val.toNat
a : α × β
h :
  a ∈
    List.replaceF (fun x => bif x.fst == k then some (k, f x.fst x.snd) else none)
      m.buckets.val[(mkIdx ⋯ (hash k).toUSize).val.toNat].toList
⊢ ((hash a.fst).toUSize % m.buckets.val.size).toNat = (mkIdx ⋯ (hash k).toUSize).val.toNat

tactic: match mem_replaceF h with
| .inl rfl => rfl
| .inr h => exact H _ h
state_before: case refine_2
α : Type u_1
β : Type u_2
f : α → β → β
inst✝¹ : BEq α
inst✝ : Hashable α
m : Imp α β
k : α
h✝ : m.buckets.WF
H :
  ∀ (a : α × β),
    a ∈ m.buckets.val[(mkIdx ⋯ (hash k).toUSize).val.toNat].toList →
      ((hash a.fst).toUSize % m.buckets.val.size).toNat = (mkIdx ⋯ (hash k).toUSize).val.toNat
a : α × β
h :
  a ∈
    List.replaceF (fun x => bif x.fst == k then some (k, f x.fst x.snd) else none)
      m.buckets.val[(mkIdx ⋯ (hash k).toUSize).val.toNat].toList
⊢ ((hash a.fst).toUSize % m.buckets.val.size).toNat = (mkIdx ⋯ (hash k).toUSize).val.toNat
state_after: no goals

tactic: rfl
state_before: α : Type u_1
β : Type u_2
f : α → β → β
inst✝¹ : BEq α
inst✝ : Hashable α
m : Imp α β
h✝ : m.buckets.WF
a : α × β
H :
  ∀ (a_1 : α × β),
    a_1 ∈ m.buckets.val[(mkIdx ⋯ (hash a.fst).toUSize).val.toNat].toList →
      ((hash a_1.fst).toUSize % m.buckets.val.size).toNat = (mkIdx ⋯ (hash a.fst).toUSize).val.toNat
h :
  a ∈
    List.replaceF (fun x => bif x.fst == a.fst then some (a.fst, f x.fst x.snd) else none)
      m.buckets.val[(mkIdx ⋯ (hash a.fst).toUSize).val.toNat].toList
⊢ ((hash a.fst).toUSize % m.buckets.val.size).toNat = (mkIdx ⋯ (hash a.fst).toUSize).val.toNat
state_after: no goals

tactic: exact H _ h
state_before: α : Type u_1
β : Type u_2
f : α → β → β
inst✝¹ : BEq α
inst✝ : Hashable α
m : Imp α β
h✝¹ : m.buckets.WF
a : α × β
k : α
h : a ∈ m.buckets.val[(mkIdx ⋯ (hash k).toUSize).val.toNat].toList
H :
  ∀ (a : α × β),
    a ∈ m.buckets.val[(mkIdx ⋯ (hash k).toUSize).val.toNat].toList →
      ((hash a.fst).toUSize % m.buckets.val.size).toNat = (mkIdx ⋯ (hash k).toUSize).val.toNat
h✝ :
  a ∈
    List.replaceF (fun x => bif x.fst == k then some (k, f x.fst x.snd) else none)
      m.buckets.val[(mkIdx ⋯ (hash k).toUSize).val.toNat].toList
⊢ ((hash a.fst).toUSize % m.buckets.val.size).toNat = (mkIdx ⋯ (hash k).toUSize).val.toNat
state_after: no goals