Bounded expectations: resource analysis for probabilistic programs

This paper presents a new static analysis for deriving upper bounds on the expected resource consumption of probabilistic programs. The analysis is fully automatic and derives symbolic bounds that are multivariate polynomials in the inputs. The new technique combines manual state-of-the-art reasoning techniques for probabilistic programs with an effective method for automatic resource-bound analysis of deterministic programs. It can be seen as both, an extension of automatic amortized resource analysis (AARA) to probabilistic programs and an automation of manual reasoning for probabilistic programs that is based on weakest preconditions. An advantage of the technique is that it combines the clarity and compositionality of a weakest-precondition calculus with the efficient automation of AARA. As a result, bound inference can be reduced to off-the-shelf LP solving in many cases and automatically-derived bounds can be interactively extended with standard program logics if the automation fails. Building on existing work, the soundness of the analysis is proved with respect to an operational semantics that is based on Markov decision processes. The effectiveness of the technique is demonstrated with a prototype implementation that is used to automatically analyze 39 challenging probabilistic programs and randomized algorithms. Experiments indicate that the derived constant factors in the bounds are very precise and even optimal for some programs.

[1]  Nils Anders Danielsson Lightweight semiformal time complexity analysis for purely functional data structures , 2008, POPL '08.

[2]  Pedro B. Vasconcelos Space cost analysis using sized types , 2008 .

[3]  Formal Certification of Randomized Algorithms , 2016 .

[4]  Philippe Flajolet,et al.  Automatic Average-Case Analysis of Algorithm , 1991, Theor. Comput. Sci..

[5]  Benjamin Grégoire,et al.  A Program Logic for Union Bounds , 2016, ICALP.

[6]  Martin Hofmann,et al.  "Carbon Credits" for Resource-Bounded Computations Using Amortised Analysis , 2009, FM.

[7]  Zhong Shao,et al.  Automated Resource Analysis with Coq Proof Objects , 2017, CAV.

[8]  Pavol Cerný,et al.  Segment Abstraction for Worst-Case Execution Time Analysis , 2015, ESOP.

[9]  Umut A. Acar,et al.  Refinement Types for Incremental Computational Complexity , 2015, ESOP.

[10]  Marcelo d'Amorim,et al.  Compositional solution space quantification for probabilistic software analysis , 2014, PLDI.

[11]  Tobias Nipkow Amortized Complexity Verified , 2015, ITP.

[12]  Sumit Gulwani,et al.  SPEED: precise and efficient static estimation of program computational complexity , 2009, POPL '09.

[13]  Ugo Dal Lago,et al.  The geometry of types , 2012, POPL.

[14]  Samir Genaim,et al.  On the Limits of the Classical Approach to Cost Analysis , 2012, SAS.

[15]  Zhong Shao,et al.  Compositional certified resource bounds , 2015, PLDI.

[16]  Timon Gehr,et al.  PSI: Exact Symbolic Inference for Probabilistic Programs , 2016, CAV.

[17]  Marco Gaboardi,et al.  Relational cost analysis , 2017, POPL.

[18]  Krishnendu Chatterjee,et al.  Termination Analysis of Probabilistic Programs Through Positivstellensatz's , 2016, CAV.

[19]  Martin Hofmann,et al.  Amortized Resource Analysis with Polymorphic Recursion and Partial Big-Step Operational Semantics , 2010, APLAS.

[20]  Jan Hoffmann,et al.  Arrays and References in Resource Aware ML , 2017, FSCD.

[21]  Daniel R. Licata,et al.  Denotational cost semantics for functional languages with inductive types , 2015, ICFP.

[22]  Zoubin Ghahramani,et al.  Probabilistic machine learning and artificial intelligence , 2015, Nature.

[23]  Matthew B. Dwyer,et al.  Probabilistic symbolic execution , 2012, ISSTA 2012.

[24]  Steffen Jost,et al.  Type-Based Allocation Analysis for Co-recursion in Lazy Functional Languages , 2015, ESOP.

[25]  Bernd Grobauer,et al.  Cost recurrences for DML programs , 2001, ICFP '01.

[26]  Helmut Veith,et al.  A simple and scalable static analysis for bound analysis and amortized complexity analysis , 2014, Software Engineering.

[27]  Andreas Haeberlen,et al.  Differential Privacy Under Fire , 2011, USENIX Security Symposium.

