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%.
- Esteban Allende, Oscar Callau, Johan Fabry, Éric Tanter, and Marcus Denker. Gradual Typing for Smalltalk. Science of Computer Programming, 2014. Google Scholar
Digital Library
- Ambrose Bonnaire-Sergeant, Rowan Davies, and Sam Tobin-Hochstadt. Practical Optional Types for Clojure. In Proc. ESOP, 2016.Google Scholar
- Chiyan Chen and Hongwei Xi. Combining Programming with Theorem Proving. In Proc. ICFP, 2005. Google Scholar
Digital Library
- Ravi Chugh, David Herman, and Ranjit Jhala. Dependent Types for Javascript. In Proc. OOPSLA, 2012. Google Scholar
Digital Library
- Ravi Chugh, Patrick M. Rondon, and Ranjit Jhala. Nested Refinements: A Logic for Duck Typing. In Proc. POPL, 2012. Google Scholar
Digital Library
- Microsoft Co. Typescript Language Specification. http: //www.typescriptlang.org, 2014.Google Scholar
- George B. Dantzig and B. Curtis Eaves. Fourier-Motzkin Elimination and Its Dual. J. Combinatorial Theory Series A, 1973.Google Scholar
- Leonardo De Moura and Nikolaj Bjorner. Z3: An Efficient SMT Solver. In Proc. TACAS, 2008. Google Scholar
Digital Library
- Matthias Felleisen, Robert Bruce Findler, and Matthew Flatt. Semantics Engineering with PLT Redex. MIT Press, 2009. Google Scholar
Digital Library
- Matthew Flatt and PLT. Reference: Racket. Technical Report PLT-TR-2010-1, PLT Design Inc., 2010.Google Scholar
- https:// racket-lang.org/tr1.Google Scholar
- Matthew Fluet and Riccardo Pucella. Practical Datatype Specializations with Phantom Types and Recursion Schemes. Electronic Notes in Theoretical Computer Science, 2006. Google Scholar
Digital Library
- Michael Greenberg, Benjamin C. Pierce, and Stephanie Weirich. Contracts Made Manifest. In Proc. POPL, 2010. Google Scholar
Digital Library
- 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 Scholar
- David Herman and Philippe Meunier. Improving the Static Analysis of Embedded Languages via Partial Evaluation. In Proc. ICFP, 2004. Google Scholar
Digital Library
- Facebook Inc. Flow: A static type checker for JavaScript. http://flowtype.org, 2014.Google Scholar
- Facebook Inc. Hack. http://hacklang.org, 2014.Google Scholar
- Kenneth Knowles and Cormac Flanagan. Compositional Reasoning and Decidable Checking for Dependent Contract Types. In Proc. PLPV, 2009. Google Scholar
Digital Library
- Kenneth Knowles and Cormac Flanagan. Hybrid Type Checking. ACM Trans. Program. Lang. Syst., 2010. Google Scholar
Digital Library
- Frederic P. Miller, Agnes F. Vandome, and John McBrewster. Advanced Encryption Standard. Alpha Press, 2009.Google Scholar
- Xinming Ou, Gang Tan, Yitzhak Mandelbaum, and David Walker. Dynamic Typing with Dependent Types. IFIP Intl. Conf. on Theoretical Computer Science, 2004.Google Scholar
- Benjamin C. Pierce and David N. Turner. Local Type Inference. ACM Trans. Program. Lang. Syst., 2000. Google Scholar
Digital Library
- Patrick M. Rondon, Ming Kawaguci, and Ranjit Jhala. Liquid Types. In Proc. PLDI, 2008. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- Sam Tobin-Hochstadt and Matthias Felleisen. Interlanguage Migration: From Scripts to Programs. In Proc. DLS, 2006.Google Scholar
- Sam Tobin-Hochstadt and Matthias Felleisen. Logical Types for Untyped Languages. In Proc. ICFP, 2010. Google Scholar
Digital Library
- Niki Vazou, Eric L. Seidel, Ranjit Jhala, Dimitrios Vytiniotis, and Simon Peyton-Jones. Refinement Types for Haskell. In Proc. ICFP, 2014. Google Scholar
Digital Library
- Panagiotis Vekris, Benjamin Cosman, and Ranjit Jhala. Trust, but Verify: Two-Phase Typing for Dynamic Languages. In Proc. ECOOP, 2015.Google Scholar
- 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 Scholar
Digital Library
- Stephanie Weirich. Depending on Types. In Proc. ICFP, 2014. Google Scholar
Digital Library
- Hongwei Xi. Dependent ML: An Approach to Practical Programming with Dependent Types. J. Functional Programming, 2007. Google Scholar
Digital Library
- Hongwei Xi and Frank Pfenning. Eliminating Array Bound Checking Through Dependent Types. In Proc. PLDI, 1998. Google Scholar
Digital Library
Index Terms
Occurrence typing modulo theories
Recommendations
Occurrence typing modulo theories
PLDI '16: Proceedings of the 37th ACM SIGPLAN Conference on Programming Language Design and ImplementationWe 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 ...
Gradual liquid type inference
Refinement types allow for lightweight program verification by enriching types with logical predicates. Liquid typing provides a decidable refinement inference mechanism that is convenient but subject to two major issues: (1) inference is global and ...
Revisiting occurrence typing
AbstractWe revisit occurrence typing, a technique to refine the type of variables occurring in type-cases and, thus, capture some programming patterns used in untyped languages. Although occurrence typing was tied from its inception to set-...







Comments