fix(library/util): incorrect hypothesis renaming when pretty printing goals

This commit is contained in:
Leonardo de Moura 2015-07-23 18:38:35 -07:00
parent e221d38790
commit f1a19a10c4
4 changed files with 36 additions and 12 deletions

View file

@ -830,24 +830,27 @@ format format_goal(formatter const & fmt, buffer<expr> const & hyps, expr const
bool compact = get_pp_compact_goals(opts);
format turnstile = unicode ? format("\u22A2") /* ⊢ */ : format("|-");
format r;
unsigned i = 0;
while (i < hyps.size()) {
if (i > 0)
r += compose(comma(), line());
unsigned i = hyps.size();
bool first = true;
while (i > 0) {
i--;
expr l = hyps[i];
format ids = fmt(l);
expr t = tmp_subst.instantiate(mlocal_type(l));
lean_assert(hyps.size() > 0);
while (i < hyps.size() - 1) {
expr l2 = hyps[i+1];
while (i > 0) {
expr l2 = hyps[i-1];
expr t2 = tmp_subst.instantiate(mlocal_type(l2));
if (t2 != t)
break;
ids += space() + fmt(l2);
i++;
ids = fmt(l2) + space() + ids;
i--;
}
r += group(ids + space() + colon() + nest(indent, line() + fmt(t)));
i++;
if (first)
first = false;
else
r = compose(comma(), line()) + r;
r = group(ids + space() + colon() + nest(indent, line() + fmt(t))) + r;
}
if (compact)
r = group(r);

View file

@ -4,8 +4,8 @@ H : b ∧ a
⊢ a
a b : Prop,
H : b ∧ a,
H_1 : a
H_1 : b ∧ a,
H : a
⊢ a ∧ b
assert_fail.lean:4:0: error: failed to add declaration 'example' to environment, value has metavariables
remark: set 'formatter.hide_full_terms' to false to see the complete term

View file

@ -0,0 +1,13 @@
import data.nat
open nat
example (a b c : nat) : a = 2 → b = 3 → a + b + c = c + 5 :=
begin
intro h1 h2,
have H : a + b = 2 + b, by rewrite h1,
have H : a + b = 2 + 3, by rewrite -h2; exact H,
have H : a + b = 5, from H,
rewrite H,
state,
rewrite add.comm
end

View file

@ -0,0 +1,8 @@
assert_tac2.lean:11:2: proof state
a b c : ,
h1 : a = 2,
h2 : b = 3,
H_2 : a + b = 2 + b,
H_1 : a + b = 2 + 3,
H : a + b = 5
⊢ 5 + c = c + 5