Document Open Access Logo

Datalog: Bag Semantics via Set Semantics

Authors Leopoldo Bertossi, Georg Gottlob, Reinhard Pichler

Thumbnail PDF


  • Filesize: 0.61 MB
  • 19 pages

Document Identifiers

Author Details

Leopoldo Bertossi
  • RelationalAI Inc., USA
  • Carleton University, Ottawa, Canada
  • Member of the "Millenium Institute for Foundational Research on Data" (IMFD, Chile)
Georg Gottlob
  • University of Oxford, UK
  • TU Wien, Austria
Reinhard Pichler
  • TU Wien, Austria


Many thanks to Renzo Angles and Claudio Gutierrez for information on their work on SPARQL with bag semantics; and to Wolfgang Fischl for his help testing some queries in SQL DBMSs. We appreciate the useful comments received from the reviewers. Part of this work was done while L. Bertossi was spending a sabbatical at the DBAI Group of TU Wien with support from the "Vienna Center for Logic and Algorithms" and the Wolfgang Pauli Society. This author is grateful for their support and hospitality, and specially to G. Gottlob for making the stay possible. He was also supported by NSERC Discovery Grant #06148. The work of G. Gottlob was supported by the Austrian Science Fund (FWF):P30930 and the EPSRC programme grant EP/M025268/1 VADA. The work of R. Pichler was supported by the Austrian Science Fund (FWF):P30930.

Cite AsGet BibTex

Leopoldo Bertossi, Georg Gottlob, and Reinhard Pichler. Datalog: Bag Semantics via Set Semantics. In 22nd International Conference on Database Theory (ICDT 2019). Leibniz International Proceedings in Informatics (LIPIcs), Volume 127, pp. 16:1-16:19, Schloss Dagstuhl - Leibniz-Zentrum für Informatik (2019)


Duplicates in data management are common and problematic. In this work, we present a translation of Datalog under bag semantics into a well-behaved extension of Datalog, the so-called warded Datalog^+/-, under set semantics. From a theoretical point of view, this allows us to reason on bag semantics by making use of the well-established theoretical foundations of set semantics. From a practical point of view, this allows us to handle the bag semantics of Datalog by powerful, existing query engines for the required extension of Datalog. This use of Datalog^+/- is extended to give a set semantics to duplicates in Datalog^+/- itself. We investigate the properties of the resulting Datalog^+/- programs, the problem of deciding multiplicities, and expressibility of some bag operations. Moreover, the proposed translation has the potential for interesting applications such as to Multiset Relational Algebra and the semantic web query language SPARQL with bag semantics.

Subject Classification

