Recursion Schemes in Coq

Program calculation, a programming technique to derive efficient programs from naive ones by program transformation, is challenging for program optimization. Tesson et al. have shown that Coq, a popular proof assistant, provides a cost-effective way to implement a powerful system for verifying correctness of program transformations, but their applications are limited to list functions in the Theory of Lists. In this paper, we propose an easy-to-use Coq library to prove more advanced calculation rules in Coq for various recursion schemes, which capture recursive programs on an arbitrary algebraic datatype. We prove all the lemmas and theorems about recursion schemes in Coq including histomorphisms and futumorphisms proposed by Uustalu et al. Our library can be used to obtain certified runnable programs from their definitions written with recursion schemes in Coq scripts. We demonstrate a certified runnable program for the Fibonacci numbers and unbounded knapsack problem from their histomorphic definitions.

[1]  Richard S. Bird,et al.  Algebra of programming , 1997, Prentice Hall International series in computer science.

[2]  Maarten M. Fokkinga,et al.  Functional Programming with Bananas, Lenses, Envelopes and Barbed Wire , 1991, FPCA.

[3]  Adam Chlipala,et al.  Certified Programming with Dependent Types - A Pragmatic Introduction to the Coq Proof Assistant , 2013 .

[4]  Richard S. Bird,et al.  An introduction to the theory of lists , 1987 .

[5]  Frédéric Loulergue,et al.  A Verified Generate-Test-Aggregate Coq Library for Parallel Programs Extraction , 2014, ITP.

[6]  Frédéric Loulergue,et al.  Calculating Parallel Programs in Coq Using List Homomorphisms , 2017, International Journal of Parallel Programming.

[7]  Shin-Cheng Mu,et al.  Algebra of programming in Agda: Dependent types for relational program derivation , 2009, J. Funct. Program..

[8]  Ralf Hinze,et al.  Unifying structured recursion schemes , 2013, ICFP.

[9]  Masato Takeichi,et al.  Deriving structural hylomorphisms from recursive definitions , 1996, ICFP '96.

[10]  Shin-Cheng Mu,et al.  Formal derivation of Greedy algorithms from relational specifications: A tutorial , 2016, J. Log. Algebraic Methods Program..

[11]  D. Sangiorgi Introduction to Bisimulation and Coinduction , 2011 .

[12]  Tarmo Uustalu,et al.  Primitive (Co)Recursion and Course-of-Value (Co)Iteration, Categorically , 1999, Informatica.

[13]  Venanzio Capretta,et al.  Recursive Coalgebras from Comonads , 2004, CMCS.

[14]  Akihiko Takano,et al.  Shortcut deforestation in calculational form , 1995, FPCA '95.

[15]  Hideki Hashimoto,et al.  Program Calculation in Coq , 2010, AMAST.

[16]  Varmo Vene,et al.  CATEGORICAL PROGRAMMING WITH INDUCTIVE AND COINDUCTIVE TYPES , 2000 .