Lably
Skip to content

Primitive recursive function

Function computable with bounded loops

  • 17 min read
  • 7 chapters

Related on Lably

Through Computer program, Control flow and Loop (statement)

The importance of primitive recursive functions lies in the fact that most computable functions that are studied in number theory (and more generally in mathematics) are primitive recursive. For example, addition and division, the factorial and exponential function, and the function which returns the nth prime are all primitive recursive. In fact, for showing that a computable function is primitive recursive, it suffices to show that its time complexity is bounded above by a primitive recursive function of the input size. It is hence not particularly easy to devise a computable function that is not primitive recursive; some examples are shown in section § Limitations below.

The set of primitive recursive functions is known as PR in computational complexity theory.

Definition

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

The basic primitive recursive functions are given by these axioms:

  1. Constant functions Cnk: For each natural number n and every k, the k-ary constant function, defined by Cnk(x1,…,xk)=defn, 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)=defx+1, is primitive recursive.
  3. Projection functions Pik: For all natural numbers i,k such that 1≤i≤k, the k-ary function defined by Pik(x1,…,xk)=defxi 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)=deff,wheref(x1,…,xk)=h(g1(x1,…,xk),…,gm(x1,…,xk)). For m=1, the ordinary function composition h∘g1 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)=deff,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′∈N.

    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 f:Nm→Nn is primitive recursive if it can be written as

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

where each component fi:Nm→N is a (scalar-valued) primitive recursive function.

Sign in to keep reading

6 more chapters are free with a Lably account.

More in Foundations