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.8X smaller rulesets 25X 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.
翻译:许多汇编者、合成者和理论证明者都依赖重写规则来简化表达式或证明等同。 制定重写规则可能很困难: 规则可能是不正确的, 盈利性规则很容易被忽略, 规则在语义变换时必须重新检查或扩展。 大的规则也可能具有挑战性: 冗余规则会减缓基于规则的搜索, 阻碍调试 。 本文探索平等饱和度, 一种使用电子绘图来应用重写规则的有希望的技术, 也可以用来推导重写规则。 电子图表可以缩略地代表大量列举的术语和潜在的重写规则。 我们显示, 平等饱和性能有效地缩小两种组合, 导致更快速合成更小的、 更通用的规则。 我们将这些战略原型成一个工具, 以调制标尺为规则。 与在 CVC4 上建立的类似工具相比, 规则r 将5. 8x 更小的规则合成为25X, 而不会损害验证权力。 在最后到最后的案例研究中, 我们展示一个长期的域, 将规则组合成一个被处理的域。