Abstract
We introduce the class of constant probability (CP) programs and show that classical results from probability theory directly yield a simple decision procedure for (positive) almost sure termination of programs in this class. Moreover, asymptotically tight bounds on their expected runtime can always be computed easily. Based on this, we present an algorithm to infer the exact expected runtime of any CP program.
Supported by the DFG Research Training Group 2236 UnRAVeL and the London Mathematical Society (Grant 41662, Research in Pairs).
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
If \(p' = 0\) and \(k = 0\) then \(\mu _\mathcal {P}\ge 0\).
- 2.
If \(m=0\) then \(\chi _\mathcal {P}(\lambda )=(p_0-1) \cdot \lambda ^k+p_{-1} \cdot \lambda ^{k-1}+\ldots +p_{-k}\), and if \(k=0\) then \(\chi _\mathcal {P}(\lambda )=p_m \cdot \lambda ^{m}+\ldots +p_1 \cdot \lambda +(p_0-1)\). Note that \(p_0 \ne 1\) since \(\mathcal {P}\) is PAST and in Definition 12 we required that \(m> 0\) implies \(p_m > 0\) and \(k > 0\) implies \(p_{-k} > 0\). Hence, the characteristic polynomial has exactly the degree \(k + m\), even if \(m = 0\) or \(k = 0\).
References
Agrawal, S., Chatterjee, K., Novotný, P.: Lexicographic ranking supermartingales: an efficient approach to termination of probabilistic programs. Proc. ACM Program. Lang. (POPL) 2, 34:1–34:32 (2018). https://doi.org/10.1145/3158122
Ash, R.B., Doleans-Dade, C.A.: Probability and Measure Theory. Elsevier/Academic Press (2000)
Bazzi, L., Mitter, S.: The solution of linear probabilistic recurrence relations. Algorithmica 36(1), 41–57 (2003). https://doi.org/10.1007/s00453-002-1003-4
Bournez, O., Garnier, F.: Proving positive almost-sure termination. In: Giesl, J. (ed.) RTA 2005. LNCS, vol. 3467, pp. 323–337. Springer, Heidelberg (2005). https://doi.org/10.1007/978-3-540-32033-3_24
Braverman, M.: Termination of integer linear programs. In: Ball, T., Jones, R.B. (eds.) CAV 2006. LNCS, vol. 4144, pp. 372–385. Springer, Heidelberg (2006). https://doi.org/10.1007/11817963_34
Brázdil, T., Brozek, V., Etessami, K.: One-counter stochastic games. In: Lodaya, K., Mahajan, M. (eds.) FSTTCS 2010, LIPIcs, vol. 8, pp. 108–119 (2010). https://doi.org/10.4230/LIPIcs.FSTTCS.2010.108
Brázdil, T., Kučera, A., Novotný, P., Wojtczak, D.: Minimizing expected termination time in one-counter Markov decision processes. In: Czumaj, A., Mehlhorn, K., Pitts, A., Wattenhofer, R. (eds.) ICALP 2012. LNCS, vol. 7392, pp. 141–152. Springer, Heidelberg (2012). https://doi.org/10.1007/978-3-642-31585-5_16
Brázdil, T., Esparza, J., Kiefer, S., Kucera, A.: Analyzing probabilistic pushdown automata. Formal Methods Syst. Des. 43(2), 124–163 (2013). https://doi.org/10.1007/s10703-012-0166-0
Brockschmidt, M., Emmes, F., Falke, S., Fuhs, C., Giesl, J.: Analyzing runtime and size complexity of integer programs. ACM Trans. Program. Lang. Syst. 38(4), 13:1–13:50 (2016). https://doi.org/10.1145/2866575
Chakarov, A., Sankaranarayanan, S.: Probabilistic program analysis with martingales. In: Sharygina, N., Veith, H. (eds.) CAV 2013. LNCS, vol. 8044, pp. 511–526. Springer, Heidelberg (2013). https://doi.org/10.1007/978-3-642-39799-8_34
Chatterjee, K., Fu, H., Murhekar, A.: Automated recurrence analysis for almost-linear expected-runtime bounds. In: Majumdar, R., Kunčak, V. (eds.) CAV 2017. LNCS, vol. 10426, pp. 118–139. Springer, Cham (2017). https://doi.org/10.1007/978-3-319-63387-9_6
Chatterjee, K., Novotný, P., Zikelic, D.: Stochastic invariants for probabilistic termination. In: Castagna, G., Gordon, A.D. (eds.) POPL 2017, pp. 145–160 (2017). https://doi.org/10.1145/3093333.3009873
Chatterjee, K., Fu, H., Novotný, P., Hasheminezhad, R.: Algorithmic analysis of qualitative and quantitative termination problems for affine probabilistic programs. ACM Trans. Program. Lang. Syst. 40(2), 7:1–7:45 (2018). https://doi.org/10.1145/3174800
Elaydi, S.: An Introduction to Difference Equations. Springer, New York (2005). https://doi.org/10.1007/0-387-27602-5
Esparza, J., Kucera, A., Mayr, R.: Quantitative analysis of probabilistic pushdown automata: expectations and variances. In: Panangaden, P. (ed.) LICS 2005, pp. 117–126 (2005). https://doi.org/10.1109/LICS.2005.39
Feller, W.: An Introduction to Probability Theory and Its Applications, Probability and Mathematical Statistics, vol. 1. Wiley, Hoboken (1950)
Fioriti, L.M.F., Hermanns, H.: Probabilistic termination: soundness, completeness, and compositionality. In: Rajamani, S.K., Walker, D. (eds.) POPL 2015, pp. 489–501 (2015). https://doi.org/10.1145/2676726.2677001
Frohn, F., Giesl, J.: Termination of triangular integer loops is decidable. In: Dillig, I., Tasiran, S. (eds.) CAV 2019. LNCS, vol. 11562, pp. 426–444. Springer, Cham (2019). https://doi.org/10.1007/978-3-030-25543-5_24
Fu, H., Chatterjee, K.: Termination of nondeterministic probabilistic programs. In: Enea, C., Piskac, R. (eds.) VMCAI 2019. LNCS, vol. 11388, pp. 468–490. Springer, Cham (2019). https://doi.org/10.1007/978-3-030-11245-5_22
Giesl, J., Giesl, P., Hark, M.: Computing expected runtimes for constant probability programs. CoRR abs/1905.09544 (2019). https://arxiv.org/abs/1905.09544
Grimmett, G., Stirzaker, D.: Probability and Random Processes. Oxford University Press, Oxford (2001)
Johansson, F., et al.: MpMath: a Python library for arbitrary-precision floating-point arithmetic. http://mpmath.org/
Kaminski, B.L., Katoen, J.: On the hardness of almost-sure termination. In: Italiano, G.F., Pighizzini, G., Sannella, D. (eds.) MFCS 2015. LNCS, vol. 9234, pp. 307–318. Springer, Heidelberg (2015). https://doi.org/10.1007/978-3-662-48057-1_24
Kaminski, B.L., Katoen, J.-P., Matheja, C., Olmedo, F.: Weakest precondition reasoning for expected run–times of probabilistic programs. In: Thiemann, P. (ed.) ESOP 2016. LNCS, vol. 9632, pp. 364–389. Springer, Heidelberg (2016). https://doi.org/10.1007/978-3-662-49498-1_15
Karp, R.M.: Probabilistic recurrence relations. J. ACM 41(6), 1136–1150 (1994). https://doi.org/10.1145/195613.195632
Kozen, D.: Semantics of probabilistic programs. In: Kosaraju, S.R. (ed.) FOCS 1979, pp. 101–114 (1979). https://doi.org/10.1109/SFCS.1979.38
McIver, A., Morgan, C.: Abstraction, Refinement and Proof for Probabilistic Systems. Springer, New York (2005). https://doi.org/10.1007/b138392
McIver, A., Morgan, C., Kaminski, B.L., Katoen, J.: A new proof rule for almost-sure termination. Proc. ACM Program. Lang. (POPL) 2, 33:1–33:28 (2018). https://doi.org/10.1145/3158121
Meurer, A., et al.: SymPy: symbolic computing in Python. Peer J Comput. Sci. 3, e103 (2017). https://doi.org/10.7717/peerj-cs.103
Ngo, V.C., Carbonneaux, Q., Hoffmann, J.: Bounded expectations: resource analysis for probabilistic programs. In: Foster, J.S., Grossman, D. (eds.) PLDI 2018, pp. 496–512 (2018). https://doi.org/10.1145/3192366.3192394. Extended Version available at https://arxiv.org/abs/1711.08847
Ouaknine, J., Pinto, J.S., Worrell, J.: On termination of integer linear loops. In: Indyk, P. (ed.) SODA 2015, pp. 957–969 (2015). https://doi.org/10.1137/1.9781611973730.65
Puterman, M.L.: Markov Decision Processes: Discrete Stochastic Dynamic Programming. Wiley, New York (1994)
Spitzer, F.: Principles of Random Walk. Springer, New York (1964). https://doi.org/10.1007/978-1-4757-4229-9
Tassarotti, J., Harper, R.: Verified tail bounds for randomized programs. In: Avigad, J., Mahboubi, A. (eds.) ITP 2018. LNCS, vol. 10895, pp. 560–578. Springer, Cham (2018). https://doi.org/10.1007/978-3-319-94821-8_33
Tiwari, A.: Termination of linear programs. In: Alur, R., Peled, D.A. (eds.) CAV 2004. LNCS, vol. 3114, pp. 70–82. Springer, Heidelberg (2004). https://doi.org/10.1007/978-3-540-27813-9_6
Acknowledgments
We would like to thank Nicos Georgiou and Vladislav Vysotskiy for drawing our attention to Wald’s Lemma and to the work of Frank Spitzer on random walks, and Benjamin Lucien Kaminski and Christoph Matheja for many helpful discussions. Furthermore, we thank Tom Küspert who helped with the implementation of our technique in our tool KoAT.
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2019 Springer Nature Switzerland AG
About this paper
Cite this paper
Giesl, J., Giesl, P., Hark, M. (2019). Computing Expected Runtimes for Constant Probability Programs. In: Fontaine, P. (eds) Automated Deduction – CADE 27. CADE 2019. Lecture Notes in Computer Science(), vol 11716. Springer, Cham. https://doi.org/10.1007/978-3-030-29436-6_16
Download citation
DOI: https://doi.org/10.1007/978-3-030-29436-6_16
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-030-29435-9
Online ISBN: 978-3-030-29436-6
eBook Packages: Computer ScienceComputer Science (R0)