A Coq Library for Internal Verification of Running-Times

This paper presents a Coq library that lifts an abstract yet precise notion of running-time into the type of a function. Our library is based on a monad that counts abstract steps, controlled by one of the monadic operations. The monad’s computational content, however, is simply that of the identity monad so programs written in our monad (that recur on the natural structure of their arguments) extract into idiomatic OCaml code. We evaluated the expressiveness of the library by proving that red-black tree insertion and search, merge sort, insertion sort, Fibonacci, iterated list insertion, BigNum addition, and Okasaki’s Braun Tree algorithms all have their expected running times.

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

[2]  Robert Atkey,et al.  Parameterised notions of computation , 2006, J. Funct. Program..

[3]  Ricardo Peña-Marí,et al.  Space consumption analysis by abstract interpretation: Inference of recursive functions , 2015, Sci. Comput. Program..

[4]  Arthur Charguéraud,et al.  Machine-Checked Verification of the Correctness and Amortized Complexity of an Efficient Union-Find Implementation , 2015, ITP.

[5]  Jennifer Paykin,et al.  A static cost analysis for a higher-order language , 2012, PLPV.

[6]  Zhong Shao,et al.  Automatic Static Cost Analysis for Parallel Programs , 2015, ESOP.

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

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

[9]  Dan S. Wallach,et al.  Denial of Service via Algorithmic Complexity Attacks , 2003, USENIX Security Symposium.

[10]  Chris Okasaki Three Algorithms on Braun Trees , 1997, J. Funct. Program..

[11]  Frank Pfenning,et al.  Dependent types in practical programming , 1999, POPL '99.

[12]  James McKinna,et al.  A Machine-Checked Proof of the Average-Case Complexity of Quicksort in Coq , 2009, TYPES.

[13]  Matthieu Sozeau,et al.  Subset Coercions in Coq , 2006, TYPES.

[14]  Benjamin Livshits,et al.  Verifying higher-order programs with the dijkstra monad , 2013, PLDI.

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

[16]  Ronald L. Rivest,et al.  Introduction to Algorithms , 1990 .

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

[18]  Hongwei Xi,et al.  Dependently Typed Data Structures , 2000 .

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

[20]  Rob R. Hoogerwoord,et al.  A Logarithmic Implementation of Flexible Arrays , 1992, MPC.

[21]  Ronald L. Rivest,et al.  Introduction to Algorithms, 3rd Edition , 2009 .

[22]  Thorsten Altenkirch,et al.  Monads need not be endofunctors , 2010, Log. Methods Comput. Sci..

[23]  Elvira Albert,et al.  Heap space analysis for garbage collected languages , 2013, Sci. Comput. Program..

[24]  Martin Hofmann,et al.  A program logic for resources , 2007, Theor. Comput. Sci..

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

[26]  Jean-Christophe Filliâtre,et al.  Functors for Proofs and Programs , 2004, ESOP.

[27]  Wouter Swierstra A Hoare Logic for the State Monad , 2009, TPHOLs.