A Denotational Approach to Measuring Complexity in Functional Programs
2
CHAPTER 1. INTRODUCTION
higher-order functional languages. A third appealing property of functional languages (although not unique to them) is the widespread use of type constructors. Type constructors allow us to de ne data types without necessarily knowing much about the actual implementation; for example, we know that a list has a head, containing an element of some data type, and a tail, which is another list, and we can abstract away from implementation details. This facilitates analysis in two ways: by suppressing implementation details that do not a ect the value of data, the analysis becomes much simpler; and by restricting the operations on data types we can guarantee that no element of the data type has an invalid form (such as a circular list). The drawback is that because implementation details are hidden, it may be harder to determine the amount of space they require or the time taken by operations on data. Lastly, many functional languages allow lazy evaluation, either directly, as an integral part of the language, or indirectly, via higher-order types. When we speak of lazy evaluation, we usually mean at least one of two di erent optimizations. First, any evaluation is postponed until needed, avoiding possibly costly work if the result is never used. We also can manipulate data structures that are theoretically in nite as long as we only need to examine a nite amount of the structure. Second, evaluation can be memoized; that is, the result of an evaluation can be saved so that it can be looked up if needed again, avoiding re-evaluation. Programmers and researchers thus often nd functional languages very attractive. The applicative structure, lack of side e ects, and use of exible type constructors make it easier to design programs at a high level of abstraction, thus making it easier to prove program correctness. Furthermore, if we know that evaluation of one part of an expression has no side e ects, it is easy to analyze the expression compositionally. It is also possible to substitute part of an expression with another of equal value and know that the overall result is unchanged; this property is known as referential transparency . Such properties make the extensional analysis (i.e., analysis of inputoutput properties) of functional programs reasonably simple. Additionally, the use of higher-order and lazy data types increases the expressive power and elegance of programs; a program written in a functional language is frequently shorter than the equivalent program written in an imperative language. These advantages do come with a cost: As programs resemble function declarations more than machine instructions, it may be more di cult to det
ermine the appropriate instructions needed for the computer to run them. Analyzing internal properties such as space and time complexity becomes more di cult when much of the work done by the computer is hidden from the programmer. Because the compiler or interpreter handles all space allocation invisibly, we may not know exactly how much space is allocated for a given data structure or how much time is taken managing the space. Furthermore, for certain types it may be di cult to de ne what we mean by time complexity. For example, consider the function twice=
f: x:f (f (x))
The time it takes to compute twice f x is dependent on the size of x, the complexity of f, and the size of the output of f on x. A standard de nition for the complexity of an algorithm is a function from the size of the input to the time it takes to compute the output; however such a de nition does not work for programs such as twice, which needs not only the complexity of f but the size of f (x). A similar situation holds for lazy data structures; for example, we can easily show that a program that calculates the length of a list will take time proportional to the length of the list. Lazy lists, however, may not be completely evaluated, thus the time needed to nd their lengths includes the time taken to nish evaluating the structure of the list, adding a potentially
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: ...
热门文档