This paper presents a theoretical framework for defining corecursive functions safely in a total setting, based on corecursion up-to and relational parametricity. The end product is a general corecursor that allows corecursive (and even recursive) calls under well-behaved operations, including constructors. Corecursive functions that are well behaved can be registered as such, thereby increasing the corecursor's expressiveness. To the extensible corecursor corresponds an equally flexible coinduction principle. The metatheory is formalized in the Isabelle proof assistant and forms the core of a prototype tool. The approach is foundational: The corecursor is derived from first principles, without requiring new axioms or extensions of the logic. This ensures that no inconsistencies can be introduced by omissions in a termination or productivity check.
© Blanchette, Popescu, & Traytel, 2013. This is the author's version of the work. It is posted here for your personal use. Not for redistribution. The definitive version was published in ICFP'15, doi.org/10.1145/2784731.2784732.Paper draft Supplementary material