238 research outputs found

    The safety of higher order demand propagation

    Get PDF
    Higher Order Demand Propagation as proposed in [Pa98] provides a non-standard denotational semantics for a realistic functional language. This semantics can be used to deduce generalised strictness information for higher order polymorphic functions. This report provides the formal proof for the correctness of this strictness information with respect to the non-strict standard semantics

    Deciding subset relationship of co-inductively defined set constants

    Get PDF
    Static analysis of different non-strict functional programming languages makes use of set constants like Top, Inf, and Bot denoting all expressions, all lists without a last Nil as tail, and all non-terminating programs, respectively. We use a set language that permits union, constructors and recursive definition of set constants with a greatest fixpoint semantics. This paper proves decidability, in particular EXPTIMEcompleteness, of subset relationship of co-inductively defined sets by using algorithms and results from tree automata. This shows decidability of the test for set inclusion, which is required by certain strictness analysis algorithms in lazy functional programming languages

    Strictness and Totality Analysis

    Get PDF
    We define a novel inference system for strictness and totality analysis for the simply-typed lazy lambda-calculus with constants and fixpoints. Strictness information identifies those terms that definitely denote bottom (i.e. do not evaluate to WHNF) whereas totality information identifies those terms that definitely do not denote bottom (i.e. do evaluate to WHNF). The analysis is presented as an annotated type system allowing conjunctions only at ``top level´´. We give examples of its use and prove the correctness with respect to a natural-style operational semantics

    Abstract Interpretation of Polymorphic Higher-Order Functions

    Get PDF
    This thesis describes several abstract interpretations of polymorphic functions. In all the interpretations, information about any instance of a polymorphic function is obtained from that of the smallest, thus avoiding the computation of the instance directly. This is useful in the case of recursive functions, because it avoids the expensive computation of finding fixed points of functionals corresponding to complex instances. We define an explicitly typed polymorphic language with the Hindley-Milner type system to illustrate our ideas, and provide two semantics of polymorphism that relate separate instances of any polymorphic function. The choice of which semantics to use depends on the particular program analysis we want to study. For studying strictness analysis and binding-time analysis, we introduce a semantics based on embedding-closure pairs. We see how the abstract function of the smallest instance of a polymorphic function is used in building an approximation to that of any instance. Furthermore, we extend the language to include lists, and describe both strictness analysis and binding-time analysis of lists. Thus, this work extends previous work by others, on analyses of polymorphic first-order functions and also of monomorphic higher-order functions, to polymorphic higher-order functions. In relating distinct instances of a polymorphic function, the approximate abstract function is expressed as the greatest lower bound of a set of functions. This may not be very cheap to compute. However, there are often ways of obtaining the same result by considering a smaller set of functions. Another issue concerns how close the approximations are to the exact values. In the first-order case, it is shown that the approximate values coincide with the exact values. In general this is not the case, but experimental results on strictness analysis indicate that good approximations are obtained. Embedding-projection pairs are used to provide a semantics that is convenient for termination analysis of polymorphic functions. We show that the abstract interpretation of an instance can be approximated by the least upper bound of a set of functions that are built from that of the smallest

    Multiple intermediate structure deforestation by shortcut fusion

    Get PDF
    Shortcut fusion is a well-known optimization technique for functional programs. Its aim is to transform multi-pass algorithms into single pass ones, achieving deforestation of the intermediate structures that multi-pass algorithms need to construct. Shortcut fusion has already been extended in several ways. It can be applied to monadic programs, maintaining the global effects, and also to obtain circular and higher-order programs. The techniques proposed so far, however, only consider programs defined as the composition of a single producer with a single consumer. In this paper, we analyse shortcut fusion laws to deal with programs consisting of an arbitrary number of function compositions. (C) 2016 Elsevier B.V. All rights reserved.We would like to thank the anonymous reviewers for their detailed and helpful comments. This work was partially funded by ERDF - European Regional Development Fund through the COMPETE Programme (operational programme for competitiveness) and by National Funds through the FCT - Fundacao para a Ciencia e a Tecnologia (Portuguese Foundation for Science and Technology) within projects FCOMP-01-0124-FEDER-020532 and FCOMP-01-0124-FEDER-022701

    Polynomial relators

    Get PDF

    Relational Parametricity for Computational Effects

    Get PDF
    According to Strachey, a polymorphic program is parametric if it applies a uniform algorithm independently of the type instantiations at which it is applied. The notion of relational parametricity, introduced by Reynolds, is one possible mathematical formulation of this idea. Relational parametricity provides a powerful tool for establishing data abstraction properties, proving equivalences of datatypes, and establishing equalities of programs. Such properties have been well studied in a pure functional setting. Many programs, however, exhibit computational effects, and are not accounted for by the standard theory of relational parametricity. In this paper, we develop a foundational framework for extending the notion of relational parametricity to programming languages with effects.Comment: 31 pages, appears in Logical Methods in Computer Scienc

    Shortcut fusion rules for the derivation of circular and higher-order programs

    Get PDF
    Functional programs often combine separate parts using intermediate data structures for communicating results. Programs so defined are modular, easier to understand and maintain, but suffer from inefficiencies due to the generation of those gluing data structures. To eliminate such redundant data structures, some program transformation techniques have been proposed. One such technique is shortcut fusion, and has been studied in the context of both pure and monadic functional programs. In this paper, we study several shortcut fusion extensions, so that, alternatively, circular or higher-order programs are derived. These extensions are also provided for effect-free programs and monadic ones. Our work results in a set of generic calculation rules, that are widely applicable, and whose correctness is formally established.Fundação para a Ciência e a Tecnologi

    Projection-Based Program Analysis

    Get PDF
    Projection-based program analysis techniques are remarkable for their ability to give highly detailed and useful information not obtainable by other methods. The first proposed projection-based analysis techniques were those of Wadler and Hughes for strictness analysis, and Launchbury for binding-time analysis; both techniques are restricted to analysis of first-order monomorphic languages. Hughes and Launchbury generalised the strictness analysis technique, and Launchbury the binding-time analysis technique, to handle polymorphic languages, again restricted to first order. Other than a general approach to higher-order analysis suggested by Hughes, and an ad hoc implementation of higher-order binding-time analysis by Mogensen, neither of which had any formal notion of correctness, there has been no successful generalisation to higher-order analysis. We present a complete redevelopment of monomorphic projection-based program analysis from first principles, starting by considering the analysis of functions (rather than programs) to establish bounds on the intrinsic power of projection-based analysis, showing also that projection-based analysis can capture interesting termination properties. The development of program analysis proceeds in two distinct steps: first for first-order, then higher order. Throughout we maintain a rigorous notion of correctness and prove that our techniques satisfy their correctness conditions. Our higher-order strictness analysis technique is able to capture various so-called data-structure-strictness properties such as head strictness-the fact that a function may be safely assumed to evaluate the head of every cons cell in a list for which it evaluates the cons cell. Our technique, and Hunt's PER-based technique (originally proposed at about the same time as ours), are the first techniques of any kind to capture such properties at higher order. Both the first-order and higher-order techniques are the first projection-based techniques to capture joint strictness properties-for example, the fact that a function may be safely assumed to evaluate at least one of several arguments. The first-order binding-time analysis technique is essentially the same as Launchbury's; the higher-order technique is the first such formally-based higher-order generalisation. Ours are the first projection-based termination analysis techniques, and are the first techniques of any kind that are able to detect termination properties such as head termination-the fact that termination of a cons cell implies termination of the head. A notable feature of the development is the method by which the first-order analysis semantics are generalised to higher-order: except for the fixed-point constant the higher-order semantics are all instances of a higher-order semantics parameterised by the constants defining the various first-order semantics
    corecore