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.
Similar content being viewed by others
References
Appel, A. Compiling with Continuations. Cambridge University Press, 1992.
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.
Barendregt, H.P. The Lambda Calculus--Its Syntax and Semantics. North-Holland, 1984.
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.
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.
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.
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.
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.
Barthe, G., Hatcliff, J., and Sørensen, M.H. An Induction Principle for Pure Type Systems. March 1998, submitted for publication.
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.
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.
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.
Berardi, S. Type Dependence and Constructive Mathematics. Ph.D. Thesis. University of Torino, 1990.
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.
Coquand, T. and Herbelin, H. A-translation and looping combinators in pure type systems. Journal of Functional Programming, 4(1):77–88, 1994.
Curry, H.B. and Feys, R. Combinatory Logic. North-Holland, 1958.
Danvy, O. Back to direct style. Science of Computer Programming, 22(3):183–195, 1994.
Danvy, O. and Filinski, A. Representing control, a study of the CPS transformation. Mathematical Structures in Computer Science, 2(4):361–391, 1992.
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.
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.
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.
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.
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.
Felleisen, M., Friedman, D., Kohlbecker, E., and Duba, B.Asyntactic theory of sequential control. Theoretical Computer Science, 52(3):205–237, 1987.
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).
Friedman, D., Wand, M., and Haynes, C. Essentials of Programming Languages. MIT Press and McGraw-Hill, 1991.
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.
Geuvers, H. Logics and Type Systems. Ph.D. Thesis. University of Nijmegen, 1993.
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.
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.
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.
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.
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.
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.
Harper, R. and Lillibridge, M. Polymormphic type assignment and CPS conversion. LISP and Symbolic Computation, 6:361–380, 1993.
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.
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.
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.
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.
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.
Hindley, J.R. and Seldin, J.P. Introduction to Combinators and λ-Calculus. Cambridge University Press, 1986.
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.
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.
Longo, G. and Moggi, E. Constructive natural deduction and its ‘ώ-set’ interpretation. Mathematical Structures in Computer Science, 1(2):215–254, 1991.
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.
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.
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.
Murthy, C. Extracting Constructive Contents from Classical Proofs. Ph.D. Thesis, Cornell University, 1990.
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.
Peyton Jones, S.L. The Implementation of Functional Programming Languages. Prentice Hall International. 1987.
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.
Plotkin, G. Call-by-name, call-by-value and the λ-calculus. Theoretical Computer Science, 1:125–159, 1975.
Prawitz, D. Natural Deduction: A Proof Theoretical Study. Almquist & Wiksell, 1965.
Prawitz, D. Ideas and results of proof theory. In The 2nd Scandinavian Logical Symposium, J.E. Fenstad (Ed.). North-Holland, 1970, pp. 235–307.
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.
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.
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.
Sabry, A. and Felleisen, M. Reasoning about programs in continuation-passing style. Lisp and Symbolic Computation, 6:289–360, 1993.
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).
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.
Schmidt, D.A. Denotational Semantics: A Methodology for Language Development. Allyn and Bacon, Inc., 1986.
Seldin, J.P. Normalization and excluded middle I. Studia Logica, XLVIII(2):193–217, 1989.
Seldin, J.P. and Hindley, J.R. (Eds.). To H.B. Curry: Essays on Combinatory Logic, Lambda Calculus and Formalism. Academic Press Limited, 1980.
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).
Shivers, O. Control-Flow Analysis of Higher-Order Languages. Ph.D. Thesis. Carnegie Mellon University, 1991.
Sørensen, M.H. Strong normalization from weak normalization in typed λ-calculi. Information and Computation, 133(1):35–71, 1997.
Stålmarck, G. Normalization theorems for full first order classical natural deduction. Journal of Symbolic Logic, 56(1):129–149, 1991.
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.
Tait, W.W. Intensional interpretations of functionals of finite type I. Journal of Symbolic Logic, 32(2):190–212, 1967.
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.
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).
Terlouw, J. Een Nadere Bewijstheoretische Analyse van GSTT's. Manuscript (in Dutch), 1989.
Werner, B. Continuations, Evaluation Styles and Types Systems. Manuscript, 1992.
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.
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).
Author information
Authors and Affiliations
Rights 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
Issue Date:
DOI: https://doi.org/10.1023/A:1010000206149