feat(frontends/lean/inductive_cmd): improve notation for declaring 'empty' inductive datatypes

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
Leonardo de Moura 2014-07-25 11:24:01 -07:00
parent a5b9a7b296
commit a450ad5a95
3 changed files with 15 additions and 9 deletions

View file

@ -152,8 +152,7 @@ notation `Ω` `(` A `,` a `)` := loop_space A a
definition loop2d_space (A : Type) (a : A) := (refl a) = (refl a)
notation `Ω²` `(` A `,` a `)` := loop2d_space A a
inductive empty : Type :=
-- empty
inductive empty : Type
theorem empty_elim (c : Type) (H : empty) : c
:= empty_rec (λ e, c) H

View file

@ -3,8 +3,7 @@
-- Authors: Leonardo de Moura, Jeremy Avigad
definition Prop [inline] := Type.{0}
inductive false : Prop :=
-- No constructors
inductive false : Prop
theorem false_elim (c : Prop) (H : false) : c
:= false_rec c H

View file

@ -279,17 +279,25 @@ struct inductive_cmd_fn {
name d_name = parse_decl_name();
parse_inductive_univ_params();
expr d_type = parse_datatype_type();
m_p.check_token_next(g_assign, "invalid inductive declaration, ':=' expected");
bool empty_type = true;
if (m_p.curr_is_token(g_assign)) {
empty_type = false;
m_p.next();
}
level_param_names d_lvls;
std::tie(d_type, d_lvls) = elaborate_inductive_type(d_type);
if (!m_first) {
check_params(d_type, *first_d_type);
check_levels(d_lvls, *first_d_lvls);
}
if (empty_type) {
decls.push_back(inductive_decl(d_name, d_type, list<intro_rule>()));
} else {
buffer<expr> params;
add_params_to_local_scope(d_type, params);
auto d_intro_rules = parse_intro_rules(params);
decls.push_back(inductive_decl(d_name, d_type, d_intro_rules));
}
if (!m_p.curr_is_token(g_with)) {
m_levels.append(m_explict_levels);
for (auto l : d_lvls) m_levels.push_back(l);