When Do Homomorphism Counts Help in Query Algorithms?

Authors Balder ten Cate , Victor Dalmau , Phokion G. Kolaitis , Wei-Lin Wu

Thumbnail PDF


  • Filesize: 0.8 MB
  • 20 pages

Document Identifiers

Author Details

Balder ten Cate
  • University of Amsterdam, The Netherlands
Victor Dalmau
  • Universitat Pompeu Fabra, Barcelona, Spain
Phokion G. Kolaitis
  • University of California Santa Cruz, CA, USA
  • IBM Almaden Research Center, San Jose, CA, USA
Wei-Lin Wu
  • University of California Santa Cruz, CA, USA

Cite AsGet BibTex

Balder ten Cate, Victor Dalmau, Phokion G. Kolaitis, and Wei-Lin Wu. When Do Homomorphism Counts Help in Query Algorithms?. In 27th International Conference on Database Theory (ICDT 2024). Leibniz International Proceedings in Informatics (LIPIcs), Volume 290, pp. 8:1-8:20, Schloss Dagstuhl – Leibniz-Zentrum für Informatik (2024)


A query algorithm based on homomorphism counts is a procedure for determining whether a given instance satisfies a property by counting homomorphisms between the given instance and finitely many predetermined instances. In a left query algorithm, we count homomorphisms from the predetermined instances to the given instance, while in a right query algorithm we count homomorphisms from the given instance to the predetermined instances. Homomorphisms are usually counted over the semiring ℕ of non-negative integers; it is also meaningful, however, to count homomorphisms over the Boolean semiring 𝔹, in which case the homomorphism count indicates whether or not a homomorphism exists. We first characterize the properties that admit a left query algorithm over 𝔹 by showing that these are precisely the properties that are both first-order definable and closed under homomorphic equivalence. After this, we turn attention to a comparison between left query algorithms over 𝔹 and left query algorithms over ℕ. In general, there are properties that admit a left query algorithm over ℕ but not over 𝔹. The main result of this paper asserts that if a property is closed under homomorphic equivalence, then that property admits a left query algorithm over 𝔹 if and only if it admits a left query algorithm over ℕ. In other words and rather surprisingly, homomorphism counts over ℕ do not help as regards properties that are closed under homomorphic equivalence. Finally, we characterize the properties that admit both a left query algorithm over 𝔹 and a right query algorithm over 𝔹.

Subject Classification

