Advertisement

Nested Datatypes with Generalized Mendler Iteration: Map Fusion and the Example of the Representation of Untyped Lambda Calculus with Explicit Flattening

  • Ralph Matthes
Part of the Lecture Notes in Computer Science book series (LNCS, volume 5133)

Abstract

Nested datatypes are families of datatypes that are indexed over all types such that the constructors may relate different family members. Moreover, the argument types of the constructors refer to indices given by expressions where the family name may occur. Especially in this case of true nesting, there is no direct support by theorem provers to guarantee termination of functions that traverse these data structures.

A joint article with A. Abel and T. Uustalu (TCS 333(1–2), pp. 3–66, 2005) proposes iteration schemes that guarantee termination not by structural requirements but just by polymorphic typing. They are generic in the sense that no specific syntactic form of the underlying datatype “functor” is required. In subsequent work (accepted for the Journal of Functional Programming), the author introduced an induction principle for the verification of programs obtained from Mendler-style iteration of rank 2, which is one of those schemes, and justified it in the Calculus of Inductive Constructions through an implementation in the theorem prover Coq.

The new contribution is an extension of this work to generalized Mendler iteration (introduced in Abel et al, cited above), leading to a map fusion theorem for the obtained iterative functions. The results and their implementation in Coq are used for a case study on a representation of untyped lambda calculus with explicit flattening. Substitution is proven to fulfill two of the three monad laws, the third only for “hereditarily canonical” terms, but this is rectified by a relativisation of the whole construction to those terms.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Bird, R., Meertens, L.: Nested Datatypes. In: Jeuring, J. (ed.) MPC 1998. LNCS, vol. 1422, pp. 52–67. Springer, Heidelberg (1998)CrossRefGoogle Scholar
  2. 2.
    Bird, R., Gibbons, J., Jones, G.: Program optimisation, naturally. In: Davies, J., Roscoe, B., Woodcock, J. (eds.) Millenial Perspectives in Computer Science, Proceedings of the 1999 Oxford-Microsoft Symp. in Honour of Professor Sir Anthony Hoare, Palgrave (2000)Google Scholar
  3. 3.
    Hinze, R.: Efficient generalized folds. In: Jeuring, J. (ed.) Proceedings of the Second Workshop on Generic Programming, WGP 2000, Ponte de Lima, Portugal (2000)Google Scholar
  4. 4.
    Bellegarde, F., Hook, J.: Substitution: A formal methods case study using monads and transformations. Science of Computer Programming 23, 287–311 (1994)zbMATHCrossRefGoogle Scholar
  5. 5.
    Bird, R.S., Paterson, R.: De Bruijn notation as a nested datatype. Journal of Functional Programming 9(1), 77–91 (1999)zbMATHCrossRefMathSciNetGoogle Scholar
  6. 6.
    Altenkirch, T., Reus, B.: Monadic Presentations of Lambda Terms Using Generalized Inductive Types. In: Flum, J., Rodríguez-Artalejo, M. (eds.) CSL 1999. LNCS, vol. 1683, pp. 453–468. Springer, Heidelberg (1999)CrossRefGoogle Scholar
  7. 7.
    Coq Development Team: The Coq Proof Assistant Reference Manual Version 8.1. Project LogiCal, INRIA (2006), http://coq.inria.fr
  8. 8.
    Paulin-Mohring, C.: Définitions Inductives en Théorie des Types d’Ordre Supérieur. Habilitation à diriger les recherches, Université Claude Bernard Lyon I (1996)Google Scholar
  9. 9.
    Letouzey, P.: A New Extraction for Coq. In: Geuvers, H., Wiedijk, F. (eds.) TYPES 2002. LNCS, vol. 2646, pp. 200–219. Springer, Heidelberg (2003)CrossRefGoogle Scholar
  10. 10.
    Abel, A., Matthes, R., Uustalu, T.: Iteration and coiteration schemes for higher-order and nested datatypes. Theoretical Computer Science 333(1–2), 3–66 (2005)zbMATHCrossRefMathSciNetGoogle Scholar
  11. 11.
    Bird, R., Paterson, R.: Generalised folds for nested datatypes. Formal Aspects of Computing 11(2), 200–222 (1999)zbMATHCrossRefGoogle Scholar
  12. 12.
    Abel, A., Matthes, R. (Co-)Iteration for Higher-Order Nested Datatypes. In: Geuvers, H., Wiedijk, F. (eds.) TYPES 2002. LNCS, vol. 2646, pp. 1–20. Springer, Heidelberg (2003)CrossRefGoogle Scholar
  13. 13.
    Bird, R., de Moor, O.: Algebra of Programming. International Series in Computer Science, vol. 100. Prentice-Hall, Englewood Cliffs (1997)zbMATHGoogle Scholar
  14. 14.
    Matthes, R.: An induction principle for nested datatypes in intensional type theory. Journal of Functional Programming (to appear, 2008)Google Scholar
  15. 15.
    Martin, C., Gibbons, J., Bayley, I.: Disciplined, efficient, generalised folds for nested datatypes. Formal Aspects of Computing 16(1), 19–35 (2004)zbMATHCrossRefGoogle Scholar
  16. 16.
    Johann, P., Ghani, N.: Initial Algebra Semantics is enough! In: Ronchi Della Rocca, S. (ed.) TLCA 2007. LNCS, vol. 4583, pp. 207–222. Springer, Heidelberg (2007)CrossRefGoogle Scholar
  17. 17.
    Matthes, R.: Coq development for Nested datatypes with generalized Mendler iteration: map fusion and the example of the representation of untyped lambda calculus with explicit flattening (January 2008), http://www.irit.fr/~Ralph.Matthes/Coq/MapFusion/
  18. 18.
    Matthes, R.: Coq development for An induction principle for nested datatypes in intensional type theory (January 2008), http://www.irit.fr/~Ralph.Matthes/Coq/InductionNested/
  19. 19.
    Mendler, N.P.: Recursive types and type constraints in second-order lambda calculus. In: Proceedings of the Second Annual IEEE Symposium on Logic in Computer Science, Ithaca, pp. 30–36. IEEE Computer Society Press (1987)Google Scholar
  20. 20.
    Barthe, G., Frade, M.J., Giménez, E., Pinto, L., Uustalu, T.: Type-based termination of recursive definitions. Mathematical Structures in Computer Science 14, 97–141 (2004)zbMATHCrossRefGoogle Scholar
  21. 21.
    Uustalu, T., Vene, V.: A cube of proof systems for the intuitionistic predicate μ-, ν-logic. In: Haveraaen, M., Owe, O. (eds.) Selected Papers of the 8th Nordic Workshop on Programming Theory (NWPT 1996). Research Reports, Department of Informatics, University of Oslo, vol. 248, pp. 237–246 (May 1997)Google Scholar
  22. 22.
    Matthes, R.: Naive reduktionsfreie Normalisierung (translated to English: naive reduction-free normalization). Slides of talk on December 19, 1996, given at the Bern Munich meeting on proof theory and computer science in Munich, available at the author’s homepage (December 1996)Google Scholar
  23. 23.
    Hofmann, M.: Extensional concepts in intensional type theory. PhD thesis, University of Edinburgh, Available as report ECS-LFCS-95-327 (1995)Google Scholar
  24. 24.
    Altenkirch, T.: Extensional equality in intensional type theory. In: 14th Annual IEEE Symposium on Logic in Computer Science (LICS 1999), pp. 412–420. IEEE Computer Society, Los Alamitos (1999)Google Scholar
  25. 25.
    Oury, N.: Extensionality in the Calculus of Constructions. In: Hurd, J., Melham, T. (eds.) TPHOLs 2005. LNCS, vol. 3603, pp. 278–293. Springer, Heidelberg (2005)Google Scholar
  26. 26.
    Wadler, P.: Theorems for free? In: Proceedings of the fourth international conference on functional programming languages and computer architecture, Imperial College, pp. 347–359. ACM Press, London (1989)CrossRefGoogle Scholar
  27. 27.
    Abel, A.: A Polymorphic Lambda-Calculus with Sized Higher-Order Types. Doktorarbeit (PhD thesis), LMU München (2006)Google Scholar
  28. 28.
    Dybjer, P.: A general formulation of simultaneous inductive-recursive definitions in type theory. The Journal of Symbolic Logic 65(2), 525–549 (2000)zbMATHCrossRefMathSciNetGoogle Scholar
  29. 29.
    Capretta, V.: A polymorphic representation of induction-recursion. Note of 9 pages available on the author’s web page (a second 15 pages version of May 2005 has been seen by the present author) (March 2004)Google Scholar
  30. 30.
    Mac Lane, S.: Categories for the Working Mathematician, 2nd edn. Graduate Texts in Mathematics, vol. 5. Springer, Heidelberg (1998)zbMATHGoogle Scholar
  31. 31.
    Matthes, R.: Recursion on nested datatypes in dependent type theory. In: Beckmann, A., Dimitracopoulos, C., Löwe, B. (eds.) Logic and Theory of Algorithms. LNCS, vol. 5028. Springer, Heidelberg (to appear, 2008)CrossRefGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2008

Authors and Affiliations

  • Ralph Matthes
    • 1
  1. 1.Institut de Recherche en Informatique de Toulouse (IRIT)C. N. R. S. et Université Paul Sabatier (Toulouse III)Toulouse Cedex 9 

Personalised recommendations