diff --git a/src/library/tactic/tactic.cpp b/src/library/tactic/tactic.cpp index ace9ce2b7..386f36a73 100644 --- a/src/library/tactic/tactic.cpp +++ b/src/library/tactic/tactic.cpp @@ -17,6 +17,7 @@ Author: Leonardo de Moura #include "kernel/for_each_fn.h" #include "kernel/replace_fn.h" #include "library/normalize.h" +#include "library/util.h" #include "library/kernel_bindings.h" #include "library/tactic/tactic.h" #include "library/io_state_stream.h" @@ -108,7 +109,26 @@ tactic then(tactic const & t1, tactic const & t2) { return tactic([=](environment const & env, io_state const & ios, proof_state const & s1) -> proof_state_seq { return map_append(t1(env, ios, s1), [=](proof_state const & s2) { check_interrupted(); - return t2(env, ios, s2); + bool has_meta = false; + goals const & gs = s2.get_goals(); + for (goal const & g : gs) { + if (has_expr_metavar_relaxed(g.get_type())) { + has_meta = true; + break; + } + } + if (has_meta) { + buffer gs; + substitution subst = s2.get_subst(); + to_buffer(s2.get_goals(), gs); + for (unsigned i = 0; i < gs.size(); i++) { + gs[i] = gs[i].instantiate(subst); + } + proof_state new_s2(s2, to_list(gs)); + return t2(env, ios, new_s2); + } else { + return t2(env, ios, s2); + } }, "THEN tactical"); }); } diff --git a/tests/lean/778.hlean b/tests/lean/778.hlean new file mode 100644 index 000000000..e32fd4034 --- /dev/null +++ b/tests/lean/778.hlean @@ -0,0 +1,9 @@ +open bool +definition is_equiv_bnot : is_equiv bnot := +begin + fapply is_equiv.mk, + exact bnot, + all_goals (intro b;cases b), + state, + repeat reflexivity +end diff --git a/tests/lean/778.hlean.expected.out b/tests/lean/778.hlean.expected.out new file mode 100644 index 000000000..be3812fca --- /dev/null +++ b/tests/lean/778.hlean.expected.out @@ -0,0 +1,18 @@ +778.hlean:7:4: proof state + +⊢ bnot (bnot ff) = ff + + +⊢ bnot (bnot tt) = tt + + +⊢ bnot (bnot ff) = ff + + +⊢ bnot (bnot tt) = tt + + +⊢ bool.cases_on (bnot ff) ?M_1 ?M_2 = eq.ap bnot (bool.cases_on ff ?M_3 ?M_4) + + +⊢ bool.cases_on (bnot tt) ?M_1 ?M_2 = eq.ap bnot (bool.cases_on tt ?M_3 ?M_4)