feat(library/tactic/intros_tactic): use '_' to say that some names are irrelevant in the intro tactic
See #695
This commit is contained in:
parent
d4e49a8434
commit
727a4f5a3a
3 changed files with 26 additions and 6 deletions
|
@ -1902,16 +1902,29 @@ expr parser::parse_tactic_expr_list() {
|
||||||
expr parser::parse_tactic_id_list() {
|
expr parser::parse_tactic_id_list() {
|
||||||
auto p = pos();
|
auto p = pos();
|
||||||
buffer<expr> args;
|
buffer<expr> args;
|
||||||
if (curr_is_identifier()) {
|
if (curr_is_identifier() || curr_is_token(get_placeholder_tk())) {
|
||||||
while (curr_is_identifier()) {
|
while (curr_is_identifier() || curr_is_token(get_placeholder_tk())) {
|
||||||
name id = get_name_val();
|
name id;
|
||||||
|
if (curr_is_identifier())
|
||||||
|
id = get_name_val();
|
||||||
|
else
|
||||||
|
id = name("_");
|
||||||
args.push_back(mk_local(id, mk_expr_placeholder()));
|
args.push_back(mk_local(id, mk_expr_placeholder()));
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
check_token_next(get_lbracket_tk(), "invalid tactic, '[' or identifier expected");
|
check_token_next(get_lbracket_tk(), "invalid tactic, '[', identifier or '_' expected");
|
||||||
while (true) {
|
while (true) {
|
||||||
args.push_back(mk_local(check_id_next("invalid tactic, identifier expected"), mk_expr_placeholder()));
|
auto id_pos = pos();
|
||||||
|
name id;
|
||||||
|
if (curr_is_identifier())
|
||||||
|
id = get_name_val();
|
||||||
|
else if (curr_is_token(get_placeholder_tk()))
|
||||||
|
id = name("_");
|
||||||
|
else
|
||||||
|
throw parser_error("invalid tactic, identifier or '_' expected", id_pos);
|
||||||
|
next();
|
||||||
|
args.push_back(mk_local(id, mk_expr_placeholder()));
|
||||||
if (!curr_is_token(get_comma_tk()))
|
if (!curr_is_token(get_comma_tk()))
|
||||||
break;
|
break;
|
||||||
next();
|
next();
|
||||||
|
@ -1933,7 +1946,7 @@ expr parser::parse_tactic_opt_expr_list() {
|
||||||
}
|
}
|
||||||
|
|
||||||
expr parser::parse_tactic_opt_id_list() {
|
expr parser::parse_tactic_opt_id_list() {
|
||||||
if (curr_is_token(get_lbracket_tk()) || curr_is_identifier()) {
|
if (curr_is_token(get_lbracket_tk()) || curr_is_identifier() || curr_is_token(get_placeholder_tk())) {
|
||||||
return parse_tactic_id_list();
|
return parse_tactic_id_list();
|
||||||
} else if (curr_is_token(get_with_tk())) {
|
} else if (curr_is_token(get_with_tk())) {
|
||||||
next();
|
next();
|
||||||
|
|
|
@ -44,6 +44,8 @@ static tactic intro_intros_tactic(list<name> _ns, bool is_intros) {
|
||||||
name new_name;
|
name new_name;
|
||||||
if (!is_nil(ns)) {
|
if (!is_nil(ns)) {
|
||||||
new_name = head(ns);
|
new_name = head(ns);
|
||||||
|
if (new_name == "_")
|
||||||
|
new_name = get_unused_name(binding_name(t), m);
|
||||||
ns = tail(ns);
|
ns = tail(ns);
|
||||||
} else {
|
} else {
|
||||||
new_name = get_unused_name(binding_name(t), m);
|
new_name = get_unused_name(binding_name(t), m);
|
||||||
|
|
5
tests/lean/run/intro_under.lean
Normal file
5
tests/lean/run/intro_under.lean
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
example (p q r : Prop) : p → q → r → r :=
|
||||||
|
begin
|
||||||
|
intro _ _ Hr,
|
||||||
|
assumption
|
||||||
|
end
|
Loading…
Reference in a new issue