Analysis I, Section 3.1

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:

The other axioms of Zermelo-Frankel set theory are discussed in later sections.

Some technical notes:

namespace Chapter3

Some of the axioms of Zermelo-Frankel theory with atoms

class SetTheory where Set : Type Object : Type set_to_object : Set Object mem : Object Set Prop emptyset: Set emptyset_mem x : ¬ mem x emptyset extensionality X Y : ( x, mem x X mem x Y) X = Y singleton : Object Set singleton_axiom x y : mem x (singleton y) x = y union_pair : Set Set Set union_pair_axiom X Y x : mem x (union_pair X Y) (mem x X mem x Y) specify A (P: Subtype (fun x mem x A) Prop) : Set specification_axiom A (P: Subtype (fun x mem x A) Prop) : ( x, mem x (specify A P) mem x A) x, mem x.val (specify A P) P x replace A (P: Subtype (fun x mem x A) Object Prop) (hP: x y y', P x y P x y' y = y') : Set replacement_axiom A (P: Subtype (fun x mem x A) Object Prop) (hP: x y y', P x y P x y' y = y') : y, mem y (replace A P hP) x, P x y nat : Set nat_equiv : Subtype (fun x mem x nat)export SetTheory (Set Object)-- This instance implicitly imposes (some of) the axioms of Zermelo-Frankel set theory with atoms. variable [SetTheory]

Definition 3.1.1 (objects can be elements of sets)

instance objects_mem_sets : Membership Object Set where mem X x := SetTheory.mem x X

Axiom 3.1 (Sets are objects)

instance sets_are_objects : Coe Set Object where coe X := SetTheory.set_to_object Xabbrev SetTheory.Set.toObject (X:Set) : Object := X

Axiom 3.1 (Sets are objects)

theorem SetTheory.Set.coe_eq {X Y:Set} (h: X.toObject = Y.toObject) : X = Y := SetTheory.set_to_object.inj' h

Axiom 3.1 (Sets are objects)

@[simp] theorem SetTheory.Set.coe_eq_iff (X Y:Set) : X.toObject = Y.toObject X = Y := inst✝:SetTheoryX:SetY:SetX.toObject = Y.toObjectX = Y inst✝:SetTheoryX:SetY:SetX.toObject = Y.toObjectX = Yinst✝:SetTheoryX:SetY:SetX = YX.toObject = Y.toObject inst✝:SetTheoryX:SetY:SetX.toObject = Y.toObjectX = Y All goals completed! 🐙 inst✝:SetTheoryX:SetY:Seth:X = YX.toObject = Y.toObject; inst✝:SetTheoryX:SetX.toObject = X.toObject; All goals completed! 🐙

Axiom 3.2 (Equality of sets)

abbrev SetTheory.Set.ext {X Y:Set} (h: x, x X x Y) : X = Y := SetTheory.extensionality _ _ h

Axiom 3.2 (Equality of sets)

theorem SetTheory.Set.ext_iff (X Y: Set) : X = Y x, x X x Y := inst✝:SetTheoryX:SetY:SetX = Y∀ (x : Object), xXxY inst✝:SetTheoryX:SetY:SetX = Y → ∀ (x : Object), xXxYinst✝:SetTheoryX:SetY:Set(∀ (x : Object), xXxY) → X = Y inst✝:SetTheoryX:SetY:SetX = Y → ∀ (x : Object), xXxY inst✝:SetTheoryX:SetY:Seth:X = Y∀ (x : Object), xXxY; inst✝:SetTheoryX:Set∀ (x : Object), xXxX; All goals completed! 🐙 inst✝:SetTheoryX:SetY:Set(∀ (x : Object), xXxY) → X = Y inst✝:SetTheoryX:SetY:Seth:∀ (x : Object), xXxYX = Y; inst✝:SetTheoryX:SetY:Seth:∀ (x : Object), xXxY∀ (x : Object), xXxY; All goals completed! 🐙instance SetTheory.Set.instEmpty : EmptyCollection Set where emptyCollection := SetTheory.emptyset

Axiom 3.3 (empty set). Note: one may have to explicitly cast ∅ to Set due to Mathlib's existing set theory notation.

theorem SetTheory.Set.not_mem_empty : x, x (:Set) := SetTheory.emptyset_mem

Empty set is unique

theorem declaration uses 'sorry'SetTheory.Set.eq_empty_iff_forall_notMem {X:Set} : X = ( x, ¬ x X) := inst✝:SetTheoryX:SetX = ∀ (x : Object), xX All goals completed! 🐙

Empty set is unique

