Hostname: page-component-7c8c6479df-ws8qp Total loading time: 0 Render date: 2024-03-17T15:42:39.465Z Has data issue: false hasContentIssue false

Semantic subtyping with an SMT solver

Published online by Cambridge University Press:  06 March 2012

GAVIN M. BIERMAN
Affiliation:
Microsoft Research, Cambridge, UK (e-mail: gmb@microsoft.com, adg@microsoft.com)
ANDREW D. GORDON
Affiliation:
Microsoft Research, Cambridge, UK (e-mail: gmb@microsoft.com, adg@microsoft.com)
CĂTĂLIN HRIŢCU
Affiliation:
Saarland University and University of Pennyslvania, Philadelphia, PA, USA (e-mail: catalin.hritcu@gmail.com)
DAVID LANGWORTHY
Affiliation:
Microsoft Corporation, Redmond, WA (e-mail: dlan@microsoft.com)
Rights & Permissions [Opens in a new window]

Abstract

Core share and HTML view are not available for this content. However, as you have access to this content, a full PDF is available via the ‘Save PDF’ action button.

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 a Satisfiability Modulo Theories solver to compute subtyping efficiently. Moreover, using a satisfiability modulo theories solver allows us to show the uniqueness of normal forms for non-deterministic expressions, provide precise counterexamples when type-checking fails, detect empty types, and compute instances of types statically and at run-time.

Type
Articles
Copyright
Copyright © Cambridge University Press 2012

References

