Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] Overloading notation for different types in Coq

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] Overloading notation for different types in Coq


Chronological Thread 
  • From: Abhishek Anand <abhishek.anand.iitg AT gmail.com>
  • To: coq-club <coq-club AT inria.fr>
  • Subject: Re: [Coq-Club] Overloading notation for different types in Coq
  • Date: Fri, 19 May 2017 22:44:57 -0400
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=abhishek.anand.iitg AT gmail.com; spf=Pass smtp.mailfrom=abhishek.anand.iitg AT gmail.com; spf=None smtp.helo=postmaster AT mail-qt0-f176.google.com
  • Ironport-phdr: 9a23:iPJQzBCtGSJ4Zrjt4EknUyQJP3N1i/DPJgcQr6AfoPdwSPT+pMbcNUDSrc9gkEXOFd2CrakV1ayL7OigATVGusfe9ihaMdRlbFwst4Y/p08aPIa9E0r1LfrnPWQRPf9pcxtbxUy9KlVfA83kZlff8TWY5D8WHQjjZ0IufrymUoHdgN6q2O+s5pbdfxtHhCanYbN1MR66sRjdutMYjIZmK6s90BvEr3lVcOhS2W9kOEifkhj468qy5pJv7zhct/c8/MNcTKv2eLg1QrNfADk6KW4549HluwfeRgWV/HscVWsWkhtMAwfb6RzxQ4n8vCjnuOdjwSeWJcL5Q6w6VjSk9KdrVQTniDwbOD4j8WHYkdJ/gaRGqx+8vRN/worUYIaINPpie67WYN0XSXZdUstXSidMBJ63YYkSAOobJetXrYf9qVsAoxW9GAeiGv/gxyRSiXPqx6A3yfgtHR3E0QEmAtkAsG7UrNLwNKoKTe2616nIzTTYb/NWxzj965XDfwwnof6WW7J/bNfaxE41GAzejlWQqJflPzOL2eQOqWSU9exgWvipi2E6sQ1xozmvxtsjioTSiYIVz0rL9SR9wIovOdK4T0t7bMeiHZBNuS+aMI52TdkjQ2FuoCs11roGuYS9fCcUzJQnwwTTZOKafIiV5B/oSeWfIS9giX57ZL6ygwy+/Eugx+HmSMW4zVdHojBYntTOt30A0QHY5NKdRftn5Eih3C6C1wDN5eFAJkA5ja/bJIQgwr40j5YTqFjDEjPvlEX4kaObdEQp9vKn6+TgZbXmqZucOJFuhg7iNaQun9SzAeU+MgcQQ2iW4fqw2KHn8EHjQ7hHjuc6nrfEvJ3bP8gXu6y0Dg5N3oYm8Rm/DjOm0NoCnXkAKVJIYAiIgJPpO1HPO/D4Demwg1e2nDhxwfDJJLvhDYjXInjCkbfhYbl95lVTyAo2199f5pZUBqsdL/L0X0/9rMbYAQMhMwyo3+bnD81w2Z8ZWWKWG6OWLKfSsUKT6e80OOmNZIoVuC7nJPQ/5v7ui2U5mV4HcqWz05sXciPwIvMzKEKAJHHon91JRWwNp081SPHgoFyESz9aIXioCfES/DY+XausDYbYRo2uyJWH1SG3VslfbGBHEVCBEjHhcYyCV7ENaT6dCsBkmz0AE7OmTtlyhlmVqAbmxu8/faLv8SoCuMe72Q==

Increasing the level of your notation (thereby reducing its "priority") helps:

Class VDash (A B C : Type) := vdash : A -> B -> C -> Prop.
Notation "G '|-' e '::' T" := (vdash G e T) (at level 999, e at level 59).

Ltac tactic :=
  solve [match goal with
  | H: _ |- _ => auto
  end].
  
Global Instance vd : VDash nat nat nat := fun a b c => True.

Check (0 |- 0::0).

(* The manual says that levels are supposed to be 200 or less, so I have no idea why 999 is allowed. 200 isn't high enough for the last Check to check*)



On Fri, May 19, 2017 at 4:59 PM, Marianna Rapoport <mrapoport AT uwaterloo.ca> wrote:
As a follow up on the turnstile notation, is it possible to avoid a parse conflict with the match notation of Ltac?

Minimal example:

Class VDash (A B C : Type) := vdash : A -> B -> C -> Prop.
Notation "G '|-' e '::' T" := (vdash G e T) (at level 40, e at level 59).

Ltac tactic :=
  solve [match goal with
  | H: _ |- _ => auto
  end].

The error I get is:

Syntax error: '::' expected after [constr:operconstr level 59] (in [constr:operconstr]).

On Thu, May 18, 2017, at 03:27 PM, Marianna Rapoport wrote:
> That's exactly what I was looking for. Thanks a lot!
>
> Marianna
>
> On Thu, May 18, 2017, at 02:05 PM, Gaetan Gilbert wrote:
> > With typeclasses you can do something like see attached file.
> >
> > Gaëtan Gilbert
> >
> > On 18/05/2017 19:57, Marianna Rapoport wrote:
> > > I would like to be able to define the same Coq notations for different
> > > inductive definitions, and distinguish the notations based on the
> > > types of their arguments.
> > >
> > > Here is a minimal example:
> > >
> > >     Inductive type : Type :=
> > >     | TBool : type.
> > >
> > >     Inductive term1 : Type :=
> > >     | tvar1 : term1.
> > >
> > >     Inductive term2 : Type :=
> > >     | tvar2 : term2.
> > >
> > >     Definition context := nat -> (option type).
> > >
> > >     Reserved Notation "G '⊢' t '::' T" (at level 40, t at level 59).
> > >
> > >     Inductive typing1 : context -> term1 -> type -> Prop :=
> > >      | T_Var1 : forall G T,
> > >           G ⊢ tvar1 :: T
> > >     where "G '⊢' t1 '::' T" := (typing1 G t1 T)
> > >     with typing2 : context -> term2 -> type -> Prop :=
> > >      | T_Var2 : forall G x T,
> > >           G ⊢ tvar2 :: T
> > >     where "G '⊢' t2 '::' T" := (typing2 G t2 T).
> > >
> > > As you see, there is a mutually inductive definition, in which I'd
> > > like to be able to use the same notation for different types of terms
> > > (`term1` and `term2`).
> > >
> > > The error I get when trying to compile this is `Error: Illegal
> > > application (Non-functional construction): The _expression_ "tvar1" of
> > > type "term1" cannot be applied to the term "x" : "?T"`.
> > >
> > > Is there a way to get this to work, maybe by using type classes?
> >
> > Email had 1 attachment:
> > + tc_notas.v
> >   1k (text/x-verilog)





Archive powered by MHonArc 2.6.18.

Top of Page