Friends with Benefits - Implementing Corecursion in Foundational Proof Assistants

We introduce AmiCo, a tool that extends a proof assistant, Isabelle/HOL, with flexible function definitions well beyond primitive corecursion. All definitions are certified by the assistant's inference kernel to guard against inconsistencies. A central notion is that of friends: functions that preserve the productivity of their arguments and that are allowed in corecursive call contexts. As new friends are registered, corecursion benefits by becoming more expressive. We describe this process and its implementation, from the user's specification to the synthesis of a higher-order definition to the registration of a friend. We show some substantial case studies where our approach makes a difference.

[1]  Andreas Abel Compositional Coinduction with Sized Types , 2016, CMCS.

[2]  Grigore Rosu,et al.  CIRC: A Behavioral Verification Tool Based on Circular Coinduction , 2009, CALCO.

[3]  Robert Atkey,et al.  Productive coprogramming with guarded recursion , 2013, ICFP.

[4]  Yves Bertot,et al.  Interactive Theorem Proving and Program Development: Coq'Art The Calculus of Inductive Constructions , 2010 .

[5]  Lawrence C. Paulson,et al.  A Fixedpoint Approach to Implementing (Co)Inductive Definitions , 1994, CADE.

[6]  Andreas Lochbihler,et al.  Probabilistic Functions and Cryptographic Oracles in Higher Order Logic , 2016, ESOP.

[7]  Nils Anders Danielsson Beating the Productivity Checker Using Embedded Languages , 2010, PAR@ITP.

[8]  Peter Gammie,et al.  The Stern-Brocot Tree , 2015, Arch. Formal Proofs.

[9]  Peter V. Homeier The HOL-Omega Logic , 2009, TPHOLs.

[10]  Ulf Norell,et al.  A Brief Overview of Agda - A Functional Language with Dependent Types , 2009, TPHOLs.

[11]  Jeremy Avigad,et al.  The Lean Theorem Prover (System Description) , 2015, CADE.

[12]  Konrad Slind,et al.  Function Definition in Higher-Order Logic , 1996, TPHOLs.

[13]  Brigitte Pientka,et al.  Copatterns: programming infinite structures by observations , 2013, POPL.

[14]  Yves Bertot,et al.  Filters on CoInductive Streams, an Application to Eratosthenes' Sieve , 2005, TLCA.

[15]  Thomas Chatain,et al.  Avoiding Shared Clocks in Networks of Timed Automata , 2012, CONCUR.

[16]  Andreas Abel,et al.  MiniAgda: Integrating Sized and Dependent Types , 2010, PAR@ITP.

[17]  Jeremy Gibbons,et al.  Linear−time Breadth−first Tree Algorithms: An Exercise in the Arithmetic of Folds and Zips , 1993 .

[18]  Brian Huffman,et al.  Holcf '11: a definitional domain theory for verifying functional programs , 2012 .

[19]  Olaf Müller,et al.  Possibly Infinite Sequences in Theorem Provers: A Comparative Study , 1997, TPHOLs.

[20]  Andrei Popescu,et al.  Witnessing (Co)datatypes , 2015, ESOP.

[21]  Stefan Milius,et al.  Abstract GSOS Rules and a Modular Treatment of Recursive Definitions , 2013, Log. Methods Comput. Sci..

[22]  Jan J. M. M. Rutten,et al.  Automata and Coinduction (An Exercise in Coalgebra) , 1998, CONCUR.

[23]  M. Erwig,et al.  Probabilistic Functional Programming in Haskell , 2005 .

[24]  References , 1971 .

[25]  Tobias Nipkow,et al.  Finding Lexicographic Orders for Termination Proofs in Isabelle/HOL , 2007, TPHOLs.

[26]  Eduardo Giménez,et al.  Codifying Guarded Definitions with Recursive Schemes , 1994, TYPES.

[27]  Michael Norrish,et al.  A Brief Overview of HOL4 , 2008, TPHOLs.

[28]  Patrik Jansson,et al.  Proofs for free - Parametricity for dependent types , 2012, J. Funct. Program..

[29]  John Harrison,et al.  Inductive Definitions: Automation and Application , 1995, TPHOLs.

[30]  Ekaterina Komendantskaya,et al.  Inductive and Coinductive Components of Corecursive Functions in Coq , 2008, CMCS.

[31]  Alexander Krauss Partial Recursive Functions in Higher-Order Logic , 2006, IJCAR.

[32]  Brigitte Pientka,et al.  Well-founded recursion with copatterns and sized types , 2016, Journal of Functional Programming.

[33]  Sumit Gulwani,et al.  Programming by Examples - and its applications in Data Wrangling , 2016, Dependable Software Systems Engineering.

[34]  Magnus O. Myreen Functional Programs: Conversions between Deep and Shallow Embeddings , 2012, ITP.

