lean2/tests/lua/hop1.lua
Leonardo de Moura 63d478c63f fix(tests/lua/hop1): incorrect assertion
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-08-03 20:06:50 -07:00

24 lines
703 B
Lua

function tst_match(p, t)
local r = match(p, t)
assert(r)
print("--------------")
for i = 1, #r do
print(" #" .. i .. " := " .. tostring(r[i]))
end
end
local env = environment()
local N = Const("N")
local f = Const("f")
local a = Const("a")
local b = Const("b")
local x = Local("x", N)
local y = Local("y", N)
tst_match(f(Var(0), Var(0)), f(a, a))
tst_match(f(Var(0), Var(1)), f(a, b))
tst_match(Var(0)(x, y), f(x, f(x, y)))
assert(not match(Var(0)(x, x), f(x, f(x, y))))
assert(not match(Var(0)(x), f(x, y)))
tst_match(Pi(x, y, Var(2)(x)), Pi(x, y, f(f(x))))
tst_match(Fun(x, y, Var(2)(x)), Fun(x, y, f(f(x))))
assert(not match(Pi(x, Var(2)(x)), Pi(x, y, f(f(x)))))