Answer Counting Under Guarded TGDs

Authors Cristina Feier, Carsten Lutz, Marcin Przybyłko

Thumbnail PDF


  • Filesize: 0.84 MB
  • 22 pages

Document Identifiers

Author Details

Cristina Feier
  • Department of Computer Science, Universität Bremen, Germany
Carsten Lutz
  • Department of Computer Science, Universität Bremen, Germany
Marcin Przybyłko
  • Department of Computer Science, Universität Bremen, Germany


We thank the anonymous reviewers for useful comments.

Cite AsGet BibTex

Cristina Feier, Carsten Lutz, and Marcin Przybyłko. Answer Counting Under Guarded TGDs. In 24th International Conference on Database Theory (ICDT 2021). Leibniz International Proceedings in Informatics (LIPIcs), Volume 186, pp. 11:1-11:22, Schloss Dagstuhl – Leibniz-Zentrum für Informatik (2021)


We study the complexity of answer counting for ontology-mediated queries and for querying under constraints, considering conjunctive queries and unions thereof (UCQs) as the query language and guarded TGDs as the ontology and constraint language, respectively. Our main result is a classification according to whether answer counting is fixed-parameter tractable (FPT), W[1]-equivalent, #W[1]-equivalent, #W[2]-hard, or #A[2]-equivalent, lifting a recent classification for UCQs without ontologies and constraints due to Dell et al. [Holger Dell et al., 2019]. The classification pertains to various structural measures, namely treewidth, contract treewidth, starsize, and linked matching number. Our results rest on the assumption that the arity of relation symbols is bounded by a constant and, in the case of ontology-mediated querying, that all symbols from the ontology and query can occur in the data (so-called full data schema). We also study the meta-problems for the mentioned structural measures, that is, to decide whether a given ontology-mediated query or constraint-query specification is equivalent to one for which the structural measure is bounded.

Subject Classification

