We describe a new automatic static analysis for determining upper-bound functions on the use of quantitative resources for strict, higher-order, polymorphic, recursive programs dealing with possibly-aliased data. Our analysis is a variant of Tarjan's manual amortised cost analysis technique. We use a type-based approach, exploiting linearity to allow inference, and place a new emphasis on the number of references to a data object. The bounds we infer depend on the sizes of the various inputs to a program. They thus expose the impact of specific inputs on the overall cost behaviour.The key novel aspect of our work is that it deals directly with polymorphic higher-order functions without requiring source-level transformations that could alter resource usage. We thus obtain safe and accurate compile-time bounds. Our work is generic in that it deals with a variety of quantitative resources. We illustrate our approach with reference to dynamic memory allocations/deallocations, stack usage, and worst-case execution time, using metrics taken from a real implementation on a simple micro-controller platform that is used in safety-critical automotive applications.
We show how to efficiently obtain linear a priori bounds on the heap space consumption of first-order functional programs.The analysis takes space reuse by explicit deallocation into account and also furnishes an upper bound on the heap usage in the presence of garbage collection. It covers a wide variety of examples including, for instance, the familiar sorting algorithms for lists, including quicksort.The analysis relies on a type system with resource annotations. Linear programming (LP) is used to automatically infer derivations in this enriched type system.We also show that integral solutions to the linear programs derived correspond to programs that can be evaluated without any operating system support for memory management. The particular integer linear programs arising in this way are shown to be feasibly solvable under mild assumptions.
We introduce a novel variant of logical relations that maps types not merely to partial equivalence relations on values, as is commonly done, but rather to a proof-relevant generalisation thereof, namely setoids. The objects of a setoid establish that values inhabit semantic types, whilst its morphisms are understood as proofs of semantic equivalence. The transition to proof-relevance solves two well-known problems caused by the use of existential quantification over future worlds in traditional Kripke logical relations: failure of admissibility, and spurious functional dependencies. We illustrate the novel format with two applications: a direct-style validation of Pitts and Stark's equivalences for "new" and a denotational semantics for a region-based effect system that supports type abstraction in the sense that only externally visible effects need to be tracked; non-observable internal modifications, such as the reorganisation of a search tree or lazy initialisation, can count as 'pure' or 'read only'. This 'fictional purity' allows clients of a module soundly to validate more effect-based program equivalences than would be possible with traditional effect systems. Syntax and SemanticsWe will interpret effect-refined types over a somewhat generic, untyped denotational model for stateful computations in the category of predomains (ω-cpos). We also introduce a meta-language [24], providing concrete syntax for functions in the model. We omit the standard details of interpreting CBV programming languages via such a metalanguage, or proofs of adequacy, relating the operationally induced observational (in)equivalence to (in)equality in the model. Denotational model We assume predomains V and H modelling values and heaps, respectively. As much of the metatheory does not rely on the finer details of how these predomains are defined, we axiomatise the properties we use. Firstly, we assume the existence of a set of (concrete) locations L and for each h ∈ H a finite set dom(h) ⊆ L. We also assume a constant ∅ ∈ H, the empty heap.where l ∈ L and h ′ ∈ H. These three operations are continuous, in particular, h ≤ h ′ ⇒ dom(h) ⊆ dom(h ′ ) and the following axioms hold:then dom(h ′ ) = dom(h)∪{l} and l dom(h) and h ′ (l) = v. Given V this abstract datatype can be implemented in a number of ways, e.g., as finite maps. We define the domain of computations C to be partial continuous functions from H to H × V, the bottom element being the everywhere undefined function.We assume that V embeds tuples of values, i.e., if v 1 , . . . , v n ∈ V then (v 1 , . . . , v n ) ∈ V and it is possible to tell whether a value is of that form and in this case to retrieve the components. We also assume that V embeds continuous functions f : V → C, i.e., if f is such a function then fun( f ) ∈ V and, finally, locations are also values, i.e. if l ∈ L then loc(l) ∈ V and one can tell whether a value is a location or a function. A canonical example of such a V is the least solution to the predomain equation with C = H ⇁ H×V and V ≃ int(Z) + fun(V → C...
scite is a Brooklyn-based organization that helps researchers better discover and understand research articles through Smart Citations–citations that display the context of the citation and describe whether the article provides supporting or contrasting evidence. scite is used by students and researchers from around the world and is funded in part by the National Science Foundation and the National Institute on Drug Abuse of the National Institutes of Health.
customersupport@researchsolutions.com
10624 S. Eastern Ave., Ste. A-614
Henderson, NV 89052, USA
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
Copyright © 2024 scite LLC. All rights reserved.
Made with 💙 for researchers
Part of the Research Solutions Family.