Analysis I, Section 5.4

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:

namespace Chapter5

Definition 5.4.1 (sequences bounded away from zero with sign). Sequences are indexed to start from zero as this is more convenient for Mathlib purposes.

abbrev bounded_away_pos (a: ) : Prop := (c:), c > 0 n, a n c

Definition 5.4.1 (sequences bounded away from zero with sign).

abbrev bounded_away_neg (a: ) : Prop := (c:), c > 0 n, a n -c

Definition 5.4.1 (sequences bounded away from zero with sign).

theorem bounded_away_pos_def (a: ) : bounded_away_pos a (c:), c > 0 n, a n c := a:bounded_away_pos ac > 0, ∀ (n : ), a nc All goals completed! 🐙

Definition 5.4.1 (sequences bounded away from zero with sign).

theorem bounded_away_neg_def (a: ) : bounded_away_neg a (c:), c > 0 n, a n -c := a:bounded_away_neg ac > 0, ∀ (n : ), a n-c All goals completed! 🐙

Examples 5.4.2

declaration uses 'sorry'example : bounded_away_pos (fun n 1 + 10^(-(n:)-1)) := bounded_away_pos fun n => 1 + 10 ^ (-n - 1) All goals completed! 🐙

Examples 5.4.2

declaration uses 'sorry'example : bounded_away_neg (fun n - - 10^(-(n:)-1)) := bounded_away_neg fun n => - -10 ^ (-n - 1) All goals completed! 🐙

Examples 5.4.2

declaration uses 'sorry'example : ¬ bounded_away_pos (fun n (-1)^n) := ¬bounded_away_pos fun n => (-1) ^ n All goals completed! 🐙declaration uses 'sorry'example : ¬ bounded_away_neg (fun n (-1)^n) := ¬bounded_away_neg fun n => (-1) ^ n All goals completed! 🐙declaration uses 'sorry'example : bounded_away_zero (fun n (-1)^n) := bounded_away_zero fun n => (-1) ^ n All goals completed! 🐙theorem declaration uses 'sorry'bounded_away_zero_of_pos {a: } (ha: bounded_away_pos a) : bounded_away_zero a := a:ha:bounded_away_pos abounded_away_zero a All goals completed! 🐙theorem declaration uses 'sorry'bounded_away_zero_of_neg {a: } (ha: bounded_away_neg a) : bounded_away_zero a := a:ha:bounded_away_neg abounded_away_zero a All goals completed! 🐙theorem declaration uses 'sorry'not_bounded_away_pos_neg {a: } : ¬ (bounded_away_pos a bounded_away_neg a) := a:¬(bounded_away_pos abounded_away_neg a) All goals completed! 🐙abbrev Real.isPos (x:Real) : Prop := a: , bounded_away_pos a (a:Sequence).isCauchy x = LIM aabbrev Real.isNeg (x:Real) : Prop := a: , bounded_away_neg a (a:Sequence).isCauchy x = LIM a

Proposition 5.4.4 (basic properties of positive reals) / Exercise 5.4.1

theorem declaration uses 'sorry'Real.trichotomous (x:Real) : x = 0 x.isPos x.isNeg := x:Realx = 0x.isPosx.isNeg All goals completed! 🐙

Proposition 5.4.4 (basic properties of positive reals) / Exercise 5.4.1

theorem declaration uses 'sorry'Real.not_zero_pos (x:Real) : ¬ (x = 0 x.isPos) := x:Real¬(x = 0x.isPos) All goals completed! 🐙theorem Real.nonzero_of_pos {x:Real} (hx: x.isPos) : x 0 := x:Realhx:x.isPosx0 x:Realhx:x.isPosthis:¬(x = 0x.isPos)x0 x:Realhx:x.isPosthis:¬x = 0¬x = 0 All goals completed! 🐙

Proposition 5.4.4 (basic properties of positive reals) / Exercise 5.4.1

