2014-05-25 18:15:25 +00:00
|
|
|
local env = environment()
|
|
|
|
local l = param_univ("l")
|
2014-10-02 23:54:56 +00:00
|
|
|
env = add_decl(env, mk_constant_assumption("group", {l}, mk_sort(l+1)))
|
|
|
|
env = add_decl(env, mk_constant_assumption("abelian_group", {l}, mk_sort(l+1)))
|
|
|
|
env = add_decl(env, mk_constant_assumption("ring", {l}, mk_sort(l+1)))
|
|
|
|
env = add_decl(env, mk_constant_assumption("abelian_ring", {l}, mk_sort(l+1)))
|
2014-05-25 18:15:25 +00:00
|
|
|
local group = Const("group", {l})
|
|
|
|
local ring = Const("ring", {l})
|
|
|
|
local ab_group = Const("abelian_group", {l})
|
|
|
|
local ab_ring = Const("abelian_ring", {l})
|
2014-10-02 23:54:56 +00:00
|
|
|
env = add_decl(env, mk_constant_assumption("carrier", {l}, mk_arrow(group, mk_sort(l))))
|
2014-05-25 18:15:25 +00:00
|
|
|
env = add_coercion(env, "carrier")
|
|
|
|
|
2014-10-02 23:54:56 +00:00
|
|
|
env = add_decl(env, mk_constant_assumption("ag2g", {l}, mk_arrow(ab_group, group)))
|
|
|
|
env = add_decl(env, mk_constant_assumption("r2g", {l}, mk_arrow(ring, group)))
|
|
|
|
env = add_decl(env, mk_constant_assumption("ar2r", {l}, mk_arrow(ab_ring, ring)))
|
|
|
|
env = add_decl(env, mk_constant_assumption("ar2ag", {l}, mk_arrow(ab_ring, ab_group)))
|
2014-05-25 18:15:25 +00:00
|
|
|
env = add_coercion(env, "ag2g")
|
|
|
|
env = add_coercion(env, "r2g")
|
|
|
|
env = add_coercion(env, "ar2r")
|
|
|
|
env = add_coercion(env, "ar2ag")
|
|
|
|
for_each_coercion_sort(env, function(C, f) print(tostring(C) .. " >-> sort : " .. tostring(f)) end)
|
|
|
|
for_each_coercion_user(env, function(C, D, f) print(tostring(C) .. " >-> " .. tostring(D) .. " : " .. tostring(f)) end)
|
|
|
|
|
2014-09-14 19:01:14 +00:00
|
|
|
print(get_coercions_to_sort(env, Const("abelian_ring", {1})):head())
|
|
|
|
assert(env:type_check(get_coercions_to_sort(env, Const("abelian_ring", {1})):head()))
|
2014-06-13 05:18:27 +00:00
|
|
|
print("Coercions (abelian ring): ")
|
2014-09-20 16:00:10 +00:00
|
|
|
cs = get_coercions_from(env, ab_ring)
|
2014-06-13 05:18:27 +00:00
|
|
|
for i = 1, #cs do
|
2014-09-20 16:00:10 +00:00
|
|
|
print(tostring(cs[i][2]) .. " : " .. tostring(cs[i][4]) .. " : " .. tostring(cs[i][3]))
|
2014-06-13 05:18:27 +00:00
|
|
|
end
|