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

full_name: Batteries.HashMap.Imp.Buckets.ext
code: @[ext] protected theorem ext : ∀ {b₁ b₂ : Buckets α β}, b₁.1.data = b₂.1.data → b₁ = b₂
  
goal: b₁.val.data = b₂.val.data → b₁ = b₂

full_name: Batteries.HashMap.Imp.Buckets.update_data
code: theorem update_data (self : Buckets α β) (i d h) :
    (self.update i d h).1.data = self.1.data.set i.toNat d 
goal: (self.update i d h).val.data = self.val.data.set i.toNat d

full_name: Batteries.HashMap.Imp.Buckets.exists_of_update
code: theorem exists_of_update (self : Buckets α β) (i d h) :
    ∃ l₁ l₂, self.1.data = l₁ ++ self.1[i] :: l₂ ∧ List.length l₁ = i.toNat ∧
      (self.update i d h).1.data = l₁ ++ d :: l₂ 
goal: ∃ l₁ l₂, self.val.data = l₁ ++ self.val[i] :: l₂ ∧ l₁.length = i.toNat ∧ (self.update i d h).val.data = l₁ ++ d :: l₂

full_name: Batteries.HashMap.Imp.Buckets.update_update
code: theorem update_update (self : Buckets α β) (i d d' h h') :
    (self.update i d h).update i d' h' = self.update i d' h 
goal: (self.update i d h).update i d' h' = self.update i d' h

full_name: Batteries.HashMap.Imp.Buckets.size_eq
code: theorem size_eq (data : Buckets α β) :
  size data = .sum (data.1.data.map (·.toList.length)) 
goal: data.size = Nat.sum (List.map (fun x => x.toList.length) data.val.data)

full_name: Batteries.HashMap.Imp.Buckets.mk_size
code: theorem mk_size (h) : (mk n h : Buckets α β).size = 0 
goal: (Batteries.HashMap.Imp.Buckets.mk n h).size = 0

full_name: Batteries.HashMap.Imp.Buckets.WF.mk'
code: theorem WF.mk' [BEq α] [Hashable α] (h) : (Buckets.mk n h : Buckets α β).WF 
goal: (Batteries.HashMap.Imp.Buckets.mk n h).WF

full_name: Batteries.HashMap.Imp.Buckets.WF.update
code: theorem WF.update [BEq α] [Hashable α] {buckets : Buckets α β} {i d h} (H : buckets.WF)
    (h₁ : ∀ [PartialEquivBEq α] [LawfulHashable α],
      (buckets.1[i].toList.Pairwise fun a b => ¬(a.1 == b.1)) →
      d.toList.Pairwise fun a b => ¬(a.1 == b.1))
    (h₂ : (buckets.1[i].All fun k _ => ((hash k).toUSize % buckets.1.size).toNat = i.toNat) →
      d.All fun k _ => ((hash k).toUSize % buckets.1.size).toNat = i.toNat) :
    (buckets.update i d h).WF 
goal: (buckets.update i d h).WF

full_name: Batteries.HashMap.Imp.reinsertAux_size
code: theorem reinsertAux_size [Hashable α] (data : Buckets α β) (a : α) (b : β) :
    (reinsertAux data a b).size = data.size.succ 
goal: (Batteries.HashMap.Imp.reinsertAux data a b).size = data.size.succ

full_name: Batteries.HashMap.Imp.reinsertAux_WF
code: theorem reinsertAux_WF [BEq α] [Hashable α] {data : Buckets α β} {a : α} {b : β} (H : data.WF)
    (h₁ : ∀ [PartialEquivBEq α] [LawfulHashable α],
      haveI := mkIdx data.2 (hash a).toUSize
      data.val[this.1].All fun x _ => ¬(a == x)) :
    (reinsertAux data a b).WF 
goal: (Batteries.HashMap.Imp.reinsertAux data a b).WF

full_name: Batteries.HashMap.Imp.expand_size
code: theorem expand_size [Hashable α] {buckets : Buckets α β} :
    (expand sz buckets).buckets.size = buckets.size 
