coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Xavier Leroy <Xavier.Leroy AT inria.fr>
- To: coq-club AT inria.fr
- Cc: Pierre-Marie Pédrot <pierre-marie.pedrot AT inria.fr>
- Subject: Re: [Coq-Club] A fast "eq" predicate for Gallina?
- Date: Thu, 21 Jan 2021 11:14:40 +0100
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=Xavier.Leroy AT inria.fr; spf=Pass smtp.mailfrom=xavier.leroy AT gmail.com; spf=None smtp.helo=postmaster AT mail-wm1-f43.google.com
- Ironport-phdr: 9a23:wDfTSRYP22iuMo6g+tkgE0L/LSx+4OfEezUN459isYplN5qZrs++bnLW6fgltlLVR4KTs6sC17OH9fm8EjVbqdbZ6TZeKcMKD0dEwewt3CUYSPafDkP6KPO4JwcbJ+9lEGFfwnegLEJOE9z/bVCB6le77DoVBwmtfVEtfre9FYHdldm42P6v8JPPfQpImCC9YbRvJxmqsAndrMYbjZZmJ6or1xfErXREd/lYyGh1IV6fgwvw6t2/8ZJ+8Slcoe4t+9JFXa7nY6k2ULtUASg8PWso/sPrrx7DTQWO5nsYTGoblwdDDhbG4h/nQJr/qzP2ueVh1iaUO832Vq00Vi+576h3Uh/oiTwIOCA//WrKl8F/lqNboBampxxi347ZZZyeOfRicq/Be94RWHFMVdhNWSNfHoy8bpMPD+sfMuZes4n9vEYFoR+nCQWxGO/j1jpEi3nr1qM4zushCxnL0wMuH90MsHraotb7OroMX++p16TH1ynPYulM1Dvh9ITFcBYsquyMU7JqdsrRzFEiGALfgVWOqIzqISmV3fkLvWeF9epgUuKugHMgpg5wuDev2MYshZfTho4PzF7L6z95wIE1JNCjSU57Z8SkEJpKuC2AOYt2WNovTmd1syk11rMIo4S0fDQWyJs53R7fbeSKfoqU7hzjVeucIzd1iXF5dbywmxq8/0itx/DiWsS7zVpHsjdJn93Nu30O2RLe6dSLRuV580qv3TuC0wHe5+BZLE0yiKHVKIYhz6YumpYPtUnPBCz7lUXsgKOLaEkp+fKk5uvpb7jgu5SSLZV7ihvkPaQrgsG/Afo3MgwJX2WD/OSzzrzj/UngTLREi/06j7DVsJ7VKMkVvKK5DAhV0oEs6xa7ETiqysgXnX4CLF5deRKHiZbmO03WLfzmEfuyh06gnTRryvzcI7HtHJbAImLMnbrvZbp97lRTyAs3zdBR/ZJUDbQBLer8W0DrqtzYDwE2Mxauz+bjFtp9zIQeWGKUD6+WNaPdq16I5uY1L+aQY48VvS7xK+I56P72kX85hVgdcLG10psQcXC0B+hpI0GEYXX3mdoBCmcLvg8mTOPwklGCUDhTZ2yzX60m/D07BpimB5/ZRo+xmLyBwDu7HppOa2BeFF+DDG3od4KYW/oXaSOSI8phnSceVbe7UYMh1BeutBX7y7V9NObU9DcY5trf041+4PSWnhUv/xR1Cd6c2ieDVTJahGQNEg8/wqFyuwRZx02EwOAss/VGFNFJoddESAArHZ/a1e1zTd7oDFGSNuyVQUqrF431SQo6Scg8lppXOx4kR4eSyyvb1i/vOIc70qSRDcVsoKPaxXn4YchnmS6fifsRymI+S84KDlWIw65y8w+JWtzMmkSd0rmvLOESgHWL+2CEwm6D+kpfVVwoCPSXbTUkfkLT6O/ByAbHRr6qB64gN1IYm8GHI6pOLNbuiAcfSQ==
It occurs to me that I don't really need "eq x y = true -> x = y", but
instead can get by with "eq x y = false -> x <> y"
This is just as inconsistent. If x and y are (structurally) equal but physically unequal, you get false = false -> ~True.
"eq" cannot be a Coq function because it does not map equals to equals.
One possibility is to use the function "lambda x y a b. if eq x y then a else b" with a type that forces "a" and "b" to be equal if "x" and "y" are equal (and thus both "then" and "else" branches could be taken). Something like:
Parameter eq: forall {T U: Type} (x y: T) (a b: U), (x = y -> a = b) -> U.
Axiom eq_same: forall {T U: Type} (x: T) (a b: U) P, eq x x a b P = a.
Axiom eq_different: forall {T U: Type} (x y: T) (a b: U) P, x <> y -> eq x y a b P = b.
Axiom eq_same: forall {T U: Type} (x: T) (a b: U) P, eq x x a b P = a.
Axiom eq_different: forall {T U: Type} (x y: T) (a b: U) P, x <> y -> eq x y a b P = b.
- Xavier Leroy
(another good reason
not to be classical!), because the vast majority of the comparisons I'd
be doing will end up being false. And I can get that with UIDs, or even
just mostly-unqiue IDs. I would then embed such a UID in each
structure I need to compare quickly.
That should be somewhat attainable once Ltac2 has a more complete set
of mutable structure capabilities - so that an Ltac2 function can create
such an almost-UID. That would at least allow me to generate UIDs at
type checking time, which again might be sufficient for my purposes,
although barely.
Of course, it would be even better if Gallina had an opaque type to use
for these UIDs that implemented a very fast equality check - but
integers would work for now. And even better still if Gallina could
generate such UIDs itself without violating the logic.
On Wed, 20 Jan 2021 21:22:38 +0100
Pierre-Marie Pédrot <pierre-marie.pedrot AT inria.fr> wrote:
> On 20/01/2021 21:17, jonikelee AT gmail.com wrote:
> > I am working on some Coq reflection procedures and trying to stay
> > within Gallina as much as possible.
>
> Why don't you implement your own heap inside Coq then, using some form
> of state monad? It's going to be overly cumbersome but at least you'd
> get pointer equality from first principles.
>
> PMP
>
- [Coq-Club] A fast "eq" predicate for Gallina?, jonikelee AT gmail.com, 01/20/2021
- Re: [Coq-Club] A fast "eq" predicate for Gallina?, Sylvain Boulmé, 01/20/2021
- Re: [Coq-Club] A fast "eq" predicate for Gallina?, jonikelee AT gmail.com, 01/20/2021
- Re: [Coq-Club] A fast "eq" predicate for Gallina?, Jean-Christophe Léchenet, 01/21/2021
- Re: [Coq-Club] A fast "eq" predicate for Gallina?, jonikelee AT gmail.com, 01/20/2021
- Re: [Coq-Club] A fast "eq" predicate for Gallina?, Adam Chlipala, 01/20/2021
- Re: [Coq-Club] A fast "eq" predicate for Gallina?, Sylvain Boulmé, 01/20/2021
- Re: [Coq-Club] A fast "eq" predicate for Gallina?, jonikelee AT gmail.com, 01/20/2021
- Re: [Coq-Club] A fast "eq" predicate for Gallina?, Pierre-Marie Pédrot, 01/20/2021
- Re: [Coq-Club] A fast "eq" predicate for Gallina?, jonikelee AT gmail.com, 01/20/2021
- Re: [Coq-Club] A fast "eq" predicate for Gallina?, Xavier Leroy, 01/21/2021
- Re: [Coq-Club] A fast "eq" predicate for Gallina?, jonikelee AT gmail.com, 01/21/2021
- Re: [Coq-Club] A fast "eq" predicate for Gallina?, Xavier Leroy, 01/21/2021
- Re: [Coq-Club] A fast "eq" predicate for Gallina?, jonikelee AT gmail.com, 01/20/2021
- Re: [Coq-Club] A fast "eq" predicate for Gallina?, Pierre-Marie Pédrot, 01/20/2021
- Re: [Coq-Club] A fast "eq" predicate for Gallina?, Pierre-Marie Pédrot, 01/20/2021
- Re: [Coq-Club] A fast "eq" predicate for Gallina?, Adam Chlipala, 01/20/2021
- Re: [Coq-Club] A fast "eq" predicate for Gallina?, Mario Carneiro, 01/20/2021
- Re: [Coq-Club] A fast "eq" predicate for Gallina?, Mario Carneiro, 01/20/2021
- Re: [Coq-Club] A fast "eq" predicate for Gallina?, Sylvain Boulmé, 01/20/2021
Archive powered by MHonArc 2.6.19+.