2013-11-18 17:27:46 +00:00
|
|
|
local env = environment()
|
2014-01-01 21:52:25 +00:00
|
|
|
env:import("Int")
|
2014-01-09 16:33:52 +00:00
|
|
|
env:add_uvar_cnstr("M", level(level(), 1))
|
2014-01-07 00:46:11 +00:00
|
|
|
env:add_uvar_cnstr("Z", level(level("M"), 1))
|
2013-11-18 17:27:46 +00:00
|
|
|
assert(env:is_ge(level("Z"), level("M")))
|
|
|
|
local child = env:mk_child()
|
|
|
|
assert(env:has_children())
|
|
|
|
assert(child:has_parent())
|
|
|
|
child:add_var("x", Const("Int"))
|
|
|
|
for o in child:local_objects() do
|
|
|
|
assert(o:get_name() == name("x"))
|
|
|
|
print(o)
|
|
|
|
end
|
|
|
|
local eenv = empty_environment()
|
2013-12-08 22:37:38 +00:00
|
|
|
print(not eenv:find_object("Int"))
|
2013-11-18 17:27:46 +00:00
|
|
|
assert(not pcall(function() env:parent() end))
|
|
|
|
local p = child:parent()
|
|
|
|
assert(p:has_children())
|
2014-01-07 00:46:11 +00:00
|
|
|
assert(not pcall(function() env:add_uvar_cnstr("Z") end))
|
|
|
|
child:add_uvar_cnstr("Z")
|
|
|
|
assert(not pcall(function() child:add_uvar_cnstr("M", level("Z")) end))
|
2013-11-18 17:27:46 +00:00
|
|
|
child:add_definition("val1", Const("true"), true)
|
|
|
|
child:add_definition("val2", Const("Bool"), Const("true"), true)
|
|
|
|
local ok, msg = pcall(function() child:add_definition("val3", Const("Int"), Const("true"), true) end)
|
|
|
|
assert(not ok)
|
|
|
|
print(msg)
|
|
|
|
assert(child:normalize(Const("val2")) == Const("val2"))
|
2014-01-16 23:07:51 +00:00
|
|
|
local Int = Const("Int")
|
|
|
|
child:add_theorem("Th1", mk_eq(Int, iVal(0), iVal(0)), Const("trivial"))
|
|
|
|
child:add_axiom("H1", mk_eq(Int, Const("x"), iVal(0)))
|
2013-11-18 17:27:46 +00:00
|
|
|
assert(child:has_object("H1"))
|
|
|
|
local ctx = context(context(), "x", Const("Int"), iVal(10))
|
|
|
|
assert(child:normalize(Var(0), ctx) == iVal(10))
|
2013-12-22 19:51:38 +00:00
|
|
|
assert(child:type_check(Var(0), ctx) == Const("Int"))
|