Associative-Commutative Rewriting

Nachum Dershowitz, Jieh Hsiang, N. Alan Josephson, David A. PlaistedIJCAI 1983

Introduction

Term-rewriting systems serve as fundamental automated tools for simplifying mathematical expressions by repeatedly replacing sub-terms with simpler equivalents. However, a significant hurdle arises when functions exhibit Associative-Commutative (AC) properties, such as addition ($+$) or logical AND ($\wedge$). Standard rewriting techniques often fail in these contexts because simple commutative rules like $u + v \to v + u$ lead to infinite loops. This paper details the integration of AC-handling into the REVE rewrite laboratory and introduces the Associative Path Ordering (APO) to ensure system termination.

The Challenge of AC Axioms

In symbolic logic and computer science, the goal of rewriting is to reach a "normal form"—a unique, simplest version of an expression. When operators are AC, the number of possible permutations for a single expression grows exponentially. This creates two primary difficulties:

  1. Unification: Matching a pattern like $u + v$ against a term requires considering all possible groupings and orders.
  2. Termination: Proving that a sequence of rewrites will eventually stop is difficult because terms can be rearranged without necessarily appearing "simpler" to a standard algorithm.

Methodology: Extending the REVE Environment

The authors extended the REVE environment to address these challenges through three primary mechanisms:

AC Unification and Completion

The system integrates Stickel’s algorithm for AC unification, which involves solving linear Diophantine equations to find valid matches under AC assumptions. Furthermore, the Knuth-Bendix completion procedure was adapted to handle AC operators. This procedure transforms a set of equations into a consistent set of directed rewrite rules using "pseudo-rules" to maintain consistency across different term structures.

Proving Termination: Associative Path Ordering (APO)

The core theoretical contribution is the Associative Path Ordering (APO). Unlike standard recursive path orderings that view terms as binary trees, APO "flattens" terms into variadic trees. For example, $f(a, f(b, c))$ becomes $f(a, b, c)$. By transforming terms into sets of minimal elements, APO allows the system to compare the "weight" of terms even when their internal structure is rearranged by AC properties, providing a rigorous proof that the rewriting process will terminate.

Benchmarks and Applications

The effectiveness of these methods was evaluated using several classic symbolic benchmarks.

Symbolic Differentiation

The system was used to implement a set of rules for calculating derivatives. This requires handling both the associativity of addition and the commutativity of multiplication to simplify the resulting expressions effectively.

Rewrite rules for symbolic differentiation.

Boolean Algebra and Logic Programming

A significant achievement was the creation of a complete rewrite system for propositional logic. The authors demonstrated a refutationally complete theorem prover for Boolean algebra. By adding specific rules for first-order predicate calculus, the system can automatically derive contradictions, thereby proving theorems.

Rewrite rules for a Boolean algebra system.

Key Insights

The research suggests that AC rewriting can serve as a declarative alternative to logic programming languages like Prolog. While Prolog relies on resolution, this system utilizes completion, allowing rules to be treated as bidirectional equivalences. The implementation of APO significantly reduces the computational overhead of checking term ordering, which is notoriously difficult in AC systems.

Conclusion and Future Work

The successful implementation of AC unification and completion in REVE represents a major step forward for automated reasoning. While the system currently requires some manual guidance—specifically in defining the initial operator hierarchy—it provides the first rigorous proofs of termination for complex Boolean systems. Future work aims to optimize the handling of variables within the APO and reduce the NP-complete complexity inherent in AC unification for larger rule sets.

Summary updated

BibTeX
@inproceedings{dershowitz1983associative,
  author = {Nachum Dershowitz and Jieh Hsiang and N. Alan Josephson and David A. Plaisted},
  title = {{Associative-Commutative Rewriting}},
  booktitle = {International Joint Conference on Artificial Intelligence},
  year = {1983},
}
Figure