M1 — the linear train step descends the certified softmax-CE gradient #
StableHLO.lean proves the Chapter-1 linear train step piecewise: the forward
graph (fwdGraph_faithful), the loss cotangent (lossCotGraph_isCEgrad), the
per-parameter Jacobians (wGrad/bGrad_isWeightJacobian), and the plain-SGD update
(sgdW/sgdB_isCertifiedGradStep). Each of those, however, still mentions the
emitted cotangent as den (lossCotGraph …) — a denotation of an emitted graph,
not yet a named closed form.
This file bundles them into a single statement per parameter: the emitted SGD
update subtracts lr times [the certified ∂logits/∂θ Jacobian] contracted with
[the certified closed-form softmax-CE gradient softmax − onehot]. Every factor
is now a named, axiom-audited certified quantity — no residual den-of-graph, no
trusted optimizer step. This is the denotation half of milestone M1 for linear
(what the emitted train step computes).
Two things are deliberately NOT done here, and are tracked in
planning/archive/verified_train_step.md:
- The chain-rule fold. The two-factor sum below is, by
pdiv_comp, the single gradient∂/∂θ (crossEntropy ∘ mnistLinear)— i.e. literally one step of gradient descent on the loss. Stating it in folded form needsDifferentiableAtforcrossEntropy(no such lemma exists yet) and for the dense-wrt-flattened-weights map; left as the next proof step. The unfolded form here carries the same content with no smoothness obligation. - The rendering half.
den/SHlois a single-example semantics with no constructors for the batched weight-graddot_general, bias-gradreduce, or SGDmultiply/subtract; that tail ofverified_mlir/linear_train_step.mliris still hand-written string concat. Closingemitted text = render(provenGraph)needs the batched multi-output AST (Stage 1 of the plan).
M1 (weight). The emitted linear SGD weight update subtracts lr times the
certified ∂logits/∂W Jacobian contracted with the certified closed-form
softmax-CE gradient softmax − onehot.
crossEntropy is differentiable in the logits. The standalone form of the
differentiability infrastructure inside softmaxCE_grad: softmax > 0 lets
Real.log (hence crossEntropy = -log(softmax · label)) inherit smoothness.
The dense layer is differentiable in its (flattened) weights. The map
v ↦ dense (unflatten v) b x is affine — a finite sum of coordinate
evaluations scaled by x, plus the constant bias.
The softmax-CE loss is differentiable in the (flattened) weights.
The total-loss gradient wrt a weight entry equals the certified
(∂logits/∂W) · (softmax − onehot) contraction (the chain rule, pdiv_comp).
M1 (weight, folded). The emitted linear SGD weight update is literally
one step of gradient descent on the certified softmax-CE loss:
W − lr·∂(crossEntropy ∘ mnistLinear)/∂W.
One updated-parameter output of a multi-result module: its MLIR result type,
the SSA name it binds, and the lines computing it from the rendered cotangent
%dy. Renderable (computable); the ℝ-valued denotation lives separately.
Instances For
A multi-output train-step module: the forward+loss cotangent subgraph (an
SHlo, rendered ONCE → shared %dy) plus the updated-parameter outputs. The
multi-result generalization of renderModule.
Instances For
renderModuleN — render a multi-output module: cotangent once (shared
%dy), each output's lines, then a tuple return.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The linear train-step module (renderable; the %onehot value is a runtime
input that pretty ignores, so the placeholder cotangent renders identically
to the live one). Structural peer of linearTrainStepModuleV.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The two outputs' ℝ denotations: the flattened certified weight update and
the certified bias update.
Equations
- Proofs.StableHLO.linWeightDen W b x lr label = (Proofs.StableHLO.sgdW W b x lr label).flatten
Instances For
Equations
- Proofs.StableHLO.linBiasDen W b x lr label = Proofs.StableHLO.sgdB W b x lr label
Instances For
denN — the tuple of per-example output denotations the module computes.
Equations
- Proofs.StableHLO.linTrainStepDenN W b x lr label = [⟨m * n, Proofs.StableHLO.linWeightDen W b x lr label⟩, ⟨n, Proofs.StableHLO.linBiasDen W b x lr label⟩]
Instances For
Faithfulness, output 0 (weights). The rendered weight output denotes
literally W − lr·∂(softmax-CE loss)/∂W (M1 sgdW_descends_loss_gradient).