Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] A fast "eq" predicate for Gallina?

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] A fast "eq" predicate for Gallina?


Chronological Thread 
  • From: Mario Carneiro <di.gama AT gmail.com>
  • To: coq-club AT inria.fr
  • Subject: Re: [Coq-Club] A fast "eq" predicate for Gallina?
  • Date: Wed, 20 Jan 2021 15:43:07 -0500
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=di.gama AT gmail.com; spf=Pass smtp.mailfrom=di.gama AT gmail.com; spf=None smtp.helo=postmaster AT mail-qv1-f41.google.com
  • Ironport-phdr: 9a23:CMbZ5BMGz4p2nt734iwl6mtUPXoX/o7sNwtQ0KIMzox0Iv77rarrMEGX3/hxlliBBdydt6sVzbOM+Pm5ACRAuc/H7CldNsQUFlcssoY/p0QYGsmLCEn2frbBThcRO4B8bmJj5GyxKkNPGczzNBX4q3y26iMOSF2kbVImbuv6FZTPgMupyuu854PcYxlShDq6fLh+MAi6oR/eu8ULhYZuMLs9xgXGrndVZuha2H5jKVaPkxrh/Mu984Nv/iZKt/4968JMVLjxcrglQ7BfEDkoKX0+6tfxtRnEQwuP538cXXsTnxFVHQXL7wz0U4novCfiueVzxCeVPcvtTbApQjui9LtkSAXpiCgcKTE09nzch9Fqg6JapBKhoAF/w5LRbYqIOvdyYr/RcNUHTmdHQ81fVTFOApmkYoQAAeoOP+ZWoYf+qVUTsxWxGRKhC/nzxjJSnHL6wbE23uYnHArb3AIgBdUOsHHModvyLqgSS+G1zK7VxjjddfxWwzH955bJchA7pvGHQLV9ftfQyUU1GAPKlFCQppb+MjOa0+QCqWmb7+56We2zjG4nrhh8rz6yzcgjlofHnJgaykzY9Spn2oY1I8W1RkFlbNOnFJZdty+XOo91T84tX21mtjs2x6EJt5OlcyUHzIoqyhDQZvGZbYSF7RPuWfqMLDpki39oea6ziwiy/0Wm1+byVdG03U5UoiZZltTArHMA2hzJ5sSZV/dw+l2t1DmS2w3V9+pKO1o7lbDBJJ4k2rMwloQcsUDEHiLunUX5lq6WdkE99uix9eTrf6zqppGTOoNpkA3+PaMumsuwAeQ8LAcCRXSU+eO51LH7/E35RqtFjuEun6XHrJzXId4Xq625DgNPzIov9hKyAy2p3dgFhXUHKUhKeBODj4jnIVHOJ/X4AO+ijFStijtryOrJPrj7DZjWIXjDla3ufbd560JG1AUzytVf64pOCr4dOPLzRlPxtNvAAxAlNAy02v/rB8l51oMDQm2CGbSZMaPXsV+Q/O0jOeiMZIkPuDb8Mfcp/fDujWVq0WMaKKKuxN4cbG2yNvVgOUSQJ3T20fkbFmJfmwMkTeuio1SYVzNSfXH6C649oD4yDYuOAoLKR4Tri7uEinToVqZKb3xLXwjfWUzjcJ+JDq9VNHCiZ/R5mzlBboCPDpc73Ej35gD/wrtjaOHT/39A7MOx5J1O/+TW0CoK23lxBsWZ3XuKSjgtzGwNTj4ymqt4pB4kkwrR4e1Dm/VdUOdrybZJXwM9b8OOyuV7D5XrRFuEcIvQDlmhRdqiDHc6Sddjm9I=

The lean implementation uses quotient types. The version in the paper has the form

forall A B, subsingleton B -> forall x y : A, (option (x = y) -> B) -> B

or equivalently

forall x y, trunc (option (x = y))

where trunc is the quotient by the always-true relation. The "reference implementation" of the function, available to the logic, evaluates the inner function on none, while the actual implementation calls the function with "some <>" if x and y are pointer-equal. The restriction to subsingletons (in the CPS version) or using the propositional truncation ensures that there is no difference between the "none" and "some <>" cases in the logic itself - the two cases can take more or less time but must compute the same answer.

This does not respect definitional equality, in the sense that the computation is not following the same path as the definitional reduction. In most cases these constants have in fact been defined as constants, which block any definitional reduction (but must still be proven to exist via the "reference implementation" to ensure soundness).

Mario Carneiro

On Wed, Jan 20, 2021 at 3:20 PM Pierre-Marie Pédrot <pierre-marie.pedrot AT inria.fr> wrote:
On 20/01/2021 20:45, Adam Chlipala wrote:
> I've seen some recent work in Lean along these lines, I believe, but I,
> for one, am glad not to see that kind of feature complicating the
> trusted core of Coq!  To start with, taken literally, your proposal
> sounds logically inconsistent, since there could be two definitionally
> equal values that trigger different behavior for the "eq" operation.

As long as you only have an under-approximation in the sense that

forall x y, pointereq x y = true -> x = y

you should be safe, if you only care about soundness.

You'd have a very hard time with subject reduction though, and that
would be a big concern to me. I don't know how Lean 4 implements pointer
equality, but they already threw SR with the bathwater, so it is a
non-problem for them.

PMP




Archive powered by MHonArc 2.6.19+.

Top of Page