theorem declaration uses 'sorry'SetTheory.Set.empty_unique : ∃! (X:Set), x, ¬ x X := inst✝:SetTheory∃! X, ∀ (x : Object), xX All goals completed! 🐙/-- Lemma 3.1.5 (Single choice) -/ lemma SetTheory.Set.nonempty_def {X:Set} (h: X ) : x, x X := inst✝:SetTheoryX:Seth:Xx, xX -- This proof is written to follow the structure of the original text. inst✝:SetTheoryX:Seth:Xthis:∀ (x : Object), xXFalse have claim (x:Object) : x X x (:Set) := inst✝:SetTheoryX:Seth:Xx, xX All goals completed! 🐙 inst✝:SetTheoryX:Seth:Xthis:∀ (x : Object), xXclaim:X = False All goals completed! 🐙instance SetTheory.Set.instSingleton : Singleton Object Set where singleton := SetTheory.singleton

Axiom 3.3(a) (singleton). Note one may have to explicitly cast {a} to Set due to Mathlib's existing set theory notation.

theorem SetTheory.Set.mem_singleton (x a:Object) : x ({a}:Set) x = a := inst✝:SetTheoryx:Objecta:Objectx{a}x = a All goals completed! 🐙instance SetTheory.Set.instUnion : Union Set where union := SetTheory.union_pair

Axiom 3.4 (Pairwise union)

theorem SetTheory.Set.mem_union (x:Object) (X Y:Set) : x (X Y) (x X x Y) := SetTheory.union_pair_axiom X Y xinstance SetTheory.Set.instInsert : Insert Object Set where insert x X := {x} X

Axiom 3.3(b) (pair). Note that one often has to cast {a,b} to Set

theorem SetTheory.Set.pair_eq (a b:Object) : ({a,b}:Set) = {a} {b} := inst✝:SetTheorya:Objectb:Object{a, b} = {a}{b} All goals completed! 🐙

Axiom 3.3(b) (pair). Note that one often has to cast {a,b} to Set

theorem SetTheory.Set.mem_pair (x a b:Object) : x ({a,b}:Set) (x = a x = b) := inst✝:SetTheoryx:Objecta:Objectb:Objectx{a, b}x = ax = b All goals completed! 🐙

Remark 3.1.8

theorem declaration uses 'sorry'SetTheory.Set.singleton_uniq (a:Object) : ∃! (X:Set), x, x X x = a := inst✝:SetTheorya:Object∃! X, ∀ (x : Object), xXx = a All goals completed! 🐙

Remark 3.1.8

theorem declaration uses 'sorry'SetTheory.Set.pair_uniq (a b:Object) : ∃! (X:Set), x, x X x = a x = b := inst✝:SetTheorya:Objectb:Object∃! X, ∀ (x : Object), xXx = ax = b All goals completed! 🐙

Remark 3.1.8

theorem declaration uses 'sorry'SetTheory.Set.pair_comm (a b:Object) : ({a,b}:Set) = {b,a} := inst✝:SetTheorya:Objectb:Object{a, b} = {b, a} All goals completed! 🐙

Remark 3.1.8

theorem declaration uses 'sorry'SetTheory.Set.pair_self (a:Object) : ({a,a}:Set) = {a} := inst✝:SetTheorya:Object{a, a} = {a} All goals completed! 🐙

Exercise 3.1.1

theorem declaration uses 'sorry'SetTheory.Set.pair_eq_pair {a b c d:Object} (h: ({a,b}:Set) = {c,d}) : a = c b = d a = d b = c := inst✝:SetTheorya:Objectb:Objectc:Objectd:Objecth:{a, b} = {c, d}a = cb = da = db = c All goals completed! 🐙abbrev SetTheory.Set.empty : Set := abbrev SetTheory.Set.singleton_empty : Set := {empty.toObject}abbrev SetTheory.Set.pair_empty : Set := {empty.toObject, singleton_empty.toObject}

Exercise 3.1.2

theorem declaration uses 'sorry'SetTheory.Set.emptyset_neq_singleton : empty singleton_empty := inst✝:SetTheoryemptysingleton_empty All goals completed! 🐙

Exercise 3.1.2

theorem declaration uses 'sorry'SetTheory.Set.emptyset_neq_pair : empty pair_empty := inst✝:SetTheoryemptypair_empty All goals completed! 🐙

Exercise 3.1.2

theorem declaration uses 'sorry'SetTheory.Set.singleton_empty_neq_pair : singleton_empty pair_empty := inst✝:SetTheorysingleton_emptypair_empty All goals completed! 🐙

Remark 3.1.11. (These results can be proven either by a direct rewrite, or by using extensionality.)

theorem declaration uses 'sorry'SetTheory.Set.union_congr_left (A A' B:Set) (h: A = A') : A B = A' B := inst✝:SetTheoryA:SetA':SetB:Seth:A = A'AB = A'B All goals completed! 🐙

