Introduction to P vs. NP
wesammikhail.com
wesammikhail.com
> NP, on the other hand, is a class of problems that are hard to solve yet easy to verify.
The latter description is not quite correct, as NP includes P. So not all problems in NP are hard to solve. Similarly with EXP.
The class of problems that are hard to solve yet easy to verify, is exactly NP\P, which we assume (but cannot prove) is non-empty.
This is to say, it's possible for a problem the best P algorithm we can find takes n^(10^82) time while the NP algorithm we can find is say (1.00000000.....(10^82 zeroes)... 1)^n. For any practical number the NP algorithm will be faster. (I used 10^82 because it's the approximate number of atoms in the observable universe.)
Also, the reason why profiling is imo not good enough is that you really shouldn’t even try to write an implementation with a known-to-be “slow” algorithm at the designed input size. For that, understanding O-notation is essential.
On the other hand, I have had great benefit from studying PL and semantics for software engineering. It taught me to write more readable and reliable code.
(From a person who studied both as a part of his master)
This is really annoying because it's so easy to do better: instead of saying (like the article does) "NP is a class of problems that are hard to solve yet easy to verify", you just have to say "NP is a class of problems that are easy to verify, no matter how hard they are to solve".
With this small change it's much easier to see that P is inside NP, whereas with the original explanation, most people have to re-calibrate their understanding of what NP is when they learn that it actually does include P.
It also makes it easy to see that "P vs NP" is just the question: "are there really any hard problems that are easy to verify, or is every problem like that easy and we just aren't very good at solving some of them?"
I personally might use the example to convey the concept to non-CS people.
https://www.math.ias.edu/~avi/PUBLICATIONS/MYPAPERS/AW09/AW0...
https://www.scottaaronson.com/papers/pnp.pdf
> "Although there’s no “purely mechanical procedure” to determine if a mathematical statement S is true or false, there is a mechanical procedure to determine if S has a proof of some bounded length n: simply enumerate over all proofs of length at most n, and check if any of them prove S. This method, however, takes exponential time. The P ? = NP problem asks whether there’s a fast algorithm to find such a proof (or to report that no proof of length at most n exists), for a suitable meaning of the word “fast.”"
"Fast" seems to mean polynomial time (which can still be a very long time, but not blowing up in the way that exponential time does). The paper gives some clear examples:
> "Think of a large jigsaw puzzle with (say) 10^1000 possible ways of arranging the pieces, or an encrypted message with a similarly huge number of possible decrypts, or an airline with astronomically many ways of scheduling its flights, or a neural network with millions of weights that can be set independently. All of these examples share two key features:
(1) a finite but exponentially-large space of possible solutions; and
(2) a fast, mechanical way to check whether any claimed solution is “valid.” (For example, do the puzzle pieces now fit together in a rectangle? Does the proposed airline schedule achieve the desired profit? Does the neural network correctly classify the images in a test suite?)
> "We’re asking whether, under the above conditions, there’s a general method to find a valid solution whenever one exists, and which is enormously faster than just trying all the possibilities one by one, from now till the end of the universe, like in Jorge Luis Borges’ Library of Babel."
The paper also discusses caveats, assumptions, limitations, etc. of the concept in an approachable manner. Then it goes off into the depths of theorem and conjecture.
Each solution can be encoded as an integer, and as long as you can construct your query as "is solution less than N?", you can use binary search to solve the problem in log(n) repetitions of the query, which does not affect the complexity class.
I remember that the Traveling Salesman can be constructed as "is the minimum path less than N" in which N represents the solution, not the size.
These are the complexity classes of Function P (FP) and Function NP (FNP), which are the function problem extensions of the decision problem classes, and require finding the value, not just answering yes or no.
A simple example of a decision problem in P but whose search problem is not known to be in FP: For a given integer x, “does there exist a non-trivial prime factor of x?” vs. “find a non-trivial prime factor of x”.
Wish they’d given/linked a few examples there, anyone happen to know some off the top of their head?
_also_ Karmarkar’s algo appears to be an important law case on whether math can be copyrighted for people interested in that angle
It's important to note that this happens literally all the time in research. There are hundreds of problems that are easily seen to be _in NP_, that we simply don't know whether or not is in P. Many of these problems aren't that interesting, though.
Computational Complexity: A Modern Approach
readable, and covers all the topics
I see what you did there.
Prompt:
"Give me good computer science arguments for why P = NP and why P != NP"
Response:
"The P vs. NP problem is a major open question in computer science, which asks whether problems whose solutions can be quickly verified by a computer can also be quickly solved by a computer. Both sides of the argument have been extensively debated, but the problem remains unsolved. Here are some arguments for both possibilities:
Arguments for P = NP:
Lack of counterexamples: Despite extensive research, no concrete counterexample has been found to definitively prove that P != NP. This lack of evidence may suggest that P = NP could still be true.
Potential algorithmic breakthroughs: If P = NP, this implies that a polynomial-time algorithm exists for every problem in NP, even though such algorithms may not be known yet. There is always the possibility that new algorithmic techniques or breakthroughs could be discovered, leading to polynomial-time solutions for NP problems.
Simplicity and symmetry: From a theoretical perspective, some argue that P = NP is a more elegant and symmetric outcome, as it would mean all problems that can be verified in polynomial time can also be solved in polynomial time.
Arguments for P != NP:
Exponential lower bounds: Some computational problems have proven exponential lower bounds, indicating that these problems are fundamentally difficult to solve. While these problems may not be in NP, they provide evidence that not all problems can be solved efficiently.
The lack of efficient algorithms: Despite extensive research and many attempts, no efficient (i.e., polynomial-time) algorithms have been found for any of the NP-complete problems, which are among the hardest problems in NP. This suggests that P and NP might indeed be separate complexity classes.
The existence of NP-complete problems: NP-complete problems are those that, if any one of them can be solved in polynomial time, then all NP problems can be solved in polynomial time. They are considered the hardest problems in NP. The existence of such problems, and the lack of polynomial-time algorithms for them, supports the belief that P != NP.
Cryptography: Modern cryptography relies on the assumption that certain problems are hard to solve, such as factoring large numbers. If P = NP, then these cryptographic schemes would become insecure, as the difficult problems on which they are based could be solved efficiently. The widespread use and success of cryptography provide some evidence that P != NP.
It is important to note that these arguments are speculative, and no definitive proof has been found for either side of the debate. The P vs. NP problem remains a significant open question in computer science."
That is (nearly) correct under Cook reductions but not Karp reductions.
I say "nearly" because "if language L can be solved (decided) in polynomial time, then so can any problem in NP" is a vacuously true statement for any L not in P, so by this definition nearly all languages (a measure 1 fraction of them) are also NP-complete despite most of them not being in any particularly interesting complexity class.
If we escape this degeneracy by replacing the antecedent with "given access to an efficient way to decide L", then we've recreated NP hardness under Cook reductions.
So if I am concerned with what can be done in polynomial time, then why would I limit myself to Karp reductions? If I want to finely separate classes of problems, then Karp reductions are probably better suited as the reduction builds a much more direct link between the two problems.
That is (nearly) correct under Cook reductions but not Karp reductions.
It is however still not clear to me why this is not true under Karp reductions, because there are not necessarily Karp reductions for some problems that have Cook reductions? If so, are there two different NP-complete classes, one per reduction?
Because under Karp, SAT and UNSAT are widely different problems whereas under Cook, they're not.
You can verify SAT in polynomial time. You can not do that for UNSAT.