lean2/tests/lua/subst1.lua

35 lines
1,002 B
Lua
Raw Normal View History

local m = mk_metavar("m", Prop)
local s = substitution()
assert(not s:is_assigned(m))
assert(not s:is_expr_assigned("m"))
assert(not s:is_level_assigned("m"))
local f = Const("f")
local g = Const("g")
local a = Const("a")
local t = f(f(a))
s:assign(m, t)
assert(s:is_assigned(m))
assert(s:is_expr_assigned("m"))
assert(not s:is_level_assigned("m"))
assert(s:instantiate(g(m)) == g(t))
s:assign("m", a)
assert(s:instantiate(g(m)) == g(a))
local l = mk_level_one()
local u = mk_meta_univ("u")
s:assign(u, l)
assert(s:is_assigned(u))
assert(s:is_level_assigned("u"))
assert(not s:is_expr_assigned("u"))
local m2 = mk_metavar("m2", Prop)
s:assign(m2, f(m))
assert(s:is_expr_assigned("m"))
-- m is assigned, so it is does not occur in f(m2)
-- assert(s:occurs_expr("m", f(m2)))
print(s:instantiate(mk_sort(u)))
assert(s:instantiate(mk_sort(u)) == mk_sort(l))
local s = substitution()
local m2 = mk_metavar("m2", Prop)
s:assign(m2, f(m))
assert(not s:is_expr_assigned("m"))
assert(s:occurs_expr("m", f(m2)))