[28]  Joost-Pieter Katoen,et al.  How long, O Bayesian network, will I sample thee? A program analysis perspective on expected sampling times , 2018, ESOP.

[29]  Dexter Kozen,et al.  Semantics of probabilistic programs , 1979, 20th Annual Symposium on Foundations of Computer Science (sfcs 1979).

[30]  Annabelle McIver,et al.  Abstraction, Refinement And Proof For Probabilistic Systems (Monographs in Computer Science) , 2004 .

[31]  Anna Philippou,et al.  Tools and Algorithms for the Construction and Analysis of Systems , 2018, Lecture Notes in Computer Science.

[32]  Albert R. Meyer,et al.  Mathematics for Computer Science , 2017 .

[33]  Karl Crary,et al.  Resource bound certification , 2000, POPL '00.

[34]  Jürgen Giesl,et al.  Lower Runtime Bounds for Integer Programs , 2016, IJCAR.

[35]  Thomas A. Henzinger,et al.  Probabilistic programming , 2014, FOSE.

[36]  Krishnendu Chatterjee,et al.  Non-polynomial Worst-Case Analysis of Recursive Programs , 2019, ACM Trans. Program. Lang. Syst..

[37]  Martin Hofmann,et al.  Automatic Type Inference for Amortised Heap-Space Analysis , 2013, ESOP.

[38]  Martin Hofmann,et al.  Amortised Resource Analysis and Typed Polynomial Interpretations , 2014, RTA-TLCA.

[39]  Tomás Brázdil,et al.  Runtime Analysis of Probabilistic Programs with Unbounded Recursion , 2010, ICALP.

[40]  Martin Hofmann,et al.  Multivariate amortized resource analysis , 2012, TOPL.

[41]  Joost-Pieter Katoen,et al.  Reasoning about Recursive Probabilistic Programs* , 2016, 2016 31st Annual ACM/IEEE Symposium on Logic in Computer Science (LICS).

[42]  Robert Atkey,et al.  Amortised Resource Analysis with Separation Logic , 2010, ESOP.

[43]  Martin Hofmann,et al.  Type-Based Amortised Heap-Space Analysis , 2006, ESOP.

[44]  Benjamin Grégoire,et al.  Formal certification of code-based cryptographic proofs , 2009, POPL '09.

[45]  Sriram Sankaranarayanan,et al.  Probabilistic Program Analysis with Martingales , 2013, CAV.

[46]  Reiner Hähnle,et al.  Resource Analysis of Complex Programs with Cost Equations , 2014, APLAS.

[47]  Thomas A. Henzinger,et al.  ABC: Algebraic Bound Computation for Loops , 2010, LPAR.

[48]  Gilles Barthe,et al.  Programming language techniques for differential privacy , 2016, SIGL.

[49]  David Monniaux,et al.  Backwards Abstract Interpretation of Probabilistic Programs , 2001, ESOP.

[50]  David Monniaux Abstract interpretation of programs as Markov decision processes , 2005, Sci. Comput. Program..

[51]  G. Grimmett,et al.  Probability and random processes , 2002 .

[52]  Sumit Gulwani,et al.  Bound Analysis of Imperative Programs with the Size-Change Abstraction , 2011, SAS.

[53]  Matt Fredrikson,et al.  J an 2 01 8 Verifying and Synthesizing Constant-Resource Implementations with Types , 2018 .

[54]  Annabelle McIver,et al.  Linear-Invariant Generation for Probabilistic Programs: - Automated Support for Proof-Based Methods , 2010, SAS.

[55]  Jürgen Giesl,et al.  Alternating Runtime and Size Complexity Analysis of Integer Programs , 2014, TACAS.

[56]  Axel Legay,et al.  Statistical Model Checking for SystemC Models , 2016, 2016 IEEE 17th International Symposium on High Assurance Systems Engineering (HASE).

[57]  Martin Hofmann,et al.  Static determination of quantitative resource usage for higher-order programs , 2010, POPL '10.

[58]  Sumit Gulwani,et al.  Static analysis for probabilistic programs: inferring whole program properties from finitely many paths , 2013, PLDI.

[59]  Christel Baier,et al.  Principles of model checking , 2008 .

[60]  Wolfgang Wechler,et al.  Universal Algebra for Computer Scientists , 1992, EATCS Monographs on Theoretical Computer Science.

[61]  Ugo Dal Lago,et al.  Analysing the complexity of functional programs: higher-order meets first-order , 2015, ICFP.

