Abstract
We present a framework for offline partial evaluation for call-by-value functional programming languages with an ML-style typing discipline. This includes a binding-time analysis which is (1) polymorphic with respect to binding times; (2) allows the use of polymorphic recursion with respect to binding times; (3) is applicable to a polymorphically typed term; and (4) is proven correct with respect to a novel small-step specialization semantics.The main innovation is to build the analysis on top of the region calculus of Tofte and Talpin [1994], thus leveraging the tools and techniques developed for it. Our approach factorizes the binding-time analysis into region inference and a subsequent constraint analysis. The key insight underlying our framework is to consider binding times as properties of regions.Specialization is specified as a small-step semantics, building on previous work on syntactic-type soundness results for the region calculus. Using similar syntactic proof techniques, we prove soundness of the binding-time analysis with respect to the specializer. In addition, we prove that specialization preserves the call-by-value semantics of the region calculus by showing that the reductions of the specializer are contextual equivalences in the region calculus.
- Abadi, M., Banerjee, A., Heintze, N., and Riecke, J. 1999. A core calculus of dependency. In Proceedings of the 1999 ACM SIGPLAN Symposium on Principles of Programming Languages (San Antonio, Tex). ACM, New York, 147--160.]] Google Scholar
- Banerjee, A., Heintze, N., and Riecke, J. 1999. Region analysis and the polymorphic lambda calculus. In proceedings of the 14th Annual Symposium on Logic in Computer Science, LICS'99 (Trento, Italy). IEEE Computer Society Press, Los Alamitos, Calif., 88--97.]] Google Scholar
- Birkedal, L. and Tofte, M. 2001. A constraint-based region inference algorithm. Theoret. Comput. Sci. 58, 299--392.]] Google Scholar
- Birkedal, L. and Welinder, M. 1993. Partial evaluation of Standard ML. Rapport 93/22, DIKU, University of Copenhagen.]]Google Scholar
- Birkedal, L. and Welinder, M. 1994. Binding-time analysis for Standard-ML. In Proceedings of the 1994 ACM SIGPLAN Workshop on Partial Evaluation and Semantics-Based Program Manipulation (Orlando, Fla), 61--71. (Technical Report 94/9, Department of Computer Science.)]]Google Scholar
- Bondorf, A. and Jørgensen, J. 1993. Efficient analyses for realistic off-line partial evaluation. J. Funct. Prog. 3, 3 (July), 315--346.]]Google Scholar
- Bulyonkov, M. 1993. Extracting polyvariant binding time analysis from polyvariant specializer. In Proceedings of the 1993 ACM SIGPLAN Workshop on Partial Evaluation and Semantics-Based Program Manipulation (Copenhagen, Denmark), D. Schmidt, Ed. ACM, New York, 59--65.]] Google Scholar
- Calcagno, C. 2001. Stratified operational semantics for safety and correctness of the region calculus. In Proceedings of the 2001 ASM SIGPLAN Symposium on Principles of Programming Languages (London, England), H. R. Nielson, Ed. ACM, New York, 155--165.]] Google Scholar
- Calcagno, C., Helsen, S., and Thiemann, P. 2002. Syntactic type soundness results for the region calculus. Inf. Comput. 173, 2, 199--221.]] Google Scholar
- Consel, C. 1989. Analyse de programmes, evaluation partielle et génération de compilateurs. Ph.D. dissertation, Université de Paris VI, Paris, France.]]Google Scholar
- Consel, C. 1990. Binding time analysis for higher order untyped functional languages. In Proceedings of the 1990 ACM Conference on Lisp and Functional Programming (Nice, France). ACM, New York, 264--272.]] Google Scholar
- Consel, C. 1993a. Polyvariant binding-time analysis for applicative languages. In Proceedings of the 1993 ACM SIGPLAN Workshop on Partial Evalution and Semantics-Based Program Manipulation (Copenhagen, Denmark), D. Schmidt, Ed. ACM, New York, 66--77.]] Google Scholar
- Consel, C. 1993b. A tour of Schism. In Proceedings of the 1993 ACM SIGPLAN Workshop on Partial Evalution and Semantics-Based Program Manipulation (Copenhagen, Denmark), D. Schmidt, Ed. ACM, New York, 134--154.]] Google Scholar
- Consel, C. and Danvy, O. 1991. For a better support of static data flow. In Functional Prgramming Languages and Computer Architecture (Cambridge, Mass.), J. Hughes, Ed. Lecture Notes in Computer Science, vol. 523. Springer-Verlag, New York, 496--519.]] Google Scholar
- Consel, C. and Danvy, O. 1993. Tutorial notes on partial evaluation. In Proceedings of the 1993 ACM SIGPLAN Symposium on Principles of Programming Languages (Charleston, S.C.). ACM, New York, 493--501.]] Google Scholar
- Consel, C., Jouvelot, P., and Ørbæk, P. 1994. Separate polyvariant binding-time reconstruction. Tech. Rep. CRI-A/261, Ecole des Mines, Paris. Oct.]]Google Scholar
- Danvy, O., Malmkjær, K., and Palsberg, J. 1995. The essence of eta-expansion in partial evaluation. LISP Symb. Comput. 8, 3 (July), 209--227.]] Google Scholar
- Danvy, O., Malmkjær, K., and Palsberg, J. 1996. Eta-expansion does The Trick. ACM Trans. Prog. Lang. Syst. 18, 6 (Nov.), 730--751.]] Google Scholar
- Dussart, D., Heldal, R., and Hughes, J. 1997. Module-sensitive program specialisation. In Proceedings of the 1997 Conference on Programming Language Design and Implementation (Las Vegas, Nev.). ACM, New York, 206--214.]] Google Scholar
- Dussart, D., Henglein, F., and Mossin, C. 1995. Polymorphic recursion and subtype qualifications: Polymorphic binding-time analysis in polynomial time. In Proceedings of the 1995 International Static Analysis Symposium (Glasgow, Scotland), A. Mycroft, Ed. Lecture Notes in Computer Science, vol. 983, Springer-Verlag, New York, 118--136.]] Google Scholar
- Gengler, M., and Rytz, B. 1992. A polyvariant binding time analysis handling partially known values. In Proceedings of the 2nd Workshop on Static Analysis. Bigre Journal, vol. 81--82. IRISA, Rennes, France, 322--330.]]Google Scholar
- Gifford, D. and Lucassen, J. 1986. Integrating functional and imperative programming. In Proceedings of the 1986 ACM Conference on LISP and Functional Programming. ACM, New York, 28--38.]] Google Scholar
- Glenstrup, A. J. and Jones, N. D. 1996. BTA algorithms to ensure termination of offline partial evaluation. In PSA-96: Andrei Ershov Second International Memorial Conference, Perspectives of System Informatics (Novosibirsk, Russia), Lecture Notes in Computer Science, vol. 1181. Springer-Verlag, New York, 273--284.]] Google Scholar
- Glynn, K., Stuckey, P., Sulzmann, M., and Søndergaard, H. 2001. Boolean constraints for binding-time analysis. In Programs as Data Objects II (Aarhus, Denmark). Lecture Notes in Computer Science, vol. 2053. Springer-Verlag, New York, 39--62.]] Google Scholar
- Harper, R. 1994. A simplified account of polymorphic references. Inf. Proc. Lett. 51, 4 (Aug.), 201--206. (See also note {Harper 1996}.)]] Google Scholar
- Harper, R. 1996. A note on: "A simplified account of polymorphic references". Inf. Proc. Lett. 57, 1 (Jan.), 15--16. (See also {Harper 1994}.)]] Google Scholar
- Hatcliff, J. and Danvy, O. 1997. A computational formalization for partial evaluation. Math. Struct. Comput. Sci. 7, 5, 507--542.]] Google Scholar
- Heldal, R. 2001. The treatment of polymorphism and modules in a partial evaluator. Ph.D. dissertation. Chalmers University of Technology.]]Google Scholar
- Heldal, R. and Hughes, J. 2000. Extending a partial evaluator which supports separate compilation. Theoret. Comput. Sci. 248, 99--145.]] Google Scholar
- Heldal, R. and Hughes, J. 2001. Binding-time analysis for polymorphic types. In PSI-01: Andrei Ershov Fourth International Conference, Perspectives of System Informatics (Novosibirsk, Russia), Lecture Notes in Computer Science, vol. 2244. Springer-Verlag, New York, 191--204.]] Google Scholar
- Helsen, S. 2002. Region-based program specialization---An operational approach to polymorphic offline partial evaluation for ML-like languages. Ph.D. dissertation, Unversität Freiburg, Germany. Available from http://www.freidok.uni-freiburg.de/volltexte/538/.]]Google Scholar
- Helsen, S. 2004. Bisimilarity for the region calculus. Higher-Order and Symbolic Computation. 17, 4.]] Google Scholar
- Helsen, S. and Thiemann, P. 2000a. Fragmental specialization. In Semantics, Applications and Implementation of Program Generation (SAIG'00) (Montreal, Ont., Canada), W. Taha, Ed. Lecture Notes in Computer Science, vol. 1927. Springer-Verlag, New York, 51--71.]] Google Scholar
- Helsen, S. and Thiemann, P. 2000b. Syntactic type soundness for the region calculus. In ACM Workshop on Higher Order Operational Techniques in Semantics (HOOTS) (Montreal, Ont., Canada). A. Jeffrey, Ed. Electronic Notes in Theoretical Computer Science, vol. 41(3). Elsevier Science, Amsterdam, The Netherlands 1--20.]]Google Scholar
- Henglein, F. 1991. Efficient type interference for higher-order binding-time analysis. In Functional Programming Languages and Computer Architecture (Cambridge, Mass.), J. Hughes, Ed. Lecture Notes in Computer Science, vol. 523. Springer-Verlag, New York, 448--472.]] Google Scholar
- Henglein, F., and Mossin, C. 1994. Polymorphic binding-time analysis. In Proceedings of European Symposium on Programming, D. Sannella, Ed. Lecture Notes in Computer Science, vol. 788. Springer-Verlag, New York 287--301.]] Google Scholar
- Hornof, L., and Noyè, J. 2000. Accurate binding-time analysis for imperative languages: Flow, context, and return sensitivity. Theoret. Comput. Sci. 248, 1--2 (Oct.), 3--27.]] Google Scholar
- Jones, N., Gomard, C., and Sestoft, P. 1993. Partial Evaluation and Automatic Program Generation. Prentice-Hall, Englewood Cliffs, N.J.]] Google Scholar
- Jouvelot, P. and Gifford, D. 1991. Algebraic reconstruction of types and effects. In Proceedings of the 1991 ACM SIGPLAN Symposium on Principles of Programming Languages (Orlando, Florida), ACM New York, 303--310.]] Google Scholar
- Lassen, S. 1998. Relational reasoning about contexts. In Higher Order Operational Techniques in Semantics (HOOTS), A. Gordon and A. Pitts, Eds. Publications of the Newton Institute. Cambridge University Press, 91--136.]] Google Scholar
- Launchbury, J. and Holst, C. K. 1991. Handwriting cogen to avoid problems with static typing. In Draft Proceedings, Fourth Annual Glasgow Workshop on Functional Programming. Glasgow University, Skye, Scotland, 210--218.]]Google Scholar
- Lawall, J. and Thiemann, P. 1997. Sound specialization in the presence of computational effects. In Proceedings of the Theoretical Aspects of Computer Software (Sendai, Japan), Lecture Notes in Computer Science, vol. 1284 Springer-Verlag, New York, 165--190.]] Google Scholar
- Lee, C. S. 2002a. Finiteness analysis in polynomial time. In Static Analysis: 9th International Symposium, SAS 2002, M. Hermenegildo and G. Puebla, Eds. Lecture Notes in Computer Science, vol. 2477. Springer-Verlag, New York, 493--508.]] Google Scholar
- Lee, C. S. 2002b. Program termination analysis in polynomial time. In Generative Programming and Component Engineering: ACM SIGPLAN/SIGSOFT Conference, GPCE 2002, D. Batory, C. Consel, and W. Taha, Eds. Lecture Notes in Computer Science, vol. 2487. Springer-Verlag, New York, 218--235.]] Google Scholar
- Lee, C. S., Jones, N. D., and Ben-Amram, A. M. 2001. The size-change principle for program termination. In Proceedings of the 2001 ACM SIGPLAN Symposium on Principles of Programming Languages (London, England), H. R. Nielson, Ed. ACM New York, 81--92.]] Google Scholar
- Milner, R. 1978. A theory of type polymorphism in programming. J. Comput. Syst. Sci. 17, 348--375.]]Google Scholar
- Milner, R., Tofte, M., Harper, R., and MacQueen, D. 1997. The Definition of Standard ML (Revised). MIT Press, Cambridge, Mass.]] Google Scholar
- Mogensen, T. 1989. Binding time analysis for polymorphically typed higher order languages. In TAPSOFT '89 (Barcelona, Spain), J. Díaz and F. Orejas, Eds. Lecture Notes in Computer Science, vol. 351 and 352. Springer-Verlag, New York, 298--312.]] Google Scholar
- Moggi, E. 1991. Notions of computations and monads. Inf. Comput. 93, 55--92.]] Google Scholar
- Morris, J. 1968. Lambda calculus models of programming languages. Ph.D. dissertation. MIT Press, Cambridge, Mass.]]Google Scholar
- Nielson, F., and Nielson, H. R. 1988. Automatic binding-time analysis for a typed lambda calculus. Sci. Comput. Prog. 10, 139--176.]] Google Scholar
- Nielson, F. and Nielson, H. R. 1992. Two-Level Functional Languages. Cambridge Tracts in Theoretical Computer Science, vol. 34. Cambridge University Press, Cambridge, Mass.]] Google Scholar
- Odersky, M., Sulzmann, M., and Wehr, M. 1999. Type inference with constrained types. Theory Pract. Obj. Syst. 5, 1, 35--55.]] Google Scholar
- Plotkin, G. 1975. Call-by-name, call-by-value and the λ-calculus. Theoret. Comput. Sci. 1, 125--159.]]Google Scholar
- Plotkin, G. 1981. A structural approach to operational semantics. Tech. Rep. DAIMI FN-19. Aarhus University, Denmark.]]Google Scholar
- Rytz, B. and Gengler, M. 1992. A polyvariant binding time analysis. In Proceedings of the 1992 ACM SIGPLAN Workshop on Partial Evaluation and Semantics-Based Program Manipulation, C. Consel, Ed. Yale University, San Francisco, CA, 21--28. Report YALEU/DCS/RR-909.]]Google Scholar
- Talpin, J.-P. and Jouvelot, P. 1992. Polymorphic type, region and effect inference. J. Funct. Prog. 2, 3 (July), 245--272.]]Google Scholar
- Thiemann, P. 1996. Implementing memoization for partial evaluation. In International Symposium on Programming Languages, Implementations, Logics and Programs (PLILP '96) (Aachen, Germany), H. Kuchen and D. Swierstra, Eds. Lecture Notes in Computer Science, vol. 1140. Springer-Verlag, New York, 198--212.]] Google Scholar
- Thiemann, P. 1997a. Correctness of a region-based binding-time analysis. In Proceedings of the 1997 Conference on Mathematical Foundations of Programming Semantics. Electronic Notes in Theoretical Computer Science, vol. 6. Carnegie Mellon University, Pittsburgh, Pa. Elsevier Science, BV, Amsterdam, The Netherlands. URL: http://www.elsevier.nl/ locate/entcs/volume6.html.]]Google Scholar
- Thiemann, P. 1997b. A unified framework for binding-time analysis. In TAPSOFT '97: Theory and Practice of Software Development, M. Bidoit and M. Dauchet, Eds. Number 1214 in Lecture Notes in Computer Science. Springer-Verlag, Lille, France, 742--756.]] Google Scholar
- Thiemann, P. 1998. A generic framework for specialization. In Proceedings of the 7th European Symposium on Programming (Lisbon, Portugal), C. Hankin, Ed. Lecture Notes in Computer Science, vol 1381. Springer-Verlag, New York, 267--281.]] Google Scholar
- Thiemann, P. 1999a. Combinators for program generation. J. Funct. Prog. 9, 5 (Sept.), 483--525.]] Google Scholar
- Thiemann, P. 1999b. Interpreting specialization in type theory. In Proceedings of the ACM SIGPLAN Workshop on Partial Evaluation and Semantics-Based Program Manipulation PEPM '99 (San Antonio, Tex.), O. Danvy, Ed. ACM, New York, 30--43. BRICS Notes Series NS-99-1.]]Google Scholar
- Thiemann, P. 2000. The PGG System--User Manual. Universität Freiburg, Freiburg, Germany. Available from http://www.informatik.uni-freiburg.de/proglang/software/pgg/.]]Google Scholar
- Thiemann, P. 2001. Enforcing safety properties using type specialization. In Proceedings of the 2001 European Symposium on Programming (Genova,Italy), D. Sands, Ed. Lecture Notes in Computer Science. Springer-Verlag, New York.]] Google Scholar
- Thiemann, P. 2002. A prototype dependency calculus. In Proceedings of the 11th European Symposium on Programming (Grenoble, France), D. L. Metayèr, Ed. Lecture Notes in Computer Science, vol. 2305. Springer-Verlag, New York, 228--242.]] Google Scholar
- Thiemann, P. and Dussart, D. 1997. Partial evaluation for higher-order languages with state. Berichte des Wilhelm-Schickard-Instituts WSI-97-XX, Universität Tübingen. Apr.]]Google Scholar
- Tofte, M. and Birkedal, L. 1998. A region inference algorithm. ACM Trans. Prog. Lang. Syst. 20, 5, 724--767.]] Google Scholar
- Tofte, M. and Birkedal, L. 2000. Unification and polymorphism in region inference. In Proof, Language, and Interaction: Essays in Honour of Robin Milner. MIT Press, Cambridge Mass.]] Google Scholar
- Tofte, M., Birkedal, L., Elsman, M., Hallenberg, N., Olensen, T., and Sestoft, P. 2001. Programming with Regions in the ML Kit, Version 4.0.0. Available from http://www.it.edu/research/ mlkit/dist/mlkit-4.0.0.pdf.]]Google Scholar
- Tofte, M. and Talpin, J.-P. 1994. Implementation of the typed call-by-value λ-calculus using a stack of regions. In Proceedings of the 1994 ACM SIGPLAN Symposium on Principles of Programming Languages (Portland, Ore). ACM, New York, 188--201.]] Google Scholar
- Tofte, M. and Talpin, J.-P. 1997. Region-based memory management. Inf. Comput. 132, 2, 109--176.]] Google Scholar
- Wright, A. and Felleisen, M. 1994. A syntactic approach to type soundness. Inf. Comput. 115, 1, 38--94.]] Google Scholar
Index Terms
- Polymorphic specialization for ML
Recommendations
A compilation method for ML-style polymorphic record calculi
POPL '92: Proceedings of the 19th ACM SIGPLAN-SIGACT symposium on Principles of programming languagesPolymorphic record calculi have recently attracted much attention as a typed foundation for object-oriented programming. This is based on the fact that a function that selects a field l of a record can be given a polymorphic type that enables it to be ...
Polymorphic unification and ML typing
POPL '89: Proceedings of the 16th ACM SIGPLAN-SIGACT symposium on Principles of programming languagesWe study the complexity of type inference for a core fragment of ML with lambda abstraction, function application, and the polymorphic let declaration. Our primary technical tool is the unification problem for a class of “polymorphic” type expressions. ...
A temporal-logic approach to binding-time analysis
LICS '96: Proceedings of the 11th Annual IEEE Symposium on Logic in Computer ScienceThe Curry-Howard isomorphism identifies proofs with typed /spl lambda/-calculus terms, and correspondingly identifies propositions with types. We show how this isomorphism can be extended to relate constructive temporal logic with binding-time analysis. ...
Comments