一句话:提出引导式等式饱和,将复杂重写拆成经人工中间引导连接的自动等式饱和步骤,提升可扩展性。
自动重写技术(如贪心简化和等式饱和)无需人工输入,但难以扩展到大搜索空间,项大小或重写长度的微小增加都可能导致失败。本文提出半自动的引导式等式饱和:当全自动等式饱和无法扩展时,允许人在关键决策点提供中间引导,将重写拆分为从原项到引导、再从引导到目标的两个更简单的自动等式饱和步骤;多个引导可形成序列。引导可以是完整项,也可以是含未定义元素的 sketch,由等式饱和搜索实例化,且往往比完整项简洁得多。作者在 Lean 4 证明助手和 RISE 数组语言编译器中评估:前者以教科书式证明草稿书写,可在不到一秒内完成原本需数分钟的无引导搜索,并发现此前需手工完成的复杂证明;后者中无引导优化在一小时和 60 GB 内存内失败,而引导式方法最多用 3 个引导,在数秒内以低于 1 GB 内存完成相同优化。
Rewriting is a principled term transformation technique with uses across theorem proving and compilation. In theorem proving, each rewrite is a proof step; in compilation, rewrites optimize a program term. While developing rewrite sequences manually is possible, this process does not scale to larger rewrite sequences. Automated rewriting techniques, like greedy simplification or equality saturation, work well without requiring human input. Yet, they do not scale to large search spaces, limiting the complexity of tasks where automated rewriting is effective, and meaning that just a small increase in term size or rewrite length may result in failure. This paper proposes a semi-automatic rewriting technique as a means to scale rewriting by allowing human insight at key decision points. Specifically, we propose guided equality saturation that embraces human guidance when fully automated equality saturation does not scale. The rewriting is split into two simpler automatic equality saturation steps: from the original term to a human-provided intermediate guide , and from the guide to the target. Complex rewriting tasks may require multiple guides, resulting in a sequence of equality saturation steps. A guide can be a complete term, or a sketch containing undefined elements that are instantiated by the equality saturation search. Such sketches may be far more concise than complete terms. We demonstrate the generality and effectiveness of guided equality saturation using two case studies. First, we integrate guided equality saturation in the Lean 4 proof assistant. Proofs are written in the style of textbook proof sketches, as a series of calculations omitting details and skipping steps. These proofs conclude in less than a second instead of minutes when compared to unguided equality saturation, and can find complex proofs that previously had to be done manually. Second, in the compiler of the RISE array language, where unguided equality saturation fails to perform optimizations within an hour and using 60 GB of memory, guided equality saturation performs the same optimizations with at most 3 guides, within seconds using less than 1 GB memory.
@article{paperbot2594,
title = {Guided Equality Saturation},
author = {Thomas Kœhler and Andrés Goens and Siddharth Bhat and Tobias Grosser and Phil Trinder and Michel Steuwer},
journal = {Proceedings of the ACM on Programming Languages},
volume = {8},
number = {POPL},
year = {2024},
doi = {10.1145/3632900}
}