Primitive recursive function: Difference between revisions

From HandWiki
imported>Steve Marsio
linkage
 
AstroAI (talk | contribs)
add
 
Line 1: Line 1:
{{Short description|Function computable with bounded loops}}
{{Short description|Function computable with bounded loops}}
In [[Computability theory|computability theory]], a '''primitive recursive function''' is, roughly speaking, a function that can be computed by a [[Computer program|computer program]] whose loops are all [[For loop|"for" loops]] (that is, an upper bound of the number of iterations of every loop can be determined before entering the loop). Primitive recursive functions form a strict [[Subset|subset]] of those [[General recursive function|general recursive function]]s that are also total functions.  
{{CS1 config|mode=cs2}}
In [[Computability theory|computability theory]], a '''primitive recursive function''' is, roughly speaking, a function that can be computed by a [[Computer program|computer program]] whose loops are all [[For loop|"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|subset]] of those [[General recursive function|general recursive function]]s 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|number theory]] (and more generally in mathematics) are primitive recursive. For example, [[Addition|addition]] and [[Division (mathematics)|division]], the [[Factorial|factorial]] and [[Exponential function|exponential function]], and the function which returns the ''n''th prime are all primitive recursive.<ref>Brainerd and Landweber, 1974</ref> In fact, for showing that a computable function is primitive recursive, it suffices to show that its [[Time complexity|time complexity]] is bounded above by a primitive recursive function of the input size.{{cn|reason=Give a source for a proof.|date=November 2021}} It is hence not particularly easy to devise a [[Computable function|computable function]] that is ''not'' primitive recursive; some examples are shown in section {{slink||Limitations}} below.
The importance of primitive recursive functions lies in the fact that most [[Computable function|computable function]]s that are studied in [[Number theory|number theory]] (and more generally in mathematics) are primitive recursive. For example, [[Addition|addition]] and [[Division (mathematics)|division]], the [[Factorial|factorial]] and [[Exponential function|exponential function]], and the function which returns the ''n''th prime are all primitive recursive.{{sfn|Brainerd|Landweber|1974}} In fact, for showing that a computable function is primitive recursive, it suffices to show that its [[Time complexity|time complexity]] is bounded above by a primitive recursive function of the input size.{{sfn|Hartmanis|1989}} It is hence not particularly easy to devise a [[Computable function|computable function]] that is ''not'' primitive recursive; some examples are shown in section {{section link||Limitations}} below.


The set of primitive recursive functions is known as [[PR (complexity)|PR]] in [[Computational complexity theory|computational complexity theory]].
The set of primitive recursive functions is known as [[PR (complexity)|PR]] in [[Computational complexity theory|computational complexity theory]].
Line 8: Line 9:
== Definition ==
== Definition ==


A primitive recursive function takes a fixed number of arguments, each a [[Natural number|natural number]] (nonnegative integer: {0, 1, 2, ...}), and returns a natural number. If it takes ''n'' arguments it is called ''n''-[[Arity|ary]].
A primitive recursive function takes a fixed number of arguments, each a [[Natural number|natural number]] (nonnegative integer: {0, 1, 2, ...}), and returns a natural number. If it takes ''n'' arguments, it is called ''n''-[[Arity|ary]].


The basic primitive recursive functions are given by these [[Axiom|axiom]]s:
The basic primitive recursive functions are given by these [[Axiom|axiom]]s:
{{ordered list|start=1
{{ordered list|start=1
|1=''Constant functions {{mvar|C{{su|b=n|p=k}}}}'': For each natural number {{mvar|n}} and every {{mvar|k}}, the ''k''-ary constant function, defined by <math>C_n^k(x_1,\ldots,x_k) \ \stackrel{\mathrm{def}}{=}\  n</math>, is primitive recursive.
|1=''Constant functions <math>C_n^k</math>'': For each natural number <math>n</math> and every <math>k</math>, the ''k''-ary constant function, defined by <math>C_n^k(x_1,\ldots,x_k) \ \stackrel{\mathrm{def}}{=}\  n</math>, is primitive recursive.


| 2=''Successor function'': The 1-ary successor function ''S'', which returns the successor of its argument (see Peano postulates), that is, <math>S(x) \ \stackrel{\mathrm{def}}{=}\  x + 1</math>, is primitive recursive.
| 2=''Successor function'': The 1-ary successor function ''S'', which returns the successor of its argument (see Peano postulates), that is, <math>S(x) \ \stackrel{\mathrm{def}}{=}\  x + 1</math>, is primitive recursive.
| 3=''Projection function'' <math>P_i^k</math>: For all natural numbers <math>i, k</math> such that <math>1\le i\le k</math>, the ''k''-ary function defined by <math>P_i^k(x_1,\ldots,x_k) \ \stackrel{\mathrm{def}}{=}\  x_i</math> is primitive recursive.
 
| 3=''Projection functions'' <math>P_i^k</math>: For all natural numbers <math>i, k</math> such that <math>1\le i\le k</math>, the ''k''-ary function defined by <math>P_i^k(x_1,\ldots,x_k) \ \stackrel{\mathrm{def}}{=}\  x_i</math> is primitive recursive.
}}
}}
More complex primitive recursive functions can be obtained by applying the [[Operation (mathematics)|operation]]s given by these axioms:
More complex primitive recursive functions can be obtained by applying the [[Operation (mathematics)|operation]]s given by these axioms:
{{ordered list|start=4
{{ordered list|start=4
| 4=''Composition operator'' <math>\circ\,</math> (also called the ''substitution operator''): Given an ''m''-ary function <math>h(x_1,\ldots,x_m)\,</math> and ''m'' ''k''-ary functions <math>g_1(x_1,\ldots,x_k),\ldots,g_m(x_1,\ldots, x_k)</math>: <math display="block">h \circ (g_1, \ldots, g_m) \ \stackrel{\mathrm{def}}{=}\  f, \quad\text{where}\quad f(x_1,\ldots,x_k) = h(g_1(x_1,\ldots,x_k),\ldots,g_m(x_1,\ldots,x_k)).</math>
| 4=''Composition operator'' <math>\circ\,</math> (also called the ''substitution operator''): Given an ''m''-ary function <math>h(x_1,\ldots,x_m)\,</math> and ''m'' ''k''-ary functions <math>g_1(x_1,\ldots,x_k),\ldots,g_m(x_1,\ldots, x_k)</math>: <math display="block">h \circ (g_1, \ldots, g_m) \ \stackrel{\mathrm{def}}{=}\  f, \quad\text{where}\quad f(x_1,\ldots,x_k) = h(g_1(x_1,\ldots,x_k),\ldots,g_m(x_1,\ldots,x_k)).</math> For <math>m=1</math>, the ordinary [[Function composition|function composition]] <math>h \circ g_1</math> is obtained.
| 5=''Primitive recursion operator'' {{mvar|&rho;}}: Given the ''k''-ary function <math>g(x_1,\ldots,x_k)\,</math> and the (''k''&nbsp;+&nbsp;2)-ary function <math>h(y,z,x_1,\ldots,x_k)\,</math>:<math display="block">\begin{align}  
 
| 5=''Primitive recursion operator'' <math>\rho</math>: Given the ''k''-ary function <math>g(x_1,\ldots,x_k)\,</math> and the <math>(k+2)</math>-ary function <math>h(y,z,x_1,\ldots,x_k)\,</math>:
:<math display="block">\begin{align}
             \rho(g, h) &\ \stackrel{\mathrm{def}}{=}\  f, \quad\text{where the }(k+1)\text{-ary function } f \text{ is defined by}\\
             \rho(g, h) &\ \stackrel{\mathrm{def}}{=}\  f, \quad\text{where the }(k+1)\text{-ary function } f \text{ is defined by}\\
    f(0,x_1,\ldots,x_k) &= g(x_1,\ldots,x_k) \\
f(y, x_1, \dots, x_k) &= \begin{cases}
   f(S(y),x_1,\ldots,x_k) &= h(y,f(y,x_1,\ldots,x_k),x_1,\ldots,x_k).\end{align}</math>
  g(x_1, \dots, x_k)     & \text{if } y=0,  \\
   h(y', f(y', x_1, \dots, x_k) ,x_1, \dots, x_k) & \text{if } y=S(y') \text{ for a } y' \in \mathbb{N}.
\end{cases}
\end{align}</math>
''Interpretation:''
''Interpretation:''
The function&nbsp;''f'' acts as a [[For loop|for-loop]] from 0 up to the value of its first argument. The rest of the arguments for&nbsp;''f'', denoted here with ''x''<sub>1</sub>,&nbsp;...,&nbsp;''x''<sub>''k''</sub>, are a set of initial conditions for the for-loop which may be used by it during calculations but which are immutable by it. The functions ''g'' and ''h'' on the right-hand side of the equations that define ''f'' represent the body of the loop, which performs calculations. The function&nbsp;''g'' is used only once to perform initial calculations. Calculations for subsequent steps of the loop are performed by&nbsp;''h''. The first parameter of&nbsp;''h'' is fed the "current" value of the for-loop's index. The second parameter of&nbsp;''h'' is fed the result of the for-loop's previous calculations, from previous steps. The rest of the parameters for&nbsp;''h'' are those immutable initial conditions for the for-loop mentioned earlier. They may be used by&nbsp;''h'' to perform calculations but they will not themselves be altered by&nbsp;''h''.
The function <math>f</math> acts as a [[For loop|for-loop]] from <math>0</math> up to the value of its first argument. The rest of the arguments for <math>f</math>, denoted here with <math>x_1,\ldots,x_k</math>, are a set of initial conditions for the for-loop which may be used by it during calculations but which are immutable by it. The functions <math>g</math> and <math>h</math> on the right-hand side of the equations that define <math>f</math> represent the body of the loop, which performs calculations. The function <math>g</math> is used only once to perform initial calculations. Calculations for subsequent steps of the loop are performed by <math>h</math>. The first parameter of <math>h</math> is fed the "current" value of the for-loop's index. The second parameter of <math>h</math> is fed the result of the for-loop's previous calculations, from previous steps. The rest of the parameters for <math>h</math> are those immutable initial conditions for the for-loop mentioned earlier. They may be used by <math>h</math> to perform calculations but they will not themselves be altered by <math>h</math>.
}}
}}


The '''primitive recursive functions''' are the basic functions and those obtained from the basic functions by applying these operations a finite number of times.
The '''primitive recursive functions''' are the basic functions and those obtained from the basic functions by applying these operations a finite number of times.
=== Primitive-recursiveness of vector-valued functions ===
A (vector-valued) function{{refn|Also known as ''"sequence function"''.{{sfn|Fachini|Maggiolo-Schettini|1979}}{{sfn|Fachini|Maggiolo-Schettini|1982}}}} <math>f : \mathbb{N}^m \to \mathbb{N}^n</math> is primitive recursive if it can be written as
:<math>f(x_1, \dots, x_m) = (f_1(x_1, \dots, x_m), \dots, f_n(x_1, \dots, x_m))</math>
where each component <math>f_i : \mathbb{N}^m \to \mathbb{N}</math> is a (scalar-valued) primitive recursive function.<ref>{{harvtxt|PlanetMath}}.</ref>


== Examples ==
== Examples ==
Line 47: Line 59:
|<math>S \circ S</math> is a 1-ary function that adds 2 to its input, <math>(S \circ S)(x) = x+2</math>.
|<math>S \circ S</math> is a 1-ary function that adds 2 to its input, <math>(S \circ S)(x) = x+2</math>.


|<math>S \circ C_0^1</math> is a 1-ary function which returns 1 for every input: <math>(S \circ C_0^1)(x) = S(C_0^1(x)) = S(0) = 1</math>. That is, <math>S \circ C_0^1</math> and <math>C_1^1</math> are the same function: <math>S \circ C_0^1 = C_1^1</math>. In a similar way, every <math>C_n^1</math> can be expressed as a composition of appropriately many <math>S</math> and <math>C_0^1</math>.
}}
}}


