**1. Introduction**

In Denotational Semantics one of the aims consists of giving mathematical models of programming languages so that the meaning of a recursive algorithm can be obtained as an element of the constructed model.

Most programming languages allow to construct recursive algorithms by means of a recursive definition expressing the meaning of such a definition in terms of its own meaning. In order to analyze the correctness of such recursive definitions, D.S. Scott developed a mathematical theory of computation which is based on ideas from order theory and topology (Davey & Priestley, 1990; Scott, 1970; 1972). From the Scott theory viewpoint, the meaning of such a denotational specification is obtained as the fixed point of a nonrecursive mapping, induced by the denotational specification, which is at the same time the topological limit of successive iterations of the nonrecursive mapping acting on a distinguished element of the model. Moreover, the order of Scott's model represents some notion of information so that each iteration of the nonrecursive mapping, which models each step of the program computation, is identified with an element of the mathematical model which is greater than (or equal to) the other ones associated with the preceding iterations (preceding steps of the program computation) because each iteration gives more information about the meaning than those computed before. Hence the aforesaid meaning of the recursive denotational specification is modeled as the fixed point of the nonrecursive mapping which is obtained as the limit, with respect to the so-called Scott topology, of the increasing sequence of successive iterations. Consequently, the fixed point captures the amount of information defined by the increasing sequence, i.e. the fixed point yields the total information about the meaning provided by the elements of the increasing sequence, and it does not contain more information than can be obtained from the elements of such a sequence.

A typical and illustrative example of such recursive definitions is given by those recursive algorithms that compute the factorial of a nonnegative integer number by means of the following recursive denotational specification:

On one hand, we will show that Schellekens' method, and thus the original ideas of Scott, is useful to obtain asymptotic upper bounds of complexity for a class of recursive algorithms whose running time of computing leads to recurrence equations different from the Divide and Conquer ones. Moreover, we improve the original Schellekens's method by introducing a new fixed point technique which allows to obtain lower asymptotic bounds for the running time of computing of the aforesaid algorithms. We will illustrate and validate the developed method applying our results to provide the asymptotic complexity (upper and lower bounds) of the running time of computing of a celebrated recursive algorithm that computes the Fibonacci

<sup>101</sup> A Common Mathematical Framework for Asymptotic Complexity Analysis

and Denotational Semantics for Recursive Programs Based on Complexity Spaces

On the other hand, we will introduce a generalized mathematical method, in the spirit of Schellekens and based on the mathematical approach given in (Romaguera & Schellekens, 2000), which will be useful to formally describe the running time of computing of algorithms that perform a computation using recursive denotational specifications and the meaning, and thus the correctness, of such a denotational specification simultaneously. In order to validate the new results we will apply them to provide, at the same time, the program correctness and the asymptotic complexity class (upper and lower bounds) of the running time of a recursive

The remainder of the chapter is organized as follows: In Section 2 we recall a few pertinent concepts from asymptotic complexity analysis of algorithms. Section 3 is devoted to introduce the method of Schellekens, and its relationship to the above exposed Scott ideas, which provides an upper bound of the asymptotic complexity for those algorithms whose running time of computing leads to a Divide and Conquer recurrence equation. The utility of the method is illustrated by means of the application given by Schellekens to obtain an asymptotic upper bound of the average running time of computing of Mergesort. In order to analyze the complexity of the recursive algorithm that computes the Fibonacci sequence via the Schellekens approach, in Section 4 we will introduce the new method based on successive approximations and fixed point techniques that allow us to describe the complexity class (asymptotic upper and lower bounds) for the running time of computing of recursive algorithms more general than the Divide and Conquer ones. Moreover, in Section 5 we give the generalized mathematical method which is useful to describe formally the running time of computing of algorithms that perform a computation using recursive denotational specifications as well as their program correctness . Finally, in Section 6 we summarize the aims achieved and the advantages of our new mathematical methodologies with respect to

From now on, the letters **R**<sup>+</sup> and **N** will denote the set of nonnegative real numbers and the

In Computer Science the complexity analysis of an algorithm is based on determining mathematically the quantity of resources needed by the algorithm in order to solve the

Our basic reference for complexity analysis of algorithms is (Brassard & Bratley, 1988).

program that computes the factorial function via the denotational specification (1).

sequence (see, for instance, (Cull et al., 1985)).

the Schellekens and Scott ones.

**2. Fundamentals of Asymptotic Complexity Analysis**

set of positive integer numbers, respectively.

problem for which it has been designed.

