Nothing Special   »   [go: up one dir, main page]

skip to main content
10.1145/2103656.2103686acmconferencesArticle/Chapter ViewAbstractPublication PagespoplConference Proceedingsconference-collections
research-article

Nested refinements: a logic for duck typing

Published: 25 January 2012 Publication History

Abstract

Programs written in dynamic languages make heavy use of features --- run-time type tests, value-indexed dictionaries, polymorphism, and higher-order functions --- that are beyond the reach of type systems that employ either purely syntactic or purely semantic reasoning. We present a core calculus, System D, that merges these two modes of reasoning into a single powerful mechanism of nested refinement types wherein the typing relation is itself a predicate in the refinement logic. System D coordinates SMT-based logical implication and syntactic subtyping to automatically typecheck sophisticated dynamic language programs. By coupling nested refinements with McCarthy's theory of finite maps, System D can precisely reason about the interaction of higher-order functions, polymorphism, and dictionaries. The addition of type predicates to the refinement logic creates a circularity that leads to unique technical challenges in the metatheory, which we solve with a novel stratification approach that we use to prove the soundness of System D.

Supplementary Material

JPG File (popl_4a_2.jpg)
MP4 File (popl_4a_2.mp4)

References

[1]
M. Abadi, L. Cardelli, B. C. Pierce, and G. Plotkin. Dynamic typing in a statically-typed language. In POPL, 1989.
[2]
J.-h. D. An, A. Chaudhuri, J. S. Foster, and M. Hicks. Dynamic inference of static types for ruby. In POPL, 2011.
[3]
C. Anderson, S. Drossopoulou, and P. Giannini. Towards Type Inference for JavaScript. In ECOOP, pages 428--452, June 2005.
[4]
J. Bengtson, K. Bhargavan, C. Fournet, A. Gordon, and S. Maffeis. Refinement types for secure implementations. In CSF, 2008.
[5]
Y. Bertot and P. Castéran. Interactive theorem proving and program development. coq'art: The calculus of inductive constructions, 2004.
[6]
G. M. Bierman, A. D. Gordon, C. Hritcu, and D. E. Langworthy. Semantic subtyping with an smt solver. In ICFP, 2010.
[7]
A. R. Bradley, Z. Manna, and H. B. Sipma. What's decidable about arrays? In VMCAI, pages 427--442, 2006.
[8]
R. Chugh, P. M. Rondon, and R. Jhala. Nested refinements: A logic for duck typing. http://arxiv.org/abs/1103.5055v2.
[9]
R. Chugh, J. A. Meister, R. Jhala, and S. Lerner. Staged information flow for javascript. In Proceedings of PLDI 2009, pages 50--62, 2009.
[10]
J. Condit, B. Hackett, S. K. Lahiri, and S. Qadeer. Unifying type checking and property checking for low-level code. In POPL, 2009.
[11]
R. Davies. Practical Refinement-Type Checking. PhD thesis, Carnegie Mellon University, Pittsburgh, PA, USA, 2005.
[12]
L. de Moura and N. Bjørner. Z3: An efficient SMT solver. In TACAS, 2008.
[13]
L. de Moura and N. Bjørner. Generalized, efficient array decision procedures. In FMCAD, pages 45--52, 2009.
[14]
J. Dunfield. A Unified System of Type Refinements. PhD thesis, Carnegie Mellon University, Pittsburgh, PA, USA, 2007.
[15]
R. B. Findler and M. Felleisen. Contracts for higher-order functions. In ICFP, pages 48--59, 2002.
[16]
C. Flanagan. Hybrid type checking. In POPL. ACM, 2006.
[17]
M. Furr, J. hoon (David) An, J. S. Foster, and M. W. Hicks. Static type inference for ruby. In SAC, pages 1859--1866, 2009.
[18]
A. Guha, C. Softoiu, and S. Krishnamurthi. Typing local control and state using flow analysis. In ESOP, 2011.
[19]
P. Heidegger and P. Thiemann. Recency types for analyzing scripting languages. In ECOOP, pages 200--224, 2010.
[20]
P. Hooimeijer and M. Veanes. An evaluation of automata algorithms for string analysis. In VMCAI, pages 248--262, 2011.
[21]
R. Jhala, R. Majumdar, and R.-G. Xu. State of the union: Type inference via craig interpolation. In TACAS, 2007.
[22]
A. J. Kennedy and B. C. Pierce. On decidability of nominal subtyping with variance. In FOOL-WOOD, 2007.
[23]
K. Knowles and C. Flanagan. Hybrid type checking. ACM TOPLAS, 32 (2), 2010.
[24]
R. Komondoor, G. Ramalingam, S. Chandra, and J. Field. Dependent types for program understanding. In TACAS, pages 157--173, 2005.
[25]
J. McCarthy. Towards a mathematical science of computation. In In IFIP Congress, pages 21--28. North-Holland, 1962.
[26]
G. Nelson and D. C. Oppen. Simplification by cooperating decision procedures. TOPLAS, 1979.
[27]
X. Ou, G. Tan, Y. Mandelbaum, and D. Walker. Dynamic typing with dependent types. In IFIP TCS, pages 437--450, 2004.
[28]
J. Palsberg and M. I. Schwartzbach. OO Type Systems. Wiley, 1994.
[29]
B. C. Pierce and D. N. Turner. Local type inference. In POPL, pages 252--265, 1998.
[30]
D. Rémy. Type checking records and variants in a natural extension of ml. In POPL, 1989.
[31]
P. Rondon, M. Kawaguchi, and R. Jhala. Liquid types. In PLDI, 2008.
[32]
P. Rondon, M. Kawaguchi, and R. Jhala. Low-level liquid types. In POPL, pages 131--144, 2010.
[33]
R. Shostak. Deciding combinations of theories. Journal of the ACM, 31 (1): 1--12, 1984.
[34]
J. Siek and W. Taha. Gradual typing for functional languages. In Scheme and Functional Programming Workshop, 2006.
[35]
N. Swamy, J. Chen, and R. Chugh. Enforcing stateful authorization and information flow policies in fine. In ESOP, 2010.
[36]
The Dojo Foundation. Dojo toolkit. http://dojotoolkit.org/.
[37]
}python-32The Python Software Foundation. Python 3.2 standard library. http://python.org/.
[38]
P. Thiemann. Towards a type system for analyzing javascript programs. In ESOP, 2005.
[39]
S. Tobin-Hochstadt and M. Felleisen. Logical types for untyped languages. In ICFP, pages 117--128, 2010.
[40]
H. Xi and F. Pfenning. Dependent types in practical programming. In POPL, 1999.
[41]
T. Zhao. Type inference for scripting languages with implicit extension. In FOOL, 2010.