===Addition===
===Addition===


A definition of the 2-ary function <math>Add</math>, to compute the sum of its arguments, can be obtained using the primitive recursion operator <math>\rho</math>. To this end, the well-known equations  
A definition of the 2-ary function <math>\operatorname{Add}</math>, to compute the sum of its arguments, can be obtained using the primitive recursion operator <math>\rho</math>. To this end, the well-known equations  
:<math>\begin{array}{rcll}
:<math>\begin{align}
0+y & = & y & \text{ and} \\
0 + y &= y, \\
S(x)+y & = & S(x+y) & . \\
S(x) + y &= S(x+y)
\end{array}</math>
\end{align}</math>
are "rephrased in primitive recursive function terminology": In the definition of <math>\rho(g,h)</math>, the first equation suggests to choose <math>g = P_1^1</math> to obtain <math>Add(0,y) = g(y) = y</math>; the second equation suggests to choose <math>h = S \circ P_2^3</math> to obtain <math>Add(S(x),y) = h(x,Add(x,y),y) = (S \circ P_2^3)(x,Add(x,y),y) = S(Add(x,y))</math>. Therefore, the addition function can be defined as <math>Add = \rho(P_1^1,S \circ P_2^3)</math>. As a computation example,
are "rephrased in primitive recursive function terminology": In the definition of <math>\rho(g, h)</math>, the first equation suggests to choose <math>g = P_1^1</math> to obtain <math>\operatorname{Add}(0, y) = g(y) = y</math>; the second equation suggests to choose <math>h = S \circ P_2^3</math> to obtain <math>\operatorname{Add}(S(x), y) = h(x, \operatorname{Add}(x, y), y) = (S \circ P_2^3)(x, \operatorname{Add}(x, y), y) = S(\operatorname{Add}(x, y))</math>. Therefore, the addition function can be defined as <math>\operatorname{Add} = \rho(P_1^1, S \circ P_2^3)</math>. As a computation example,
:<math>\begin{array}{lll}
:<math>\begin{align}
& Add(1,7) \\
\operatorname{Add}(1, 7)
= & \rho(P_1^1,S \circ P_2^3) \; (S(0),7) & \text{ by Def. } Add, S \\
  &= \rho(P_1^1, S \circ P_2^3) (S(0), 7) && \text{ by Def. } \operatorname{Add}, S \\
= & (S \circ P_2^3)(0,Add(0,7),7) & \text{ by case } \rho(g,h) \; (S(...),...) \\
  &= (S \circ P_2^3)(0, \operatorname{Add}(0, 7), 7) && \text{ by case } \rho(g, h) (S(...), ...) \\
