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.
Supplemental Material
- 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 Scholar
- 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 Scholar
Digital Library
- 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 Scholar
- Lars Birkedal and Morten Welinder. Hand-writing program generator generators. In Programming Language Implementation and Logic Programming, pages 198–214, 1994. Google Scholar
Cross Ref
- 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 Scholar
Digital Library
- 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 Scholar
- 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 Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- Boris Feigin and Alan Mycroft. Jones optimality and hardware virtualization: a report on work in progress. In PEPM, pages 169–175, 2008. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
- Robert Gluck. Jones optimality, binding-time improvements, and the strength of program specializers. In ASIA-PEPM, pages 9–19, 2002. Google Scholar
Digital Library
- Robert Gluck. An investigation of jones optimality and bti-universal specializers. Higher-Order and Symbolic Computation, 21(3):283–309, 2008. Google Scholar
Digital Library
- Robert Glück. An experiment with the fourth Futamura projection. In Ershov Memorial Conference, pages 135–150, 2009.Google Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Cross Ref
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
- Neil D. Jones, Carsten K. Gomard, and Peter Sestoft. Partial Evaluation and Automatic Program Generation. Prentice-Hall International, 1993.Google Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Cross Ref
- Henning Makholm. On jones-optimal specialization for strongly typed languages. In SAIG, pages 129–148, 2000. Google Scholar
Cross Ref
- 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 Scholar
Cross Ref
- 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 Scholar
Digital Library
- Tobias Nipkow. Lambda calculus. https://www21.in.tum.de/teaching/logik/SS13/lambda-en.pdf , (accessed July 7, 2017), August 2, 2012.Google Scholar
- Frank Pfenning and Peter Lee. Metacircularity in the polymorphic λ-calculus. Theoretical Computer Science, 89(1):137–159, 1991. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- Sebastian Skalberg. Mechanical proof of the optimality of a partial evaluator. M.S. Thesis; DIKU, University of Copenhagen, 1999.Google Scholar
- 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 Scholar
Cross Ref
- Peter Thiemann. Cogen in six lines. In Proceedings of ICFP’96, ACM International Conference on Functional Programming, pages 180–189, 1996. Google Scholar
Digital Library
- 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 Scholar
Digital Library
Index Terms
Jones-optimal partial evaluation by specialization-safe normalization
Recommendations
A self-applicable online partial evaluator for recursive flowchart languages
This paper describes a self-applicable online partial evaluator for a flowchart language with recursive calls. Self-application of the partial evaluator yields generating extensions that are as efficient as those reported in the literature for offline ...
An investigation of Jones optimality and BTI-universal specializers
Jones optimality implies that a program specializer is strong enough to remove an entire level of self-interpretation. This paper argues that Jones optimality, which was originally devised as a criterion for self-applicable specializers, plays a ...
A self-applicable partial evaluator for the lambda calculus: correctness and pragmatics
We describe theoretical and a few practical aspects of an implemented self-applicable partial evaluator for the untyped lambda calculus with constants, conditionals, and a fixed point operator.
The purpose of this paper is first to announce the existence ...






Comments