Computable function
Computable functions are the basic objects of study in computability theory. Computable functions are the formalized analogue of the intuitive notion of algorithms, in the sense that a function is computable if there exists an algorithm that can do the job of the function, i.e. given an input of the function domain it can return the corresponding output. Computable functions are used to discuss computability without referring to any concrete model of computation such as Turing machines or register machines. Any definition, however, must make reference to some specific model of computation but all valid definitions yield the same class of functions.
Particular models of computability that give rise to the set of computable functions are the Turing-computable functions and the μ-recursive functions.
Before the precise definition of computable function, mathematicians often used the informal term effectively calculable. This term has since come to be identified with the computable functions. Note that the effective computability of these functions does not imply that they can be efficiently computed. In fact, for some effectively calculable functions it can be shown that any algorithm that computes them will be very inefficient in the sense that the running time of the algorithm increases exponentially with the length of the input. The fields of feasible computability and computational complexity study functions that can be computed efficiently.
According to the Church–Turing thesis, computable functions are exactly the functions that can be calculated using a mechanical calculation device given unlimited amounts of time and storage space. Equivalently, this thesis states that a function is computable if and only if it has an algorithm. Note that an algorithm in this sense is understood to be a sequence of steps a person with unlimited time and an unlimited supply of pen and paper could follow.
The Blum axioms can be used to define an abstract computational complexity theory on the set of computable functions. In computational complexity theory, the problem of determining the complexity of a computable function is known as a function problem.
Definition
Computability of a function is an informal notion. One way to describe it is to say that a function is computable if its value can be obtained by an effective procedure. With more rigor, a functionis computable if and only if there is an effective procedure that, given any -tuple of natural numbers, will produce the value. In agreement with this definition, the remainder of this article presumes that computable functions take finitely many natural numbers as arguments and produce a value which is a single natural number.
As counterparts to this informal description, there exist multiple formal, mathematical definitions. The class of computable functions can be defined in many equivalent models of computation, including
- Turing machines
- μ-recursive functions
- Lambda calculus
- Post machines.
- Register machines
For example, one can formalize computable functions as μ-recursive functions, which are partial functions that take finite tuples of natural numbers and return a single natural number. They are the smallest class of partial functions that includes the constant, successor, and projection functions, and is closed under composition, primitive recursion, and the μ operator.
Equivalently, computable functions can be formalized as functions which can be calculated by an idealized computing agent such as a Turing machine or a register machine. Formally speaking, a partial function can be calculated if and only if there exists a computer program with the following properties:
- If is defined, then the program will terminate on the input with the value stored in the computer memory.
- If is undefined, then the program never terminates on the input.
Characteristics of computable functions
Enderton gives the following characteristics of a procedure for computing a computable function; similar characterizations have been given by Turing , Rogers , and others.
- "There must be exact instructions, finite in length, for the procedure." Thus every computable function must have a finite program that completely describes how the function is to be computed. It is possible to compute the function by just following the instructions; no guessing or special insight is required.
- "If the procedure is given a k-tuple x in the domain of f, then after a finite number of discrete steps the procedure must terminate and produce f." Intuitively, the procedure proceeds step by step, with a specific rule to cover what to do at each step of the calculation. Only finitely many steps can be carried out before the value of the function is returned.
- "If the procedure is given a k-tuple x which is not in the domain of f, then the procedure might go on forever, never halting. Or it might get stuck at some point, but it must not pretend to produce a value for f at x." Thus if a value for f is ever found, it must be the correct value. It is not necessary for the computing agent to distinguish correct outcomes from incorrect ones because the procedure is defined as correct if and only if it produces an outcome.
- The procedure must theoretically work for arbitrarily large arguments. It is not assumed that the arguments are smaller than the number of atoms in the Earth, for example.
- The procedure is required to halt after finitely many steps in order to produce an output, but it may take arbitrarily many steps before halting. No time limitation is assumed.
- Although the procedure may use only a finite amount of storage space during a successful computation, there is no bound on the amount of space that is used. It is assumed that additional storage space can be given to the procedure whenever the procedure asks for it.
The field of computational complexity studies functions with prescribed bounds on the time and/or space allowed in a successful computation.
Computable sets and relations
A set of natural numbers is called computable if there is a computable, total function such that for any natural number, if is in and if is not in.A set of natural numbers is called computably enumerable if there is a computable function such that for each number, is defined if and only if is in the set. Thus a set is computably enumerable if and only if it is the domain of some computable function. The word enumerable is used because the following are equivalent for a nonempty subset of the natural numbers:
- is the domain of a computable function.
- is the range of a total computable function. If is infinite then the function can be assumed to be injective.
enumeration of, because the list will include every element of.
Because each finitary relation on the natural numbers can be identified with a corresponding set of finite sequences of natural numbers, the notions of computable relation and computably enumerable relation can be defined from their analogues for sets.
Formal languages
In computability theory in computer science, it is common to consider formal languages. An alphabet is an arbitrary set. A word on an alphabet is a finite sequence of symbols from the alphabet; the same symbol may be used more than once. For example, binary strings are exactly the words on the alphabet. A language is a subset of the collection of all words on a fixed alphabet. For example, the collection of all binary strings that contain exactly 3 ones is a language over the binary alphabet.
A key property of a formal language is the level of difficulty required to decide whether a given word is in the language. Some coding system must be developed to allow a computable function to take an arbitrary word in the language as input; this is usually considered routine. A language is called computable if there is a computable function such that for each word over the alphabet, if the word is in the language and if the word is not in the language. Thus a language is computable just in case there is a procedure that is able to correctly tell whether arbitrary words are in the language.
A language is computably enumerable if there is a computable function such that is defined if and only if the word is in the language. The term enumerable'' has the same etymology as in computably enumerable sets of natural numbers.
Examples
The following functions are computable:- Each function with a finite domain; e.g., any finite sequence of natural numbers.
- Each constant function f : Nk → N, f := n.
- Addition f : N2 → N, f := n1 + n2
- The function which gives the list of prime factors of a number.
- The greatest common divisor of two numbers is a computable function.
- Bézout's identity, a linear Diophantine equation
f is unary, max, min, arg max and many more combinations.
The following examples illustrate that a function may be computable though it is not known which algorithm computes it.
- The function f such that f = 1 if there is a sequence of at least n consecutive fives in the decimal expansion of π, and f = 0 otherwise, is computable. = 1 if n < k and f
- Each finite segment of an uncomputable sequence of natural numbers is computable. E.g., for each natural number n, there exists an algorithm that computes the finite sequence Σ, Σ, Σ,..., Σ — in contrast to the fact that there is no algorithm that computes the entire Σ-sequence, i.e. Σ for all n. Thus, "Print 0, 1, 4, 6, 13" is a trivial algorithm to compute Σ, Σ, Σ, Σ, Σ; similarly, for any given value of n, such a trivial algorithm exists to compute Σ, Σ, Σ,..., Σ.
Church–Turing thesis
- Many equivalent models of computation are known, and they all give the same definition of computable function.
- No stronger model of computation which is generally considered to be effectively calculable has been proposed.
Provability
Given a function, one may be interested not only if it is computable, but also whether this can be proven in a particular proof system. A function that can be proven to be computable is called provably total.The set of provably total functions is recursively enumerable: one can enumerate all the provably total functions by enumerating all their corresponding proofs, that prove their computability. This can be done by enumerating all the proofs of the proof system and ignoring irrelevant ones.
Relation to recursively defined functions
In a function defined by a recursive definition, each value is defined by a fixed first-order formula of other, previously defined values of the same function or other functions, which might be simply constants. A subset of these is the primitive recursive functions. Every such function is provably total: For such a k-ary function f, each value can be computed by following the definition backwards, iteratively, and after finite number of iteration, a constant is reached.The converse is not true, as not every provably total function is primitive recursive. Indeed, one can enumerate all the primitive recursive functions and define a function en such that for all n, m: en = fn, where fn is the n-th primitive recursive function. Now, g = en+1 is provably total but not primitive recursive, by a diagonalization argument: had there been a j such that g = fj, we would have got g = en+1 = fj +1= g+1, a contradiction.
One such function, which is provable total but not primitive recursive, is Ackermann function: since it is recursively defined, it is indeed easy to prove its computability.
Total functions that are not provably total
In a sound proof system, every provably total function is indeed total, but the converse is not true: in every first-order proof system that is strong enough and sound, one can prove the existence of total functions that cannot be proven total in the proof system.If the total computable functions are enumerated via the Turing machines that produces them, then the above statement can be shown, if the proof system is sound, by a similar diagonalization argument to that used above, using the enumeration of provably total functions given earlier. One uses a Turing machine that enumerates the relevant proofs, and for every input n calls fn by invoking the Turing machine that computes it according to the n-th proof. Such a Turing machine is guaranteed to halt if the proof system is sound.
Uncomputable functions and unsolvable problems
Every computable function has a finite procedure giving explicit, unambiguous instructions on how to compute it. Furthermore, this procedure has to be encoded in the finite alphabet used by the computational model, so there are only countably many computable functions. For example, functions may be encoded using a string of bits.The real numbers are uncountable so most real numbers are not computable. See computable number. The set of finitary functions on the natural numbers is uncountable so most are not computable. Concrete examples of such functions are Busy beaver, Kolmogorov complexity, or any function that outputs the digits of a noncomputable number, such as Chaitin's constant.
Similarly, most subsets of the natural numbers are not computable. The halting problem was the first such set to be constructed. The Entscheidungsproblem, proposed by David Hilbert, asked whether there is an effective procedure to determine which mathematical statements are true. Turing and Church independently showed in the 1930s that this set of natural numbers is not computable. According to the Church–Turing thesis, there is no effective procedure which can perform these computations.