## Amortized Resource Analysis with Polymorphic Recursion and Partial Big-Step Operational Semantics -- Extended Version

### Cached

### Download Links

Citations: | 4 - 3 self |

### BibTeX

@MISC{Hoffmann_amortizedresource,

author = {Jan Hoffmann and Martin Hofmann},

title = {Amortized Resource Analysis with Polymorphic Recursion and Partial Big-Step Operational Semantics -- Extended Version},

year = {}

}

### OpenURL

### Abstract

This paper studies the problem of statically determining upper bounds on the resource consumption of first-order functional programs. A previous work approached the problem with an automatic typebased amortized analysis for polynomial resource bounds. The analysis is parametric in the resource and can be instantiated to heap space, stack space, or clock cycles. Experiments with a prototype implementation have shown that programs are analyzed efficiently and that the computed bounds exactly match the measured worst-case resource behavior for many functions. This paper describes the inference algorithm that is used in the implementation of the system. It can deal with resourcepolymorphic recursion which is required in the type derivation of many functions. The computation of the bounds is fully automatic if a maximal degree of the polynomials is given. The soundness of the inference is proved with respect to a novel operational semantics for partial evaluations to show that the inferred bounds hold for terminating as well as non-terminating computations. A corollary is that run-time bounds also establish the termination of programs.

### Citations

147 | Static prediction of heap space usage for first-order functional programs
- HOFMANN, JOST
(Show Context)
Citation Context ...in which each type is annotated with resource variables and the corresponding linear constraints are collected as each type rule is applied. The main innovation in comparison to the classic algorithm =-=[16]-=- is the resource-polymorphic recursion enabled by the rule T:FUNAPP. The number of computed constraints grows linearly in the maximal degree k that has to be provided by the user. There is a tradeoff ... |

144 |
Amortized computational complexity
- Tarjan
- 1985
(Show Context)
Citation Context ...r approach to the problem follows a line of research that was initiated by Hofmann and Jost [1]. It is based on the potential method of amortized analysis that has been invented by Sleator and Tarjan =-=[2]-=- to simplify the manual reasoning about the costs of a sequence of operations that manipulate a data structure. [1] showed that a fully automatic amortized resource analysis can efficiently compute bo... |

133 | Proving the Correctness of Reactive Systems Using Sized Types
- Hughes, Pareto, et al.
- 1996
(Show Context)
Citation Context ...t available. Moreover, type derivations can be seen as certificates and can be automatically translated into formalized proofs in program logic [4]. Another related approach is the use of sized types =-=[20, 19, 6, 7]-=- which provide a general framework to represent the size of the data in its type. Sized types are a very important concept and we Grobauer [11] and Flajolet [10]. In those systems, an a priori unknown... |

121 | Resource Bound Certification
- Crary, Weirich
- 2000
(Show Context)
Citation Context ...the code; by a straightforward intraprocedural analysis a set of recurrence equations or inequations for these functions is then derived. A type-based extraction of such recurrences has been given in =-=[9]-=-. Even for relatively simple programs the resulting recurrences are quite complicated and difficult to solve with standard methods. In the COSTA project [2, 1] progress has been made with the solution... |

96 |
Inductive definitions, semantics and abstract interpretation
- Cousot, Cousot
- 1992
(Show Context)
Citation Context ...tize the resource behavior of compiled code on specific machines. Secondly, it allows for shorter and less syntactic proofs. An alternative approach is to use coinductively defined big-step semantics =-=[10, 11]-=-.Amortized Resource Analysis with Polymorphic Recursion 9 V, H ⊢ e � | 0 P:ZERO b ∈ {True, False} V, H ⊢ b � | K bool P:CONSTB unit P:CONSTU V, H ⊢ () � | K n ∈ Z V, H ⊢ n � | K V(x) = v int P:CONSTI... |

83 | Recursion and Dynamic DataStructures in Bounded Space; Towards Embedded ML Programming
- Hughes, Pareto
- 1999
(Show Context)
Citation Context ...t available. Moreover, type derivations can be seen as certificates and can be automatically translated into formalized proofs in program logic [4]. Another related approach is the use of sized types =-=[20, 19, 6, 7]-=- which provide a general framework to represent the size of the data in its type. Sized types are a very important concept and we Grobauer [11] and Flajolet [10]. In those systems, an a priori unknown... |

68 | Cost Analysis of Java Bytecode
- Albert, Arenas, et al.
- 2007
(Show Context)
Citation Context ...ction of such recurrences has been given in [9]. Even for relatively simple programs the resulting recurrences are quite complicated and difficult to solve with standard methods. In the COSTA project =-=[2, 1]-=- progress has been made with the solution of those recurrences. Still, we find that amortization yields better results in cases where resource usage of intermediate functions depends on factors other ... |

62 | Calculating Sized Types
- Chin, Khoo
(Show Context)
Citation Context ...t available. Moreover, type derivations can be seen as certificates and can be automatically translated into formalized proofs in program logic [4]. Another related approach is the use of sized types =-=[20, 19, 6, 7]-=- which provide a general framework to represent the size of the data in its type. Sized types are a very important concept and we Grobauer [11] and Flajolet [10]. In those systems, an a priori unknown... |

60 | Automatic average-case analysis of algorithms
- Flajolet, Salvy, et al.
- 1991
(Show Context)
Citation Context ...ch is the use of sized types [20, 19, 6, 7] which provide a general framework to represent the size of the data in its type. Sized types are a very important concept and we Grobauer [11] and Flajolet =-=[10]-=-. In those systems, an a priori unknown resource bounding function is introduced for each function in the code; by a straightforward intraprocedural analysis a set of recurrence equations or inequatio... |

47 | Speed: precise and efficient static estimation of program computational complexity
- Gulwani, Mehra, et al.
- 2009
(Show Context)
Citation Context ...omial bounds that we have introduced in a companion paper [15]. Other resource analyses that can in principle obtain polynomial bounds are approaches based on recurrences pioneered by i. In contrast, =-=[14]-=- indicates that a nested loop on 1 ≤ i ≤ n and 1 ≤ j ≤ i is over-approximated with the bound n 2 . The examples from loc. cit. suggest that the two approaches are complementary in the sense that the m... |

39 | Automatic Inference of Upper Bounds for Recurrence Relations in Cost Analysis
- Albert, Arenas, et al.
- 2008
(Show Context)
Citation Context ...ction of such recurrences has been given in [9]. Even for relatively simple programs the resulting recurrences are quite complicated and difficult to solve with standard methods. In the COSTA project =-=[2, 1]-=- progress has been made with the solution of those recurrences. Still, we find that amortization yields better results in cases where resource usage of intermediate functions depends on factors other ... |

36 | Coinductive Big-step Operational Semantics
- Leroy, Grall
(Show Context)
Citation Context ...in big-step style, the small-step semantics does not directly match the implementation and it may thus be difficult to establish bounds on the resource consumption of a step. Another classic approach =-=[8, 24]-=- is to add divergence rules to the operational semantics that are interpreted coinductively. But then one loses the ability to prove statements by induction on the evaluation which is crucial for the ... |

29 | Control-flow refinement and progress invariants for bound analysis
- Gulwani, Jain, et al.
- 2009
(Show Context)
Citation Context ...ompositions of functions seem to be better dealt with by amortization. A successful method to estimate time bounds for C++ procedures with loops and recursion was recently developed by Gulwani et al. =-=[14, 12, 13]-=- in the SPEED project. They annotate programs with counters and use automatic invariant discovery between their values using off-the-shelf program analysis tools which are based on abstract interpreta... |

27 | Automatic certification of heap consumption
- Beringer, Hofmann, et al.
- 2005
(Show Context)
Citation Context ...ood for analyzing recursive programs involving inductive data types. Moreover, type derivations can be seen as certificates and can be automatically translated into formalized proofs in program logic =-=[21]-=-. Another related approach is the use of sized types [22–24] which provide a general framework to represent the size of the data in its type. Sized types are a very important concept and we also emplo... |

26 | Type-based amortised heap-space analysis
- Hofmann, Jost
- 2006
(Show Context)
Citation Context ...nsiderably extended the range of type-based amortized analysis, but the restriction to linaer bounds remained. Examples are the extensions of type-based amortized analysis to object-oriented programs =-=[17, 18]-=-, to generic resource metrics [22, 5], to polymorphic and higher-order programs [21], and to Java-like bytecode by means of separation logic [3]. Somewhat unexpectedly, we recently discovered a techni... |

24 | The reachability-bound problem
- Gulwani, Zuleger
- 2009
(Show Context)
Citation Context ... on abstract interpretation. A recent innovation for non-recursive programs is the combination of disjunctive invariant generation via abstract interpretation with proof rules that employ SMT-solvers =-=[20]-=-. In contrast to our method, these techniques can not fully automatically analyze iterations over data structures. Instead, the user needs to define numerical “quantitative functions”. A methodologica... |

