Copenhagen Ph . D . Dissertation Tom Hvitved Contract Formalisation and Modular Implementation of Domain - Specific Languages
چکیده
This dissertation encompasses the topics contract formalisation, domainspecific languages implementation, and enterprise resource planning systems. The dissertation is a collection of six independent chapters, two of which are published papers, two of which are extended versions of published papers, and two of which are unpublished manuscripts. Our contributions to the field of contract formalisation covers three chapters. The first chapter is a comprehensive, comparative survey of previous work on formal languages and models for legally binding contracts. We provide a list of key requirements for formalising contracts, which serves both as our comparison measure, and as a guideline for future formalisms. We conclude that, although much work has been carried out in the field, much remains to be done. In particular, only very few previous approaches present a clear, formal semantics. To this end, we propose a novel, formal model of legally binding contracts in the second chapter. Besides striving for an unambiguous, formal semantics, we focus on a model that properly accounts for blame assignment. That is, our contract model takes into account that a breach of contract must be attributable to one or more of the contract participants. In the third chapter we shift the focus from legally binding contracts to contracts for distributed programming. We propose a fundamentally new generalisation of the traditional programming-by-contract paradigm, which gives rise to a game-theoretic view on distributed-programming contracts. Perhaps surprisingly, many aspects of contracts for distributed programming and traditional legally binding contracts turn out to coincide. Our contributions to the field of domain-specific languages implementation covers two chapters. We introduce a Haskell library for constructing data types, and functions on them, in a modular and extendable fashion. Our library targets implementations of domain-specific languages, in which the abstract syntax trees (ASTs) are represented as elements of a recursive algebraic data type. The shortcoming of the traditional approach is that it is missing modularity, and typically we find ourselves implementing AST transformations for which the type system does not properly account for the underlying invariants (also known as the Expression Problem). In the first of the two chapters we introduce our library, which enables full modularity and extensibility, as well as seamless support for AST annotations and run-time optimisation in the vein of deforestation. In the second chapter we extend our library with support for variable binders. We use a restricted form of higher-order abstract syntax that permits effective recursion schemes, as well as transformations on higher-order ASTs. In the final chapter we present a novel software architecture for enterprise resource planning (ERP) systems, based on domain-specific languages. This chapter ties together the previous chapters, by drawing on our domain-specific language for contracts and our Haskell library of compositional data types. We present a detailed overview of our architecture, as well as the domain-specific languages for specifying the data model, reports, and contracts respectively. The data model defines objects that we want to model, such as customers; the reports define the information we want to derive from the transactions in the system, such as current balance; and the contracts define the expected future transactions, such as payments. We demonstrate the validity of our approach by means of a use case, in which we implement a small ERP system from scratch. The implementation that we obtain is but a fraction of the code in normal ERP systems, and the domain-specific style yields specifications that are much closer to the informal, textual requirements than the corresponding implementations in standard ERP systems.