4 research outputs found

    Semantics-driven design and implementation of high-assurance hardware

    Get PDF

    Generic Constraints for Type-Safe Embedded Programming

    No full text
    Domain-specific languages (DSLs) are everywhere, with applications in areas such as parser generation, music synthesis, parallel programming and even the design of domain-specific languages. However, while the pay-off in using a DSL may be substantial, the cost of introducing a language may be made prohibitively high by the need to construct a supporting toolchain. A common tactic is to embed a DSL into a general-purpose host programming language. Existing infrastructure such as a language’s compiler or type system may be re-used, provided that the embedding accurately captures the properties of the DSL. While the rich type systems and orthogonal abstraction features of modern functional languages have proved particularly capable in this regard, they are not without their shortcomings. Building type-safe functions defined over an embedded DSL can introduce application-specific type constraints that end up being imposed on the DSL data types themselves. At best, these constraints are unwieldy and at worst they can limit the range of DSL expressions that can be built. In this thesis we tackle the problem of accurately embedding a DSL’s type system into that of the purely functional language Haskell. We present a framework for expressing application-specific constraints at the point of a DSL expression’s use rather than when the DSL’s embedding is defined. We show how our framework can be applied more generally to capture arbitrary properties of a DSL expression and, in certain cases, how we may subsequently prove additional safety properties such as the totality of a function which operates over DSL expressions. We evaluate our techniques by illustrating their use in constructing a DSL for heterogeneous parallel programming. However, our methods have potentially wider applications such as context-dependent computation, which are also discussed

    HERMIT: Mechanized Reasoning during Compilation in the Glasgow Haskell Compiler

    Get PDF
    It is difficult to write programs which are both correct and fast. A promising approach, functional programming, is based on the idea of using pure, mathematical functions to construct programs. With effort, it is possible to establish a connection between a specification written in a functional language, which has been proven correct, and a fast implementation, via program transformation. When practiced in the functional programming community, this style of reasoning is still typically performed by hand, by either modifying the source code or using pen-and-paper. Unfortunately, performing such semi-formal reasoning by directly modifying the source code often obfuscates the program, and pen-and-paper reasoning becomes outdated as the program changes over time. Even so, this semi-formal reasoning prevails because formal reasoning is time-consuming, and requires considerable expertise. Formal reasoning tools often only work for a subset of the target language, or require programs to be implemented in a custom language for reasoning. This dissertation investigates a solution, called HERMIT, which mechanizes reasoning during compilation. HERMIT can be used to prove properties about programs written in the Haskell functional programming language, or transform them to improve their performance. Reasoning in HERMIT proceeds in a style familiar to practitioners of pen-and-paper reasoning, and mechanization allows these techniques to be applied to real-world programs with greater confidence. HERMIT can also re-check recorded reasoning steps on subsequent compilations, enforcing a connection with the program as the program is developed. HERMIT is the first system capable of directly reasoning about the full Haskell language. The design and implementation of HERMIT, motivated both by typical reasoning tasks and HERMIT's place in the Haskell ecosystem, is presented in detail. Three case studies investigate HERMIT's capability to reason in practice. These case studies demonstrate that semi-formal reasoning with HERMIT lowers the barrier to writing programs which are both correct and fast
    corecore