04

The derivation sheet

Every symbol, contribution, gradient, and rounding decision for OPD-TOY-001—open on the page.

Pin the symbols before the arithmetic

MATH-REC-TOY-001 · independent receipt

Epistemic status: invented deterministic teaching fixture. Natural logs; nats; vocabulary [A,B]; temperature 1; two evaluated positions; no explicit EOS.

Symbol table
SymbolMeaningShape / unitLocal derivative
xxfixed prompttoken sequenceheld fixed
st=(x,y<t)s_t=(x,y_{<t})visited prefix occurrenceone contextheld fixed
p(⋅∣s)p(\cdot\mid s)teacher distributionΔ1\Delta^{1}; unitlessheld fixed
zθ(s)z_\theta(s)student logitsR2\mathbb R^2differentiated
qθ(⋅∣s)q_\theta(\cdot\mid s)student distributionΔ1\Delta^{1}; unitlessdifferentiated
DF,DRD_F,D_Rlocal KL scalarnatsderived
λ\lambdastudent-output source fraction[0,1]; unitlesschosen
  1. Probability vectors are positive and normalized.
  2. The categorical u = 0.8 branch is detached.
  3. xA is fixed by provenance in the supplied comparison occurrence, not by its text.
  4. Conditioned-path mixtures are not the full response expectation.
  5. Teacher probabilities are supervision, not a guarantee of truth or process causality.

Reverse KL, line by line

01 · state x
DR(x)=34log⁡3/41/2+14log⁡1/41/2=34log⁡32+14log⁡12=34log⁡3−log⁡2=0.304098831081123286−0.173286795139986327=0.130812035941136959 nats.\begin{aligned}D_R(x)&=\frac34\log\frac{3/4}{1/2}+\frac14\log\frac{1/4}{1/2}\\&=\frac34\log\frac32+\frac14\log\frac12\\&=\frac34\log3-\log2\\&=0.304098831081123286-0.173286795139986327\\&=0.130812035941136959\ \text{nats}.\end{aligned}

The A contribution is positive and the B contribution negative; KL non-negativity applies to their sum, not each term.

02 · state xB
DR(xB)=35log⁡3/59/10+25log⁡2/51/10=35log⁡23+25log⁡4=75log⁡2−35log⁡3=−0.243279064864898629+0.554517744447956248=0.311238679583057618 nats.\begin{aligned}D_R(xB)&=\frac35\log\frac{3/5}{9/10}+\frac25\log\frac{2/5}{1/10}\\&=\frac35\log\frac23+\frac25\log4\\&=\frac75\log2-\frac35\log3\\&=-0.243279064864898629+0.554517744447956248\\&=0.311238679583057618\ \text{nats}.\end{aligned}

The teacher assigns only 0.1 to B, so the student's 0.4 weight produces the larger positive term.

03 · unweighted route mean
L^R=12[DR(x)+DR(xB)]=340log⁡3+15log⁡2=0.221025357762097289 nats⟶0.221025 nats at six decimals.\begin{aligned}\widehat L_R&=\tfrac12[D_R(x)+D_R(xB)]\\&=\tfrac3{40}\log3+\tfrac15\log2\\&=0.221025357762097289\ \text{nats}\\&\longrightarrow\boxed{0.221025\ \text{nats at six decimals}}.\end{aligned}

Round the full-precision mean once. Averaging the displayed six-decimal components produces the tie 0.2210255; decimal round-half-up would show 0.221026 instead.

Forward direction, fixed route, and the expectation you did not sample

Full-precision local values · toy
PrefixReverse KL q ‖ pForward KL p ‖ qOccurrence used by
x0.1308120359411370.143841036225890both routes
xB0.3112386795830580.226289161185359realized u = 0.8 student route
xA0.5826853020432400.534110808710307supplied fixed route
MATH-EQ-FORWARD-MEAN-001
L^F(x ⁣→ ⁣xB)=15log⁡3−120log⁡2=0.185065098705624673 nats.\widehat L_F(x\!\to\!xB)=\frac15\log3-\frac1{20}\log2=0.185065098705624673\ \text{nats}.

Same realized prefixes, different local direction. The route remains student-generated.

The supplied fixed route [x,xA] has mean reverse KL 0.356748668992188 and mean forward KL 0.338975922468099 nats. Mixing that one route with the realized student route gives a useful six-cell contrast—but not the exact expectation over all student responses.

