skip to main content
research-article
Open Access

A Calculus for Amortized Expected Runtimes

Published:11 January 2023Publication History
Skip Abstract Section

Abstract

We develop a weakest-precondition-style calculus à la Dijkstra for reasoning about amortized expected runtimes of randomized algorithms with access to dynamic memory — the aert calculus. Our calculus is truly quantitative, i.e. instead of Boolean valued predicates, it manipulates real-valued functions. En route to the aert calculus, we study the ert calculus for reasoning about expected runtimes of Kaminski et al. [2018] extended by capabilities for handling dynamic memory, thus enabling compositional and local reasoning about randomized data structures. This extension employs runtime separation logic, which has been foreshadowed by Matheja [2020] and then implemented in Isabelle/HOL by Haslbeck [2021]. In addition to Haslbeck’s results, we further prove soundness of the so-extended ert calculus with respect to an operational Markov decision process model featuring countably-branching nondeterminism, provide extensive intuitive explanations, and provide proof rules enabling separation logic-style verification for upper bounds on expected runtimes. Finally, we build the so-called potential method for amortized analysis into the ert calculus, thus obtaining the aert calculus. Soundness of the aert calculus is obtained from the soundness of the ert calculus and some probabilistic form of telescoping. Since one needs to be able to handle changes in potential which can in principle be both positive or negative, the aert calculus needs to be — essentially — capable of handling certain signed random variables. A particularly pleasing feature of our solution is that, unlike e.g. Kozen [1985], we obtain a loop rule for our signed random variables, and furthermore, unlike e.g. Kaminski and Katoen [2017], the aert calculus makes do without the need for involved technical machinery keeping track of the integrability of the random variables.

Finally, we present case studies, including a formal analysis of a randomized delete-insert-find-any set data structure [Brodal et al. 1996], which yields a constant expected runtime per operation, whereas no deterministic algorithm can achieve this.

