Basic properties of sets #
Sets in Lean are homogeneous; all their elements have the same type. Sets whose elements
have type X
are thus defined as Set X := X → Prop
. Note that this function need not
be decidable. The definition is in the core library.
This file provides some basic definitions related to sets and functions not present in the core library, as well as extra lemmas for functions in the core library (empty set, univ, union, intersection, insert, singleton, set-theoretic difference, complement, and powerset).
Note that a set is a term, not a type. There is a coercion from Set α
to Type*
sending
s
to the corresponding subtype ↥s
.
See also the file SetTheory/ZFC.lean
, which contains an encoding of ZFC set theory in Lean.
Main definitions #
Notation used here:
Definitions in the file:
Nonempty s : Prop
: the predicates ≠ ∅
. Note that this is the preferred way to express the fact thats
has an element (see the Implementation Notes).inclusion s₁ s₂ : ↥s₁ → ↥s₂
: the map↥s₁ → ↥s₂
induced by an inclusions₁ ⊆ s₂
.
Notation #
sᶜ
for the complement ofs
Implementation notes #
s.Nonempty
is to be preferred tos ≠ ∅
or∃ x, x ∈ s
. It has the advantage that thes.Nonempty
dot notation can be used.For
s : Set α
, do not useSubtype s
. Instead use↥s
or(s : Type*)
ors
.
Tags #
set, sets, subset, subsets, union, intersection, insert, singleton, complement, powerset
Set coercion to a type #
Equations
- Set.instBooleanAlgebraSet = BooleanAlgebra.mk ⋯ ⋯ ⋯ ⋯ ⋯ ⋯
Alias of the forward direction of Set.le_iff_subset
.
Alias of the reverse direction of Set.le_iff_subset
.
Alias of the forward direction of Set.lt_iff_ssubset
.
Alias of the reverse direction of Set.lt_iff_ssubset
.
Equations
- instCoeTCElem s = { coe := fun (x : ↑s) => ↑x }
This lemma is intended for use with rw
where a membership predicate is needed,
hence the explicit argument and the equality in the reverse direction from normal.
See also Set.mem_setOf_eq
for the reverse direction applied to an argument.
Subset and strict subset relations #
Equations
- ⋯ = ⋯
Equations
- ⋯ = ⋯
Definition of strict subsets s ⊂ t
and basic properties. #
Non-empty sets #
Alias of the reverse direction of Set.nonempty_coe_sort
.
Extract a witness from s.Nonempty
. This function might be used instead of case analysis
on the argument. Note that it makes a proof depend on the Classical.choice
axiom.
Equations
- h.some = Classical.choose h
Instances For
Lemmas about the empty set #
See also Set.nonempty_iff_ne_empty
.
See also Set.not_nonempty_iff_eq_empty
.
See also nonempty_iff_ne_empty'
.
See also not_nonempty_iff_eq_empty'
.
Alias of Set.forall_mem_empty
.
Alias of the reverse direction of Set.empty_ssubset
.
Universal set. #
In Lean @univ α
(or univ : Set α
) is the set that contains all elements of type α
.
Mathematically it is the same as α
but it has a different type.
Alias of the forward direction of Set.univ_subset_iff
.
Equations
- ⋯ = ⋯
Lemmas about union #
Equations
- ⋯ = ⋯
Equations
- ⋯ = ⋯
Lemmas about intersection #
Equations
- ⋯ = ⋯
Equations
- ⋯ = ⋯
Distributivity laws #
Lemmas about insert
#
insert α s
is the set {α} ∪ s
.
Alias of Set.exists_mem_insert
.
Alias of Set.forall_mem_insert
.
Lemmas about singletons #
Equations
- Set.uniqueSingleton a = { default := ⟨a, ⋯⟩, uniq := ⋯ }
Lemmas about sets defined as {x ∈ s | p x}
. #
Disjointness #
Alias of the reverse direction of Set.not_disjoint_iff_nonempty_inter
.
Alias of the forward direction of Set.disjoint_iff_forall_ne
.
Lemmas about complement #
Alias of the reverse direction of Set.subset_compl_iff_disjoint_right
.
Alias of the reverse direction of Set.subset_compl_iff_disjoint_left
.
Alias of the reverse direction of Set.disjoint_compl_left_iff_subset
.
Alias of the reverse direction of Set.disjoint_compl_right_iff_subset
.
Lemmas about set difference #
Alias of Set.diff_nonempty
.
Lemmas about pairs #
Powerset #
Sets defined as an if-then-else #
If-then-else for sets #
A function between linear orders which is neither monotone nor antitone makes a dent upright or downright.
A function between linear orders which is neither monotone nor antitone makes a dent upright or downright.
inclusion
is the "identity" function between two subsets s
and t
, where s ⊆ t
Equations
- Set.inclusion h x = ⟨↑x, ⋯⟩
Instances For
Decidability instances for sets #
Equations
Equations
- Set.decidableUniv a = isTrue ⋯
Equations
- Set.decidableSingleton a b = inferInstanceAs (Decidable (a = b))
Equations
- Set.decidableSetOf a p = inst