Bellman Optimality Proofs

In Bellman equations we fixed a policy π\pi 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.

# Bellman Optimality Operator

For a state ss, an action aa and any vector v∈R∣S∣v \in \mathbb{R}^{|\mathcal{S}|}, define the one-step lookahead

F(s,a,v)=R(s,a)+γ∑s′∈SP(s′∣s,a) v(s′)\begin{equation} F(s, a, v) = R(s, a) + \gamma \sum_{s' \in \mathcal{S}} P(s' \mid s, a)\, v(s') \end{equation}

This can be read as take action aa in state ss, collect the immediate reward, and then pretend that vv correctly scores wherever you get to. FF depends only on the MDP, not on any policy, and plugging in v=Vπv = V^\pi gives F(s,a,Vπ)=Qπ(s,a)F(s, a, V^\pi) = Q^\pi(s, a)

Averaging the lookahead over a policy gives the Bellman operator TπT^\pi:

(Tπv)(s)=∑a∈Aπ(a∣s) F(s,a,v),i.e.Tπv=Rπ+γPπv\begin{equation} (T^\pi v)(s) = \sum_{a \in \mathcal{A}} \pi(a \mid s)\, F(s, a, v), \qquad \text{i.e.} \qquad T^\pi v = R^\pi + \gamma P^\pi v \end{equation}

The Bellman expectation equation Eq.9Eq. 9 from the previous note is then just TπVπ=VπT^\pi V^\pi = V^\pi. In other words, VπV^\pi is a fixed point of TπT^\pi.

Taking the best action instead of the average gives the Bellman optimality operator TT:

(Tv)(s)=max⁡a∈AF(s,a,v)=max⁡a∈A[R(s,a)+γ∑s′∈SP(s′∣s,a) v(s′)].\begin{equation} (Tv)(s) = \max_{a \in \mathcal{A}} F(s, a, v) = \max_{a \in \mathcal{A}} \Big[R(s, a) + \gamma \sum_{s' \in \mathcal{S}} P(s' \mid s, a)\, v(s')\Big]. \end{equation}

There are three properties of the Bellman operator that we will use to show that it has a unique fixed point. For all v,w∈R∣S∣v, w \in \mathbb{R}^{|\mathcal{S}|}:

  1. Tπv≤TvT^\pi v \le Tv for every π\pi, with equality when π\pi is greedy with respect to vv.
  2. If v≤wv \le w entrywise, then Tv≤TwTv \le Tw.
  3. Contraction. ∥Tv−Tw∥∞≤γ ∥v−w∥∞\|Tv - Tw\|_\infty \le \gamma\, \|v - w\|_\infty, and the same holds for every TπT^\pi.

Proof of (1). An average of F(s,a,v)F(s, a, v) over actions can't exceed its max, and it equals the max when all the weight is on maximizing actions.

Proof of (2). P(s′∣s,a)≥0P(s' \mid s, a) \ge 0, so v≤wv \le w gives F(s,a,v)≤F(s,a,w)F(s, a, v) \le F(s, a, w) for every aa, and taking the max over aa preserves the inequality.

Proof of (3). For any two functions of aa, ∣max⁡af(a)−max⁡ag(a)∣≤max⁡a∣f(a)−g(a)∣|\max_a f(a) - \max_a g(a)| \le \max_a |f(a) - g(a)|. Applying it to F(s,⋅,v)F(s, \cdot, v) and F(s,⋅,w)F(s, \cdot, w):

∣(Tv)(s)−(Tw)(s)∣≤max⁡a∣F(s,a,v)−F(s,a,w)∣=γmax⁡a∣∑s′P(s′∣s,a)(v(s′)−w(s′))∣≤γ ∥v−w∥∞.\begin{align} |(Tv)(s) - (Tw)(s)| &\le \max_a |F(s, a, v) - F(s, a, w)| \\ &= \gamma \max_a \Big|\sum_{s'} P(s' \mid s, a)\big(v(s') - w(s')\big)\Big| \\ &\le \gamma\, \|v - w\|_\infty. \end{align}

Banach fixed point theorem: an operator HH on Rd\mathbb{R}^d with ∥H(x)−H(y)∥≤β∥x−y∥\|H(x) - H(y)\| \le \beta \|x - y\| for some β<1\beta \lt 1 has exactly one fixed point x∗x^*, and iterating HH from any starting point converges to it, with ∥Hk(x0)−x∗∥≤βk∥x0−x∗∥\|H^k(x_0) - x^*\| \le \beta^k \|x_0 - x^*\|.

By Banach's fixed point theorem, it follows that TπT^\pi has exactly one fixed point, which must be VπV^\pi, which we call V∗V^*.

The main theorem

Theorem. Let V∗V^* be the unique fixed point of TT, and let π∗\pi^* be greedy with respect to V∗V^*. Then,

  1. Vπ∗=V∗V^{\pi^*} = V^*,
  2. Vπ≤V∗V^\pi \le V^* for every policy π\pi.

So V∗(s)=max⁡πVπ(s)V^*(s) = \max_\pi V^\pi(s) in every state, and π∗\pi^* is optimal. With finitely many actions the argmax is never empty, so there is always a deterministic optimal policy.

Proof of (1). Since π∗\pi^* is greedy: Tπ∗V∗=TV∗=V∗T^{\pi^*} V^* = TV^* = V^*. So V∗V^* is a fixed point of Tπ∗T^{\pi^*}. But Tπ∗T^{\pi^*} has only one fixed point, Vπ∗V^{\pi^*}.

Proof of (2). Take any π\pi. By domination,

Vπ=TπVπ≤TVπ.\begin{equation} V^\pi = T^\pi V^\pi \le T V^\pi. \end{equation}

Now if you apply TT to both sides repeatedly. Monotonicity keeps the inequality, so Vπ≤TVπ≤T2Vπ≤⋯≤TkVπV^\pi \le TV^\pi \le T^2 V^\pi \le \dots \le T^k V^\pi. By Banach, TkVπ→V∗T^k V^\pi \to V^*, hence Vπ≤V∗V^\pi \le 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∗)Q^*(s, a) = F(s, a, V^*) for the Q-function of an optimal policy, so that V∗(s)=max⁡aQ∗(s,a)V^*(s) = \max_a Q^*(s, a). From the fixed point equation V∗=TV∗V^* = TV^* and its counterpart for Q∗Q^* we obtain:

V∗(s)=max⁡a∈A[R(s,a)+γ∑s′∈SP(s′∣s,a) V∗(s′)],Q∗(s,a)=R(s,a)+γ∑s′∈SP(s′∣s,a) max⁡a′∈AQ∗(s′,a′).\begin{align} V^*(s) &= \max_{a \in \mathcal{A}} \Big[R(s, a) + \gamma \sum_{s' \in \mathcal{S}} P(s' \mid s, a)\, V^*(s')\Big], \\ Q^*(s, a) &= R(s, a) + \gamma \sum_{s' \in \mathcal{S}} P(s' \mid s, a)\, \max_{a' \in \mathcal{A}} Q^*(s', a'). \end{align}
← All notes