If someone ever demonstrates that P=NP, will it give us a polynomial factoring algorithm, or will it only tell us that such an algorithm exists, but we still have to find it?
3 Answers
Proving P=NP would not necessarily give you an algorithm, because there are many different methods to prove something (i.e. Direct proof, Proof by contradiction, etc.).
But it is shown that if you were to find a polynomial time algorithm to solve a NP-complete problem that you could modify that algorithm to solve all NP-problems, including the Integer factorization problem.
- 1,377
- 1
- 10
- 23
- 6,435
- 10
- 29
- 62
-
7I don't believe this is true, at least technically. Consider a diagonalization over all possible Turing machines, where we run the first machine for a step, then the first two machines for a step, etc. If the correct Turing machine is nr. $k$ in our ordered list of TMs, at some point we will have run enough steps to run it until it halted. $k$ will be unimaginably large, as will the number of steps wasted on Turing machines before $k$. However, this $k$ is a constant with respect to $n$, the input size, thus this diagonalization will still be polynomial time if a poly-time algorithm exists. – orlp Nov 05 '18 at 14:27
-
Thus if a poly-time algorithm exists at all, we will immediately have found it: I just described it above. It won't be practically useful in any way shape or form, but it's still technically polynomial with respect to the input size. – orlp Nov 05 '18 at 14:29
-
4What @orlp describes is often known as Levin's universal search algorithm. – hmakholm left over Monica Nov 05 '18 at 14:48
-
11The answer is correct. If it perhaps could more rigorous in language. A polynomical time algorithm to any NPC problem would lead to a polynomial algorithm for any NP problem yet polynomical does not imply practical. – Meir Maor Nov 05 '18 at 16:00
-
6@MeirMaor Exactly: it's possible that, for example $\mathbf{P}=\mathbf{NP}$ but factorizing $n$-bit numbers takes time at least $n^{1000}$. – David Richerby Nov 05 '18 at 16:13
-
@DavidRicherby I think this is a very important point that would very much be worth being in an answer. I actually considered writing a short answer regarding this. Of course the exponent could be much much worse. It's concievable that the exponent is such that no matter how far our computers get it's never at all useful. Another interesting point is that as far as I remember we don't actually know any good algorithms with even mediocre powers. Nothing really above $n^{15}$ or so even if you count from very basic elementary operations. – DRF Nov 05 '18 at 16:58
-
4@MeirMaor The OP wanted to know if knowing P = NP will give us a polynomial time factoring algorithm, not whether it'll be practical. At least that's the question OP asked. And the answer to that question is yes, not no, which is what this answer claims (as well as the other answer). I think if we're being pedantic both answers are incorrect. – orlp Nov 05 '18 at 16:58
-
1@DRF oh... https://cstheory.stackexchange.com/questions/6660/polynomial-time-algorithms-with-huge-exponent-constant https://cs.stackexchange.com/questions/13202/decision-problems-in-mathsfp-without-fast-algorithms https://cs.stackexchange.com/questions/97784/what-are-some-problems-in-mathrmp-with-time-complexity-of-high-degree-polyn – one of the example algorithms is $O(n^{43737})$! I think it would be a bit crazy if the best possible factorisation algorithm were something $O(n^{100})$-ish, but I wouldn't count it out. – leftaroundabout Nov 06 '18 at 09:58
-
(Perhaps $\mathbf{P} = \mathbf{NP}$ can be proven with an exponent that's something like the factorial of the number of states in the ND-Turing machine that implements the NP algorithm.) – leftaroundabout Nov 06 '18 at 09:59
-
1@orlp What is the input of your problem? Are you trying to solve the halting problem? I am sorry, but I don't see how what you said relates to the P vs NP problem. Could you explain it better, please? – Hilder Vitor Lima Pereira Nov 06 '18 at 15:54
Bill Garsarch just posted about this the other day. The short answer is that there is an explicit algorithm, which is known today, such that if P = NP (or even just FACTORING ∈ P) then the algorithm solves factoring in polynomial time on all instances. However, this algorithm is utterly infeasible for real-world computation because it works by iterating over other algorithms. In a sense, it simply moves the nonconstructivity of the proof into the algorithm itself.
One thing that is interesting is that this result is somewhat specific to factoring. There does not appear to be a known algorithm that would solve SAT in polynomial time correctly, on all inputs, whose correctness proof is conditional only on P = NP. See this followup blog post by Lance Fortnow.
- 211
- 1
- 5
No, the proof may not give us directly a new algorithm. What immediately we can do is classical problem reduction;
Let $x$ be a problem that proves $\mathbf{NP}=\mathbf{P}$.
We can reduce the factorization problem into Hamiltonian Path Problem ( that is $ \in \mathbf{NP}$-Complete) in the polynomial time as Adleman did in DNA computing. You can find the details of the reduction steps in this answer. So we can reduce our problem to $x$ in polynomial time, solve $x$ and transfer the solutions back to the factorization problem since the reductions are answer-preserving, i.e. backward available.
Note: If the proof of $\mathbf{NP}=\mathbf{P}$ is not performed by showing an $\mathbf{NP}$-Complete problem has a polynomial time solution the reduction will not work until one find one. But in general, if the equality is the case, we expect that one will find a polynomial time algorithm for an $\mathbf{NP}$-Complete problem.
- 48,443
- 11
- 116
- 196
-
The law of excluded middle already tells us that $\mathbf{P}=\mathbf{NP}$ or $\mathbf{P}\neq\mathbf{NP},$! So, presumably, $x$ is a problem that proves $\mathbf{P}=\mathbf{NP}$. – David Richerby Nov 05 '18 at 16:16
-
-
2Yours second paragraph talks about "[solving] the famous open problem $\mathbf{P}=\mathbf{NP}$ or $\mathbf{P}\neq\mathbf{NP}$." I'm saying that's a trivial problem and it would be better to say that $x$ proves that $\mathbf{P}=\mathbf{NP}$. – David Richerby Nov 05 '18 at 16:23