Computational complexity asks how the cost of solving a problem grows as the problem gets bigger. It sorts problems into classes by how much time or memory the best known method needs, and it asks which problems are fundamentally hard rather than just unsolved.
Measuring growth
Complexity cares about scaling, not stopwatch time. Sorting a list of ten items is trivial. The question is what happens at ten million. Algorithms are described with big-O notation:
- Linear: double the input, double the work.
- Quadratic: double the input, four times the work.
- Exponential: add one item, double the work. These become impractical very fast.
Attention in a transformer is a familiar case. Its cost grows quadratically with the length of the input, which is one reason long context windows are expensive.
The classes that come up most
- P: problems a computer can solve in polynomial time, which is generally treated as "efficient."
- NP: problems where a proposed answer can be checked quickly, even if finding one may be slow.
- NP-hard: problems at least as hard as the hardest in NP.
Whether P equals NP is the best-known open question in the field, covered in P vs NP. Most researchers believe they differ, but no one has proven it. Related conjectures, like the exponential time hypothesis, make sharper claims about how hard specific problems are.
Complexity also studies algebraic versions of these questions, such as comparing the cost of computing certain polynomials, and the exact speed of basic operations. The matrix multiplication exponent is one example: it measures how fast two big grids of numbers can be multiplied, which underlies nearly all of deep learning.
Why it matters to people using AI
Three reasons:
- Cost. Complexity explains why some AI workloads get costly as inputs grow, and why efficiency tricks matter.
- Security. Public-key cryptography is built on problems believed to be hard. If a fast algorithm were found for one, the scheme based on it would fail. Hardness is a belief supported by decades of effort, not a proof.
- Verification. When AI systems claim new proofs or faster algorithms, complexity gives the vocabulary to check what was actually shown. Machine-checked proofs in tools like the Lean theorem prover exist for that reason.
A caution
"Hard in the worst case" does not always mean hard in practice. Many NP-hard problems are solved well enough on real inputs. Complexity describes guarantees, and real workloads often sit comfortably inside them.