2014-05-25 15:22:28 +00:00
|
|
|
local env = environment()
|
|
|
|
local l1 = param_univ("l1")
|
|
|
|
local l2 = param_univ("l2")
|
2014-10-02 23:54:56 +00:00
|
|
|
env = add_decl(env, mk_constant_assumption("functor", {l1, l2}, mk_arrow(mk_sort(l1), mk_sort(l2), mk_sort(imax_univ(l1, l2)))))
|
2014-05-25 15:22:28 +00:00
|
|
|
local A = Local("A", mk_sort(l1))
|
|
|
|
local B = Local("B", mk_sort(l2))
|
|
|
|
local functor = Const("functor", {l1, l2})
|
2014-10-02 23:54:56 +00:00
|
|
|
env = add_decl(env, mk_constant_assumption("to_fun", {l1, l2}, Pi(A, B, mk_arrow(functor(A, B), mk_arrow(A, B)))))
|
2014-05-25 15:22:28 +00:00
|
|
|
env = add_coercion(env, "to_fun", "functor")
|
|
|
|
for_each_coercion_fun(env, function(C, f) print(tostring(C) .. " >-> function : " .. tostring(f)) end)
|
2014-10-02 23:54:56 +00:00
|
|
|
env = add_decl(env, mk_constant_assumption("nat", Type))
|
|
|
|
env = add_decl(env, mk_constant_assumption("real", Type))
|
2014-05-25 15:22:28 +00:00
|
|
|
local nat = Const("nat")
|
|
|
|
local real = Const("real")
|
2014-10-02 23:54:56 +00:00
|
|
|
env = add_decl(env, mk_constant_assumption("f1", Const("functor", {1, 1})(nat, real)))
|
2014-09-14 19:01:14 +00:00
|
|
|
print(get_coercions_to_fun(env, Const("functor", {1, 1})(nat, real)):head())
|
2014-10-02 23:54:56 +00:00
|
|
|
env = add_decl(env, mk_constant_assumption("sfunctor", {l1}, mk_arrow(mk_sort(l1), mk_sort(l1))))
|
|
|
|
env = add_decl(env, mk_constant_assumption("sf2f", {l1}, Pi(A, mk_arrow(Const("sfunctor", {l1})(A), Const("functor", {l1, l1})(A, A)))))
|
2014-05-25 15:22:28 +00:00
|
|
|
env = add_coercion(env, "sf2f")
|
2014-09-14 19:01:14 +00:00
|
|
|
print(get_coercions_to_fun(env, Const("sfunctor", {1})(nat)):head())
|
|
|
|
assert(env:type_check(get_coercions_to_fun(env, Const("sfunctor", {1})(nat)):head()))
|