feat(library/blast/forward/ematch): add support for the new hcongr lemmas in the ematching module
This commit is contained in:
parent
32268b71d2
commit
5edcccaeb0
3 changed files with 52 additions and 9 deletions
|
@ -297,9 +297,26 @@ struct ematch_fn {
|
||||||
if (!cg_lemma)
|
if (!cg_lemma)
|
||||||
return false;
|
return false;
|
||||||
buffer<expr> t_args;
|
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())
|
if (p_args.size() != t_args.size())
|
||||||
return false;
|
return false;
|
||||||
|
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;
|
auto const * r_names = &cg_lemma->m_rel_names;
|
||||||
for (unsigned i = 0; i < p_args.size(); i++) {
|
for (unsigned i = 0; i < p_args.size(); i++) {
|
||||||
lean_assert(*r_names);
|
lean_assert(*r_names);
|
||||||
|
@ -310,6 +327,7 @@ struct ematch_fn {
|
||||||
}
|
}
|
||||||
r_names = &tail(*r_names);
|
r_names = &tail(*r_names);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
15
tests/lean/run/blast_ematch_heq1.lean
Normal file
15
tests/lean/run/blast_ematch_heq1.lean
Normal 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
|
10
tests/lean/run/blast_ematch_heq2.lean
Normal file
10
tests/lean/run/blast_ematch_heq2.lean
Normal 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
|
Loading…
Reference in a new issue