Non-polynomial Worst-Case Analysis of Recursive Programs

We study the problem of developing efficient approaches for proving worst-case bounds of non-deterministic recursive programs. Ranking functions are sound and complete for proving termination and worst-case bounds of non-recursive programs. First, we apply ranking functions to recursion, resulting in measure functions, and show that they provide a sound and complete approach to prove worst-case bounds of non-deterministic recursive programs. Our second contribution is the synthesis of measure functions in non-polynomial forms. We show that non-polynomial measure functions with logarithm and exponentiation can be synthesized through abstraction of logarithmic or exponentiation terms, Farkas’ Lemma, and Handelman’s Theorem using linear programming. While previous methods obtain worst-case polynomial bounds, our approach can synthesize bounds of the form \(\mathcal {O}(n \log n)\) as well as \(\mathcal {O}(n^r)\) where r is not an integer. We present experimental results to demonstrate that our approach can efficiently obtain worst-case bounds of classical recursive algorithms such as Merge-Sort, Closest-Pair, Karatsuba’s algorithm and Strassen’s algorithm.

[1]  Swarat Chaudhuri,et al.  Temporal Reasoning for Procedural Programs , 2010, VMCAI.

[2]  Robert W. Floyd,et al.  Assigning Meanings to Programs , 1993 .

[3]  Alexander Schrijver,et al.  Combinatorial optimization. Polyhedra and efficiency. , 2003 .

[4]  Andreas Podelski,et al.  Termination proofs for systems code , 2006, PLDI '06.

[5]  Jakob Engblom,et al.  The worst-case execution-time problem—overview of methods and survey of tools , 2008, TECS.

[6]  Naoki Kobayashi,et al.  Automatic Termination Verification for Higher-Order Functional Programs , 2014, ESOP.

[7]  Marsha Chechik,et al.  Tools and Algorithms for the Construction and Analysis of Systems , 2016, Lecture Notes in Computer Science.

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

[9]  Elvira Albert,et al.  Automatic Inference of Upper Bounds for Recurrence Relations in Cost Analysis , 2008, SAS.

[10]  Krishnendu Chatterjee,et al.  Algorithmic analysis of qualitative and quantitative termination problems for affine probabilistic programs , 2015, POPL.

[11]  Patrick Cousot,et al.  Proving Program Invariance and Termination by Parametric Abstraction, Lagrangian Relaxation and Semidefinite Programming , 2005, VMCAI.

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

[13]  Martin Hofmann,et al.  Efficient Type-Checking for Amortised Heap-Space Analysis , 2009, CSL.

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

[15]  Neil D. Jones,et al.  The size-change principle for program termination , 2001, POPL '01.

[16]  Roberto Bagnara,et al.  Precise widening operators for convex polyhedra , 2003, Sci. Comput. Program..

[17]  Olivier Bournez,et al.  Proving Positive Almost-Sure Termination , 2005, RTA.

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

[19]  Claire Jones,et al.  Probabilistic non-determinism , 1990 .

[20]  Wei-Ngan Chin,et al.  Calculating Sized Types , 1999, PEPM '00.

[21]  Henny B. Sipma,et al.  Synthesis of Linear Ranking Functions , 2001, TACAS.

[22]  Chin Soon Lee Ranking functions for size-change termination , 2009, TOPL.

[23]  William R. Harris,et al.  Complexity verification using guided theorem enumeration , 2017, POPL.

[24]  Alexander Schrijver,et al.  Theory of linear and integer programming , 1986, Wiley-Interscience series in discrete mathematics and optimization.

[25]  Kurt Gödel,et al.  On undecidable propositions of formal mathematical systems , 1934 .

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

[27]  Martin Hofmann,et al.  Multivariate amortized resource analysis , 2011, POPL '11.

[28]  Patrick Cousot,et al.  An abstract interpretation framework for termination , 2012, POPL '12.

[29]  H. P. Williams THEORY OF LINEAR AND INTEGER PROGRAMMING (Wiley-Interscience Series in Discrete Mathematics and Optimization) , 1989 .

