Advertisement

Automatic autoprojection of higher order recursive equations

  • Anders Bondorf
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 432)

Abstract

Autoprojection, or self-applicable partial evaluation, has been implemented for first order functional languages for some years now. This paper describes an approach to treat a higher order subset of the Scheme language. The system has been implemented as an extension to the existing autoprojector Similix [Bondorf & Danvy 90] that treats a first order Scheme subset. To our knowledge, our system is the first fully automatic and implemented autoprojector for a higher order language.

Given a source program and some, but not all of its inputs, partial evaluation produces a residual program. When applied to the rest of the inputs, the residual program yields the same result as the source program would when applied to all inputs. One important application of autoprojection is semantics directed compiler generation: given a denotational, interpretive specification of a programming language, it is possible automatically to generate a stand-alone compiler by self-applying the partial evaluator.

Efficient autoprojection is known to require binding time analysing source programs to be partially evaluated. Binding time analysis establishes in advance which parts of the source program that can be evaluated during partial evaluation and which parts that cannot. We describe a new automatic binding time analysis for higher order programs written in the Scheme subset. The analysis requires no type information. It is based on a closure analysis [Sestoft 88b], which for any application point finds the set of lambda abstractions that can possibly be applied at that point. The binding time analysis has the interesting property that no structured binding time values are needed.

Since our language is higher order, interpreters written in a higher order style can be partially evaluated. To exemplify this, we present and partially evaluate three versions of an interpreter for a lambda calculus language: one written in direct style, one written in continuation passing style, and one implementing normal order reduction. The two latter are heavily based on higher order programming.

Keywords

Partial evaluation self-application binding time analysis semantics directed compiler generation 

