Automatic amortised analysis of dynamic memory allocation for lazy functional programs

  • Authors:
  • Hugo Simões;Pedro Vasconcelos;Mário Florido;Steffen Jost;Kevin Hammond

  • Affiliations:
  • Universidade do Porto, Porto, Portugal;Universidade do Porto, Porto, Portugal;Universidade do Porto, Porto, Portugal;Ludwig Maximillians Universität, Munich, Germany;University of St Andrews, St Andrews, United Kingdom

  • Venue:
  • Proceedings of the 17th ACM SIGPLAN international conference on Functional programming
  • Year:
  • 2012

Quantified Score

Hi-index 0.00

Visualization

Abstract

This paper describes the first successful attempt, of which we are aware, to define an automatic, type-based static analysis of resource bounds for lazy functional programs. Our analysis uses the automatic amortisation approach developed by Hofmann and Jost, which was previously restricted to eager evaluation. In this paper, we extend this work to a lazy setting by capturing the costs of unevaluated expressions in type annotations and by amortising the payment of these costs using a notion of lazy potential. We present our analysis as a proof system for predicting heap allocations of a minimal functional language (including higher-order functions and recursive data types) and define a formal cost model based on Launchbury's natural semantics for lazy evaluation. We prove the soundness of our analysis with respect to the cost model. Our approach is illustrated by a number of representative and non-trivial examples that have been analysed using a prototype implementation of our analysis.