[35]  Martin Erwig,et al.  Functional Pearls: Probabilistic functional programming in Haskell , 2006, J. Funct. Program..

[36]  Dmitriy Traytel Formal Languages, Formally and Coinductively , 2017, Log. Methods Comput. Sci..

[37]  Tobias Nipkow,et al.  Code Generation via Higher-Order Rewrite Systems , 2010, FLOPS.

[38]  Lawrence Charles Paulson,et al.  Isabelle/HOL: A Proof Assistant for Higher-Order Logic , 2002 .

[39]  Johannes Hölzl,et al.  Recursive Functions on Lazy Lists via Domains and Topologies , 2014, ITP.

[40]  Ulrich Berger,et al.  An inverse of the evaluation functional for typed lambda -calculus , 1991, [1991] Proceedings Sixth Annual IEEE Symposium on Logic in Computer Science.

[41]  M. Züst,et al.  Programming TLS in Isabelle / HOL , 2014 .

[42]  Brian Huffman,et al.  Lifting and Transfer: A Modular Design for Quotients in Isabelle/HOL , 2013, CPP.

[43]  Damien Pous,et al.  Coinduction All the Way Up , 2016, 2016 31st Annual ACM/IEEE Symposium on Logic in Computer Science (LICS).

[44]  John C. Reynolds,et al.  Types, Abstraction and Parametric Polymorphism , 1983, IFIP Congress.

[45]  Andrei Popescu,et al.  Foundational extensible corecursion: a proof assistant perspective , 2015, ICFP.

[46]  Chantal Keller,et al.  Parametricity in an Impredicative Sort , 2012, ArXiv.

[47]  Jan J. M. M. Rutten,et al.  Universal coalgebra: a theory of systems , 2000, Theor. Comput. Sci..

[48]  Jurriaan Rot,et al.  Coalgebraic Bisimulation-Up-To , 2013, SOFSEM.

[49]  Andrea Asperti,et al.  The Matita Interactive Theorem Prover , 2011, CADE.

[50]  Alexandra Silva,et al.  Language Constructs for Non-Well-Founded Computation , 2013, ESOP.

[51]  Brigitte Pientka,et al.  Indexed codata types , 2016, ICFP.

[52]  Ralf Hinze,et al.  The Bird Tree , 2009, Journal of Functional Programming.

[53]  Thorsten Altenkirch,et al.  Containers: Constructing strictly positive types , 2005, Theor. Comput. Sci..

[54]  M. Gordon,et al.  Introduction to HOL: a theorem proving environment for higher order logic , 1993 .

[55]  Stefan Milius Completely iterative algebras and completely iterative monads , 2005, Inf. Comput..

[56]  Alexander Krauss,et al.  Recursive Definitions of Monadic Functions , 2010, PAR@ITP.

[57]  Donald E. Knuth,et al.  Fast Pattern Matching in Strings , 1977, SIAM J. Comput..

[58]  K. Rustan M. Leino,et al.  Automating Theorem Proving with SMT , 2013, ITP.

[59]  Glynn Winskel,et al.  A Note on Model Checking the Modal nu-Calculus , 1991, Theor. Comput. Sci..

[60]  Lawrence S. Moss Parametric corecursion , 2001, Theor. Comput. Sci..

[61]  John Matthews Recursive Function Definition over Coinductive Types , 1999, TPHOLs.

[62]  Andrei Popescu,et al.  Truly Modular (Co)datatypes for Isabelle/HOL , 2014, ITP.

[63]  Lawrence C. Paulson Mechanizing Coinduction and Corecursion in Higher-Order Logic , 1997, J. Log. Comput..

[64]  Andrei Popescu,et al.  Foundational, Compositional (Co)datatypes for Higher-Order Logic: Category Theory Applied to Theorem Proving , 2012, 2012 27th Annual IEEE Symposium on Logic in Computer Science.

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

[66]  Chung-Kil Hur,et al.  The power of parameterization in coinductive proof , 2013, POPL.

[67]  Edsger W. Dijkstra,et al.  An Exercise for Dr. R. M. Burstall , 1982 .

[68]  Mark Adams Introducing HOL Zero - (Extended Abstract) , 2010, ICMS.

[69]  Philip Wadler,et al.  Theorems for free! , 1989, FPCA.

[70]  K. Rustan M. Leino,et al.  Co-induction Simply - Automatic Co-inductive Proofs in a Program Verifier , 2014, FM.

[71]  John Harrison,et al.  HOL Light: An Overview , 2009, TPHOLs.

[72]  Eduardo Giménez,et al.  An Application of Co-inductive Types in Coq: Verification of the Alternating Bit Protocol , 1995, TYPES.

[73]  D. A. Turner,et al.  Elementary Strong Functional Programming , 1995, FPLE.