This page builds every symbol the parent note leans on, starting from a smart 12-year-old who has never seen a single one. Read top to bottom: each block only uses things defined above it.
Figure s01 — the RL loop. The violet agent (holding its strategy) sends an action (magenta arrow) to the orange environment, which returns the next state and a reward (navy arrow). Round and round: this loop is the entire game TRPO plays. (The symbols π,a,s,r for these four objects are defined just below.)
Why we need them: reinforcement learning is the loop state → action → reward → next state, repeated. TRPO's whole job is to improve the policyπ. See Policy Gradient Methods for the base loop.
The subscript names what randomness we average over: Ea∼π[…] = "average over actions a drawn from policy π." The squiggle ∼ reads "sampled from."
Why the topic needs it: rewards are random (the policy is random, the world may be random). We can't talk about "the return" — only its average, which is exactly what we try to raise.
We need to score individual states and actions, not just whole games.
Figure s02 — advantage as height above the average. The violet bars are the action-values Q(s,a) for four actions; the orange line is the state's average value V(s). Each magenta arrow is the advantageA=Q−V: actions above the line have A>0 (do more of them), below have A<0 (do less).
The surrogate we build next averages over states. We must say precisely which states, and how often each counts.
Why the topic needs it: when we average an advantage "over the states the policy sees," dπ is exactly that weighting. The old policy's version, dπθold, is the distribution of states we actually have samples from.
Now the heart of the matter: why the surrogate objective has the exact shape it does.
The lemma is exact but useless as written: it needs s∼dπ′ and a∼π′ — samples from the new policy we don't have yet. So we make one approximation: since we search only near the old policy, replace dπ′≈dπθold (the states barely move if behaviour barely moves). For the actions, we still only sampled a∼πθold, so we re-weight them with the importance ratio (defined in §8). Dropping the constant 1−γ1 (it doesn't change the argmax) gives:
Now we make "how differently the policy behaves" a real number.
Figure s03 — KL as loss of overlap. Magenta is the old policy's action distribution, violet is the new one; the orange shaded region is their overlap. As the new curve slides away, the overlap shrinks and the KL divergence grows — a single number for "how far behaviour drifted."
DKL above compares the two policies in one fixed states. But a policy acts across many states, so TRPO averages this per-state KL over the states the old policy actually visits.
Now we have every piece. Near θold the surrogate is nearly linear and the constraint nearly quadratic, so TRPO solves this clean sub-problem (with s=θ−θold):
Step A — set up the Lagrangian. At the best s the boundary is active (21s⊤Fs=δ: you always spend the whole budget). Glue objective and constraint with a multiplier λ>0:
L(s,λ)=g⊤s−λ(21s⊤Fs−δ).What/why: at the optimum, any further push that raises g⊤s is exactly cancelled by the constraint's pushback — that balance is a zero gradient of L.
Step B — differentiate in s and set to zero.∇sL=g−λFs=0⟹s=λ1F−1g.What this says: the direction is forced to be the natural gradient F−1g; only its length (1/λ) is still unknown.
Step C — pin the length using the active constraint. Substitute s=λ1F−1g into 21s⊤Fs=δ, using that F is symmetric so (F−1g)⊤F(F−1g)=g⊤F−1g:
\;\;\Longrightarrow\;\; \frac1\lambda=\sqrt{\frac{2\delta}{g^\top F^{-1}g}}.$$
**Step D — assemble.** Put $1/\lambda$ back into $s=\tfrac1\lambda F^{-1}g$:
> [!formula] The TRPO step (derived from every symbol above)
> $$s^\star=\sqrt{\dfrac{2\delta}{g^\top F^{-1} g}}\;\; F^{-1}g$$
> The **direction** is the natural gradient $F^{-1}g$; the square-root **scalar** shrinks it so it lands exactly on the trust-region boundary $\bar D_{\mathrm{KL}}=\delta$.
> [!intuition] What $F^{-1}$ actually does to $g$
> Plain gradient $g$ says "uphill in slider-space." Multiplying by $F^{-1}$ **rescales** it into "uphill in behaviour-space" — it *slows down* directions where behaviour is sensitive (steep $F$) and *speeds up* safe directions. That corrected direction $F^{-1}g$ is the ==natural gradient==. See [[Natural Gradient Descent]].
> [!definition] Two computational tools you'll meet
> - **[[Conjugate Gradient Method]]** — solves $Fx=g$ (i.e. finds $F^{-1}g$) *without ever building or inverting $F$*, using only cheap products $Fv$.
> - **Line search** — after computing $s^\star$, TRPO shrinks it by a factor $\beta^j$ until the *true* KL is $\le\delta$ and the surrogate really improved, because the quadratic bowl was only an approximation.
The refinement [[Proximal Policy Optimization (PPO)]] keeps this same behaviour-limit idea but replaces the exact constraint with a cheap clipped objective.
---
## Prerequisite map
```mermaid
graph TD
A["state s and action a"] --> B["policy pi as probability"]
B --> C["parameters theta and network pi-theta"]
D["expectation E average"] --> E["return J with discount gamma and start rho0"]
E --> F["value V and Q and advantage A"]
E --> V["state visitation d-pi"]
F --> P["performance difference lemma"]
V --> P
P --> S["surrogate objective L"]
B --> H["importance ratio new over old"]
H --> S
S --> G["policy gradient g equals grad L"]
G --> LG["log prob score form"]
B --> I["KL divergence between policies"]
I --> J["trust region size delta"]
I --> K["Fisher matrix F curvature"]
G --> L["natural gradient F-inverse g"]
K --> L
J --> N["TRPO constrained step"]
L --> N
S --> N
```
---
## Equipment checklist
Test yourself — say the answer, then reveal.
What does $\pi(a\mid s)=0.7$ mean in plain words? ::: In state $s$, the strategy chooses action $a$ 70\% of the time; probabilities over actions sum to 1.
What is the difference between parameter space and behaviour space? ::: Parameter space = the network knobs $\theta$; behaviour space = the actual action probabilities $\pi_\theta(\cdot\mid s)$. Equal knob moves can cause tiny or huge behaviour changes.
What role does the initial-state distribution $\rho_0$ play in $J$? ::: Every trajectory starts from $s_0\sim\rho_0$; averaging over it makes $J$ a single well-defined number rather than depending on where you happened to begin.
How does the infinite-horizon return handle episodes that terminate? ::: A terminal state is made absorbing with reward 0, so all rewards after termination are 0 and the infinite discounted sum equals the finite episode's return.
Why do we subtract $V$ to get the advantage $A=Q-V$? ::: To measure how much better an action is than the policy's *average* behaviour in that state, removing baseline noise from the learning signal.
What is $d^\pi(s)$ and over which policy do we use it in the surrogate? ::: The discounted state-visitation distribution — how often, discounted, $\pi$ lands in $s$. In the surrogate we use $d^{\pi_{\theta_{\text{old}}}}$, the states we actually sampled.
State the performance-difference lemma in words. ::: A new policy's return minus the old one's equals (up to $1/(1-\gamma)$) the average old-policy advantage collected over the new policy's visited states.
Which approximation turns the lemma into the surrogate $L$? ::: Replacing the new policy's state visitation $d^{\pi'}$ with the old one's $d^{\pi_{\theta_{\text{old}}}}$, valid only when the policies are close; actions are re-weighted by importance sampling.
Over exactly which distributions are $s$ and $a$ sampled in $L(\theta)$? ::: $s\sim d^{\pi_{\theta_{\text{old}}}}$ and $a\sim\pi_{\theta_{\text{old}}}$ — precisely the state–action