[62]  Viktor Kuncak,et al.  Contract-based resource verification for higher-order functions with memoization , 2017, POPL.

[63]  Martin Hofmann,et al.  Multivariate Amortised Resource Analysis for Term Rewrite Systems , 2015, TLCA.

[64]  Annabelle McIver,et al.  Compositional Specification and Analysis of Cost-Based Properties in Probabilistic Programs , 2005, FM.

[65]  Zhong Shao,et al.  End-to-end verification of stack-space bounds for C programs , 2014, PLDI.

[66]  Martin Hofmann,et al.  Amortized Resource Analysis with Polynomial Potential , 2010, ESOP.

[67]  Steffen Jost,et al.  Automatic amortised analysis of dynamic memory allocation for lazy functional programs , 2012, ICFP.

[68]  Ugo Dal Lago,et al.  Linear Dependent Types and Relative Completeness , 2011, LICS.

[69]  Jacques Cohen,et al.  Automating program analysis , 1988, JACM.

[70]  Joost-Pieter Katoen,et al.  Weakest Precondition Reasoning for Expected Run-Times of Probabilistic Programs , 2016, ESOP.

[71]  Sriram Sankaranarayanan,et al.  Expectation Invariants for Probabilistic Program Loops as Fixed Points , 2014, SAS.

[72]  Ralph Benzinger,et al.  Automated higher-order complexity analysis , 2004, Theor. Comput. Sci..

[73]  Jürgen Giesl,et al.  Analyzing Innermost Runtime Complexity of Term Rewriting by Dependency Pairs , 2013, Journal of Automated Reasoning.

[74]  Krishnendu Chatterjee,et al.  Automated Recurrence Analysis for Almost-Linear Expected-Runtime Bounds , 2017, CAV.

[75]  Axel Legay,et al.  PSCV: A Runtime Verification Tool for Probabilistic SystemC Models , 2016, CAV.

[76]  Ankush Das,et al.  Towards automatic resource bound analysis for OCaml , 2016, POPL.

[77]  Bertrand Jeannet,et al.  Apron: A Library of Numerical Abstract Domains for Static Analysis , 2009, CAV.

[78]  Holger Hermanns,et al.  Probabilistic Termination , 2015, POPL.

[79]  Elvira Albert,et al.  Non-cumulative Resource Analysis , 2015, TACAS.

[80]  Zachary Kincaid,et al.  Compositional recurrence analysis revisited , 2017, PLDI.

[81]  Alessandro Panconesi,et al.  Concentration of Measure for the Analysis of Randomized Algorithms , 2009 .

[82]  Arthur Charguéraud,et al.  Machine-Checked Verification of the Correctness and Amortized Complexity of an Efficient Union-Find Implementation , 2015, ITP.

[83]  Zhong Shao,et al.  Type-Based Amortized Resource Analysis with Integers and Arrays , 2014, FLOPS.

[84]  Joost-Pieter Katoen,et al.  The Probabilistic Model Checking Landscape* , 2016, 2016 31st Annual ACM/IEEE Symposium on Logic in Computer Science (LICS).

[85]  Gilles Barthe,et al.  Proving Differential Privacy in Hoare Logic , 2014, 2014 IEEE 27th Computer Security Foundations Symposium.

[86]  R. Ash,et al.  Probability and measure theory , 1999 .

[87]  Bounded expectations: resource analysis for probabilistic programs , 2018, PLDI.

[88]  Patrick Cousot,et al.  Probabilistic Abstract Interpretation , 2012, ESOP.

[89]  Avi Pfeffer,et al.  Practical Probabilistic Programming , 2016, ILP.

[90]  Javier Esparza,et al.  Quantitative analysis of probabilistic pushdown automata: expectations and variances , 2005, 20th Annual IEEE Symposium on Logic in Computer Science (LICS' 05).

[91]  Georg Moser,et al.  A combination framework for complexity , 2013, Inf. Comput..

[92]  Annabelle McIver,et al.  Operational versus weakest pre-expectation semantics for the probabilistic guarded command language , 2014, Perform. Evaluation.

[93]  Martin Hofmann,et al.  Static prediction of heap space usage for first-order functional programs , 2003, POPL '03.

[94]  Hanne Riis Nielson,et al.  A Hoare-Like Proof System for Analysing the Computation Time of Programs , 1987, Sci. Comput. Program..