Abstract
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.
...does P terminate with probability 1 on input \(\sigma \)? (almostsure termination)

2.
...is the expected time until P terminates on input \(\sigma \) finite? (positive almostsure 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 almostsure termination as well as deciding its universal variant is \(\varPi ^0_2\)complete in the arithmetical hierarchy. Deciding positive almostsure 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.
Similar content being viewed by others
Notes
The left branch is executed with probability \(\nicefrac {1}{3}\) and the right branch with probability \(\nicefrac {2}{3}\).
i.e. \({\textsf {diverge}}\) is syntactic sugar for \({\textsf {while}}\, \left( {\textsf {true}} \right) \, \left\{ {{\textsf {skip}}} \right\} \).
The notion of valid inputs is needed due to our restriction that program states have finite domains. If we drop this restriction, the set of all program states becomes uncountable. Moreover, note that it is clearly decidable whether a program state is valid for a given program.
Note that we allow the values of the quantified variables to be drawn from a computable domain other than \(\mathbb {N}\) that could be encoded in the natural numbers such as \(\mathbb {Q}\), the set of syntactically correct programs, etc.
The last quantifier is universal if n is even and existential if n is odd.
In this context, a set is cofinite iff its relative complement, i.e. its complement with respect to some appropriate universe, is finite.
i.e. iff \(\mathbb {S}_P \setminus \{\sigma \in \mathbb {S}_P ~~ (P,\, \sigma ) \in \mathcal {H} \}\) is finite.
This is because we ask for an apriori expected value with respect to an initial state.
I.e. the postexpectation that maps every program state to constantly 1.
The \(\varepsilon \) in the \( T _k(\ldots ,\, \varepsilon )\) comes from the fact that \( T _k\) is supposed to simulate k steps of an ordinary program. The \(\varepsilon \) thus stands for an empty sequence of resolutions of probabilistic choices.
The program P cheers as it was able to prove the termination of Q on input \(g_Q(i)\).
The runtime of a program corresponds to the number of execution steps in our operational semantics of pGCL (Definition 3). If more finegrained runtime models are considered that take, for instance, the size of numbers into account, a single program step can be simulated in at most polynomial time on a Turing machine. To this end, we first translate pGCL programs to programs on a random access machine and translate the resulting program to Turing machines (cf. [37, Theorem 2.5]). In particular, our reduction remains valid for such more finegrained runtime models.
Rounding up the value of i to a natural number, i.e. computing \(\max \{\lceil i \rceil ,\, 0\}\), is a technical necessity: We assume that variable valuations range over \(\mathbb {Q}\) but the domain of \(g_Q\) is \(\mathbb {N}\).
As opposed to a smoothed analysis of an algorithm.
References
Arons, T., Pnueli, A., Zuck, L.D.: Parameterized Verification by Probabilistic Abstraction. In: FoSSaCS, LNCS, vol. 2620, pp. 87–102. Springer (2003)
Ash, R.B., DoleansDade, C.: Probability and Measure Theory. Academic Press, Cambridge (2000)
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)
Bläser, M., Manthey, B.: Smoothed complexity theory. TOCT 7(2), 6:1–6:21 (2015)
Bournez, O., Garnier, F.: Proving positive almostsure 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)
Bournez, O., Hoyrup, M.: Rewriting logic and probabilities. In: RTA, LNCS, vol. 2706, pp. 61–75. Springer (2003)
Chakarov, A., Sankaranarayanan, S.: Probabilistic program analysis with martingales. In: CAV, LNCS, vol. 8044, pp. 511–526. Springer (2013)
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)
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)
Davis, M.D.: Computability and Unsolvability. McGrawHill Series in Information Processing and Computers. McGrawHill, New York (1958)
Davis, M.D.: Computability, Complexity, and Languages: Fundamentals of Theoretical Computer Science. Academic Press, Cambridge (1994)
Dijkstra, E.W.: A Discipline of Programming. PrenticeHall, Englewood Cliffs (1976)
Esparza, J., Gaiser, A., Kiefer, S.: Proving termination of probabilistic programs using patterns. In: CAV, LNCS, vol. 7358, pp. 123–138. Springer (2012)
Fioriti, L.M.F., Hermanns, H.: Probabilistic termination: soundness, completeness, and compositionality. In: POPL 2015, pp. 489–501. ACM (2015)
Foster, N., Kozen, D., Mamouras, K., Reitblatt, M., Silva, A.: Probabilistic NetKAT. In: ESOP, LNCS, vol. 9632, pp. 282–309. Springer (2016)
Gill, J.: Computational complexity of probabilistic turing machines. SIAM J. Comput. 6(4), 675–695 (1977)
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)
Gretz, F., Katoen, J.P., McIver, A.: Operational versus Weakest preexpectation semantics for the probabilistic guarded command language. Perform. Eval. 73, 110–132 (2014)
Hart, S., Sharir, M., Pnueli, A.: Termination of probabilistic concurrent programs. TOPLAS 5(3), 356–380 (1983)
Jansen, N., Kaminski, B.L., Katoen, J.P., Olmedo, F., Gretz, F., McIver, A.: Conditioning in probabilistic programming. ENTCS 319, 199–216 (2015)
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)
Kaminski, B.L., Katoen, J.P., Matheja, C.: Inferring covariances for probabilistic programs. In: QEST 2016, pp. 191–206 (2016)
Kaminski, B.L., Katoen, J.P., Matheja, C., Olmedo, F.: Weakest precondition reasoning for expected runtimes of probabilistic programs. (2016). arXiv:1601.01001
Kaminski, B.L., Katoen, J.P., Matheja, C., Olmedo, F.: Weakest precondition reasoning for expected runtimes of probabilistic programs. In: ESOP, LNCS, vol. 9632, pp. 364–389. Springer (2016)
Katoen, J., McIver, A., Meinicke, L., Morgan, C.C.: Linearinvariant generation for probabilistic programs: automated support for proofbased methods. In: SAS, LNCS, vol. 6337, pp. 390–406. Springer (2010)
Kleene, S.C.: Recursive predicates and quantifiers. Trans. AMS 53(1), 41–73 (1943)
Klenke, A.: Probability Theory: A Comprehensive Course. Springer, Berlin (2013)
Kozen, D.: Semantics of probabilistic programs. J. Comput. Syst. Sci. 22(3), 328–350 (1981)
Kozen, D.: A probabilistic PDL. J. Comput. Syst. Sci. 30(2), 162–178 (1985)
dal Lago, U., Grellois, C.: Probabilistic termination by monadic affine sized typing. In: ESOP, LNCS, vol. 10201, pp. 393–419. Springer (2017)
McIver, A., Morgan, C.: Abstraction, Refinement and Proof for Probabilistic Systems. Springer, Berlin (2004)
McIver, A., Morgan, C., Kaminski, B.L., Katoen, J.P.: A new proof rule for almostsure termination. In: POPL [to appear] (2018)
Morgan, C.: Proof rules for probabilistic loops. In: Proceedings of the BCSFACS 7th Refinement Workshop, Workshops in Computing, p. 7. Springer Verlag (1996)
Murawski, A., Ouaknine, J.: On probabilistic program equivalence and refinement. In: CONCUR, LNCS, vol. 3653, pp. 156–170. Springer (2005)
Odifreddi, P.: Classical Recursion Theory: The Theory of Functions and Sets of Natural Numbers. Elsevier, Amsterdam (1992)
Odifreddi, P.: Classical Recursion Theory, vol. II. Elsevier, Amsterdam (1999)
Papadimitriou, C.H.: Computational Complexity. AddisonWesley, Boston (1994)
Post, E.L.: Recursively enumerable sets of positive integers and their decision problems. Bull. AMS 50(5), 284–316 (1944)
Puterman, M.L.: Markov Decision Processes: Discrete Stochastic Dynamic Programming. Wiley, New York (2005)
Rogers, H.: Theory of Recursive Functions and Effective Computability, vol. 5. McGrawHill, New York (1967)
Sharir, M., Pnueli, A., Hart, S.: Verification of probabilistic programs. SIAM J. Comput. 13(2), 292–314 (1984). https://doi.org/10.1137/0213021
Sneyers, J., de Schreye, D.: Probabilistic termination of CHRiSM Programs. In: LOPSTR, LNCS, vol. 7225, pp. 221–236. Springer (2011)
Tiomkin, M.L.: Probabilistic termination versus fair termination. TCS 66(3), 333–340 (1989)
Ying, M.: Floyd–Hoare logic for quantum programs. ACM Trans. Program. Lang. Syst. 33(6), 19 (2011)
Acknowledgements
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.
Author information
Authors and Affiliations
Corresponding authors
Additional information
This research is Funded by the Excellence Initiative of the German federal and state governments, by the RTG 2236 UnRAVeL, and by the CDZ Project CAP (GZ 1023).
Rights and permissions
About this article
Cite this article
Kaminski, B.L., Katoen, JP. & Matheja, C. On the hardness of analyzing probabilistic programs. Acta Informatica 56, 255–285 (2019). https://doi.org/10.1007/s0023601803211
Received:
Accepted:
Published:
Issue Date:
DOI: https://doi.org/10.1007/s0023601803211