Intractable Problems
Not all decidable problems are practically solvable. Some require time exponential in input size — they are intractable.
Time Complexity Classes
P (Polynomial Time)
Problems solvable by a deterministic TM in polynomial time. These are generally considered tractable.
Examples: sorting (
NP (Nondeterministic Polynomial Time)
Problems solvable by a nondeterministic TM in polynomial time. Equivalently: problems whose solutions can be verified in polynomial time.
Examples: SAT, CLIQUE, Hamiltonian Cycle, Subset Sum, Graph Coloring.
The Big Question: P = NP?
Whether
NP-Completeness
A problem
- For every
, ( is polynomial-time reducible to )
Polynomial-Time Reduction
If
If
Cook-Levin Theorem
Theorem: SAT (Boolean Satisfiability) is NP-complete.
This was the first problem proven NP-complete (Cook 1971, Levin 1973).
Proof Idea
Given a nondeterministic TM
The formula encodes the TM's computation tableau:
- Cell variables:
— at time , tape cell contains symbol - State variables:
— at time , head is at position - State variables:
— at time , TM is in state
The formula asserts:
- The initial configuration is correct (input
on tape, start state) - Each configuration legally follows from the previous one (transition function)
- At some time step, an accepting state is reached
Since the TM runs in polynomial time, the tableau is polynomial-sized, and the formula can be constructed in polynomial time.
Common NP-Complete Problems
SAT and Variants
- SAT: Given a boolean formula, is it satisfiable?
- 3-SAT: SAT with exactly 3 literals per clause
- NAE-3-SAT: Not-All-Equal 3-SAT
Graph Problems
- CLIQUE: Does
have a clique of size ? - Vertex Cover: Does
have a vertex cover of size ? - Hamiltonian Cycle: Does
have a cycle visiting every vertex exactly once? - TSP (Traveling Salesman): Visit all cities with total cost
- Graph Coloring: Can
be colored with colors?
Number/Set Problems
- Subset Sum: Given numbers, is there a subset summing to target
? - Partition: Can a set be partitioned into two equal-sum subsets?
- Knapsack (decision version): Can we pack items with total value
under weight limit ? - Set Cover: Can we cover all elements with
sets?
Proving NP-Completeness
Standard Recipe
- Show
: Give a polynomial-time verifier (certificate + checking algorithm) - Select a known NP-complete problem
"close" to - Construct a polynomial-time reduction
from to - Prove correctness:
Reduction Example: 3-SAT CLIQUE
Given a 3-CNF formula
- For each literal in each clause, create a vertex
- Connect vertices from different clauses unless they represent contradictory literals (
and ) has a -clique iff is satisfiable (select one true literal per clause)
Beyond NP
PSPACE
Problems solvable using polynomial space (no time bound).
PSPACE-complete examples:
- TQBF (True Quantified Boolean Formula)
- Generalized Geography
- Equivalence of regular expressions
- Equivalence of NFA
EXP
Problems requiring exponential time.
EXP-complete examples:
- Generalized Chess, Checkers, Go
- Equivalence of regular expressions with exponentiation
NEXP
Nondeterministic exponential time.
The Hierarchy
We know
Coping with Intractability
Since many important problems are NP-complete, we need practical approaches:
1. Approximation Algorithms
Find solutions within a guaranteed factor of optimal.
- Vertex Cover: 2-approximation (greedy matching)
- TSP with triangle inequality: 1.5-approximation (Christofides)
- Set Cover:
-approximation (greedy)
2. Fixed-Parameter Tractability (FPT)
If the "hard" parameter
- Vertex Cover:
- Parameterized complexity: FPT
W[1] W[2]...
3. Heuristics and Local Search
No guarantees, but often work in practice: genetic algorithms, simulated annealing, tabu search, SAT solvers (DPLL, CDCL).
4. Special Cases
Many NP-complete problems become polynomial on restricted inputs:
- 2-SAT (P), Horn-SAT (P)
- Graph coloring on trees (2 colors), bipartite graphs
- TSP on a line, on a tree