I'm trying to construct a computable function $f:\omega^2\to\omega$ such that
- For all $e\in\omega$, $x\mapsto f(e,x)$ is primitive recursive.
- If $g:\omega\to\omega$ is primitive recursive, then there exists $e\in\omega$ such that $f(e,x)=g(x)$ for all $x\in\omega$.
What I've tried so far:
By the normal form theorem there's a primitive recursive unary function $U$, and a trinary recursive relation $T_1$ such that if $f$ is a unary partial recursive function, then it has a code $e$ such that: $$f(x)=U(\mu yT_1(e,x,y))$$
So it seems like there should be a computable relation $Q_1$ that determines if $e$ is a code for a unary partial recursive function, and then we have a computable function $c$ defined by
$$c(e,x)=\begin{cases}U(\mu y(T_1(e,x,y)) &\mbox{if }Q(e)\\0 &\mbox{otherwise}\end{cases}$$
The notes I'm working from codes finite sequences of numbers as follows
$$\langle x_0,\dots,x_n\rangle:=2^{x_0+1}3^{x_1+1}\dots p_n^{x_n+1}$$
And we have primitive recursive functions/predicates like $seq(e)$ that says $e$ codes a sequence, $lth(e)$ that outputs the length of $e$, and $(e)_i$ that outputs the $i$-th number in the sequence coded by $e$.
The partial recursive functions are then coded by
- $\langle 0\rangle$ corresponds to $O$ the zero function
- $\langle 1\rangle$ corresponds to $S$ the successor function
- $\langle 2,n,i\rangle$ ($1\le i\le n$) the projection functions
- $\langle 3,a_1,\dots,a_n,b\rangle$ for the composition $\chi(\psi_1(x)\dots,\psi_n(x))$ where $b$ codes $\chi$, $a_i$ codes $\psi_i$.
- $\langle 4,a,b\rangle$ for primitive recursion from $\chi,\psi$.
And just for completeness
- $\langle 5,a\rangle$ for $\mu$-recursion.
So if $e$ codes a unary primitive recursion function, we have $(e)_1\in\{0,1,2,3,4\}$ and some obvious requirements like $(e)_1=2\implies lth(e)=3\wedge(e)_2=(e)_3=1$.
But then it starts to turn into a mess when I consider composition, because I need $b$ to code an $n$-ary primitive recursive function, so do I need to find a primitive recursive relation that decides if $b$ does so?
So I need $Q_n(e)$ that says $e$ codes an $n$-ary primitive recursive function, so we have $\chi_{Q_n}(0)=0$ for all $n\ge 1$.
But then to define the $Q_n$ it seems like I would need to somehow use all the $Q_n$s simultaneously, which doesn't seem allowable.
And at that point I give up.
Also I've tried searching for R. Péter's construction, but the closest I came was a German version of her book (at least I think that's what it was), but unfortunately I don't speak German so it wasn't very useful to me personally.
So, is my approach completely wrong? If so what should be I trying, if not how do I get around my problem?