In Bellman equations we fixed a policy π and evaluated it. Here we look for the best policy. The trick is to view the Bellman equations as fixed points of operators on value functions. We follow the assumptions and notation from the previous note.
For a state s, an action a and any vector v∈R∣S∣, define the one-step lookahead
F(s,a,v)=R(s,a)+γs′∈S∑P(s′∣s,a)v(s′)
This can be read as take action a in state s, collect the immediate reward, and then pretend that v correctly scores wherever you get to. F depends only on the MDP, not on any policy, and plugging in v=Vπ gives F(s,a,Vπ)=Qπ(s,a)
Averaging the lookahead over a policy gives the Bellman operator Tπ:
(Tπv)(s)=a∈A∑π(a∣s)F(s,a,v),i.e.Tπv=Rπ+γPπv
The Bellman expectation equation Eq.9 from the previous note is then just TπVπ=Vπ. In other words, Vπ is a fixed point of Tπ.
Taking the best action instead of the average gives the Bellman optimality operatorT:
Banach fixed point theorem: an operator H on Rd with ∥H(x)−H(y)∥≤β∥x−y∥ for some β<1 has exactly one fixed point x∗, and iterating H from any starting point converges to it, with ∥Hk(x0)−x∗∥≤βk∥x0−x∗∥.
By Banach's fixed point theorem, it follows that Tπ has exactly one fixed point, which must be Vπ, which we call V∗.
The main theorem
Theorem. Let V∗ be the unique fixed point of T, and let π∗ be greedy with respect to V∗. Then,
Vπ∗=V∗,
Vπ≤V∗ for every policy π.
So V∗(s)=maxπVπ(s) in every state, and π∗ is optimal. With finitely many actions the argmax is never empty, so there is always a deterministic optimal policy.
Proof of (1). Since π∗ is greedy: Tπ∗V∗=TV∗=V∗. So V∗ is a fixed point of Tπ∗. But Tπ∗ has only one fixed point, Vπ∗.
Proof of (2). Take any π. By domination,
Vπ=TπVπ≤TVπ.
Now if you apply T to both sides repeatedly. Monotonicity keeps the inequality, so Vπ≤TVπ≤T2Vπ≤⋯≤TkVπ. By Banach, TkVπ→V∗, hence Vπ≤V∗.
Note that the max is achieved in every state simultaneously by the same policy, which isn't something that surprises me when I first saw this.
The Bellman Optimality Equations
Consider Q∗(s,a)=F(s,a,V∗) for the Q-function of an optimal policy, so that V∗(s)=maxaQ∗(s,a). From the fixed point equation V∗=TV∗ and its counterpart for Q∗ we obtain: