0 | ||| Properties of Ackermann functions
5 | -- Primitive recursive functions are functions that can be calculated
6 | -- by programs that don't use unbounded loops. Almost all common
7 | -- mathematical functions are primitive recursive.
9 | -- Uncomputable functions are functions that can't be calculated by
10 | -- any programs at all. One example is the Busy Beaver function:
11 | -- BB(k) = the maximum number of steps that can be executed by a
12 | -- halting Turing machine with k states.
13 | -- The values of the Busy Beaver function are unimaginably large for
14 | -- any but the smallest inputs.
16 | -- The Ackermann function is the most well-known example of a total
17 | -- computable function that is not primitive recursive, i.e. a general
18 | -- recursive function. It grows strictly faster than any primitive
19 | -- recursive function, but also strictly slower than a function like
20 | -- the Busy Beaver.
22 | -- There are many variations of the Ackermann function. Here is one
23 | -- common definition
24 | -- (see https://sites.google.com/site/pointlesslargenumberstuff/home/2/ackermann)
25 | -- that uses nested recursion:
28 | -- Base rule
30 | -- Prime rule
32 | -- Catastrophic rule
35 | -- The so-called "base rule" and "prime rule" work together to ensure
36 | -- termination. Happily, the Idris totality checker has no issues.
38 | -- An unusual "repeating" defintion of the function is given in the
39 | -- book The Little Typer:
44 | where
49 | -- These two definitions don't look like they define the same
50 | -- function, but they do: