Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] performance question: replace autorewrite by reflection?

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] performance question: replace autorewrite by reflection?


Chronological Thread 
  • From: "jonikelee AT gmail.com" <jonikelee AT gmail.com>
  • To: Jason Gross <jasongross9 AT gmail.com>
  • Cc: coq-club AT inria.fr
  • Subject: Re: [Coq-Club] performance question: replace autorewrite by reflection?
  • Date: Wed, 29 Jul 2020 23:38:41 -0400
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=jonikelee AT gmail.com; spf=Pass smtp.mailfrom=jonikelee AT gmail.com; spf=None smtp.helo=postmaster AT mail-qt1-f170.google.com
  • Ironport-phdr: 9a23:d+ZEzBHCzgvs9Hi/8Rm2sJ1GYnF86YWxBRYc798ds5kLTJ76p8qybnLW6fgltlLVR4KTs6sC17OI9f69EjBQqb+681k6OKRWUBEEjchE1ycBO+WiTXPBEfjxciYhF95DXlI2t1uyMExSBdqsLwaK+i764jEdAAjwOhRoLerpBIHSk9631+ev8JHPfglEnjWwba5zIRmsrAjctsYajIRhJ60s1hbHv3xEdvhMy2h1P1yThRH85smx/J5n7Stdvu8q+tBDX6vnYak2VKRUAzs6PW874s3rrgTDQhCU5nQASGUWkwFHDBbD4RrnQ5r+qCr6tu562CmHIc37SK0/VDq+46t3ThLjlTwKPCAl/m7JlsNwjbpboBO/qBx5347Ue5yeOP5ncq/AYd8WWW9NU8BWWCJcH4O8dJMPAPQdMuZEoYf9oF4OogG/BQmqGejjzjBFi3vz0aA8zu8vExzJ3BY4EtwAsHrassj7OqQQXuC7y6fHwinMYfxN1Dfh6oXFaAwtrOuQUb5ud8fa1EkhFxnCjlWVsYHpMTGV1uMLs2ia7OpvS+avhHA5pAxqrTivw90jiojNho4P1l/E8iB5zIgoLtC/Sk57ZtikEJpTty6EM4t5XN0tTnpnuCY/0LIGuJq7cDIWx5Qgwh7ScvqKeJWH7Rz/TuieOyt4hG57d7KlgRa/6VWsxvHgW8SozFpHsjdJn9rPu30T1xLe9siKRPR98Eql2DuB2QLe5+5YLUwqmqTVK50sz74/m5cPvknOAjL7lUbwgaSLeEsk/e2o5P7mYrXgvpKcMo50ih3kPqswh8O/HPw0MgcPX2iH+eS8yabs8VflT7VNi/06iqbZsJHGJcQbu662GBVZ0ock6xu5Ejyo08wYkGEZIF5ZfB+LlYvkNlHULPzlDPqzn06gnCppyvzaJrHtHJTAImTenLrkYLpw71JTxQ88wN1e+55YFrQMLO/vVkDssdHVCgM2PBG7zuviEtp92I0eVGeBAqCHMa7drFqF6fwzLOWQeIMYviv2JeI/6P70l3A5nEcQfam30psTb3C1BvFmLF+YYXrom9sBCHsKshcnQOzklVGPUyJfa2y9X6I74TE7B4amApnZSo+xh7yB2T+3HpxQZm9YFlCBCWnke5mAVvsWay+fItVtniEFWLS9UYMtyBOjuBPix7piNOXU+ykYtZz51Nhy4u3ejRMy9TtyD8Sc0GGCUWV0kX0WSDIt06B/pFZyylaH0aRin/NYEtlT6+tTUggmLZ7c0/B6C9fqVw3dedeJUU+qTcmiATEsVd082MQOYkZ4G9W6lB/PxSuqA7kPl7yKHpM46Kzc32Kib/p6nlTPz64nx3Y8RdBUfTmkj7V48QfJAJXSwm2Wkq+rceIX2yubp0mZym/b9kNfVg9zXKHIUFgQY0LXqZLy4UaIB+usDrImMQZFxMOqJa5Da9mvhlJDEqSwcO/Can68zj/jTS2DwamBOc+3IjxMjhWYM1ANlkUoxVjDMAE/Aim7pGeHVW5hEFvuZwXn9uws8SrmHH9x9BmDagha75Tw+hMRgqbCGfYa37ZBoTt47jstQw770NXRBN6N4QFmefcEOI9v0BJ8zWvc8jdFENm4Nak73wwRdg12uwXl0BAlUog=

