Dynamic Magic Sets for Programs with Monotone Recursive Aggregates

  • Mario Alviano
  • Gianluigi Greco
  • Nicola Leone
Part of the Lecture Notes in Computer Science book series (LNCS, volume 6645)


Disjunctive Logic Programming (DLP) is an extension of Datalog that allows for disjunction in rule head and nonmonotonic negation in bodies. All of the queries in the second level of the polynomial hierarchy can be expressed in this language. However, DLP does not allow for representing properties which involve sets of data in a natural way. Extending the language by introducing aggregate functions has been proposed in the literature to overcome this lack, then leading to the language DLP\(^{\mathcal{A},\neg}\). In particular, DLP\({^{\mathcal{A},\neg}}\) allows for using recursive aggregates, which naturally arise in many practical application scenarios. An aggregate is recursive if its aggregate set depends on the evaluation of the aggregate itself. The evaluation of programs with aggregates is hard, especially when aggregates are recursive, optimization techniques are highly needed to make these programs usable in real-world applications.

In this paper, we focus on the optimization of queries over programs with recursive aggregates. In particular, we design an extension of the Dynamic Magic Set (DMS) technique to programs with stratified negation and monotone recursive aggregates, and we demonstrate the correctness of the proposed technique. For assessing the effectiveness of the new technique, we consider a standard benchmark for recursive aggregates, referred to as Company Controls, along with a couple of benchmarks involving aggregates over the WordNet database. Experimental results confirm the effectiveness of our technique.


