Unifying Hybrid Types and Contracts

Contract systems and hybrid type systems provide two alternative approaches for enforcing precisely-defined interface specifications, with complementary advantages: contract systems excel at blame assignment, whereas hybrid type systems support type-based static analysis. We unify these two approaches by demonstrating that hybrid type checking is sufficiently expressive to encode higher-order contracts with proper blame assignment. In particular, a contract obligation that enforces both sides of a contract is decomposed into two type casts that each enforce one side of the contract. This expressiveness result provides several benefits, including allowing one of these casts to be lifted from variable references to variable definitions, resulting in improved contract coverage and removing the need for privileged contract obligations.

[1]  David A. McAllester,et al.  A sound (and complete) model of contracts , 2004, ICFP '04.

[2]  David A. McAllester,et al.  Sound and complete models of contracts , 2006, Journal of Functional Programming.

[3]  Kenneth Knowles,et al.  Type Reconstruction for General Refinement Types , 2007, ESOP.

[4]  David Lorge Parnas,et al.  A technique for software module specification with examples , 1972, CACM.

[5]  Matthias Felleisen,et al.  Modular set-based analysis from contracts , 2006, POPL '06.

[6]  Frank Pfenning,et al.  Refinement types for ML , 1991, PLDI '91.

[7]  Robert Bruce Findler,et al.  Contracts as Pairs of Projections , 2006, FLOPS.

[8]  Chiyan Chen,et al.  Combining programming with theorem proving , 2005, ICFP '05.

[9]  Michael Kölling,et al.  Blue - Language Specification, Version 1.0 , 1997 .

[10]  Bertrand Meyer,et al.  Eiffel: The Language , 1991 .

[11]  Gary T. Leavens,et al.  Design by Contract with JML , 2006 .

[12]  Hongwei Xi,et al.  Imperative programming with dependent types , 2000, Proceedings Fifteenth Annual IEEE Symposium on Logic in Computer Science (Cat. No.99CB36332).

[13]  Matthias Felleisen,et al.  Contracts for higher-order functions , 2002, ICFP '02.

[14]  Frank Pfenning,et al.  Dependent types in practical programming , 1999, POPL '99.

[15]  David Luckham,et al.  Programming with Specifications , 1990, Texts and Monographs in Computer Science.

[16]  Cormac Flanagan,et al.  Hybrid type checking , 2006, POPL '06.

[17]  簡聰富,et al.  物件導向軟體之架構(Object-Oriented Software Construction)探討 , 1989 .

[18]  Richard C. Holt,et al.  The Turing programming language , 1988, CACM.