Exploiting Database Management Systems and Treewidth for Counting

  • Johannes K. FichteEmail author
  • Markus HecherEmail author
  • Patrick ThierEmail author
  • Stefan WoltranEmail author
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 12007)


Bounded treewidth is one of the most cited combinatorial invariants, which was applied in the literature for solving several counting problems efficiently. A canonical counting problem is #Sat, which asks to count the satisfying assignments of a Boolean formula. Recent work shows that benchmarking instances for #Sat often have reasonably small treewidth. This paper deals with counting problems for instances of small treewidth. We introduce a general framework to solve counting questions based on state-of-the-art database management systems (DBMS). Our framework takes explicitly advantage of small treewidth by solving instances using dynamic programming (DP) on tree decompositions (TD). Therefore, we implement the concept of DP into a DBMS (PostgreSQL), since DP algorithms are already often given in terms of table manipulations in theory. This allows for elegant specifications of DP algorithms and the use of SQL to manipulate records and tables, which gives us a natural approach to bring DP algorithms into practice. To the best of our knowledge, we present the first approach to employ a DBMS for algorithms on TDs. A key advantage of our approach is that DBMS naturally allow to deal with huge tables with a limited amount of main memory (RAM), parallelization, as well as suspending computation.


Dynamic programming Parameterized algorithmics Bounded treewidth Database systems SQL Relational algebra Counting 


  1. 1.
    Postgresql documentation 12 (2019).
  2. 2.
    Abseher, M., Musliu, N., Woltran, S.: htd – a free, open-source framework for (customized) tree decompositions and beyond. In: Salvagnin, D., Lombardi, M. (eds.) CPAIOR 2017. LNCS, vol. 10335, pp. 376–386. Springer, Cham (2017). Scholar
  3. 3.
    Bacchus, F., Dalmao, S., Pitassi, T.: Algorithms and complexity results for #SAT and Bayesian inference. In: FOCS 2003, pp. 340–351. IEEE Computer Society (2003)Google Scholar
  4. 4.
    Bannach, M., Berndt, S.: Practical access to dynamic programming on tree decompositions. Algorithms 12(8), 172 (2019)MathSciNetCrossRefGoogle Scholar
  5. 5.
    Bliem, B., Charwat, G., Hecher, M., Woltran, S.: D-flat\({}^{\text{2 }}\): subset minimization in dynamic programming on tree decompositions made easy. Fundam. Inform. 147(1), 27–61 (2016)MathSciNetzbMATHCrossRefGoogle Scholar
  6. 6.
    Burchard, J., Schubert, T., Becker, B.: Laissez-Faire caching for parallel #SAT solving. In: Heule, M., Weaver, S. (eds.) SAT 2015. LNCS, vol. 9340, pp. 46–61. Springer, Cham (2015). Scholar
  7. 7.
    Chakraborty, S., Fremont, D.J., Meel, K.S., Seshia, S.A., Vardi, M.Y.: Distribution-aware sampling and weighted model counting for SAT. In: AAAI 2014, pp. 1722–1730. The AAAI Press (2014)Google Scholar
  8. 8.
    Chakraborty, S., Meel, K.S., Vardi, M.Y.: Improving approximate counting for probabilistic inference: From linear to logarithmic sat solver calls. In: IJCAI 2016, pp. 3569–3576. The AAAI Press (2016)Google Scholar
  9. 9.
    Charwat, G., Woltran, S.: Expansion-based QBF solving on tree decompositions. Fundam. Inform. 167(1–2), 59–92 (2019)MathSciNetzbMATHCrossRefGoogle Scholar
  10. 10.
    Choi, A., Van den Broeck, G., Darwiche, A.: Tractable learning for structured probability spaces: a case study in learning preference distributions. In: IJCAI 2015. The AAAI Press (2015)Google Scholar
  11. 11.
    Codd, E.F.: A relational model of data for large shared data banks. Commun. ACM 13(6), 377–387 (1970)zbMATHCrossRefGoogle Scholar
  12. 12.
    Cygan, M., et al.: Parameterized Algorithms. Springer, Switzerland (2015). Scholar
  13. 13.
    Darwiche, A.: New advances in compiling CNF to decomposable negation normal form. In: ECAI 2004, pp. 318–322. IOS Press (2004)Google Scholar
  14. 14.
    Darwiche, A.: SDD: a new canonical representation of propositional knowledge bases. In: IJCAI 2011, pp. 819–826. AAAI Press/IJCAI (2011)Google Scholar
  15. 15.
    Dell, H., Komusiewicz, C., Talmon, N., Weller, M.: The PACE 2017 parameterized algorithms and computational experiments challenge: the second iteration. In: IPEC 2017, Leibniz International Proceedings in Informatics (LIPIcs), vol. 89, pp. 30:1–30:12. Dagstuhl Publishing (2018)Google Scholar
  16. 16.
    Diestel, R.: Graph Theory. Graduate Texts in Mathematics, vol. 173, 4th edn. Springer, Heidelberg (2012). Scholar
  17. 17.
    Domshlak, C., Hoffmann, J.: Probabilistic planning via heuristic forward search and weighted model counting. J. Artif. Intell. Res. 30, 565–620 (2007)MathSciNetzbMATHCrossRefGoogle Scholar
  18. 18.
    Doubilet, P., Rota, G.C., Stanley, R.: On the foundations of combinatorial theory (VI): the idea of generating function. In: Berkeley Symposium on Mathematical Statistics and Probability, vol. 2, pp. 267–318 (1972)Google Scholar
  19. 19.
    Dueñas-Osorio, L., Meel, K.S., Paredes, R., Vardi, M.Y.: Counting-based reliability estimation for power-transmission grids. In: AAAI 2017, pp. 4488–4494. The AAAI Press (2017)Google Scholar
  20. 20.
    Ermon, S., Gomes, C.P., Selman, B.: Uniform solution sampling using a constraint solver as an oracle. In: UAI 2012, pp. 255–264. AUAI Press (2012)Google Scholar
  21. 21.
    Fichte, J.K., Hecher, M., Morak, M., Woltran, S.: Exploiting treewidth for projected model counting and its limits. In: Beyersdorff, O., Wintersteiger, C.M. (eds.) SAT 2018. LNCS, vol. 10929, pp. 165–184. Springer, Cham (2018). Scholar
  22. 22.
    Fichte, J.K., Hecher, M., Woltran, S., Zisser, M.: A benchmark collection of #SAT instances and tree decompositions (benchmark set), June 2018.
  23. 23.
    Fichte, J.K., Hecher, M., Zisser, M.: An improved GPU-based SAT model counter. In: Schiex, T., de Givry, S. (eds.) CP 2019. LNCS, vol. 11802, pp. 491–509. Springer, Cham (2019). Scholar
  24. 24.
    Gomes, C.P., Sabharwal, A., Selman, B.: Chapter 20: Model counting. In: Handbook of Satisfiability, Frontiers in Artificial Intelligence and Applications, vol. 185, pp. 633–654. IOS Press (2009)Google Scholar
  25. 25.
    Kiljan, K., Pilipczuk, M.: Experimental evaluation of parameterized algorithms for feedback vertex set. In: SEA. LIPIcs, vol. 103, pp. 12:1–12:12. Schloss Dagstuhl (2018)Google Scholar
  26. 26.
    Kleine Büning, H., Lettman, T.: Propositional Logic: Deduction and Algorithms. Cambridge University Press, Cambridge (1999)zbMATHGoogle Scholar
  27. 27.
    Kloks, T.: Treewidth: Computations and Approximations. LNCS, vol. 842. Springer, Heidelberg (1994). Scholar
  28. 28.
    Koriche, F., Lagniez, J.M., Marquis, P., Thomas, S.: Knowledge compilation for model counting: affine decision trees. In: IJCAI 2013. The AAAI Press (2013)Google Scholar
  29. 29.
    Lagniez, J., Marquis, P.: Preprocessing for propositional model counting. In: AAAI, pp. 2688–2694. AAAI Press (2014)Google Scholar
  30. 30.
    Lagniez, J.M., Marquis, P.: An improved decision-DDNF compiler. In: IJCAI 2017, pp. 667–673. The AAAI Press (2017)Google Scholar
  31. 31.
    Langer, A., Reidl, F., Rossmanith, P., Sikdar, S.: Evaluation of an MSO-solver. In: Proceedings of ALENEX. pp. 55–63. SIAM/Omnipress (2012)Google Scholar
  32. 32.
    Liu, J., Zhong, W., Jiao, L.: Comments on “the 1993 DIMACS graph coloring challenge” and “energy function-based approaches to graph coloring”. IEEE Trans. Neural Netw. 17(2), 533 (2006)CrossRefGoogle Scholar
  33. 33.
    Muise, C., McIlraith, S.A., Beck, J.C., Hsu, E.I.: Dsharp: fast d-DNNF compilation with sharpSAT. In: Kosseim, L., Inkpen, D. (eds.) AI 2012. LNCS (LNAI), vol. 7310, pp. 356–361. Springer, Heidelberg (2012). Scholar
  34. 34.
    Oztok, U., Darwiche, A.: A top-down compiler for sentential decision diagrams. In: IJCAI 2015, pp. 3141–3148. The AAAI Press (2015)Google Scholar
  35. 35.
    Roth, D.: On the hardness of approximate reasoning. Artif. Intell. 82(1–2), 273–302 (1996)MathSciNetCrossRefGoogle Scholar
  36. 36.
    Samer, M., Szeider, S.: Algorithms for propositional model counting. J. Discrete Algorithms 8(1), 50–64 (2010)MathSciNetzbMATHCrossRefGoogle Scholar
  37. 37.
    Sang, T., Bacchus, F., Beame, P., Kautz, H., Pitassi, T.: Combining component caching and clause learning for effective model counting. In: SAT 2004 (2004)Google Scholar
  38. 38.
    Sang, T., Beame, P., Kautz, H.: Performing Bayesian inference by weighted model counting. In: AAAI 2005. The AAAI Press (2005)Google Scholar
  39. 39.
    Sharma, S., Roy, S., Soos, M., Meel, K.S.: GANAK: a scalable probabilistic exact model counter. In: IJCAI, pp. 1169–1176. (2019)Google Scholar
  40. 40.
    Thurley, M.: sharpSAT – counting models with advanced component caching and implicit BCP. In: Biere, A., Gomes, C.P. (eds.) SAT 2006. LNCS, vol. 4121, pp. 424–429. Springer, Heidelberg (2006). Scholar
  41. 41.
    Toda, S.: PP is as hard as the polynomial-time hierarchy. SIAM J. Comput. 20(5), 865–877 (1991)MathSciNetzbMATHCrossRefGoogle Scholar
  42. 42.
    Toda, T., Soh, T.: Implementing efficient all solutions SAT solvers. ACM J. Exp. Algorithmics 21, 1–12 (2015). special Issue SEA 2014MathSciNetzbMATHCrossRefGoogle Scholar
  43. 43.
    Ullman, J.D.: Principles of Database and Knowledge-Base Systems, vol. II. Computer Science Press (1989)Google Scholar
  44. 44.
    Xue, Y., Choi, A., Darwiche, A.: Basing decisions on sentences in decision diagrams. In: AAAI 2012. The AAAI Press (2012)Google Scholar

Copyright information

© Springer Nature Switzerland AG 2020

Authors and Affiliations

  1. 1.TU DresdenDresdenGermany
  2. 2.TU WienViennaAustria
  3. 3.University of PotsdamPotsdamGermany

Personalised recommendations