fix(frontends/lean/tactic_notation): add skip tactic to save intermediate result

@kha, this commit fixes the issue: comma before a `{}` block will show the state inside the block.
This commit is contained in:
Leonardo de Moura 2017-01-20 20:58:05 -08:00
parent a357c0cab2
commit e2bf4fcddb
3 changed files with 50 additions and 0 deletions

View file

@ -414,8 +414,12 @@ static expr parse_begin_end_block(parser & p, pos_info const & start_pos, name c
/* parse next element */
expr next_tac;
if (p.curr_is_token(get_begin_tk())) {
expr skip_tac = p.save_pos(mk_tactic_skip(p.env(), tac_class), pos);
r = concat(p, r, skip_tac, start_pos, pos, tac_class);
next_tac = parse_begin_end_block(p, pos, get_end_tk(), tac_class);
} else if (p.curr_is_token(get_lcurly_tk())) {
expr skip_tac = p.save_pos(mk_begin_end_element(mk_tactic_skip(p.env(), tac_class)), pos);
r = concat(p, r, skip_tac, start_pos, pos, tac_class);
next_tac = parse_begin_end_block(p, pos, get_rcurly_tk(), tac_class);
} else if (p.curr_is_token(get_do_tk())) {
expr tac = p.parse_expr();

View file

@ -0,0 +1,40 @@
constant addc {a b : nat} : a + b = b + a
constant addassoc {a b c : nat} : (a + b) + c = a + (b + c)
constant zadd (a : nat) : 0 + a = a
open nat
example : ∀ n m : , n + m = m + n :=
begin
intros n m,
induction m with m' ih,
--^ "command": "info"
{ change n + 0 = 0 + n, simp [zadd] },
--^ "command": "info"
{ change succ (n + m') = succ m' + n,
rw [succ_add, ih]
--^ "command":"info"
}
end
example : ∀ n m : , n + m = m + n :=
begin
intros n m,
induction m with m' ih,
{ change n + 0 = 0 + n, simp [zadd] },
--^ "command": "info"
{ change succ (n + m') = succ m' + n,
rw [succ_add, ih]
}
end
example : ∀ n m : , n + m = m + n :=
begin
intros n m,
induction m with m' ih,
{ change n + 0 = 0 + n, simp [zadd] },
--^ "command": "info"
{ change succ (n + m') = succ m' + n,
rw [succ_add, ih]
}
end

View file

@ -0,0 +1,6 @@
{"message":"file invalidated","response":"ok","seq_num":0}
{"record":{"state":"n : \n⊢ n + 0 = 0 + n\n\nn m' : ,\nih : n + m' = m' + n\n⊢ n + succ m' = succ m' + n"},"response":"ok","seq_num":11}
{"record":{"state":"n : \n⊢ n + 0 = 0 + n\n\nn m' : ,\nih : n + m' = m' + n\n⊢ n + succ m' = succ m' + n"},"response":"ok","seq_num":13}
{"record":{"state":"n m' : ,\nih : n + m' = m' + n\n⊢ succ (n + m') = succ m' + n"},"response":"ok","seq_num":16}
{"record":{"state":"n : \n⊢ n + 0 = 0 + n"},"response":"ok","seq_num":25}
{"record":{"state":"no goals"},"response":"ok","seq_num":36}