Magic Sets for the Bottom-Up Evaluation of Finitely Recursive Programs

  • Francesco Calimeri
  • Susanna Cozza
  • Giovambattista Ianni
  • Nicola Leone
Part of the Lecture Notes in Computer Science book series (LNCS, volume 5753)


The support for function symbols in logic programming under answer set semantics allows to overcome some modeling limitations of traditional Answer Set Programming (ASP) systems, such as the inability of handling infinite domains. On the other hand, admitting function symbols in ASP makes inference undecidable in the general case. Lately, the research community is focusing on finding proper subclasses for which decidability of inference is guaranteed. The two major proposals, so far, are finitary programs and finitely-ground programs. These two proposals are somehow complementary: indeed, the former is conceived to allow decidable querying (by means of a top-down evaluation strategy), while the latter supports the computability of answer-sets (by means of a bottom-up evaluation strategy). One of the main advantages of finitely-ground programs is that they can be ”directly” evaluated by current ASP systems, which are based on a bottom-up computational model. However, there are also some interesting programs which are suitable for top-down query evaluation; but do not fall in the class of finitely-ground programs.

In this paper, we focus on disjunctive finitely-recursive positive (DFRP) programs. We present a proper adaptation of the magic-sets technique for DFRP programs, which ensures query equivalence under both brave and cautious reasoning. We show that, if the input program is DFRP, then its magic-set rewriting is guaranteed to be finitely ground. Thus, reasoning on DFRP programs turns out to be decidable, and we provide an effective method for its computation on the ASP system DLV.


