I have the following function definition -:
$f(0,n) = n$
$f(\text{Succ}( m), n) = \text{Succ} (f(n,0))$
After solving for this given function, I get the number $n$ if first argument is $0$, which is the base case. Example $f(0,4) = 4$.
If the second argument is $0$, function always returns $1$. Example: $f(4,0) = 1$
If both arguments are $> 0$, the function always returns $2$. Example $f(4,4) = 2$
First of all I would like to know if this is an example of a known function that I am unaware of, like is there a name for this recursive function like fibbonacci, exponential etc.
Also is this function considered primitve recursive, since the recursion is not on the immediate predecessor of the variable under consideration ?
Edit-: Thanks for the explanation about this function being primitive recursive. Would the Type Construct for this function be something like this-:
$R(m, n, x.r. Succ(r)) $, where n is the base result and r is the result of the recursive call?
You just explained how to compute it by a much simpler algorithm then the recursive presentation you initially gave. Being primitive recursive isn't about the presentation given, it's about the function and whether a primitive recursive presentation is possible. So yes, given that it can be computed by a simple finite "if, then, else" logic, it's primitive recursive.
And no, there's no name for this, other than "$f(m,n)$ = (if $m=0$, return $n$, else if $n=0$, return one, else return 2)."