A topic in the Open Knowledge Graph — a free, open map of 15,290 topics and the order to learn them in.

NP and Polynomial-Time Verification

College Depth 83 in the knowledge graph I know this Set as goal
77topics build on this
484prerequisites beneath it
See this on the map →
Nondeterministic Turing MachinesTime Complexity and the Class P+2 moreBPP and Randomized ComplexityBoolean Satisfiability (SAT)+8 more
complexity NP verification certificates

Core Idea

NP (nondeterministic polynomial time) is the class of decision problems for which 'yes' instances have polynomial-length certificates verifiable in polynomial time. Equivalently, NP consists of problems solvable by a nondeterministic TM in polynomial time. Every problem in P is in NP (a certificate is the solution itself), but whether P = NP is the most famous open problem in computer science. NP captures many natural combinatorial search problems including satisfiability, graph coloring, and the traveling salesman problem.

How It's Best Learned

For each NP problem, identify what the certificate is and write a polynomial-time verifier. For 3-SAT, the certificate is a satisfying assignment; for Hamiltonian Cycle, it is the cycle itself. This verifier-based definition is often more intuitive than the NTM-based definition.

Common Misconceptions

Explainer

You have already studied the class P — problems solvable by a deterministic Turing machine in polynomial time. NP extends this in a subtle but powerful way: it captures problems where checking a proposed solution is easy, even if finding one might not be.

The cleanest definition of NP is via verifiers. A decision problem L is in NP if there exists a polynomial-time algorithm V (the verifier) such that: for every 'yes' instance x, there is a string c (the certificate or witness) where V(x, c) accepts, and for every 'no' instance x, no string c makes V(x, c) accept. The certificate c must have length polynomial in |x|. For 3-SAT, c is a satisfying truth assignment; for Hamiltonian Cycle, c is the cycle itself; for Graph Coloring, c is the coloring. In each case, you can check the certificate in polynomial time — just verify it satisfies the constraints — even though finding the certificate may require searching through exponentially many possibilities.

The equivalent definition uses nondeterministic Turing machines (NTMs). An NTM can "guess" an entire certificate in one step and then verify it in polynomial time. NP is exactly the class of problems solvable by an NTM in polynomial time. Both definitions are equivalent: an NTM guess corresponds exactly to the existential certificate. The NTM formulation makes it easy to see that P ⊆ NP — any deterministic TM is a special case of an NTM — but the verifier formulation is usually more intuitive.

The P vs. NP question asks whether every NP problem is also in P. Informally: if checking a solution is easy, is finding one also easy? Most computer scientists believe P ≠ NP — that there are problems where verification is genuinely easier than search — but no proof exists. This is not merely a technical question; a proof that P = NP would imply polynomial-time algorithms for thousands of optimization and search problems, while a proof that P ≠ NP would rigorously confirm the hardness of problems like 3-SAT, protein folding, and cryptographic key recovery.

It is also worth distinguishing NP from co-NP, the class of problems whose *complements* are in NP. For Hamiltonian Cycle, co-NP asks: "does this graph have NO Hamiltonian cycle?" — and there is no known short certificate for a 'no' answer. Whether NP = co-NP is another major open question. These classes sit at the foundation of complexity theory, and understanding NP through its certificate definition is the essential first step toward NP-completeness.

Practice Questions 3 questions

Prerequisite Chain

Understanding ZeroThe Number ZeroCounting to FiveCounting to 10Counting to 20Counting a Set of Objects Up to 20Cardinality: The Last Number CountedMatching Numerals to QuantitiesSubitizing Small QuantitiesAddition Within 10Number Bonds to 10Addition Within 20Doubles and Near DoublesDoubles Facts Within 10Near Doubles Facts Within 20Mental Math Strategies for AdditionMental Math: Adding and Subtracting TensAddition Within 100Repeated Addition as MultiplicationMultiplication as Equal GroupsMultiplication: ArraysBasic Multiplication Facts (0s, 1s, 2s, 5s, 10s)Multiplication Facts Within 100Division as Equal SharingDivision as Grouping (Measurement Division)Division: Grouping (Repeated Subtraction) ModelDivision: Fair Sharing ModelDivision as Equal SharingDivision as GroupingBasic Division FactsDivision Facts Within 100Multiplication and Division Fact FamiliesRelationship Between Multiplication and DivisionDivision Facts as Inverse of MultiplicationRemainders and Quotients in DivisionDivision Word ProblemsMulti-Step Word ProblemsSolving Multi-Step Word ProblemsMultiplication Word ProblemsDivision Word ProblemsIntroduction to Long DivisionFactors and MultiplesPrime and Composite NumbersEquivalent FractionsRelating Fractions and DecimalsDecimal Place ValueIntegers and the Number LineComparing and Ordering IntegersAbsolute ValueAdding IntegersSubtracting IntegersMultiplying IntegersDividing IntegersUnit RatesProportionsPercent ConceptConverting Between Fractions, Decimals, and PercentsOperations with Rational NumbersTwo-Step EquationsSolving Multi-Step EquationsEquations with Variables on Both SidesLiteral EquationsSlope-Intercept FormPoint-Slope FormWriting Linear EquationsParallel and Perpendicular Line SlopesGraphing Linear EquationsPiecewise FunctionsStep FunctionsComposition of FunctionsInverse FunctionsRadical Functions and GraphsRational ExponentsExponential Functions and GraphsLogarithms IntroductionBig-O Notation and Asymptotic AnalysisBreadth-First Search (BFS)Shortest Paths in Unweighted GraphsDijkstra's Shortest Path AlgorithmAlgorithm Analysis and Big-O NotationTuring MachinesTime Complexity and the Class PNondeterministic Turing MachinesNP and Polynomial-Time Verification

Longest path: 84 steps · 484 total prerequisite topics

Prerequisites (4)

Leads To (10)