Logic Program Ground Atom Disjunctive Rule Disjunctive Logic Program Magic Version 
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.
    Baral, C.: Knowledge Representation, Reasoning and Declarative Problem Solving. CUP (2003)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.
    Gelfond, M., Lifschitz, V.: Classical Negation in Logic Programs and Disjunctive Databases. NGC 9, 365–385 (1991)CrossRefzbMATHGoogle Scholar
  4. 4.
    Lifschitz, V.: Answer Set Planning. In: ICLP 1999, pp. 23–37 (1999)Google Scholar
  5. 5.
    Marek, V.W., Truszczyński, M.: Stable Models and an Alternative Logic Programming Paradigm. In: The Logic Programming Paradigm – A 25-Year Perspective, pp. 375–398 (1999)Google Scholar
  6. 6.
    Syrjänen, T.: Omega-restricted logic programs. In: Eiter, T., Faber, W., Truszczyński, M. (eds.) LPNMR 2001. LNCS (LNAI), vol. 2173, p. 267. Springer, Heidelberg (2001)Google Scholar
  7. 7.
    Bonatti, P.A.: Reasoning with infinite stable models II: Disjunctive programs. In: Stuckey, P.J. (ed.) ICLP 2002. LNCS, vol. 2401, pp. 333–346. Springer, Heidelberg (2002)CrossRefGoogle Scholar
  8. 8.
    Bonatti, P.A.: Reasoning with infinite stable models. AI 156(1), 75–111 (2004)MathSciNetzbMATHGoogle Scholar
  9. 9.
    Simkus, M., Eiter, T.: FDNC: Decidable Non-monotonic Disjunctive Logic Programs with Function Symbols. In: Dershowitz, N., Voronkov, A. (eds.) LPAR 2007. LNCS (LNAI), vol. 4790, pp. 514–530. Springer, Heidelberg (2007)CrossRefGoogle Scholar
  10. 10.
    Lin, F., Wang, Y.: Answer Set Programming with Functions. In: KR 2008, Sydney, Australia, pp. 454–465. AAAI Press, Menlo Park (2008)Google Scholar
  11. 11.
    Cabalar, P.: Partial Functions and Equality in Answer Set Programming. In: Garcia de la Banda, M., Pontelli, E. (eds.) ICLP 2008. LNCS, vol. 5366, pp. 392–406. Springer, Heidelberg (2008)CrossRefGoogle Scholar
  12. 12.
    Calimeri, F., Cozza, S., Ianni, G., Leone, N.: Computable Functions in ASP: Theory and Implementation. In: Garcia de la Banda, M., Pontelli, E. (eds.) ICLP 2008. LNCS, vol. 5366, pp. 407–424. Springer, Heidelberg (2008)CrossRefGoogle Scholar
  13. 13.
    Baselice, S., Bonatti, P.A., Criscuolo, G.: On Finitely Recursive Programs. Tech. Report 0901.2850v1, (2009); To appear in TPLP (TPLP)Google Scholar
  14. 14.
    Bonatti, P.A.: Erratum to: Reasoning with infinite stable models. AI 172(15), 1833–1835 (2008)zbMATHGoogle Scholar
  15. 15.
    Leone, N., Pfeifer, G., Faber, W., Eiter, T., Gottlob, G., Perri, S., Scarcello, F.: The DLV System for Knowledge Representation and Reasoning. ACM TOCL 7(3), 499–562 (2006)MathSciNetCrossRefzbMATHGoogle Scholar
  16. 16.
    Calimeri, F., Cozza, S., Ianni, G., Leone, N.: DLV-Complex, homepage (since 2008),
  17. 17.
    Marano, M., Ianni, G., Ricca, F.: A Magic Set Implementation for Disjunctive Logic Programming with Function Symbols. Submitted to CILC 2009 (2009)Google Scholar
  18. 18.
    Bancilhon, F., Maier, D., Sagiv, Y., Ullman, J.D.: Magic Sets and Other Strange Ways to Implement Logic Programs. In: PODS 1986, Cambridge, Massachusetts, pp. 1–15 (1986)Google Scholar
  19. 19.
    Ullman, J.D.: Principles of Database and Knowledge Base Systems, vol. 2. Computer Science Press (1989)Google Scholar
  20. 20.
    Beeri, C., Ramakrishnan, R.: On the Power of Magic. In: PODS 1987, pp. 269–284. ACM, New York (1987)Google Scholar
  21. 21.
    Cumbo, C., Faber, W., Greco, G., Leone, N.: Enhancing the magic-set method for disjunctive datalog programs. In: Demoen, B., Lifschitz, V. (eds.) ICLP 2004. LNCS, vol. 3132, pp. 371–385. Springer, Heidelberg (2004)CrossRefGoogle Scholar
  22. 22.
    Van Gelder, A., Ross, K.A., Schlipf, J.S.: The Well-Founded Semantics for General Logic Programs. J. ACM 38(3), 620–650 (1991)MathSciNetzbMATHGoogle Scholar
  23. 23.
    Lifschitz, V., Turner, H.: Splitting a Logic Program. In: ICLP 1994, pp. 23–37. MIT Press, Cambridge (1994)Google Scholar
  24. 24.
    Naqvi, S., Tsur, S.: A logical language for data and knowledge bases. CS Press, NY (1989)Google Scholar
  25. 25.
    Schreye, D.D., Decorte, S.: Termination of Logic Programs: The Never-Ending Story. JLP 19/20, 199–260 (1994)MathSciNetCrossRefzbMATHGoogle Scholar
  26. 26.
    Bossi, A., Cocco, N., Fabris, M.: Norms on Terms and their use in Proving Universal Termination of a Logic Program. Theoretical Computer Science 124(2), 297–328 (1994)MathSciNetCrossRefzbMATHGoogle Scholar
  27. 27.
    Bruynooghe, M., Codish, M., Gallagher, J.P., Genaim, S., Vanhoof, W.: Termination analysis of logic programs through combination of type-based norms. ACM TOPLAS 29(2), 10 (2007)CrossRefGoogle Scholar
  28. 28.
    Behrend, A.: Soft stratification for magic set based query evaluation in deductive databases. In: PODS 2003, San Diego, CA, USA, pp. 102–110 (2003)Google Scholar
  29. 29.
    Faber, W., Greco, G., Leone, N.: Magic Sets and their Application to Data Integration. JCSS 73(4), 584–609 (2007)MathSciNetzbMATHGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2009

Authors and Affiliations

  • Francesco Calimeri
    • 1
  • Susanna Cozza
    • 1
  • Giovambattista Ianni
    • 1
  • Nicola Leone
    • 1
  1. 1.Department of MathematicsUniversity of CalabriaRendeItaly

Personalised recommendations