Thanks, Jason!


On Wed, 29 Jul 2020 22:51:51 -0400
Jason Gross <jasongross9 AT gmail.com> wrote:

> This is actually the topic of a recent draft of mine, recently
> (re)submitted to POPL 2021
> <http://people.csail.mit.edu/jgross/#partial-evaluation-rewriting>.
>
> Some background: One of the biggest bottlenecks in the rewrite
> tactics is the allocation of evars (in particular, the allocation of
> evar contexts) when instantiating lemmas. This shows up mostly when
> you have a large context or many binders in the goal, and issues such
> as #12524 <https://github.com/coq/coq/issues/12524> (setoid_rewrite
> and rewrite_strat are cubic in the number of binders even when there
> are no matches) and #12510 <https://github.com/coq/coq/issues/12510>
> are about this. Separately, even when there are no matches and no
> binders, autorewrite, rewrite, rewrite!, and rewrite? are all
> quadratic in the size of the goal ( #12600
> <https://github.com/coq/coq/issues/12600>). So I would not say that
> autorewrite is already optimized, and I believe there are a number of
> relatively low-hanging fruit.
>
> Second: Getting a proof term that does not incur overhead which is
> quadratic (or worse) in the number of rewrites is highly non-trivial;
> you may find the "Performance Bottlenecks of Proof-Producing
> Rewriting" section (Appendix A) of the aforementioned paper
> <https://people.csail.mit.edu/jgross/personal-website/papers/2021-rewriting-popl-draft.pdf#page=22>
> enlightening.
>
> Given this, there is reason (and evidence) to expect that using a
> reflective procedure will speed things up for you. I believe Rtac
> (see, e.g., Gregory Malecha's thesis
> <https://gmalecha.github.io/publications/2015/extensible-proof-engineering-in-intensional-type-theory>)
> has a general reflective rewriter (though I was not able to make it
> work in recent versions of Coq, and development seems to be
> abandoned), and the rewriting engine that I created for fiat-crypto
> <https://github.com/mit-plv/rewriter>, which is the subject of the
> aforementioned POPL submission, is another example of such a general
> engine. Unfortunately, I cannot in good conscience suggest that you
> use the framework that I built as anything other than an example; it
> suffers from a number of restrictions that could be lifted with
> engineering work (such as the fact that while any type without
> arguments is supported, the only type families supported are option
> and prod), and, more importantly, it's unmaintainable in its current
> form and should be rewritten from scratch
> <https://github.com/mit-plv/rewriter/issues/15>.
>
> Hope this helps,
> Jason
>
>
> On Wed, Jul 29, 2020 at 7:14 PM jonikelee AT gmail.com
> <jonikelee AT gmail.com> wrote:
>
> > Using Ltac profiling, it looks like about 40% of time spent in one
> > project I have is within autorewrite, the remainder primarily doing
> > proof search. The particular autorewrite hint dbs are not large (10
> > or so rules each, one has only 3 rules) and the addition of rules
> > ends before the hint dbs are used. In such cases, would it be
> > advantageous to create a reflective procedure to replace use of
> > autorewrite by a particular hint db? Or is this unlikely to
> > improve performance, considering that autorewrite is already
> > optimized (presumably)? I do not beleive that Qeds are
> > significantly time consuming in this project, so I don't think
> > shrinking the proof terms will have much benefit.
> >
> >




Archive powered by MHonArc 2.6.19+.

Top of Page