I'm trying to prove $f(n) = 2n$ is primitive recursive. I understand that for something to be primitive recursive it must have the following properties:
$0(x)=x$ the zero function
$s(x)= x+1$ the successor
$p^i (x1,...x2,x3)= xi =$ projection
So would the primitive recursive definition of $f(n)=2n$:
$f(2,n)$
$s(2*f(x))$
$p^i (2)$
Is this correct? If not could someone give me an intuitive explanation? I'm really struggling to understand this!
Thank you in advance!
----EDIT: Ive now got a different answer: $f(0,m)$ $f(2,n)=f(mult(2,n))$
According to wikipedia, we can construct a $1$-ary function $h$ by primitive recursion given a $0$-ary function $f$ and a $2$-ary function $g$ such that $h(0)=f()$ and $h(s(y))=g(y,h(y))$. We can denote this $h=PR(f,g)$. Thus, we can construct $h(n)=2n$ if $f()=0()$ and $g(y,n)=n+2=s(s(n))$. Now we just have to lace these all together:
$$f=PR(0,s\circ s\circ p_2^2),$$
or equivalently,
$$f(0)=0\\f(s(n))=s(s(p_2^2(n,f(n))))=s(s(f(n)))=f(n)+2$$
Here $p_2^2$ is the $2$-ary projection function $p_2^2(y,n)=n$, so that $s\circ s\circ p_2^2(y,n)=n+2$ as desired.