lean2/tests/lua/cnstr1.lua
Leonardo de Moura dc627c9965 test(lua): add constraint API tests, and fix minor bugs
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-05-02 13:37:46 -07:00

35 lines
987 B
Lua

local a = Const("a")
local f = Const("f")
local m = mk_metavar("m", Bool)
local j = justification("type match")
local c = mk_eq_cnstr(f(a), m, j)
assert(c:is_eq())
assert(c:is_eqc())
assert(not c:is_choice())
assert(not c:is_level())
assert(c:lhs() == f(a))
assert(c:rhs() == m)
assert(c:justification():is_eqp(j))
print(c)
local c2 = mk_conv_cnstr(f(m), f(a), j)
print(c2)
assert(not c2:is_eq())
assert(c2:is_conv())
assert(c2:is_eqc())
assert(c2:lhs() == f(m))
local c3 = mk_level_cnstr(mk_level_zero(), mk_level_one(), j)
assert(c3:is_level())
print(c3)
assert(c ~= c2)
assert(c == mk_eq_cnstr(f(a), m, j))
assert(c:is_eqp(c))
assert(not c:is_eqp(mk_eq_cnstr(f(a), m, j)))
assert(c:hash() == mk_eq_cnstr(f(a), m, j):hash())
local c4 = mk_choice_cnstr(m, {a, f(a), f(f(a))}, j)
print(c4)
assert(c4:is_choice())
assert(c4:choice_expr() == m)
print(c4:choice_set():head())
assert(c4:choice_set():head() == a)
assert(c4:choice_set():tail():head() == f(a))
assert(#(c4:choice_set()) == 3)