skip to main content
10.1145/2034773.2034807acmconferencesArticle/Chapter ViewAbstractPublication PagesicfpConference Proceedingsconference-collections
research-article

A hierarchy of mendler style recursion combinators: taming inductive datatypes with negative occurrences

Published: 19 September 2011 Publication History

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?

Supplementary Material

MP4 File (_talk9.mp4)

References

[1]
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.
[2]
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.
[3]
Bird and Meertens. Nested datatypes. In MPC: 4th International Conference on Mathematics of Program Construction. LNCS, Springer-Verlag, 1998.
[4]
R. Bird and R. Paterson. Generalised folds for nested datatypes. Formal Aspects of Computing, 11: 11--2, 1999.
[5]
R. S. Bird and O. de Moor. Algebra of Programming. Prentice-Hall, 1997.
[6]
A. Chlipala. Parametric higher-order abstract syntax for mechanized semantics. ICFP '08, pages 143--156. ACM, 2008.
[7]
A. Church. A formulation of the simple theory of types. Journal of Symbolic Logic, 5 (1): 56--68, 1940.
[8]
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.
[9]
K. Crary and S. Weirich. Flexible type analysis. In ICFP, pages 233--248, 1999.
[10]
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.
[11]
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.
[12]
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.
[13]
L. Fegaras and T. Sheard. Revisiting catamorphisms over datatypes with embedded functions (or, programs from outer space). POPL '96, pages 284--294. ACM, 1996.
[14]
T. Hagino. A Categorical Programming Language. PhD thesis, University of Edinburgh, 1987.
[15]
R. Hinze. Efficient generalized folds. In J. Jeuring, editor, Proc. of 2nd Workshop on Generic Programming. July 2000.
[16]
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.
[17]
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.
[18]
C. E. Martin, J. Gibbons, and I. Bayley. Disciplined, efficient, generalised folds for nested datatypes. Formal Aspects of Computing, 16 (1): 19--35, 2004.
[19]
R. Matthes. Extensions of System F by Iteration and Primitive Recursion on Monotone Inductive Types. PhD thesis, Ludwig-Maximilians Universität, May 1998.
[20]
R. Matthes. An induction principle for nested datatypes in intensional type theory. Journal of Functional Programming, 19 (3-4): 439--468, June 2009.
[21]
R. Matthes. Map fusion for nested datatypes in intensional type theory. Sci. Comput. Program., 76: 204--224, March 2011.
[22]
E. Meijer and G. Hutton. Bananas in space: extending fold and unfold to exponential types. FPCA '95, pages 324--333. ACM, 1995.
[23]
N. P. Mendler. Recursive types and type constraints in second-order lambda calculus. In LICS, pages 30--36. IEEE Computer Society, 1987.
[24]
N. P. Mendler. Inductive types and type constraints in the second-order lambda calculus. Ann. Pure Appl. Logic, 51 (1-2): 159--172, 1991.
[25]
R. Paterson. Control structures from types. Unpublished draft, 1993.
[26]
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.
[27]
F. Pfenning and C. Elliot. Higher-order abstract syntax. PLDI '88, pages 199--208. ACM, 1988.
[28]
B. Russell. Mathematical logic as based on the theory of types. American Journal of Mathematics, 30: 222--262, 1908.
[29]
C.-C. Shan. A static simulation of dynamic delimited control. Higher Order Symbol. Comput., 20: 371--401, December 2007.
[30]
T. Sheard. Putting curry-howard to work. In Proceedings of the 2005 ACM SIGPLAN workshop on Haskell, pages 74--85. ACM, 2005.
[31]
The GHC Team. The Glorious Glasgow Haskell Compilation System User's Guide, Version 7.0.1, 2010.
[32]
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.
[33]
T. Uustalu and V. Vene. Mendler-style inductive types, categorically. Nordic Journal of Computing, 6 (3): 343--361, 1999.
[34]
T. Uustalu and V. Vene. Primitive (co)recursion and course-of-value (co)iteration, categorically. Informatica, Lith. Acad. Sci, 10 (1): 5--26, 1999.
[35]
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.
[36]
V. Vene. Categorical Programming with Inductive and Coinductive Types. PhD thesis, Dept. of Computer Science, Univ. of Tartu, 2000.
[37]
G. Washburn and S. Weirich. Boxes go bananas: encoding higher-order abstract syntax with parametric polymorphism. ICFP '03, pages 249--262. ACM, 2003.

Cited By

View all

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM Conferences
ICFP '11: Proceedings of the 16th ACM SIGPLAN international conference on Functional programming
September 2011
470 pages
ISBN:9781450308656
DOI:10.1145/2034773
  • cover image ACM SIGPLAN Notices
    ACM SIGPLAN Notices  Volume 46, Issue 9
    ICFP '11
    September 2011
    456 pages
    ISSN:0362-1340
    EISSN:1558-1160
    DOI:10.1145/2034574
    Issue’s Table of Contents
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

Sponsors

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 19 September 2011

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. catamorphism
  2. higher-order abstract syntax
  3. histomorphism
  4. parametric polymorphism
  5. parametricity
  6. recursion combinators
  7. recursion schemes
  8. termination
  9. totality

Qualifiers

  • Research-article

Conference

ICFP '11
Sponsor:

Acceptance Rates

ICFP '11 Paper Acceptance Rate 33 of 92 submissions, 36%;
Overall Acceptance Rate 333 of 1,064 submissions, 31%

Upcoming Conference

ICFP '25
ACM SIGPLAN International Conference on Functional Programming
October 12 - 18, 2025
Singapore , Singapore

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)14
  • Downloads (Last 6 weeks)0
Reflects downloads up to 25 Jan 2025

Other Metrics

Citations

Cited By

View all

View Options

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Figures

Tables

Media

Share

Share

Share this Publication link

Share on social media