21 |
The Art of Computer Programming, Volume 1 (3rd ed.): Fundamental Algorithms, volume 1
- Knuth
- 1997
(Show Context)
Citation Context ...nstraints. 7. Case Study: Sorting Algorithms in RAML A classic application of quantitative resource analysis is the runtime analysis of sorting algorithms. In the book The Art of Computer Programming =-=[23]-=-, Knuth manually determines worst-case bounds for many well-known sorting algorithms that are implemented in an assembly language for the MIX architecture. Among the analyzed algorithms are quick sort... |

21 | Eekelen. Polynomial Size Analysis for First-Order Functions
- Shkaravska, Kesteren, et al.
- 2007
(Show Context)
Citation Context ...rtain amount of data dependency and dispenses with the explicit manipulation of symbolic expressions in favour of numerical potential annotations. Polynomial resource bounds have also been studied in =-=[25]-=- that addresses the derivation of polynomial size bounds for functions whose exact growth rate is polynomial. Besides this strong restriction, the efficiency of inference remains unclear. 9. Conclusio... |

20 |
Automated Higher-Order Complexity Analysis
- Benzinger
(Show Context)
Citation Context ... progress has been made with the solution of those recurrences. In an automatic complexity analysis for higher-order Nuprl terms Benzinger uses Mathematica to solve the generated recurrence equations =-=[17]-=-. Still, we find that amortization yields better results in cases where resource usage of intermediate functions depends on factors other than input size, e.g., sizes of partitions in quick sort. Also... |

18 | Cost recurrences for DML programs
- Grobauer
- 2001
(Show Context)
Citation Context ...her related approach is the use of sized types [20, 19, 6, 7] which provide a general framework to represent the size of the data in its type. Sized types are a very important concept and we Grobauer =-=[11]-=- and Flajolet [10]. In those systems, an a priori unknown resource bounding function is introduced for each function in the code; by a straightforward intraprocedural analysis a set of recurrence equa... |

15 |
Endre Tarjan. Amortized computational complexity
- Robert
- 1985
(Show Context)
Citation Context ... approach to the problem follows a line of research that was initiated by Hofmann and Jost [16]. It is based on the potential method of amortized analysis that has been invented by Sleator and Tarjan =-=[26]-=- to simplify the manual reasoning about the costs of a sequence of operations that manipulate a data structure. Hofmann and Jost [16] showed that a fully automatic amortized resource analysis can effi... |

15 | A numerical abstract domain based on expression abstraction and max operator with application in timing analysis
- Gulavani, Gulwani
- 2008
(Show Context)
Citation Context ...ompositions of functions seem to be better dealt with by amortization. A successful method to estimate time bounds for C++ procedures with loops and recursion was recently developed by Gulwani et al. =-=[18, 19]-=- in the SPEED project. They annotate programs with counters and use automatic invariant discovery between their values using off-the-shelf program analysis tools which are based on abstract interpreta... |

13 | Amortized resource analysis with polynomial potential
- Hoffmann, Hofmann
- 2010
(Show Context)
Citation Context ... generic resource metrics [22, 5], to polymorphic and higher-order programs [21], and to Java-like bytecode by means of separation logic [3]. Somewhat unexpectedly, we recently discovered a technique =-=[15]-=- that yields an automatic amortized analysis for polynomial bounds while still relying on linear constraint solving only. The resulting system efficiently computes resource bounds for first-order func... |

11 |
Cousot and Radhia Cousot. Inductive definitions, semantics and abstract interpretation
- Patrick
- 1992
(Show Context)
Citation Context ...in big-step style, the small-step semantics does not directly match the implementation and it may thus be difficult to establish bounds on the resource consumption of a step. Another classic approach =-=[8, 24]-=- is to add divergence rules to the operational semantics that are interpreted coinductively. But then one loses the ability to prove statements by induction on the evaluation which is crucial for the ... |

11 | Static determination of quantitative resource usage for higher-order programs
- Jost, Hammond, et al.
- 2010
(Show Context)
Citation Context ...inaer bounds remained. Examples are the extensions of type-based amortized analysis to object-oriented programs [17, 18], to generic resource metrics [22, 5], to polymorphic and higher-order programs =-=[21]-=-, and to Java-like bytecode by means of separation logic [3]. Somewhat unexpectedly, we recently discovered a technique [15] that yields an automatic amortized analysis for polynomial bounds while sti... |

