Documentation

LeanMlir.Proofs.Nets.MobileNet.MobileNetV4FullB

MobileNetV4-Conv-M at batch BatchNorm — the whole net's forward and graph #

MobileNetV4BackB0.lean is the block and stage level — every UIB family, the stride-2 form, the fused stage, the head, the table-driven k = 0 dispatch and the row-typed UibParams. This file is the net level: a net-level ℝ forward at the 21-row Conv-M table (mobilenetv4ForwardBFull), the typed StableHLO graph over it at mnv4FwdChainB's own tokens (mnv4FwdGraphBFull), and their faithfulness (mnv4FwdGraphBFull_faithful). ResNet50FullB.lean is the file this one mirrors.

This is timm's mobilenetv4_conv_medium (1.0.28, the pinned spec): the post-DW carries each downsample's stride, the pre-DW is BN only, stage 0 is relu, the head pools before conv_head, the stem pads symmetrically. The artifacts are pinned to that function by three gates: scripts/parity/mnv4_timm_parity.py (the JAX reference = timm on shared weights), scripts/parity/mnv4_forward_tie.py (the render = the JAX reference) and scripts/parity/grad_tie.py --net mnv4 (the render's backward = jax.grad of it).

No accuracy is quoted for this net.

The trunk is five CertLayer groups #

Each resolution group — rows 1–2, 3–6, 7–10, 11–15, 16–21 — is assembled with CertLayer.comp and CertLayer.residual directly, as are the fused stage and the head, and inside a group:

The groups are composed by a prefix chain (mnv4Pre0 … mnv4Pre6), not by one more CertLayer.comp; the section before mnv4Pre0 says why. Mnv4SmoothAt therefore binds one .ok per group plus the stem's clause (eight fields), and no 0 < ε hypothesis, because those live inside the weight records.

The stem sits outside the chain, as EfficientNet-B0's does. CertLayer demands a backward graph, and no render emits a gradient into %x: the artifact's backward ends at the stem conv's weight gradient. So mnv4StemB is a plain function here (cbReluStridedB at the stem's widths), its VJP is cbReluStridedBHasVJPAt, and the net-level VJP composes the two with vjpCompAt.

Conventions this net runs at #

depth21 UIB blocks + the fused stage; 13 ExtraDW / 4 ConvNeXt-like / 4 FFN, and no IB
ladder224 →(stem s2) 112 →(fused s2) 56 →(blk1) 28 →(blk3) 14 →(blk11) 7 → GAP
channels32 → 48 → 80 → 160 → 256, head 256 → 960 → 1280
BatchNormbatch (bnBatchLA, reduce [0,2,3], width N·h·w) at all 77 sites
activationrelu, not relu6 (MobileNetV2 sits one file over and uses relu6), after every expand, post-DW, the stem, stage 0 and both head convs; the pre-DW and the project are BN only
paddingSYMMETRIC (k-1)/2 at every strided site — the stem, stage 0, the three strided post-DWs (timm)
stridethe three stride-2 rows (1, 3, 11) stride their POST-DW (timm's dw_mid); the pre-DW and the expand run at the input resolution
head1×1 256 → 960 conv-bn-relu at 7×7, GAP, then conv_head 960 → 1280 conv-bn-relu on the pooled [N, 960, 1, 1] (its BN over the batch alone), then dense
census233 parameter slots at nCls = 10 (8,447,322 scalars; 9,715,512 at 1000), bias-free by construction
artifactsmnv4_fwd, mnv4in_fwd, and the 224×224 train steps at either precision — bf16 := false for mnv4_adam_train_step, mnv4in_adam64, mnv4in_adamdp64, true for the *bf16 ones' trunk. Not this graph: the frozen-statistics evals mnv4{,in}_fwd_eval and the 256×256 mnv4in_fwd_eval_s256 (stated in MobileNetV4FullBEval, at any input size, f32), the classifier-dropout variants mnv4in_emaacc{,dp}8x128wxdowd005bf16 (a %do operand; mnv4FwdGraphBFullDo below at bf16 := true), and the stochastic-depth train steps mnv4in_acc{,dp}8x128wxdropdowd01bf16 (a drop-path site on each of the 18 skip rows; MobileNetV4FullBDrop's graph at bf16 := true)

N stays a binder throughout, as at r34/R50. On the data-parallel artifacts the render's N is the per-replica batch and BatchNorm is synchronised across replicas; MobileNetV4SyncB.lean is this file's twin for them: replica r's forward graph denotes shard r of mobilenetv4ForwardBFull (R * N), this file's forward at the global batch. Unlike R50 there is no resolution binder q: the statements are at 224×224.

Rows 4/5/7, 8/10, 12/18, 13/14 and 15/19/20 are shape-identical (same ic, oc, expand, preDWk, postDWk, h), so their UibParams records have the same type and swapping their weights typechecks. Typing pins shape, not identity; what pins identity is the SSA names the forward graph writes (%u4qW vs %u10qW), which is why the graph reads its names from s.p off the table rather than taking them as arguments.

Checked against the committed bytes: verified_mlir/mnv4_fwd.mlir's signature is 234 arguments = %x + 233 parameters, and every name this file writes appears there.

References #

