Inverting the Bellman Equation: From $Q$-Values to World Models

Alistair Letcher, Mattie Fellows, Alexander D. Goldie, Jonathan Richens, Jakob N. Foerster, Oliver RichardsonarXiv 2026

TL;DR

Model-free reinforcement learning agents trained on multiple goals secretly learn an accurate model of their environment's physics. This paper introduces P-learning, a method to invert the Bellman equation and extract this hidden "world model," revealing that model-free agents possess surprising, latent zero-shot generalization capabilities.

What Problem Does This Paper Address?

Reinforcement learning (RL) is traditionally split into two separate paradigms:

  1. Model-free RL, where agents learn what actions to take based on rewards without understanding the underlying physics.
  2. Model-based RL, where agents explicitly learn a "world model" (how the environment transitions from state to state) to plan ahead.

Model-free agents are notoriously narrow—change the reward function slightly, and they usually have to relearn everything. This is due to the value equivalence problem: many completely different environment dynamics can yield the exact same optimal policy or value function ($Q$-values). Because model-free agents only learn what they value rather than what they understand, their internal knowledge has been historically viewed as uninterpretable and non-transferable.

This paper challenges this dichotomy by asking a fundamental question: When do model-free agents implicitly encode an accurate model of their environment?

Methods

The authors prove that if a value-based agent is trained on a sufficiently rich set of goals (Goal-Conditioned RL), the value equivalence problem breaks, forcing the agent to implicitly encode a unique and accurate world model.

To extract this hidden model, they introduce P-learning, an inverse analogue to Q-learning. While standard Q-learning holds the environment dynamics fixed and iteratively updates value estimates, P-learning holds the agent's learned $Q$-values, policies, and rewards fixed, and iteratively updates a candidate world model to make it mathematically consistent with the Bellman equation.

Figure 1: Illustration of P-learning: extracting the world model contained in an agent’s Q-values. Code available at github.com/aletcher/inverting-bellman.

The authors provide rigorous theoretical guarantees across four regimes (deterministic/stochastic and finite/continuous state spaces), mapping out the exact number and distribution of goals required to perfectly reconstruct the environment's true transition kernel.

Datasets

The authors evaluate their approach on three standard RL benchmarks modified for goal-conditioning:

  1. FourRooms: A discrete gridworld benchmark tested across three levels of stochasticity (deterministic, windy, and teleporting).
  2. MuJoCo Reacher: A continuous, deterministic robotic arm environment.
  3. MountainCar: A continuous physics environment used to evaluate generalization across distinct state variables (position vs. velocity).

Key Insights and Ideas

  • Value Equivalence is Fragile: You don't need infinite goals to understand the world. Training an agent on just a handful of diverse objectives provides enough mathematical constraints to uniquely pin down the true environment dynamics from model-free value functions.
  • The "Local-Global" Hypothesis: Value-based agents trained to predict returns on a small number of local goals (e.g., reaching specific spatial positions) tend to implicitly encode an accurate world model over all dependent environment variables—including features the rewards never directly depended on, like velocity.
  • Zero-Shot Planning via Extraction: Because the extracted implicit world model captures the true physics of the environment, you can drop a standard planning algorithm inside it to solve completely out-of-distribution (OOD) tasks zero-shot, without ever retraining the original model-free agent.

Key Results

  • High-Fidelity Extraction: In the continuous Reacher environment, using an agent trained on just $|G| = 4$ position-based goals, P-learning extracted a world model with an incredibly low Normalized Mean Squared Error (NMSE) of $1.2 \times 10^{-4}$, even though the agent's underlying $Q$-values were coarsely approximated (NMSE = $0.57$).
Figure 2: Q-values (top) and implicit WM (bottom) of a Reacher agent trained on |G| = 4 goals. Learnt values Qg(θ, ω, a) are coarsely similar (NMSE = 5.7 × 10−1) to ground truth Qtrue, shown for g = (0, 1), a = (1, 1) and two slices ω = (1, −1), θ = (1, −1). Nevertheless, the extracted WM P(θ, ω, a) is highly accurate (NMSE = 1.2 × 10−4), shown for prediction of y-position Py vs true P true y (same slice). Bottom right: WM/true rollouts of goal-conditioned policy for two start states.
  • Performance Correlates with Understanding: The authors identified a powerful Spearman rank correlation ($\rho = -0.98$) between an agent's return and the accuracy of its internal world model. Higher network capacity and better model-free performance directly cause the agent to internalize a better model of the world.
Figure 4: Agent return on training goals (left), implicit world model MSE (middle) and return of WM-extracted policies on unseen goals (right), for a Reacher agent trained with just |G| = 4 goals. Top: metrics as a function of training time for fixed width W = 512 and increasing depth D. Bottom: Heatmap over all widths/depths at the end of training, with mean ± SE over 10 seeds. The Spearman correlation coefficient between agent return and WM error is ρ = −0.98 [−0.99, −0.95].
  • Superb Sample Efficiency: In the discrete FourRooms environment ($|S| = 68$), perfect or quasi-perfect world model recovery was achieved using a tiny fraction of candidate goals: just 1 goal for deterministic dynamics, 4 for windy dynamics, and roughly 20 for fully stochastic teleportation dynamics.

Limitations and Future Work

  • Continuous Stochastic Limits: The theoretical proofs for stochastic continuous environments currently only apply to unconditional policies (where the agent's behavior doesn't change based on the goal). Extending this to goal-conditioned policies remains an open challenge.
  • Algorithmic Scope: This framework is strictly limited to value-based agents that learn $Q$-values. It does not encompass pure policy gradient methods or partially observable Markov decision processes (POMDPs).
  • Scale: While highly effective on standard continuous control tasks, P-learning has yet to be tested on massive, high-dimensional environments like Atari or complex 3D simulators.
  • Future Outlook: The authors propose using P-learning as an interpretability or auditing tool, allowing researchers to "peek" inside a model-free agent's mind to see what it actually understands about safety and physics before deploying it in the real world.

Summary updated

BibTeX
@misc{letcher2026inverting,
  author = {Alistair Letcher and Mattie Fellows and Alexander D. Goldie and Jonathan Richens and Jakob N. Foerster and Oliver Richardson},
  title = {{Inverting the Bellman Equation: From $Q$-Values to World Models}},
  year = {2026},
  eprint = {2606.21173},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2606.21173},
}
Figure