HepLean Documentation

Std.Data.HashSet.RawLemmas

Hash set lemmas #

This module contains lemmas about Std.Data.HashSet.Raw. 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.Raw.size_empty {α : Type u} {c : Nat} :
@[simp]
theorem Std.HashSet.Raw.size_emptyc {α : Type u} :
.size = 0
theorem Std.HashSet.Raw.isEmpty_eq_size_eq_zero {α : Type u} {m : Std.HashSet.Raw α} :
m.isEmpty = (m.size == 0)
@[simp]
theorem Std.HashSet.Raw.isEmpty_empty {α : Type u} [BEq α] [Hashable α] {c : Nat} :
@[simp]
theorem Std.HashSet.Raw.isEmpty_emptyc {α : Type u} [BEq α] [Hashable α] :
.isEmpty = true
@[simp]
theorem Std.HashSet.Raw.isEmpty_insert {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (h : m.WF) {a : α} :
(m.insert a).isEmpty = false
theorem Std.HashSet.Raw.mem_iff_contains {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] {a : α} :
a m m.contains a = true
theorem Std.HashSet.Raw.contains_congr {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (h : m.WF) {a : α} {b : α} (hab : (a == b) = true) :
m.contains a = m.contains b
theorem Std.HashSet.Raw.mem_congr {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (h : m.WF) {a : α} {b : α} (hab : (a == b) = true) :
a m b m
@[simp]
theorem Std.HashSet.Raw.contains_empty {α : Type u} [BEq α] [Hashable α] {a : α} {c : Nat} :
@[simp]
theorem Std.HashSet.Raw.not_mem_empty {α : Type u} [BEq α] [Hashable α] {a : α} {c : Nat} :
@[simp]
theorem Std.HashSet.Raw.contains_emptyc {α : Type u} [BEq α] [Hashable α] {a : α} :
.contains a = false
@[simp]
theorem Std.HashSet.Raw.not_mem_emptyc {α : Type u} [BEq α] [Hashable α] {a : α} :
theorem Std.HashSet.Raw.contains_of_isEmpty {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (h : m.WF) {a : α} :
m.isEmpty = truem.contains a = false
theorem Std.HashSet.Raw.not_mem_of_isEmpty {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (h : m.WF) {a : α} :
m.isEmpty = true¬a m
theorem Std.HashSet.Raw.isEmpty_eq_false_iff_exists_contains_eq_true {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (h : m.WF) :
m.isEmpty = false ∃ (a : α), m.contains a = true
theorem Std.HashSet.Raw.isEmpty_eq_false_iff_exists_mem {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (h : m.WF) :
m.isEmpty = false ∃ (a : α), a m
theorem Std.HashSet.Raw.isEmpty_iff_forall_contains {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (h : m.WF) :
m.isEmpty = true ∀ (a : α), m.contains a = false
theorem Std.HashSet.Raw.isEmpty_iff_forall_not_mem {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (h : m.WF) :
m.isEmpty = true ∀ (a : α), ¬a m
@[simp]
theorem Std.HashSet.Raw.insert_eq_insert {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] {a : α} :
insert a m = m.insert a
@[simp]
theorem Std.HashSet.Raw.singleton_eq_insert {α : Type u} [BEq α] [Hashable α] {a : α} :
{a} = .insert a
@[simp]
theorem Std.HashSet.Raw.contains_insert {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (h : m.WF) {k : α} {a : α} :
(m.insert k).contains a = (k == a || m.contains a)
@[simp]
theorem Std.HashSet.Raw.mem_insert {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (h : m.WF) {k : α} {a : α} :
a m.insert k (k == a) = true a m
theorem Std.HashSet.Raw.contains_of_contains_insert {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (h : m.WF) {k : α} {a : α} :
(m.insert k).contains a = true(k == a) = falsem.contains a = true
theorem Std.HashSet.Raw.mem_of_mem_insert {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (h : m.WF) {k : α} {a : α} :
a m.insert k(k == a) = falsea m
theorem Std.HashSet.Raw.contains_of_contains_insert' {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (h : m.WF) {k : α} {a : α} :
(m.insert k).contains a = true¬((k == a) = true m.contains k = false)m.contains a = true

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.Raw.mem_of_mem_insert' {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (h : m.WF) {k : α} {a : α} :
a m.insert k¬((k == a) = true ¬k m)a m

This is a restatement of mem_insert that is written to exactly match the proof obligation in the statement of get_insertIfNew.

@[simp]
theorem Std.HashSet.Raw.contains_insert_self {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (h : m.WF) {k : α} :
(m.insert k).contains k = true
@[simp]
theorem Std.HashSet.Raw.mem_insert_self {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (h : m.WF) {k : α} :
k m.insert k
theorem Std.HashSet.Raw.size_insert {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (h : m.WF) {k : α} :
(m.insert k).size = if k m then m.size else m.size + 1
theorem Std.HashSet.Raw.size_le_size_insert {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (h : m.WF) {k : α} :
m.size (m.insert k).size
theorem Std.HashSet.Raw.size_insert_le {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (h : m.WF) {k : α} :
(m.insert k).size m.size + 1
@[simp]
theorem Std.HashSet.Raw.erase_empty {α : Type u} [BEq α] [Hashable α] {k : α} {c : Nat} :
@[simp]
theorem Std.HashSet.Raw.erase_emptyc {α : Type u} [BEq α] [Hashable α] {k : α} :
.erase k =
@[simp]
theorem Std.HashSet.Raw.isEmpty_erase {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (h : m.WF) {k : α} :
(m.erase k).isEmpty = (m.isEmpty || m.size == 1 && m.contains k)
@[simp]
theorem Std.HashSet.Raw.contains_erase {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (h : m.WF) {k : α} {a : α} :
(m.erase k).contains a = (!k == a && m.contains a)
@[simp]
theorem Std.HashSet.Raw.mem_erase {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (h : m.WF) {k : α} {a : α} :
a m.erase k (k == a) = false a m
theorem Std.HashSet.Raw.contains_of_contains_erase {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (h : m.WF) {k : α} {a : α} :
(m.erase k).contains a = truem.contains a = true
theorem Std.HashSet.Raw.mem_of_mem_erase {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (h : m.WF) {k : α} {a : α} :
a m.erase ka m
theorem Std.HashSet.Raw.size_erase {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (h : m.WF) {k : α} :
(m.erase k).size = if k m then m.size - 1 else m.size
theorem Std.HashSet.Raw.size_erase_le {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (h : m.WF) {k : α} :
(m.erase k).size m.size
theorem Std.HashSet.Raw.size_le_size_erase {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (h : m.WF) {k : α} :
m.size (m.erase k).size + 1
@[simp]
theorem Std.HashSet.Raw.get?_empty {α : Type u} [BEq α] [Hashable α] {a : α} {c : Nat} :
(Std.HashSet.Raw.empty c).get? a = none
@[simp]
theorem Std.HashSet.Raw.get?_emptyc {α : Type u} [BEq α] [Hashable α] {a : α} :
.get? a = none
theorem Std.HashSet.Raw.get?_of_isEmpty {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (h : m.WF) {a : α} :
m.isEmpty = truem.get? a = none
theorem Std.HashSet.Raw.get?_insert {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (h : m.WF) {k : α} {a : α} :
(m.insert k).get? a = if (k == a) = true ¬k m then some k else m.get? a
theorem Std.HashSet.Raw.contains_eq_isSome_get? {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (h : m.WF) {a : α} :
m.contains a = (m.get? a).isSome
theorem Std.HashSet.Raw.get?_eq_none_of_contains_eq_false {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (h : m.WF) {a : α} :
m.contains a = falsem.get? a = none
theorem Std.HashSet.Raw.get?_eq_none {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (h : m.WF) {a : α} :
¬a mm.get? a = none
theorem Std.HashSet.Raw.get?_erase {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (h : m.WF) {k : α} {a : α} :
(m.erase k).get? a = if (k == a) = true then none else m.get? a
theorem Std.HashSet.Raw.get_insert {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (h : m.WF) {k : α} {a : α} {h₁ : a m.insert k} :
(m.insert k).get a h₁ = if h₂ : (k == a) = true ¬k m then k else m.get a
@[simp]
theorem Std.HashSet.Raw.get_erase {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (h : m.WF) {k : α} {a : α} {h' : a m.erase k} :
(m.erase k).get a h' = m.get a
theorem Std.HashSet.Raw.get?_eq_some_get {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (h : m.WF) {a : α} {h' : a m} :
m.get? a = some (m.get a h')
@[simp]
theorem Std.HashSet.Raw.get?_erase_self {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (h : m.WF) {k : α} :
(m.erase k).get? k = none
@[simp]
theorem Std.HashSet.Raw.get!_empty {α : Type u} [BEq α] [Hashable α] [Inhabited α] {a : α} {c : Nat} :
(Std.HashSet.Raw.empty c).get! a = default
@[simp]
theorem Std.HashSet.Raw.get!_emptyc {α : Type u} [BEq α] [Hashable α] [Inhabited α] {a : α} :
.get! a = default
theorem Std.HashSet.Raw.get!_of_isEmpty {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [Inhabited α] [EquivBEq α] [LawfulHashable α] (h : m.WF) {a : α} :
m.isEmpty = truem.get! a = default
theorem Std.HashSet.Raw.get!_insert {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [Inhabited α] [EquivBEq α] [LawfulHashable α] (h : m.WF) {k : α} {a : α} :
(m.insert k).get! a = if (k == a) = true ¬k m then k else m.get! a
theorem Std.HashSet.Raw.get!_eq_default_of_contains_eq_false {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [Inhabited α] [EquivBEq α] [LawfulHashable α] (h : m.WF) {a : α} :
m.contains a = falsem.get! a = default
theorem Std.HashSet.Raw.get!_eq_default {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [Inhabited α] [EquivBEq α] [LawfulHashable α] (h : m.WF) {a : α} :
¬a mm.get! a = default
theorem Std.HashSet.Raw.get!_erase {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [Inhabited α] [EquivBEq α] [LawfulHashable α] (h : m.WF) {k : α} {a : α} :
(m.erase k).get! a = if (k == a) = true then default else m.get! a
@[simp]
theorem Std.HashSet.Raw.get!_erase_self {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [Inhabited α] [EquivBEq α] [LawfulHashable α] (h : m.WF) {k : α} :
(m.erase k).get! k = default
theorem Std.HashSet.Raw.get?_eq_some_get!_of_contains {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] [Inhabited α] (h : m.WF) {a : α} :
m.contains a = truem.get? a = some (m.get! a)
theorem Std.HashSet.Raw.get?_eq_some_get! {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] [Inhabited α] (h : m.WF) {a : α} :
a mm.get? a = some (m.get! a)
theorem Std.HashSet.Raw.get!_eq_get!_get? {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] [Inhabited α] (h : m.WF) {a : α} :
m.get! a = (m.get? a).get!
theorem Std.HashSet.Raw.get_eq_get! {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] [Inhabited α] (h : m.WF) {a : α} {h' : a m} :
m.get a h' = m.get! a
@[simp]
theorem Std.HashSet.Raw.getD_empty {α : Type u} [BEq α] [Hashable α] {a : α} {fallback : α} {c : Nat} :
(Std.HashSet.Raw.empty c).getD a fallback = fallback
@[simp]
theorem Std.HashSet.Raw.getD_emptyc {α : Type u} [BEq α] [Hashable α] {a : α} {fallback : α} :
.getD a fallback = fallback
theorem Std.HashSet.Raw.getD_of_isEmpty {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (h : m.WF) {a : α} {fallback : α} :
m.isEmpty = truem.getD a fallback = fallback
theorem Std.HashSet.Raw.getD_insert {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (h : m.WF) {k : α} {a : α} {fallback : α} :
(m.insert k).getD a fallback = if (k == a) = true ¬k m then k else m.getD a fallback
theorem Std.HashSet.Raw.getD_eq_fallback_of_contains_eq_false {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (h : m.WF) {a : α} {fallback : α} :
m.contains a = falsem.getD a fallback = fallback
theorem Std.HashSet.Raw.getD_eq_fallback {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (h : m.WF) {a : α} {fallback : α} :
¬a mm.getD a fallback = fallback
theorem Std.HashSet.Raw.getD_erase {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (h : m.WF) {k : α} {a : α} {fallback : α} :
(m.erase k).getD a fallback = if (k == a) = true then fallback else m.getD a fallback
@[simp]
theorem Std.HashSet.Raw.getD_erase_self {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (h : m.WF) {k : α} {fallback : α} :
(m.erase k).getD k fallback = fallback
theorem Std.HashSet.Raw.get?_eq_some_getD_of_contains {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (h : m.WF) {a : α} {fallback : α} :
m.contains a = truem.get? a = some (m.getD a fallback)
theorem Std.HashSet.Raw.get?_eq_some_getD {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (h : m.WF) {a : α} {fallback : α} :
a mm.get? a = some (m.getD a fallback)
theorem Std.HashSet.Raw.getD_eq_getD_get? {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (h : m.WF) {a : α} {fallback : α} :
m.getD a fallback = (m.get? a).getD fallback
theorem Std.HashSet.Raw.get_eq_getD {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] (h : m.WF) {a : α} {fallback : α} {h' : a m} :
m.get a h' = m.getD a fallback
theorem Std.HashSet.Raw.get!_eq_getD_default {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] [EquivBEq α] [LawfulHashable α] [Inhabited α] (h : m.WF) {a : α} :
m.get! a = m.getD a default
@[simp]
theorem Std.HashSet.Raw.containsThenInsert_fst {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] (h : m.WF) {k : α} :
(m.containsThenInsert k).fst = m.contains k
@[simp]
theorem Std.HashSet.Raw.containsThenInsert_snd {α : Type u} {m : Std.HashSet.Raw α} [BEq α] [Hashable α] (h : m.WF) {k : α} :
(m.containsThenInsert k).snd = m.insert k