I am trying to show the following statement:
Let $C$ be a primitive recursively closed class of functions and let $f:\mathbb N^3 \to \mathbb N$ and $g:\mathbb N^4 \to \mathbb N$ with $f,g \in C$. Show that the following function $h: \mathbb N^3 \to \mathbb N$ is also in $C$:
$$h(x,0,z)=f(x,0,z)$$$$h(x,y,0)=f(x,y,0)$$$$h(x,y+1,z+1)=g(x,y,z,h(x,y,z))$$
I've tried to defined the following function:
$$H(x,y,z)= \langle h(x,y,0),h(x,y+1,z) \rangle$$
If I could show that $H$ is primitive recursive, then, since $h(x,y,z)=r(H(x,y{\dot -}1,z)$, it is clear that $h$ is in $C$ since composition of primitive recursive functions is primitive recursive.
Now, $$H(x,y,0)= \langle h(x,y,0),h(x,y+1,0) \rangle$$$$= \langle f(x,y,0),f(x,y+1,0) \rangle$$
$$H(x,y,z+1)=\langle h(x,y,0),h(x,y+1,z+1) \rangle$$$$=\langle f(x,y,0),g(x,y,z,h(x,y,z) \rangle$$$$=\langle f(x,y,0), g(x,y,z,r(H(x,y{\dot -}1,z) \rangle$$
This last expression is a function $G(x,y,z,H(x,y,z))$, so $H$ is defined by primitive recursion, which in turn means that $H$ is primitive recursive.
I am not so sure if the steps of my proof are correct and I don't know if there is an easier solution to this exercise.
I would really apreciate if someone could take a look at my answer and tell me if he or she notices any mistakes and/or post an alternative solution.
Just in case, $\langle x,y \rangle=2^x(2y+1) {\dot -} 1$, and $r(\langle x,y \rangle)=y$