goal: (Batteries.HashMap.Imp.expand sz buckets).buckets.size = buckets.size

full_name: Batteries.HashMap.Imp.expand_size.go
code: theorem expand_size [Hashable α] {buckets : Buckets α β} :
    (expand sz buckets).buckets.size = buckets.size 
goal: (Batteries.HashMap.Imp.expand.go i source target).size =
  Nat.sum (List.map (fun x => x.toList.length) source.data) + target.size

full_name: Batteries.HashMap.Imp.expand_WF.foldl
code: theorem expand_WF.foldl [BEq α] [Hashable α] (rank : α → Nat) {l : List (α × β)} {i : Nat}
    (hl₁ : ∀ [PartialEquivBEq α] [LawfulHashable α], l.Pairwise fun a b => ¬(a.1 == b.1))
    (hl₂ : ∀ x ∈ l, rank x.1 = i)
    {target : Buckets α β} (ht₁ : target.WF)
    (ht₂ : ∀ bucket ∈ target.1.data,
      bucket.All fun k _ => rank k ≤ i ∧
        ∀ [PartialEquivBEq α] [LawfulHashable α], ∀ x ∈ l, ¬(x.1 == k)) :
    (l.foldl (fun d x => reinsertAux d x.1 x.2) target).WF ∧
    ∀ bucket ∈ (l.foldl (fun d x => reinsertAux d x.1 x.2) target).1.data,
      bucket.All fun k _ => rank k ≤ i 
goal: (List.foldl (fun d x => Batteries.HashMap.Imp.reinsertAux d x.fst x.snd) target l).WF ∧
  ∀ (bucket : Batteries.AssocList α β),
    bucket ∈ (List.foldl (fun d x => Batteries.HashMap.Imp.reinsertAux d x.fst x.snd) target l).val.data →
      Batteries.AssocList.All (fun k x => rank k ≤ i) bucket

full_name: Batteries.HashMap.Imp.expand_WF.go
code: theorem expand_WF [BEq α] [Hashable α] {buckets : Buckets α β} (H : buckets.WF) :
    (expand sz buckets).buckets.WF 
goal: (Batteries.HashMap.Imp.expand.go i source target).WF

full_name: Batteries.HashMap.Imp.expand_WF
code: theorem expand_WF [BEq α] [Hashable α] {buckets : Buckets α β} (H : buckets.WF) :
    (expand sz buckets).buckets.WF 
goal: (Batteries.HashMap.Imp.expand sz buckets).buckets.WF

full_name: Batteries.HashMap.Imp.insert_size
code: theorem insert_size [BEq α] [Hashable α] {m : Imp α β} {k v}
    (h : m.size = m.buckets.size) :
    (insert m k v).size = (insert m k v).buckets.size 
goal: (m.insert k v).size = (m.insert k v).buckets.size

full_name: _private.«.lake».packages.batteries.Batteries.Data.HashMap.WF.0.Batteries.HashMap.Imp.mem_replaceF
code: private theorem mem_replaceF {l : List (α × β)} {x : α × β} {p : α × β → Bool} {f : α × β → β} :
    x ∈ (l.replaceF fun a => bif p a then some (k, f a) else none) → x.1 = k ∨ x ∈ l 
goal: x ∈ List.replaceF (fun a => bif p a then some (k, f a) else none) l → x.fst = k ∨ x ∈ l

full_name: _private.«.lake».packages.batteries.Batteries.Data.HashMap.WF.0.Batteries.HashMap.Imp.pairwise_replaceF
code: private theorem pairwise_replaceF [BEq α] [PartialEquivBEq α]
    {l : List (α × β)} {f : α × β → β}
    (H : l.Pairwise fun a b => ¬(a.fst == b.fst)) :
    (l.replaceF fun a => bif a.fst == k then some (k, f a) else none)
      |>.Pairwise fun a b => ¬(a.fst == b.fst) 
goal: List.Pairwise (fun a b => ¬(a.fst == b.fst) = true)
  (List.replaceF (fun a => bif a.fst == k then some (k, f a) else none) l)

