- Source: Primitive recursive function
In computability theory, a primitive recursive function is, roughly speaking, a function that can be computed by a computer program whose loops are all "for" loops (that is, an upper bound of the number of iterations of every loop is fixed before entering the loop). Primitive recursive functions form a strict subset of those general recursive functions that are also total functions.
The importance of primitive recursive functions lies in the fact that most computable functions that are studied in number theory (and more generally in mathematics) are primitive recursive. For example, addition and division, the factorial and exponential function, and the function which returns the nth prime are all primitive recursive. In fact, for showing that a computable function is primitive recursive, it suffices to show that its time complexity is bounded above by a primitive recursive function of the input size. It is hence not particularly easy to devise a computable function that is not primitive recursive; some examples are shown in section § Limitations below.
The set of primitive recursive functions is known as PR in computational complexity theory.
Definition
A primitive recursive function takes a fixed number of arguments, each a natural number (nonnegative integer: {0, 1, 2, ...}), and returns a natural number. If it takes n arguments it is called n-ary.
The basic primitive recursive functions are given by these axioms:
More complex primitive recursive functions can be obtained by applying the operations given by these axioms:
The primitive recursive functions are the basic functions and those obtained from the basic functions by applying these operations a finite number of times.
Examples
= Addition
=A definition of the 2-ary function
A
d
d
{\displaystyle Add}
, to compute the sum of its arguments, can be obtained using the primitive recursion operator
ρ
{\displaystyle \rho }
. To this end, the well-known equations
0
+
y
=
y
and
S
(
x
)
+
y
=
S
(
x
+
y
)
.
{\displaystyle {\begin{array}{rcll}0+y&=&y&{\text{ and}}\\S(x)+y&=&S(x+y)&.\\\end{array}}}
are "rephrased in primitive recursive function terminology": In the definition of
ρ
(
g
,
h
)
{\displaystyle \rho (g,h)}
, the first equation suggests to choose
g
=
P
1
1
{\displaystyle g=P_{1}^{1}}
to obtain
A
d
d
(
0
,
y
)
=
g
(
y
)
=
y
{\displaystyle Add(0,y)=g(y)=y}
; the second equation suggests to choose
h
=
S
∘
P
2
3
{\displaystyle h=S\circ P_{2}^{3}}
to obtain
A
d
d
(
S
(
x
)
,
y
)
=
h
(
x
,
A
d
d
(
x
,
y
)
,
y
)
=
(
S
∘
P
2
3
)
(
x
,
A
d
d
(
x
,
y
)
,
y
)
=
S
(
A
d
d
(
x
,
y
)
)
{\displaystyle Add(S(x),y)=h(x,Add(x,y),y)=(S\circ P_{2}^{3})(x,Add(x,y),y)=S(Add(x,y))}
. Therefore, the addition function can be defined as
A
d
d
=
ρ
(
P
1
1
,
S
∘
P
2
3
)
{\displaystyle Add=\rho (P_{1}^{1},S\circ P_{2}^{3})}
. As a computation example,
A
d
d
(
1
,
7
)
=
ρ
(
P
1
1
,
S
∘
P
2
3
)
(
S
(
0
)
,
7
)
by Def.
A
d
d
,
S
=
(
S
∘
P
2
3
)
(
0
,
A
d
d
(
0
,
7
)
,
7
)
by case
ρ
(
g
,
h
)
(
S
(
.
.
.
)
,
.
.
.
)
=
S
(
A
d
d
(
0
,
7
)
)
by Def.
∘
,
P
2
3
=
S
(
ρ
(
P
1
1
,
S
∘
P
2
3
)
(
0
,
7
)
)
by Def.
A
d
d
=
S
(
P
1
1
(
7
)
)
by case
ρ
(
g
,
h
)
(
0
,
.
.
.
)
=
S
(
7
)
by Def.
P
1
1
=
8
by Def.
S
.
{\displaystyle {\begin{array}{lll}&Add(1,7)\\=&\rho (P_{1}^{1},S\circ P_{2}^{3})\;(S(0),7)&{\text{ by Def. }}Add,S\\=&(S\circ P_{2}^{3})(0,Add(0,7),7)&{\text{ by case }}\rho (g,h)\;(S(...),...)\\=&S(Add(0,7))&{\text{ by Def. }}\circ ,P_{2}^{3}\\=&S(\;\rho (P_{1}^{1},S\circ P_{2}^{3})\;(0,7)\;)&{\text{ by Def. }}Add\\=&S(P_{1}^{1}(7))&{\text{ by case }}\rho (g,h)\;(0,...)\\=&S(7)&{\text{ by Def. }}P_{1}^{1}\\=&8&{\text{ by Def. }}S.\\\end{array}}}
= Doubling
=Given
A
d
d
{\displaystyle Add}
, the 1-ary function
A
d
d
∘
(
P
1
1
,
P
1
1
)
{\displaystyle Add\circ (P_{1}^{1},P_{1}^{1})}
doubles its argument,
(
A
d
d
∘
(
P
1
1
,
P
1
1
)
)
(
x
)
=
A
d
d
(
x
,
x
)
=
x
+
x
{\displaystyle (Add\circ (P_{1}^{1},P_{1}^{1}))(x)=Add(x,x)=x+x}
.
= Multiplication
=In a similar way as addition, multiplication can be defined by
M
u
l
=
ρ
(
C
0
1
,
A
d
d
∘
(
P
2
3
,
P
3
3
)
)
{\displaystyle Mul=\rho (C_{0}^{1},Add\circ (P_{2}^{3},P_{3}^{3}))}
. This reproduces the well-known multiplication equations:
M
u
l
(
0
,
y
)
=
ρ
(
C
0
1
,
A
d
d
∘
(
P
2
3
,
P
3
3
)
)
(
0
,
y
)
by Def.
M
u
l
=
C
0
1
(
y
)
by case
ρ
(
g
,
h
)
(
0
,
.
.
.
)
=
0
by Def.
C
0
1
.
{\displaystyle {\begin{array}{lll}&Mul(0,y)\\=&\rho (C_{0}^{1},Add\circ (P_{2}^{3},P_{3}^{3}))\;(0,y)&{\text{ by Def. }}Mul\\=&C_{0}^{1}(y)&{\text{ by case }}\rho (g,h)\;(0,...)\\=&0&{\text{ by Def. }}C_{0}^{1}.\\\end{array}}}
and
M
u
l
(
S
(
x
)
,
y
)
=
ρ
(
C
0
1
,
A
d
d
∘
(
P
2
3
,
P
3
3
)
)
(
S
(
x
)
,
y
)
by Def.
M
u
l
=
(
A
d
d
∘
(
P
2
3
,
P
3
3
)
)
(
x
,
M
u
l
(
x
,
y
)
,
y
)
by case
ρ
(
g
,
h
)
(
S
(
.
.
.
)
,
.
.
.
)
=
A
d
d
(
M
u
l
(
x
,
y
)
,
y
)
by Def.
∘
,
P
2
3
,
P
3
3
=
M
u
l
(
x
,
y
)
+
y
by property of
A
d
d
.
{\displaystyle {\begin{array}{lll}&Mul(S(x),y)\\=&\rho (C_{0}^{1},Add\circ (P_{2}^{3},P_{3}^{3}))\;(S(x),y)&{\text{ by Def. }}Mul\\=&(Add\circ (P_{2}^{3},P_{3}^{3}))\;(x,Mul(x,y),y)&{\text{ by case }}\rho (g,h)\;(S(...),...)\\=&Add(Mul(x,y),y)&{\text{ by Def. }}\circ ,P_{2}^{3},P_{3}^{3}\\=&Mul(x,y)+y&{\text{ by property of }}Add.\\\end{array}}}
= Predecessor
=The predecessor function acts as the "opposite" of the successor function and is recursively defined by the rules
P
r
e
d
(
0
)
=
0
{\displaystyle Pred(0)=0}
and
P
r
e
d
(
S
(
n
)
)
=
n
{\displaystyle Pred(S(n))=n}
. A primitive recursive definition is
P
r
e
d
=
ρ
(
C
0
0
,
P
1
2
)
{\displaystyle Pred=\rho (C_{0}^{0},P_{1}^{2})}
. As a computation example,
P
r
e
d
(
8
)
=
ρ
(
C
0
0
,
P
1
2
)
(
S
(
7
)
)
by Def.
P
r
e
d
,
S
=
P
1
2
(
7
,
P
r
e
d
(
7
)
)
by case
ρ
(
g
,
h
)
(
S
(
.
.
.
)
,
.
.
.
)
=
7
by Def.
P
1
2
.
{\displaystyle {\begin{array}{lll}&Pred(8)\\=&\rho (C_{0}^{0},P_{1}^{2})\;(S(7))&{\text{ by Def. }}Pred,S\\=&P_{1}^{2}(7,Pred(7))&{\text{ by case }}\rho (g,h)\;(S(...),...)\\=&7&{\text{ by Def. }}P_{1}^{2}.\\\end{array}}}
= Truncated subtraction
=The limited subtraction function (also called "monus", and denoted "
−
.
{\displaystyle {\stackrel {.}{-}}}
") is definable from the predecessor function. It satisfies the equations
y
−
.
0
=
y
and
y
−
.
S
(
x
)
=
P
r
e
d
(
y
−
.
x
)
.
{\displaystyle {\begin{array}{rcll}y{\stackrel {.}{-}}0&=&y&{\text{and}}\\y{\stackrel {.}{-}}S(x)&=&Pred(y{\stackrel {.}{-}}x)&.\\\end{array}}}
Since the recursion runs over the second argument, we begin with a primitive recursive definition of the reversed subtraction,
R
S
u
b
(
y
,
x
)
=
x
−
.
y
{\displaystyle RSub(y,x)=x{\stackrel {.}{-}}y}
. Its recursion then runs over the first argument, so its primitive recursive definition can be obtained, similar to addition, as
R
S
u
b
=
ρ
(
P
1
1
,
P
r
e
d
∘
P
2
3
)
{\displaystyle RSub=\rho (P_{1}^{1},Pred\circ P_{2}^{3})}
. To get rid of the reversed argument order, then define
S
u
b
=
R
S
u
b
∘
(
P
2
2
,
P
1
2
)
{\displaystyle Sub=RSub\circ (P_{2}^{2},P_{1}^{2})}
. As a computation example,
S
u
b
(
8
,
1
)
=
(
R
S
u
b
∘
(
P
2
2
,
P
1
2
)
)
(
8
,
1
)
by Def.
S
u
b
=
R
S
u
b
(
1
,
8
)
by Def.
∘
,
P
2
2
,
P
1
2
=
ρ
(
P
1
1
,
P
r
e
d
∘
P
2
3
)
(
S
(
0
)
,
8
)
by Def.
R
S
u
b
,
S
=
(
P
r
e
d
∘
P
2
3
)
(
0
,
R
S
u
b
(
0
,
8
)
,
8
)
by case
ρ
(
g
,
h
)
(
S
(
.
.
.
)
,
.
.
.
)
=
P
r
e
d
(
R
S
u
b
(
0
,
8
)
)
by Def.
∘
,
P
2
3
=
P
r
e
d
(
ρ
(
P
1
1
,
P
r
e
d
∘
P
2
3
)
(
0
,
8
)
)
by Def.
R
S
u
b
=
P
r
e
d
(
P
1
1
(
8
)
)
by case
ρ
(
g
,
h
)
(
0
,
.
.
.
)
=
P
r
e
d
(
8
)
by Def.
P
1
1
=
7
by property of
P
r
e
d
.
{\displaystyle {\begin{array}{lll}&Sub(8,1)\\=&(RSub\circ (P_{2}^{2},P_{1}^{2}))\;(8,1)&{\text{ by Def. }}Sub\\=&RSub(1,8)&{\text{ by Def. }}\circ ,P_{2}^{2},P_{1}^{2}\\=&\rho (P_{1}^{1},Pred\circ P_{2}^{3})\;(S(0),8)&{\text{ by Def. }}RSub,S\\=&(Pred\circ P_{2}^{3})\;(0,RSub(0,8),8)&{\text{ by case }}\rho (g,h)\;(S(...),...)\\=&Pred(RSub(0,8))&{\text{ by Def. }}\circ ,P_{2}^{3}\\=&Pred(\;\rho (P_{1}^{1},Pred\circ P_{2}^{3})\;(0,8)\;)&{\text{ by Def. }}RSub\\=&Pred(P_{1}^{1}(8))&{\text{ by case }}\rho (g,h)\;(0,...)\\=&Pred(8)&{\text{ by Def. }}P_{1}^{1}\\=&7&{\text{ by property of }}Pred.\\\end{array}}}
= Converting predicates to numeric functions
=In some settings it is natural to consider primitive recursive functions that take as inputs tuples that mix numbers with truth values (that is
t
{\displaystyle t}
for true and
f
{\displaystyle f}
for false), or that produce truth values as outputs. This can be accomplished by identifying the truth values with numbers in any fixed manner. For example, it is common to identify the truth value
t
{\displaystyle t}
with the number
1
{\displaystyle 1}
and the truth value
f
{\displaystyle f}
with the number
0
{\displaystyle 0}
. Once this identification has been made, the characteristic function of a set
A
{\displaystyle A}
, which always returns
1
{\displaystyle 1}
or
0
{\displaystyle 0}
, can be viewed as a predicate that tells whether a number is in the set
A
{\displaystyle A}
. Such an identification of predicates with numeric functions will be assumed for the remainder of this article.
= Predicate "Is zero"
=As an example for a primitive recursive predicate, the 1-ary function
I
s
Z
e
r
o
{\displaystyle IsZero}
shall be defined such that
I
s
Z
e
r
o
(
x
)
=
1
{\displaystyle IsZero(x)=1}
if
x
=
0
{\displaystyle x=0}
, and
I
s
Z
e
r
o
(
x
)
=
0
{\displaystyle IsZero(x)=0}
, otherwise. This can be achieved by defining
I
s
Z
e
r
o
=
ρ
(
C
1
0
,
C
0
2
)
{\displaystyle IsZero=\rho (C_{1}^{0},C_{0}^{2})}
. Then,
I
s
Z
e
r
o
(
0
)
=
ρ
(
C
1
0
,
C
0
2
)
(
0
)
=
C
1
0
(
0
)
=
1
{\displaystyle IsZero(0)=\rho (C_{1}^{0},C_{0}^{2})(0)=C_{1}^{0}(0)=1}
and e.g.
I
s
Z
e
r
o
(
8
)
=
ρ
(
C
1
0
,
C
0
2
)
(
S
(
7
)
)
=
C
0
2
(
7
,
I
s
Z
e
r
o
(
7
)
)
=
0
{\displaystyle IsZero(8)=\rho (C_{1}^{0},C_{0}^{2})(S(7))=C_{0}^{2}(7,IsZero(7))=0}
.
= Predicate "Less or equal"
=Using the property
x
≤
y
⟺
x
−
.
y
=
0
{\displaystyle x\leq y\iff x{\stackrel {.}{-}}y=0}
, the 2-ary function
L
e
q
{\displaystyle Leq}
can be defined by
L
e
q
=
I
s
Z
e
r
o
∘
S
u
b
{\displaystyle Leq=IsZero\circ Sub}
. Then
L
e
q
(
x
,
y
)
=
1
{\displaystyle Leq(x,y)=1}
if
x
≤
y
{\displaystyle x\leq y}
, and
L
e
q
(
x
,
y
)
=
0
{\displaystyle Leq(x,y)=0}
, otherwise. As a computation example,
L
e
q
(
8
,
3
)
=
I
s
Z
e
r
o
(
S
u
b
(
8
,
3
)
)
by Def.
L
e
q
=
I
s
Z
e
r
o
(
5
)
by property of
S
u
b
=
0
by property of
I
s
Z
e
r
o
{\displaystyle {\begin{array}{lll}&Leq(8,3)\\=&IsZero(Sub(8,3))&{\text{ by Def. }}Leq\\=&IsZero(5)&{\text{ by property of }}Sub\\=&0&{\text{ by property of }}IsZero\\\end{array}}}
= Predicate "Greater or equal"
=Once a definition of
L
e
q
{\displaystyle Leq}
is obtained, the converse predicate can be defined as
G
e
q
=
L
e
q
∘
(
P
2
2
,
P
1
2
)
{\displaystyle Geq=Leq\circ (P_{2}^{2},P_{1}^{2})}
. Then,
G
e
q
(
x
,
y
)
=
L
e
q
(
y
,
x
)
{\displaystyle Geq(x,y)=Leq(y,x)}
is true (more precisely: has value 1) if, and only if,
x
≥
y
{\displaystyle x\geq y}
.
= If-then-else
=The 3-ary if-then-else operator known from programming languages can be defined by
If
=
ρ
(
P
2
2
,
P
3
4
)
{\displaystyle {\textit {If}}=\rho (P_{2}^{2},P_{3}^{4})}
. Then, for arbitrary
x
{\displaystyle x}
,
If
(
S
(
x
)
,
y
,
z
)
=
ρ
(
P
2
2
,
P
3
4
)
(
S
(
x
)
,
y
,
z
)
by Def.
If
=
P
3
4
(
x
,
If
(
x
,
y
,
z
)
,
y
,
z
)
by case
ρ
(
S
(
.
.
.
)
,
.
.
.
)
=
y
by Def.
P
3
4
{\displaystyle {\begin{array}{lll}&{\textit {If}}(S(x),y,z)\\=&\rho (P_{2}^{2},P_{3}^{4})\;(S(x),y,z)&{\text{ by Def. }}{\textit {If}}\\=&P_{3}^{4}(x,{\textit {If}}(x,y,z),y,z)&{\text{ by case }}\rho (S(...),...)\\=&y&{\text{ by Def. }}P_{3}^{4}\\\end{array}}}
and
If
(
0
,
y
,
z
)
=
ρ
(
P
2
2
,
P
3
4
)
(
0
,
y
,
z
)
by Def.
If
=
P
2
2
(
y
,
z
)
by case
ρ
(
0
,
.
.
.
)
=
z
by Def.
P
2
2
.
{\displaystyle {\begin{array}{lll}&{\textit {If}}(0,y,z)\\=&\rho (P_{2}^{2},P_{3}^{4})\;(0,y,z)&{\text{ by Def. }}{\textit {If}}\\=&P_{2}^{2}(y,z)&{\text{ by case }}\rho (0,...)\\=&z&{\text{ by Def. }}P_{2}^{2}.\\\end{array}}}
.
That is,
If
(
x
,
y
,
z
)
{\displaystyle {\textit {If}}(x,y,z)}
returns the then-part,
y
{\displaystyle y}
, if the if-part,
x
{\displaystyle x}
, is true, and the else-part,
z
{\displaystyle z}
, otherwise.
= Junctors
=Based on the
If
{\displaystyle {\textit {If}}}
function, it is easy to define logical junctors. For example, defining
A
n
d
=
If
∘
(
P
1
2
,
P
2
2
,
C
0
2
)
{\displaystyle And={\textit {If}}\circ (P_{1}^{2},P_{2}^{2},C_{0}^{2})}
, one obtains
A
n
d
(
x
,
y
)
=
If
(
x
,
y
,
0
)
{\displaystyle And(x,y)={\textit {If}}(x,y,0)}
, that is,
A
n
d
(
x
,
y
)
{\displaystyle And(x,y)}
is true if, and only if, both
x
{\displaystyle x}
and
y
{\displaystyle y}
are true (logical conjunction of
x
{\displaystyle x}
and
y
{\displaystyle y}
).
Similarly,
O
r
=
If
∘
(
P
1
2
,
C
1
2
,
P
2
2
)
{\displaystyle Or={\textit {If}}\circ (P_{1}^{2},C_{1}^{2},P_{2}^{2})}
and
N
o
t
=
If
∘
(
P
1
1
,
C
0
1
,
C
1
1
)
{\displaystyle Not={\textit {If}}\circ (P_{1}^{1},C_{0}^{1},C_{1}^{1})}
lead to appropriate definitions of disjunction and negation:
O
r
(
x
,
y
)
=
If
(
x
,
1
,
y
)
{\displaystyle Or(x,y)={\textit {If}}(x,1,y)}
and
N
o
t
(
x
)
=
If
(
x
,
0
,
1
)
{\displaystyle Not(x)={\textit {If}}(x,0,1)}
.
= Equality predicate
=Using the above functions
L
e
q
{\displaystyle Leq}
,
G
e
q
{\displaystyle Geq}
and
A
n
d
{\displaystyle And}
, the definition
E
q
=
A
n
d
∘
(
L
e
q
,
G
e
q
)
{\displaystyle Eq=And\circ (Leq,Geq)}
implements the equality predicate. In fact,
E
q
(
x
,
y
)
=
A
n
d
(
L
e
q
(
x
,
y
)
,
G
e
q
(
x
,
y
)
)
{\displaystyle Eq(x,y)=And(Leq(x,y),Geq(x,y))}
is true if, and only if,
x
{\displaystyle x}
equals
y
{\displaystyle y}
.
Similarly, the definition
L
t
=
N
o
t
∘
G
e
q
{\displaystyle Lt=Not\circ Geq}
implements the predicate "less-than", and
G
t
=
N
o
t
∘
L
e
q
{\displaystyle Gt=Not\circ Leq}
implements "greater-than".
= Other operations on natural numbers
=Exponentiation and primality testing are primitive recursive. Given primitive recursive functions
e
{\displaystyle e}
,
f
{\displaystyle f}
,
g
{\displaystyle g}
, and
h
{\displaystyle h}
, a function that returns the value of
g
{\displaystyle g}
when
e
≤
f
{\displaystyle e\leq f}
and the value of
h
{\displaystyle h}
otherwise is primitive recursive.
= Operations on integers and rational numbers
=By using Gödel numberings, the primitive recursive functions can be extended to operate on other objects such as integers and rational numbers. If integers are encoded by Gödel numbers in a standard way, the arithmetic operations including addition, subtraction, and multiplication are all primitive recursive. Similarly, if the rationals are represented by Gödel numbers then the field operations are all primitive recursive.
= Some common primitive recursive functions
=The following examples and definitions are from Kleene (1952) pp. 223–231. Many appear with proofs. Most also appear with similar names, either as proofs or as examples, in Boolos-Burgess-Jeffrey 2002 pp. 63–70; they add the logarithm lo(x, y) or lg(x, y) depending on the exact derivation.
In the following the mark " ' ", e.g. a', is the primitive mark meaning "the successor of", usually thought of as " +1", e.g. a +1 =def a'. The functions 16–20 and #G are of particular interest with respect to converting primitive recursive predicates to, and extracting them from, their "arithmetical" form expressed as Gödel numbers.
Addition: a+b
Multiplication: a×b
Exponentiation: ab
Factorial a! : 0! = 1, a'! = a!×a'
pred(a): (Predecessor or decrement): If a > 0 then a−1 else 0
Proper subtraction a ∸ b: If a ≥ b then a−b else 0
Minimum(a1, ... an)
Maximum(a1, ... an)
Absolute difference: | a−b | =def (a ∸ b) + (b ∸ a)
~sg(a): NOT[signum(a)]: If a=0 then 1 else 0
sg(a): signum(a): If a=0 then 0 else 1
a | b: (a divides b): If b=k×a for some k then 0 else 1
Remainder(a, b): the leftover if b does not divide a "evenly". Also called MOD(a, b)
a = b: sg | a − b | (Kleene's convention was to represent true by 0 and false by 1; presently, especially in computers, the most common convention is the reverse, namely to represent true by 1 and false by 0, which amounts to changing sg into ~sg here and in the next item)
a < b: sg( a' ∸ b )
Pr(a): a is a prime number Pr(a) =def a>1 & NOT(Exists c)1
(a)i: exponent of pi in a: the unique x such that pix|a & NOT(pix'|a)
lh(a): the "length" or number of non-vanishing exponents in a
lo(a, b): (logarithm of a to base b): If a, b > 1 then the greatest x such that bx | a else 0
In the following, the abbreviation x =def x1, ... xn; subscripts may be applied if the meaning requires.
#A: A function φ definable explicitly from functions Ψ and constants q1, ... qn is primitive recursive in Ψ.
#B: The finite sum Σy
#C: A predicate P obtained by substituting functions χ1,..., χm for the respective variables of a predicate Q is primitive recursive in χ1,..., χm, Q.
#D: The following predicates are primitive recursive in Q and R:
NOT_Q(x) .
Q OR R: Q(x) V R(x),
Q AND R: Q(x) & R(x),
Q IMPLIES R: Q(x) → R(x)
Q is equivalent to R: Q(x) ≡ R(x)
#E: The following predicates are primitive recursive in the predicate R:
(Ey)y
φ(x) =
φ1(x) if Q1(x) is true,
. . . . . . . . . . . . . . . . . . .
φm(x) if Qm(x) is true
φm+1(x) otherwise
#G: If φ satisfies the equation:
φ(y,x) = χ(y, COURSE-φ(y; x2, ... xn ), x2, ... xn then φ is primitive recursive in χ. The value COURSE-φ(y; x2 to n ) of the course-of-values function encodes the sequence of values φ(0,x2 to n), ..., φ(y-1,x2 to n) of the original function.
Relationship to recursive functions
The broader class of partial recursive functions is defined by introducing an unbounded search operator. The use of this operator may result in a partial function, that is, a relation with at most one value for each argument, but does not necessarily have any value for any argument (see domain). An equivalent definition states that a partial recursive function is one that can be computed by a Turing machine. A total recursive function is a partial recursive function that is defined for every input.
Every primitive recursive function is total recursive, but not all total recursive functions are primitive recursive. The Ackermann function A(m,n) is a well-known example of a total recursive function (in fact, provable total), that is not primitive recursive. There is a characterization of the primitive recursive functions as a subset of the total recursive functions using the Ackermann function. This characterization states that a function is primitive recursive if and only if there is a natural number m such that the function can be computed by a Turing machine that always halts within A(m,n) or fewer steps, where n is the sum of the arguments of the primitive recursive function.
An important property of the primitive recursive functions is that they are a recursively enumerable subset of the set of all total recursive functions (which is not itself recursively enumerable). This means that there is a single computable function f(m,n) that enumerates the primitive recursive functions, namely:
For every primitive recursive function g, there is an m such that g(n) = f(m,n) for all n, and
For every m, the function h(n) = f(m,n) is primitive recursive.
f can be explicitly constructed by iteratively repeating all possible ways of creating primitive recursive functions. Thus, it is provably total. One can use a diagonalization argument to show that f is not recursive primitive in itself: had it been such, so would be h(n) = f(n,n)+1. But if this equals some primitive recursive function, there is an m such that h(n) = f(m,n) for all n, and then h(m) = f(m,m), leading to contradiction.
However, the set of primitive recursive functions is not the largest recursively enumerable subset of the set of all total recursive functions. For example, the set of provably total functions (in Peano arithmetic) is also recursively enumerable, as one can enumerate all the proofs of the theory. While all primitive recursive functions are provably total, the converse is not true.
Limitations
Primitive recursive functions tend to correspond very closely with our intuition of what a computable function must be. Certainly the initial functions are intuitively computable (in their very simplicity), and the two operations by which one can create new primitive recursive functions are also very straightforward. However, the set of primitive recursive functions does not include every possible total computable function—this can be seen with a variant of Cantor's diagonal argument. This argument provides a total computable function that is not primitive recursive. A sketch of the proof is as follows:
This argument can be applied to any class of computable (total) functions that can be enumerated in this way, as explained in the article Machine that always halts. Note however that the partial computable functions (those that need not be defined for all arguments) can be explicitly enumerated, for instance by enumerating Turing machine encodings.
Other examples of total recursive but not primitive recursive functions are known:
The function that takes m to Ackermann(m,m) is a unary total recursive function that is not primitive recursive.
The Paris–Harrington theorem involves a total recursive function that is not primitive recursive.
The Sudan function
The Goodstein function
Variants
= Constant functions
=Instead of
C
n
k
{\displaystyle C_{n}^{k}}
,
alternative definitions use just one 0-ary zero function
C
0
0
{\displaystyle C_{0}^{0}}
as a primitive function that always returns zero, and built the constant functions from the zero function, the successor function and the composition operator.
= Weak primitive recursion
=The 1-place predecessor function is primitive recursive, see section #Predecessor. Fischer, Fischer & Beigel removed the implicit predecessor from the recursion rule, replacing it by the weaker rule
f
(
0
,
x
1
,
…
,
x
k
)
=
g
(
x
1
,
…
,
x
k
)
and
f
(
S
(
y
)
,
x
1
,
…
,
x
k
)
=
h
(
S
(
y
)
,
f
(
y
,
x
1
,
…
,
x
k
)
,
x
1
,
…
,
x
k
)
{\displaystyle {\begin{array}{lcl}f(0,x_{1},\ldots ,x_{k})&=&g(x_{1},\ldots ,x_{k})&{\text{and}}\\f(S(y),x_{1},\ldots ,x_{k})&=&h(S(y),f(y,x_{1},\ldots ,x_{k}),x_{1},\ldots ,x_{k})\end{array}}}
They proved that the predecessor function still could be defined, and hence that "weak" primitive recursion also defines the primitive recursive functions.
= Iterative functions
=Weakening this even further by using functions
h
{\displaystyle h}
of arity k+1, removing
y
{\displaystyle y}
and
S
(
y
)
{\displaystyle S(y)}
from the arguments of
h
{\displaystyle h}
completely, we get the iteration rule:
f
(
0
,
x
1
,
…
,
x
k
)
=
g
(
x
1
,
…
,
x
k
)
and
f
(
S
(
y
)
,
x
1
,
…
,
x
k
)
=
h
(
f
(
y
,
x
1
,
…
,
x
k
)
,
x
1
,
…
,
x
k
)
{\displaystyle {\begin{array}{lcll}f(0,x_{1},\ldots ,x_{k})&=&g(x_{1},\ldots ,x_{k})&{\textrm {and}}\\f(S(y),x_{1},\ldots ,x_{k})&=&h(f(y,x_{1},\ldots ,x_{k}),x_{1},\ldots ,x_{k})\end{array}}}
The class of iterative functions is defined the same way as the class of primitive recursive functions except with this weaker rule. These are conjectured to be a proper subset of the primitive recursive functions.
= Additional primitive recursive forms
=Some additional forms of recursion also define functions that are in fact
primitive recursive. Definitions in these forms may be easier to find or
more natural for reading or writing. Course-of-values recursion defines primitive recursive functions. Some forms of mutual recursion also define primitive recursive functions.
The functions that can be programmed in the LOOP programming language are exactly the primitive recursive functions. This gives a different characterization of the power of these functions. The main limitation of the LOOP language, compared to a Turing-complete language, is that in the LOOP language the number of times that each loop will run is specified before the loop begins to run.
= Computer language definition
=An example of a primitive recursive programming language is one that contains basic arithmetic operators (e.g. + and −, or ADD and SUBTRACT), conditionals and comparison (IF-THEN, EQUALS, LESS-THAN), and bounded loops, such as the basic for loop, where there is a known or calculable upper bound to all loops (FOR i FROM 1 TO n, with neither i nor n modifiable by the loop body). No control structures of greater generality, such as while loops or IF-THEN plus GOTO, are admitted in a primitive recursive language.
The LOOP language, introduced in a 1967 paper by Albert R. Meyer and Dennis M. Ritchie, is such a language. Its computing power coincides with the primitive recursive functions. A variant of the LOOP language is Douglas Hofstadter's BlooP in Gödel, Escher, Bach. Adding unbounded loops (WHILE, GOTO) makes the language general recursive and Turing-complete, as are all real-world computer programming languages.
The definition of primitive recursive functions implies that their computation halts on every input (after a finite number of steps). On the other hand, the halting problem is undecidable for general recursive functions.
Finitism and consistency results
The primitive recursive functions are closely related to mathematical finitism, and are used in several contexts in mathematical logic where a particularly constructive system is desired. Primitive recursive arithmetic (PRA), a formal axiom system for the natural numbers and the primitive recursive functions on them, is often used for this purpose.
PRA is much weaker than Peano arithmetic, which is not a finitistic system. Nevertheless, many results in number theory and in proof theory can be proved in PRA. For example, Gödel's incompleteness theorem can be formalized into PRA, giving the following theorem:
If T is a theory of arithmetic satisfying certain hypotheses, with Gödel sentence GT, then PRA proves the implication Con(T)→GT.
Similarly, many of the syntactic results in proof theory can be proved in PRA, which implies that there are primitive recursive functions that carry out the corresponding syntactic transformations of proofs.
In proof theory and set theory, there is an interest in finitistic consistency proofs, that is, consistency proofs that themselves are finitistically acceptable. Such a proof establishes that the consistency of a theory T implies the consistency of a theory S by producing a primitive recursive function that can transform any proof of an inconsistency from S into a proof of an inconsistency from T. One sufficient condition for a consistency proof to be finitistic is the ability to formalize it in PRA. For example, many consistency results in set theory that are obtained by forcing can be recast as syntactic proofs that can be formalized in PRA.
History
Recursive definitions had been used more or less formally in mathematics before, but the construction of primitive recursion is traced back to Richard Dedekind's theorem 126 of his Was sind und was sollen die Zahlen? (1888). This work was the first to give a proof that a certain recursive construction defines a unique function.
Primitive recursive arithmetic was first proposed by Thoralf Skolem in 1923.
The current terminology was coined by Rózsa Péter (1934) after Ackermann had proved in 1928 that the function which today is named after him was not primitive recursive, an event which prompted the need to rename what until then were simply called recursive functions.
See also
Grzegorczyk hierarchy
Recursion (computer science)
Primitive recursive functional
Double recursion
Primitive recursive set function
Primitive recursive ordinal function
Tail call
Notes
References
Brainerd, W.S., Landweber, L.H. (1974), Theory of Computation, Wiley, ISBN 0-471-09585-0
Fischer, Michael J.; Fischer, Robert P.; Beigel, Richard (November 1989). "Primitive Recursion without Implicit Predecessor". ACM SIGACT News. 20 (4): 87–91. doi:10.1145/74074.74089. S2CID 33850327.
Juris Hartmanis (1989), “Overview of computational Complexity Theory” in J. Hartmanis (ed.), Computational Complexity Theory, Providence: American Mathematical Society, pp. 1–17.
Robert I. Soare, Recursively Enumerable Sets and Degrees, Springer-Verlag, 1987. ISBN 0-387-15299-7
Stephen Kleene (1952) Introduction to Metamathematics, North-Holland Publishing Company, New York, 11th reprint 1971: (2nd edition notes added on 6th reprint). In Chapter XI. General Recursive Functions §57
George Boolos, John Burgess, Richard Jeffrey (2002), Computability and Logic: Fourth Edition, Cambridge University Press, Cambridge, UK. Cf pp. 70–71.
Robert I. Soare 1995 Computability and Recursion http://www.people.cs.uchicago.edu/~soare/History/compute.pdf
Daniel Severin 2008, Unary primitive recursive functions, J. Symbolic Logic Volume 73, Issue 4, pp. 1122–1138 arXiv projecteuclid doi:10.2178/jsl/1230396909 JSTOR 275903221
Kata Kunci Pencarian:
- Daftar istilah komputer
- Algoritma
- Daftar kata yang dilindungi di SQL
- Primitive recursive function
- General recursive function
- Ackermann function
- Recursive function
- Primitive recursive arithmetic
- Elementary recursive function
- Primitive recursive set function
- Successor function
- Μ operator
- Computable function