lean2/tests/lua/tc7.lua
Leonardo de Moura 16bdc51fc4 refactor(kernel/type_checker): simplify type checker API, and remove add_cnstr_fn
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-06-26 13:36:31 -07:00

21 lines
772 B
Lua

local env = environment()
env = add_decl(env, mk_var_decl("N", Type))
local N = Const("N")
env = add_decl(env, mk_var_decl("f", mk_arrow(N, N)))
env = add_decl(env, mk_var_decl("g", mk_arrow(N, N)))
env = add_decl(env, mk_var_decl("a", N))
local f = Const("f")
local g = Const("g")
local x = Local("x", N)
env = add_decl(env, mk_definition("h", mk_arrow(N, N), Fun(x, f(x)), {opaque=false}))
local h = Const("h")
local a = Const("a")
local m1 = mk_metavar("m1", N)
local ngen = name_generator("tst")
local tc = type_checker(env, ngen)
assert(not tc:is_def_eq(f(m1), g(a)))
assert(not tc:is_def_eq(f(m1), a))
assert(not tc:is_def_eq(f(a), a))
assert(not tc:is_def_eq(mk_lambda("x", N, Var(0)), h(m1)))
assert(tc:is_def_eq(h(a), f(a)))
assert(tc:is_def_eq(h(a), f(m1)))