Skip to main content

Advertisement

CPS Translations and Applications: The Cube and Beyond

  • Published:
Higher-Order and Symbolic Computation

Abstract

Continuation passing style (CPS) translations of typed λ-calculi have numerous applications. However, the range of these applications has been confined by the fact that CPS translations are known for non-dependent type systems only, thus excluding well-known systems like the calculus of constructions (CC) and the logical frameworks (LF). This paper presents techniques for CPS translating systems with dependent types, with an emphasis on pure type-theoretical applications.

In the first part of the paper we review several lines of work in which the need for CPS translations of dependent type systems has arisen, and discuss the difficulties involved with CPS translating such systems. One way of overcoming these difficulties is to work with so-called domain-free type systems. Thus, instead of Barendregt's λ-cube we shall consider the domain-free λ-cube, and instead of traditional pure type systems, we shall consider domain-free pure type systems.

We therefore begin the second part by reviewing the domain-free λ-cube, which includes domain-free versions of CC and LF, and then present CPS translations for all the systems of the domain-free λ-cube. We also introduce Direct Style (DS) (i.e., inverse CPS) translations for all the systems of the domain-free λ-cube; such DS translations, which have been used in a number of applications, were previously formulated for untyped and simply-typed languages only.

In the third part we review domain-free pure type systems and generalize the CPS translations of the domain-free λ-cube to a large class of domain-free pure type systems which includes most of the systems that appear in the literature, including those of the domain-free λ-cube. Many translations that appear in the literature arise as special cases of ours.

In the fourth part of the paper we present two approaches to CPS translations of traditional pure type systems. The first, indirect, technique lifts the CPS translation of domain-free pure type systems to the analogous class of traditional pure type systems by using results that relate derivations in domain-free and traditional pure type systems. The second, direct, approach translates derivations, requiring a certain order on derivations to be well-founded. Both techniques yield translations for most of the systems that appear in the literature, including those of Barendregt's λ-cube.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Subscribe and save

Springer+ Basic
$34.99 /Month
  • Get 10 units per month
  • Download Article/Chapter or eBook
  • 1 Unit = 1 Article or 1 Chapter
  • Cancel anytime
Subscribe now

Buy Now

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Similar content being viewed by others