10 | Amortised resource analysis with separation logic
- Atkey
- 2010
(Show Context)
Citation Context ...sed amortized analysis to object-oriented programs [17, 18], to generic resource metrics [22, 5], to polymorphic and higher-order programs [21], and to Java-like bytecode by means of separation logic =-=[3]-=-. Somewhat unexpectedly, we recently discovered a technique [15] that yields an automatic amortized analysis for polynomial bounds while still relying on linear constraint solving only. The resulting ... |

10 | Amortised memory analysis using the depth of data structures
- Campbell
- 2009
(Show Context)
Citation Context ...based amortized analysis, but the restriction to linaer bounds remained. Examples are the extensions of type-based amortized analysis to object-oriented programs [17, 18], to generic resource metrics =-=[22, 5]-=-, to polymorphic and higher-order programs [21], and to Java-like bytecode by means of separation logic [3]. Somewhat unexpectedly, we recently discovered a technique [15] that yields an automatic amo... |

9 | Carbon Credits” for Resource-Bounded Computations using Amortised Analysis
- Jost, Loidl, et al.
- 2009
(Show Context)
Citation Context ...he RAML analysis is proved to be sound and available at the touch of a button every time the program changed. 8. Related Work Most closely related is the previous work on automatic amortized analysis =-=[15, 16, 17, 22, 21]-=- (see §1). This paper is the first that investigates polymorphic recursion and the relations of the inferred bounds to non-terminating computations. A major conceptual innovation is the extension of t... |

7 |
Olha Shkaravska. Automatic certification of heap consumption
- Beringer, Hofmann, et al.
- 2005
(Show Context)
Citation Context ...oth integration of components whose implementation is not available. Moreover, type derivations can be seen as certificates and can be automatically translated into formalized proofs in program logic =-=[4]-=-. Another related approach is the use of sized types [20, 19, 6, 7] which provide a general framework to represent the size of the data in its type. Sized types are a very important concept and we Gro... |

6 | Efficient type-checking for amortised heapspace analysis
- Hofmann, Rodriguez
(Show Context)
Citation Context ...nsiderably extended the range of type-based amortized analysis, but the restriction to linaer bounds remained. Examples are the extensions of type-based amortized analysis to object-oriented programs =-=[17, 18]-=-, to generic resource metrics [22, 5], to polymorphic and higher-order programs [21], and to Java-like bytecode by means of separation logic [3]. Somewhat unexpectedly, we recently discovered a techni... |

3 |
Corneliu Popeea, and Huu Hai Nguyen. Verifying Safety Policies with Size Properties and Alias Controls
- Chin, Khoo, et al.
- 2005
(Show Context)
Citation Context |

3 |
Gulavani and Sumit Gulwani. A Numerical Abstract Domain Based on Expression Abstraction and Max Operator with Application in Timing Analysis
- Bhargav
- 2008
(Show Context)
Citation Context ...ompositions of functions seem to be better dealt with by amortization. A successful method to estimate time bounds for C++ procedures with loops and recursion was recently developed by Gulwani et al. =-=[14, 12, 13]-=- in the SPEED project. They annotate programs with counters and use automatic invariant discovery between their values using off-the-shelf program analysis tools which are based on abstract interpreta... |

2 |
Eekelen, M.C.: Polynomial Size Analysis of FirstOrder Functions. In: Typed Lambda Calc. Apps
- Shkaravska, Kesteren, et al.
- 2007
(Show Context)
Citation Context ...rtain amount of data dependency and dispenses with the explicit manipulation of symbolic expressions in favour of numerical potential annotations. Polynomial resource bounds have also been studied in =-=[25]-=- that addresses the derivation of polynomial size bounds for functions whose exact growth rate is polynomial. usage of the form ∑ 1≤i≤n 8 Conclusion and Future Research We have continued our work on a... |

1 | D.: Efficient Type-Checking for Amortised Heap-Space Analysis - Systems |

1 | 354–369 6. Campbell, B.: Amortised Memory Analysis using the Depth of Data Structures - Meth - 2009 |

1 | M.: Static Determination of Quantitative Resource Usage for Higher-Order Programs - Prog - 2009 |

1 | M.: Amortized Resource Analysis with Polynomial Potential - Prog - 2010 |

1 | Resource Bound Certification. In: 27th ACM Symp. on Principles of Prog. Langs. (POPL’00). (2000) 184–198 - Sci - 1991 |

1 | 190–204 Resource Analysis with Polymorphic Recursion (Extended) 25 - Prog - 2009 |