Tabling Mechanisms for Logic Programs

The use of tabling in logic programming allows bottom-up evaluation to be incorporated in a top-down framework, combining advantages that accrue from both. At the engine level, tabling also introduces complications not present in pure top-down evaluation, due to the need for subgoals and answers to access tables during clause resolution. This paper describes the design, implementation, and experimental evaluation of data structures and algorithms for high-performance table access. Our approach uses tries as the basis for tables. Tries provide complete discrimination for terms, and permit a lookup and possible insertion to be performed in a single pass through a term. A novel technique of substitution factoring is also proposed. When substitution factoring is used in conjunction with tries, the access cost for answers is proportional to the size of the answer substitution, rather than to the size of the answer itself. As a special case, the access cost of answers to a datalog query is proportional to the number of non-ground arguments of the query, giving a means of dynamic argument reduction. Answer tries can be implemented both as interpreted structures and as compiled WAM-like code. When they are compiled, the speed of computing substitutions through answer tries is competitive with the speed of unit facts compiled as WAM code, or asserted. Because answer tries can also be created an order of magnitude more quickly than asserted code, they form a promising alternative for representing dynamic terms, even in SLD evaluation. A preliminary version of certain results in this paper were presented at the Second Workshop on Logic Programming and Deductive Databases, ICLP-94, Italy 15].

[1]  Hans Jürgen Ohlbach Abstraction Tree Indexing for Terms , 1990, ECAI.

[2]  David Scott Warren,et al.  Query evaluation under the well-founded semantics , 1993, PODS.

[3]  David Scott Warren,et al.  An Abstract Machine for SLG Resolution: Definite Programs , 1994, ILPS.

[4]  R. Ramesh,et al.  A Portable Method of Integrating SLG Resolution into Prolog Systems , 1994, ILPS.

[5]  I. V. Ramakrishnan,et al.  Dynamic Argument Reduction for In-memory Data Queries , 1994, Workshop on Deductive Databases and Logic Programming.

[6]  V.,et al.  Optimizing Clause Resolution in Tabled Logic Programs , 1994 .

[7]  Kotagiri Ramamohanarao,et al.  Design overview of the Aditi deductive database system , 1991, [1991] Proceedings. Seventh International Conference on Data Engineering.

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

[9]  Divesh Srivastava,et al.  CORAL - Control, Relations and Logic , 1992, VLDB.

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

[11]  Carlo Zaniolo,et al.  The LDL System Prototype , 1990, IEEE Trans. Knowl. Data Eng..

[12]  Jeffrey F. Naughton,et al.  Argument Reduction by Factoring , 1989, VLDB.

[13]  Donald E. Knuth,et al.  The art of computer programming: V.1.: Fundamental algorithms , 1997 .

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

[15]  S. Sudarshan,et al.  Optimizations of Bottom-Up Evaluation with Non-Ground Terms , 1993, ILPS.

[16]  Éric Villemonte de la Clergerie,et al.  Layer sharing: an improved structure-sharing framework , 1993, POPL '93.

[17]  Konstantinos Sagonas,et al.  Xsb as an Eecient Deductive Database Engine , 1994 .

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