Appendix A

Mathematical Toolkit

A handful of mathematical tools carry almost every argument in this companion: conditional expectations turn the recursive definition of the return into Bellman equations; contraction mappings make dynamic programming converge; Markov chains supply the distributions over which approximation errors are measured; stochastic approximation explains why sample-based updates with decreasing step sizes find what their expectations point to; importance sampling and the log-derivative trick turn expectations under one distribution into expectations under another, or into gradients; and the Sherman–Morrison formula makes least-squares TD incremental. This appendix states each tool precisely, proves it (or sketches the proof where the full argument belongs to a specialist text), and checks it in the Wolfram Language.

A.1Expectations and Conditioning

All random variables in the book live on finite or countable sets unless stated otherwise, so expectations are sums: 𝔼[X]=∑xxPr⁡{X=x}\mathbb{E}[X] = \sum_x x\Pr\{X = x\}. For an event or a random variable YY with Pr⁡{Y=y}>0\Pr\{Y = y\} > 0, the conditional expectation is 𝔼[X∣Y=y]=∑xxPr⁡{X=x∣Y=y}\mathbb{E}[X \mid Y = y] = \sum_x x\Pr\{X = x \mid Y = y\}, and 𝔼[X∣Y]\mathbb{E}[X \mid Y] denotes the random variable g(Y)g(Y) with g(y)=𝔼[X∣Y=y]g(y) = \mathbb{E}[X \mid Y = y].

Lemma A.1 (Law of Total Expectation). 𝔼[𝔼[X∣Y]]=𝔼[X]\mathbb{E}\bigl[\mathbb{E}[X \mid Y]\bigr] = \mathbb{E}[X]. More generally, if YY is a function of ZZ (so that ZZ carries more information), then 𝔼[𝔼[X∣Z]∣Y]=𝔼[X∣Y]\mathbb{E}\bigl[\mathbb{E}[X \mid Z] \mid Y\bigr] = \mathbb{E}[X \mid Y], and for any function hh, 𝔼[h(Y) X∣Y]=h(Y) 𝔼[X∣Y]\mathbb{E}[h(Y)\,X \mid Y] = h(Y)\,\mathbb{E}[X \mid Y].

Proof. ∑yPr⁡{Y=y}∑xxPr⁡{X=x∣Y=y}=∑xx∑yPr⁡{X=x,Y=y}=∑xxPr⁡{X=x}\sum_y \Pr\{Y = y\}\sum_x x\Pr\{X = x \mid Y = y\} = \sum_x x\sum_y \Pr\{X = x, Y = y\} = \sum_x x\Pr\{X = x\}, the exchange of sums being legitimate when 𝔼∣X∣<∞\mathbb{E}\lvert X\rvert < \infty. The general form is the same computation restricted to the event {Y=y}\{Y = y\}, which is a union of events {Z=z}\{Z = z\}. The last identity holds because h(Y)h(Y) is constant on {Y=y}\{Y = y\}. □

How it produces the Bellman equation. Starting from Gt=Rt+1+γGt+1G_t = R_{t+1} + \gamma G_{t+1} ((3.5)), condition on St=sS_t = s and then on the finer information (St,At,Rt+1,St+1)(S_t, A_t, R_{t+1}, S_{t+1}), writing ℋ\mathcal{H} for the event {St=s,At=a,Rt+1=r,St+1=s′}\{S_t = s, A_t = a, R_{t+1} = r, S_{t+1} = s'\}:

vπ(s)=𝔼π[Rt+1+γGt+1∣St=s]=∑aπ(a∣s)∑s′,rp(s′,r∣s,a)[r+γ 𝔼π[Gt+1∣ℋ]]. \begin{aligned} v_\pi(s) &= \mathbb{E}_\pi[R_{t+1} + \gamma G_{t+1} \mid S_t = s] \\ &= \sum_a \pi(a \mid s)\sum_{s', r}p(s', r \mid s, a)\bigl[r + \gamma\,\mathbb{E}_\pi[G_{t+1} \mid \mathcal{H}]\bigr]. \end{aligned}

The Markov property says that the last conditional expectation depends on s′s' only, and equals vπ(s′)v_\pi(s'); this gives (3.9). The same two steps, total expectation and the Markov property, produce every Bellman equation in the book, the policy gradient theorem (Theorem 13.2) included. A second use, in Monte Carlo and TD methods, is that 𝔼[X∣Y]\mathbb{E}[X \mid Y] is the best predictor of XX from YY in mean square: 𝔼[(X−f(Y))2]=𝔼[(X−𝔼[X∣Y])2]+𝔼[(𝔼[X∣Y]−f(Y))2]\mathbb{E}[(X - f(Y))^2] = \mathbb{E}[(X - \mathbb{E}[X \mid Y])^2] + \mathbb{E}[(\mathbb{E}[X \mid Y] - f(Y))^2] (expand and apply the lemma to the cross term), which is why averaging sampled returns estimates values.

A symbolic joint distribution py,xp_{y,x} of (Y,X)(Y, X) on {1,2}2\{1,2\}^2 with values x1,x2x_1, x_2: ∑yPr⁡{Y=y} 𝔼[X∣Y=y]−𝔼[X]\sum_y \Pr\{Y = y\}\,\mathbb{E}[X \mid Y = y] - \mathbb{E}[X].
const towJoint = await wl`{{Subscript[p, 1, 1], Subscript[p, 1, 2]}, {Subscript[p, 2, 1], Subscript[p, 2, 2]}}`
const towX = await wl`{Subscript[x, 1], Subscript[x, 2]}`
await show`Simplify[Sum[Total[${towJoint}[[y]]] (${towJoint}[[y]] . ${towX})/Total[${towJoint}[[y]]], {y, 2}] - Total[${towJoint} . ${towX}]]`
∑yPr⁡{Y=y} 𝔼[X∣Y=y]−𝔼[X]=0 \sum_y \Pr\{Y=y\}\,\mathbb{E}[X \mid Y=y] - \mathbb{E}[X] = 0

A.2Contractions and Banach’s Fixed-Point Theorem