$$fact(n) = \begin{cases} 1 & \text{if } n = 1 \\ nfact(n-1) \text{ if } n > 1 \end{cases} \tag{1}$$

Of course the above denotational specification has the drawback that the meaning of the symbol *fact* is expressed in terms of itself. Hence the symbol *fact* can not be replaced by its meaning in the denotational specification (1), since the meaning, given by the right-hand side in (1), also contains the symbol. Following the original ideas of Scott, the meaning of the specification (1), i.e. the entire factorial function, is obtained as the unique total function that is a fixed point of the nonrecursive functional *φf act* defined on the set of partial functions ordered by extension (see (Davey & Priestley, 1990) for a detailed description of the set of partial functions) by

$$\phi\_{fact}f(n) = \begin{cases} 1 & \text{if } n = 1\\ nf(n-1) \text{ if } n > 1 \text{ and } n - 1 \in \text{dom}f \end{cases}$$

where the successive iterations acting over the partial function *f*<sup>1</sup> (dom*f*<sup>1</sup> = 1 and *f*1(1) = 1) hold that *φ<sup>n</sup> f act <sup>f</sup>*1(*m*) = 1 if *<sup>m</sup>* <sup>=</sup> 1 and *<sup>φ</sup><sup>n</sup> f act f*1(*m*) = *m*! for all *m* ≤ *n*. Thus, the increasing with respect to the extension order sequence of iterations (*φ<sup>n</sup> f act*(*f*1))*n*∈**<sup>N</sup>** models each step of the computation of the factorial of a nonnegative integer number by a recursive algorithm using the specification (1) and, in addition, the limit of the sequence with respect to the Scott topology is exactly the meaning of the symbol *fact* which provides the factorial of each nonnegative integer number. Furthermore, each iteration provides more information about the symbol *fact* (i.e. about the entire factorial function) than the preceding ones.

Since Scott's mathematical theory of computation was introduced, it has been wondered in the literature whether such a model can be applied to other fields of Computer Science which differ from Denotational Semantics. A positive answer to the posed question was provided by M.P. Schellekens in (Schellekens, 1995). In fact, Schellekens showed that the original Scott idea of getting, via fixed point techniques, the meaning of a denotational specification as the topological limit of "successive approximations" is helpful in Asymptotic Complexity Analysis. Concretely, Schellekens introduced a novel mathematical method to provide asymptotic upper bounds of the complexity of those algorithms whose running time of computing satisfies a recurrence equation of Divide and Conquer type in such a way that the original ideas of Scott, namely, the meaning is a fixed point and is the limit of a sequence of successive iterations of a functional acting on a distinguished element, are respected but now the fixed point technique is new. Furthermore, in Schellekens' method the topology, intrinsic to the Scott model, is induced by a "distance" tool which provides, in addition, a measure of the degree of approximation of the elements that form the model. This fact yields an advantage over the Scott model because in the latter one quantitative data approach is not available.

Motivated by the fact that Schellekens' method successfully applies the Scott ideas for Denotational Semantics to the asymptotic complexity analysis of algorithms and that, in addition, the aforesaid method improves the Scott one in the sense that it allows to provide quantitative information, not only qualitative, about the degree of approximation of the elements that form the model, the propose of this chapter is twofold.

2 Will-be-set-by-IN-TECH