ACM Subject Classification
  • Theory of computation → Logic and databases
  • query algorithms
  • homomorphism
  • homomorphism counts
  • conjunctive query
  • constraint satisfaction


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


  1. Serge Abiteboul, Richard Hull, and Victor Vianu. Foundations of Databases, volume 8. Addison-Wesley Reading, 1995. Google Scholar
  2. Miklos Ajtai and Yuri Gurevich. Datalog vs first-order logic. Journal of Computer and System Sciences, 49(3):562-588, 1994. 30th IEEE Conference on Foundations of Computer Science. URL: https://doi.org/10.1016/S0022-0000(05)80071-6.
  3. Albert Atserias, Phokion G Kolaitis, and Wei-Lin Wu. On the expressive power of homomorphism counts. In 2021 36th Annual ACM/IEEE Symposium on Logic in Computer Science (LICS), pages 1-13. IEEE, 2021. URL: https://doi.org/10.1109/LICS52264.2021.9470543.
  4. Michal Bielecki and Jan Van den Bussche. Database interrogation using conjunctive queries. In Database Theory - ICDT 2003, 9th Int. Conf., 2003, Proceedings, volume 2572 of Lecture Notes in Computer Science, pages 259-269. Springer, 2003. URL: https://doi.org/10.1007/3-540-36285-1_17.
  5. 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), dec 2015. URL: https://doi.org/10.1145/2661643.
  6. Jan Böker, Yijia Chen, Martin Grohe, and Gaurav Rattan. The complexity of homomorphism indistinguishability. In 44th International Symposium on Mathematical Foundations of Computer Science, MFCS 2019, volume 138 of LIPIcs, pages 54:1-54:13. Schloss Dagstuhl - Leibniz-Zentrum für Informatik, 2019. URL: https://doi.org/10.4230/LIPIcs.MFCS.2019.54.
  7. Andrei A. Bulatov. A dichotomy theorem for nonuniform CSPs. In Chris Umans, editor, 58th IEEE Annual Symp. on Found. of Computer Science, FOCS 2017, Berkeley, CA, USA, October 15-17, 2017, pages 319-330. IEEE Computer Society, 2017. URL: https://doi.org/10.1109/FOCS.2017.37.
  8. Silvia Butti and Víctor Dalmau. Fractional homomorphism, Weisfeiler-Leman invariance, and the Sherali-Adams hierarchy for the constraint satisfaction problem. In International Symposium on Mathematical Foundations of Computer Science, 2021. URL: https://doi.org/10.4230/LIPIcs.MFCS.2021.27.
  9. Yijia Chen, Jörg Flum, Mingjun Liu, and Zhiyang Xun. On algorithms based on finitely many homomorphism counts. In 47th International Symposium on Mathematical Foundations of Computer Science (MFCS 2022), 2022. URL: https://doi.org/10.4230/LIPIcs.MFCS.2022.32.
  10. Víctor Dalmau, Phokion G. Kolaitis, and Moshe Y. Vardi. Constraint satisfaction, bounded treewidth, and finite-variable logics. In Principles and Practice of Constraint Programming - CP 2002, 8th International Conference, CP 2002, Proceedings, volume 2470 of Lecture Notes in Computer Science, pages 310-326. Springer, 2002. URL: https://doi.org/10.1007/3-540-46135-3_21.
  11. Holger Dell, Martin Grohe, and Gaurav Rattan. Lovász meets Weisfeiler and Leman. In 45th International Colloquium on Automata, Languages, and Programming, ICALP 2018, volume 107 of LIPIcs, pages 40:1-40:14. Schloss Dagstuhl - Leibniz-Zentrum für Informatik, 2018. URL: https://doi.org/10.4230/LIPIcs.ICALP.2018.40.
  12. Zdenek Dvorák. On recognizing graphs by numbers of homomorphisms. J. Graph Theory, 64(4):330-342, 2010. URL: https://doi.org/10.1002/jgt.20461.
  13. Jan Foniok, Jaroslav Nešetřil, and Claude Tardif. Generalised dualities and maximal finite antichains in the homomorphism order of relational structures. European Journal of Combinatorics, 29(4):881-899, 2008. URL: https://doi.org/10.1016/j.ejc.2007.11.017.
  14. Haim Gaifman, Harry Mairson, Yehoshua Sagiv, and Moshe Y. Vardi. Undecidable optimization problems for database logic programs. J. ACM, 40(3):683-713, jul 1993. URL: https://doi.org/10.1145/174130.174142.
  15. Todd J. Green. Containment of conjunctive queries on annotated relations. Theory Comput. Syst., 49(2):429-459, 2011. URL: https://doi.org/10.1007/s00224-011-9327-6.
  16. Todd J. Green, Gregory Karvounarakis, and Val Tannen. Provenance semirings. In Leonid Libkin, editor, Proceedings of the Twenty-Sixth ACM SIGACT-SIGMOD-SIGART Symposium on Principles of Database Systems, 2007, pages 31-40. ACM, 2007. URL: https://doi.org/10.1145/1265530.1265535.
  17. Pavol Hell and Jaroslav Nešetřil. Graphs and homomorphisms, volume 28 of Oxford lecture series in mathematics and its applications. Oxford University Press, 2004. Google Scholar
  18. Dan Kalman. The generalized Vandermonde matrix. Mathematics Magazine, 57(1):15-21, 1984. URL: https://doi.org/10.2307/2690290.
  19. Grigoris Karvounarakis and Todd J. Green. Semiring-annotated data: queries and provenance? SIGMOD Rec., 41(3):5-14, 2012. URL: https://doi.org/10.1145/2380776.2380778.
  20. Mahmoud Abo Khamis, Hung Q. Ngo, Reinhard Pichler, Dan Suciu, and Yisu Remy Wang. Convergence of datalog over (pre-) semirings. In PODS '22: Int. Conf. on Management of Data, Philadelphia, 2022, pages 105-117. ACM, 2022. URL: https://doi.org/10.1145/3517804.3524140.
  21. Egor V. Kostylev, Juan L. Reutter, and András Z. Salamon. Classification of annotation semirings over containment of conjunctive queries. ACM Trans. Database Syst., 39(1):1:1-1:39, 2014. URL: https://doi.org/10.1145/2556524.
  22. Gábor Kun. Constraints, MMSNP and expander relational structures. Combinatorica, 33(3):335-347, 2013. URL: https://doi.org/10.1007/s00493-013-2405-4.
  23. Gábor Kun and Mario Szegedy. A new line of attack on the dichotomy conjecture. European Journal of Combinatorics, 52:338-367, 2016. Special Issue: Recent Advances in Graphs and Analysis. URL: https://doi.org/10.1016/j.ejc.2015.07.011.
  24. Jaroslaw Kwiecien, Jerzy Marcinkowski, and Piotr Ostropolski-Nalewaja. Determinacy of real conjunctive queries. the boolean case. In Proceedings of the 41st ACM SIGMOD-SIGACT-SIGAI Symposium on Principles of Database Systems, PODS '22, pages 347-358, New York, NY, USA, 2022. Association for Computing Machinery. URL: https://doi.org/10.1145/3517804.3524168.
  25. László Lovász. Operations with structures. Acta Math. Acad. Sci. Hungar, 18(3-4):321-328, 1967. Google Scholar
  26. Alan Nash, Luc Segoufin, and Victor Vianu. Views and queries: Determinacy and rewriting. ACM Trans. Database Syst., 35(3), jul 2010. URL: https://doi.org/10.1145/1806907.1806913.
  27. Benjamin Rossman. Homomorphism preservation theorems. Journal of the ACM (JACM), 55(3):1-53, 2008. URL: https://doi.org/10.1145/1379759.1379763.
  28. Claude Tardif, Cynthia Loten, and Benoit Larose. A characterisation of first-order constraint satisfaction problems. Logical Methods in Computer Science, 3(4), 2007. URL: https://doi.org/10.2168/LMCS-3(4:6)2007.
  29. Dmitriy Zhuk. A proof of CSP dichotomy conjecture. In Chris Umans, editor, 58th IEEE Annual Symposium on Foundations of Computer Science, FOCS 2017, Berkeley, CA, USA, October 15-17, 2017, pages 331-342. IEEE Computer Society, 2017. URL: https://doi.org/10.1109/FOCS.2017.38.