A norm on ℝn\mathbb{R}^n is a function ∥⋅∥\lVert\cdot\rVert that is positive except at 𝟎\mathbf{0}, homogeneous (∥c𝐱∥=∣c∣∥𝐱∥\lVert c\mathbf{x}\rVert = \lvert c\rvert\lVert\mathbf{x}\rVert) and satisfies the triangle inequality. Three appear in the book: the max norm ∥𝐯∥∞=max⁡s∣v(s)∣\lVert\mathbf{v}\rVert_\infty = \max_s\lvert v(s)\rvert, natural for dynamic programming; the weighted Euclidean norm ∥𝐯∥μ2=∑sμ(s)v(s)2\lVert\mathbf{v}\rVert_\mu^2 = \sum_s \mu(s)v(s)^2, natural for approximation (Chapter 9); and the induced matrix norm ∥𝐀∥∞=max⁡i∑j∣Aij∣\lVert\mathbf{A}\rVert_\infty = \max_i\sum_j\lvert A_{ij}\rvert, the largest factor by which 𝐀\mathbf{A} can stretch a vector in max norm. In particular ∥𝐏∥∞=1\lVert\mathbf{P}\rVert_\infty = 1 for every stochastic matrix. All norms on ℝn\mathbb{R}^n are equivalent and make it complete: every Cauchy sequence converges.

Definition A.2 (Contraction). A map TT from a metric space (X,d)(X, d) to itself is a contraction with modulus γ∈[0,1)\gamma \in [0, 1) if d(Tx,Ty)≤γ d(x,y)d(T x, T y) \le \gamma\,d(x, y) for all x,y∈Xx, y \in X.

Theorem A.3 (Banach Fixed-Point Theorem). Let (X,d)(X, d) be a complete metric spaceStefan Banach. Sur les opérations dans les ensembles abstraits et leur application aux équations intégrales. Fundamenta Mathematicae, 3(1):133–181, Institute of Mathematics, Polish Academy of Sciences, 1922. doi: 10.4064/fm-3-1-133-181 and TT a contraction with modulus γ\gamma. Then TT has exactly one fixed point x∗=Tx∗x^* = Tx^*; for every x0x_0 the iterates xk+1=Txkx_{k+1} = Tx_k converge to x∗x^*, and

d(xk,x∗)≤γkd(x0,x∗),d(xk,x∗)≤γk1−γ d(x1,x0),d(xk,x∗)≤γ1−γ d(xk,xk−1). \begin{aligned} d(x_k, x^*) &\le \gamma^k d(x_0, x^*), \\ d(x_k, x^*) &\le \frac{\gamma^k}{1 - \gamma}\,d(x_1, x_0), \\ d(x_k, x^*) &\le \frac{\gamma}{1 - \gamma}\,d(x_k, x_{k-1}). \end{aligned} (A.1)

Proof. By induction d(xk+1,xk)≤γkd(x1,x0)d(x_{k+1}, x_k) \le \gamma^k d(x_1, x_0), so for m>km > k, by the triangle inequality and the geometric series,

d(xm,xk)≤∑j=km−1γjd(x1,x0)≤γk1−γ d(x1,x0). d(x_m, x_k) \le \sum_{j=k}^{m-1}\gamma^j d(x_1, x_0) \le \frac{\gamma^k}{1 - \gamma}\,d(x_1, x_0).

The sequence is Cauchy, hence converges to some x∗x^*. A contraction is continuous, so Tx∗=lim⁡Txk=lim⁡xk+1=x∗Tx^* = \lim Tx_k = \lim x_{k+1} = x^*. If y∗y^* is another fixed point, d(x∗,y∗)=d(Tx∗,Ty∗)≤γ d(x∗,y∗)d(x^*, y^*) = d(Tx^*, Ty^*) \le \gamma\,d(x^*, y^*) forces d(x∗,y∗)=0d(x^*, y^*) = 0. The first bound is d(xk,x∗)=d(Txk−1,Tx∗)≤γ d(xk−1,x∗)d(x_k, x^*) = d(Tx_{k-1}, Tx^*) \le \gamma\,d(x_{k-1}, x^*) iterated; the second (a priori) follows by letting m→∞m \to \infty in the display; the third (a posteriori) is the second applied with xk−1x_{k-1} as the starting point and one step. □

The a priori bound says how many iterations will suffice before starting; the a posteriori bound gives a stopping rule from observed quantities: if ∥𝐯k−𝐯k−1∥∞<ε(1−γ)/γ\lVert\mathbf{v}_k - \mathbf{v}_{k-1}\rVert_\infty < \varepsilon(1 - \gamma)/\gamma then ∥𝐯k−𝐯∗∥∞<ε\lVert\mathbf{v}_k - \mathbf{v}_*\rVert_\infty < \varepsilon, which is how value iteration (Algorithm 4.10) should be stopped.

Proposition A.4 (The Bellman Operators Are Max-Norm Contractions). For γ<1\gamma < 1, the operators (Tπ𝐯)(s)=∑aπ(a∣s)∑s′,rp(s′,r∣s,a)[r+γv(s′)](T_\pi\mathbf{v})(s) = \sum_a \pi(a \mid s)\sum_{s', r}p(s', r \mid s, a)[r + \gamma v(s')] and (T∗𝐯)(s)=max⁡a∑s′,rp(s′,r∣s,a)[r+γv(s′)](T_*\mathbf{v})(s) = \max_a\sum_{s', r}p(s', r \mid s, a)[r + \gamma v(s')] are contractions with modulus γ\gamma in ∥⋅∥∞\lVert\cdot\rVert_\infty. Their fixed points are vπv_\pi and v∗v_*.

Proof. Tπ𝐯−Tπ𝐮=γ𝐏π(𝐯−𝐮)T_\pi\mathbf{v} - T_\pi\mathbf{u} = \gamma\mathbf{P}_\pi(\mathbf{v} - \mathbf{u}), and ∥γ𝐏π∥∞=γ\lVert\gamma\mathbf{P}_\pi\rVert_\infty = \gamma. For T∗T_*, use the elementary inequality ∣max⁡af(a)−max⁡ag(a)∣≤max⁡a∣f(a)−g(a)∣\lvert\max_a f(a) - \max_a g(a)\rvert \le \max_a\lvert f(a) - g(a)\rvert (if the first maximum is the larger and is attained at a0a_0, the difference is at most f(a0)−g(a0)f(a_0) - g(a_0)), with f(a)−g(a)=γ∑s′p(s′∣s,a)(v(s′)−u(s′))f(a) - g(a) = \gamma\sum_{s'}p(s' \mid s, a)(v(s') - u(s')), which is at most γ∥𝐯−𝐮∥∞\gamma\lVert\mathbf{v} - \mathbf{u}\rVert_\infty in absolute value. The fixed points are the solutions of the Bellman equations (3.9) and (3.17), unique by the theorem. □

