coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Alexandre Pilkiewicz <alexandre.pilkiewicz AT polytechnique.org>
- To: Coq Club <coq-club AT inria.fr>
- Subject: [Coq-Club] [Type Classes]: avoid duplication of instances
- Date: Fri, 1 Oct 2010 17:55:12 +0200
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:from:date:x-google-sender-auth:message-id :subject:to:content-type; b=kDzyrfB8hvTCT3WxsPupMEku5NWaQ6r3CENwkqw7Rb466VKiB13s7y0rVY29AHtU9M PZSKEV7sgGkd3gZv0eJ8QQgrfrZ2ymlgTNM0DH3jWb3/JtN7R7HZumu4+vF6rKt9cZSN 7zvtKeMowVMjE/bG1r/S+5VNywn8ESkqboQis=
Dear list.
I'm trying to use Coq type classes in one of my developments, but I
run in a problem of duplicated instances:
I have a class for decidable equality
<<<
Class EqDec (A:Type) := {
eq_dec: forall (x y:A), {x = y} + {x <> y}
}.
Notation "x == y" := (eq_dec x y) (at level 70, no associativity).
>>>
Now, I want to define a module type (for trees), with elements
equipped with a decidable equality.
My only solution is to do something like
<<<
Module Type TREE.
Parameter elt: Type.
Instance EqDec_elt : EqDec elt.
...
End TREE.
>>>
Say I now have an implementation of trees for elt := positive
I have to create this new instance EqDec_elt, equal to a predefined EqDec_pos
but now, when x and y are both of type positive, x == y can use one
instance or the other, leading to huge difficulties. For example, if
one of my hypothesis is of the form
<<<
H : if (x == y) then ... else ...
>>>
typing destruct (x == y). will typically not change H because a
different instance was chosen.
Is there a way to express in the signature that the type elt has
decidable equality, without forcing implementations to duplicate the
instance ?
Thanks
Alexandre Pilkiewicz
- [Coq-Club] [Type Classes]: avoid duplication of instances, Alexandre Pilkiewicz
- Re: [Coq-Club] [Type Classes]: avoid duplication of instances,
Stéphane Lescuyer
- Re: [Coq-Club] [Type Classes]: avoid duplication of instances,
Alexandre Pilkiewicz
- Re: [Coq-Club] [Type Classes]: avoid duplication of instances,
Stéphane Lescuyer
- Re: [Coq-Club] [Type Classes]: avoid duplication of instances, Alexandre Pilkiewicz
- Re: [Coq-Club] [Type Classes]: avoid duplication of instances,
Aaron Bohannon
- Re: [Coq-Club] [Type Classes]: avoid duplication of instances,
Stéphane Lescuyer
- Re: [Coq-Club] [Type Classes]: avoid duplication of instances,
Aaron Bohannon
- Re: [Coq-Club] [Type Classes]: avoid duplication of instances, Stéphane Lescuyer
- Re: [Coq-Club] [Type Classes]: avoid duplication of instances, Aaron Bohannon
- Re: [Coq-Club] [Type Classes]: avoid duplication of instances,
Aaron Bohannon
- Re: [Coq-Club] [Type Classes]: avoid duplication of instances, Aaron Bohannon
- Re: [Coq-Club] [Type Classes]: avoid duplication of instances,
Stéphane Lescuyer
- Re: [Coq-Club] [Type Classes]: avoid duplication of instances,
Stéphane Lescuyer
- Re: [Coq-Club] [Type Classes]: avoid duplication of instances,
Alexandre Pilkiewicz
- Re: [Coq-Club] [Type Classes]: avoid duplication of instances,
Stéphane Lescuyer
Archive powered by MhonArc 2.6.16.