···203203instance SetTheory.Set.instInsert : Insert Object Set where
204204 insert x X := {x} ∪ X
205205206206+@[simp]
207207+theorem SetTheory.Set.mem_insert (a b: Object) (X: Set) : a ∈ insert b X ↔ a = b ∨ a ∈ X := by
208208+ simp [instInsert]
209209+206210/-- Axiom 3.3(b) (pair). Note: in some applications one may have to cast {a,b}
207211 to Set. -/
208212theorem SetTheory.Set.pair_eq (a b:Object) : ({a,b}:Set) = {a} ∪ {b} := by rfl
···706710/-- Definition 3.1.26 example -/
707711708712example : ({1, 2, 3, 4}:Set) \ {2,4,6} = {1, 3} := by
709709- apply ext; simp only [mem_sdiff, instInsert]; aesop
713713+ apply ext; aesop
710714711715/-- Example 3.1.30 -/
712716example : ({3,5,9}:Set).replace (P := fun x y ↦ ∃ (n:ℕ), x.val = n ∧ y = (n+1:ℕ)) (by aesop)
+41-33
analysis/Analysis/Section_3_5.lean
···6767theorem SetTheory.Set.mem_slice (x z:Object) (Y:Set) :
6868 z ∈ (SetTheory.Set.slice x Y) ↔ ∃ y:Y, z = (⟨x, y⟩:OrderedPair) := replacement_axiom _ _
69697070-/-- Definition 3.5.2 (Cartesian product) -/
7070+/-- Definition 3.5.4 (Cartesian product) -/
7171abbrev SetTheory.Set.cartesian (X Y:Set) : Set :=
7272 union (X.replace (P := fun x z ↦ z = slice x Y) (by intros; simp_all))
7373···8585 use x; simp_all
8686 rintro ⟨ x, y, rfl ⟩; use slice x Y; refine ⟨ by simp, ?_ ⟩
8787 rw [replacement_axiom]; use x
8888-8989-abbrev SetTheory.Set.curry {X Y Z:Set} (f: X ×ˢ Y → Z) : X → Y → Z :=
9090- fun x y ↦ f ⟨ (⟨ x, y ⟩:OrderedPair), by simp ⟩
91889289noncomputable abbrev SetTheory.Set.fst {X Y:Set} (z:X ×ˢ Y) : X :=
9390 ((mem_cartesian _ _ _).mp z.property).choose
···10299 obtain ⟨ x, hx: z.val = (⟨ x, snd z ⟩:OrderedPair)⟩ := (exists_comm.mp this).choose_spec
103100 simp_all [EmbeddingLike.apply_eq_iff_eq]
104101102102+/-- This equips an `OrderedPair` with proofs that `x ∈ X` and `y ∈ Y`. -/
105103def SetTheory.Set.mk_cartesian {X Y:Set} (x:X) (y:Y) : X ×ˢ Y :=
106104 ⟨(⟨ x, y ⟩:OrderedPair), by simp⟩
107105···124122 (mk_cartesian (fst z) (snd z)) = z := by
125123 rw [mk_cartesian, Subtype.mk.injEq, pair_eq_fst_snd]
126124127127-noncomputable abbrev SetTheory.Set.uncurry {X Y Z:Set} (f: X → Y → Z) : X ×ˢ Y → Z :=
128128- fun z ↦ f (fst z) (snd z)
129129-130130-theorem SetTheory.Set.curry_uncurry {X Y Z:Set} (f: X → Y → Z) : curry (uncurry f) = f := by sorry
131131-132132-theorem SetTheory.Set.uncurry_curry {X Y Z:Set} (f: X ×ˢ Y → Z) : uncurry (curry f) = f := by sorry
133133-134134-noncomputable abbrev SetTheory.Set.prod_commutator (X Y:Set) : X ×ˢ Y ≃ Y ×ˢ X where
135135- toFun := sorry
136136- invFun := sorry
137137- left_inv := sorry
138138- right_inv := sorry
139139-140140-noncomputable abbrev SetTheory.Set.prod_associator (X Y Z:Set) : (X ×ˢ Y) ×ˢ Z ≃ X ×ˢ (Y ×ˢ Z) where
141141- toFun := sorry
142142- invFun := sorry
143143- left_inv := sorry
144144- right_inv := sorry
145145-146125/--
147126 Connections with the Mathlib set product, which consists of Lean pairs like `(x, y)`
148127 equipped with a proof that `x` is in the left set, and `y` is in the right set.
···151130noncomputable abbrev SetTheory.Set.prod_equiv_prod (X Y:Set) :
152131 ((X ×ˢ Y):_root_.Set Object) ≃ (X:_root_.Set Object) ×ˢ (Y:_root_.Set Object) where
153132 toFun := fun z ↦ ⟨(fst z, snd z), by simp⟩
133133+ invFun := fun z ↦ mk_cartesian ⟨z.val.1, z.prop.1⟩ ⟨z.val.2, z.prop.2⟩
134134+ left_inv := by intro; simp
135135+ right_inv := by intro; simp
136136+137137+/-- Example 3.5.5 -/
138138+example : ({1, 2}: Set) ×ˢ ({3, 4, 5}: Set) = ({
139139+ ((mk_cartesian (1: Nat) (3: Nat)): Object),
140140+ ((mk_cartesian (1: Nat) (4: Nat)): Object),
141141+ ((mk_cartesian (1: Nat) (5: Nat)): Object),
142142+ ((mk_cartesian (2: Nat) (3: Nat)): Object),
143143+ ((mk_cartesian (2: Nat) (4: Nat)): Object),
144144+ ((mk_cartesian (2: Nat) (5: Nat)): Object)
145145+}: Set) := by apply ext; aesop
146146+147147+/-- Example 3.5.5 / Exercise 3.6.5. There is a bijection between `X ×ˢ Y` and `Y ×ˢ X`. -/
148148+noncomputable abbrev SetTheory.Set.prod_commutator (X Y:Set) : X ×ˢ Y ≃ Y ×ˢ X where
149149+ toFun := sorry
154150 invFun := sorry
155151 left_inv := sorry
156152 right_inv := sorry
157153154154+/-- Example 3.5.5. A function of two variables can be thought of as a function of a pair. -/
155155+noncomputable abbrev SetTheory.Set.curry_equiv {X Y Z:Set} : (X → Y → Z) ≃ (X ×ˢ Y → Z) where
156156+ toFun := fun f z ↦ f (fst z) (snd z)
157157+ invFun := fun f x y ↦ f ⟨ (⟨ x, y ⟩:OrderedPair), by simp ⟩
158158+ left_inv := by intro; simp
159159+ right_inv := by intro; simp [←pair_eq_fst_snd]
158160159159-/-- Definition 3.5.7 -/
161161+/-- Definition 3.5.6 -/
160162abbrev SetTheory.Set.tuple {I:Set} {X: I → Set} (a: ∀ i, X i) : Object :=
161163 ((fun i ↦ ⟨ a i, by rw [mem_iUnion]; use i; exact (a i).property ⟩):I → iUnion I X)
162164163163-/-- Definition 3.5.7 -/
165165+/-- Definition 3.5.6 -/
164166abbrev SetTheory.Set.iProd {I: Set} (X: I → Set) : Set :=
165167 ((iUnion I X)^I).specify (fun t ↦ ∃ a : ∀ i, X i, t = tuple a)
166168167167-/-- Definition 3.5.7 -/
169169+/-- Definition 3.5.6 -/
168170theorem SetTheory.Set.mem_iProd {I: Set} {X: I → Set} (t:Object) :
169171 t ∈ iProd X ↔ ∃ a: ∀ i, X i, t = tuple a := by
170172 simp only [iProd, specification_axiom'']; constructor
···180182theorem SetTheory.Set.tuple_inj {I:Set} {X: I → Set} (a b: ∀ i, X i) :
181183 tuple a = tuple b ↔ a = b := by sorry
182184185185+/-- Example 3.5.8. There is a bijection between `(X ×ˢ Y) ×ˢ Z` and `X ×ˢ (Y ×ˢ Z)`. -/
186186+noncomputable abbrev SetTheory.Set.prod_associator (X Y Z:Set) : (X ×ˢ Y) ×ˢ Z ≃ X ×ˢ (Y ×ˢ Z) where
187187+ toFun := fun p ↦ mk_cartesian (fst (fst p)) (mk_cartesian (snd (fst p)) (snd p))
188188+ invFun := fun p ↦ mk_cartesian (mk_cartesian (fst p) (fst (snd p))) (snd (snd p))
189189+ left_inv := by intro; simp
190190+ right_inv := by intro; simp
191191+183192/--
184184- Example 3.5.11. I suspect most of the equivalences will require classical reasoning and only be
193193+ Example 3.5.10. I suspect most of the equivalences will require classical reasoning and only be
185194 defined non-computably, but would be happy to learn of counterexamples.
186195-/
187196noncomputable abbrev SetTheory.Set.singleton_iProd_equiv (i:Object) (X:Set) :
···191200 left_inv := sorry
192201 right_inv := sorry
193202194194-/-- Example 3.5.11 -/
203203+/-- Example 3.5.10 -/
195204noncomputable abbrev SetTheory.Set.empty_iProd_equiv (X: (∅:Set) → Set) : iProd X ≃ Unit where
196205 toFun := sorry
197206 invFun := sorry
198207 left_inv := sorry
199208 right_inv := sorry
200209201201-/-- Example 3.5.11 -/
210210+/-- Example 3.5.10 -/
202211noncomputable abbrev SetTheory.Set.iProd_of_const_equiv (I:Set) (X: Set) :
203212 iProd (fun i:I ↦ X) ≃ (I → X) where
204213 toFun := sorry
···206215 left_inv := sorry
207216 right_inv := sorry
208217218218+/-- Example 3.5.10 -/
209219noncomputable abbrev SetTheory.Set.iProd_equiv_prod (X: ({0,1}:Set) → Set) :
210220 iProd X ≃ (X ⟨ 0, by simp ⟩) ×ˢ (X ⟨ 1, by simp ⟩) where
211221 toFun := sorry
···213223 left_inv := sorry
214224 right_inv := sorry
215225216216-/-- Example 3.5.9 -/
226226+/-- Example 3.5.10 -/
217227noncomputable abbrev SetTheory.Set.iProd_equiv_prod_triple (X: ({0,1,2}:Set) → Set) :
218228 iProd X ≃ (X ⟨ 0, by simp ⟩) ×ˢ (X ⟨ 1, by simp ⟩) ×ˢ (X ⟨ 2, by simp ⟩) where
219229 toFun := sorry
···292302 left_inv := sorry
293303 right_inv := sorry
294304295295-/-- Lemma 3.5.12 (finite choice) -/
305305+/-- Lemma 3.5.11 (finite choice) -/
296306theorem SetTheory.Set.finite_choice {n:ℕ} {X: Fin n → Set} (h: ∀ i, X i ≠ ∅) : iProd X ≠ ∅ := by
297307 -- This proof broadly follows the one in the text
298308 -- (although it is more convenient to induct from 0 rather than 1)
···395405 -- the first line of this construction should be `apply isTrue` or `apply isFalse`.
396406 sorry
397407398398-399408/- Exercise 3.5.5 -/
400409def SetTheory.Set.diff_of_prod :
401410 Decidable (∀ (A B C D:Set), (A ×ˢ B) \ (C ×ˢ D) = (A \ C) ×ˢ (B \ D)) := by
402411 -- the first line of this construction should be `apply isTrue` or `apply isFalse`.
403412 sorry
404404-405413406414/--
407415 Exercise 3.5.6.
+1-1
analysis/Analysis/Section_3_6.lean
···224224theorem SetTheory.Set.card_eq_zero {X:Set} (hX: X.finite) :
225225 X.card = 0 ↔ X = ∅ := by sorry
226226227227-/-- Exercise 3.6.5 -/
227227+/-- Exercise 3.6.5. You might find `SetTheory.Set.prod_commutator` useful. -/
228228theorem SetTheory.Set.prod_EqualCard_prod (A B:Set) :
229229 EqualCard (A ×ˢ B) (B ×ˢ A) := by sorry
230230