Ordering the reals

Analysis I, Section 5.4: Ordering the reals

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:

  • Ordering on the real line

Tips from past users

Users of the companion who have completed the exercises in this section are welcome to send their tips for future users in this section as PRs.

  • (Add tip here)

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 BoundedAwayPos (a: ) : Prop := (c:), c > 0 n, a n c

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

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

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

theorem boundedAwayPos_def (a: ) : BoundedAwayPos a (c:), c > 0 n, a n c := a: BoundedAwayPos a c > 0, (n : ), a n c All goals completed! 🐙

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

theorem boundedAwayNeg_def (a: ) : BoundedAwayNeg a (c:), c > 0 n, a n -c := a: BoundedAwayNeg a c > 0, (n : ), a n -c All goals completed! 🐙

Examples 5.4.2

example : BoundedAwayPos (fun n 1 + 10^(-(n:)-1)) := 1, 1 > 0 All goals completed! 🐙, (n : ), (fun n => 1 + 10 ^ (-n - 1)) n 1 n✝:(fun n => 1 + 10 ^ (-n - 1)) n✝ 1; n✝:0 10 ^ (-n✝ - 1); All goals completed! 🐙

Examples 5.4.2

example : BoundedAwayNeg (fun n -1 - 10^(-(n:)-1)) := 1, 1 > 0 All goals completed! 🐙, (n : ), (fun n => -1 - 10 ^ (-n - 1)) n -1 n✝:(fun n => -1 - 10 ^ (-n - 1)) n✝ -1; n✝:0 10 ^ (-n✝ - 1); All goals completed! 🐙

Examples 5.4.2

example : ¬ BoundedAwayPos (fun n (-1)^n) := ¬BoundedAwayPos fun n => (-1) ^ n c:h1:c > 0h2: (n : ), (fun n => (-1) ^ n) n cFalse; c:h1:c > 0h2:(fun n => (-1) ^ n) 1 cFalse; All goals completed! 🐙

Examples 5.4.2

example : ¬ BoundedAwayNeg (fun n (-1)^n) := ¬BoundedAwayNeg fun n => (-1) ^ n c:h1:c > 0h2: (n : ), (fun n => (-1) ^ n) n -cFalse; c:h1:c > 0h2:(fun n => (-1) ^ n) 0 -cFalse; All goals completed! 🐙

Examples 5.4.2

example : BoundedAwayZero (fun n (-1)^n) := 1, 1 > 0 All goals completed! 🐙, (n : ), |(fun n => (-1) ^ n) n| 1 n✝:|(fun n => (-1) ^ n) n✝| 1; All goals completed! 🐙
theorem BoundedAwayZero.boundedAwayPos {a: } (ha: BoundedAwayPos a) : BoundedAwayZero a := a: ha:BoundedAwayPos aBoundedAwayZero a a: ha:BoundedAwayPos ac:h1:c > 0n:h2:a n c|a n| c; rwa [abs_of_nonneg (a: ha:BoundedAwayPos ac:h1:c > 0n:h2:a n c0 a n All goals completed! 🐙)a: ha:BoundedAwayPos ac:h1:c > 0n:h2:a n ca n ctheorem BoundedAwayZero.boundedAwayNeg {a: } (ha: BoundedAwayNeg a) : BoundedAwayZero a := a: ha:BoundedAwayNeg aBoundedAwayZero a a: ha:BoundedAwayNeg ac:h1:c > 0n:h2:a n -c|a n| c; a: ha:BoundedAwayNeg ac:h1:c > 0n:h2:a n -c-a n c; All goals completed! 🐙theorem not_boundedAwayPos_boundedAwayNeg {a: } : ¬ (BoundedAwayPos a BoundedAwayNeg a) := a: ¬(BoundedAwayPos a BoundedAwayNeg a) a: w✝¹:left✝¹:w✝¹ > 0h2: (n : ), a n w✝¹w✝:left✝:w✝ > 0h4: (n : ), a n -w✝False; All goals completed! 🐙abbrev Real.IsPos (x:Real) : Prop := a: , BoundedAwayPos a (a:Sequence).IsCauchy x = LIM aabbrev Real.IsNeg (x:Real) : Prop := a: , BoundedAwayNeg a (a:Sequence).IsCauchy x = LIM atheorem Real.isPos_def (x:Real) : IsPos x a: , BoundedAwayPos a (a:Sequence).IsCauchy x = LIM a := x:Realx.IsPos a, BoundedAwayPos a (↑a).IsCauchy x = LIM a All goals completed! 🐙theorem Real.isNeg_def (x:Real) : IsNeg x a: , BoundedAwayNeg a (a:Sequence).IsCauchy x = LIM a := x:Realx.IsNeg a, BoundedAwayNeg a (↑a).IsCauchy x = LIM a All goals completed! 🐙

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 = 0 x.IsPos x.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 = 0 x.IsPos) All goals completed! 🐙
theorem Real.nonzero_of_pos {x:Real} (hx: x.IsPos) : x 0 := x:Realhx:x.IsPosx 0 x:Realhx:x.IsPosthis:?_mvar.15897 := Chapter5.Real.not_zero_pos _fvar.15893x 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 = 0 x.IsNeg) All goals completed! 🐙
theorem Real.nonzero_of_neg {x:Real} (hx: x.IsNeg) : x 0 := x:Realhx:x.IsNegx 0 x:Realhx:x.IsNegthis:?_mvar.16366 := Chapter5.Real.not_zero_neg _fvar.16362x 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.IsPos x.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).IsPos q > 0 All goals completed! 🐙theorem declaration uses 'sorry'Real.neg_of_coe (q:) : (q:Real).IsNeg q < 0 := q:(↑q).IsNeg q < 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) : 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) : abs x = -x := x:Realhx:x.IsNegx.abs = -x have : ¬x.IsPos := x:Realhx:x.IsNegx.abs = -x x:Realhx:x.IsNegthis:?_mvar.22500 := Chapter5.Real.not_pos_neg _fvar.22489¬x.IsPos; All goals completed! 🐙 All goals completed! 🐙

Definition 5.4.5 (absolute value)

@[simp] theorem Real.abs_of_zero : abs 0 = 0 := abs 0 = 0 have hpos: ¬(0:Real).IsPos := abs 0 = 0 this:?_mvar.259693 := Chapter5.Real.not_zero_pos 0¬IsPos 0; All goals completed! 🐙 have hneg: ¬(0:Real).IsNeg := abs 0 = 0 hpos:¬Chapter5.Real.IsPos 0 := ?_mvar.259687this:?_mvar.496262 := Chapter5.Real.not_zero_neg 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:Realx y x < y x = 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:Realx y x > y x = 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 _ _theorem declaration uses 'sorry'Real.isPos_iff (x:Real) : x.IsPos x > 0 := x:Realx.IsPos x > 0 All goals completed! 🐙theorem declaration uses 'sorry'Real.isNeg_iff (x:Real) : x.IsNeg x < 0 := x:Realx.IsNeg x < 0 All goals completed! 🐙

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

theorem declaration uses 'sorry'Real.trichotomous' (x y:Real) : x > y x < y x = y := x:Realy:Realx > y x < y x = 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 > y x < 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 > y x = 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 < y x = 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:x yhz:z.IsPosz * x z * 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! 🐙open Classical in /-- (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_ge := sorry le_antisymm := sorry le_total := sorry toDecidableLE := Classical.decRel _

(Not from textbook) Linear Orders come with a definition of absolute value |.| Show that it agrees with our earlier definition.

