Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] "Core" Coq typeclasses

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] "Core" Coq typeclasses


Chronological Thread 
  • From: Daniel Schepler <dschepler AT gmail.com>
  • To: Coq Club <coq-club AT inria.fr>
  • Cc: "Benjamin C. Pierce" <bcpierce AT cis.upenn.edu>
  • Subject: Re: [Coq-Club] "Core" Coq typeclasses
  • Date: Mon, 19 Jun 2017 17:06:33 -0700
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=dschepler AT gmail.com; spf=Pass smtp.mailfrom=dschepler AT gmail.com; spf=None smtp.helo=postmaster AT mail-ot0-f171.google.com
  • Ironport-phdr: 9a23:3BdkLhyWXl8SrVbXCy+O+j09IxM/srCxBDY+r6Qd1O4fIJqq85mqBkHD//Il1AaPBtSEraocw8Pt8InYEVQa5piAtH1QOLdtbDQizfssogo7HcSeAlf6JvO5JwYzHcBFSUM3tyrjaRsdF8nxfUDdrWOv5jAOBBr/KRB1JuPoEYLOksi7ze6/9pnRbglSmDaxfa55IQmrownWqsQYm5ZpJLwryhvOrHtIeuBWyn1tKFmOgRvy5dq+8YB6/ShItP0v68BPUaPhf6QlVrNYFygpM3o05MLwqxbOSxaE62YGXWUXlhpIBBXF7A3/U5zsvCb2qvZx1S+HNsDtU7s6RSqt4LtqSB/wiScIKTg58H3MisdtiK5XuQ+tqwBjz4LRZoyeKfhwcb7Hfd4CR2VBUMZfWSJCDI2hcYUAE/EMPfpEo4Tnu1cCsQeyCAuqCejyyjFInHj23agi3uovCw7G2g0gEMwKsH/Jsdv6KKcSXv6tzKnM0zrDde5d1DDg54jTbh8hoe+DXap0ccXP00kiDAzFjlCKpozkOzOZzPgCs2+e7+d5U++klm0pqxlprzWtycogkJTFipwVx1ze9ih13pw5KcC6RUJmZ9OvDYFeuDuAN4RsR8MvW2Fotzg+yr0BoZO7eTIFyJUjxxLGbPyHb5SE7gvtVOqMIzp0mWhpeL24hxa1/kigzvPzWtOo31ZNqypJitjMtnYT2BzP8sWKSPRw8l281TqR1w3f8OJJLV4umabGKZMt36Y8lp8JvkTCGi/2ll/2jKiTdkg85+eo8PjoYrX4qZ+EM497lBv+P78hmsy6G+s4MwwOU3KH9uS70b3v5Vf5T6lSjv0qjqnZt4jXKtgcpq6gGgNazoIj6wukADq9y9QZnXwHLEpfdx6djojpPUvOIPHiAvuljVSsimQj+/eTFbr4Sr7JM3KLxLzmZPN271NW4As119FWoZxOXOIvOvX2D2P4st3VClcCOAy52+LqEp0p2pgVWW+XBqKDGKzXuF6MoOkoJr/fN8cupD/hJq19tLbVhngjlApYJPHx0A==

On Mon, Jun 19, 2017 at 3:45 PM, Matthieu Sozeau
<mattam AT mattam.org>
wrote:
> Like John, I use mostly Equivalence and Proper, the standard library does
> not define many more than those. Usually I have a variant of EquivDec as
> well for decidable equality tests.
> About John's issues, I find the second one quite interesting, I understand
> it's due to the high overlap allowed. One could imagine to have a warning
> when a user-introduced instance can be used to solve every goal of the
> class, and refine it to give warnings for overlap as well. I always
> refrained going into this direction because it quickly becomes heuristic in
> our setting to decide which instances overlap due to computation and
> dependencies. Maybe a simply minded syntactic check would help here though,
> providing part of a solution to problem 1 as well. I have no better solution
> to the diamond problem and would advocate the same fix.

More generally than EquivDec, I often end up adding a "Decision" typeclass:

Class Decision (P:Prop) : Type :=
decide : {P} + {~P}.
Arguments decide P [Decision].

And then it's very easy to add instances like:

Instance and_dec `{Decision P} `{Decision Q} : Decision (P /\ Q).
Instance nat_lt_dec (m n:nat) : Decision (m < n).
Instance Forall_dec `{!forall x:X, Decision (P x)} (l:list X) :
Decision (Forall P l).

etc.

(Although sometimes, I've found if I also define e.g. nat_le_dec,
nat_gt_dec, nat_ge_dec, it tends to resolve to nat_le_dec in every
case. Probably not much of an issue, though, unless you want close
control over the extraction.)
--
Daniel Schepler



Archive powered by MHonArc 2.6.18.

Top of Page