Abiteboul, S., Buneman, P. & Suciu, D. (2000) Data on the Web. San Fransisco, CA: Morgan Kaufmann.Google Scholar
Aiken, A. & Wimmers, E. (1993) Type inclusion constraints and type inference. In the Proceedings of ICFP 03, the Eighth ACM SIGPLAN International Conference on Functional Programming, ACM, New York, USA.Google Scholar
Aiken, A., Wimmers, E. L. & Lakshman, T. K. (1994) Soft typing with conditional types. In the Proceedings of the 21st ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL), ACM, New York, USA.Google Scholar
Aspinall, D. 1994 Subtyping with singleton types. In the Proceedings of CSL, LNCS vol. 933. Heidelberg, Germany: Springer.Google Scholar
Aspinall, D. & Hofmann, M. (2005) Dependent types. In Advanced Topics in Types and Programming Languages, chapter 2. Cambridge, MA: MIT Press.Google Scholar
Backes, M., Hriţcu, C. & Tarrach, T. (2011) Automatically verifying typing constraints for a data processing language. In the Proceedings of CPP, the 11th Generative Approaches to Second Language Acquisition Conference (GASLA 2011). Somerville, MA: CPP.Google Scholar
Barnett, M., Chang, B.-Y. E., DeLine, R., Jacobs, B. & Leino, K. R. M. 2005 Boogie: A modular reusable verifier for object-oriented programs. In the Proceedings of FMCO, Amsterdam, The Netherlands, LNCS vol. 4111.Google Scholar
Barrett, C., Deters, M., Oliveras, A. & Stump, A. (2008) Design and results of the 3rd Annual SMT Competition (SMT-COMP 2007). Int. J. Artif. Intell. Tools. 17 (4), 569606.CrossRefGoogle Scholar
Barrett, C. & Tinelli, C. (2007) CVC3. In the Proceedings of CAV, Berlin, Germany, LNCS vol. 4590.Google Scholar
Bengtson, J., Bhargavan, K., Fournet, C., Gordon, A. D. & Maffeis, S. (2008) Refinement types for secure implementations. In the Proceedings of CSF, Pittsburgh, PA, USA.Google Scholar
Benzaken, V., Castagna, G. & Frisch, A. (2003) CDuce: An XML-friendly general purpose language. In the Proceedings of the Eighth ACM SIGPLAN International Conference on Functional Programming (ICFP), Uppsala, Sweden.Google Scholar
Bierman, G. M., Gordon, A. D., Hriţcu, C. & Langworthy, D. (2010a) Semantic Subtyping with an SMT Solver. Technical Report MSR-TR-2010-99, Microsoft Research, Redmond, WA.CrossRefGoogle Scholar
Bierman, G. M., Gordon, A. D., Hriţcu, C. & Langworthy, D. (2010b) Semantic subtyping with an SMT solver. In the Proceedings of the 15th ACM SIGPLAN International Conference on Functional Programming (ICFP), Baltimore, MD, USA.Google Scholar
Bierman, G. M., Meijer, E. & Torgersen, M. (2007) Lost in translation: Formalizing proposed extensions to C#. In the Proceedings of the 15th ACM SIGPLAN International Conference on Functional Programming (OOPSLA), Baltimore, MD, USA.Google Scholar
Böhme, S., Leino, K. R. M. & Wolff, B. (2008) HOL-Boogie – an interactive prover for the Boogie program-verifier. In the Proceedings of TPHOLs, Montreal, Canada, LNCS vol. 5170.Google Scholar
Box, D. (2010) Update on SQL Server Modeling CTP (Repository/Modeling Services, “Quadrant” and “M”). Accessed September 22, 2010. Blog available at http://blogs.msdn.com/b/modelcitizenGoogle Scholar
Boyer, R. S., Kaufmann, M. & Moore, J. S. (1995) The Boyer-Moore theorem prover and its interactive enhancement. Comput. Math. Appl. 29 (2), 2762.CrossRefGoogle Scholar
Buneman, P., Naqvi, S., Tannen, V. & Wong, L. (1995) Principles of programming with complex objects and collection types. Theor. Comput. Sci. 149 (1), 348.CrossRefGoogle Scholar
Buneman, P. & Pierce, B. C. (1999) Union types for semi-structured data. In the Proceedings of DBPL, Kinloch Rannoch, Scotland, UK, LNCS vol. 1949.Google Scholar
Burstall, R. M., MacQueen, D. B. & Sannella, D. (1980) HOPE: An experimental applicative language. In the Proceedings of LISP Conference, Stanford, CA, USA.Google Scholar
Calcagno, C., Cardelli, L. & Gordon, A. D. (2005) Deciding validity in a spatial logic for trees. J. Funct. Program. 15, 543572.CrossRefGoogle Scholar
Cartwright, R. & Fagan, M. (1991) Soft typing. In the Proceedings of PLDI, Toronto, Ontario, Canada.Google Scholar
Castagna, G. (2005) Patterns and types for querying XML documents. In the Proceedings of DBPL, Trondheim, Norway, LNCS vol. 3774.Google Scholar
Castagna, G. & Chen, G. (2001) Dependent types with subtyping and late-bound overloading. Inf. Comput. 168 (1), 167.CrossRefGoogle Scholar
Cohen, S. (2006) User-defined aggregate functions: Bridging theory and practice. In the Proceedings of SIGMOD, Chicago, IL, USA.Google Scholar
Crockford, D. (2006) The Application/Json Media Type for JavaScript Object Notation (JSON). RFC 4627. Reston, VA: The Internet Society.CrossRefGoogle Scholar
Damm, F. (1994) Subtyping with union types, intersection types and recursive types. In the Proceedings of TACS, Sendai, Japan.Google Scholar
de Moura, L. M. & Bjørner, N. (2007) Efficient E-matching for SMT solvers. In the Proceedings of CADE-21, Bremen, Germany, LNCS vol. 4603. Heidelberg, Germany: Springer, pp. 183198.Google Scholar
de Moura, L. M. & Bjørner, N. (2008) Z3: An efficient SMT solver. In the Proceedings of TACAS, Budapest, Hungary.Google Scholar
de Moura, L. M. & Bjørner, N. (2009) Generalized, efficient array decision procedures. In Proceedings of FMCAD, Austin, TX, USA.Google Scholar
Detlefs, D., Nelson, G. & Saxe, J. B. (2005) Simplify: A theorem prover for program checking. J. ACM. 52 (3), 365473.CrossRefGoogle Scholar
Dunfield, J. (Aug. 2007) A Unified System of Type Refinements. PhD. thesis, CMU-CS-07-129, Carnegie Mellon University, Pittsburgh, PA.Google Scholar
Dunfield, J. & Pfenning, F. (2004) Tridirectional typechecking. In the Proceedings of the 31st ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL, Venice, Italy.Google Scholar
Dutertre, B. & de Moura, L. M.. The YICES SMT solver. Accessed February 27, 2012. Available at: http://yices.csl.sri.com/tool-paper.pdf, 2006.Google Scholar
Findler, R. & Felleisen, M. (2002) Contracts for higher-order functions. In the Proceedings of the SeventhACM SIGPLAN International Conference on Functional Programming (ICFP '02), Pittsburgh, PA, USA.Google Scholar
Fisher, K., Mandelbaum, Y. & Walker, D. (2006) The next 700 data description languages. In the Proceedings of the Symposium on Principles of Programming Languages (POPL), Charleston, SC.Google Scholar
Flanagan, C. (2006) Hybrid-type checking. In the Proceedings of the Symposium on Principles of Programming Languages (POPL), Charleston, SC.Google Scholar
Freeman, T. & Pfenning, F. (1991) Refinement types for ML. In the Proceedings of the ACM SIGPLAN'91 Conference on Programming Language Design and Implementation (PLDI), Toronto, Ontario, Canada.Google Scholar
Frisch, A., Castagna, G. & Benzaken, V. (2008) Semantic subtyping: Dealing set-theoretically with function, union, intersection, and negation types. J. ACM 55 (4), 19:119:64.CrossRefGoogle Scholar
Genevès, P., Layaïda, N. & Schmitt, A. (2007) Efficient static analysis of XML paths and types. In the Proceedings of the ACM SIGPLAN 2007 Conference on Programming Language Design and Implementation (PLDI), San Diego, CA, USA.Google Scholar
Giesl, J. (1997) Termination of nested and mutually recursive algorithms. J. Autom. Reasoning 19, 129.CrossRefGoogle Scholar
Gordon, A. D. & Jeffrey, A. (2002) Typing one-to-one and one-to-many correspondences in security protocols. In the Proceedings of ISSS, Kyoto, Japan.Google Scholar
Greenberg, M., Pierce, B. & Weirich, S. (2010) Contracts made manifest. In the Proceedings of the 37th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL), Madrid, Spain.Google Scholar
Greve, D. A., Kaufmann, M., Manolios, P., Moore, J. S., Ray, S., Ruiz-Reina, J.-L., Sumners, R., Vroon, D. & Wilding, M. (2008) Efficient execution in an automated reasoning environment. J. Funct. Program. 18 (1), 1546.CrossRefGoogle Scholar
Hosoya, H. & Pierce, B. (2003) XDuce: A statically typed XML processing language. ACM Trans. Internet Technol. 3 (2), 117148.CrossRefGoogle Scholar
Hosoya, H., Vouillon, J. & Pierce, B. (2000) Regular expression types for XML. In the Proceedings of the Fifth ACM SIGPLAN International Conference on Functional Programming (ICFP), Montreal, Canada.Google Scholar
Jaffar, J. & Maher, M. J. (1994) Constraint logic programming: A survey. J. Log. Algebr. Program. 19 (20), 503581.CrossRefGoogle Scholar
Jhala, R., Majumdar, R. & Rybalchenko, A. (2011) HMC: Verifying functional programs using abstract interpreters. In the Proceedings of CAV, Snowbird, UT, USA. DBLP, pp. 470485.Google Scholar
Jhala, R., Majumdar, R. & Xu, R.-G. (2007) State of the union: Type inference via Craig interpolation. In the Proceedings of TACAS, Braga, Portugal.Google Scholar
Jones, C. (1986) Systematic Software Development Using VDM. Upper Saddle River, NJ: Prentice-Hall.Google Scholar
Kawaguchi, M., Rondon, P. M. & Jhala, R. (2009) Type-based data structure verification. In the Proceedings of the 2009 ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI), Dublin, Ireland. New York: ACM, pp. 304315.CrossRefGoogle Scholar
King, J. C. (1976) Symbolic execution and program testing. Commun. ACM. 19, 385394.CrossRefGoogle Scholar
Knowles, K., Tomb, A., Gronski, J., Freund, S. & Flanagan, C. (2007) Sage: Unified Hybrid Checking for First-Class Types, General Refinement Types and Dynamic. Technical Report, UCSC, Santa Cruz, CA.Google Scholar
Knowles, K. W. & Flanagan, C. (2010) Hybrid type checking. ACM TOPLAS 32 (2), 6:16:34.CrossRefGoogle Scholar
Komondoor, R., Ramalingam, G., Chandra, S. & Field, J. (2005) Dependent types for program understanding. In the Proceedings of the Eleventh International Conference on Tools and Algorithms for the Construction and Analysis of Systems (TACAS), Edinburgh, UK.Google Scholar
Kopylov, A. (2003) Dependent intersection: A new way of defining records in type theory. In the Proceedings of the 18th IEEE Symposium on Logic in Computer Science (LICS), Ottawa, Canada.Google Scholar
Kuncak, V., Mayer, M., Piskac, R. & Suter, P. (2010) Complete functional synthesis. In the Proceedings of the 2010 ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI). New York: ACM, pp. 316329.CrossRefGoogle Scholar
Leino, K. R. M. & Monahan, R. (2009) Reasoning about comprehensions with first-order SMT solvers. In the Proceedings of the ACM Symposium on Applied Computing (SAC), Honolulu, HI, USA.Google Scholar
Lerner, B., Flower, M., Grossman, D. & Chambers, C. (2007) Searching for type-error messages. In the Proceedings of PLDI, San Diego, CA, USA.Google Scholar
Lovas, W. & Pfenning, F. (2007) A bidirectional refinement type system for LF. In the Proceedings of LFMTP, Bremen, Germany.Google Scholar
McCarthy, J. (1962) Towards a mathematical science of computation. In the Proceedings of IFIP Congress, Munich, Germany.Google Scholar
Meijer, E., Beckman, B. & Bierman, G. M. (2007) LINQ: Reconciling objects, relations and XML in the .NET framework. In the Proceedings of SIGMOD, Beijing, China.Google Scholar
Meng, J. & Paulson, L. C. (2008) Translating higher-order problems to first-order clauses. J. Autom. Reasoning 40 (1), 3560.CrossRefGoogle Scholar
Meyer, B. 1992 Eiffel: The Language. Upper Saddle River, NJ: Prentice Hall.Google Scholar
Microsoft Corporation (Oct. 2009) The Microsoft Code Name “M” Modeling Language Specification Version 0.5. Preliminary implementation available as part of the SQL Server Modeling CTP (November 2009). Redmond, WA: Microsoft Corp.Google Scholar
Nordström, B. & Petersson, K. (1983) Types and specifications. In the Proceedings of IFIP, Paris, France.Google Scholar
Pierce, B. C. (1991) Programming with Intersection Types, Union Types, and Polymorphism. Technical Report CMU-CS-91-106, Carnegie Mellon University, Pittsburgh, PA.Google Scholar
Pierce, B. C. (2002) Types and Programming Languages. Cambridge, MA: MIT Press.Google Scholar
Pierce, B. C. & Turner, D. N. (2000) Local type inference. ACM Trans. Program. Lang. Syst. 22 (1), 144.CrossRefGoogle Scholar
Pratt, V. (1983) Five paradigm shifts in programming language design and their realization in Viron, a dataflow programming environment. In the Proceedings of POPL, Austin, TX, USA.Google Scholar
Ranise, S. & Tinelli, C. (2006) The SMT-LIB Standard: Version 1.2. Technical Report, Department. of Computer Science, The University of Iowa, Iowa.Google Scholar
Reynolds, J. C. (1996) Design of the programming language Forsythe. In Algol-Like Languages, O'Hearn, P. W. & Tennant, R. D. (eds), chapter 8. Basel, Switzerland: Birkhäser, pp. 173234.Google Scholar
Rondon, P., Kawaguchi, M. & Jhala, R. (2008) Liquid types. In the Proceedings of PLDI, Tucson, AZ, USA.Google Scholar
Rushby, J., Owre, S. & Shankar, N. (1998) Subtypes for specifications: Predicate subtyping in PVS. IEEE Trans. Softw. Eng. 24 (9), 709720.CrossRefGoogle Scholar
Saraswat, V., Nystrom, N., Palsberg, J. & Grothoff, C. (2008) Constrained types for object-oriented languages. In the Proceedings of OOPSLA, Nashville, TN, USA.Google Scholar
Siméon, J. & Wadler, P. (2003) The essence of XML. In the Proceedings of POPL, New Orleans, USA.Google Scholar
Sozeau, M. (2006) Subset coercions in Coq. In the Proceedings of TYPES, Nottingham, UK, LNCS vol. 4502.Google Scholar
Swamy, N., Chen, J. & Chugh, R. (2010) Enforcing stateful authorization and information flow policies in Fine. In the Proceedings of ESOP, Paphos, Cyprus.Google Scholar
Terauchi, T. (2010) Dependent types from counterexamples. In the Proceedings of POPL, Madrid, Spain.Google Scholar
Tobin-Hochstadt, S. & Felleisen, M. (2008) The design and implementation of Typed Scheme. In the Proceedings of the 35th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL), San Francisco, CA, USA.Google Scholar
Tobin-Hochstadt, S. & Felleisen, M. (2010) Logical types for untyped languages. In the Proceedings of the 15th ACM SIGPLAN International Conference on Functional Programming (ICFP), Baltimore, MD, USA.Google Scholar
TypiCal Project 2009 The Coq Proof Assistant. Version 8.2. Accessed February 27, 2012. Available at: http://coq.inria.fr.Google Scholar
Unno, H. & Kobayashi, N. (2009) Dependent type inference with interpolants. In the Proceedings of the 11th International ACM SIGPLAN Conference on Principles and Practice of Declarative Programming (PPDP), Coimbra, Portugal.Google Scholar
Wright, A. K. & Cartwright, R. (1997) A practical soft type system for scheme. ACM TOPLAS 19, 87152.CrossRefGoogle Scholar
Wright, A. K. & Felleisen, M. (1994) A syntactic approach to type soundness. Inf. Comput. 115 (1), 3894.CrossRefGoogle Scholar
Xi, H. & Pfenning, F. (1999) Dependent types in practical programming. In the Proceedings of the 26th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL), San Antonio, TX, USA.Google Scholar
Submit a response

Discussions

No Discussions have been published for this article.