-
Notifications
You must be signed in to change notification settings - Fork 232
Expand file tree
/
Copy pathSection_8_3.lean
More file actions
203 lines (180 loc) · 8.41 KB
/
Section_8_3.lean
File metadata and controls
203 lines (180 loc) · 8.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
import Mathlib.Tactic
import Analysis.Section_8_1
import Analysis.Section_8_2
/-!
# Analysis I, Section 8.3: Uncountable sets
I have attempted to make the translation as faithful a paraphrasing as possible of the original
text. When there is a choice between a more idiomatic Lean solution and a more faithful
translation, I have generally chosen the latter. In particular, there will be places where the
Lean code could be "golfed" to be more elegant and idiomatic, but I have consciously avoided
doing so.
Main constructions and results of this section:
- Uncountable sets.
Some non-trivial API is provided beyond what is given in the textbook in order connect these
notions with existing summation notions.
-/
namespace Chapter8
/-- Theorem 8.3.1 -/
theorem EqualCard.power_set_false (X:Type) : ¬ EqualCard X (Set X) := by
-- This proof is written to follow the structure of the original text.
by_contra!; choose f hf using this
set A := {x | x ∉ f x }; choose x hx using hf.2 A
by_cases h : x ∈ A <;> have h' := h
. simp [A] at h'; simp_all
rw [←hx] at h'
have : x ∈ A := by simp [A, h']
contradiction
theorem Uncountable.iff (X:Type) : Uncountable X ↔ ¬ AtMostCountable X := by
rw [AtMostCountable.iff, uncountable_iff_not_countable]
theorem Uncountable.equiv {X Y: Type} (hXY : EqualCard X Y) :
Uncountable X ↔ Uncountable Y := by
simp [Uncountable.iff, AtMostCountable.equiv hXY]
/-- Corollary 8.3.3 -/
theorem Uncountable.power_set_nat : Uncountable (Set ℕ) := by
-- This proof is written to follow the structure of the original text.
rw [Uncountable.iff]
unfold AtMostCountable
have : ¬ CountablyInfinite (Set ℕ) := by
have := EqualCard.power_set_false ℕ
contrapose! this; exact this.symm
have : ¬ Finite (Set ℕ) := by
by_contra!
have : Finite ((fun x:ℕ ↦ ({x}:Set ℕ)) '' .univ) := Finite.Set.subset (s := .univ) (by aesop)
replace : Finite ℕ := by
apply Finite.of_finite_univ
rw [←Set.finite_coe_iff]
apply Finite.Set.finite_of_finite_image (f := fun x ↦ ({x}:Set ℕ))
intro _ _ _ _ _; aesop
have hinf : ¬ Finite ℕ := by rw [not_finite_iff_infinite]; infer_instance
contradiction
tauto
open Real in
/-- Corollary 8.3.4 -/
theorem Uncountable.real : Uncountable ℝ := by
-- This proof is written to follow the structure of the original text.
set a : ℕ → ℝ := fun n ↦ (10:ℝ)^(-(n:ℝ))
set f : Set ℕ → ℝ := fun A ↦ ∑' n:A, a n
have hsummable (A: Set ℕ) : Summable (fun n:A ↦ a n) := by
apply Summable.subtype (f := a)
convert summable_geometric_of_lt_one (?_:0 ≤ (1/10:ℝ)) ?_ using 2 with n <;> try norm_num
unfold a
rw [one_div_pow, rpow_neg, one_div]; simp; norm_num
have h_decomp {A B C: Set ℕ} (hC : C = A ∪ B) (hAB: ∀ n, n ∉ A ∩ B) : ∑' n:C, a n = ∑' n:A, a n + ∑' n:B, a n := by
convert Summable.tsum_union_disjoint ?_ ?_ ?_ <;> first | infer_instance | try apply hsummable
. rw [hC]
rw [Set.disjoint_iff_inter_eq_empty]; grind
have h_nonneg (A:Set ℕ) : ∑' n:A, a n ≥ 0 := by simp [a]; positivity
have h_congr {A B: Set ℕ} (hAB: A = B) : ∑' n:A, a n = ∑' n:B, a n := by rw [hAB]
have : Function.Injective f := by
intro A B hAB; by_contra!
rw [←Set.symmDiff_nonempty] at this
apply Nat.min_spec at this
set n₀ := Nat.min (symmDiff A B)
simp [symmDiff] at this; choose h1 h2 using this
wlog h : n₀ ∈ A ∧ n₀ ∉ B generalizing A B
. simp [h] at h1
apply this hAB.symm <;> simp [symmDiff_comm] <;> grind
replace h2 {n:ℕ} (hn: n < n₀) : n ∈ A ↔ n ∈ B := by grind
have : (0:ℝ) > 0 := calc
_ = f A - f B := by linarith
_ = ∑' n:A, a n - ∑' n:B, a n := rfl
_ = (∑' n:{n ∈ A|n ≤ n₀}, a n + ∑' n:{n ∈ A|n > n₀}, a n) -
(∑' n:{n ∈ B|n ≤ n₀}, a n + ∑' n:{n ∈ B|n > n₀}, a n) := by
congr; all_goals {
apply h_decomp
. ext n; simp; grind
intro n hn; simp at hn; linarith
}
_ = ((∑' n:{n ∈ A|n < n₀}, a n + ∑' n:{n ∈ A|n = n₀}, a n) + ∑' n:{n ∈ A|n > n₀}, a n) -
((∑' n:{n ∈ B|n < n₀}, a n + ∑' n:{n ∈ B|n = n₀}, a n) + ∑' n:{n ∈ B|n > n₀}, a n) := by
congr; all_goals {
apply h_decomp
. ext n; simp [le_iff_lt_or_eq]
intro n hn; simp at hn; linarith
}
_ = ((∑' n:{n ∈ A|n < n₀}, a n + a n₀) + ∑' n:{n ∈ A|n > n₀}, a n) -
((∑' n:{n ∈ B|n < n₀}, a n + 0) + ∑' n:{n ∈ B|n > n₀}, a n) := by
congr 3
. calc
_ = ∑' n:({n₀}:Set ℕ), a n := by apply h_congr; ext n; simp; grind
_ = _ := by simp
. calc
_ = ∑' n:(∅:Set ℕ), a n := by apply h_congr; ext n; simp; grind
_ = _ := by simp
_ = (∑' n:{n ∈ A|n < n₀}, a n - ∑' n:{n ∈ B|n < n₀}, a n) + a n₀ +
∑' n:{n ∈ A|n > n₀}, a n - ∑' n:{n ∈ B|n > n₀}, a n := by abel
_ = 0 + a n₀ + ∑' n:{n ∈ A|n > n₀}, a n - ∑' n:{n ∈ B|n > n₀}, a n := by
congr; rw [sub_eq_zero]; apply tsum_congr_set_coe; grind
_ ≥ 0 + a n₀ + 0 - ∑' n:{n|n > n₀}, a n := by
gcongr; positivity
calc
_ = ∑' (n : {n ∈ B|n > n₀}), a n + ∑' (n : {n ∉ B|n > n₀}), a n := by
apply h_decomp
. ext n; simp; tauto
intro n hn; simp at hn; tauto
_ ≥ ∑' (n : {n ∈ B|n > n₀}), a n + 0 := by gcongr; solve_by_elim
_ = _ := by simp
_ = 0 + (10:ℝ)^(-(n₀:ℝ)) + 0 - (1 / (9:ℝ)) * (10:ℝ)^(-(n₀:ℝ)) := by
congr
set ι : ℕ → {n | n > n₀} := fun j ↦ ⟨ j+(n₀+1), by simp; linarith ⟩
have hι : Function.Bijective ι := by
split_ands
. intro j k hjk; simpa [ι] using hjk
intro ⟨ n, hn ⟩; simp [ι] at hn ⊢; use n - n₀ - 1; omega
rw [←(Equiv.ofBijective ι hι).tsum_eq]
simp [ι, a]
calc
_ = ∑' j:ℕ, (10:ℝ)^(-1-n₀:ℝ) * (1/(10:ℝ))^j := by
apply tsum_congr; intro j
simp only [Equiv.ofBijective, DFunLike.coe, EquivLike.coe]
rw [pow_add, pow_add, rpow_sub, rpow_neg, rpow_one, rpow_natCast] <;> try positivity
simp; congr
_ = (10:ℝ)^(-1-n₀:ℝ) * ∑' j:ℕ, (1/(10:ℝ))^j := tsum_mul_left
_ = _ := by
rw [tsum_geometric_of_lt_one, (?_:-1 - (n₀:ℝ) = (-n₀:ℝ) + (-1:ℝ)),
rpow_add, rpow_neg, rpow_natCast] <;> try positivity
ring; abel; norm_num
_ = (8 / (9:ℝ)) * (10:ℝ)^(-(n₀:ℝ)) := by ring
_ > 0 := by positivity
simp at this
replace : EqualCard (Set ℕ) (Set.range f) := ⟨(Equiv.ofInjective _ this).toFun, (Equiv.ofInjective _ this).bijective⟩
replace := (equiv this).mp power_set_nat
contrapose this
rw [not_uncountable_iff] at this ⊢
apply SetCoe.countable
/-- Exercise 8.3.1 -/
example {X:Type} [Finite X] : Nat.card (Set X) = 2 ^ Nat.card X := by
sorry
open Classical in
/-- Exercise 8.3.2. Some subtle type changes due to how sets are implemented in Mathlib. Also we shift the sequence {lit}`D` by one so that we can work in {lean}`Set A` rather than {lean}`Set B`. -/
theorem Schroder_Bernstein_lemma {X: Type} {A B C: Set X} (hAB: A ⊆ B) (hBC: B ⊆ C) (f: C ↪ A) :
let D : ℕ → Set A := Nat.rec ((f.image ∘ ((B.embeddingOfSubset _ hBC).image)) {x:B | ↑x ∉ A}) (fun _ ↦ (f.image ∘ ((B.embeddingOfSubset _ hBC).image) ∘ (A.embeddingOfSubset _ hAB).image))
Set.univ.PairwiseDisjoint D ∧
let g : A → B := fun x ↦ if h: x ∈ ⋃ n, D n ∧ ∃ y:B, f ⟨↑y, hBC y.property⟩ = x then h.2.choose else ⟨ ↑x, hAB x.property ⟩
Function.Bijective g
:= by
sorry
abbrev LeCard (X Y: Type) : Prop := ∃ f: X → Y, Function.Injective f
/-- Exercise 8.3.3 -/
theorem Schroder_Bernstein {X Y:Type} (hXY : LeCard X Y) (hYX : LeCard Y X) : EqualCard X Y := by
sorry
abbrev LtCard (X Y: Type) : Prop := LeCard X Y ∧ ¬ EqualCard X Y
/-- Exercise 8.3.4 -/
example {X:Type} : LtCard X (Set X) := by sorry
example {A B C: Type} (hAB: LtCard A B) (hBC: LtCard B C) :
LtCard A C := by
sorry
abbrev CardOrder : Preorder Type := {
le := LeCard
lt := LtCard
le_refl := by
sorry
le_trans := by
sorry
lt_iff_le_not_ge := by
sorry
}
/-- Exercise 8.3.5 -/
example (X:Type) : ¬ CountablyInfinite (Set X) := by
sorry
end Chapter8