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

Nested refinements: a logic for duck typing

Authors Info & Claims
Published:25 January 2012Publication 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.

Skip Supplemental Material Section

Supplemental Material

popl_4a_2.mp4

mp4

290.4 MB

References

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

Index Terms

  1. Nested refinements: a logic for duck typing

      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
      • 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

        Copyright © 2012 ACM

        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]

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 25 January 2012

        Permissions

        Request permissions about this article.

        Request Permissions

        Check for updates

        Qualifiers

        • research-article

        Acceptance Rates

        Overall Acceptance Rate824of4,130submissions,20%

        Upcoming Conference

        POPL '25

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader