lean2/tests/lua/is_prop1.lua
Leonardo de Moura 94fa987814 fix(kernel/type_checker): is_proposition method was still assuming that a Pi never has type Bool
The method is_proposition was using an optimization that became incorrect after  we identified Pi and forall.
It was assuming that any Pi expression is not a proposition.
This is not true anymore. Now, (Pi x : A, B) is a proposition if B is a proposition.

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-15 11:02:52 -08:00

27 lines
1.1 KiB
Lua

local env = get_environment()
assert(env:is_proposition(Const("true")))
assert(env:is_proposition(Const("false")))
assert(not env:is_proposition(nVal(0)))
assert(env:is_proposition(parse_lean([[forall x : Nat, x > 0]])))
parse_lean_cmds([[
variable f : Nat -> Nat -> Nat
variable p : Nat -> Bool
variables a b c : Nat
definition B := Bool
variable q : B
]])
assert(env:is_proposition(parse_lean([[p (f a 0)]])))
assert(env:is_proposition(parse_lean([[p (f a 0) /\ a > 0]])))
assert(not env:is_proposition(parse_lean([[fun x, p (f x 0) /\ a > 0]])))
assert(env:is_proposition(parse_lean([[forall x : Bool, x]])))
assert(not env:is_proposition(parse_lean([[forall x : Nat, Nat]])))
assert(not env:is_proposition(parse_lean([[forall T : Type, T]])))
assert(env:is_proposition(parse_lean([[forall x y z, x /\ z /\ y]])))
assert(env:is_proposition(parse_lean([[true -> false]])))
assert(env:is_proposition(parse_lean([[Nat -> false]])))
assert(not env:is_proposition(parse_lean([[true -> Nat]])))
assert(not env:is_proposition(parse_lean([[Type]])))
assert(env:is_proposition(parse_lean([[0 == 1]])))
assert(env:is_proposition(parse_lean([[q]])))