Rewrite rule inference using equality saturation
Authors:
Open Access
- 15 October 2021
- journal article
- research article
- Published by Association for Computing Machinery (ACM) in Proceedings of the ACM on Programming Languages
- Vol. 5 (OOPSLA) , 1-28
Abstract
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 rechecked or extended whenever semantics are tweaked. Large rulesets can also be challenging to apply: redundant rules slow down rule-based search and frustrate debugging. This paper explores how equality saturation, a promising technique that uses e-graphs to apply rewrite rules, can also be used to infer rewrite rules. E-graphs can compactly represent the exponentially large sets of enumerated terms and potential rewrite rules. We show that equality saturation efficiently shrinks both sets, leading to faster synthesis of smaller, more general rulesets. We prototyped these strategies in a tool dubbed Ruler. Compared to a similar tool built on CVC4, Ruler synthesizes 5.8× smaller rulesets 25× faster without compromising on proving power. In an end-to-end case study, we show Ruler-synthesized rules which perform as well as those crafted by domain experts, and addressed a longstanding issue in a popular open source tool.Keywords
All Related Versions
Funding Information
- National Science Foundation (1813166, 1749570)
This publication has 54 references indexed in Scilit:
- Simplify: a theorem prover for program checkingJournal of the ACM, 2005
- Automatic generation of peephole optimizationsACM SIGPLAN Notices, 2004
- DenaliACM SIGPLAN Notices, 2002
- Ten years of partial order reduction1998
- An approach for exploring code improving transformationsACM Transactions on Programming Languages and Systems, 1997
- Superoptimizer: a look at the smallest programACM SIGARCH Computer Architecture News, 1987
- Simple Word Problems in Universal Algebras1983
- Efficiency of a Good But Not Linear Set Union AlgorithmJournal of the ACM, 1975
- Peephole optimizationCommunications of the ACM, 1965
- On programming of arithmetic operationsCommunications of the ACM, 1958