Analysis I, Section 3.1: Fundamentals (of set theory) #
In this section we set up a version of Zermelo-Frankel set theory (with atoms) that tries to be as faithful as possible to the original text of Analysis I, Section 3.1. All numbering refers to the original text.
I have attempted to make the translation as faithful a paraphrasing as possible of the original text. When there is a choice between a more idiomatic Lean solution and a more faithful translation, I have generally chosen the latter. In particular, there will be places where the Lean code could be "golfed" to be more elegant and idiomatic, but I have consciously avoided doing so.
Main constructions and results of this section:
- A type
Chapter3.SetTheory.Setof sets - A type
Chapter3.SetTheory.Objectof objects - An axiom that every set is (or can be coerced into) an object
- The empty set
∅, singletons{y}, and pairs{y,z}(and more general finite tuples), with their attendant axioms - Pairwise union
X ∪ Y, and their attendant axioms - Coercion of a set
Ato its associated typeA.toSubtype, which is a subtype ofObject, and basic API. (This is a technical construction needed to make the Zermelo-Frankel set theory compatible with the dependent type theory of Lean.) - The specification
A.specify Pof a setAand a predicateP: A.toSubtype → Propto the subset of elements ofAobeyingP, and the axiom of specification. TODO: somehow implement set builder elaboration for this. - The replacement
A.replace hPof a setAvia a predicateP: A.toSubtype → Object → Propobeying a uniqueness condition∀ x y y', P x y ∧ P x y' → y = y', and the axiom of replacement. - A bijective correspondence between the Mathlib natural numbers
ℕand a setChapter3.Nat : Chapter3.Set(the axiom of infinity). - Axioms of regularity, power set, and union (used in later sections of this chapter, but not required here)
- Connections with Mathlib's notion of a set
The other axioms of Zermelo-Frankel set theory are discussed in later sections.
Some technical notes:
- Mathlib of course has its own notion of a
Set(or more precisely, a typeSet Xassociated to each typeX), which is not compatible with the notionChapter3.Setdefined here, though we will try to make the notations match as much as possible. This causes some notational conflict: for instance, one may need to explicitly specify(∅:Chapter3.Set)instead of just∅to indicate that one is using theChapter3.Setversion of the empty set, rather than the Mathlib version of the empty set, and similarly for other notation defined here. - In Analysis I, we chose to work with an "impure" set theory, in which there could be more
Objects than justSets. In the type theory of Lean, this requires treatingChapter3.SetandChapter3.Objectas distinct types. Occasionally this means we have to use a coercion(X: Chapter3.Object)of aChapter3.SetXto make into aChapter3.Object: this is mostly needed when manipulating sets of sets. - Strictly speaking, a set
X:Setis not a type; however, we will coerce sets to types, and specifically to a subtype ofObject. A similar coercion is in place for Mathlib's formalization of sets. - After this chapter is concluded, the notion of a
Chapter3.SetTheory.Setwill be deprecated in favor of the standard Mathlib notion of aSet(or more precisely of the typeSet Xof a set in a given typeX). However, due to various technical incompatibilities between set theory and type theory, we will not attempt to create a full equivalence between these two notions of sets. (As such, this makes this entire chapter optional from the point of view of the rest of the book, though we retain it for pedagogical purposes.)
Tips from past users #
Users of the companion who have completed the exercises in this section are welcome to send their tips for future users in this section as PRs.
- (Add tip here)
The axioms of Zermelo-Frankel theory with atoms.
Instances
Definition 3.1.1 (objects can be elements of sets)
Equations
- Chapter3.SetTheory.objects_mem_sets = { mem := fun (X : Chapter3.Set) (x : Chapter3.Object) => Chapter3.SetTheory.mem x X }
Axiom 3.1 (Sets are objects)
Equations
- Chapter3.SetTheory.sets_are_objects = { coe := fun (X : Chapter3.Set) => Chapter3.SetTheory.set_to_object X }
Axiom 3.1 (Sets are objects)
Axiom 3.1 (Sets are objects)
Equations
- Chapter3.SetTheory.Set.instEmpty = { emptyCollection := Chapter3.SetTheory.emptyset }
Axiom 3.3 (empty set). Note: in some applications one may have to explicitly cast ∅ to Set due to Mathlib's existing set theory notation.
Equations
- Chapter3.SetTheory.Set.instSingleton = { singleton := Chapter3.SetTheory.singleton }
Equations
Equations
- Chapter3.SetTheory.Set.instInsert = { insert := fun (x : Chapter3.Object) (X : Chapter3.Set) => {x} ∪ X }
Equations
Instances For
Equations
Instances For
Equations
Instances For
Exercise 3.1.2
Exercise 3.1.2
Exercise 3.1.2
Definition 3.1.14.
Equations
- Chapter3.SetTheory.Set.instSubset = { Subset := fun (X Y : Chapter3.Set) => ∀ x ∈ X, x ∈ Y }
Definition 3.1.14.
Note that the strict subset operation in Mathlib is denoted ⊂ rather than ⊊.
Equations
- Chapter3.SetTheory.Set.instSSubset = { SSubset := fun (X Y : Chapter3.Set) => X ⊆ Y ∧ X ≠ Y }
Examples 3.1.16
This defines the subtype A.toSubtype for any A:Set.
Note that A.toSubtype gives you a type, similar to how Object or Set are types.
A value x' of type A.toSubtype combines some x: Object with a proof that hx: x ∈ A.
To produce an element x' of this subtype, use ⟨ x, hx ⟩, where x: Object and hx: x ∈ A.
The object x associated to a subtype element x' is recovered as x'.val, and
the property hx that x belongs to A is recovered as x'.property.
Instances For
Equations
- Chapter3.instCoeSortSetType = { coe := fun (A : Chapter3.Set) => A.toSubtype }
If one has a proof hx of x ∈ A, then A.subtype_mk hx will then make the element of A
(viewed as a subtype) corresponding to x.
Equations
- A.subtype_mk hx = ⟨x, hx⟩
Instances For
Equations
- Chapter3.SetTheory.Set.instIntersection = { inter := fun (X Y : Chapter3.Set) => X.specify fun (x : X.toSubtype) => ↑x ∈ Y }
Equations
- Chapter3.SetTheory.Set.instSDiff = { sdiff := fun (X Y : Chapter3.Set) => X.specify fun (x : X.toSubtype) => ↑x ∉ Y }
Not from textbook: sets form a distributive lattice.
Equations
- One or more equations did not get rendered due to their size.
Sets have a minimal element.
Equations
- Chapter3.SetTheory.Set.instOrderBot = { bot := ∅, bot_le := ⋯ }
Equations
Instances For
Axiom 3.8 (Axiom of infinity)
Instances For
Equations
Equations
- Chapter3.SetTheory.Set.instNatCast = { natCast := fun (n : ℕ) => Chapter3.SetTheory.Set.nat_equiv n }
Equations
- Chapter3.SetTheory.Set.toNat = { coe := fun (n : Chapter3.Nat.toSubtype) => Chapter3.SetTheory.Set.nat_equiv.symm n }
Equations
- Chapter3.SetTheory.Object.instNatCast = { natCast := fun (n : ℕ) => ↑↑n }
Equations
- Chapter3.SetTheory.Object.instOfNat = { ofNat := ↑↑n }
Exercise 3.1.10.
You may find Function.onFun_apply and the fin_cases tactic useful.
Exercise 3.1.11.
The challenge is to prove this without using Set.specify, Set.specification_axiom,
Set.specification_axiom', or anything built from them (like differences and intersections).
Equations
- Chapter3.SetTheory.Set.inst_coe_set = { coe := fun (X : Chapter3.Set) => {x : Chapter3.Object | x ∈ X} }