Liquid Amortization: Proving Amortized Complexity with LiquidHaskell (Functional Pearl)

Jan van Brügge

Research output: Chapter in Book/Report/Conference proceedingConference contribution

4 Downloads (Pure)

Abstract

Formal reasoning about the time complexity of algorithms and data structures is usually done in interactive theorem provers like Isabelle/HOL. This includes reasoning about amortized time complexity which looks at the worst case performance over a series of operations. However, most programs are not written within a theorem prover and thus use the data structures of the production language. To verify the correctness it is necessary to translate the data structures from the production language into the language of the prover. Such a translation step could introduce errors, for example due to a mismatch in features between the two languages. We show how to prove amortized complexity of data structures directly in Haskell using LiquidHaskell. Besides skipping the translation step, our approach can also provide a didactic advantage. Learners do not have to learn an additional language for proofs and can focus on the new concepts only. For this paper, we do not assume prior knowledge of amortized complexity as we explain the concepts and apply them in our first case study, a simple stack with multipop. Moving to more complicated (and useful) data structures, we show that the same technique works for binomial heaps which can be used to implement a priority queue. We also prove amortized complexity bounds for Claessen’s version of the finger tree, a sequence-like data structure with constant-time cons/uncons on either end. Finally we discuss the current limitations of LiquidHaskell that made certain versions of the data structures not feasible.
Original languageEnglish
Title of host publicationHaskell 2024: Proceedings of the 17th ACM SIGPLAN International Haskell Symposium
PublisherAssociation for Computing Machinery
Pages97-108
Number of pages12
ISBN (Print)9798400711022
DOIs
Publication statusPublished - 28 Aug 2024
Event17th ACM SIGPLAN International Haskell Symposium 2024
- Milan, Italy
Duration: 6 Sept 20247 Sept 2024

Conference

Conference17th ACM SIGPLAN International Haskell Symposium 2024
Abbreviated titleHaskell '24
Country/TerritoryItaly
CityMilan
Period6/09/247/09/24

Keywords

  • LiquidHaskell
  • amortized complexity
  • datastructures
  • finger trees
  • functional pearl
  • theorem proving

ASJC Scopus subject areas

  • Software
  • Human-Computer Interaction
  • Computer Vision and Pattern Recognition
  • Computer Science Applications
  • Computer Graphics and Computer-Aided Design

Fingerprint

Dive into the research topics of 'Liquid Amortization: Proving Amortized Complexity with LiquidHaskell (Functional Pearl)'. Together they form a unique fingerprint.

Cite this