Abstract
We study a first-order functional language with the novel combination of the ideas of refinement type (the subset of a type to satisfy a Boolean expression) and type-test (a Boolean expression testing whether a value belongs to a type). Our core calculus can express a rich variety of typing idioms; for example, intersection, union, negation, singleton, nullable, variant, and algebraic types are all derivable. We formulate a semantics in which expressions denote terms, and types are interpreted as first-order logic formulas. Subtyping is defined as valid implication between the semantics of types. The formulas are interpreted in a specific model that we axiomatize using standard first-order theories. On this basis, we present a novel type-checking algorithm able to eliminate many dynamic tests and to detect many errors statically. The key idea is to rely on an SMT solver to compute subtyping efficiently. Moreover, interpreting types as formulas allows us to call the SMT solver at run-time to compute instances of types.
Supplemental Material
- }}The Microsoft code name "M" Modeling Language Specification Version 0.5. Microsoft Corporation, Oct. 2009. Preliminary implementation available as part of the SQL Server Modeling CTP (November 2009).Google Scholar
- }}A. Aiken and E. Wimmers. Type inclusion constraints and type inference. In Proceedings of ICFP, 1993. Google Scholar
Digital Library
- }}D. Aspinall and M. Hofmann. Dependent types. In Advanced Topics in Types and Programming Languages, chapter 2. MIT Press, 2005.Google Scholar
- }}C. Barrett, M. Deters, A. Oliveras, and A. Stump. Design and results of the 3rd Annual SMT Competition. International Journal on Artificial Intelligence Tools, 17(4):569--606, 2008.Google Scholar
Cross Ref
- }}C. Barrett and C. Tinelli. CVC3. In Proceedings of CAV, 2007. Google Scholar
Digital Library
- }}J. Bengtson, K. Bhargavan, C. Fournet, A. D. Gordon, and S. Maffeis. Refinement types for secure implementations. In Proceedings of CSF, 2008. Google Scholar
Digital Library
- }}V. Benzaken, G. Castagna, and A. Frisch. CDuce: An XML-friendly general purpose language. In Proceedings of ICFP, 2003. Google Scholar
Digital Library
- }}G. M. Bierman, A. D. Gordon, C. Hriţcu, and D. Langworthy. Semantic subtyping with an SMT solver. Technical Report MSR--TR--2010--99, Microsoft Research, July 2010.Google Scholar
Digital Library
- }}P. Buneman, S. Naqvi, V. Tannen, and L. Wong. Principles of programming with complex objects and collection types. Theoretical Computer Science, 149(1):3--48, 1995. Google Scholar
Digital Library
- }}R. M. Burstall, D. B. MacQueen, and D. Sannella. HOPE: An experimental applicative language. In LISP Conference, pages 136--143, 1980. Google Scholar
Digital Library
- }}D. Crockford. The application/json media type for JavaScript Object Notation (JSON), July 2006. RFC 4627.Google Scholar
- }}F. Damm. Subtyping with union types, intersection types and recursive types. In Proceedings of TACS, 1994. Google Scholar
Digital Library
- }}L. de Moura and N. Bjørner. Z3: An efficient SMT solver. In Proceedings of TACAS, 2008. Google Scholar
Digital Library
- }}L. M. de Moura and N. Bjørner. Generalized, efficient array decision procedures. In FMCAD, 2009.Google Scholar
- }}D. Detlefs, G. Nelson, and J. B. Saxe. Simplify: a theorem prover for program checking. J. ACM, 52(3):365--473, 2005. Google Scholar
Digital Library
- }}J. Dunfield and F. Pfenning. Tridirectional typechecking. In Proceedings of POPL, pages 281--292, 2004. Google Scholar
Digital Library
- }}B. Dutertre and L. de Moura. The YICES SMT solver. Available at http://yices.csl.sri.com/tool-paper.pdf, 2006.Google Scholar
- }}R. Findler and M. Felleisen. Contracts for higher-order functions. In ICFP, 2002. Google Scholar
Digital Library
- }}K. Fisher, Y. Mandelbaum, and D. Walker. The next 700 data description languages. In Proceedings of POPL, 2006. Google Scholar
Digital Library
- }}C. Flanagan. Hybrid type checking. In Proceedings of POPL, 2006. Google Scholar
Digital Library
- }}T. Freeman and F. Pfenning. Refinement types for ML. In Proceedings of PLDI, 1991. Google Scholar
Digital Library
- }}A. Frisch, G. Castagna, and V. Benzaken. Semantic subtyping: Dealing set-theoretically with function, union, intersection, and negation types. J. ACM, 55(4), 2008. Google Scholar
Digital Library
- }}A. D. Gordon and A. Jeffrey. Typing one-to-one and one-to-many correspondences in security protocols. In Proceedings of ISSS, 2002. Google Scholar
Digital Library
- }}H. Hosoya, J. Vouillon, and B. Pierce. Regular expression types for XML. In Proceedings of ICFP, 2000. Google Scholar
Digital Library
- }}C. Jones. Systematic software development using VDM. Prentice-Hall Englewood Cliffs, NJ, 1986. Google Scholar
Digital Library
- }}K. Knowles, A. Tomb, J. Gronski, S. Freund, and C. Flanagan. Sage: Unified hybrid checking for first-class types, general refinement types and Dynamic. Technical report, UCSC, 2007.Google Scholar
- }}A. Kopylov. Dependent intersection: A new way of defining records in type theory. In LICS, pages 86--95. IEEE Computer Society, 2003. Google Scholar
Digital Library
- }}K. R. M. Leino and R. Monahan. Reasoning about comprehensions with first-order SMT solvers. In Proceedings of SAC, 2009. Google Scholar
Digital Library
- }}W. Lovas and F. Pfenning. A bidirectional refinement type system for LF. In Proceedings of LFMTP, 2007.Google Scholar
- }}E. Meijer, B. Beckman, and G. Bierman. LINQ: Reconciling objects, relations and XML in the .NET framework. In Proceedings of SIGMOD, 2007. Google Scholar
Digital Library
- }}J. Meng and L. C. Paulson. Translating higher-order problems to first-order clauses. Journal of Automated Reasoning, 40(1):35--60, 2008. Google Scholar
Digital Library
- }}B. Meyer. Eiffel: the language. Prentice Hall, 1992. Google Scholar
Digital Library
- }}B. Nordström and K. Petersson. Types and specifications. In IFIP'83, 1983.Google Scholar
- }}B. C. Pierce. Types and Programming Languages. MIT Press, 2002. Google Scholar
Digital Library
- }}B. C. Pierce and D. N. Turner. Local type inference. In Proceedings of POPL, 1998. Google Scholar
Digital Library
- }}S. Ranise and C. Tinelli. The SMT-LIB Standard: Version 1.2, 2006.Google Scholar
- }}J. C. Reynolds. Design of the programming language Forsythe. In Algol-Like Languages, chapter 8. Birkhäser, 1996. Google Scholar
Digital Library
- }}P. Rondon, M. Kawaguchi, and R. Jhala. Liquid types. In Proceedings of PLDI, 2008. Google Scholar
Digital Library
- }}J. Rushby, S. Owre, and N. Shankar. Subtypes for specifications: Predicate subtyping in PVS. IEEE Transactions on Software Engineering, 24(9):709--720, 1998. Google Scholar
Digital Library
- }}V. Saraswat, N. Nystrom, J. Palsberg, and C. Grothoff. Constrained types for object-oriented languages. In Proceedings of OOPSLA, 2008. Google Scholar
Digital Library
- }}M. Sozeau. Subset coercions in Coq. In Proceedings of TYPES, 2006. Google Scholar
Digital Library
- }}S. Tobin-Hochstadt and M. Felleisen. Logical types for Scheme. In Proceedings of ICFP, 2010.Google Scholar
- }}H. Xi and F. Pfenning. Dependent types in practical programming. In Proceedings of POPL, 1999. Google Scholar
Digital Library
Index Terms
Semantic subtyping with an SMT solver
Recommendations
Semantic subtyping: Dealing set-theoretically with function, union, intersection, and negation types
Subtyping relations are usually defined either syntactically by a formal system or semantically by an interpretation of types into an untyped denotational model. This work shows how to define a subtyping relation semantically in the presence of Boolean ...
Semantic subtyping with an SMT solver
ICFP '10: Proceedings of the 15th ACM SIGPLAN international conference on Functional programmingWe study a first-order functional language with the novel combination of the ideas of refinement type (the subset of a type to satisfy a Boolean expression) and type-test (a Boolean expression testing whether a value belongs to a type). Our core ...
Semantic subtyping with an smt solver
We study a first-order functional language with the novel combination of the ideas of refinement type (the subset of a type to satisfy a Boolean expression) and type-test (a Boolean expression testing whether a value belongs to a type). Our core ...







Comments