Skip to main content Accessibility help
×
Home
Hostname: page-component-99c86f546-vl2kb Total loading time: 0.197 Render date: 2021-12-07T01:20:45.778Z Has data issue: true Feature Flags: { "shouldUseShareProductTool": true, "shouldUseHypothesis": true, "isUnsiloEnabled": true, "metricsAbstractViews": false, "figures": true, "newCiteModal": false, "newCitedByModal": true, "newEcommerce": true, "newUsageEvents": true }

Correctness of compiling polymorphism to dynamic typing*

Published online by Cambridge University Press:  12 December 2016

KUEN-BANG HOU (Favonia)
Affiliation:
Carnegie Mellon University Pittsburgh, PA, USA (e-mail: favonia@cs.cmu.edu)
NICK BENTON
Affiliation:
Microsoft Research Cambridge, Cambridgeshire, United Kingdom (e-mail: nick@microsoft.com)
ROBERT HARPER
Affiliation:
Carnegie Mellon University Pittsburgh, PA, USA (e-mail: rwh@cs.cmu.edu)

Abstract

The connection between polymorphic and dynamic typing was originally considered by Curry et al. (1972, Combinatory Logic, vol. ii) in the form of “polymorphic type assignment” for untyped λ-terms. Types are assigned after the fact to what is, in modern terminology, a dynamic language. Interest in type assignment was revitalized by the proposals of Bracha et al. (1998, OOPSLA) and Bank et al. (1997, POPL) to enrich Java with polymorphism (generics), which in turn sparked the development of other languages, such as Scala, with similar combinations of features. In such a setting, where the target language already has a monomorphic type system, it is desirable to compile polymorphism to dynamic typing in such a way that as much static typing as possible is preserved, relying on dynamics only insofar as genericity is actually required. The basic approach is to compile polymorphism using embeddings from each type into a universal “top” type, ${\mathbb{D}}$ , and partial projections that go in the other direction. This scheme is intuitively reasonable, and, indeed, has been used in practice many times. Proving its correctness, however, is non-trivial. This paper studies the compilation of System F to an extension of Moggi's computational meta-language with a dynamic type and shows how the compilation may be proved correct using a logical relation.

Type
Theoretical Pearls
Copyright
Copyright © Cambridge University Press 2016 

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

Footnotes

*

This research is sponsored in part by the National Science Foundation under Grant Number 1116703. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation.

References

