Is the language {<p,n> | p and n are natural numbers and there's no prime number in [p,p+n]} belongs to NP class? - Computer Science Stack Exchange most recent 30 from cs.stackexchange.com 2019-11-21T14:19:15Z https://cs.stackexchange.com/feeds/question/106600 https://creativecommons.org/licenses/by-sa/4.0/rdf https://cs.stackexchange.com/q/106600 1 Is the language {<p,n> | p and n are natural numbers and there's no prime number in [p,p+n]} belongs to NP class? hps13 https://cs.stackexchange.com/users/102300 2019-04-07T11:21:33Z 2019-04-07T21:20:34Z <p>I was wondering if the following language belongs to NP class and if its complimentary belongs to NP class:</p> <p><span class="math-container">\begin{align} C=\left\{\langle p,n\rangle\mid\right.&amp;\ \left. p \text{ and $n$ are natural numbers}\right.\\ &amp;\left.\text{ and there's no prime number in the range}\left[p,p+n\right]\right\} \end{align}</span></p> <p>could you please check if my reasoning is okay to deduce NP? (I am not sure, but here's what I think): for each word <span class="math-container">$\langle p,n\rangle \in C$</span> we know that the word belongs to C because there exists a primal certificate - an nontrivial divisor to any of the numbers between <span class="math-container">$[p,p+n]$</span>, though I am not really sure it is in NP.</p> <p>regarding the complement: I think it is in NP because the compliment compositeness can be decided by guessing a factor nondeterministically. But again I am not so sure about it and I don't know how to correctly prove and show it.</p> <p>Would really appreciate your input on that as I am quite unsure and also checked textbooks and internet (and this site) about it.</p> <p>Edit: for the sake of solving the problem, due to xskxzr's comment, let's assume p and n are represented by binary, as there's a difference according to his comment between p and n being represented in unary and binary(this is also quite interesting).</p> https://cs.stackexchange.com/questions/106600/-/106603#106603 5 Answer by orlp for Is the language {<p,n> | p and n are natural numbers and there's no prime number in [p,p+n]} belongs to NP class? orlp https://cs.stackexchange.com/users/22714 2019-04-07T12:24:50Z 2019-04-07T12:24:50Z <p>Note that there's always a prime between <span class="math-container">$p$</span> and <span class="math-container">$2p$</span> for any <span class="math-container">$p$</span> thus we can eliminate <span class="math-container">$n$</span> as a complexity parameter, as for any non-trivial instance we have <span class="math-container">$n &lt; p$</span>.</p> <p>The complement (there exists a prime in range <span class="math-container">$[p, p+n]$</span>) is quite easy (due to the shoulders of giants). There are various well-known polynomial size certificates of primality of <span class="math-container">$q$</span> you could return along with some <span class="math-container">$q \in [p, p+n]$</span> if that prime <span class="math-container">$q$</span> exists. Thus your language is in co-NP.</p> <p>However the question of whether it is in NP or not seems very hard to me. Our input size is <span class="math-container">$b$</span> such that <span class="math-container">$2^b \approx p$</span>. You need the existence of a <span class="math-container">$O(b^c)$</span> sized certificate that in the worst case asserts the compositeness of an exponentially large (<span class="math-container">$|[p, p+n]| \approx |[p, 2p]| \approx p \approx 2^b$</span>) series of consecutive integers. From my intuition about number theory, finding such a certificate would be a major result, but disproving its existence would be as well. But perhaps someone with more number theoretic knowledge than me can pitch in if either of those turn out to be easy.</p> https://cs.stackexchange.com/questions/106600/-/106624#106624 2 Answer by gnasher729 for Is the language {<p,n> | p and n are natural numbers and there's no prime number in [p,p+n]} belongs to NP class? gnasher729 https://cs.stackexchange.com/users/17408 2019-04-07T21:20:34Z 2019-04-07T21:20:34Z <p>As orlp says, it's trivial to give a certificate if the answer is "YES" (just give a non-trivial factor of each of the numbers in question), the problem is whether this certificate is polynomial sized. </p> <p>There is a conjecture, backed by heuristics and some computational evidence, that there is a constant c > 0 such that for any k-bit prime p, there is a prime between p and p + c * k^2. If this conjecture is true, then the certificate is actually of size O (k^3) whenever the answer is YES, so the problem is in NP. But, it's just a conjecture. </p> <p>But of course if we might be able to prove the much weaker conjecture "for some c, there is always a prime between p and p + c * k^3" or the even weaker conjecture "there is a polynomial pol (k) such that there is always a prime between p and p + pol(k)", then this problem would also be in NP. So we can prove that is in NP by proving something about prime gaps. </p> <p>There is also the possibility that a less obvious and shorter certificate exists. </p>