2014-05-31 04:05:47 +00:00
|
|
|
local env = environment()
|
|
|
|
|
|
|
|
local env = environment()
|
|
|
|
local l = mk_param_univ("l")
|
|
|
|
local U_l = mk_sort(l)
|
2014-07-22 16:43:18 +00:00
|
|
|
local U_l1 = mk_sort(max_univ(l, 1)) -- Make sure U_l1 is not Prop
|
2014-05-31 04:05:47 +00:00
|
|
|
local nat = Const({"nat", "nat"})
|
|
|
|
local vec_l = Const({"vec", "vec"}, {l}) -- vec.{l}
|
|
|
|
local zero = Const({"nat", "zero"})
|
|
|
|
local succ = Const({"nat", "succ"})
|
|
|
|
local one = succ(zero)
|
|
|
|
local list_l = Const({"list", "list"}, {l}) -- list.{l}
|
|
|
|
|
|
|
|
env = add_inductive(env,
|
|
|
|
name("nat", "nat"), Type,
|
|
|
|
name("nat", "zero"), nat,
|
|
|
|
name("nat", "succ"), mk_arrow(nat, nat))
|
|
|
|
|
2014-06-13 15:26:05 +00:00
|
|
|
env:for_each_decl(function(d) print(d:name()) end)
|
2014-05-31 04:05:47 +00:00
|
|
|
env = add_aliases(env, "nat", "natural")
|
2014-07-28 04:01:59 +00:00
|
|
|
assert(get_expr_aliases(env, {"natural", "zero"}):head() == name("nat", "zero"))
|
|
|
|
assert(get_expr_aliases(env, {"natural", "nat"}):head() == name("nat", "nat"))
|
|
|
|
assert(is_expr_aliased(env, {"nat", "nat"}) == name("natural", "nat"))
|
2014-05-31 04:05:47 +00:00
|
|
|
|
2014-06-30 16:14:55 +00:00
|
|
|
local A = Local("A", U_l)
|
|
|
|
|
2014-05-31 04:05:47 +00:00
|
|
|
env = add_inductive(env,
|
2014-06-30 16:14:55 +00:00
|
|
|
name("list", "list"), {l}, 1, Pi(A, U_l1),
|
|
|
|
name("list", "nil"), Pi(A, list_l(A)),
|
|
|
|
name("list", "cons"), Pi(A, mk_arrow(A, list_l(A), list_l(A))))
|
2014-05-31 04:05:47 +00:00
|
|
|
|
|
|
|
env = add_aliases(env, "list", "lst")
|
2014-07-28 04:01:59 +00:00
|
|
|
print(not get_expr_aliases(env, {"lst", "list_rec"}):is_nil())
|
2014-05-31 04:05:47 +00:00
|
|
|
env = add_aliases(env, "list")
|
2014-07-28 04:01:59 +00:00
|
|
|
print(get_expr_aliases(env, "list_rec"):head())
|
|
|
|
assert(not get_expr_aliases(env, "list_rec"):is_nil())
|
|
|
|
assert(not get_expr_aliases(env, {"lst", "list_rec"}):is_nil())
|
2014-05-31 04:05:47 +00:00
|
|
|
|
2014-06-03 22:19:29 +00:00
|
|
|
env = add_aliases(env, "list", "l")
|
2014-07-28 04:01:59 +00:00
|
|
|
print(get_expr_aliases(env, {"l", "list"}):head())
|
|
|
|
print(get_expr_aliases(env, {"l", "cons"}):head())
|
2014-05-31 04:05:47 +00:00
|
|
|
|
|
|
|
local A = Local("A", mk_sort(1))
|
2014-07-22 16:43:18 +00:00
|
|
|
local R = Local("R", mk_arrow(A, A, Prop))
|
2014-05-31 04:05:47 +00:00
|
|
|
local a = Local("a", A)
|
|
|
|
local b = Local("b", A)
|
|
|
|
|
2014-07-28 04:01:59 +00:00
|
|
|
env = add_expr_alias(env, "z", name("nat", "zero"))
|
|
|
|
assert(get_expr_aliases(env, "z"):head() == name("nat", "zero"))
|
|
|
|
assert(get_expr_aliases(env, "zz"):is_nil())
|