ACM Subject Classification
  • Theory of computation → Database theory
  • Ontology-Mediated Querying
  • Querying under Constraints
  • Answer Counting
  • Parameterized Complexity


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


  1. Serge Abiteboul, Richard Hull, and Victor Vianu. Foundations of Databases. Addison-Wesley, 1995. URL:
  2. Franz Baader, Ian Horrocks, Carsten Lutz, and Ulrike Sattler. An Introduction to Description Logic. Cambridge University Press, 2017. URL:
  3. 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:
  4. Pablo Barceló, Gerald Berger, and Andreas Pieris. Containment for rule-based ontology-mediated queries. In PODS, pages 267-279, 2018. URL:
  5. Pablo Barceló, Victor Dalmau, Cristina Feier, Carsten Lutz, and Andreas Pieris. The limits of efficiency for open- and closed-world query evaluation under guarded TGDs. In Proc. of PODS, 2020. URL:
  6. Pablo Barceló, Cristina Feier, Carsten Lutz, and Andreas Pieris. When is ontology-mediated querying efficient? In Proc. of LICS, pages 1-13, 2019. URL:
  7. Pablo Barceló, Diego Figueira, Georg Gottlob, and Andreas Pieris. Semantic optimization of conjunctive queries. J. ACM, 67(6), 2020. URL:
  8. Pablo Barceló, Georg Gottlob, and Andreas Pieris. Semantic acyclicity under constraints. In PODS, pages 343-354, 2016. URL:
  9. Meghyn Bienvenu, Quentin Manière, and Michaël Thomazo. Answering counting queries over DL-Lite ontologies. In Proc. of IJCAI, 2020. URL:
  10. Meghyn Bienvenu and Magdalena Ortiz. Ontology-mediated query answering with data-tractable description logics. In Proc. of Reasoning Web, volume 9203 of LNCS, pages 218-307. Springer, 2015. URL:
  11. Meghyn Bienvenu, Balder ten Cate, Carsten Lutz, and Frank Wolter. Ontology-based data access: A study through disjunctive datalog, CSP, and MMSNP. ACM Trans. Database Syst., 39(4):33:1-33:44, 2014. URL:
  12. 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. URL:
  13. Andrea Calì, Georg Gottlob, and Andreas Pieris. Towards more expressive ontology languages: The query answering problem. Artif. Intell., 193:87-128, 2012. URL:
  14. Diego Calvanese, Julien Corman, Davide Lanti, and Simon Razniewski. Counting query answers over DL-Lite knowledge base. In Proc. of IJCAI, 2020. URL:
  15. Diego Calvanese, Giuseppe De Giacomo, and Maurizio Lenzerini. On the decidability of query containment under constraints. In Proc. of PODS, pages 149-158. ACM Press, 1998. URL:
  16. Hubie Chen and Stefan Mengel. A trichotomy in the complexity of counting answers to conjunctive queries. In Proc. of ICDT, pages 110-126, 2015. URL:
  17. Hubie Chen and Stefan Mengel. Counting answers to existential positive queries: A complexity classification. In Proc. of PODS, pages 315-326, 2016. URL:
  18. Víctor Dalmau and Peter Jonsson. The complexity of counting homomorphisms seen from the other side. J. Theor. Comput. Sci., 329(1-3):315-323, 2004. URL:
  19. Holger Dell, Marc Roth, and Philip Wellnitz. Counting answers to existential questions. In Proc. of ICALP, pages 113:1-113:15, 2019. URL:
  20. Arnaud Durand and Stefan Mengel. The complexity of weighted counting for acyclic conjunctive queries. J. Comput. Syst. Sci., 80(1):277-296, 2014. URL:
  21. Arnaud Durand and Stefan Mengel. Structural tractability of counting of solutions to conjunctive queries. J. Theory Comput. Syst., 57(4):1202-1249, 2015. URL:
  22. Ronald Fagin, Phokion G. Kolaitis, Renée J. Miller, and Lucian Popa. Data exchange: semantics and query answering. J. Theor. Comput. Sci., 336(1):89-124, 2005. URL:
  23. Cristina Feier, Carsten Lutz, and Marcin Przybyłko. Answer counting under guarded TGDs, 2021. URL:
  24. Diego Figueira. Semantically acyclic conjunctive queries under functional dependencies. In Proc. of LICS, page 847–856. ACM, 2016. URL:
  25. Jörg Flum and Martin Grohe. The parameterized complexity of counting problems. SIAM J. Comput., 33(4):892-922, 2004. URL:
  26. Martin Grohe. The complexity of homomorphism and constraint satisfaction problems seen from the other side. J. ACM, 54(1):1:1-1:24, 2007. URL:
  27. 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:
  28. Bogdan Kostov and Petr Kremen. Count distinct semantic queries over multiple linked datasets. OJSW, 5(1):1-11, 2018. URL:
  29. Egor V. Kostylev and Juan L. Reutter. Complexity of answering counting aggregate queries over DL-Lite. J. Web Semant., 33:94-111, 2015. URL:
  30. Nicola Leone, Marco Manna, Giorgio Terracina, and Pierfrancesco Veltri. Fast query answering over existential rules. ACM Trans. Comput. Log., 20(2):12:1-12:48, 2019. URL:
  31. David Maier, Alberto O. Mendelzon, and Yehoshua Sagiv. Testing implications of data dependencies. ACM Trans. Database Syst., 4(4):455-469, 1979. URL:
  32. Reinhard Pichler and Sebastian Skritek. Tractable counting of the answers to conjunctive queries. J. Comput. Syst. Sci., 79(6):984-1001, 2013. URL:
  33. Antonella Poggi, Domenico Lembo, Diego Calvanese, Giuseppe De Giacomo, Maurizio Lenzerini, and Riccardo Rosati. Linking data to ontologies. J. Data Semantics, 4900:133-173, 2008. URL: