Skip to main content
×
Home
    • Aa
    • Aa

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
Linked references
Hide All

This list contains references from the content that can be linked to their source. For a full set of references and notes please see the PDF or HTML where available.

A. Aiken , E. L. Wimmers & T. K. Lakshman (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.

C. Barrett , M. Deters , A. Oliveras & A. Stump (2008) Design and results of the 3rd Annual SMT Competition (SMT-COMP 2007). Int. J. Artif. Intell. Tools. 17 (4), 569606.

V. Benzaken , G. Castagna & A. Frisch (2003) CDuce: An XML-friendly general purpose language. In the Proceedings of the Eighth ACM SIGPLAN International Conference on Functional Programming (ICFP), Uppsala, Sweden.

G. M. Bierman , A. D. Gordon , C. Hriţcu & D. Langworthy (2010b) Semantic subtyping with an SMT solver. In the Proceedings of the 15th ACM SIGPLAN International Conference on Functional Programming (ICFP), Baltimore, MD, USA.

R. S. Boyer , M. Kaufmann & J. S. Moore (1995) The Boyer-Moore theorem prover and its interactive enhancement. Comput. Math. Appl. 29 (2), 2762.

P. Buneman , S. Naqvi , V. Tannen & L. Wong (1995) Principles of programming with complex objects and collection types. Theor. Comput. Sci. 149 (1), 348.

G. Castagna & G. Chen (2001) Dependent types with subtyping and late-bound overloading. Inf. Comput. 168 (1), 167.

S. Cohen (2006) User-defined aggregate functions: Bridging theory and practice. In the Proceedings of SIGMOD, Chicago, IL, USA.

D. Detlefs , G. Nelson & J. B. Saxe (2005) Simplify: A theorem prover for program checking. J. ACM. 52 (3), 365473.

J. Dunfield & F. Pfenning (2004) Tridirectional typechecking. In the Proceedings of the 31st ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL, Venice, Italy.

R. Findler & M. Felleisen (2002) Contracts for higher-order functions. In the Proceedings of the SeventhACM SIGPLAN International Conference on Functional Programming (ICFP '02), Pittsburgh, PA, USA.

A. Frisch , G. Castagna & V. Benzaken (2008) Semantic subtyping: Dealing set-theoretically with function, union, intersection, and negation types. J. ACM 55 (4), 19:119:64.

P. Genevès , N. Layaïda & A. Schmitt (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.

J. Giesl (1997) Termination of nested and mutually recursive algorithms. J. Autom. Reasoning 19, 129.

H. Hosoya & B. Pierce (2003) XDuce: A statically typed XML processing language. ACM Trans. Internet Technol. 3 (2), 117148.

H. Hosoya , J. Vouillon & B. Pierce (2000) Regular expression types for XML. In the Proceedings of the Fifth ACM SIGPLAN International Conference on Functional Programming (ICFP), Montreal, Canada.

M. Kawaguchi , P. M. Rondon & R. Jhala (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.

J. C. King (1976) Symbolic execution and program testing. Commun. ACM. 19, 385394.

K. W. Knowles & C. Flanagan (2010) Hybrid type checking. ACM TOPLAS 32 (2), 6:16:34.

R. Komondoor , G. Ramalingam , S. Chandra & J. Field (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.

V. Kuncak , M. Mayer , R. Piskac & P. Suter (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.

K. R. M. Leino & R. Monahan (2009) Reasoning about comprehensions with first-order SMT solvers. In the Proceedings of the ACM Symposium on Applied Computing (SAC), Honolulu, HI, USA.

B. Lerner , M. Flower , D. Grossman & C. Chambers (2007) Searching for type-error messages. In the Proceedings of PLDI, San Diego, CA, USA.

J. Meng & L. C. Paulson (2008) Translating higher-order problems to first-order clauses. J. Autom. Reasoning 40 (1), 3560.

B. Meyer 1992 Eiffel: The Language. Upper Saddle River, NJ: Prentice Hall.

B. C. Pierce & D. N. Turner (2000) Local type inference. ACM Trans. Program. Lang. Syst. 22 (1), 144.

P. Rondon , M. Kawaguchi & R. Jhala (2008) Liquid types. In the Proceedings of PLDI, Tucson, AZ, USA.

J. Rushby , S. Owre & N. Shankar (1998) Subtypes for specifications: Predicate subtyping in PVS. IEEE Trans. Softw. Eng. 24 (9), 709720.

S. Tobin-Hochstadt & M. Felleisen (2010) Logical types for untyped languages. In the Proceedings of the 15th ACM SIGPLAN International Conference on Functional Programming (ICFP), Baltimore, MD, USA.

A. K. Wright & R. Cartwright (1997) A practical soft type system for scheme. ACM TOPLAS 19, 87152.

A. K. Wright & M. Felleisen (1994) A syntactic approach to type soundness. Inf. Comput. 115 (1), 3894.

H. Xi & F. Pfenning (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? *
×