Sound specialization in the presence of computational effects

  • Julia L. Lawall
  • Peter Thiemann
Session 2
Part of the Lecture Notes in Computer Science book series (LNCS, volume 1281)


Moggi's computational lambda calculus λc is a well-established model of computation. We define a two-level version λc of the computational lambda calculus and demonstrate that it is an inevitable description for sound specialization. We implement the calculus in terms of a standard two-level lambda calculus via a continuation-passing style transformation. This transformation is sound and complete with respect to λc; it forms a reflection in the two-level lambda calculus of λc. As a practical ramification of this work we show that several published specialization algorithms are unsound and develop a sound specializer similar to continuation-based specializers.


lambda calculus partial evaluation functional programming continuations 


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    H. P. Barendregt. The Lambda Calculus — Its Syntax and Semantics. NorthHolland, 1984.Google Scholar
  2. 2.
    Gilles Barthe, John Hatcliff, and Morten Heine Sørensen. Reflections on reflections. In Hugh Glaser and Herbert Kuchen, editors, Programming Languages, Implementations, Logics, and Programs (PLILP '97), volume ? of Lecture Notes in Computer Science, page To appear, Southampton, England, September 1996. Springer-Verlag.Google Scholar
  3. 3.
    Anders Bondorf. Improving binding-times without explicit CPS conversion. In Proc. 1992 ACM Conference on Lisp and Functional Programming, pages 1–10, San Francisco, California, USA, June 1992.Google Scholar
  4. 4.
    Anders Boudorf and Olivier Danvy. Automatic autoprojection of recursive equations with global variables and abstract data types. Science of Programming, 16(2):151–195, 1991.Google Scholar
  5. 5.
    Anders Bondorf and Dirk Dussart. Improving CPS-based partial evaluation: Writing cogen by hand. In Peter Sestoft and Harald Søndergaard, editors, Proc. ACM SIGPLAN Workshop on Partial Evaluation and Semantics-Based Program Manipulation PEPM '94, pages 1–10, Orlando, Fla., June 1994. ACM.Google Scholar
  6. 6.
    Anders Bondorf and Jesper Jørgensen. Efficient analyses for realistic off-line partial evaluation: Extended version. Technical Report 93/4, DIKU, University of Copenhagen, Denmark, 1993. extended version of [7].Google Scholar
  7. 7.
    Anders Bondorf and Jesper Jørgensen, Efficient analysis for realistic off-line partial evaluation. Journal of Functional Programming, 3(3):315–346, July 1993.Google Scholar
  8. 8.
    William Clinger and Jonathan Rees. Revised 4 report on the algorithmic language scheme. Al Memo 84ßb, MIT, 1991. Scholar
  9. 9.
    Charles Consel and Olivier Danvy. For a better support of static data flow. In John Hughes, editor, Proc. Functional Programming Languages and Computer Architecture 1991, volume 523 of Lecture Notes in Computer Science, pages 496–519, Cambridge, MA, 1991. Springer-Verlag.Google Scholar
  10. 10.
    Olivier Danvy. Back to direct style. Science of Programming, 22:183–195, 1994.Google Scholar
  11. 11.
    Olivier Danvy and Dirk Dussart. CPS transformation after binding-time analysis. Unpublished note, Computer Science Department, Aarhus University, April 1995.Google Scholar
  12. 12.
    B. A. Davey and H. A. Priestley. Introduction to Lattices and Order. Cambridge University Press, 1990.Google Scholar
  13. 13.
    Rowan Davies. A temporal-logic approach to binding-time analysis. In Proceedings, 11 th Annual IEEE Symposium on Logic in Computer Science, pages 184–195, New Brunswick, New Jersey, July 1996. IEEE Computer Society Press.Google Scholar
  14. 14.
    Rowan Davies and Frank Pfenning. A modal analysis of staged computation. In Proc. 23rd Annual ACM Symposium on Principles of Programming Languages, pages 258–270, St. Petersburg, Fla., January 1996. ACM Press.Google Scholar
  15. 15.
    Dirk Dussart and Eddy Bevers. CPS transformation after binding-time analysis (extended abstract). In Proceedings of the 7th Nordic Workshop on Programming Theory, pages 112–126, Göteborg, Sweden, November 1995.Google Scholar
  16. 16.
    Dirk Dussart and Peter Thiemann. Partial evaluation for higher-order languages with state. Berichte des Wilhelm-Schickard-Instituts WSI-97-XX, Universität Tübingen, April 1997.Google Scholar
  17. 17.
    R. Kent Dybvig, editor. International Conference on Functional Programming, Philadelphia, PA, May 1996. ACM Press, New York.Google Scholar
  18. 18.
    Cormac Flanagan, Amr Sabry, Bruce F. Duba, and Matthias Felleisen. The essence of compiling with continuations. In Proc. of the ACM SIGPLAN '93 Conference on Programming Language Design and Implementation, pages 237–247, Albuquerque, New Mexico, June 1993.Google Scholar
  19. 19.
    Robert Glück and Jesper Jørgensen. Efficient multi-level generating extensions for program specialization. In Swierstra and Hermenegildo [36], pages 259–278.Google Scholar
  20. 20.
    Carsten K. Gomard. A self-applicable partial evaluator for the lambda-calculus. ACM Transactions on Programming Languages and Systems, 14(2):147–172, 1992.Google Scholar
  21. 21.
    John Hatcliff. Mechanically verifying the correctness of an offline partial evaluator. In Swierstra and Hermenegildo [36], pages 279–298.Google Scholar
  22. 22.
    John Hatcliff and Olivier Danvy. A generic account of continuation-passing styles. In Proc. 21st Annual ACM Symposium on Principles of Programming Languages, pages 458–471, Portland, OG, January 1994. ACM Press.Google Scholar
  23. 23.
    John Hatcliff and Olivier Danvy. A computational formalization for partial evaluation. Mathematical Structures in Computer Science, 1997. To appear.Google Scholar
  24. 24.
    Neil D. Jones, Carsten K. Gomard, and Peter Sestoft. Partial Evaluation and Automatic Program Generation. Prentice Hall, 1993.Google Scholar
  25. 25.
    Julia Lawall and Olivier Danvy. Continuation-based partial evaluation. In Proc. 1994 ACM Conference on Lisp and Functional Programming, pages 227–238, Orlando, Florida, USA, June 1994. ACM Press.Google Scholar
  26. 26.
    Robin Milner, Mads Tofte, and Robert Harper. The Definition of Standard ML. MIT Press, 1990.Google Scholar
  27. 27.
    Eugenio Moggi. Computational lambda-calculus and monads. Technical Report ECS-LFCS-88-86, University of Edinburgh, 1988.Google Scholar
  28. 28.
    Eugenio Moggi. Computational lambda-calculus and monads. In Proc. of the 4rd Annual Symposium on Logic in Computer Science, pages 14–23, Pacific Grove, CA, June 1989. IEEE Computer Society Press.Google Scholar
  29. 29.
    Eugenio Moggi. A categorical account of two-level languages. In Proc. Mathematical Foundations of Programming Semantics, Thirteenth Annual Conference, volume 5 of Electronic Notes in Theoretical Computer Science, Pittsburgh, PA, March 1997. Carnegie Mellon University, Elsevier Science BV.Google Scholar
  30. 30.
    Flemming Nielson. A formal type system for comparing partial evaluators. In Dines Bjørner, Andrei P. Ershov, and Neil D. Jones, editors, Partial Evaluation and Mixed Computation, pages 349–384, Amsterdam, 1988. North-Holland.Google Scholar
  31. 31.
    Flemming Nielson and Hanne Riis Nielson. Two-Level Functional Languages. Cambridge University Press, 1992.Google Scholar
  32. 32.
    Jens Palsberg. Correctness of binding-time analysis. Journal of Functional Programming, 3(3):347–364, July 1993.Google Scholar
  33. 33.
    Gordon Plotkin. Call-by-name, call-by-value and the λ-calculus. Theoretical Computer Science, 1:125–159, 1975.Google Scholar
  34. 34.
    Amr Sabry and Matthias Felleisen. Reasoning about programs in continuationpassing style. Lisp and Symbolic Computation, 6(3/4):289–360, 1993.Google Scholar
  35. 35.
    Amr Sabry and Philip Wadler. A reflection on call-by-value. In Dybvig [17], pages 13–24.Google Scholar
  36. 36.
    Doaitse Swierstra and Manuel Hermenegildo, editors. Programming Languages, Implementations, Logics, and Programs (PLILP '95), volume 982 of Lecture Notes in Computer Science, Utrecht, The Netherlands, September 1995. Springer-Verlag.Google Scholar
  37. 37.
    Peter Thiemann. Cogen in six lines. In Dybvig [I7], pages 180–189.Google Scholar
  38. 38.
    Mitchell Wand. Specifying the correctness of binding-time analysis. Journal of Functional Programming, 3(3):365–387, July 1993.Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 1997

Authors and Affiliations

  • Julia L. Lawall
    • 1
  • Peter Thiemann
    • 2
  1. 1.IRISA/IRRIA RennesCampus Universitaire de BeaulieuRennes CedexFrance
  2. 2.Universität TübingenTübingenGermany

Personalised recommendations