Let's define $M$ such that for $x \ge 0$:
$$ M(0)=0 $$
$$ M(x+1)=x $$
Now, I want to show that $M$ is primitive recursive. How should I go about doing this?
Thanks a bunch!
Let's define $M$ such that for $x \ge 0$:
$$ M(0)=0 $$
$$ M(x+1)=x $$
Now, I want to show that $M$ is primitive recursive. How should I go about doing this?
Thanks a bunch!
The definition
A function is primitive recursive if it is in the smallest class $\mathcal C$ that contains:
And such that composition and primitive recursion hold:
$$ \lambda x_1 ... x_m.h(g_1(x_1, ..., x_m), ..., g_k(x_1, ..., x_m)) $$
$$\begin{cases} f(0, x_2, ..., x_k) &= g(x_2, ..., x_k) \\ f(x_1 + 1, x_2, ..., x_k) & = h(x_1, f(x_1, ..., x_k), x_2, ..., x_k) \end{cases}$$
EDIT: note I did not use currying in defining the functions, but I listed the arguments in tuples. This is for simplicity and ease of reading.
The application
In your case you have to define the two functions:
Combine them (primitive recursion) to obtain the binary function $f$ such that:
$$\begin{cases} f(0, x) &= g(x) = 0 \\ f(x_1 + 1, x_2) & = h(x_1, f(x_1, x_2), x_2) = x_1 \end{cases}$$
You now have a function $f$ that behaves like pred, but has the wrong arity. To fix this, you can use composition: