Magic Sets and Their Application to Data Integration

  • Wolfgang Faber
  • Gianluigi Greco
  • Nicola Leone
Part of the Lecture Notes in Computer Science book series (LNCS, volume 3363)


We propose a generalization of the well-known Magic Sets technique to Datalog¬ programs with (possibly unstratified) negation under stable model semantics. Our technique produces a new program whose evaluation is generally more efficient (due to a smaller instantiation), while preserving soundness under cautious reasoning. Importantly, if the original program is consistent, then full query-equivalence is guaranteed for both brave and cautious reasoning, which turn out to be sound and complete.

In order to formally prove the correctness of our Magic Sets transformation, we introduce a novel notion of modularity for Datalog¬ under the stable model semantics, which is relevant per se. We prove that a module can be evaluated independently from the rest of the program, while preserving soundness under cautious reasoning. For consistent programs, both soundness and completeness are guaranteed for brave reasoning and cautious reasoning as well. Our Magic Sets optimization constitutes an effective method for enhancing the performance of data-integration systems in which query-answering is carried out by means of cautious reasoning over Datalog¬ programs. In fact, preliminary results of experiments in the EU project INFOMIX, show that Magic Sets are fundamental for the scalability of the system.


Logic Program Stable Model Query Optimization Query Answering Data Integration System 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Ullman, J.D.: Principles of Database and Knowledge Base Systems. Computer Science Press, Rockville (1989)Google Scholar
  2. 2.
    Gelfond, M., Lifschitz, V.: The Stable Model Semantics for Logic Programming. In: ICLP/SLP 1988, pp. 1070–1080. MIT Press, Cambridge (1988)Google Scholar
  3. 3.
    Bidoit, N., Froidevaux, C.: Negation by Default and Unstratifiable Logic Programs. Theoretical Computer Science 78, 85–112 (1991)zbMATHCrossRefMathSciNetGoogle Scholar
  4. 4.
    Dantsin, E., Eiter, T., Gottlob, G., Voronkov, A.: Complexity and Expressive Power of Logic Programming. ACM Computing Surveys 33, 374–425 (2001)CrossRefGoogle Scholar
  5. 5.
    Bidoit, N., Froidevaux, C.: General Logical Databases and Programs: Default Logic Semantics and Stratification. Information and Computation 91, 15–54 (1991)zbMATHCrossRefMathSciNetGoogle Scholar
  6. 6.
    Marek, V.W., Truszczyński, M.: Autoepistemic Logic. JACM 38, 588–619 (1991)zbMATHCrossRefGoogle Scholar
  7. 7.
    Schlipf, J.: The Expressive Powers of Logic Programming Semantics. JCSS 51, 64–86 (1995); Abstract in Proc. PODS 1990, pp. 196–204zbMATHMathSciNetGoogle Scholar
  8. 8.
    Leone, N., Pfeifer, G., Faber, W., Eiter, T., Gottlob, G., Perri, S., Scarcello, F.: The DLV System for Knowledge Representation and Reasoning. In: ACM TOCL (2004) (to appear)Google Scholar
  9. 9.
    Niemelä, I., Simons, P., Syrjänen, T.: Smodels: A System for Answer Set Programming. In: NMR 2000 (2000)Google Scholar
  10. 10.
    Arenas, M., Bertossi, L.E., Chomicki, J.: Specifying and querying database repairs using logic programs with exceptions. In: Proc. of FQAS 2000, pp. 27–41. Springer, Heidelberg (2000)Google Scholar
  11. 11.
    Greco, G., Greco, S., Zumpano, E.: A logic programming approach to the integration, repairing and querying of inconsistent databases. In: Codognet, P. (ed.) ICLP 2001. LNCS, vol. 2237, pp. 348–364. Springer, Heidelberg (2001)CrossRefGoogle Scholar
  12. 12.
    Barceló, P., Bertossi, L.: Repairing databases with annotated predicate logic. In: Proc. the 10th Int. Workshop on Non-Monotonic Reasoning (NMR 2002), pp. 160–170 (2002)Google Scholar
  13. 13.
    Calì, A., Lembo, D., Rosati, R.: Query rewriting and answering under constraints in data integration systems. In: Proc. of IJCAI 2003, pp. 16–21 (2003)Google Scholar
  14. 14.
    Bravo, L., Bertossi, L.: Logic programming for consistently querying data integration systems. In: Proc. of IJCAI 2003, pp. 10–15 (2003)Google Scholar
  15. 15.
    Chomicki, J., Marcinkowski, J.: Minimal-Change Integrity Maintenance Using Tuple Deletions. Information and Computation (2004) (to appear)Google Scholar
  16. 16.
    Lifschitz, V., Turner, H.: Splitting a Logic Program. In: Van Hentenryck, P. (ed.) ICLP 1994, pp. 23–37. MIT Press, Cambridge (1994)Google Scholar
  17. 17.
    Eiter, T., Gottlob, G., Mannila, H.: Disjunctive Datalog. ACM TODS 22, 364–418 (1997)CrossRefGoogle Scholar
  18. 18.
    Dung, P.M.: On the Relations between Stable and Well-Founded Semantics of Logic Programs. Theoretical Computer Science 105, 7–25 (1992)zbMATHCrossRefMathSciNetGoogle Scholar
  19. 19.
    Beeri, C., Ramakrishnan, R.: On the power of magic. JLP 10, 255–259 (1991)zbMATHCrossRefMathSciNetGoogle Scholar
  20. 20.
    Calì, A., Calvanese, D., De Giacomo, G., Lenzerini, M.: Data integration under integrity constraints. Information Systems 29, 147–163 (2004)CrossRefGoogle Scholar
  21. 21.
    Calì, A., Lembo, D., Rosati, R.: On the decidability and complexity of query answering over inconsistent and incomplete databases. In: PODS 2003, pp. 260–271 (2003)Google Scholar
  22. 22.
    Bancilhon, F., Maier, D., Sagiv, Y., Ullman, J.D.: Magic Sets and Other Strange Ways to Implement Logic Programs. In: PODS 1986, pp. 1–16 (1986)Google Scholar
  23. 23.
    Mumick, I.S., Finkelstein, S.J., Pirahesh, H., Ramakrishnan, R.: Magic is relevant. In: SIGMOD Conference 1990, pp. 247–258 (1990)Google Scholar
  24. 24.
    Stuckey, P.J., Sudarshan, S.: Compiling query constraints. In: PODS 1994, pp. 56–67. ACM Press, New York (1994)Google Scholar
  25. 25.
    Ross, K.A.: Modular Stratification and Magic Sets for Datalog Programs with Negation. JACM 41, 1216–1266 (1994)zbMATHCrossRefGoogle Scholar
  26. 26.
    Kemp, D.B., Srivastava, D., Stuckey, P.J.: Bottom-up evaluation and query optimization of well-founded models. Theoretical Computer Science 146, 145–184 (1995)zbMATHCrossRefMathSciNetGoogle Scholar
  27. 27.
    Seshadri, P., Hellerstein, J.M., Pirahesh, H., Leung, T.Y.C., Ramakrishnan, R., Srivastava, D., Stuckey, P.J., Sudarshan, S.: Cost-based optimization for magic: Algebra and implementation. In: SIGMOD Conference 1996, pp. 435–446. ACM Press, New York (1996)CrossRefGoogle Scholar
  28. 28.
    Behrend, A.: Soft stratification for magic set based query evaluation in deductive databases. In: PODS 2003, pp. 102–110. ACM Press, New York (2003)CrossRefGoogle Scholar
  29. 29.
    Greco, S.: Binding Propagation Techniques for the Optimization of Bound Disjunctive Queries. IEEE TKDE 15, 368–385 (2003)Google Scholar
  30. 30.
    Cumbo, C., Faber, W., Greco, G.: Enhancing the magic-set method for disjunctive datalog programs. In: Proc. of ICLP 2004, Saint-Malo, France (2004) (forthcoming)Google Scholar
  31. 31.
    Greco, G., Greco, S., Trubitsyna, I., Zumpano, E.: Optimization of Bound Disjunctive Queries with Constraints. TPLP (to appear (CoRR report cs.LO/0406013))Google Scholar
  32. 32.
    Eiter, T., Fink, M., Greco, G., Lembo, D.: Efficient evaluation of logic programs for querying data integration systems. In: Palamidessi, C. (ed.) ICLP 2003. LNCS, vol. 2916, pp. 163–177. Springer, Heidelberg (2003)CrossRefGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2004

Authors and Affiliations

  • Wolfgang Faber
    • 1
  • Gianluigi Greco
    • 1
  • Nicola Leone
    • 1
  1. 1.Mathematics DepartmentUniversity of CalabriaRendeItaly

Personalised recommendations