Skip to main content

Recursive Functions

This file was updated on 28th Oct, 2024, and it's not finished.

Intuitively, the notion of an effective computable function ff from natural numbers to natural numbers is the notion of a function for which there is a finite list of instructions that in principle make it possible to determine the value f(x1,,xn)f(x_1, \dots, x_n) for any arguments x1,,xnx_1, \dots, x_n.

We adopt the system in which the number zero id represented by the cipher 00, and a natural number n>0n > 0 is represented by the cipher 00 followed by a sequence of nn little raised strokes or accents. Thus the numeral for one is 00', the numeral for two is 00'', and so on.

3 Basic Functions

Zero Function

For any argument xx, z(x)=0z(x) = 0.

z(0)=0,z(0)=0,z(0)=0,z(0) = 0, z(0') = 0, z(0'') = 0, \dots

Successor Function

s(0)=0,s(0)=0,s(0)=0,s(0) = 0', s(0') = 0'', s(0'') = 0''', \dots

Identity Function / Projection Function

For each positive integer nn, there are nn identity functions of nn arguments, which pick out the first, second, \dots, and nn-th of the arguments:

idin(x1,,xi,,xn)=xi.\text{id}^n_i(x_1, \dots, x_i, \dots, x_n) = x_i.

Operations

Composition / Substitution

If ff is a function of mm arguments and each of g1,,gmg_1, \dots, g_m is a function of nn arguments, then the function obtained by composition from f,g1,,gmf, g_1, \dots, g_m is the function hh where we have

Cn: h(x1,,xn)=f(g1(x1,,xn),,gm(x1,,xn)).\text{Cn: }h(x_1, \dots, x_n) = f \left( g_1(x_1, \dots, x_n), \dots, g_m(x_1, \dots, x_n) \right).

This expression can also be written as

h=Cn[f,g1,,gm].h = \text{Cn} \left[ f, g_1, \dots, g_m \right].

Addition

x+0=x,  x+y=(x+y).x + 0 = x, \; x + y' = (x + y)'.

Multiplication

x0=0,  xy=x+(xy).x \cdot 0 = 0, \; x \cdot y' = x + (x \cdot y).

Exponentiation

x0=0,  xy=xxy.x^0 = 0', \; x^{y'} = x \cdot x^y.

Super-Exponentiation

xxxx  (a stack of y  xs)xxxxx  (a row of y  xs)xy.x^{x^{x^{x^{\cdot^{\cdot^{\cdot}}}}}} \; (\text{a stack of } y \; x \text{s}) \equiv x \uparrow x \uparrow x \uparrow x \uparrow \dots \uparrow x \; (\text{a row of } y \; x \text{s}) \equiv x \Uparrow y. x0=0,  xy=x(xy).x \Uparrow 0 = 0', \; x \Uparrow y' = x \uparrow (x \Uparrow y).

Other Functions

Constant Function

For any natural number nn, let the constant function constn\text{const}_n be defined by constn(x)=n\text{const}_n (x) = n for all xx.

const0(x)=0=z(x).\text{const}_0 (x) = 0 = z(x). constn(x)=n=s(constn1(x))=Cn[s,constn1](x),n1.\text{const}_n (x) = n = s(\text{const}_{n-1} (x)) = \text{Cn} [s, \text{const}_{n-1}] (x), n \geq 1.

Sum Function

sum(x,0)=x,  sum(x,y)=sum(x,y).\text{sum} (x, 0) = x, \; \text{sum} (x, y') = \text{sum} (x, y)'.

Product Function

prod(x,0)=z(x),  prod(x,y)=x+prod(x,y).\text{prod} (x, 0) = z(x), \; \text{prod} (x, y') = x + \text{prod} (x, y).

Factorial Function

The factorial x!x! for positive xx is the product 1×2×3××x1 \times 2 \times 3 \times \cdots \times x of all positive integers up to and including xx, and by convention 0!=10! = 1.

0!=1,  y!=y!y.0! = 1, \; y'! = y! \cdot y'.

Primitive Recursion

Pr: h(x,0)=f(x),  h(x,y)=g(x,y,h(x,y)).Pr: h(x1,,xn,0)=f(x1,,xn),  h(x1,,xn,y)=g(x1,,xn,y,h(x1,,xn,y)).\text{Pr: } \underline{h(x, 0) = f(x), \; h(x, y') = g(x, y, h(x, y))}. \\ \cdots \\ \text{Pr: } \underline{h(x_1, \dots, x_n, 0) = f(x_1, \dots, x_n), \; h(x_1, \dots, x_n, y') = g(x_1, \dots, x_n, y, h(x_1, \dots, x_n, y))}.

Where the underlined equations — called the recursion equations for the function hh — hold, hh is said to be definable by (primitive) recursion from the functions ff and gg. In shorthand,

h=Pr[f,g].h = \text{Pr} [f, g].

Example 1 sum=Pr[id11,Cn[s,id33]].\text{sum} = \text{Pr} \left[ \text{id}^1_1, \text{Cn} \left[s, \text{id}^3_3\right] \right].

sum(x,0)=x=id11(x)=f(x).\text{sum} (x, 0) = x = \text{id}^1_1 (x) = f(x). sum(x,y)=sum(x,y)sum(x,s(y))=s(sum(x,y)).\text{sum} (x, y') = \text{sum} (x, y)' \Rightarrow \text{sum} (x, s(y)) = s(\text{sum} (x, y)). sum(x,s(y))=s(sum(x,y))=Cn[s,id33](x,y,sum(x,y))=g(x,y,sum(x,y)).\begin{array}{rll} \text{sum} (x, s(y)) & = & s(\text{sum} (x, y)) \\ & = & \text{Cn} [s, \text{id}^3_3] (x, y, \text{sum} (x, y)) \\ & = & g(x, y, \text{sum} (x, y)). \end{array}

Example 2 prod=Pr[z,Cn[sum,id13,id33]].\text{prod} = \text{Pr} [z, \text{Cn} [\text{sum}, \text{id}^3_1, \text{id}^3_3]].

h(x,0)=0=z(x)f=z.h(x, 0) = 0 = z(x) \Rightarrow f = z.

We know prod(x,y)=x+prod(x,y)\text{prod} (x, y') = x + \text{prod} (x, y), so

h(x,y)=g(x,y,h(x,y))=id13(x,y,h(x,y))+id33(x,y,h(x,y))=sum(id13(x,y,h(x,y)),id33(x,y,h(x,y)))=Cn[sum,id13,id33](x,y,h(x,y)).\begin{array}{rll} h(x, y') & = & g(x, y, h(x, y)) \\ & = & \text{id}^3_1 (x, y, h(x, y)) + \text{id}^3_3 (x, y, h(x, y)) \\ & = & \text{sum} (\text{id}^3_1 (x, y, h(x, y)), \text{id}^3_3 (x, y, h(x, y))) \\ & = & \text{Cn} [\text{sum}, \text{id}^3_1, \text{id}^3_3] (x, y, h(x, y)). \end{array}

That is

Cn[sum,id13,id33]=g.\text{Cn} [\text{sum}, \text{id}^3_1, \text{id}^3_3] = g.