A Theoretical Framework for the Declarative Debugging of Datalog Programs

  • R. Caballero
  • Y. García-Ruiz
  • F. Sáenz-Pérez
Part of the Lecture Notes in Computer Science book series (LNCS, volume 4925)


The logic programming language Datalog has been extensively researched as a query language for deductive databases. Although similar to Prolog, the Datalog operational mechanisms are more intricate, leading to computations quite hard to debug by traditional approaches. In this paper, we present a theoretical framework for debugging Datalog programs based on the ideas of declarative debugging. In our setting, a debugging session starts when the user detects an unexpected answer for some query, and ends with the debugger pointing to either an erroneous predicate or to a set of mutually recursive predicates as the cause of the unexpected answer. Instead of representing the computations by means of trees, as usual in declarative debugging, we propose graphs as a more convenient structure in the case of Datalog, proving formally the soundness and completeness of the debugging technique. We also present a debugging tool implemented in the publicly available deductive database system DES following this theoretical framework.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Ramakrishnan, R., Ullman, J.: A survey of research on Deductive Databases. The Journal of Logic Programming 23(2), 125–149 (1993)CrossRefGoogle Scholar
  2. 2.
    Beeri, C., Ramakrishnan, R.: On the power of magic. In: Proceedings of the Sixth ACM Symposium on Principles of Database Systems, pp. 269–284 (1987)Google Scholar
  3. 3.
    Dietrich, S.W.: Extension tables: Memo relations in logic programming. In: SLP, pp. 264–272 (1987)Google Scholar
  4. 4.
    Arora, T., Ramakrishnan, R., Roth, W.G., Seshadri, P., Srivastava, D.: Explaining program execution in deductive systems. In: Deductive and Object-Oriented Databases, pp. 101–119 (1993)Google Scholar
  5. 5.
    Wieland, C.: Two explanation facilities for the deductive database management system DeDEx. In: Kangassalo, H. (ed.) ER 1990, pp. 189–203, ER Institute (1990)Google Scholar
  6. 6.
    Specht, G.: Generating explanation trees even for negations in deductive database systems. In: Proceedings of the 5th Workshop on Logic Programming Environments, Vancouver, Canada (1993)Google Scholar
  7. 7.
    Russo, F., Sancassani, M.: A declarative debugging environment for Datalog. In: Proceedings of the First Russian Conference on Logic Programming, pp. 433–441. Springer, London (1992)Google Scholar
  8. 8.
    Baral, C.: Knowledge representation, reasoning, and declarative problem solving. Cambridge University Press, Cambridge (2003)CrossRefzbMATHGoogle Scholar
  9. 9.
    Syrjänen, T.: Debugging inconsistent answer set programs. In: Proceedings of the 11th International Workshop on Non-Monotonic Reasoning, Lake District, UK, pp. 77–84 (May 2006)Google Scholar
  10. 10.
    Brain, M., Gebser, M., Pührer, J., Schaub, T., Tompits, H., Woltran, S.: Debugging ASP Programs by Means of ASP. In: Baral, C., Brewka, G., Schlipf, J. (eds.) LPNMR 2007. LNCS (LNAI), vol. 4483, pp. 31–43. Springer, Heidelberg (2007)CrossRefGoogle Scholar
  11. 11.
    Caballero, R., García-Ruiz, Y., Sáenz-Pérez, F.: A new proposal for debugging datalog programs. In: 16th International Workshop on Functional and (Constraint) Logic Programming (WFLP 2007) (June 2007)Google Scholar
  12. 12.
    Shapiro, E.: Algorithmic Program Debugging. In: ACM Distiguished Dissertation. MIT Press, Cambridge (1982)Google Scholar
  13. 13.
    Sáenz-Pérez, F.: Datalog Educational System. User’s Manual. Technical Report 139-04, Facultad de Informática, Universidad Complutense de Madrid (2004),
  14. 14.
    Apt, K.R., Blair, H.A., Walker, A.: Towards a theory of declarative knowledge. In: Foundations of deductive databases and logic programming, pp. 89–148. Morgan Kaufmann Publishers Inc., San Francisco (1988)CrossRefGoogle Scholar
  15. 15.
    Ullman, J.: Database and Knowledge-Base Systems Vols. I (Classical Database Systems) and II (The New Technologies). Computer Science Press (1995)Google Scholar
  16. 16.
    Chandra, A.K., Harel, D.: Horn clauses queries and generalizations. J. Log. Program. 2(1), 1–15 (1985)MathSciNetCrossRefzbMATHGoogle Scholar
  17. 17.
    Gelfond, M., Lifschitz, V.: The stable model semantics for logic programming. In: Kowalski, R.A., Bowen, K. (eds.) Proceedings of the Fifth International Conference on Logic Programming, pp. 1070–1080. MIT Press, Cambridge (1988)Google Scholar
  18. 18.
    Naish, L.: A Declarative Debugging Scheme. Journal of Functional and Logic Programming 3 (1997)Google Scholar
  19. 19.
    Caballero, R.: A declarative debugger of incorrect answers for constraint functional-logic programs. In: WCFLP 2005: Proceedings of the 2005 ACM SIGPLAN workshop on Curry and functional logic programming, pp. 8–13. ACM Press, New York (2005)CrossRefGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2008

Authors and Affiliations

  • R. Caballero
    • 1
  • Y. García-Ruiz
    • 1
  • F. Sáenz-Pérez
    • 2
  1. 1.Departamento de Sistemas Informáticos y ComputaciónUniversidad Complutense de MadridSpain
  2. 2.Departamento de Ingeniería del Software e Inteligencia ArtificialUniversidad Complutense de MadridSpain

Personalised recommendations