ACM Subject Classification
  • Information systems → Query languages
  • Theory of computation → Logic
  • Theory of computation → Semantics and reasoning
  • Datalog
  • duplicates
  • multisets
  • query answering
  • chase
  • Datalog+/-


  • Access Statistics
  • Total Accesses (updated on a weekly basis)
    PDF Downloads


  1. Serge Abiteboul, Richard Hull, and Victor Vianu. Foundations of Databases. Addison Wesley, 1994. Google Scholar
  2. Renzo Angles and Claudio Gutiérrez. The Multiset Semantics of SPARQL Patterns. In Proc. ISWC 2016, volume 9981 of LNCS, pages 20-36, 2016. URL:
  3. Marcelo Arenas, Georg Gottlob, and Andreas Pieris. Expressive languages for querying the semantic web. In Proc. PODS'14, pages 14-26. ACM, 2014. URL:
  4. Marcelo Arenas, Georg Gottlob, and Andreas Pieris. Expressive languages for querying the semantic web. ACM Trans. Database Syst. (to appear), 2018. Google Scholar
  5. Jean-François Baget, Michel Leclère, Marie-Laure Mugnier, and Eric Salvat. On rules with existential variables: Walking the decidability line. Artif. Intell., 175(9-10):1620-1654, 2011. URL:
  6. Luigi Bellomarini, Georg Gottlob, Andreas Pieris, and Emanuel Sallinger. Swift Logic for Big Data and Knowledge Graphs. In Proc. IJCAI 2017, pages 2-10., 2017. URL:
  7. Luigi Bellomarini, Emanuel Sallinger, and Georg Gottlob. The Vadalog System: Datalog-based Reasoning for Knowledge Graphs. PVLDB, 11(9):975-987, 2018. Google Scholar
  8. Andrea Calì, Georg Gottlob, and Michael Kifer. Taming the Infinite Chase: Query Answering under Expressive Relational Constraints. J. Artif. Intell. Res., 48:115-174, 2013. Google Scholar
  9. Andrea Calì, Georg Gottlob, and Thomas Lukasiewicz. Datalog^±: a unified approach to ontologies and integrity constraints. In Proc. ICDT 2009, volume 361 of ACM International Conference Proceeding Series, pages 14-30. ACM, 2009. Google Scholar
  10. Andrea Calì, Georg Gottlob, and Thomas Lukasiewicz. A general Datalog-based framework for tractable query answering over ontologies. J. Web Sem., 14:57-83, 2012. URL:
  11. Andrea Calì, Georg Gottlob, and Andreas Pieris. Towards more expressive ontology languages: The query answering problem. Artif. Intell., 193:87-128, 2012. URL:
  12. Ashok K. Chandra, Dexter Kozen, and Larry J. Stockmeyer. Alternation. J. ACM, 28(1):114-133, 1981. URL:
  13. Heinz-Dieter Ebbinghaus and Jörg Flum. Finite Model Theory. Springer, 2nd edition, 1999. Google Scholar
  14. Ronald Fagin, Phokion G. Kolaitis, Renée J. Miller, and Lucian Popa. Data exchange: semantics and query answering. Theor. Comput. Sci., 336(1):89-124, 2005. URL:
  15. Floris Geerts and Antonella Poggi. On database query languages for K-relations. J. Applied Logic, 8(2):173-185, 2010. URL:
  16. Birte Glimm, Chimezie Ogbuji, Sandro Hawke, Ivan Herman, Bijan Parsia, Axel Polleres, and Andy Seaborne. SPARQL 1.1 Entailment Regimes. W3C Recommendation 21 march 2013, W3C, 2013. URL:
  17. Georg Gottlob and Andreas Pieris. Beyond SPARQL under OWL 2 QL Entailment Regime: Rules to the Rescue. In Proc. IJCAI 2015, pages 2999-3007. AAAI Press, 2015. URL:
  18. Todd J. Green, Gregory Karvounarakis, and Val Tannen. Provenance semirings. In Proc. PODS'07, pages 31-40. ACM, 2007. URL:
  19. David S. Johnson and Anthony C. Klug. Testing Containment of Conjunctive Queries under Functional and Inclusion Dependencies. J. Comput. Syst. Sci., 28(1):167-189, 1984. URL:
  20. Michael J. Maher and Raghu Ramakrishnan. Déjà Vu in Fixpoints of Logic Programs. In Proc. NACLP 1989, pages 963-980. MIT Press, 1989. Google Scholar
  21. Inderpal Singh Mumick, Hamid Pirahesh, and Raghu Ramakrishnan. The Magic of Duplicates and Aggregates. In Proc. VLDB 1990, pages 264-277. Morgan Kaufmann, 1990. URL:
  22. Inderpal Singh Mumick and Oded Shmueli. Finiteness Properties of Database Queries. In Proc. ADC '93, pages 274-288. World Scientific, 1993. Google Scholar
  23. Axel Polleres and Johannes Peter Wallner. On the relation between SPARQL1.1 and Answer Set Programming. Journal of Applied Non-Classical Logics, 23(1-2):159-212, 2013. URL:
  24. Johan van Benthem and Kees Doets. Higher-Order Logic. In Dov M. Gabbay and Franz Guenthner, editors, Handbook of Philosophical Logic, Vol. I, Synthese Library, Vol. 164, pages 275-329. D. Reidel Publishing Company, 1983. Google Scholar
  25. Dag Westerståhl. Quantifiers in Formal and Natural. In Dov M. Gabbay and Franz Guenthner, editors, Handbook of Philosophical Logic, Vol. 14, pages 223-338. Springer, 2007. Google Scholar
Questions / Remarks / Feedback

Feedback for Dagstuhl Publishing

Thanks for your feedback!

Feedback submitted

Could not send message

Please try again later or send an E-mail