Ahmed, A. (2006) Step-indexed syntactic logical relations for recursive and quantified types. In Programming Languages and Systems, Sestoft, Peter (ed), Lecture Notes in Computer Science, vol. 3924. Berlin, Heidelberg: Springer, pp. 6983.CrossRefGoogle Scholar
Ahmed, A., Findler, R. B., Siek, J. G. & Wadler, P. (2011) Blame for all. In Proceedings of the 38th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL). New York, NY, USA: ACM, pp. 201–214.CrossRefGoogle Scholar
Amadio, R. (1993) On the adequacy of PER models. In Proceedings of the 18th International Symposium on Mathematical Foundations of Computer Science (MFCS). LNCS, vol. 711. Berlin, Heidelberg: Springer, pp. 222–231.Google Scholar
Appel, A. W. & McAllester, D. (2001) An indexed model of recursive types for foundational proof-carrying code. ACM Trans. Program. Lang. Syst. 23 (5), 657683.CrossRefGoogle Scholar
Bank, J. A., Myers, A. C. & Liskov, B. (1997) Parameterized types for Java. In Proceedings of the 24th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL). New York, NY, USA: ACM, pp. 132–145.CrossRefGoogle Scholar
Benton, N. (2005) Embedded interpreters. J. Funct. Program. 15 (4), 503542.CrossRefGoogle Scholar
Benton, N. & Hur, C.-K. (2010) Realizability and Compositional Compiler Correctness for a Polymorphic Language. Technical Report, MSR-TR-2010-62. Microsoft Research.Google Scholar
Bracha, G., Odersky, M., Stoutamire, D. & Wadler, P. (1998) Making the future safe for the past: adding genericity to the Java programming language. In Proceedings of the 1998 ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages & Applications (OOPSLA '98), vol. 33. New York, NY, USA: ACM, pp. 183–200.Google Scholar
Crary, K. & Harper, R. (2007) Syntactic logical relations for polymorphic and recursive types. Electron. Notes Theor. Comput. Sci. 172, 259299.CrossRefGoogle Scholar
Curry, H. B., Hindley, J. R. & Seldin, J. P. (1972) Combinatory Logic, Volume ii. Studies in logic and the foundations of mathematics, vol. 65. North-Holland Publishing Company.Google Scholar
Findler, R. B. & Felleisen, M. (2002) Contracts for higher-order functions. In Proceedings of the International Conference on Functional Programming (ICFP). New York, NY, USA: ACM, pp. 48–59. doi = 10.1145/581478.581484.Google Scholar
Girard, J.-Y. (1972) Interprétation fonctionnelle et élimination des coupures de l'arithmétique d'ordre supérieur. Ph.D. thesis, Université Paris 7.Google Scholar
Harper, R. (2012) Practical Foundations for Programming Languages. Cambridge University Press.CrossRefGoogle Scholar
Hur, C.-K., & Dreyer, D. (2011) A Kripke logical relation between ML and assembly. In Proceedings of the 38th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL). New York, NY, USA: ACM, pp. 133–146.Google Scholar
Igarashi, A., Pierce, B. C. & Wadler, P. (2001) Featherweight Java: A minimal core calculus for Java and GJ. ACM Trans. Program. Lang. Syst. 23 (3), 396450.CrossRefGoogle Scholar
McCracken, N. 1979 (June) An Investigation of a Programming Language with a Polymorphic Type Structure. Ph.D. thesis, Syracuse University.Google Scholar
Meyer, A. R., & Wand, M. (1985) Continuation semantics in typed lambda-calculi. In Logics of Programs, Rohit Parikh (ed), Lecture Notes in Computer Science, vol. 193. Berlin, Heidelberg: Springer, pp. 219224.CrossRefGoogle ScholarPubMed
Milner, R. (1978) A theory of type polymorphism in programming. J. Comput. Syst. Sci. 17 (3), 348374.CrossRefGoogle Scholar
Minamide, Y., Morrisett, G. & Harper, Rt. (1996) Typed closure conversion. In Proceedings of the 23rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL). New York, NY, USA: ACM, pp. 271–283.CrossRefGoogle Scholar
Moggi, E. (1991) Notions of computation and monads. Inform. Comput. 93 (1), 5592.CrossRefGoogle Scholar
Moors, A., Piessens, F. & Odersky, M. (2008) Generics of a higher kind. In Proceedings of the 23rd ACM SIGPLAN Conference on Object-Oriented Programming Systems Languages and Applications (OOPSLA). New York, NY, USA: ACM, pp. 423–438.CrossRefGoogle Scholar
Pitts, A. M. (1996) Relational properties of domains. Inform. Comput. 127 (2), 6690.CrossRefGoogle Scholar
Plotkin, G. D. (1977) LCF considered as a programming language. Theor. Comput. Sci. 5 (3), 223255.CrossRefGoogle Scholar
Ramsey, N. (2011) Embedding an interpreted language using higher-order functions and types. J. Funct. Program. 21 (6), 585615.Google Scholar
Reynolds, J. (1983) Types, abstraction and parametric polymorphism. InInformation Processing 83. IFIP Congress Series, vol. 9. North-Holland, pp. 513523.Google Scholar
Reynolds, J. C. (1974) Towards a theory of type structure. In Programming Symposium, Proceedings Colloque sur la Programmation. Berlin, Heidelberg: Springer-Verlag, pp. 408–423.Google Scholar
Rossberg, A., Russo, C. V., & Dreyer, D. (2010) F-ing modules. In Proceedings of the 5th ACM SIGPLAN Workshop on Types in Language Design and Implementation (TLDI). New York, NY, USA: ACM, pp. 89–102.CrossRefGoogle Scholar
Scott, D. (1976) Data types as lattices. SIAM J. Comput. 5 (3), 522587.CrossRefGoogle Scholar
Submit a response

Discussions

No Discussions have been published for this article.
1
Cited by

Send article to Kindle

To send this article to your Kindle, first ensure no-reply@cambridge.org is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about sending to your Kindle. Find out more about sending to your Kindle.

Note you can select to send to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be sent to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

Correctness of compiling polymorphism to dynamic typing*
Available formats
×

Send article to Dropbox

To send this article to your Dropbox account, please select one or more formats and confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your <service> account. Find out more about sending content to Dropbox.

Correctness of compiling polymorphism to dynamic typing*
Available formats
×

Send article to Google Drive

To send this article to your Google Drive account, please select one or more formats and confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your <service> account. Find out more about sending content to Google Drive.

Correctness of compiling polymorphism to dynamic typing*
Available formats
×
×

Reply to: Submit a response

Please enter your response.

Your details

Please enter a valid email address.

Conflicting interests

Do you have any conflicting interests? *