The first check iterates TπT_\pi symbolically on a two-state chain from an arbitrary start 𝐮\mathbf{u} and confirms that the error after kk steps is exactly (γ𝐏)k(𝐮−𝐯π)(\gamma\mathbf{P})^k(\mathbf{u} - \mathbf{v}_\pi), whence the rate γk\gamma^k. The second proves the inequality used for T∗T_* by quantifier elimination over the reals.

Three applications of Tπ𝐯=𝐫+γ𝐏𝐯T_\pi\mathbf{v} = \mathbf{r} + \gamma\mathbf{P}\mathbf{v} from 𝐮\mathbf{u}, minus 𝐯π+(γ𝐏)3(𝐮−𝐯π)\mathbf{v}_\pi + (\gamma\mathbf{P})^3(\mathbf{u} - \mathbf{v}_\pi) with 𝐯π=(𝐈−γ𝐏)−1𝐫\mathbf{v}_\pi = (\mathbf{I} - \gamma\mathbf{P})^{-1}\mathbf{r}.
const bnP = await wl`{{p, 1 - p}, {1 - q, q}}`
const bnR = await wl`{Subscript[r, 1], Subscript[r, 2]}`
const bnT = await wl`Function[v, ${bnR} + \[Gamma] ${bnP} . v]`
const bnV = await wl`Inverse[IdentityMatrix[2] - \[Gamma] ${bnP}] . ${bnR}`
await show`Simplify[Nest[${bnT}, {Subscript[u, 1], Subscript[u, 2]}, 3] - ${bnV} - MatrixPower[\[Gamma] ${bnP}, 3] . ({Subscript[u, 1], Subscript[u, 2]} - ${bnV})]`
Tπ3𝐮−𝐯π−(γ𝐏)3(𝐮−𝐯π)={0,0} T_\pi^3\mathbf{u} - \mathbf{v}_\pi - (\gamma\mathbf{P})^3(\mathbf{u} - \mathbf{v}_\pi) = \{0,0\} The maximum is non-expansive in the max norm: a statement about all real a,b,c,da, b, c, d, decided exactly.
await show`Resolve[ForAll[{a, b, c, d}, Abs[Max[a, b] - Max[c, d]] <= Max[Abs[a - c], Abs[b - d]]], Reals]`
(∀a,b,c,d∈ℝ: ∣max⁡(a,b)−max⁡(c,d)∣≤max⁡(∣a−c∣,∣b−d∣))=True \begin{aligned} &\Bigl(\forall a,b,c,d \in \mathbb{R}:\ \lvert\max(a,b) - \max(c,d)\rvert \le \max(\lvert a-c\rvert, \lvert b-d\rvert)\Bigr) \\ &= \text{True} \end{aligned}

A.3Finite Markov Chains

Fixing a policy turns an MDP into a Markov chain on the states, with transition matrix 𝐏π(s,s′)=∑aπ(a∣s) p(s′∣s,a)\mathbf{P}_\pi(s, s') = \sum_a \pi(a \mid s)\,p(s' \mid s, a). Distributions are row vectors and evolve by 𝐝t+1=𝐝t𝐏\mathbf{d}_{t+1} = \mathbf{d}_t\mathbf{P}. Two structures occur in the book: continuing chains, which run forever and settle into a stationary distribution, and episodic chains, which are absorbed in a terminal state and are described by expected numbers of visits.

A.3.1Stationary Distributions and the Ergodic Theorem

A distribution 𝝁\boldsymbol{\mu} is stationary if 𝝁𝐏=𝝁\boldsymbol{\mu}\mathbf{P} = \boldsymbol{\mu}: starting from it, the chain stays in it. The chain is irreducible if every state can reach every other with positive probability, and aperiodic if, for every state, the greatest common divisor of the lengths of the paths returning to it is 11 (a self-loop suffices).

Theorem A.5 (Ergodic Theorem for Finite Chains). Let 𝐏\mathbf{P} be the transition matrix of an irreducible chain on a finite set. Then (i) there is a unique stationary distribution 𝝁\boldsymbol{\mu}, and μ(s)>0\mu(s) > 0 for every ss; (ii) for every function ff and every initial state, 1n∑t=0n−1f(St)→∑sμ(s)f(s)\frac{1}{n}\sum_{t=0}^{n-1}f(S_t) \to \sum_s \mu(s)f(s) almost surely; (iii) if the chain is also aperiodic, Pr⁡{St=s′∣S0=s}→μ(s′)\Pr\{S_t = s' \mid S_0 = s\} \to \mu(s') for all s,s′s, s', geometrically fast.

We do not reprove it; see Levin and Peres for a complete treatment.David A. Levin and Yuval Peres. Markov Chains and Mixing Times. American Mathematical Society, Providence, RI, second edition, 2017. ISBN 978-1-4704-2962-1. doi: 10.1090/mbk/107. With contributions by Elizabeth L. Wilmer; with an appendix by James G. Propp and David B. Wilson Part (i) is linear algebra (Perron–Frobenius: 11 is a simple eigenvalue of 𝐏\mathbf{P} with a positive left eigenvector). Part (ii) is the strong law of large numbers applied to the independent excursions between visits to a fixed state, with μ(s)=1/𝔼[return time to s]\mu(s) = 1/\mathbb{E}[\text{return time to } s]. Part (iii) is where aperiodicity enters: the chain (0110)\begin{pmatrix}0 & 1\\ 1 & 0\end{pmatrix} has 𝝁=(12,12)\boldsymbol{\mu} = (\frac{1}{2}, \frac{1}{2}) and satisfies (ii), but its distribution oscillates forever. Part (ii) is what the book needs for the average-reward setting (Section 10.3): it guarantees that r(π)r(\pi) does not depend on the start state, and that time averages of rewards along one trajectory estimate it. A useful shortcut for computing 𝝁\boldsymbol{\mu} is balance across a cut: in stationarity the probability flow from a set BB to its complement equals the flow back. For two states with Pr⁡{1→2}=a\Pr\{1 \to 2\} = a and Pr⁡{2→1}=b\Pr\{2 \to 1\} = b this gives μ(1) a=μ(2) b\mu(1)\,a = \mu(2)\,b.