Remark 3.1.11. (These results can be proven either by a direct rewrite, or by using extensionality.)

theorem declaration uses 'sorry'SetTheory.Set.union_congr_right (A B B':Set) (h: B = B') : A B = A B' := inst✝:SetTheoryA:SetB:SetB':Seth:B = B'AB = AB' All goals completed! 🐙

Lemma 3.1.12 (Basic properties of unions) / Exercise 3.1.3

theorem declaration uses 'sorry'SetTheory.Set.singleton_union_singleton (a b:Object) : ({a}:Set) ({b}:Set) = {a,b} := inst✝:SetTheorya:Objectb:Object{a}{b} = {a, b} All goals completed! 🐙

Lemma 3.1.12 (Basic properties of unions) / Exercise 3.1.3

theorem declaration uses 'sorry'SetTheory.Set.union_comm (A B:Set) : A B = B A := inst✝:SetTheoryA:SetB:SetAB = BA All goals completed! 🐙

Lemma 3.1.12 (Basic properties of unions) / Exercise 3.1.3

theorem declaration uses 'sorry'SetTheory.Set.union_assoc (A B C:Set) : (A B) C = A (B C) := inst✝:SetTheoryA:SetB:SetC:SetABC = A(BC) -- this proof is written to follow the structure of the original text. inst✝:SetTheoryA:SetB:SetC:Set∀ (x : Object), xABCxA(BC) inst✝:SetTheoryA:SetB:SetC:Setx:ObjectxABCxA(BC) inst✝:SetTheoryA:SetB:SetC:Setx:ObjectxABCxA(BC)inst✝:SetTheoryA:SetB:SetC:Setx:ObjectxA(BC)xABC inst✝:SetTheoryA:SetB:SetC:Setx:ObjectxABCxA(BC) inst✝:SetTheoryA:SetB:SetC:Setx:Objecthx:xABCxA(BC) inst✝:SetTheoryA:SetB:SetC:Setx:Objecthx:xABxCxA(BC) inst✝:SetTheoryA:SetB:SetC:Setx:Objectcase1:xABxA(BC)inst✝:SetTheoryA:SetB:SetC:Setx:Objectcase2:xCxA(BC) inst✝:SetTheoryA:SetB:SetC:Setx:Objectcase1:xABxA(BC) inst✝:SetTheoryA:SetB:SetC:Setx:Objectcase1:xAxBxA(BC) inst✝:SetTheoryA:SetB:SetC:Setx:Objectcase1a:xAxA(BC)inst✝:SetTheoryA:SetB:SetC:Setx:Objectcase1b:xBxA(BC) inst✝:SetTheoryA:SetB:SetC:Setx:Objectcase1a:xAxA(BC) inst✝:SetTheoryA:SetB:SetC:Setx:Objectcase1a:xAxAxBC; All goals completed! 🐙 have : x B C := inst✝:SetTheoryA:SetB:SetC:SetABC = A(BC) inst✝:SetTheoryA:SetB:SetC:Setx:Objectcase1b:xBxBxC; All goals completed! 🐙 inst✝:SetTheoryA:SetB:SetC:Setx:Objectcase1b:xBthis:xBCxAxBC; All goals completed! 🐙 have : x B C := inst✝:SetTheoryA:SetB:SetC:SetABC = A(BC) inst✝:SetTheoryA:SetB:SetC:Setx:Objectcase2:xCxBxC; All goals completed! 🐙 inst✝:SetTheoryA:SetB:SetC:Setx:Objectcase2:xCthis:xBCxAxBC; All goals completed! 🐙 All goals completed! 🐙

Proposition 3.1.27(c)

theorem declaration uses 'sorry'SetTheory.Set.union_self (A:Set) : A A = A := inst✝:SetTheoryA:SetAA = A All goals completed! 🐙

Proposition 3.1.27(a)

theorem declaration uses 'sorry'SetTheory.Set.union_empty (A:Set) : A = A := inst✝:SetTheoryA:SetA = A All goals completed! 🐙

Proposition 3.1.27(a)

theorem declaration uses 'sorry'SetTheory.Set.empty_union (A:Set) : A = A := inst✝:SetTheoryA:SetA = A All goals completed! 🐙theorem SetTheory.Set.triple_eq (a b c:Object) : {a,b,c} = ({a}:Set) {b,c} := inst✝:SetTheorya:Objectb:Objectc:Object{a, b, c} = {a}{b, c} All goals completed! 🐙

Example 3.1.10

theorem declaration uses 'sorry'SetTheory.Set.pair_union_pair (a b c:Object) : ({a,b}:Set) {b,c} = {a,b,c} := sorry

Definition 3.1.14.

