2014-06-22 21:13:30 +00:00
|
|
|
local env = environment()
|
|
|
|
local N = Const("N")
|
|
|
|
local p = Const("p")
|
|
|
|
local q = Const("q")
|
|
|
|
local a = Const("a")
|
|
|
|
local b = Const("b")
|
|
|
|
local f = Const("f")
|
|
|
|
local H1 = Const("H1")
|
|
|
|
local H2 = Const("H2")
|
|
|
|
local And = Const("and")
|
|
|
|
local and_intro = Const("and_intro")
|
2014-07-22 16:43:18 +00:00
|
|
|
local A = Local("A", Prop)
|
|
|
|
local B = Local("B", Prop)
|
|
|
|
local C = Local("C", Prop)
|
2014-10-02 23:54:56 +00:00
|
|
|
env = add_decl(env, mk_constant_assumption("N", Type))
|
|
|
|
env = add_decl(env, mk_constant_assumption("p", mk_arrow(N, N, Prop)))
|
|
|
|
env = add_decl(env, mk_constant_assumption("q", mk_arrow(N, Prop)))
|
|
|
|
env = add_decl(env, mk_constant_assumption("f", mk_arrow(N, N)))
|
|
|
|
env = add_decl(env, mk_constant_assumption("a", N))
|
|
|
|
env = add_decl(env, mk_constant_assumption("b", N))
|
|
|
|
env = add_decl(env, mk_constant_assumption("and", mk_arrow(Prop, Prop, Prop)))
|
|
|
|
env = add_decl(env, mk_constant_assumption("and_intro", Pi(A, B, mk_arrow(A, B, And(A, B)))))
|
|
|
|
env = add_decl(env, mk_constant_assumption("foo_intro", Pi(A, B, C, mk_arrow(B, B))))
|
|
|
|
env = add_decl(env, mk_constant_assumption("foo_intro2", Pi(A, B, C, mk_arrow(B, B))))
|
2014-06-22 21:13:30 +00:00
|
|
|
env = add_decl(env, mk_axiom("Ax1", q(a)))
|
|
|
|
env = add_decl(env, mk_axiom("Ax2", q(a)))
|
|
|
|
env = add_decl(env, mk_axiom("Ax3", q(b)))
|
|
|
|
local Ax1 = Const("Ax1")
|
|
|
|
local Ax2 = Const("Ax2")
|
|
|
|
local Ax3 = Const("Ax3")
|
|
|
|
local foo_intro = Const("foo_intro")
|
|
|
|
local foo_intro2 = Const("foo_intro2")
|
|
|
|
local ng = name_generator("foo")
|
2014-06-26 20:35:36 +00:00
|
|
|
local tc = type_checker(env, ng)
|
2014-07-22 16:43:18 +00:00
|
|
|
local m1 = mk_metavar("m1", Prop)
|
2014-06-22 21:13:30 +00:00
|
|
|
print("before is_def_eq")
|
2014-06-26 20:35:36 +00:00
|
|
|
local tc = type_checker(env, ng)
|
2014-08-20 05:31:26 +00:00
|
|
|
r, cs = tc:is_def_eq(foo_intro(m1, q(a), q(a), Ax1), foo_intro(q(a), q(a), q(a), Ax2))
|
|
|
|
assert(r)
|
|
|
|
cs = cs:linearize()
|
|
|
|
assert(#cs == 1)
|
|
|
|
assert(cs[1]:lhs() == m1)
|
|
|
|
assert(cs[1]:rhs() == q(a))
|
2014-06-26 20:35:36 +00:00
|
|
|
local tc = type_checker(env, ng)
|
2014-06-25 23:50:30 +00:00
|
|
|
print(tostring(foo_intro) .. " : " .. tostring(tc:check(foo_intro)))
|
|
|
|
print(tostring(foo_intro2) .. " : " .. tostring(tc:check(foo_intro2)))
|
|
|
|
assert(tc:is_def_eq(foo_intro, foo_intro2))
|
|
|
|
print("before is_def_eq2")
|
2014-08-20 05:31:26 +00:00
|
|
|
local r, cs = tc:is_def_eq(foo_intro(m1, q(a), q(b), Ax1), foo_intro2(q(a), q(a), q(a), Ax2))
|
|
|
|
assert(r)
|
|
|
|
cs = cs:linearize()
|
|
|
|
assert(#cs == 0)
|
2014-06-26 20:35:36 +00:00
|
|
|
local tc = type_checker(env, ng)
|
2014-06-22 21:13:30 +00:00
|
|
|
print("before failure")
|
|
|
|
assert(not pcall(function() print(tc:check(and_intro(m1, q(a), Ax1, Ax3))) end))
|
|
|
|
print("before success")
|
2014-08-20 05:31:26 +00:00
|
|
|
local t, cs = tc:check(and_intro(m1, q(a), Ax1, Ax2))
|
|
|
|
cs = cs:linearize()
|
|
|
|
assert(#cs == 1)
|