coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Alexandre Pilkiewicz <alexandre.pilkiewicz AT polytechnique.org>
- To: St�phane Lescuyer <stephane.lescuyer AT polytechnique.org>
- Cc: Coq Club <coq-club AT inria.fr>
- Subject: Re: [Coq-Club] [Type Classes]: avoid duplication of instances
- Date: Fri, 1 Oct 2010 19:42:23 +0200
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type :content-transfer-encoding; b=k26ml05KBLRlngjdwFyL4UBSzj9/d2tqx6ZyVdK6ZRFvgJqxLlPKuHPeFdnHlM4a1Y LLC3dOqIfFBmz/LEfQOsxOrKqF10lA/b8lsh7jVjP41l9BSltS7lIhB/xgeHHQPG0Svi v3kMtR62ccxj0j6eJU3ql0GkridMfvsDYV+/Y=
Hi Stéphane
You're right, I did not spot the problem at the right place! It's with
functors that my problem shows up.
Here is an example:
<<<
Require Import Peano_dec.
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).
Instance EqDec_nat : EqDec nat :={
eq_dec := eq_nat_dec
}.
Module Type DECIDABLE.
Parameter t: Type.
Instance EqDec_t : EqDec t.
End DECIDABLE.
Module DecNat <: DECIDABLE.
(* notice that in my development, this module is less trivial *)
Definition t := nat.
Definition EqDec_t := EqDec_nat.
End DecNat.
Module Foo (X:DECIDABLE).
Lemma foo : forall (x y:X.t),
if (x == y) then x = y else x <> y.
Proof.
intros. destruct (x == y); auto.
Qed.
End Foo.
Module FooNat := Foo(DecNat).
Lemma bar : forall (x y: nat), True.
Proof.
intros x y.
pose proof (FooNat.foo x y).
destruct (x == y). (* wrong destruction !! *)
>>>
I have to unfold DecNat.t in H. and unfold DecNat.EqDec_t in H. for
the destruction to work.
If I add
<<<
Set Printing All. pose (x == y).
>>>
here is what I get:
<<<
H : match @eq_dec DecNat.t DecNat.EqDec_t x y return Prop with
| left _ => @eq DecNat.t x y
| right _ => not (@eq DecNat.t x y)
end
s := @eq_dec nat EqDec_nat x y : sumbool (@eq nat x y) (not (@eq nat x y))
>>>
Thanks for your help
Alexandre
- [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, Alexandre Pilkiewicz
- 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.