My solutions to Tao's Analysis I, formalized in Lean
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fill in some of 3.5, fix numbering

+49 -39
+48 -38
analysis/Analysis/Section_3_5.lean
··· 67 67 theorem SetTheory.Set.mem_slice (x z:Object) (Y:Set) : 68 68 z ∈ (SetTheory.Set.slice x Y) ↔ ∃ y:Y, z = (⟨x, y⟩:OrderedPair) := replacement_axiom _ _ 69 69 70 - /-- Definition 3.5.2 (Cartesian product) -/ 70 + /-- Definition 3.5.4 (Cartesian product) -/ 71 71 abbrev SetTheory.Set.cartesian (X Y:Set) : Set := 72 72 union (X.replace (P := fun x z ↦ z = slice x Y) (by intros; simp_all)) 73 73 ··· 86 86 rintro ⟨ x, y, rfl ⟩; use slice x Y; refine ⟨ by simp, ?_ ⟩ 87 87 rw [replacement_axiom]; use x 88 88 89 - abbrev SetTheory.Set.curry {X Y Z:Set} (f: X ×ˢ Y → Z) : X → Y → Z := 90 - fun x y ↦ f ⟨ (⟨ x, y ⟩:OrderedPair), by simp ⟩ 91 - 92 89 noncomputable abbrev SetTheory.Set.fst {X Y:Set} (z:X ×ˢ Y) : X := 93 90 ((mem_cartesian _ _ _).mp z.property).choose 94 91 ··· 102 99 obtain ⟨ x, hx: z.val = (⟨ x, snd z ⟩:OrderedPair)⟩ := (exists_comm.mp this).choose_spec 103 100 simp_all [EmbeddingLike.apply_eq_iff_eq] 104 101 102 + /-- This equips an `OrderedPair` with proofs that `x ∈ X` and `y ∈ Y`. -/ 105 103 def SetTheory.Set.mk_cartesian {X Y:Set} (x:X) (y:Y) : X ×ˢ Y := 106 104 ⟨(⟨ x, y ⟩:OrderedPair), by simp⟩ 107 105 ··· 124 122 (mk_cartesian (fst z) (snd z)) = z := by 125 123 rw [mk_cartesian, Subtype.mk.injEq, pair_eq_fst_snd] 126 124 127 - noncomputable abbrev SetTheory.Set.uncurry {X Y Z:Set} (f: X → Y → Z) : X ×ˢ Y → Z := 128 - fun z ↦ f (fst z) (snd z) 129 - 130 - theorem SetTheory.Set.curry_uncurry {X Y Z:Set} (f: X → Y → Z) : curry (uncurry f) = f := by sorry 125 + /-- Example 3.5.5 -/ 126 + example : ({1, 2}: Set) ×ˢ ({3, 4, 5}: Set) = ({ 127 + ((mk_cartesian (1: Nat) (3: Nat)): Object), 128 + ((mk_cartesian (1: Nat) (4: Nat)): Object), 129 + ((mk_cartesian (1: Nat) (5: Nat)): Object), 130 + ((mk_cartesian (2: Nat) (3: Nat)): Object), 131 + ((mk_cartesian (2: Nat) (4: Nat)): Object), 132 + ((mk_cartesian (2: Nat) (5: Nat)): Object) 133 + }: Set) := by 134 + apply ext; 135 + aesop 131 136 132 - theorem SetTheory.Set.uncurry_curry {X Y Z:Set} (f: X ×ˢ Y → Z) : uncurry (curry f) = f := by sorry 133 - 137 + /-- Example 3.5.5 / Exercise 3.6.5. There is a bijection between `X ×ˢ Y` and `Y ×ˢ X`. -/ 134 138 noncomputable abbrev SetTheory.Set.prod_commutator (X Y:Set) : X ×ˢ Y ≃ Y ×ˢ X where 135 139 toFun := sorry 136 140 invFun := sorry 137 141 left_inv := sorry 138 142 right_inv := sorry 139 143 140 - noncomputable abbrev SetTheory.Set.prod_associator (X Y Z:Set) : (X ×ˢ Y) ×ˢ Z ≃ X ×ˢ (Y ×ˢ Z) where 141 - toFun := sorry 142 - invFun := sorry 143 - left_inv := sorry 144 - right_inv := sorry 145 - 146 - /-- 147 - Connections with the Mathlib set product, which consists of Lean pairs like `(x, y)` 148 - equipped with a proof that `x` is in the left set, and `y` is in the right set. 149 - Lean pairs like `(x, y)` are similar to our `OrderedPair`, but more general. 150 - -/ 151 - noncomputable abbrev SetTheory.Set.prod_equiv_prod (X Y:Set) : 152 - ((X ×ˢ Y):_root_.Set Object) ≃ (X:_root_.Set Object) ×ˢ (Y:_root_.Set Object) where 153 - toFun := fun z ↦ ⟨(fst z, snd z), by simp⟩ 154 - invFun := sorry 155 - left_inv := sorry 156 - right_inv := sorry 157 - 144 + /-- Example 3.5.5. A function of two variables can be thought of as a function of a pair. -/ 145 + noncomputable abbrev SetTheory.Set.curry_equiv {X Y Z:Set} : (X → Y → Z) ≃ (X ×ˢ Y → Z) where 146 + toFun := fun f z ↦ f (fst z) (snd z) 147 + invFun := fun f x y ↦ f ⟨ (⟨ x, y ⟩:OrderedPair), by simp ⟩ 148 + left_inv := by intro; simp 149 + right_inv := by intro; simp [←pair_eq_fst_snd] 158 150 159 - /-- Definition 3.5.7 -/ 151 + /-- Definition 3.5.6 -/ 160 152 abbrev SetTheory.Set.tuple {I:Set} {X: I → Set} (a: ∀ i, X i) : Object := 161 153 ((fun i ↦ ⟨ a i, by rw [mem_iUnion]; use i; exact (a i).property ⟩):I → iUnion I X) 162 154 163 - /-- Definition 3.5.7 -/ 155 + /-- Definition 3.5.6 -/ 164 156 abbrev SetTheory.Set.iProd {I: Set} (X: I → Set) : Set := 165 157 ((iUnion I X)^I).specify (fun t ↦ ∃ a : ∀ i, X i, t = tuple a) 166 158 167 - /-- Definition 3.5.7 -/ 159 + /-- Definition 3.5.6 -/ 168 160 theorem SetTheory.Set.mem_iProd {I: Set} {X: I → Set} (t:Object) : 169 161 t ∈ iProd X ↔ ∃ a: ∀ i, X i, t = tuple a := by 170 162 simp only [iProd, specification_axiom'']; constructor ··· 180 172 theorem SetTheory.Set.tuple_inj {I:Set} {X: I → Set} (a b: ∀ i, X i) : 181 173 tuple a = tuple b ↔ a = b := by sorry 182 174 175 + /-- Example 3.5.8. There is a bijection between `(X ×ˢ Y) ×ˢ Z` and `X ×ˢ (Y ×ˢ Z)`. -/ 176 + noncomputable abbrev SetTheory.Set.prod_associator (X Y Z:Set) : (X ×ˢ Y) ×ˢ Z ≃ X ×ˢ (Y ×ˢ Z) where 177 + toFun := fun p ↦ mk_cartesian (fst (fst p)) (mk_cartesian (snd (fst p)) (snd p)) 178 + invFun := fun p ↦ mk_cartesian (mk_cartesian (fst p) (fst (snd p))) (snd (snd p)) 179 + left_inv := by intro; simp 180 + right_inv := by intro; simp 181 + 183 182 /-- 184 - Example 3.5.11. I suspect most of the equivalences will require classical reasoning and only be 183 + Connections with the Mathlib set product, which consists of Lean pairs like `(x, y)` 184 + equipped with a proof that `x` is in the left set, and `y` is in the right set. 185 + Lean pairs like `(x, y)` are similar to our `OrderedPair`, but more general. 186 + -/ 187 + noncomputable abbrev SetTheory.Set.prod_equiv_prod (X Y:Set) : 188 + ((X ×ˢ Y):_root_.Set Object) ≃ (X:_root_.Set Object) ×ˢ (Y:_root_.Set Object) where 189 + toFun := fun z ↦ ⟨(fst z, snd z), by simp⟩ 190 + invFun := fun z ↦ mk_cartesian ⟨z.val.1, z.prop.1⟩ ⟨z.val.2, z.prop.2⟩ 191 + left_inv := by intro; simp 192 + right_inv := by intro; simp 193 + 194 + /-- 195 + Example 3.5.10. I suspect most of the equivalences will require classical reasoning and only be 185 196 defined non-computably, but would be happy to learn of counterexamples. 186 197 -/ 187 198 noncomputable abbrev SetTheory.Set.singleton_iProd_equiv (i:Object) (X:Set) : ··· 191 202 left_inv := sorry 192 203 right_inv := sorry 193 204 194 - /-- Example 3.5.11 -/ 205 + /-- Example 3.5.10 -/ 195 206 noncomputable abbrev SetTheory.Set.empty_iProd_equiv (X: (∅:Set) → Set) : iProd X ≃ Unit where 196 207 toFun := sorry 197 208 invFun := sorry 198 209 left_inv := sorry 199 210 right_inv := sorry 200 211 201 - /-- Example 3.5.11 -/ 212 + /-- Example 3.5.10 -/ 202 213 noncomputable abbrev SetTheory.Set.iProd_of_const_equiv (I:Set) (X: Set) : 203 214 iProd (fun i:I ↦ X) ≃ (I → X) where 204 215 toFun := sorry ··· 206 217 left_inv := sorry 207 218 right_inv := sorry 208 219 220 + /-- Example 3.5.10 -/ 209 221 noncomputable abbrev SetTheory.Set.iProd_equiv_prod (X: ({0,1}:Set) → Set) : 210 222 iProd X ≃ (X ⟨ 0, by simp ⟩) ×ˢ (X ⟨ 1, by simp ⟩) where 211 223 toFun := sorry ··· 213 225 left_inv := sorry 214 226 right_inv := sorry 215 227 216 - /-- Example 3.5.9 -/ 228 + /-- Example 3.5.10 -/ 217 229 noncomputable abbrev SetTheory.Set.iProd_equiv_prod_triple (X: ({0,1,2}:Set) → Set) : 218 230 iProd X ≃ (X ⟨ 0, by simp ⟩) ×ˢ (X ⟨ 1, by simp ⟩) ×ˢ (X ⟨ 2, by simp ⟩) where 219 231 toFun := sorry ··· 292 304 left_inv := sorry 293 305 right_inv := sorry 294 306 295 - /-- Lemma 3.5.12 (finite choice) -/ 307 + /-- Lemma 3.5.11 (finite choice) -/ 296 308 theorem SetTheory.Set.finite_choice {n:ℕ} {X: Fin n → Set} (h: ∀ i, X i ≠ ∅) : iProd X ≠ ∅ := by 297 309 -- This proof broadly follows the one in the text 298 310 -- (although it is more convenient to induct from 0 rather than 1) ··· 395 407 -- the first line of this construction should be `apply isTrue` or `apply isFalse`. 396 408 sorry 397 409 398 - 399 410 /- Exercise 3.5.5 -/ 400 411 def SetTheory.Set.diff_of_prod : 401 412 Decidable (∀ (A B C D:Set), (A ×ˢ B) \ (C ×ˢ D) = (A \ C) ×ˢ (B \ D)) := by 402 413 -- the first line of this construction should be `apply isTrue` or `apply isFalse`. 403 414 sorry 404 - 405 415 406 416 /-- 407 417 Exercise 3.5.6.
+1 -1
analysis/Analysis/Section_3_6.lean
··· 224 224 theorem SetTheory.Set.card_eq_zero {X:Set} (hX: X.finite) : 225 225 X.card = 0 ↔ X = ∅ := by sorry 226 226 227 - /-- Exercise 3.6.5 -/ 227 + /-- Exercise 3.6.5. You might find `SetTheory.Set.prod_commutator` useful. -/ 228 228 theorem SetTheory.Set.prod_EqualCard_prod (A B:Set) : 229 229 EqualCard (A ×ˢ B) (B ×ˢ A) := by sorry 230 230