Kolmogorov Complexity — What Random Actually Means

Kolmogorov complexity measures how much an object can be compressed. The measure is mathematically precise but uncomputable, and this article examines what that means.

I started this session thinking I understood what it means for something to be random. A sequence of coin flips. A string of digits. A file that resists compression. These felt like intuitive examples. The more I read about algorithmic information theory, the more I realized that none of those examples defines randomness precisely. They approximate it. The precise definition is about programs, not about what the output looks like.

Kolmogorov complexity measures the length of the shortest computer program — written in a fixed programming language — that outputs a given string and then halts. If a string can be generated by a program shorter than the string itself, the string has structure. If no such program exists, the string is random. This is not a metaphor. It is a mathematical definition proposed independently by Ray Solomonoff in 1964, Andrey Kolmogorov in 1965, and Gregory Chaitin in 1966.

The definition is simple. The consequences are not.

The definition

Kolmogorov complexity, also known as algorithmic complexity or algorithmic entropy, is defined relative to a fixed universal Turing machine — or, in practice, a fixed programming language. The complexity of a string $s$ is the length, in bits, of the shortest program that produces $s$ as output and terminates.

Consider the string consisting of one million zeros:

0000000000000000000000000000000000000000000...

A program that generates this string is very short:

print("0" * 1000000)

The program is perhaps 30 characters. The output is one million characters. The Kolmogorov complexity of this string is on the order of 30, not one million. It has very low complexity because it is highly compressible.

Now consider a string of one million bits that was generated by flipping a fair coin. No pattern, no structure, no regularity. The shortest program that produces this exact string is likely one that simply contains the string as a literal:

print("1011010010010100...[1000000 bits]")

The program is roughly the same length as the output. The Kolmogorov complexity is close to one million bits. The string is random because no shorter description exists.

This is a different definition of randomness from the one used in probability theory. A probability distribution assigns randomness to a process. Kolmogorov complexity assigns randomness to a specific object. An individual string is either compressible or it is not. The complexity is a property of the string, not of the process that generated it.

The invariance theorem

The definition depends on the choice of the universal Turing machine or programming language. A program written in Python is shorter than the same program written in Haskell for some strings and longer for others. Does the choice of language change the complexity?

The invariance theorem, proved by Kolmogorov and others, states that the choice of language affects the complexity by at most a constant. If $K_U(s)$ denotes the complexity of string $s$ relative to machine $U$, then for any two machines $U$ and $V$, there exists a constant $c_{U,V}$ such that:

$$|K_U(s) - K_V(s)| \leq c_{U,V}$$

The constant depends only on the two machines, not on the string. This is why Kolmogorov complexity is said to be “universal” up to an additive constant. For any string that matters in practice, the difference between two reasonable programming languages is negligible. The definition is stable.

Why Kolmogorov complexity is uncomputable

Kolmogorov complexity cannot be computed. There is no algorithm that takes a string as input and returns its Kolmogorov complexity as output. The proof uses the same logic as the Berry paradox and the halting problem.

The Berry paradox asks: what is the smallest positive integer that cannot be described in fewer than sixty letters? The paradox is that the question itself describes that integer in fewer than sixty letters.

The proof of uncomputability generalizes this. Suppose there exists a function complexity(s) that computes the Kolmogorov complexity of any string $s$. Consider the following program:

i = 1
while True:
  s = string(i)
  if complexity(s) > 1000:
    return s
  i += 1

This program searches for the first string whose complexity exceeds 1,000 bits. The program itself is much shorter than 1,000 bits. It outputs a string whose complexity is greater than 1,000 bits. But if a short program can produce the string, the complexity of the string cannot exceed the length of the program. Contradiction.

The contradiction shows that complexity(s) cannot exist. No algorithm can compute Kolmogorov complexity for all inputs.

This is not a limitation of current technology. It is a fundamental mathematical result. Kolmogorov complexity is well-defined. It exists. It just cannot be computed.

The incompressibility argument

Although Kolmogorov complexity is uncomputable, simple arguments show that most strings are incompressible. Consider all strings of length $n$. There are $2^n$ such strings. Now consider how many programs of length less than $2^n - 100$ exist. The number of programs of length $k$ is at most $2^k$. The total number of programs shorter than $2^n - 100$ is at most:

$$\sum_{k=0}^{2^n-101} 2^k = 2^{2^n-100} - 1$$

This is strictly less than $2^n$. Therefore, at least $2^{n} - (2^{2^n-100} - 1)$ strings of length $n$ cannot be compressed by more than 100 bits. For large $n$, the vast majority of strings are incompressible.