theorem declaration uses 'sorry'Real.not_zero_neg (x:Real) : ¬ (x = 0 x.isNeg) := x:Real¬(x = 0x.isNeg) All goals completed! 🐙theorem Real.nonzero_of_neg {x:Real} (hx: x.isNeg) : x 0 := x:Realhx:x.isNegx0 x:Realhx:x.isNegthis:¬(x = 0x.isNeg)x0 x:Realhx:x.isNegthis:¬x = 0¬x = 0 All goals completed! 🐙

Proposition 5.4.4 (basic properties of positive reals) / Exercise 5.4.1

theorem declaration uses 'sorry'Real.not_pos_neg (x:Real) : ¬ (x.isPos x.isNeg) := x:Real¬(x.isPosx.isNeg) All goals completed! 🐙

Proposition 5.4.4 (basic properties of positive reals) / Exercise 5.4.1

@[simp] theorem declaration uses 'sorry'Real.neg_iff_pos_of_neg (x:Real) : x.isNeg (-x).isPos := x:Realx.isNeg(-x).isPos All goals completed! 🐙

Proposition 5.4.4 (basic properties of positive reals) / Exercise 5.4.1

theorem declaration uses 'sorry'Real.pos_add {x y:Real} (hx: x.isPos) (hy: y.isPos) : (x+y).isPos := x:Realy:Realhx:x.isPoshy:y.isPos(x + y).isPos All goals completed! 🐙

Proposition 5.4.4 (basic properties of positive reals) / Exercise 5.4.1

theorem declaration uses 'sorry'Real.pos_mul {x y:Real} (hx: x.isPos) (hy: y.isPos) : (x*y).isPos := x:Realy:Realhx:x.isPoshy:y.isPos(x * y).isPos All goals completed! 🐙theorem declaration uses 'sorry'Real.pos_of_coe (q:) : (q:Real).isPos q > 0 := q:(↑q).isPosq > 0 All goals completed! 🐙theorem declaration uses 'sorry'Real.neg_of_coe (q:) : (q:Real).isNeg q < 0 := q:(↑q).isNegq < 0 All goals completed! 🐙open Classical in /-- Need to use classical logic here because isPos and isNeg are not decidable -/ noncomputable abbrev Real.abs (x:Real) : Real := if x.isPos then x else (if x.isNeg then -x else 0)

Definition 5.4.5 (absolute value)

@[simp] theorem Real.abs_of_pos (x:Real) (hx: x.isPos) : Real.abs x = x := x:Realhx:x.isPosx.abs = x All goals completed! 🐙

Definition 5.4.5 (absolute value)

@[simp] theorem Real.abs_of_neg (x:Real) (hx: x.isNeg) : Real.abs x = -x := x:Realhx:x.isNegx.abs = -x have : ¬ x.isPos := x:Realhx:x.isNegx.abs = -x x:Realhx:x.isNegthis:¬(x.isPosx.isNeg)¬x.isPos; x:Realhx:x.isNegthis:¬x.isPos¬x.isPos; All goals completed! 🐙 All goals completed! 🐙

Definition 5.4.5 (absolute value)

@[simp] theorem Real.abs_of_zero : Real.abs 0 = 0 := abs 0 = 0 have hpos: ¬ (0:Real).isPos := abs 0 = 0 this:¬(0 = 0isPos 0)¬isPos 0; this:¬isPos 0¬isPos 0; All goals completed! 🐙 have hneg: ¬ (0:Real).isNeg := abs 0 = 0 hpos:¬isPos 0this:¬(0 = 0isNeg 0)¬isNeg 0; hpos:¬isPos 0this:¬isNeg 0¬isNeg 0; All goals completed! 🐙 All goals completed! 🐙

Definition 5.4.6 (Ordering of the reals)

instance Real.instLT : LT Real where lt x y := (x-y).isNeg

Definition 5.4.6 (Ordering of the reals)

