course-of-values recursion

In defining a function by primitive recursion, the value of the next argument f(n+1) depends only on the value of the current argument f(n). Definition of functions by course-of-values recursion, f(n+1) depends on value(s) of some or all of the preceding arguments f(n),,f(0). Two very basic examples of definition by course-of-values recursion are

  1. 1.

    (Fibonacci numbersMathworldPlanetmath). F(0)=F(1)=1, and F(n+1)=F(n)+F(n-1).

  2. 2.

    f(0)=1, and f(n+1)=f(n)+f(n-1)++f(0).

In the first example, we may write F(n+1)=g(F(n),F(n-1)), where g is the familiar additionPlanetmathPlanetmath function, a function of two arguments. In other words, value of the current argument of F depends on the values of a fixed number of preceding arguments (in this case, 2). In the second example, value of the current argument of f depends on the values of all of the values of the preceding arguments. Suppose we write f(n+1)=h(f(n),,f(0)), where h is the (n+1)-ary addition function. This h is different from g in the sense that g has a fixed arity, whereas the arity of h depends on the argument of f. In other words, as n varies, a “different” h is required! Is it possible to define f via a fixed function as in the first example? Moreover, what is the relationMathworldPlanetmath between course-of-values recursion and primitive recursion?

The answer to the first question is yes. To get around the difficulty of “varying arity”, we employ the technique of encoding the entire sequenceMathworldPlanetmath of values of the preceding arguments of f by a “code number”, and come up with a function h that depends on the this code number. h then can be used to define f.

Pick an encoding of finite sequences of non-negative integers, preferably a primitive recursive encoding. As usual, we set


as the code, or sequence number of the sequence a1,,am, and if x=a1,,am, we set (x)i:=ai if im, and 0 otherwise.

For this entry, we choose the multiplicative encoding of Gödel (see this entry ( for more detail) because of its convenience. Then


where pi is the i-th prime numberMathworldPlanetmath, and :=1.

Definition. For any function f:k+1, define the course-of-values function f¯ of f as follows: f¯ has the same arity as f, and for any 𝒙k,

  1. 1.

    f¯(𝒙,0):=, and

  2. 2.


For example, if F(n) is the n-th Fibonacci number, then F¯(0)=1, F¯(1)=1=4, and F¯(2)=4,1=2532=288, etc… It is evident that F¯ grows very rapidly.

Definition. A function f:k+1 is said to be defined by course-of-values recursion via function h:k+2 if, for any 𝒙k:


The two examples above are defined by course-of-values recursion:

  • F(n)=h(n,F¯(n)), where h(x,y):=(y)x+(y)x-˙1.

  • f(n)=h(n,f¯(n)), where h(x,y)=i=0x-˙1(y)i.

The second question posed at the beginning can now be answered:

Proposition 1.

f is primitive recursive iff f¯ is.


By definition, and using multiplicative encoding, we have f¯(𝒙,0):==1, and


Thus, if f is primitive recursive, so is f¯ by primitive recursion. Conversely, if f¯ is primitive recursive, so is f(𝒙,y)=(f¯(𝒙,y+1))y+1. ∎

Proposition 2.

If h:Nk+1N is primitive recursive, so is f defined by course-of-values recursion via h.


From the proof of the propositionPlanetmathPlanetmath above, we see that


Thus, as h is primitive recursive, so is f¯ by primitive recursion, and hence f is primitive recursive by the previous proposition. ∎

Remark. If the value of the next argument of f depends on values of a fixed set of prior arguments, then the primitive recursiveness of f can be proved via mutual recursion. For example, suppose f(k+1)=h(f(k-1),f(k-3),f(k-4)). By setting fi(n):=f(n+i) for i=0,1,2,3, we see that

fi(n+1)=f(n+i+1)=fi+1(n)for i=0,1,2.


f3(n+1) = f0(n+4)=f(n+4)=h(f(n+2),f(n+1),f(n))
= h(f0(n+2),f0(n+1),f0(n))=h(f2(n),f1(n),f0(n)).

So the fi are defined by mutual recursion, and if h is primitive recursive, so is each fi.

Title course-of-values recursion
Canonical name CourseofvaluesRecursion
Date of creation 2013-03-22 19:06:13
Last modified on 2013-03-22 19:06:13
Owner CWoo (3771)
Last modified by CWoo (3771)
Numerical id 11
Author CWoo (3771)
Entry type Definition
Classification msc 03D20
Synonym course-of-value
Synonym course-of-values