Fast and Optimal Extraction for Sparse Equality Graphs
Amir Kafshdar Goharshady, Chun Kit Lam, Lionel Parreaux
摘要
Equality graphs (e-graphs) are used to compactly represent equivalence classes of terms in symbolic reasoning systems. Beyond their original roots in automated theorem proving, e-graphs have been used in a variety of applications. They have become particularly important as the key ingredient in the popular technique of equality saturation , which has notable applications in compiler optimization, program synthesis, program verification, and symbolic execution, among others. In a typical equality saturation workflow, an e-graph is used to store a large number of equalities that are generated by local rewrites during a saturation phase, after which an optimal term is extracted from the e-graph as the output of the technique. However, despite its crucial role in equality saturation, e-graph extraction has received relatively little attention in the literature, which we seek to start addressing in this paper. Extraction is a challenging problem and is notably known to be NP-hard in general, so current equality saturation tools rely either on slow optimal extraction algorithms based on integer linear programming (ILP) or on heuristics that may not always produce the optimal result. In fact, in this paper, we show that e-graph extraction is hard to approximate within any constant ratio. Thus, any such heuristic will produce wildly suboptimal results in the worst case. Fortunately, we show that the problem becomes tractable when the e-graph is sparse, which is the case in many practical applications. We present a novel parameterized algorithm for extracting optimal terms from e-graphs with low treewidth, a measure of how “tree-like” a graph is, and prove its correctness. We also present an efficient Rust implementation of our algorithm and evaluate it against ILP on a number of benchmarks extracted from the Cranelift benchmark suite, a real-world compiler optimization library based on equality saturation. Our algorithm optimally extracts e-graphs with treewidths of up to 10 in a fraction of the time taken by ILP. These results suggest that our algorithm can be a valuable tool for equality saturation users who need to extract optimal terms from sparse e-graphs.
问 Lune
几分钟读透这篇 Paper,不用再花一下午。
Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。
已有 8 篇顶会 Paper 引用了它。别等审稿人问起,先弄清它们发现了什么。
脉络
- Efficient Extraction for Effectful E-graphs 引用了 Synthesizing structured CAD models with equality saturation and inverse transformations
- Efficient Extraction for Effectful E-graphs 引用了 Better Together: Unifying Datalog and Equality Saturation
- Improving Equality Saturation for EDA via Semantic E-Graphs 引用了 Synthesizing structured CAD models with equality saturation and inverse transformations
- Improving Equality Saturation for EDA via Semantic E-Graphs 引用了 Better Together: Unifying Datalog and Equality Saturation
- A New Approach to Optimal Function Inlining for Code Size Minimization via E-graphs 引用了 Semantic code search via equational reasoning
- A New Approach to Optimal Function Inlining for Code Size Minimization via E-graphs 引用了 Rewrite rule inference using equality saturation
- Better Together: Unifying Datalog and Equality Saturation 引用了 Synthesizing structured CAD models with equality saturation and inverse transformations
- Better Together: Unifying Datalog and Equality Saturation 引用了 Rewrite rule inference using equality saturation
- EGG-SR: Embedding Symbolic Equivalence into Symbolic Regression via Equality Graph 引用了 Rewrite rule inference using equality saturation
- Rewrite rule inference using equality saturation 引用了 Synthesizing structured CAD models with equality saturation and inverse transformations
- Rewrite rule inference using equality saturation 引用了 Semantic code search via equational reasoning
引用它的顶会 Paper8
- HeuriGym: An Agentic Benchmark for LLM-Crafted Heuristics in Combinatorial OptimizationHongzheng Chen, Yingheng Wang, Yaohui Cai, Hins Hu 等ICLR 2026 · 26 次引用
- EGG-SR: Embedding Symbolic Equivalence into Symbolic Regression via Equality GraphNan Jiang, Ziyi Wang, Yexiang XueICLR 2026 · 3 次引用
- Efficient Extraction for Effectful E-graphsOliver Flatt, Anjali Pal, Yihong Zhang, Ryan Tjoa 等OOPSLA 2026 · 1 次引用
- A New Approach to Optimal Function Inlining for Code Size Minimization via E-graphsAmir K. Goharshady, Chun Kit Lam, Andreas Pavlogiannis, Ahmed Khaled ZaherOOPSLA 2026 · 1 次引用
- Improving Equality Saturation for EDA via Semantic E-GraphsSijie Kong, Jingtao Xia, Daniel Ruelas-Petrisko, Zachary D. Sisco 等PLDI 2026
它引用的 Paper14
- Synthesizing structured CAD models with equality saturation and inverse transformationsChandrakana Nandi, Max Willsey, Adam Anderson, James R. Wilcox 等PLDI 2020 · 65 次引用
- Semantic code search via equational reasoningVarot Premtoon, James Koppel, Armando Solar-LezamaPLDI 2020 · 49 次引用
- A Single-Exponential Time 2-Approximation Algorithm for TreewidthTuukka KorhonenFOCS 2021 · 49 次引用
- Better Together: Unifying Datalog and Equality SaturationYihong Zhang, Yisu Remy Wang, Oliver Flatt, David Cao 等PLDI 2023 · 38 次引用
- Rewrite rule inference using equality saturationChandrakana Nandi, Max Willsey, Amy Zhu, Yisu Remy Wang 等OOPSLA 2021 · 35 次引用
相关 Paper
- egg: Fast and extensible equality saturationMax Willsey, Chandrakana Nandi, Yisu Remy Wang, Oliver Flatt 等POPL 2021 · 170 次引用
- Slotted E-Graphs: First-Class Support for (Bound) Variables in E-GraphsRudi Schneider, Marcus Rossel, Amir Shaikhha, Andrés Goens 等PLDI 2025 · 1 次引用
- Equivalence Hypergraphs: DPO Rewriting for Monoidal E-GraphsAleksei Tiurin, Chris Barrett, Dan R. Ghica, Nick HuLICS 2025
- Dis/Equality GraphsGeorge Zakhour, Pascal Weisenburger, Jahrim Gabriele Cesario, Guido SalvaneschiPOPL 2025 · 3 次引用
- Optimism in Equality SaturationRussel Arbore, Alvin Cheung, Max WillseyPLDI 2026
