Iliad

Solomonoff Induction

Cluster DD.3.1 · AIXI

How an idealized agent should predict. A Bayesian mixture over a countable class of computable hypotheses learns to predict any sequence, with total error bounded by the description length of the truth -- a formal Occam's razor.

By David Quarel (Australian National University), Leon Lang (University of Amsterdam)

What you’ll learn
  • Define the Bayesian mixture over a class of environments and prove it is a proper predictor whose posterior updates multiplicatively.
  • Prove the cumulative prediction-error bound and specialize it to the Solomonoff prior to recover the Occam bound.
  • Show the mixture makes boundedly many mistakes and is Pareto-optimal under KL and squared loss.
  • Bound the misspecified case when the truth lies outside the model class.

Much of this material is drawn from (Hutter et al. 2024, Chapter 3) and the earlier (Hutter 2005); both books provide fuller explanations, additional context, and proofs that we gloss over here.

Difficulty ratings. Each problem is tagged with a rating in square brackets following Knuth's exercise rating scheme (Knuth 1973): roughly, [00] trivial, [10] 15–minute pencil-and-paper, [20] 1–2 hours, [30] several hours to a day, [40] a significant research result. Intermediate values are possible.

Overview

Solomonoff induction is the prediction half of Universal AI: what would an optimally intelligent agent do if it only had to predict, given unlimited compute and the weakest possible assumptions? The answer is a single Bayesian mixture over a countable class of candidate environments, weighted by a prior . It (eventually) predicts as well as the true environment , and under the universal choice — = all computable environments, prior with the Kolmogorov complexity — the assumption "" becomes "the universe is computable," and Occam's razor drops out of the mathematics.

This module is a worksheet: you build the theory yourself, one problem at a time. The sequel module, AIXI, lifts the same mixture to sequential decision-making (learning to act).

Prerequisites

  • Comfort with discrete probability: conditional distributions, the chain rule, expectations.
  • Kullback–Leibler divergence and basic information theory (helpful, developed as needed).

Goal and Roadmap

A recipe for prediction: Solomonoff induction is an attempt to mathematically formalize the problem of induction from philosophy: How to make predictions about the future based on past observations?

We formalize this as sequence prediction: There is some true environment that generates a sequence of (binary) symbols. Each next symbol is sampled from conditioned on the past . A predictor takes the history and gives a distribution over the next symbol .

We measure the quality of a predictor by the -expected squared prediction error, summed over every timestep:

How to construct a predictor such that is small (or at least finite)? Bayesian inference to the rescue: we choose as our predictor a Bayesian mixture over a countable class of candidate environments, weighted by prior beliefs (formalized in Definition 1.2). The main results we build up to are:

  • Cumulative bound (Section 4): Assuming , . The higher the prior on , the lower the prediction error.
  • Explicit bound (Exercise 4.2): specialize to the Solomonoff prior to get , where is the Kolmogorov complexity.
  • Pareto optimality (Exercise 6.2 and 8.2): no other predictor weakly dominates on every , for either KL or squared loss.
  • Misspecified version (Section 7): If , the cumulative bound becomes : the constant complexity term plus an approximation term that in general grows linearly in , so diverges. Here is the "closest" environment to .

Notation

For more background, see the corresponding post on Solomonoff induction.

Symbols used throughout.

  • : the binary alphabet; all finite binary strings; length- strings.
  • : the empty string. ; .
  • : the corresponding random variables.
  • : generic environments / predictors. : the true (unknown) environment generating the data. : a Bayesian mixture of environments.
  • : a countable class of candidate environments.
  • with : the prior over . : the posterior after observing .
  • : the set of probability distributions over a finite set .

1. The mixture is a predictor

Definition 1.1 (Environment). An environment assigns to each history a predictive distribution over the next symbol. The joint probability of a string is defined by the chain rule

so that and for all . The true (unknown) environment generating the data is denoted .

Definition 1.2 (Bayesian mixture ). Let be a countable class of environments with prior weights satisfying . The Bayesian mixture is defined as a prior-weighted mixture over all environments in :

