Abstract
Total functional programming offers the beguiling vision that, just by virtue of the compiler accepting a program, we are guaranteed that it will always terminate. In the case of programs that are not intended to terminate, e.g., servers, we are guaranteed that programs will always be productive. Productivity means that, even if a program generates an infinite amount of data, each piece will be generated in finite time. The theoretical underpinning for productive programming with infinite output is provided by the category theoretic notion of final coalgebras. Hence, we speak of coprogramming with non-well-founded codata, as a dual to programming with well-founded data like finite lists and trees.
Systems that offer facilities for productive coprogramming, such as the proof assistants Coq and Agda, currently do so through syntactic guardedness checkers. Syntactic guardedness checkers ensure that all self-recursive calls are guarded by a use of a constructor. Such a check ensures productivity. Unfortunately, these syntactic checks are not compositional, and severely complicate coprogramming.
Guarded recursion, originally due to Nakano, is tantalising as a basis for a flexible and compositional type-based approach to coprogramming. However, as we show, by itself, guarded recursion is not suitable for coprogramming due to the fact that there is no way to make finite observations on pieces of infinite data. In this paper, we introduce the concept of clock variables that index Nakano's guarded recursion. Clock variables allow us to "close over" the generation of infinite data, and to make finite observations, something that is not possible with guarded recursion alone.
- A. Abel. Termination checking with types. ITA, 38 (4): 277--319, 2004.Google Scholar
- A. W. Appel and D. A. McAllester. An indexed model of recursive types for foundational proof-carrying code. ACM Trans. Program. Lang. Syst., 23 (5): 657--683, 2001. Google Scholar
Digital Library
- R. S. Bird. Using Circular Programs to Eliminate Multiple Traversals of Data. Acta Informatica, 21: 239--250, 1984.Google Scholar
Digital Library
- L. Birkedal and R. E. Møgelberg. Intensional type theory with guarded recursive types qua fixed points on universes. In ACM/IEEE Symposium on Logic in Computer Science (LICS 2013), 2013.Google Scholar
Digital Library
- L. Birkedal, J. Schwinghammer, and K. Støvring. A metric model of guarded recursion. In Presented at FICS 2010, 2010.Google Scholar
- L. Birkedal, R. E. Møgelberg, J. Schwinghammer, and K. Støvring. First steps in synthetic guarded domain theory: step-indexing in the topos of trees. Log. Meth. in Computer Science, 8 (4), 2012.Google Scholar
Cross Ref
- V. Capretta. General recursion via coinductive types. Log. Meth. in Computer Science, 1 (2), 2005.Google Scholar
- N. A. Danielsson. Beating the productivity checker using embedded languages. In Workshop on Partiality and Recursion in Interactive Theorem Provers (PAR 2010), volume 43 of EPTCS, pages 29--48, 2010.Google Scholar
Cross Ref
- N. A. Danielsson and T. Altenkirch. Mixing induction and coinduction. Draft, 2009.Google Scholar
- D. Dreyer, A. Ahmed, and L. Birkedal. Logical step-indexed logical relations. Log. Meth. in Computer Science, 7 (2), 2011.Google Scholar
- N. Ghani, P. Hancock, and D. Pattinson. Representations of stream processors using nested fixed points. Log. Meth. in Computer Science, 5 (3), 2009.Google Scholar
- E. Giménez. Codifying guarded definitions with recursive schemes. In Types for Proofs and Programs, International Workshop TYPES'94, volume 996 of Lecture Notes in Computer Science, pages 39--59, 1994. Google Scholar
Digital Library
- G. Hutton and M. Jaskelioff. Representing contractive functions on streams. Submitted, 2011.Google Scholar
- N. R. Krishnaswami and N. Benton. A semantic model for graphical user interfaces. In ACM SIGPLAN international conference on Functional Programming, ICFP 2011, pages 45--57, 2011. Google Scholar
Digital Library
- N. R. Krishnaswami and N. Benton. Ultrametric semantics of reactive programs. In IEEE Symposium on Logic in Computer Science, LICS 2011, pages 257--266, 2011. Google Scholar
Digital Library
- J. Launchbury and S. L. Peyton Jones. Lazy functional state threads. In Proceedings of the ACM SIGPLAN'94 Conference on Programming Language Design and Implementation (PLDI), pages 24--35, 1994. Google Scholar
Digital Library
- R. Loader. Equational Theories for Inductive Types. Annals of Pure and Applied Logic, 84 (2): 175--217, 1997.Google Scholar
Cross Ref
- C. McBride and R. Paterson. Applicative programming with effects. J. Funct. Prog., 18 (1): 1--13, 2008. Google Scholar
Digital Library
- E. Moggi and A. Sabry. Monadic encapsulation of effects: a revised approach (extended version). J. Funct. Prog., 11 (6): 591--627, 2001. Google Scholar
Digital Library
- H. Nakano. A modality for recursion. In IEEE Symposium on Logic in Computer Science (LICS 2000), pages 255--266, 2000. Google Scholar
Digital Library
- A. M. Pitts. Computational adequacy via 'mixed' inductive definitions. In Mathematical Foundations of Programming Semantics, Proc. 9th Int. Conf., volume 802 of Lecture Notes in Computer Science, pages 72--82. Springer-Verlag, Berlin, 1994. Google Scholar
Digital Library
- P. Severi and F.-J. de Vries. Pure type systems with corecursion on streams: from finite to infinitary normalisation. In ACM SIGPLAN International Conference on Functional Programming, ICFP'12, 2012. Google Scholar
Digital Library
- M. B. Smyth and G. D. Plotkin. The category-theoretic solution of recursive domain equations. SIAM J. Comput., 11 (4): 761--783, 1982.Google Scholar
Digital Library
- A. Tarski. A lattice-theoretical fixpoint theorem and its applications. Pacific Journal of Mathematics, 5 (2): 285--309, 1955.Google Scholar
Cross Ref
Index Terms
Productive coprogramming with guarded recursion
Recommendations
A type theory for productive coprogramming via guarded recursion
CSL-LICS '14: Proceedings of the Joint Meeting of the Twenty-Third EACSL Annual Conference on Computer Science Logic (CSL) and the Twenty-Ninth Annual ACM/IEEE Symposium on Logic in Computer Science (LICS)To ensure consistency and decidability of type checking, proof assistants impose a requirement of productivity on corecursive definitions. In this paper we investigate a type-based alternative to the existing syntactic productivity checks of Coq and ...
Productive coprogramming with guarded recursion
ICFP '13: Proceedings of the 18th ACM SIGPLAN international conference on Functional programmingTotal functional programming offers the beguiling vision that, just by virtue of the compiler accepting a program, we are guaranteed that it will always terminate. In the case of programs that are not intended to terminate, e.g., servers, we are ...
A Model of Guarded Recursion With Clock Synchronisation
Guarded recursion is an approach to solving recursive type equations where the type variable appears guarded by a modality to be thought of as a delay for one time step. Atkey and McBride proposed a calculus in which guarded recursion can be used when ...







Comments