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

Alistair Letcher, Mattie Fellows, Alexander David Goldie, Jonathan Richens, Jakob Nicolaus Foerster, Oliver Ethan RichardsonNeurIPS 2026

TL;DR

Reinforcement learning usually draws a sharp line between agents that learn how the world works (model-based) and agents that simply learn what actions pay off (model-free). This paper erases that boundary, proving that model-free agents trained on a diverse enough set of goals secretly construct an accurate, unique map of their environment's physics. By "inverting" the fundamental math of reinforcement learning, we can read an agent's mind, extract its hidden world model, and use it to solve completely new tasks zero-shot.

What Problem Does This Paper Address?

Imagine navigating a pitch-black maze. If someone tells you that taking a step left gets you closer to the exit, you know the value of that action, even if you don't know the exact layout of the walls. In reinforcement learning (RL), this is the classic divide: model-free agents learn action-values ($Q$-values) tied to a specific reward, whereas model-based agents explicitly learn the transition dynamics ($P$, or how states lead to next states).

Because totally different environments can yield the exact same $Q$-values—a roadblock known as value equivalence—it has long been assumed that you cannot uniquely reconstruct the rules of an environment just by looking at a model-free agent's value estimates. Knowing what an agent values doesn't tell you what it understands.

However, modern agents are increasingly trained on multiple objectives via Goal-Conditioned RL (GCRL). The authors ask a deceptively simple question: If a model-free agent learns to achieve enough different goals, do those combined constraints force it to implicitly learn the true physics of its world?

Methods

At the heart of RL lies the Bellman equation, which states that the value of an action today equals the immediate reward plus the discounted value of where you land tomorrow. Standard $Q$-learning treats the environment's transition dynamics ($P$) as fixed and iteratively updates $Q$-values to satisfy this equation.

The authors flip this on its head with a novel algorithm called $P$-learning. Given a trained agent with fixed goal-conditioned $Q$-values, policies ($\pi$), and known reward functions ($r$), $P$-learning treats $P$ as the unknown variable. It optimizes a candidate world model to minimize the Bellman residual—finding the transition dynamics most consistent with the agent's internal values.

Illustration of P-learning: while Q-learning extracts action-values from an environment, P-learning inverts the process to decode the agent's implicit world model directly from its Q-values.

Unlike $Q$-learning, which chases a moving target during optimization, $P$-learning is a clean, stationary supervised learning problem—requiring zero new interactions with the real environment. In finite, tabular settings, the Bellman equation becomes a system of linear equations, and $P$-learning converges neatly to a closed-form solution via the Moore–Penrose pseudo-inverse. For continuous spaces, the model is trained via gradient descent using the reparameterization trick or direct backpropagation.

Datasets

Because this is an RL paper, evaluation takes place in interactive simulated environments rather than static datasets:

  • FourRooms: Modified into three increasingly stochastic variants—deterministic, local ("windy"), and fully stochastic ("teleporting")—to test finite-state theory.
  • MuJoCo Reacher: A continuous, deterministic robotic arm task using sparse, position-based goals (matching the ReacherHard setup).
  • MountainCar: Augmented by the authors to support arbitrary goal-conditioning (e.g., reaching specific positions or velocities) rather than just reaching the single default hilltop.

Key Insights and Ideas

  • Goals break ambiguity: While a single goal leaves the world's physics underdetermined, multiple goals act like triangulation. In finite deterministic worlds, just one generic (noisy) goal is mathematically enough to uniquely pin down $P$. In finite stochastic worlds, the goals simply need to span the state space.
  • Hidden generalization: Model-free agents know far more than their training tasks suggest. An agent trained only to reach specific spatial coordinates implicitly learns velocity dynamics too—because to predict future positions accurately, its internal representations must account for momentum.
  • Convergent mental models: Two MountainCar agents trained on completely orthogonal objectives—one chasing positions, the other chasing velocities—end up encoding nearly identical internal world models.
  • Better agents have better physics: As you scale up a neural network's width and depth, the agent's task performance correlates near-perfectly with the physical accuracy of its extracted world model. Goal-conditioned RL appears to be a secretly hybrid (model-free + model-based) paradigm.