theorem declaration uses 'sorry'Real.abs_eq_abs (x:Real) : |x| = abs x := x:Real|x| = x.abs 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:x 0x⁻¹.IsPos x:Realhx:x.IsPoshnon:x 0hident:x⁻¹ * x = 1x⁻¹.IsPos have hinv_non: x⁻¹ 0 := x:Realhx:x.IsPosx⁻¹.IsPos x:Realhx:x.IsPoshnon:x 0hident:x⁻¹ = 0x⁻¹ * x 1; All goals completed! 🐙 have hnonneg : ¬x⁻¹.IsNeg := x:Realhx:x.IsPosx⁻¹.IsPos x:Realhx:x.IsPoshnon:x 0hident:x⁻¹ * x = 1hinv_non:_fvar.741017⁻¹ 0 := ?_mvar.793453h:x⁻¹.IsNegFalse x:Realhx:x.IsPoshnon:x 0hident:x⁻¹ * x = 1hinv_non:_fvar.741017⁻¹ 0 := ?_mvar.793453h:x⁻¹.IsNegthis:(x * x⁻¹).IsNegFalse have id : -(1:Real) = (-1:) := x:Realhx:x.IsPosx⁻¹.IsPos All goals completed! 🐙 x:Realhx:x.IsPoshnon:x 0hident:x⁻¹ * x = 1hinv_non:_fvar.741017⁻¹ 0 := ?_mvar.793453h:x⁻¹.IsNegid:-1 = (-1) := ?_mvar.802738this:-1 > 0False All goals completed! 🐙 x:Realhx:x.IsPoshnon:x 0hident:x⁻¹ * x = 1hinv_non:_fvar.741017⁻¹ 0 := ?_mvar.793453hnonneg:¬Chapter5.Real.IsNeg _fvar.741017⁻¹ := ?_mvar.794644trich:?_mvar.804208 := Chapter5.Real.trichotomous _fvar.741017⁻¹x⁻¹.IsPos All goals completed! 🐙
theorem declaration uses 'sorry'Real.div_of_pos {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 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:x 0x⁻¹ < y⁻¹ x:Realy:Realhx:x.IsPoshy:y.IsPoshxy:x > yhxnon:x 0hynon:y 0x⁻¹ < y⁻¹ x:Realy:Realhx:x.IsPoshy:y.IsPoshxy:x > yhxnon:x 0hynon:y 0hxinv:x⁻¹.IsPosx⁻¹ < y⁻¹ x:Realy:Realhx:x.IsPoshy:y.IsPoshxy:x > yhxnon:x 0hynon:y 0hxinv:x⁻¹.IsPosthis:y⁻¹ x⁻¹False x:Realy:Realhx:x.IsPoshy:y.IsPoshxy:x > yhxnon:x 0hynon:y 0hxinv:x⁻¹.IsPosthis✝:y⁻¹ x⁻¹this:1 > 1 := Trans.trans (Trans.trans (Trans.trans ) ) False 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), a b (c : Real), c + a c + b All goals completed! 🐙 add_le_add_right := (a b : Real), a b (c : Real), a + c b + c All goals completed! 🐙 mul_lt_mul_of_pos_left := (a b c : Real), a < b 0 < c c * a < c * b All goals completed! 🐙 mul_lt_mul_of_pos_right := (a b c : Real), a < b 0 < c a * c < b * c All goals completed! 🐙 le_of_add_le_add_left := (a b c : Real), a + b a + c b c All goals completed! 🐙 zero_le_one := 0 1 All goals completed! 🐙

Proposition 5.4.9 (The non-negative reals are closed)

