2014-07-04 03:41:42 +00:00
|
|
|
import logic
|
2014-11-23 01:34:05 +00:00
|
|
|
namespace experiment
|
2014-07-04 03:41:42 +00:00
|
|
|
inductive nat : Type :=
|
2015-02-26 01:00:10 +00:00
|
|
|
| zero : nat
|
|
|
|
| succ : nat → nat
|
2014-07-04 03:41:42 +00:00
|
|
|
|
2014-09-04 22:03:59 +00:00
|
|
|
check @nat.rec
|
2014-07-04 03:41:42 +00:00
|
|
|
|
|
|
|
(*
|
|
|
|
local env = get_env()
|
2014-09-04 22:03:59 +00:00
|
|
|
local nat_rec = Const({"nat", "rec"}, {1})
|
2014-07-04 03:41:42 +00:00
|
|
|
local nat = Const("nat")
|
|
|
|
local n = Local("n", nat)
|
2014-07-22 16:43:18 +00:00
|
|
|
local C = Fun(n, Prop)
|
|
|
|
local p = Local("p", Prop)
|
2014-07-04 03:41:42 +00:00
|
|
|
local ff = Const("false")
|
|
|
|
local tt = Const("true")
|
|
|
|
local t = nat_rec(C, ff, Fun(n, p, tt))
|
|
|
|
local zero = Const("zero")
|
|
|
|
local succ = Const("succ")
|
|
|
|
local one = succ(zero)
|
|
|
|
local tc = type_checker(env)
|
|
|
|
print(env:whnf(t(one)))
|
|
|
|
print(env:whnf(t(zero)))
|
|
|
|
local m = mk_metavar("m", nat)
|
|
|
|
print(env:whnf(t(m)))
|
|
|
|
|
|
|
|
function test_unify(env, lhs, rhs, num_s)
|
|
|
|
print(tostring(lhs) .. " =?= " .. tostring(rhs) .. ", expected: " .. tostring(num_s))
|
2014-07-27 19:01:06 +00:00
|
|
|
local ss = unify(env, lhs, rhs, name_generator(), true, substitution(), options())
|
2014-07-04 03:41:42 +00:00
|
|
|
local n = 0
|
|
|
|
for s in ss do
|
|
|
|
print("solution: ")
|
|
|
|
s:for_each_expr(function(n, v, j)
|
|
|
|
print(" " .. tostring(n) .. " := " .. tostring(v))
|
|
|
|
end)
|
|
|
|
s:for_each_level(function(n, v, j)
|
|
|
|
print(" " .. tostring(n) .. " := " .. tostring(v))
|
|
|
|
end)
|
|
|
|
n = n + 1
|
|
|
|
end
|
|
|
|
if num_s ~= n then print("n: " .. n) end
|
|
|
|
assert(num_s == n)
|
|
|
|
end
|
|
|
|
|
|
|
|
test_unify(env, t(m), tt, 1)
|
|
|
|
test_unify(env, t(m), ff, 1)
|
2014-09-04 22:03:59 +00:00
|
|
|
*)
|
2014-11-23 01:34:05 +00:00
|
|
|
end experiment
|