Key Results

Even when practical setups violate strict theoretical assumptions (like using just 4 sparse goals in a continuous space instead of infinitely many), $P$-learning extracts remarkably crisp dynamics:

  • Noisy values, crisp physics: In Reacher (trained on just 4 fingertip-position goals), even when the agent's learned $Q$-values are only coarsely accurate compared to ground truth ($\text{NMSE} = 5.7 \times 10^{-1}$), the extracted world model is razor-sharp ($\text{NMSE} = 1.2 \times 10^{-4}$).
  • Zero-shot OOD planning: By running value iteration purely inside the Reacher agent's extracted world model, the resulting policies achieve quasi-optimal returns on out-of-distribution tasks—including reaching target joint angles and target angular velocities, despite the agent never seeing velocity rewards during training.
  • Strong performance-fidelity link: Across varying network architectures in Reacher, the Spearman rank correlation between an agent's training return and its implicit world model error is $\rho = -0.98$.
  • Convergent representations: In MountainCar, the world models extracted from a position-trained agent and a velocity-trained agent are ~42 times closer to each other ($\text{NMSE} = 1.7 \times 10^{-4}$) than to the true environment ($\text{NMSE} = 7.2 \times 10^{-3}$).
  • Stochastic validation: In FourRooms, exact dynamics recovery required just $|\mathcal{G}| = 1$, $4$, and $20$ goals for deterministic, windy, and teleporting variants, respectively.

Limitations and Future Work

The authors are upfront about several caveats:

  • Theoretical gaps: For continuous and stochastic environments, their mathematical uniqueness proofs currently only hold for unconditional policies (a single policy evaluated across many goals), leaving general goal-conditioned policies as an open conjecture.
  • Scope: The method requires agents that explicitly learn $Q$-values (excluding pure policy-gradient methods) and assumes full observability (excluding POMDPs). Scalability to massive finite state spaces also remains untested.
  • Not a replacement for MBRL: $P$-learning is a diagnostic readout tool, not a sample-efficiency hack to replace model-based RL.

Looking ahead, this work opens a fascinating door for AI safety and interpretability: auditing an agent's "beliefs" about the world before deployment, diagnosing why generalization fails, and repurposing misspecified model-free agents for brand-new tasks without collecting a single new frame of data.

Summary updated

Abstract

Model-based and model-free reinforcement learning are traditionally viewed as separate paradigms: instead of learning a model of the transition kernel $P$, model-free agents typically estimate value functions tied to a specific policy and reward. In this paper, we challenge this dichotomy by proving that value-based agents trained on a sufficiently rich set of reward functions, e.g. using goal-conditioned RL, implicitly encode a unique and accurate world model. To extract this model in practice, we introduce $P$-learning, an inverse analogue to $Q$-learning that samples from an agent's $Q$-values, policies and rewards to decode its internal model of the environment. We then provide sufficient conditions on the type and number of goals for which agents encode the true kernel $P$, covering both stochastic and deterministic MDPs over finite or continuous state spaces. Even when our assumptions are violated, we empirically demonstrate that agents trained on a handful of reward functions encode accurate dynamics in Reacher, MountainCar and stochastic variants of FourRooms. Surprisingly, we find that policies trained exclusively on a Reacher agent's implicit world model are quasi-optimal on out-of-distribution, velocity-based goals despite position-only training -- suggesting that agents contain hidden generalisation capabilities and providing a new lens into the connection between model-based, model-free, and goal-conditioned RL.
BibTeX
@inproceedings{letcher2026inverting,
  author = {Alistair Letcher and Mattie Fellows and Alexander David Goldie and Jonathan Richens and Jakob Nicolaus Foerster and Oliver Ethan Richardson},
  title = {{Inverting the Bellman Equation: From $Q$-Values to World Models}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=ILIYkAejvy},
}
Figure