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:
parent
a357c0cab2
commit
e2bf4fcddb
3 changed files with 50 additions and 0 deletions
|
|
@ -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();
|
||||
|
|
|
|||
40
tests/lean/interactive/goal_info.lean
Normal file
40
tests/lean/interactive/goal_info.lean
Normal 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
|
||||
6
tests/lean/interactive/goal_info.lean.expected.out
Normal file
6
tests/lean/interactive/goal_info.lean.expected.out
Normal 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}
|
||||
Loading…
Add table
Reference in a new issue