Аналіз I, Додаток A.6

Деякі приклади доказів та квантифікаторів у Lean

Твердження A.6.1

example : ε > (0:), δ > 0, 2 * δ < ε := ε > 0, δ > 0, 2 * δ < ε ε::ε > 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 /-- Твердження A.6.2. Наведений нижче доказ є дещо не ідіоматичним для Lean, але ілюструє, як реалізувати доказ типу "нехай ε буде величиною, яку буде обрано пізніше". -/ 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 -- ми оберемо це пізніше ?eps > 0 (x : ), 0 < x x < ?eps sin x > x / 2 (x : ), 0 < x x < ?eps sin x > x / 2?eps > 0 -- відкласти перевірку позитивності на потім x:hx:0 < x x < ?epssin x > x / 2?eps > 0 x:hx:0 < x x < ?epshpos:0 < xsin x > x / 2?eps > 0 have hderiv : deriv sin = cos := ε > 0, (x : ), 0 < x x < ε sin x > x / 2 x✝:hx:0 < x✝ x✝ < ?epshpos:0 < x✝x:deriv sin x = cos x x✝:hx:0 < x✝ x✝ < ?epshpos:0 < x✝x:HasDerivAt sin (cos x) x All goals completed! 🐙 have := exists_deriv_eq_slope sin hpos (x:hx:0 < x x < ?epshpos:0 < xhderiv:deriv sin = cosContinuousOn sin (Set.Icc 0 x) All goals completed! 🐙) (x:hx:0 < x x < ?epshpos:0 < xhderiv:deriv sin = cosDifferentiableOn sin (Set.Ioo 0 x) All goals completed! 🐙) x:hx:0 < x x < ?epshpos:0 < xhderiv:deriv sin = costhis: c, (0 < c c < x) cos c = sin x / xsin x > x / 2?eps > 0 x:hx:0 < x x < ?epshpos:0 < xhderiv:deriv sin = cosy:hy3:cos y = sin x / xhy1:0 < yhy2:y < xsin x > x / 2?eps > 0 x:hx:0 < x x < ?epshpos:0 < xhderiv:deriv sin = cosy:hy3:cos y = sin x / xhy1:0 < yhy2:y < xhcosy:cos y > 1 / 2sin x > x / 2x:hx:0 < x x < ?epshpos:0 < xhderiv:deriv sin = cosy:hy3:cos y = sin x / xhy1:0 < yhy2:y < xcos y > 1 / 2?eps > 0 x:hx:0 < x x < ?epshpos:0 < xhderiv:deriv sin = cosy:hy3:cos y = sin x / xhy1:0 < yhy2:y < xhcosy:cos y > 1 / 2sin x > x / 2 x:hx:0 < x x < ?epshpos:0 < xhderiv: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:hx:0 < x x < ?epshpos:0 < xhderiv: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:hx:0 < x x < ?epshpos:0 < xhderiv: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:hx:0 < x x < ?epshpos:0 < xhderiv: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:hx:0 < x x < ?epshpos:0 < xhderiv: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:hx:0 < x x < ?epshpos:0 < xhderiv:deriv sin = cosy:hy3:cos y = sin x / xhy1:0 < yhy2:y < xybound:y < π / 3cos y > 1 / 2x:hx:0 < x x < ?epshpos:0 < xhderiv:deriv sin = cosy:hy3:cos y = sin x / xhy1:0 < yhy2:y < xy < π / 3?eps > 0 x:hx:0 < x x < ?epshpos:0 < xhderiv: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:hx:0 < x x < ?epshpos:0 < xhderiv:deriv sin = cosy:hy3:cos y = sin x / xhy1:0 < yhy2:y < xybound:y < π / 3π / 3 π All goals completed! 🐙) ybound x:hx:0 < x x < ?epshpos:0 < xhderiv: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:hx:0 < x x < ?epshpos:0 < xhderiv:deriv sin = cosy:hy3:cos y = sin x / xhy1:0 < yhy2:y < xthis:y < ?epsy < π / 3?eps > 0 -- Тепер час підібрати ε All goals completed! 🐙 π / 3 > 0 All goals completed! 🐙open Real in /-- Твердження A.6.2: більш ідіоматичний доказ -/ 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! 🐙 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 < x✝hx:x✝ < π / 3x:deriv sin x = cos x x✝:hpos:0 < x✝hx: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! 🐙