Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] [coqdev] Tabled typeclass resolution

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] [coqdev] Tabled typeclass resolution


Chronological Thread 
  • From: Robbert Krebbers <mailinglists AT robbertkrebbers.nl>
  • To: coq-club <coq-club AT inria.fr>
  • Subject: Re: [Coq-Club] [coqdev] Tabled typeclass resolution
  • Date: Wed, 5 Feb 2020 20:07:16 +0100
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=mailinglists AT robbertkrebbers.nl; spf=Pass smtp.mailfrom=mailinglists AT robbertkrebbers.nl; spf=None smtp.helo=postmaster AT filter02.hostcontrol.com
  • Ironport-phdr: 9a23:2dcH6hRAiShlXttKRqe7u0b+Edpsv+yvbD5Q0YIujvd0So/mwa6zZBWN2/xhgRfzUJnB7Loc0qyK6vymBDVLuM/c+DBaKdoQDkRD0Z1X1yUbQ+e9QXXhK/DrayFoVO9jb3RCu0+BDE5OBczlbEfTqHDhpRQbGxH4KBYnbr+tQt2agMu4zf299IPOaAtUmjW9falyLBKrpgnNq8Uam4RvJrs+xxfTonZEZutayX51KV+Tgh3w4tu88IN5/ylfpv4s+dRMXbnmc6g9ULdVECkoP2cp6cPxqBLNVxGP5nwSUmUXlhpHHQ3I5wzkU5nyryX3qPNz1DGVMsPqQ780Xy+i77pwRx/zlCgHLT85/3rJhcF2kalWvQiupx17w47TfYGVKP9zdb7TcN8GWWZMWNtaWipcCY2+coQPFfIMM/tGoYnzp1UArhWwCgejC+zt1jBGiX720LYm0+kiCwzKwBAsEtwMvXnSsd77NL0SUeewzKTQ0TvDaOhZ1izj54jSbhAqvPSCXahufsXK0kYgCRnFjk6NooHiOjOazOUNs2ya7+pmWuKvj28nqxptoji03coskI7JiZkOxV/a7yV53IU1JcemR0FgetGrDoFQtzqAO4twRsMvWmdlszs0xL0BvJ60ZikKyJI/yhHFcfyGfImI4gz5WOaWOzd4i2ppeKiliBa2/0igyPfwWdSq31tMsyFLkcHMu2gN2hDJ98SKSvlw8l2i1DuOzQze5eJJLVgwmKfUMZIt3KI8m54JvUnBGiL6glv6gLKSe0gi5+Om8f7oYq/8qZ+ZL4J0ih/xMqApmsGnD+Q4MwwOX3SF9uSmyLHv41f1QLVNjv0tjqnWrJfaJcIHpq6jBA9V1pwv5Aq4DzejyNgYnH8HI0xZeB+fj4XlIUzCLfD6APulgFmhkS1nyv/FM7H5B5XCNHnDkLPvfbZn7E5czRI+zdVF6JJVDrEBIfTzWkD1tNzZFR85Lxe0zv39CNV6zYwRQnyAArWFMKPRq1+H+PkgLPKSa48PozbxMf4l5/r2gX8jhVAdZbWp3YcQaH2gAvtmJFyZbWPwjdcFDGcFpREzTPfqiV2HST5cfWy+X6M65jEhCYKpF53PRo63gO/J4CDuFZpPI2tCF1rERXzvbsCPX+oGQCOUOM5o1DIeA+uPUYgkgCupvgX30aYvDfDZ8CcVr4mrgN185unSkx429CdoFOyH1GuHQntonXkFTTU7xrs5p0grmQTL6rRxn/ENTY8b3PhOSApvbceAndw/MMj7X0f6RvnMUEyvGI30GzY7RN8r39wUbkx3Fs+5yBbHjXLzUu0l0oeTDZlxyZrymn34JsJz0XHDjvFzlV4sSMZVKW68i6R1+hLIQYjNwRzAyvSaMJ8E1SuIz1+tiGqDuEYCDlx+UKHZUGpHPA3Wqs/l7UTEU6WpDfIsNQ4TkcM=

[Moving this discussion to Coq-club]

While the tabbed implementation appears to avoid exponential blowups in *time* for (failed) searches, the paper does not address the problem of the exponential *size* of terms generated by type class search. Ralf Jung has a nice blog post about this issue:

https://www.ralfj.de/blog/2019/05/15/typeclasses-exponential-blowup.html

Does anyone know if Lean solves this issue? For example, by having some better sharing mechanism?

On 14/01/2020 12.48, Gabriel Scherer wrote:
Dear coqdev,

The Lean implementers have a new arXiv submission on a "tabled" typeclass-resolution engine that avoids exponential blowups in cases of inheritance/implication diamonds. I thought this may be of interest to coqdev, as the approach could presumably also be applied to Coq's typeclasses. (See below for abstract.)

The paper contains actual benchmarks that do exhibit bad behaviors of previous versions of Lean and Coq (Figure 4, page 15). One minor detail that I found interesting is that in the first "bad benchmark", the running times for Coq and Lean3 are extremely close together, which suggests that the Lean runtime is not noticeably faster by a not-1 constant factor (as one could maybe expect from the advertisement of a performance-focused C++ implementation).  (In the second benchmark, Lean3 is noticeably faster than Coq.)

Title: Tabled Typeclass Resolution
Authors: Daniel Selsam, Sebastian Ullrich, Leonardo de Moura
Categories: cs.PL cs.LO
  arXiv: https://arxiv.org/abs/2001.04301
  PDF: https://arxiv.org/pdf/2001.04301

  Typeclasses provide an elegant and effective way of managing ad-hoc
polymorphism in both programming languages and interactive proof
assistants.
However, the increasingly sophisticated uses of typeclasses within proof
assistants has exposed two critical problems with existing typeclass
resolution
procedures: the diamond problem, which causes exponential running
times in both
theory and practice, and the cycle problem, which causes loops in
the presence
of cycles and so thwarts many desired uses of typeclasses. We
present a new
typeclass resolution procedure, called tabled typeclass resolution,
that solves
these problems. We have implemented our procedure for the upcoming
version (v4)
of the Lean Theorem Prover, and we confirm empirically that our
implementation
is exponentially faster than existing systems in the presence of
diamonds. Our
procedure is sufficiently lightweight that it could easily be
implemented in
other systems. We hope our new procedure facilitates even more
sophisticated
uses of typeclasses in both software development and interactive theorem
proving.




Archive powered by MHonArc 2.6.18.

Top of Page