Algorithms

P vs NP

P vs NP asks whether every problem whose solution can be checked quickly can also be solved quickly. Explore a small SAT instance and compare searching all assignments with verifying one.

8 minLevel 3/3The interactive stage stays ad-free.
Variables6Assignments0 / 64Satisfying found0StatusSearching
(x1 ∨ x2 ∨ x3) ∧ (¬x1 ∨ ¬x2 ∨ x3) ∧ (x1 ∨ ¬x3 ∨ x4) ∧ (¬x4 ∨ x5 ∨ x6) ∧ (x2 ∨ x4 ∨ ¬x5) ∧ (¬x3 ∨ ¬x5 ∨ x6) ∧ (¬x2 ∨ x4 ∨ x6) ∧ (x1 ∨ x5 ∨ ¬x6)
000000
000001
000010
000011
000100
000101
000110
000111
001000
001001
001010
001011
001100
001101
001110
001111
010000
010001
010010
010011
010100
010101
010110
010111
011000
011001
011010
011011
011100
011101
011110
011111
100000
100001
100010
100011
100100
100101
100110
100111
101000
101001
101010
101011
101100
101101
101110
101111
110000
110001
110010
110011
110100
110101
110110
110111
111000
111001
111010
111011
111100
111101
111110
111111
C1: x1∨x2∨x3 FC2: ¬x1∨¬x2∨x3 TC3: x1∨¬x3∨x4 TC4: ¬x4∨x5∨x6 TC5: x2∨x4∨¬x5 TC6: ¬x3∨¬x5∨x6 TC7: ¬x2∨x4∨x6 TC8: x1∨x5∨¬x6 T

Checking one assignment takes 8 clause checks. Finding a satisfying assignment may require searching all 2⁶ = 64 possibilities. That gap — fast verification versus unknown search time — is the heart of P vs NP. This is a toy instance; real SAT instances have thousands of variables.

What you are seeing

1

P contains problems solvable in polynomial time. NP contains problems whose proposed solutions can be verified in polynomial time.

2

A SAT formula with n variables has 2ⁿ possible assignments. Verifying one assignment is fast; searching all of them explodes.

3

Nobody knows whether P = NP. A proof either way would be one of the biggest results in mathematics and computer science.

Why it matters

P vs NP shapes cryptography, optimization, scheduling, and algorithm design. If P = NP, many hard problems would suddenly become tractable.

Complexity & details

Brute-force SAT over n variables costs O(2ⁿ · m) for m clauses. Verification of one assignment costs O(m).

Frequently asked questions

What does NP stand for?+

Nondeterministic Polynomial time. It is the class of problems with solutions that can be verified in polynomial time.

Is SAT in NP?+

Yes. Given an assignment, you can check every clause in polynomial time. SAT is also NP-complete.