References

  1. Appel, A. Compiling with Continuations. Cambridge University Press, 1992.

  2. Augustsson, L. Cayenne: A programming language with dependent types. In Proceedings of the 1998 ACM SIGPLAN International Conference on Functional Programming. Baltimore, Maryland, 1998, ACM Press, pp. 239–250.

  3. Barendregt, H.P. The Lambda Calculus--Its Syntax and Semantics. North-Holland, 1984.

  4. Barendregt, H.P. Lambda calculi with types. In Handbook of Logic in Computer Science, S. Abramsky, D.M. Gabbay, and T.S.E. Maibaum (Eds.). Vol. 2, Oxford Science Publications, 1992, pp. 117–309.

  5. Barthe, G., Hatcliff, J., and Sørensen, M.H. CPS-translation and applications: The cube and beyond. In Proceedings of the Second ACM SIGPLAN Workshop on Continuations, O. Danvy (Ed.), number NS-96-13 in BRICS Notes, 1996, pp. 4/1–4/31.

  6. Barthe, G., Hatcliff, J., and Sørensen, M.H. A notion of classical pure type system. In Proceedings of the Thirteenth Annual Conference on the Mathematical Foundations of Programming Semantics, S. Brookes and M. Mislove (Eds.). Pittsburgh, Pennsylvania, March 1997. Electronic Notes in Theoretical Computer Science, vol. 6.

  7. Barthe, G., Hatcliff, J., and Sørensen, M.H.Weak Normalization Implies Strong Normalization in Generalized Non-Dependent Pure Type Systems. March 1997, submitted for publication.

  8. Barthe, G., Hatcliff, J., and Sørensen, M.H. Reflections on reflections. In Proceedings of the Ninth International Symposium on Programming Languages, Implementations, Logics and Programs, H. Glaser, P. Hartel, and H. Kuchen (Eds.). Southampton, United Kingdom, September 1997. Lecture Notes in Computer Science, vol. 1292, Springer-Verlag, pp. 241–258.

  9. Barthe, G., Hatcliff, J., and Sørensen, M.H. An Induction Principle for Pure Type Systems. March 1998, submitted for publication.

  10. Barthe, G., Hatcliff, J., and Sørensen, M.H. A taxonomy of CPS and DS translations. Technical Report TR 98-11, Department of Computing and Information Sciences, Kansas State University, 1988.

  11. Barthe, G., Hatcliff, J., and Thiemann, P. Monadic type systems: Pure type systems for impure settings. In Proceedings of the Second Workshop on Higher-Order Operational Techniques in Semantics (HOOTS II), A. Gordon, A. Pitts, and C. Talcott (Eds.). Stanford, California, December 1997. Electronic Notes in Theoretical Computer Science, vol. 10.

  12. Barthe, G. and Sørensen, M.H. Domain-free pure type systems. In Proceedings of Logical Foundations of Computer Science LFCS'97, S. Adian and A. Nerode (Eds.), Yaroslav, Russia, July 1997. Lecture Notes in Computer Science, vol. 1234, Springer-Verlag, pp. 9–20.

  13. Berardi, S. Type Dependence and Constructive Mathematics. Ph.D. Thesis. University of Torino, 1990.

  14. Consel, C. and Danvy, O. For a better support of static data flow. In Conference on Functional Programming and Computer Architecture, J. Hughes (Ed.). 1991. Lecture Notes in Computer Science, vol. 523, Springer-Verlag, pp. 495–519.

  15. Coquand, T. and Herbelin, H. A-translation and looping combinators in pure type systems. Journal of Functional Programming, 4(1):77–88, 1994.

    Google Scholar 

  16. Curry, H.B. and Feys, R. Combinatory Logic. North-Holland, 1958.

  17. Danvy, O. Back to direct style. Science of Computer Programming, 22(3):183–195, 1994.

    Google Scholar 

  18. Danvy, O. and Filinski, A. Representing control, a study of the CPS transformation. Mathematical Structures in Computer Science, 2(4):361–391, 1992.

    Google Scholar 

  19. Danvy, O. and Lawall, J. Back to direct style II: First-class continuations. In Proceedings of the 1992 ACM Conference on Lisp and Functional Programming. San Francisco, California, June 1992. ACM Press, LISP Pointers, V(1):299–310.

    Google Scholar 

  20. Dowek, G., Huet, G., and Werner, B. On the existence of long βη-normal forms in the cube. In Informal Proceedings of TYPES'93, H. Geuvers (Ed.). Nijmegen, The Netherlands, May 1993, pp. 115–130.

    Google Scholar 

  21. Dussart, D., Hughes, J., and Thiemann, P. Type specialisation for imperative languages. In Proceedings of the 1997 ACM SIGPLAN International Conference on Functional Programming. Amsterdam, The Netherlands, June 1997. ACM Press, pp. 204–216.

  22. Felleisen, M. The Calculi of λ υ -CS Conversion: A Syntactic Theory of Control and State in Imperative Higher Order Programming Languages. Ph.D. Thesis. Indiana University, 1987.

  23. Felleisen, M. and Friedman, D. Control operators, the SECD machine, and the λ;-calculus. In Formal Description of Programming Concepts III, M. Wirsing (Ed.), North-Holland, 1986, pp. 193–217.

  24. Felleisen, M., Friedman, D., Kohlbecker, E., and Duba, B.Asyntactic theory of sequential control. Theoretical Computer Science, 52(3):205–237, 1987.

    Google Scholar 

  25. Flanagan, C., Sabry, A., Duba, B., and Felleisen, M. The essence of compiling with continuations. In Proceedings of the ACM SIGPLAN'93 Conference on Programming Language Design and Implementation. Albuquerque, New Mexico, June 1993, pp. 237–247, SIGPLAN Notices 28(6).

    Google Scholar 

  26. Friedman, D., Wand, M., and Haynes, C. Essentials of Programming Languages. MIT Press and McGraw-Hill, 1991.

  27. Gandy, R.O. An early proof of normalization by A.M. Turing. In J.P. Seldin and J.R. Hindley, Academic Press Limited, 1980, pp. 453–455.

  28. Geuvers, H. Logics and Type Systems. Ph.D. Thesis. University of Nijmegen, 1993.

  29. Geuvers, H. and Nederhof, M.J. A modular proof of strong normalisation for the Calculus of Constructions. Journal of Functional Programming, 1:155–189, 1991.

    Google Scholar 

  30. Girard, J.-Y. Interprétation fonctionnelle et élimination des coupures dans l'arithmétique d'ordre supérieur. Thèse d'Etat. Université Paris VII, 1972.

  31. Griffin, T.G. A formulae-as-types notion of control. In Conference Record of the Annual ACM Symposium on Principles of Programming Languages. San Francisco, California, January 1990. ACM Press, pp. 47–58.

  32. de Groote, P. The conservation theorem revisited. In Typed Lambda Calculus and Applications, M. Bezem and J.F. Groote (Eds.). Utrecht, The Netherlands, March 1993. Lecture Notes in Computer Science, vol. 664, Springer-Verlag, pp. 163–178.

    Google Scholar 

  33. Harper, R., Honsell, F., and Plotkin, G. A framework for defining logics. Journal of the ACM, 40(1):143–84, 1993.A PreliminaryVersion Appeared in the Proceedings of the First IEEE Symposium on Logic in Computer Science, June 1987, pp. 194–204.

    Google Scholar 

  34. Harper, R. and Lillibridge, M. Explicit polymorphism and CPS conversion. In Conference Record of the Twentieth Annual ACM Symposium on Principles of Programming Languages. Charleston, South Carolina, January 1993, ACM Press, pp. 206–219.

  35. Harper, R. and Lillibridge, M. Polymormphic type assignment and CPS conversion. LISP and Symbolic Computation, 6:361–380, 1993.

    Google Scholar 

  36. Harper, R. and Mitchell, J.C. On the type structure of Standard ML. ACM Transactions on Programming Languages and Systems, 15(2):211–252, 1993.

    Google Scholar 

  37. Harper, R. and Morrisett, G. Compiling polymorphism using intensional type analysis. In Conference Record of the Twenty-Second Annual ACM Symposium on Principles of Programming Languages. San Francisco, California, January 1995, ACM Press, pp. 130–141.

  38. Hatcliff, J. Foundations of partial evaluation of functional programs with computational effects. In Symposium on Partial Evaluation, O. Danvy, R. Glück, and P. Thiemann (Eds.). September 1998 ACM Computing Surveys, vol. 30.

  39. Hatcliff, J. and Danvy, O. A generic account of continuation-passing styles. In Conference Record of the Twenty-First Annual ACM Symposium on Principles of Programming Languages. Portland, Oregon, January 1994, ACM Press, pp. 458–471.

  40. Hatcliff, J. and Danvy, O. A computational formalization for partial evaluation. Mathematical Structures in Computer Science, 7:507–541, 1997. Special issue devoted to selected papers from the Workshop on Logic, Domains, and Programming Languages. Darmstadt, Germany, May 1995.

    Google Scholar 

  41. Hindley, J.R. and Seldin, J.P. Introduction to Combinators and λ-Calculus. Cambridge University Press, 1986.

  42. Howard, W. The formulae-as-types notion of construction. In T.H.B. Curry: Essays on Combinatory Logic, Lambda, Calculus and Formalism, J.P. Seldin and J.R. Hindley, Academic Press Limited, 1980, pp. 479–490.

  43. Lawall, J. and Thiemann, P. Sound specialization in the presence of computational effects. In Proceedings of Theoretical Aspects of Computer Software, M. Abadi and T. Ito (Eds.). Sendai, Japan, September 1997. Lecture Notes in Computer Science, vol. 1281, Springer-Verlag, pp. 165–190.

    Google Scholar 

  44. Longo, G. and Moggi, E. Constructive natural deduction and its ‘ώ-set’ interpretation. Mathematical Structures in Computer Science, 1(2):215–254, 1991.

    Google Scholar 

  45. Meijer, E. and Peyton Jones, S. Henk: A typed intermediate language. In Proceedings of the ACM SIGPLAN Workshop on Types in Compilation, Amsterdam, The Netherlands, June 1997.

  46. Meyer, A.R. and Wand, M. Continuation semantics in typed lambda-calculi (summary). In Logics of Programs, R. Parikh (Ed.). Lecture Notes in Computer Science, vol. 193, Springer-Verlag, 1985, pp. 219–224.

  47. Minamide, Y., Morrisett, G., and Harper, R. Typed closure conversion. In Conference Record of the Twentythird Annual ACM Symposium on Principles of Programming Languages. St. Petersburg, Florida, January 1996, ACM Press, pp. 271–283.

  48. Murthy, C. Extracting Constructive Contents from Classical Proofs. Ph.D. Thesis, Cornell University, 1990.

  49. Nielsen, K. and Sørensen, M.H. Call-by-name CPS-translation as a binding-time improvement. In Static Analysis Symposium, A. Mycroft (Ed.). Glasgow, Scotland, September 1995. Lecture Notes in Computer Science, Springer-Verlag, vol. 983, pp. 296–313.

  50. Peyton Jones, S.L. The Implementation of Functional Programming Languages. Prentice Hall International. 1987.

  51. Peyton Jones, S.L., Hall, C., Hammond, K., Partain, W., and Wadler, P. The Glasgow Haskell compiler: A technical overview. In Proceedings of the UK Joint Framework for Information Technology (JFIT) Technical Conference, Keele, 1993.

  52. Plotkin, G. Call-by-name, call-by-value and the λ-calculus. Theoretical Computer Science, 1:125–159, 1975.

    Google Scholar 

  53. Prawitz, D. Natural Deduction: A Proof Theoretical Study. Almquist & Wiksell, 1965.

  54. Prawitz, D. Ideas and results of proof theory. In The 2nd Scandinavian Logical Symposium, J.E. Fenstad (Ed.). North-Holland, 1970, pp. 235–307.

  55. Rehof, N.J. and Sørensen, M.H. The λΔ calculus. In Theoretical Aspects of Computer Software, M. Hagiya and J. Mitchell (Eds.). Sendai, Japan, April 1994. Lecture Notes in Computer Science, vol. 789, Springer-Verlag, pp. 516–542.

    Google Scholar 

  56. Reynolds, J.C. Definitional interpreters for higher-order programming languages. Higher-Order and Symbolic Computation 11(4):7–105, 1998. Reprinted from the proceedings of the 25thACMNational Conference, 1972.

    Google Scholar 

  57. Sabry, A. Note on Axiomatizing the Semantics of Control Operators. Technical Report CIS-TR-96-03. Department of Computer and Information Science, University of Oregon, 1996.

  58. Sabry, A. and Felleisen, M. Reasoning about programs in continuation-passing style. Lisp and Symbolic Computation, 6:289–360, 1993.

    Google Scholar 

  59. Sabry, A. and Felleisen, M. Is continuation passing useful for data-flow analysis? In Proceedings of the ACM SIGPLAN'94 Conference on Programming Language Design and Implementation, Orlando, Florida, June 1994, pp. 1–12. SIGPLAN Notices 29(6).

    Google Scholar 

  60. Sabry, A. and Wadler, P. A reflection on call-by-value. ACM Transactions on Programming Languages and Systems, 19(6):916–941, 1997. Earlier version in the proceedings of the 1996 International Conference on Functional Programming.

    Google Scholar 

  61. Schmidt, D.A. Denotational Semantics: A Methodology for Language Development. Allyn and Bacon, Inc., 1986.

  62. Seldin, J.P. Normalization and excluded middle I. Studia Logica, XLVIII(2):193–217, 1989.

    Google Scholar 

  63. Seldin, J.P. and Hindley, J.R. (Eds.). To H.B. Curry: Essays on Combinatory Logic, Lambda Calculus and Formalism. Academic Press Limited, 1980.

  64. Shao, Z. and Appel, A.W. A type-based compiler for Standard ML. In Proceedings of the ACM SIGPLAN'95 Conference on Programming Language Design and Implementation, La Jolla, California, June 1995, pp. 116–129, SIGPLAN Notices 30(6).

    Google Scholar 

  65. Shivers, O. Control-Flow Analysis of Higher-Order Languages. Ph.D. Thesis. Carnegie Mellon University, 1991.

  66. Sørensen, M.H. Strong normalization from weak normalization in typed λ-calculi. Information and Computation, 133(1):35–71, 1997.

    Google Scholar 

  67. Stålmarck, G. Normalization theorems for full first order classical natural deduction. Journal of Symbolic Logic, 56(1):129–149, 1991.

    Google Scholar 

  68. Steele, G.L., Jr. Rabbit: A compiler for scheme. Technical Report AI-TR-474, Artificial Intelligence Laboratory, Massachusetts Institute of Technology, Cambridge, Massachusetts, May 1978.

    Google Scholar 

  69. Tait, W.W. Intensional interpretations of functionals of finite type I. Journal of Symbolic Logic, 32(2):190–212, 1967.

    Google Scholar 

  70. Tait, W.W. Arealizability interpretation of the theory of species. In Logic Colloquium, R. Parikh (Ed.). Lecture Notes in Mathematics, vol. 453, Springer-Verlag, 1975, pp. 240–251.

  71. Tarditi, D., Morrisett, G., Cheng, P., Stone, C., Harper, R., and Lee, P. TIL: A type-directed optimizing compiler for ML. In Proceedings of the ACM SIGPLAN' 96 Conference on Programming Language Design and Implementation, Philadelphia, Pennsylvania, May 1996, pp. 181–192. SIGPLAN Notices 31(5).

    Google Scholar 

  72. Terlouw, J. Een Nadere Bewijstheoretische Analyse van GSTT's. Manuscript (in Dutch), 1989.

  73. Werner, B. Continuations, Evaluation Styles and Types Systems. Manuscript, 1992.

  74. Xi, H. Weak and strong normalizations in typed λ-calculi. In Proceedings of TLCA'97, P. de Groote and J. Hindley (Eds.). Nancy, France, Lecture Notes in Computer Science, vol. 1210, Springer-Verlag, April 1997, pp. 390–404.

  75. Xi, H. and Pfenning, F. Eliminating array bound checking through dependent types. In Proceedings of the ACM SIGPLAN'98 Conference on Programming Languages Design and Implementation, Montréal, Canada, June 1998, pp. 249–257. SIGPLAN Notices 33(5).

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Rights and permissions

Reprints and permissions

About this article

Cite this article

Barthe, G., Hatcliff, J. & Sørensen, M.H.B. CPS Translations and Applications: The Cube and Beyond. Higher-Order and Symbolic Computation 12, 125–170 (1999). https://doi.org/10.1023/A:1010000206149

Download citation

  • Issue Date:

  • DOI: https://doi.org/10.1023/A:1010000206149