This note is an alternative treatment of Sections 18.1.2–18.2.4 of Principles of Robot Autonomy (2026), reorganized to suit the way I learn. A reader can use it in place of those sections and then return to the book.
The book's treatment is excellent, but it largely takes the existence of an optimal policy for granted, and under its definitions that existence was not obvious to me. The main goal here is to prove it (Theorem 4.3) and to show how the proof leads directly to the two classical algorithms, value iteration and policy iteration.
I have done my best to ensure correctness, but errors may remain.
1Mathematical Prerequisites
Definition 1.1 (Metric space).
A metric space is a set together with a function , called a metric, such that for all :
;
;
;
.
Example 1.2.
Let be a nonempty set. The set of bounded real-valued functions on ,
is a metric space under , which is finite because and are bounded. We write , so that . When is finite, every function on is bounded, and is simply with the max norm.
Definition 1.3 (Complete metric space).
A metric space is complete if every Cauchy sequence in converges to an element of .
It is straightforward to verify from the definitions that is complete.
Definition 1.4 (Contraction).
Let be a metric space. A map is a contraction if there exists such that for all . We then call a -contraction.
Theorem 1.5 (Banach fixed-point theorem).
Let be a nonempty complete metric space and let be a -contraction. Then:
there exists a unique such that ;
for any , the iterates converge to , and .
We use this theorem without proof. (The error bound in part 2 follows by applying the contraction property times to .)
Order notation. For we write if for every . Convergence in implies pointwise convergence, so pointwise inequalities survive limits: if and for all , then .
We will also need one elementary inequality.
Lemma 1.6.
Let be a finite set and let for . Then
Proof.
Let attain . Then . Exchanging the roles of and gives the same bound for .
□
2Finite Discounted Markov Decision Processes
A finite discounted Markov decision process (MDP) is a tuple
where is a finite set of states, is a finite set of actions,
is the transition probability, is the reward function, and is the discount factor. For every and ,
Throughout, and .
A stationary stochastic policy assigns to each state a probability distribution over actions:
When the system is in state , the action is drawn from . “Stationary” means the distribution depends only on the current state, not on the time or on the earlier history. We write for the set of all such policies. A deterministic policy is a map ; we identify it with the stochastic policy that puts probability on at each state . There are deterministic policies.
A finite trajectory of length has the form
Conditional on the initial state , its probability under is
For an infinite trajectory , the discounted return is
Since and are finite, is bounded: there is with for all , . Therefore
so the discounted return is well defined and bounded.
For a policy , the state-value function is
the expected discounted return when the process starts in and follows thereafter. By the bound above, .
Conditioning on the first action and the next state , and using the Markov property, we obtain the Bellman equation
(1)
3Policy Evaluation as a Fixed Point
We work in the complete metric space . Since is finite, this is just the space of all functions , and in particular .
For a policy , define the Bellman operator by
Lemma 3.1.
For every :
;
is a -contraction;
is monotone: if , then .
Proof.
Part 1 is the Bellman equation (1). For parts 2 and 3, note that for every ,
because the reward terms cancel. The weights are nonnegative and sum to . Hence
and taking the supremum over gives . If , the same identity (with and swapped) is a nonnegative combination of the nonnegative numbers , so .
So we can compute to any accuracy by applying repeatedly, starting from any function (for example ). This is called iterative policy evaluation.
4Existence of an Optimal Policy
Evaluating a given policy is not the end goal: we want the best one. Ideally we want a single policy that is at least as good as every other policy from every starting state.
Definition 4.1 (Optimal policy).
A policy is optimal if for every , that is, for every and every .
Asking for domination at every state simultaneously is a strong requirement: a priori, one policy might be best from while a different policy is best from . Fortunately this cannot happen.
2. is an average, with weights , of the bracketed quantities, and an average never exceeds the maximum, which is .
□
Theorem 4.3 (Existence of an optimal policy).
Every finite discounted MDP has an optimal policy, and it can be chosen to be deterministic. Moreover, if denotes the unique fixed point of , then for every optimal .
Proof.
Step 1: the fixed point. By Lemma 4.2 and Theorem 1.5, has a unique fixed point .
Step 2: a policy that achieves . Since is finite, for each the maximum in is attained. Define a deterministic policy by choosing, for each ,
Because puts all its mass on a maximizing action,
So is a fixed point of . By Corollary 3.2, the only fixed point of is ; hence .
Step 3: no policy does better. Let . By Lemma 4.2, . We claim that
The case is the inequality just shown. If it holds for , applying the monotone operator (Lemma 3.1) to both sides gives it for . Hence
so for all . By Corollary 3.2, , and passing to the limit gives .
Thus is optimal. Finally, if is any optimal policy, then and , so .
□
is called the optimal value function, and the equation is the Bellman optimality equation. The optimal value function is unique, but optimal policies need not be: any policy that is greedy with respect to , in the sense of Step 2, is optimal.
5Policies with Memory
Theorem 4.3 shows that is optimal among stationary policies. A natural worry is that a policy which looks at the clock, or remembers where it has been, could do better. This section shows it cannot.
Definition 5.1 (General policy).
A history at time is . A general policy assigns to each history a probability distribution over actions, and the action at time is drawn as .
For example, “take action for the first ten steps, then ” and “take if has been visited before, otherwise ” are general policies but not stationary ones. Stationary policies are the special case in which depends only on the last state .
Under a general policy, the probability of a trajectory is
and its value is defined exactly as before,
The environment is still Markov: whatever does, the next state is drawn from . What changes is that generally does not satisfy a Bellman equation of the form , because how behaves after reaching can depend on how it got there. So Step 3 of the proof of Theorem 4.3, which works through , does not apply. We need a different argument.
Proposition 5.2.
For every general policy , .
Proof.
Fix and a start state . For define
(i) The start: . With there are no rewards yet, only the term .
(ii) The limit: .
(iii) Each step goes down: .
Condition on the history and the action . However chose , the next state is drawn from , so . Hence
Since is the maximum over of the first two terms of , we have for every state and every action . Therefore .
Conclusion. By (iii), for every . By (i) and (ii), letting gives . Since was arbitrary, .
□
6Value Iteration
The proof is constructive. Starting from any (for example ), iterate
By Theorem 1.5, and . This algorithm is called value iteration. After stopping, we output a policy that is greedy with respect to the final iterate, as in Step 2 of the proof. The next proposition says that a good approximation of yields a good policy.
Proposition 6.1.
Let satisfy , and let be greedy with respect to , i.e. . Then
Proof.
Using , and ,
Each operator is a -contraction, so . Rearranging gives the claim.
□
In fact, because there are only finitely many deterministic policies, once is close enough to the greedy policy is exactly optimal; but how close is “close enough” depends on gaps in the problem that are not known in advance, so in practice one stops at a tolerance.
Complexity. One application of costs : for each of the states and actions, we sum over next states. With we have , so as soon as , that is,
Since , it suffices to take . The total cost is therefore
7Policy Iteration
Policy iteration takes a different route: it moves through a sequence of deterministic policies, each strictly better than the last, until it reaches an optimal one.
For a policy , define the action-value function
is the expected discounted return from starting at , taking action once, and following thereafter. In this notation,
The algorithm. Start from any policy . For :
Policy evaluation: compute (see below).
Policy improvement: define a deterministic policy
keeping whenever is deterministic and already attains the maximum.
Stop if .
The tie-breaking rule in step 2 prevents the algorithm from cycling among equally good policies.
Proposition 7.1 (Policy improvement).
Let and let be greedy with respect to , i.e. . Then
Consequently, if at some state , then ; and if , then is optimal.
Proof.
By construction, . Applying the monotone operator repeatedly, exactly as in Step 3 of the proof of Theorem 4.3 but with the inequalities reversed, gives
and this sequence converges to by Corollary 3.2. So . If , then is a fixed point of , so and is optimal.
□
Corollary 7.2.
Policy iteration terminates after at most improvement steps, with an optimal deterministic policy.
Proof.
All with are deterministic. If the algorithm stops, i.e. , then , so is optimal by Proposition 7.1. If it does not stop, the tie-breaking rule means that at some state the action does not attain , so , and Proposition 7.1 gives with strict inequality at . Value functions therefore strictly increase, so no deterministic policy is visited twice. Since there are deterministic policies, the algorithm stops after at most steps.
□
Exact policy evaluation. Unlike value iteration, policy evaluation can be done exactly, for any stationary policy (deterministic or not). Define the matrix and the vector by
The matrix is invertible: if , then , and since is row-stochastic, , which forces .
Complexity. Solving this linear system costs by Gaussian elimination, or with fast matrix multiplication (for example, with Strassen's algorithm). The improvement step computes at cost . One iteration of policy iteration therefore costs
In practice, policy iteration usually needs far fewer iterations than value iteration, but each iteration is more expensive.