These are abbrevs, and the rows are named rather than indexed. UibParams (mnv4Blocks[3]!) in a type would force whnf through List.get! at every use; a named reducible constant reduces to its projections directly, which is what lets CertLayer.comp line up 2 * 28 with 56 across a stride join without a single transport.

The #guard below is the whole safety of that move: these 21 constants are pinned to mnv4Blocks — the ONE table mnv4FwdChainB, the backward, the parameter signature and the BN stat list all fold over — so a typo here is a build failure rather than a proof about a different net.

@[reducible, inline]
Equations
Instances For
    @[reducible, inline]
    Equations
    Instances For
      @[reducible, inline]
      Equations
      Instances For
        @[reducible, inline]
        Equations
        Instances For
          @[reducible, inline]
          Equations
          Instances For
            @[reducible, inline]
            Equations
            Instances For
              @[reducible, inline]
              Equations
              Instances For
                @[reducible, inline]
                Equations
                Instances For
                  @[reducible, inline]
                  Equations
                  Instances For
                    @[reducible, inline]
                    Equations
                    Instances For
                      @[reducible, inline]
                      Equations
                      Instances For
                        @[reducible, inline]
                        Equations
                        Instances For
                          @[reducible, inline]
                          Equations
                          Instances For
                            @[reducible, inline]
                            Equations
                            Instances For
                              @[reducible, inline]
                              Equations
                              Instances For
                                @[reducible, inline]
                                Equations
                                Instances For
                                  @[reducible, inline]
                                  Equations
                                  Instances For
                                    @[reducible, inline]
                                    Equations
                                    Instances For
                                      @[reducible, inline]
                                      Equations
                                      Instances For
                                        @[reducible, inline]
                                        Equations
                                        Instances For
                                          @[reducible, inline]
                                          Equations
                                          Instances For

                                            Every MobileNetV4-Conv-M parameter, generic in the class count so one statement covers the 10-class Imagenette artifacts and the 1000-class mnv4in ones.

                                            The 21 block fields are UibParams mnv4Row{k} — a record whose every width is a projection of its row, so a record that disagrees with its row cannot be constructed and the forward below needs no side conditions on widths. That is strictly stronger than ResNet-50's R50IdW/R50ProjW, which are typed by loose {mid oc} binders. It still does not pin identity between shape-identical rows (4/5/7, 8/10, 12/18, 13/14, 15/19/20) — see the header.

                                            The 0 < ε obligations live INSIDE the records (UibParams's hq he hd hz), so the stem, the fused stage and the head carry theirs as fields too. R50 keeps a separate R50IdPos bundle; matching UibParams here means the whole-net VJP binds no epsilon hypotheses at all.

                                            Every conv is bias-free — both renders bake convBias := false and bind each bias to the %zb{c} zero the prelude declares — but the records still carry a b slot because the stage vocabulary takes one. Those fields are ∀-quantified over; bias = 0 is one instance. Field names are the render's own SSA prefixes, so a reader can match a parameter to its emitted name without a table.

                                            • sW : Kernel4 32 3 3 3

                                              stem %sW/%sg/%sbt: 3×3/s2, symmetric, 3 → 32, 224 → 112.

                                            • sb : Vec 32
                                            • sE : ℝ
                                            • hsE : 0 < self.sE
                                            • sg : Vec 32
                                            • sbt : Vec 32
                                            • f0cW : Kernel4 128 32 3 3

                                              fused stage %f0cW: 3×3/s2 symmetric, 32 → 128, 112 → 56, then relu.

                                            • f0cb : Vec 128
                                            • f0cE : ℝ
                                            • hf0cE : 0 < self.f0cE
                                            • f0cg : Vec 128
                                            • f0cbt : Vec 128
                                            • f0pW : Kernel4 48 128 1 1

                                              fused stage %f0pW: the 1×1 project, 128 → 48, no activation.

                                            • f0pb : Vec 48
                                            • f0pE : ℝ
                                            • hf0pE : 0 < self.f0pE
                                            • f0pg : Vec 48
                                            • f0pbt : Vec 48
                                            • block 1: %u1*, 48 → 80, expand 4, dw 3/5, at 28×28.

                                            • block 2: %u2*, 80 → 80, expand 2, dw 3/3, at 28×28.

                                            • block 3: %u3*, 80 → 160, expand 6, dw 3/5, at 14×14.

                                            • block 4: %u4*, 160 → 160, expand 4, dw 3/3, at 14×14.

                                            • block 5: %u5*, 160 → 160, expand 4, dw 3/3, at 14×14.

                                            • block 6: %u6*, 160 → 160, expand 4, dw 3/5, at 14×14.

                                            • block 7: %u7*, 160 → 160, expand 4, dw 3/3, at 14×14.

                                            • block 8: %u8*, 160 → 160, expand 4, dw 3/0, at 14×14.

                                            • block 9: %u9*, 160 → 160, expand 2, dw 0/0, at 14×14.

                                            • block 10: %u10*, 160 → 160, expand 4, dw 3/0, at 14×14.

                                            • block 11: %u11*, 160 → 256, expand 6, dw 5/5, at 7×7.

                                            • block 12: %u12*, 256 → 256, expand 4, dw 5/5, at 7×7.

                                            • block 13: %u13*, 256 → 256, expand 4, dw 3/5, at 7×7.

                                            • block 14: %u14*, 256 → 256, expand 4, dw 3/5, at 7×7.

                                            • block 15: %u15*, 256 → 256, expand 4, dw 0/0, at 7×7.

                                            • block 16: %u16*, 256 → 256, expand 4, dw 3/0, at 7×7.

                                            • block 17: %u17*, 256 → 256, expand 2, dw 3/5, at 7×7.

                                            • block 18: %u18*, 256 → 256, expand 4, dw 5/5, at 7×7.

                                            • block 19: %u19*, 256 → 256, expand 4, dw 0/0, at 7×7.

                                            • block 20: %u20*, 256 → 256, expand 4, dw 0/0, at 7×7.

                                            • block 21: %u21*, 256 → 256, expand 2, dw 5/0, at 7×7.

                                            • h1W : Kernel4 960 256 1 1

                                              head conv 1 %h1W: 1×1, 256 → 960, at 7×7.

                                            • h1b : Vec 960
                                            • h1E : ℝ
                                            • hh1E : 0 < self.h1E
                                            • h1g : Vec 960
                                            • h1bt : Vec 960
                                            • hW : Kernel4 1280 960 1 1

                                              head conv 2 %hW (timm's conv_head): 1×1, 960 → 1280, on the POOLED features.

                                            • hb : Vec 1280
                                            • hE : ℝ
                                            • hhE : 0 < self.hE
                                            • hg : Vec 1280
                                            • hbt : Vec 1280
                                            • Wd : Mat 1280 nCls

                                              classifier %Wd/%bd, after conv_head.

                                            • bd : Vec nCls
                                            Instances For
                                              @[reducible]
                                              noncomputable def Proofs.StableHLO.mnv4StemB (N h w : ℕ) {ic oc kH kW : ℕ} (Ws : Kernel4 oc ic kH kW) (bs : Vec oc) (εs : ℝ) (γs βs : Vec oc) :
                                              Vec (N * (ic * (2 * h) * (2 * w))) → Vec (N * (oc * h * w))

                                              MNv4's stem forward: 3×3/s2 conv, SYMMETRIC padding (timm's conv_stem) → batch BN → relu. The XLA-SAME phase (flatConvStride2Xla, pads (0,1) at 224) also gives 112×112, so only a forward on shared weights tells the two apart.

                                              Equations
                                              Instances For
                                                noncomputable def Proofs.StableHLO.mnv4FusedStack (N : ℕ) {nCls : ℕ} (w : Mnv4BWeights nCls) :
                                                CertLayer (N * (32 * 112 * 112)) (N * (48 * 56 * 56))

                                                The fused stage (stage 0): 3×3/s2 symmetric conv-bn-relu 32 → 128 at 112 → 56, then the 1×1 project 128 → 48 (timm's EdgeResidual).

                                                Equations
                                                • One or more equations did not get rendered due to their size.
                                                Instances For
                                                  noncomputable def Proofs.StableHLO.mnv4HeadStack (N : ℕ) {nCls : ℕ} (w : Mnv4BWeights nCls) :
                                                  CertLayer (N * (256 * 7 * 7)) (N * nCls)

                                                  The head, timm's order: 1×1 256 → 960 conv-bn-relu at 7×7, GAP, conv_head 1×1 960 → 1280 conv-bn-relu on the pooled features (its BN over the batch alone), classifier.

                                                  Equations
                                                  • One or more equations did not get rendered due to their size.
                                                  Instances For

                                                    The trunk is built in groups, and that is a proof-engineering requirement. One 24-stage CertLayer elaborates fine — it is the graph faithfulness proof over it that does not: the whole-net rewrite chain produces a term whose kernel check ends in a deterministic timeout. Split at the net's own resolution boundaries, each group's proof is small, and the whole-net theorem is six rewrites over them. The grouping is the ladder a reader already knows — 56, 28, 14, 7 — so it costs nothing in readability and buys a bounded proof.

                                                    noncomputable def Proofs.StableHLO.mnv4Res28Layer (N : ℕ) {nCls : ℕ} (w : Mnv4BWeights nCls) :
                                                    CertLayer (N * (48 * 56 * 56)) (N * (80 * 28 * 28))

                                                    Trunk group Res28 — rows 1–2: the 56→28 reduction and the block that follows it.

                                                    Equations
                                                    Instances For
                                                      noncomputable def Proofs.StableHLO.mnv4Res14aLayer (N : ℕ) {nCls : ℕ} (w : Mnv4BWeights nCls) :
                                                      CertLayer (N * (80 * 28 * 28)) (N * (160 * 14 * 14))

                                                      Trunk group Res14a — rows 3–6: the 28→14 reduction, then three ExtraDW blocks.

                                                      Equations
                                                      • One or more equations did not get rendered due to their size.
                                                      Instances For
                                                        noncomputable def Proofs.StableHLO.mnv4Res14bLayer (N : ℕ) {nCls : ℕ} (w : Mnv4BWeights nCls) :
                                                        CertLayer (N * (160 * 14 * 14)) (N * (160 * 14 * 14))

                                                        Trunk group Res14b — rows 7–10 at 14×14: ExtraDW, ConvNeXt, FFN, ConvNeXt — three families in four blocks.

                                                        Equations
                                                        • One or more equations did not get rendered due to their size.
                                                        Instances For
                                                          noncomputable def Proofs.StableHLO.mnv4Res7aLayer (N : ℕ) {nCls : ℕ} (w : Mnv4BWeights nCls) :
                                                          CertLayer (N * (160 * 14 * 14)) (N * (256 * 7 * 7))

                                                          Trunk group Res7a — rows 11–15: the last reduction (14→7), then four blocks at 7×7.

                                                          Equations
                                                          • One or more equations did not get rendered due to their size.
                                                          Instances For
                                                            noncomputable def Proofs.StableHLO.mnv4Res7bLayer (N : ℕ) {nCls : ℕ} (w : Mnv4BWeights nCls) :
                                                            CertLayer (N * (256 * 7 * 7)) (N * (256 * 7 * 7))

                                                            Trunk group Res7b — rows 16–21 at 7×7: the net's tail.

                                                            Equations
                                                            • One or more equations did not get rendered due to their size.
                                                            Instances For

                                                              The seven groups are composed by a prefix chain, not by one more CertLayer.comp.

                                                              A mnv4NetLayer := fused.comp (res28.comp (… .comp head)) elaborates fine and reads beautifully. But every downstream statement then has to peel CertLayer.comp to get at .fwd, and at MNv4's LITERAL resolutions that peel is fatal: (L₁.comp L₂).fwd = L₂.fwd ∘ L₁.fwd is rfl, yet discharging it at these instances — by rfl, by simp only [CertLayer.comp_fwd], inside the graph-faithfulness capstone or in a standalone lemma — ends in a (kernel) deterministic timeout. The groups' own five-stage comp chains are fine; it is composing the compositions, under something that can start unfolding, that is not.

                                                              So the top level is seven named prefixes and the forward is their nest — ResNet-50's shape at seven stages instead of eighteen. What that costs is the hypothesis bundle: Mnv4SmoothAt binds one .ok per group plus the stem's clause (eight fields) rather than one for the whole trunk. Each group's .ok is still the conjunction CertLayer.comp assembled from its blocks' conditions at their own activations, so the 38 relu clauses are never written down one by one, and no 0 < ε hypothesis appears at all. R50's two apex bundles carry 35 fields.

                                                              More generally, a net whose resolutions are literals cannot afford the proof idioms a net with a resolution binder can: ResNet-50's q keeps den stuck, MNv4's 224/112/56/28/14/7 let it run. The stem graph builder's genericity, the prefix chain and the capstone's rw in place of simp only all trace to that.

                                                              @[reducible]
                                                              noncomputable def Proofs.StableHLO.mnv4Pre0 (N : ℕ) {nCls : ℕ} (w : Mnv4BWeights nCls) (x : Vec (N * (3 * 224 * 224))) :
                                                              Vec (N * (32 * 112 * 112))

                                                              Prefix 0: the stem's output.

                                                              Equations
                                                              Instances For
                                                                @[reducible]
                                                                noncomputable def Proofs.StableHLO.mnv4Pre1 (N : ℕ) {nCls : ℕ} (w : Mnv4BWeights nCls) (x : Vec (N * (3 * 224 * 224))) :
                                                                Vec (N * (48 * 56 * 56))

                                                                Prefix 1: through the fused stage, at 56×56.

                                                                Equations
                                                                Instances For
                                                                  @[reducible]
                                                                  noncomputable def Proofs.StableHLO.mnv4Pre2 (N : ℕ) {nCls : ℕ} (w : Mnv4BWeights nCls) (x : Vec (N * (3 * 224 * 224))) :
                                                                  Vec (N * (80 * 28 * 28))

                                                                  Prefix 2: through rows 1–2, at 28×28.

                                                                  Equations
                                                                  Instances For
                                                                    @[reducible]
                                                                    noncomputable def Proofs.StableHLO.mnv4Pre3 (N : ℕ) {nCls : ℕ} (w : Mnv4BWeights nCls) (x : Vec (N * (3 * 224 * 224))) :
                                                                    Vec (N * (160 * 14 * 14))

                                                                    Prefix 3: through rows 3–6, at 14×14.

                                                                    Equations
                                                                    Instances For
                                                                      @[reducible]
                                                                      noncomputable def Proofs.StableHLO.mnv4Pre4 (N : ℕ) {nCls : ℕ} (w : Mnv4BWeights nCls) (x : Vec (N * (3 * 224 * 224))) :
                                                                      Vec (N * (160 * 14 * 14))

                                                                      Prefix 4: through rows 7–10, still at 14×14.

                                                                      Equations
                                                                      Instances For
                                                                        @[reducible]
                                                                        noncomputable def Proofs.StableHLO.mnv4Pre5 (N : ℕ) {nCls : ℕ} (w : Mnv4BWeights nCls) (x : Vec (N * (3 * 224 * 224))) :
                                                                        Vec (N * (256 * 7 * 7))

                                                                        Prefix 5: through rows 11–15, at 7×7.

                                                                        Equations
                                                                        Instances For
                                                                          @[reducible]
                                                                          noncomputable def Proofs.StableHLO.mnv4Pre6 (N : ℕ) {nCls : ℕ} (w : Mnv4BWeights nCls) (x : Vec (N * (3 * 224 * 224))) :
                                                                          Vec (N * (256 * 7 * 7))

                                                                          Prefix 6: through rows 16–21 — the whole trunk below the head.

                                                                          Equations
                                                                          Instances For
                                                                            noncomputable def Proofs.StableHLO.mobilenetv4ForwardBFull (N : ℕ) {nCls : ℕ} (w : Mnv4BWeights nCls) (x : Vec (N * (3 * 224 * 224))) :
                                                                            Vec (N * nCls)

                                                                            The full batch-BN MobileNetV4-Conv-M, N*(3*224*224) → N*nCls.

                                                                            The stem, the fused stage, the five resolution groups, the head. Every block inside those groups is mnv4BodyOfRow at its own row, so the k = 0 dispatch is READ from mnv4Blocks rather than chosen here — the property MobileNetV4BackB0.lean's dispatch section exists to establish, now carried to the net. The eighteen skips are CertLayer.residual, which typechecks with no transport because s.oc and s.ic reduce to the same literal at every stride-1 row (guarded there).

                                                                            Equations
                                                                            Instances For
                                                                              def Proofs.StableHLO.mnv4StemGraphB (epsStr : String) (N h w : ℕ) {ic oc kH kW : ℕ} (Ws : Kernel4 oc ic kH kW) (bs : Vec oc) (εs : ℝ) (γs βs : Vec oc) (bf16 : Bool) (e : SHlo (N * (ic * (2 * h) * (2 * w)))) :
                                                                              SHlo (N * (oc * h * w))

                                                                              Stem graph: 3×3/s2 symmetric conv → batch BN → relu.

                                                                              Generic in the widths, and that is an elaboration requirement, not style. Pinning ic := 3, oc := 32, h := 112 here makes the conv's den_batchOp rfl a claim about concrete 150528- and 401408-element tensors, and the KERNEL tries to reduce it: the lemma takes over a minute and then fails with (kernel) deterministic timeout. Proven at binders it takes two seconds, and applying it at the net's literals is free — instantiating a proven lemma, not proving one. mnv2StemGraphB and r50StemGraphB are generic for the same reason, which is easy to read as a stylistic habit and is not.

                                                                              Equations
                                                                              • One or more equations did not get rendered due to their size.
                                                                              Instances For
                                                                                def Proofs.StableHLO.mnv4FusedGraphB (epsStr : String) (N h w : ℕ) {ic mid oc kH kW : ℕ} (Wc : Kernel4 mid ic kH kW) (bc : Vec mid) (εc : ℝ) (γc βc : Vec mid) (Wp : Kernel4 oc mid 1 1) (bp : Vec oc) (εp : ℝ) (γp βp : Vec oc) (bf16 : Bool) (e : SHlo (N * (ic * (2 * h) * (2 * w)))) :
                                                                                SHlo (N * (oc * h * w))

                                                                                Fused stage graph: 3×3/s2 symmetric conv → BN → relu → 1×1 project → BN. No skip. Generic in the widths, for the reason mnv4StemGraphB records.

                                                                                Equations
                                                                                • One or more equations did not get rendered due to their size.
                                                                                Instances For
                                                                                  def Proofs.StableHLO.mnv4ExtraDWBodyGraphB (epsStr : String) (N : ℕ) (s : UibSpec) (p : UibParams s) (bf16 : Bool) (e : SHlo (N * (s.ic * s.h * s.h))) :
                                                                                  SHlo (N * (s.oc * s.h * s.h))

                                                                                  ExtraDW body graph — both depthwises present, 13 of Conv-M's 21 rows (and all three stride-2 ones, whose own builder is below). The BODY only: the identity skip is .addVB'd on at the call site, which is what keeps the whole-net graph LINEAR instead of duplicating each skip's entire input subtree.

                                                                                  Equations
                                                                                  • One or more equations did not get rendered due to their size.
                                                                                  Instances For
                                                                                    theorem Proofs.StableHLO.mnv4ExtraDWBodyGraphB_faithful (epsStr : String) (N : ℕ) (s : UibSpec) (p : UibParams s) (bf16 : Bool) (hq : s.preDWk ≠ 0) (hd : s.postDWk ≠ 0) (e : SHlo (N * (s.ic * s.h * s.h))) :
                                                                                    den (mnv4ExtraDWBodyGraphB epsStr N s p bf16 e) = (mnv4BodyOfRow N s p).fwd (den e)

                                                                                    The ExtraDW body graph denotes the row-typed body's forward — generic in the row, so one theorem serves all thirteen. The two hypotheses are exactly the dispatch conditions mnv4PreDWSlot/mnv4PostDWSlot branch on, discharged by decide at each concrete row.

                                                                                    def Proofs.StableHLO.mnv4ConvNeXtBodyGraphB (epsStr : String) (N : ℕ) (s : UibSpec) (p : UibParams s) (bf16 : Bool) (e : SHlo (N * (s.ic * s.h * s.h))) :
                                                                                    SHlo (N * (s.oc * s.h * s.h))

                                                                                    ConvNeXt-like body graph — pre-DW only, postDWk = 0, four of Conv-M's rows (8, 10, 16, 21). The absent depthwise emits no tokens, exactly as mnv4PostDWSlot inserts id': the UibParams record still carries a degenerate DepthwiseKernel _ 0 0 in that slot and this graph simply does not read it. A token stated for an absent depthwise would be a den of a node the artifact does not have.

                                                                                    Equations
                                                                                    • One or more equations did not get rendered due to their size.
                                                                                    Instances For
                                                                                      theorem Proofs.StableHLO.mnv4ConvNeXtBodyGraphB_faithful (epsStr : String) (N : ℕ) (s : UibSpec) (p : UibParams s) (bf16 : Bool) (hq : s.preDWk ≠ 0) (hd : s.postDWk = 0) (e : SHlo (N * (s.ic * s.h * s.h))) :
                                                                                      den (mnv4ConvNeXtBodyGraphB epsStr N s p bf16 e) = (mnv4BodyOfRow N s p).fwd (den e)
                                                                                      def Proofs.StableHLO.mnv4FfnBodyGraphB (epsStr : String) (N : ℕ) (s : UibSpec) (p : UibParams s) (bf16 : Bool) (e : SHlo (N * (s.ic * s.h * s.h))) :
                                                                                      SHlo (N * (s.oc * s.h * s.h))

                                                                                      FFN body graph — neither depthwise, four of Conv-M's rows (9, 15, 19, 20): expand, project, and nothing else. Both slots are id'.

                                                                                      Equations
                                                                                      • One or more equations did not get rendered due to their size.
                                                                                      Instances For
                                                                                        theorem Proofs.StableHLO.mnv4FfnBodyGraphB_faithful (epsStr : String) (N : ℕ) (s : UibSpec) (p : UibParams s) (bf16 : Bool) (hq : s.preDWk = 0) (hd : s.postDWk = 0) (e : SHlo (N * (s.ic * s.h * s.h))) :
                                                                                        den (mnv4FfnBodyGraphB epsStr N s p bf16 e) = (mnv4BodyOfRow N s p).fwd (den e)
                                                                                        def Proofs.StableHLO.mnv4StridedGraphB (epsStr : String) (N : ℕ) (s : UibSpec) (p : UibParams s) (bf16 : Bool) (e : SHlo (N * (s.ic * (2 * s.h) * (2 * s.h)))) :
                                                                                        SHlo (N * (s.oc * s.h * s.h))

                                                                                        Strided block graph — rows 1, 3 and 11, all ExtraDW. timm strides dw_mid: the BN-only pre-DW and the expand run at the input resolution 2h, the post-DW (.depthwiseStrided, symmetric) takes it to h, the project runs at h. No skip: ic ≠ oc at all three, so the block IS the body and there is no .addVB.

                                                                                        Equations
                                                                                        • One or more equations did not get rendered due to their size.
                                                                                        Instances For
                                                                                          theorem Proofs.StableHLO.mnv4StridedGraphB_faithful (epsStr : String) (N : ℕ) (s : UibSpec) (p : UibParams s) (bf16 : Bool) (hq : s.preDWk ≠ 0) (e : SHlo (N * (s.ic * (2 * s.h) * (2 * s.h)))) :
                                                                                          den (mnv4StridedGraphB epsStr N s p bf16 e) = (mnv4StridedBodyOfRow N s p).fwd (den e)
                                                                                          def Proofs.StableHLO.mnv4SkipGraphB {N n : ℕ} (body : SHlo (N * n) → SHlo (N * n)) (e : SHlo (N * n)) :
                                                                                          SHlo (N * n)

                                                                                          One skip row's graph: its body's, plus the identity skip. Trivial as a definition; it exists as a barrier to unfolding.

                                                                                          Why it is a named combinator and not an inline .addVB. The residual add needs the block's input subtree twice, and MNv4 has eighteen of them. Written inline — or behind a let in the whole-net graph, which simp only [mnv4FwdGraphBFull] zeta-expands — the term doubles at every skip the moment anything unfolds it, and the whole-net faithfulness proof ends in a kernel deterministic timeout.

                                                                                          Kept folded, with mnv4SkipGraphB_faithful rewriting den (mnv4SkipGraphB body e) in ONE step, den e occurs once and the whole-net term stays linear in the depth. R50 never met this: its r50IdGraphB takes e as a binder and duplicates it inside the builder, which has the same effect for the same reason.

                                                                                          Equations
                                                                                          Instances For
                                                                                            theorem Proofs.StableHLO.mnv4SkipGraphB_faithful {N n : ℕ} (body : SHlo (N * n) → SHlo (N * n)) (f : Vec (N * n) → Vec (N * n)) (hb : ∀ (e' : SHlo (N * n)), den (body e') = f (den e')) (e : SHlo (N * n)) :

                                                                                            A skip row denotes residual of whatever its body denotes — generic in both, so one theorem covers all eighteen, in this graph and the eval graph (MobileNetV4FullBEval), and the body's own faithfulness lemma is the only input.

                                                                                            def Proofs.StableHLO.mnv4HeadGraphB (epsStr : String) (N h w : ℕ) {c mid oc nCls : ℕ} (W1 : Kernel4 mid c 1 1) (b1 : Vec mid) (ε1 : ℝ) (γ1 β1 : Vec mid) (W2 : Kernel4 oc mid 1 1) (b2 : Vec oc) (ε2 : ℝ) (γ2 β2 : Vec oc) (Wd : Mat oc nCls) (bd : Vec nCls) (bf16 : Bool) (e : SHlo (N * (c * h * w))) :
                                                                                            SHlo (N * nCls)

                                                                                            Head graph, timm's order: 1×1 conv-BN-relu, GAP, conv_head 1×1 conv-BN-relu on the pooled features, dense — with the two castIdx relabellings mnv4Head carries, which emit no text. Generic in the widths, for the reason mnv4StemGraphB records.

                                                                                            Equations
                                                                                            • One or more equations did not get rendered due to their size.
                                                                                            Instances For
                                                                                              theorem Proofs.StableHLO.mnv4FusedStack_graph_faithful (N : ℕ) (epsStr : String) {nCls : ℕ} (w : Mnv4BWeights nCls) (bf16 : Bool) (e : SHlo (N * (32 * 112 * 112))) :
                                                                                              den (mnv4FusedGraphB epsStr N 56 56 w.f0cW w.f0cb w.f0cE w.f0cg w.f0cbt w.f0pW w.f0pb w.f0pE w.f0pg w.f0pbt bf16 e) = (mnv4FusedStack N w).fwd (den e)

                                                                                              The fused stage's graph faithfulness, restated at mnv4FusedStack itself.

                                                                                              This corollary exists so the whole-net proof never has to unfold mnv4FusedStack. It looks redundant and is not: at MNv4's literal resolutions, letting anything unfold far enough for den to start recursing turns the kernel's check into an evaluation of the whole graph, which is the failure the group split above works around. Seven rewrites all of the shape den <subgraph> = <subLayer>.fwd (den ·) keep every stage opaque.

                                                                                              theorem Proofs.StableHLO.mnv4StemB_graph_faithful (N : ℕ) (epsStr : String) {nCls : ℕ} (w : Mnv4BWeights nCls) (bf16 : Bool) (e : SHlo (N * (3 * 224 * 224))) :
                                                                                              den (mnv4StemGraphB epsStr N 112 112 w.sW w.sb w.sE w.sg w.sbt bf16 e) = mnv4StemB N 112 112 w.sW w.sb w.sE w.sg w.sbt (den e)

                                                                                              The stem's, likewise, at the net's own widths.

                                                                                              def Proofs.StableHLO.mnv4FwdGraphBFull (N : ℕ) (epsStr : String) {nCls : ℕ} (w : Mnv4BWeights nCls) (bf16 : Bool) (e : SHlo (N * (3 * 224 * 224))) :
                                                                                              SHlo (N * nCls)

                                                                                              The full batch-BN MobileNetV4-Conv-M forward graph, at mnv4FwdChainB's own tokens and its own SSA names, so the typed graph diffs against mnv4_fwd.mlir and mnv4in_fwd.mlir name for name (the artifacts it covers are listed in the module's conventions table). Checked against the committed bytes: all 247 names this writes appear in mnv4_fwd.mlir, and between them they cover all 233 of its declared parameters. bf16 selects the conv and depthwise kinds at every site (StableHLO.PrecisionSwitch): false is the f32 artifacts' graph, true the bf16 ones'; the dense stays f32 in both.

                                                                                              The eighteen skip rows go through mnv4SkipGraphB, which is what keeps this term LINEAR in the depth — see that combinator's docstring for the failure mode it exists to prevent.

                                                                                              Equations
                                                                                              • One or more equations did not get rendered due to their size.
                                                                                              Instances For
                                                                                                theorem Proofs.StableHLO.mnv4FwdGraphBFull_faithful (N : ℕ) (epsStr : String) {nCls : ℕ} (w : Mnv4BWeights nCls) (bf16 : Bool) (e : SHlo (N * (3 * 224 * 224))) :
                                                                                                den (mnv4FwdGraphBFull N epsStr w bf16 e) = mobilenetv4ForwardBFull N w (den e)

                                                                                                The MobileNetV4-Conv-M forward graph at batch BatchNorm denotes the whole-net forward. Seven rewrites — the stem, the fused stage, the five resolution groups and the head — each of which was itself proved one block at a time.

                                                                                                Each group's proof discharges its blocks' dispatch hypotheses by decide at the concrete row, so what selects ExtraDW / ConvNeXt / FFN is the TABLE, not this file. A row wired to the wrong builder fails to elaborate rather than proving something about a different net.

                                                                                                Trunk group Res28 — rows 1–2, at 56 → 28 — as its own blocks, each at its table row (mnv4Row1, mnv4Row2).

                                                                                                Trunk group Res14a — rows 3–6, at 28 → 14 — as its own blocks, each at its table row (mnv4Row3, mnv4Row4, mnv4Row5, mnv4Row6).

                                                                                                Trunk group Res14b — rows 7–10, at 14×14 — as its own blocks, each at its table row (mnv4Row7, mnv4Row8, mnv4Row9, mnv4Row10).

                                                                                                Trunk group Res7a — rows 11–15, at 14 → 7 — as its own blocks, each at its table row (mnv4Row11, mnv4Row12, mnv4Row13, mnv4Row14, mnv4Row15).

                                                                                                Trunk group Res7b — rows 16–21, at 7×7 — as its own blocks, each at its table row (mnv4Row16, mnv4Row17, mnv4Row18, mnv4Row19, mnv4Row20, mnv4Row21).

                                                                                                noncomputable def Proofs.StableHLO.mnv4HeadFeatB (N h w : ℕ) {c mid oc : ℕ} (W1 : Kernel4 mid c 1 1) (b1 : Vec mid) (ε1 : ℝ) (γ1 β1 : Vec mid) (W2 : Kernel4 oc mid 1 1) (b2 : Vec oc) (ε2 : ℝ) (γ2 β2 : Vec oc) :
                                                                                                Vec (N * (c * h * w)) → Vec (N * oc)

                                                                                                The head up to the classifier's input: 1×1 conv-BN-relu, GAP, conv_head conv-BN-relu on the pooled features, relabelled to [N, oc]. Generic in the widths, as mnv4HeadGraphB.

                                                                                                Equations
                                                                                                • One or more equations did not get rendered due to their size.
                                                                                                Instances For
                                                                                                  noncomputable def Proofs.StableHLO.mobilenetv4ForwardBFullDo (N : ℕ) {nCls : ℕ} (w : Mnv4BWeights nCls) (m : Vec (N * 1280)) (x : Vec (N * (3 * 224 * 224))) :
                                                                                                  Vec (N * nCls)

                                                                                                  The MobileNetV4-Conv-M forward with classifier dropout at the per-element mask m (the driver's inverted mask, %do): mobilenetv4ForwardBFull with dropout m on the classifier's input.

                                                                                                  Equations
                                                                                                  • One or more equations did not get rendered due to their size.
                                                                                                  Instances For
                                                                                                    theorem Proofs.StableHLO.mobilenetv4ForwardBFullDo_ones (N : ℕ) {nCls : ℕ} (w : Mnv4BWeights nCls) (x : Vec (N * (3 * 224 * 224))) :
                                                                                                    mobilenetv4ForwardBFullDo N w (fun (x : Fin (N * 1280)) => 1) x = mobilenetv4ForwardBFull N w x

                                                                                                    At the all-ones mask the dropout forward is the certified forward.

                                                                                                    def Proofs.StableHLO.mnv4HeadGraphBDo (epsStr mName : String) (N h w : ℕ) {c mid oc nCls : ℕ} (W1 : Kernel4 mid c 1 1) (b1 : Vec mid) (ε1 : ℝ) (γ1 β1 : Vec mid) (W2 : Kernel4 oc mid 1 1) (b2 : Vec oc) (ε2 : ℝ) (γ2 β2 : Vec oc) (Wd : Mat oc nCls) (bd : Vec nCls) (bf16 : Bool) (m : Vec (N * oc)) (e : SHlo (N * (c * h * w))) :
                                                                                                    SHlo (N * nCls)

                                                                                                    Head graph with classifier dropout: mnv4HeadGraphB with a dropoutB on the dense's input, its mask the input mName (the render's is doName).

                                                                                                    Equations
                                                                                                    • One or more equations did not get rendered due to their size.
                                                                                                    Instances For
                                                                                                      def Proofs.StableHLO.mnv4FwdGraphBFullDo (N : ℕ) (epsStr mName : String) {nCls : ℕ} (w : Mnv4BWeights nCls) (bf16 : Bool) (m : Vec (N * 1280)) (e : SHlo (N * (3 * 224 * 224))) :
                                                                                                      SHlo (N * nCls)

                                                                                                      The %do forward graph: mnv4FwdGraphBFull with the dropout head.

                                                                                                      Equations
                                                                                                      • One or more equations did not get rendered due to their size.
                                                                                                      Instances For
                                                                                                        theorem Proofs.StableHLO.mnv4HeadDo_graph_faithful (N : ℕ) (epsStr mName : String) {nCls : ℕ} (w : Mnv4BWeights nCls) (bf16 : Bool) (m : Vec (N * 1280)) (e : SHlo (N * (256 * 7 * 7))) :
                                                                                                        den (mnv4HeadGraphBDo epsStr mName N 7 7 w.h1W w.h1b w.h1E w.h1g w.h1bt w.hW w.hb w.hE w.hg w.hbt w.Wd w.bd bf16 m e) = batchMap N (dense w.Wd w.bd) (dropout m (mnv4HeadFeatB N 7 7 w.h1W w.h1b w.h1E w.h1g w.h1bt w.hW w.hb w.hE w.hg w.hbt (den e)))

                                                                                                        The dropout head's faithfulness at the net's widths — the barrier mnv4HeadStack_graph_faithful is for the plain head.

                                                                                                        theorem Proofs.StableHLO.mnv4FwdGraphBFullDo_faithful (N : ℕ) (epsStr mName : String) {nCls : ℕ} (w : Mnv4BWeights nCls) (bf16 : Bool) (m : Vec (N * 1280)) (e : SHlo (N * (3 * 224 * 224))) :
                                                                                                        den (mnv4FwdGraphBFullDo N epsStr mName w bf16 m e) = mobilenetv4ForwardBFullDo N w m (den e)

                                                                                                        The %do forward graph denotes the dropout forward, at every mask — the trunk by the same group rewrites as mnv4FwdGraphBFull_faithful.