instance SetTheory.Set.uinstSubset : HasSubset Set where Subset X Y := x, x X x Y

Definition 3.1.14. Note that the strict subset operation in Mathlib is denoted rather than .

instance SetTheory.Set.instSSubset : HasSSubset Set where SSubset X Y := X Y X Y

Definition 3.1.14.

theorem SetTheory.Set.subset_def (X Y:Set) : X Y x, x X x Y := inst✝:SetTheoryX:SetY:SetXYxX, xY All goals completed! 🐙

Definition 3.1.14. Note that the strict subset operation in Mathlib is denoted rather than .

theorem SetTheory.Set.ssubset_def (X Y:Set) : X Y (X Y X Y) := inst✝:SetTheoryX:SetY:SetXYXYXY All goals completed! 🐙

Remark 3.1.15

theorem declaration uses 'sorry'SetTheory.Set.subset_congr_left {A A' B:Set} (hAA':A = A') (hAB: A B) : A' B := inst✝:SetTheoryA:SetA':SetB:SethAA':A = A'hAB:ABA'B All goals completed! 🐙

Examples 3.1.16

theorem declaration uses 'sorry'SetTheory.Set.subset_self (A:Set) : A A := inst✝:SetTheoryA:SetAA All goals completed! 🐙

Examples 3.1.16

theorem declaration uses 'sorry'SetTheory.Set.empty_subset (A:Set) : A := inst✝:SetTheoryA:SetA All goals completed! 🐙

Proposition 3.1.17 (Partial ordering by set inclusion)

theorem SetTheory.Set.subset_trans (A B C:Set) (hAB:A B) (hBC:B C) : A C := inst✝:SetTheoryA:SetB:SetC:SethAB:ABhBC:BCAC -- this proof is written to follow the structure of the original text. inst✝:SetTheoryA:SetB:SetC:SethAB:ABhBC:BCxA, xC inst✝:SetTheoryA:SetB:SetC:SethAB:ABhBC:BCx:Objecthx:xAxC inst✝:SetTheoryA:SetB:SetC:SethAB:xA, xBhBC:BCx:Objecthx:xAxC inst✝:SetTheoryA:SetB:SetC:SethAB:xA, xBhBC:BCx:Objecthx:xBxC inst✝:SetTheoryA:SetB:SetC:SethAB:xA, xBhBC:BCx:Objecthx:xCxC All goals completed! 🐙

Proposition 3.1.17 (Partial ordering by set inclusion)

theorem declaration uses 'sorry'SetTheory.Set.subset_antisymm (A B:Set) (hAB:A B) (hBA:B A) : A = B := inst✝:SetTheoryA:SetB:SethAB:ABhBA:BAA = B All goals completed! 🐙

Proposition 3.1.17 (Partial ordering by set inclusion)

theorem declaration uses 'sorry'SetTheory.Set.ssubset_trans (A B C:Set) (hAB:A B) (hBC:B C) : A C := inst✝:SetTheoryA:SetB:SetC:SethAB:ABhBC:BCAC All goals completed! 🐙

This defines the subtype A.toSubtype for any A:Set. 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

abbrev SetTheory.Set.toSubtype (A:Set) := Subtype (fun x x A)instance : CoeSort (Set) (Type) where coe A := A.toSubtype/-- Elements of a set (implicitly coerced to a subtype) are also elements of the set (with respect to the membership operation of the set theory). -/ lemma SetTheory.Set.subtype_property (A:Set) (x:A) : x.val A := x.propertylemma SetTheory.Set.subtype_coe (A:Set) (x:A) : x.val = x := rfllemma SetTheory.Set.coe_inj (A:Set) (x y:A) : x.val = y.val x = y := Subtype.coe_inj

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.

def SetTheory.Set.subtype_mk (A:Set) {x:Object} (hx:x A) : A := x, hx lemma SetTheory.Set.subtype_mk_coe {A:Set} {x:Object} (hx:x A) : A.subtype_mk hx = x := inst✝:SetTheoryA:Setx:Objecthx:xA↑(A.subtype_mk hx) = x All goals completed! 🐙abbrev SetTheory.Set.specify (A:Set) (P: A Prop) : Set := SetTheory.specify A P

Axiom 3.6 (axiom of specification)

theorem SetTheory.Set.specification_axiom {A:Set} {P: A Prop} {x:Object} (h: x A.specify P) : x A := (SetTheory.specification_axiom A P).1 x h

Axiom 3.6 (axiom of specification)

theorem SetTheory.Set.specification_axiom' {A:Set} (P: A Prop) (x:A.toSubtype) : x.val A.specify P P x := (SetTheory.specification_axiom A P).2 xtheorem declaration uses 'sorry'SetTheory.Set.specify_subset {A:Set} (P: A Prop) : A.specify P A := inst✝:SetTheoryA:SetP:A.toSubtypePropA.specify PA All goals completed! 🐙

This exercise may require some understanding of how subtypes are implemented in Lean.

theorem declaration uses 'sorry'SetTheory.Set.specify_congr {A A':Set} (hAA':A = A') {P: A Prop} {P': A' Prop} (hPP': (x:Object) (h:x A) (h':x A') P x, h P' x, h' ) : A.specify P = A'.specify P' := inst✝:SetTheoryA:SetA':SethAA':A = A'P:A.toSubtypePropP':A'.toSubtypeProphPP':∀ (x : Object) (h : xA) (h' : xA'), Px, hP'x, h'A.specify P = A'.specify P' All goals completed! 🐙instance SetTheory.Set.instIntersection : Inter Set where inter X Y := X.specify (fun x x.val Y)

Definition 3.1.22 (Intersections)

theorem SetTheory.Set.mem_inter (x:Object) (X Y:Set) : x (X Y) (x X x Y) := inst✝:SetTheoryx:ObjectX:SetY:SetxXYxXxY inst✝:SetTheoryx:ObjectX:SetY:SetxXYxXxYinst✝:SetTheoryx:ObjectX:SetY:SetxXxYxXY inst✝:SetTheoryx:ObjectX:SetY:SetxXYxXxY inst✝:SetTheoryx:ObjectX:SetY:Seth:xXYxXxY inst✝:SetTheoryx:ObjectX:SetY:Seth:xXYh':xXxXxY inst✝:SetTheoryx:ObjectX:SetY:Seth:xXYh':xXxY All goals completed! 🐙 inst✝:SetTheoryx:ObjectX:SetY:SethX:xXhY:xYxXY All goals completed! 🐙instance SetTheory.Set.instSDiff : SDiff Set where sdiff X Y := X.specify (fun x x.val Y)

Definition 3.1.26 (Difference sets)

theorem SetTheory.Set.mem_sdiff (x:Object) (X Y:Set) : x (X \ Y) (x X x Y) := inst✝:SetTheoryx:ObjectX:SetY:SetxX \ YxXxY inst✝:SetTheoryx:ObjectX:SetY:SetxX \ YxXxYinst✝:SetTheoryx:ObjectX:SetY:SetxXxYxX \ Y inst✝:SetTheoryx:ObjectX:SetY:SetxX \ YxXxY inst✝:SetTheoryx:ObjectX:SetY:Seth:xX \ YxXxY inst✝:SetTheoryx:ObjectX:SetY:Seth:xX \ Yh':xXxXxY inst✝:SetTheoryx:ObjectX:SetY:Seth:xX \ Yh':xXxY All goals completed! 🐙 inst✝:SetTheoryx:ObjectX:SetY:SethX:xXhY:xYxX \ Y All goals completed! 🐙

Proposition 3.1.27(d) / Exercise 3.1.6

theorem declaration uses 'sorry'SetTheory.Set.inter_comm (A B:Set) : A B = B A := inst✝:SetTheoryA:SetB:SetAB = BA All goals completed! 🐙

Proposition 3.1.27(b)

theorem declaration uses 'sorry'SetTheory.Set.subset_union {A X: Set} (hAX: A X) : A X = X := inst✝:SetTheoryA:SetX:SethAX:AXAX = X All goals completed! 🐙

Proposition 3.1.27(b)

theorem declaration uses 'sorry'SetTheory.Set.union_subset {A X: Set} (hAX: A X) : X A = X := inst✝:SetTheoryA:SetX:SethAX:AXXA = X All goals completed! 🐙

Proposition 3.1.27(c)

theorem declaration uses 'sorry'SetTheory.Set.inter_self (A:Set) : A A = A := inst✝:SetTheoryA:SetAA = A All goals completed! 🐙

Proposition 3.1.27(e)

theorem declaration uses 'sorry'SetTheory.Set.inter_assoc (A B C:Set) : (A B) C = A (B C) := inst✝:SetTheoryA:SetB:SetC:SetABC = A(BC) All goals completed! 🐙

Proposition 3.1.27(f)

theorem declaration uses 'sorry'SetTheory.Set.inter_union_distrib_left (A B C:Set) : A (B C) = (A B) (A C) := sorry

Proposition 3.1.27(f)

theorem declaration uses 'sorry'SetTheory.Set.union_inter_distrib_left (A B C:Set) : A (B C) = (A B) (A C) := sorry

Proposition 3.1.27(f)

theorem declaration uses 'sorry'SetTheory.Set.union_compl {A X:Set} (hAX: A X) : A (X \ A) = X := inst✝:SetTheoryA:SetX:SethAX:AXAX \ A = X All goals completed! 🐙

Proposition 3.1.27(f)

theorem declaration uses 'sorry'SetTheory.Set.inter_compl {A X:Set} (hAX: A X) : A (X \ A) = := inst✝:SetTheoryA:SetX:SethAX:AXA(X \ A) = All goals completed! 🐙

Proposition 3.1.27(g)

theorem declaration uses 'sorry'SetTheory.Set.compl_union {A B X:Set} (hAX: A X) (hBX: B X) : X \ (A B) = (X \ A) (X \ B) := inst✝:SetTheoryA:SetB:SetX:SethAX:AXhBX:BXX \ (AB) = X \ A(X \ B) All goals completed! 🐙

Proposition 3.1.27(g)

theorem declaration uses 'sorry'SetTheory.Set.compl_inter {A B X:Set} (hAX: A X) (hBX: B X) : X \ (A B) = (X \ A) (X \ B) := inst✝:SetTheoryA:SetB:SetX:SethAX:AXhBX:BXX \ (AB) = X \ AX \ B All goals completed! 🐙

Not from textbook: sets form a distributive lattice.

instance declaration uses 'sorry'declaration uses 'sorry'declaration uses 'sorry'declaration uses 'sorry'declaration uses 'sorry'declaration uses 'sorry'declaration uses 'sorry'SetTheory.Set.instDistribLattice : DistribLattice Set where le := (· ·) le_refl := subset_self le_trans := subset_trans le_antisymm := subset_antisymm inf := (· ·) sup := (· ·) le_sup_left := inst✝:SetTheory∀ (a b : Set), aab All goals completed! 🐙 le_sup_right := inst✝:SetTheory∀ (a b : Set), bab All goals completed! 🐙 sup_le := inst✝:SetTheory∀ (a b c : Set), acbcabc All goals completed! 🐙 inf_le_left := inst✝:SetTheory∀ (a b : Set), aba All goals completed! 🐙 inf_le_right := inst✝:SetTheory∀ (a b : Set), abb All goals completed! 🐙 le_inf := inst✝:SetTheory∀ (a b c : Set), abacabc All goals completed! 🐙 le_sup_inf := inst✝:SetTheory∀ (x y z : Set), (xy) ⊓ (xz)xyz inst✝:SetTheoryX:SetY:SetZ:Set(XY) ⊓ (XZ)XYZ inst✝:SetTheoryX:SetY:SetZ:Set(XY)(XZ)XYZ inst✝:SetTheoryX:SetY:SetZ:SetXYZXYZ All goals completed! 🐙

Sets have a minimal element.

instance SetTheory.Set.instOrderBot : OrderBot Set where bot := bot_le := empty_subset

Definition of disjointness (using the previous instances)

theorem SetTheory.Set.disjoint_iff (A B:Set) : Disjoint A B A B = := inst✝:SetTheoryA:SetB:SetDisjoint A BAB = All goals completed! 🐙abbrev SetTheory.Set.replace (A:Set) {P: A Object Prop} (hP : x y y', P x y P x y' y = y') : Set := SetTheory.replace A P hP

Axiom 3.7 (Axiom of replacement)

theorem SetTheory.Set.replacement_axiom {A:Set} {P: A Object Prop} (hP: x y y', P x y P x y' y = y') (y:Object) : y A.replace hP x, P x y := SetTheory.replacement_axiom A P hP yabbrev Nat := SetTheory.nat

Axiom 3.8 (Axiom of infinity)

def SetTheory.Set.nat_equiv : Nat := SetTheory.nat_equiv-- Below are some API for handling coercions. This may not be the optimal way to set things up. instance SetTheory.Set.instOfNat {n:} : OfNat Nat n where ofNat := nat_equiv ninstance SetTheory.Set.instNatCast : NatCast Nat where natCast n := nat_equiv ninstance SetTheory.Set.toNat : Coe Nat where coe n := nat_equiv.symm ninstance SetTheory.Object.instNatCast : NatCast Object where natCast n := (n:Nat).valinstance SetTheory.Object.instOfNat {n:} : OfNat Object n where ofNat := ((n:Nat):Object)@[simp] lemma SetTheory.Object.ofnat_eq {n:} : ((n:Nat):Object) = (n:Object) := rfllemma SetTheory.Object.ofnat_eq' {n:} : (ofNat(n):Object) = (n:Object) := rfllemma SetTheory.Set.nat_coe_eq {n:} : (n:Nat) = OfNat.ofNat n := rfl@[simp] lemma SetTheory.Set.nat_equiv_inj (n m:) : (n:Nat) = (m:Nat) n=m := Equiv.apply_eq_iff_eq nat_equiv@[simp] lemma SetTheory.Set.nat_equiv_symm_inj (n m:Nat) : (n:) = (m:) n = m := Equiv.apply_eq_iff_eq nat_equiv.symm@[simp] theorem SetTheory.Set.ofNat_inj (n m:) : (ofNat(n) : Nat) = (ofNat(m) : Nat) ofNat(n) = ofNat(m) := inst✝:SetTheoryn:m:OfNat.ofNat n = OfNat.ofNat mOfNat.ofNat n = OfNat.ofNat m All goals completed! 🐙@[simp] theorem SetTheory.Set.ofNat_inj' (n m:) : (ofNat(n) : Object) = (ofNat(m) : Object) ofNat(n) = ofNat(m) := inst✝:SetTheoryn:m:OfNat.ofNat n = OfNat.ofNat mOfNat.ofNat n = OfNat.ofNat m inst✝:SetTheoryn:m:n = mOfNat.ofNat n = OfNat.ofNat m All goals completed! 🐙@[simp] lemma SetTheory.Set.nat_equiv_coe_of_coe (n:) : ((n:Nat):) = n := Equiv.symm_apply_apply nat_equiv n@[simp] lemma SetTheory.Set.nat_equiv_coe_of_coe' (n:Nat) : ((n:):Nat) = n := Equiv.symm_apply_apply nat_equiv.symm nexample : (5:Nat) (3:Nat) := inst✝:SetTheory53 All goals completed! 🐙example : (5:Object) (3:Object) := inst✝:SetTheory53 All goals completed! 🐙

Example 3.1.16 (simplified).

declaration uses 'sorry'example : ({3, 5}:Set) {1, 3, 5} := inst✝:SetTheory{3, 5}{1, 3, 5} All goals completed! 🐙

Example 3.1.17 (simplified).

declaration uses 'sorry'example : ({3, 5}:Set).specify (fun x x.val 3) = {(5:Object)} := inst✝:SetTheory({3, 5}.specify fun x => ↑x3) = {5} All goals completed! 🐙

Example 3.1.24

declaration uses 'sorry'example : ({1, 2, 4}:Set) {2,3,4} = {2, 4} := inst✝:SetTheory{1, 2, 4}{2, 3, 4} = {2, 4} All goals completed! 🐙

Example 3.1.24

declaration uses 'sorry'example : ({1, 2}:Set) {3,4} = := inst✝:SetTheory{1, 2}{3, 4} = All goals completed! 🐙declaration uses 'sorry'example : ¬ Disjoint ({1, 2, 3}:Set) {2,3,4} := inst✝:SetTheory¬Disjoint {1, 2, 3} {2, 3, 4} All goals completed! 🐙declaration uses 'sorry'example : Disjoint (:Set) := inst✝:SetTheoryDisjoint All goals completed! 🐙

Definition 3.1.26 example

declaration uses 'sorry'example : ({1, 2, 3, 4}:Set) \ {2,4,6} = {1, 3} := inst✝:SetTheory{1, 2, 3, 4} \ {2, 4, 6} = {1, 3} All goals completed! 🐙

Example 3.1.30

declaration uses 'sorry'example : ({3,5,9}:Set).replace (P := fun x y (n:), x.val = n y = (n+1:)) (inst✝:SetTheory∀ (x : {3, 5, 9}.toSubtype) (y y' : Object), (fun x y => ∃ n, ↑x = ny = (n + 1)) x y(fun x y => ∃ n, ↑x = ny = (n + 1)) x y'y = y' All goals completed! 🐙) = {4,6,10} := inst✝:SetTheory{3, 5, 9}.replace = {4, 6, 10} All goals completed! 🐙

Example 3.1.31

declaration uses 'sorry'example : ({3,5,9}:Set).replace (P := fun x y y=1) (inst✝:SetTheory∀ (x : {3, 5, 9}.toSubtype) (y y' : Object), (fun x y => y = 1) x y(fun x y => y = 1) x y'y = y' All goals completed! 🐙) = {1} := inst✝:SetTheory{3, 5, 9}.replace = {1} All goals completed! 🐙

Exercise 3.1.5. One can use the tfae_have and tfae_finish tactics here.

theorem declaration uses 'sorry'SetTheory.Set.subset_tfae (A B C:Set) : [A B, A B = B, A B = A].TFAE := inst✝:SetTheoryA:SetB:SetC:Set[AB, AB = B, AB = A].TFAE All goals completed! 🐙

Exercise 3.1.7

theorem declaration uses 'sorry'SetTheory.Set.inter_subset_left (A B:Set) : A B A := inst✝:SetTheoryA:SetB:SetABA All goals completed! 🐙

Exercise 3.1.7

theorem declaration uses 'sorry'SetTheory.Set.inter_subset_right (A B:Set) : A B B := inst✝:SetTheoryA:SetB:SetABB All goals completed! 🐙

Exercise 3.1.7

theorem declaration uses 'sorry'SetTheory.Set.subset_inter_iff (A B C:Set) : C A B C A C B := inst✝:SetTheoryA:SetB:SetC:SetCABCACB All goals completed! 🐙

Exercise 3.1.7

theorem declaration uses 'sorry'SetTheory.Set.subset_union_left (A B:Set) : A A B := inst✝:SetTheoryA:SetB:SetAAB All goals completed! 🐙

Exercise 3.1.7

theorem declaration uses 'sorry'SetTheory.Set.subset_union_right (A B:Set) : B A B := inst✝:SetTheoryA:SetB:SetBAB All goals completed! 🐙

Exercise 3.1.7

theorem declaration uses 'sorry'SetTheory.Set.union_subset_iff (A B C:Set) : A B C A C B C := inst✝:SetTheoryA:SetB:SetC:SetABCACBC All goals completed! 🐙

Exercise 3.1.8

theorem declaration uses 'sorry'SetTheory.Set.inter_union_cancel (A B:Set) : A (A B) = A := inst✝:SetTheoryA:SetB:SetA(AB) = A All goals completed! 🐙

Exercise 3.1.8

theorem declaration uses 'sorry'SetTheory.Set.union_inter_cancel (A B:Set) : A (A B) = A := inst✝:SetTheoryA:SetB:SetAAB = A All goals completed! 🐙

Exercise 3.1.9

theorem declaration uses 'sorry'SetTheory.Set.partition_left {A B X:Set} (h_union: A B = X) (h_inter: A B = ) : A = X \ B := inst✝:SetTheoryA:SetB:SetX:Seth_union:AB = Xh_inter:AB = A = X \ B All goals completed! 🐙

Exercise 3.1.9

theorem declaration uses 'sorry'SetTheory.Set.partition_right {A B X:Set} (h_union: A B = X) (h_inter: A B = ) : B = X \ A := inst✝:SetTheoryA:SetB:SetX:Seth_union:AB = Xh_inter:AB = B = X \ A All goals completed! 🐙

Exercise 3.1.10

theorem declaration uses 'sorry'Set.pairwise_disjoint (A B:Set) : Pairwise (Function.onFun Disjoint ![A \ B, A B, B \ A]) := inst✝:SetTheoryA:SetB:SetPairwise (Function.onFun Disjoint ![A \ B, AB, B \ A]) All goals completed! 🐙

Exercise 3.1.10

theorem declaration uses 'sorry'Set.union_eq_partition (A B:Set) : A B = (A \ B) (A B) (B \ A) := inst✝:SetTheoryA:SetB:SetAB = A \ BABB \ A All goals completed! 🐙

Exercise 3.1.11. The challenge is to prove this without using Set.specify, Set.specification_axiom, or Set.specification_axiom'.

theorem declaration uses 'sorry'SetTheory.Set.specification_from_replacement {A:Set} {P: A Prop} : B, A B x, x.val B P x := inst✝:SetTheoryA:SetP:A.toSubtypePropB, AB∀ (x : A.toSubtype), ↑xBP x All goals completed! 🐙

Exercise 3.1.12.

theorem declaration uses 'sorry'SetTheory.Set.subset_union_subset {A B A' B':Set} (hA'A: A' A) (hB'B: B' B) : A A' A B := inst✝:SetTheoryA:SetB:SetA':SetB':SethA'A:A'AhB'B:B'BAA'AB All goals completed! 🐙

Exercise 3.1.12.

theorem declaration uses 'sorry'SetTheory.Set.subset_inter_subset {A B A' B':Set} (hA'A: A' A) (hB'B: B' B) : A A' A B := inst✝:SetTheoryA:SetB:SetA':SetB':SethA'A:A'AhB'B:B'BAA'AB All goals completed! 🐙

Exercise 3.1.12.

theorem declaration uses 'sorry'SetTheory.Set.subset_diff_subset_counter : (A B A' B':Set), (A' A) (B' B) ¬ (A \ A') (B B') := inst✝:SetTheoryA B A' B', A'AB'B¬A \ A'BB' All goals completed! 🐙/- Final part of Exercise 3.1.12: state and prove a reasonable substitute positive result for the above theorem that involves set differences . -/

Exercise 3.1.13

theorem declaration uses 'sorry'SetTheory.Set.singleton_iff (A:Set) (hA: A ) : ¬ B, B A x, A = {x} := inst✝:SetTheoryA:SethA:A¬B, BAx, A = {x} All goals completed! 🐙end Chapter3