theorem Real.LIM_of_nonneg {a: } (ha: n, a n 0) (hcauchy: (a:Sequence).IsCauchy) : LIM a 0 := a: ha: (n : ), a n 0hcauchy:(↑a).IsCauchyLIM a 0 -- This proof is written to follow the structure of the original text. a: ha: (n : ), a n 0hcauchy:(↑a).IsCauchyhlim:LIM a < 0False a: ha: (n : ), a n 0hcauchy:(↑a).IsCauchyx:Chapter5.Real := Chapter5.LIM _fvar.811261hlim:x < 0False a: ha: (n : ), a n 0hcauchy:(↑a).IsCauchyx:Chapter5.Real := Chapter5.LIM _fvar.811261hlim: a, BoundedAwayNeg a (↑a).IsCauchy x = LIM aFalse; a: ha: (n : ), a n 0hcauchy:(↑a).IsCauchyx:Chapter5.Real := Chapter5.LIM _fvar.811261b: hb:BoundedAwayNeg bhb_cauchy:(↑b).IsCauchyhlim:x = LIM bFalse a: ha: (n : ), a n 0hcauchy:(↑a).IsCauchyx:Chapter5.Real := Chapter5.LIM _fvar.811261b: hb: c > 0, (n : ), b n -chb_cauchy:(↑b).IsCauchyhlim:x = LIM bFalse; a: ha: (n : ), a n 0hcauchy:(↑a).IsCauchyx:Chapter5.Real := Chapter5.LIM _fvar.811261b: hb_cauchy:(↑b).IsCauchyhlim:x = LIM bc:cpos:c > 0hb: (n : ), b n -cFalse have claim1 : n, ¬ (c/2).Close (a n) (b n) := a: ha: (n : ), a n 0hcauchy:(↑a).IsCauchyLIM a 0 a: ha: (n : ), a n 0hcauchy:(↑a).IsCauchyx:Chapter5.Real := Chapter5.LIM _fvar.811261b: hb_cauchy:(↑b).IsCauchyhlim:x = LIM bc:cpos:c > 0hb: (n : ), b n -cn:¬(c / 2).Close (a n) (b n); a: hcauchy:(↑a).IsCauchyx:Chapter5.Real := Chapter5.LIM _fvar.811261b: hb_cauchy:(↑b).IsCauchyhlim:x = LIM bc:cpos:c > 0hb: (n : ), b n -cn:ha:a n 0¬(c / 2).Close (a n) (b n); a: hcauchy:(↑a).IsCauchyx:Chapter5.Real := Chapter5.LIM _fvar.811261b: hb_cauchy:(↑b).IsCauchyhlim:x = LIM bc:cpos:c > 0n:ha:a n 0hb:b n -c¬(c / 2).Close (a n) (b n) a: hcauchy:(↑a).IsCauchyx:Chapter5.Real := Chapter5.LIM _fvar.811261b: hb_cauchy:(↑b).IsCauchyhlim:x = LIM bc:cpos:c > 0n:ha:a n 0hb:b n -cc / 2 < |a n - b n| calc _ < c := a: hcauchy:(↑a).IsCauchyx:Chapter5.Real := Chapter5.LIM _fvar.811261b: hb_cauchy:(↑b).IsCauchyhlim:x = LIM bc:cpos:c > 0n:ha:a n 0hb:b n -cc / 2 < c All goals completed! 🐙 _ a n - b n := a: hcauchy:(↑a).IsCauchyx:Chapter5.Real := Chapter5.LIM _fvar.811261b: hb_cauchy:(↑b).IsCauchyhlim:x = LIM bc:cpos:c > 0n:ha:a n 0hb:b n -cc a n - b n All goals completed! 🐙 _ _ := le_abs_self _ have claim2 : ¬(c/2).EventuallyClose (a:Sequence) (b:Sequence) := a: ha: (n : ), a n 0hcauchy:(↑a).IsCauchyLIM a 0 a: ha: (n : ), a n 0hcauchy:(↑a).IsCauchyx:Chapter5.Real := Chapter5.LIM _fvar.811261b: hb_cauchy:(↑b).IsCauchyhlim:x = LIM bc:cpos:c > 0hb: (n : ), b n -cclaim1:(c / 2).EventuallyClose a b n, (c / 2).Close (a n) (b n); a: ha: (n : ), a n 0hcauchy:(↑a).IsCauchyx:Chapter5.Real := Chapter5.LIM _fvar.811261b: hb_cauchy:(↑b).IsCauchyhlim:x = LIM bc:cpos:c > 0hb: (n : ), b n -cclaim1: N, n N, |a n - b n| c / 2 n, (c / 2).Close (a n) (b n); a: ha: (n : ), a n 0hcauchy:(↑a).IsCauchyx:Chapter5.Real := Chapter5.LIM _fvar.811261b: hb_cauchy:(↑b).IsCauchyhlim:x = LIM bc:cpos:c > 0hb: (n : ), b n -cclaim1✝: N, n N, |a n - b n| c / 2N:claim1: n N, |a n - b n| c / 2(c / 2).Close (a N) (b N); All goals completed! 🐙 have claim3 : ¬Sequence.Equiv a b := a: ha: (n : ), a n 0hcauchy:(↑a).IsCauchyLIM a 0 a: ha: (n : ), a n 0hcauchy:(↑a).IsCauchyx:Chapter5.Real := Chapter5.LIM _fvar.811261b: hb_cauchy:(↑b).IsCauchyhlim:x = LIM bc:cpos:c > 0hb: (n : ), b n -cclaim1: (n : ), ¬(_fvar.811942 / 2).Close (@_fvar.811261 n) (@_fvar.811886 n) := ?_mvar.812043claim2:Sequence.Equiv a b(c / 2).EventuallyClose a b; a: ha: (n : ), a n 0hcauchy:(↑a).IsCauchyx:Chapter5.Real := Chapter5.LIM _fvar.811261b: hb_cauchy:(↑b).IsCauchyhlim:x = LIM bc:cpos:c > 0hb: (n : ), b n -cclaim1: (n : ), ¬(_fvar.811942 / 2).Close (@_fvar.811261 n) (@_fvar.811886 n) := ?_mvar.812043claim2: ε > 0, ε.EventuallyClose a b(c / 2).EventuallyClose a b; All goals completed! 🐙 a: ha: (n : ), a n 0hcauchy:(↑a).IsCauchyx:Chapter5.Real := Chapter5.LIM _fvar.811261b: hb_cauchy:(↑b).IsCauchyc:cpos:c > 0hb: (n : ), b n -cclaim1: (n : ), ¬(_fvar.811942 / 2).Close (@_fvar.811261 n) (@_fvar.811886 n) := ?_mvar.812043claim2:¬Rat.EventuallyClose (_fvar.811942 / 2) _fvar.811261 _fvar.811886 := ?_mvar.815094claim3:¬Chapter5.Sequence.Equiv _fvar.811261 _fvar.811886 := ?_mvar.827492hlim:Sequence.Equiv a bFalse All goals completed! 🐙

