Principles and practice of unification factoring

The efficiency of resolution-based logic programming languages, such as Prolog, depends critically on selecting and executing sets of applicable clause heads to resolve against subgoals. Traditional approaches to this problem have focused on using indexing to determine the smallest possible applicable set. Despite their usefulness, these approaches ignore the nondeterminism inherent in many programming languages to the extent that they do not attempt to optimize execution after the applicable set has been determined. Unification factoring seeks to rectify this omission by regarding the indexing and unification phases of clause resolution as a single process. This article formalizes that process through the construction of factoring automata. A polynomial-time algorithm is given for constructing optimal factoring automata that preserve the clause selection strategy of Prolog. More generally, when the clause selection strategy is not fixed, constructing such an optimal automaton is shown to be NP-complete, solving an open trie minimization problem. Unification factoring is implemented through a source code transformation that preserves the full semantics of Prolog. This transformation is specified in the article, and using it, several well-known programs show significant performance improvements across several different systems. A prototype of unification factoring is available by anonymous ftp.

[1]  Steven Skiena,et al.  Unification factoring for efficient execution of logic programs , 1995, POPL '95.

[2]  Peter Van Roy,et al.  Can Logic Programming Execute as Fast as Imperative Programming? , 1990 .

[3]  J. Lloyd Foundations of Logic Programming , 1984, Symbolic Computation.

[4]  Neng-Fa Zhou Global Optimizations in a Prolog Compiler for the TOAM , 1993, J. Log. Program..

[5]  I. V. Ramakrishnan,et al.  Automata-driven indexing of Prolog clauses , 1989, POPL '90.

[6]  V. Rajaraman,et al.  A Distributed Index Sequential Access Method , 1976, Inf. Process. Lett..

[7]  Ehud Shapiro,et al.  From Decision Trees to Decision Graphs , 1990, NACLP.

[8]  I. V. Ramakrishnan,et al.  Multistage indexing algorithms for speeding prolog execution , 1994, Softw. Pract. Exp..

[9]  Lee Naish,et al.  NUA-Prolog: An Extension to the WAM for Parallel Andorra , 1991, ICLP.

[10]  I. V. Ramakrishnan,et al.  Associative-Commutative Discrimination Nets , 1993, TAPSOFT.

[11]  Evan Tick,et al.  Determinacy testing for nondeterminate logic programming languages , 1994, TOPL.

[12]  Werner Hans,et al.  A Complete Indexing Scheme for WAM-based Abstract Machines , 1992, PLILP.

[13]  David H. D. Warren,et al.  An Efficient Easily Adaptable System for Interpreting Natural Language Queries , 1982, CL.

[14]  I. V. Ramakrishnan,et al.  Adaptive Pattern Matching , 1992, ICALP.

[15]  Ronald L. Rivest,et al.  Constructing Optimal Binary Decision Trees is NP-Complete , 1976, Inf. Process. Lett..

[16]  Michael J. Maher,et al.  Unification Revisited , 1988, Foundations of Deductive Databases and Logic Programming..

[17]  Timothy J. Hickey,et al.  Global Compilation of Prolog , 1989, J. Log. Program..

[18]  Michael Kifer,et al.  HILOG: A Foundation for Higher-Order Logic Programming , 1993, J. Log. Program..

[19]  Douglas Comer,et al.  The Complexity of Trie Index Construction , 1977, JACM.