Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
article

Occurrence typing modulo theories

Published: 02 June 2016 Publication History

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.
[2]
Ambrose Bonnaire-Sergeant, Rowan Davies, and Sam Tobin-Hochstadt. Practical Optional Types for Clojure. In Proc. ESOP, 2016.
[3]
Chiyan Chen and Hongwei Xi. Combining Programming with Theorem Proving. In Proc. ICFP, 2005.
[4]
Ravi Chugh, David Herman, and Ranjit Jhala. Dependent Types for Javascript. In Proc. OOPSLA, 2012.
[5]
Ravi Chugh, Patrick M. Rondon, and Ranjit Jhala. Nested Refinements: A Logic for Duck Typing. In Proc. POPL, 2012.
[6]
Microsoft Co. Typescript Language Specification. http: //www.typescriptlang.org, 2014.
[7]
George B. Dantzig and B. Curtis Eaves. Fourier-Motzkin Elimination and Its Dual. J. Combinatorial Theory Series A, 1973.
[8]
Leonardo De Moura and Nikolaj Bjorner. Z3: An Efficient SMT Solver. In Proc. TACAS, 2008.
[9]
Matthias Felleisen, Robert Bruce Findler, and Matthew Flatt. Semantics Engineering with PLT Redex. MIT Press, 2009.
[10]
Matthew Flatt and PLT. Reference: Racket. Technical Report PLT-TR-2010-1, PLT Design Inc., 2010.
[11]
https:// racket-lang.org/tr1.
[12]
Matthew Fluet and Riccardo Pucella. Practical Datatype Specializations with Phantom Types and Recursion Schemes. Electronic Notes in Theoretical Computer Science, 2006.
[13]
Michael Greenberg, Benjamin C. Pierce, and Stephanie Weirich. Contracts Made Manifest. In Proc. POPL, 2010.
[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.
[15]
David Herman and Philippe Meunier. Improving the Static Analysis of Embedded Languages via Partial Evaluation. In Proc. ICFP, 2004.
[16]
Facebook Inc. Flow: A static type checker for JavaScript. http://flowtype.org, 2014.
[17]
Facebook Inc. Hack. http://hacklang.org, 2014.
[18]
Kenneth Knowles and Cormac Flanagan. Compositional Reasoning and Decidable Checking for Dependent Contract Types. In Proc. PLPV, 2009.
[19]
Kenneth Knowles and Cormac Flanagan. Hybrid Type Checking. ACM Trans. Program. Lang. Syst., 2010.
[20]
Frederic P. Miller, Agnes F. Vandome, and John McBrewster. Advanced Encryption Standard. Alpha Press, 2009.
[21]
Xinming Ou, Gang Tan, Yitzhak Mandelbaum, and David Walker. Dynamic Typing with Dependent Types. IFIP Intl. Conf. on Theoretical Computer Science, 2004.
[22]
Benjamin C. Pierce and David N. Turner. Local Type Inference. ACM Trans. Program. Lang. Syst., 2000.
[23]
Patrick M. Rondon, Ming Kawaguci, and Ranjit Jhala. Liquid Types. In Proc. PLDI, 2008.
[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.
[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.
[26]
Sam Tobin-Hochstadt and Matthias Felleisen. Interlanguage Migration: From Scripts to Programs. In Proc. DLS, 2006.
[27]
Sam Tobin-Hochstadt and Matthias Felleisen. Logical Types for Untyped Languages. In Proc. ICFP, 2010.
[28]
Niki Vazou, Eric L. Seidel, Ranjit Jhala, Dimitrios Vytiniotis, and Simon Peyton-Jones. Refinement Types for Haskell. In Proc. ICFP, 2014.
[29]
Panagiotis Vekris, Benjamin Cosman, and Ranjit Jhala. Trust, but Verify: Two-Phase Typing for Dynamic Languages. In Proc. ECOOP, 2015.
[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.
[31]
Stephanie Weirich. Depending on Types. In Proc. ICFP, 2014.
[32]
Hongwei Xi. Dependent ML: An Approach to Practical Programming with Dependent Types. J. Functional Programming, 2007.
[33]
Hongwei Xi and Frank Pfenning. Eliminating Array Bound Checking Through Dependent Types. In Proc. PLDI, 1998.

Cited By

View all
  • (2024)Refinement Type RefutationsProceedings of the ACM on Programming Languages10.1145/36897458:OOPSLA2(962-987)Online publication date: 8-Oct-2024
  • (2023)Correctness-by-Construction Meets Refinement TypesProceedings of the 25th ACM International Workshop on Formal Techniques for Java-like Programs10.1145/3605156.3606449(8-10)Online publication date: 18-Jul-2023
  • (2023)What Types Are Needed for Typing Dynamic Objects? A Python-Based Empirical StudyProgramming Languages and Systems10.1007/978-981-99-8311-7_2(24-45)Online publication date: 26-Nov-2023
  • Show More Cited By

Index Terms

  1. Occurrence typing modulo theories

      Recommendations

      Comments

      Information & Contributors

      Information

      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
      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 the author(s) 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: 02 June 2016
      Published in SIGPLAN Volume 51, Issue 6

      Check for updates

      Author Tags

      1. Racket
      2. Refinement types
      3. occurrence typing

      Qualifiers

      • Article

      Contributors

      Other Metrics

      Bibliometrics & Citations

      Bibliometrics

      Article Metrics

      • Downloads (Last 12 months)29
      • Downloads (Last 6 weeks)2
      Reflects downloads up to 27 Jan 2025

      Other Metrics

      Citations

      Cited By

      View all
      • (2024)Refinement Type RefutationsProceedings of the ACM on Programming Languages10.1145/36897458:OOPSLA2(962-987)Online publication date: 8-Oct-2024
      • (2023)Correctness-by-Construction Meets Refinement TypesProceedings of the 25th ACM International Workshop on Formal Techniques for Java-like Programs10.1145/3605156.3606449(8-10)Online publication date: 18-Jul-2023
      • (2023)What Types Are Needed for Typing Dynamic Objects? A Python-Based Empirical StudyProgramming Languages and Systems10.1007/978-981-99-8311-7_2(24-45)Online publication date: 26-Nov-2023
      • (2020)Taming type annotations in gradual typingProceedings of the ACM on Programming Languages10.1145/34282594:OOPSLA(1-30)Online publication date: 13-Nov-2020
      • (2019)Verifiable Certificates for Predicate SubtypingProgramming Languages and Systems10.1007/978-3-030-17184-1_16(440-466)Online publication date: 6-Apr-2019
      • (2024)Mechanizing Refinement TypesProceedings of the ACM on Programming Languages10.1145/36329128:POPL(2099-2128)Online publication date: 5-Jan-2024
      • (2022)Revisiting occurrence typingScience of Computer Programming10.1016/j.scico.2022.102781217:COnline publication date: 1-May-2022
      • (2022)Embedded Domain Specific VerifiersPrinciples of Systems Design10.1007/978-3-031-22337-2_26(535-553)Online publication date: 29-Dec-2022
      • (2020)Taming type annotations in gradual typingProceedings of the ACM on Programming Languages10.1145/34282594:OOPSLA(1-30)Online publication date: 13-Nov-2020
      • (2020)JavaScript AOT compilationACM SIGPLAN Notices10.1145/3393673.327695053:8(50-63)Online publication date: 6-Apr-2020
      • 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

      Figures

      Tables

      Media

      Share

      Share

      Share this Publication link

      Share on social media