skip to main content
10.1145/237721.237784acmconferencesArticle/Chapter ViewAbstractPublication PagespoplConference Proceedingsconference-collections
Article
Free Access

Type-directed partial evaluation

Authors Info & Claims
Published:01 January 1996Publication History

ABSTRACT

We present a strikingly simple partial evaluator, that is type-directed and reifies a compiled program into the text of a residual, specialized program. Our partial evaluator is concise (a few lines) and it handles the flagship examples of offline monovariant partial evaluation. Its source programs are constrained in two ways: they must be closed and monomorphically typable. Thus dynamic free variables need to be factored out in a "dynamic initial environment". Type-directed partial evaluation uses no symbolic evaluation for specialization, and naturally processes static computational effects.Our partial evaluator is the part of an offline partial evaluator that residualizes static values in dynamic contexts. Its restriction to the simply typed lambda-calculus coincides with Berger and Schwichtenberg's "inverse of the evaluation functional" (LICS'91), which is an instance of normalization in a logical setting. As such, type-directed partial evaluation essentially achieves lambda-calculus normalization. We extend it to produce specialized programs that are recursive and that use disjoint sums and computational effects. We also analyze its limitations: foremost, it does not handle inductive types.This paper therefore bridges partial evaluation and λ-calculus normalization through higher-order abstract syntax, and touches upon parametricity, proof theory, and type theory (including subtyping and coercions), compiler optimization, and rut-time code generation (including decompilation). It also offers a simple solution to denotational semantics-based compilation and compiler generation.