References

  1. [Aho, Sethi, & Ullman 86]
    Alfred V. Aho, Ravi Sethi, and Jeffrey D. Ullman: Compilers: Principles, Techniques and Tools, Addison-Wesley 1986.Google Scholar
  2. [Bjørner, Ershov, & Jones 88]
    Dines Bjørner, Andrei P. Ershov, and Neil D. Jones (eds.): Partial Evaluation and Mixed Computation, Gl. Avernæs, Denmark, October 1987, North-Holland 1988.Google Scholar
  3. [Bondorf 89]
    Anders Bondorf: A self-applicable partial evaluator for term rewriting systems, TAPSOFT'89, Proceedings of the International Joint Conference on Theory and Practice of Software Development, J. Diaz and F. Orejas (eds.), Barcelona, Spain, Lecture Notes in Computer Science No 352 pp 81–96, Springer-Verlag 1989.Google Scholar
  4. [Bondorf 90]
    Ph.D. thesis (forthcoming), DIKU, University of Copenhagen, Denmark.Google Scholar
  5. [Bondorf & Danvy 90]
    Anders Bondorf and Olivier Danvy: Automatic autoprojection of recursive equations with global variables and abstract data types, Technical Report No 90-4, DIKU, University of Copenhagen, Denmark.Google Scholar
  6. [Bondorf, Jones, Mogensen, & Sestoft 90]
    Anders Bondorf, Neil D. Jones, Torben Æ. Mogensen, and Peter Sestoft: Binding time analysis and the taming of self-application, submitted for publication, DIKU, University of Copenhagen, Denmark.Google Scholar
  7. [Bulyonkov 84]
    Mikhail A. Bulyonkov: Polyvariant mixed computation for analyzer programs, Acta Informatica 21 pp 473–484, 1984.CrossRefMathSciNetGoogle Scholar
  8. [Consel 88]
    Charles Consel: New insights into partial evaluation: the SCHISM experiment, ESOP'88 (ed. Harald Ganzinger), Nancy, France, Lecture Notes in Computer Science No 300 pp 236–247, Springer-Verlag 1988.Google Scholar
  9. [Consel 89]
    Charles Consel: Analyse de programmes, Evaluation partielle et Génération de compilateurs, Ph.D. thesis, LITP, University of Paris 6, France 1989.Google Scholar
  10. [Consel & Danvy 89]
    Charles Consel and Olivier Danvy: Partial evaluation of pattern matching in strings, Information Processing Letters 30, No 2 pp 79–86, 1989.Google Scholar
  11. [Dybvig 87]
    R. Kent Dybvig: The SCHEME Programming Language, Prentice-Hall, New Jersey 1987.Google Scholar
  12. [Ershov 77]
    Andrei P. Ershov: On the partial computation principle, Information Processing Letters 6, No 2 pp 38–41, April 1977.CrossRefGoogle Scholar
  13. [Futamura 71]
    Yoshihiko Futamura: Partial evaluation of computing process — an approach to a compiler-compiler, Systems, Computers, Controls 2, 5, 45–50, 1971.Google Scholar
  14. [Gomard 89]
    Carsten K. Gomard: Higher Order Partial Evaluation — HOPE for the Lambda Calculus, Master's thesis, DIKU student report 89-9-11, University of Copenhagen, 1989.Google Scholar
  15. [Gomard 90]
    Carsten K. Gomard: Partial Type Inference for Untyped Functional Programs, submitted for publication, DIKU, University of Copenhagen, 1989.Google Scholar
  16. [Gomard & Jones 89]
    Carsten K. Gomard and Neil D. Jones: Compiler generation by partial evaluation, Information Processing '89. Proceedings of the 11th IFIP World Computer Congress, G. X. Ritter (ed.), pp 1139–1144, North-Holland, 1989.Google Scholar
  17. [Hudak & Young 88]
    Paul Hudak and Jonathan Young: A collecting interpretation of expressions (without powerdomains), Proceedings of the Fifteenth Annual ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages pp 107–118, San Diego, California, January 1988.Google Scholar
  18. [JonGomBonDanMog 90]
    Neil D. Jones, Carsten K. Gomard, Anders Bondorf, Olivier Danvy, and Torben Æ. Mogensen: A self-applicable partial evaluator for the lambda calculus, IEEE Computer Society 1990 International Conference on Computer Languages, 1990.Google Scholar
  19. [Jones, Sestoft, & Søndergaard 85]
    Neil D. Jones, Peter Sestoft, and Harald Søndergaard: An experiment in partial evaluation: the generation of a compiler generator, Rewriting Techniques and Applications (ed. J.-P. Jouannaud), Dijon, France, Lecture Notes in Computer Science No 202 pp 124–140, Springer-Verlag 1985.Google Scholar
  20. [Jones, Sestoft, & Søndergaard 89]
    Neil D. Jones, Peter Sestoft, and Harald Søndergaard: MIX: a self-applicable partial evaluator for experiments in compiler generation, International Journal LISP and Symbolic Computation 2, 1, pp 9–50, 1989CrossRefGoogle Scholar
  21. [Kohlbecker 86]
    Eugene E. Kohlbecker: Syntactic Extensions in the Programming Language Lisp, Ph.D. thesis, Indiana University, Bloomington 1986.Google Scholar
  22. [Mogensen 88]
    Torben Æ. Mogensen: Partially static structures in a self-applicable partial evaluator, pp 325–347 of [Bjørner, Ershov, & Jones 88].Google Scholar
  23. [Mogensen 89a]
    Torben Æ. Mogensen: Binding Time Aspects of Partial Evaluation, Ph.D. thesis, DIKU, University of Copenhagen, Denmark 1989.Google Scholar
  24. [Mogensen 89b]
    Torben Æ. Mogensen: Binding time analysis for polymorphically typed higher order languages, TAPSOFT'89, Proceedings of the International Joint Conference on Theory and Practice of Software Development, J. Diaz and F. Orejas (eds.), Barcelona, Spain, Lecture Notes in Computer Science No 352 pp 298–312, Springer-Verlag 1989.Google Scholar
  25. [Nielson & Nielson 88]
    Hanne R. Nielson and Flemming Nielson: Automatic binding time analysis for a typed λ-calculus, Proceedings of the Fifteenth Annual ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages pp 98–106, San Diego, Calinfornia, January 1988.Google Scholar
  26. [Rees & Clinger 86]
    Jonathan Rees and William Clinger (eds.): Revised 3 Report on the Algorithmic Language Scheme, Sigplan Notices 21, 12, pp 37–79, December 1986.Google Scholar
  27. [Romanenko 88]
    Sergei A. Romanenko: A compiler generator produced by a self-applicable specialiser can have a surprisingly natural and understandable structure, pp 445–463 of [Bjørner, Ershov, & Jones 88].Google Scholar
  28. [Schmidt 85]
    David A. Schmidt: Detecting global variables in denotational specifications, ACM Transactions on Programming Languages and Systems 7, No 2 pp 299–310, april 1985.CrossRefGoogle Scholar
  29. [Schmidt 86]
    David A. Schmidt: Denotational Semantics, a Methodology for Language Development, Allyn and Bacon, Boston 1986.Google Scholar
  30. [Sestoft 88a]
    Peter Sestoft: Automatic call unfolding in a partial evalator, pp 485–506 of [Bjørner, Ershov, & Jones 88].Google Scholar
  31. [Sestoft 88b]
    Peter Sestoft: Replacing Function Parameters by Global Variables, Master's thesis, DIKU student report 88-7-2, University of Copenhagen, 1988.Google Scholar
  32. [Sestoft 89]
    Peter Sestoft: Replacing function parameters by global variables, Proceedings of the Fourth International Conference on Functional Programming and Computer Architecture, London, UK, pp 39–53, ACM Press, September 1989.Google Scholar
  33. [Turchin 80]
    Valentin F. Turchin: Semantic definitions in Refal and the automatic production of compilers, Proceedings of the Workshop on Semantics-Directed Compiler Generation, Neil D. Jones (ed.), Arhus, Denmark, Lecture Notes in Computer Science No 94 pp 441–474, Springer-Verlag 1980.Google Scholar
  34. [Turchin 86]
    Valentin F. Turchin: The concept of a supercompiler, ACM Transactions on Programming Languages and Systems 8, No 3 pp 292–325, July 1986.CrossRefGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 1990

Authors and Affiliations

  • Anders Bondorf
    • 1
  1. 1.DIKU, University of CopenhagenCopenhagen ØDenmark

Personalised recommendations