Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] Rewriting in sort Type

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] Rewriting in sort Type


Chronological Thread 
  • From: Christian Doczkal <christian.doczkal AT ens-lyon.fr>
  • To: coq-club AT inria.fr
  • Subject: Re: [Coq-Club] Rewriting in sort Type
  • Date: Fri, 9 Aug 2019 16:12:19 +0200
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=christian.doczkal AT ens-lyon.fr; spf=Pass smtp.mailfrom=christian.doczkal AT ens-lyon.fr; spf=None smtp.helo=postmaster AT labbe.ens-lyon.fr
  • Autocrypt: addr=christian.doczkal AT ens-lyon.fr; prefer-encrypt=mutual; keydata= mQINBFIuNbYBEADAiZlQsnkRrXHOkaZ2mZIVNxzcBha3+HhZ8IhtxF4t5QXRNWFLtdwBuE8u D0GMB/Lacm/LujwcI756cPM/7PhrUFAyn1IrYHYsK4/O5gBEgbSBRjD0X8mJ0V3oIm/PtjMC YiXBJwzOMNXOeWp+HcyCR0eh2sQD94gbF9SUOKDoamNB3DbLEHKjYPJ9O3zQw/Xai624OXB0 Wk5yIW77I1mGWhwbWxeHOJ/NmhHEU38YfbxXSzCLeMv98bNTej4oA+cPtMZ94AZOSy/oroMh rsr6wA9PL7NS+B1kRbgv6a5KL9latAI7zPeXcVsYw076rL850PLez/SXDuIr9mud4v8Zvcp9 65vTK4lTAD4C4vneNRGt4iwCOIgGsAN6BgqEgr7EwLX8dAX57OXPKZj0/0TdCbu+qsoSrQ3u +Ul6k374jFeIndqg/e9NiJbHjYAuug3cZZ6mH24SXWtTd4hGWi6f26tQQcRyGiduZkw5Wn26 g0UVgps7o2zHwlp9LJVjL3pCw7a9tKOfZaH+h7dV5JsA/Oq+7F3PhTbyNagi4A9igw+0qU+n Ws/nZDVMRiUv+1HY4PG8q6iEGSfHHjwW8InYS+Ah3stTddJ0sLc+0AGutx8ueTE2Ks14c4c8 aNW5y9bNFI/6/UQmO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iAOk1MBICU3aF9eiizLHj+Ff2QLROjv04iKnZt5XaKNwHqa65GQ9V050j6wq+Dzi81tQUh2QILFVZdxOGjIjmIVXOLevmAve5mFSgiTNrxvDBPr3nGJnNIGLDnK/7fblh805c1BYzzddH6p1IDbEBOev/VVP1tNzFFRA0KBe0wubiCNVlzIwSQ2OPAqmDMKPTq1CE/OwvI/PfLLMS7T36Mr0u4+PkpX4/g14UO6ezjrUNb3XtNfR8Il6FYHPqyvsGGnUJtw52GOfqklyZTT9aYTC+WKku5Tg/II+gFsLHV4erxrKbinToVqZKb3xLXwjfWUzjcJ+JDq9VNXCiZ/R5mzlBboCPDo8s0Rb35V3+wrBtI6zZ/DZdsYPk0p57/b+LzEBgxXlPF82Yllq1YSRxl2IMSSUx2fkk80F70RKHwK9+xfJCR4UKu6F5FzwiPJuZ9NRUTsjoU1uaLNqPUxOiU9KgRz8rHIo8
  • Openpgp: preference=signencrypt

Note that, due to cumulativity, Xeq *is* already a crelation. So the
following works for me:

Require Import Setoid CRelationClasses CMorphisms.
Section X.
Variables (X : Type) (Xeq : X -> X -> Prop) (Xlt : X -> X -> Type).
Instance Xeq_equiv : CRelationClasses.Equivalence Xeq. Admitted.
Instance Xlt_morph : CMorphisms.Proper (Xeq==>Xeq==>iffT) Xlt. Admitted.

Goal forall x y z: X, Xeq x y -> Xlt x z -> Xlt y z.
Proof. intros x y z E L. rewrite <- E. exact L. Qed.
End X.

Best,
Christian

On 8/9/19 1:20 PM, Vincent Semeria wrote:
> Indeed, I managed to do a rewriting in Type using CMorphisms directly.
>
> However, Xeq is a relation in Prop and when I try to mix
> Instance Xeq_equiv : RelationClasses.Equivalence Xeq.
> Instance Xlt_morph : CMorphisms.Proper (Xeq==>Xeq==>iffT) Xlt.
>
> then the rewrite fails again with this error
> Tactic failure: setoid rewrite failed: Unable to satisfy the following
> constraints:
> UNDEFINED EVARS:
>  ?X34==[x y z H H0 |- crelation X] (internal placeholder) {?c}
>
> so it wants a crelation in Type.
>
> I think it would be a pity to generalize Xeq in sort Type, is there a way
> to rewrite a CMorphism over a RelationClasses.Equivalence ?
>
>
> On Fri, Aug 9, 2019 at 12:12 PM Christian Doczkal
> <christian.doczkal AT ens-lyon.fr
>
> <mailto:christian.doczkal AT ens-lyon.fr>>
> wrote:
>
> Hi,
>
> I'm not sure about the Add Parametric Morphism command, but for
> rewriting it suffices to declare type class instances for
> Equivalence/PreOrder/etc. and the right instances of "Proper". These come
> in two variants:
>
> RelationClasses and Morphisms deal with relations in Prop
>
> CRelationClasses and CMorphisms deal with relations in Type
>
> Just make sure you are importing the right libraries and things should
> work.
>
> Hope this helps!
>
> Best,
> Christian
>
> On 8/9/19 12:04 PM, Vincent Semeria wrote:
> > Dear Coq clubbers,
> >
> > I currently work on some ordered setoids (X, Xeq, Xlt) and for
> performance reasons I'd like the order to be in sort Type :
> > Xlt : X -> X -> Type.
> >
> > Then I can store some information in Xlt, to speed up later functions
> that take Xlt as arguments. For example this is what C-CoRN does for the
> real numbers.
> >
> > However the compatibility between order and equality won't compile in
> sort Type :
> > Add Parametric Morphism : Xlt
> >     with signature Xeq ==> Xeq ==> iff
> >       as Xlt_morph.
> >
> > because iff wants a Prop. Even if I define
> > Definition iffT (A B:Type) := prod (A -> B) (B -> A)
> >
> > then Add Parametric Morphism complains that it wants a relation Type,
> ie a Type -> Type -> Prop.
> >
> > The documentation only mentions relations in sort Prop,
> > https://coq.inria.fr/refman/addendum/generalized-rewriting.html
> >
> > Is there a way to do this ?
> >
> > Thanks,
> > Vincent
> >
>
>


Attachment: signature.asc
Description: OpenPGP digital signature




Archive powered by MHonArc 2.6.18.

Top of Page