Guided Equality Saturation
Thomas Koehler, Andrés Goens, Siddharth Bhat, Tobias Grosser, Phil Trinder, Michel Steuwer
Abstract
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.
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Your agent calls
Luneget_paper_fulltext
Free to start. No credit card required.
Terminal
Install the CLIlune papers fulltext 6d03102e-bf72-4322-898e-a54778154f06Cited by top-tier papers5
- PolyJuice: Detecting Mis-compilation Bugs in Tensor Compilers with Equality Saturation Based RewritingChijin Zhou, Bingzhou Qian, Gwihwan Go, Quan Zhang et al.OOPSLA 2024 · 7 citations
- Exo 2: Growing a Scheduling LanguageYuka Ikarashi, Kevin Qian, Samir Droubi, Alex Reinking et al.ASPLOS 2025 · 7 citations
- Towards Pen-and-Paper-Style Equational Reasoning in Interactive Theorem Provers by Equality SaturationMarcus Rossel, Rudi Schneider, Thomas Koehler, Michel Steuwer et al.POPL 2026 · 2 citations
- Slotted E-Graphs: First-Class Support for (Bound) Variables in E-GraphsRudi Schneider, Marcus Rossel, Amir Shaikhha, Andrés Goens et al.PLDI 2025 · 1 citation
- Improving Equality Saturation for EDA via Semantic E-GraphsSijie Kong, Jingtao Xia, Daniel Ruelas-Petrisko, Zachary D. Sisco et al.PLDI 2026
Builds on9
- Ansor: Generating High-Performance Tensor Programs for Deep LearningLianmin Zheng, Chengfan Jia, Minmin Sun, Zhao Wu et al.OSDI 2020 · 551 citations
- egg: Fast and extensible equality saturationMax Willsey, Chandrakana Nandi, Yisu Remy Wang, Oliver Flatt et al.POPL 2021 · 170 citations
- Synthesizing structured CAD models with equality saturation and inverse transformationsChandrakana Nandi, Max Willsey, Adam Anderson, James R. Wilcox et al.PLDI 2020 · 65 citations
- Vectorization for digital signal processors via equality saturationAlexa VanHattum, Rachit Nigam, Vincent T. Lee, James Bornholt et al.ASPLOS 2021 · 57 citations
- Semantic code search via equational reasoningVarot Premtoon, James Koppel, Armando Solar-LezamaPLDI 2020 · 49 citations
Related papers
- Rewrite rule inference using equality saturationChandrakana Nandi, Max Willsey, Amy Zhu, Yisu Remy Wang et al.OOPSLA 2021 · 35 citations
- Equality Saturation Theory Exploration à la CarteAnjali Pal, Brett Saiki, Ryan Tjoa, Cynthia Richey et al.OOPSLA 2023 · 11 citations
- A Multi-width Parametric Bitvector Equivalence SolverLuigi Rinaldi, John Wickerson, Samuel CowardCAV 2026
- Optimism in Equality SaturationRussel Arbore, Alvin Cheung, Max WillseyPLDI 2026
- The taming of the rew: a type theory with computational assumptionsJesper Cockx, Nicolas Tabareau, Théo WinterhalterPOPL 2021 · 24 citations
