skip to main content

egg: Fast and extensible equality saturation

Published:04 January 2021Publication History
Skip Abstract Section

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.

References

  1. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  2. 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 ScholarGoogle ScholarCross RefCross Ref
  3. 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 ScholarGoogle ScholarCross RefCross Ref
  4. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  5. 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 ScholarGoogle Scholar
  6. 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 ScholarGoogle ScholarCross RefCross Ref
  7. 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 ScholarGoogle ScholarCross RefCross Ref
  8. 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 ScholarGoogle ScholarCross RefCross Ref
  9. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  10. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  11. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  12. 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 ScholarGoogle Scholar
  13. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  14. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  15. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  16. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  17. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  18. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  19. Charles Gregory Nelson. 1980. Techniques for Program Verification. Ph.D. Dissertation. Stanford, CA, USA. AAI8011683.Google ScholarGoogle Scholar
  20. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  21. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  22. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  23. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  24. 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 ScholarGoogle Scholar
  25. 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 ScholarGoogle Scholar
  26. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  27. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  28. 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 ScholarGoogle Scholar
  29. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  30. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  31. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  32. 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 ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. egg: Fast and extensible equality saturation

    Recommendations

    Comments

    Login options

    Check if you have access through your login credentials or your institution to get full access on this article.

    Sign in

    Full Access

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader
    About Cookies On This Site

    We use cookies to ensure that we give you the best experience on our website.

    Learn more

    Got it!