128 research outputs found

    Modeling, Sharing, and Recursion for Weak Reduction Strategies using Explicit Substitution

    Get PDF
    We present the lambda sigma^a_w calculus, a formal synthesis of the concepts ofsharing and explicit substitution for weak reduction. We show howlambda sigma^a_w can be used as a foundation of implementations of functionalprogramming languages by modelling the essential ingredients of suchimplementations, namely weak reduction strategies, recursion, spaceleaks, recursive data structures, and parallel evaluation, in a uniform way.First, we give a precise account of the major reduction strategiesused in functional programming and the consequences of choosing lambda-graph-reduction vs. environment-based evaluation. Second, we showhow to add constructors and explicit recursion to give a precise accountof recursive functions and data structures even with respect tospace complexity. Third, we formalize the notion of space leaks in lambda sigma^a_wand use this to define a space leak free calculus; this suggests optimisationsfor call-by-need reduction that prevent space leaking and enablesus to prove that the "trimming" performed by the STG machine doesnot leak space.In summary we give a formal account of several implementationtechniques used by state of the art implementations of functional programminglanguages.Keywords. Implementation of functional programming, lambdacalculus, weak reduction, explicit substitution, sharing, recursion, spaceleaks

    Intersection Types and (Positive) Almost-Sure Termination

    Full text link
    Randomized higher-order computation can be seen as being captured by a lambda calculus endowed with a single algebraic operation, namely a construct for binary probabilistic choice. What matters about such computations is the probability of obtaining any given result, rather than the possibility or the necessity of obtaining it, like in (non)deterministic computation. Termination, arguably the simplest kind of reachability problem, can be spelled out in at least two ways, depending on whether it talks about the probability of convergence or about the expected evaluation time, the second one providing a stronger guarantee. In this paper, we show that intersection types are capable of precisely characterizing both notions of termination inside a single system of types: the probability of convergence of any lambda-term can be underapproximated by its type, while the underlying derivation's weight gives a lower bound to the term's expected number of steps to normal form. Noticeably, both approximations are tight -- not only soundness but also completeness holds. The crucial ingredient is non-idempotency, without which it would be impossible to reason on the expected number of reduction steps which are necessary to completely evaluate any term. Besides, the kind of approximation we obtain is proved to be optimal recursion theoretically: no recursively enumerable formal system can do better than that

    The call-by-need lambda calculus

    Get PDF

    Tracking Redexes in the Lambda Calculus

    Get PDF
    Residuals of redexes keep track of redexes along reductions in the lambda calculus. Families of redexes keep track of redexes created along these reductions. In this paper, we review these notions and their relation to a labeled-calculus introduced here in a systematic way. These properties may be extended to combinatory logic, term rewriting systems, process calculi and proofnets of linear logic

    Reescritura de términos y sustituciones explícitas

    Get PDF
    La operación de sustitución constituye un engranaje básico en los fundamentos de la teoría de lenguajes de programación. Juega un rol central en el lambda cálculo (por ende, en lenguajes de programación funcional), en unificación de primer orden y de orden superior (por ende, en lenguajes de programación basados en el paradigma lógico), en modalidades de pasaje de parámetros (por ende, en lenguajes de programación imperativos), etc. Recientemente, investigadores en informática se han interesado en el pasaje de la noción usual de la sustitución, atómica, y de gruesa granularidad, hacia una noción más refinada, de más fina granularidad. La noción de sustitución es transportada del metalenguaje (nuestro lenguaje de discurso) al lenguaje objeto (nuestro lenguaje de estudio). Como consecuencia de ello se obtienen los llamados cálculos de sustituciones explícitas. Estos son de sumo interés a la hora de estudiar la interpretación operacional de los formalismos en cuestión y constituyen los objetos de interés de esta tesis. Se desarrollan los siguientes tres ejes de estudio: Primero, se consideran estrategias de reescritura perpetuas en lambda cálculos con sustituciones explícitas. Estas son estrategias de reescritura que preservan la posibilidad de reducciones infinitas. Se propone una caracterización inductiva del conjunto de términos que no poseen reducciones infinitas (los llamados fuertemente normalizantes). Un lambda cálculo polimórfico con sustituciones explícitas también es analizado, incluyendo propiedades tales como subject reduction y normalización fuerte. Segundo, colocamos el ς-cálculo de M. Abadi and L. Cardelli enriquecido con sustituciones explícitas bajo el microscopio. Este cálculo se encuentra en un nivel semejante de abstracción al lambda cálculo pero se basa en objetos en lugar de funciones. Propiedades tales como simulación del lambda cálculo, confluencia y preservación de la normalización fuerte (aquellos términos que son fuertemente normalizantes en ς también lo son en ς con sustituciones explícitas) son consideradas. Finalmente, dirigimos nuestra atención a la tarea de relacionar la reescritura de orden superior con aquella de primer orden. Fijamos una variante de los ERS (apodados SERSdb) de Z. Khasidashvili como nuestro formalismo de orden superior de partida y definimos un proceso de conversión que permite codificar cualquier SERSdb como un sistema de reescritura de primer orden. En este último, cada paso de reescritura se lleva a cabo módulo una teoría ecuacional determinada por un cálculo de sustituciones explícitas. La misma se formula de manera genérica a través de una presentación de cálculos de sustituciones explícitas basada en macros y axiomas sobre estas macros, parametrizando de esta manera al procedimiento de conversión sobre cualquier cálculo de sustituciones explícitas que obedece la presentación basada en macros. El procedimiento de conversión se encarga de codificar pattern matching de orden superior y sustitución en el entorno de reescritura de primer orden. Asimismo, propiedades que relacionan la noción de reescritura en el orden superior con aquella de primer orden son analizadas en detalle. Se identifica una clase de SERSdb para los cuales el sistema de primer orden resultante de su conversión no requiere una teoría ecuacional para implementar pattern matching de orden superior, bastando para ello matching sintáctico. También se argumenta que esta clase de sistemas de orden superior es apropiada para transferir resultados del entorno de reescritura de orden superior a aquella de primer orden. A modo de ejemplo no-trivial de ello, estudiamos la transferencia del teorema de standarización (fuerte).Substitution spans many areas in programming language theory. It plays a central role in the lambda calculus (hence functional programming), in first and higher-order unikation (hence logic programming), parameter passing methods (hence imperative programming), etc. Recently researchers became interested in shifting from the usual atomic, coarse grained view of substitution to a more refined, fine grained one. Substitution is promoted from the metalevel (our language of discourse) to the object-level (our language of study). This is interesting when studying the operational interpretation of the formalisms in question. Calculi of object-level or explicit substitution is the concern of this thesis. The following three study axes are developed. First we consider perpetual rewrite strategies in lambda calculi of explicit substitutions. These are rewrite strategies that preserve the possibility of inhite derivations. Also, we study how to characterize inductively the set of terms that do not possess infinite derivations (the strongly normalizing terms). Polymorphic lambda calculus with explicit substitutions shall receive our attention too, including properties such as subject reduction and strong normalization. Secondly, we put the ς-calculus of M.Abadi and L.Cardelli augmented with explicit substitutions under the microscope. This calculus is at the level of the lambda calculus but is based on objects instead of functions. Properties such as simulation of the lambda calculus, confluence and preservation of strong normalization (terms which are strongly normalizing in ς are also strongly normalizii in ς with explicit substitutions) are considered. Finally, we address the task of reducing higher-order rewriting to first-order rewriting. We fix a variant of Z-Khasidashvili's ERS (dubbed SERSdb) as our departing formalism and provide a conversion procedure to encode any ERS as a first-order rewrite system in which a rewrite step takes place modulo an equational theory determined by a calculus of explicit substitutions. The latter is achieved with the aid of a macro-based presentation of calculi of explicit substitutions, thus parametrizing the conversion procedure over any calculus of explicit substitutions in compliance with the aforementioned presentation. The conversion procedure is in charge of encoding higherorder pattern matching and substitution in the first-order framework. Properties relating the rewrite relation in the higher-order framework and that of the resulting first-order system are studied in detail. We then identify a class of SERSdb for which the resulting first-order system does not require the equational theory to implement higher-order pattern matching, thus contenting itself with syntactic matching. It is argued that this class of systems is appropriate for transferring results from the first-order framework to the higher-order one. As a non-trivial example we study the transfer of the (strong) standardization theorem.Fil:Bonelli, Eduardo. Universidad de Buenos Aires. Facultad de Ciencias Exactas y Naturales; Argentina

    A call-by-need lambda calculus

    Full text link

    Linear Dependent Types in a Call-by-Value Scenario (Long Version)

    Get PDF
    Linear dependent types allow to precisely capture both the extensional behaviour and the time complexity of lambda terms, when the latter are evaluated by Krivine's abstract machine. In this work, we show that the same paradigm can be applied to call-by-value evaluation. A system of linear dependent types for Plotkin's PCF is introduced, called dlPCFV, whose types reflect the complexity of evaluating terms in the so-called CEK machine. dlPCFV is proved to be sound, but also relatively complete: every true statement about the extensional and intentional behaviour of terms can be derived, provided all true index term inequalities can be used as assumptions.Comment: 22 page

    Intersection types and (positive) almost-sure termination

    Get PDF
    Randomized higher-order computation can be seen as being captured by a λ-calculus endowed with a single algebraic operation, namely a construct for binary probabilistic choice. What matters about such computations is the probability of obtaining any given result, rather than the possibility or the necessity of obtaining it, like in (non)deterministic computation. Termination, arguably the simplest kind of reachability problem, can be spelled out in at least two ways, depending on whether it talks about the probability of convergence or about the expected evaluation time, the second one providing a stronger guarantee. In this paper, we show that intersection types are capable of precisely characterizing both notions of termination inside a single system of types: the probability of convergence of any λ-term can be underapproximated by its type, while the underlying derivation's weight gives a lower bound to the term's expected number of steps to normal form. Noticeably, both approximations are tight-not only soundness but also completeness holds. The crucial ingredient is non-idempotency, without which it would be impossible to reason on the expected number of reduction steps which are necessary to completely evaluate any term. Besides, the kind of approximation we obtain is proved to be optimal recursion theoretically: no recursively enumerable formal system can do better than that

    Useful Open Call-By-Need

    Get PDF
    This paper studies useful sharing, which is a sophisticated optimization for ?-calculi, in the context of call-by-need evaluation in presence of open terms. Useful sharing turns out to be harder in call-by-need than in call-by-name or call-by-value, because call-by-need evaluates inside environments, making it harder to specify when a substitution step is useful. We isolate the key involved concepts and prove the correctness and the completeness of useful sharing in this setting
    • …
    corecore