Corollary 5.4.10

theorem 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:(↑a).IsCauchyhb:(↑b).IsCauchyhmono: (n : ), a n b nLIM a LIM b -- This proof is written to follow the structure of the original text. have := LIM_of_nonneg (a := b - a) (a: b: ha:(↑a).IsCauchyhb:(↑b).IsCauchyhmono: (n : ), a n b n (n : ), (b - a) n 0 a: b: ha:(↑a).IsCauchyhb:(↑b).IsCauchyhmono: (n : ), a n b nn:(b - a) n 0; All goals completed! 🐙) (Sequence.IsCauchy.sub hb ha) a: b: ha:(↑a).IsCauchyhb:(↑b).IsCauchyhmono: (n : ), a n b nthis:LIM b - LIM a 0LIM a LIM b; All goals completed! 🐙

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, (↑a).IsCauchy (↑b).IsCauchy (∀ (n : ), a n > b n) ¬LIM a > LIM b b, (↑fun n => 1 + 1 / (n + 1)).IsCauchy (↑b).IsCauchy (∀ (n : ), (fun n => 1 + 1 / (n + 1)) n > b n) ¬(LIM fun n => 1 + 1 / (n + 1)) > LIM b (↑fun n => 1 + 1 / (n + 1)).IsCauchy (↑fun n => 1 - 1 / (n + 1)).IsCauchy (∀ (n : ), 1 + 1 / (n + 1) > (fun n => 1 - 1 / (n + 1)) n) ¬(LIM fun n => 1 + 1 / (n + 1)) > LIM fun n => 1 - 1 / (n + 1) All goals completed! 🐙

Proposition 5.4.12 (Bounding reals by rationals)