Its one-step predictive distribution is

with posterior weights

Here is the posterior belief in after observing .

The mixture is defined as a sum of joint probabilities. To use it as a predictor we need its one-step conditional , and we need to know it is a genuine probability distribution (so that, later, Pinsker's inequality applies to it).

Exercise 1.1 (Generalized chain rule) [05]. The two-term chain rule baked into Definition 1.1 extends to arbitrary contiguous blocks. Show that for any and any history with ,

Solution

Expand the conditional as a ratio of joints; the chain rule (Definition 1.1) telescopes the ratio to a product over indices :

For any , the past is just extended by , so the same expansion identifies every contiguous sub-block as a conditional with the right history. Splitting the product at index :

Exercise 1.2 (Mixture is a predictor) [10]. Starting from , show that

and conclude that , i.e. is a probability distribution over .

Hint

Write , expand the numerator, and use the chain rule (Definition 1.1). For the last part, note that the posterior weights sum to .

Solution

The one-step conditional is the ratio of joint to marginal, . Expanding the numerator and applying the chain rule to each term:

The posterior weights are non-negative and sum to :

Therefore is a convex combination of the probability distributions , so it is itself a probability distribution over :

Exercise 1.3 (Posterior update) [10]. Show that the posterior weight updates multiplicatively as new symbols arrive. For every with ,

That is: the new posterior equals the old posterior, scaled by the likelihood ratio of how well predicted the just-observed symbol relative to the mixture's own prediction.

Solution

By Definition 1.2,

Apply the chain rule (Definition 1.1) to both and : and . Dividing,

Rearranging gives the claim.

Exercise 1.4 (Multi-step posterior linearity) [10]. Exercise 1.2 showed that 's one-step prediction is the posterior-weighted average of the per-model one-step predictions. The same identity extends to predictions over a whole future segment : for any ,

That is: the same posterior governs 's predictions for arbitrarily many steps into the future, not just the next one. Show this.

Hint

Write , expand the numerator using the mixture definition, and apply the generalized chain rule (Exercise 1.1 with , , ) to factor each .

Solution

By definition of the conditional and the mixture form (Definition 1.2),

The generalized chain rule (Exercise 1.1 with , , ) gives . Substituting,

2. KL divergence

The KL divergence between two joint distributions over a length- history splits, by an inductive application of the chain rule for probabilities, into a sum of per-step conditional KLs. This telescoping identity lets us trade a single joint KL over an entire history for a sum of per-step KLs (and vice versa): exactly the bridge we will need in Section 4.

We introduce two pieces of notation that will be used throughout the rest of the worksheet:

Definition 2.1 (Cumulative and per-step KL). For environments / predictors , horizon , and , the cumulative joint KL and the expected per-step KL at step are

with the conventions for and for .

We write and .

Theorem 2.2 (KL divergence is non-negative). For any environments and any horizon and step :

(a) , with equality iff for every with .

(b) , with equality iff for every with and every .

Proof in Appendix B.

Exercise 2.1 (Telescoping KL) [10]. Show by induction on that for all environments ,

where on the right-hand side, the summand uses the conventions , .

Hint

For the induction step, factor (and likewise for ) inside the log; the log splits additively into two pieces matching and .

Solution

By induction on .

Base case ():

using and likewise for .

Induction step. Apply the chain rule for probabilities (Definition 1.1) inside the log: , and similarly for . The log splits additively:

3. Mixture dominance

The mixture never assigns much less probability than any single environment weighted by its prior. This single inequality is the engine behind the cumulative bound of Section 4 below: dividing through gives , which is then fed into Pinsker and the chain rule in the proof of the main cumulative bound.

Exercise 3.1 (Mixture dominance) [05]. Show that for every and every ,

Solution

By Definition 1.2, . Every term in this sum is non-negative, so dropping all terms except the one with can only decrease the sum:

Remark (Solomonoff specialization). Under the Solomonoff prior, , so the bound becomes

This is what makes universal: a single predictor dominates the entire computable model class up to a factor that depends only on the model's description length.

4. Cumulative prediction error bound (main result)

The next ingredient relates squared prediction error to KL divergence (Cover & Thomas 2006, Lemma 11.6.1). We require the following inequality:

Theorem 4.1 (Pinsker's inequality). Let and be probability distributions over , i.e., with . Write and . Then

The proof of this inequality is mostly tedious algebra but is included in Appendix A.

Definition 4.2 (Cumulative expected and per step squared prediction error). For environments / predictors and horizon , the cumulative expected squared error and the per-step squared error at step are

Write and .

Exercise 4.1 (Cumulative prediction bound) [15]. Show that

Hint
Solution

The proof is a three-step chain:

Step (1): Pinsker, pointwise. For each and , both and are probability distributions on ( by Section 1), so Theorem 4.1 gives

Multiplying by and summing over gives , so (Exercise 2.1), from which we take .

Step (2): Mixture dominance. By Exercise 3.1, , so , hence pointwise. Substituting into the definition gives the bound.

Step (3): Total mass. Pull the constant out and use ( is an environment).

Exercise 4.2 (Explicit complexity bound) [05]. Specialize Section 4 to the Solomonoff prior (where is the length of the shortest program computing ) to show

Solution

By Section 4, for any prior, . The Solomonoff prior assigns the weight , so

Exercise 4.3 (Per-step error) [05]. Hence prove that the per-step expected prediction error

converges to zero as .

Solution

Follows immediately as implies .

5. Bounded number of prediction mistakes

So far we have bounded squared error. For a deterministic environment (i.e. a single infinite binary sequence in ), one can ask the sharper -loss question: how often does the mixture predict the wrong bit? The cumulative bound is strong enough to give an answer.

Let be a deterministic environment, so on every history; write for the unique bit on which puts all its mass. Define the threshold predictor associated with : at each step, predict the more-likely bit,

We say the mixture makes a mistake at time if .

Exercise 5.1 (Bounded prediction mistakes) [15]. Show that the number of mistakes made by the threshold predictor on the -trajectory is at most

Hint

At a mistake step, (why?). The per-step squared error along the deterministic -trajectory simplifies dramatically; bound it from below, then sum.

Solution

Step 1: per-step squared error along the -trajectory. Because is deterministic, the outer sum over in collapses onto the unique trajectory , with weight . Write for the mass the mixture places on the correct bit. Since assigns mass to and to the other bit,

Step 2: a mistake step contributes at least . A mistake at time means , i.e. the threshold predictor chose the other bit. This requires , i.e. , i.e. . So at every mistake step,

Step 3: sum and apply the cumulative bound. Let be the total number of mistakes. Summing over mistake steps (non-negative contributions from non-mistake steps only help):

where the last step is Section 4. Rearranging, .

Remark (Solomonoff specialization). Under the Solomonoff prior , so and the bound becomes

With the constant is just under , so if the true environment is computable, and can be described by a program at most bits long, then the predictor will make at worst mistakes over predicting the entire sequence . Note that the bound is purely existence-style: it does not say when the mistakes happen. They could all occur at the start, or be arbitrarily far into the future.

6. Pareto optimality under KL loss

The final two sections establish that the Bayesian mixture is uniquely Pareto-optimal under both KL and squared prediction loss: no other predictor can do at least as well as on every environment without coinciding with entirely.

Definition 6.1 (Pareto domination). For some measure of loss that takes an environment and a predictor , a predictor weakly Pareto-dominates with respect to loss and class if

is Pareto-optimal (w.r.t. ) if the only predictor that weakly dominates it is itself.

We specialize to in Section 6 and to in Section 8.

Exercise 6.1 (KL Pythagorean identity) [10]. For any predictor with on every , show that

Hint

Take the difference between the two summation terms.

Solution

Take the difference . Inside each the pieces cancel, leaving

The factor does not depend on , so we swap the order of summation and pull it out, then use :

Rearranging gives the claimed identity.

Exercise 6.2 (KL Pareto-optimality) [05]. Show that is Pareto-optimal under in the sense of Definition 6.1: if is any predictor with

then .

Hint

Multiply the assumed inequality by and sum over ; then apply the KL Pythagorean identity to recognize the extra non-negative term, which must vanish.

Solution

Multiply the assumed inequality by and sum over :

The KL Pythagorean identity rewrites the LHS as

so Equation 3 forces . KL is non-negative, hence , which forces for every . By chain rule, the conditionals agree at every history with .

7. Misspecified models: when

The cumulative bound Section 4 assumed the true environment lives in the model class . What happens when it does not? We now show the bound degrades gracefully: it splits cleanly into a complexity term ("cost of not knowing which model is best"), exactly as before, plus a linear-in-time approximation term ("cost of no model being right"). See (Hutter 2005, §3.2.8) for the original treatment.

Throughout this section, we no longer assume . We will state the bound in terms of an arbitrary , so taking the infimum over on the right-hand side gives the tightest version by using the "closest" approximation of to .

Exercise 7.1 (Misspecified KL bound) [10]. Show that for all ,

Hint
Solution

Mixture dominance applied to (Section 3) gives for every . Hence , and taking logs,

Now take the -expectation. The LHS becomes ; the second RHS term becomes ; the constant survives because has total mass .

Remark (Reading the two terms). The right-hand side splits into two qualitatively different terms:

  • is constant in : under the Solomonoff prior, this is . The familiar "complexity" cost of search.
  • The approximation term (by Exercise 2.1) is a sum of per-step KLs; in general it grows with . It vanishes identically iff matches on every -reachable history, in particular when and we pick , recovering Section 4.

Combining with Pinsker (Theorem 4.1) gives the corresponding bound on , which is infinite in general but inherits the rate of .

Details on how to define the best choice of are in Appendix D.

8. Pareto optimality under squared loss

The squared specialization (Definition 4.2) lives one level down from KL: at the conditional distributions . The natural Pythagorean decomposition at a fixed history uses posterior weights : those are the weights that make the mean of the 's (via the posterior-predictive form, Definition 1.2). The Pareto-optimality aggregation, however, uses prior weights . Bridging the two takes one extra Bayes-rule step.

Exercise 8.1 (Squared Pythagorean identity) [10]. Fix any and any history : the history is arbitrary, not sampled from any environment. For any and any predictor , show

Hint

Add and subtract inside the squared term, then expand. Use and the posterior-predictive form of (Definition 1.2), , to kill the cross-term. The weighting must be posterior weights (not prior weights ), because is the posterior-weighted mean of the 's, not the prior one.

Solution

Throughout, the history and symbol are fixed but arbitrary. Abbreviate , , , and for the duration of the calculation.

Step 1: is the posterior-weighted mean of the 's. By the posterior-predictive form of the mixture (Definition 1.2) and the posterior normalization ,

Step 2: the cross-term vanishes. A direct consequence of Step 1, again using :

Step 3: expand the square. Write and expand:

The middle sum is zero by Step 2; the trailing . So

Exercise 8.2 (Squared Pareto-optimality) [05]. Show that is Pareto-optimal under in the sense of Definition 6.1: if is any predictor with

then at every history with (equivalently, -almost surely) and every . Histories that the mixture never reaches (, i.e., reached by no either) are invisible to the loss and are not pinned down.

Hint

Multiply the assumed inequality by and sum over ; then for each fixed history , multiply the per-history Pythagorean identity from above by and use the Bayes identity to bridge from posterior weights (inside the identity) to prior weights (in the aggregated Pareto inequality).

Solution

Multiply the assumed inequality by and sum over :

Now bridge to the per-history Pythagorean. At each fixed history and symbol , the identity says

with the abbreviations , , . Multiply by and use Bayes, :

Sum over and all histories and symbols . The two terms become exactly and respectively, so

where

Combining with Equation 4,

Since is a sum of non-negative terms and is itself , every term vanishes: at every . So at every history with .

A. Proof of Pinsker's inequality

We first prove the following Lemma:

Lemma A.1 (Pinsker's binary inequality). For and we have

Define , so that

using . Recall also that on , so .

Case . For every we have , hence .

Integrating over ,

Case . For every we have , hence .

Integrating over ,

Proof of Theorem 4.1

We now reduce Theorem 4.1 to the binary inequality Lemma A.1. Recall and . We handle the boundary case first, then reduce the interior case directly to Lemma A.1.

Case 1: for some . If , then the right-hand side of contains , so holds trivially. If instead , that atom contributes to both sides (using the convention ). The other atom then satisfies and , so both sides vanish and holds.

Case 2: . Since and , the two sides of become

So is exactly , which is Lemma A.1 with and (here , since ).

B. Proof of KL non-negativity

We prove Theorem 2.2. The core is the elementary inequality

(Let ; then , vanishing only at , with , so is strictly convex and attains its unique minimum at .)

Lemma B.1 (Gibbs' inequality). Let be probability distributions over a finite set , with the conventions and . Then

with equality iff for every with .

Proof

If for some with , the LHS is and the inequality is strict. Otherwise restrict the sum to (terms with contribute by convention), where every ratio is in . Apply to :

where the last step uses (the sum over may miss some -mass). Negating gives the claim. Equality in requires for every with , i.e. there; equality in then forces to have no mass outside . Both together give on all of .

Proof of Theorem 2.2

Part (a). Apply Lemma B.1 with , , . Both are probability distributions on since and are environments. The lemma gives with the stated equality condition.

Part (b). For each fixed history with , apply Lemma B.1 with , , (both are probability distributions on ):

with equality iff . Multiply by and sum over : this gives , as a sum of non-negative terms. Equality forces every with to contribute a vanishing inner sum, which is exactly the stated condition.

C. Model Class

All results in this sheet hold for any countable class and prior . The canonical Solomonoff choice takes to be the class of all computable environments and the Solomonoff prior

where is the Kolmogorov complexity of : the length of the shortest program that computes . The Bayesian mixture under this particular prior is the universal mixture, written . With this class the assumption reduces to "the universe is computable": as weak an assumption as one can make. For technical details on Kolmogorov complexity, see (Hutter et al. 2024, §2.7).

The class of all computable measures is countable but not enumerable (by the halting problem, you can't decide which Turing machines define total functions), so one can't even formally write as the decision problem of determining if is undecidable. A faithful construction of requires expanding to all lower-semicomputable semimeasures (Levin), at which point becomes a semimeasure rather than a measure: instead of , conditionals may not sum to , and every other proof in this sheet gains a side-case. This also gives the nice benefit that .

We dodge all of this: is just some countable set of proper measures with , and we assume is defined for each when we need it. We never need itself to be in , nor do we need its computability, so we don't ask. See (Hutter 2005, §2.4.3) for the full Levin construction.

D. Best choice of .

The bound is valid for every . A tempting question: which gives the tightest bound? The answer is genuinely setting-dependent.

Finite horizon . The minimizer of the RHS is

This is well-defined (finitely many terms, attained when is finite), but the answer depends on : for small the prior term dominates and a high-prior coarse model wins; for large the fit term dominates and the best per-step approximator wins. Both regimes are correct.

Asymptotic rate. A horizon-free analogue minimizes the per-step KL rate

This is the right notion when one cares about the linear-growth slope of the bound. But it has two drawbacks: the limit need not exist for non-stationary (one can substitute but at the cost of clarity), and it discards the prior entirely, so the minimizer is not the same as at any finite , but only of its slope.

Stationary . The per-step KLs are constant in , so all three notions essentially agree: , where the KL is taken under the (common) one-step conditional law. This is the case where " = projection of onto in KL" has unambiguous meaning.

Upshot. The bound holds for all , and one is free to take the infimum on the RHS over . Which actually attains that infimum is a separate question whose answer depends on horizon, prior, and any structural assumptions on .

References

T. M. Cover and J. A. Thomas (2006). Elements of Information Theory. Wiley-Intersience.

Marcus Hutter, David Quarel, and Elliot Catt (2024). An Introduction to Universal Artificial Intelligence. Chapman & Hall.

D. E. Knuth (1973). The Art of Computer Programming, Volume I: Fundamental Algorithms. Addison-Wesley.