From Code to Compliance

Thoughts & analysis on AI, law, and everything between.


Finite-Memory Hypothesis Testing and World Models

TL;DR

How much can a limited observer infer about a hidden process, and when is a learned model of that process good enough to plan with?

Nick Bostrom’s 2003 paper on the simulation argument made me think about what an observer can infer about the system that generates its experience. An observer has access to what happens inside that system and has to reason about what produced those observations. I wanted to connect that question to world models, where an agent learns about its environment from experience and then uses what it learned to decide what to do. Bostrom’s paper

I split the work into two parts. The first asks what can be inferred with a strict limit on memory. The second asks when a learned model is reliable enough to use for planning. They share a question about what an observer can infer from the information available to it, but the mathematical setup and the experimental setup answer different questions.

Finite-memory hypothesis testing

The source emits a sequence of zeros and ones. There are two hypotheses, H=+1H = +1 and H=−1H=-1. At the start, the source draws a hidden phase ZZ uniformly from {0,1}\{0,1\}. The phase decides which parity of time indices carries information about HH. Given H=hH = h and Z=zZ = z, the observations are independent. For a bias parameter 0<c<120<c<\frac12, write qt(h,z)q_t(h,z) for the conditional probability Pr⁡(Xt=1∣H=h,Z=z)\Pr(X_t=1\mid H=h,Z=z). It takes two values

qt(h,z)={12+hc,t mod 2=z,12,t mod 2≠z.q_t(h,z) = \begin{cases} \frac12 + hc, & t \bmod 2 = z,\\ \frac12, & t \bmod 2 \ne z. \end{cases}

For example, if Z=1Z = 1, observations one and three carry a bias and observations two and four are fair coin flips. The observer sees the bits but has to infer which hypothesis generated them without being told the phase.

Now give the observer three internal states. A deterministic observer has one destination state for each pair of current state and observed bit. A randomized observer assigns a probability distribution to the destination. After the final observation, the test can use only the final state. The objective is the total variation distance between the two distributions of that final state, where p+(s)p_+(s) and p−(s)p_-(s) are its probabilities under the two hypotheses.

TV⁡(p+,p−)=12∑s∣p+(s)−p−(s)∣,Perrormin⁡=12(1−TV⁡(p+,p−)).\begin{aligned} \operatorname{TV}(p_+,p_-) &= \frac12\sum_s |p_+(s)-p_-(s)|,\\ P_{\mathrm{error}}^{\min} &= \frac12\bigl(1-\operatorname{TV}(p_+,p_-)\bigr). \end{aligned}

With equal priors, the second equation explains why a larger distance matters. It lowers the best achievable probability of making the wrong decision from the final state.

Manuscript 1 — Four observations. At the four-observation horizon, the best deterministic three-state observer in the comparison achieves total variation 5c4\frac{5c}{4}. An explicit randomized observer reaches 9403c7500\frac{9403c}{7500}. The gap is positive for every c>0c > 0 in the model, with the same three-state budget.

9403c7500−5c4=7c1875>0\frac{9403c}{7500} - \frac{5c}{4} = \frac{7c}{1875} > 0

The gain is small and exact. This construction shows that randomized transitions can improve the decision without adding a state. This manuscript was prepared for the Journal of Applied Probability.

Manuscript 2 — Three and five observations. The second manuscript computes exact deterministic optima at both horizons and gives rational randomized transition probabilities that achieve strictly greater total variation for 0<c<120<c<\frac12. The comparison covers a range of source biases rather than a single numerical example. Submitted to Stochastic Models.

Manuscript 3 — Exact and approximate testing. Here the reference is the optimal decision using all nn observations. Write P+(n)(w)P_+^{(n)}(w) and P−(n)(w)P_-^{(n)}(w) for the probabilities of observing the entire binary word ww under the two hypotheses. Then the full-history benchmark is

Bn(c)=12∑w∈{0,1}n∣P+(n)(w)−P−(n)(w)∣B_n(c) = \frac12\sum_{w\in\{0,1\}^n}\left|P_+^{(n)}(w)-P_-^{(n)}(w)\right|

For odd nn, the manuscript gives a lower bound of (n(n−1)/2)\binom{n}{(n-1)/2} states for matching this benchmark exactly, where (nk)\binom{n}{k} counts the ways to choose kk elements from nn. With fixed positive tolerance ε\varepsilon, a reflected counter can instead use O ⁣(1+log⁡(1/ε)c)O\!\left(\frac{1+\log(1/\varepsilon)}{c}\right) states once the horizon is sufficiently long. These bounds count states. The number of bits needed to encode mm states is ⌈log⁡2m⌉\lceil \log_2 m\rceil. Submitted to IEEE Transactions on Information Theory.

World models

A world model learns how a state changes after an action. A planner can use the model to simulate several candidate action sequences, estimate the outcome of each, and choose what to do. The model’s predictions are then used as inputs to later predictions. A small error on one step can propagate through the rest of the simulated trajectory, especially if the planner considers actions that take the model into states it has rarely seen.

For a concrete example, imagine a planner deciding whether to brake now or in two steps. The learned model slightly underestimates how far the system will travel at each step. That difference may be small in a prediction report, yet after several steps it may make the late-braking option look safer than it is. A larger error elsewhere may leave the preferred action unchanged. I want to measure both effects by comparing the model’s forecasts with the reference environment and checking whether the model changes which action the planner prefers.

The first practical step is to measure how errors accumulate. In my Latent Dynamics Benchmark, a linear transition model is fitted on seeded synthetic trajectories. The benchmark evaluates free-running predictions on held-out trajectories, reports error over a specified rollout horizon, and compares it with a persistence baseline that predicts the state will stay where it is. The reference dynamics are known, so the error is directly measurable. In the benchmark, xtx_t is the state and utu_t is the action.

xt+1=0.92xt+0.35utx_{t+1}=0.92x_t+0.35u_t

The rollout error over TT steps is

RMSE⁡=1T∑t=1T(x^t−xt)2.\operatorname{RMSE}=\sqrt{\frac1T\sum_{t=1}^T(\hat{x}_t-x_t)^2}.

The sum compares each predicted state with its corresponding reference state. The rollout feeds each predicted state back into the fitted model, so the metric reflects errors that accumulate over multiple steps. This experiment measures state prediction in a one-dimensional system. The next experiment adds planning and evaluates the selected action sequence in the reference environment. Latent Dynamics Benchmark

The connection to Bostrom is the question about what an observer can infer about a system it experiences from within. For world models, I can make part of that question testable by fixing a reference environment, controlling what the agent sees, and measuring the consequences of planning with a learned model.

Finite-Memory Hypothesis Testing and World Models