MHB Showing the nth prime is primitive recursive

  • Thread starter Thread starter Nono713
  • Start date Start date
  • Tags Tags
    Prime Primitive
AI Thread Summary
The discussion focuses on proving that the function f(n), which returns the nth prime number, is primitive recursive. The proof begins by establishing the base case with f(0) = 2 and uses induction to define f(n + 1) as the least x in a specific interval that satisfies a prime condition. Concerns are raised about using bounded search in intervals not starting at zero, but it's clarified that auxiliary functions can be defined to handle such cases. The reasoning presented is deemed valid, reinforcing the conclusion that f(n) is indeed primitive recursive. The conversation emphasizes the importance of understanding bounded search within the context of primitive recursion.
Nono713
Gold Member
MHB
Messages
615
Reaction score
4
I've been asked in an exercise to show that the function $f(n)$ which returns the $n$th prime is a primitive recursive function. We've covered the basics of primitive recursion, the primitive recursive schematic notation, addition, multiplication, limited subtraction, bounded products, sums, quantifiers, bounded search (minimization), and relations/cases. Could someone check over my work, because I'm still not comfortable with how to build these kinds of proofs:



Premises:

- the prime decision function ($p(x) = 0$ if $x$ is not prime, $p(x) = 1$ otherwise) is primitive recursive
- the factorial function and subtraction function are primitive recursive (proved earlier)

Proof:

We first define $f(0) = 2$ (the first prime is $2$) which is a composition of primitive recursive functions (using the successor and zero functions), and is the first prime number. So the base case holds.

Next we assume that $f(n)$ is the $n$th prime number, and we define $f(n + 1)$ as "the least $x$ less than or equal to $f(n)! - f(n)$ such that $x + f(n) + 1$ is prime". From Euclid's proof of the infinitude of primes, which shows there exists a prime between $m$ and $m! + 1$ for any natural number $m$, the above means that $f(n + 1)$ returns the smallest prime in $[ f(n) + 1, f(n)! + 1 ]$, which is the next prime after $f(n)$. Therefore, by induction, $f(n)$ does indeed return the $n$th prime for all $n$.

The expression for $f(n + 1)$ is a (primitive recursive) bounded search, as we search in the interval $[ 0, f(n)! - f(n) ]$ for the least element $x$ which satisfies the primitive recursive relation "$x + f(n) + 1$ is prime", where the interval bounds are finite and are primitive recursive (composed from the zero function and a composition of factorial and subtraction respectively). Therefore $f(n)$ is primitive recursive.



I'm kind of wondering about using bounded search like this to search inside an interval that doesn't start at zero. I feel it is correct since the predicate is still primitive recursive but I'm not sure if it's sufficient justification. What do you guys think?
 
Physics news on Phys.org
I think your reasoning is fine.

Bacterius said:
we define $f(n + 1)$ as "the least $x$ less than or equal to $f(n)! - f(n)$ such that $x + f(n) + 1$ is prime".
Are you saying this instead of "the least $f(n)<x\le f(n)!+1$ such that $x$ is prime" because you need to search in an interval that starts with 0? That's OK, but it is also possible to define an auxiliary primitive recursive function that searches for the least number satisfying a p.r. relation in any bounded interval.
 

Similar threads

Replies
5
Views
3K
Replies
6
Views
2K
Replies
11
Views
4K
Replies
18
Views
3K
Replies
1
Views
2K
Replies
2
Views
2K
Replies
1
Views
1K
Back
Top