Disjunctive Logic Programming recursive aggregates Magic Sets 


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Lobo, J., Minker, J., Rajasekar, A.: Foundations of Disjunctive Logic Programming. The MIT Press, Cambridge (1992)MATHGoogle Scholar
  2. 2.
    Eiter, T., Gottlob, G., Mannila, H.: Disjunctive Datalog. ACM TODS 22(3), 364–418 (1997)CrossRefGoogle Scholar
  3. 3.
    Ricca, F., Grasso, G., Alviano, M., Manna, M., Lio, V., Iiritano, S., Leone, N.: Team-building with Answer Set Programming in the Gioia-Tauro Seaport. TPLP (2011) (to appear)Google Scholar
  4. 4.
    Manna, M., Ruffolo, M., Oro, E., Alviano, M., Leone, N.: The HiLeX System for Semantic Information Extraction. TLDKS(2011) (to appear)Google Scholar
  5. 5.
    Ricca, F., Alviano, M., Dimasi, A., Grasso, G., Ielpa, S.M., Iiritano, S., Manna, M., Leone, N.: A Logic–Based System for e-Tourism. FI 105, 35–55 (2010)MathSciNetGoogle Scholar
  6. 6.
    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)MathSciNetCrossRefMATHGoogle Scholar
  7. 7.
    Janhunen, T., Niemelä, I., Simons, P., You, J.H.: Partiality and Disjunctions in Stable Model Semantics. In: KR 2000, April 12-15, pp. 411–419 (2000)Google Scholar
  8. 8.
    Lierler, Y.: Disjunctive Answer Set Programming via Satisfiability. In: Baral, C., Greco, G., Leone, N., Terracina, G. (eds.) LPNMR 2005. LNCS (LNAI), vol. 3662, pp. 447–451. Springer, Heidelberg (2005)CrossRefGoogle Scholar
  9. 9.
    Drescher, C., Gebser, M., Grote, T., Kaufmann, B., König, A., Ostrowski, M., Schaub, T.: Conflict-Driven Disjunctive Answer Set Solving. In: KR 2008, pp. 422–432. AAAI Press, Menlo Park (2008)Google Scholar
  10. 10.
    Kemp, D.B., Stuckey, P.J.: Semantics of Logic Programs with Aggregates. In: ISLP 1991, pp. 387–401. MIT Press, Cambridge (1991)Google Scholar
  11. 11.
    Denecker, M., Pelov, N., Bruynooghe, M.: Ultimate Well-Founded and Stable Semantics for Logic Programs with Aggregates. In: Codognet, P. (ed.) ICLP 2001. LNCS, vol. 2237, pp. 212–226. Springer, Heidelberg (2001)CrossRefGoogle Scholar
  12. 12.
    Dix, J., Osorio, M.: On Well-Behaved Semantics Suitable for Aggregation. In: ILPS 1997, Port Jefferson, N.Y (1997)Google Scholar
  13. 13.
    Simons, P., Niemelä, I., Soininen, T.: Extending and Implementing the Stable Model Semantics. AI 138, 181–234 (2002)MathSciNetMATHGoogle Scholar
  14. 14.
    Pelov, N., Truszczyński, M.: Semantics of disjunctive programs with monotone aggregates - an operator-based approach. In: NMR 2004, pp. 327–334 (2004)Google Scholar
  15. 15.
    Manna, M., Ricca, F., Terracina, G.: Consistent Query Answering via ASP from Different Perspectives: Theory and Practice. TPLP (2011) (to appear)Google Scholar
  16. 16.
    Ullman, J.D.: Principles of Database and Knowledge Base Systems, vol. 2. CS Press, Rockvillie (1989)Google Scholar
  17. 17.
    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
  18. 18.
    Beeri, C., Ramakrishnan, R.: On the power of magic. JLP 10(1-4), 255–259 (1991)MathSciNetCrossRefMATHGoogle Scholar
  19. 19.
    Kowalski, R.A.: Predicate Logic as Programming Language. In: IFIP Congress, pp. 569–574 (1974)Google Scholar
  20. 20.
    Greco, S.: Binding Propagation Techniques for the Optimization of Bound Disjunctive Queries. IEEE TKDE 15(2), 368–385 (2003)Google Scholar
  21. 21.
    Cumbo, C., Faber, W., Greco, G.: Improving Query Optimization for Disjunctive Datalog. In: APPIA-GULP-PRODE, pp. 252–262 (2003)Google Scholar
  22. 22.
    Faber, W., Greco, G., Leone, N.: Magic Sets and their Application to Data Integration. JCSS 73(4), 584–609 (2007)MathSciNetMATHGoogle Scholar
  23. 23.
    Gelfond, M., Lifschitz, V.: Classical Negation in Logic Programs and Disjunctive Databases. NGC 9, 365–385 (1991)CrossRefMATHGoogle Scholar
  24. 24.
    Faber, W., Leone, N., Pfeifer, G.: Recursive aggregates in disjunctive logic programs: Semantics and complexity. In: Alferes, J.J., Leite, J. (eds.) JELIA 2004. LNCS (LNAI), vol. 3229, pp. 200–212. Springer, Heidelberg (2004)CrossRefGoogle Scholar
  25. 25.
    Abiteboul, S., Hull, R., Vianu, V.: Foundations of Databases. Addison-Wesley, Reading (1995)MATHGoogle Scholar
  26. 26.
    Faber, W., Pfeifer, G., Leone, N., Dell’Armi, T., Ielpa, G.: Design and implementation of aggregate functions in the dlv system. TPLP 8(5-6), 545–580 (2008)MathSciNetMATHGoogle Scholar
  27. 27.
    Alviano, M., Faber, W., Leone, N.: Using unfounded sets for computing answer sets of programs with recursive aggregates. In: CILC 2007 (2007)Google Scholar
  28. 28.
    Alviano, M.: Dynamic Magic Sets for Disjunctive Datalog Programs. In: ICLP 2010. LIPIcs, vol. 7, pp. 226–235 (2010)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2011

Authors and Affiliations

  • Mario Alviano
    • 1
  • Gianluigi Greco
    • 1
  • Nicola Leone
    • 1
  1. 1.Department of MathematicsUniversity of CalabriaRendeItaly

Personalised recommendations