Are the classes of recursive and primitive recursive functions closed under almost everywhere equality?

23 Views Asked by At

If $f$ is a recursive (respectively primitive recursive) function from $\mathbb{N}$ to $\mathbb{N}$, and $g$ is a function from $\mathbb{N}$ to $\mathbb{N}$ that is equal to $f$ except for at most finitely many values, is $g$ also recursive (respectively primitive recursive)?

1

There are 1 best solutions below

0
On BEST ANSWER

Yes. Note that the function

$$cases(a, b, c, d) = \begin{cases} c & a = b \\ d & otherwise \end{cases}$$

is primitive recursive. Suppose $f$ is recursive and equal to $g$ almost everywhere; let $\{a_1, \ldots, a_n\} = \{x \mid f(x) \neq g(x)\}$. Then we see that $g(x) = cases(x, a_1, g(a_1), cases(x, a_2, g(a_2), \ldots, cases(x, a_n, g(a_n), f(x) \cdots ))$. This function is primitive recursive when $f$ is, and a total general recursive function when $f$ is.