Skip to content

Commit 660caa1

Browse files
authored
Merge branch 'teorth:main' into bump-Mathlib
2 parents 75f5c75 + 28d2a79 commit 660caa1

File tree

2 files changed

+161
-2
lines changed

2 files changed

+161
-2
lines changed

Analysis/Section_5_1.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Main constructions and results of this section:
1616
namespace Chapter5
1717

1818
/-- Definition 5.1.1 (Sequence). To avoid some technicalities involving dependent types, we extend sequences by zero to the left of the starting point `n₀`. -/
19+
@[ext]
1920
structure Sequence where
2021
n₀ : ℤ
2122
seq : ℤ → ℚ

Analysis/Section_5_3.lean

Lines changed: 160 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,16 @@ Main constructions and results of this section:
1616
namespace Chapter5
1717

1818
/-- A class of Cauchy sequences that start at zero -/
19+
@[ext]
1920
class CauchySequence extends Sequence where
2021
zero : n₀ = 0
2122
cauchy : toSequence.isCauchy
2223

24+
theorem CauchySequence.ext' {a b: CauchySequence} (h: a.seq = b.seq) : a = b := by
25+
apply CauchySequence.ext
26+
. rw [a.zero, b.zero]
27+
exact h
28+
2329
/-- A sequence starting at zero that is Cauchy, can be viewed as a Cauchy sequence.-/
2430
abbrev CauchySequence.mk' {a:ℕ → ℚ} (ha: (a:Sequence).isCauchy) : CauchySequence where
2531
n₀ := 0
@@ -30,12 +36,29 @@ abbrev CauchySequence.mk' {a:ℕ → ℚ} (ha: (a:Sequence).isCauchy) : CauchySe
3036
zero := rfl
3137
cauchy := ha
3238

