| 1 |
|
| 2 |
Require Import Ltac2.Ltac2. |
| 3 |
|
| 4 |
Module B13462. |
| 5 |
|
| 6 |
Axiom plus: nat -> nat -> nat. |
| 7 |
|
| 8 |
Declare Custom Entry foo. |
| 9 |
|
| 10 |
Definition enter{T: Type}: T -> T := @id T. |
| 11 |
|
| 12 |
Notation "a +++ b" := (plus a b) (in custom foo at level 5, a custom foo, b custom foo). |
| 13 |
Notation "x" := x (in custom foo at level 0, x ident). |
| 14 |
Notation "{{ x }}" := (enter x) (x custom foo at level 5). |
| 15 |
|
| 16 |
Ltac2 Notation "go" "(" a(constr(custom(foo))) ")" := pose $a as x. |
| 17 |
|
| 18 |
Goal forall (p q: nat), False. |
| 19 |
Proof. |
| 20 |
intros. |
| 21 |
go (p +++ q). |
| 22 |
Abort. |
| 23 |
|
| 24 |
End B13462. |
| 25 |
|
| 26 |
Declare Custom Entry bar. |
| 27 |
|
| 28 |
Fail Ltac2 Notation "foo" a(constr(custom(foo))) := a. |
| 29 |
Succeed Ltac2 Notation "foo" a(constr(custom(B13462.foo))) := a. |
| 30 |
|
| 31 |
Fail Ltac2 Notation "foo" a(constr(custom(foo,bar))) := a. |
| 32 |
|
| 33 |
Fail Ltac2 Notation "foo" a(constr(level(-10))) := a. |
| 34 |
Fail Ltac2 Notation "foo" a(constr(level(bar))) := a. |
| 35 |
|
| 36 |
Ltac2 Notation "foo" a(constr(level(10))) := a. |
| 37 |
Ltac2 Eval foo S 0. |
| 38 |
Ltac2 Eval (foo S : constr). (* ": constr" is a ltac2 cast not a term cast *) |
| 39 |
|
| 40 |
Fail Ltac2 Notation "bar" a(constr(level(10),level(10))) := a. |
| 41 |
Ltac2 Notation "bar" a(constr(custom(bar),level(0))) "!" := a. |
| 42 |
Ltac2 Notation "bar" a(constr) "!" := a. |
| 43 |
|
| 44 |
Notation "!! x" := (S x : bool) (in custom bar at level 10, x custom bar at level 0). |
| 45 |
Notation "##" := (0:bool) (in custom bar). |
| 46 |
|
| 47 |
Notation "!! x" := (S x) (at level 2). |
| 48 |
|
| 49 |
Ltac2 Eval bar !! 0 !. (* picked bar with argument in constr so succeeds *) |
| 50 |
Fail Ltac2 Eval bar ## !. (* picked bar with argument in custom bar so fails (nat <> bool) *) |