Acta Informatica

, Volume 56, Issue 3, pp 255–285 | Cite as

On the hardness of analyzing probabilistic programs

  • Benjamin Lucien KaminskiEmail author
  • Joost-Pieter KatoenEmail author
  • Christoph MathejaEmail author
Original Article


We study the hardness of deciding probabilistic termination as well as the hardness of approximating expected values (e.g. of program variables) and (co)variances for probabilistic programs.

Termination We distinguish two notions of probabilistic termination: Given a program P and an input \(\sigma \)...
  1. 1.

    ...does P terminate with probability 1 on input \(\sigma \)? (almost-sure termination)

  2. 2. the expected time until P terminates on input \(\sigma \) finite? (positive almost-sure termination)

For both of these notions, we also consider their universal variant, i.e. given a program P, does P terminate on all inputs? We show that deciding almost-sure termination as well as deciding its universal variant is \(\varPi ^0_2\)-complete in the arithmetical hierarchy. Deciding positive almost-sure termination is shown to be \(\varSigma _2^0\)-complete, whereas its universal variant is \(\varPi _3^0\)-complete.

Expected values Given a probabilistic program P and a random variable f mapping program states to rationals, we show that computing lower and upper bounds on the expected value of f after executing P is \(\varSigma _1^0\)- and \(\varSigma _2^0\)-complete, respectively. Deciding whether the expected value equals a given rational value is shown to be \(\varPi ^0_2\)-complete.

Covariances We show that computing upper and lower bounds on the covariance of two random variables is both \(\varSigma _2^0\)-complete. Deciding whether the covariance equals a given rational value is shown to be in \(\varDelta _3^0\). In addition, this problem is shown to be \(\varSigma ^0_2\)-hard as well as \(\varPi ^0_2\)-hard and thus a “proper” \(\varDelta _3^0\)-problem. All hardness results on covariances apply to variances as well.



