more examples of primitive recursive functions
With bounded minimization, bounded maximization, and properties of primitive recursive predicates, many more examples of primitive recursive functions can now be exhibited. We list some of the most common ones:
-
1.
is the smallest prime number greater than or equal to .
Let be the predicate “ is prime” and the predicate “”. Then
where is the minimization operator. Since both and are primitive recursive, is recursive. From Euclid’s proof of the infinitude of primes (http://planetmath.org/ProofThatThereAreInfinitelyManyPrimes), two conclusions can be made:
-
–
is a total function, and
-
–
the search for need not be unbounded: let be all the prime numbers less than (suppose ), then does not divide any of the , so must be at least . Let be some prime such that . Then for any , which means that . So what we have shown is that is the most we need to search to find the next prime after . Since , we may reformulate the above expression:
Since is primitive recursive, we conclude that is primitive recursive by one application of bounded minimization and functional composition.
-
–
-
2.
is the -th prime number, and . Again, this is a total function. To see that is primitive recursive, we simply note that .
-
3.
, which is if , and otherwise, is primitive recursive. The predicate “” is primitive recursive, so that is primitive recursive. returns if , and otherwise. Thus “” is a primitive recursive predicate, and its characteristic function is easily seen to be , hence primitive recursive.
Note that the least such that is also the only satisfying the equation. An alternative, more direct (without bounded minimization) way to prove that is primitive recursive is by noticing that , where is the sign function, and is the remainder function, both of which are primitive recursive. Since is primitive recursive, so is .
Remark. is also the characteristic function of the predicate “”, which shows that “ divides ” is a primitive recursive predicate.
-
4.
, which returns the largest (bounded by ) such that , is primitive recursive, since it can be obtained by an application of bounded maximization to the predicate “”.
-
5.
, which returns the largest (bounded by ) such that , the integer version of the logarithm function, is primitive recursive, for is the largest such that , and has been shown to be primitive recursive in the previous example. To make a total function, we also set if .
-
6.
is the -th Fibonacci number. The Fibonacci numbers are defined using a slight variation of primitive recursion: , and . To show that is primitive recursive, first define a function as follows:
Then , and . Moreover, , and
Thus is defined via primitive recursion from multiplication, exponentiation, and , all of which primitive recursive. Therefore, , and consequently, , is primitive recursive. The type of recursion used in defining the Fibonacci numbers is known as course-of-values recursion.
-
7.
is the greatest common divisor of and (for convenience, we set ). In other words, the function is defined by two cases:
Since both and are primitive recursive (from previous example), as well as the predicate “”, so is their conjunction. Let be the corresponding characteristic function. By taking the bounded maximum, the second case of is primitive recursive. Since the first case of is clearly primitive recursive, hence itself is primitive recursive.
-
8.
As a result, the predicate “ and are coprime” is primitive recursive, as it has the same characteristic function as the predicate “”, and has just been shown to be primitive recursive.
-
9.
Euler -function (http://planetmath.org/EulerPhifunction) is primitive recursive. Let be the characteristic function of the primitive recursive predicate “ and are coprime”. Consider the bounded sum
which is primitive recursive. Hence is too. Note that .
Remark. It is not hard to show that, all of the functions above are in fact elementary recursive.
Title | more examples of primitive recursive functions |
---|---|
Canonical name | MoreExamplesOfPrimitiveRecursiveFunctions |
Date of creation | 2013-03-22 19:06:02 |
Last modified on | 2013-03-22 19:06:02 |
Owner | CWoo (3771) |
Last modified by | CWoo (3771) |
Numerical id | 13 |
Author | CWoo (3771) |
Entry type | Example |
Classification | msc 03D20 |