Abstract
An e-graph efficiently represents a congruence relation over many expressions. Although they were originally developed in the late 1970s for use in automated theorem provers, a more recent technique known as equality saturation repurposes e-graphs to implement state-of-the-art, rewrite-driven compiler optimizations and program synthesizers. However, e-graphs remain unspecialized for this newer use case. Equality saturation workloads exhibit distinct characteristics and often require ad-hoc e-graph extensions to incorporate transformations beyond purely syntactic rewrites.
This work contributes two techniques that make e-graphs fast and extensible, specializing them to equality saturation. A new amortized invariant restoration technique called rebuilding takes advantage of equality saturation's distinct workload, providing asymptotic speedups over current techniques in practice. A general mechanism called e-class analyses integrates domain-specific analyses into the e-graph, reducing the need for ad hoc manipulation.
We implemented these techniques in a new open-source library called egg. Our case studies on three previously published applications of equality saturation highlight how egg's performance and flexibility enable state-of-the-art results across diverse domains.
- Marc Andries, Gregor Engels, Annegret Habel, Berthold Hofmann, Hans-Jörg Kreowski, Sabine Kuske, Detlef Plump, Andy Schürr, and Gabriele Taentzer. 1999. Graph Transformation for Specification and Programming. Sci. Comput. Program. 34, 1 (April 1999 ), 1-54. https://doi.org/10.1016/S0167-6423 ( 98 ) 00023-9 Google Scholar
Digital Library
- Matthias Boehm. 2019. Apache SystemML. Encyclopedia of Big Data Technologies ( 2019 ), 81-86. https://doi.org/10.1007/978-3-319-77525-8_187 Google Scholar
Cross Ref
- James M. Boyle, Terence J. Harmer, and Victor L. Winter. 1996. The TAMPR Program Transformation System: Simplifying the Development of Numerical Software. In Modern Software Tools for Scientific Computing, SciTools 1996, Oslo, Norway, September 16-18, 1996, Erlend Arge, Are Magnus Bruaset, and Hans Petter Langtangen (Eds.). Birkhäuser, 353-372. https://doi.org/10.1007/978-1-4612-1986-6_17 Google Scholar
Cross Ref
- Martin Davis and Hilary Putnam. 1960. A Computing Procedure for Quantification Theory. J. ACM 7, 3 ( July 1960 ), 201-215. https://doi.org/10.1145/321033.321034 Google Scholar
Digital Library
- Leonardo de Moura and Nikolaj Bjørner. 2007. Eficient E-Matching for SMT Solvers. In Automated Deduction-CADE-21, Frank Pfenning (Ed.). Springer Berlin Heidelberg, Berlin, Heidelberg, 183-198.Google Scholar
- Leonardo De Moura and Nikolaj Bjørner. 2008. Z3: An Eficient SMT Solver. In Proceedings of the Theory and Practice of Software, 14th International Conference on Tools and Algorithms for the Construction and Analysis of Systems (Budapest, Hungary) ( TACAS'08/ETAPS'08). Springer-Verlag, Berlin, Heidelberg, 337-340. http://dl.acm.org/citation.cfm?id= 1792734. 1792766Google Scholar
Cross Ref
- Nachum Dershowitz. 1993. A taste of rewrite systems. Springer Berlin Heidelberg, Berlin, Heidelberg, 199-228. https: //doi.org/10.1007/3-540-56883-2_11 Google Scholar
Cross Ref
- Nachum Dershowitz and Jean-Pierre Jouannaud. 1990. Rewrite Systems. In Handbook of Theoretical Computer Science, Volume B: Formal Models and Semantics, Jan van Leeuwen (Ed.). Elsevier and MIT Press, 243-320. https://doi.org/10.1016/b978-0-444-88074-1. 50011-1 Google Scholar
Cross Ref
- David Detlefs, Greg Nelson, and James B. Saxe. 2005. Simplify: A Theorem Prover for Program Checking. J. ACM 52, 3 (May 2005 ), 365-473. https://doi.org/10.1145/1066100.1066102 Google Scholar
Digital Library
- Peter J. Downey, Ravi Sethi, and Robert Endre Tarjan. 1980. Variations on the Common Subexpression Problem. J. ACM 27, 4 (Oct. 1980 ), 758-771. https://doi.org/10.1145/322217.322228 Google Scholar
Digital Library
- Tao Du, Jeevana Priya Inala, Yewen Pu, Andrew Spielberg, Adriana Schulz, Daniela Rus, Armando Solar-Lezama, and Wojciech Matusik. 2018. InverseCSG: automatic conversion of 3D models to CSG trees. 1-16. https://doi.org/10.1145/ 3272127.3275006 Google Scholar
Digital Library
- Kevin Ellis, Daniel Ritchie, Armando Solar-Lezama, and Joshua B. Tenenbaum. 2018. Learning to Infer Graphics Programs from Hand-Drawn Images. In Neural Information Processing Systems (NIPS).Google Scholar
- Zhihao Jia, Oded Padon, James Thomas, Todd Warszawski, Matei Zaharia, and Alex Aiken. 2019. TASO: optimizing deep learning computation with automatic generation of graph substitutions. In Proceedings of the 27th ACM Symposium on Operating Systems Principles. 47-62.Google Scholar
Digital Library
- Rajeev Joshi, Greg Nelson, and Keith Randall. 2002. Denali: A Goal-directed Superoptimizer. SIGPLAN Not. 37, 5 (May 2002 ), 304-314. https://doi.org/10.1145/543552.512566 Google Scholar
Digital Library
- Dexter Kozen. 1977. Complexity of Finitely Presented Algebras. In Proceedings of the Ninth Annual ACM Symposium on Theory of Computing (Boulder, Colorado, USA) ( STOC '77). Association for Computing Machinery, New York, NY, USA, 164-177. https://doi.org/10.1145/800105.803406 Google Scholar
Digital Library
- Henry Massalin. 1987. Superoptimizer: A Look at the Smallest Program. In Proceedings of the Second International Conference on Architectual Support for Programming Languages and Operating Systems (Palo Alto, California, USA) ( ASPLOS II). IEEE Computer Society Press, Washington, DC, USA, 122-126. https://doi.org/10.1145/36206.36194 Google Scholar
Digital Library
- Chandrakana Nandi, James R. Wilcox, Pavel Panchekha, Taylor Blau, Dan Grossman, and Zachary Tatlock. 2018. Functional Programming for Compiling and Decompiling Computer-aided Design. Proc. ACM Program. Lang. 2, ICFP, Article 99 ( July 2018 ), 31 pages. https://doi.org/10.1145/3236794 Google Scholar
Digital Library
- Chandrakana Nandi, Max Willsey, Adam Anderson, James R. Wilcox, Eva Darulova, Dan Grossman, and Zachary Tatlock. 2020. Synthesizing Structured CAD Models with Equality Saturation and Inverse Transformations. In Proceedings of the 41st ACM SIGPLAN Conference on Programming Language Design and Implementation (London, UK) ( PLDI 2020 ). Association for Computing Machinery, New York, NY, USA, 31-44. https://doi.org/10.1145/3385412.3386012 Google Scholar
Digital Library
- Charles Gregory Nelson. 1980. Techniques for Program Verification. Ph.D. Dissertation. Stanford, CA, USA. AAI8011683.Google Scholar
- Greg Nelson and Derek C. Oppen. 1980. Fast Decision Procedures Based on Congruence Closure. J. ACM 27, 2 (April 1980 ), 356-364. https://doi.org/10.1145/322186.322198 Google Scholar
Digital Library
- Robert Nieuwenhuis and Albert Oliveras. 2005. Proof-Producing Congruence Closure. In Proceedings of the 16th International Conference on Term Rewriting and Applications (Nara, Japan) ( RTA'05). Springer-Verlag, Berlin, Heidelberg, 453-468. https://doi.org/10.1007/978-3-540-32033-3_33 Google Scholar
Digital Library
- Pavel Panchekha, Alex Sanchez-Stern, James R. Wilcox, and Zachary Tatlock. 2015. Automatically Improving Accuracy for Floating Point Expressions. SIGPLAN Not. 50, 6 ( June 2015 ), 1-11. https://doi.org/10.1145/2813885.2737959 Google Scholar
Digital Library
- Varot Premtoon, James Koppel, and Armando Solar-Lezama. 2020. Semantic Code Search via Equational Reasoning. In Proceedings of the 41st ACM SIGPLAN Conference on Programming Language Design and Implementation (London, UK) ( PLDI 2020 ). Association for Computing Machinery, New York, NY, USA, 1066-1082. https://doi.org/10.1145/3385412.3386001 Google Scholar
Digital Library
- Gopal Sharma, Rishabh Goyal, Difan Liu, Evangelos Kalogerakis, and Subhransu Maji. 2017. CSGNet: Neural Shape Parser for Constructive Solid Geometry. CoRR abs/1712.08290 ( 2017 ). arXiv: 1712.08290 http://arxiv.org/abs/1712.08290Google Scholar
- Michael Stepp, Ross Tate, and Sorin Lerner. 2011. Equality-Based Translation Validator for LLVM. In Computer Aided Verification, Ganesh Gopalakrishnan and Shaz Qadeer (Eds.). Springer Berlin Heidelberg, Berlin, Heidelberg, 737-742.Google Scholar
- Robert Endre Tarjan. 1975. Eficiency of a Good But Not Linear Set Union Algorithm. J. ACM 22, 2 (April 1975 ), 215-225. https://doi.org/10.1145/321879.321884 Google Scholar
Digital Library
- Ross Tate, Michael Stepp, Zachary Tatlock, and Sorin Lerner. 2009. Equality Saturation: A New Approach to Optimization. In Proceedings of the 36th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (Savannah, GA, USA) ( POPL '09). ACM, New York, NY, USA, 264-276. https://doi.org/10.1145/1480881.1480915 Google Scholar
Digital Library
- Yonglong Tian, Andrew Luo, Xingyuan Sun, Kevin Ellis, William T. Freeman, Joshua B. Tenenbaum, and Jiajun Wu. 2019. Learning to Infer and Execute 3D Shape Programs. In International Conference on Learning Representations. https://openreview.net/forum?id=rylNH20qFQGoogle Scholar
- Mark van den Brand, Jan Heering, Paul Klint, and Pieter A. Olivier. 2002. Compiling language definitions: the ASF+SDF compiler. ACM Trans. Program. Lang. Syst. 24, 4 ( 2002 ), 334-368. https://doi.org/10.1145/567097.567099 Google Scholar
Digital Library
- Eelco Visser, Zine-El-Abidine Benaissa, and Andrew P. Tolmach. 1998. Building Program Optimizers with Rewriting Strategies. In Proceedings of the third ACM SIGPLAN International Conference on Functional Programming (ICFP '98), Baltimore, Maryland, USA, September 27-29, 1998, Matthias Felleisen, Paul Hudak, and Christian Queinnec (Eds.). ACM, 13-26. https://doi.org/10.1145/289423.289425 Google Scholar
Digital Library
- Yisu Remy Wang, Shana Hutchison, Jonathan Leang, Bill Howe, and Dan Suciu. 2020. SPORES: Sum-Product Optimization via Relational Equality Saturation for Large Scale Linear Algebra. Proceedings of the VLDB Endowment ( 2020 ).Google Scholar
Digital Library
- Chenming Wu, Haisen Zhao, Chandrakana Nandi, Jefrey I. Lipton, Zachary Tatlock, and Adriana Schulz. 2019. Carpentry Compiler. ACM Transactions on Graphics 38, 6 ( 2019 ), Article No. 195. presented at SIGGRAPH Asia 2019.Google Scholar
Digital Library
Index Terms
egg: Fast and extensible equality saturation
Recommendations
Neural adaptive control for uncertain nonlinear system with input saturation
This paper presents neural adaptive control methods for a class of nonlinear systems in the presence of actuator saturation. Backstepping technique is widely used for the control of nonlinear systems. By introducing alternative state variables and ...
Reducing Overparameterization of Symbolic Regression Models with Equality Saturation
GECCO '23: Proceedings of the Genetic and Evolutionary Computation ConferenceOverparameterized models in regression analysis are often harder to interpret and can be harder to fit because of ill-conditioning. Genetic programming is prone to overparameterized models as it evolves the structure of the model without taking the ...
Rewrite rule inference using equality saturation
Many compilers, synthesizers, and theorem provers rely on rewrite rules to simplify expressions or prove equivalences. Developing rewrite rules can be difficult: rules may be subtly incorrect, profitable rules are easy to miss, and rulesets must be ...






Comments