The LISP7O Pattern Matching System

Lawrence G. Tesler, Horace J. Enea, David Canfield SmithIJCAI 1973

Abstract

LISP70 is an extensible descendant of LISP that replaces traditional algorithmic function definitions with a powerful system of pattern-directed rewrite rules. By compiling these rules into efficient discrimination trees and automatically ordering them by "specificity," LISP70 allows developers to build highly customizable compilers and AI planning systems that are both more readable and more efficient than their predecessors.

Introduction

In the early 1970s, LISP was the preeminent language for Artificial Intelligence, yet it faced significant challenges. Standard S-expressions were often cumbersome for describing the complex symbolic transformations required for natural language processing or compiler design. Furthermore, extending LISP typically necessitated deep modifications to the interpreter's internals. A persistent tension existed between "tailoring" a language for specific problem-solving facilities and "tuning" it for performance. Most systems of that era relied on interpreters for flexibility, which inevitably sacrificed execution speed. LISP70 was developed as a "successor to LISP" to resolve these issues through a natively extensible, compiler-only architecture.

The Pattern-Directed Rewrite System

The core innovation of LISP70 is its Pattern-Directed Rewrite System. Instead of traditional algorithmic functions, programmers define rules using a Decomposer -> Recomposer (DEC -> REC) syntax. This approach allows for several key technical features:

  • The Replacement Mechanism: Function calls within patterns can act as non-terminal symbols in a top-down parser, consuming arguments from the input stream and injecting results back for further matching.
  • Extensible Functions: The ALSO clause allows users to add new rewrite rules to existing functions modularly, enabling specialized optimizations without altering the base compiler.
  • Automatic Specificity Ordering: To ensure the most precise match is found first, LISP70 uses a specificity algorithm that automatically reorders rules so that literals are checked before general variables.

Architecture: From ML to LAP

LISP70 achieves high performance and portability by avoiding direct compilation to hardware. Instead, it compiles to an intermediate, machine-independent language called "ML," based on the Burroughs 5000 architecture. This ML code is subsequently translated into machine-specific "LAP" (LISP Assembly Program) code.

Comparison of ML (Machine Language) and LAP (LISP Assembly Program) code generation.

This two-stage compilation process ensures that the system remains portable while maintaining the efficiency of native machine code. By eliminating the interpreter entirely—even the EVAL function works by compiling on the fly—LISP70 ensures that the execution environment and the compiler are always synchronized.

Key Insights and Efficiency

To optimize pattern matching, LISP70 utilizes discrimination trees. The system "factors" rules so that if multiple rules share the same initial test, that test is performed only once. This minimizes backtracking overhead. Additionally, the system handles "existential values" by automatically generating unique labels (similar to GENSYM) when a variable appears in the Recomposer but not the Decomposer, a feature particularly useful for compiler construction.

The authors argue that a language should be a "kernel" that users can tailor. By integrating S-expressions, Algol-like MLISP, and rewrite rules, LISP70 provides a versatile toolkit where programmers can choose the most appropriate notation for their specific task.

Results and Future Work

The transition to rewrite rules has demonstrated significant benefits in "lucid programming." Complex logic, such as robot planning or recursive compiler translations, becomes more readable and less error-prone compared to traditional LISP. Despite the lack of an interpreter, the backtracking implementation in LISP70 is highly efficient, incurring minimal time or space overhead.

While the system was successfully used for question-answering and planning programs on the PDP-10, the authors noted challenges in debugging within a compiler-only environment. Future work aimed to expand control structures, improve interactive editing, and bootstrap the compiler onto other hardware architectures.

Summary updated

BibTeX
@inproceedings{tesler1973lisp,
  author = {Lawrence G. Tesler and Horace J. Enea and David Canfield Smith},
  title = {{The LISP7O Pattern Matching System}},
  booktitle = {International Joint Conference on Artificial Intelligence},
  year = {1973},
}
Figure