In computability theory, the Ackermann function, named after Wilhelm Ackermann, is one of the simplest and earliest-discovered examples of a total computable function that is not primitive recursive. All primitive recursive functions are total and computable, but the Ackermann function illustrates that not all total computable functions are primitive recursive. It is essentially constructed by diagonalizing a sequence of primitive recursive functions f1,f2,… selected from the Grzegorczyk hierarchy. This makes the Ackermann function the first limit point fω of the fast-growing hierarchy. After Ackermann's publication of his function (which had three non-negative integer arguments), many authors modified it to suit various purposes, so that today "the Ackermann function" may refer to any of numerous variants of the original function. One common version is the two-argument Ackermann–Péter function developed by Rózsa Péter and Raphael Robinson. This function is defined from the recurrence relation A(m+1,n+1)=A(m,A(m+1,n)) with appropriate base cases. Its value grows very rapidly; for example, A(4,2) results in 265536−3, an integer with 19,729 decimal digits.
History In the late 1920s, the mathematicians Gabriel Sudan and Wilhelm Ackermann, students of David Hilbert, were studying the foundations of computation. Both Sudan and Ackermann are credited with discovering total computable functions (termed simply "recursive" in some references) that are not primitive recursive. Sudan published the lesser-known Sudan function, then shortly afterwards and independently, in 1928, Ackermann published his function φ (from Greek, the letter phi). Ackermann's three-argument function, φ(m,n,p), is defined such that for p=0,1,2, it reproduces the basic operations of addition, multiplication, and exponentiation as φ(m,n,0)=m+nφ(m,n,1)=m×nφ(m,n,2)=mn and for p>2 it extends these basic operations in a way that can be compared to the hyperoperations: φ(m,n,3)=m[4](n+1)φ(m,n,p)⪆m[p+1](n+1)for p>3 (Aside from its historic role as a total-computable-but-not-primitive-recursive function, Ackermann's original function is seen to extend the basic arithmetic operations beyond exponentiation, although not as seamlessly as do variants of Ackermann's function that are specifically designed for that purpose—such as Goodstein's hyperoperation sequence.) In On the Infinite, David Hilbert first hypothesized that the Ackermann function was not primitive recursive, but it was Ackermann, Hilbert's personal secretary and former student, who actually proved the hypothesis in his paper On Hilbert's Construction of the Real Numbers. Rózsa Péter and Raphael Robinson later developed a two-variable version of the Ackermann function that became preferred by almost all authors. The generalized hyperoperation sequence, e.g. G(m,a,b)=a[m]b, is a version of the Ackermann function as well. In 1963 R. Creighton Buck based an intuitive two-variable variant F on the hyperoperation sequence: F(m,n)=2[m]n. Compared to most other versions, Buck's function has no unessential offsets: F(0,n)=2[0]n=n+1F(1,n)=2[1]n=2+nF(2,n)=2[2]n=2×nF(3,n)=2[3]n=2nF(4,n)=2[4]n=222...2⋮ Many other versions of Ackermann function have been investigated.
Definition
Definition: as m-ary function Ackermann's original three-argument function φ(m,n,p) is defined recursively as follows for nonnegative integers m,n, and p: φ(m,n,0)=m+nφ(m,0,1)=0φ(m,0,2)=1φ(m,0,p)=mfor p>2φ(m,n,p)=φ(m,φ(m,n−1,p),p−1)for n,p>0 Of the various two-argument versions, the one developed by Péter and Robinson (called "the" Ackermann function by most authors) is defined for nonnegative integers m and n as follows: A(0,n)=n+1A(m+1,0)=A(m,1)A(m+1,n+1)=A(m,A(m+1,n)) The Ackermann function has also been expressed in relation to the hyperoperation sequence: A(m,n)={n+1m=02[m](n+3)−3m>0 or, written in Knuth's up-arrow notation (extended to integer indices ≥−2): A(m,n)={n+1m=02↑m−2(n+3)−3m>0 or, equivalently, in terms of Buck's function F: A(m,n)={n+1m=0F(m,n+3)−3m>0 By induction on m, one can show that F(m,n)≤A(m,n) for all m,n∈ℕ0.
Definition: as iterated 1-ary function Define fn as the n-th iterate of f: f0(x)=xfn+1(x)=f(fn(x)) Iteration is the process of composing a function with itself a certain number of times. Function composition is an associative operation, so f(fn(x))=fn(f(x)). Conceiving the Ackermann function as a sequence of unary functions, one can set Am(n)=A(m,n). The function then becomes a sequence A0,A1,A2,... of unary functions, defined from iteration: A0(n)=n+1Am+1(n)=Amn+1(1).
Computation
Computation by LOOP program The functions Ai fit into the (finite-level) fast-growing hierarchy (FGH) of functions
FGH0(n)=n+1FGHm+1(n)=FGHmn(n). The following inequality holds: ∀m>1,∀n>1:Am(n)<FGHm(n) For fixed k, the function FGHk(n) can be computed by a LOOP program of nesting depth k:
The function Ak(n) can also be computed by a LOOP-k program. (The program (schema) is not listed here.) It is obvious that A(m,n), not being a primitive recursive function —see below—, cannot be computed by a LOOP program.
Computation by term rewriting system, based on 2-ary function The recursive definition of the Ackermann function can naturally be transposed to a term rewriting system (TRS). The definition of the 2-ary Ackermann function leads to the obvious reduction rules (r1)A(0,n)→S(n)(r2)A(S(m),0)→A(m,S(0))(r3)A(S(m),S(n))→A(m,A(S(m),n)) Example Compute A(1,2)→∗4 The reduction sequence is
To compute A(m,n) one can use a stack, which initially contains the elements ⟨m,n⟩. Then repeatedly the two top elements are replaced according to the rules (r1)0,n→(n+1)(r2)(m+1),0→m,1(r3)(m+1),(n+1)→m,(m+1),n Schematically, starting from ⟨m,n⟩:
WHILE stackLength <> 1 { POP 2 elements; PUSH 1 or 2 or 3 elements, applying the rules r1, r2, r3 }
The pseudocode is published in Grossman & Zeitman (1988). For example, on input ⟨2,1⟩,
Remarks
The leftmost-innermost strategy is implemented in 225 computer languages on Rosetta Code. For all m,n the computation of A(m,n) takes no more than (A(m,n)+1)m steps. Grossman & Zeitman (1988) pointed out that in the computation of A(m,n) the maximum length of the stack is A(m,n), as long as m>0. Their own algorithm, inherently iterative, computes A(m,n) within 𝒪(mA(m,n)) time and within 𝒪(m) space.
… excerpt ends here. Continue reading the full article.