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-06-12 19:29:04 +00:00
|
|
|
assert(get_alias_exprs(env, {"natural", "zero"}):head() == zero)
|
|
|
|
assert(get_alias_exprs(env, {"natural", "nat"}):head() == nat)
|
2014-05-31 04:05:47 +00:00
|
|
|
assert(is_aliased(env, nat) == name("natural", "nat"))
|
|
|
|
|
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-06-12 19:29:04 +00:00
|
|
|
print(not get_alias_exprs(env, {"lst", "list_rec"}):is_nil())
|
2014-05-31 04:05:47 +00:00
|
|
|
env = add_aliases(env, "list")
|
2014-06-12 19:29:04 +00:00
|
|
|
print(get_alias_exprs(env, "list_rec"):head())
|
|
|
|
assert(not get_alias_exprs(env, "list_rec"):is_nil())
|
|
|
|
assert(not get_alias_exprs(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-06-12 19:29:04 +00:00
|
|
|
print(get_alias_exprs(env, {"l", "list"}):head())
|
|
|
|
print(get_alias_exprs(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)
|
|
|
|
|
|
|
|
env = add_alias(env, "z", zero)
|
2014-06-12 19:29:04 +00:00
|
|
|
assert(get_alias_exprs(env, "z"):head() == zero)
|
|
|
|
assert(get_alias_exprs(env, "zz"):is_nil())
|