Abstract
Abstract Relational cost analysis aims at formally establishing bounds on the difference in the evaluation costs of two programs. As a particular case, one can also use relational cost analysis to establish bounds on the difference in the evaluation cost of the same program on two different inputs. One way to perform relational cost analysis is to use a relational type-and-effect system that supports reasoning about relations between two executions of two programs. Building on this basic idea, we present a type-and-effect system, called ARel, for reasoning about the relative cost (the difference in the evaluation cost) of array-manipulating, higher order functional-imperative programs. The key ingredient of our approach is a new lightweight type refinement discipline that we use to track relations (differences) between two mutable arrays. This discipline combined with Hoare-style triples built into the types allows us to express and establish precise relative costs of several interesting programs that imperatively update their data. We have implemented ARel using ideas from bidirectional type checking.
Highlights
Standard cost analysis aims at statically establishing an upper or a lower bound on the evaluation cost of a program
The evaluation cost is usually measured in abstract units, for example, the number of reduction steps in an operational semantics, the number of recursive calls made by the program, the maximum number of abstract units of memory used during the program’s evaluation, etc
Relational cost analysis has many applications: It can show that an optimized program is not slower than the original program on stipulated inputs; in cryptography, it can show that an algorithm’s run time is independent of secret inputs, and that there are no leaks on the timing side channel; in algorithmic analysis, it can help understand the sensitivity of an algorithm’s cost to input changes, which can be useful for resource allocation
Summary
Standard cost analysis aims at statically establishing an upper or a lower bound on the evaluation cost of a program. This type represents a pair of computations, which when starting from arrays related by the relational precondition P, end with arrays related by the relational postcondition Q, return values related at τ , newly generated arrays referred by static names γ , and have relative cost at most r This design is inspired by relational Hoare logics (Benton, 2004; Nanevski et al, 2013), but there are two key differences: (1) Our pre- and postconditions are minimal—they only specify the indices at which a pair of corresponding arrays differ across the two runs, not full functional properties. ARel provides typing rules for the fix-point operator that allow one to simultaneously reason about the cost in the unary and relational setting This is useful for the analysis of several programs that we show later. An appendix with full proofs is available in the repository
Talk to us
Join us for a 30 min session where you can share your feedback and ask us any queries you have
Disclaimer: All third-party content on this website/platform is and will remain the property of their respective owners and is provided on "as is" basis without any warranties, express or implied. Use of third-party content does not indicate any affiliation, sponsorship with or endorsement by them. Any references to third-party content is to identify the corresponding services and shall be considered fair use under The CopyrightLaw.