fix(library/tactic/change_tactic): fixes #1686

This commit is contained in:
Leonardo de Moura 2017-06-20 12:04:07 -07:00
parent 3c306d0a7b
commit ce3387b246
2 changed files with 30 additions and 3 deletions

View file

@ -19,7 +19,8 @@ vm_obj change_core(expr const & e, bool check, tactic_state const & s) {
type_context ctx = mk_type_context_for(s);
if (!check || ctx.is_def_eq(e, g->get_type())) {
auto mctx = ctx.mctx();
expr new_M = mctx.mk_metavar_decl(g->get_context(), e);
expr new_e = mctx.instantiate_mvars(e);
expr new_M = mctx.mk_metavar_decl(g->get_context(), new_e);
/*
We use the proof term
@ -41,8 +42,8 @@ vm_obj change_core(expr const & e, bool check, tactic_state const & s) {
};
return tactic::mk_exception(thunk, s);
}
} catch (exception & e) {
return tactic::mk_exception(e, s);
} catch (exception & ex) {
return tactic::mk_exception(ex, s);
}
}

26
tests/lean/run/1686.lean Normal file
View file

@ -0,0 +1,26 @@
def f (n : ) := n + n
def g (n : ) := 2*n
example (n : ) : g (n+1) = f n + 2 :=
begin
change 2 * (n + 1) = f n + 2,
unfold f,
guard_target 2 * (n + 1) = n + n + 2,
admit
end
example (n : ) : g (n+1) = f n + 2 :=
begin
change g (n + 1) with 2 * (n+1),
unfold f,
guard_target 2 * (n + 1) = n + n + 2,
admit
end
example (n : ) : g (n+1) = f n + 2 :=
begin
change 2 * (n + 1) = _,
unfold f,
guard_target 2 * (n + 1) = n + n + 2,
admit
end