Analysis I, Appendix A.5: Nested quantifiers

Some examples of nested quantifiers in Lean

example : x > (0:), y > 0, y^2 = x := x > 0, y > 0, y ^ 2 = x x:hx:x > 0 y > 0, y ^ 2 = x x:hx:x > 0x > 0 x ^ 2 = x x:hx:x > 0x > 0x:hx:x > 0x ^ 2 = x x:hx:x > 0x > 0 All goals completed! 🐙 x:hx:x > 00 x All goals completed! 🐙namespace SwanExamplevariable (Swans:Type)variable (isBlack : Swans Prop)example : (¬ s:Swans, isBlack s) = ( s:Swans, ¬ isBlack s) := Swans:TypeisBlack:Swans Prop(¬ (s : Swans), isBlack s) = s, ¬isBlack s All goals completed! 🐙example : (¬ s:Swans, isBlack s) = ( s:Swans, ¬ isBlack s) := Swans:TypeisBlack:Swans Prop(¬ s, isBlack s) = (s : Swans), ¬isBlack s All goals completed! 🐙end SwanExampleexample : (¬ x, (0 < x x < Real.pi/2) Real.cos x 0) = ( x, (0 < x x < Real.pi/2) Real.cos x < 0) := (¬ (x : ), 0 < x x < Real.pi / 2 Real.cos x 0) = x, (0 < x x < Real.pi / 2) Real.cos x < 0 (∃ x, 0 < x x < Real.pi / 2 Real.cos x < 0) x, (0 < x x < Real.pi / 2) Real.cos x < 0 All goals completed! 🐙example : (¬ x:, x^2 + x + 1 = 0) = ( x:, x^2 + x + 1 0) := (¬ x, x ^ 2 + x + 1 = 0) = (x : ), x ^ 2 + x + 1 0 All goals completed! 🐙theorem square_expand : (x:), (x + 1)^2 = x^2 + 2 * x + 1 := (x : ), (x + 1) ^ 2 = x ^ 2 + 2 * x + 1 x:(x + 1) ^ 2 = x ^ 2 + 2 * x + 1 All goals completed! 🐙example : (Real.pi+1)^2 = Real.pi^2 + 2 * Real.pi + 1 := (Real.pi + 1) ^ 2 = Real.pi ^ 2 + 2 * Real.pi + 1 All goals completed! 🐙 -- one can also use `exact square_expand _`example : (y:), (Real.cos y + 1)^2 = Real.cos y^2 + 2 * Real.cos y + 1 := (y : ), (Real.cos y + 1) ^ 2 = Real.cos y ^ 2 + 2 * Real.cos y + 1 y:(Real.cos y + 1) ^ 2 = Real.cos y ^ 2 + 2 * Real.cos y + 1 All goals completed! 🐙theorem solve_quadratic : (x:), x^2 + 2 * x - 8 = 0 := x, x ^ 2 + 2 * x - 8 = 0 2 ^ 2 + 2 * 2 - 8 = 0 All goals completed! 🐙/- The following proof will not typecheck. example : Real.pi^2 + 2 * Real.pi - 8 = 0 := by apply solve_quadratic -/ namespace Remark_A_5_1variable (Man : Type)variable (Mortal : Man Prop)example (premise : m : Man, Mortal m) (Socrates : Man) : Mortal Socrates := Man:TypeMortal:Man Proppremise: (m : Man), Mortal mSocrates:ManMortal Socrates All goals completed! 🐙 -- `exact premise Socrates` would also workend Remark_A_5_1example : ( a:, b:, (a+b)^2 = a^2 + 2*a*b + b^2) = ( b:, a:, (a+b)^2 = a^2 + 2*a*b + b^2) := (∀ (a b : ), (a + b) ^ 2 = a ^ 2 + 2 * a * b + b ^ 2) = (b a : ), (a + b) ^ 2 = a ^ 2 + 2 * a * b + b ^ 2 All goals completed! 🐙example : ( a:, b:, a^2 + b^2 = 0) = ( b:, a:, a^2 + b^2 = 0) := (∃ a b, a ^ 2 + b ^ 2 = 0) = b a, a ^ 2 + b ^ 2 = 0 All goals completed! 🐙example : n:, m:, m > n := (n : ), m, m > n n: m, m > n n:n + 1 > n All goals completed! 🐙example : ¬ m:, n:, m > n := ¬ m, (n : ), m > n h: m, (n : ), m > nFalse m:hm: (n : ), m > nFalse -- `obtain ⟨m, hm⟩ := h` would also work here m:hm:m > m + 1False All goals completed! 🐙

Exercise A.5.1

def declaration uses 'sorry'Exercise_A_5_1a : Decidable ( x > (0:), y > (0:), y^2 = x ) := Decidable (∀ x > 0, y > 0, y ^ 2 = x) -- the first line of this construction should be either `apply isTrue` or `apply isFalse`. All goals completed! 🐙
def declaration uses 'sorry'Exercise_A_5_1b : Decidable ( x > (0:), y > (0:), y^2 = x ) := Decidable (∃ x > 0, y > 0, y ^ 2 = x) -- the first line of this construction should be either `apply isTrue` or `apply isFalse`. All goals completed! 🐙def declaration uses 'sorry'Exercise_A_5_1c : Decidable ( x > (0:), y > (0:), y^2 = x ) := Decidable (∃ x > 0, y > 0, y ^ 2 = x) -- the first line of this construction should be either `apply isTrue` or `apply isFalse`. All goals completed! 🐙def declaration uses 'sorry'Exercise_A_5_1d : Decidable ( y > (0:), x > (0:), y^2 = x ) := Decidable (∀ y > 0, x > 0, y ^ 2 = x) -- the first line of this construction should be either `apply isTrue` or `apply isFalse`. All goals completed! 🐙def declaration uses 'sorry'Exercise_A_5_1e : Decidable ( y > (0:), x > (0:), y^2 = x ) := Decidable (∃ y > 0, x > 0, y ^ 2 = x) -- the first line of this construction should be either `apply isTrue` or `apply isFalse`. All goals completed! 🐙