Complexity
Maheshwari & Smid · Ch. 8 · Introduction to Theory of Computation
P is the class of problems solvable in polynomial time. NP is the class whose solutions can be verified in polynomial time. Whether P = NP is the central open question. The Cook-Levin theorem proves that SAT is NP-complete: every NP problem reduces to it in polynomial time.
P: efficiently solvable
P contains problems where an algorithm runs in O(nk) time for some constant k. Sorting, shortest path, matching, primality testing: all in P.
NP: efficiently verifiable
NP contains problems where a proposed solution (certificate) can be checked in polynomial time. Finding a solution may be hard, but verifying one is fast. Every problem in P is also in NP (just solve it and check).
Polynomial-time reductions
Problem A reduces to problem B (A ≤P B) if instances of A can be transformed to instances of B in polynomial time. If B is in P and A reduces to B, then A is in P too. Reductions let us compare hardness.
NP-completeness
A problem is NP-complete if it is in NP and every NP problem reduces to it. NP-complete problems are the hardest in NP. If any one of them is in P, then P = NP and all of them are in P.
Cook-Levin theorem
The Cook-Levin theorem (1971) proves that SAT (boolean satisfiability) is NP-complete. The proof encodes the computation of any NP Turing machine as a boolean formula. Every step, state, and tape cell becomes a variable. The formula is satisfiable if and only if the machine accepts. Since any NP problem can be encoded this way, SAT is the universal NP-complete problem.
Neighbors
- ā Algorithms Ch.10 ā NP-completeness in the algorithms context
- š¢ Discrete Math Ch.3 ā propositional logic and SAT
- ā Algorithms Ch.1 ā complexity classes in practice: O(n log n) sorting, O(n²) dynamic programming
- š¢ Discrete Math Ch.4 ā graph theory: Hamilton path is the canonical NP-complete problem
- š Cryptography Ch.1 ā cryptographic security assumes P ā NP: factoring is believed hard