Kolmogorov Complexity and Algorithmic Randomness

Shen, Uspensky, Vereshchagin Β· Textbook Β· kolmbook-eng-scan.pdf

TL;DR

Kolmogorov complexity K(x) measures the length of the shortest program that prints x on a universal Turing machine. Most strings are incompressible β€” K(x) β‰ˆ |x| for random strings. The framework is universal (robust across all choices of Turing machine), gives rise to a formal definition of randomness, and connects directly to Occam's razor, minimum description length (MDL), Solomonoff induction, and AIXI. Ilya Sutskever has called understanding this textbook essential for thinking clearly about intelligence.

1. The Big Idea: Compression as Complexity

How do we measure the complexity of an object β€” a string, an image, a sequence? One natural answer: by the length of its shortest description. A string like 0000...0 (one million zeros) has a very short description: "print zero one million times." But a truly random string has no shorter description than itself.

This is the core insight of Kolmogorov complexity, developed independently by Solomonoff (1964), Kolmogorov (1965), and Chaitin (1966): the complexity of x is the length of the shortest program p such that a universal Turing machine U outputs x when run on p.

Why does this matter for ML? Every learning algorithm implicitly makes assumptions about which hypotheses are simpler. Kolmogorov complexity formalizes simplicity in a way that is provably universal β€” independent of the particular language or representation you choose. It grounds Occam's razor in mathematics.

2. Defining Kolmogorov Complexity

Fix a universal Turing machine U. The Kolmogorov complexity of a string x is defined as the length of the shortest program (binary string) p that causes U to output x and halt:

Kolmogorov complexity
K(x)=min⁑{p : U(p)=x}∣p∣K(x) = \min_{\{p \,:\, U(p) = x\}} |p|

Here |p| denotes the length of program p in bits. If no program outputs x, we set K(x) = ∞ (but for any computable x, K(x) is always finite).

Concrete examples

  • 0n (n zeros): K(0^n) β‰ˆ logβ‚‚(n) bits β€” the program just says "print n zeros", so you only need to encode n.
  • Ο€ to n digits: K(Ο€_n) = O(log n) β€” there is a short program to compute Ο€ to any precision.
  • Random string of length n : K(x) β‰ˆ n for most strings β€” the only program is essentially to print x itself.

3. The Invariance Theorem

The definition of K(x) depends on the choice of universal Turing machine U β€” different machines give potentially different complexities. Is this a fatal flaw? No: the Invariance Theorem shows that the choice of U matters only up to a constant.

Invariance Theorem
∣KU(x)βˆ’KUβ€²(x)βˆ£β‰€cU,Uβ€²forΒ allΒ x|K_U(x) - K_{U'}(x)| \leq c_{U,U'} \quad \text{for all } x

where c_{U,U'} is a constant that depends only on U and U', not on x. The key idea of the proof: to simulate U' on U, you only need a fixed-size "translator" program. That translator pays a one-time cost c_{U,U'} independent of x.

ML parallel: Invariance is what makes K(x) an objective measure of complexity. Just as a physical quantity like temperature doesn't depend on the thermometer you use (up to calibration), complexity doesn't depend on the programming language β€” Python, C, lambda calculus β€” you use to describe it (up to a constant).

4. Incompressibility and Randomness

Intuitively, a random string has no pattern β€” no regularity that allows a shorter description. Kolmogorov complexity formalizes this: a string x is algorithmically random if it cannot be significantly compressed.

Algorithmic randomness (c-incompressibility)
xΒ isΒ c-randomβ€…β€ŠβŸΊβ€…β€ŠK(x)β‰₯∣xβˆ£βˆ’cx \text{ is } c\text{-random} \iff K(x) \geq |x| - c

A simple counting argument shows that most strings are incompressible: there are 2^n binary strings of length n, but only 2^{n-c+1} βˆ’ 1 programs of length less than n βˆ’ c. So the fraction of n-bit strings with K(x) < n βˆ’ c is at most 2^{βˆ’c+1}. For c = 10, fewer than 1 in 500 strings of any length are 10-compressible.

5. Conditional Complexity and Mutual Information

Just as Shannon entropy has a conditional version H(X|Y), Kolmogorov complexity has a conditional version. K(x|y) is the length of the shortest program that outputs x when given y as a free input β€” y is available to the program at no cost.

Conditional complexity
K(x∣y)=min⁑{p : U(p,y)=x}∣p∣K(x \mid y) = \min_{\{p \,:\, U(p, y) = x\}} |p|

This leads naturally to algorithmic mutual information: how much information does knowing y give you about x?

Algorithmic mutual information
I(x:y)=K(x)+K(y)βˆ’K(x,y)I(x : y) = K(x) + K(y) - K(x, y)

Here K(x, y) is the complexity of the pair (x, y) β€” the shortest program that outputs both. The chain rule connects these quantities, analogous to H(X,Y) = H(X) + H(Y|X) in Shannon theory:

Chain rule for complexity
K(x,y)=K(x)+K(y∣x)+O(log⁑K(x,y))K(x, y) = K(x) + K(y \mid x) + O(\log K(x, y))

6. The Universal Distribution

Plain Kolmogorov complexity K has a technical problem: it does not satisfy the Kraft inequality, which is a fundamental constraint on code lengths in information theory. Prefix-free (or self-delimiting) complexity K^p fixes this by requiring programs to form a prefix-free set β€” no program is a prefix of another.

