Abstract

Liquid Haskell is an extension to the type system of Haskell that supports formal reasoning about program correctness by encoding logical properties as refinement types. In this article, we show how Liquid Haskell can also be used to reason about program efficiency in the same setting. We use the system's existing verification machinery to ensure that the results of our cost analysis are valid, together with custom invariants for particular program contexts to ensure that the results of our analysis are precise. To illustrate our approach, we analyse the efficiency of a wide range of popular data structures and algorithms, and in doing so, explore various notions of resource usage. Our experience is that reasoning about efficiency in Liquid Haskell is often just as simple as reasoning about correctness, and that the two can naturally be combined.

Highlights

  • Estimating the amount of resources that are required to execute a program is a key aspect of software development

  • The problem of statically analysing the resource usage, or execution cost, of programs has been subject to much research in which a broad range of techniques have been studied, including resource-aware type systems [Çiçek et al 2017; Hoffmann et al 2012; Hofmann and Jost 2003; Jost et al 2017; Wang et al 2017], program and separation logics [Aspinall et al 2007; Atkey 2010], and sized types [Vasconcelos 2008]

  • Ś We prove that our library’s approach to cost analysis is correct with respect to an underlying model of execution cost using the metatheory of Liquid Haskell

Read more

Summary

Introduction

Estimating the amount of resources that are required to execute a program is a key aspect of software development. The problem of statically analysing the resource usage, or execution cost, of programs has been subject to much research in which a broad range of techniques have been studied, including resource-aware type systems [Çiçek et al 2017; Hoffmann et al 2012; Hofmann and Jost 2003; Jost et al 2017; Wang et al 2017], program and separation logics [Aspinall et al 2007; Atkey 2010], and sized types [Vasconcelos 2008] Another technique for statically analysing execution cost, inspired by the early work in [Moran and Sands 1999] on improvement theory, is to reify resource usage into the definition of a program by means of a datatype that accumulates abstract computation ‘steps’. Formal analysis at the type level has been successfully applied in Agda [Danielsson 2008] and more recently Coq [McCarthy et al 2017], while recent work in [Radiček et al 2018] developed the theoretical foundations of the value-level approach

Objectives
Results
Conclusion
Full Text
Paper version not known

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call