737 research outputs found

    Taxonomies and Toolkits: uses for the Mathematics of program construction

    Get PDF
    In this extended abstract, we present a brief description of the tutorial. The primary reference material, a book and some software (1] , is available for ftp from the Eindhoven University of Technology. In this tutorial, we will consider a mathematical approach to the derivation of families of algorithms solving a particular problem. These families of algorithms are easily translated into practical toolkits of algorithms (C++ class libraries in our case). In the following paragraphs, we briefly describe why we need such toolkits, algorithm derivations, and a slightly non-standard algorithm derivation method. Generic programming (or template programming in C++) forms one of the cornerstones (along with object-oriented programming) of component programming. Generic algorithm libraries fill the need for standard algorithms such as sorting and string searching algorithms, freeing the programmer from re-implementing such error prone components. The algorithms in a generic library do not make unnecessary assumptions about the nature of the data being operated upon. For example, a string searching library would work well with strings of characters or strings of floating point numbers. The very nature of generic programs make them extremely difficult to debug and test. Exhaustive testing is generally not possible since the number of types (for the template parameter) is usually infinite. These practical difficulties can be alleviated by using the mathematics of program construction to design the program correctly in the first place. In the next paragraph, we will consider the mathematical appeal of taxonomies of algorithms. There are a number of mature areas of computer science (such as finite automata construction and string pattern matching) for which there are literally dozens of known algorithms. Many of these algorithms remain without rigorous proof, despite the fact that they were developed over twenty years ago. The differing presentation styles, and half-derivations of some of the algorithms makes them particularly difficult to compare to one another, and even more difficult to implement correctly. Dijkstra's approach to correct program construction is rarely, if ever, used by software engineers working on "real-life" projects. A great deal of time, patience, and practice are required to learn and apply the method. Unfortunately, the strict use of Dijkstra's calculus is still best suited to programming-in-the-small (the development of elegant algorithms solving small problems, such as greatest-common-divisor). We will present a method of constructing taxonomies of algorithms. The method starts with a naive first algorithm, which is easy to prove correct but is impractical to implement. The taxonomy will be grown as a ''family tree" , with the naive algorithm at the root. At each step, a variant of Dijkstra's discipline of programming is used to add either an algorithm detail (some algorithm transformation) or a problem detail (a problem restriction which allows an algorithmic improvement). The details are always added in a correctness-preserving manner, meaning that the correctness proof of any derived algorithm is in the composition of the details. The aim is to arrive at all of the known algorithms and hopefully derive some new ones. Once such a taxonomy has been developed, it is finally possible to provide implementations (in the form of class libraries) of all of the known algorithms solving a particular problem. The presence of the correctness proofs in the taxonomy has yielded impressive code quality in the class libraries (fewer than five bugs per 10,000 of code in the first release). In the tutorial, we will also discuss the implementation of one such class library

    Maximum Segment Sum, Monadically (distilled tutorial, with solutions)

    Full text link
    The maximum segment sum problem is to compute, given a list of integers, the largest of the sums of the contiguous segments of that list. This problem specification maps directly onto a cubic-time algorithm; however, there is a very elegant linear-time solution too. The problem is a classic exercise in the mathematics of program construction, illustrating important principles such as calculational development, pointfree reasoning, algebraic structure, and datatype-genericity. Here, we take a sideways look at the datatype-generic version of the problem in terms of monadic functional programming, instead of the traditional relational approach; the presentation is tutorial in style, and leavened with exercises for the reader.Comment: Revision of the article in Proceedings DSL 2011, EPTCS 66, arXiv:1109.0323, to provide solutions to the exercise

    Programming Telepathy: Implementing Quantum Non-Locality Games

    Full text link
    Quantum pseudo-telepathy is an intriguing phenomenon which results from the application of quantum information theory to communication complexity. To demonstrate this phenomenon researchers in the field of quantum communication complexity devised a number of quantum non-locality games. The setting of these games is as follows: the players are separated so that no communication between them is possible and are given a certain computational task. When the players have access to a quantum resource called entanglement, they can accomplish the task: something that is impossible in a classical setting. To an observer who is unfamiliar with the laws of quantum mechanics it seems that the players employ some sort of telepathy; that is, they somehow exchange information without sharing a communication channel. This paper provides a formal framework for specifying, implementing, and analysing quantum non-locality games

    Programming with Quantum Communication

    Get PDF
    This work develops a formal framework for specifying, implementing, and analysing quantum communication protocols. We provide tools for developing simple proofs and analysing programs which involve communication, both via quantum channels and exhibiting the LOCC (local operations, classical communication) paradigm

    Constructing applicative functors

    Get PDF
    Applicative functors define an interface to computation that is more general, and correspondingly weaker, than that of monads. First used in parser libraries, they are now seeing a wide range of applications. This paper sets out to explore the space of non-monadic applicative functors useful in programming. We work with a generalization, lax monoidal functors, and consider several methods of constructing useful functors of this type, just as transformers are used to construct computational monads. For example, coends, familiar to functional programmers as existential types, yield a range of useful applicative functors, including left Kan extensions. Other constructions are final fixed points, a limited sum construction, and a generalization of the semi-direct product of monoids. Implementations in Haskell are included where possible

    Refactoring pattern matching

    Get PDF
    Defining functions by pattern matching over the arguments is advantageous for understanding and reasoning, but it tends to expose the implementation of a datatype. Significant effort has been invested in tackling this loss of modularity; however, decoupling patterns from concrete representations while maintaining soundness of reasoning has been a challenge. Inspired by the development of invertible programming, we propose an approach to program refactoring based on a right-invertible language rinv—every function has a right (or pre-) inverse. We show how this new design is able to permit a smooth incremental transition from programs with algebraic datatypes and pattern matching, to ones with proper encapsulation, while maintaining simple and sound reasoning

    Inductive and Coinductive Components of Corecursive Functions in Coq

    Get PDF
    In Constructive Type Theory, recursive and corecursive definitions are subject to syntactic restrictions which guarantee termination for recursive functions and productivity for corecursive functions. However, many terminating and productive functions do not pass the syntactic tests. Bove proposed in her thesis an elegant reformulation of the method of accessibility predicates that widens the range of terminative recursive functions formalisable in Constructive Type Theory. In this paper, we pursue the same goal for productive corecursive functions. Notably, our method of formalisation of coinductive definitions of productive functions in Coq requires not only the use of ad-hoc predicates, but also a systematic algorithm that separates the inductive and coinductive parts of functions.Comment: Dans Coalgebraic Methods in Computer Science (2008

    Deriving real-time action systems with multiple time bands using algebraic reasoning

    Get PDF
    The verify-while-develop paradigm allows one to incrementally develop programs from their specifications using a series of calculations against the remaining proof obligations. This paper presents a derivation method for real-time systems with realistic constraints on their behaviour. We develop a high-level interval-based logic that provides flexibility in an implementation, yet allows algebraic reasoning over multiple granularities and sampling multiple sensors with delay. The semantics of an action system is given in terms of interval predicates and algebraic operators to unify the logics for an action system and its properties, which in turn simplifies the calculations and derivations
    • …
    corecore