ResNet-34's whole-net input-VJP at TRUE BATCH-NORM (T1, the VJP half) #
ResNet34FullB.lean states the batch-BN forward and its typed graph. This file gives that forward
a certified HasVJPAt at the paper depth — the batched peer of what MobileNetV2FullVJP.lean does
for MobileNetV2's seventeen bottlenecks, and the last piece of T1 in formalization.yaml 4e's port.
No new mathematics, and one new lemma one tier down #
Every block VJP is already proven at bnBatchLA: r34BasicBlockB_has_vjp_at and
r34DownBlockB_has_vjp_at (ResNet34BackB0.lean) are exactly the two block shapes
ResNet34FullB.lean's r34IdB / r34DownB unfold to. The eight bundle lemmas below are
delegations in the EfficientNetFullB0 style.
⭐ The one thing that did not exist is batchMap_has_vjp_at (Foundation/BatchMapVJPAt.lean,
written for this): r34's stem ends in batchMap N (maxPool3s2Flat 64 56 56) and a max-pool has no
derivative at a tie, so the GLOBAL batchMap_has_vjp cannot lift it. The per-example pool VJP at a
Vec point was already there (maxPool3s2Flat_has_vjp_at_vec), so the batched pool is two lines.
The hypothesis budget #
⚠ Pointwise (HasVJPAt), not global, and necessarily. relu is kinked. ⛔ And r34 carries
two kink clauses per block, not one: the body's mid-relu AND the post-residual outer relu.
That outer relu is ResNet's structural difference from MobileNetV2/EfficientNet, whose residual
add IS the block output. Sixteen blocks therefore carry 32 clauses, plus the stem's relu and the
stem pool's no-tie condition — bundled per block into R34IdSmoothAt / R34DownSmoothAt so the
apex binds 18 smoothness bundles rather than 34 loose hypotheses, exactly as
MobileNetV2FullVJP.lean bundles IVSmoothAt.
⚠ The pool's condition is per example (∀ r : Fin N, MaxPool3s2Smooth … on that example's
row), because a tie is a property of one image's window, not of the batch. That is the shape
batchMap_has_vjp_at consumes.
The running activations are named r34Pre1 … r34Pre16 so each bundle can be STATED at the
activation entering its block without a sixteen-deep nested application inline; r34Pre16 doubles
as the trunk, and resnet34ForwardB_full_eq_chain bridges it back to the committed
nested-application forward.
⭐ N is a variable throughout: this tier carries no numerals.
Both relu sites of an identity basic block are away from the kink at v: the body's mid-relu
(at the first BN's output) and the OUTER relu (at the post-residual sum).
Instances For
Both relu sites of a downsample basic block are away from the kink at v. The mid-relu is
after the STRIDED conv's BN (already at h×w); the outer relu is at the projected residual.
- hmid (k : Fin (N * (oc * h * w))) : StableHLO.bnBatchLA N oc h w q.ε₁ q.γ₁ q.β₁ (StableHLO.batchMap N (flatConvStride2 q.W₁ q.b₁) v) k ≠ 0
Instances For
The stem's relu is away from the kink at the input x (the 7×7/s2 conv's BN output, at the
pre-pool 2h×2w grid).
Equations
- One or more equations did not get rendered due to their size.
Instances For
The stem pool has no argmax tie, per example: a tie is a property of one image's 3×3
window, so the condition is stated on each row of the batched activation. This is the shape
batchMap_has_vjp_at consumes.
Equations
- Proofs.R34PoolSmoothAt N h w v = ∀ (r : Fin N), Proofs.MaxPool3s2Smooth (Proofs.Tensor3.unflatten (Proofs.Mat.unflatten v r))
Instances For
Identity basic block VJP — r34BasicBlockB_has_vjp_at at the bundle's fields.
Equations
Instances For
Downsample basic block VJP — r34DownBlockB_has_vjp_at at the bundle's fields.
Equations
Instances For
⭐ Stem VJP: the 7×7/s2 conv-bn-relu, then the batched 3×3/s2 pool. The pool half is where
batchMap_has_vjp_at earns its existence.
Equations
- One or more equations did not get rendered due to their size.
Instances For
⭐ The head is GLOBAL — GAP and dense are both smooth everywhere, and each is batchMap of a
per-example op, so batchMap_has_vjp suffices and no smoothness hypothesis appears.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Proofs.r34Pre1 N w = Proofs.r34IdB N 56 56 w.a0 ∘ Proofs.r34Pre0 N w
Instances For
Equations
- Proofs.r34Pre2 N w = Proofs.r34IdB N 56 56 w.a1 ∘ Proofs.r34Pre1 N w
Instances For
Equations
- Proofs.r34Pre3 N w = Proofs.r34IdB N 56 56 w.a2 ∘ Proofs.r34Pre2 N w
Instances For
Equations
- Proofs.r34Pre4 N w = Proofs.r34DownB N 28 28 w.d2 ∘ Proofs.r34Pre3 N w
Instances For
Equations
- Proofs.r34Pre5 N w = Proofs.r34IdB N 28 28 w.b0 ∘ Proofs.r34Pre4 N w
Instances For
Equations
- Proofs.r34Pre6 N w = Proofs.r34IdB N 28 28 w.b1 ∘ Proofs.r34Pre5 N w
Instances For
Equations
- Proofs.r34Pre7 N w = Proofs.r34IdB N 28 28 w.b2 ∘ Proofs.r34Pre6 N w
Instances For
Equations
- Proofs.r34Pre8 N w = Proofs.r34DownB N 14 14 w.d3 ∘ Proofs.r34Pre7 N w
Instances For
Equations
- Proofs.r34Pre9 N w = Proofs.r34IdB N 14 14 w.c0 ∘ Proofs.r34Pre8 N w
Instances For
Equations
- Proofs.r34Pre10 N w = Proofs.r34IdB N 14 14 w.c1 ∘ Proofs.r34Pre9 N w
Instances For
Equations
- Proofs.r34Pre11 N w = Proofs.r34IdB N 14 14 w.c2 ∘ Proofs.r34Pre10 N w
Instances For
Equations
- Proofs.r34Pre12 N w = Proofs.r34IdB N 14 14 w.c3 ∘ Proofs.r34Pre11 N w
Instances For
Equations
- Proofs.r34Pre13 N w = Proofs.r34IdB N 14 14 w.c4 ∘ Proofs.r34Pre12 N w
Instances For
Equations
- Proofs.r34Pre14 N w = Proofs.r34DownB N 7 7 w.d4 ∘ Proofs.r34Pre13 N w
Instances For
Equations
- Proofs.r34Pre15 N w = Proofs.r34IdB N 7 7 w.e0 ∘ Proofs.r34Pre14 N w
Instances For
Equations
- Proofs.r34Pre16 N w = Proofs.r34IdB N 7 7 w.e1 ∘ Proofs.r34Pre15 N w
Instances For
⭐⭐ ResNet-34 at TRUE BATCH-NORM has a certified input-VJP at a smooth point — all sixteen
basic blocks. Chains stem → the [3,4,6,3] ladder → head with vjp_comp_at, one positivity
bundle and one smoothness bundle per block. T1's VJP half for formalization.yaml 4e's port.
⚠ Pointwise, and necessarily: relu is kinked. ⛔ Each block contributes TWO clauses — the body's mid-relu and the post-residual OUTER relu — where MobileNetV2's bottleneck contributes two relu6 clauses and EfficientNet's MBConv contributes none.
⭐ The head takes no hypothesis at all (GAP and dense are smooth, and each is batchMap of a
per-example op), and N is a variable: this tier carries no numerals.
Equations
- One or more equations did not get rendered due to their size.
Instances For
⭐ The committed nested-application forward IS the layered chain the VJP is stated on —
the r34 peer of mobilenetv2ForwardB_full_eq_chain, and what lets the VJP be about
resnet34ForwardB_full rather than about a re-spelling of it.
⭐⭐ Public correctness theorem: the sixteen-block batch-BN backward equals the
pdiv-contracted Jacobian of resnet34ForwardB_full ITSELF — the committed
nested-application forward ResNet34FullB.lean defines and
resnet34FwdGraphB_full_faithful proves the typed graph denotes — not of the layered chain
the VJP is assembled on. Tied back through resnet34ForwardB_full_eq_chain.