References

  1. Susanne Albers and Marek Karpinski. 2002. Randomized Splay Trees: Theoretical and Experimental Results. Inform. Process. Lett., 81, 4 (2002), 213–221. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Robert Atkey. 2011. Amortised Resource Analysis with Separation Logic. Log. Methods Comput. Sci., 7, 2 (2011). Google ScholarGoogle Scholar
  3. Martin Avanzini, Ugo Dal Lago, and Alexis Ghyselen. 2019. Type-Based Complexity Analysis of Probabilistic Functional Programs. In LICS. IEEE, 1–13. Google ScholarGoogle Scholar
  4. Christel Baier and Joost-Pieter Katoen. 2008. Principles of Model Checking. MIT Press. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Kevin Batz, Mingshuai Chen, Benjamin Lucien Kaminski, Joost-Pieter Katoen, Christoph Matheja, and Philipp Schröer. 2021. Latticed k-Induction with an Application to Probabilistic Programs. In CAV (2) (Lecture Notes in Computer Science, Vol. 12760). Springer, 524–549. Google ScholarGoogle Scholar
  6. Kevin Batz, Ira Fesefeldt, Marvin Jansen, Joost-Pieter Katoen, Florian Keß ler, Christoph Matheja, and Thomas Noll. 2022. Foundations for Entailment Checking in Quantitative Separation Logic. In ESOP (Lecture Notes in Computer Science, Vol. 13240). Springer, 57–84. Google ScholarGoogle Scholar
  7. Kevin Batz, Benjamin Lucien Kaminski, Joost-Pieter Katoen, and Christoph Matheja. 2021. Relatively complete verification of probabilistic programs: an expressive language for expectation-based reasoning. Proc. ACM Program. Lang., 5, POPL (2021), 1–30. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Kevin Batz, Benjamin Lucien Kaminski, Joost-Pieter Katoen, Christoph Matheja, and Thomas Noll. 2019. Quantitative Separation Logic — A Logic for Reasoning about Probabilistic Programs. Proc. ACM Program. Lang., 3, POPL (2019), 34:1–34:29. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Kevin Batz, Benjamin Lucien Kaminski, Joost-Pieter Katoen, Christoph Matheja, and Lena Verscht. 2022. A Calculus for Amortized Expected Runtimes - Extended Version. CoRR, to appear Google ScholarGoogle Scholar
  10. David Blackwell. 1967. Positive dynamic programming. In Proceedings of the 5th Berkeley Symposium on Mathematical Statistics and Probability. 1, University of California Press, 415–418. Google ScholarGoogle Scholar
  11. Tomás Brázdil, Stefan Kiefer, Antonín Kucera, and Ivana Hutarová Vareková. 2015. Runtime Analysis of Probabilistic Programs with Unbounded Recursion. J. Comput. System Sci., 81, 1 (2015), 288–310. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Gerth Stølting Brodal, Shiva Chaudhuri, and Jaikumar Radhakrishnan. 1996. The Randomized Complexity of Maintaining the Minimum. Nord. J. Comput., 3, 4 (1996), 337–351. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Quentin Carbonneaux, Jan Hoffmann, Tahina Ramananandro, and Zhong Shao. 2014. End-to-end verification of stack-space bounds for C programs. In PLDI. ACM, 270–281. Google ScholarGoogle Scholar
  14. Orieta Celiku and Annabelle McIver. 2005. Compositional Specification and Analysis of Cost–Based Properties in Probabilistic Programs. In Proc. of the International Symposium on Formal Methods (FM) (Lecture Notes in Computer Science, Vol. 3582). Springer, 107–122. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Arthur Charguéraud and François Pottier. 2019. Verifying the Correctness and Amortized Complexity of a Union-Find Implementation in Separation Logic with Time Credits. J. Autom. Reason., 62, 3 (2019), 331–365. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. 2009. Introduction to Algorithms, 3rd Edition. MIT Press. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Martin Fürer. 1999. Randomized Splay Trees. In SODA. ACM/SIAM, 903–904. Google ScholarGoogle Scholar
  18. Armaël Guéneau, Arthur Charguéraud, and François Pottier. 2018. A Fistful of Dollars: Formalizing Asymptotic Complexity Claims via Deductive Program Verification. In ESOP (Lecture Notes in Computer Science, Vol. 10801). Springer, 533–560. Google ScholarGoogle ScholarCross RefCross Ref
  19. Maximilian Paul Louis Haslbeck. 2021. Verified Quantitative Analysis of Imperative Algorithms. Technische Universität München. Google ScholarGoogle Scholar
  20. Maximilian Paul Louis Haslbeck and Tobias Nipkow. 2018. Hoare Logics for Time Bounds - A Study in Meta Theory. In TACAS (1) (Lecture Notes in Computer Science, Vol. 10805). Springer, 155–171. Google ScholarGoogle Scholar
  21. Jan Hoffmann. 2011. Types with Potential: Polynomial Resource Bounds via Automatic Amortized Analysis. Ph. D. Dissertation. LMU Munich. Google ScholarGoogle Scholar
  22. Jan Hoffmann and Steffen Jost. 2022. Two decades of automatic amortized resource analysis. Math. Struct. Comput. Sci.. Google ScholarGoogle Scholar
  23. Samin S. Ishtiaq and Peter William O’Hearn. 2001. BI as an Assertion Language for Mutable Data Structures. In Proc. of the Symposium on Principles of Programming Languages (POPL). ACM, 14–26. Google ScholarGoogle Scholar
  24. David M. Kahn and Jan Hoffmann. 2020. Exponential Automatic Amortized Resource Analysis. In FoSSaCS (Lecture Notes in Computer Science, Vol. 12077). Springer, 359–380. Google ScholarGoogle Scholar
  25. Benjamin Lucien Kaminski. 2019. Advanced Weakest Precondition Calculi for Probabilistic Programs. RWTH Aachen University. Aachen. https://doi.org/10.18154/RWTH-2019-01829 Google ScholarGoogle ScholarCross RefCross Ref
  26. Benjamin Lucien Kaminski and Joost-Pieter Katoen. 2017. A Weakest Pre–expectation Semantics for Mixed–sign Expectations. In Proc. of the Annual Symposium on Logic in Computer Science (LICS). IEEE Computer Society, 1–12. Google ScholarGoogle ScholarCross RefCross Ref
  27. Benjamin Lucien Kaminski, Joost-Pieter Katoen, Christoph Matheja, and Federico Olmedo. 2018. Weakest Precondition Reasoning for Expected Runtimes of Randomized Algorithms. J. ACM, 30. Google ScholarGoogle Scholar
  28. Dexter Kozen. 1985. A Probabilistic PDL. J. Comput. System Sci., 30, 2 (1985), 162–178. Google ScholarGoogle ScholarCross RefCross Ref
  29. Lorenz Leutgeb, Georg Moser, and Florian Zuleger. 2022. Automated Expected Amortised Cost Analysis of Probabilistic Data Structures. In Proc. of the International Conference on Computer-Aided Verification (Lecture Notes inn Computer Science). (to appear) Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Christoph Matheja. 2020. Automated Reasoning and Randomization in Separation Logic. RWTH Aachen University, Germany. Google ScholarGoogle Scholar
  31. Annabelle McIver and Carroll Morgan. 2005. Abstraction, Refinement and Proof for Probabilistic Systems. Springer. Google ScholarGoogle Scholar
  32. Glen Mével, Jacques-Henri Jourdan, and François Pottier. 2019. Time Credits and Time Receipts in Iris. In ESOP (Lecture Notes in Computer Science, Vol. 11423). Springer, 3–29. Google ScholarGoogle ScholarCross RefCross Ref
  33. Fabian Meyer, Marcel Hark, and Jürgen Giesl. 2021. Inferring Expected Runtimes of Probabilistic Integer Programs Using Expected Sizes. In TACAS (1) (Lecture Notes in Computer Science, Vol. 12651). Springer, 250–269. Google ScholarGoogle Scholar
  34. David Monniaux. 2001. An Abstract Analysis of the Probabilistic Termination of Programs. In Proc. of the Static Analysis Symposium (SAS) (Lecture Notes in Computer Science, Vol. 2126). Springer, 111–126. Google ScholarGoogle ScholarCross RefCross Ref
  35. Marcel Moosbrugger, Ezio Bartocci, Joost-Pieter Katoen, and Laura Kovács. 2021. Automated Termination Analysis of Polynomial Probabilistic Programs. In ESOP (Lecture Notes in Computer Science, Vol. 12648). Springer, 491–518. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. Van Chan Ngo, Quentin Carbonneaux, and Jan Hoffmann. 2018. Bounded Expectations: Resource Analysis for Probabilistic Programs. In Proc. of the Conference on Programming Language Design and Implementation (PLDI). ACM, 496–512. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. Tobias Nipkow. 2015. Amortized Complexity Verified. In ITP (Lecture Notes in Computer Science, Vol. 9236). Springer, 310–324. Google ScholarGoogle ScholarCross RefCross Ref
  38. Tobias Nipkow and Hauke Brinkop. 2019. Amortized Complexity Verified. J. Autom. Reason., 62, 3 (2019), 367–391. Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. William W. Pugh. 1989. Skip Lists: A Probabilistic Alternative to Balanced Trees. In WADS (Lecture Notes in Computer Science, Vol. 382). Springer, 437–449. Google ScholarGoogle ScholarCross RefCross Ref
  40. Martin Lee Puterman. 2005. Markov Decision Processes: Discrete Stochastic Dynamic Programming. John Wiley & Sons. Google ScholarGoogle ScholarDigital LibraryDigital Library
  41. Vineet Rajani, Marco Gaboardi, Deepak Garg, and Jan Hoffmann. 2021. A unifying type-theory for higher-order (amortized) cost analysis. Proc. ACM Program. Lang., 5, POPL (2021), 1–28. Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. John Charles Reynolds. 2002. Separation Logic: A Logic for Shared Mutable Data Structures. In Proc. of the Annual Symposium on Logic in Computer Science (LICS). IEEE Computer Society, 55–74. Google ScholarGoogle ScholarCross RefCross Ref
  43. Daniel Dominic Sleator and Robert Endre Tarjan. 1985. Self-Adjusting Binary Search Trees. J. ACM, 652–686. Google ScholarGoogle Scholar
  44. Robert Endre Tarjan. 1985. Amortized Computational Complexity. SIAM Journal on Algebraic Discrete Methods, 306–318. Google ScholarGoogle Scholar
  45. Di Wang, David M. Kahn, and Jan Hoffmann. 2020. Raising expectations: automating expected cost analysis with types. Proc. ACM Program. Lang., 4, ICFP (2020), 110:1–110:31. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. A Calculus for Amortized Expected Runtimes

                Recommendations

                Comments

                Login options

                Check if you have access through your login credentials or your institution to get full access on this article.

                Sign in

                Full Access

                • Article Metrics

                  • Downloads (Last 12 months)278
                  • Downloads (Last 6 weeks)66

                  Other Metrics

                PDF Format

                View or Download as a PDF file.

                PDF

                eReader

                View online with eReader.

                eReader
                About Cookies On This Site

                We use cookies to ensure that we give you the best experience on our website.

                Learn more

                Got it!