Top-Down vs . Bottom-Up Revisited

Ullman ([Ull89a, Ull89b]) has shown that for the evaluation of safe Datalog programs, bottomup evaluation using Magic Sets optimization has time complexity less than or equal to a particular top-down strategy, Queue-based Rule Goal Tree (QRGT) evaluation. This result has sometimes been incorrectly interpreted to mean that bottom-up evaluation beats top-down evaluation for evaluating Datalog programs|top-down strategies such as Prolog (which does no memoing, and uses last call optimization) can beat both QRGT and bottom-up evaluation on some Datalog programs. In this paper we compare a Prolog evaluation based on the WAM model (using last call optimization) with a bottom-up execution based on Magic Templates with Tail Recursion optimization ([Ros91]), and show the following: (1) Bottom-up evaluation makes no more inferences than Prolog for range-restricted programs. (2) For a restricted class of programs (which properly includes safe Datalog) the cost of bottom-up evaluation is never worse than a constant times the cost of Prolog evaluation (and can be much better than Prolog for many programs). Our other main contribution is to identify the factors that make the cost of an inference potentially more expensive in the bottom-up model in the general case; this leads to a clearer understanding of the potential implementation costs of memoing/set-oriented evaluations, and suggests an important direction for future research.

[1]  S BoyerRoger,et al.  Ttle sharing of structure in theorem proving programs , 1972 .

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

[3]  Alvin M. Despain,et al.  Semi-Intelligent Backtracking of Prolog Based on Static Data Dependency Analysis , 1985, SLP.

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

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

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

[7]  Jeffrey D. Ullman,et al.  Principles of Database and Knowledge-Base Systems, Volume II , 1988, Principles of computer science series.

[8]  David Maier,et al.  Computing with logic , 1988 .

[9]  Michael Kifer,et al.  HiLog: A First-Order Semantics for Higher-Order Logic Programming Constructs , 1989, NACLP.

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

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

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

[13]  Jeffrey F. Naughton,et al.  Bottom-Up Evaluation of Logic Programs , 1991, Computational Logic - Essays in Honor of Alan Robinson.

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