Advertisement

LISP and Symbolic Computation

, Volume 6, Issue 3–4, pp 289–360 | Cite as

Reasoning about programs in continuation-passing style

  • AMR Sabry
  • Matthias Felleisen
Article

Abstract

Plotkin's λ v -calculus for call-by-value programs is weaker than the λβη-calculus for the same programs in continuation-passing style (CPS). To identify the call-by-value axioms that correspond to βη on CPS terms, we define a new CPS transformation and an inverse mapping, both of which are interesting in their own right. Using the new CPS transformation, we determine the precise language of CPS terms closed under βη-transformations, as well as the call-by-value axioms that correspond to the so-called administrative βη-reductions on CPS terms. Using the inverse mapping, we map the remaining β and η equalities on CPS terms to axioms on call-by-value terms. On the pure (constant free) set of Λ-terms, the resulting set of axioms is equivalent to Moggi's computational λ-calculus. If the call-by-value language includes the control operatorsabort andcall-with-current-continuation, the axioms are equivalent to an extension of Felleisenet al.'s λ v -C-calculus and to the equational subtheory of Talcott's logic IOCC.

Keywords

λ-calculus λv-calculus continuation-passing style CPS transformations inverse CPS transformations λv-C-calculus IOCC 

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Allison, L.A Practical Introduction to Denotational Semantics. Volume 23 ofCambridge Computer Science Texts, Cambridge University Press (1986).Google Scholar
  2. 2.
    Appel, A.Compiling with Continuations. Cambridge University Press (1992).Google Scholar
  3. 3.
    Appel, A. and Jim, T. Continuation-passing, closure-passing style. InConference Record of the 16th ACM Symposium on Principles of Programming Languages (1989) 293–302.Google Scholar
  4. 4.
    Barendregt, H. P.The Lambda Calculus: Its Syntax and Semantics. Volume 103 ofStudies in Logic and the Foundations of Mathematics, North-Holland, revised edition (1984).Google Scholar
  5. 5.
    Bartley, D. H. and Jensen, J. C. The implementation of PC Scheme. InProceedings of the ACM Conference on Lisp and Functional Programming (1986) 86–93.Google Scholar
  6. 6.
    Boehm, H.-J. and Demers, A. Implementing Russel. InProceedings of the ACM Sigplan Symposium on Compiler Construction, Sigplan Notices, 21, 7 (1986) 186–195.Google Scholar
  7. 7.
    Bondorf, A. Improving binding times without explicit CPS-conversion. InProceedings of the ACM Conference on Lisp and Functional Programming (1992) 1–10.Google Scholar
  8. 8.
    Clinger, W., Friedman, D., and Wand, M. A scheme for a higher-level semantic algebra. In Reynolds, J. and Nivat, M., editors,Algebraic Methods in Semantics, Cambridge University Press (1985) 237–250.Google Scholar
  9. 9.
    Crank, E. and Felleisen, M. Parameter-passing and the lambda calculus. InConference Record of the 18th ACM Symposium on Principles of Programming Languages (1991) 233–244.Google Scholar
  10. 10.
    Curry, H. B. and Feys, R.Combinatory Logic, Volume I. North-Holland, Amsterdam (1958).Google Scholar
  11. 11.
    Danvy, O. Back to direct style.Science of Computer Programming (1993). To appear. Preliminary version in: Proceedings of the 4th European Symposium on Programming, 1992. Lecture Notes in Computer Science, 582, Springer Verlag.Google Scholar
  12. 12.
    Danvy, O. and Filinski, A. Abstracting control. InProceedings of the ACM Conference on Lisp and Functional Programming (1990) 151–160.Google Scholar
  13. 13.
    Danvy, O. and Filinski, A. Representing control: A study of the CPS transformation.Mathematical Structures in Computer Science, 2, 4 (1992) 361–391.Google Scholar
  14. 14.
    Danvy, O. and Lawall, J. Back to direct style II: First-class continuations. InProceedings of the ACM Conference on Lisp and Functional Programming (1992) 299–310.Google Scholar
  15. 15.
    Felleisen, M. The theory and practice of first-class prompts. InConference Record of the 15th ACM Symposium on Principles of Programming Languages (1988) 180–190.Google Scholar
  16. 16.
    Felleisen, M. and Friedman, D. P. Control operators, the SECD-machine, and the λ-calculus. In Wirsing, M., editor,Formal Description of Programming Concepts-III, North-Holland (1986) 193–217.Google Scholar
  17. 17.
    Felleisen, M. and Friedman, D. P. A syntactic theory of sequential state.Theoretical Computer Science, 69, 3 (1989) 243–287. Preliminary version in: Conference Record of the 14th ACM Symposium on Principles of Programming Languages, 1987.Google Scholar
  18. 18.
    Felleisen, M. and Hieb, R. The revised report on the syntactic theories of sequential control and state.Theoretical Computer Science, 102 (1992) 235–271. Technical Report 89–100, Rice University.Google Scholar
  19. 19.
    Felleisen, M., Friedman, D. P., Kohlbecker, E., and Duba, B. A syntactic theory of sequential control.Theoretical Computer Science, 52, 3 (1987) 205–237. Preliminary version: Reasoning with Continuations, in Proceedings of the 1st IEEE Symposium on Logic in Computer Science. 1986.Google Scholar
  20. 20.
    Felleisen, M., Wand, M., Friedman, D.P., and Duba, B.F. Abstract continuations: A mathematical semantics for handling full functional jumps. InProceedings of the ACM Conference on Lisp and Functional Programming (1988) 52–62.Google Scholar
  21. 21.
    Fischer, M. Lambda calculus schemata. InProceedings of the ACM Conference on Proving Assertions About Programs, Sigplan Notices, 7, 1 (1972) 104–109. Expanded version inLISP and Symbolic Computation (this issue).Google Scholar
  22. 22.
    Flanagan, C., Sabry, A., Duba, B. F., and Felleisen, M. The essence of compiling with continuations. InProceedings of the ACM Sigplan Conference on Programming Language Design and Implementation (1993). To appear.Google Scholar
  23. 23.
    Friedman, D. P., Haynes, C.T., and Kohlbecker, E. Programming with continuations. In Pepper, P., editor,Program Transformations and Programming Environments, Springer-Verlag (1985) 263–274.Google Scholar
  24. 24.
    Friedman, D. P., Wand, M., and Haynes, C.T.Essentials of Programming Languages. The MIT Press (1992).Google Scholar
  25. 25.
    Galbiati, L. and Talcott, C. L. A simplifier for untyped lambda expressions. InProceedings Conditional Term Rewriting Systems, Lecture Notes in Computer Science, 516 (1990) 342–353.Google Scholar
  26. 26.
    Griffin, T.G. A formulae-as-type notion of control. InConference Record of the 17th ACM Symposium on Principles of Programming Languages (1990) 47–58.Google Scholar
  27. 27.
    Haynes, C.T., Friedman, D. P., and Wand, M. Obtaining coroutines from continuations.Journal of Computer Languages (Pergamon Press), 11, 3/4 (1986) 143–153.Google Scholar
  28. 28.
    Hieb, R., Dybvig, K., and Bruggeman, C. Representing control in the presence of first-class continuations. InProceedings of the ACM Sigplan Conference on Programming Language Design and Implementation (1990) 66–77.Google Scholar
  29. 29.
    Kelsey, R. and Hudak, P. Realistic compilation by program transformation. InConference Record of the 16th ACM Symposium on Principles of Programming Languages (1989) 281–292.Google Scholar
  30. 30.
    Kranz, D., Kelsey, R., Rees, J., Hudak, P., Philbin, J., and Adams, N. Orbit: An otpimizing compiler for Scheme. InProceedings of the ACM Sigplan Symposium on Compiler Construction, Sigplan Notices, 21, 7 (1986) 219–233.Google Scholar
  31. 31.
    Landin, P.J. The mechanical evaluation of expressions.Computer Journal, 6, 4 (1964) 308–320.Google Scholar
  32. 32.
    Leroy, X.The Zinc Experiment: An Economical Implementation of the ML Language. Technical Report 117, INRIA (1990).Google Scholar
  33. 33.
    Mason, I. and Talcott, C. L. Equivalence in functional languages with effects.Journal of Functional Programming, 1, 3 (July 1991) 287–327.Google Scholar
  34. 34.
    Mazurkiewicz, A. W. Proving algorithms by tail functions.Information and Control, 18 (1971) 220–226.Google Scholar
  35. 35.
    Meyer, A. R. and Wand, M. Continuation semantics in typed lambdacalculi. InProceedings Workshop Logics of Programs, Lecture Notes in Computer Science, 193 (1985) 219–224.Google Scholar
  36. 36.
    Moggi, E. Computational lambda-calculus and monads. InProceedings of the 4th IEEE Symposium on Logic in Computer Science (1989) 14–23. Also appeared as: LFCS Report ECS-LFCS-88-86, University of Edinburgh, 1988.Google Scholar
  37. 37.
    Morris, L. The next 700 formal language descriptions.Lisp and Functional Programming (1993). In this issue. Original manuscript dated November 1970.Google Scholar
  38. 38.
    Nielson, F. A denotational framework for data flow analysis.Acta Informatica, 18 (1982) 265–287.Google Scholar
  39. 39.
    Plotkin, G.D. Call-by-name, call-by-value, and the λ-calculus.Theoretical Computer Science, 1 (1975) 125–159.Google Scholar
  40. 40.
    Rees, J. and Clinger, W. Revised3 report on the algorithmic language Scheme.Sigplan Notices, 21, 12 (1986) 37–79.Google Scholar
  41. 41.
    Reynolds, J. C. Definitional interpreters for higher-order programming languages. InProceedings of the ACM Annual Conference (1972) 717–740.Google Scholar
  42. 42.
    Sabry, A. and Felleisen, M. Reasoning about programs in continuationpassing style. InProceedings of the ACM Conference on Lisp and Functional Programming (1992) 288–298. Technical Report 92–180, Rice University.Google Scholar
  43. 43.
    Shivers, O.Control-Flow Analysis of Higher-Order Languages or Taming Lambda. PhD thesis, Carneige-Mellon University (1991).Google Scholar
  44. 44.
    Sitaram, D. and Felleisen, M. Reasoning with continuations II: Full abstraction for models of control. InProceedings of the ACM Conference on Lisp and Functional Programming (1990) 161–175.Google Scholar
  45. 45.
    Steel, T.B., editor.Formal Language Description Languages for Computer Programming. North-Holland (1966).Google Scholar
  46. 46.
    Steele Jr., Guy L.Rabbit: A Compiler for Scheme. MIT AI Memo 474. Massachusetts Institute of Technology (1978).Google Scholar
  47. 47.
    Strachey, C. and Wadsworth, C.P.Continuations: A Mathematical Semantics for Handling Full Jumps. Technical Monograph PRG-11, Oxford University Computing Laboratory, Programming Research Group (1974).Google Scholar
  48. 48.
    Talcott, C. L. A theory for program and data specification.Theoretical Computer Science, 104 (1992) 129–159. Preliminary version in Proceedings of the International Symposium on Design and Implementation of Symbolic Computation Systems, (Lecture Notes in Computer Science, 429, 1990).Google Scholar
  49. 49.
    Wand, M. Correctness of procedure representations in higher-order assembly language. In Brookes, S., editor,Proceedings of the Conference on the Mathematical Foundations of Programing Semantics, Lecture Notes in Computer Science, 598, Springer Verlag (1992) 294–311.Google Scholar

Copyright information

© Kluwer Academic Publishers 1993

Authors and Affiliations

  • AMR Sabry
    • 1
  • Matthias Felleisen
    • 1
  1. 1.Department of Computer ScienceRice UniversityHouston

Personalised recommendations