Fast and Optimal Extraction for Sparse Equality Graphs

被引:2
作者
Goharshady, Amir Kafshdar [1 ,2 ]
Lam, Chun Kit [1 ,2 ]
Parreaux, Lionel [1 ,2 ]
机构
[1] Hong Kong Univ Sci & Technol HKUST, Dept Comp Sci, Hong Kong, Peoples R China
[2] Hong Kong Univ Sci & Technol HKUST, Dept Math, Hong Kong, Peoples R China
来源
PROCEEDINGS OF THE ACM ON PROGRAMMING LANGUAGES-PACMPL | 2024年 / 8卷 / OOPSLA期
关键词
e-graphs; equality saturation; extraction; treewidth; MODEL CHECKING; TREE-WIDTH; TREEWIDTH; ALGORITHM; MINORS; EFFICIENT; PROGRAMS;
D O I
10.1145/3689801
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
Equality graphs (e-graphs) are used to compactly represent equivalence classes of terms in symbolic reason-ing systems. Beyond their original roots in automated theorem proving, e-graphs have been used in a varietyof applications. They have become particularly important as the key ingredient in the popular technique ofequality saturation, which has notable applications in compiler optimization, program synthesis, programverification, and symbolic execution, among others. In a typical equality saturation workflow, an e-graph isused to store a large number of equalities that are generated by local rewrites during a saturation phase, afterwhich an optimal term isextractedfrom the e-graph as the output of the technique. However, despite itscrucial 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 tobe NP-hard in general, so current equality saturation tools rely either on slow optimal extraction algorithmsbased 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 ishard to approximatewithin any constant ratio. Thus,any such heuristic will produce wildly suboptimal results in the worst case. Fortunately, we show that theproblem becomes tractable when the e-graph is sparse, which is the case in many practical applications. Wepresent a novel parameterized algorithm for extracting optimal terms from e-graphs with low treewidth, ameasure of how "tree-like" a graph is, and prove its correctness. We also present an efficient Rust implemen-tation of our algorithm and evaluate it against ILP on a number of benchmarks extracted from the Craneliftbenchmark suite, a real-world compiler optimization library based on equality saturation. Our algorithm op-timally extracts e-graphs with treewidths of up to 10 in a fraction of the time taken by ILP. These resultssuggest that our algorithm can be a valuable tool for equality saturation users who need to extract optimalterms from sparse e-graphs
引用
收藏
页数:27
相关论文
共 91 条
[71]   FAST DECISION PROCEDURES BASED ON CONGRUENCE CLOSURE [J].
NELSON, G ;
OPPEN, DC .
JOURNAL OF THE ACM, 1980, 27 (02) :356-364
[72]  
Nieuwenhuis R, 2005, LECT NOTES COMPUT SC, V3467, P453
[73]  
Obdrzálek J, 2003, LECT NOTES COMPUT SC, V2725, P80
[74]  
Oliveira MD, 2023, AAAI CONF ARTIF INTE, P6297
[75]   Semantic Code Search via Equational Reasoning [J].
Premtoon, Varot ;
Koppel, James ;
Solar-Lezama, Armando .
PROCEEDINGS OF THE 41ST ACM SIGPLAN CONFERENCE ON PROGRAMMING LANGUAGE DESIGN AND IMPLEMENTATION (PLDI '20), 2020, :1066-1082
[76]  
Reed B. A., 1992, Proceedings of the Twenty-Fourth Annual ACM Symposium on the Theory of Computing, P221, DOI 10.1145/129712.129734
[77]   GRAPH MINORS .3. PLANAR TREE-WIDTH [J].
ROBERTSON, N ;
SEYMOUR, PD .
JOURNAL OF COMBINATORIAL THEORY SERIES B, 1984, 36 (01) :49-64
[78]   GRAPH MINORS .1. EXCLUDING A FOREST [J].
ROBERTSON, N ;
SEYMOUR, PD .
JOURNAL OF COMBINATORIAL THEORY SERIES B, 1983, 35 (01) :39-61
[79]   GRAPH MINORS .2. ALGORITHMIC ASPECTS OF TREE-WIDTH [J].
ROBERTSON, N ;
SEYMOUR, PD .
JOURNAL OF ALGORITHMS, 1986, 7 (03) :309-322
[80]  
Rosenthal Eli, 2023, E GRAPH RES APPL PRA