···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···8686 rintro ⟨ x, y, rfl ⟩; use slice x Y; refine ⟨ by simp, ?_ ⟩
8787 rw [replacement_axiom]; use x
88888989-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 ⟩
9191-9289noncomputable abbrev SetTheory.Set.fst {X Y:Set} (z:X ×ˢ Y) : X :=
9390 ((mem_cartesian _ _ _).mp z.property).choose
9491···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
125125+/-- Example 3.5.5 -/
126126+example : ({1, 2}: Set) ×ˢ ({3, 4, 5}: Set) = ({
127127+ ((mk_cartesian (1: Nat) (3: Nat)): Object),
128128+ ((mk_cartesian (1: Nat) (4: Nat)): Object),
129129+ ((mk_cartesian (1: Nat) (5: Nat)): Object),
130130+ ((mk_cartesian (2: Nat) (3: Nat)): Object),
131131+ ((mk_cartesian (2: Nat) (4: Nat)): Object),
132132+ ((mk_cartesian (2: Nat) (5: Nat)): Object)
133133+}: Set) := by
134134+ apply ext;
135135+ aesop
131136132132-theorem SetTheory.Set.uncurry_curry {X Y Z:Set} (f: X ×ˢ Y → Z) : uncurry (curry f) = f := by sorry
133133-137137+/-- Example 3.5.5 / Exercise 3.6.5. There is a bijection between `X ×ˢ Y` and `Y ×ˢ X`. -/
134138noncomputable abbrev SetTheory.Set.prod_commutator (X Y:Set) : X ×ˢ Y ≃ Y ×ˢ X where
135139 toFun := sorry
136140 invFun := sorry
137141 left_inv := sorry
138142 right_inv := sorry
139143140140-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-146146-/--
147147- Connections with the Mathlib set product, which consists of Lean pairs like `(x, y)`
148148- equipped with a proof that `x` is in the left set, and `y` is in the right set.
149149- Lean pairs like `(x, y)` are similar to our `OrderedPair`, but more general.
150150--/
151151-noncomputable abbrev SetTheory.Set.prod_equiv_prod (X Y:Set) :
152152- ((X ×ˢ Y):_root_.Set Object) ≃ (X:_root_.Set Object) ×ˢ (Y:_root_.Set Object) where
153153- toFun := fun z ↦ ⟨(fst z, snd z), by simp⟩
154154- invFun := sorry
155155- left_inv := sorry
156156- right_inv := sorry
157157-144144+/-- Example 3.5.5. A function of two variables can be thought of as a function of a pair. -/
145145+noncomputable abbrev SetTheory.Set.curry_equiv {X Y Z:Set} : (X → Y → Z) ≃ (X ×ˢ Y → Z) where
146146+ toFun := fun f z ↦ f (fst z) (snd z)
147147+ invFun := fun f x y ↦ f ⟨ (⟨ x, y ⟩:OrderedPair), by simp ⟩
148148+ left_inv := by intro; simp
149149+ right_inv := by intro; simp [←pair_eq_fst_snd]
158150159159-/-- Definition 3.5.7 -/
151151+/-- Definition 3.5.6 -/
160152abbrev SetTheory.Set.tuple {I:Set} {X: I → Set} (a: ∀ i, X i) : Object :=
161153 ((fun i ↦ ⟨ a i, by rw [mem_iUnion]; use i; exact (a i).property ⟩):I → iUnion I X)
162154163163-/-- Definition 3.5.7 -/
155155+/-- Definition 3.5.6 -/
164156abbrev SetTheory.Set.iProd {I: Set} (X: I → Set) : Set :=
165157 ((iUnion I X)^I).specify (fun t ↦ ∃ a : ∀ i, X i, t = tuple a)
166158167167-/-- Definition 3.5.7 -/
159159+/-- Definition 3.5.6 -/
168160theorem SetTheory.Set.mem_iProd {I: Set} {X: I → Set} (t:Object) :
169161 t ∈ iProd X ↔ ∃ a: ∀ i, X i, t = tuple a := by
170162 simp only [iProd, specification_axiom'']; constructor
···180172theorem SetTheory.Set.tuple_inj {I:Set} {X: I → Set} (a b: ∀ i, X i) :
181173 tuple a = tuple b ↔ a = b := by sorry
182174175175+/-- Example 3.5.8. There is a bijection between `(X ×ˢ Y) ×ˢ Z` and `X ×ˢ (Y ×ˢ Z)`. -/
176176+noncomputable abbrev SetTheory.Set.prod_associator (X Y Z:Set) : (X ×ˢ Y) ×ˢ Z ≃ X ×ˢ (Y ×ˢ Z) where
177177+ toFun := fun p ↦ mk_cartesian (fst (fst p)) (mk_cartesian (snd (fst p)) (snd p))
178178+ invFun := fun p ↦ mk_cartesian (mk_cartesian (fst p) (fst (snd p))) (snd (snd p))
179179+ left_inv := by intro; simp
180180+ right_inv := by intro; simp
181181+183182/--
184184- Example 3.5.11. I suspect most of the equivalences will require classical reasoning and only be
183183+ Connections with the Mathlib set product, which consists of Lean pairs like `(x, y)`
184184+ equipped with a proof that `x` is in the left set, and `y` is in the right set.
185185+ Lean pairs like `(x, y)` are similar to our `OrderedPair`, but more general.
186186+-/
187187+noncomputable abbrev SetTheory.Set.prod_equiv_prod (X Y:Set) :
188188+ ((X ×ˢ Y):_root_.Set Object) ≃ (X:_root_.Set Object) ×ˢ (Y:_root_.Set Object) where
189189+ toFun := fun z ↦ ⟨(fst z, snd z), by simp⟩
190190+ invFun := fun z ↦ mk_cartesian ⟨z.val.1, z.prop.1⟩ ⟨z.val.2, z.prop.2⟩
191191+ left_inv := by intro; simp
192192+ right_inv := by intro; simp
193193+194194+/--
195195+ Example 3.5.10. I suspect most of the equivalences will require classical reasoning and only be
185196 defined non-computably, but would be happy to learn of counterexamples.
186197-/
187198noncomputable abbrev SetTheory.Set.singleton_iProd_equiv (i:Object) (X:Set) :
···191202 left_inv := sorry
192203 right_inv := sorry
193204194194-/-- Example 3.5.11 -/
205205+/-- Example 3.5.10 -/
195206noncomputable abbrev SetTheory.Set.empty_iProd_equiv (X: (∅:Set) → Set) : iProd X ≃ Unit where
196207 toFun := sorry
197208 invFun := sorry
198209 left_inv := sorry
199210 right_inv := sorry
200211201201-/-- Example 3.5.11 -/
212212+/-- Example 3.5.10 -/
202213noncomputable abbrev SetTheory.Set.iProd_of_const_equiv (I:Set) (X: Set) :
203214 iProd (fun i:I ↦ X) ≃ (I → X) where
204215 toFun := sorry
···206217 left_inv := sorry
207218 right_inv := sorry
208219220220+/-- Example 3.5.10 -/
209221noncomputable abbrev SetTheory.Set.iProd_equiv_prod (X: ({0,1}:Set) → Set) :
210222 iProd X ≃ (X ⟨ 0, by simp ⟩) ×ˢ (X ⟨ 1, by simp ⟩) where
211223 toFun := sorry
···213225 left_inv := sorry
214226 right_inv := sorry
215227216216-/-- Example 3.5.9 -/
228228+/-- Example 3.5.10 -/
217229noncomputable abbrev SetTheory.Set.iProd_equiv_prod_triple (X: ({0,1,2}:Set) → Set) :
218230 iProd X ≃ (X ⟨ 0, by simp ⟩) ×ˢ (X ⟨ 1, by simp ⟩) ×ˢ (X ⟨ 2, by simp ⟩) where
219231 toFun := sorry
···292304 left_inv := sorry
293305 right_inv := sorry
294306295295-/-- Lemma 3.5.12 (finite choice) -/
307307+/-- Lemma 3.5.11 (finite choice) -/
296308theorem SetTheory.Set.finite_choice {n:ℕ} {X: Fin n → Set} (h: ∀ i, X i ≠ ∅) : iProd X ≠ ∅ := by
297309 -- This proof broadly follows the one in the text
298310 -- (although it is more convenient to induct from 0 rather than 1)
···395407 -- the first line of this construction should be `apply isTrue` or `apply isFalse`.
396408 sorry
397409398398-399410/- Exercise 3.5.5 -/
400411def SetTheory.Set.diff_of_prod :
401412 Decidable (∀ (A B C D:Set), (A ×ˢ B) \ (C ×ˢ D) = (A \ C) ×ˢ (B \ D)) := by
402413 -- the first line of this construction should be `apply isTrue` or `apply isFalse`.
403414 sorry
404404-405415406416/--
407417 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