A Denotational Approach to Measuring Complexity in Functional Programs
1.3. EVALUATION STRATEGIES cost of the length function that computes the length of a list is
5
n(t++ ttail+ tfalse)+ (n+ 1)(tnil?+ tapp+ trec)+ ttrue where n is the actual length of the list, and the costs represent the major actions of applying a function (tapp ), unrolling a recursive de nition (trec), tak
ing the tail of a list (ttail), taking either the false (tfalse) or true (ttrue) branches of a conditional, and adding two integers (t+ ). From this information we can determine that the time it takes to run length is O(n), i.e., is proportional to the length of the list.
1.3 Evaluation Strategies When evaluating an application, there is more than one way to handle the argument. The argument could be evaluated rst and the result handed to the calling function. This type of evaluation is called strict or call-by-value . Alternatively, the argument could be saved and evaluated only when needed. If the argument is evaluated every time it is needed, the evaluation strategy is called call-by-name . If the result of evaluating the argument is saved so reevaluation is not necessary, the evaluation strategy is called call-by-need . Thus when evaluating the expression (lam x:lam y:x+ x) e1 e2 The expression e1 is evaluated once for call-by-value and call-by-need, but twice for call-by-name, while the expression e2 is evaluated once by call-by-value, and not at all by call-by-need and call-byname. If it takes a lot of time to evaluate e1, then the call-by-value and the call-by-need strategies will take signi cantly less time to evaluate the overall expression. On the other hand, if it takes a long time to evaluation e2, then the call-by-name and call-by-need evaluations strategies will be faster than the call-by-value. It would thus seem that the call-by-need evaluation strategy would always be the most e cient. In practice, however, there is considerable overhead and complexity involved in keeping track of unevaluated expressions and updating the results of evaluation. For that reason there are many functional languages (e.g., Lisp, SML) that implement call-by-value evaluation. Even those languages that implement call-by-need (e.g., Haskell, Miranda) will often use strictness analysis to determine which arguments will always be evaluated, and use call-by-value evaluation on those arguments.
1.4 The Semantics The goal of this work is the development of a denotational pro ling semantics of higher-order strict and non-strict functional languages in order to analyze complexity behavior of programs in such languages. We are particularly interested in describing the costs of programs where part of the computation is delayed| either because an argument is needed or because a data type is lazy. The speci c language in use throughout this work is relatively simple| essentially the -calculus with conditionals, recursion, and constants. This language is a generalization of PCF ( 39]) in that we do not explicitly de ne the constants. It will be analyzed under two evaluation strategies: call-by-value and call-by-name. We discuss possibilities for analysis under call-by-need evaluation in section 6.2.4. The desired semantics for the language under both evaluation strategies will satisfy the following properties:
Managing Code Complexity... 暂无评价 4页 免费 A Denotational Approach ... 暂无评价 256页 免费 Measuring relational com... 暂无评价 14页 免费 ...
A Denotational Approach ... 暂无评价 256页 免费 Comparing the Complexity.... Measuring relational complexity in oddity discrimination tasks A relation-based...
Tilbury Methods of measuring the size and complexity of PLC programs in different logic control design methodologies? Received: 26 June 2003 / Accepted: 8...
Measuring Functional siz... 暂无评价 4页 免费 A Vector-Based Approach .... FROM MEASUREMENT OF SOFTWARE FUNCTIONAL SIZE TO MEASUREMENT OF COMPLEXITY D....
Computational Complexity and Lexical.Functional Grammar Computational Complexity ...Denotational Semantics for "Natural" Language Question-Answering Programs Main,...
Communication Complexity Method for Measuring Nondeterminism in Finite Automata While deterministic nite automata seem to be well understood, surprisingly many ...
A principled approach to detecting surprising ... or computational complexity reasons, is problematic...belongs to the same functional family as the ...
Functional Dependencies ... 暂无评价 5页 2.00...The metrics reflect the complexity of event ...The reactive approach aims at measuring dependencies...
functional and implementation/(software solutions) ...Complexity of CI Mutual dependency of CIs ...Vulnerability Measuring/identification possibility ...
Functional knowledge Sociolinguistic knowledge Strategic... measuring general ability or skill Aptitude tests...complexity of response Discrete-point tests: ...
热门文档