2014-05-21 18:24:24 +00:00
|
|
|
local env = bare_environment()
|
2014-07-22 16:43:18 +00:00
|
|
|
env = add_decl(env, mk_var_decl("A", Prop))
|
2014-05-15 21:17:58 +00:00
|
|
|
env = add_decl(env, mk_var_decl("T", Type))
|
2014-07-22 16:43:18 +00:00
|
|
|
env = add_decl(env, mk_definition("B2", Type, Prop, {opaque=false}))
|
2014-05-15 21:17:58 +00:00
|
|
|
env = add_decl(env, mk_var_decl("C", Const("B2")))
|
2014-07-22 16:43:18 +00:00
|
|
|
env = add_decl(env, mk_definition("BB", Type, mk_arrow(Prop, Prop), {opaque=false}))
|
2014-05-15 21:17:58 +00:00
|
|
|
local tc = type_checker(env)
|
|
|
|
assert(tc:is_prop(Const("A")))
|
|
|
|
assert(tc:is_prop(Const("C")))
|
|
|
|
assert(not tc:is_prop(Const("T")))
|
|
|
|
assert(not tc:is_prop(Const("B2")))
|
2014-06-26 20:35:36 +00:00
|
|
|
print(tc:check(mk_lambda("x", mk_metavar("m", mk_metavar("t", mk_sort(mk_meta_univ("l")))), Var(0))))
|
2014-05-15 21:17:58 +00:00
|
|
|
print(tc:ensure_sort(Const("B2")))
|
|
|
|
assert(not pcall(function()
|
|
|
|
print(tc:ensure_sort(Const("A")))
|
|
|
|
end
|
|
|
|
))
|
|
|
|
print(tc:ensure_pi(Const("BB")))
|
|
|
|
assert(not pcall(function()
|
|
|
|
print(tc:ensure_pi(Const("A")))
|
|
|
|
end
|
|
|
|
))
|
|
|
|
assert(not pcall(function()
|
2014-07-22 16:43:18 +00:00
|
|
|
env = add_decl(env, mk_var_decl("A", mk_local("l1", Prop)))
|
2014-05-15 21:17:58 +00:00
|
|
|
end
|
|
|
|
))
|
|
|
|
assert(not pcall(function()
|
|
|
|
print(tc:check(Let("x", Type, Const("A"), Var(0))))
|
|
|
|
end
|
|
|
|
))
|
|
|
|
assert(not pcall(function()
|
2014-07-22 16:43:18 +00:00
|
|
|
print(tc:check(mk_lambda("x", Prop, Var(0))(Type)))
|
2014-05-15 21:17:58 +00:00
|
|
|
end
|
|
|
|
))
|
|
|
|
assert(not pcall(function()
|
|
|
|
print(tc:check(Var(0)))
|
|
|
|
end
|
|
|
|
))
|
|
|
|
|
2014-07-22 16:43:18 +00:00
|
|
|
assert(tc:check(mk_pi("x", Prop, Var(0))) == Prop)
|
2014-05-15 21:17:58 +00:00
|
|
|
|
2014-05-21 18:24:24 +00:00
|
|
|
local env = bare_environment({impredicative=false})
|
2014-05-15 21:17:58 +00:00
|
|
|
local tc = type_checker(env)
|
2014-07-22 16:43:18 +00:00
|
|
|
assert(tc:check(mk_pi("x", Prop, Var(0))) == Type)
|