Multivariate amortized resource analysis

We study the problem of automatically analyzing the worst-case resource usage of procedures with several arguments. Existing automatic analyses based on amortization or sized types bound the resource usage or result size of such a procedure by a sum of unary functions of the sizes of the arguments. In this article we generalize this to arbitrary multivariate polynomial functions thus allowing bounds of the form mn which had to be grossly overestimated by m2 + n2 before. Our framework even encompasses bounds like ∑i,j≤ n mi mj where the mi are the sizes of the entries of a list of length n. This allows us for the first time to derive useful resource bounds for operations on matrices that are represented as lists of lists and to considerably improve bounds on other superlinear operations on lists such as longest common subsequence and removal of duplicates from lists of lists. Furthermore, resource bounds are now closed under composition which improves accuracy of the analysis of composed programs when some or all of the components exhibit superlinear resource or size behavior. The analysis is based on a novel multivariate amortized resource analysis. We present it in form of a type system for a simple first-order functional language with lists and trees, prove soundness, and describe automatic type inference based on linear programming. We have experimentally validated the automatic analysis on a wide range of examples from functional programming with lists and trees. The obtained bounds were compared with actual resource consumption. All bounds were asymptotically tight, and the constants were close or even identical to the optimal ones.

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

[2]  Sumit Gulwani,et al.  Control-flow refinement and progress invariants for bound analysis , 2009, PLDI '09.

[3]  Sumit Gulwani,et al.  The reachability-bound problem , 2010, PLDI '10.

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

[5]  Jan Hoffmann,et al.  Types with potential: polynomial resource bounds via automatic amortized analysis , 2011 .

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

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

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

[9]  Patrick Cousot,et al.  Inductive definitions, semantics and abstract interpretations , 1992, POPL '92.

[10]  Björn Lisper,et al.  Fully Automatic, Parametric Worst-Case Execution Time Analysis , 2003, WCET.

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

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

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

[14]  Björn Lisper,et al.  An Efficient Algorithm for Parametric WCET Calculation , 2009, 2009 15th IEEE International Conference on Embedded and Real-Time Computing Systems and Applications.

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

[16]  Daniel Le Métayer,et al.  ACE: an automatic complexity evaluator , 1988, TOPL.

[17]  Philippe Clauss,et al.  Symbolic Polynomial Maximization Over Convex Sets and Its Application to Memory Requirement Estimation , 2009, IEEE Transactions on Very Large Scale Integration (VLSI) Systems.

[18]  Saumya K. Debray,et al.  Cost analysis of logic programs , 1993, TOPL.

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

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

[21]  R. Stanley Enumerative Combinatorics: Volume 1 , 2011 .

[22]  Greg J. Michaelson,et al.  Hume: A Domain-Specific Language for Real-Time Embedded Systems , 2003, GPCE.

[23]  Elvira Albert,et al.  Closed-Form Upper Bounds in Static Cost Analysis , 2011, Journal of Automated Reasoning.

[24]  Xavier Leroy,et al.  Coinductive big-step operational semantics , 2006, Inf. Comput..

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

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

[27]  Benjamin C. Pierce,et al.  Advanced Topics In Types And Programming Languages , 2004 .

[28]  R. Tarjan Amortized Computational Complexity , 1985 .

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

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

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

[32]  Martin Hofmann,et al.  Automatic Certification of Heap Consumption , 2004, LPAR.

[33]  Viktor Vafeiadis,et al.  Finding heap-bounds for hardware synthesis , 2009, 2009 Formal Methods in Computer-Aided Design.

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

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

[36]  Elvira Albert,et al.  Asymptotic Resource Usage Bounds , 2009, APLAS.

[37]  Mads Rosendahl,et al.  Automatic complexity analysis , 1989, FPCA.

[38]  Sergio Yovine,et al.  Parametric prediction of heap memory requirements , 2008, ISMM '08.

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

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

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

[42]  Ernst Althaus,et al.  Precise and efficient parametric path analysis , 2011, LCTES '11.

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

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

[45]  Lyle Harold Ramshaw,et al.  Formalizing the analysis of algorithms , 1979 .

[46]  Ralph Benzinger,et al.  Automated complexity analysis of Nuprl extracted programs , 2001, Journal of Functional Programming.

[47]  Brian Campbell,et al.  Amortised Memory Analysis Using the Depth of Data Structures , 2009, ESOP.

[48]  Shengchao Qin,et al.  Analysing memory resource bounds for low-level programs , 2008, ISMM '08.

[49]  Elvira Albert,et al.  More Precise Yet Widely Applicable Cost Analysis , 2011, VMCAI.

[50]  M. Hofmann A Type System for Bounded Space and Functional In-Place Update , 2000, Nord. J. Comput..

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

[52]  Sebastian Altmeyer,et al.  Parametric Timing Analysis for Complex Architectures , 2008, 2008 14th IEEE International Conference on Embedded and Real-Time Computing Systems and Applications.

[53]  Walid Taha,et al.  Generating Heap-Bounded Programs in a Functional Setting , 2003, EMSOFT.

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

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

[56]  Charalambos A. Charalambides,et al.  Enumerative combinatorics , 2018, SIGA.

[57]  Ben Wegbreit,et al.  Mechanical program analysis , 1975, CACM.

[58]  Elvira Albert,et al.  Parametric inference of memory requirements for garbage collected languages , 2010, ISMM '10.