The authors would like to thank Luis María Ferrer Fioriti (Saarland University), Federico Olmedo (University of Chile), and Wolfgang Thomas (RWTH Aachen University) for the fruitful discussions on the topics of this paper. Furthermore, we acknowledge the valuable and very constructive comments we received from the anonymous referees that lead to substantial improvements of this paper.


  1. 1.
    Arons, T., Pnueli, A., Zuck, L.D.: Parameterized Verification by Probabilistic Abstraction. In: FoSSaCS, LNCS, vol. 2620, pp. 87–102. Springer (2003)Google Scholar
  2. 2.
    Ash, R.B., Doleans-Dade, C.: Probability and Measure Theory. Academic Press, Cambridge (2000)zbMATHGoogle Scholar
  3. 3.
    Barthe, G., Köpf, B., Olmedo, F., Béguelin, S.Z.: Probabilistic relational reasoning for differential privacy. ACM Trans. Program. Lang. Syst. 35(3), 9 (2013)CrossRefzbMATHGoogle Scholar
  4. 4.
    Bläser, M., Manthey, B.: Smoothed complexity theory. TOCT 7(2), 6:1–6:21 (2015)MathSciNetCrossRefzbMATHGoogle Scholar
  5. 5.
    Bournez, O., Garnier, F.: Proving positive almost-sure termination. In: Proceedings of 16th International Conference on Term Rewriting and Applications, RTA 2005, Nara, Japan, April 19–21, 2005,LNCS, vol. 3467, pp. 323–337. Springer (2005)Google Scholar
  6. 6.
    Bournez, O., Hoyrup, M.: Rewriting logic and probabilities. In: RTA, LNCS, vol. 2706, pp. 61–75. Springer (2003)Google Scholar
  7. 7.
    Chakarov, A., Sankaranarayanan, S.: Probabilistic program analysis with martingales. In: CAV, LNCS, vol. 8044, pp. 511–526. Springer (2013)Google Scholar
  8. 8.
    Chatterjee, K., Fu, H., Goharshady, A.K.: Termination analysis of probabilistic programs through positivstellensatz’s. In: CAV (1), LNCS, vol. 9779, pp. 3–22. Springer (2016)Google Scholar
  9. 9.
    Chatterjee, K., Fu, H., Novotný, P., Hasheminezhad, R.: Algorithmic analysis of qualitative and quantitative termination problems for affine probabilistic programs. In: POPL, pp. 327–342. ACM (2016)Google Scholar
  10. 10.
    Davis, M.D.: Computability and Unsolvability. McGraw-Hill Series in Information Processing and Computers. McGraw-Hill, New York (1958)Google Scholar
  11. 11.
    Davis, M.D.: Computability, Complexity, and Languages: Fundamentals of Theoretical Computer Science. Academic Press, Cambridge (1994)Google Scholar
  12. 12.
    Dijkstra, E.W.: A Discipline of Programming. Prentice-Hall, Englewood Cliffs (1976)zbMATHGoogle Scholar
  13. 13.
    Esparza, J., Gaiser, A., Kiefer, S.: Proving termination of probabilistic programs using patterns. In: CAV, LNCS, vol. 7358, pp. 123–138. Springer (2012)Google Scholar
  14. 14.
    Fioriti, L.M.F., Hermanns, H.: Probabilistic termination: soundness, completeness, and compositionality. In: POPL 2015, pp. 489–501. ACM (2015)Google Scholar
  15. 15.
    Foster, N., Kozen, D., Mamouras, K., Reitblatt, M., Silva, A.: Probabilistic NetKAT. In: ESOP, LNCS, vol. 9632, pp. 282–309. Springer (2016)Google Scholar
  16. 16.
    Gill, J.: Computational complexity of probabilistic turing machines. SIAM J. Comput. 6(4), 675–695 (1977)MathSciNetCrossRefzbMATHGoogle Scholar
  17. 17.
    Gordon, A.D., Henzinger, T.A., Nori, A.V., Rajamani, S.K.: Probabilistic programming. In: Future of Software Engineering (FOSE), pp. 167–181. ACM (2014)Google Scholar
  18. 18.
    Gretz, F., Katoen, J.P., McIver, A.: Operational versus Weakest pre-expectation semantics for the probabilistic guarded command language. Perform. Eval. 73, 110–132 (2014)CrossRefGoogle Scholar
  19. 19.
    Hart, S., Sharir, M., Pnueli, A.: Termination of probabilistic concurrent programs. TOPLAS 5(3), 356–380 (1983)CrossRefzbMATHGoogle Scholar
  20. 20.
    Jansen, N., Kaminski, B.L., Katoen, J.P., Olmedo, F., Gretz, F., McIver, A.: Conditioning in probabilistic programming. ENTCS 319, 199–216 (2015)MathSciNetzbMATHGoogle Scholar
  21. 21.
    Kaminski, B.L., Katoen, J.P.: On the hardness of almost–sure termination. In: Proceedings of MFCS 2015, Part I, LNCS, vol. 9234, pp. 307–318. Springer (2015)Google Scholar
  22. 22.
    Kaminski, B.L., Katoen, J.P., Matheja, C.: Inferring covariances for probabilistic programs. In: QEST 2016, pp. 191–206 (2016)Google Scholar
  23. 23.
    Kaminski, B.L., Katoen, J.P., Matheja, C., Olmedo, F.: Weakest precondition reasoning for expected run-times of probabilistic programs. (2016). arXiv:1601.01001
  24. 24.
    Kaminski, B.L., Katoen, J.P., Matheja, C., Olmedo, F.: Weakest precondition reasoning for expected run-times of probabilistic programs. In: ESOP, LNCS, vol. 9632, pp. 364–389. Springer (2016)Google Scholar
  25. 25.
    Katoen, J., McIver, A., Meinicke, L., Morgan, C.C.: Linear-invariant generation for probabilistic programs: automated support for proof-based methods. In: SAS, LNCS, vol. 6337, pp. 390–406. Springer (2010)Google Scholar
  26. 26.
    Kleene, S.C.: Recursive predicates and quantifiers. Trans. AMS 53(1), 41–73 (1943)MathSciNetCrossRefzbMATHGoogle Scholar
  27. 27.
    Klenke, A.: Probability Theory: A Comprehensive Course. Springer, Berlin (2013)zbMATHGoogle Scholar
  28. 28.
    Kozen, D.: Semantics of probabilistic programs. J. Comput. Syst. Sci. 22(3), 328–350 (1981)MathSciNetCrossRefzbMATHGoogle Scholar
  29. 29.
    Kozen, D.: A probabilistic PDL. J. Comput. Syst. Sci. 30(2), 162–178 (1985)MathSciNetCrossRefzbMATHGoogle Scholar
  30. 30.
    dal Lago, U., Grellois, C.: Probabilistic termination by monadic affine sized typing. In: ESOP, LNCS, vol. 10201, pp. 393–419. Springer (2017)Google Scholar
  31. 31.
    McIver, A., Morgan, C.: Abstraction, Refinement and Proof for Probabilistic Systems. Springer, Berlin (2004)zbMATHGoogle Scholar
  32. 32.
    McIver, A., Morgan, C., Kaminski, B.L., Katoen, J.P.: A new proof rule for almost-sure termination. In: POPL [to appear] (2018)Google Scholar
  33. 33.
    Morgan, C.: Proof rules for probabilistic loops. In: Proceedings of the BCS-FACS 7th Refinement Workshop, Workshops in Computing, p. 7. Springer Verlag (1996)Google Scholar
  34. 34.
    Murawski, A., Ouaknine, J.: On probabilistic program equivalence and refinement. In: CONCUR, LNCS, vol. 3653, pp. 156–170. Springer (2005)Google Scholar
  35. 35.
    Odifreddi, P.: Classical Recursion Theory: The Theory of Functions and Sets of Natural Numbers. Elsevier, Amsterdam (1992)zbMATHGoogle Scholar
  36. 36.
    Odifreddi, P.: Classical Recursion Theory, vol. II. Elsevier, Amsterdam (1999)zbMATHGoogle Scholar
  37. 37.
    Papadimitriou, C.H.: Computational Complexity. Addison-Wesley, Boston (1994)zbMATHGoogle Scholar
  38. 38.
    Post, E.L.: Recursively enumerable sets of positive integers and their decision problems. Bull. AMS 50(5), 284–316 (1944)MathSciNetCrossRefzbMATHGoogle Scholar
  39. 39.
    Puterman, M.L.: Markov Decision Processes: Discrete Stochastic Dynamic Programming. Wiley, New York (2005)zbMATHGoogle Scholar
  40. 40.
    Rogers, H.: Theory of Recursive Functions and Effective Computability, vol. 5. McGraw-Hill, New York (1967)zbMATHGoogle Scholar
  41. 41.
    Sharir, M., Pnueli, A., Hart, S.: Verification of probabilistic programs. SIAM J. Comput. 13(2), 292–314 (1984). MathSciNetCrossRefzbMATHGoogle Scholar
  42. 42.
    Sneyers, J., de Schreye, D.: Probabilistic termination of CHRiSM Programs. In: LOPSTR, LNCS, vol. 7225, pp. 221–236. Springer (2011)Google Scholar
  43. 43.
    Tiomkin, M.L.: Probabilistic termination versus fair termination. TCS 66(3), 333–340 (1989)MathSciNetCrossRefzbMATHGoogle Scholar
  44. 44.
    Ying, M.: Floyd–Hoare logic for quantum programs. ACM Trans. Program. Lang. Syst. 33(6), 19 (2011)CrossRefGoogle Scholar

Copyright information

© Springer-Verlag GmbH Germany, part of Springer Nature 2018

Authors and Affiliations

  1. 1.Software Modeling and Verification GroupRWTH Aachen UniversityAachenGermany

Personalised recommendations