MHB Showing the nth prime is primitive recursive

  • Thread starter Thread starter Nono713
  • Start date Start date
  • Tags Tags
    Prime Primitive
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.
 
Hi all, I've been a roulette player for more than 10 years (although I took time off here and there) and it's only now that I'm trying to understand the physics of the game. Basically my strategy in roulette is to divide the wheel roughly into two halves (let's call them A and B). My theory is that in roulette there will invariably be variance. In other words, if A comes up 5 times in a row, B will be due to come up soon. However I have been proven wrong many times, and I have seen some...
Thread 'Detail of Diagonalization Lemma'
The following is more or less taken from page 6 of C. Smorynski's "Self-Reference and Modal Logic". (Springer, 1985) (I couldn't get raised brackets to indicate codification (Gödel numbering), so I use a box. The overline is assigning a name. The detail I would like clarification on is in the second step in the last line, where we have an m-overlined, and we substitute the expression for m. Are we saying that the name of a coded term is the same as the coded term? Thanks in advance.

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