In the setting of ordinary computability theory, where computation is performed on finite objects (e.g., numbers, strings, or combinatorial objects such as graphs) there is a well-accepted notion of computational feasibility, namely polynomial-time computability. The extended Church-Turing thesis codifies the convention: the intuitive notion of feasibility is captured by the formal model of computability by a polynomial-time Turing machine.333Ignoring the possibility of quantum computers. From a programming perspective this can be interpreted as a formal definition of a class of programs that should be considered fast. Of course this theory only applies to programs whose execution is determined from a finite string that is considered the input. In practice, software often relies on external libraries or features user interaction. One may address this by moving to a setting where a Turing machine does not only act on finite inputs but additionally interacts with ‘infinite inputs’. This leads to the familiar oracle Turing machine model, where infinitary inputs are presented via an oracle that can be fed with and will return finite strings, so that only finite information about the oracle function is available at any step of the computation. The word oracle is used as no assumptions about the process to produce the values are made. In particular, the oracle provides return values instantly. From the software point of view this means judging the speed of a program independently of the quality of libraries or lazy users. Since the oracle can be understood as type-one input and oracle machines to compute type-two functions, the investigation of resource consumption in this model is called second-order complexity theory.
Can a sensible account of feasible computation be given in this model? If so, can it be kept consistent with the familiar notion of polynomial-time for ordinary Turing machine computation and the more traditional way of using oracle machines with 0-1 valued oracles ? These problems were first posed by Constable in 1973 . He proposed only potential solutions and the task was taken up again by Mehlhorn in 1976, who gave a fully-formulated model . This model is centered around Cobham’s scheme-based approach to characterizing polynomial-time . While such scheme based approaches are very valuable from a theoretical point of view , for some applications it may be desirable to have a characterization that relies on providing bounds on resource consumption in a machine-based model. Indeed, Mehlhorn related his formulation to the oracle machine model by proving that it satisfies the Ritchie-Cobham property: a functional is in his class if and only if there is an oracle machine and a bounding functional from the class such that for any inputs the machine computes the value of the functional in question and has a running time bounded by the size of the bounding functional. The impredicative nature of Mehlhorn’s OTM characterization left open the possibility of a characterisation based more closely on the type-one model of polynomial-time Turing machines.
Only in 1996 did Kapron and Cook show that it is possible to give such a characterisation by relying on the notions of function length and second-order polynomials . The resulting class of basic polynomial-time functionals was proved equal to Mehlhorn’s, providing evidence of its naturalness and opening the way for applications in diverse areas. A representative but by no means exhasutive list includes work in computable analysis , programming language theory , NP search problems , and descriptive set theory . The model was also used as a starting point for understanding how complexity impacts classical results on computability in higher types [3, 23, 22].
Ideas similar to those used by Kapron and Cook were used for a number of logical characterizations of the basic polynomial-time functionals supporting appropriateness of the class. Works using logics based on bounded arithmetic [12, 27] rely on implicit representations of second-order polynomials. A drawback of the Kapron-Cook approach is that length functions and second-order polynomials are not particularly natural objects to work with. For instance, the length of a function – which can be viewed as the most basic example of a second-order polynomial – is not feasible. This has direct implications for the applications. The most common approach to avoid technical difficulties is to restrict to length-monotone oracles [15, 28]. This corresponds to using only a fragment of second-order complexity theory and may in turn lead to technical difficulties.
Additional support for Mehlhorn’s class and insight in its structure came from initial doubts whether it is broad enough to include all type-two functionals that should be considered feasible. Cook formulated a notion of intuitive feasibility, and pointed out that a type-two well quasi-ordering functional, which meets the criteria of intuitive feasibility, is not in Mehlhorn’s class . Subsequent work uncovered a number of shortcomings of the notion of intuitive feasibility. Seth provided a class that satisfies the conditions but has no recursive presentation  and also proved that Cook’s functional does not preserve the Kalmar elementary functions . Attempts by Seth and later by Pezzoli to formulate further restrictions on intuitively feasible functionals to avoid noted pitfalls lead back to Mehlhorn’s class .
Cook’s intuitive feasibility uses the notion of oracle polynomial-time, which is formulated using ordinary polynomials. A POTM (for ‘polynomial oracle Turing machine’) is an oracle machine whose running time is bounded in the maximum size of its string input and all answers returned by its oracle input during its computation on these inputs. By itself, this notion is too weak to provide a class of feasible functionals: it is well known that iterating a polynomial-time function may result in exponential growth and that this is possible within this class. While Cook’s approach was to rule out this behaviour on a semantical level, an alternate approach explored by a number of works involves the introduction of further restrictions to the POTM model [25, 21, 13]. Most of these restrictions are fairly elaborate and in some sense implicitly bound by second-order polynomials.
The present paper investigates less elaborate ways to restrict the behaviour of POTMs. We present two simple syntactic restrictions to the POTM model that give proper subclasses of Mehlhorn’s class and prove them to – when closed in a natural way – lead back to the familiar class of feasible functionals.
The first restriction, originally introduced by Kawamura and Steinberg, is called finite length revision and operators computable by a POTM with finite length revision are called strongly polynomial-time computable . It is known that this excludes very simple examples of polynomial-time computable operators. The second restriction is similar, original to this work and we dub it finite lookahead revision. We call operators that are computable by such a POTM moderately polynomial-time computable. The name is motivated by our results that this class includes the strongly polynomial-time computable operators (Proposition 2.2) and is contained in the polynomial-time operators (Proposition 2.2). These inclusions are proven to be strict (Example 2.2), but in contrast to strong polynomial-time it requires some effort to find something that is polynomial-time but not moderately polynomial-time. Along the way we prove that in our setting an additional restriction on the POTMs that Kawamura and Steinberg impose is not actually a restriction (Lemma 2.1).
In both cases, the failure to capture feasibility is due to a lack of closure under composition. The main result of this paper (Theorem 3.2) is that each of these classes, when closed under lambda-abstraction and application, results in exactly the polynomial-time functionals. To prove this we establish moderate polynomial-time computability of limited recursion (Lemma 3.2) and provide a factorization of any moderately polynomial-time computable operator into a composition of two strongly polynomial-time computable operators (Theorem 3.3). The proof of the later turns out to have a nice interpretation: The outer operator executes the original machine while throwing exeptions in certain cases and the inner operator is an exception handler whose form only depends on restricted information about the original operator. Finally, we point out a case where composition does not lead to a loss of moderate polynomial-time computability (Lemma 3.3).
The notion of a POTM is what a person familiar with complexity theory would probably come up with first if asked what programs with subroutine calls should be considered efficient. The inadequacy of this model is very easy to grasp: even if the subroutine is polynomial-time, there is no guarantee that the combined program runs in polynomial-time. The two conditions of finite length and lookahead revision are very straightforward attempts to solve this issue. We prove that imposing either in addition to the POTM condition leads to feasible programs and that it remains possible to produce solutions to all feasible problems as long as one is willing to separate the task at hand into subtasks if necessary. We provide some – but far from complete – insight into when such a split is necessary and how it can be done.
Let denote any finite alphabet, and the set of finite strings over . Usually , occasionally we use another separator symbol . The empty string is denoted , and arbitrary elements of are denoted . If , we write to denote their concatentation, to denote the length of , to denote truncated to its highest-order bits, for . We write to indicate that is an initial segment of (i.e. for some , ). For every and we note that there exist polynomial-time functions and such that . We assume that for every there are constants such that and that increasing the size of any of the strings does not decrease the size of the tuple. The tupling functions are lifted to also pair functions via . A type 0 functional is an element of , and for , a type funtional is a mapping from functionals of type to . This paper is mostly concerned with type functionals for .
1.1 Second-order complexity theory
In , Kapron and Cook introduce a computational model for type-two polynomial time functionals using oracle Turing machines. We begin by reviewing their model. For notational simplicity, we do this in the operator setting: Denote by the Baire space, that is the collection of all univariate type 1 functions. The elements of are denoted by , , …. An operator is a mapping .
An oracle Turing machine (OTM) or for short oracle machine is a Turing machine that has distinguished and distinct query and answers tapes and a designated oracle state. The run of an oracle machine on oracle and input proceeds as the run of a regular machine on input , but whenever the oracle machine enters the oracle state, with written on the query tape, is placed immediately on the answer tape, and the read/write head returns to its initial position on both of these tapes. If the machine terminates we denote the result by .
The number of steps an oracle machine takes given oracle and input is counted as in a Turing machine with the following addition already implied above: entering the oracle state takes one time step, but there is no cost for receiving an answer from the oracle. 444In this paper, we follow the unit-cost model , as opposed to the length-cost model . Note that while an answer is received from the oracle in a single step, any further processing takes time dependant on its length. The running time of an oracle machine usually depends on the oracle.
To be able to talk about bounds for this running time it is necessary to have a notion for the size of an oracle.
For a given oracle function define its size function by
This suggests the type as the right type for running times: If is a function of this type, we say that the running time of an oracle machine is bounded by if for all oracles and all strings it holds that
The only thing left to do is to pick out the time bounds that should be considered polynomial.
The set of second-order polynomials is the smallest subset of that contains the functions , , , is closed under point-wise addition and multiplication and such that whenever is an element, then so is .
We may now use Kapron and Cook’s characterization  as our definition of Mehlhorn’s class:
An operator is polynomial-time computable if there is an oracle machine and a second-order polynomial such that for all oracles and all strings it holds that
We use to denote the class of all polynomial-time operators.
This notion gives rise to a notion of polynomial-time computable functionals of type two. By abuse of notation we also refer to this class of functionals by . The functional view becomes important in Section 3. In literature these notions are often referred to as ‘basic polynomial-time’. As discussed in the introduction this is due to past uncertainties about the class being broad enough. We believe that enough evidence has been gathered that the class is appropriate and drop the ‘basic’.
Consider the following result taken from  that implies the closure of polynomial-time computable operators under composition.
Let and be second-order polynomials that bound the running times of oralce machines. Then there exists an oracle machine that computes the composition of the corresponding operators and a such that for all and
The proof is straightforward and the reader not familiar with the setting may sketch a proof to get a feeling for oracle machines, higher-order time bounds and second-order polynomials. Unsurprisingly, the machine in this proof is constructed by replacing the oracle query commands in the program of the machine computing the outer operator by copies of the program of the machine computing the inner operator and slightly adjusting the rest of the code. Note how this result lends itself to generalizations: Kawamura and Steinberg use it to lift closure under composition to a class of partial operators that they still refer to as polynomial-time computable. The proof also remains valid if the second-order polynomials and are replaced by arbitrary functions and that are monotone in the sense that whenever is point wise bigger than and both are non-decreasing then the same holds for the functions and .
Reasoning about second-order polynomials as bounding functions can at times be tricky. Their structure theory is significantly less well developed than that of regular polynomials. Indeed, it is not clear whether second-order polynomials allow a nice structure theory at all. Furthermore, the use of nonfinitary objects in running times raises the question of computational difficulty of evaluating such bounds. It is a very simple task to find the length of a string from a string. In contrast, evaluating the length of a string function is intuitively a hard task as it involves taking a maximum over an exponential number of inputs. The following theorem from  makes this intuition formal.
The length function is not polynomial-time computable: An operator that fulfills
cannot be polynomial-time computable.
As a consequence, a running time bound of an oracle machine is not very useful for estimating the time of a run on a given oracle and input. Even if the running time is a second-order polynomial, to get the value one has to evaluate the length function several times.
Of course, in this setting the task is a little silly. It is possible to evaluate the machine and just count the number of steps it takes. This results in a tighter bound that can be computed from the oracle and the input in polynomial time. However, from a point of view of clockability, the problem is relevant: given a second-order polynomial that is interpreted as a ‘budget’ and an oracle machine that need not run in polynomial time it is in general impossible to specify another machine that runs in polynomial-time and such that for all oracles and inputs
That is: returns the correct value in the case that the run of is in budget .
1.2 Oracle polynomial-time
The following notion was originally introduced by Cook  and has been investigated by several other authors as well [25, 26, 21]. Recall that for an oracle machine the number of steps this machine takes on input with oracle was denoted by and that for counting the steps, the convention to count an oracle query as one step was chosen.
Let be an oracle machine. For any oracle and input denote by the maximum of the lengths of the input and any of the oracle answers that the machine gets in the run on input with oracle . The machine is said to run in oracle polynomial-time if there is a polynomial such that for all oracles and inputs
Let denote the class of operators that are computed by a machine that runs in oracle polynomial-time.
To avoid confusion with different notions of running times, we call a function that fulfills the condition from (1.2) in place of a step-count of . Thus, an oracle machine runs in oracle polynomial-time if and only if it has a polynomial step-count. An oracle machine with a polynomial step-count may be referred to as a POTM.
The nature of the restrictions imposed on POTMs significantly differs from imposing a second-order time bound as is done in Definition 1.1. Instead of using higher-order running times, the same type of function that are used as running times for regular Turing machines is used. The dependence on the oracle is accounted for by modifying the input of the bounding function. This appears to be a relaxation of bounding by second-order polynomials. The following result of  shows that this is indeed the case.
Any oracle machine that runs in time bounded by a second-order polynomial has a polynomial step-count.
Let be an oracle machine that runs in time bounded by a second-order polynomial . For let be the constant function with value . Claim that the polynomial given by
is a step-count. To verify this let be an arbitrary oracle and an arbitrary input. Replace the oracle with the oracle that returns the same values as on all of the oracle queries that are asked in the computation of and returns the empty string on all other arguments. Since the machine can only interact with the oracles through the queries, the computations and coincide. In particular the time these computations take are the same. By definition of , and it holds that . It follows from being a running time bound of and the monotonicity of second-order polynomials that
Since and were arbitrary, it follows that is a polynomial step-count of .
It is well known that forms a proper subclass of . There exist operators in that do repeated squaring and thus do not preserve polynomial-time computability.
can be computed by a machine that runs in oracle polynomial-time but does not preserve polynomial-time computability as it maps the polynomial-time computable function to a function whose return values grow exponentially.
2 Recovering feasibility from
The failure of to preserve polynomial-time computability indicates that it is unsuitable as a class that captures an acceptable notion of feasibility. We may ask whether there is a natural way to restrict the POTM model to recover feasibility. One way to do this is to introduce preservation of polynomial-time functions as an extrinsic or a semantic restriction . This is the approach taken by Cook with his notion of intuitively feasible functionals . Since the formulation of Cook’s restrictions is most comfortably done using lambda calculus we postpone restating them to Section 3. Here, we consider intrinsic or syntactic restrictions of the POTM model instead. While in part this is motivated by some of the drawbacks of the extrinsic approach, we believe that the syntactic approach stands on its own merit. In particular, if the syntactic condition is simple enough and checkable with minimal overhead, it provides simpler analysis techniques for showing that a particular operator is feasible.
Motivated by the difficulty encountered with repeated squaring in Example 1.2, we consider POTMs with restrictions on the oracle access that disallow this behaviour. Similar restrictions have been considered by Seth [25, 26]. Seth’s class consists of operators computable by POTMs whose number of queries to the oracle is uniformly bounded by a constant, while his class is defined using a form of dynamic bound on the size of any query made to the oracle. It should be noted, that Seth proves his class to coincide with Mehlhorn’s class and that it employs POTMs that are clocked with something that faintly resembles second-order polynomials. The class is too restrictive to allow to recover all polynomial-time operators. The class is aimed at finding a bigger class of operators that should still be considered feasible and thus overly complicated for our purposes. For the similar reasons we do also not go into detail about restrictions considered by Pezzoli .
We seek conditions that do not beg the question of whether is a maximal class of feasible functionals, disallow iteration and are less restrictive than those of .
2.1 Strong polynomial-time computability
The first restriction on that we consider was introduced by Kawamura and Steinberg in :
An oracle machine is said to run with finite length revision if there exists a number such that in the run of the machine on any oracle and any input the number of times it happens that an oracle answer is bigger than the input and all of the previous oracle answers is at most .
It should be noted that Kawamura and Steinberg use a slightly different notion of a step-count. They say that a function is a step-count of an oracle machine if for all oracles and inputs it holds that
where is the maximum of and the biggest oracle answer given in the first steps of the computation of with oracle and input . For the function to be a step-count in the sense of the present paper it suffices to satisfy the condition for the special choice . The reason we use the same name for both of these notions is that they are equivalent in our setting. The result is interesting in its own right as the advantage of Kawamura and Steinberg’s notion is that it can be checked on the fly whether a given polynomial is a step-count of an oracle machine without risking to spend a huge amount of time if this is not the case. We only state this for the case we are really interested in, but the proof generalizes.
Every oracle machine that computes an operator from has a polynomial step-count (in the sense of Kawamura and Steinberg).
Let be a machine that computes an element of . Then there exists a polynomial such that
We claim that this polynomial is already a step-count in the sense of Kawamura and Steinberg. Towards a contradiction, assume that the polynomial was not a step-count. Then there exists some time , a string and an oracle such that if we evaluate the polynomial at the size of the biggest oracle answer that is returned in the computation of with oracle , and input up until the -th step. Replace the oracle by the oracle that returns the exact same answers as on the strings that are asked in this run before the -th step and returns on all other strings. Note that due to the machine being deterministic the computation of on oracle and are identical up to the -th time step. Furthermore, due to the definition of , the number coincides with the biggest size of any oracle answer gives. Thus, it follows that and therefore
This contradicts the assumption that is a step-count of the machine .
The key idea of the above proof is that the oracle can be modified arbitrarily. In a setting where not all oracles are eligible this might not be possible anymore. In this case it is advisable to work with step-counts in the sense of Kawamura and Steinberg. Since this paper only considers total operators, i.e. no restrictions are imposed on the oracles, it is irrelevant which notion is used. In particular we may formulate strong polynomial-time computability as introduced in .
An operator is strongly polynomial-time computable if it can be computed by an oracle machine that has both finite length-revision and a polynomial step-count. The class of these operators is denoted by .
As the name suggests, strong polynomial-time compuatbility implies polynomial-time computability. We state this as it can be deduced from the results of this paper. A direct proof is given in .
The running time of a machine that has a polynomial step-count and finite length revision can be bounded by a second-order polynomial.
A merit of strong polynomial-time computability is that it has a direct interpretation as additional information about the running time of the machine: Knowing a polynomial step-count of a program and the number of length revisions, one can modify the program to provide real-time information about how long it estimates it will run. It can provide an estimate of the remaining computation time under the assumption that all necessary information has already been obtained from the oracle. In case new information is gained via oracle interaction it may update this estimate, but it may only do so at most times.
A drawback of strong polynomial-time computability is that it severely restricts the access a machine has to certain oracles. It may always run into an increasing sequence of answers early in the computation. Once it runs out of length revisions, it can not pose any further oracle queries. There is no way to design a machine with finite length revision that does not simply abort when the revision budget is exceeded. This is reflected in the following example that shows that there are operators from that are not in , and was first considered in .
is polynomial-time computable but not strongly polynomial-time. Any machine computing must query at every . Regardless of the order in which the machine decides to ask the queries, there is always an oracle whose answers are increasing in size. However, , as it may be computed by examining queries, each of which is of size at most .
2.2 Finite lookahead revision
The notion of strong polynomial-time computability rests on controlling the size of answers provided by calls to the oracle. While this restriction achieves the goal of disallowing anything but finite depth iteration, Example 2.1 shows that it also excludes rather simple polynomial-time computable operators. This suggests an alternate form of control, namely controlling the size of the queries themselves instead of the answers.
An oracle machine is said to run with finite lookahead revision if it there exists a natural number , such that for all possible oracles and inputs it happens at most times that a query is posed whose size exceeds the size of all previous queries.
We are mostly interested in operators that can be computed a machine that both has finite lookahead revision and a polynomial step-count. In keeping with the terminology of strong polynomial time, we shall call the class of operators so computable moderate polynomial time, denoted . Consider the operator that maximizes the size of the return value of the oracle over the initial segments of the string input. This operator was used to separate from in Example 2.1 and therefore fails to be strongly polynomial-time computable. The operator is inlcuded in : A machine computing on inputs may just query the initial segments of in decreasing order of length to obtain the maximum answer.
While the definition above seems reasonable enough, it entails that machines sometimes need to unnecessarily pose oracle queries: to ask all interesting queries up to a certain size it may be necessary to pose a big query whose answer is of no interest to the computation just to avoid lookahead revisions during the computation. It is possible to tweak the oracle access of machines to avoid this behaviour and still capture the class of operators that are computed with finite lookahead revision. For instance one may use a finite stack of oracle tapes, where no pushing is allowed and popping requires the machine to specify a number of cells the tape is then truncated to in unary. While this model is not the most straight forward one, it is appealing since similar restrictions on the oracle access have to be imposed to reason about space bounded computation in the presence of oracles [2, 16].
The running time of a machine that has a polynomial step-count and finite lookahead revision can be bounded by a second-order polynomial.
Let be a machine with polynomial step-count that never does more than lookahead revisions. Since increasing a function point-wise preserves being a step-count, we may assume . Claim that the running time is bounded by the second-order polynomial
To see this, prove the stronger statement that the runtime of such a machine is bounded by the non-polynomial function by induction over the lookahead revision number . If is zero, the machine does not ask any oracle queries and has to terminate within steps. If the assertion has been proven for and is a machine with lookahead revision number , then consider the machine that carries out the same operations as does but aborts as soon as attempts to do the -th length revision by issuing a big oracle query. This machine has length revision number . Thus, by the induction hypothesis, the oracle query that lead to abort and that triggers the last lookahead revision in can at most have been of length . By definition of the length function the answer of the oracle has at most length applied to that value. Since all later oracle queries have to be of smaller length and is a step-count of the machine, the time that takes can be bounded by the step-count applied to the maximum of that value and the length of the input. Recall that we assumed and therefore . Thus,
Which proves the assertion, and therefore also the proposition.
Every strongly polynomial-time computable operator is moderately polynomial-time computable.
let be a machine that proves that an operator is strongly polynomial-time computable. Let be a polynomial step-count of the machine and let be its number of length revisions. Consider the machine that works as follows: First it checks if is bigger than and if so poses an oracle query of this size. This leads to a lookahead revision. Then it follows the first steps that takes while remembering the size of the biggest oracle answer that it receives. This does not lead to a lookahead revision as the machine does not have enough time to formulate a query big enough. Since is a step count, can at most take steps before it has to either terminate or encounter a length revision. If it terminates, let return its return value. If it encouters a length revision, then the maximum of the return values that recorded is bigger than and repeats the proceedure with replaced by . Note that the whole process can at most be iterated times as each time has to either terminate or encounter a length revision. Thus, in the last repetition, has to terminate and it follows that and compute the same operator. Also note that during each of the repetitions encounters exactly one lookahead revision and thus the number of lookahead revisions of is bounded by the number of length revision of . Finally has a polynomial step-count as the number of steps required to carry out the operations described above can easily be bounded by a polynomial. It follows that proves that the operator computed by is included in .
Although is more powerful than , it is still not powerful enough to capture all of :
Consider the operator defined as follows: First recursively define a sequence of functions by
That is: start on value and times iterate the process of applying the function and then truncating the result to have length . Set
We claim that this operator is polynomial-time computable but can not be computed by a machine that has finite lookahead revision and a polynomial step-count. To see that is polynomial-time computable note that for any string of length bigger than one we have
Thus, the straight-forward algorithm that on input and oracle computes the sequence runs in time about .
To see that cannot be computed by a machine with polynomial step-count and finite lookahead revision, let be a machine that computes and has a polynomial step-count . Without loss of generality assume . For any given number construct a sequence of oracles such that forces lookahead revisions on input . To do so, first choose some such that . This is fulfilled by almost all natural numbers as the right hand side grows exponentially while the left hand side is a polynomial, in particular an appropriate exists.
Recursively define the sequence in parallel with a sequence of pairwise distinct strings of length such that each string has at least one digit that is 0. Let be the constant function returning the empty string and for define from the strings by
The function is well-defined due to the assumptions about the sequence .
The string is recursively defined from as follows: For recall that was defined to be the constant function returning the empty string. Consider the computation . Since is a step-count and (the second inequality follows since due to the assumptions), there exists at least one string of length that neither coincides with nor nor with any of the oracle queries asked in this computation. Now assume that all with have been defined. This means that is defined. Consider the computation of . Since the length of the return values of is bounded by , the number of steps in this compuation is smaller than
Thus, there exists a string of length that is different from the strings , and as well as all the oracle queries that are asked in the computation.
This finishes the construction and it is left to prove that forces lookahead revisions. The proof proceeds by induction on . The case is trivial as forcing lookahead revisions does not require doing anything. Next assume that the assertion has been proven for . Claim that the string is posed as a query in the computation . Since the values of and only differ in the strings and , the computations of on and coincide up to the point where either of these strings is posed as a query. Since the computation with oracle takes at most
steps, the machine either queries or none of the two. Towards a contradiction assume that the machine poses neither of the two queries. The runs on and coincide and – by the construction of the string – the return value is different from . Therefore, the run on the oracle which is identical to everywhere but on input where it returns instead of leads to an identical run. The fact that leads to a contradiction with the assumption that computes . Thus, has to be posed as an oracle query in the computation . The same argument with the same counter example function also proves that the string has to be posed as a query. Since no query before the query can have had size , posing this query requires an additional lookahead revision.
2.3 Existence of step-counts and an application
While the notion of finite lookahead revision is most useful in the presence of a polynomial step-count, it is also meaningful for general operators. Consider the iteration operator from Example : intuitively it should be possible to prove that this operator cannot be computed by a machine with finite lookahead revision at all. However, the usual construction of a counterexample oracle only generalizes under the assumption that the machine considered has a step-count. Luckily, using topological methods that originate from computable analysis, it is possible to prove that step counts do always exist: In , Schröder notes that a machine that computes a total operator has a well-defined running time. In the setting of regular machines the existence of a function that bounds the running time is obvious: the set of all strings of length smaller than a fixed natural number is finite and a time bound of a machine without an oracle can therefore be obtained by taking the maximum of the times of its runs on each of these. Recall that the size of an oracle is defined by
The sets of all oracles whose size is bounded by a given function is almost never finite. However, if Baire space is given its standard topology, all of the sets are compact. Schröder notes that for any machine , the time function is a continuous function. Since continuous functions assume their maximum over compact sets, the time function is well defined under the assumption that the machine terminates on all inputs. Thus for any machine there exists a function such that for all and
From such a time function one may obtain a step-count just like a polynomial step-count was obtained from a polynomial running time in Theorem . We give a direct proof of a stronger statement by adapting Schröders’ methods to the setting.
Lemma (Existence of step-counts)
Any oracle machine that computes a total operator has a computable step-count.
Fix an oracle machine that computes a total operator. Note that the time function , is a continuous mapping. The set
is a compact subset of . Since a continuous function assumes its maximum on a compact set, we may define a function via
Moreover, this function is computable as its values can be obtained by simulating the computation of (again using the fact that is compact and therefore at some point it can be verified that the possible computation paths are exhausted).
It remains to prove that is indeed a step count of : For an arbitrary oracle denote by the oracle that returns the initial segments of the length of the answers that provides. Let be an arbitrary oracle and an input. Note that in the computation a finite number of oracle queries is asked. Furthermore, the steps of the computation that are taken before the first oracle query is asked coincide with the computation where is replaced by the oracle . Consider the computation . Since , by the definition of the machine takes at most steps before it terminates or asks an oracle query that and do not agree on. If the machine terminates before it asks such a query, it follows that is a step-count and we are done. If the machine asks a query such that the two oracles do not agree on , then has to be bigger than . We may replace the oracle by the oracle , and it follows that . Thus, by definition of again, the number of steps the machine takes until it either terminates or asks a query that distinguishes the two oracles and is bounded by . Repeating the above argument at most times proves that and do not provide a counter example for being a step-count for . Since and were arbitrary, it follows that is a step-count of .
As an application of the above lemma and for the sake of having a rather simple construction of a counter-example oracle spelled out in this paper we revisit Example .
Example (Repeated squaring revisited)
The operator from Example , namely
is not polynomial-time computable. Moreover, as noted in Example , it can not be computed by a machine that has a polynomial step-count and finite lookahead revision.
More generally, there does not exist an oracle machine with finite lookahead revision that computes : Towards a contradiction assume that was an oracle machine that computes . Let be a computable step-count of which exists by Lemma . Without loss of generality assume that is strictly increasing. Define oracles that force big numbers of lookahead revisions as follows. Let
Note that cannot be written without a lookahead revision happening: The output is too long to be written in the number of steps that the machine may take without asking a query. Further note that and that the length of the return values of on strings that are shorter than are bounded by . Therefore, at least two lookahead revisions must have happened for the machine to be able to print : The time the machine is granted without lookahead revision does neither suffice to print the whole output nor to ask a query big enough to obtain an oracle answer of length bigger than , which grants more time, namely , but still not enough to print the output. Thus, at some point after the first query, whose size is bounded by another query of bigger size, but still bounded by must be issued to obtain a big value of and be able to print the output. Iterating this argument leads to the conclusion that the computation must feature at least lookahead revisions and since the machine was arbitrary that the operator does not have finite lookahead revision.
3 Lambda-calculi for feasible functionals
The preceding chapter presented two classes and of operators based on simple syntactical restrictions to POTMs, both of which fail to capture all of . The rest of the paper proves that this is exclusively due to a failure of closure of these classes under composition.
Composition is a notion from the operator setting, but for this chapter the functional standpoint is more convenient. In the functional setting, there are more ways of combining functionals. consider for instance : one may apply and hand the resulting string as input to , i.e. send and to , or leave the string argument in open and use this as function input for : I.e. send and to . The latter captures the composition of operators and uses the familiar notation for lambda-abstraction. One may go one step further and also use lambda-abstraction over and to express the two ways to combine functionals by terms in the lambda-calculus with and as constants. On the other hand, any term in the lambda-calculus with constants from a given class of functionals can be interpreted as a functional again. It should be noted that in general these functionals need not be type-one or two anymore as the lambda-calculus provides variables for each finite type.
This section reasons about closures of classes of functionals under -abstraction and application as a subsitute for closure under composition in the operator setting. We do not attempt to give a self-contained presentation of the tools from lambda-calculus needed here and point to  for more details. The most important parts are also gathered in Appendix A. Our primary focus is on using such calculi definitionally – that is we are interested in the denotational semantics of type-one and -two terms, and only require operational notions to reduce arbitrary terms to such terms. In particular, we consider systems with constant symbols for every function in some type-one or -two class, without necessarily giving reduction rules for such symbols. Note that we do not restrict the type of the functionals we work with from the beginning on but do this after the closing procedures by means of taking sections.
For a class of functionals, let denote the set of simple-typed -terms where a constant symbol is available for each element of . For a set of terms the one-section of , denoted , is the class of functions represented by type-one terms of . The two-section of , denoted , is the set of functionals represented by type-two terms of .
Denote the class of polynomial-time computable functions by . It is well-known that . Seth proves that , where is his class of functionals computed by POTMs only allowed to access their oracle a finite number of times.
Mehlhorn’s schematic characterization of polynomial-time  fits quite nicely into the lambda calculus approach. However, the limited recursion on notation scheme translates to a type-three constant as it produces a type-two functional from a set of type-two functionals. Work by Cook and Urquhart revealed that it is possible to use a type-two constant instead . Cook and Urquart consider lambda-terms with symbols for a collection of basic polynomial-time computable functions as well as one type-two symbol capturing limited recursion on notation. We denote the functional that Cook and Urquart use to give meaning to by as for our purposes a slightly different one is more convenient. Set
where . Readers familiar with the Mehlhorn’s limited recursion on notation scheme should note that this is an application of the scheme to feasible functionals and that itself is a feasible functional. The next section verifies this directly for a very similar functional.
Cook and Kapron consider a version of the Cook-Urquhart system which includes constant symbols for all type-one polynomial-time functions . The classes of functionals that correspond to the terms in either of these version coincide. Kapron and Cook call these functionals the the basic feasible functionals and denote them by . Thus, up to identification of lambda terms with the functionals they represent. Adding all polynomial-time functions as symbols has the advantage that need only be used for properly higher-order recursions.
The class contains functionals of all finite types and can be cut down to the types we are interested in by considering the sections and . While there are reasonable doubts whether the class captures feasiblity in all finite types , the significance of its two-section is demonstrated by the following result of Kapron and Cook .
The basic feasible functionals of type-two are exactly the polynomial-time functionals.
It is also true that . Cook’s notion of intuitively feasible functionals is based on this property of : Cook calls a type-two functional intuitively feasible if the corresponding operator is in and adding it to does not change the one-section, i.e. .
3.1 Limited recursion as an operator
As mentioned, using a recursion functional slightly different from Cook and Urquart’s is more convenient for our purposes. Consider the limited recursion functional , i.e. the type-two functional defined by and
First we establish that we may indeed swap the recursion functional with this functional.
The recursion functionals and are equivalent in the sense that
Clearly, . For the other direction first show that the operator
may be defined using . Define such that . Thus,
where if and otherwise. Let be the polynomial-time function that satisfies: if and otherwise. Then
This proves the assertion.
The classes and contain operators. To capture the limited recursion functional we first need to give an equivalent operator. Indeed an arbitrary type-two functional may be translated to an operator within the lambda calculus in exactly the same way and this may be interpreted as an alternate normal form. Not surprisingly, this normal form relies on the availability of tupling functions and projections. In the situations we are most interested in these are always available, either because constants for the polynomial-time computable functions are available or because we can provide replacements for these.
A different way to approach this problem would be to adapt the definition of oracle machines to allow for multiple oracles and multiple input and output tapes. It is worthwhile to note that the definitions of and generalize in a straight forward way and that this is equivalent to using translations. Using the extended definition is more convenient for high level proofs as it hides all uses of tupling and projections in the types. However, it requires additional definitions and notations and for the sake of being self-contained we mostly avoid it.
Recall that we denote the -ary polynomial-time computable string-tupling functions by and that they have polynomial-time computable projections . The limited recursion operator is defined by
The right hand side is a type-two term from and thus . Recall that the tupling functions for string functions were defined by . Thus, the tupling functions on string functions are also available as a type-two terms. The same is true for the projections. Therefore any type-two functional can be replaced by an operator using lambda-abstraction and application and additionally tupling functions and projections.
3.2 The lambda-closures of and
This section proves that . For the first equality, the strategy is very simple: We prove . For the second equality additional work has to be done.
The limited recursion operator is moderately polynomial-time computable.
A high-level description of an oracle machine computing can be given as follows: On inputs and fix the following notations: , and . The machine operates as follows: first it queries at . The return value is not used, but this query guarantees that has exactly one lookahead revision. Then, for set , and return . Since for , the initial query made by is the largest. Thus has a quadratic step-count and lookahead revision 1.
This theorem does not rely on the reformulation of the recursion functional. It can be checked that it is also true if Cook and Urquart’s formulation is used. However, the description of the machine becomes more involved.
The first main result of this section follows easily.
The functionals represented by lambda terms with symbols for moderate polynomial-time computable operators are exactly the basic feasible functionals.
Since , to prove that it suffices to specify lambda-terms in moderately polynomial-time computable operators that can be used to replace the symbols for any polynomial-time computable function and the symbol for the limited recursion functional.
Note that for any polynomial-time computable function in one argument, the constant operator defined by is moderately polynomial-time computable. Thus the lambda-term that evaluates to the function may be used as replacement for a symbol for the polynomial-time computable function . For multiple arguments note that the operator defined by is moderately polynomial-time computable. For a -ary polynomial-time computable function also the function is polynomial-time computable and a symbol for may be replaced by the term
This generalizes to functions of arbitrary arity: For a -ary use .
Due to the moderate polynomial-time computability of the limited recursion operator and the availability of tupling functions from the first part of the proof, the lambda-term
may be used to replace the symbol .
Unfortunately the same tactic is bound to fail for the strongly polynomial-time computable operators: an argument similar to that given for the maximization operator in Example 2.1 shows that the limited recursion operator is not in . This forces us to attempt to split the functional into simpler parts. Due to the concrete form of our limited recursion functional, this can fairly easily be done. It should be noted though, that this is a very special case of a more general theorem proved in the next section and that understanding the decomposition in the next lemma is not crucial for the understanding of the paper.
There exists a lambda-term with two constants from that evaluates to the limited recursion functional .
For convenience we use oracle machines with multiple oracles and the corresponding generalisation of . Functionals such that for all ,
can obtained by considering oracle machines and that work as follows: computes the function in a straightforward way. The following is a high-level description of an oracle machine computing : on inputs , letting , for , it sets , and if set , otherwise halt and return . If all steps complete, it returns . Thus computes has a quadratic step-count and length revision 1. Moreover, and satisfy equation 1.
The following theorem can now be proven completely analogous to the same statement for .
The functionals represented by lambda terms with symbols for strongly polynomial-time computable operators are exactly the basic feasible functionals.
The only adjustment that has to be made is to change the lambda term replacing to the term over that exists according to Lemma 3.2.
The closure of and under lambda-abstraction and application are exactly the polynomial-time computable functionals.
3.3 Some results about composition
The decomposition of the limited recursion functional into a lambda-term over two strongly polynomial-time computable functionals from Lemma 3.2 is a special case of a general phenomenon. It is instructive to revisit the maximization functional from Example 2.1 with this in mind.
Example (Revisiting Example 2.1)
For the statement of the corresponding result we switch back to the operator setting and provide a decomposition of any moderately polynomial-time computable operator into a composition of two strongly polynomial-time computable operators. Note that composition of operators may be expressed as a lambda term: . Furthermore, the translations between functionals and operators were shown to be possible within the lambda-calculus over . Thus, the decomposition from Lemma 3.2 is a special case of the following theorem.
Any moderate polynomial-time computable operator can be written as composition of two strongy polynomial-time computable operators.