Prefix complexity
Kp(x)=min⁑{p : Up(p)=x}∣p∣K^p(x) = \min_{\{p \,:\, U^p(p) = x\}} |p|

Because programs are prefix-free, we can apply the Kraft inequality: βˆ‘_p 2^{-|p|} ≀ 1. This means we can treat 2^{-|p|} as a probability weight. Summing over all programs that output x, we get the universal prior (or Solomonoff's prior):

Universal prior (Solomonoff's prior)
m(x)=βˆ‘{p : Up(p)=x}2βˆ’βˆ£p∣m(x) = \sum_{\{p \,:\, U^p(p) = x\}} 2^{-|p|}

The dominant term is the shortest program: m(x) β‰ˆ 2^{-K^p(x)}. Simpler objects (lower K^p) get exponentially higher probability. This is Occam's razor made precise: assign probability proportional to simplicity.

7. Solomonoff Induction

Given a sequence x₁xβ‚‚...xβ‚™, how should we predict xβ‚™β‚Šβ‚? Solomonoff's answer: use the universal prior m as a Bayesian prior, weighted over all computable hypotheses that are consistent with the observed data.

Solomonoff induction
P(xn+1∣x1β‹―xn)∝m(x1β‹―xn+1)P(x_{n+1} \mid x_1 \cdots x_n) \propto m(x_1 \cdots x_{n+1})

This is a Bayesian mixture over all computable models, weighted by their prior probability (program length). As n grows, the mixture converges: short programs that correctly predicted the data accumulate probability mass; long programs that needed many ad hoc adjustments are washed out.

Key convergence theorem

If the true data-generating process is any computable probability distribution ΞΌ, then Solomonoff induction converges to ΞΌ β€” in the sense that the cumulative prediction error (summed KL divergence) is bounded by K^p(ΞΌ), the complexity of ΞΌ itself. The simpler the true process, the faster convergence. This is the theoretical justification for Occam's razor.

8. Why Ilya Thinks This Is Foundational

Ilya Sutskever has pointed to the Shen–Uspensky–Vereshchagin textbook as one of the most important texts for understanding intelligence. The reason is not just historical interest β€” it is that Kolmogorov complexity provides the only framework that:

  • Gives a substrate-independent, language-independent definition of the complexity of any computable object
  • Formally justifies Occam's razor: simpler explanations are exponentially more probable under the universal prior
  • Provides a notion of randomness that does not depend on a probability distribution β€” a string is random if it has no structure, period
  • Grounds the idea that a sufficiently general predictor must converge to the correct model of any computable environment

If you believe that intelligence is fundamentally about prediction and compression β€” finding the shortest description of the world that explains the observations β€” then Kolmogorov complexity is not an optional advanced topic. It is the mathematical core of what intelligence means.

"If you really understand Kolmogorov complexity and Solomonoff induction, you understand why deep learning works at all." The neural network is learning to compress β€” finding short programs (weights) that reproduce training data. Generalization is compression: if you've found a short description, it should predict well on new data from the same source.

9. Connections to MDL, AIXI, and Modern ML

9a. Minimum Description Length (MDL)

MDL, introduced by Rissanen (1978), is a practical approximation to Solomonoff induction. Given data D and a hypothesis class H, MDL selects the hypothesis h* that minimizes the total description length:

hβˆ—=arg⁑min⁑h∈H[L(h)+L(D∣h)]h^* = \arg\min_{h \in H} \left[ L(h) + L(D \mid h) \right]

where L(h) is the code length for the model and L(D|h) is the code length for the data given the model (negative log-likelihood). This is equivalent to MAP estimation with a prior proportional to 2^{-L(h)} β€” a direct implementation of Occam's razor. BIC, AIC, and regularization can all be interpreted as MDL variants.

9b. AIXI: The Ideal Rational Agent

Marcus Hutter's AIXI (2000) extends Solomonoff induction to reinforcement learning. AIXI is a Bayesian agent that uses the universal prior m as its model of the environment and chooses actions to maximize expected future reward, averaged over all computable environments weighted by m.

AIXI is provably optimal in a formal sense: no other algorithm achieves higher total reward in expectation over all computable environments. Like Solomonoff induction, it is uncomputable β€” but it defines what optimal intelligence means when computational constraints are lifted.

Modern RL from human feedback (RLHF) and model-based RL can be seen as computable approximations to AIXI: instead of summing over all computable environments, they learn a world model from data. The universal prior m tells us what the ideal world model would look like.

9c. Deep Learning as Compression

Every trained neural network can be thought of as a compressed description of its training data. The network weights encode a program β€” a short description β€” from which the training distribution can be approximately reconstructed. Generalization corresponds to low K(weights): the simpler the compressed program, the better it should generalize.

  • Weight decay / L2 regularization: corresponds to a Gaussian prior β€” penalizing description length of weights
  • Dropout: can be interpreted as averaging over multiple compressed descriptions (subnetworks)
  • Early stopping: stops before the model starts memorizing noise β€” i.e., before K(weights|data) grows too large
  • Scaling laws: larger models can encode longer programs β€” access to exponentially more compressible hypothesis classes
  • In-context learning: the model has learned a prior m over tasks; few-shot examples update this prior, analogous to K(task|examples) β‰ͺ K(task)