theorem Real.exists_rat_le_and_nat_ge {x:Real} (hx: x.IsPos) : ( q:, q > 0 (q:Real) x) N:, x < (N:Real) := x:Realhx:x.IsPos(∃ q > 0, q x) N, x < N -- This proof is written to follow the structure of the original text. x:Realhx: a, BoundedAwayPos a (↑a).IsCauchy x = LIM a(∃ q > 0, q x) N, x < N; x:Reala: hbound:BoundedAwayPos ahcauchy:(↑a).IsCauchyheq:x = LIM a(∃ q > 0, q x) N, x < N x:Reala: hbound: c > 0, (n : ), a n chcauchy:(↑a).IsCauchyheq:x = LIM a(∃ q > 0, q x) N, x < N; x:Reala: hcauchy:(↑a).IsCauchyheq:x = LIM aq:hq:q > 0hbound: (n : ), a n q(∃ q > 0, q x) N, x < N x:Reala: hcauchy:(↑a).IsCauchyheq:x = LIM aq:hq:q > 0hbound: (n : ), a n qthis:?_mvar.836461 := Chapter5.Sequence.isBounded_of_isCauchy _fvar.836430(∃ q > 0, q x) N, x < N x:Reala: hcauchy:(↑a).IsCauchyheq:x = LIM aq:hq:q > 0hbound: (n : ), a n qthis: M 0, (↑a).BoundedBy M(∃ q > 0, q x) N, x < N; x:Reala: hcauchy:(↑a).IsCauchyheq:x = LIM aq:hq:q > 0hbound: (n : ), a n qr:hr:r 0this:(↑a).BoundedBy r(∃ q > 0, q x) N, x < N x:Reala: hcauchy:(↑a).IsCauchyheq:x = LIM aq:hq:q > 0hbound: (n : ), a n qr:hr:r 0this: (n : ), |if 0 n then a n.toNat else 0| r(∃ q > 0, q x) N, x < N x:Reala: hcauchy:(↑a).IsCauchyheq:x = LIM aq:hq:q > 0hbound: (n : ), a n qr:hr:r 0this: (n : ), |if 0 n then a n.toNat else 0| rq xx:Reala: hcauchy:(↑a).IsCauchyheq:x = LIM aq:hq:q > 0hbound: (n : ), a n qr:hr:r 0this: (n : ), |if 0 n then a n.toNat else 0| r N, x < N x:Reala: hcauchy:(↑a).IsCauchyheq:x = LIM aq:hq:q > 0hbound: (n : ), a n qr:hr:r 0this: (n : ), |if 0 n then a n.toNat else 0| rq x x:Reala: hcauchy:(↑a).IsCauchyheq:x = LIM aq:hq:q > 0hbound: (n : ), a n qr:hr:r 0this: (n : ), |if 0 n then a n.toNat else 0| rq = LIM fun x => q All goals completed! 🐙 x:Reala: hcauchy:(↑a).IsCauchyheq:x = LIM aq:hq:q > 0hbound: (n : ), a n qr:hr:r 0this: (n : ), |if 0 n then a n.toNat else 0| rN:hN:r < N N, x < N; x:Reala: hcauchy:(↑a).IsCauchyheq:x = LIM aq:hq:q > 0hbound: (n : ), a n qr:hr:r 0this: (n : ), |if 0 n then a n.toNat else 0| rN:hN:r < Nx < N calc x r := x:Reala: hcauchy:(↑a).IsCauchyheq:x = LIM aq:hq:q > 0hbound: (n : ), a n qr:hr:r 0this: (n : ), |if 0 n then a n.toNat else 0| rN:hN:r < Nx r x:Reala: hcauchy:(↑a).IsCauchyheq:x = LIM aq:hq:q > 0hbound: (n : ), a n qr:hr:r 0this: (n : ), |if 0 n then a n.toNat else 0| rN:hN:r < Nx LIM fun x => r x:Reala: hcauchy:(↑a).IsCauchyheq:x = LIM aq:hq:q > 0hbound: (n : ), a n qr:hr:r 0this: (n : ), |if 0 n then a n.toNat else 0| rN:hN:r < N (n : ), a n r x:Reala: hcauchy:(↑a).IsCauchyheq:x = LIM aq:hq:q > 0hbound: (n : ), a n qr:hr:r 0this: (n : ), |if 0 n then a n.toNat else 0| rN:hN:r < Nn:a n r; x:Reala: hcauchy:(↑a).IsCauchyheq:x = LIM aq:hq:q > 0hbound: (n : ), a n qr:hr:r 0N:hN:r < Nn:this:|if 0 n then a (↑n).toNat else 0| ra n r; x:Reala: hcauchy:(↑a).IsCauchyheq:x = LIM aq:hq:q > 0hbound: (n : ), a n qr:hr:r 0N:hN:r < Nn:this:|a n| ra n r All goals completed! 🐙 _ < ((N:):Real) := x:Reala: hcauchy:(↑a).IsCauchyheq:x = LIM aq:hq:q > 0hbound: (n : ), a n qr:hr:r 0this: (n : ), |if 0 n then a n.toNat else 0| rN:hN:r < Nr < N All goals completed! 🐙 _ = N := rfl

Corollary 5.4.13 (Archimedean property )

