Below is a half-working simple recursive notation:
Universe ARG. Definition ARG := Type@{ARG}.
Parameter X: ARG.
Notation A := (fun x:ARG->ARG => fun y:x X => y).
Parameter P: ARG -> ARG.
Parameter s: P X.
Notation "[ x .. z u ]" := (x P .. (z P u) .. ) (at level 5, z, u at next level).
Check (A P (A P (A P s))). (* [A A A s]: P X *)
Print Grammar constr.
(*| "5" RIGHTA
[ "["; NEXT; LIST1 NEXT; NEXT; "]"
| "["; NEXT; NEXT; "]" ]*)
Check [A A A s]. (* Syntax error: [constr:operconstr] or [constr:operconstr] expected (in [constr:operconstr]). *)
As you see, Coq recognizes A P (A P (A P s))
as [A A A s]: P X
but cannot parse [A A A s]
. Where is the problem, what's the fix?
EDIT: Coq seems to require some "parsing aids" here. For example, the following works:
Notation "( x .. z [ u ] )" := (x P .. (z P u) .. ) (at level 5, z at next level).
Check (A A A [s]): P X.
As I'd like to get rid of the inner notation, the question remains open
The problem is that Coq <= 8.7 does not support recursive notations of the form x .. y z
very well, and the fix is to download Coq master, or wait for Coq 8.8. Hugo Herbelin's fix, entitled Adding support for recursive notations of the form "x , .. , y , z"
, was merged on Aug 1, 2017.