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.

Merge pull request #268 from gaearon/coalesce-curry

Fill in some of 3.5, fix numbering

authored by

teorth and committed by
GitHub
a43e4807 58c793d4

+47 -35
+5 -1
analysis/Analysis/Section_3_1.lean
··· 203 203 instance SetTheory.Set.instInsert : Insert Object Set where 204 204 insert x X := {x} ∪ X 205 205 206 + @[simp] 207 + theorem SetTheory.Set.mem_insert (a b: Object) (X: Set) : a ∈ insert b X ↔ a = b ∨ a ∈ X := by 208 + simp [instInsert] 209 + 206 210 /-- Axiom 3.3(b) (pair). Note: in some applications one may have to cast {a,b} 207 211 to Set. -/ 208 212 theorem SetTheory.Set.pair_eq (a b:Object) : ({a,b}:Set) = {a} ∪ {b} := by rfl ··· 706 710 /-- Definition 3.1.26 example -/ 707 711 708 712 example : ({1, 2, 3, 4}:Set) \ {2,4,6} = {1, 3} := by 709 - apply ext; simp only [mem_sdiff, instInsert]; aesop 713 + apply ext; aesop 710 714 711 715 /-- Example 3.1.30 -/ 712 716 example : ({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
··· 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 ··· 85 85 use x; simp_all 86 86 rintro ⟨ x, y, rfl ⟩; use slice x Y; refine ⟨ by simp, ?_ ⟩ 87 87 rw [replacement_axiom]; use x 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 88 92 89 noncomputable abbrev SetTheory.Set.fst {X Y:Set} (z:X ×ˢ Y) : X := 93 90 ((mem_cartesian _ _ _).mp z.property).choose ··· 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 131 - 132 - theorem SetTheory.Set.uncurry_curry {X Y Z:Set} (f: X ×ˢ Y → Z) : uncurry (curry f) = f := by sorry 133 - 134 - noncomputable abbrev SetTheory.Set.prod_commutator (X Y:Set) : X ×ˢ Y ≃ Y ×ˢ X where 135 - toFun := sorry 136 - invFun := sorry 137 - left_inv := sorry 138 - right_inv := sorry 139 - 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 125 /-- 147 126 Connections with the Mathlib set product, which consists of Lean pairs like `(x, y)` 148 127 equipped with a proof that `x` is in the left set, and `y` is in the right set. ··· 151 130 noncomputable abbrev SetTheory.Set.prod_equiv_prod (X Y:Set) : 152 131 ((X ×ˢ Y):_root_.Set Object) ≃ (X:_root_.Set Object) ×ˢ (Y:_root_.Set Object) where 153 132 toFun := fun z ↦ ⟨(fst z, snd z), by simp⟩ 133 + invFun := fun z ↦ mk_cartesian ⟨z.val.1, z.prop.1⟩ ⟨z.val.2, z.prop.2⟩ 134 + left_inv := by intro; simp 135 + right_inv := by intro; simp 136 + 137 + /-- Example 3.5.5 -/ 138 + example : ({1, 2}: Set) ×ˢ ({3, 4, 5}: Set) = ({ 139 + ((mk_cartesian (1: Nat) (3: Nat)): Object), 140 + ((mk_cartesian (1: Nat) (4: Nat)): Object), 141 + ((mk_cartesian (1: Nat) (5: Nat)): Object), 142 + ((mk_cartesian (2: Nat) (3: Nat)): Object), 143 + ((mk_cartesian (2: Nat) (4: Nat)): Object), 144 + ((mk_cartesian (2: Nat) (5: Nat)): Object) 145 + }: Set) := by apply ext; aesop 146 + 147 + /-- Example 3.5.5 / Exercise 3.6.5. There is a bijection between `X ×ˢ Y` and `Y ×ˢ X`. -/ 148 + noncomputable abbrev SetTheory.Set.prod_commutator (X Y:Set) : X ×ˢ Y ≃ Y ×ˢ X where 149 + toFun := sorry 154 150 invFun := sorry 155 151 left_inv := sorry 156 152 right_inv := sorry 157 153 154 + /-- Example 3.5.5. A function of two variables can be thought of as a function of a pair. -/ 155 + noncomputable abbrev SetTheory.Set.curry_equiv {X Y Z:Set} : (X → Y → Z) ≃ (X ×ˢ Y → Z) where 156 + toFun := fun f z ↦ f (fst z) (snd z) 157 + invFun := fun f x y ↦ f ⟨ (⟨ x, y ⟩:OrderedPair), by simp ⟩ 158 + left_inv := by intro; simp 159 + right_inv := by intro; simp [←pair_eq_fst_snd] 158 160 159 - /-- Definition 3.5.7 -/ 161 + /-- Definition 3.5.6 -/ 160 162 abbrev SetTheory.Set.tuple {I:Set} {X: I → Set} (a: ∀ i, X i) : Object := 161 163 ((fun i ↦ ⟨ a i, by rw [mem_iUnion]; use i; exact (a i).property ⟩):I → iUnion I X) 162 164 163 - /-- Definition 3.5.7 -/ 165 + /-- Definition 3.5.6 -/ 164 166 abbrev SetTheory.Set.iProd {I: Set} (X: I → Set) : Set := 165 167 ((iUnion I X)^I).specify (fun t ↦ ∃ a : ∀ i, X i, t = tuple a) 166 168 167 - /-- Definition 3.5.7 -/ 169 + /-- Definition 3.5.6 -/ 168 170 theorem SetTheory.Set.mem_iProd {I: Set} {X: I → Set} (t:Object) : 169 171 t ∈ iProd X ↔ ∃ a: ∀ i, X i, t = tuple a := by 170 172 simp only [iProd, specification_axiom'']; constructor ··· 180 182 theorem SetTheory.Set.tuple_inj {I:Set} {X: I → Set} (a b: ∀ i, X i) : 181 183 tuple a = tuple b ↔ a = b := by sorry 182 184 185 + /-- Example 3.5.8. There is a bijection between `(X ×ˢ Y) ×ˢ Z` and `X ×ˢ (Y ×ˢ Z)`. -/ 186 + noncomputable abbrev SetTheory.Set.prod_associator (X Y Z:Set) : (X ×ˢ Y) ×ˢ Z ≃ X ×ˢ (Y ×ˢ Z) where 187 + toFun := fun p ↦ mk_cartesian (fst (fst p)) (mk_cartesian (snd (fst p)) (snd p)) 188 + invFun := fun p ↦ mk_cartesian (mk_cartesian (fst p) (fst (snd p))) (snd (snd p)) 189 + left_inv := by intro; simp 190 + right_inv := by intro; simp 191 + 183 192 /-- 184 - Example 3.5.11. I suspect most of the equivalences will require classical reasoning and only be 193 + Example 3.5.10. I suspect most of the equivalences will require classical reasoning and only be 185 194 defined non-computably, but would be happy to learn of counterexamples. 186 195 -/ 187 196 noncomputable abbrev SetTheory.Set.singleton_iProd_equiv (i:Object) (X:Set) : ··· 191 200 left_inv := sorry 192 201 right_inv := sorry 193 202 194 - /-- Example 3.5.11 -/ 203 + /-- Example 3.5.10 -/ 195 204 noncomputable abbrev SetTheory.Set.empty_iProd_equiv (X: (∅:Set) → Set) : iProd X ≃ Unit where 196 205 toFun := sorry 197 206 invFun := sorry 198 207 left_inv := sorry 199 208 right_inv := sorry 200 209 201 - /-- Example 3.5.11 -/ 210 + /-- Example 3.5.10 -/ 202 211 noncomputable abbrev SetTheory.Set.iProd_of_const_equiv (I:Set) (X: Set) : 203 212 iProd (fun i:I ↦ X) ≃ (I → X) where 204 213 toFun := sorry ··· 206 215 left_inv := sorry 207 216 right_inv := sorry 208 217 218 + /-- Example 3.5.10 -/ 209 219 noncomputable abbrev SetTheory.Set.iProd_equiv_prod (X: ({0,1}:Set) → Set) : 210 220 iProd X ≃ (X ⟨ 0, by simp ⟩) ×ˢ (X ⟨ 1, by simp ⟩) where 211 221 toFun := sorry ··· 213 223 left_inv := sorry 214 224 right_inv := sorry 215 225 216 - /-- Example 3.5.9 -/ 226 + /-- Example 3.5.10 -/ 217 227 noncomputable abbrev SetTheory.Set.iProd_equiv_prod_triple (X: ({0,1,2}:Set) → Set) : 218 228 iProd X ≃ (X ⟨ 0, by simp ⟩) ×ˢ (X ⟨ 1, by simp ⟩) ×ˢ (X ⟨ 2, by simp ⟩) where 219 229 toFun := sorry ··· 292 302 left_inv := sorry 293 303 right_inv := sorry 294 304 295 - /-- Lemma 3.5.12 (finite choice) -/ 305 + /-- Lemma 3.5.11 (finite choice) -/ 296 306 theorem SetTheory.Set.finite_choice {n:ℕ} {X: Fin n → Set} (h: ∀ i, X i ≠ ∅) : iProd X ≠ ∅ := by 297 307 -- This proof broadly follows the one in the text 298 308 -- (although it is more convenient to induct from 0 rather than 1) ··· 395 405 -- the first line of this construction should be `apply isTrue` or `apply isFalse`. 396 406 sorry 397 407 398 - 399 408 /- Exercise 3.5.5 -/ 400 409 def SetTheory.Set.diff_of_prod : 401 410 Decidable (∀ (A B C D:Set), (A ×ˢ B) \ (C ×ˢ D) = (A \ C) ×ˢ (B \ D)) := by 402 411 -- the first line of this construction should be `apply isTrue` or `apply isFalse`. 403 412 sorry 404 - 405 413 406 414 /-- 407 415 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