= & S(Add(0,7)) & \text{ by Def. } \circ, P_2^3 \\
  &= S(\operatorname{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(\rho(P_1^1, S \circ P_2^3) (0, 7)) && \text{ by Def. } \operatorname{Add} \\
= & S(P_1^1(7)) & \text{ by case } \rho(g,h) \; (0,...) \\
  &= S(P_1^1(7)) && \text{ by case } \rho(g, h) (0,...) \\
= & S(7) & \text{ by Def. } P_1^1 \\
  &= S(7) && \text{ by Def. } P_1^1 \\
= & 8 & \text{ by Def. } S . \\  
  &= 8 && \text{ by Def. } S. \\  
\end{array}</math>
\end{align}</math>


===Doubling===
===Doubling===


Given <math>Add</math>, the 1-ary function <math>Add \circ (P_1^1,P_1^1)</math> doubles its argument, <math>(Add \circ (P_1^1,P_1^1))(x) = Add(x,x) = x+x</math>.
Given <math>\operatorname{Add}</math>, the 1-ary function <math>\operatorname{Add} \circ (P_1^1, P_1^1)</math> doubles its argument, <math>(\operatorname{Add} \circ (P_1^1, P_1^1))(x) = \operatorname{Add}(x, x) = x + x.</math>


===Multiplication===
===Multiplication===


In a similar way as addition, multiplication can be defined by <math>Mul = \rho(C_0^1,Add \circ(P_2^3,P_3^3))</math>. This reproduces the well-known multiplication equations:  
In a similar way as addition, multiplication can be defined by <math>\operatorname{Mul} = \rho(C_0^1, \operatorname{Add} \circ(P_2^3, P_3^3))</math>. This reproduces the well-known multiplication equations:  
:<math>\begin{array}{lll}
:<math>\begin{align}
& Mul(0,y) \\
\operatorname{Mul}(0, y)
= & \rho(C_0^1,Add \circ(P_2^3,P_3^3)) \; (0,y) & \text{ by Def. } Mul \\
  &= \rho(C_0^1, \operatorname{Add} \circ(P_2^3, P_3^3)) (0, y) && \text{ by Def. } \operatorname{Mul} \\
= & C_0^1(y) & \text{ by case } \rho(g,h) \; (0,...)\\
  &= C_0^1(y) && \text{ by case } \rho(g, h) (0, ...) \\
= & 0 & \text{ by Def. } C_0^1 . \\
  &= 0 && \text{ by Def. } C_0^1.
\end{array}</math>  
\end{align}</math>  
and  
and  
:<math>\begin{array}{lll}
:<math>\begin{align}
& Mul(S(x),y) \\
\operatorname{Mul}(S(x), y)
= & \rho(C_0^1,Add \circ(P_2^3,P_3^3)) \; (S(x),y) & \text{ by Def. } Mul \\
  &= \rho(C_0^1, \operatorname{Add} \circ(P_2^3, P_3^3)) (S(x),y) && \text{ by Def. } \operatorname{Mul} \\
= & (Add \circ(P_2^3,P_3^3)) \; (x,Mul(x,y),y) & \text{ by case } \rho(g,h) \; (S(...),...) \\
  &= (\operatorname{Add} \circ(P_2^3 ,P_3^3)) (x, \operatorname{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 \\
  &= \operatorname{Add}(\operatorname{Mul}(x, y), y) && \text{ by Def. } \circ, P_2^3, P_3^3 \\
= & Mul(x,y)+y & \text{ by property of } Add . \\
  &= \operatorname{Mul}(x, y) + y && \text{ by property of } \operatorname{Add}.
\end{array}</math>
\end{align}</math>


===Predecessor===
===Predecessor===


The predecessor function acts as the "opposite" of the successor function and is recursively defined by the rules <math>Pred(0) = 0</math> and <math>Pred(S(n)) = n</math>. A primitive recursive definition is <math>Pred = \rho(C_0^0, P_1^2)</math>. As a computation example,
The predecessor function acts as the "opposite" of the successor function and is recursively defined by the rules <math>\operatorname{Pred}(0) = 0</math> and <math>\operatorname{Pred}(S(n)) = n</math>. A primitive recursive definition is <math>\operatorname{Pred} = \rho(C_0^0, P_1^2)</math>. As a computation example,
:<math>\begin{array}{lll}
:<math>\begin{align}
& Pred(8) \\
\operatorname{Pred}(8)
= & \rho(C_0^0, P_1^2) \; (S(7)) & \text{ by Def. } Pred, S \\
  &= \rho(C_0^0, P_1^2) (S(7)) && \text{ by Def. } \operatorname{Pred}, S \\
= & P_1^2(7,Pred(7)) & \text{ by case } \rho(g,h) \; (S(...),...) \\
  &= P_1^2(7, \operatorname{Pred}(7)) && \text{ by case } \rho(g, h) (S(...), ...) \\
= & 7 & \text{ by Def. } P_1^2 . \\
  &= 7 && \text{ by Def. } P_1^2.
\end{array}</math>
\end{align}</math>


===Truncated subtraction===
===Truncated subtraction===


The limited subtraction function (also called "[[Monus|monus]]", and denoted "<math>\stackrel.-</math>") is definable from the predecessor function. It satisfies the equations  
The limited subtraction function (also called "[[Monus|monus]]", and denoted "<math>\mathbin{\dot{-}}</math>") is definable from the predecessor function. It satisfies the equations  
:<math>\begin{array}{rcll}
:<math>\begin{align}
y \stackrel.- 0 & = & y & \text{and} \\
y \mathbin{\dot{-}} 0 &= y, \\
y \stackrel.- S(x) & = & Pred(y \stackrel.- x) & . \\
y \mathbin{\dot{-}} S(x) &= \operatorname{Pred}(y \mathbin{\dot{-}} x).
\end{array}</math>
\end{align}</math>
Since the recursion runs over the second argument, we begin with a primitive recursive definition of the reversed subtraction, <math>RSub(y,x) = x \stackrel.- y</math>. Its recursion then runs over the first argument, so its primitive recursive definition can be obtained, similar to addition, as <math>RSub = \rho(P_1^1, Pred \circ P_2^3)</math>. To get rid of the reversed argument order, then define <math>Sub = RSub \circ (P_2^2,P_1^2)</math>. As a computation example,
Since the recursion runs over the second argument, we begin with a primitive recursive definition of the reversed subtraction, <math>\operatorname{RSub}(y, x) = x \mathbin{\dot{-}} y</math>. Its recursion then runs over the first argument, so its primitive recursive definition can be obtained, similar to addition, as <math>\operatorname{RSub} = \rho(P_1^1, \operatorname{Pred} \circ P_2^3)</math>. To get rid of the reversed argument order, then define <math>\operatorname{Sub} = \operatorname{RSub} \circ (P_2^2, P_1^2)</math>. As a computation example,
:<math>\begin{array}{lll}
:<math>\begin{align}
& Sub(8,1) \\
\operatorname{Sub}(8, 1)
= & (RSub \circ (P_2^2,P_1^2)) \; (8,1) & \text{ by Def. } Sub \\
  &= (\operatorname{RSub} \circ (P_2^2, P_1^2)) (8, 1) && \text{ by Def. } \operatorname{Sub} \\
= & RSub(1,8) & \text{ by Def. } \circ, P_2^2, P_1^2 \\
  &= \operatorname{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 \\
  &= \rho(P_1^1, \operatorname{Pred} \circ P_2^3) (S(0), 8) && \text{ by Def. } \operatorname{RSub}, S \\
= & (Pred \circ P_2^3) \; (0,RSub(0,8),8) & \text{ by case } \rho(g,h) \; (S(...),...) \\
  &= (\operatorname{Pred} \circ P_2^3) (0, \operatorname{RSub}(0, 8), 8) && \text{ by case } \rho(g, h) (S(...), ...) \\
= & Pred(RSub(0,8)) & \text{ by Def. } \circ, P_2^3 \\
  &= \operatorname{Pred}(\operatorname{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 \\
  &= \operatorname{Pred}(\rho(P_1^1, \operatorname{Pred} \circ P_2^3) (0, 8)) && \text{ by Def. } \operatorname{RSub} \\
= & Pred(P_1^1(8)) & \text{ by case } \rho(g,h) \; (0,...) \\
  &= \operatorname{Pred}(P_1^1(8)) && \text{ by case } \rho(g, h) (0, ...) \\
= & Pred(8) & \text{ by Def. } P_1^1 \\
  &= \operatorname{Pred}(8) && \text{ by Def. } P_1^1 \\
= & 7 & \text{ by property of } Pred . \\
  &= 7 && \text{ by property of } \operatorname{Pred}.
\end{array}</math>
\end{align}</math>


=== Converting predicates to numeric functions ===
=== 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 [[Philosophy:Truth value|truth value]]s (that is ''t'' for true and ''f'' for false), or that produce truth values as outputs.<ref>Kleene [1952 pp.&nbsp;226–227]</ref> 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'' with the number 1 and the truth value ''f'' with the number 0. Once this identification has been made, the [[Indicator function|characteristic function]] of a set ''A'', which always returns 1 or 0, can be viewed as a predicate that tells whether a number is in the set ''A''. Such an identification of predicates with numeric functions will be assumed for the remainder of this article.
In some settings, it is natural to consider primitive recursive functions that take as inputs tuples that mix numbers with [[Truth value|truth value]]s (that is, <math>t</math> for true, and <math>f</math> for false), or that produce truth values as outputs.{{sfn|Kleene|1974|pp=226–227}} 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 <math>t</math> with the number <math>1</math>, and the truth value <math>f</math> with the number <math>0</math>. Once this identification has been made, the [[Indicator function|characteristic function]] of a set <math>A</math>, which always returns <math>1</math> or <math>0</math>, can be viewed as a predicate that tells whether a number is in the set <math>A</math>. Such an identification of predicates with numeric functions will be assumed for the remainder of this article.


=== Predicate "Is zero" ===
=== Predicate "Is zero" ===


As an example for a primitive recursive predicate, the 1-ary function <math>IsZero</math> shall be defined such that <math>IsZero(x) = 1</math> if <math>x = 0</math>, and  
As an example for a primitive recursive predicate, the 1-ary function <math>\operatorname{IsZero}</math> shall be defined such that <math>\operatorname{IsZero}(x) = 1</math> if <math>x = 0</math>, and <math>\operatorname{IsZero}(x) = 0</math> otherwise. This can be achieved by defining <math>\operatorname{IsZero} = \rho(C_1^0, C_0^2)</math>. Then <math>\operatorname{IsZero}(0) = \rho(C_1^0, C_0^2)(0) = C_1^0() = 1</math>, and e.g. <math>\operatorname{IsZero}(8) = \rho(C_1^0, C_0^2)(S(7)) = C_0^2(7, \operatorname{IsZero}(7)) = 0</math>.
<math>IsZero(x) = 0</math>, otherwise. This can be achieved by defining <math>IsZero = \rho(C_1^0,C_0^2)</math>. Then, <math>IsZero(0) = \rho(C_1^0,C_0^2)(0) = C_1^0(0) = 1</math> and e.g. <math>IsZero(8) = \rho(C_1^0,C_0^2)(S(7)) = C_0^2(7,IsZero(7)) = 0</math>.


=== Predicate "Less or equal" ===
=== Predicate "Less or equal" ===


Using the property <math>x \leq y \iff x \stackrel.- y = 0</math>, the 2-ary function <math>Leq</math> can be defined by <math>Leq = IsZero \circ Sub</math>. Then <math>Leq(x,y) = 1</math> if <math>x \leq y</math>, and <math>Leq(x,y) = 0</math>, otherwise. As a computation example,
Using the property <math>x \leq y \iff x \mathbin{\dot{-}} y = 0</math>, the 2-ary function <math>\operatorname{Leq}</math> can be defined by <math>\operatorname{Leq} = \operatorname{IsZero} \circ \operatorname{Sub}</math>. Then <math>\operatorname{Leq}(x, y) = 1</math> if <math>x \leq y</math>, and <math>\operatorname{Leq}(x, y) = 0</math> otherwise. As a computation example,
:<math>\begin{array}{lll}
:<math>\begin{align}
& Leq(8,3) \\
\operatorname{Leq}(8, 3)
= & IsZero(Sub(8,3)) & \text{ by Def. } Leq \\
  &= \operatorname{IsZero}(\operatorname{Sub}(8, 3)) && \text{ by Def. } \operatorname{Leq} \\
= & IsZero(5) & \text{ by property of } Sub \\
  &= \operatorname{IsZero}(5) && \text{ by property of } \operatorname{Sub} \\
= & & \text{ by property of } IsZero \\
  &= 0 && \text{ by property of } \operatorname{IsZero} \\
\end{array}</math>
\end{align}</math>


=== Predicate "Greater or equal" ===
=== Predicate "Greater or equal" ===


Once a definition of <math>Leq</math> is obtained, the converse predicate can be defined as <math>Geq = Leq \circ (P_2^2,P_1^2)</math>. Then, <math>Geq(x,y) = Leq(y,x)</math> is true (more precisely: has value 1) if, and only if, <math>x \geq y</math>.
Once a definition of <math>\operatorname{Leq}</math> is obtained, the converse predicate can be defined as <math>\operatorname{Geq} = \operatorname{Leq} \circ (P_2^2, P_1^2)</math>. Then, <math>\operatorname{Geq}(x, y) = \operatorname{Leq}(y, x)</math> is true (more precisely: has value 1) if and only if <math>x \geq y</math>.


=== If-then-else ===
=== If-then-else ===


The 3-ary if-then-else operator known from programming languages can be defined by <math>\textit{If} = \rho(P_2^2,P_3^4)</math>. Then, for arbitrary <math>x</math>,
The 3-ary if-then-else operator known from programming languages can be defined by <math>\operatorname{If} = \rho(P_2^2, P_3^4)</math>. Then, for arbitrary <math>x</math>,
:<math>\begin{array}{lll}
:<math>\begin{align}
& \textit{If}(S(x),y,z) \\
\operatorname{If}(S(x), y, z)
= & \rho(P_2^2,P_3^4) \; (S(x),y,z) & \text{ by Def. } \textit{If} \\
  &= \rho(P_2^2, P_3^4) (S(x), y, z) && \text{ by Def. } \operatorname{If} \\
= & P_3^4(x,\textit{If}(x,y,z),y,z) & \text{ by case } \rho(S(...),...) \\
  &= P_3^4(x, \operatorname{If}(x, y, z), y, z) && \text{ by case } \rho(S(...), ...) \\
= & y & \text{ by Def. } P_3^4 \\
  &= y && \text{ by Def. } P_3^4
\end{array}</math>
\end{align}</math>
and  
and  
:<math>\begin{array}{lll}
:<math>\begin{align}
& \textit{If}(0,y,z) \\
\operatorname{If}(0, y, z)
= & \rho(P_2^2,P_3^4) \; (0,y,z) & \text{ by Def. } \textit{If} \\
  &= \rho(P_2^2, P_3^4) (0, y, z) && \text{ by Def. } \operatorname{If} \\
= & P_2^2(y,z) & \text{ by case } \rho(0,...) \\
  &= P_2^2(y, z) && \text{ by case } \rho(0, ...) \\
= & z & \text{ by Def. } P_2^2 . \\
  &= z && \text{ by Def. } P_2^2.
\end{array}</math>.
\end{align}</math>
That is, <math>\textit{If}(x,y,z)</math> returns the then-part, <math>y</math>, if the if-part, <math>x</math>, is true, and the else-part, <math>z</math>, otherwise.
That is, <math>\operatorname{If}(x, y, z)</math> returns the then-part (<math>y</math>) if the if-part (<math>x</math>) is true, and the else-part (<math>z</math>) otherwise.


=== Junctors ===
=== Junctors ===


Based on the <math>\textit{If}</math> function, it is easy to define logical junctors. For example, defining <math>And = \textit{If} \circ (P_1^2,P_2^2,C_0^2)</math>, one obtains <math>And(x,y) = \textit{If}(x,y,0)</math>, that is, <math>And(x,y)</math> is true if, and only if, both <math>x</math> and <math>y</math> are true ([[Logical conjunction|logical conjunction]] of <math>x</math> and <math>y</math>).
Based on the <math>\operatorname{If}</math> function, it is easy to define logical junctors. For example, defining <math>\operatorname{And} = \operatorname{If} \circ (P_1^2, P_2^2, C_0^2)</math>, one obtains <math>\operatorname{And}(x, y) = \operatorname{If}(x, y, 0)</math>, that is, <math>\operatorname{And}(x, y)</math> is true [[If and only if|if and only if]] both <math>x</math> and <math>y</math> are true ([[Logical conjunction|logical conjunction]] of <math>x</math> and <math>y</math>).


Similarly, <math>Or = \textit{If} \circ (P_1^2,C_1^2,P_2^2)</math> and <math>Not = \textit{If} \circ (P_1^1,C_0^1,C_1^1)</math> lead to appropriate definitions of disjunction and [[Negation|negation]]: <math>Or(x,y) = \textit{If}(x,1,y)</math> and <math>Not(x) = \textit{If}(x,0,1)</math>.
Similarly, <math>\operatorname{Or} = \operatorname{If} \circ (P_1^2, C_1^2, P_2^2)</math> and <math>\operatorname{Not} = \operatorname{If} \circ (P_1^1, C_0^1, C_1^1)</math> lead to appropriate definitions of [[Disjunction|disjunction]] and [[Negation|negation]]: <math>\operatorname{Or}(x, y) = \operatorname{If}(x, 1, y)</math> and <math>\operatorname{Not}(x) = \operatorname{If}(x, 0, 1)</math>.


=== Equality predicate ===
=== Equality predicate ===


Using the above functions <math>Leq</math>, <math>Geq</math> and <math>And</math>, the definition <math>Eq = And \circ (Leq, Geq)</math> implements the equality predicate. In fact, <math>Eq(x,y) = And( Leq(x,y) , Geq(x,y) )</math> is true if, and only if, <math>x</math> equals <math>y</math>.
Using the above functions <math>\operatorname{Leq}</math>, <math>\operatorname{Geq}</math> and <math>\operatorname{And}</math>, the definition <math>\operatorname{Eq} = \operatorname{And} \circ (\operatorname{Leq}, \operatorname{Geq})</math> implements the equality predicate. In fact, <math>\operatorname{Eq}(x, y) = \operatorname{And}(\operatorname{Leq}(x, y), \operatorname{Geq}(x, y))</math> is true if and only if <math>x</math> equals <math>y</math>.


Similarly, the definition <math>Lt = Not \circ Geq</math> implements the predicate "less-than", and <math>Gt = Not \circ Leq</math> implements "greater-than".
Similarly, the definition <math>\operatorname{Lt} = \operatorname{Not} \circ \operatorname{Geq}</math> implements the predicate "less-than", and <math>\operatorname{Gt} = \operatorname{Not} \circ \operatorname{Leq}</math> implements "greater-than".


=== Other operations on natural numbers ===
=== Other operations on natural numbers ===


[[Exponentiation]] and [[Primality test|primality test]]ing are primitive recursive. Given primitive recursive functions ''e'', ''f'', ''g'', and ''h'', a function that returns the value of ''g'' when ''e''≤''f'' and the value of ''h'' otherwise is primitive recursive.
[[Exponentiation]] and [[Primality test|primality test]]ing are primitive recursive. Given primitive recursive functions <math>e</math>, <math>f</math>, <math>g</math>, and <math>h</math>, a function that returns the value of <math>g</math> when <math>e \leq f</math> and the value of <math>h</math> otherwise is primitive recursive.


=== Operations on integers and rational numbers ===
=== Operations on integers and rational numbers ===
Line 184: Line 194:


=== Some common primitive recursive functions ===
=== Some common primitive recursive functions ===
:The following examples and definitions are from Kleene (1952) pp.&nbsp;223–231 — many appear with proofs. Most also appear with similar names, either as proofs or as examples, in Boolos-Burgess-Jeffrey 2002 pp.&nbsp;63–70; they add the logarithm lo(x, y) or lg(x, y) depending on the exact derivation.
The following examples and definitions are from {{harvnb|Kleene|1974|pp=222–231}}. Many appear with proofs. Most also appear with similar names, either as proofs or as examples, in {{harvnb|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 we observe that primitive recursive functions can be of four types:
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 =<sub>def</sub> 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.
# ''functions'' for short: "number-theoretic functions" from { 0, 1, 2, ...} to { 0, 1, 2, ...},
# ''predicates'': from { 0, 1, 2, ...} to truth values { t =true, f =false },
# ''propositional connectives'': from truth values { t, f } to truth values { t, f },
# ''representing functions'': from truth values { t, f } to { 0, 1, 2, ... }. Many times a predicate requires a representing function to convert the predicate's output { t, f } to { 0, 1 } (note the order "t" to "0" and "f" to "1" matches with ~sg( ) defined below). By definition a function φ('''x''') is a "representing function" of the predicate P('''x''') if φ takes only values 0 and 1 and produces ''0'' when P is true".
 
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 =<sub>def</sub> 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
:# Addition: a+b
Line 198: Line 202:
:# Exponentiation: a<sup>b</sup>
:# Exponentiation: a<sup>b</sup>
:# Factorial a! : 0! = 1, a'! = a!×a'
:# Factorial a! : 0! = 1, a'! = a!×a'
:# pred(a): (Predecessor or decrement): If a > 0 then a-1 else 0
:# 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
:# Proper subtraction a ∸ b: If a ≥ b then a−b else 0
:# Minimum(a<sub>1</sub>, ... a<sub>n</sub>)
:# Minimum(a<sub>1</sub>, ... a<sub>n</sub>)
:# Maximum(a<sub>1</sub>, ... a<sub>n</sub>)
:# Maximum(a<sub>1</sub>, ... a<sub>n</sub>)
:# Absolute difference: | a-b | =<sub>def</sub> (a ∸ b) + (b ∸ a)
:# Absolute difference: | a−b | =<sub>def</sub> (a ∸ b) + (b ∸ a)
:# ~sg(a): NOT[signum(a)]: If a=0 then 1 else 0
:# ~sg(a): NOT[signum(a)]: If a=0 then 1 else 0
:# sg(a): signum(a): If a=0 then 0 else 1
:# 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
:# 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)
:# 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 |  (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 )
:# a < b: sg( a' ∸ b )
:# Pr(a): a is a prime number Pr(a) =<sub>def</sub>  a>1 & NOT(Exists c)<sub>1<c<a</sub> [ c|a ]
:# Pr(a): a is a prime number Pr(a) =<sub>def</sub>  a>1 & NOT(Exists c)<sub>1<c<a</sub> [ c|a ]
:# p<sub>i</sub>: the i+1-st prime number
:# p<sub>i</sub>: the i+1th prime number
:# (a)<sub>i</sub>: exponent of p<sub>i</sub> in a: the unique x such that p<sub>i</sub><sup>x</sup>|a & NOT(p<sub>i</sub><sup>x'</sup>|a)
:# (a)<sub>i</sub>: exponent of p<sub>i</sub> in a: the unique x such that p<sub>i</sub><sup>x</sup>|a & NOT(p<sub>i</sub><sup>x'</sup>|a)
:# lh(a): the "length" or number of non-vanishing exponents in a
:# lh(a): the "length" or number of non-vanishing exponents in a
Line 238: Line 242:
* #G: If φ satisfies the equation:
* #G: If φ satisfies the equation:
::  φ(y,'''x''') = χ(y, COURSE-φ(y; x<sub>2</sub>, ... x<sub>n</sub> ), x<sub>2</sub>, ... x<sub>n</sub> then φ is primitive recursive in χ. The value COURSE-φ(y; '''x'''<sub>2 to n</sub> ) of the course-of-values function encodes the sequence of values φ(0,'''x'''<sub>2 to n</sub>), ..., φ(y-1,'''x'''<sub>2 to n</sub>) of the original function.
::  φ(y,'''x''') = χ(y, COURSE-φ(y; x<sub>2</sub>, ... x<sub>n</sub> ), x<sub>2</sub>, ... x<sub>n</sub> then φ is primitive recursive in χ. The value COURSE-φ(y; '''x'''<sub>2 to n</sub> ) of the course-of-values function encodes the sequence of values φ(0,'''x'''<sub>2 to n</sub>), ..., φ(y-1,'''x'''<sub>2 to n</sub>) of the original function.
== Use in first-order Peano arithmetic ==
In [[First-order logic|first-order]] Peano arithmetic, there are infinitely many variables (0-ary symbols) but no [[Arity|k-ary]] non-logical symbols with k>0 other than S, +, *, and ≤. Thus in order to define primitive recursive functions one has to use the following trick by Gödel.
By using a [[Gödel numbering for sequences]], for example [[Gödel's β function]], any finite sequence of numbers can be encoded by a single number. Such a number can therefore represent the primitive recursive function until a given n.
Let ''h'' be a 1-ary primitive recursion function defined by:
:<math> h(0) = C</math>
:<math> h(n+1) = g(n,h(n))</math>
where C is a constant and ''g'' is an already defined function.
Using Gödel's β function, for any sequence of natural numbers (k<sub>0</sub>, k<sub>1</sub>, ..., k<sub>n</sub>), there are natural numbers b and c such that, for every i ≤ n, β(b, c, i) = k<sub>i</sub>. We may thus use the following formula to define ''h''; more precisely, ''m''=''h''(''n'') is a shorthand for the following:
:<math>\exists b: \exists c: \beta(b, c, 0) = C \land \forall i: (i<n) \rightarrow (\beta(b, c, i+1) = g(i,\beta(b, c, i))) \land (m = \beta(b, c, n))</math>
and the equating to ''g'', being already defined, is in fact shorthand for some other already defined formula (as is β, whose formula is given [[Gödel's β function|here]]).
The generalization to any k-ary primitive recursion function is trivial.
== Elimination of parameters ==
The primitive recursion schema as given may be replaced by one which makes use of fewer parameters. Let <math>w</math> be an elementary pairing function, and <math>\pi_1,\pi_2</math> be its projection functions for inversion.
Theorem: Any function constructible via the clauses of primitive recursion using the standard primitive recursion schema is constructible when the schema is replaced with the following.
*<math>f'(x,0) = g'(x)</math>
*<math>f'(x,y+1) = h'(f'(x,y))</math>
This is proven by providing two intermediate schemata for primitive recursion, starting with a function defined via the standard schema, and translating the definition into terms of each intermediate schema and finally into terms of the above schema. The first intermediate schemata is as follows:
*<math>f_1(x,0) = g_1(x)</math>
*<math>f_1(x,y+1) = h_1(x,y,f_1(x,y))</math>
Translation of the standard definition of a primitive recursive function to the intermediate schema is done inductively, where an elementary pairing function <math>w</math> is used to reinterpret the definition of a <math>k+1</math>-ary primitive recursive function into a <math>k</math>-ary primitive recursive function, terminating the induction at <math>k=1</math>.
The second intermediate schema is as follows, with the <math>x</math> parameter eliminated.
*<math>f_2(x,0)=g_2(x)</math>
*<math>f_2(x,y+1)=h_2(y,f_2(x,y))</math>
Translation to it is accomplished by pairing <math>x</math> and <math>f_1(x,y)</math> together to use one parameter for handling both, namely by setting <math>g_2(x)=w(x,g_1(x))</math>, <math>h_2(x,z)=w(\pi_1 z,h_1(\pi_1 z, x, \pi_2 z))</math>, and recovering <math>f_1(x,y)</math> from these paired images by taking <math>\pi_2(f_2(x,y))</math>.
Finally, translation of the intermediate schema into the parameter-eliminated schema is done with a similar pairing and unpairing of <math>y</math> and <math>f_2(x,y)</math>. Composing these three translations gives a definition in the original parameter-free schema.<ref>H. E. Rose, ''Subrecursive Functions and Hierarchies'' (1984), pp.33--34. Oxford Logic Guides: 9, Oxford University Press, ISBN 0-19-853189-3.</ref>
This allows primitive recursion to be formalized in Peano arithmetic, due to its lack of extra ''n''-ary function symbols.{{citation needed|date=May 2023}}


== Relationship to recursive functions ==
== 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|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 of a function|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.
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|partial function]], that is, a relation which has ''at most'' one value for each argument, but which may ''fail'' to have a value at some arguments (see [[Domain of a function|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|if and only if]] there is a natural number ''m'' such that the function can be computed by a Turing [[Machine that always halts|machine that always halts]] within A(''m'',''n'') or fewer steps, where ''n'' is the sum of the arguments of the primitive recursive function.<ref>This follows from the facts that the functions of this form are the most quickly growing primitive recursive functions, and that a function is primitive recursive if and only if its time complexity is bounded by a primitive recursive function. For the former, see {{citation|title=An Introduction to Formal Languages and Automata|first=Peter|last=Linz|publisher=Jones & Bartlett Publishers|year=2011|isbn=9781449615529|page=332|url=https://books.google.com/books?id=hsxDiWvVdBcC&pg=PA332}}. For the latter, see {{citation|title=The Nature of Computation|first1=Cristopher|last1=Moore|first2=Stephan|last2=Mertens|publisher=Oxford University Press|year=2011|isbn=9780191620805|page=287|url=https://books.google.com/books?id=jnGKbpMV8xoC&pg=PA287}}</ref>
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|if and only if]] there is a natural number ''m'' such that the function can be computed by a Turing [[Machine that always halts|machine that always halts]] within A(''m'',''n'') or fewer steps, where ''n'' is the sum of the arguments of the primitive recursive function.<ref>This follows from the facts that the functions of this form are the most quickly growing primitive recursive functions, and that a function is primitive recursive if and only if its time complexity is bounded by a primitive recursive function. For the former, see {{citation|title=An Introduction to Formal Languages and Automata|first=Peter|last=Linz|publisher=Jones & Bartlett Publishers|year=2011|isbn=9781449615529|page=332|url=https://books.google.com/books?id=hsxDiWvVdBcC&pg=PA332}}. For the latter, see {{citation|title=The Nature of Computation|first1=Cristopher|last1=Moore|first2=Stephan|last2=Mertens|publisher=Oxford University Press|year=2011|isbn=9780191620805|page=287|url=https://books.google.com/books?id=jnGKbpMV8xoC&pg=PA287}}</ref>


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:
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 recursive 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 unary 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.
* For every ''m'', the function ''h''(''n'') = ''f''(''m'',''n'') is primitive recursive.
* Primitive recursive functions with two or more arguments can be encoded as unary primitive recursive functions by using a primitive recursive [[Pairing function|pairing function]] with two primitive recursive inverses.
''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 [[Diagonal lemma|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.
''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 [[Diagonal lemma|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.


Line 297: Line 261:
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:
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:


{{block indent|The primitive recursive functions of one argument (i.e., unary functions) can be [[Recursively enumerable set|computably enumerated]]. This enumeration uses the definitions of the primitive recursive functions (which are essentially just expressions with the composition and primitive recursion operations as operators and the basic primitive recursive functions as atoms), and can be assumed to contain every definition once, even though a same ''function'' will occur many times on the list (since many definitions define the same function; indeed simply composing by the [[Identity function|identity function]] generates infinitely many definitions of any one primitive recursive function). This means that the {{mvar|''n''}}-th definition of a primitive recursive function in this enumeration can be effectively determined from {{mvar|''n''}}. Indeed if one uses some [[Gödel numbering]] to encode definitions as numbers, then this {{mvar|''n''}}-th definition in the list is computed by a primitive recursive function of {{mvar|''n''}}. Let {{math|''f''<sub>''n''</sub>}} denote the unary primitive recursive function given by this definition.
{{block indent|The primitive recursive functions of one argument (i.e., unary functions) can be [[Recursively enumerable set|computably enumerated]]. This enumeration uses the definitions of the primitive recursive functions (which are essentially just expressions with the composition and primitive recursion operations as operators and the basic primitive recursive functions as atoms), and can be assumed to contain every definition once, even though a same ''function'' will occur many times on the list (since many definitions define the same function; indeed simply composing by the [[Identity function|identity function]] generates infinitely many definitions of any one primitive recursive function). This means that the <math>n</math>-th definition of a primitive recursive function in this enumeration can be effectively determined from <math>n</math>. Indeed if one uses some [[Gödel numbering]] to encode definitions as numbers, then this <math>n</math>-th definition in the list is computed by a primitive recursive function of <math>n</math>. Let <math>f_n</math> denote the unary primitive recursive function given by this definition.


Now define the "evaluator function" {{mvar|''ev''}} with two arguments, by {{math|''ev''(''i'',''j'') {{=}} ''f''<sub>''i''</sub>(''j'')}}. Clearly {{math|''ev''}} is total and computable, since one can effectively determine the definition of {{math|''f''<sub>''i''</sub>}}, and being a primitive recursive function {{math|''f''<sub>''i''</sub>}} is itself total and computable, so {{math|''f''<sub>''i''</sub>(''j'')}} is always defined and effectively computable. However a diagonal argument will show that the function {{mvar|''ev''}} of two arguments is not primitive recursive.
Now define the "evaluator function" <math>ev</math> with two arguments, by <math>ev(i,j) = f_i(j)</math>. Clearly <math>ev</math> is total and computable, since one can effectively determine the definition of <math>f_i</math>, and being a primitive recursive function <math>f_i</math> is itself total and computable, so <math>f_i(j)</math> is always defined and effectively computable. However a diagonal argument will show that the function <math>ev</math> of two arguments is not primitive recursive.


Suppose {{mvar|''ev''}} were primitive recursive, then the unary function {{mvar|''g''}} defined by {{math|''g''(''i'') {{=}} S(''ev''(''i'',''i''))}} would also be primitive recursive, as it is defined by composition from the successor function and {{mvar|''ev''}}. But then {{mvar|''g''}} occurs in the enumeration, so there is some number {{mvar|''n''}} such that {{math|''g'' {{=}} ''f''<sub>''n''</sub>}}. But now {{math|''g''(''n'') {{=}} S(''ev''(''n'',''n'')) {{=}} S(''f''<sub>''n''</sub>(''n'')) {{=}} S(''g''(''n''))}} gives a contradiction.}}
Suppose <math>ev</math> were primitive recursive, then the unary function <math>g</math> defined by <math>g(i) = S(ev(i,i))</math> would also be primitive recursive, as it is defined by composition from the successor function and <math>ev</math>. But then <math>g</math> occurs in the enumeration, so there is some number <math>n</math> such that <math>g = f_n</math>. But now <math>g(n) = S(ev(n,n)) = S(f_n(n)) = S(g(n))</math> gives a contradiction.}}


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.
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.
Line 314: Line 278:
===Constant functions===
===Constant functions===
Instead of <math>C_n^k</math>,
Instead of <math>C_n^k</math>,
alternative definitions use just one 0-ary ''zero function'' <math>C_0^0</math> 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{{sfn|Fischer|Fischer|Beigel|1989}} removed the implicit predecessor from the recursion rule, replacing it by the weaker rule
:<math>
\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}
</math>
They proved that the predecessor function still could be defined, and hence that "weak" primitive recursion also defines the primitive recursive functions.


=== Iterative functions ===
=== Iterative functions ===
Weakening this even further by using functions <math>h</math> of arity ''k''+1, removing <math>y</math> and <math>S(y)</math> from the arguments of <math>h</math> completely, we get the ''iteration rule'':
Robinson{{sfn|Robinson|1947}} considered various restrictions of the recursion rule. One is the so-called ''iteration rule'' where the function ''h'' does not have access to the parameters ''x<sub>i</sub>'' (in this case, we may assume without loss of generality that the function ''g'' is just the identity, as the general case can be obtained by substitution):
 
:<math>\begin{align} f(0,x) & = x,\\
<math>\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}</math>
f(S(y),x) & = h(y,f(y,x)). \end{align}</math>
He proved that the class of all primitive recursive functions can still be obtained in this way.


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.{{sfn|Fischer|Fischer|Beigel|1989}}
=== Pure recursion ===
Another restriction considered by Robinson{{sfn|Robinson|1947}} is ''pure recursion'', where ''h'' does not have access to the induction variable ''y'':
:<math>\begin{align} f(0,x_1,\ldots,x_k) & = g(x_1,\ldots,x_k),\\
f(S(y),x_1,\ldots,x_k) & = h(f(y,x_1,\ldots,x_k),x_1,\ldots,x_k). \end{align}</math>
Gladstone{{sfn|Gladstone|1967}} proved that this rule is enough to generate all primitive recursive functions. Gladstone{{sfn|Gladstone|1971}} improved this so that even the combination of these two restrictions, i.e., the ''pure iteration'' rule below, is enough:
:<math>\begin{align} f(0,x) & = x,\\
f(S(y),x) & =  h(f(y,x)). \end{align}</math>
Further improvements are possible: Severin{{sfn|Severin|2008}} prove that even the pure iteration rule ''without parameters'', namely
:<math>\begin{align} f(0) & = 0,\\
f(S(y)) & =  h(f(y)), \end{align}</math>
suffices to generate all [[Unary operation|unary]] primitive recursive functions if we extend the set of initial functions with truncated subtraction ''x ∸ y''. We get ''all'' primitive recursive functions if we additionally include + as an initial function.


=== Additional primitive recursive forms ===
=== Additional primitive recursive forms ===
Line 343: Line 307:
=== Computer language definition ===
=== 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|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 loop|while loop]]s or IF-THEN plus GOTO, are admitted in a primitive recursive language.  
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|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 loop|while loop]]s or IF-THEN plus GOTO, are admitted in a primitive recursive language.


The [[LOOP (programming language)|LOOP language]], introduced in a 1967 paper by [[Biography:Albert R. Meyer|Albert R. Meyer]] and Dennis M. Ritchie,<ref>{{cite conference
The [[LOOP (programming language)|LOOP language]], introduced in a 1967 paper by [[Biography:Albert R. Meyer|Albert R. Meyer]] and Dennis M. Ritchie,<ref>{{citation
| doi=10.1145/800196.806014
| doi=10.1145/800196.806014
| title=The complexity of loop programs
| contribution=The complexity of loop programs
| last1=Meyer
| last1=Meyer
| first1=Albert R.
| first1=Albert R.
| last2=Ritchie
| last2=Ritchie
| first2=Dennis M.
| first2=Dennis M.
| conference=ACM '67: Proceedings of the 1967 22nd national conference
| title=ACM '67: Proceedings of the 1967 22nd national conference
| year=1967
| year=1967
| pages=465–469
| doi-access=free
| doi-access=free
}}</ref> is such a language. Its computing power coincides with the primitive recursive functions. A variant of the LOOP language is [[Biography:Douglas Hofstadter|Douglas Hofstadter]]'s [[BlooP and FlooP|BlooP]] in ''[[Gödel, Escher, Bach]]''. Adding unbounded loops (WHILE, GOTO) makes the language [[General recursive function|general recursive]] and [[Turing completeness|Turing-complete]], as are all real-world computer programming languages.
}}</ref> is such a language. Its computing power coincides with the primitive recursive functions. A variant of the LOOP language is [[Biography:Douglas Hofstadter|Douglas Hofstadter]]'s [[BlooP and FlooP|BlooP]] in ''[[Gödel, Escher, Bach]]''. Adding unbounded loops (WHILE, GOTO) makes the language [[General recursive function|general recursive]] and [[Turing completeness|Turing-complete]], as are all real-world computer programming languages.
Line 370: Line 335:


== History ==
== History ==
[[Recursive definition]]s had been used more or less formally in mathematics before, but the construction of primitive recursion is traced back to [[Biography:Richard Dedekind|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.<ref name="Smith2013">{{cite book|author=Peter Smith|title=An Introduction to Gödel's Theorems|year=2013|publisher=Cambridge University Press|isbn=978-1-107-02284-3|pages=98–99|edition=2nd}}</ref><ref name="Tourlakis2003">{{cite book|author=George Tourlakis|title=Lectures in Logic and Set Theory: Volume 1, Mathematical Logic|year=2003|publisher=Cambridge University Press|isbn=978-1-139-43942-8|page=129}}</ref><ref name="Downey2014">{{cite book|editor=Rod Downey|title=Turing's Legacy: Developments from Turing's Ideas in Logic|year=2014|publisher=Cambridge University Press|isbn=978-1-107-04348-0|page=474}}</ref>
[[Recursive definition]]s had been used more or less formally in mathematics before, but the construction of primitive recursion is traced back to [[Biography:Richard Dedekind|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.<ref name="Smith2013">{{citation|author=Peter Smith|title=An Introduction to Gödel's Theorems|year=2013|publisher=Cambridge University Press|isbn=978-1-107-02284-3|pages=98–99|edition=2nd |url=https://www.logicmatters.net/igt/}}</ref><ref name="Tourlakis2003">{{citation|author=George Tourlakis|title=Lectures in Logic and Set Theory: Volume 1, Mathematical Logic|year=2003|publisher=Cambridge University Press|isbn=978-1-139-43942-8|page=129}}</ref><ref name="Downey2014">{{citation|editor=Rod Downey|title=Turing's Legacy: Developments from Turing's Ideas in Logic|year=2014|publisher=Cambridge University Press|isbn=978-1-107-04348-0|page=474}}</ref>


[[Primitive recursive arithmetic]]  was first proposed by [[Biography:Thoralf Skolem|Thoralf Skolem]]<ref>[[Biography:Thoralf Skolem|Thoralf Skolem]] (1923) "The foundations of elementary arithmetic" in [[Biography:Jean van Heijenoort|Jean van Heijenoort]], translator and ed. (1967) ''From Frege to Gödel: A Source Book in Mathematical Logic, 1879-1931''. Harvard Univ. Press: 302-33.</ref> in 1923.
[[Primitive recursive arithmetic]]  was first proposed by [[Biography:Thoralf Skolem|Thoralf Skolem]]<ref>[[Biography:Thoralf Skolem|Thoralf Skolem]] (1923) "The foundations of elementary arithmetic" in [[Biography:Jean van Heijenoort|Jean van Heijenoort]], translator and ed. (1967) ''From Frege to Gödel: A Source Book in Mathematical Logic, 1879-1931''. Harvard Univ. Press: 302-33.</ref> in 1923.
Line 389: Line 354:


== References ==
== References ==
* Brainerd, W.S., Landweber, L.H. (1974), ''Theory of Computation'', Wiley, {{isbn|0-471-09585-0}}
 
* {{cite journal | last1=Fischer | first1=Michael J. | last2=Fischer | first2=Robert P. | last3=Beigel | first3=Richard | title=Primitive Recursion without Implicit Predecessor | journal=[[ACM SIGACT|ACM SIGACT News]] | date=November 1989 | volume=20| issue=4| pages=87–91 | url=https://doi.org/10.1145/74074.74089 | doi=10.1145/74074.74089| s2cid=33850327 }}
*{{cite book
* Robert I. Soare, ''Recursively Enumerable Sets and Degrees'', Springer-Verlag, 1987.  {{isbn|0-387-15299-7}}
| last1 = Boolos
* 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
| first1 = George
* [[Biography:George Boolos|George Boolos]], John Burgess, [[Biography:Richard Jeffrey|Richard Jeffrey]] (2002), ''Computability and Logic: Fourth Edition'', Cambridge University Press, Cambridge, UK. Cf pp.&nbsp;70–71.
| last2 = Burgess
* Robert I. Soare 1995 ''Computability and Recursion'' http://www.people.cs.uchicago.edu/~soare/History/compute.pdf
| first2 = John
* Daniel Severin 2008, ''Unary primitive recursive functions'', J. Symbolic Logic Volume 73, Issue 4, pp.&nbsp;1122–1138 [https://arxiv.org/abs/cs/0603063v3 arXiv] [https://projecteuclid.org/euclid.jsl/1230396909 projecteuclid] {{doi|10.2178/jsl/1230396909}} {{JSTOR|275903221}}
| last3 = Jeffrey
| first3 = Richard C.
| title = Computability and Logic
| publisher = Cambridge University Press
| edition = 4th
| date = 2002
| isbn = 9780521007580
}}
 
*{{cite book
| last1 = Brainerd
| first1 = W.S.
| last2 = Landweber
| first2 = L.H.
| year = 1974
| title = Theory of Computation
| publisher = Wiley
| isbn = 0471095850
}}
 
*{{cite journal
|last1= Fachini
|first1= Emanuela
|last2= Maggiolo-Schettini
|first2= Andrea
|year= 1979
|title= A hierarchy of primitive recursive sequence functions
|journal= R.A.I.R.O. - Informatique Théorique - Theoretical Informatics
|volume= 13
|issue= 1
|pages= 49–67
|doi= 10.1051/ita/1979130100491
|doi-access= free
|url=https://www.rairo-ita.org/articles/ita/pdf/1979/01/ita1979130100491.pdf
}}
 
*{{cite journal
|last1= Fachini
|first1= Emanuela
|last2= Maggiolo-Schettini
|first2= Andrea
|year= 1982
|title= Comparing Hierarchies of Primitive Recursive Sequence Functions
|journal= Zeitschrift für mathematische Logik und Grundlagen der Mathematik
|volume= 28
|issue= 27-32
|pages= 431–445
|doi= 10.1002/malq.19820282705
}}
 
*{{cite journal
| last = Gladstone
| first = M. D.
| doi = 10.2307/2270177
| journal = The Journal of Symbolic Logic
| mr = 224460
| pages = 505–508
| title = A reduction of the recursion scheme
| volume = 32
| year = 1967
| issue = 4
| jstor = 2270177
}}
 
*{{cite journal
| last = Gladstone
| first = M. D.
| doi = 10.2307/2272468
| journal = The Journal of Symbolic Logic
| mr = 305993
| pages = 653–665
| title = Simplifications of the recursion scheme
| volume = 36
| year = 1971
  | issue = 4
| jstor = 2272468
}}
 
*{{cite book
| last = Hartmanis
| first = Juris
| year = 1989
| chapter = Overview of Computational Complexity Theory
| title = Computational Complexity Theory
| publisher = American Mathematical Society
| pages = 1–17
| isbn = 978-0-8218-0131-4
| series = Proceedings of Symposia in Applied Mathematics
| volume = 38
| mr = 1020807
}}
 
*{{cite book
| last = Kleene
| first = Stephen Cole
| year = 1974
| orig-year = 1952
| title = Introduction to Metamathematics
| chapter = Chapter XI. General Recursive Functions §57
| edition = 7th reprint; 2nd
| publisher = North-Holland Publishing Company
| oclc = 3757798
| isbn = 0444100881
}}
 
*{{cite web
| author = PlanetMath
| title = primitive recursive vector-valued function
| url = https://planetmath.org/primitiverecursivevectorvaluedfunction
| access-date = 2025-07-04
}}
 
*{{cite book
| last = Rogers
| first = Hartley Jr.
| title = Theory of Recursive Functions and Effective Computability
| publisher = MIT Press
| year = 1987
| orig-year = 1967
| edition = Reprint
| isbn = 9780262680523
}}
 
*{{cite journal
| last = Robinson
| first = Raphael M.
| doi = 10.1090/S0002-9904-1947-08911-4
| journal = [[Organization:Bulletin of the American Mathematical Society|Bulletin of the American Mathematical Society]]
| mr = 22536
| pages = 925–942
| title = Primitive recursive functions
| volume = 53
| year = 1947
| issue = 10
| doi-access = free
}}
 
*{{cite journal
| last = Severin
| first = Daniel E.
| arxiv = cs/0603063
| doi = 10.2178/jsl/1230396909
| issue = 4
| journal = The Journal of Symbolic Logic
| jstor = 275903221
| mr = 2467207
| pages = 1122–1138
| title = Unary primitive recursive functions
| volume = 73
| year = 2008
}}
 
*{{cite book
| last = Soare
| first = Robert I.
| isbn = 0-387-15299-7
| title = Recursively Enumerable Sets and Degrees
| publisher = Springer-Verlag
| year = 1987
}}
 
*{{cite journal
| last = Soare
| first = Robert I.
| doi = 10.2307/420992
| volume = 2
| issue = 3
| journal = The Bulletin of Symbolic Logic
| mr = 1416870
| pages = 284–321
| title = Computability and recursion
| url = https://scholar.archive.org/work/ruvjr6nkyre4nfxjdme2refpwe
| year = 1996
| jstor = 420992
}}


{{Mathematical logic}}
{{Mathematical logic}}

Latest revision as of 07:16, 13 March 2026

Short description: Function computable with bounded loops

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.[1] 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.[2] 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:

  1. Constant functions Cnk: For each natural number n and every k, the k-ary constant function, defined by Cnk(x1,,xk) =def n, is primitive recursive.
  2. Successor function: The 1-ary successor function S, which returns the successor of its argument (see Peano postulates), that is, S(x) =def x+1, is primitive recursive.
  3. Projection functions Pik: For all natural numbers i,k such that 1ik, the k-ary function defined by Pik(x1,,xk) =def xi is primitive recursive.

More complex primitive recursive functions can be obtained by applying the operations given by these axioms:

  1. Composition operator (also called the substitution operator): Given an m-ary function h(x1,,xm) and m k-ary functions g1(x1,,xk),,gm(x1,,xk): h(g1,,gm) =def f,wheref(x1,,xk)=h(g1(x1,,xk),,gm(x1,,xk)). For m=1, the ordinary function composition hg1 is obtained.
  2. Primitive recursion operator ρ: Given the k-ary function g(x1,,xk) and the (k+2)-ary function h(y,z,x1,,xk):
    ρ(g,h) =def f,where the (k+1)-ary function f is defined byf(y,x1,,xk)={g(x1,,xk)if y=0,h(y,f(y,x1,,xk),x1,,xk)if y=S(y) for a y.

    Interpretation:

    The function f acts as a for-loop from 0 up to the value of its first argument. The rest of the arguments for f, denoted here with x1,,xk, are a set of initial conditions for the for-loop which may be used by it during calculations but which are immutable by it. The functions g and h on the right-hand side of the equations that define f represent the body of the loop, which performs calculations. The function g is used only once to perform initial calculations. Calculations for subsequent steps of the loop are performed by h. The first parameter of h is fed the "current" value of the for-loop's index. The second parameter of h is fed the result of the for-loop's previous calculations, from previous steps. The rest of the parameters for h are those immutable initial conditions for the for-loop mentioned earlier. They may be used by h to perform calculations but they will not themselves be altered by h.

The primitive recursive functions are the basic functions and those obtained from the basic functions by applying these operations a finite number of times.

Primitive-recursiveness of vector-valued functions

A (vector-valued) function[5] f:mn is primitive recursive if it can be written as

f(x1,,xm)=(f1(x1,,xm),,fn(x1,,xm))

where each component fi:m is a (scalar-valued) primitive recursive function.[6]

Examples

  • C01 is a 1-ary function which returns 0 for every input: C01(x)=0.
  • C11 is a 1-ary function which returns 1 for every input: C11(x)=1.
  • C30 is a 0-ary function, i.e. a constant: C30=3.
  • P11 is the identity function on the natural numbers: P11(x)=x.
  • P12 and P22 is the left and right projection on natural number pairs, respectively: P12(x,y)=x and P22(x,y)=y.
  • SS is a 1-ary function that adds 2 to its input, (SS)(x)=x+2.

Addition

A definition of the 2-ary function Add, to compute the sum of its arguments, can be obtained using the primitive recursion operator ρ. To this end, the well-known equations

0+y=y,S(x)+y=S(x+y)

are "rephrased in primitive recursive function terminology": In the definition of ρ(g,h), the first equation suggests to choose g=P11 to obtain Add(0,y)=g(y)=y; the second equation suggests to choose h=SP23 to obtain Add(S(x),y)=h(x,Add(x,y),y)=(SP23)(x,Add(x,y),y)=S(Add(x,y)). Therefore, the addition function can be defined as Add=ρ(P11,SP23). As a computation example,

Add(1,7)=ρ(P11,SP23)(S(0),7) by Def. Add,S=(SP23)(0,Add(0,7),7) by case ρ(g,h)(S(...),...)=S(Add(0,7)) by Def. ,P23=S(ρ(P11,SP23)(0,7)) by Def. Add=S(P11(7)) by case ρ(g,h)(0,...)=S(7) by Def. P11=8 by Def. S.

Doubling

Given Add, the 1-ary function Add(P11,P11) doubles its argument, (Add(P11,P11))(x)=Add(x,x)=x+x.

Multiplication

In a similar way as addition, multiplication can be defined by Mul=ρ(C01,Add(P23,P33)). This reproduces the well-known multiplication equations:

Mul(0,y)=ρ(C01,Add(P23,P33))(0,y) by Def. Mul=C01(y) by case ρ(g,h)(0,...)=0 by Def. C01.

and

Mul(S(x),y)=ρ(C01,Add(P23,P33))(S(x),y) by Def. Mul=(Add(P23,P33))(x,Mul(x,y),y) by case ρ(g,h)(S(...),...)=Add(Mul(x,y),y) by Def. ,P23,P33=Mul(x,y)+y by property of Add.

Predecessor

The predecessor function acts as the "opposite" of the successor function and is recursively defined by the rules Pred(0)=0 and Pred(S(n))=n. A primitive recursive definition is Pred=ρ(C00,P12). As a computation example,

Pred(8)=ρ(C00,P12)(S(7)) by Def. Pred,S=P12(7,Pred(7)) by case ρ(g,h)(S(...),...)=7 by Def. P12.

Truncated subtraction

The limited subtraction function (also called "monus", and denoted "˙") is definable from the predecessor function. It satisfies the equations

y˙0=y,y˙S(x)=Pred(y˙x).

Since the recursion runs over the second argument, we begin with a primitive recursive definition of the reversed subtraction, RSub(y,x)=x˙y. Its recursion then runs over the first argument, so its primitive recursive definition can be obtained, similar to addition, as RSub=ρ(P11,PredP23). To get rid of the reversed argument order, then define Sub=RSub(P22,P12). As a computation example,

Sub(8,1)=(RSub(P22,P12))(8,1) by Def. Sub=RSub(1,8) by Def. ,P22,P12=ρ(P11,PredP23)(S(0),8) by Def. RSub,S=(PredP23)(0,RSub(0,8),8) by case ρ(g,h)(S(...),...)=Pred(RSub(0,8)) by Def. ,P23=Pred(ρ(P11,PredP23)(0,8)) by Def. RSub=Pred(P11(8)) by case ρ(g,h)(0,...)=Pred(8) by Def. P11=7 by property of Pred.

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 for true, and f for false), or that produce truth values as outputs.[7] 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 with the number 1, and the truth value f with the number 0. Once this identification has been made, the characteristic function of a set A, which always returns 1 or 0, can be viewed as a predicate that tells whether a number is in the set 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 IsZero shall be defined such that IsZero(x)=1 if x=0, and IsZero(x)=0 otherwise. This can be achieved by defining IsZero=ρ(C10,C02). Then IsZero(0)=ρ(C10,C02)(0)=C10()=1, and e.g. IsZero(8)=ρ(C10,C02)(S(7))=C02(7,IsZero(7))=0.

Predicate "Less or equal"

Using the property xyx˙y=0, the 2-ary function Leq can be defined by Leq=IsZeroSub. Then Leq(x,y)=1 if xy, and Leq(x,y)=0 otherwise. As a computation example,

Leq(8,3)=IsZero(Sub(8,3)) by Def. Leq=IsZero(5) by property of Sub=0 by property of IsZero

Predicate "Greater or equal"

Once a definition of Leq is obtained, the converse predicate can be defined as Geq=Leq(P22,P12). Then, Geq(x,y)=Leq(y,x) is true (more precisely: has value 1) if and only if xy.

If-then-else

The 3-ary if-then-else operator known from programming languages can be defined by If=ρ(P22,P34). Then, for arbitrary x,

If(S(x),y,z)=ρ(P22,P34)(S(x),y,z) by Def. If=P34(x,If(x,y,z),y,z) by case ρ(S(...),...)=y by Def. P34

and

If(0,y,z)=ρ(P22,P34)(0,y,z) by Def. If=P22(y,z) by case ρ(0,...)=z by Def. P22.

That is, If(x,y,z) returns the then-part (y) if the if-part (x) is true, and the else-part (z) otherwise.

Junctors

Based on the If function, it is easy to define logical junctors. For example, defining And=If(P12,P22,C02), one obtains And(x,y)=If(x,y,0), that is, And(x,y) is true if and only if both x and y are true (logical conjunction of x and y).

Similarly, Or=If(P12,C12,P22) and Not=If(P11,C01,C11) lead to appropriate definitions of disjunction and negation: Or(x,y)=If(x,1,y) and Not(x)=If(x,0,1).

Equality predicate

Using the above functions Leq, Geq and And, the definition Eq=And(Leq,Geq) implements the equality predicate. In fact, Eq(x,y)=And(Leq(x,y),Geq(x,y)) is true if and only if x equals y.

Similarly, the definition Lt=NotGeq implements the predicate "less-than", and Gt=NotLeq implements "greater-than".

Other operations on natural numbers

Exponentiation and primality testing are primitive recursive. Given primitive recursive functions e, f, g, and h, a function that returns the value of g when ef and the value of 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 1974, pp. 222–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.

  1. Addition: a+b
  2. Multiplication: a×b
  3. Exponentiation: ab
  4. Factorial a! : 0! = 1, a'! = a!×a'
  5. pred(a): (Predecessor or decrement): If a > 0 then a−1 else 0
  6. Proper subtraction a ∸ b: If a ≥ b then a−b else 0
  7. Minimum(a1, ... an)
  8. Maximum(a1, ... an)
  9. Absolute difference: | a−b | =def (a ∸ b) + (b ∸ a)
  10. ~sg(a): NOT[signum(a)]: If a=0 then 1 else 0
  11. sg(a): signum(a): If a=0 then 0 else 1
  12. a | b: (a divides b): If b=k×a for some k then 0 else 1
  13. Remainder(a, b): the leftover if b does not divide a "evenly". Also called MOD(a, b)
  14. 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)
  15. a < b: sg( a' ∸ b )
  16. Pr(a): a is a prime number Pr(a) =def a>1 & NOT(Exists c)1<c<a [ c|a ]
  17. pi: the i+1th prime number
  18. (a)i: exponent of pi in a: the unique x such that pix|a & NOT(pix'|a)
  19. lh(a): the "length" or number of non-vanishing exponents in a
  20. 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<z ψ(x, y) and product Πy<zψ(x, y) are primitive recursive in ψ.
  • #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<z R(x, y) where (Ey)y<z denotes "there exists at least one y that is less than z such that"
  • (y)y<z R(x, y) where (y)y<z denotes "for all y less than z it is true that"
  • μyy<z R(x, y). The operator μyy<z R(x, y) is a bounded form of the so-called minimization- or mu-operator: Defined as "the least value of y less than z such that R(x, y) is true; or z if there is no such value."
  • #F: Definition by cases: The function defined thus, where Q1, ..., Qm are mutually exclusive predicates (or "ψ(x) shall have the value given by the first clause that applies), is primitive recursive in φ1, ..., Q1, ... Qm:
φ(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 which has at most one value for each argument, but which may fail to have a value at some arguments (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.[8]

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 recursive function f(m,n) that enumerates the primitive recursive functions, namely:

  • For every unary 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.
  • Primitive recursive functions with two or more arguments can be encoded as unary primitive recursive functions by using a primitive recursive pairing function with two primitive recursive inverses.

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:

The primitive recursive functions of one argument (i.e., unary functions) can be computably enumerated. This enumeration uses the definitions of the primitive recursive functions (which are essentially just expressions with the composition and primitive recursion operations as operators and the basic primitive recursive functions as atoms), and can be assumed to contain every definition once, even though a same function will occur many times on the list (since many definitions define the same function; indeed simply composing by the identity function generates infinitely many definitions of any one primitive recursive function). This means that the n-th definition of a primitive recursive function in this enumeration can be effectively determined from n. Indeed if one uses some Gödel numbering to encode definitions as numbers, then this n-th definition in the list is computed by a primitive recursive function of n. Let fn denote the unary primitive recursive function given by this definition.

Now define the "evaluator function" ev with two arguments, by ev(i,j)=fi(j). Clearly ev is total and computable, since one can effectively determine the definition of fi, and being a primitive recursive function fi is itself total and computable, so fi(j) is always defined and effectively computable. However a diagonal argument will show that the function ev of two arguments is not primitive recursive.

Suppose ev were primitive recursive, then the unary function g defined by g(i)=S(ev(i,i)) would also be primitive recursive, as it is defined by composition from the successor function and ev. But then g occurs in the enumeration, so there is some number n such that g=fn. But now g(n)=S(ev(n,n))=S(fn(n))=S(g(n)) gives a contradiction.

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 Cnk,

Iterative functions

Robinson[9] considered various restrictions of the recursion rule. One is the so-called iteration rule where the function h does not have access to the parameters xi (in this case, we may assume without loss of generality that the function g is just the identity, as the general case can be obtained by substitution):

f(0,x)=x,f(S(y),x)=h(y,f(y,x)).

He proved that the class of all primitive recursive functions can still be obtained in this way.

Pure recursion

Another restriction considered by Robinson[9] is pure recursion, where h does not have access to the induction variable y:

f(0,x1,,xk)=g(x1,,xk),f(S(y),x1,,xk)=h(f(y,x1,,xk),x1,,xk).

Gladstone[10] proved that this rule is enough to generate all primitive recursive functions. Gladstone[11] improved this so that even the combination of these two restrictions, i.e., the pure iteration rule below, is enough:

f(0,x)=x,f(S(y),x)=h(f(y,x)).

Further improvements are possible: Severin[12] prove that even the pure iteration rule without parameters, namely

f(0)=0,f(S(y))=h(f(y)),

suffices to generate all unary primitive recursive functions if we extend the set of initial functions with truncated subtraction x ∸ y. We get all primitive recursive functions if we additionally include + as an initial function.

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,[13] 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.[14][15][16]

Primitive recursive arithmetic was first proposed by Thoralf Skolem[17] 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.[15][16]

See also

Notes

  1. Brainerd & Landweber 1974.
  2. Hartmanis 1989.
  3. Fachini & Maggiolo-Schettini 1979.
  4. Fachini & Maggiolo-Schettini 1982.
  5. Also known as "sequence function".[3][4]
  6. (PlanetMath {{{2}}}).
  7. Kleene 1974, pp. 226–227.
  8. This follows from the facts that the functions of this form are the most quickly growing primitive recursive functions, and that a function is primitive recursive if and only if its time complexity is bounded by a primitive recursive function. For the former, see Linz, Peter (2011), An Introduction to Formal Languages and Automata, Jones & Bartlett Publishers, p. 332, ISBN 9781449615529, https://books.google.com/books?id=hsxDiWvVdBcC&pg=PA332 . For the latter, see Moore, Cristopher; Mertens, Stephan (2011), The Nature of Computation, Oxford University Press, p. 287, ISBN 9780191620805, https://books.google.com/books?id=jnGKbpMV8xoC&pg=PA287 
  9. 9.0 9.1 Robinson 1947.
  10. Gladstone 1967.
  11. Gladstone 1971.
  12. Severin 2008.
  13. Meyer, Albert R.; Ritchie, Dennis M. (1967), "The complexity of loop programs", ACM '67: Proceedings of the 1967 22nd national conference, pp. 465–469, doi:10.1145/800196.806014 
  14. Peter Smith (2013), An Introduction to Gödel's Theorems (2nd ed.), Cambridge University Press, pp. 98–99, ISBN 978-1-107-02284-3, https://www.logicmatters.net/igt/ 
  15. 15.0 15.1 George Tourlakis (2003), Lectures in Logic and Set Theory: Volume 1, Mathematical Logic, Cambridge University Press, p. 129, ISBN 978-1-139-43942-8 
  16. 16.0 16.1 Rod Downey, ed. (2014), Turing's Legacy: Developments from Turing's Ideas in Logic, Cambridge University Press, p. 474, ISBN 978-1-107-04348-0 
  17. Thoralf Skolem (1923) "The foundations of elementary arithmetic" in Jean van Heijenoort, translator and ed. (1967) From Frege to Gödel: A Source Book in Mathematical Logic, 1879-1931. Harvard Univ. Press: 302-33.

References

  • Boolos, George; Burgess, John; Jeffrey, Richard C. (2002). Computability and Logic (4th ed.). Cambridge University Press. ISBN 9780521007580. 
  • Brainerd, W.S.; Landweber, L.H. (1974). Theory of Computation. Wiley. ISBN 0471095850. 
  • Fachini, Emanuela; Maggiolo-Schettini, Andrea (1982). "Comparing Hierarchies of Primitive Recursive Sequence Functions". Zeitschrift für mathematische Logik und Grundlagen der Mathematik 28 (27-32): 431–445. doi:10.1002/malq.19820282705. 
  • Gladstone, M. D. (1967). "A reduction of the recursion scheme". The Journal of Symbolic Logic 32 (4): 505–508. doi:10.2307/2270177. 
  • Gladstone, M. D. (1971). "Simplifications of the recursion scheme". The Journal of Symbolic Logic 36 (4): 653–665. doi:10.2307/2272468. 
  • Hartmanis, Juris (1989). "Overview of Computational Complexity Theory". Computational Complexity Theory. Proceedings of Symposia in Applied Mathematics. 38. American Mathematical Society. pp. 1–17. ISBN 978-0-8218-0131-4. 
  • Kleene, Stephen Cole (1974). "Chapter XI. General Recursive Functions §57". Introduction to Metamathematics (7th reprint; 2nd ed.). North-Holland Publishing Company. ISBN 0444100881. OCLC 3757798. 
  • Rogers, Hartley Jr. (1987). Theory of Recursive Functions and Effective Computability (Reprint ed.). MIT Press. ISBN 9780262680523. 
  • Severin, Daniel E. (2008). "Unary primitive recursive functions". The Journal of Symbolic Logic 73 (4): 1122–1138. doi:10.2178/jsl/1230396909. 
  • Soare, Robert I. (1987). Recursively Enumerable Sets and Degrees. Springer-Verlag. ISBN 0-387-15299-7.