instance Real.instLE : LE Real where le x y := (x < y) (x = y)theorem Real.lt_iff (x y:Real) : x < y (x-y).isNeg := x:Realy:Realx < y(x - y).isNeg All goals completed! 🐙theorem Real.le_iff (x y:Real) : x y (x < y) (x = y) := x:Realy:Realxyx < yx = y All goals completed! 🐙theorem declaration uses 'sorry'Real.gt_iff (x y:Real) : x > y (x-y).isPos := x:Realy:Realx > y(x - y).isPos All goals completed! 🐙theorem declaration uses 'sorry'Real.ge_iff (x y:Real) : x y (x > y) (x = y) := x:Realy:Realxyx > yx = y All goals completed! 🐙theorem declaration uses 'sorry'Real.lt_of_coe (q q':): q < q' (q:Real) < (q':Real) := q:q':q < q'q < q' All goals completed! 🐙theorem Real.gt_of_coe (q q':): q > q' (q:Real) > (q':Real) := Real.lt_of_coe _ _

Proposition 5.4.7(a) (order trichotomy) / Exercise 5.4.2

theorem declaration uses 'sorry'Real.trichotomous' (x y z:Real) : x > y x < y x = y := x:Realy:Realz:Realx > yx < yx = y All goals completed! 🐙

Proposition 5.4.7(a) (order trichotomy) / Exercise 5.4.2

theorem declaration uses 'sorry'Real.not_gt_and_lt (x y:Real) : ¬ (x > y x < y):= x:Realy:Real¬(x > yx < y) All goals completed! 🐙

Proposition 5.4.7(a) (order trichotomy) / Exercise 5.4.2

theorem declaration uses 'sorry'Real.not_gt_and_eq (x y:Real) : ¬ (x > y x = y):= x:Realy:Real¬(x > yx = y) All goals completed! 🐙

Proposition 5.4.7(a) (order trichotomy) / Exercise 5.4.2

theorem declaration uses 'sorry'Real.not_lt_and_eq (x y:Real) : ¬ (x < y x = y):= x:Realy:Real¬(x < yx = y) All goals completed! 🐙

Proposition 5.4.7(b) (order is anti-symmetric) / Exercise 5.4.2

theorem declaration uses 'sorry'Real.antisymm (x y:Real) : x < y (y - x).isPos := x:Realy:Realx < y(y - x).isPos All goals completed! 🐙

Proposition 5.4.7(c) (order is transitive) / Exercise 5.4.2

theorem declaration uses 'sorry'Real.lt_trans {x y z:Real} (hxy: x < y) (hyz: y < z) : x < z := x:Realy:Realz:Realhxy:x < yhyz:y < zx < z All goals completed! 🐙

Proposition 5.4.7(d) (addition preserves order) / Exercise 5.4.2

theorem declaration uses 'sorry'Real.add_lt_add_right {x y:Real} (z:Real) (hxy: x < y) : x + z < y + z := x:Realy:Realz:Realhxy:x < yx + z < y + z All goals completed! 🐙

Proposition 5.4.7(e) (positive multiplication preserves order) / Exercise 5.4.2

theorem Real.mul_lt_mul_right {x y z:Real} (hxy: x < y) (hz: z.isPos) : x * z < y * z := x:Realy:Realz:Realhxy:x < yhz:z.isPosx * z < y * z x:Realy:Realz:Realhxy:(y - x).isPoshz:z.isPos(y * z - x * z).isPos x:Realy:Realz:Realhxy:(y - x).isPoshz:z.isPosy * z - x * z = (y - x) * z All goals completed! 🐙

Proposition 5.4.7(e) (positive multiplication preserves order) / Exercise 5.4.2

theorem declaration uses 'sorry'Real.mul_le_mul_left {x y z:Real} (hxy: x y) (hz: z.isPos) : z * x z * y := x:Realy:Realz:Realhxy:xyhz:z.isPosz * xz * y All goals completed! 🐙theorem declaration uses 'sorry'Real.mul_pos_neg {x y:Real} (hx: x.isPos) (hy: y.isNeg) : (x * y).isNeg := x:Realy:Realhx:x.isPoshy:y.isNeg(x * y).isNeg All goals completed! 🐙

(Not from textbook) Real has the structure of a linear ordering. The order is not computable, and so classical logic is required to impose decidability.

noncomputable instance declaration uses 'sorry'declaration uses 'sorry'declaration uses 'sorry'declaration uses 'sorry'declaration uses 'sorry'declaration uses 'sorry'Real.instLinearOrder : LinearOrder Real where le_refl := sorry le_trans := sorry lt_iff_le_not_le := sorry le_antisymm := sorry le_total := sorry toDecidableLE := DecidableLE Real classical All goals completed! 🐙

Proposition 5.4.8

theorem Real.inv_of_pos {x:Real} (hx: x.isPos) : x⁻¹.isPos := x:Realhx:x.isPosx⁻¹.isPos x:Realhx:x.isPoshnon:x0x⁻¹.isPos x:Realhx:x.isPoshnon:x0hident:x * x⁻¹ = 1x⁻¹.isPos have hinv_non: x⁻¹ 0 := x:Realhx:x.isPosx⁻¹.isPos x:Realhx:x.isPoshnon:x0hident:x⁻¹ = 0x * x⁻¹1; All goals completed! 🐙 have hnonneg : ¬ x⁻¹.isNeg := x:Realhx:x.isPosx⁻¹.isPos x:Realhx:x.isPoshnon:x0hident:x * x⁻¹ = 1hinv_non:x⁻¹0h:x⁻¹.isNegFalse x:Realhx:x.isPoshnon:x0hident:x * x⁻¹ = 1hinv_non:x⁻¹0h:x⁻¹.isNegthis:(x * x⁻¹).isNegFalse have id : -(1:Real) = (-1:) := x:Realhx:x.isPosx⁻¹.isPos All goals completed! 🐙 x:Realhx:x.isPoshnon:x0hident:x * x⁻¹ = 1hinv_non:x⁻¹0h:x⁻¹.isNegid:-1 = ↑(-1)this:-1 > 0False All goals completed! 🐙 x:Realhx:x.isPoshnon:x0hident:x * x⁻¹ = 1hinv_non:x⁻¹0hnonneg:¬x⁻¹.isNegtrich:x⁻¹ = 0x⁻¹.isPosx⁻¹.isNegx⁻¹.isPos x:Realhx:x.isPoshnon:x0hident:x * x⁻¹ = 1hinv_non:x⁻¹0hnonneg:¬x⁻¹.isNegtrich:x⁻¹.isPosx⁻¹.isPos All goals completed! 🐙theorem Real.inv_of_gt {x y:Real} (hx: x.isPos) (hy: y.isPos) (hxy: x > y) : x⁻¹ < y⁻¹ := x:Realy:Realhx:x.isPoshy:y.isPoshxy:x > yx⁻¹ < y⁻¹ x:Realy:Realhx:x.isPoshy:y.isPoshxy:x > yhxnon:x0x⁻¹ < y⁻¹ x:Realy:Realhx:x.isPoshy:y.isPoshxy:x > yhxnon:x0hynon:y0x⁻¹ < y⁻¹ x:Realy:Realhx:x.isPoshy:y.isPoshxy:x > yhxnon:x0hynon:y0hxinv:x⁻¹.isPosx⁻¹ < y⁻¹ x:Realy:Realhx:x.isPoshy:y.isPoshxy:x > yhxnon:x0hynon:y0hxinv:x⁻¹.isPoshyinv:y⁻¹.isPosx⁻¹ < y⁻¹ x:Realy:Realhx:x.isPoshy:y.isPoshxy:x > yhxnon:x0hynon:y0hxinv:x⁻¹.isPoshyinv:y⁻¹.isPosthis:y⁻¹x⁻¹False x:Realy:Realhx:x.isPoshy:y.isPoshxy:x > yhxnon:x0hynon:y0hxinv:x⁻¹.isPoshyinv:y⁻¹.isPosthis✝:y⁻¹x⁻¹this:1 > 1False All goals completed! 🐙

(Not from textbook) Real has the structure of a strict ordered ring.

instance declaration uses 'sorry'Real.instIsStrictOrderedRing : IsStrictOrderedRing Real where add_le_add_left := ∀ (a b : Real), ab → ∀ (c : Real), c + ac + b All goals completed! 🐙 add_le_add_right := ∀ (a b : Real), ab → ∀ (c : Real), a + cb + c All goals completed! 🐙 mul_lt_mul_of_pos_left := ∀ (a b c : Real), a < b → 0 < cc * a < c * b All goals completed! 🐙 mul_lt_mul_of_pos_right := ∀ (a b c : Real), a < b → 0 < ca * c < b * c All goals completed! 🐙 le_of_add_le_add_left := ∀ (a b c : Real), a + ba + cbc All goals completed! 🐙 zero_le_one := 01 All goals completed! 🐙

Proposition 5.4.9 (The non-negative reals are closed)

theorem declaration uses 'sorry'Real.LIM_of_nonneg {a: } (ha: n, a n 0) (hcauchy: (a:Sequence).isCauchy) : LIM a 0 := a:ha:∀ (n : ), a n0hcauchy:{ n₀ := 0, seq := fun n => if n0 then a n.toNat else 0, vanish := ⋯ }.isCauchyLIM a0 All goals completed! 🐙 --TODO

Corollary 5.4.10

theorem declaration uses 'sorry'Real.LIM_mono {a b: } (ha: (a:Sequence).isCauchy) (hb: (b:Sequence).isCauchy) (hmono: n, a n b n) : LIM a LIM b := a:b:ha:{ n₀ := 0, seq := fun n => if n0 then a n.toNat else 0, vanish := ⋯ }.isCauchyhb:{ n₀ := 0, seq := fun n => if n0 then b n.toNat else 0, vanish := ⋯ }.isCauchyhmono:∀ (n : ), a nb nLIM aLIM b All goals completed! 🐙 --TODO

Remark 5.4.11 -

theorem declaration uses 'sorry'Real.LIM_mono_fail : (a b: ), (a:Sequence).isCauchy (b:Sequence).isCauchy ¬ ( n, a n > b n) ¬ LIM a > LIM b := a b, { n₀ := 0, seq := fun n => if n0 then a n.toNat else 0, vanish := ⋯ }.isCauchy{ n₀ := 0, seq := fun n => if n0 then b n.toNat else 0, vanish := ⋯ }.isCauchy(¬∀ (n : ), a n > b n)¬LIM a > LIM b b, { n₀ := 0, seq := fun n => if n0 then (fun n => 1 + 1 / n) n.toNat else 0, vanish := ⋯ }.isCauchy{ n₀ := 0, seq := fun n => if n0 then b n.toNat else 0, vanish := ⋯ }.isCauchy(¬∀ (n : ), (fun n => 1 + 1 / n) n > b n)¬(LIM fun n => 1 + 1 / n) > LIM b { n₀ := 0, seq := fun n => if n0 then 1 + 1 / n.toNat else 0, vanish := ⋯ }.isCauchy{ n₀ := 0, seq := fun n => if n0 then (fun n => 1 - 1 / n) n.toNat else 0, vanish := ⋯ }.isCauchy(¬∀ (n : ), 1 + 1 / n > (fun n => 1 - 1 / n) n)¬(LIM fun n => 1 + 1 / n) > LIM fun n => 1 - 1 / n All goals completed! 🐙end Chapter5