coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Rui Baptista <rpgcbaptista AT gmail.com>
- To: Jason Gross <jasongross9 AT gmail.com>
- Cc: coq-club <coq-club AT inria.fr>
- Subject: Re: [Coq-Club] Notation Levels, Parsing, and Printing
- Date: Mon, 26 Aug 2013 20:44:17 +0100
I'm not sure I haven't broken anything, but what if you replaced 'Notation "A [[ x , y ]]" := (A (x, y)).' with 'Notation "x , y" := (x, y) (at level 10).'?
On Mon, Aug 26, 2013 at 5:18 PM, Jason Gross <jasongross9 AT gmail.com> wrote:
Hi,I am trying to write notations which are only for printing. I am trying to make the following code work (in particular, I want the last line to not fail). How do I do this?Reserved Notation "--".Reserved Notation "x [[ -- ]]" (at level 10).Reserved Notation "x [[ y ]]" (at level 10, y at level 10).Reserved Notation "A [[ x , y ]]" (at level 10, x at level 10, y at level 10).Notation "x [[ y ]]" := ((fun _ => x) y).Notation "--" := Set.Notation "x [[ -- ]]" := (x).Notation "A [[ x , y ]]" := (A (x, y)).Check (fun xy : prod Type Type => fst xy = snd xy) [[ Set [[ -- ]] , Set ]].Check (fun xy : prod Type Type => fst xy = snd xy) [[ Set [[ -- ]] , -- ]].Check (fun xy : prod Type Type => fst xy = snd xy) [[ Set , -- ]].Reserved Notation "A [[ x [[ -- ]] , y ]]" (at level 10, x at level 10, y at level 10).Reserved Notation "A [[ x [[ -- ]] , -- ]]" (at level 10, x at level 10).Check (fun xy : prod Type Type => fst xy = snd xy) [[ Set , -- ]].Reserved Notation "A [[ x , -- ]]" (at level 10, x at level 10).Check (fun xy : prod Type Type => fst xy = snd xy) [[ Set , -- ]].(* Unknown interpretation for notation "_ [[ _ , -- ]]". *)As a use case for this kind of thing, suppose I want to use "--" to mean "identity" and I have a notation "a + b". If the value "a + --" simplifies under [simpl] (but doesn't simplify fully to "a"), then I still want to display the resulting term as "a + --". But if I make a notation for "a + --", then I have to define it to use it. This is fine, until I want to use "+" and "--" in another scope, where defining "a + --" is unnecessary, perhaps because in this scope, the meaning of "--" is opaque. Then I have the problem that Coq doesn't know how to interpret "a + --", even though it knew how to interpret it before the extra reserved notation. Is there a way to fix this, for example, to declare that a notation is only for printing, or to set the levels so that things will just work with the most recently declared notation in that scope? Or failing that, can I get notations to bind to other notations which are not yet defined (i.e., say that "(a + --)%some_scope" should parse, by default, as "(a + ( -- )%some_scope)%some_scope" for all scopes "some_scope")?Thanks,Jason
- [Coq-Club] Notation Levels, Parsing, and Printing, Jason Gross, 08/26/2013
- Re: [Coq-Club] Notation Levels, Parsing, and Printing, Rui Baptista, 08/26/2013
Archive powered by MHonArc 2.6.18.