Hash set lemmas #
This module contains lemmas about Std.Data.HashSet
. Most of the lemmas require
EquivBEq α
and LawfulHashable α
for the key type α
. The easiest way to obtain these instances
is to provide an instance of LawfulBEq α
.
@[simp]
theorem
Std.HashSet.isEmpty_emptyWithCapacity
{α : Type u}
{x✝ : BEq α}
{x✝¹ : Hashable α}
{c : Nat}
:
@[reducible, inline, deprecated Std.HashSet.isEmpty_empty (since := "2025-03-12")]
Equations
@[simp]
theorem
Std.HashSet.contains_emptyWithCapacity
{α : Type u}
{x✝ : BEq α}
{x✝¹ : Hashable α}
{a : α}
{c : Nat}
:
@[simp]
theorem
Std.HashSet.not_mem_emptyWithCapacity
{α : Type u}
{x✝ : BEq α}
{x✝¹ : Hashable α}
{a : α}
{c : Nat}
:
@[reducible, inline, deprecated Std.HashSet.contains_empty (since := "2025-03-12")]
@[reducible, inline, deprecated Std.HashSet.not_mem_empty (since := "2025-03-12")]
Equations
@[simp]
theorem
Std.HashSet.insert_eq_insert
{α : Type u}
{x✝ : BEq α}
{x✝¹ : Hashable α}
{m : HashSet α}
{a : α}
:
theorem
Std.HashSet.contains_of_contains_insert'
{α : Type u}
{x✝ : BEq α}
{x✝¹ : Hashable α}
{m : HashSet α}
[EquivBEq α]
[LawfulHashable α]
{k a : α}
:
This is a restatement of contains_insert
that is written to exactly match the proof
obligation in the statement of get_insert
.
theorem
Std.HashSet.mem_of_mem_insert'
{α : Type u}
{x✝ : BEq α}
{x✝¹ : Hashable α}
{m : HashSet α}
[EquivBEq α]
[LawfulHashable α]
{k a : α}
:
This is a restatement of mem_insert
that is written to exactly match the proof obligation
in the statement of get_insert
.
theorem
Std.HashSet.mem_insert_self
{α : Type u}
{x✝ : BEq α}
{x✝¹ : Hashable α}
{m : HashSet α}
[EquivBEq α]
[LawfulHashable α]
{k : α}
:
@[simp]
@[reducible, inline, deprecated Std.HashSet.size_empty (since := "2025-03-12")]
Equations
@[simp]
theorem
Std.HashSet.erase_emptyWithCapacity
{α : Type u}
{x✝ : BEq α}
{x✝¹ : Hashable α}
{a : α}
{c : Nat}
:
@[reducible, inline, deprecated Std.HashSet.erase_empty (since := "2025-03-12")]
Equations
@[simp]
theorem
Std.HashSet.get?_emptyWithCapacity
{α : Type u}
{x✝ : BEq α}
{x✝¹ : Hashable α}
{a : α}
{c : Nat}
:
@[reducible, inline, deprecated Std.HashSet.get?_empty (since := "2025-03-12")]
Equations
theorem
Std.HashSet.get?_beq
{α : Type u}
{x✝ : BEq α}
{x✝¹ : Hashable α}
{m : HashSet α}
[EquivBEq α]
[LawfulHashable α]
{k : α}
:
@[reducible, inline, deprecated Std.HashSet.get!_empty (since := "2025-03-12")]
abbrev
Std.HashSet.get!_emptyc
{α : Type u_1}
{x✝ : BEq α}
{x✝¹ : Hashable α}
[Inhabited α]
{a : α}
:
Equations
@[simp]
theorem
Std.HashSet.getD_emptyWithCapacity
{α : Type u}
{x✝ : BEq α}
{x✝¹ : Hashable α}
{a fallback : α}
{c : Nat}
:
@[reducible, inline, deprecated Std.HashSet.getD_empty (since := "2025-03-12")]
Equations
@[simp]
theorem
Std.HashSet.containsThenInsert_fst
{α : Type u}
{x✝ : BEq α}
{x✝¹ : Hashable α}
{m : HashSet α}
{k : α}
:
@[simp]
theorem
Std.HashSet.containsThenInsert_snd
{α : Type u}
{x✝ : BEq α}
{x✝¹ : Hashable α}
{m : HashSet α}
{k : α}
:
theorem
Std.HashSet.distinct_toList
{α : Type u}
{x✝ : BEq α}
{x✝¹ : Hashable α}
{m : HashSet α}
[EquivBEq α]
[LawfulHashable α]
:
List.Pairwise (fun (a b : α) => (a == b) = false) m.toList
theorem
Std.HashSet.foldM_eq_foldlM_toList
{α : Type u}
{x✝ : BEq α}
{x✝¹ : Hashable α}
{m : HashSet α}
{δ : Type v}
{m' : Type v → Type v}
[Monad m']
[LawfulMonad m']
{f : δ → α → m' δ}
{init : δ}
:
@[simp]
@[simp]
theorem
Std.HashSet.contains_insertMany_list
{α : Type u}
{x✝ : BEq α}
{x✝¹ : Hashable α}
{m : HashSet α}
[EquivBEq α]
[LawfulHashable α]
{l : List α}
{k : α}
:
theorem
Std.HashSet.mem_of_mem_insertMany_list
{α : Type u}
{x✝ : BEq α}
{x✝¹ : Hashable α}
{m : HashSet α}
[EquivBEq α]
[LawfulHashable α]
{l : List α}
{k : α}
(contains_eq_false : l.contains k = false)
:
k ∈ m.insertMany l → k ∈ m
theorem
Std.HashSet.get?_insertMany_list_of_not_mem_of_mem
{α : Type u}
{x✝ : BEq α}
{x✝¹ : Hashable α}
{m : HashSet α}
[EquivBEq α]
[LawfulHashable α]
{l : List α}
{k k' : α}
(k_beq : (k == k') = true)
(not_mem : ¬k ∈ m)
(distinct : List.Pairwise (fun (a b : α) => (a == b) = false) l)
(mem : k ∈ l)
:
theorem
Std.HashSet.get?_insertMany_list_of_mem
{α : Type u}
{x✝ : BEq α}
{x✝¹ : Hashable α}
{m : HashSet α}
[EquivBEq α]
[LawfulHashable α]
{l : List α}
{k : α}
(mem : k ∈ m)
:
theorem
Std.HashSet.get_insertMany_list_of_not_mem_of_mem
{α : Type u}
{x✝ : BEq α}
{x✝¹ : Hashable α}
{m : HashSet α}
[EquivBEq α]
[LawfulHashable α]
{l : List α}
{k k' : α}
(k_beq : (k == k') = true)
(not_mem : ¬k ∈ m)
(distinct : List.Pairwise (fun (a b : α) => (a == b) = false) l)
(mem : k ∈ l)
{h : k' ∈ m.insertMany l}
:
theorem
Std.HashSet.get_insertMany_list_of_mem
{α : Type u}
{x✝ : BEq α}
{x✝¹ : Hashable α}
{m : HashSet α}
[EquivBEq α]
[LawfulHashable α]
{l : List α}
{k : α}
(mem : k ∈ m)
{h : k ∈ m.insertMany l}
:
theorem
Std.HashSet.get!_insertMany_list_of_not_mem_of_mem
{α : Type u}
{x✝ : BEq α}
{x✝¹ : Hashable α}
{m : HashSet α}
[EquivBEq α]
[LawfulHashable α]
[Inhabited α]
{l : List α}
{k k' : α}
(k_beq : (k == k') = true)
(not_mem : ¬k ∈ m)
(distinct : List.Pairwise (fun (a b : α) => (a == b) = false) l)
(mem : k ∈ l)
:
theorem
Std.HashSet.get!_insertMany_list_of_mem
{α : Type u}
{x✝ : BEq α}
{x✝¹ : Hashable α}
{m : HashSet α}
[EquivBEq α]
[LawfulHashable α]
[Inhabited α]
{l : List α}
{k : α}
(mem : k ∈ m)
:
theorem
Std.HashSet.getD_insertMany_list_of_not_mem_of_mem
{α : Type u}
{x✝ : BEq α}
{x✝¹ : Hashable α}
{m : HashSet α}
[EquivBEq α]
[LawfulHashable α]
{l : List α}
{k k' fallback : α}
(k_beq : (k == k') = true)
(not_mem : ¬k ∈ m)
(distinct : List.Pairwise (fun (a b : α) => (a == b) = false) l)
(mem : k ∈ l)
:
theorem
Std.HashSet.getD_insertMany_list_of_mem
{α : Type u}
{x✝ : BEq α}
{x✝¹ : Hashable α}
{m : HashSet α}
[EquivBEq α]
[LawfulHashable α]
{l : List α}
{k fallback : α}
(mem : k ∈ m)
:
theorem
Std.HashSet.size_le_size_insertMany_list
{α : Type u}
{x✝ : BEq α}
{x✝¹ : Hashable α}
{m : HashSet α}
[EquivBEq α]
[LawfulHashable α]
{l : List α}
:
theorem
Std.HashSet.size_insertMany_list_le
{α : Type u}
{x✝ : BEq α}
{x✝¹ : Hashable α}
{m : HashSet α}
[EquivBEq α]
[LawfulHashable α]
{l : List α}
:
@[simp]
theorem
Std.HashSet.isEmpty_insertMany_list
{α : Type u}
{x✝ : BEq α}
{x✝¹ : Hashable α}
{m : HashSet α}
[EquivBEq α]
[LawfulHashable α]
{l : List α}
:
theorem
Std.HashSet.Equiv.insertMany_list
{α : Type u}
{x✝ : BEq α}
{x✝¹ : Hashable α}
{m₁ m₂ : HashSet α}
[EquivBEq α]
[LawfulHashable α]
(l : List α)
(h : m₁.Equiv m₂)
:
(m₁.insertMany l).Equiv (m₂.insertMany l)
theorem
Std.HashSet.Equiv.filter
{α : Type u}
{x✝ : BEq α}
{x✝¹ : Hashable α}
{m₁ m₂ : HashSet α}
(f : α → Bool)
(h : m₁.Equiv m₂)
:
(HashSet.filter f m₁).Equiv (HashSet.filter f m₂)
@[simp]
theorem
Std.HashSet.equiv_emptyWithCapacity_iff_isEmpty
{α : Type u}
{x✝ : BEq α}
{x✝¹ : Hashable α}
{m : HashSet α}
[EquivBEq α]
[LawfulHashable α]
{c : Nat}
:
@[reducible, inline, deprecated Std.HashSet.equiv_empty_iff_isEmpty (since := "2025-03-12")]
abbrev
Std.HashSet.equiv_emptyc_iff_isEmpty
{α : Type u_1}
{x✝ : BEq α}
{x✝¹ : Hashable α}
{m : HashSet α}
[EquivBEq α]
[LawfulHashable α]
:
@[simp]
theorem
Std.HashSet.emptyWithCapacity_equiv_iff_isEmpty
{α : Type u}
{x✝ : BEq α}
{x✝¹ : Hashable α}
{m : HashSet α}
[EquivBEq α]
[LawfulHashable α]
{c : Nat}
:
@[reducible, inline, deprecated Std.HashSet.empty_equiv_iff_isEmpty (since := "2025-03-12")]
abbrev
Std.HashSet.emptyc_equiv_iff_isEmpty
{α : Type u_1}
{x✝ : BEq α}
{x✝¹ : Hashable α}
{m : HashSet α}
[EquivBEq α]
[LawfulHashable α]
: