lean2/tests/lua/hop1.lua

29 lines
808 B
Lua
Raw Normal View History

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)
2015-06-08 22:52:50 +00:00
local V0 = mk_idx_metavar(0, N)
local V1 = mk_idx_metavar(1, N)
tst_match(f(V0, V0), f(a, a))
tst_match(f(V0, V1), f(a, b))
2015-06-08 22:52:50 +00:00
local F0 = mk_idx_metavar(0, Pi(x, y, N))
tst_match(F0(x, y), f(x, f(x, y)))
assert(not match(F0(x, x), f(x, f(x, y))))
assert(not match(F0(x), f(x, y)))
2015-06-08 22:52:50 +00:00
local F0 = mk_idx_metavar(0, Pi(x, N))
tst_match(Pi(x, y, F0(x)), Pi(x, y, f(f(x))))
tst_match(Fun(x, y, F0(x)), Fun(x, y, f(f(x))))
assert(match(Pi(x, F0(x)), Pi(x, y, f(f(x)))))