An Investigation of Contracts as Projections

نویسندگان

  • Robert Bruce Findler
  • Matthias Blume
  • Matthias Felleisen
چکیده

April 1, 2004 version) Software contracts help programmers enforce program properties that the language’s type system cannot express. Unlike types, contracts are (usually) enforced at run-time. When a contract fails, the contract system signals an error. Beyond such errors, contracts should have no other observable (functional) effect on the program’s results. In most implementations, however, the language of contracts is the full-fledged programming language, which means that programmers may (intentionally or unintentionally) introduce visible effects into their contracts. Here we present the results of investigating the nature of contracts from a denotational perspective. Specifically, we use SPCF and the category of observably sequential functions to show that contracts are best understood as projections. Thus far, the investigation has produced a significantly faster contract implementation and the insight that our contract language cannot express all projections, which in turn has produced a new contract combinator. 1 Modeling Contracts Many programming languages support dynamically enforced software contracts [1, 2, 6, 8, 9, 11, 12, 15, 16, 17, 18, 19, 20, 21, 22, 23, 25, 26, 28]. With software contracts, programmers can state program invariants that the type system cannot express. Unlike types, however, contracts are not verified at compile time but monitored at run-time.1 When the contract monitor discovers that a contract does not hold for a particular function argument or result, it signals an error. Thus, contracts impose an overhead on the execution of programs, and contract system designers therefore provide a mechanism to disable contract monitoring. The nature of contract systems suggests that contracts should not affect the functional behavior of programs. Otherwise, running a program without contracts may produce different results than running programs with contracts, even 1Extended static checking [7] and soft typing [5] are efforts to validate contracts statically and to generate code to check those parts of the contract that cannot be verified. without any contract violations. Unfortunately, ensuring that contracts have no observable effects is a difficult task. Therefore the designers of software contracts simply ignore the problem and have programmers formulate contracts in the full-fledged programming language. To improve our understanding of this problem, we developed an operational model of a functional programming language with contracts, λCON [9]. That model specifies the meaning of the language and the meaning of contracts. In particular, it shows how to blame a specific program component for a contract violation. In this paper we present the results of investigating this setting from a denotational perspective. Specifically, we develop a denotational model of contracts using SPCF and the category of observably sequential functions [3, 4]. We chose SPCF because it has a purely functional (“standard”) model that is fully abstract and yet includes errors, exceptions, and a modicum of exception handling. It is thus possible to study contracts in a minimally realistic setting with pleasant mathematical properties. The goal of this effort is to characterize contracts mathematically and to use this characterization to improve contract systems. We start from the conjecture that software contracts are projections and then ask whether all syntactic contracts denote projections and whether our contract syntax expresses all projections. The answers—though not surprising in retrospect—have already improved the implementation of our contract system [10]. The paper’s organization follows this introduction. The next section informally explains contracts and why we use projections to model them. Then we recall the Cartesianclosed category of manifestly sequential functions and introduce SPCF, its syntax, types, and semantics. Based on this prelude, we formally introduce projections as contracts, answer the above questions, and discuss the implications for our implementation of contracts. 2 Contracts as Projections A contract in an imperative programming language consists of a pair of assertions for a procedure, i.e., a precondition on the arguments of the procedure and the state

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Investigation of Trustee Rule and its Applications in Banking Contracts

The Stimman rule is one of the jurisprudential rules of dealing with transactions. The concept of Stimman's rule speaks of non-guarantees. This rule has specific implications for transactions and provides for rules that violate the contract's legitimacy. The main question is what is the application and application of this rule in banking contracts? The research method in this paper is a descri...

متن کامل

American Option Pricing of Future Contracts in an Effort to Investigate Trading Strategies; Evidence from North Sea Oil Exchange

In this paper, Black Scholes’s pricing model was developed to study American option on future contracts of Brent oil. The practical tests of the model show that market priced option contracts as future contracts less than what model did, which mostly represent option contracts with price rather than without price. Moreover, it suggests call option rather than put option. Using t hypothesis test...

متن کامل

m-Projections involving Minkowski inverse and range symmetric property in Minkowski space

In this paper we study the impact of Minkowski metric matrix on a projection in the Minkowski Space M along with their basic algebraic and geometric properties.The relation between the m-projections and the Minkowski inverse of a matrix A in the minkowski space M is derived. In the remaining portion commutativity of Minkowski inverse in Minkowski Space M is analyzed in terms of m-projections as...

متن کامل

Contracts as Pairs of Projections

Assertion-based contracts provide a powerful mechanism for stating invariants at module boundaries and for enforcing them uniformly. Recently Findler and Felleisen have shown how to add contracts to higher-order functional languages, allowing programmers to assert invariants about functions as values. In this paper, we develop a model for such contracts. Specifically, we follow Dana Scott’s pro...

متن کامل

DISCRETE TOMOGRAPHY AND FUZZY INTEGER PROGRAMMING

We study the problem of reconstructing binary images from four projections data in a fuzzy environment. Given the uncertainly projections,w e want to find a binary image that respects as best as possible these projections. We provide an iterative algorithm based on fuzzy integer programming and linear membership functions.

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 2004