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.
Reflective Metagraph Rewriting as a Foundation for an AGI "Language of Thought"
MeTTa(Meta Type Talk)是一种新的程序设计语言,用于OpenCog Hyperon AGI系统。它被设计为一种元语言,具有非常基本和通用的设施,用于处理符号、接地、变量、类型、替换和模式匹配。原语的存在是为了创建新的类型系统和相关的DSL。非正式地说,MeTTa是Hyperon最低级的“思想语言”--学习更具体知识表示的算法将在其中操作的元语言,并且这些算法本身可以在其中表示。在这里,我们解释了如何将MeTTa语言形式化为元数据重写规则系统,这种方法自然适合Hyperon框架,因为后者的核心组件是分布式元数据知识存储(Atomspace)。构成MeTTa程序的元图重写规则也可以表示为元图,为MeTTa反射和自修改代码提供了自然模型。考虑到MeTTa程序计算其他MeTTa程序的执行轨迹之间的等价性,允许我们使用同伦类型论来建模MeTTa执行轨迹的空间。考虑到在MeTTa程序的执行轨迹之间映射的MeTTa程序的限制,我们发现,给定的MeTTa码基被有效地建模为无穷广群,并且所有MeTTa码基的空间被建模为(无穷,1)-topis。在离散物理学上下文中,该拓扑基本上与先前从关于超图的重写规则导出的所谓的“Ruliad”相同。作为元数据重写规则的MeTTA的形式化还可以提供有用的框架,用于在MeTTa解释器内构造用于模式匹配和等式推断的有效方法的实现。