Cited By

View all

Index Terms

  1. Nested refinements: a logic for duck typing

      Recommendations

      Comments

      Please enable JavaScript to view thecomments powered by Disqus.

      Information & Contributors

      Information

      Published In

      cover image ACM Conferences
      POPL '12: Proceedings of the 39th annual ACM SIGPLAN-SIGACT symposium on Principles of programming languages
      January 2012
      602 pages
      ISBN:9781450310833
      DOI:10.1145/2103656
      • cover image ACM SIGPLAN Notices
        ACM SIGPLAN Notices  Volume 47, Issue 1
        POPL '12
        January 2012
        569 pages
        ISSN:0362-1340
        EISSN:1558-1160
        DOI:10.1145/2103621
        Issue’s Table of Contents
      Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

      Sponsors

      In-Cooperation

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      Published: 25 January 2012

      Permissions

      Request permissions for this article.

      Check for updates

      Author Tags

      1. dynamic languages
      2. refinement types

      Qualifiers

      • Research-article

      Conference

      POPL '12
      Sponsor:

      Acceptance Rates

      Overall Acceptance Rate 824 of 4,130 submissions, 20%

      Upcoming Conference

      POPL '25

      Contributors

      Other Metrics

      Bibliometrics & Citations

      Bibliometrics

      Article Metrics

      • Downloads (Last 12 months)25
      • Downloads (Last 6 weeks)3
      Reflects downloads up to 16 Nov 2024

      Other Metrics

      Citations

      Cited By

      View all
      • (2022)Migrating gradual typesJournal of Functional Programming10.1017/S095679682200008932Online publication date: 6-Oct-2022
      • (2022)Revisiting occurrence typingScience of Computer Programming10.1016/j.scico.2022.102781217:COnline publication date: 1-May-2022
      • (2022)An empirical study of the Python/C API on evolution and bug patternsJournal of Software: Evolution and Process10.1002/smr.250735:2Online publication date: 6-Sep-2022
      • (2017)Soft contract verification for higher-order stateful programsProceedings of the ACM on Programming Languages10.1145/31581392:POPL(1-30)Online publication date: 27-Dec-2017
      • (2017)Analysis of JavaScript ProgramsACM Computing Surveys10.1145/310674150:4(1-34)Online publication date: 25-Aug-2017
      • (2017)Gradual refinement typesACM SIGPLAN Notices10.1145/3093333.300985652:1(775-788)Online publication date: 1-Jan-2017
      • (2017)Refining types using type guards in TypeScriptProceedings of the 2017 ACM SIGPLAN Workshop on Partial Evaluation and Program Manipulation10.1145/3018882.3018887(111-122)Online publication date: 2-Jan-2017
      • (2017)Gradual refinement typesProceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages10.1145/3009837.3009856(775-788)Online publication date: 1-Jan-2017
      • (2016)A vision for online verification-validationACM SIGPLAN Notices10.1145/3093335.299325552:3(190-201)Online publication date: 20-Oct-2016
      • (2016)First-class effect reflection for effect-guided programmingACM SIGPLAN Notices10.1145/3022671.298403751:10(820-837)Online publication date: 19-Oct-2016
      • Show More Cited By

      View Options

      Login options

      View options

      PDF

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader

      Media

      Figures

      Other

      Tables

      Share

      Share

      Share this Publication link

      Share on social media