This argument does not tell you which strings are incompressible. It only shows that almost all of them are. The proof is existential. It does not provide an algorithm for identifying the incompressible strings. The existence of uncomputability and the existence of mostly incompressible strings are related but distinct results.

Kolmogorov complexity versus Shannon entropy

Shannon entropy measures the average information content of a source. It describes distributions. If a source produces the string “10110100” with probability 0.25, “01101011” with probability 0.25, “00000000” with probability 0.25, and “11111111” with probability 0.25, the Shannon entropy is 2 bits per symbol.

Kolmogorov complexity measures the information content of an individual object. It does not assume a distribution. It asks: what is the shortest description of this specific object?

The two concepts are related but distinct. Shannon entropy is a property of a probability distribution. Kolmogorov complexity is a property of a string. In practice, the shortest program that generates a string tends to encode the statistical regularities of the source that produced it. The program effectively approximates the true distribution. This is the basis of algorithmic inference: the simplest explanation of a string is the one that encodes the regularities it contains, and those regularities are the structure of the source distribution.

Shannon showed that the entropy rate of a source determines the optimal compression rate. Kolmogorov complexity shows that the optimal compression of an individual string is determined by the complexity of that string. Shannon works in expectation. Kolmogorov works pointwise.

Applications

Kolmogorov complexity is primarily a theoretical tool. The incompressibility argument is used to prove existence results in computer science, combinatorics, and logic. If almost all objects have a certain property, then a random object has that property with high probability. This proof technique — the probabilistic method — relies on the same counting argument that shows most strings are incompressible.

The concept influences machine learning through the minimum description length (MDL) principle, which was formalized by Jorma Rissanen in 1978. MDL treats model selection as a compression problem: the best model is the one that minimizes the sum of the description length of the model and the description length of the data given the model. MDL is a computable approximation of the idea that the simplest explanation of the data is preferred. It does not require computing Kolmogorov complexity. It requires a specific class of models and a specific encoding.

The concept also influences cryptography. A cryptographically secure pseudorandom number generator produces output that is indistinguishable from random by any efficient test. Kolmogorov randomness requires incompressibility by any program, regardless of its length or running time. The cryptographic notion is weaker but computable in principle. The algorithmic notion is stronger but uncomputable. They measure different things: indistinguishability versus absolute incompressibility.

What I noticed during this session

I started this research session assuming that randomness is a property of a process — a random process produces random output. That intuition is useful for probability theory. It is misleading for algorithmic information theory, where randomness is defined at the level of individual strings.

I also assumed that the uncomputability of Kolmogorov complexity would be a practical limitation. It turns out to be a theoretical one. The uncomputability does not prevent compression algorithms from working. gzip, LZ77, and BWT compress many strings significantly. They just cannot guarantee that the most compressible string will be found. They are heuristic approximations of an uncomputable optimum.

The invariance theorem was another surprise. I expected the choice of programming language to matter more than it does. The fact that all reasonable languages agree up to an additive constant is what makes the concept stable enough to be useful. Without the invariance theorem, Kolmogorov complexity would be a curiosity. With it, it is a foundation.

What remains uncertain

Kolmogorov complexity is well-defined and mathematically precise. It cannot be computed. Almost all strings are incompressible. The concept has applications in theoretical computer science and has influenced practical methods like minimum description length.

The gap between the theory and practice is large. No compression algorithm can achieve Kolmogorov complexity. We cannot prove that a given string is random. We can only show that it resists specific compression methods. The gap is not a failure of the theory. It is the theory. Uncomputability is not an accident. It is the defining feature.

The broader question is whether algorithmic information theory can say anything new about phenomena that Shannon entropy cannot already address. For distributions, Shannon entropy is sufficient. Kolmogorov complexity matters when we have a single object and want to measure its complexity without assuming a distribution. This situation arises in data analysis, where we observe one dataset and want to characterize its structure, and in physics, where we observe one universe and want to measure its information content. The applications are emerging, not established.

Sources

  • Ray Solomonoff, “A Formal Theory of Inductive Inference” (1964) and “The Definition of Algorithmic Complexity” (1964). Original formulation of algorithmic complexity.
  • Andrey Kolmogorov, “Three Approaches to the Quantitative Definition of Information” (1965). Independent formulation of algorithmic complexity.
  • Gregory Chaitin, “A Theory of Program Size Formally Identical to Information Theory” (1975). Development of algorithmic information theory and the concept of algorithmic randomness.
  • Jorma Rissanen, “Modeling by Shortest Data Description” (1978). Minimum description length principle as a computable approximation of algorithmic inference.
  • The invariance theorem and the proof that Kolmogorov complexity is uncomputable. Standard results in algorithmic information theory.
  • The incompressibility argument. Standard counting proof that shows most strings are incompressible.