33-
lemma CauchySequence.coe_eq {a:ℕ → ℚ} (ha: (a:Sequence).isCauchy) : (mk' ha).toSequence = (a:Sequence) := by rfl
39+
@[simp]
40+
theorem CauchySequence.coe_eq {a:ℕ → ℚ} (ha: (a:Sequence).isCauchy) : (mk' ha).toSequence = (a:Sequence) := by rfl
3441

3542
instance CauchySequence.instCoeFun : CoeFun CauchySequence (fun _ ↦ ℕ → ℚ) where
3643
coe := fun a n ↦ a.toSequence (n:ℤ)
3744

38-
lemma CauchySequence.coe_coe {a:ℕ → ℚ} (ha: (a:Sequence).isCauchy) : mk' ha = a := by rfl
45+
@[simp]
46+
theorem CauchySequence.coe_to_sequence (a: CauchySequence) : ((a:ℕ → ℚ):Sequence) = a.toSequence := by
47+
apply Sequence.ext
48+
. rw [a.zero]
49+
ext n
50+
by_cases h:n ≥ 0
51+
all_goals simp [h]
52+
rw [a.vanish]
53+
rw [a.zero]
54+
exact lt_of_not_ge h
55+
56+
@[simp]
57+
theorem CauchySequence.coe_coe {a:ℕ → ℚ} (ha: (a:Sequence).isCauchy) : mk' ha = a := by rfl
58+
59+
/-- Proposition 5.3.3 / Exercise 5.3.1 -/
60+
theorem Sequence.equiv_trans {a b c:ℕ → ℚ} (hab: Sequence.equiv a b) (hbc: Sequence.equiv b c) :
61+
Sequence.equiv a c := by sorry
3962

4063
/-- Proposition 5.3.3 / Exercise 5.3.1 -/
4164
instance CauchySequence.instSetoid : Setoid CauchySequence where
@@ -46,6 +69,141 @@ instance CauchySequence.instSetoid : Setoid CauchySequence where
4669
trans := sorry
4770
}
4871

72+
theorem CauchySequence.equiv_iff (a b: CauchySequence) : a ≈ b ↔ Sequence.equiv a b := by rfl
73+
74+
/-- Every constant sequence is Cauchy -/
75+
theorem Sequence.isCauchy_of_const (a:ℚ) : ((fun n:ℕ ↦ a):Sequence).isCauchy := by sorry
76+
77+
instance CauchySequence.instZero : Zero CauchySequence where
78+
zero := CauchySequence.mk' (a := fun _: ℕ ↦ 0) (Sequence.isCauchy_of_const (0:ℚ))
79+
80+
abbrev Real := Quotient CauchySequence.instSetoid
81+
82+
open Classical in
83+
/-- It is convenient in Lean to assign the "dummy" value of 0 to `LIM a` when `a` is not Cauchy. This requires Classical logic, because the property of being Cauchy is not computable or decidable. -/
84+
noncomputable abbrev LIM (a:ℕ → ℚ) : Real := Quotient.mk _ (if h : (a:Sequence).isCauchy then CauchySequence.mk' h else (0:CauchySequence))
85+
86+
theorem LIM_def {a:ℕ → ℚ} (ha: (a:Sequence).isCauchy) : LIM a = Quotient.mk _ (CauchySequence.mk' ha) := by
87+
rw [LIM, dif_pos ha]
88+
89+
/-- Definition 5.3.1 (Real numbers) -/
90+
theorem Real.eq_lim (x:Real) : ∃ (a:ℕ → ℚ), (a:Sequence).isCauchy ∧ x = LIM a := by
91+
-- I had a lot of trouble with this proof; perhaps there is a more idiomatic way to proceed
92+
apply Quot.ind _ x; intro a
93+
set a' : ℕ → ℚ := (a:ℕ → ℚ); use a'
94+
set s : Sequence := (a':Sequence)
95+
have : s = a.toSequence := CauchySequence.coe_to_sequence a
96+
rw [this]
97+
refine ⟨ a.cauchy, ?_ ⟩
98+
congr
99+
convert (dif_pos a.cauchy).symm with n
100+
. apply CauchySequence.ext'
101+
change a.seq = s.seq
102+
rw [this]
103+
classical
104+
exact Classical.propDecidable _
105+
106+
/-- Definition 5.3.1 (Real numbers) -/
107+
theorem Real.lim_eq_lim (a b:ℕ → ℚ) (ha: (a:Sequence).isCauchy) (hb: (b:Sequence).isCauchy) :
108+
LIM a = LIM b ↔ Sequence.equiv a b := by
109+
constructor
110+
. intro h
111+
replace h := Quotient.exact h
112+
rwa [dif_pos ha, dif_pos hb, CauchySequence.equiv_iff] at h
113+
intro h
114+
apply Quotient.sound
115+
rwa [dif_pos ha, dif_pos hb, CauchySequence.equiv_iff]
116+
117+
/--Lemma 5.3.6 (Sum of Cauchy sequences is Cauchy)-/
118+
theorem Sequence.add_cauchy {a b:ℕ → ℚ} (ha: (a:Sequence).isCauchy) (hb: (b:Sequence).isCauchy) : (a + b:Sequence).isCauchy := by
119+
-- This proof is written to follow the structure of the original text.
120+
rw [isCauchy_def] at ha hb ⊢
121+
intro ε hε
122+
have : ε/2 > 0 := by exact half_pos hε
123+
replace ha := ha (ε/2) this
124+
replace hb := hb (ε/2) this
125+
rw [Rat.eventuallySteady_def] at ha hb ⊢
126+
obtain ⟨ N, hN, hha ⟩ := ha
127+
obtain ⟨ M, hM, hhb ⟩ := hb
128+
use max N M
129+
simp at hN hM ⊢
130+
simp [hN, Rat.steady_def'] at hha hhb ⊢
131+
intro n m hnN hnM hmN hmM
132+
have hn := hN.trans hnN
133+
have hm := hM.trans hmM
134+
replace hha := hha n m hnN hmN
135+
replace hhb := hhb n m hn hnM hm hmM
136+
simp [hn, hm, hnN, hnM, hmN, hmM] at hha hhb ⊢
137+
convert Section_4_3.add_close hha hhb
138+
ring
139+
140+
/--Lemma 5.3.7 (Sum of equivalent sequences is equivalent)-/
141+
theorem Sequence.add_equiv_left {a a':ℕ → ℚ} (b:ℕ → ℚ) (haa': Sequence.equiv a a') :
142+
Sequence.equiv (a + b) (a' + b) := by
143+
sorry
144+
145+
/--Lemma 5.3.7 (Sum of equivalent sequences is equivalent)-/
146+
theorem Sequence.add_equiv_right {b b':ℕ → ℚ} (a:ℕ → ℚ) (hbb': Sequence.equiv b b') :
147+
Sequence.equiv (a + b) (a + b') := by
148+
simp_rw [add_comm, add_equiv_left a hbb']
149+
150+
/--Lemma 5.3.7 (Sum of equivalent sequences is equivalent)-/
151+
theorem Sequence.add_equiv {a b a' b':ℕ → ℚ} (haa': Sequence.equiv a a') (hbb': Sequence.equiv b b') :
152+
Sequence.equiv (a + b) (a' + b') := equiv_trans (add_equiv_left b haa') (add_equiv_right a' hbb')
153+
154+
/-- Definition 5.3.4 (Addition of reals) -/
155+
noncomputable instance Real.add_inst : Add Real where
156+
add := fun x y ↦
157+
Quotient.liftOn₂ x y (fun a b ↦ LIM (a + b)) (by
158+
intro a b a' b' haa' hbb'
159+
change LIM ((a:ℕ → ℚ) + (b:ℕ → ℚ)) = LIM ((a':ℕ → ℚ) + (b':ℕ → ℚ))
160+
rw [lim_eq_lim]
161+
. exact Sequence.add_equiv haa' hbb'
162+
all_goals apply Sequence.add_cauchy
163+
all_goals rw [CauchySequence.coe_to_sequence]
164+
. exact a.cauchy
165+
. exact b.cauchy
166+
. exact a'.cauchy
167+
exact b'.cauchy
168+
)
169+
170+
/--Proposition 5.3.10 (Product of Cauchy sequences is Cauchy)-/
171+
theorem Sequence.mul_cauchy {a b:ℕ → ℚ} (ha: (a:Sequence).isCauchy) (hb: (b:Sequence).isCauchy) : (a * b:Sequence).isCauchy := by
172+
sorry
173+
174+
/--Proposition 5.3.10 (Product of equivalent sequences is equivalent) / Exercise 5.3.2 -/
175+
theorem Sequence.mul_equiv_left {a a':ℕ → ℚ} (b:ℕ → ℚ) (haa': Sequence.equiv a a') :
176+
Sequence.equiv (a * b) (a' * b) := by
177+
sorry
178+
179+
/--Proposition 5.3.10 (Product of equivalent sequences is equivalent) / Exercise 5.3.2 -/
180+
theorem Sequence.mul_equiv_right {b b':ℕ → ℚ} (a:ℕ → ℚ) (hbb': Sequence.equiv b b') :
181+
Sequence.equiv (a * b) (a * b') := by
182+
simp_rw [mul_comm, mul_equiv_left a hbb']
183+
184+
/--Proposition 5.3.10 (Product of equivalent sequences is equivalent) / Exercise 5.3.2 -/
185+
theorem Sequence.mul_equiv {a b a' b':ℕ → ℚ} (haa': Sequence.equiv a a') (hbb': Sequence.equiv b b') :
186+
Sequence.equiv (a * b) (a' * b') := equiv_trans (mul_equiv_left b haa') (mul_equiv_right a' hbb')
187+
188+
/-- Definition 5.3.9 (Product of reals) -/
189+
noncomputable instance Real.mul_inst : Mul Real where
190+
mul := fun x y ↦
191+
Quotient.liftOn₂ x y (fun a b ↦ LIM (a * b)) (by
192+
intro a b a' b' haa' hbb'
193+
change LIM ((a:ℕ → ℚ) * (b:ℕ → ℚ)) = LIM ((a':ℕ → ℚ) * (b':ℕ → ℚ))
194+
rw [lim_eq_lim]
195+
. exact Sequence.mul_equiv haa' hbb'
196+
all_goals apply Sequence.mul_cauchy
197+
all_goals rw [CauchySequence.coe_to_sequence]
198+
. exact a.cauchy
199+
. exact b.cauchy
200+
. exact a'.cauchy
201+
exact b'.cauchy
202+
)
203+
204+
205+
206+
49207

50208

51209

0 commit comments

Comments
 (0)