Skip to main content
×
Home

Semantic subtyping with an SMT solver

  • GAVIN M. BIERMAN (a1), ANDREW D. GORDON (a1), CĂTĂLIN HRIŢCU (a2) and DAVID LANGWORTHY (a3)
Abstract
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 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.

Copyright
References
Hide All
Abiteboul S., Buneman P. & Suciu D. (2000) Data on the Web. San Fransisco, CA: Morgan Kaufmann.
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.
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.
Aspinall D. 1994 Subtyping with singleton types. In the Proceedings of CSL, LNCS vol. 933. Heidelberg, Germany: Springer.
Aspinall D. & Hofmann M. (2005) Dependent types. In Advanced Topics in Types and Programming Languages, chapter 2. Cambridge, MA: MIT Press.
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.
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.
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.
Barrett C. & Tinelli C. (2007) CVC3. In the Proceedings of CAV, Berlin, Germany, LNCS vol. 4590.
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.
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.
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.
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.
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.
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.
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/modelcitizen
Boyer R. S., Kaufmann M. & Moore J. S. (1995) The Boyer-Moore theorem prover and its interactive enhancement. Comput. Math. Appl. 29 (2), 2762.
Buneman P., Naqvi S., Tannen V. & Wong L. (1995) Principles of programming with complex objects and collection types. Theor. Comput. Sci. 149 (1), 348.
Buneman P. & Pierce B. C. (1999) Union types for semi-structured data. In the Proceedings of DBPL, Kinloch Rannoch, Scotland, UK, LNCS vol. 1949.
Burstall R. M., MacQueen D. B. & Sannella D. (1980) HOPE: An experimental applicative language. In the Proceedings of LISP Conference, Stanford, CA, USA.
Calcagno C., Cardelli L. & Gordon A. D. (2005) Deciding validity in a spatial logic for trees. J. Funct. Program. 15, 543572.
Cartwright R. & Fagan M. (1991) Soft typing. In the Proceedings of PLDI, Toronto, Ontario, Canada.
Castagna G. (2005) Patterns and types for querying XML documents. In the Proceedings of DBPL, Trondheim, Norway, LNCS vol. 3774.
Castagna G. & Chen G. (2001) Dependent types with subtyping and late-bound overloading. Inf. Comput. 168 (1), 167.
Cohen S. (2006) User-defined aggregate functions: Bridging theory and practice. In the Proceedings of SIGMOD, Chicago, IL, USA.
Crockford D. (2006) The Application/Json Media Type for JavaScript Object Notation (JSON). RFC 4627. Reston, VA: The Internet Society.
Damm F. (1994) Subtyping with union types, intersection types and recursive types. In the Proceedings of TACS, Sendai, Japan.
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.
de Moura L. M. & Bjørner N. (2008) Z3: An efficient SMT solver. In the Proceedings of TACAS, Budapest, Hungary.
de Moura L. M. & Bjørner N. (2009) Generalized, efficient array decision procedures. In Proceedings of FMCAD, Austin, TX, USA.
Detlefs D., Nelson G. & Saxe J. B. (2005) Simplify: A theorem prover for program checking. J. ACM. 52 (3), 365473.
Dunfield J. (Aug. 2007) A Unified System of Type Refinements. PhD. thesis, CMU-CS-07-129, Carnegie Mellon University, Pittsburgh, PA.
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.
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.
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.
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.
Flanagan C. (2006) Hybrid-type checking. In the Proceedings of the Symposium on Principles of Programming Languages (POPL), Charleston, SC.
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.
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.
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.
Giesl J. (1997) Termination of nested and mutually recursive algorithms. J. Autom. Reasoning 19, 129.
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.
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.
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.
Hosoya H. & Pierce B. (2003) XDuce: A statically typed XML processing language. ACM Trans. Internet Technol. 3 (2), 117148.
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.
Jaffar J. & Maher M. J. (1994) Constraint logic programming: A survey. J. Log. Algebr. Program. 19 (20), 503581.
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.
Jhala R., Majumdar R. & Xu R.-G. (2007) State of the union: Type inference via Craig interpolation. In the Proceedings of TACAS, Braga, Portugal.
Jones C. (1986) Systematic Software Development Using VDM. Upper Saddle River, NJ: Prentice-Hall.
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.
King J. C. (1976) Symbolic execution and program testing. Commun. ACM. 19, 385394.
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.
Knowles K. W. & Flanagan C. (2010) Hybrid type checking. ACM TOPLAS 32 (2), 6:16:34.
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.
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.
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.
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.
Lerner B., Flower M., Grossman D. & Chambers C. (2007) Searching for type-error messages. In the Proceedings of PLDI, San Diego, CA, USA.
Lovas W. & Pfenning F. (2007) A bidirectional refinement type system for LF. In the Proceedings of LFMTP, Bremen, Germany.
McCarthy J. (1962) Towards a mathematical science of computation. In the Proceedings of IFIP Congress, Munich, Germany.
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.
Meng J. & Paulson L. C. (2008) Translating higher-order problems to first-order clauses. J. Autom. Reasoning 40 (1), 3560.
Meyer B. 1992 Eiffel: The Language. Upper Saddle River, NJ: Prentice Hall.
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.
Nordström B. & Petersson K. (1983) Types and specifications. In the Proceedings of IFIP, Paris, France.
Pierce B. C. (1991) Programming with Intersection Types, Union Types, and Polymorphism. Technical Report CMU-CS-91-106, Carnegie Mellon University, Pittsburgh, PA.
Pierce B. C. (2002) Types and Programming Languages. Cambridge, MA: MIT Press.
Pierce B. C. & Turner D. N. (2000) Local type inference. ACM Trans. Program. Lang. Syst. 22 (1), 144.
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.
Ranise S. & Tinelli C. (2006) The SMT-LIB Standard: Version 1.2. Technical Report, Department. of Computer Science, The University of Iowa, Iowa.
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.
Rondon P., Kawaguchi M. & Jhala R. (2008) Liquid types. In the Proceedings of PLDI, Tucson, AZ, USA.
Rushby J., Owre S. & Shankar N. (1998) Subtypes for specifications: Predicate subtyping in PVS. IEEE Trans. Softw. Eng. 24 (9), 709720.
Saraswat V., Nystrom N., Palsberg J. & Grothoff C. (2008) Constrained types for object-oriented languages. In the Proceedings of OOPSLA, Nashville, TN, USA.
Siméon J. & Wadler P. (2003) The essence of XML. In the Proceedings of POPL, New Orleans, USA.
Sozeau M. (2006) Subset coercions in Coq. In the Proceedings of TYPES, Nottingham, UK, LNCS vol. 4502.
Swamy N., Chen J. & Chugh R. (2010) Enforcing stateful authorization and information flow policies in Fine. In the Proceedings of ESOP, Paphos, Cyprus.
Terauchi T. (2010) Dependent types from counterexamples. In the Proceedings of POPL, Madrid, Spain.
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.
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.
TypiCal Project 2009 The Coq Proof Assistant. Version 8.2. Accessed February 27, 2012. Available at: http://coq.inria.fr.
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.
Wright A. K. & Cartwright R. (1997) A practical soft type system for scheme. ACM TOPLAS 19, 87152.
Wright A. K. & Felleisen M. (1994) A syntactic approach to type soundness. Inf. Comput. 115 (1), 3894.
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.
Recommend this journal

Email your librarian or administrator to recommend adding this journal to your organisation's collection.

Journal of Functional Programming
  • ISSN: 0956-7968
  • EISSN: 1469-7653
  • URL: /core/journals/journal-of-functional-programming
Please enter your name
Please enter a valid email address
Who would you like to send this to? *
×

Metrics

Full text views

Total number of HTML views: 0
Total number of PDF views: 6 *
Loading metrics...

Abstract views

Total abstract views: 130 *
Loading metrics...

* Views captured on Cambridge Core between September 2016 - 21st November 2017. This data will be updated every 24 hours.