Optimizations of Bottom-Up Evaluation with Non-Ground Terms

Bottom-up evaluation of logic programs can be seen as an implementation of memoization. Memoization helps detect loops, avoid repeated computation when subgoals are generated repeatedly, and in conjunction with a fair search strategy, as in bottom-up evaluation, ensures that evaluation is complete. Programs that generate non-ground facts (i.e., facts containing universally quantiied variables) and also need memoization are important in several contexts such as the implementation of meta-interpreters, abstract interpretation and partial evaluation. Current bottom-up evaluation techniques (and other memoing techniques), while eecient for programs that generate only ground facts, are very ineecient for programs that generate non-ground facts. In this paper we present an eecient bottom-up evaluation technique for programs that generate non-ground facts. The technique includes a combination of a modiied Magic rewriting technique, and a run-time evaluation technique that incorporates several new optimizations. The technique maintains extra information with query and answer facts in order to speed upànswer-return' uniications. The technique has been implemented, and enables us to run some programs faster (asymptotically and practically) than using either Prolog or unoptimized bottom-up evaluation. The underlying ideas can also be used to adapt other memoing strategies (e.g., QSQR, Alexander Templates) with similar gains in eeciency. We also show that bottom-up evaluation can be implemented with a time cost that is within a log log factor of Prolog, (or a log factor using our simpler implementation) for all queries on deenite clause programs; conversely, there are programs where bottom-up evaluation is arbitrarily better than Prolog. These results provide important insight into the relation between bottom-up evaluation and top-down evaluation, and signiicantly extend earlier results on the subject. 0 This paper has an appendix containing details that may be useful to the referees. However, the paper is self-contained without the appendix and the appendix does not form a part of the paper.

[1]  Eiichi Goto,et al.  A Hashing Method for Fast Set Operations , 1976, Inf. Process. Lett..

[2]  Fernando Pereira,et al.  A Structure-Sharing Representation for Unification-Based Grammar Formalisms , 1985, ACL.

[3]  François Bancilhon,et al.  Naive Evaluation of Recursively Defined Relations , 1986, On Knowledge Base Management Systems.

[4]  Robert E. Tarjan,et al.  Making data structures persistent , 1986, STOC '86.

[5]  Hisao Tamaki,et al.  OLD Resolution with Tabulation , 1986, ICLP.

[6]  R. Ramakrishnan,et al.  An amateur's introduction to recursive query processing strategies , 1986, SIGMOD '86.

[7]  Laurent Vieille,et al.  Recursive Axioms in Deductive Databases: The Query/Subquery Approach , 1986, Expert Database Conf..

[8]  Kotagiri Ramamohanarao,et al.  A Generalization of the Differential Approach to Recursive Query Evaluation , 1987, J. Log. Program..

[9]  Catriel Beeri,et al.  On the power of magic , 1987, J. Log. Program..

[10]  Suzanne W. Dietrich,et al.  Extension Tables: Memo Relations in Logic Programming , 1987, SLP.

[11]  Laurent Vieille From QSQ towards QoSaQ: Global Optimization of Recursive Queries , 1988, Expert Database Conf..

[12]  Laurent Vieille,et al.  Recursive Query Processing: The Power of Logic , 1989, Theor. Comput. Sci..

[13]  Hirohisa Seki,et al.  On the power of Alexander templates , 1989, PODS.

[14]  Jeffrey D. Ullman,et al.  Bottom-up beats top-down for datalog , 1989, PODS '89.

[15]  François Bry,et al.  Query Evaluation in Deductive Databases: Bottom-Up and Top-Down Reconciled , 1990, Data Knowl. Eng..

[16]  Richard A. O'Keefe,et al.  The Craft of Prolog , 1990 .

[17]  Gopal Gupta,et al.  On Criteria for Or-Parallel Execution Models of Logic Programs , 1990, NACLP.

[18]  Sergio Greco,et al.  Minimum and maximum predicates in logic programming , 1991, PODS '91.

[19]  S. Sudarshan,et al.  Aggregation and Relevance in Deductive Databases , 1991, VLDB.

[20]  Kenneth A. Ross,et al.  Modular acyclicity and tail recursion in logic programs , 1991, PODS.

[21]  S. Sudarshan Top-Down vs . Bottom-Up Revisited , 1991 .

[22]  Raghu Ramakrishnan,et al.  Magic Templates: A Spellbinding Approach To Logic Programs , 1991, J. Log. Program..

[23]  Robert E. Tarjan,et al.  Fully persistent lists with catenation , 1991, SODA '91.

[24]  Divesh Srivastava,et al.  Controlling the Search in Bottom-Up Evaluation , 1992, JICSLP.

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

[26]  David Scott Warren,et al.  Memoing for logic programs , 1992, CACM.

[27]  Divesh Srivastava,et al.  Rule Ordering in Bottom-Up Fixpoint Evaluation of Logic Programs , 1990, IEEE Trans. Knowl. Data Eng..