Abstract
The Mendler style catamorphism (which corresponds to weak induction) always terminates even for negative inductive datatypes. The Mendler style histomorphism (which corresponds to strong induction) is known to terminate for positive inductive datatypes. To our knowledge, the literature is silent on its termination properties for negative datatypes. In this paper, we prove that histomorphisms do not always termintate by showing a counter-example. We also enrich the Mendler collection of recursion combinators by defining a new form of Mendler style catamorphism (msfcata), which terminates for all inductive datatypes, that is more expressive than the original. We organize the collection of combinators by placing them into a hierarchy of ever increasing generality, and describing the termination properties of each point on the hierarchy. We also provide many examples (including a case study on a negative inductive datatype), which illustrate both the expressive power and beauty of the Mendler style. One lesson we learn from this work is that weak induction applies to negative inductive datatypes but strong induction is problematic. We provide a proof of weak induction by exhibiting an embedding of our new combinator into Fω. We pose the open question: Is there a safe way to apply strong induction to negative inductive datatypes?
Supplemental Material
- A. Abel, R. Matthes, and T. Uustalu. Generalized iteration and coiteration for higher-order nested datatypes. In FoSSaCS, volume 2620 of LNCS, pages 54--69. Springer, 2003. Google Scholar
Digital Library
- A. Abel, R. Matthes, and T. Uustalu. Iteration and coiteration schemes for higher-order and nested datatypes. Theoretical Computer Science, 333 (1-2): 3--66, 2005. ISSN 0304-3975. Google Scholar
Digital Library
- Bird and Meertens. Nested datatypes. In MPC: 4th International Conference on Mathematics of Program Construction. LNCS, Springer-Verlag, 1998. Google Scholar
Digital Library
- R. Bird and R. Paterson. Generalised folds for nested datatypes. Formal Aspects of Computing, 11: 11--2, 1999.Google Scholar
Digital Library
- R. S. Bird and O. de Moor. Algebra of Programming. Prentice-Hall, 1997. Google Scholar
Digital Library
- A. Chlipala. Parametric higher-order abstract syntax for mechanized semantics. ICFP '08, pages 143--156. ACM, 2008. Google Scholar
Digital Library
- A. Church. A formulation of the simple theory of types. Journal of Symbolic Logic, 5 (1): 56--68, 1940.Google Scholar
Cross Ref
- R. L. Constable, S. F. Allen, H. M. Bromley, W. R. Cleaveland, J. F. Cremer, R. W. Harper, D. J. Howe, T. B. Knoblock, N. P. Mendler, P. Panangaden, J. T. Sasaki, and S. F. Smith. Implementing mathematics with the Nuprl proof development system. Prentice-Hall, Inc., Upper Saddle River, NJ, USA, 1986. ISBN 0-13-451832-2. Google Scholar
Digital Library
- K. Crary and S. Weirich. Flexible type analysis. In ICFP, pages 233--248, 1999. Google Scholar
Digital Library
- J. Despeyroux and P. Leleu. Primitive recursion for higher-order abstract syntax with dependant types. In Informal proceedings of the FLoC'99 IMLA, June 1999.Google Scholar
- J. Despeyroux, A. P. Felty, and A. Hirschowitz. Higher-order abstract syntax in coq. In Proceedings of the Second International Conference on Typed Lambda Calculi and Applications, pages 124--138, London, UK, 1995. Springer-Verlag. Google Scholar
Digital Library
- J. Despeyroux, F. Pfenning, and C. Schürmann. Primitive recursion for higher-order abstract syntax. In P. de Groote, editor, TLCA, volume 1210 of LNCS, pages 147--163. Springer, 1997. ISBN 3-540-62688-3. Google Scholar
Digital Library
- L. Fegaras and T. Sheard. Revisiting catamorphisms over datatypes with embedded functions (or, programs from outer space). POPL '96, pages 284--294. ACM, 1996. Google Scholar
Digital Library
- T. Hagino. A Categorical Programming Language. PhD thesis, University of Edinburgh, 1987. Google Scholar
Digital Library
- R. Hinze. Efficient generalized folds. In J. Jeuring, editor, Proc. of 2nd Workshop on Generic Programming. July 2000.Google Scholar
- R. Hinze. Adjoint folds and unfolds. In C. Bolduc, J. Desharnais, and B. Ktari, editors, Mathematics of Program Construction, volume 6120 of LNCS, pages 195--228. Springer Berlin / Heidelberg, 2010. Google Scholar
Digital Library
- Honsell, Miculan, and Scagnetto. An axiomatic approach to metareasoning on nominal algebras in HOAS. In ICALP: Annual International Colloquium on Automata, Languages and Programming, 2001. Google Scholar
Digital Library
- C. E. Martin, J. Gibbons, and I. Bayley. Disciplined, efficient, generalised folds for nested datatypes. Formal Aspects of Computing, 16 (1): 19--35, 2004. Google Scholar
Digital Library
- R. Matthes. Extensions of System F by Iteration and Primitive Recursion on Monotone Inductive Types. PhD thesis, Ludwig-Maximilians Universität, May 1998.Google Scholar
- R. Matthes. An induction principle for nested datatypes in intensional type theory. Journal of Functional Programming, 19 (3-4): 439--468, June 2009. Google Scholar
Digital Library
- R. Matthes. Map fusion for nested datatypes in intensional type theory. Sci. Comput. Program., 76: 204--224, March 2011. Google Scholar
Digital Library
- E. Meijer and G. Hutton. Bananas in space: extending fold and unfold to exponential types. FPCA '95, pages 324--333. ACM, 1995. Google Scholar
Digital Library
- N. P. Mendler. Recursive types and type constraints in second-order lambda calculus. In LICS, pages 30--36. IEEE Computer Society, 1987.Google Scholar
- N. P. Mendler. Inductive types and type constraints in the second-order lambda calculus. Ann. Pure Appl. Logic, 51 (1-2): 159--172, 1991.Google Scholar
Cross Ref
- R. Paterson. Control structures from types. Unpublished draft, 1993.Google Scholar
- C. Paulin-Mohring. Inductive definitions in the system Coq - rules and properties. In M. Bezem and J. F. Groote, editors, TLCA, volume 664 of LNCS, pages 328--345. Springer, 1993. Google Scholar
Digital Library
- F. Pfenning and C. Elliot. Higher-order abstract syntax. PLDI '88, pages 199--208. ACM, 1988. Google Scholar
Digital Library
- B. Russell. Mathematical logic as based on the theory of types. American Journal of Mathematics, 30: 222--262, 1908.Google Scholar
Cross Ref
- C.-C. Shan. A static simulation of dynamic delimited control. Higher Order Symbol. Comput., 20: 371--401, December 2007. Google Scholar
Digital Library
- T. Sheard. Putting curry-howard to work. In Proceedings of the 2005 ACM SIGPLAN workshop on Haskell, pages 74--85. ACM, 2005. Google Scholar
Digital Library
- The GHC Team. The Glorious Glasgow Haskell Compilation System User's Guide, Version 7.0.1, 2010.Google Scholar
- T. Uustalu. Natural Deduction for Intuitionistic Least and Greatest Fixedpoint Logics, with an Application to Program Construction. PhD thesis, Dept. of Teleinformatics, Royal Inst. of Technology, Stockholm, May 1998.Google Scholar
- T. Uustalu and V. Vene. Mendler-style inductive types, categorically. Nordic Journal of Computing, 6 (3): 343--361, 1999. Google Scholar
Digital Library
- T. Uustalu and V. Vene. Primitive (co)recursion and course-of-value (co)iteration, categorically. Informatica, Lith. Acad. Sci, 10 (1): 5--26, 1999.Google Scholar
- T. Uustalu and V. Vene. Coding recursion à la Mendler (extended abstract). In J. Jeuring, editor, Proc. of 2nd Workshop on Generic Programming, pages 69--85. 2000.Google Scholar
- V. Vene. Categorical Programming with Inductive and Coinductive Types. PhD thesis, Dept. of Computer Science, Univ. of Tartu, 2000.Google Scholar
- G. Washburn and S. Weirich. Boxes go bananas: encoding higher-order abstract syntax with parametric polymorphism. ICFP '03, pages 249--262. ACM, 2003. Google Scholar
Digital Library
Index Terms
A hierarchy of mendler style recursion combinators: taming inductive datatypes with negative occurrences
Recommendations
A hierarchy of mendler style recursion combinators: taming inductive datatypes with negative occurrences
ICFP '11: Proceedings of the 16th ACM SIGPLAN international conference on Functional programmingThe Mendler style catamorphism (which corresponds to weak induction) always terminates even for negative inductive datatypes. The Mendler style histomorphism (which corresponds to strong induction) is known to terminate for positive inductive datatypes. ...
Boxes go bananas: encoding higher-order abstract syntax with parametric polymorphism
Higher-order abstract syntax is a simple technique for implementing languages with functional programming. Object variables and binders are implemented by variables and binders in the host language. By using this technique, one can avoid implementing ...
Boxes go bananas: encoding higher-order abstract syntax with parametric polymorphism
ICFP '03: Proceedings of the eighth ACM SIGPLAN international conference on Functional programmingHigher-order abstract syntax is a simple technique for implementing languages with functional programming. Object variables and binders are implemented by variables and binders in the host language. By using this technique, one can avoid implementing ...







Comments