2014-05-25 17:01:04 +00:00
|
|
|
local env = environment()
|
|
|
|
local l = param_univ("l")
|
|
|
|
local Ul = mk_sort(l)
|
|
|
|
local lst_l = Const("lst", {l})
|
|
|
|
local A = Local("A", Ul)
|
2014-10-02 23:54:56 +00:00
|
|
|
env = add_decl(env, mk_constant_assumption("lst", {l}, mk_arrow(Ul, Ul)))
|
|
|
|
env = add_decl(env, mk_constant_assumption("lst2lst", {l}, Pi(A, mk_arrow(lst_l(A), lst_l(A)))))
|
|
|
|
env = add_decl(env, mk_constant_assumption("head", {l}, Pi(A, mk_arrow(lst_l(A), A))))
|
|
|
|
env = add_decl(env, mk_constant_assumption("id", {l}, Pi(A, mk_arrow(A, A))))
|
2014-05-25 17:01:04 +00:00
|
|
|
function add_bad_coercion(env, c)
|
|
|
|
ok, msg = pcall(function() add_coercion(env, c) end)
|
|
|
|
assert(not ok)
|
|
|
|
print("Expected error: " .. tostring(msg:what()))
|
|
|
|
end
|
|
|
|
function add_bad_coercion2(env, c, cls)
|
|
|
|
ok, msg = pcall(function() add_coercion(env, c, cls) end)
|
|
|
|
assert(not ok)
|
|
|
|
print("Expected error: " .. tostring(msg:what()))
|
|
|
|
end
|
|
|
|
add_bad_coercion(env, "lst2lst")
|
|
|
|
add_bad_coercion(env, "head")
|
|
|
|
add_bad_coercion(env, "id")
|
|
|
|
add_bad_coercion2(env, "head", "lst")
|