The areas / V03. Sets, finite structures and big operators
Mathlib.Data.Set.Insert
93 declarations and 9 deprecated aliases. Mathlib docs · Source
Lemmas about insertion, singleton, and pairs
This file provides extra lemmas about insert, singleton, and pair.
Tags
insert, singleton
Set coercion to a type
Lemmas about insert
insert a s is the set {a} ∪ s.
Lemmas about singletons
Disjointness
Lemmas about pairs
Powerset
Lemmas about inclusion, the injection of subtypes induced by ⊆
Decidability instances for sets
theorem Set.insert_def E0 #
∀ {α : Type u_1} (x : α) (s : Set α), insert x s = {y | y = x ∨ y ∈ s}
theorem Set.subset_insert E0 #
∀ {α : Type u_1} (x : α) (s : Set α), s ⊆ insert x s
theorem Set.mem_insert E0 #
∀ {α : Type u_1} (x : α) (s : Set α), x ∈ insert x s
theorem Set.mem_insert_of_mem E0 #
∀ {α : Type u_1} {x : α} {s : Set α} (y : α), x ∈ s → x ∈ insert y s
theorem Set.mem_of_mem_insert_of_ne E0 #
∀ {α : Type u_1} {s : Set α} {a b : α}, b ∈ insert a s → b ≠ a → b ∈ s
theorem Set.mem_insert_iff E0 #
∀ {α : Type u_1} {x a : α} {s : Set α}, x ∈ insert a s ↔ x = a ∨ x ∈ s
theorem Set.insert_eq_of_mem E0 #
∀ {α : Type u_1} {a : α} {s : Set α}, a ∈ s → insert a s = s
theorem Set.ne_insert_of_notMem E1 #
∀ {α : Type u_1} {s : Set α} (t : Set α) {a : α}, a ∉ s → s ≠ insert a t
theorem Set.insert_eq_self E0 #
∀ {α : Type u_1} {s : Set α} {a : α}, insert a s = s ↔ a ∈ s
theorem Set.insert_ne_self E1 #
∀ {α : Type u_1} {s : Set α} {a : α}, insert a s ≠ s ↔ a ∉ s
theorem Set.insert_subset_iff E0 #
∀ {α : Type u_1} {s t : Set α} {a : α}, insert a s ⊆ t ↔ a ∈ t ∧ s ⊆ t
theorem Set.insert_subset E1 #
∀ {α : Type u_1} {s t : Set α} {a : α}, a ∈ t → s ⊆ t → insert a s ⊆ t
theorem Set.insert_subset_insert E1 #
∀ {α : Type u_1} {s t : Set α} {a : α}, s ⊆ t → insert a s ⊆ insert a t
theorem Set.insert_subset_insert_iff E0 #
∀ {α : Type u_1} {s t : Set α} {a : α}, a ∉ s → (insert a s ⊆ insert a t ↔ s ⊆ t)
theorem Set.subset_insert_iff_of_notMem E1 #
∀ {α : Type u_1} {s t : Set α} {a : α}, a ∉ s → (s ⊆ insert a t ↔ s ⊆ t)
theorem Set.ssubset_iff_insert E1 #
∀ {α : Type u_1} {s t : Set α}, s ⊂ t ↔ ∃ a ∉ s, insert a s ⊆ t
theorem LE.le.ssubset_of_mem_notMem E1 #
∀ {α : Type u_1} {s t : Set α} {a : α}, s ⊆ t → a ∈ t → a ∉ s → s ⊂ t
theorem Set.ssubset_insert E1 #
∀ {α : Type u_1} {s : Set α} {a : α}, a ∉ s → s ⊂ insert a s
theorem Set.insert_comm E1 #
∀ {α : Type u_1} (a b : α) (s : Set α), insert a (insert b s) = insert b (insert a s)
theorem Set.insert_idem E1 #
∀ {α : Type u_1} (a : α) (s : Set α), insert a (insert a s) = insert a s
theorem Set.insert_union E1 #
∀ {α : Type u_1} {s t : Set α} {a : α}, insert a s ∪ t = insert a (s ∪ t)
theorem Set.union_insert E0 #
∀ {α : Type u_1} {s t : Set α} {a : α}, s ∪ insert a t = insert a (s ∪ t)
theorem Set.insert_nonempty E0 #
∀ {α : Type u_1} (a : α) (s : Set α), (insert a s).Nonempty
instance Set.instNonemptyElemInsert E0 #
∀ {α : Type u_1} (a : α) (s : Set α), Nonempty ↑(insert a s)
theorem Set.insert_inter_distrib E1 #
∀ {α : Type u_1} (a : α) (s t : Set α), insert a (s ∩ t) = insert a s ∩ insert a t
theorem Set.insert_union_distrib E1 #
∀ {α : Type u_1} (a : α) (s t : Set α), insert a (s ∪ t) = insert a s ∪ insert a t
theorem Set.forall_of_forall_insert E1 #
∀ {α : Type u_1} {P : α → Prop} {a : α} {s : Set α}, (∀ x ∈ insert a s, P x) → ∀ x ∈ s, P x
theorem Set.forall_insert_of_forall E1 #
∀ {α : Type u_1} {P : α → Prop} {a : α} {s : Set α}, (∀ x ∈ s, P x) → P a → ∀ x ∈ insert a s, P x
theorem Set.exists_mem_insert E1 #
∀ {α : Type u_1} {P : α → Prop} {a : α} {s : Set α}, (∃ x ∈ insert a s, P x) ↔ P a ∨ ∃ x ∈ s, P x
theorem Set.forall_mem_insert E1 #
∀ {α : Type u_1} {P : α → Prop} {a : α} {s : Set α}, (∀ x ∈ insert a s, P x) ↔ P a ∧ ∀ x ∈ s, P x
def Set.subtypeInsertEquivOption E1 #
{α : Type u_1} → [DecidableEq α] → {t : Set α} → {x : α} → x ∉ t → { i // i ∈ insert x t } ≃ Option { i // i ∈ t }
Inserting an element to a set is equivalent to the option type.
instance Set.instLawfulSingleton E0 #
∀ {α : Type u_1}, LawfulSingleton α (Set α)
theorem Set.singleton_def E0 #
∀ {α : Type u_1} (a : α), {a} = insert a ∅
theorem Set.mem_singleton_iff E0 #
∀ {α : Type u_1} {a b : α}, a ∈ {b} ↔ a = b
theorem Set.notMem_singleton_iff E0 #
∀ {α : Type u_1} {a b : α}, a ∉ {b} ↔ a ≠ b
theorem Set.ofPred_eq_eq_singleton E0 #
∀ {α : Type u_1} {a : α}, {n | n = a} = {a}
theorem Set.ofPred_eq_eq_singleton' E0 #
∀ {α : Type u_1} {a : α}, {x | a = x} = {a}
theorem Set.mem_singleton E0 #
∀ {α : Type u_1} (a : α), a ∈ {a}
theorem Set.singleton_eq_singleton_iff E0 #
∀ {α : Type u_1} {x y : α}, {x} = {y} ↔ x = y
theorem Set.singleton_injective E1 #
∀ {α : Type u_1}, Function.Injective singleton
theorem Set.mem_singleton_of_eq E0 #
∀ {α : Type u_1} {x y : α}, x = y → x ∈ {y}
theorem Set.insert_eq E0 #
∀ {α : Type u_1} (x : α) (s : Set α), insert x s = {x} ∪ s
theorem Set.singleton_nonempty E0 #
∀ {α : Type u_1} (a : α), {a}.Nonempty
theorem Set.empty_ssubset_singleton E1 #
∀ {α : Type u_1} {a : α}, ∅ ⊂ {a}
theorem Set.singleton_subset_iff E0 #
∀ {α : Type u_1} {a : α} {s : Set α}, {a} ⊆ s ↔ a ∈ s
theorem Set.singleton_subset_singleton E1 #
∀ {α : Type u_1} {a b : α}, {a} ⊆ {b} ↔ a = b
theorem Set.singleton_union E0 #
∀ {α : Type u_1} {s : Set α} {a : α}, {a} ∪ s = insert a s
theorem Set.union_singleton E0 #
∀ {α : Type u_1} {s : Set α} {a : α}, s ∪ {a} = insert a s
theorem Set.exists_mem_singleton E1 #
∀ {α : Type u_1} {P : α → Prop} {a : α}, (∃ x ∈ {a}, P x) ↔ P a
theorem Set.forall_mem_singleton E1 #
∀ {α : Type u_1} {P : α → Prop} {a : α}, (∀ x ∈ {a}, P x) ↔ P a
theorem Set.singleton_inter_nonempty E0 #
∀ {α : Type u_1} {s : Set α} {a : α}, ({a} ∩ s).Nonempty ↔ a ∈ s
theorem Set.inter_singleton_nonempty E0 #
∀ {α : Type u_1} {s : Set α} {a : α}, (s ∩ {a}).Nonempty ↔ a ∈ s
theorem Set.singleton_inter_eq_empty E0 #
∀ {α : Type u_1} {s : Set α} {a : α}, {a} ∩ s = ∅ ↔ a ∉ s
theorem Set.inter_singleton_eq_empty E0 #
∀ {α : Type u_1} {s : Set α} {a : α}, s ∩ {a} = ∅ ↔ a ∉ s
theorem Set.singleton_inter_of_notMem E0 #
∀ {α : Type u_1} {s : Set α} {a : α}, a ∉ s → {a} ∩ s = ∅
Alias of the reverse direction of Set.singleton_inter_eq_empty.
theorem Set.inter_singleton_of_notMem E0 #
∀ {α : Type u_1} {s : Set α} {a : α}, a ∉ s → s ∩ {a} = ∅
Alias of the reverse direction of Set.inter_singleton_eq_empty.
theorem Set.singleton_inter_of_mem E1 #
∀ {α : Type u_1} {s : Set α} {a : α}, a ∈ s → {a} ∩ s = {a}
theorem Set.inter_singleton_of_mem E1 #
∀ {α : Type u_1} {s : Set α} {a : α}, a ∈ s → s ∩ {a} = {a}
theorem Set.notMem_singleton_empty E1 #
∀ {α : Type u_1} {s : Set α}, s ∉ {∅} ↔ s.Nonempty
instance Set.uniqueSingleton E0 #
{α : Type u_1} → (a : α) → Unique ↑{a}
theorem Set.singleton_iff_unique_mem E1 #
∀ {α : Type u_1} {s : Set α}, (∃ a, s = {a}) ↔ ∃! a, a ∈ s
theorem Set.ofPred_mem_list_eq_replicate E1 #
∀ {α : Type u_1} {l : List α} {a : α}, {x | x ∈ l} = {a} ↔ ∃ n > 0, l = List.replicate n a
theorem Set.ofPred_mem_list_eq_singleton_of_nodup E1 #
∀ {α : Type u_1} {l : List α}, l.Nodup → ∀ {a : α}, {x | x ∈ l} = {a} ↔ l = [a]
theorem Set.default_coe_singleton E0 #
∀ {α : Type u_1} (x : α), default = ⟨x, ⋯⟩
theorem Set.subset_singleton_iff E0 #
∀ {α : Type u_3} {s : Set α} {x : α}, s ⊆ {x} ↔ ∀ y ∈ s, y = x
theorem Set.subset_singleton_iff_eq E0 #
∀ {α : Type u_1} {s : Set α} {x : α}, s ⊆ {x} ↔ s = ∅ ∨ s = {x}
theorem Set.Nonempty.subset_singleton_iff E0 #
∀ {α : Type u_1} {s : Set α} {a : α}, s.Nonempty → (s ⊆ {a} ↔ s = {a})
theorem Set.ssubset_singleton_iff E0 #
∀ {α : Type u_1} {s : Set α} {x : α}, s ⊂ {x} ↔ s = ∅
theorem Set.disjoint_singleton_left E0 #
∀ {α : Type u_1} {s : Set α} {a : α}, Disjoint {a} s ↔ a ∉ s
theorem Set.disjoint_singleton_right E0 #
∀ {α : Type u_1} {s : Set α} {a : α}, Disjoint s {a} ↔ a ∉ s
theorem Set.disjoint_singleton E1 #
∀ {α : Type u_1} {a b : α}, Disjoint {a} {b} ↔ a ≠ b
theorem Set.disjoint_insert_left E0 #
∀ {α : Type u_1} {s t : Set α} {a : α}, Disjoint (insert a s) t ↔ a ∉ t ∧ Disjoint s t
theorem Set.disjoint_insert_right E0 #
∀ {α : Type u_1} {s t : Set α} {a : α}, Disjoint s (insert a t) ↔ a ∉ s ∧ Disjoint s t
theorem Set.insert_inj E1 #
∀ {α : Type u_1} {s : Set α} {a b : α}, a ∉ s → (insert a s = insert b s ↔ a = b)
theorem Set.insert_sdiff_eq_singleton E0 #
∀ {α : Type u_1} {a : α} {s : Set α}, a ∉ s → insert a s \ s = {a}
theorem Set.inter_insert_of_mem E1 #
∀ {α : Type u_1} {s t : Set α} {a : α}, a ∈ s → s ∩ insert a t = insert a (s ∩ t)
theorem Set.insert_inter_of_mem E1 #
∀ {α : Type u_1} {s t : Set α} {a : α}, a ∈ t → insert a s ∩ t = insert a (s ∩ t)
theorem Set.inter_insert_of_notMem E1 #
∀ {α : Type u_1} {s t : Set α} {a : α}, a ∉ s → s ∩ insert a t = s ∩ t
theorem Set.insert_inter_of_notMem E1 #
∀ {α : Type u_1} {s t : Set α} {a : α}, a ∉ t → insert a s ∩ t = s ∩ t
theorem Set.pair_eq_singleton E1 #
∀ {α : Type u_1} (a : α), {a, a} = {a}
theorem Set.pair_comm E1 #
∀ {α : Type u_1} (a b : α), {a, b} = {b, a}
theorem Set.pair_eq_pair_iff E0 #
∀ {α : Type u_1} {x y z w : α}, {x, y} = {z, w} ↔ x = z ∧ y = w ∨ x = w ∧ y = z
theorem Set.pair_subset_iff E0 #
∀ {α : Type u_1} {s : Set α} {a b : α}, {a, b} ⊆ s ↔ a ∈ s ∧ b ∈ s
theorem Set.pair_subset E1 #
∀ {α : Type u_1} {s : Set α} {a b : α}, a ∈ s → b ∈ s → {a, b} ⊆ s
theorem Set.subset_pair_iff E0 #
∀ {α : Type u_1} {s : Set α} {a b : α}, s ⊆ {a, b} ↔ ∀ x ∈ s, x = a ∨ x = b
theorem Set.subset_pair_iff_eq E0 #
∀ {α : Type u_1} {s : Set α} {x y : α}, s ⊆ {x, y} ↔ s = ∅ ∨ s = {x} ∨ s = {y} ∨ s = {x, y}
theorem Set.Nonempty.subset_pair_iff_eq E0 #
∀ {α : Type u_1} {s : Set α} {a b : α}, s.Nonempty → (s ⊆ {a, b} ↔ s = {a} ∨ s = {b} ∨ s = {a, b})
theorem Set.range_ite_const E1 #
∀ {α : Type u_1} {β : Type u_2} {p : α → Prop} [inst : DecidablePred p] {x y : β},
(∃ a, p a) → (∃ a, ¬p a) → (Set.range fun a ↦ if p a then x else y) = {x, y}
theorem Set.powerset_singleton E1 #
∀ {α : Type u_1} (x : α), 𝒫 {x} = {∅, {x}}
The powerset of a singleton contains only ∅ and the singleton itself.
theorem Set.preimage_fst_singleton_eq_range E1 #
∀ {α : Type u_3} {β : Type u_4} {a : α}, Prod.fst ⁻¹' {a} = Set.range fun x ↦ (a, x)
theorem Set.preimage_snd_singleton_eq_range E1 #
∀ {α : Type u_3} {β : Type u_4} {b : β}, Prod.snd ⁻¹' {b} = Set.range fun x ↦ (x, b)
instance Set.decidableSingleton E0 #
{α : Type u_1} → (a b : α) → [Decidable (a = b)] → Decidable (a ∈ {b})
theorem Prop.compl_singleton E0 #
∀ (p : Prop), {p}ᶜ = {¬p}
Deprecated aliases
| Name | New name | Since |
|---|---|---|
HasSubset.Subset.ssubset_of_mem_notMem | LE.le.ssubset_of_mem_notMem | 2026-06-05 |
Set.empty_ne_singleton | Set.singleton_nonempty | 2026-11-14 |
Set.insert_diff_eq_singleton | Set.insert_sdiff_eq_singleton | 2026-06-03 |
Set.setOf_eq_eq_singleton | Set.ofPred_eq_eq_singleton | 2026-07-09 |
Set.setOf_eq_eq_singleton' | Set.ofPred_eq_eq_singleton' | 2026-07-09 |
Set.setOf_mem_list_eq_replicate | Set.ofPred_mem_list_eq_replicate | 2026-07-09 |
Set.setOf_mem_list_eq_singleton_of_nodup | Set.ofPred_mem_list_eq_singleton_of_nodup | 2026-07-09 |
Set.set_compr_eq_eq_singleton | Set.ofPred_eq_eq_singleton | 2026-11-16 |
Set.singleton_ne_empty | Set.singleton_nonempty | 2026-11-11 |