Documentation

LeanMlir.Proofs.Nets.ResNet.ResNet34Fold

PoC: the ResNet-34 (Chapter 5) train step, proof-tied to the certified SGD step #

The Chapter-5 capstone — the full [3,4,6,3] ResNet-34 (a 7×7/s2 stem, 16 residual blocks, GAP + final dense). This file makes every parameter update of the per-example, SGD-inline train step den-faithful — each emitted SGD op denotes the certified loss-descent step.

RETIRED ARTIFACT (2026-09-06, 4c leg 1). This fold was about verified_mlir/resnet34_train_step.mlir, and both that file and its renderer (ResNet34Render.lean) are gone: it was the last train step in the suite at per-example BatchNorm, so resnet34_fwd could not be a prefix of both it and the batch-BN Adam step. planning/archive/renderer_convergence.md carries the decision. Every theorem below is unchanged and still true — each is a statement about an OP KIND and an arbitrary cotangent, not about bytes — and its live peer is Nets/ResNet/ResNet34FoldB.lean, the same fold at the batched, un-fused gradient nodes every ResNet-34 artifact now emits. Read this file as the per-example ladder it always was; read that one for what ships.

Two new core ops, ZERO new theorems for 142 of the 146 params. Like cifar8-bn, the overwhelming majority of ResNet-34's parameter outputs fold by reusing the existing generic den = certified lemmas:

The genuinely-new shapes are the strided convolutions — the 7×7/s2 stem and the 3×3/s2 downsample bodies + projection skips — which no prior fold exercised through an SGD op. They get the two new core ops convStridedWeightSgd/convStridedBiasSgd (StableHLO.lean) and the two den = certified lemmas below. Both are one-line delegations to the generic strided bridge mnv2_render_stem_conv{W,b}_certified, exactly mirroring CifarPoC.convW_den's delegation to cnn_render_convW_certified.

Honest residual (same boundary as every prior fold) #

Strided convolutions — the two new den = certified lemmas (the only new content) #

theorem Proofs.ResNet34PoC.convStridedW_den {ic oc h w kH kW : } (xN wN lrStr cotN : String) (b : Vec oc) (x : Vec (ic * (2 * h) * (2 * w))) (W : Kernel4 oc ic kH kW) (c : Vec (oc * h * w)) (lr : ) (idx : Fin (oc * ic * kH * kW)) :
StableHLO.den (StableHLO.SHlo.convStridedWeightSgd xN wN lrStr b x W lr (StableHLO.SHlo.operand cotN c)) idx = W.flatten idx - lr * j : Fin (oc * h * w), pdiv (fun (v' : Vec (oc * ic * kH * kW)) => flatConvStride2 (Kernel4.unflatten v') b x) W.flatten idx j * c j

Any emitted STRIDED conv weight op = certified. Generic in the conv dims, the kernel size (covers the 7×7 stem AND every 3×3 downsample/projection) and the cotangent c: the convStridedWeightSgd op denotes flatten W − lr·(certified ∂(flatConvStride2)/∂W · c), the emitted op's den reduced (rfl) to the LHS of the generic strided weight bridge. The strided peer of CifarPoC.convW_den.

theorem Proofs.ResNet34PoC.convStridedB_den {ic oc h w kH kW : } (bN lrStr cotN : String) (W : Kernel4 oc ic kH kW) (x : Vec (ic * (2 * h) * (2 * w))) (b : Vec oc) (c : Vec (oc * h * w)) (lr : ) (o : Fin oc) :
StableHLO.den (StableHLO.SHlo.convStridedBiasSgd bN lrStr W x b lr (StableHLO.SHlo.operand cotN c)) o = b o - lr * j : Fin (oc * h * w), pdiv (fun (b' : Vec oc) => flatConvStride2 W b' x) b o j * c j

Any emitted STRIDED conv bias op = certified. The bias peer of convStridedW_den; the convStridedBiasSgd op (which emits the same reduce text as convBiasSgd) denotes b − lr·(certified ∂(flatConvStride2)/∂b · c).