MATH-EQ-OUTER-EXAMPLE-001 · variant-specific contrast
Ey1∼q(⋅∣x)[LR∣x]=0.75(0.356748668992188)+0.25(0.221025357762097)=0.322817841184666.\mathbb E_{y_1\sim q(\cdot\mid x)}[L_R\mid x]=0.75(0.356748668992188)+0.25(0.221025357762097)=0.322817841184666.

This hypothetical branch expectation uses xA when the student itself draws A. It is not the contract's fixed u=0.8 sample receipt and still does not model EOS or later draws.

Analytic gradients meet finite differences

Local student-logit gradients at temperature 1
StateForward ∇zDF\nabla_zD_FReverse ∇zDR\nabla_zD_R
x[0.25, −0.25][0.205989804125271, −0.205989804125271]
xB[−0.3, 0.3][−0.430022272614733, 0.430022272614733]
xA[−0.5, 0.5][−0.469054366516490, 0.469054366516490]

Each vector has length two, units “nats per logit,” and sum zero. For the canonical two-state mean, keep state blocks separate:

MATH-EQ-MEAN-BLOCKS-001
∇(zx,zxB)L^R=[0.102994902062635,−0.102994902062635,−0.215011136307367,0.215011136307367].\nabla_{(z_x,z_{xB})}\widehat L_R=[0.102994902062635,-0.102994902062635,-0.215011136307367,0.215011136307367].

Do not average gradients componentwise unless another toy deliberately shares one logit vector. A real network passes each block through its state-dependent Jacobian to common parameters.

executed receipt

MATH-LAB-001 perturbs frozen-state logits with central differences, step h=10−5h=10^{-5}, and requires absolute error at most 2×10−102\times10^{-10} with relative tolerance exactly zero. The observed maximum is loaded from the generated receipt and audited separately.

Inspect the JSON receipt (local copy) · Read the independent Python source (local copy) · Read the Markdown sheet (local copy)

Change one coordinate without smuggling in the other

Now the one approved interaction. Predict before touching it: if the trajectory source stays at λ=1\lambda=1 and only KL direction changes, should the on-policy label move?

MATH-EXP-001 · sourced relationship + toy arithmeticSource measure × local divergence

toy numbersderived valuessourced separation All outputs use natural logs and report nats.

Static fallback active. Interactive controls require JavaScript. Every source × divergence state remains available in the complete matrix below.

Predict first: at λ = 1, would switching reverse KL to forward KL make the trajectory off-policy?

1 · student route Arrow keys move among 0, 0.5, and 1. This changes source coefficients only.
This changes the fixed-state formula and gradient only.
Trajectory sourceStudent-generated route · on-policy at collection

0.0 fixed + 1.0 realized student

Held-fixed local formula
DR(q∥p)=∑iqilog⁡qipiD_R(q\|p)=\sum_i q_i\log\frac{q_i}{p_i}

D_KL(student || teacher) at a held-fixed prefix

Supplied fixed [x,xA]
0.356748668992188 nats
Realized student [x,xB]
0.221025357762097 nats
Conditioned-path mixture
0.221025357762097 nats
Local gradient at xB
[-0.430022272614733, 0.430022272614733]nats per logit · [A,B]

0.0 × 0.356748668992188 + 1.0 × 0.221025357762097

λ never selects KL direction. KL direction never changes provenance.

All six states · static fallback and cross-check
MATH-FIG-002 · static fallback · toy conditioned-path values
Outer source coefficientLocal DKL(student ‖ teacher)Local DKL(teacher ‖ student)Provenance label
λ = 0Fixed route only0.356748668992188reverse KL · nats0.338975922468099forward KL · natsfixed
λ = 0.5Equal conditioned-path coefficients0.288887013377143reverse KL · nats0.262020510586862forward KL · natsmixed
λ = 1Realized student route only0.221025357762097reverse KL · nats0.185065098705625forward KL · natsstudent / on-policy at collection

Invariant 1: moving across columns changes the divergence, not provenance. Invariant 2: moving down rows changes source coefficients, not KL direction. Values mix the supplied fixed route with the realized u = 0.8 student route; they are not the full student-trajectory expectation.

What the gradient preview holds fixed

The prefix xB, teacher vector [0.9,0.1], vocabulary order [A,B], and temperature 1 stay fixed. Only the student logits move. Reverse default: [-0.430022272614733, 0.430022272614733]. Forward: [-0.300000000000000, 0.300000000000000]. Neither vector differentiates through the earlier categorical draw.

The table is not redundant decoration. It is the complete no-script and print path, and it makes every boundary state inspectable at once.