skip to main content
article

Occurrence typing modulo theories

Published:02 June 2016Publication History
Skip Abstract Section

Abstract

We present a new type system combining occurrence typing---a technique previously used to type check programs in dynamically-typed languages such as Racket, Clojure, and JavaScript---with dependent refinement types. We demonstrate that the addition of refinement types allows the integration of arbitrary solver-backed reasoning about logical propositions from external theories. By building on occurrence typing, we can add our enriched type system as a natural extension of Typed Racket, reusing its core while increasing its expressiveness. The result is a well-tested type system with a conservative, decidable core in which types may depend on a small but extensible set of program terms. In addition to describing our design, we present the following: a formal model and proof of correctness; a strategy for integrating new theories, with specific examples including linear arithmetic and bitvectors; and an evaluation in the context of the full Typed Racket implementation. Specifically, we take safe vector operations as a case study, examining all vector accesses in a 56,000 line corpus of Typed Racket programs. Our system is able to prove that 50% of these are safe with no new annotations, and with a few annotations and modifications we capture more than 70%.

References

  1. Esteban Allende, Oscar Callau, Johan Fabry, Éric Tanter, and Marcus Denker. Gradual Typing for Smalltalk. Science of Computer Programming, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Ambrose Bonnaire-Sergeant, Rowan Davies, and Sam Tobin-Hochstadt. Practical Optional Types for Clojure. In Proc. ESOP, 2016.Google ScholarGoogle Scholar
  3. Chiyan Chen and Hongwei Xi. Combining Programming with Theorem Proving. In Proc. ICFP, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Ravi Chugh, David Herman, and Ranjit Jhala. Dependent Types for Javascript. In Proc. OOPSLA, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Ravi Chugh, Patrick M. Rondon, and Ranjit Jhala. Nested Refinements: A Logic for Duck Typing. In Proc. POPL, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Microsoft Co. Typescript Language Specification. http: //www.typescriptlang.org, 2014.Google ScholarGoogle Scholar
  7. George B. Dantzig and B. Curtis Eaves. Fourier-Motzkin Elimination and Its Dual. J. Combinatorial Theory Series A, 1973.Google ScholarGoogle Scholar
  8. Leonardo De Moura and Nikolaj Bjorner. Z3: An Efficient SMT Solver. In Proc. TACAS, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Matthias Felleisen, Robert Bruce Findler, and Matthew Flatt. Semantics Engineering with PLT Redex. MIT Press, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Matthew Flatt and PLT. Reference: Racket. Technical Report PLT-TR-2010-1, PLT Design Inc., 2010.Google ScholarGoogle Scholar
  11. https:// racket-lang.org/tr1.Google ScholarGoogle Scholar
  12. Matthew Fluet and Riccardo Pucella. Practical Datatype Specializations with Phantom Types and Recursion Schemes. Electronic Notes in Theoretical Computer Science, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Michael Greenberg, Benjamin C. Pierce, and Stephanie Weirich. Contracts Made Manifest. In Proc. POPL, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Jessica Gronski, Kenneth Knowles, Aaron Tomb, Stephen N. Freund, and Cormac Flanagan. Sage: Hybrid Checking for Flexible Specifications. In Proc. Wksp. on Scheme and Functional Programming, 2006.Google ScholarGoogle Scholar
  15. David Herman and Philippe Meunier. Improving the Static Analysis of Embedded Languages via Partial Evaluation. In Proc. ICFP, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Facebook Inc. Flow: A static type checker for JavaScript. http://flowtype.org, 2014.Google ScholarGoogle Scholar
  17. Facebook Inc. Hack. http://hacklang.org, 2014.Google ScholarGoogle Scholar
  18. Kenneth Knowles and Cormac Flanagan. Compositional Reasoning and Decidable Checking for Dependent Contract Types. In Proc. PLPV, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Kenneth Knowles and Cormac Flanagan. Hybrid Type Checking. ACM Trans. Program. Lang. Syst., 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Frederic P. Miller, Agnes F. Vandome, and John McBrewster. Advanced Encryption Standard. Alpha Press, 2009.Google ScholarGoogle Scholar
  21. Xinming Ou, Gang Tan, Yitzhak Mandelbaum, and David Walker. Dynamic Typing with Dependent Types. IFIP Intl. Conf. on Theoretical Computer Science, 2004.Google ScholarGoogle Scholar
  22. Benjamin C. Pierce and David N. Turner. Local Type Inference. ACM Trans. Program. Lang. Syst., 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Patrick M. Rondon, Ming Kawaguci, and Ranjit Jhala. Liquid Types. In Proc. PLDI, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Nikhil Swamy, Juan Chen, Cédric Fournet, Pierre-Yves Strub, Karthikeyan Bhargavan, and Jean Yang. Secure Distributed Programming with Value-dependent Types. In Proc. ICFP, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Nikhil Swamy, Cătălin Hriţcu, Chantal Keller, Aseem Rastogi, Antoine Delignat-Lavaud, Simon Forest, Karthikeyan Bhargavan, Cédric Fournet, Pierre-Yves Strub, Markulf Kohlweiss, Jean-Karim Zinzindohoue, and Santiago Zanella-Béguelin. Dependent Types and Multi-monadic Effects in F*. In Proc. POPL, 2016. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Sam Tobin-Hochstadt and Matthias Felleisen. Interlanguage Migration: From Scripts to Programs. In Proc. DLS, 2006.Google ScholarGoogle Scholar
  27. Sam Tobin-Hochstadt and Matthias Felleisen. Logical Types for Untyped Languages. In Proc. ICFP, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Niki Vazou, Eric L. Seidel, Ranjit Jhala, Dimitrios Vytiniotis, and Simon Peyton-Jones. Refinement Types for Haskell. In Proc. ICFP, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Panagiotis Vekris, Benjamin Cosman, and Ranjit Jhala. Trust, but Verify: Two-Phase Typing for Dynamic Languages. In Proc. ECOOP, 2015.Google ScholarGoogle Scholar
  30. Michael M. Vitousek, Andrew M. Kent, Jeremy G. Siek, and Jim Baker. Design and Evaluation of Gradual Typing for Python. In Proc. DLS, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Stephanie Weirich. Depending on Types. In Proc. ICFP, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. Hongwei Xi. Dependent ML: An Approach to Practical Programming with Dependent Types. J. Functional Programming, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. Hongwei Xi and Frank Pfenning. Eliminating Array Bound Checking Through Dependent Types. In Proc. PLDI, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Occurrence typing modulo theories

      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

      Full Access

      • Published in

        cover image ACM SIGPLAN Notices
        ACM SIGPLAN Notices  Volume 51, Issue 6
        PLDI '16
        June 2016
        726 pages
        ISSN:0362-1340
        EISSN:1558-1160
        DOI:10.1145/2980983
        • Editor:
        • Andy Gill
        Issue’s Table of Contents
        • cover image ACM Conferences
          PLDI '16: Proceedings of the 37th ACM SIGPLAN Conference on Programming Language Design and Implementation
          June 2016
          726 pages
          ISBN:9781450342612
          DOI:10.1145/2908080
          • General Chair:
          • Chandra Krintz,
          • Program Chair:
          • Emery Berger

        Copyright © 2016 ACM

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 2 June 2016

        Check for updates

        Qualifiers

        • article

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader
      About Cookies On This Site

      We use cookies to ensure that we give you the best experience on our website.

      Learn more

      Got it!