theorem Real.le_mul {ε:Real} (: ε.IsPos) (x:Real) : M:, M > 0 M * ε > x := ε:Real:ε.IsPosx:Real M > 0, M * ε > x -- This proof is written to follow the structure of the original text. ε:Real:ε.IsPos M > 0, M * ε > 0ε:Real:ε.IsPosx:Realhx:x.IsPos M > 0, M * ε > xε:Real:ε.IsPosx:Realhx:x.IsNeg M > 0, M * ε > x ε:Real:ε.IsPos M > 0, M * ε > 0 ε:Real:ε.IsPos1 > 0 1 * ε > 0; All goals completed! 🐙 ε:Real:ε.IsPosx:Realhx:x.IsPos M > 0, M * ε > x ε:Real:ε.IsPosx:Realhx:x.IsPosN:hN:x / ε < N M > 0, M * ε > x ε:Real:ε.IsPosx:Realhx:x.IsPosN:hN:x / ε < NM: := _fvar.851138 + 1 M > 0, M * ε > x; refine M, ε:Real:ε.IsPosx:Realhx:x.IsPosN:hN:x / ε < NM: := _fvar.851138 + 1M > 0 All goals completed! 🐙, ?_ replace hN : x/ε < M := hN.trans (ε:Real:ε.IsPosx:Realhx:x.IsPosN:hN:x / ε < NM: := _fvar.851138 + 1N < M All goals completed! 🐙) ε:Real:ε.IsPosx:Realhx:x.IsPosN:M: := _fvar.851138 + 1hN:_fvar.847982 / _fvar.847980 < _fvar.851227 := LT.lt.trans _fvar.851141 ?_mvar.853540x < M * ε ε:Real:ε.IsPosx:Realhx:x.IsPosN:M: := _fvar.851138 + 1hN:_fvar.847982 / _fvar.847980 < _fvar.851227 := LT.lt.trans _fvar.851141 ?_mvar.853540x = x / ε * ε ε:Real:ε > 0x:Realhx:x.IsPosN:M: := _fvar.859059 + 1hN:x / ε < Mx = x / ε * ε; All goals completed! 🐙 ε:Real:ε.IsPosx:Realhx:x.IsNeg1 > 0 1 * ε > x; ε:Realx:Real:0 < εhx:x < 0x < ε; All goals completed! 🐙

Proposition 5.4.14 / Exercise 5.4.5

theorem declaration uses 'sorry'Real.rat_between {x y:Real} (hxy: x < y) : q:, x < (q:Real) (q:Real) < y := x:Realy:Realhxy:x < y q, x < q q < y All goals completed! 🐙

Exercise 5.4.3

theorem declaration uses 'sorry'Real.floor_exist (x:Real) : ∃! n:, (n:Real) x x < (n:Real)+1 := x:Real∃! n, n x x < n + 1 All goals completed! 🐙

Exercise 5.4.4

theorem declaration uses 'sorry'Real.exist_inv_nat_le {x:Real} (hx: x.IsPos) : N:, N>0 (N:Real)⁻¹ < x := x:Realhx:x.IsPos N > 0, (↑N)⁻¹ < x All goals completed! 🐙

Exercise 5.4.6

theorem declaration uses 'sorry'Real.dist_lt_iff (ε x y:Real) : |x-y| < ε y-ε < x x < y+ε := ε:Realx:Realy:Real|x - y| < ε y - ε < x x < y + ε All goals completed! 🐙

Exercise 5.4.6

theorem declaration uses 'sorry'Real.dist_le_iff (ε x y:Real) : |x-y| ε y-ε x x y+ε := ε:Realx:Realy:Real|x - y| ε y - ε x x y + ε All goals completed! 🐙

Exercise 5.4.7

theorem declaration uses 'sorry'Real.le_add_eps_iff (x y:Real) : ( ε > 0, x y+ε) x y := x:Realy:Real(∀ ε > 0, x y + ε) x y All goals completed! 🐙

Exercise 5.4.7

theorem declaration uses 'sorry'Real.dist_le_eps_iff (x y:Real) : ( ε > 0, |x-y| ε) x = y := x:Realy:Real(∀ ε > 0, |x - y| ε) x = y All goals completed! 🐙

Exercise 5.4.8

