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

NP and Polynomial-Time Verification

College Depth 92 in the knowledge graph ☐ I know this ☆ Set as goal
77topics build on this
495prerequisites beneath it
See this on the map →
Nondeterministic Turing MachinesTime Complexity and the Class P+2 more→→BPP 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 Zero → The Number Zero → Counting to Five → Counting to 10 → Counting to 20 → Counting a Set of Objects Up to 20 → Cardinality: The Last Number Counted → Matching Numerals to Quantities → Subitizing Small Quantities → Combining Small Groups Within 5 → Number Bonds Within 5 → Number Bonds to 10 → Tens and Ones Place Value → Reading and Writing Three-Digit Numbers → Comparing Three-Digit Numbers → Comparing and Ordering Three-Digit Quantities → Comparing and Ordering Whole Numbers → Comparing Numbers 1 to 20 → Ordering Numbers to 20 → Number Line 0 to 20 → Addition Within 20 → Doubles and Near Doubles → Doubles Facts Within 10 → Near Doubles Facts Within 20 → Mental Math Strategies for Addition → Mental Math: Adding and Subtracting Tens → Addition Within 100 → Repeated Addition as Multiplication → Multiplication as Equal Groups → Multiplication: Arrays → Basic Multiplication Facts (0s, 1s, 2s, 5s, 10s) → Multiplication Facts Within 100 → Division as Equal Sharing → Division as Grouping (Measurement Division) → Division: Grouping (Repeated Subtraction) Model → Division: Fair Sharing Model → Division as Equal Sharing → Division as Grouping → Basic Division Facts → Division Facts Within 100 → Multiplication and Division Fact Families → Relationship Between Multiplication and Division → Division Facts as Inverse of Multiplication → Remainders and Quotients in Division → Division Word Problems → Multi-Step Word Problems → Solving Multi-Step Word Problems → Multiplication Word Problems → Division Word Problems → Introduction to Long Division → Factors and Multiples → Prime and Composite Numbers → Equivalent Fractions → Relating Fractions and Decimals → Decimal Place Value → Integers and the Number Line → Opposites and Additive Inverses → Absolute Value → Adding Integers → Subtracting Integers → Multiplying Integers → Introduction to Exponents → Order of Operations → Integer Order of Operations → Variable Expressions → The Distributive Property → Variables and Expressions Review → Introduction to Polynomials → Adding and Subtracting Polynomials → Multiplying Polynomials → Factorial → Permutations → Combinations → Counting Principles: Addition and Multiplication Rules → Introduction to Graph Theory → Propositional Logic Foundations → Logical Equivalences → Boolean Algebra → Introduction to Propositional Logic → Introduction to Predicate Logic (First-Order Logic) → First-Order Logic Syntax → ZFC Axioms Overview → Axiom Schema of Separation → Axiom Schema of Replacement → Von Neumann Ordinals → Hereditarily Finite Sets → Recursive Definitions on Finite Sets → Natural Numbers in Set Theory: Iterative Construction → Formal Arithmetic and Expressibility → Turing Machines → Time Complexity and the Class P → Nondeterministic Turing Machines → NP and Polynomial-Time Verification

Longest path: 93 steps · 495 total prerequisite topics

Prerequisites (4)

Leads To (10)