[30]  Elvira Albert,et al.  Termination and Cost Analysis with COSTA and its User Interfaces , 2009, Electron. Notes Theor. Comput. Sci..

[31]  D. Handelman Representing polynomials by positive linear functions on compact convex polyhedra. , 1988 .

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

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

[34]  Amr Sabry,et al.  Proving the correctness of reactive systems using sized types , 1996, POPL '96.

[35]  Marko C. J. D. van Eekelen,et al.  Polynomial Size Analysis of First-Order Functions , 2007, TLCA.

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

[37]  Torben Amtoft,et al.  Faithful Translations between Polyvariant Flows and Polymorphic Types , 2000, ESOP.

[38]  Zhenbing Zeng,et al.  Generating exact nonlinear ranking functions by symbolic-numeric hybrid method , 2013, J. Syst. Sci. Complex..

[39]  Henny B. Sipma,et al.  Constraint-Based Linear-Relations Analysis , 2004, SAS.

[40]  Florian Zuleger,et al.  Ramsey vs. Lexicographic Termination Proving , 2013, TACAS.

[41]  Krishnendu Chatterjee,et al.  Termination of Nondeterministic Probabilistic Programs , 2019, VMCAI.

[42]  Wim H. Hesselink Proof rules for recursive procedures , 2005, Formal Aspects of Computing.

[43]  Sumit Gulwani,et al.  SPEED: Symbolic Complexity Bound Analysis , 2009, CAV.

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

[45]  Henny B. Sipma,et al.  Linear Invariant Generation Using Non-linear Constraint Solving , 2003, CAV.

[46]  Andreas Podelski,et al.  Summarization for termination: no return! , 2009, Formal Methods Syst. Des..

[47]  Martin Hofmann,et al.  Resource Aware ML , 2012, CAV.

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

[49]  Andreas Podelski,et al.  A Complete Method for the Synthesis of Linear Ranking Functions , 2004, VMCAI.

[50]  Henny B. Sipma,et al.  Linear Ranking with Reachability , 2005, CAV.

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

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

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

[54]  Krishnendu Chatterjee,et al.  Stochastic invariants for probabilistic termination , 2016, POPL.

[55]  Allen Van Gelder,et al.  Termination detection in logic programs using argument sizes (extended abstract) , 1991, PODS.

[56]  Bevan K. Youse,et al.  Introduction to real analysis , 1972 .

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

[58]  Paul Feautrier,et al.  Multi-dimensional Rankings, Program Termination, and Complexity Bounds of Flowchart Programs , 2010, SAS.

[59]  Caterina Urban,et al.  The Abstract Domain of Segmented Ranking Functions , 2013, SAS.

[60]  Elvira Albert,et al.  Cost Analysis of Java Bytecode , 2007, ESOP.

[61]  Sumit Gulwani,et al.  A Numerical Abstract Domain Based on Expression Abstraction and Max Operator with Application in Timing Analysis , 2008, CAV.

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

[63]  Chaochen Zhou,et al.  Recent advances in program verification through computer algebra , 2009, Frontiers of Computer Science in China.

[64]  Jürgen Giesl,et al.  Analyzing Runtime and Size Complexity of Integer Programs , 2016, ACM Trans. Program. Lang. Syst..

[65]  Roberto Giacobazzi,et al.  Verification, Model Checking, and Abstract Interpretation , 2013, Lecture Notes in Computer Science.

[66]  John Hughes,et al.  Recursion and dynamic data-structures in bounded space: towards embedded ML programming , 1999, ICFP '99.

[67]  Patrick Cousot,et al.  Abstract interpretation: a unified lattice model for static analysis of programs by construction or approximation of fixpoints , 1977, POPL.

[68]  Georg Moser,et al.  The complexity of interaction , 2016, POPL.

[69]  Krishnendu Chatterjee,et al.  Termination of Nondeterministic Recursive Probabilistic Programs , 2017, ArXiv.