Аналіз I, Додаток A.6
Деякі приклади доказів та квантифікаторів у Lean
Твердження A.6.1
example : ∀ ε > (0:ℝ), ∃ δ > 0, 2 * δ < ε := ⊢ ∀ ε > 0, ∃ δ > 0, 2 * δ < ε
ε:ℝhε:ε > 0⊢ ∃ δ > 0, 2 * δ < ε
ε:ℝhε:ε > 0⊢ ε / 3 > 0 ∧ 2 * (ε / 3) < ε
ε:ℝhε:ε > 0⊢ ε / 3 > 0ε:ℝhε:ε > 0⊢ 2 * (ε / 3) < ε
ε:ℝhε:ε > 0⊢ ε / 3 > 0 All goals completed! 🐙
ε:ℝhε:ε > 0⊢ 2 * (ε / 3) < ε All goals completed! 🐙
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 < ?eps⊢ sin x > x / 2⊢ ?eps > 0⊢ ℝ
x:ℝhx:0 < x ∧ x < ?epshpos:0 < x⊢ sin 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 = cos⊢ ContinuousOn sin (Set.Icc 0 x) All goals completed! 🐙) (x:ℝhx:0 < x ∧ x < ?epshpos:0 < xhderiv:deriv sin = cos⊢ DifferentiableOn ℝ 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 / x⊢ sin 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 < x⊢ sin 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 / 2⊢ sin x > x / 2x:ℝhx:0 < x ∧ x < ?epshpos:0 < xhderiv:deriv sin = cosy:ℝhy3:cos y = sin x / xhy1:0 < yhy2:y < x⊢ cos 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 / 2⊢ 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)⊢ 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 < π / 3⊢ cos y > 1 / 2x:ℝhx:0 < x ∧ x < ?epshpos:0 < xhderiv:deriv sin = cosy:ℝhy3:cos y = sin x / xhy1:0 < yhy2:y < x⊢ y < π / 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 < π / 3⊢ cos 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 / 2⊢ cos 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 < ?eps⊢ y < π / 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 < π / 3⊢ sin 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 = cos⊢ ContinuousOn sin (Set.Icc 0 x) All goals completed! 🐙) (x:ℝhpos:0 < xhx:x < π / 3hderiv:deriv sin = cos⊢ DifferentiableOn ℝ 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 / x⊢ sin x > x / 2
x:ℝhpos:0 < xhx:x < π / 3hderiv:deriv sin = cosy:ℝhy3:cos y = sin x / xhy1:0 < yhy2:y < x⊢ sin 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 / 2⊢ 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)⊢ 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! 🐙