A Parsing System Based on Logic Programming

Yuji Matsumoto, Ryôichi Sugimura

Abstract

This paper introduces SAX, a parsing system that translates restricted Definite Clause Grammars (DCGs) into efficient Prolog programs. By integrating a bottom-up parsing strategy with top-down prediction, SAX effectively handles left-recursive rules without backtracking or redundant computations. Experimental results demonstrate that SAX achieves a nearly tenfold speedup over previous systems like BUP when compiled, providing a practical solution for natural language processing in logic programming environments.

Introduction

In the mid-1980s, Definite Clause Grammars (DCGs) were a standard for natural language description in Prolog. However, standard top-down implementations suffered from two primary drawbacks: infinite loops caused by left-recursion (e.g., NP -> NP PP) and computational inefficiency due to redundant backtracking. While bottom-up parsers like the BUP system addressed left-recursion, they often relied on side-effects for state management, hindering compiler optimization.

The SAX system (the sequential counterpart to the parallel PAX system) was developed to bridge this gap. It offers a theoretically sound framework that is fast enough for real-world applications by translating grammar rules into optimized, tail-recursive Prolog predicates.

Methodology

The SAX system employs a hybrid parsing strategy that combines bottom-up construction with top-down filtering.

Grammar Translation and Prediction

SAX translates a restricted subset of DCG into Prolog. To manage the search space, it utilizes "top-down prediction" via a filtering mechanism. A structure is only constructed if it is "linked" to a symbol currently expected by the parser. This is achieved by distinguishing between:

  • Type-One Occurrences: The first element in a grammar rule's right-hand side, which triggers the rule.
  • Type-Two Occurrences: Subsequent elements that augment the partial structure.

Optimization via Processes

A key innovation in SAX is the representation of partial parses as "processes" (predicate calls) rather than using side-effects. This approach allows the Prolog compiler to apply advanced optimizations, such as tail-recursion elimination, leading to significant performance gains over previous systems.

Experimental Evaluation

The system was evaluated using a modified version of Jane Robinson’s "Diagram" grammar, comprising approximately 200 rules and 500 lexical entries. The test set consisted of eight sentences of varying complexity (8 to 34 words) extracted from Robinson's original research.

Results

The primary performance metric was the time required to parse the test sentences on two different hardware platforms: a VAX 11/785 running Quintus Prolog and the specialized PSI (Prolog Machine).

Table 1: Performance benchmarks for the SAX system across eight test sentences.

As shown in the table above, SAX demonstrates robust performance across a range of sentence lengths. Notably, for a complex 32-word sentence (Sentence 7), the system achieved a parse time of 1,530ms on the VAX and 741ms on the PSI. When compiled, SAX consistently outperformed the BUP system by nearly an order of magnitude. The deterministic nature of the translated code ensures that parsing time remains predictable and efficient, avoiding the overhead of backtracking.

Conclusion

SAX represents a significant advancement in logic-based parsing. By moving away from side-effect-heavy implementations and leveraging the strengths of Prolog compilers, the authors achieved a high-performance system capable of handling complex natural language structures. Future work includes relaxing DCG restrictions to support more complex linguistic theories and extending the system to handle the unique challenges of Japanese morphological analysis and segmentation.

Summary updated

BibTeX
@inproceedings{matsumoto1987parsing,
  author = {Yuji Matsumoto and Ryôichi Sugimura},
  title = {{A Parsing System Based on Logic Programming}},
  booktitle = {International Joint Conference on Artificial Intelligence},
  year = {1987},
}
Figure