Backward-graph faithfulness for the VERIFIED MobileNetV2 inverted-residual block #
The MobileNetV2 peer of EfficientNetBackB0.lean: a backward StableHLO graph
that denotes the proven VJP of the batched MobileNetV2 inverted-residual block —
project ∘ depthwise-bn-relu6 ∘ expand-bn-relu6 with the linear-bottleneck skip.
The block is the EfficientNet MBConv body minus the squeeze-excite stage, with
relu6 in place of swish and the same linear-bottleneck projB (1×1 conv →
bn, no activation). The project stage and the residual fan-in are reused VERBATIM
from the EfficientNet file (they are global/clean — no smoothness wrinkle).
The relu6 wrinkle #
Unlike swish (smooth everywhere, GLOBAL swish_has_vjp), relu6 has a TWO-SIDED kink
(at 0 and at 6), so its VJP is only the pointwise relu6_has_vjp_at, conditioned
on the smoothness hypothesis ∀ k, x k ≠ 0 ∧ x k ≠ 6 at the pre-activation. Its
per-op backward token is .selectMid (the mask if 0<x<6 then dy else 0), whose
denotation faithfulness is the already-proven (rfl) selectMid_faithful
(StableHLO.lean:794).
Because relu6's VJP is _at, the whole MobileNetV2 stage/body VJP and its backward-
graph faithfulness are stated in the _at / hypothesis-threaded form (via
vjp_comp_at, lifting the global bnBatchLA/batchMap/conv/depthwise VJPs through
HasVJP.toHasVJPAt), NOT the EfficientNet global form. The relu6 smoothness
hypothesis at the pre-relu6 activation bnBatchLA(…)(batchMap(conv)(x)) is threaded
through; the bn/conv/depthwise pieces stay activation-independent (linear) or global.
Structure #
cbrB/dwbrB— batched conv/depthwise → bn → relu6 stages (cbsB/dwbsBwithrelu6forswish), with_atdifferentiability + VJP and backward-graph faithfulness (cbrBackBatchedGraph+…_faithful).cbrLayer/dwbrLayer/dwbrStridedLayer/projLayer— the four stages asCertLayers.mnv2BodyLayer/mnv2DownBodyLayercompose them withCertLayer.comp, and each body VJP, differentiability lemma and graph_faithfulis that layer'svjp/diff/faithful.mnv2BodyB_has_vjp_at— the SE-less bodyprojB ∘ dwbrB ∘ cbrBat the relu6 smoothness families, with its backward graphmnv2BodyBackBatchedGraph+…_faithful. ⚠ This family takesicandocSEPARATELY (2026-09-06). It was written for the residual block and pinned them equal, which is right there but wrong one level up: the paper ladder'sb11(64 → 96) andb17(160 → 320) are stride-1 bodies withic ≠ oc, andMobileNetV2FullB.lean'smnv2ExpOnlyBis exactly that shape. Generalising changed no proof —mnv2DownBodyBalready had this shape, and every existing call site (BackNetFolds.lean) is atic = ocand infers it.mnv2ResidBlockBackBatchedGraph_faithful— the CAPSTONE: the whole batched MobileNetV2 inverted-residual block backward graph (body + identity skip) denotes the provenresidual_has_vjp_atof the SE-less body. Mirrors the EfficientNetmbResidBlockBackBatchedGraph_faithfulwithout theseBfactor, threaded through the relu6 smoothness hypotheses;CertLayer.residual mnv2BodyLayer'sfaithful.
Batched conv → bn → relu6 stage (MobileNetV2 expand), at the network layout
N·(oc·h·w). Identical to EfficientNet's cbsB but with relu6 for swish.
Equations
- Proofs.StableHLO.cbrB N W b ε γ β = Proofs.relu6 (N * (oc * h * w)) ∘ Proofs.StableHLO.bnBatchLA N oc h w ε γ β ∘ Proofs.StableHLO.batchMap N (Proofs.flatConv W b)
Instances For
Batched depthwise → bn → relu6 stage (MobileNetV2 depthwise), at the network
layout. Identical to EfficientNet's dwbsB but with relu6 for swish.
Equations
- Proofs.StableHLO.dwbrB N W b ε γ β = Proofs.relu6 (N * (c * h * w)) ∘ Proofs.StableHLO.bnBatchLA N c h w ε γ β ∘ Proofs.StableHLO.batchMap N (Proofs.depthwiseFlat W b)
Instances For
Batched STRIDE-2 depthwise → bn → relu6 stage (MobileNetV2 downsample
depthwise), at the network layout. The stride-2 analogue of dwbrB: maps the
larger input spatial c·(2h)·(2w) to the output spatial c·h·w. Identical to
EfficientNet's dwbsSB but with relu6 for swish.
Equations
- Proofs.StableHLO.dwbrBstrided N W b ε γ β = Proofs.relu6 (N * (c * h * w)) ∘ Proofs.StableHLO.bnBatchLA N c h w ε γ β ∘ Proofs.StableHLO.batchMap N (Proofs.depthwiseStride2FlatXla W b)
Instances For
Generic relu6-on-batched-bn-stage _at VJP. The relu6 analogue of
bnSwishStage_has_vjp, but _at (relu6 only has a pointwise VJP): compose the
batched-op VJP, the true-BN VJP (both global, lifted via .toHasVJPAt), and
relu6's pointwise VJP at the pre-relu6 activation.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Differentiability of the generic relu6-on-batched-bn-stage at a smooth point.
cbrB (conv-bn-relu6) _at VJP at a smooth point.
Equations
- Proofs.StableHLO.cbrB_has_vjp_at N W b ε hε γ β x h_smooth = Proofs.StableHLO.bnRelu6Stage_has_vjp_at N (Proofs.flatConv W b) ⋯ (Proofs.flatConv_has_vjp W b) ε hε γ β x h_smooth
Instances For
dwbrB (depthwise-bn-relu6) _at VJP at a smooth point.
Equations
- Proofs.StableHLO.dwbrB_has_vjp_at N W b ε hε γ β x h_smooth = Proofs.StableHLO.bnRelu6Stage_has_vjp_at N (Proofs.depthwiseFlat W b) ⋯ (Proofs.depthwiseFlat_has_vjp W b) ε hε γ β x h_smooth
Instances For
dwbrBstrided (STRIDE-2 depthwise-bn-relu6) _at VJP at a smooth point. The
stride-2 analogue of dwbrB_has_vjp_at: lifts depthwiseStride2FlatXla_has_vjp
(the strided per-channel conv input-VJP) through the generic relu6-bn stage.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Batched conv → bn → relu6 stage backward graph (MobileNetV2 expand):
convBackBatched ∘ bnBatchLABack ∘ selectMid, each at its cumulative forward
activation. The relu6 analogue of cbsBackBatchedGraph — .selectMid (the
relu6 two-sided-kink mask) replaces .swishBack.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Batched depthwise → bn → relu6 stage backward graph (MobileNetV2 depthwise).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Batched STRIDE-2 depthwise → bn → relu6 stage backward graph (MobileNetV2
downsample depthwise). The stride-2 analogue of dwbrBackBatchedGraph: the
bn/relu6 run at the OUTPUT spatial h×w, then depthwiseStridedBackBatched maps
the bn-cotangent back to the larger input c·(2h)·(2w) (zero-upsample +
reversed-kernel per-channel depthwise). The relu6 back is .selectMid as before.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The conv → bn → relu6 stage as a CertLayer, certified where its pre-relu6 activation misses
both kinks. The kernel extent is a binder, so the same layer is a 1×1 or a 3×3.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The depthwise → bn → relu6 stage as a CertLayer.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The stride-2 depthwise → bn → relu6 stage as a CertLayer: 2h × 2w in, h × w out.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The conv → bn stage (projB, no activation) as a CertLayer. Globally certified
(ok = True): with no activation there is no kink.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The SE-less body as a CertLayer: cbrLayer ; dwbrLayer ; projLayer, left-nested so its
fwd is projB ∘ (dwbrB ∘ cbrB), the association the stated types use. Its ok is the
expand and depthwise relu6 clauses; projLayer contributes True.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The batched MobileNetV2 inverted-residual body's VJP at a smooth point —
projB ∘ dwbrB ∘ cbrB (the EfficientNet MBConv body MINUS seB, with relu6
for swish), mnv2BodyLayer's VJP.
h_se is the expand relu6 smoothness (at the cbrB pre-relu6 activation);
h_sd is the depthwise relu6 smoothness (at the dwbrB pre-relu6 activation,
fed the cbrB output).
Equations
- One or more equations did not get rendered due to their size.
Instances For
The batched MobileNetV2 body backward graph: the three stage graphs chained at
their cumulative forward activations (cbrB⁻¹ ∘ dwbrB⁻¹ ∘ projB⁻¹).
Equations
- One or more equations did not get rendered due to their size.
Instances For
The downsample body as a CertLayer: cbrLayer at 2h × 2w, then dwbrStridedLayer and
projLayer at h × w.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The batched MobileNetV2 DOWNSAMPLE inverted-residual body's VJP at a smooth
point — projB ∘ dwbrBstrided ∘ cbrB, the stride-2 analogue of
mnv2BodyB_has_vjp_at (swaps the stride-1 dwbrB depthwise stage for the
STRIDED dwbrBstrided). The expand cbrB runs at the larger 2h×2w (1×1
conv keeps spatial), the strided depthwise then halves spatial to h×w; project
runs at h×w. NO residual (spatial/channels change), so this is the body alone:
mnv2DownBodyLayer's VJP.
h_se is the expand relu6 smoothness (at the cbrB pre-relu6 activation, at
2h×2w); h_sd is the strided-depthwise relu6 smoothness (at the dwbrBstrided
pre-relu6 activation, fed the cbrB output).
Equations
- One or more equations did not get rendered due to their size.
Instances For
The batched MobileNetV2 downsample body backward graph: the three stage graphs
chained at their cumulative forward activations
(cbrB⁻¹ ∘ dwbrBstrided⁻¹ ∘ projB⁻¹). Stride-2 analogue of
mnv2BodyBackBatchedGraph (strided depthwise stage graph, no residual).
Equations
- One or more equations did not get rendered due to their size.
Instances For
CAPSTONE — the batched MobileNetV2 DOWNSAMPLE inverted-residual body: backward
graph ↔ the proven mnv2DownBodyB_has_vjp_at. The three batched stage backward
graphs (cbrB/dwbrBstrided/projB) chained at their forward activations,
proven equal to the downsample-body VJP. The stride-2 analogue of
mnv2BodyBackBatchedGraph_faithful (no residual skip — the downsample block
changes spatial/channels, so the body alone is the block), threaded through the
two relu6 smoothness hypotheses (relu6's VJP is only _at). The MobileNetV2
relu6 peer of the EfficientNet mbDownBodyBackBatchedGraph_faithful; it is
mnv2DownBodyLayer's faithful.
The whole batched MobileNetV2 inverted-residual block backward graph (body + identity skip).
Equations
- One or more equations did not get rendered due to their size.
Instances For
CAPSTONE — the whole batched MobileNetV2 inverted-residual block: backward
graph ↔ the proven VJP. The three batched stage backward graphs
(cbrB/dwbrB/projB) chained at their forward activations + the identity
skip, proven equal to residual_has_vjp_at of the SE-less body
projB ∘ dwbrB ∘ cbrB. The MobileNetV2 analogue of the EfficientNet
mbResidBlockBackBatchedGraph_faithful, without the seB factor, threaded
through the relu6 smoothness hypotheses (relu6's VJP is only _at).
It is CertLayer.residual mnv2BodyLayer's faithful: the residual fan-in backward
(body cotangent + the identity skip's verbatim %dy).