Abstract
It is by now folklore that the bottom-up evaluation of a program after the “magic set” transformation is “as efficient as” top-down evaluation. There are a number of formalizations of this in the literature. However, the naive formalization is false: As shown by Ross, SLD-resolution can be much more efficient than bottom-up evaluation with magic sets on tail-recursive programs.
We show that this happens only for tail-recursive programs, and that the only problem of magic sets is the materialization of “lemmas”. So magic sets are always “as goal-directed as” SLD-resolution. These results are not surprising, but we believe that the variants given here are especially useful for teaching purposes. We also give rather simple proofs.
Furthermore, we demonstrate that SLD-resolution can be directly simulated by bottom-up evaluable programs if all recursions are tail-recursive. This is based on the meta-interpreter approach of Bry and seems to be very promising.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
F. Bancilhon and Ft. Ramakrishnan. An amateur’s introduction to recursive query processing. In C. Zaniolo, editor, Proc. of SIGMOD’86, pages 16–52, 1986.
S. Brass and J. Dix. A general approach to bottom-up computation of disjunctive semantics. In J. Dix, L. M. Pereira, and T. Przymusinski, editors, Nonmonotonic Extensions of Logic Programming, number 927 in LNAI, pages 127–155. Springer, 1995.
F. Bry. Query evaluation in recursive databases: bottom-up and top-down reconciled. Data & Knowledge Engineering, 5:289–312, 1990.
S. Greco and C. Zaniolo. Optimization of linear logic programs using counting methods. In A. Pirotte, C. Delobel, and G. Gottlob, editors, Advances in Database Technology — EDBT’92, 3rd Int. Conf., number 580 in LNCS, pages 72–87. Springer-Verlag, 1992.
L. Kalinichenko and V. Zadorozhny. A generalized information resource query language and basic query evaluation technique. In C. Delobel, M. Kifer, and Y. Masunaga, editors, Deductive and Object-Oriented Databases, 2nd Int. Conf. (DOOD’91), number 566 in LNCS, pages 547–566. Springer, 1991.
D. B. Kemp, K. Ramamohanarao, and Z. Somogyi. Right-, left- and multi-linear rule transformations that maintain context information. In D. McLeod, R. Sacks-Davis, and H. Schek, editors, Proc. Very Large Data Bases, 16th Int. Conf. (VLDB’90), pages 380–391. Morgan Kaufmann Publishers, 1990.
R. Ramakrishnan, D. Srivastava, S. Sudarshan, and P. Seshadri. The CORAL deductive system. The VLDB Journal, 3:161–210, 1994.
R. Ramakrishnan and S. Sudarshan. Top-down vs. bottom-up revisited. In V. Saraswat and K. Ueda, editors, Proc. of the 1991 Int. Symposium on Logic Programming, pages 321–336. MIT Press, 1991.
K. Ramamohanarao. An implementation overview of the Aditi deductive database system. In S. Ceri, K. Tanaka, and S. Tsur, editors, Deductive and Object-Oriented Databases, Third Int. Conf, (DOOD’93), number 760 in LNCS, pages 184–203. Springer, 1993.
K. A. Ross. Modular acyclicity and tail recursion in logic programs. In Proc. of the Tenth ACM SIGACT-SIGMOD-SIGART Symp. on Princ. of Database Systems (PODS y 91), pages 92–101, 1991.
Y. Sagiv. Is there anything better than magic? In S. Debray and M. Hermenegildo, editors, Proc. of the North American Conf. on Logic Programming, pages 235–254. MIT Press, 1990.
K. Sagonas, T. Swift, and D. S. Warren. XSB as an efficient deductive database engine. In R. T. Snodgrass and M. Winslett, editors, Proc. of the 1994 ACM SIGMOD Int. Conf on Management of Data (SIGMOD’94), pages 442–453, 1994.
H. Seki. On the power of Alexander templates. In Proc. of the Eighth ACM SIGACT-SIGMOD-SIGART Symposium on Principles of Database Systems (PODS’89), pages 150–159, 1989.
J. D. Ullman. Bottom-up beats top-down for Datalog. In Proc. of the Eighth ACM SIGACT-SIGMOD-SIGART Symposium on Principles of Database Systems (PODS’89), pages 140–149, 1989.
J. D. Ullman. Principles of Database and Knowledge-Base Systems, Vol. 2. Computer Science Press, 1989.
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 1996 British Computer Society
About this paper
Cite this paper
Brass, S. (1996). Magic Sets vs. SLD-Resolution. In: Eder, J., Kalinichenko, L.A. (eds) Advances in Databases and Information Systems. Workshops in Computing. Springer, London. https://doi.org/10.1007/978-1-4471-1486-4_13
Download citation
DOI: https://doi.org/10.1007/978-1-4471-1486-4_13
Publisher Name: Springer, London
Print ISBN: 978-3-540-76014-6
Online ISBN: 978-1-4471-1486-4
eBook Packages: Springer Book Archive