References

  1. 1.Thorsten Altenkirch, Martin Hofmann, and Thomas Streicher. Categorical reconstruction of a reduction free reduction proof. In Peter Dybjer and Randy Pollack, editors, Informal Proceedings of the Joint CLICS- TYPES Workshop on Categomes and Type Theory, Ggteborg, Sweden, May 1995. Report 85, Programming Methodology Group, Chalmers University and the University of GSteborg. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. 2.Henk Barendregt. The Lambda Calculus Its Syntax and Semantics. North-Holland, 1984.Google ScholarGoogle Scholar
  3. 3.Ulrich Berger and Helmut Schwichtenberg. An inverse of the evaluation functional for typed )#-calculus. In Proceedings of the S#xth Annual IEEE Symposium on Logic in Computer Science, pages 203-2tl, Amsterdam, The Netherlands, July 1991. IEEE Computer Society Press.Google ScholarGoogle ScholarCross RefCross Ref
  4. 4.Lars Birkedal and Morten Welinder. Partial evaluation of Standard ML. Master's thesis, D1KU, Computer Science Department, University of Copenhagen, August 1993. DIKU report 93/22.Google ScholarGoogle Scholar
  5. 5.Hans-J. Boehm, editor. Proceedings of the Twenty- F#rst Annual A CM Symposium on Pmnciples of Programmzng Languages, Portland, Oregon, January 1994. ACM Press. Google ScholarGoogle Scholar
  6. 6.Anders Bondorf. Self-Applicable Partial Evaluation. PhD thesis, DtKU, Computer Science Department, University of Copenhagen, Copenhagen, Denmark, 1990. DIKU Report 90-17.Google ScholarGoogle Scholar
  7. 7.Anders Bondorf. Improving binding times without explicit cps-conversion. In William Clinger, editor, Proceed#ngs of the 1992 A CM Conference on Lisp and Functional Programming, LISP Pointers, Vol. V, No. 1, pages 1-10, San Francisco, California, June 1992. ACM Press. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. 8.Anders Bondorf and Olivier Danvy. Automatic autoprojection of recursive equations with global variables and abstract data types. Science of Computer Programming, 16:151-195, 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. 9.Anders Bondorf and Jesper Jorgensen. Efficient analyses for realistic off-line partial evaluation. Journal of Functional Programming, 3(3):315-346, 1993.Google ScholarGoogle ScholarCross RefCross Ref
  10. 10.William Clinger and Jonathan Rees (editors). Revisecl4 report on the algorithmic language Scheme. LISP Poznters, IV(3):1-55, July-September 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. 11.Charles Consel. Analyse de Programmes, Evaluation Partielle et Gdndrat#on de Comp#lateurs. PhD thesis, Universit# Pierre et Marie Curie (Paris VI), Paris, France, June 1989.Google ScholarGoogle Scholar
  12. 12.Charles Consel. Polyvariant binding-time analysis for applicative languages. In David A. Schmidt, editor, Proceedings of the Second A CM SIGPLAN S#mpos:um on Partial Evaluation and Semantics-Based Program Manipulatzon, pages 66-77, Copenhagen, Denmark, June 1993. ACM Press. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. 13.Charles Consel and Olivier Danvy. From interpreting to compiling binding times. In Neil D. Jones, editor, Proceedings of the Third European Symposium on Programmzng, number 432 in Lecture Notes in Computer Science, pages 88-105, Copenhagen, Denmark, May 1990. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. 14.Charles Consel and Olivier Danvy. Static and dynamic semantics processing. In Robert (Corky) Cartwright, editor, Procee&ngs of the Eighteenth Annual A CM Symposium on Principles o} Programming Languages, pages 14-24, Orlando, Florida, January 1991. ACM Press. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. 15.Charles Consel and Olivier Danvy. Tutorial notes on partial evaluation. In Susan L. Graham, editor, Proceedings of the Twentieth Annual A CM Symposium on Principles of Programming Languages, pages 493-501, Charleston, South Carolina, January 1993. ACM Press. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. 16.Olivier Danvy and Andrzej Filinski. Abstracting control. In Mitchell Wand, editor, Proceedings of the 1990 A CM Conference on L#sp and Functional Programming, pages 151-160, Nice, France, June 1990. ACM Press. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. 17.Olivier Danvy and Andrzej Filinski. Representing control, a study of the CPS transformation. Mathematical Structures in Computer Science, 2(4):361-391, December 1992.Google ScholarGoogle ScholarCross RefCross Ref
  18. 18.Olivier Danvy, Karoline Malmkjaer, and Jens Palsberg. The essence of eta-expansion in partial evaluation. LISP and Symbohc Computation, 8(3):209-227, 1995. An earlier version appeared in the proceedings of the 1994 ACM SIGPLAN Workshop on Partial Evaluation and Semantics-Based Program Manipulation. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. 19.Olivier Danvy, Karoline Malmkjaer, and Jens Palsberg. Eta-expansion does The Trick. Technical report BRICS RS-95-41, DAIMI, Computer Science Department, Aarhus University, Aarhus, Denmark, August 1995.Google ScholarGoogle Scholar
  20. 20.Rowan Davies and Frank Pfenning. A modal analysis of staged computation. In Guy L. Steele Jr., editor, Proceed#ngs of the Twenty-Third Annual A CM Symposium on Princzples of Programming Languages, St. Petersburg Beach, Florida, January 1996. ACM Press. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. 21.Matthias Felleisen. The theory and practice of first-class prompts. In Jeanne Ferrante and Peter Mager, editors, Proceedings of the Fifteenth Annual A CM Symposium on Principles of Programming Languages, pages 180- 190, San Diego, California, January 1988. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. 22.Andrzej Filinski. Representing monads. In Boehm {5}, pages 446-457. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. 23.Andrzej FiIinski. Controlling Effects. PhD thesis, School of Computer Science, Carnegie Mellon University, Pittsburgh, Pennsylvania, 1995.Google ScholarGoogle Scholar
  24. 24.Daniel P. Friedman, Mitchell Wand, and Christopher T. Haynes. Essenhals of Programming Languages. The MIT Press and McGraw-Hill, 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. 25.Yoshihito Futamura. Partial evaluation of computation process - an approach to a compiler-compiler. Systems, Computers, Controls 2, 5, pages 45-50, 1971.Google ScholarGoogle Scholar
  26. 26.Robert Glfick and Jesper J0rgensen. Efficient multilevel generating extensions for program specialization. In S. D. Swierstra and M. Hermenegildo, editors, Seventh International Symposium on Programming Language Implementation and Logic Programming, number 982 in Lecture Notes in Computer Science, p#ges 259- 278, Utrecht, The Netherlands, September 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. 27.Mayer Goldberg. Recursive Apphcation Survival #n the A-Calculus. PhD thesis, Computer Science Department, Indiana lIniversity, Bloomington, Indiana, 1996. Forthcoming. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. 28.John Hatcliff and Olivier Danvy. A generic account of continuation-passing styles. In Boehm {5}, pages 458- 471. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. 29.Fritz Henglein. Dynamic typing: Syntax and proof theory. Science of Computer Programming, 22(3):197-230, 1993. Special Issue on ESOP'92, the Fourth European Symposium on Programming, Rennes, February 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. 30.G#rard Huet. R#solution d'fiquations dans les tangages d'ordre 1, 2, .., w. Th#se d't#tat, Universit# de Paris VII, Paris, France, 1976.Google ScholarGoogle Scholar
  31. 31.C. Barry Jay and Neil Ghani. The virtues of eta-expansion. Journal of Functional Programming, 5(3):135- 154, 1995.Google ScholarGoogle Scholar
  32. 32.Neil D. Jones, editor. Semant, cs-D,rected Compiler Generation, number 94 in Lecture Notes in Computer Science, Aarhus, Denmark, 1980.Google ScholarGoogle Scholar
  33. 33.Nell D. Jones. Challenging problems in partial evaluation and mixed computation. In Partial Evaluation and M,xed Computation, pages 1-14. North-Holland, 1988.Google ScholarGoogle Scholar
  34. 34.Neil D. Jones. Mix ten years after. In William L. Scherlis, editor, Proceedzngs o} the A CM SIGPLAN Symposium on Partial Evaluation and Semantics-Based Program Manipulation, pages 24-38, La Jolla, California, June 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. 35.Neil D. Jones, Carsten K. Gomard, Anders Bondorf, Olivier Danvy, and Torben #. Mogensen. A selfapplicable partial evaluator for the lambda calculus. In K. C. Tai and Alexander L. Wolf, editors, Proceedings of the 1990 IEEE International Conference on Computer Languages, pages 49-58, New Orleans, Louisiana, March 1990.Google ScholarGoogle ScholarCross RefCross Ref
  36. 36.Nell D. Jones, Carsten K. Gomard, and Peter Sestoft. Partial Evaluation and Automatic Program Generation. Prentice Hall International Series in Computer Science. Prentice-Hall, 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. 37.John Launchbury. Projectzon Factorisations #n Part#at Evaluation. Distinguished Dissertations in Computer Science. Cambridge University Press, 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. 38.Julia L. Lawall and Olivier Danvy. Continuationbased partial evaluation. In Carolyn L. Talcott, editor, Proceedings of the 199# A CM Conference on L#sp and Functional Programming, LISP Pointers, Vol. VII, No. 3, Orlando, Florida, June 1994. ACM Press. Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. 39.Ralph Loader. Normalisation by translation. Technical report, Computing Laboratory, Oxford University, April 1995.Google ScholarGoogle Scholar
  40. 40.Karoline Malmkjaer, Nevin Heintze, and Olivier Danvy. ML partial evaluation using set-based analysis. In John Reppy. editor, Record of the 199# A CM SIG- PLAN Workshop on ML and its Apphcat#ons, Rapport de recherche N~ 2265, INR{A, pages 112-119, Orlando, Florida, June 1994. Also appears as Technical report CMU-CS-94-129.Google ScholarGoogle Scholar
  41. 41.Torben }E. Mogensen. B#nding Time Aspects of Part, al Evatuat,on. PhD thesis, DIKU, Computer Science Department, University of Copenhagen, Copenhagen, Denmark, March 1989.Google ScholarGoogle Scholar
  42. 42.Eugenio Moggi. Notions of computation and monads. Information and Computation, 93:55-92, 199t. Google ScholarGoogle ScholarDigital LibraryDigital Library
  43. 43.Peter D. Mosses. SIS -- semantics implementation system, reference manual and user guide. Technical Report MD-30, DAIMI, Computer Science Department, Aarhus University, Aarhus, Denmark, 1979.Google ScholarGoogle Scholar
  44. 44.Flemming Nielson and Hanne Riis Nielson. Two-Level Functional Languages, volume 34 of Cambridge Tracts in Theoretical Computer Science. Cambridge University Press, 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  45. 45.Larry Paulson. Compiler generation from denotational semantics. In Bernard Lorho, editor, Methods and Tools for Compiler Construction, pages 219-250. Cambridge University Press, t984. Google ScholarGoogle ScholarDigital LibraryDigital Library
  46. 46.Frank Pfenning. Logic programming in the LF logical framework. In G#rard Huet and Gordon Plotkin, editors, Logical _Frameworks, pages 149-181. Cambridge University Press, 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  47. 47.John C. Reynolds. The essence of Algol. In van Vliet, editor, International Symposium on Algorithmic Languages, pages 345-372, Amsterdam, 1982. North- Holland.Google ScholarGoogle Scholar
  48. 48.Erik Ruf. Topics in Online Partial Evaluation. PhD thesis, Stanford University, Stanford, California, February 1993. Technical report CSL-TR-93-563. Google ScholarGoogle ScholarDigital LibraryDigital Library
  49. 49.Guy L. Steele Jr. Rabbit: A compiler for Scheme. Technical Report AI-TR-474, Artificial Intelligence Laboratory, Massachusetts Institute of Technology, Cambridge, Massachusetts, May 1978. Google ScholarGoogle ScholarDigital LibraryDigital Library
  50. 50.Philip Wadter. The essence of functional programming (tutorial). In Andrew W. Appel, editor, Proceedings of the Nineteenth Annual A CM Symposium on Principles of Programming Languages, pages 1-14, Albuquerque, New Mexico, January 1992. ACM Press. Google ScholarGoogle ScholarDigital LibraryDigital Library
  51. 51.Daniel Weise, Roland Conybeare, Erik Ruf, and Score Seligman. Aueomatic online partial evaluation. In John Hughes, editor, Proceedings of the F#fth A CM Conference on Functional Programming and Computer Architecture, number 523 in Lecture Notes in Computer Science, pages 165-191, Cambridge, Massachusetts, August 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Type-directed partial evaluation

    Recommendations

    Comments

    Login options

    Check if you have access through your login credentials or your institution to get full access on this article.

    Sign in
    • Published in

      cover image ACM Conferences
      POPL '96: Proceedings of the 23rd ACM SIGPLAN-SIGACT symposium on Principles of programming languages
      January 1996
      423 pages
      ISBN:0897917693
      DOI:10.1145/237721
      • Chairman:
      • Hans-J. Boehm,
      • Conference Chair:
      • Guy Steele

      Copyright © 1996 ACM

      Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 1 January 1996

      Permissions

      Request permissions about this article.

      Request Permissions

      Check for updates

      Qualifiers

      • Article

      Acceptance Rates

      POPL '96 Paper Acceptance Rate34of148submissions,23%Overall Acceptance Rate824of4,130submissions,20%

      Upcoming Conference

      POPL '25

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader