, Volume 24, Issue 2, pp 162–182 | Cite as

Model counting with error-correcting codes

  • Dimitris Achlioptas
  • Panos TheodoropoulosEmail author


The idea of counting the number of satisfying truth assignments (models) of a formula by adding random parity constraints can be traced back to the seminal work of Valiant and Vazirani showing that NP is as easy as detecting unique solutions. While theoretically sound, the random parity constraints used in that construction suffer from the following drawback: each constraint, on average, involves half of all variables. As a result, the branching factor associated with searching for models that also satisfy the parity constraints quickly gets out of hand. In this work we prove that one can work with much shorter parity constraints and still get rigorous mathematical guarantees, especially when the number of models is large so that many constraints need to be added. Our work is motivated by the realization that the essential feature for a system of parity constraints to be useful in probabilistic model counting is that its set of solutions resembles an error-correcting code.


Model counting Satisfiability Randomized algorithms Systems of parity equations Coding theory Low density parity check codes 



We are grateful to Kuldeep Meel and Moshe Vardi for sharing their code and formulas and for several valuable conversations. We also thank Zayd Hammoudeh, Ben Sherman, and Kostas Zampetakis for several comments on earlier versions.


  1. 1.
    Achim, T., Sabharwal, A., Ermon, S. (2016). Beyond parity constraints: Fourier analysis of hash functions for inference. In M. Balcan, & K.Q. Weinberger (Eds.) Proceedings of the 33nd International Conference on Machine Learning, ICML 2016, New York City, NY, USA, June 19-24, 2016, JMLR Workshop and Conference Proceedings., (Vol. 48 pp. 2254–2262).
  2. 2.
    Chakraborty, S., Fremont, D.J., Meel, K.S., Seshia, S.A., Vardi, M.Y. (2014). Distribution-aware sampling and weighted model counting for SAT. In Brodley, C.E., & Stone, P. (Eds.) Proceedings of the Twenty-Eighth AAAI Conference on Artificial Intelligence. (pp. 1722–1730). Québec City: AAAI Press.
  3. 3.
    Chakraborty, S., Meel, K.S., Vardi, M.Y. (2013). A scalable approximate model counter. In Schulte, C. (Ed.) Principles and Practice of Constraint Programming - 19th International Conference, CP 2013, Uppsala, Proceedings, Lecture Notes in Computer Science., (Vol. 8124 pp. 200–216): Springer.
  4. 4.
    Chakraborty, S., Meel, K.S., Vardi, M.Y. (2016). Algorithmic improvements in approximate counting for probabilistic inference: From linear to logarithmic SAT calls. In Kambhampati, S. (Ed.) Proceedings of the Twenty-Fifth International Joint Conference on Artificial Intelligence, IJCAI 2016. (pp. 3569–3576). New York: IJCAI/AAAI Press.
  5. 5.
    Ermon, S., Gomes, C.P., Sabharwal, A., Selman, B. (2013). Taming the curse of dimensionality: Discrete integration by hashing and optimization. In Proceedings of the 30th international conference on machine learning (ICML).Google Scholar
  6. 6.
    Ermon, S., Gomes, C.P., Sabharwal, A., Selman, B. (2014). Low-density parity constraints for hashing-based discrete integration. In Proceedings of the 31st international conference on machine learning (ICML) (pp. 271–279).Google Scholar
  7. 7.
    Gomes, C.P., Hoffmann, J., Sabharwal, A., Selman, B. (2007). Short XORs for model counting: From theory to practice. In Theory and applications of satisfiability testing (SAT) (pp. 100–106).Google Scholar
  8. 8.
    Gomes, C.P., Sabharwal, A., Selman, B. (2006). Model counting: a new strategy for obtaining good bounds. In Proceedings of the 21st national conference on artificial intelligence (AAAI) (pp 54–61).Google Scholar
  9. 9.
    Ivrii, A., Malik, S., Meel, K.S., Vardi, M.Y. (2016). On computing minimal independent support and its applications to sampling and counting. Constraints, 21(1), 41–58. Scholar
  10. 10.
    Meel, K.S., Vardi, M.Y., Chakraborty, S., Fremont, D.J., Seshia, S.A., Fried, D., Ivrii, A., Malik, S. (2016). Constrained sampling and counting: Universal hashing meets sat solving. In Workshops at the thirtieth AAAI conference on artificial intelligence.Google Scholar
  11. 11.
    Richardson, T., & Urbanke, R. (2008). Modern coding theory. New York: Cambridge University Press.CrossRefzbMATHGoogle Scholar
  12. 12.
    Sipser, M. (1983). A complexity theoretic approach to randomness. In Proceedings of the 15th ACM symposium on theory of computing (STOC) (pp 330–335).Google Scholar
  13. 13.
    Sipser, M., & Spielman, D.A. (1996). Expander codes. IEEE Transactions on Information Theory, 42(6), 1710–1722. Scholar
  14. 14.
    Soos, M. (2009). Cryptominisat–a sat solver for cryptographic problems.
  15. 15.
    Stockmeyer, L. (1985). On approximation algorithms for Ṗ. SIAM Journal on Computing, 14(4), 849–861.MathSciNetCrossRefzbMATHGoogle Scholar
  16. 16.
    Thurley, M. (2006). Sharpsat: Counting models with advanced component caching and implicit bcp. In Proceedings of the 9th International Conference on Theory and Applications of Satisfiability Testing, SAT’06. 424–429). Berlin: Springer.
  17. 17.
    Valiant, L., & Vazirani, V. (1986). NP is as easy as detecting unique solutions. Theoretical Computer Science, 47, 85–93.MathSciNetCrossRefzbMATHGoogle Scholar
  18. 18.
    Zhao, S., Chaturapruek, S., Sabharwal, A., Ermon, S. (2016). Closing the gap between short and long xors for model counting. In Schuurmans, D., & Wellman, M.P. (Eds.) Proceedings of the Thirtieth AAAI Conference on Artificial Intelligence. (pp. 3322–3329). Phoenix: AAAI Press.

Copyright information

© Springer Science+Business Media, LLC, part of Springer Nature 2019

Authors and Affiliations

  1. 1.Department of Computer ScienceUniversity of California Santa CruzSanta CruzUSA
  2. 2.Department of Informatics and TelecommunicationsUniversity of AthensPanepistimiopolisGreece

Personalised recommendations