Kolmogorov complexity, also called algorithmic complexity, is the length of the shortest program that produces a given string on a fixed universal computer and then halts. It turns the vague notion of simplicity into a precise quantity: a string is simple when a short description generates it and complex when no description is much shorter than the string itself.
Among AI fundamentals, the concept underpins the theory of inductive inference, Solomonoff induction, the minimum description length principle and formal readings of Occam’s razor. In artificial intelligence it explains why learning is closely tied to compression, even though the quantity itself can never be computed exactly.
The formal definition of Kolmogorov complexity
Fix a universal Turing machine U. The Kolmogorov complexity K(x) of a binary string x is the minimum length, in bits, of any program p such that U run on p outputs x and halts. The conditional complexity K(x|y) is the same quantity when the machine also receives y as auxiliary input, and it measures how much new information x contains given y.
The invariance theorem makes the definition meaningful: for any two universal machines, the complexities differ by at most a constant that depends on the machines, not on x. Complexity is therefore well defined up to an additive constant, which is negligible for long strings but can dominate for short ones.
The table below lists the core quantities used in algorithmic information theory.
| Quantity | Notation | Meaning |
|---|---|---|
| Plain complexity | C(x) | Shortest program, any program set |
| Prefix complexity | K(x) | Shortest program from a prefix-free set |
| Conditional complexity | K(x|y) | Shortest program given y as input |
| Mutual information | I(x:y) | K(x) + K(y) – K(x,y), up to log terms |
| Algorithmic probability | m(x) | Chance a random program outputs x |
The prefix-free variant K is preferred in most modern work because its values satisfy the Kraft inequality, which allows them to be read as code lengths and linked to probabilities through the coding theorem.
Key properties and limits
Kolmogorov complexity has several properties that hold for every string and shape how it can be used. Some are upper bounds, some are counting arguments, and one is a hard impossibility result.
| Property | Statement | Consequence |
|---|---|---|
| Upper bound | K(x) is at most about n + 2 log n bits | Literal printing is always possible |
| Incompressibility | Most strings of length n have K(x) near n | Random strings dominate |
| Uncomputability | No algorithm computes K(x) for all x | Only upper bounds are available |
| Upper semicomputability | K(x) can be approximated from above | Compressors give estimates |
| Chaitin incompleteness | A formal system proves K(x) greater than c only for bounded c | High complexity is mostly unprovable |
Uncomputability follows from a variant of the Berry paradox: if a program could compute K, a short program could search for the first string of complexity above a large bound and print it, contradicting that bound. In practice, any real compressor such as gzip or a neural model only provides an upper bound on K(x).
Kolmogorov complexity compared with related measures
Kolmogorov complexity is often confused with Shannon entropy, yet the two answer different questions. Entropy describes the average information of a random source, while Kolmogorov complexity describes the information in one individual object, with no probability distribution required.
| Concept | Applies to | Computable | Main use |
|---|---|---|---|
| Kolmogorov complexity | Individual objects | No | Theory of randomness and induction |
| Shannon entropy | Probability distributions | Yes, given the distribution | Coding and communication |
| Minimum description length | Models plus data | Yes, for restricted model classes | Model selection |
| Computational complexity | Problems and algorithms | Depends on the problem | Running time and memory |
| Logical depth | Individual objects | No | Measuring organized structure |
For data drawn from a computable distribution, the expected Kolmogorov complexity equals the entropy up to a constant, which connects the two theories. The term should not be confused with computational complexity, which concerns running time rather than description length.
Why the concept matters for machine learning
Learning from data can be framed as finding a short description of that data. A model that captures real regularities compresses the training set, while a model that memorizes noise gains nothing in total description length. This view gives a principled reason to prefer simple hypotheses, and it is the formal core behind Occam’s razor in AI.
- Solomonoff induction weights every hypothesis by 2 raised to minus its program length and is provably optimal for computable sequences, but it is incomputable.
- AIXI combines Solomonoff induction with reinforcement learning to define an idealized, incomputable agent.
- Minimum description length replaces K with computable code lengths and is used for model selection.
- Normalized compression distance uses real compressors to approximate shared information between files for clustering and classification.
- The view that prediction is compression explains why language models trained on next-token loss act as strong general-purpose compressors.
Researchers also use Kolmogorov-style arguments to explain generalization: networks that find low-complexity functions tend to generalize, and some studies suggest deep networks have an implicit bias toward simple functions, although this remains an active and partly disputed research question.
Common misconceptions
Several errors appear repeatedly when practitioners apply the concept. Most stem from treating an idealized, incomputable measure as if it were a practical metric.
- A compressed file size is not K(x); it is only an upper bound tied to one compressor.
- Complexity is not the same as usefulness: random noise has maximal K but carries no structure.
- The additive constant is not always negligible; for short strings, the choice of machine changes the result.
- High complexity does not prove randomness in practice, because no algorithm can certify it for long strings.
The simple explanation
Imagine describing a piece of text to a friend over the phone. A line of one thousand letters A is easy. You just say “A, one thousand times.” A line of random letters is hard. You must read out every letter.
Kolmogorov complexity counts the length of the shortest possible description of something. Simple things have short descriptions. Random things do not. Finding patterns means finding shorter descriptions, and that is what learning machines try to do.
How it is used in practice
A research group wants to group about 2,000 malware samples into families without writing hand-made features. The analysts cannot compute Kolmogorov complexity, so they approximate it with a standard compressor and calculate the normalized compression distance between every pair of files: two samples that compress much better together than apart share most of their code.
The resulting distance matrix feeds a hierarchical clustering algorithm. The clusters largely match the families that human analysts had labeled earlier, and several previously unknown variants land next to their closest relatives. The team also notes the limits: packed or encrypted samples look almost random to the compressor, so they cluster poorly until unpacked, a direct reminder that compressors only bound the true complexity from above.