Show that the following function is primitive recursive

756 Views Asked by At

Let $f$ be a function defined by \begin{array}{l} f(0)=1;\quad f(1)=2;\quad f(2)=3;\quad f(n)=0 \mbox{, for $n>2$} \end{array}

How to show that $f$ is primitive recursive?

1

There are 1 best solutions below

0
On BEST ANSWER

Proposition. Let $g(x)$ be a primitive recursive function and $f(x) = g(x)$ for all but finitely many values of $x$. Then $f(x)$ is also a primitive recursive function.

Proof. Let $\{a_1, \dots, a_n\}$ be the set $\{x \mid f(x) \neq g(x)\}$. Let $b_i = f(a_i), i = 1,\dots, n$. Then we can define $f(x)$ using $g(x)$ and other primitive recursive functions and substitution: $$f(x) = g(x)\cdot\mbox{sg}\left(|x-a_1|\cdot\ \dots\ \cdot |x-a_n|\right) + \sum_{i = 1}^n b_i\cdot\overline{\mbox{sg}}|x - a_i|,$$ where $$\mbox{sg}(x) = \begin{cases} 1, & \text{if } x \neq 0,\\ 0, & \text{if } x = 0. \end{cases} \qquad \overline{\mbox{sg}}(x) = 1\ \dot{-}\ \mbox{sg}(x),$$ $$|x - y| = (x\ \dot{-}\ y) + (y\ \dot{-}\ x), \qquad x\ \dot{-}\ y = \max(x - y, 0).$$

Now apply this proposition with $g(x) \equiv 0$ and $\{a_1, a_2, a_3\} = \{0, 1, 2\}$