theorem declaration uses 'sorry'Real.LIM_of_le {x:Real} {a: } (hcauchy: (a:Sequence).IsCauchy) (h: n, a n x) : LIM a x := x:Reala: hcauchy:(↑a).IsCauchyh: (n : ), (a n) xLIM a x All goals completed! 🐙

Exercise 5.4.8

theorem declaration uses 'sorry'Real.LIM_of_ge {x:Real} {a: } (hcauchy: (a:Sequence).IsCauchy) (h: n, a n x) : LIM a x := x:Reala: hcauchy:(↑a).IsCauchyh: (n : ), (a n) xLIM a x All goals completed! 🐙
theorem Real.max_eq (x y:Real) : max x y = if x y then x else y := max_def' x ytheorem Real.min_eq (x y:Real) : min x y = if x y then x else y := rfl

Exercise 5.4.9

theorem declaration uses 'sorry'Real.neg_max (x y:Real) : max x y = - min (-x) (-y) := x:Realy:Realmax x y = -min (-x) (-y) All goals completed! 🐙

Exercise 5.4.9

theorem declaration uses 'sorry'Real.neg_min (x y:Real) : min x y = - max (-x) (-y) := x:Realy:Realmin x y = -max (-x) (-y) All goals completed! 🐙

Exercise 5.4.9

theorem declaration uses 'sorry'Real.max_comm (x y:Real) : max x y = max y x := x:Realy:Realmax x y = max y x All goals completed! 🐙

Exercise 5.4.9

theorem declaration uses 'sorry'Real.max_self (x:Real) : max x x = x := x:Realmax x x = x All goals completed! 🐙

Exercise 5.4.9

theorem declaration uses 'sorry'Real.max_add (x y z:Real) : max (x + z) (y + z) = max x y + z := x:Realy:Realz:Realmax (x + z) (y + z) = max x y + z All goals completed! 🐙

Exercise 5.4.9

theorem declaration uses 'sorry'Real.max_mul (x y :Real) {z:Real} (hz: z.IsPos) : max (x * z) (y * z) = max x y * z := x:Realy:Realz:Realhz:z.IsPosmax (x * z) (y * z) = max x y * z All goals completed! 🐙
/- Additional exercise: What happens if z is negative? -/

Exercise 5.4.9

theorem declaration uses 'sorry'Real.min_comm (x y:Real) : min x y = min y x := x:Realy:Realmin x y = min y x All goals completed! 🐙

Exercise 5.4.9

theorem declaration uses 'sorry'Real.min_self (x:Real) : min x x = x := x:Realmin x x = x All goals completed! 🐙

Exercise 5.4.9

theorem declaration uses 'sorry'Real.min_add (x y z:Real) : min (x + z) (y + z) = min x y + z := x:Realy:Realz:Realmin (x + z) (y + z) = min x y + z All goals completed! 🐙

Exercise 5.4.9

theorem declaration uses 'sorry'Real.min_mul (x y :Real) {z:Real} (hz: z.IsPos) : min (x * z) (y * z) = min x y * z := x:Realy:Realz:Realhz:z.IsPosmin (x * z) (y * z) = min x y * z All goals completed! 🐙

Exercise 5.4.9

theorem declaration uses 'sorry'Real.inv_max {x y :Real} (hx:x.IsPos) (hy:y.IsPos) : (max x y)⁻¹ = min x⁻¹ y⁻¹ := x:Realy:Realhx:x.IsPoshy:y.IsPos(max x y)⁻¹ = min x⁻¹ y⁻¹ All goals completed! 🐙

Exercise 5.4.9

theorem declaration uses 'sorry'Real.inv_min {x y :Real} (hx:x.IsPos) (hy:y.IsPos) : (min x y)⁻¹ = max x⁻¹ y⁻¹ := x:Realy:Realhx:x.IsPoshy:y.IsPos(min x y)⁻¹ = max x⁻¹ y⁻¹ All goals completed! 🐙

Not from textbook: the rationals map as an ordered ring homomorphism into the reals.

abbrev declaration uses 'sorry'Real.ratCast_ordered_hom : →+*o Real where toRingHom := ratCast_hom monotone' := Monotone (↑ratCast_hom).toFun All goals completed! 🐙
end Chapter5