Of course the above denotational specification has the drawback that the meaning of the symbol *fact* is expressed in terms of itself. Hence the symbol *fact* can not be replaced by its meaning in the denotational specification (1), since the meaning, given by the right-hand side in (1), also contains the symbol. Following the original ideas of Scott, the meaning of the specification (1), i.e. the entire factorial function, is obtained as the unique total function that is a fixed point of the nonrecursive functional *φf act* defined on the set of partial functions ordered by extension (see (Davey & Priestley, 1990) for a detailed description of the set of

1 if *n* = 1

the symbol *fact* (i.e. about the entire factorial function) than the preceding ones.

where the successive iterations acting over the partial function *f*<sup>1</sup> (dom*f*<sup>1</sup> = 1 and *f*1(1) = 1)

the computation of the factorial of a nonnegative integer number by a recursive algorithm using the specification (1) and, in addition, the limit of the sequence with respect to the Scott topology is exactly the meaning of the symbol *fact* which provides the factorial of each nonnegative integer number. Furthermore, each iteration provides more information about

Since Scott's mathematical theory of computation was introduced, it has been wondered in the literature whether such a model can be applied to other fields of Computer Science which differ from Denotational Semantics. A positive answer to the posed question was provided by M.P. Schellekens in (Schellekens, 1995). In fact, Schellekens showed that the original Scott idea of getting, via fixed point techniques, the meaning of a denotational specification as the topological limit of "successive approximations" is helpful in Asymptotic Complexity Analysis. Concretely, Schellekens introduced a novel mathematical method to provide asymptotic upper bounds of the complexity of those algorithms whose running time of computing satisfies a recurrence equation of Divide and Conquer type in such a way that the original ideas of Scott, namely, the meaning is a fixed point and is the limit of a sequence of successive iterations of a functional acting on a distinguished element, are respected but now the fixed point technique is new. Furthermore, in Schellekens' method the topology, intrinsic to the Scott model, is induced by a "distance" tool which provides, in addition, a measure of the degree of approximation of the elements that form the model. This fact yields an advantage over the Scott model because in the latter one quantitative data approach is not

Motivated by the fact that Schellekens' method successfully applies the Scott ideas for Denotational Semantics to the asymptotic complexity analysis of algorithms and that, in addition, the aforesaid method improves the Scott one in the sense that it allows to provide quantitative information, not only qualitative, about the degree of approximation of the

elements that form the model, the propose of this chapter is twofold.

1 if *n* = 1

*n f*(*<sup>n</sup>* <sup>−</sup> <sup>1</sup>) if *<sup>n</sup>* <sup>&</sup>gt; 1 and *<sup>n</sup>* <sup>−</sup> <sup>1</sup> <sup>∈</sup> dom*<sup>f</sup>* ,

*nf act*(*<sup>n</sup>* <sup>−</sup> <sup>1</sup>) if *<sup>n</sup>* <sup>&</sup>gt; <sup>1</sup> . (1)

*f act f*1(*m*) = *m*! for all *m* ≤ *n*. Thus, the increasing

*f act*(*f*1))*n*∈**<sup>N</sup>** models each step of

*f act*(*n*) =

*φf act f*(*n*) =

*f act <sup>f</sup>*1(*m*) = 1 if *<sup>m</sup>* <sup>=</sup> 1 and *<sup>φ</sup><sup>n</sup>*

with respect to the extension order sequence of iterations (*φ<sup>n</sup>*

partial functions) by

hold that *φ<sup>n</sup>*

available.

On one hand, we will show that Schellekens' method, and thus the original ideas of Scott, is useful to obtain asymptotic upper bounds of complexity for a class of recursive algorithms whose running time of computing leads to recurrence equations different from the Divide and Conquer ones. Moreover, we improve the original Schellekens's method by introducing a new fixed point technique which allows to obtain lower asymptotic bounds for the running time of computing of the aforesaid algorithms. We will illustrate and validate the developed method applying our results to provide the asymptotic complexity (upper and lower bounds) of the running time of computing of a celebrated recursive algorithm that computes the Fibonacci sequence (see, for instance, (Cull et al., 1985)).

On the other hand, we will introduce a generalized mathematical method, in the spirit of Schellekens and based on the mathematical approach given in (Romaguera & Schellekens, 2000), which will be useful to formally describe the running time of computing of algorithms that perform a computation using recursive denotational specifications and the meaning, and thus the correctness, of such a denotational specification simultaneously. In order to validate the new results we will apply them to provide, at the same time, the program correctness and the asymptotic complexity class (upper and lower bounds) of the running time of a recursive program that computes the factorial function via the denotational specification (1).

The remainder of the chapter is organized as follows: In Section 2 we recall a few pertinent concepts from asymptotic complexity analysis of algorithms. Section 3 is devoted to introduce the method of Schellekens, and its relationship to the above exposed Scott ideas, which provides an upper bound of the asymptotic complexity for those algorithms whose running time of computing leads to a Divide and Conquer recurrence equation. The utility of the method is illustrated by means of the application given by Schellekens to obtain an asymptotic upper bound of the average running time of computing of Mergesort. In order to analyze the complexity of the recursive algorithm that computes the Fibonacci sequence via the Schellekens approach, in Section 4 we will introduce the new method based on successive approximations and fixed point techniques that allow us to describe the complexity class (asymptotic upper and lower bounds) for the running time of computing of recursive algorithms more general than the Divide and Conquer ones. Moreover, in Section 5 we give the generalized mathematical method which is useful to describe formally the running time of computing of algorithms that perform a computation using recursive denotational specifications as well as their program correctness . Finally, in Section 6 we summarize the aims achieved and the advantages of our new mathematical methodologies with respect to the Schellekens and Scott ones.
