Hostname: page-component-6766d58669-7fx5l Total loading time: 0 Render date: 2026-05-15T12:02:37.532Z 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.

Information

Type
Articles
Copyright
Copyright © Cambridge University Press 2012
Submit a response

Discussions

No Discussions have been published for this article.