2014-08-03 23:03:58 +00:00
|
|
|
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)
|
2015-02-03 23:15:04 +00:00
|
|
|
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))
|
2015-02-03 23:15:04 +00:00
|
|
|
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))
|
2015-02-03 23:15:04 +00:00
|
|
|
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))))
|
2015-05-15 01:21:17 +00:00
|
|
|
assert(match(Pi(x, F0(x)), Pi(x, y, f(f(x)))))
|