The normalized left eigenvector for eigenvalue 11 of a two-state chain.
const mkP = await wl`{{1 - a, a}, {b, 1 - b}}`
await show`Simplify[With[{m = First[NullSpace[Transpose[${mkP}] - IdentityMatrix[2]]]}, m/Total[m]]]`
𝝁={ba+b,aa+b} \boldsymbol{\mu} = \left\{\frac{b}{a+b},\frac{a}{a+b}\right\}

A.3.2The Neumann Series and Expected Visits

Proposition A.6 (Neumann Series). If 𝐀\mathbf{A} is a square matrix with ∥𝐀m∥<1\lVert\mathbf{A}^m\rVert < 1 for some m≥1m \ge 1 and some induced norm (equivalently, spectral radius <1< 1), then 𝐈−𝐀\mathbf{I} - \mathbf{A} is invertible and (𝐈−𝐀)−1=∑k=0∞𝐀k(\mathbf{I} - \mathbf{A})^{-1} = \sum_{k=0}^\infty \mathbf{A}^k.

Proof. Grouping the terms in blocks of mm, ∥𝐀jm+i∥≤∥𝐀m∥j∥𝐀i∥\lVert\mathbf{A}^{jm + i}\rVert \le \lVert\mathbf{A}^m\rVert^j\lVert\mathbf{A}^i\rVert, so the series converges absolutely. The telescoping identity (𝐈−𝐀)∑k=0n−1𝐀k=𝐈−𝐀n(\mathbf{I} - \mathbf{A})\sum_{k=0}^{n-1}\mathbf{A}^k = \mathbf{I} - \mathbf{A}^n and 𝐀n→𝟎\mathbf{A}^n \to \mathbf{0} give the result in the limit. □

