feat(library/blast/forward/ematch): add support for the new hcongr lemmas in the ematching module

This commit is contained in:
Leonardo de Moura 2016-01-11 11:10:47 -08:00
parent 32268b71d2
commit 5edcccaeb0
3 changed files with 52 additions and 9 deletions

View file

@ -297,18 +297,36 @@ struct ematch_fn {
if (!cg_lemma)
return false;
buffer<expr> t_args;
get_app_args(t, t_args);
expr const & fn = get_app_args(t, t_args);
if (p_args.size() != t_args.size())
return false;
auto const * r_names = &cg_lemma->m_rel_names;
for (unsigned i = 0; i < p_args.size(); i++) {
lean_assert(*r_names);
if (auto Rc = head(*r_names)) {
s = cons(entry(*Rc, Match, p_args[i], t_args[i]), s);
} else {
s = cons(entry(get_eq_name(), DefEqOnly, p_args[i], t_args[i]), s);
if (cg_lemma->m_hcongr_lemma) {
/* Lemma was created using mk_hcongr_lemma */
lean_assert(is_standard(env()));
fun_info finfo = get_fun_info(fn, t_args.size());
list<param_info> const * pinfos = &finfo.get_params_info();
lean_assert(length(*pinfos) == t_args.size());
for (unsigned i = 0; i < t_args.size(); i++) {
param_info const & pinfo = head(*pinfos);
if (!pinfo.is_inst_implicit() && !pinfo.is_implicit() && !pinfo.is_subsingleton()) {
/* We only match explicit arguments that are *not* subsingletons */
s = cons(entry(get_eq_name(), Match, p_args[i], t_args[i]), s);
} else {
s = cons(entry(get_eq_name(), DefEqOnly, p_args[i], t_args[i]), s);
}
pinfos = &tail(*pinfos);
}
} else {
auto const * r_names = &cg_lemma->m_rel_names;
for (unsigned i = 0; i < p_args.size(); i++) {
lean_assert(*r_names);
if (auto Rc = head(*r_names)) {
s = cons(entry(*Rc, Match, p_args[i], t_args[i]), s);
} else {
s = cons(entry(get_eq_name(), DefEqOnly, p_args[i], t_args[i]), s);
}
r_names = &tail(*r_names);
}
r_names = &tail(*r_names);
}
return true;
}

View file

@ -0,0 +1,15 @@
import data.nat
open algebra nat
section
open nat
set_option blast.strategy "ematch"
set_option blast.cc.heq true
attribute add.comm [forward]
attribute add.assoc [forward]
example (a b c : nat) : a + b + b + c = c + b + a + b :=
by blast
end

View file

@ -0,0 +1,10 @@
import algebra.group
variable {A : Type}
variable [s : group A]
include s
set_option blast.cc.heq true
example (a : A) : a * 1⁻¹ = a :=
by inst_simp