Skip to content

Fill in some of 3.5, fix numbering #268

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion analysis/Analysis/Section_3_1.lean
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@ theorem SetTheory.Set.mem_union (x:Object) (X Y:Set) : x ∈ (X ∪ Y) ↔ (x
instance SetTheory.Set.instInsert : Insert Object Set where
insert x X := {x} ∪ X

@[simp]
theorem SetTheory.Set.mem_insert (a b: Object) (X: Set) : a ∈ insert b X ↔ a = b ∨ a ∈ X := by
simp [instInsert]

/-- Axiom 3.3(b) (pair). Note: in some applications one may have to cast {a,b}
to Set. -/
theorem SetTheory.Set.pair_eq (a b:Object) : ({a,b}:Set) = {a} ∪ {b} := by rfl
Expand Down Expand Up @@ -706,7 +710,7 @@ example : Disjoint (∅:Set) ∅ := by sorry
/-- Definition 3.1.26 example -/

example : ({1, 2, 3, 4}:Set) \ {2,4,6} = {1, 3} := by
apply ext; simp only [mem_sdiff, instInsert]; aesop
apply ext; aesop

/-- Example 3.1.30 -/
example : ({3,5,9}:Set).replace (P := fun x y ↦ ∃ (n:ℕ), x.val = n ∧ y = (n+1:ℕ)) (by aesop)
Expand Down
74 changes: 41 additions & 33 deletions analysis/Analysis/Section_3_5.lean
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ abbrev SetTheory.Set.slice (x:Object) (Y:Set) : Set :=
theorem SetTheory.Set.mem_slice (x z:Object) (Y:Set) :
z ∈ (SetTheory.Set.slice x Y) ↔ ∃ y:Y, z = (⟨x, y⟩:OrderedPair) := replacement_axiom _ _

/-- Definition 3.5.2 (Cartesian product) -/
/-- Definition 3.5.4 (Cartesian product) -/
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2025-08-04 at 16 23 46

abbrev SetTheory.Set.cartesian (X Y:Set) : Set :=
union (X.replace (P := fun x z ↦ z = slice x Y) (by intros; simp_all))

Expand All @@ -86,9 +86,6 @@ theorem SetTheory.Set.mem_cartesian (z:Object) (X Y:Set) :
rintro ⟨ x, y, rfl ⟩; use slice x Y; refine ⟨ by simp, ?_ ⟩
rw [replacement_axiom]; use x

abbrev SetTheory.Set.curry {X Y Z:Set} (f: X ×ˢ Y → Z) : X → Y → Z :=
fun x y ↦ f ⟨ (⟨ x, y ⟩:OrderedPair), by simp ⟩

noncomputable abbrev SetTheory.Set.fst {X Y:Set} (z:X ×ˢ Y) : X :=
((mem_cartesian _ _ _).mp z.property).choose

Expand All @@ -102,6 +99,7 @@ theorem SetTheory.Set.pair_eq_fst_snd {X Y:Set} (z:X ×ˢ Y) :
obtain ⟨ x, hx: z.val = (⟨ x, snd z ⟩:OrderedPair)⟩ := (exists_comm.mp this).choose_spec
simp_all [EmbeddingLike.apply_eq_iff_eq]

/-- This equips an `OrderedPair` with proofs that `x ∈ X` and `y ∈ Y`. -/
def SetTheory.Set.mk_cartesian {X Y:Set} (x:X) (y:Y) : X ×ˢ Y :=
⟨(⟨ x, y ⟩:OrderedPair), by simp⟩

Expand All @@ -124,25 +122,6 @@ theorem SetTheory.Set.mk_cartesian_fst_snd_eq {X Y: Set} (z: X ×ˢ Y) :
(mk_cartesian (fst z) (snd z)) = z := by
rw [mk_cartesian, Subtype.mk.injEq, pair_eq_fst_snd]

noncomputable abbrev SetTheory.Set.uncurry {X Y Z:Set} (f: X → Y → Z) : X ×ˢ Y → Z :=
fun z ↦ f (fst z) (snd z)

theorem SetTheory.Set.curry_uncurry {X Y Z:Set} (f: X → Y → Z) : curry (uncurry f) = f := by sorry

theorem SetTheory.Set.uncurry_curry {X Y Z:Set} (f: X ×ˢ Y → Z) : uncurry (curry f) = f := by sorry

noncomputable abbrev SetTheory.Set.prod_commutator (X Y:Set) : X ×ˢ Y ≃ Y ×ˢ X where
toFun := sorry
invFun := sorry
left_inv := sorry
right_inv := sorry

noncomputable abbrev SetTheory.Set.prod_associator (X Y Z:Set) : (X ×ˢ Y) ×ˢ Z ≃ X ×ˢ (Y ×ˢ Z) where
toFun := sorry
invFun := sorry
left_inv := sorry
right_inv := sorry

/--
Connections with the Mathlib set product, which consists of Lean pairs like `(x, y)`
equipped with a proof that `x` is in the left set, and `y` is in the right set.
Expand All @@ -151,20 +130,43 @@ noncomputable abbrev SetTheory.Set.prod_associator (X Y Z:Set) : (X ×ˢ Y) ×ˢ
noncomputable abbrev SetTheory.Set.prod_equiv_prod (X Y:Set) :
((X ×ˢ Y):_root_.Set Object) ≃ (X:_root_.Set Object) ×ˢ (Y:_root_.Set Object) where
toFun := fun z ↦ ⟨(fst z, snd z), by simp⟩
invFun := fun z ↦ mk_cartesian ⟨z.val.1, z.prop.1⟩ ⟨z.val.2, z.prop.2⟩
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filled these in because it's auxiliary to the book.

left_inv := by intro; simp
right_inv := by intro; simp

/-- Example 3.5.5 -/
example : ({1, 2}: Set) ×ˢ ({3, 4, 5}: Set) = ({
((mk_cartesian (1: Nat) (3: Nat)): Object),
((mk_cartesian (1: Nat) (4: Nat)): Object),
((mk_cartesian (1: Nat) (5: Nat)): Object),
((mk_cartesian (2: Nat) (3: Nat)): Object),
((mk_cartesian (2: Nat) (4: Nat)): Object),
((mk_cartesian (2: Nat) (5: Nat)): Object)
}: Set) := by apply ext; aesop

/-- Example 3.5.5 / Exercise 3.6.5. There is a bijection between `X ×ˢ Y` and `Y ×ˢ X`. -/
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2025-08-04 at 16 25 00

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling out the future exercise explicitly so it's clear why we're not filling this in.

noncomputable abbrev SetTheory.Set.prod_commutator (X Y:Set) : X ×ˢ Y ≃ Y ×ˢ X where
toFun := sorry
invFun := sorry
left_inv := sorry
right_inv := sorry

/-- Example 3.5.5. A function of two variables can be thought of as a function of a pair. -/
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2025-08-04 at 16 24 36

noncomputable abbrev SetTheory.Set.curry_equiv {X Y Z:Set} : (X → Y → Z) ≃ (X ×ˢ Y → Z) where
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filled this in because it isn't a "why" or an exercise.

toFun := fun f z ↦ f (fst z) (snd z)
invFun := fun f x y ↦ f ⟨ (⟨ x, y ⟩:OrderedPair), by simp ⟩
left_inv := by intro; simp
right_inv := by intro; simp [←pair_eq_fst_snd]

/-- Definition 3.5.7 -/
/-- Definition 3.5.6 -/
abbrev SetTheory.Set.tuple {I:Set} {X: I → Set} (a: ∀ i, X i) : Object :=
((fun i ↦ ⟨ a i, by rw [mem_iUnion]; use i; exact (a i).property ⟩):I → iUnion I X)

/-- Definition 3.5.7 -/
/-- Definition 3.5.6 -/
abbrev SetTheory.Set.iProd {I: Set} (X: I → Set) : Set :=
((iUnion I X)^I).specify (fun t ↦ ∃ a : ∀ i, X i, t = tuple a)

/-- Definition 3.5.7 -/
/-- Definition 3.5.6 -/
theorem SetTheory.Set.mem_iProd {I: Set} {X: I → Set} (t:Object) :
t ∈ iProd X ↔ ∃ a: ∀ i, X i, t = tuple a := by
simp only [iProd, specification_axiom'']; constructor
Expand All @@ -180,8 +182,15 @@ theorem SetTheory.Set.tuple_mem_iProd {I: Set} {X: I → Set} (a: ∀ i, X i) :
theorem SetTheory.Set.tuple_inj {I:Set} {X: I → Set} (a b: ∀ i, X i) :
tuple a = tuple b ↔ a = b := by sorry

/-- Example 3.5.8. There is a bijection between `(X ×ˢ Y) ×ˢ Z` and `X ×ˢ (Y ×ˢ Z)`. -/
noncomputable abbrev SetTheory.Set.prod_associator (X Y Z:Set) : (X ×ˢ Y) ×ˢ Z ≃ X ×ˢ (Y ×ˢ Z) where
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've fully filled this in because it wasn't a "why" and it wasn't part of an exercise.

toFun := fun p ↦ mk_cartesian (fst (fst p)) (mk_cartesian (snd (fst p)) (snd p))
invFun := fun p ↦ mk_cartesian (mk_cartesian (fst p) (fst (snd p))) (snd (snd p))
left_inv := by intro; simp
right_inv := by intro; simp

/--
Example 3.5.11. I suspect most of the equivalences will require classical reasoning and only be
Example 3.5.10. I suspect most of the equivalences will require classical reasoning and only be
defined non-computably, but would be happy to learn of counterexamples.
-/
noncomputable abbrev SetTheory.Set.singleton_iProd_equiv (i:Object) (X:Set) :
Expand All @@ -191,29 +200,30 @@ noncomputable abbrev SetTheory.Set.singleton_iProd_equiv (i:Object) (X:Set) :
left_inv := sorry
right_inv := sorry

/-- Example 3.5.11 -/
/-- Example 3.5.10 -/
noncomputable abbrev SetTheory.Set.empty_iProd_equiv (X: (∅:Set) → Set) : iProd X ≃ Unit where
toFun := sorry
invFun := sorry
left_inv := sorry
right_inv := sorry

/-- Example 3.5.11 -/
/-- Example 3.5.10 -/
noncomputable abbrev SetTheory.Set.iProd_of_const_equiv (I:Set) (X: Set) :
iProd (fun i:I ↦ X) ≃ (I → X) where
toFun := sorry
invFun := sorry
left_inv := sorry
right_inv := sorry

/-- Example 3.5.10 -/
noncomputable abbrev SetTheory.Set.iProd_equiv_prod (X: ({0,1}:Set) → Set) :
iProd X ≃ (X ⟨ 0, by simp ⟩) ×ˢ (X ⟨ 1, by simp ⟩) where
toFun := sorry
invFun := sorry
left_inv := sorry
right_inv := sorry

/-- Example 3.5.9 -/
/-- Example 3.5.10 -/
noncomputable abbrev SetTheory.Set.iProd_equiv_prod_triple (X: ({0,1,2}:Set) → Set) :
iProd X ≃ (X ⟨ 0, by simp ⟩) ×ˢ (X ⟨ 1, by simp ⟩) ×ˢ (X ⟨ 2, by simp ⟩) where
toFun := sorry
Expand Down Expand Up @@ -292,7 +302,7 @@ noncomputable abbrev SetTheory.Set.Fin_equiv_Fin (n:ℕ) : Fin n ≃ _root_.Fin
left_inv := sorry
right_inv := sorry

/-- Lemma 3.5.12 (finite choice) -/
/-- Lemma 3.5.11 (finite choice) -/
theorem SetTheory.Set.finite_choice {n:ℕ} {X: Fin n → Set} (h: ∀ i, X i ≠ ∅) : iProd X ≠ ∅ := by
-- This proof broadly follows the one in the text
-- (although it is more convenient to induct from 0 rather than 1)
Expand Down Expand Up @@ -395,14 +405,12 @@ def SetTheory.Set.union_of_prod :
-- the first line of this construction should be `apply isTrue` or `apply isFalse`.
sorry


/- Exercise 3.5.5 -/
def SetTheory.Set.diff_of_prod :
Decidable (∀ (A B C D:Set), (A ×ˢ B) \ (C ×ˢ D) = (A \ C) ×ˢ (B \ D)) := by
-- the first line of this construction should be `apply isTrue` or `apply isFalse`.
sorry


/--
Exercise 3.5.6.
-/
Expand Down
2 changes: 1 addition & 1 deletion analysis/Analysis/Section_3_6.lean
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ theorem SetTheory.Set.card_pow {X Y:Set} (hX: X.finite) (hY: Y.finite) :
theorem SetTheory.Set.card_eq_zero {X:Set} (hX: X.finite) :
X.card = 0 ↔ X = ∅ := by sorry

/-- Exercise 3.6.5 -/
/-- Exercise 3.6.5. You might find `SetTheory.Set.prod_commutator` useful. -/
theorem SetTheory.Set.prod_EqualCard_prod (A B:Set) :
EqualCard (A ×ˢ B) (B ×ˢ A) := by sorry

Expand Down