Course-by-values recursion

125 Views Asked by At

I have many questions in my textbook of the kind:

Assume $g$ is primitive recursive and assume

$f(0)=c_0,\dots,f(n-1)=c_{n-1}$

$f(x+n)=g(<f(x),\dots,f(x+n-1)>)$

Prove that $f$ is primitive recursive.

For instance:

$g(0)=2,\quad g(1)=4$

$g(x+2)=3g(x+1)\dot - (2g(x)+1)$

Can I get some help either with the general scheme or with this particular problem?

1

There are 1 best solutions below

2
On BEST ANSWER

Try the following. Define first the functions $$ f_{n-1}(0) = \langle c_0, c_1, \dotsc, c_{n-2}, c_{n-1} \rangle$$ $$ f_{n-1} (y+1) = \langle \pi_2 (f_{n-1}(y)), \pi_3(f_{n-1}(y)), \dotsc, \pi_n(f_{n-1}(y)), g(\pi_1(f_{n-1}(y)), \dotsc, \pi_n(f_{n-1}(y)))\rangle $$ $$ f_{n-2}(0) = \langle 0, c_0, \dotsc, c_{n-3}, c_{n-2} \rangle, \quad f_{n-2}(y+1) = f_{n-1}(y) $$ $$ \dotsc $$ $$ f_1(0) = \langle 0, 0, \dotsc, c_0, c_1 \rangle, \quad f_1 (y+1) = f_2 (y) $$ $$ f_0(0) = \langle 0, 0, \dotsc, 0, c_0 \rangle, \quad f_0 (y+1) = f_1 (y) $$ and then set $f(x) = \pi_n (f_0(x))$.

You can see that if you call $F_i (x) = \pi_n (f_i(x))$ for all $i$, then $$ f_i(x) = \langle F_{i-n+1}(x), F_{i-n+2}(x), \dotsc, F_{i-1}(x), F_{i}(x) \rangle $$ where $F_i (x) = 0$ for negative $i$'s. So you can keep track of previous values of the function with auxiliary functions and $n$-tuples (which you can codify with primitive recursive functions), if you want to start recursion at a step different from $0$.