full_name: Batteries.HashMap.Imp.insert_WF
code: theorem insert_WF [BEq α] [Hashable α] {m : Imp α β} {k v}
    (h : m.buckets.WF) : (insert m k v).buckets.WF 
goal: (m.insert k v).buckets.WF

full_name: Batteries.HashMap.Imp.erase_size
code: theorem erase_size [BEq α] [Hashable α] {m : Imp α β} {k}
    (h : m.size = m.buckets.size) :
    (erase m k).size = (erase m k).buckets.size 
goal: (m.erase k).size = (m.erase k).buckets.size

full_name: Batteries.HashMap.Imp.erase_WF
code: theorem erase_WF [BEq α] [Hashable α] {m : Imp α β} {k}
    (h : m.buckets.WF) : (erase m k).buckets.WF 
goal: (m.erase k).buckets.WF

full_name: Batteries.HashMap.Imp.modify_size
code: theorem modify_size [BEq α] [Hashable α] {m : Imp α β} {k}
    (h : m.size = m.buckets.size) :
    (modify m k f).size = (modify m k f).buckets.size 
goal: (m.modify k f).size = (m.modify k f).buckets.size

full_name: Batteries.HashMap.Imp.modify_WF
code: theorem modify_WF [BEq α] [Hashable α] {m : Imp α β} {k}
    (h : m.buckets.WF) : (modify m k f).buckets.WF 
goal: (m.modify k f).buckets.WF

full_name: Batteries.HashMap.Imp.WF.out
code: theorem WF.out [BEq α] [Hashable α] {m : Imp α β} (h : m.WF) :
    m.size = m.buckets.size ∧ m.buckets.WF 
goal: m.size = m.buckets.size ∧ m.buckets.WF

full_name: Batteries.HashMap.Imp.WF_iff
code: theorem WF_iff [BEq α] [Hashable α] {m : Imp α β} :
    m.WF ↔ m.size = m.buckets.size ∧ m.buckets.WF 
goal: m.WF ↔ m.size = m.buckets.size ∧ m.buckets.WF

full_name: Batteries.HashMap.Imp.WF.mapVal
code: theorem WF.mapVal {α β γ} {f : α → β → γ} [BEq α] [Hashable α]
    {m : Imp α β} (H : WF m) : WF (mapVal f m) 
goal: (Batteries.HashMap.Imp.mapVal f m).WF

full_name: Batteries.HashMap.Imp.WF.filterMap
code: theorem WF.filterMap {α β γ} {f : α → β → Option γ} [BEq α] [Hashable α]
    {m : Imp α β} (H : WF m) : WF (filterMap f m) 
goal: (Batteries.HashMap.Imp.filterMap f m).WF

full_name: Batteries.HashMap.mapVal
code: /-- Map a function over the values in the map. -/
@[inline] def mapVal (f : α → β → γ) (self : HashMap α β) : HashMap α γ 
goal: {x : BEq α} →
  {x_1 : Hashable α} → {β : Type u_2} → {γ : Type u_3} → (α → β → γ) → Batteries.HashMap α β → Batteries.HashMap α γ

full_name: Batteries.HashMap.filterMap
code: /--
Applies `f` to each key-value pair `a, b` in the map. If it returns `some c` then
`a, c` is pushed into the new map; else the key is removed from the map.
-/
@[inline] def filterMap (f : α → β → Option γ) (self : HashMap α β) : HashMap α γ 
goal: {x : BEq α} →
  {x_1 : Hashable α} →
    {β : Type u_2} → {γ : Type u_3} → (α → β → Option γ) → Batteries.HashMap α β → Batteries.HashMap α γ

full_name: Batteries.HashMap.filter
code: /-- Constructs a map with the set of all pairs `a, b` such that `f` returns true. -/
@[inline] def filter (f : α → β → Bool) (self : HashMap α β) : HashMap α β 
goal: {x : BEq α} → {x_1 : Hashable α} → {β : Type u_2} → (α → β → Bool) → Batteries.HashMap α β → Batteries.HashMap α β