Approximate Model Counting, Sparse XOR Constraints and Minimum Distance

  • Michele BorealeEmail author
  • Daniele Gorla
Part of the Lecture Notes in Computer Science book series (LNCS, volume 11760)


The problem of counting the number of models of a given Boolean formula has numerous applications, including computing the leakage of deterministic programs in Quantitative Information Flow. Model counting is a hard, #P-complete problem. For this reason, many approximate counters have been developed in the last decade, offering formal guarantees of confidence and accuracy. A popular approach is based on the idea of using random XOR constraints to, roughly, successively halving the solution set until no model is left: this is checked by invocations to a SAT solver. The effectiveness of this procedure hinges on the ability of the SAT solver to deal with XOR constraints, which in turn crucially depends on the length of such constraints. We study to what extent one can employ sparse, hence short, constraints, keeping guarantees of correctness. We show that the resulting bounds are closely related to the geometry of the set of models, in particular to the minimum Hamming distance between models. We evaluate our theoretical results on a few concrete formulae. Based on our findings, we finally discuss possible directions for improvements of the current state of the art in approximate model counting.


Model counting Approximate counting XOR sampling 



We thank Marco Baldi, Massimo Battaglioni and Franco Chiaraluce for providing us with the generator and parity check matrices of the LDPC code in Subsect. 4.3.


  1. 1.
    Achlioptas, D., Theodoropoulos, P.: Probabilistic model counting with short XORs. In: Gaspers, S., Walsh, T. (eds.) SAT 2017. LNCS, vol. 10491, pp. 3–19. Springer, Cham (2017). Scholar
  2. 2.
    Babai, L., Frankl, P.: Linear Algebra Methods in Combinatorics. The University of Chicago, Chicago (1992)Google Scholar
  3. 3.
    Biondi, F., Enescu, M.A., Heuser, A., Legay, A., Meel, K.S., Quilbeuf, J.: Scalable approximation of quantitative information flow in programs. Verification, Model Checking, and Abstract Interpretation. LNCS, vol. 10747, pp. 71–93. Springer, Cham (2018). Scholar
  4. 4.
    Boreale, M., Gorla, D.: Approximate model counting, sparse XOR constraints and minimum distance. (2019)
  5. 5.
    Bose, R.C., Ray-Chaudhuri, D.K.: On a class of error correcting binary group codes. Inf. Control 3(1), 68–79 (1960)MathSciNetCrossRefGoogle Scholar
  6. 6.
    Chakraborty, S., Meel, K.S., Vardi, M.Y.: A scalable approximate model counter. In: Schulte, C. (ed.) CP 2013. LNCS, vol. 8124, pp. 200–216. Springer, Heidelberg (2013). Scholar
  7. 7.
    Chakraborty, S., Meel, K.S., Vardi, M.Y.: Algorithmic improvements in approximate counting for probabilistic inference: from linear to logarithmic SAT calls. In: Proceedings of International Joint Conference on Artificial Intelligence (2016)Google Scholar
  8. 8.
    Chatzikokolakis, K., Palamidessi, C., Panangaden, P.: Anonymity protocols as noisy channels. Inf. Comput. 206(2–4), 378–401 (2008)MathSciNetCrossRefGoogle Scholar
  9. 9.
    Ermon, S., Gomes, C.P., Sabharwal, A., Selman, B.: Low-density parity constraints for hashing-based discrete integration. In: Proceedings of the 31th International Conference on Machine Learning, ICML 2014, Beijing, China, 21–26 June 2014, pp. 271–279 (2014)Google Scholar
  10. 10.
    Fuja, T.E., Sridhara, D., Tanner, R.M.: A class of group-structured LDPC codes. In: International Symposium on Communication Theory and Applications (2001)Google Scholar
  11. 11.
    Gallager, R.G.: Low Density Parity Check Codes. MIT Press, Cambridge (1963)zbMATHGoogle Scholar
  12. 12.
    Gebser, M., Kaufmann, B., Neumann, A., Schaub, T.: clasp: a conflict-driven answer set solver. In: Baral, C., Brewka, G., Schlipf, J. (eds.) LPNMR 2007. LNCS (LNAI), vol. 4483, pp. 260–265. Springer, Heidelberg (2007). Scholar
  13. 13.
    Gomes, C.P., Sabharwal, A., Selman, B.: Model counting: a new strategy for obtaining good bounds. In: Proceedings of AAAI, pp. 54–61 (2006)Google Scholar
  14. 14.
    Gomes, C.P., Sabharwal, A., Selman, B.: Model counting. In: Handbook of Satisfiability, pp. 633–654. IOS Press (2009)Google Scholar
  15. 15.
    Hocquenghem, A.: Codes correcteurs d’erreurs. Chiffres 2, 147–156 (1959)MathSciNetzbMATHGoogle Scholar
  16. 16.
    Klebanov, V., Manthey, N., Muise, C.: SAT-based analysis and quantification of information flow in programs. In: Joshi, K., Siegle, M., Stoelinga, M., D’Argenio, P.R. (eds.) QEST 2013. LNCS, vol. 8054, pp. 177–192. Springer, Heidelberg (2013). Scholar
  17. 17.
    Klebanov, V., Weigl, A., Weibarth, J.: Sound probabilistic #SAT with projection. In: Proceedings of QAPL (2016)Google Scholar
  18. 18.
    MacKay, D.J.C.: Good error-correcting codes based on very sparse matrices. IEEE Trans. Inf. Theory 45(3), 399–432 (1999)MathSciNetCrossRefGoogle Scholar
  19. 19.
    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
  20. 20.
    Smith, G.: On the foundations of quantitative information flow. In: de Alfaro, L. (ed.) FoSSaCS 2009. LNCS, vol. 5504, pp. 288–302. Springer, Heidelberg (2009). Scholar
  21. 21.
    Soos, M., Meel, K.S.: BIRD: engineering an efficient CNF-XOR SAT solver and its applications to approximate model counting. In: Proceedings of AAAI Conference on Artificial Intelligence (AAAI) (2019)Google Scholar
  22. 22.
    Soos, M., Nohl, K., Castelluccia, C.: Extending SAT solvers to cryptographic problems. In: Kullmann, O. (ed.) SAT 2009. LNCS, vol. 5584, pp. 244–257. Springer, Heidelberg (2009). Scholar
  23. 23.
    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
  24. 24.
    Valiant, L.G.: The complexity of enumeration and reliability problems. SIAM J. Comput. 8(3), 410–421 (1979)MathSciNetCrossRefGoogle Scholar
  25. 25.
    Valiant, L.G., Vazirani, V.V.: NP is as easy as detecting unique solutions. Theor. Comput. Sci. 47(3), 85–93 (1986)MathSciNetCrossRefGoogle Scholar

Copyright information

© Springer Nature Switzerland AG 2019

Authors and Affiliations

  1. 1.Dip. Statistica, Informatica, Applicazioni (DiSIA)Università di FirenzeFlorenceItaly
  2. 2.Department of Computer ScienceUniversità di Roma “La Sapienza”RomeItaly

Personalised recommendations