75 research outputs found

    The HERMIT in the machine: a plugin for the interactive transformation of GHC core language programs

    Get PDF
    The importance of reasoning about and refactoring programs is a central tenet of functional programming. Yet our compilers and development toolchains only provide rudimentary support for these tasks. This paper introduces a programmatic and compiler-centric interface that facilitates refactoring and equational reasoning. To develop our ideas, we have implemented HERMIT, a toolkit enabling informal but systematic transformation of Haskell programs from inside the Glasgow Haskell Compiler’s optimization pipeline. With HERMIT, users can experiment with optimizations and equational reasoning, while the tedious heavy lifting of performing the actual transformations is done for them. HERMIT provides a transformation API that can be used to build higher-level rewrite tools. One use-case is prototyping new optimizations as clients of this API before being committed to the GHC toolchain. We describe a HERMIT application - a read-eval-print shell for performing transformations using HERMIT. We also demonstrate using this shell to prototype an optimization on a specific example, and report our initial experiences and remaining challenges

    Theorem Provers as Libraries -- An Approach to Formally Verifying Functional Programs

    Get PDF
    Property-directed verification of functional programs tends to take one of two paths. First, is the traditional testing approach, where properties are expressed in the original programming language and checked with a collection of test data. Alternatively, for those desiring a more rigorous approach, properties can be written and checked with a formal tool; typically, an external proof system. This dissertation details a hybrid approach that captures the best of both worlds: the formality of a proof system paired with the native integration of an embedded, domain specific language (EDSL) for testing. At the heart of this hybridization is the titular concept -- a theorem prover as a library. The verification capabilities of this prover, HaskHOL, are introduced to a Haskell development environment as a GHC compiler plugin. Operating at the compiler level provides for a comparatively simpler integration and allows verification to co-exist with the numerous other passes that stand between source code and program

    Finding The Lazy Programmer's Bugs

    Get PDF
    Traditionally developers and testers created huge numbers of explicit tests, enumerating interesting cases, perhaps biased by what they believe to be the current boundary conditions of the function being tested. Or at least, they were supposed to. A major step forward was the development of property testing. Property testing requires the user to write a few functional properties that are used to generate tests, and requires an external library or tool to create test data for the tests. As such many thousands of tests can be created for a single property. For the purely functional programming language Haskell there are several such libraries; for example QuickCheck [CH00], SmallCheck and Lazy SmallCheck [RNL08]. Unfortunately, property testing still requires the user to write explicit tests. Fortunately, we note there are already many implicit tests present in programs. Developers may throw assertion errors, or the compiler may silently insert runtime exceptions for incomplete pattern matches. We attempt to automate the testing process using these implicit tests. Our contributions are in four main areas: (1) We have developed algorithms to automatically infer appropriate constructors and functions needed to generate test data without requiring additional programmer work or annotations. (2) To combine the constructors and functions into test expressions we take advantage of Haskell's lazy evaluation semantics by applying the techniques of needed narrowing and lazy instantiation to guide generation. (3) We keep the type of test data at its most general, in order to prevent committing too early to monomorphic types that cause needless wasted tests. (4) We have developed novel ways of creating Haskell case expressions to inspect elements inside returned data structures, in order to discover exceptions that may be hidden by laziness, and to make our test data generation algorithm more expressive. In order to validate our claims, we have implemented these techniques in Irulan, a fully automatic tool for generating systematic black-box unit tests for Haskell library code. We have designed Irulan to generate high coverage test suites and detect common programming errors in the process

    Understanding and maintaining tactics graphically OR how we are learning that a diagram can be worth more than 10K LoC

    Get PDF
    The use of a functional language to implement proof strategies as proof tactics in interactive theorem provers, often provides short, concise and elegant implementations. Whilst being elegant, the use of higher order features and combinator languages often results in a very procedural view of a strategy, which may deviate significantly from the high-level ideas behind it. This can make a tactic hard to understand and hence difficult to to debug and maintain for experts and non-experts alike: one often has to tear apart complex combinations of lower level tactics manually in order to analyse a failure in the overall strategy.In an industrial technology transfer project, we have been working on porting a very large and complex proof tactic into PSGraph, a graphical language for representing proof strategies. The goal of this work is to improve understandability and maintainability of tactics. Motivated by some initial successes with this, we here extend PSGraph with additional features for development and debugging. Through the re-implementation and refactoring of several existing tactics, we demonstrates the advantages of PSGraph compared with a typical sentential tactic language with respect to debugging, readability and maintenance. In order to act as guidance for others, we give a fairly detailed comparison of the user experience with the two approaches. The paper is supported by a web page providing further details about the implementation as well as interactive illustrations of the examples

    Proceedings of the Workshop on the lambda-Prolog Programming Language

    Get PDF
    The expressiveness of logic programs can be greatly increased over first-order Horn clauses through a stronger emphasis on logical connectives and by admitting various forms of higher-order quantification. The logic of hereditary Harrop formulas and the notion of uniform proof have been developed to provide a foundation for more expressive logic programming languages. The λ-Prolog language is actively being developed on top of these foundational considerations. The rich logical foundations of λ-Prolog provides it with declarative approaches to modular programming, hypothetical reasoning, higher-order programming, polymorphic typing, and meta-programming. These aspects of λ-Prolog have made it valuable as a higher-level language for the specification and implementation of programs in numerous areas, including natural language, automated reasoning, program transformation, and databases

    Programming Language Abstractions for the Global Network

    Get PDF
    Increasing demand for Internet-based applications motivates the development of programming models that ease their implementation. With the research presented in this thesis, we aim to improve understanding of what is involved when programming applications for the global network, and in particular the Web. We are primarily concerned with the development of language-level programming abstractions that address issues arising from the failure and performance properties of the Web. Frequent failure and unpredictable performance are ever-present aspects of any Web computation, so we must bring the properties of the Web into the semantic domain of our program systems. Our primary goal is to enable concise and intuitive expression of failure semantics in the context of concurrency, which is necessary for efficient Web computation given the large overhead in every network access. The main scientific contribution of this thesis is the development of a Web programming model for which a major design goal is the integration of domain concepts, failure interpretation, concurrency, and a mechanism for flow of control after failure. Our model is the first to successfully achieve a clean integration. We develop a programming language called Focus, which incorporates two complimentary abstractions. Persistent relative observables allow reasoning about the dynamic behaviour of computations in the context of past behaviours. Examples of observables are the rate, elapsed time, and success probability of http fetches. The mechanics of our observables mechanism allows the generalisation of the observables concept to all computation, and not just Web fetches. This generalisation is key in our design approach to supervisors, which are abstractions over concurrency designed for the specification of failure semantics and concurrency for computations that contain Web fetches. In essence, supervisors monitor and control the behaviour of arbitrary concurrent computations, which are passed as parameters, while retaining a strict separation of computational logic and control logic. In conjunction with observables, supervisors allow the writing of general control functions, parameterisable both by value and computation. Observables are abstract values that fluctuate dynamically, and all computations export the same set of observables. Observables allow genericity in supervisor control, since the mechanism constrains the value of observables within a pattern of fluctuation around a single number. Whatever the activity of a computation, information about its behaviour can be obtained within a range of values in the observables. This means that supervisors can be applied independently of knowledge of the program logic for supervised computations. Supervisors and observables are useful in the context of the Web due to the multiplicity of possible failure modes, many of which require interpretation, and the need for complex flow of control in the presence of concurrency
    corecore