-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathltac_notation_levels.v
35 lines (27 loc) · 969 Bytes
/
ltac_notation_levels.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
(* Parsing precedence between custom notations and semicolon *)
Tactic Notation "myrewrite" uconstr(c) "by" tactic(t) :=
rewrite c by t.
Lemma foo: forall x, x = 2 -> 1 + 1 = x. intros. subst. reflexivity. Qed.
Goal False -> 1 + 1 + 1 = 2 + 2.
intros.
rewrite (foo 2) by reflexivity; exfalso.
(* Goal is False, as expected *)
Abort.
Goal False -> 1 + 1 + 1 = 2 + 2.
intros.
myrewrite (foo 2) by reflexivity; exfalso.
(* Surprise: Goal is "2 + 1 = 2 + 2", exfalso did not run, because it was parsed
as part of the "by" clause. *)
Abort.
Goal False -> 1 + 1 + 1 = 2 + 2.
intros.
(myrewrite (foo 2) by reflexivity); exfalso.
(* Now the goal is False again, as expected, but how can I avoid the parentheses? *)
Abort.
Tactic Notation "myrewrite3" uconstr(c) "by" tactic3(t) :=
rewrite c by t.
Goal False -> 1 + 1 + 1 = 2 + 2.
intros.
myrewrite3 (foo 2) by reflexivity; exfalso.
(* SUCCESS: Goal is False, as expected! *)
Abort.