Two cases cover the book. Discounting: for any stochastic 𝐏\mathbf{P} and γ<1\gamma < 1, ∥γ𝐏∥∞=γ<1\lVert\gamma\mathbf{P}\rVert_\infty = \gamma < 1, so (𝐈−γ𝐏)−1=∑kγk𝐏k(\mathbf{I} - \gamma\mathbf{P})^{-1} = \sum_k\gamma^k\mathbf{P}^k has nonnegative entries and row sums 1/(1−γ)1/(1 - \gamma), and 𝐯π=(𝐈−γ𝐏π)−1𝐫π\mathbf{v}_\pi = (\mathbf{I} - \gamma\mathbf{P}_\pi)^{-1}\mathbf{r}_\pi is the expected discounted sum of rewards term by term. Episodes: let 𝐐\mathbf{Q} be the transition matrix restricted to the non-terminal states, substochastic because rows lose the probability of terminating. If from every state termination happens within mm steps with probability at least ϵ>0\epsilon > 0, then every row of 𝐐m\mathbf{Q}^m sums to at most 1−ϵ1 - \epsilon, so ∥𝐐m∥∞<1\lVert\mathbf{Q}^m\rVert_\infty < 1 and the proposition applies even with γ=1\gamma = 1. The entry (𝐐k)ss′(\mathbf{Q}^k)_{ss'} is the probability of being in s′s' at time kk, not yet terminated, having started in ss, so

𝜼=𝐡(𝐈−𝐐)−1,η(s′)=𝔼[number of visits to s′], \boldsymbol{\eta} = \mathbf{h}(\mathbf{I} - \mathbf{Q})^{-1}, \qquad \eta(s') = \mathbb{E}\bigl[\text{number of visits to } s'\bigr], (A.2)

for a start distribution 𝐡\mathbf{h} (row vector); summing over s′s' gives the expected episode length, ∑s′η(s′)=𝔼[T]\sum_{s'}\eta(s') = \mathbb{E}[T]. Equivalently 𝜼=𝐡+𝜼𝐐\boldsymbol{\eta} = \mathbf{h} + \boldsymbol{\eta}\mathbf{Q}, the “expected visits” equation from which the book defines the on-policy distribution μ(s)=η(s)/∑s′η(s′)\mu(s) = \eta(s)/\sum_{s'}\eta(s') of episodic tasks (Chapter 9). The matrix (𝐈−𝐐)−1(\mathbf{I} - \mathbf{Q})^{-1} is the fundamental matrix of the absorbing chain. With discounting, 𝐡(𝐈−γ𝐐)−1\mathbf{h}(\mathbf{I} - \gamma\mathbf{Q})^{-1} gives the discounted visit counts used in the policy gradient theorem.

∑k≥0(γ𝐏)k\sum_{k \ge 0}(\gamma\mathbf{P})^k summed in closed form, minus (𝐈−γ𝐏)−1(\mathbf{I} - \gamma\mathbf{P})^{-1}.
await show`Assuming[0 < \[Gamma] < 1 && 0 < a < 1 && 0 < b < 1, Simplify[Sum[MatrixPower[\[Gamma] ${mkP}, k], {k, 0, Infinity}] - Inverse[IdentityMatrix[2] - \[Gamma] ${mkP}]]]`
∑k=0∞(γ𝐏)k−(𝐈−γ𝐏)−1=(0000) \sum_{k=0}^\infty(\gamma\mathbf{P})^k - (\mathbf{I} - \gamma\mathbf{P})^{-1} = \left( \begin{array}{cc} 0 & 0 \\ 0 & 0 \\ \end{array} \right)

The random walk of Chapter 6 (five non-terminal states, start in the center, left or right with probability 12\frac{1}{2}) is a clean example of (A.2).

Expected visits 𝐞3⊤(𝐈−𝐐)−1\mathbf{e}_3^\top(\mathbf{I} - \mathbf{Q})^{-1} for the symmetric five-state random walk started in the center.
const rwQ = await wl`Normal[SparseArray[{Band[{1, 2}] -> 1/2, Band[{2, 1}] -> 1/2}, {5, 5}]]`
const rwEta = await show`UnitVector[5, 3] . Inverse[IdentityMatrix[5] - ${rwQ}]`
𝜼={1,2,3,2,1} \boldsymbol{\eta} = \{1,2,3,2,1\}

The episode lasts 1+2+3+2+1=91 + 2 + 3 + 2 + 1 = 9 steps on average, and the on-policy distribution is 𝜼/9\boldsymbol{\eta}/9: the center state receives a third of the visits, which is the weighting under which VE̅\overline{\mathrm{VE}} is measured for this task.

A.4Stochastic Approximation

Almost every learning rule in the book has the form

𝐱n+1=𝐱n+αn(h(𝐱n)+𝐌n+1), \mathbf{x}_{n+1} = \mathbf{x}_n + \alpha_n\bigl(h(\mathbf{x}_n) + \mathbf{M}_{n+1}\bigr), (A.3)

where h(𝐱)h(\mathbf{x}) is the expected update direction and 𝐌n+1\mathbf{M}_{n+1} is zero-mean noise from sampling. The sample average is the simplest instance: with h(x)=𝔼[R]−xh(x) = \mathbb{E}[R] - x and αn=1/n\alpha_n = 1/n, Qn+1=Qn+1n(Rn−Qn)Q_{n+1} = Q_n + \frac{1}{n}(R_n - Q_n) (Chapter 2). TD(0) is another, with h(𝐰)=𝐛−𝐀𝐰h(\mathbf{w}) = \mathbf{b} - \mathbf{A}\mathbf{w} (Chapter 9), and so are Q-learning, REINFORCE and the actor–critics. The question is when 𝐱n\mathbf{x}_n converges to a zero of hh despite the noise. Robbins and Monro answered it in 1951 for root finding in one dimension;Herbert Robbins and Sutton Monro. A Stochastic Approximation Method. The Annals of Mathematical Statistics, 22(3):400–407, Institute of Mathematical Statistics, 1951. doi: 10.1214/aoms/1177729586 the following version, with a Lyapunov-function proof, is the one used most often in reinforcement learning.

Theorem A.7 (Robbins–Monro Conditions). Let ℱn\mathcal{F}_n be the history up to step nn and consider (A.3) under the following assumptions.

  1. Step sizes: αn≥0\alpha_n \ge 0 is determined by ℱn\mathcal{F}_n, and almost surely ∑n=1∞αn=∞,∑n=1∞αn2<∞. \sum_{n=1}^\infty \alpha_n = \infty, \qquad \sum_{n=1}^\infty \alpha_n^2 < \infty. (A.4)
  2. Noise: 𝔼[𝐌n+1∣ℱn]=𝟎\mathbb{E}[\mathbf{M}_{n+1} \mid \mathcal{F}_n] = \mathbf{0} and 𝔼[∥𝐌n+1∥2∣ℱn]≤K(1+∥𝐱n∥2)\mathbb{E}[\lVert\mathbf{M}_{n+1}\rVert^2 \mid \mathcal{F}_n] \le K(1 + \lVert\mathbf{x}_n\rVert^2).
  3. Drift: ∥h(𝐱)∥2≤K(1+∥𝐱∥2)\lVert h(\mathbf{x})\rVert^2 \le K(1 + \lVert\mathbf{x}\rVert^2), and there is 𝐱∗\mathbf{x}^* such that (𝐱−𝐱∗)⊤h(𝐱)<0(\mathbf{x} - \mathbf{x}^*)^\top h(\mathbf{x}) < 0 for 𝐱≠𝐱∗\mathbf{x} \ne \mathbf{x}^*, uniformly on every set {ε≤∥𝐱−𝐱∗∥≤1/ε}\{\varepsilon \le \lVert\mathbf{x} - \mathbf{x}^*\rVert \le 1/\varepsilon\}.

Then 𝐱n→𝐱∗\mathbf{x}_n \to \mathbf{x}^* almost surely.

Proof. Sketch. Let Vn=∥𝐱n−𝐱∗∥2V_n = \lVert\mathbf{x}_n - \mathbf{x}^*\rVert^2. Expanding the square and using assumption 2 to remove the cross term with 𝐌n+1\mathbf{M}_{n+1},

𝔼[Vn+1∣ℱn]=Vn+2αn(𝐱n−𝐱∗)⊤h(𝐱n)+αn2 𝔼[∥h(𝐱n)+𝐌n+1∥2∣ℱn]≤(1+Cαn2)Vn+Cαn2−2αnDn, \begin{aligned} \mathbb{E}[V_{n+1} \mid \mathcal{F}_n] &= V_n + 2\alpha_n(\mathbf{x}_n - \mathbf{x}^*)^\top h(\mathbf{x}_n) \\ &\quad + \alpha_n^2\,\mathbb{E}\bigl[\lVert h(\mathbf{x}_n) + \mathbf{M}_{n+1}\rVert^2 \mid \mathcal{F}_n\bigr] \\ &\le (1 + C\alpha_n^2)V_n + C\alpha_n^2 - 2\alpha_n D_n, \end{aligned}

where Dn=−(𝐱n−𝐱∗)⊤h(𝐱n)≥0D_n = -(\mathbf{x}_n - \mathbf{x}^*)^\top h(\mathbf{x}_n) \ge 0 and the growth bounds were used with 1+∥𝐱∥2≤C′(1+V)1 + \lVert\mathbf{x}\rVert^2 \le C'(1 + V). The Robbins–Siegmund theorem on almost supermartingalesHerbert Robbins and David Siegmund. A Convergence Theorem for Non Negative Almost Supermartingales and Some Applications. In Jagdish S. Rustagi, editor, Optimizing Methods in Statistics, pages 233–257. Academic Press, New York, 1971. doi: 10.1016/B978-0-12-604550-5.50015-8 applies because ∑αn2<∞\sum\alpha_n^2 < \infty: VnV_n converges almost surely to a finite limit V∞V_\infty and ∑nαnDn<∞\sum_n \alpha_n D_n < \infty. If V∞>0V_\infty > 0, then eventually 𝐱n\mathbf{x}_n stays in a shell {ε≤∥𝐱−𝐱∗∥≤1/ε}\{\varepsilon \le \lVert\mathbf{x} - \mathbf{x}^*\rVert \le 1/\varepsilon\} where Dn≥c>0D_n \ge c > 0 by assumption 3, and ∑αnDn≥c∑αn=∞\sum\alpha_n D_n \ge c\sum\alpha_n = \infty, a contradiction. Hence V∞=0V_\infty = 0. □

The two conditions (A.4) have transparent roles. ∑αn=∞\sum\alpha_n = \infty lets the iterates travel any distance, so the initial condition is eventually forgotten; ∑αn2<∞\sum\alpha_n^2 < \infty makes the total noise injected, whose variance is of order ∑αn2\sum\alpha_n^2, finite, so it averages out. Steps αn=1/np\alpha_n = 1/n^p satisfy both exactly when 12<p≤1\frac{1}{2} < p \le 1. A constant step size violates the second condition: the iterates then do not converge but keep fluctuating in a neighborhood of size O(α)O(\sqrt{\alpha}) around 𝐱∗\mathbf{x}^*, which is precisely what one wants when tracking a nonstationary target.

The harmonic series diverges (its convergence test is false), ∑1/n2=π2/6\sum 1/n^2 = \pi^2/6, and the conditions for αn=n−p\alpha_n = n^{-p}: ∑n−p<∞\sum n^{-p} < \infty iff p>1p > 1, ∑n−2p<∞\sum n^{-2p} < \infty iff p>12p > \frac{1}{2}.
await show`{SumConvergence[1/n, n], Sum[1/n^2, {n, 1, Infinity}], SumConvergence[1/n^p, n, Assumptions -> Element[p, Reals]], SumConvergence[1/n^(2 p), n, Assumptions -> Element[p, Reals]]}`
(∑1n<∞, ∑1n2, ∑n−p<∞⇔, ∑n−2p<∞⇔)={False,π26,p>1,2p>1} \begin{aligned} &\Bigl(\textstyle\sum \frac{1}{n} < \infty,\ \sum \frac{1}{n^2},\ \sum n^{-p} < \infty \Leftrightarrow,\ \sum n^{-2p} < \infty \Leftrightarrow\Bigr) \\ &= \left\{\text{False},\frac{\pi ^2}{6},p>1,2 p>1\right\} \end{aligned} The incremental rule Q←Q+(Rn−Q)/nQ \leftarrow Q + (R_n - Q)/n, folded over four symbolic rewards: the result is the sample mean, whatever Q1Q_1 was.
await show`Simplify[First[Fold[{#1[[1]] + (#2 - #1[[1]])/#1[[2]], #1[[2]] + 1} &, {Subscript[Q, 1], 1}, Table[Subscript[R, i], {i, 4}]]]]`
Q5=14(R1+R2+R3+R4) Q_5 = \frac{1}{4} \left(R_1+R_2+R_3+R_4\right)

The ODE method. The theorem asks for a global Lyapunov function, which is often unavailable. The more general and more useful view, developed by Kushner, Ljung and othersHarold J. Kushner and G. George Yin. Stochastic Approximation and Recursive Algorithms and Applications, volume 35 of Stochastic Modelling and Applied Probability. Springer, New York, second edition, 2003. ISBN 978-0-387-00894-3. doi: 10.1007/b97441 and given a clean form by Borkar and Meyn,Vivek S. Borkar and Sean P. Meyn. The O.D.E. Method for Convergence of Stochastic Approximation and Reinforcement Learning. SIAM Journal on Control and Optimization, 38(2):447–469, SIAM, 2000. doi: 10.1137/S0363012997331639 is that with small steps the noise averages out and the iterates follow the trajectories of the ordinary differential equation

𝐱˙(τ)=h(𝐱(τ)), \dot{\mathbf{x}}(\tau) = h(\mathbf{x}(\tau)), (A.5)

with αn\alpha_n as the time increment. Informally: if the iterates remain bounded and the ODE has a globally asymptotically stable equilibrium 𝐱∗\mathbf{x}^*, then 𝐱n→𝐱∗\mathbf{x}_n \to \mathbf{x}^* almost surely under the step-size conditions (A.4). Borkar and Meyn’s contribution is a test for boundedness: it suffices that the scaled ODE 𝐱˙=h∞(𝐱)\dot{\mathbf{x}} = h_\infty(\mathbf{x}), with h∞(𝐱)=lim⁡c→∞h(c𝐱)/ch_\infty(\mathbf{x}) = \lim_{c \to \infty}h(c\mathbf{x})/c, has the origin as globally asymptotically stable equilibrium. For linear TD(0), h(𝐰)=𝐛−𝐀𝐰h(\mathbf{w}) = \mathbf{b} - \mathbf{A}\mathbf{w}, so h∞(𝐰)=−𝐀𝐰h_\infty(\mathbf{w}) = -\mathbf{A}\mathbf{w}, and everything reduces to the stability of −𝐀-\mathbf{A}: on-policy, 𝐀\mathbf{A} is positive definite and TD converges to the TD fixed point (9.5); off-policy it may not be, which is the deadly triad of Chapter 11. Two learning processes running at different speeds, such as a critic and an actor, are handled by two-timescale versions in which the slow iterate sees the fast one at its equilibrium.A thorough reference for the classical theory, including the convergence of TD and Q-learning, is Bertsekas and Tsitsiklis (1996); the ODE method is developed in full by Kushner and Yin (2003).Dimitri P. Bertsekas and John N. Tsitsiklis. Neuro-Dynamic Programming. Athena Scientific, Belmont, MA, 1996. ISBN 1-886529-10-8

A.5Importance Sampling

To estimate an expectation under a target distribution π\pi from samples drawn from a behavior distribution bb, reweight by the likelihood ratio ρ(x)=π(x)/b(x)\rho(x) = \pi(x)/b(x). If b(x)>0b(x) > 0 wherever π(x)f(x)≠0\pi(x)f(x) \ne 0 (coverage),

𝔼b[ρ(X)f(X)]=∑xb(x)π(x)b(x)f(x)=𝔼π[f(X)],𝔼b[ρ(X)]=1,Var⁡b[ρf]=𝔼π[ρf2]−(𝔼πf)2. \begin{aligned} \mathbb{E}_b[\rho(X)f(X)] &= \sum_x b(x)\frac{\pi(x)}{b(x)}f(x) = \mathbb{E}_\pi[f(X)], \\ \mathbb{E}_b[\rho(X)] &= 1, \\ \operatorname{Var}_b[\rho f] &= \mathbb{E}_\pi[\rho f^2] - \bigl(\mathbb{E}_\pi f\bigr)^2. \end{aligned} (A.6)

The estimator is unbiased, but the second moment 𝔼π[ρf2]\mathbb{E}_\pi[\rho f^2] involves ρ=π/b\rho = \pi/b and is large, possibly infinite, when bb puts little mass where π\pi puts much. For trajectories, the probability of At,St+1,…,STA_t, S_{t+1}, \dots, S_T under a policy is a product of policy and dynamics factors; the dynamics factors are the same under π\pi and bb and cancel, leaving the ratio ρt:T−1=∏kπ(Ak∣Sk)/b(Ak∣Sk)\rho_{t:T-1} = \prod_k \pi(A_k \mid S_k)/b(A_k \mid S_k) of (5.2), computable without a model. Its variance grows exponentially with the horizon in general, which is the motivation for weighted importance sampling (biased, consistent, of bounded variance) and for the per-decision and control-variate methods of Chapter 11.

Two outcomes: 𝔼b[ρf]−𝔼π[f]\mathbb{E}_b[\rho f] - \mathbb{E}_\pi[f], 𝔼b[ρ]\mathbb{E}_b[\rho], and 𝔼b[(ρf)2]−𝔼π[f2]\mathbb{E}_b[(\rho f)^2] - \mathbb{E}_\pi[f^2], the excess second moment, with target (π,1−π)(\pi, 1-\pi) and behavior (β,1−β)(\beta, 1-\beta).
const isPi = await wl`{\[Pi], 1 - \[Pi]}`
const isB = await wl`{\[Beta], 1 - \[Beta]}`
const isF = await wl`{Subscript[f, 1], Subscript[f, 2]}`
await show`Simplify[{${isB} . (${isPi}/${isB} ${isF}) - ${isPi} . ${isF}, ${isB} . (${isPi}/${isB}), ${isB} . (${isPi}/${isB} ${isF})^2 - ${isPi} . ${isF}^2}]`
(𝔼b[ρf]−𝔼π[f], 𝔼b[ρ], 𝔼b[(ρf)2]−𝔼π[f2])={0,1,(π−β)(π(−1+β)f12−(−1+π)βf22)(−1+β)β} \begin{aligned} &\Bigl(\mathbb{E}_b[\rho f] - \mathbb{E}_\pi[f],\ \mathbb{E}_b[\rho],\ \mathbb{E}_b[(\rho f)^2] - \mathbb{E}_\pi[f^2]\Bigr) \\ &= \left\{0,1,\frac{(\pi -\beta ) \left(\pi (-1+\beta ) f_1^2-(-1+\pi ) \beta f_2^2\right)}{(-1+\beta ) \beta }\right\} \end{aligned}

The excess second moment vanishes when b=πb = \pi and blows up as β→0\beta \to 0 or β→1\beta \to 1 whenever the corresponding outcome matters under π\pi.

A.6The Log-Derivative Trick

For a family of distributions p𝜽p_{\boldsymbol{\theta}} and a function ff that does not depend on 𝜽\boldsymbol{\theta},

∇𝜽 𝔼X∼p𝜽[f(X)]=∑xf(x)∇p𝜽(x)=∑xp𝜽(x) f(x) ∇ln⁡p𝜽(x)=𝔼X∼p𝜽[f(X) ∇ln⁡p𝜽(X)], \begin{aligned} \nabla_{\boldsymbol{\theta}}\,\mathbb{E}_{X \sim p_{\boldsymbol{\theta}}}[f(X)] &= \sum_x f(x)\nabla p_{\boldsymbol{\theta}}(x) = \sum_x p_{\boldsymbol{\theta}}(x)\,f(x)\,\nabla\ln p_{\boldsymbol{\theta}}(x) \\ &= \mathbb{E}_{X \sim p_{\boldsymbol{\theta}}}\bigl[f(X)\,\nabla\ln p_{\boldsymbol{\theta}}(X)\bigr], \end{aligned} (A.7)

using ∇p=p ∇ln⁡p\nabla p = p\,\nabla\ln p wherever p>0p > 0 (for densities, under the usual conditions for differentiating under the integral). The vector ∇ln⁡p𝜽(X)\nabla\ln p_{\boldsymbol{\theta}}(X) is the score; taking f≡1f \equiv 1 shows that it has mean zero, so any constant can be subtracted from ff without bias (the baseline of Proposition 13.5). Its covariance is the Fisher information 𝐅(𝜽)=𝔼[∇ln⁡p ∇ln⁡p⊤]=−𝔼[∇2ln⁡p]\mathbf{F}(\boldsymbol{\theta}) = \mathbb{E}[\nabla\ln p\,\nabla\ln p^\top] = -\mathbb{E}[\nabla^2\ln p]. The estimator f(X)∇ln⁡p𝜽(X)f(X)\nabla\ln p_{\boldsymbol{\theta}}(X) needs only samples of XX and the ability to differentiate ln⁡p𝜽\ln p_{\boldsymbol{\theta}}, not ff: this is why it works with unknown environments. Applied to a trajectory, whose probability is ∏tπ(At∣St,𝜽) p(St+1,Rt+1∣St,At)\prod_t \pi(A_t \mid S_t, \boldsymbol{\theta})\,p(S_{t+1}, R_{t+1} \mid S_t, A_t), the logarithm turns the product into a sum and the dynamics, independent of 𝜽\boldsymbol{\theta}, drop out of the gradient: ∇ln⁡Pr⁡{trajectory}=∑t∇ln⁡π(At∣St,𝜽)\nabla\ln\Pr\{\text{trajectory}\} = \sum_t\nabla\ln\pi(A_t \mid S_t, \boldsymbol{\theta}). That is REINFORCE (Algorithm 13.4). When XX can instead be written as a differentiable function X=g𝜽(ξ)X = g_{\boldsymbol{\theta}}(\xi) of parameter-free noise ξ\xi, and ff is differentiable, the reparameterization (pathwise) estimator 𝔼[∇𝜽f(g𝜽(ξ))]\mathbb{E}[\nabla_{\boldsymbol{\theta}}f(g_{\boldsymbol{\theta}}(\xi))] is an alternative, usually of much lower variance; deterministic policy gradients and soft actor–critic rely on it.

For X∼𝒩(μ,σ2)X \sim \mathcal{N}(\mu, \sigma^2): ∂μ𝔼[X2]\partial_\mu\mathbb{E}[X^2], its score-function form 𝔼[X2 ∂μln⁡p]\mathbb{E}[X^2\,\partial_\mu\ln p], and the Fisher information computed as 𝔼[(∂μln⁡p)2]\mathbb{E}[(\partial_\mu\ln p)^2] and as −𝔼[∂μ2ln⁡p]-\mathbb{E}[\partial_\mu^2\ln p].
await show`Assuming[\[Sigma] > 0, Simplify[With[{d = NormalDistribution[\[Mu], \[Sigma]]}, {D[Expectation[x^2, x \[Distributed] d], \[Mu]], Expectation[x^2 D[Log[PDF[d, x]], \[Mu]], x \[Distributed] d], Expectation[D[Log[PDF[d, x]], \[Mu]]^2, x \[Distributed] d], -Expectation[D[Log[PDF[d, x]], {\[Mu], 2}], x \[Distributed] d]}]]]`
(∂μ𝔼[X2], 𝔼[X2 ∂μln⁡p], 𝔼[(∂μln⁡p)2], −𝔼[∂μ2ln⁡p])={2μ,2μ,1σ2,1σ2} \Bigl(\partial_\mu\mathbb{E}[X^2],\ \mathbb{E}[X^2\,\partial_\mu\ln p],\ \mathbb{E}[(\partial_\mu\ln p)^2],\ -\mathbb{E}[\partial^2_\mu\ln p]\Bigr) = \left\{2 \mu ,2 \mu ,\frac{1}{\sigma ^2},\frac{1}{\sigma ^2}\right\}

A.7The Sherman–Morrison Formula

Lemma A.8 (Sherman–Morrison). Let 𝐀\mathbf{A} be invertible and 𝐮,𝐯\mathbf{u}, \mathbf{v} vectors with 1+𝐯⊤𝐀−1𝐮≠01 + \mathbf{v}^\top\mathbf{A}^{-1}\mathbf{u} \ne 0. ThenJack Sherman and Winifred J. Morrison. Adjustment of an Inverse Matrix Corresponding to a Change in One Element of a Given Matrix. The Annals of Mathematical Statistics, 21(1):124–127, Institute of Mathematical Statistics, 1950. doi: 10.1214/aoms/1177729893

(𝐀+𝐮𝐯⊤)−1=𝐀−1−𝐀−1𝐮 𝐯⊤𝐀−11+𝐯⊤𝐀−1𝐮,det⁡(𝐀+𝐮𝐯⊤)=det⁡𝐀 (1+𝐯⊤𝐀−1𝐮). \begin{aligned} \bigl(\mathbf{A} + \mathbf{u}\mathbf{v}^\top\bigr)^{-1} &= \mathbf{A}^{-1} - \frac{\mathbf{A}^{-1}\mathbf{u}\,\mathbf{v}^\top\mathbf{A}^{-1}}{1 + \mathbf{v}^\top\mathbf{A}^{-1}\mathbf{u}}, \\ \det\bigl(\mathbf{A} + \mathbf{u}\mathbf{v}^\top\bigr) &= \det\mathbf{A}\,\bigl(1 + \mathbf{v}^\top\mathbf{A}^{-1}\mathbf{u}\bigr). \end{aligned} (A.8)

Proof. Multiply 𝐀+𝐮𝐯⊤\mathbf{A} + \mathbf{u}\mathbf{v}^\top by the right-hand side and write c=𝐯⊤𝐀−1𝐮c = \mathbf{v}^\top\mathbf{A}^{-1}\mathbf{u}, a scalar:

𝐈+𝐮𝐯⊤𝐀−1−𝐮𝐯⊤𝐀−1+c 𝐮𝐯⊤𝐀−11+c=𝐈+𝐮𝐯⊤𝐀−1−𝐮𝐯⊤𝐀−1=𝐈. \mathbf{I} + \mathbf{u}\mathbf{v}^\top\mathbf{A}^{-1} - \frac{\mathbf{u}\mathbf{v}^\top\mathbf{A}^{-1} + c\,\mathbf{u}\mathbf{v}^\top\mathbf{A}^{-1}}{1 + c} = \mathbf{I} + \mathbf{u}\mathbf{v}^\top\mathbf{A}^{-1} - \mathbf{u}\mathbf{v}^\top\mathbf{A}^{-1} = \mathbf{I}.

For the determinant, det⁡(𝐀+𝐮𝐯⊤)=det⁡𝐀 det⁡(𝐈+𝐀−1𝐮𝐯⊤)\det(\mathbf{A} + \mathbf{u}\mathbf{v}^\top) = \det\mathbf{A}\,\det(\mathbf{I} + \mathbf{A}^{-1}\mathbf{u}\mathbf{v}^\top), and 𝐈+𝐚𝐯⊤\mathbf{I} + \mathbf{a}\mathbf{v}^\top has eigenvalue 1+𝐯⊤𝐚1 + \mathbf{v}^\top\mathbf{a} on 𝐚\mathbf{a} and 11 on the hyperplane 𝐯⊥\mathbf{v}^\perp. □

A rank-one change to a matrix costs a rank-one change to its inverse: O(d2)O(d^2) operations instead of O(d3)O(d^3). Least-squares TD (Chapter 9) accumulates 𝐀̂t=𝐀̂t−1+𝐱t(𝐱t−γ𝐱t+1)⊤\widehat{\mathbf{A}}_t = \widehat{\mathbf{A}}_{t-1} + \mathbf{x}_t(\mathbf{x}_t - \gamma\mathbf{x}_{t+1})^\top, a rank-one update with 𝐮=𝐱t\mathbf{u} = \mathbf{x}_t and 𝐯=𝐱t−γ𝐱t+1\mathbf{v} = \mathbf{x}_t - \gamma\mathbf{x}_{t+1}, so its inverse can be maintained incrementally; the same device gives recursive least squares.

Both identities of the lemma for a generic 2×22 \times 2 matrix and symbolic vectors: the differences simplify to zero.
const smA = await wl`{{Subscript[a, 1, 1], Subscript[a, 1, 2]}, {Subscript[a, 2, 1], Subscript[a, 2, 2]}}`
const smU = await wl`{Subscript[u, 1], Subscript[u, 2]}`
const smV = await wl`{Subscript[v, 1], Subscript[v, 2]}`
await show`Simplify[{Inverse[${smA} + Outer[Times, ${smU}, ${smV}]] - (Inverse[${smA}] - Inverse[${smA}] . Outer[Times, ${smU}, ${smV}] . Inverse[${smA}]/(1 + ${smV} . Inverse[${smA}] . ${smU})), Det[${smA} + Outer[Times, ${smU}, ${smV}]] - Det[${smA}] (1 + ${smV} . Inverse[${smA}] . ${smU})}]`
((𝐀+𝐮𝐯⊤)−1−RHS, det⁡(𝐀+𝐮𝐯⊤)−RHS)={(0000),0} \Bigl((\mathbf{A}+\mathbf{u}\mathbf{v}^\top)^{-1} - \text{RHS},\ \det(\mathbf{A}+\mathbf{u}\mathbf{v}^\top) - \text{RHS}\Bigr) = \left\{\left( \begin{array}{cc} 0 & 0 \\ 0 & 0 \\ \end{array} \right),0\right\}