Advertisement

Towards Generic Programming with Sized Types

  • Andreas Abel
Part of the Lecture Notes in Computer Science book series (LNCS, volume 4014)

Abstract

Instances of a polytypic or generic program for a concrete recursive type often exhibit a recursion scheme that is derived from the recursion scheme of the instantiation type. In practice, the programs obtained from a generic program are usually terminating, but the proof of termination cannot be carried out with traditional methods as term orderings alone, since termination often crucially relies on the program type. This problem is tackled by an adaption of type-based termination to generic programming, and a framework for sized polytypic programming is described.

Keywords

Generic Programming Inductive Type Recursion Scheme Type Constructor Primitive Recursion 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Abel, A.: Termination and guardedness checking with continuous types. In: Hofmann, M.O. (ed.) TLCA 2003. LNCS, vol. 2701, pp. 1–15. Springer, Heidelberg (2003)CrossRefGoogle Scholar
  2. 2.
    Abel, A.: Termination checking with types. Theor. Inform. and Appl. 38, 277–319 (2004)MATHCrossRefMathSciNetGoogle Scholar
  3. 3.
    Abel, A.: A Polymorphic Lambda-Calculus with Sized Higher-Order Types. PhD thesis, Ludwig-Maximilians-Universität München (2006), Draft available at: http://www.tcs.ifi.lmu.de/~abel/diss.pdf
  4. 4.
    Abel, A., Matthes, R., Uustalu, T.: Iteration schemes for higher-order and nested datatypes. Theor. Comput. Sci. 333, 3–66 (2005)MATHCrossRefMathSciNetGoogle Scholar
  5. 5.
    Altenkirch, T., McBride, C.: Generic programming within dependently typed programming. In: Gibbons, J., Jeuring, J. (eds.) Proc. of IFIP TC2/WG2.1 Working Conf. on Generic Programming, WCGP 2002. IFIP Conf. Proceedings, vol. 243, pp. 1–20. Kluwer, Dordrecht (2003)Google 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.
    Backhouse, R., Jansson, P., Jeuring, J., Meertens, L.: Generic programming — an introduction. In: Swierstra, S.D., Oliveira, J.N. (eds.) AFP 1998. LNCS, vol. 1608, pp. 28–115. Springer, Heidelberg (1999)CrossRefGoogle Scholar
  8. 8.
    Barthe, G., Frade, M.J., Giménez, E., Pinto, L., Uustalu, T.: Type-based termination of recursive definitions. Math. Struct. in Comput. Sci. 14, 1–45 (2004)CrossRefGoogle Scholar
  9. 9.
    Barthe, G., Grégoire, B., Pastawski, F.: Practical inference for type-based termination in a polymorphic setting. In: Urzyczyn, P. (ed.) TLCA 2005. LNCS, vol. 3461, pp. 71–85. Springer, Heidelberg (2005)CrossRefGoogle Scholar
  10. 10.
    Benke, M., Dybjer, P., Jansson, P.: Universes for generic programs and proofs in dependent type theory. Nord. J. of Comput. 10, 265–289 (2003)MATHMathSciNetGoogle Scholar
  11. 11.
    Bird, R., Meertens, L.: Nested datatypes. In: Jeuring, J. (ed.) MPC 1998. LNCS, vol. 1422, pp. 52–67. Springer, Heidelberg (1998)CrossRefGoogle Scholar
  12. 12.
    Bird, R., Paterson, R.: Generalised folds for nested datatypes. Formal Asp. Comput. 11, 200–222 (1999)MATHCrossRefGoogle Scholar
  13. 13.
    Bird, R.S., Paterson, R.: De Bruijn notation as a nested datatype. J. Funct. Program. 9, 77–91 (1999)MATHCrossRefMathSciNetGoogle Scholar
  14. 14.
    Blanqui, F.: A type-based termination criterion for dependently-typed higher-order rewrite systems. In: van Oostrom, V. (ed.) RTA 2004. LNCS, vol. 3091, pp. 24–39. Springer, Heidelberg (2004)CrossRefGoogle Scholar
  15. 15.
    Blanqui, F.: Decidability of Type-Checking in the Calculus of Algebraic Constructions with Size Annotations. In: Ong, L. (ed.) CSL 2005. LNCS, vol. 3634, pp. 135–150. Springer, Heidelberg (2005)CrossRefGoogle Scholar
  16. 16.
    Crary, K., Weirich, S.: Flexible type analysis. In: Proc.of 4th ACM SIGPLAN Int. Conf. on Functional Programming, ICFP 1999, pp. 233–248. ACM Press, New York (1999)CrossRefGoogle Scholar
  17. 17.
    Crary, K., Weirich, S., Morrisett, J.G.: Intensional polymorphism in type-erasure semantics. In: Proc. of 3rd ACM SIGPLAN Int. Conf. on Functional Programming, ICFP 1998, pp. 301–312. ACM Press, New York (1998)CrossRefGoogle Scholar
  18. 18.
    Frade, M.J.: Type-Based Termination of Recursive Definitions and Constructor Subtyping in Typed Lambda Calculi. PhD thesis, Dep. de Informática, Universidade do Minho (2003)Google Scholar
  19. 19.
    Giesl, J., Thiemann, R., Schneider-Kamp, P., Falke, S.: Automated termination proofs with AProVE. In: van Oostrom, V. (ed.) RTA 2004. LNCS, vol. 3091, pp. 210–220. Springer, Heidelberg (2004)CrossRefGoogle Scholar
  20. 20.
    Giménez, E.: Structural recursive definitions in type theory. In: Larsen, K.G., Skyum, S., Winskel, G. (eds.) ICALP 1998. LNCS, vol. 1443, pp. 397–408. Springer, Heidelberg (1998)CrossRefGoogle Scholar
  21. 21.
    Harper, R., Morrisett, J.G.: Compiling polymorphism using intensional type analysis. In: Conf. Record of 22nd ACM SIGPLAN-SIGACT Symp. on Principles of Programming Languages, POPL 1995, pp. 130–141. ACM Press, New York (1995)CrossRefGoogle Scholar
  22. 22.
    Hinze, R.: Numerical representations as higher-order nested datatypes. Technical Report IAI-TR-98-12, Institut für Informatik III, Universität Bonn (1998)Google Scholar
  23. 23.
    Hinze, R.: Polytypic programming with ease (extended abstract). In: Middeldorp, A. (ed.) FLOPS 1999. LNCS, vol. 1722, pp. 21–36. Springer, Heidelberg (1999)CrossRefGoogle Scholar
  24. 24.
    Hinze, R.: Generalizing generalized tries. J. of Funct. Program. 10, 327–351 (2000)MATHCrossRefMathSciNetGoogle Scholar
  25. 25.
    Hinze, R.: A new approach to generic functional programming. In: Proc. of 27th ACM SIGPLAN-SIGACT Symp. on Principles of Programming Languages, POPL 2000, pp. 119–132. ACM Press, New York (2000)CrossRefGoogle Scholar
  26. 26.
    Hinze, R.: Manufacturing datatypes. J. of Funct. Program. 11, 493–524 (2001)MATHMathSciNetGoogle Scholar
  27. 27.
    Hinze, R.: Polytypic values possess polykinded types. Sci. of Comput. Program. 43, 129–159 (2002)MATHCrossRefMathSciNetGoogle Scholar
  28. 28.
    Hinze, R., Jeuring, J.: Generic haskell: Applications. In: Backhouse, R., Gibbons, J. (eds.) Generic Programming. LNCS, vol. 2793, pp. 57–96. Springer, Heidelberg (2003)CrossRefGoogle Scholar
  29. 29.
    Hinze, R., Jeuring, J.: Generic haskell: Practice and theory. In: Backhouse, R., Gibbons, J. (eds.) Generic Programming. LNCS, vol. 2793, pp. 1–56. Springer, Heidelberg (2003)CrossRefGoogle Scholar
  30. 30.
    Hinze, R., Jeuring, J., Löh, A.: Type-indexed data types. Sci. of Comput. Program. 51, 117–151 (2004)MATHCrossRefGoogle Scholar
  31. 31.
    Hughes, J., Pareto, L., Sabry, A.: Proving the correctness of reactive systems using sized types. In: Conf. Record of 23rd ACM SIGPLAN-SIGACT Symp. on Principles of Programming Languages, POPL 1996, pp. 410–423. ACM Press, New York (1996)CrossRefGoogle Scholar
  32. 32.
    INRIA: The Coq Proof Assistant Reference Manual, version 8.0 edition (2004), http://coq.inria.fr/doc/main.html
  33. 33.
    Jansson, P.: Functional Polytypic Programming. PhD thesis, Dept. of Computing Science, Chalmers University of Technology (2000)Google Scholar
  34. 34.
    Jansson, P., Jeuring, J.: PolyP—a polytypic programming extension. In: Conf. Record of 24th ACM SIGPLAN-SIGACT Symp. on Principles of Programming Languages, POPL 1997, pp. 470–482. ACM Press, New York (1997)CrossRefGoogle Scholar
  35. 35.
    Jansson, P., Jeuring, J.: Polytypic data conversion programs. Sci. of Comput. Program. 43, 35–75 (2002)MATHCrossRefMathSciNetGoogle Scholar
  36. 36.
    Martin, C., Gibbons, J., Bayley, I.: Disciplined, efficient, generalised folds for nested datatypes. Formal Asp. of Comput. 16, 19–35 (2004)MATHCrossRefGoogle Scholar
  37. 37.
    Mendler, N.P.: Recursive types and type constraints in second-order lambda calculus. In: Proc. of 2nd Ann. IEEE Symp. on Logic in Computer Science, LICS 1987, pp. 30–36. IEEE Computer Soc. Press, Los Alamitos (1987)Google Scholar
  38. 38.
    Norell, U.: Functional Generic Programming and Type Theory. Master’s thesis, Computing Science, Chalmers University of Technology (2002), Available from: http://www.cs.chalmers.se/~ulfn
  39. 39.
    Norell, U., Jansson, P.: Polytypic programming in Haskell. In: Trinder, P., Michaelson, G.J., Peña, R. (eds.) IFL 2003. LNCS, vol. 3145, pp. 168–184. Springer, Heidelberg (2004)CrossRefGoogle Scholar
  40. 40.
    Norell, U., Jansson, P.: Prototyping generic programming in template haskell. In: Kozen, D. (ed.) MPC 2004. LNCS, vol. 3125, pp. 314–333. Springer, Heidelberg (2004)CrossRefGoogle Scholar
  41. 41.
    Okasaki, C.: Purely Functional Data Structures. Ph.D. thesis, Carnegie Mellon University (1996)Google Scholar
  42. 42.
    Okasaki, C.: From fast exponentiation to square matrices: An adventure in types. In: Proc. of 4th ACM SIGPLAN Int. Conf. on Functional Programming, ICFP 1999, pp. 28–35. ACM Press, New York (1999)CrossRefGoogle Scholar
  43. 43.
    Okasaki, C.: Red-black trees in a functional setting. J. of Funct. Program. 9, 471–477 (1999)MATHCrossRefGoogle Scholar
  44. 44.
    Pareto, L.: Types for Crash Prevention. PhD thesis, Dept. of Computing Science, Chalmers University of Technology (2000)Google Scholar
  45. 45.
    Pfeifer, H., Rueß, H.: Polytypic proof construction. In: Bertot, Y., Dowek, G., Hirschowitz, A., Paulin, C., Théry, L. (eds.) TPHOLs 1999. LNCS, vol. 1690, pp. 55–72. Springer, Heidelberg (1999)CrossRefGoogle Scholar
  46. 46.
    Pierce, B.C.: Types and Programming Languages. MIT Press, Cambridge (2002)Google Scholar
  47. 47.
    Saha, B., Trifonov, V., Shao, Z.: Intensional analysis of quantified types. ACM Trans. on Program. Lang. and Syst. 25, 159–209 (2003)CrossRefGoogle Scholar
  48. 48.
    Sereni, D., Jones, N.D.: Termination analysis of higher-order functional programs. In: Yi, K. (ed.) APLAS 2005. LNCS, vol. 3780, pp. 281–297. Springer, Heidelberg (2005)CrossRefGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2006

Authors and Affiliations

  • Andreas Abel
    • 1
  1. 1.Institut für InformatikLudwigs-Maximilians-Universität MünchenMünchenGermany

Personalised recommendations