feat(frontends/lean/builtin_exprs): name hypothesis in suffices

closes #817
This commit is contained in:
Leonardo de Moura 2015-09-03 16:09:39 -07:00
parent e722120e34
commit 1fdbd681cc
2 changed files with 32 additions and 2 deletions

View file

@ -529,10 +529,30 @@ static expr parse_show(parser & p, unsigned, expr const *, pos_info const & pos)
static expr parse_suffices_to_show(parser & p, unsigned, expr const *, pos_info const & pos) {
auto prop_pos = p.pos();
expr from = p.parse_expr();
name id;
expr from;
if (p.curr_is_identifier()) {
id = p.get_name_val();
p.next();
if (p.curr_is_token(get_colon_tk())) {
p.next();
from = p.parse_expr();
} else {
expr left = p.id_to_expr(id, prop_pos);
id = get_this_tk();
unsigned rbp = 0;
while (rbp < p.curr_expr_lbp()) {
left = p.parse_led(left);
}
from = left;
}
} else {
id = get_this_tk();
from = p.parse_expr();
}
expr to = p.save_pos(mk_expr_placeholder(), prop_pos);
expr prop = p.save_pos(mk_arrow(from, to), prop_pos);
expr local = p.save_pos(mk_local(get_this_tk(), from), prop_pos);
expr local = p.save_pos(mk_local(id, from), prop_pos);
p.check_token_next(get_comma_tk(), "invalid 'suffices' declaration, ',' expected");
expr body;
{

10
tests/lean/run/817.lean Normal file
View file

@ -0,0 +1,10 @@
variables A B : Prop
premises (H₁ : A) (H₂ : A → B)
example : B :=
suffices A ∧ (A → B), from and.right this (and.left this),
and.intro H₁ H₂
example : B :=
suffices H : A ∧ (A → B), from and.right H (and.left H),
and.intro H₁ H₂