Imports
import Mathlib.Tactic import Mathlib.Analysis.SpecialFunctions.Trigonometric.Basic import Mathlib.Analysis.SpecialFunctions.Trigonometric.Deriv

Analysis I, Appendix A.6: Some examples of proofs and quantifiers

Some examples of proofs and quantifiers in Lean

/-- Proposition A.6.1 -/ example : ε > (0:), δ > 0, 2 * δ < ε := ε > 0, δ > 0, 2 * δ < ε intro ε ε::ε > 0 δ > 0, 2 * δ < ε ε::ε > 0ε / 3 > 0 2 * (ε / 3) < ε ε::ε > 0ε / 3 > 0ε::ε > 02 * (ε / 3) < ε ε::ε > 0ε / 3 > 0 All goals completed! 🐙 ε::ε > 02 * (ε / 3) < ε All goals completed! 🐙declaration uses `sorry`example : ¬ δ > 0, ε > (0:), 2 * δ < ε := ¬ δ > 0, ε > 0, 2 * δ < ε All goals completed! 🐙open Real in /-- Proposition A.6.2. The proof below is somewhat non-idiomatic for Lean, but illustrates how to implement a "let ε be a quantity to be chosen later" type of proof. -/ example : ε > 0, x, 0 < x x < ε sin x > x / 2 := ε > 0, (x : ), 0 < x x < ε sin x > x / 2 ?eps > 0 (x : ), 0 < x x < ?eps sin x > x / 2 -- we will choose this later ?eps > 0 (x : ), 0 < x x < ?eps sin x > x / 2 (x : ), 0 < x x < ?eps sin x > x / 2?eps > 0 -- defer the checking of positivity until later x:hpos:0 < xhx:x < ?epssin x > x / 2?eps > 0 have hderiv : deriv sin = cos := ε > 0, (x : ), 0 < x x < ε sin x > x / 2 x✝:hpos:0 < xhx:x < ?epsx:deriv sin x = cos x x✝:hpos:0 < xhx:x < ?epsx:HasDerivAt sin (cos x) x All goals completed! 🐙 have := exists_deriv_eq_slope sin hpos (x:hpos:0 < xhx:x < ?epshderiv:deriv sin = cosContinuousOn sin (Set.Icc 0 x) All goals completed! 🐙) (x:hpos:0 < xhx:x < ?epshderiv:deriv sin = cosDifferentiableOn sin (Set.Ioo 0 x) All goals completed! 🐙) x:hpos:0 < xhx:x < ?epshderiv:deriv sin = costhis: c, (0 < c c < x) cos c = sin x / xsin x > x / 2?eps > 0 x:hpos:0 < xhx:x < ?epshderiv:deriv sin = cosy:hy3:cos y = sin x / xhy1:0 < yhy2:y < xsin x > x / 2?eps > 0 x:hpos:0 < xhx:x < ?epshderiv:deriv sin = cosy:hy3:cos y = sin x / xhy1:0 < yhy2:y < xhcosy:cos y > 1 / 2sin x > x / 2x:hpos:0 < xhx:x < ?epshderiv:deriv sin = cosy:hy3:cos y = sin x / xhy1:0 < yhy2:y < xcos y > 1 / 2?eps > 0 x:hpos:0 < xhx:x < ?epshderiv:deriv sin = cosy:hy3:cos y = sin x / xhy1:0 < yhy2:y < xhcosy:cos y > 1 / 2sin x > x / 2 x:hpos:0 < xhx:x < ?epshderiv:deriv sin = cosy:hy3:cos y = sin x / xhy1:0 < yhy2:y < xhcosy:x * (1 / 2) < x * (sin x / x)sin x > x / 2 x:hpos:0 < xhx:x < ?epshderiv:deriv sin = cosy:hy3:cos y = sin x / xhy1:0 < yhy2:y < xhcosy:x * (1 / 2) < x * (sin x / x)x / 2 < sin x x:hpos:0 < xhx:x < ?epshderiv:deriv sin = cosy:hy3:cos y = sin x / xhy1:0 < yhy2:y < xhcosy:x * (1 / 2) < x * (sin x / x)x / 2 = x * (1 / 2)x:hpos:0 < xhx:x < ?epshderiv:deriv sin = cosy:hy3:cos y = sin x / xhy1:0 < yhy2:y < xhcosy:x * (1 / 2) < x * (sin x / x)sin x = x * (sin x / x) x:hpos:0 < xhx:x < ?epshderiv:deriv sin = cosy:hy3:cos y = sin x / xhy1:0 < yhy2:y < xhcosy:x * (1 / 2) < x * (sin x / x)x / 2 = x * (1 / 2) All goals completed! 🐙 All goals completed! 🐙 x:hpos:0 < xhx:x < ?epshderiv:deriv sin = cosy:hy3:cos y = sin x / xhy1:0 < yhy2:y < xybound:y < π / 3cos y > 1 / 2x:hpos:0 < xhx:x < ?epshderiv:deriv sin = cosy:hy3:cos y = sin x / xhy1:0 < yhy2:y < xy < π / 3?eps > 0 x:hpos:0 < xhx:x < ?epshderiv:deriv sin = cosy:hy3:cos y = sin x / xhy1:0 < yhy2:y < xybound:y < π / 3cos y > 1 / 2 have := cos_lt_cos_of_nonneg_of_le_pi (le_of_lt hy1) (x:hpos:0 < xhx:x < ?epshderiv:deriv sin = cosy:hy3:cos y = sin x / xhy1:0 < yhy2:y < xybound:y < π / 3π / 3 π All goals completed! 🐙) ybound x:hpos:0 < xhx:x < ?epshderiv:deriv sin = cosy:hy3:cos y = sin x / xhy1:0 < yhy2:y < xybound:y < π / 3this:cos y > 1 / 2cos y > 1 / 2 All goals completed! 🐙 have : y < ?eps := ε > 0, (x : ), 0 < x x < ε sin x > x / 2 All goals completed! 🐙 x:hpos:0 < xhx:x < ?epshderiv:deriv sin = cosy:hy3:cos y = sin x / xhy1:0 < yhy2:y < xthis:y < ?epsy < π / 3?eps > 0 -- Now it is time to pick ε All goals completed! 🐙 x:hpos:0 < xhx:x < ?epshderiv:deriv sin = cosy:hy3:cos y = sin x / xhy1:0 < yhy2:y < xthis:y < ?epsy < π / 3 All goals completed! 🐙 All goals completed! 🐙open Real in /-- Proposition A.6.2: a more idiomatic proof -/ example : ε > 0, x, 0 < x x < ε sin x > x / 2 := ε > 0, (x : ), 0 < x x < ε sin x > x / 2 use π/3, π / 3 > 0 All goals completed! 🐙 intro x x:hpos:0 < xhx:x < π / 3sin x > x / 2 have hderiv : deriv sin = cos := ε > 0, (x : ), 0 < x x < ε sin x > x / 2 x✝:hpos:0 < xhx:x < π / 3x:deriv sin x = cos x x✝:hpos:0 < xhx:x < π / 3x:HasDerivAt sin (cos x) x All goals completed! 🐙 have := exists_deriv_eq_slope sin hpos (x:hpos:0 < xhx:x < π / 3hderiv:deriv sin = cosContinuousOn sin (Set.Icc 0 x) All goals completed! 🐙) (x:hpos:0 < xhx:x < π / 3hderiv:deriv sin = cosDifferentiableOn sin (Set.Ioo 0 x) All goals completed! 🐙) x:hpos:0 < xhx:x < π / 3hderiv:deriv sin = costhis: c, (0 < c c < x) cos c = sin x / xsin x > x / 2 x:hpos:0 < xhx:x < π / 3hderiv:deriv sin = cosy:hy3:cos y = sin x / xhy1:0 < yhy2:y < xsin x > x / 2 have ybound : y < π/3 := ε > 0, (x : ), 0 < x x < ε sin x > x / 2 All goals completed! 🐙 have hcosy := cos_lt_cos_of_nonneg_of_le_pi (le_of_lt hy1) (x:hpos:0 < xhx:x < π / 3hderiv:deriv sin = cosy:hy3:cos y = sin x / xhy1:0 < yhy2:y < xybound:y < π / 3π / 3 π All goals completed! 🐙) ybound x:hpos:0 < xhx:x < π / 3hderiv:deriv sin = cosy:hy3:cos y = sin x / xhy1:0 < yhy2:y < xybound:y < π / 3hcosy:cos y > 1 / 2sin x > x / 2 x:hpos:0 < xhx:x < π / 3hderiv:deriv sin = cosy:hy3:cos y = sin x / xhy1:0 < yhy2:y < xybound:y < π / 3hcosy:x * (1 / 2) < x * (sin x / x)sin x > x / 2 x:hpos:0 < xhx:x < π / 3hderiv:deriv sin = cosy:hy3:cos y = sin x / xhy1:0 < yhy2:y < xybound:y < π / 3hcosy:x * (1 / 2) < x * (sin x / x)x / 2 < sin x x:hpos:0 < xhx:x < π / 3hderiv:deriv sin = cosy:hy3:cos y = sin x / xhy1:0 < yhy2:y < xybound:y < π / 3hcosy:x * (1 / 2) < x * (sin x / x)x / 2 = x * (1 / 2)x:hpos:0 < xhx:x < π / 3hderiv:deriv sin = cosy:hy3:cos y = sin x / xhy1:0 < yhy2:y < xybound:y < π / 3hcosy:x * (1 / 2) < x * (sin x / x)sin x = x * (sin x / x) x:hpos:0 < xhx:x < π / 3hderiv:deriv sin = cosy:hy3:cos y = sin x / xhy1:0 < yhy2:y < xybound:y < π / 3hcosy:x * (1 / 2) < x * (sin x / x)x / 2 = x * (1 / 2) All goals completed! 🐙 All goals completed! 🐙