skip to main content
research-article
Open Access
Artifacts Evaluated & Functional

Jones-optimal partial evaluation by specialization-safe normalization

Published:27 December 2017Publication History
Skip Abstract Section

Abstract

We present partial evaluation by specialization-safe normalization, a novel partial evaluation technique that is Jones-optimal, that can be self-applied to achieve the Futamura projections and that can be type-checked to ensure it always generates code with the correct type. Jones-optimality is the gold-standard for nontrivial partial evaluation and guarantees that a specializer can remove an entire layer of interpretation. We achieve Jones-optimality by using a novel affine-variable static analysis that directs specialization-safe normalization to always decrease a program’s runtime.

We demonstrate the robustness of our approach by showing Jones-optimality in a variety of settings. We have formally proved that our partial evaluator is Jones-optimal for call-by-value reduction, and we have experimentally shown that it is Jones-optimal for call-by-value, normal-order, and memoized normal-order. Each of our experiments tests Jones-optimality with three different self-interpreters.

We implemented our partial evaluator in Fωµ i, a recent language for typed self-applicable meta-programming. It is the first Jones-optimal and self-applicable partial evaluator whose type guarantees that it always generates type-correct code.

Skip Supplemental Material Section

Supplemental Material

jonesoptimal.webm

References

  1. Lars Ole Andersen. Self-applicable C program specialization. In Proceedings of PEPM’92, Workshop on Partial Evaluation and Semantics-Based Program Manipulation, pages 54–61, June 1992. (Technical Report YALEU/DCS/RR-909, Yale University).Google ScholarGoogle Scholar
  2. Kenichi Asai, Luminous Fennell, Peter Thiemann, and Yang Zhang. A type theoretic specification of partial evaluation. In PPDP’14 Proceedings of the 16th International Symposium on Principles and Practice of Declarative Programming, pages 57–68, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Steve Barker, Michael Leuschel, and Mauricio Varea. Efficient and flexible access control via Jones-optimal logic program specialisation. Higher-Order and Symbolic Computation, pages 3–35, 2007.Google ScholarGoogle Scholar
  4. Lars Birkedal and Morten Welinder. Hand-writing program generator generators. In Programming Language Implementation and Logic Programming, pages 198–214, 1994. Google ScholarGoogle ScholarCross RefCross Ref
  5. 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
  6. Anders Bondorf and Dirk Dussart. Improving CPS-based partial evaluation: Writing cogen by hand. In Proceedings of ACM SIGPLAN Workshop on Partial Evaluation and Semantics-Based Program Manipulation, pages 1–10, 1994.Google ScholarGoogle Scholar
  7. Edwin C. Brady and Kevin Hammond. Scrapping your inefficient engine: Using partial evaluation to improve domainspecific language implementation. In Proceedings of ICFP’10, ACM SIGPLAN International Conference on Functional Programming, 2010.Google ScholarGoogle Scholar
  8. Matt Brown and Jens Palsberg. Self-Representation in Girard’s System U. In Proceedings of the 42nd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL ’15, pages 471–484, New York, NY, USA, 2015. ACM. ISBN 978-1-4503-3300-9. doi: 10.1145/2676726.2676988. URL Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Matt Brown and Jens Palsberg. Breaking through the normalization barrier: A self-interpreter for f-omega. In Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2016, pages 5–17, New York, NY, USA, 2016. ACM. ISBN 978-1-4503-3549-2. doi: 10.1145/2837614.2837623. URL Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Matt Brown and Jens Palsberg. Typed self-evaluation via intensional type functions. In Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages, POPL 2017, pages 415–428, New York, NY, USA, 2017. ACM. ISBN 978-1-4503-4660-3. doi: 10.1145/3009837.3009853. URL Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Matt Brown and Jens Palsberg. Webpage accompanying this paper. The webpage accompanying this paper is available at http://compilers.cs.ucla.edu/popl18/. The full paper with the appendix is available there, as is the source code for our implementation of System F µ i ω and its self-interpreters and partial evaluator., 2018.Google ScholarGoogle Scholar
  12. Jacques Carette, Oleg Kiselyov, and Chung-chieh Shan. Finally tagless, partially evaluated: Tagless staged interpreters for simpler typed languages. Journal of Functional Programming, 19(5):509–543, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Adam Chlipala. Parametric higher-order abstract syntax for mechanized semantics. In Proceedings of the 13th ACM SIG-PLAN International Conference on Functional Programming, ICFP ’08, pages 143–156, New York, NY, USA, 2008. ACM. ISBN 978-1-59593-919-7. doi: 10.1145/1411204.1411226. URL Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Charles Consel. A tour of Schism: A partial evaluation system for higher-order applicative languages. In Proceedings of PEPM’93, Second ACM SIGPLAN Symposium on Partial Evaluation and Semantics-Based Program Manipulation, pages 145–154, 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Olivier Danvy. Type-directed partial evaluation. In Proceedings of POPL’96, 23nd Annual SIGPLAN–SIGACT Symposium on Principles of Programming Languages, pages 242–257, 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Olivier Danvy and Pablo E. Martínez López. Tagging, encoding, and Jones optimality. In Proceedings of ESOP’03, European Symposium on Programming, pages 335–347. Springer-Verlag (LNCS), 2003.Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Boris Feigin and Alan Mycroft. Jones optimality and hardware virtualization: a report on work in progress. In PEPM, pages 169–175, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Yoshihiko Futamura. Evaluation of computation process—an approach to a compiler-compiler. Higher-Order and Symbolic Computation, 12:381–391, 1999. First published in 1971 in System.Computers.Controls, Volume 2, Number 5, pages 45–50.Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Johan Gade and Robert Gluck. On Jones-optimal specializers: A case study using unmix. In Proceedings of APLAS’06, Asian Symposium on Programming Languages and Systems, pages 406–422. Springer-Verlag (LNCS 4279), 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Robert Glück. Is there a fourth Futamura projection? In Proceedings of PEPM’99, Workshop on Partial Evaluation and Semantics-Based Program Manipulation, pages 51–60, 1999.Google ScholarGoogle Scholar
  21. Robert Gluck. Jones optimality, binding-time improvements, and the strength of program specializers. In ASIA-PEPM, pages 9–19, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Robert Gluck. An investigation of jones optimality and bti-universal specializers. Higher-Order and Symbolic Computation, 21(3):283–309, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Robert Glück. An experiment with the fourth Futamura projection. In Ershov Memorial Conference, pages 135–150, 2009.Google ScholarGoogle Scholar
  24. Robert Glück. Is there a fourth futamura projection? In Proceedings of the 2009 ACM SIGPLAN Workshop on Partial Evaluation and Program Manipulation, PEPM ’09, pages 51–60, New York, NY, USA, 2009. ACM. ISBN 978-1-60558-327-3. doi: 10.1145/1480945.1480954. URL Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Carsten K. Gomard and Neil D. Jones. A partial evaluator for the untyped lambda-calculus. Journal of Functional Programming, 1(1):21–69, 1991. Google ScholarGoogle ScholarCross RefCross Ref
  26. Noriko Hirota and Kenichi Asai. Formalizing a correctness property of a type-directed partial evaluator. In PLPV’14 Proceedings of the ACM SIGPLAN 2014 Workshop on Programming Languages meets Program Verification, pages 41–46, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Barry Jay and Jens Palsberg. Typed self-interpretation by pattern matching. In Proceedings of ICFP’11, ACM SIGPLAN International Conference on Functional Programming, pages 247–258, Tokyo, September 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Neil D. Jones, Peter Sestoft, and Harald Søndergaard. An experiment in partial evaluation: The generation of a compiler generator. In J.-P. Jouannaud, editor, Proceedings of Rewriting Techniques and Applications, pages 225–282. SpringerVerlag (LNCS 202), 1985.Google ScholarGoogle Scholar
  29. Neil D. Jones, Carsten K. Gomard, and Peter Sestoft. Partial Evaluation and Automatic Program Generation. Prentice-Hall International, 1993.Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Oleg Kiselyov. Typed Tagless Final Interpreters, pages 130–174. Springer Berlin Heidelberg, Berlin, Heidelberg, 2012. ISBN 978-3-642-32202-0. doi: 10.1007/978-3-642-32202-0_3. URL Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. John Launchbury. A strongly-typed self-applicable partial evaluator. In Proceedings of FPCA’91, Sixth ACM Conference on Functional Programming Languages and Computer Architecture, pages 145–164, 1991. Google ScholarGoogle ScholarCross RefCross Ref
  32. Henning Makholm. On jones-optimal specialization for strongly typed languages. In SAIG, pages 129–148, 2000. Google ScholarGoogle ScholarCross RefCross Ref
  33. Torben Æ. Mogensen. Efficient self-interpretations in lambda calculus. Journal of Functional Programming, 2(3):345–363, 1992. See also DIKU Report D–128, Sep 2, 1994.Google ScholarGoogle ScholarCross RefCross Ref
  34. Torben Æ. Mogensen. Self-applicable online partial evaluation of the pure lambda calculus. In Proceedings of the 1995 ACM SIGPLAN Symposium on Partial Evaluation and Semantics-based Program Manipulation, PEPM ’95, pages 39–44, New York, NY, USA, 1995. ACM. ISBN 0-89791-720-0. doi: 10.1145/215465.215469. URL Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. Tobias Nipkow. Lambda calculus. https://www21.in.tum.de/teaching/logik/SS13/lambda-en.pdf , (accessed July 7, 2017), August 2, 2012.Google ScholarGoogle Scholar
  36. Frank Pfenning and Peter Lee. Metacircularity in the polymorphic λ-calculus. Theoretical Computer Science, 89(1):137–159, 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. Tillmann Rendel, Klaus Ostermann, and Christian Hofer. Typed self-representation. In Proceedings of PLDI’09, ACM SIG-PLAN Conference on Programming Language Design and Implementation, pages 293–303, June 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. Amin Shali and William Cook. Hybrid partial evaluation. In Proceedings of OOPSLA’11, ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages and Applications, pages 375–390, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. Alex Simpson. Reduction in a linear lambda-calculus with applications to operational semantics. In Proceedings of the 16th International Conference on Term Rewriting and Applications, RTA’05, pages 219–234, Berlin, Heidelberg, 2005. SpringerVerlag. ISBN 3-540-25596-6, 978-3-540-25596-3. doi: 10.1007/978-3-540-32033-3_17. URL Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. Sebastian Skalberg. Mechanical proof of the optimality of a partial evaluator. M.S. Thesis; DIKU, University of Copenhagen, 1999.Google ScholarGoogle Scholar
  41. Walid Taha, Henning Makholm, and John Hughes. Tag elimination and Jones-optimality. In Proceedings of PADO’01, Programs as Data Objects, Second Symposium, pages 257–275, 2001. Google ScholarGoogle ScholarCross RefCross Ref
  42. Peter Thiemann. Cogen in six lines. In Proceedings of ICFP’96, ACM International Conference on Functional Programming, pages 180–189, 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  43. Geoffrey Washburn and Stephanie Weirich. Boxes go bananas: Encoding higher-order abstract syntax with parametric polymorphism. In Proceedings of the Eighth ACM SIGPLAN International Conference on Functional Programming, ICFP ’03, pages 249–262, New York, NY, USA, 2003. ACM. ISBN 1-58113-756-7. doi: 10.1145/944705.944728. URL Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Jones-optimal partial evaluation by specialization-safe normalization

        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

        Full Access

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader
        About Cookies On This Site

        We use cookies to ensure that we give you the best experience on our website.

        Learn more

        Got it!