A model of ZFC #
THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.
In this file, we model Zermelo-Fraenkel set theory (+ Choice) using Lean's underlying type theory. We do this in four main steps:
- Define pre-sets inductively.
- Define extensional equivalence on pre-sets and give it a
setoid
instance. - Define ZFC sets by quotienting pre-sets by extensional equivalence.
- Define classes as sets of ZFC sets. Then the rest is usual set theory.
The model #
pSet
: Pre-set. A pre-set is inductively defined by its indexing type and its members, which are themselves pre-sets.Set
: ZFC set. Defined aspSet
quotiented bypSet.equiv
, the extensional equivalence.Class
: Class. Defined asset Set
.Set.choice
: Axiom of choice. Proved from Lean's axiom of choice.
Other definitions #
arity α n
:n
-ary functionα → α → ... → α
. Defined inductively.arity.const a n
:n
-ary constant function equal toa
.pSet.type
: Underlying type of a pre-set.pSet.func
: Underlying family of pre-sets of a pre-set.pSet.equiv
: Extensional equivalence of pre-sets. Defined inductively.pSet.omega
,Set.omega
: The von Neumann ordinalω
as apSet
, as aSet
.pSet.arity.equiv
: Extensional equivalence ofn
-arypSet
-valued functions. Extension ofpSet.equiv
.pSet.resp
: Collection ofn
-arypSet
-valued functions that respect extensional equivalence.pSet.eval
: Turns apSet
-valued function that respect extensional equivalence into aSet
-valued function.classical.all_definable
: All functions are classically definable.Set.is_func
: Predicate that a ZFC set is a subset ofx × y
that can be considered as a ZFC functionx → y
. That is, each member ofx
is related by the ZFC set to exactly one member ofy
.Set.funs
: ZFC set of ZFC functionsx → y
.Set.hereditarily p x
: Predicate that every set in the transitive closure ofx
has propertyp
.Class.iota
: Definite description operator.
Notes #
To avoid confusion between the Lean set
and the ZFC Set
, docstrings in this file refer to them
respectively as "set
" and "ZFC set".
TODO #
Prove Set.map_definable_aux
computably.
Constant n
-ary function with value a
.
Equations
- arity.const a (n + 1) = λ (_x : α), arity.const a n
- arity.const a 0 = a
Equations
The type of pre-sets in universe u
. A pre-set
is a family of pre-sets indexed by a type in Type u
.
The ZFC universe is defined as a quotient of this
to ensure extensionality.
Instances for pSet
The underlying type of a pre-set
Instances for pSet.type
Two pre-sets are extensionally equivalent if every element of the first family is extensionally equivalent to some element of the second family and vice-versa.
Equations
- pSet.setoid = {r := pSet.equiv, iseqv := pSet.setoid._proof_1}
Equations
Equations
- pSet.has_mem = {mem := pSet.mem}
Equations
Equations
The empty pre-set
Equations
Equations
Equations
- pSet.inhabited = {default := ∅}
Equations
Equations
- pSet.has_singleton = {singleton := λ (s : pSet), {s}}
Equations
The n-th von Neumann ordinal
Equations
- pSet.of_nat (n + 1) = has_insert.insert (pSet.of_nat n) (pSet.of_nat n)
- pSet.of_nat 0 = ∅
The von Neumann ordinal ω
Equations
- pSet.omega = pSet.mk (ulift ℕ) (λ (n : ulift ℕ), pSet.of_nat n.down)
Equations
- pSet.has_sep = {sep := pSet.sep}
Function equivalence is defined so that f ~ g
iff ∀ x y, x ~ y → f x ~ g y
. This extends to
equivalence of n
-ary functions.
Equations
- pSet.arity.equiv a b = ∀ (x y : pSet), x.equiv y → pSet.arity.equiv (a x) (b y)
- pSet.arity.equiv a b = pSet.equiv a b
resp n
is the collection of n-ary functions on pSet
that respect
equivalence, i.e. when the inputs are equivalent the output is as well.
Equations
- pSet.resp n = {x // pSet.arity.equiv x x}
Instances for pSet.resp
Equations
Function equivalence for functions respecting equivalence. See pSet.arity.equiv
.
Equations
- a.equiv b = pSet.arity.equiv a.val b.val
Equations
- pSet.resp.setoid = {r := pSet.resp.equiv n, iseqv := _}
The ZFC universe of sets consists of the type of pre-sets, quotiented by extensional equivalence.
Equations
Instances for Set
- Set.has_mem
- Set.has_subset
- Set.has_subset.subset.is_refl
- Set.has_subset.subset.is_trans
- Set.has_subset.subset.is_antisymm
- Set.has_emptyc
- Set.inhabited
- Set.has_insert
- Set.has_singleton
- Set.is_lawful_singleton
- Set.has_sep
- Set.has_union
- Set.has_inter
- Set.has_sdiff
- Set.has_well_founded
- Set.has_mem.mem.is_asymm
- Class.has_sep
- Class.has_insert
- Class.has_coe
Helper function for pSet.eval
.
An equivalence-respecting function yields an n-ary ZFC set function.
Equations
Instances for pSet.resp.eval
- mk : Π {n : ℕ} (f : pSet.resp n), pSet.definable n (pSet.resp.eval n f)
A set function is "definable" if it is the image of some n-ary pre-set function. This isn't exactly definability, but is useful as a sufficient condition for functions that have a computable image.
Instances of this typeclass
Instances of other typeclasses for pSet.definable
- pSet.definable.has_sizeof_inst
The evaluation of a function respecting equivalence is definable, by that same function.
Equations
Turns a definable function into a function that respects equivalence.
Equations
- pSet.definable.resp (pSet.resp.eval n f) = f
All functions are classically definable.
Equations
- classical.all_definable F = pSet.definable.eq_mk ⟨λ (x : pSet), (pSet.definable.resp (F ⟦x⟧)).val, _⟩ _
- classical.all_definable F = let p : ∃ (a : pSet), ⟦a⟧ = F := _ in pSet.definable.eq_mk ⟨classical.some p, _⟩ _
Equations
- Set.has_mem = {mem := Set.mem}
Equations
Equations
Equations
- Set.inhabited = {default := ∅}
insert x y
is the set {x} ∪ y
Equations
- Set.insert = pSet.resp.eval 2 ⟨pSet.insert, Set.insert._proof_1⟩
Equations
Equations
- Set.has_singleton = {singleton := λ (x : Set), {x}}
Equations
- Set.has_sep = {sep := Set.sep}
The powerset operation, the collection of subsets of a ZFC set
Equations
- Set.powerset = pSet.resp.eval 1 ⟨pSet.powerset, Set.powerset._proof_1⟩
The union operator, the collection of elements of elements of a ZFC set
Equations
- Set.sUnion = pSet.resp.eval 1 ⟨pSet.sUnion, Set.sUnion._proof_1⟩
The intersection operator, the collection of elements in all of the elements of a ZFC set. We
special-case ⋂₀ ∅ = ∅
.
Equations
Equations
Equations
- Set.has_sdiff = {sdiff := Set.diff}
Equations
The image of a (definable) ZFC set function
Equations
- Set.image f = let r : pSet.resp 1 := pSet.definable.resp f in pSet.resp.eval 1 ⟨pSet.image r.val, _⟩
is_func x y f
is the assertion that f
is a subset of x × y
which relates to each element
of x
a unique element of y
, so that we can consider f
as a ZFC function x → y
.
Equations
- Set.map_definable_aux f = classical.all_definable (λ (y : Set), y.pair (f y))
Given a predicate p
on ZFC sets. hereditarily p x
means that x
has property p
and the
members of x
are all hereditarily p
.
Equations
- Set.hereditarily p x = (p x ∧ ∀ (y : Set), y ∈ x → Set.hereditarily p y)
Alias of the forward direction of Set.hereditarily_iff
.
Coerce a ZFC set into a class
Equations
- Class.of_Set x = {y : Set | y ∈ x}
Equations
Equations
- Class.has_mem = {mem := Class.mem}
Equations
There is no universal set.
This is stated as univ ∉ univ
, meaning that univ
(the class of all sets) is proper (does not
belong to the class of all sets).
Convert a conglomerate (a collection of classes) into a class
Equations
- Class.Cong_to_Class x = {y : Set | ↑y ∈ x}
Convert a class into a conglomerate (a collection of classes)
Equations
- x.Class_to_Cong = {y : Class | y ∈ x}
The power class of a class is the class of all subclasses that are ZFC sets
Equations
- x.powerset = Class.Cong_to_Class (𝒫x)
The union of a class is the class of all members of ZFC sets in the class
Equations
- ⋃₀ x = ⋃₀ x.Class_to_Cong
The intersection of a class is the class of all members of ZFC sets in the class
Equations
- ⋂₀ x = ⋂₀ x.Class_to_Cong
An induction principle for sets. If every subset of a class is a member, then the class is universal.
Function value
Equations
- F ′ A = Class.iota (λ (y : Set), Class.to_Set (λ (x : Set), F (x.pair y)) A)