Cost Analysis of Programs Based on the Refinement of Cost Relations

Cost analysis aims at statically inferring the amount of resources, such as time or memory, needed to execute a program. This amount of resources is the cost of the program and it depends on its input parameters. Obtaining a function (in terms of the input parameters) that represents the cost of a...

Full description

Bibliographic Details
Main Author: Flores Montoya, Antonio
Format: Others
Language:en
Published: 2017
Online Access:https://tuprints.ulb.tu-darmstadt.de/6746/1/Thesis_Antonio_Flores.pdf
Flores Montoya, Antonio <http://tuprints.ulb.tu-darmstadt.de/view/person/Flores_Montoya=3AAntonio=3A=3A.html> (2017): Cost Analysis of Programs Based on the Refinement of Cost Relations.Darmstadt, Technische Universität, [Ph.D. Thesis]
id ndltd-tu-darmstadt.de-oai-tuprints.ulb.tu-darmstadt.de-6746
record_format oai_dc
spelling ndltd-tu-darmstadt.de-oai-tuprints.ulb.tu-darmstadt.de-67462020-07-15T07:09:31Z http://tuprints.ulb.tu-darmstadt.de/6746/ Cost Analysis of Programs Based on the Refinement of Cost Relations Flores Montoya, Antonio Cost analysis aims at statically inferring the amount of resources, such as time or memory, needed to execute a program. This amount of resources is the cost of the program and it depends on its input parameters. Obtaining a function (in terms of the input parameters) that represents the cost of a program precisely is generally not possible. Thus, cost analyses attempt to infer functions that represent upper or lower bounds of the cost of programs instead. Many existing cost analyses approach the problem in two stages. First, the target program is transformed into an integer abstract representation where the resource consumption is explicit and second, the abstract representation is analyzed and cost bounds are inferred from it. The advantage of this approach is that the second part is language independent and resource independent. That is, it can be reused across different programming languages and to analyze the program cost with respect to different resources. Cost relations are a possible abstract representation. They are similar to constraint logic programs annotated with costs and they can easily represent both imperative and functional programs. Existing cost analyses based on cost relations have limited support for programs that have a complex control flow, or present amortized complexity, that is, when the sum of the cost of the parts yields a higher asymptotic cost than the cost of the whole. This thesis identifies these limitations, and presents a new analysis of cost relations that overcomes them. The analysis can obtain upper and lower bounds of programs expressed as cost relations and it contains three parts: 1. The first part reduces any mutually recursive cost relations to cost relations that only have direct recursion and performs some simplifications. 2. The second part consists of a refinement of cost relations that partitions all possible executions of the program into a finite set of execution patterns named chains. The refinement also infers precise invariants for each of the chains, discards unfeasible execution patterns and proves termination. 3. In the third part of the analysis, cost bounds are inferred compositionally. For that purpose, a novel cost representation, named cost structures, is presented. Cost structures reduce the computation of complex bounds to the inference of simple constraints using linear programming. They can represent polynomial upper and lower bounds of programs with max and min operators. The analysis is proven sound with respect to a new semantics of cost relations. This semantics distinguishes between terminating and non-terminating executions and models the behavior of non-terminating executions accurately. In addition, the analysis has been implemented in the tool CoFloCo and it has been extensively evaluated against other state-of-the-art tools and with respect to a variety of benchmarks. These benchmarks include imperative programs, functional programs, and term rewrite systems. CoFloCo performs well in all categories which demonstrates both the power of the analysis and its versatility. 2017-08-28 Ph.D. Thesis NonPeerReviewed text CC-BY-NC-ND 4.0 International - Creative Commons, Attribution Non-commerical, No-derivatives https://tuprints.ulb.tu-darmstadt.de/6746/1/Thesis_Antonio_Flores.pdf Flores Montoya, Antonio <http://tuprints.ulb.tu-darmstadt.de/view/person/Flores_Montoya=3AAntonio=3A=3A.html> (2017): Cost Analysis of Programs Based on the Refinement of Cost Relations.Darmstadt, Technische Universität, [Ph.D. Thesis] en info:eu-repo/semantics/doctoralThesis info:eu-repo/semantics/openAccess
collection NDLTD
language en
format Others
sources NDLTD
description Cost analysis aims at statically inferring the amount of resources, such as time or memory, needed to execute a program. This amount of resources is the cost of the program and it depends on its input parameters. Obtaining a function (in terms of the input parameters) that represents the cost of a program precisely is generally not possible. Thus, cost analyses attempt to infer functions that represent upper or lower bounds of the cost of programs instead. Many existing cost analyses approach the problem in two stages. First, the target program is transformed into an integer abstract representation where the resource consumption is explicit and second, the abstract representation is analyzed and cost bounds are inferred from it. The advantage of this approach is that the second part is language independent and resource independent. That is, it can be reused across different programming languages and to analyze the program cost with respect to different resources. Cost relations are a possible abstract representation. They are similar to constraint logic programs annotated with costs and they can easily represent both imperative and functional programs. Existing cost analyses based on cost relations have limited support for programs that have a complex control flow, or present amortized complexity, that is, when the sum of the cost of the parts yields a higher asymptotic cost than the cost of the whole. This thesis identifies these limitations, and presents a new analysis of cost relations that overcomes them. The analysis can obtain upper and lower bounds of programs expressed as cost relations and it contains three parts: 1. The first part reduces any mutually recursive cost relations to cost relations that only have direct recursion and performs some simplifications. 2. The second part consists of a refinement of cost relations that partitions all possible executions of the program into a finite set of execution patterns named chains. The refinement also infers precise invariants for each of the chains, discards unfeasible execution patterns and proves termination. 3. In the third part of the analysis, cost bounds are inferred compositionally. For that purpose, a novel cost representation, named cost structures, is presented. Cost structures reduce the computation of complex bounds to the inference of simple constraints using linear programming. They can represent polynomial upper and lower bounds of programs with max and min operators. The analysis is proven sound with respect to a new semantics of cost relations. This semantics distinguishes between terminating and non-terminating executions and models the behavior of non-terminating executions accurately. In addition, the analysis has been implemented in the tool CoFloCo and it has been extensively evaluated against other state-of-the-art tools and with respect to a variety of benchmarks. These benchmarks include imperative programs, functional programs, and term rewrite systems. CoFloCo performs well in all categories which demonstrates both the power of the analysis and its versatility.
author Flores Montoya, Antonio
spellingShingle Flores Montoya, Antonio
Cost Analysis of Programs Based on the Refinement of Cost Relations
author_facet Flores Montoya, Antonio
author_sort Flores Montoya, Antonio
title Cost Analysis of Programs Based on the Refinement of Cost Relations
title_short Cost Analysis of Programs Based on the Refinement of Cost Relations
title_full Cost Analysis of Programs Based on the Refinement of Cost Relations
title_fullStr Cost Analysis of Programs Based on the Refinement of Cost Relations
title_full_unstemmed Cost Analysis of Programs Based on the Refinement of Cost Relations
title_sort cost analysis of programs based on the refinement of cost relations
publishDate 2017
url https://tuprints.ulb.tu-darmstadt.de/6746/1/Thesis_Antonio_Flores.pdf
Flores Montoya, Antonio <http://tuprints.ulb.tu-darmstadt.de/view/person/Flores_Montoya=3AAntonio=3A=3A.html> (2017): Cost Analysis of Programs Based on the Refinement of Cost Relations.Darmstadt, Technische Universität, [Ph.D. Thesis]
work_keys_str_mv AT floresmontoyaantonio costanalysisofprogramsbasedontherefinementofcostrelations
_version_ 1719327430390317056