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

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

namespace VariableExample1variable (X:Type) (x y:X)x = x : Prop#check x = x
x = x : Prop
x = y : Prop#check x = y
x = y : Prop
-- #check x+y = y+x -- тут не будуть перевірятися типи end VariableExample1namespace VariableExample2variable (x:)x + 3 : ℝ#check x+3
x + 3 : ℝ
x + 3 = 5 : Prop#check x+3 = 5
x + 3 = 5 : Prop
example (h: x = 2) : x + 3 = 5 := x:h:x = 2x + 3 = 5 All goals completed! 🐙example (h: x 2) : x + 3 5 := x:h:x 2x + 3 5 x:h:x + 3 = 5x = 2 All goals completed! 🐙example : ¬ (x:), x + 3 = 5 := x:¬ (x : ), x + 3 = 5 x: x, ¬x + 3 = 5 x:¬0 + 3 = 5 All goals completed! 🐙example : ¬ (x:), x + 3 5 := x:¬ (x : ), x + 3 5 x: x, x + 3 = 5 x:2 + 3 = 5 All goals completed! 🐙example : (x:), x + 3 = 5 := x: x, x + 3 = 5 x:2 + 3 = 5 All goals completed! 🐙example : (x:), (x+1)^2 = x^2 + 2*x + 1 := x: (x : ), (x + 1) ^ 2 = x ^ 2 + 2 * x + 1 x✝:x:(x + 1) ^ 2 = x ^ 2 + 2 * x + 1 All goals completed! 🐙end VariableExample2

Для цього прикладу тут використовується фіктивне твердження.

example : 0 = 0 := 0 = 0 x: := 3420 = 0 have : x + 155 = 497 := 0 = 0 x: := 342342 + 155 = 497 All goals completed! 🐙 All goals completed! 🐙
example : ¬ (x:), x + 155 = 497 := ¬ (x : ), x + 155 = 497 x, ¬x + 155 = 497 ¬0 + 155 = 497 All goals completed! 🐙example : ¬ x > (0:), x^2 > x := ¬ x > 0, x ^ 2 > x x, 0 < x x ^ 2 x 0 < 0.5 0.5 ^ 2 0.5 All goals completed! 🐙/- Наведений нижче код не перевірятиме тип. example : ∀ (x:ℝ), x + 3 = 5 := by use 2 sorry -/ example : x, (3 < x x < 2) (6 < 2*x 2*x < 4) := (x : ), 3 < x x < 2 6 < 2 * x 2 * x < 4 x:3 < x x < 2 6 < 2 * x 2 * x < 4 x:h:3 < x x < 26 < 2 * x 2 * x < 4 x:h1:3 < xh2:x < 26 < 2 * x 2 * x < 4 -- попередні три рядки можна забуцкати в `rintro x ⟨ h1, h2 ⟩` x:h1:3 < xh2:x < 26 < 2 * xx:h1:3 < xh2:x < 22 * x < 4 x:h1:3 < xh2:x < 26 < 2 * x All goals completed! 🐙 All goals completed! 🐙example : (x:), x^2 + 2*x - 8 = 0 := x, x ^ 2 + 2 * x - 8 = 0 2 ^ 2 + 2 * 2 - 8 = 0 All goals completed! 🐙example : ¬ x, (3 < x x < 2) (6 < 2*x 2*x < 4) := ¬ x, (3 < x x < 2) 6 < 2 * x 2 * x < 4 (x : ), 3 < x x < 2 6 < 2 * x 4 2 * x x:h1:3 < xh2:x < 2h3:6 < 2 * x4 2 * x All goals completed! 🐙