Both are maps from one value function to another; v* and v^π are their fixed points.
Introduction to Reinforcement LearningPart 1 · Foundations
Lecture 4Theory of dynamic programming
Why dynamic programming works: norms, contraction mappings and fixed points, the Bellman operators, how fast value iteration converges, and what a small error in the values can cost a greedy policy when dynamic programming is only approximate.
Key ideas, one per episode
- Ep. 15Apply a contraction until it stops moving.
- Ep. 16Exact DP converges. Approximate DP can break, but greedy degrades gracefully.
Based on: Lecture 4: Theoretical Fundamentals of Dynamic Programming, DeepMind × UCL Reinforcement Learning Lecture Series (2021), by Diana Borsa. The slides follow that order of topics, in our own words, figures and examples; they are not official material of the original course.
Watch
2 short episodes of ACML Explains for this lecture. Pick one from the list, and open the transcript to read along: each timestamp plays the episode from there. The narration is generated with a voice clone of Teddy, used with his permission.
Episode 15 · 5:05
Why dynamic programming works
Drop a map of this room on the floor of this room. Exactly one point lands on itself. That's why value iteration converges.
Apply a contraction until it stops moving.
TranscriptEpisode 15
The map on the floor
Here's a trick. Take a map of this room, and drop it on the floor of this room. Somewhere on that map, there's exactly one point lying right on top of the spot it shows. Exactly one. Always. Wherever the map lands, however it's turned. As long as the whole map lies inside the room. Rotated, crumpled a bit, it doesn't matter. Today's question is why value iteration and policy evaluation always converge. And it's the same reason that map works.
The worst state
First, we need a way to say how far apart two value functions are. Take two guesses for the values, u and v. Compare them state by state, and keep the biggest gap. That's the max norm. The distance between two value functions is the worst state. Two guesses that agree everywhere, except one state where they differ by ten? The distance is ten. Not the average state. The worst. Bit is only as right as his most wrong state. Why not the average? Because a disaster in one state can hide behind a good average.
Contractions
Now, an operator: a machine that takes a whole value function in, and gives a whole value function out. It's a contraction if it pulls any two inputs closer together, by a fixed factor smaller than one. Distance before: d. Distance after: at most α times d, with α below one. And a fixed point is an input that comes out unchanged. T of x equals x. Like a thermostat set to twenty-one degrees. It pushes the room there, and once it's there, it stays. The map on the floor is a contraction of the room. And the point that lies on its own spot? The fixed point.
Banach's theorem
Now the beautiful theorem, from Stefan Banach, nineteen twenty-two. If T is a contraction on a complete space, then first: it has exactly one fixed point. Not two. Not zero. One. Second: start anywhere, apply T, apply it again, and again. You always land on that point. And third, it's fast: after n steps, the error is at most α to the n, times the error you started with. Geometric convergence. Every step chops off the same fraction of what's left. Banach proved this in his doctoral thesis. Not bad, for a thesis.
The Bellman operator
Now look at value iteration again. One sweep takes a value function, and returns a new one. For every state: the max over actions, of the reward plus γ times the expected value of where you land. Call that machine T star, the Bellman optimality operator. Value iteration is just: apply T star, again and again. Picture it: every possible value function is a point in a huge space. T star moves points around in that space. And T star is a contraction, with factor γ. So Banach does the rest.
The proof in one picture
Why is it a contraction? One picture. Take two guesses, u and v, that differ by at most d, anywhere. Average them over the next states: the averages differ by at most d. Averaging never stretches a gap. Multiply by γ: now at most γ times d. Add the same reward to both: the gap doesn't change. And taking the max over actions can't stretch it either. So every sweep shrinks the worst gap by at least γ. That's the whole proof. No calculus. Just three facts. Averages don't stretch gaps. Maxes don't stretch gaps. And γ shrinks them. Three facts come out: there's one fixed point, v star. Value iteration reaches it from any start. And T star is monotone: bigger input, bigger output. Monotone matters too. Start below v star, and you stay below it, creeping up on every sweep.
Our numbers
We tried it on a small random MDP we made up: ten states, two actions, γ at point nine. The error starts at about four point six. After forty sweeps: about point zero six. That's about seventy-five times smaller. And the bound, γ to the k, sits right on top of it the whole way. With γ at point nine, every twenty-two sweeps cut the error at least ten times. With γ at point nine nine, you need about two hundred thirty sweeps for the same cut. Looking far ahead costs computation.
One idea behind DP
Same story for policy evaluation. Drop the max, average over what π picks instead. Call it T π. Also a γ-contraction. Also monotone. Its one fixed point is v π. So iterative policy evaluation converges too, from any starting guess. And the same holds for q functions. So every algorithm from module three is secretly the same thing: apply a contraction until it stops moving. This is why I keep saying this course makes good promises. Here's the proof. Value iteration: apply T star. Policy evaluation: apply T π. Policy iteration: alternate evaluating with T π and improving greedily. But all of this assumed we know p and can store every value exactly. Next time: what breaks when we can't. With me so far?
Two luxuries
Everything so far assumed two luxuries. We know the MDP perfectly, and we can store every value exactly. In real life? We usually get neither. We don't know p, so we estimate the Bellman update from samples. That adds sampling error. And we can't keep a table with a value for every chess board. So we fit a function: a linear model, or a neural network. That adds approximation error. Two errors, from two directions. Sometimes they cancel. Usually, they don't. The goal stays the same: a policy that's optimal, or at least close. This is where deep RL lives: big networks, and samples instead of the true model.
Approximate value iteration
Approximate value iteration: apply T star, then squeeze the result back into our function class. For example, choose the parameters that minimise the squared distance to the Bellman target, over the states. It sounds harmless. Fit a little, update a little, repeat. Does it still converge to v star? In general… no. The fitting step isn't a contraction in the max norm. Banach's promise is gone. Each fit on its own is fine. It's the repetition that hurts.
A divergence example
Here's a famous example, from Tsitsiklis and Van Roy. Two states, one parameter, θ. The first state's value is θ. The second's is two θ. All rewards are zero, and there are no decisions. The first state always moves to the second. The second stays put, except with a small chance, ε, the episode ends. All rewards are zero, so the true values are zero. Easy, right? Fit θ by least squares to the targets. Work through the algebra, and each step multiplies θ by six minus four ε, times γ, over five. With ε one eighth and γ equal to one, that's one point one. Start at one. Ten steps: two point six. Thirty steps: seventeen. The truth is zero, and the estimate runs away. Why? The fit cares about both states at once. To fix the second state, it pushes θ up, and drags the first state with it. Notice: with γ at point nine, the factor is point nine nine, and it slowly converges. Divergence needs γ above about point nine one. So the danger is real. But it needs the right conditions. Or the wrong ones.
Hopeless? Not quite
Hopeless? Not quite. Sampled, online versions of these algorithms do converge, under mild conditions. Even with function approximation, the danger of divergence rarely shows up in practice. And in this very example, there's a fix: weight each state by how often you actually visit it. Then it converges. And remember: we don't need the values to be right. We need them to be in the right order. Many value functions give the same optimal policy.
How good is a greedy policy?
Which raises the real question. If my values are a bit wrong, and I act greedily on them, how bad is my policy? There's a theorem for that. Take any q, and its greedy policy π. How much worse π is than optimal, is at most two γ over one minus γ, times how far q is from q star. Read it as an exchange rate. Value error goes in, performance loss comes out. Small errors in values, small loss in performance. Graceful. If your q is off by at most some small amount everywhere, your greedy policy loses at most that factor times that amount.
Reading the factor
Let's read the factor. γ at point nine: eighteen. γ at point nine nine: about two hundred. So the longer you look ahead, the more a small value error can cost you. Errors compound along the way. So with long horizons, invest in accurate values. They're worth it. γ equals zero: the factor is zero. Why? With no future, every policy has the same q: just the immediate reward. Nothing to get wrong. And if q equals q star, the bound is zero: being greedy on q star is optimal. Matches what we said in module three.
The proof
The proof is five lines. Add and subtract T π of q, then use the triangle inequality. Because π is greedy on q, T π of q equals T star of q. Then use the contraction, twice. Collect the terms, and divide by one minus γ. That's where the factor comes from. Not deep. Just the same contraction trick, used twice.
Module four, done
And approximate policy iteration? Evaluate approximately, improve greedily. Do the values converge to q star? In general, no. Does the policy converge to the optimal one? In general, also no. It depends on the approximation. We'll come back to that when we meet function approximation properly. Deep RL papers spend a lot of effort fighting exactly this instability. So, module four. Exact dynamic programming converges, because Bellman operators are contractions. Approximate dynamic programming can break that promise. But greedy policies degrade gracefully, and we know by how much. Being greedy is safe, as long as your values are good. Next module: we drop the model completely, and learn from experience. With me so far? See you in module five.
Interactive lab
Contraction lab
Start two different value functions on a small random MDP and apply the Bellman operator to both, again and again. The distance between them shrinks by at least a factor γ each time, so both end at the same fixed point.
This is the contraction argument of Lecture 4, run instead of proved: ‖T u − T w‖∞ ≤ γ ‖u − w‖∞. The dashed line is the bound γᵏ ‖u₀ − w₀‖∞; the measured distance never goes above it.
Two starting points, one fixed point
A small random MDP with six states and two actions. Both value functions, u and w, get the same operator again and again.
Each application shrinks the largest gap between two value functions by at least a factor γ.
The gap falls at least geometrically, whatever the start: there is one fixed point and every start reaches it (Banach).
u₀ and w₀ are random. Press Apply once.
The gap, on a log scale
Measured ‖uₖ − wₖ‖∞ against the bound γᵏ ‖u₀ − w₀‖∞, and how far u still is from the fixed point.
The two value functions
One pair of bars per state. The green tick is the fixed point both are heading to.


