Documentation

LeanMlir.Proofs.Nets.Small.CnnFoldB

The MNIST-CNN train step at batch N — CnnFold with the batch stated #

CnnFold certifies the ten parameter outputs of cnn_train_step.mlir for ONE example. tests/TestSmallNetsBatchedEmit.lean pins that text, byte for byte, as the print of a graph at the batched index: batchOp lifts of conv/relu/maxPool/dense/expe/softmaxDiv/ dotOut, subB, selectPosB, maxPoolBackB, the convBackP descriptor (the per-example conv input-VJP spelling, at the batched index) and the convWeightSgdB/convBiasSgdB/ denseWeightSgdB/denseBiasSgdB nodes. This file reads every node's den at a batch of N:

Unlike CnnFold, the chain cotangents here ARE the emitted subgraphs' denotations (the pool-back and conv-back are maxPoolBackB/convBackP nodes, not the hand-named cnnChainCot* values), so the "cotangent SSA ↔ chain-cot per-op trust" CnnFold's Scope records is closed at the batched index: dhc2B_slice/dhc1B_slice prove the two readings agree.

Scope #

The SSA names the renderer threads between the pieces. Denotation-irrelevant; kept so every node is stated with the leaf names the emitted text uses.

Instances For

    Per-example shorthands at example k (the forward CnnFold states, at slice k) #

    @[reducible, inline]
    noncomputable abbrev Proofs.CnnFoldB.xk {ic h w : ℕ} (N : ℕ) (xB : Vec (N * (ic * (2 * h) * (2 * w)))) (k : Fin N) :
    Vec (ic * (2 * h) * (2 * w))
    Equations
    Instances For
      @[reducible, inline]
      noncomputable abbrev Proofs.CnnFoldB.hc1 {ic c h w kH kW : ℕ} (N : ℕ) (W₁ : Kernel4 c ic kH kW) (b₁ : Vec c) (xB : Vec (N * (ic * (2 * h) * (2 * w)))) (k : Fin N) :
      Vec (c * (2 * h) * (2 * w))
      Equations
      Instances For
        @[reducible, inline]
        noncomputable abbrev Proofs.CnnFoldB.ac1 {ic c h w kH kW : ℕ} (N : ℕ) (W₁ : Kernel4 c ic kH kW) (b₁ : Vec c) (xB : Vec (N * (ic * (2 * h) * (2 * w)))) (k : Fin N) :
        Vec (c * (2 * h) * (2 * w))
        Equations
        Instances For
          @[reducible, inline]
          noncomputable abbrev Proofs.CnnFoldB.hc2 {ic c h w kH kW : ℕ} (N : ℕ) (W₁ : Kernel4 c ic kH kW) (b₁ : Vec c) (W₂ : Kernel4 c c kH kW) (b₂ : Vec c) (xB : Vec (N * (ic * (2 * h) * (2 * w)))) (k : Fin N) :
          Vec (c * (2 * h) * (2 * w))
          Equations
          Instances For
            @[reducible, inline]
            noncomputable abbrev Proofs.CnnFoldB.ac2 {ic c h w kH kW : ℕ} (N : ℕ) (W₁ : Kernel4 c ic kH kW) (b₁ : Vec c) (W₂ : Kernel4 c c kH kW) (b₂ : Vec c) (xB : Vec (N * (ic * (2 * h) * (2 * w)))) (k : Fin N) :
            Vec (c * (2 * h) * (2 * w))
            Equations
            Instances For
              @[reducible, inline]
              noncomputable abbrev Proofs.CnnFoldB.pool {ic c h w kH kW : ℕ} (N : ℕ) (W₁ : Kernel4 c ic kH kW) (b₁ : Vec c) (W₂ : Kernel4 c c kH kW) (b₂ : Vec c) (xB : Vec (N * (ic * (2 * h) * (2 * w)))) (k : Fin N) :
              Vec (c * h * w)
              Equations
              Instances For
                @[reducible, inline]
                noncomputable abbrev Proofs.CnnFoldB.h3 {ic c h w d1 kH kW : ℕ} (N : ℕ) (W₁ : Kernel4 c ic kH kW) (b₁ : Vec c) (W₂ : Kernel4 c c kH kW) (b₂ : Vec c) (W₃ : Mat (c * h * w) d1) (b₃ : Vec d1) (xB : Vec (N * (ic * (2 * h) * (2 * w)))) (k : Fin N) :
                Vec d1
                Equations
                Instances For
                  @[reducible, inline]
                  noncomputable abbrev Proofs.CnnFoldB.h4 {ic c h w d1 kH kW : ℕ} (N : ℕ) (W₁ : Kernel4 c ic kH kW) (b₁ : Vec c) (W₂ : Kernel4 c c kH kW) (b₂ : Vec c) (W₃ : Mat (c * h * w) d1) (b₃ : Vec d1) (W₄ : Mat d1 d1) (b₄ : Vec d1) (xB : Vec (N * (ic * (2 * h) * (2 * w)))) (k : Fin N) :
                  Vec d1
                  Equations
                  Instances For
                    @[reducible, inline]
                    noncomputable abbrev Proofs.CnnFoldB.a4 {ic c h w d1 kH kW : ℕ} (N : ℕ) (W₁ : Kernel4 c ic kH kW) (b₁ : Vec c) (W₂ : Kernel4 c c kH kW) (b₂ : Vec c) (W₃ : Mat (c * h * w) d1) (b₃ : Vec d1) (W₄ : Mat d1 d1) (b₄ : Vec d1) (xB : Vec (N * (ic * (2 * h) * (2 * w)))) (k : Fin N) :
                    Vec d1
                    Equations
                    Instances For
                      @[reducible, inline]
                      noncomputable abbrev Proofs.CnnFoldB.gk {ic c h w d1 nClasses kH kW : ℕ} (N : ℕ) (W₁ : Kernel4 c ic kH kW) (b₁ : Vec c) (W₂ : Kernel4 c c kH kW) (b₂ : Vec c) (W₃ : Mat (c * h * w) d1) (b₃ : Vec d1) (W₄ : Mat d1 d1) (b₄ : Vec d1) (W₅ : Mat d1 nClasses) (b₅ : Vec nClasses) (xB : Vec (N * (ic * (2 * h) * (2 * w)))) (label : Fin N → Fin nClasses) (k : Fin N) :
                      Vec nClasses

                      The softmax-CE loss cotangent at example k.

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

                        The batched forward, nested #

                        def Proofs.CnnFoldB.hc1B {ic c h w kH kW : ℕ} (N : ℕ) (W₁ : Kernel4 c ic kH kW) (b₁ : Vec c) (xB : Vec (N * (ic * (2 * h) * (2 * w)))) :
                        StableHLO.SHlo (N * (c * (2 * h) * (2 * w)))
                        Equations
                        Instances For
                          def Proofs.CnnFoldB.ac1B {ic c h w kH kW : ℕ} (N : ℕ) (W₁ : Kernel4 c ic kH kW) (b₁ : Vec c) (xB : Vec (N * (ic * (2 * h) * (2 * w)))) :
                          StableHLO.SHlo (N * (c * (2 * h) * (2 * w)))
                          Equations
                          Instances For
                            def Proofs.CnnFoldB.hc2B {ic c h w kH kW : ℕ} (N : ℕ) (W₁ : Kernel4 c ic kH kW) (b₁ : Vec c) (W₂ : Kernel4 c c kH kW) (b₂ : Vec c) (xB : Vec (N * (ic * (2 * h) * (2 * w)))) :
                            StableHLO.SHlo (N * (c * (2 * h) * (2 * w)))
                            Equations
                            Instances For
                              def Proofs.CnnFoldB.ac2B {ic c h w kH kW : ℕ} (N : ℕ) (W₁ : Kernel4 c ic kH kW) (b₁ : Vec c) (W₂ : Kernel4 c c kH kW) (b₂ : Vec c) (xB : Vec (N * (ic * (2 * h) * (2 * w)))) :
                              StableHLO.SHlo (N * (c * (2 * h) * (2 * w)))
                              Equations
                              Instances For
                                def Proofs.CnnFoldB.poolB {ic c h w kH kW : ℕ} (N : ℕ) (W₁ : Kernel4 c ic kH kW) (b₁ : Vec c) (W₂ : Kernel4 c c kH kW) (b₂ : Vec c) (xB : Vec (N * (ic * (2 * h) * (2 * w)))) :
                                StableHLO.SHlo (N * (c * h * w))
                                Equations
                                Instances For
                                  def Proofs.CnnFoldB.h3B {ic c h w d1 kH kW : ℕ} (N : ℕ) (W₁ : Kernel4 c ic kH kW) (b₁ : Vec c) (W₂ : Kernel4 c c kH kW) (b₂ : Vec c) (W₃ : Mat (c * h * w) d1) (b₃ : Vec d1) (xB : Vec (N * (ic * (2 * h) * (2 * w)))) :
                                  Equations
                                  Instances For
                                    def Proofs.CnnFoldB.a3B {ic c h w d1 kH kW : ℕ} (N : ℕ) (W₁ : Kernel4 c ic kH kW) (b₁ : Vec c) (W₂ : Kernel4 c c kH kW) (b₂ : Vec c) (W₃ : Mat (c * h * w) d1) (b₃ : Vec d1) (xB : Vec (N * (ic * (2 * h) * (2 * w)))) :
                                    Equations
                                    Instances For
                                      def Proofs.CnnFoldB.h4B {ic c h w d1 kH kW : ℕ} (N : ℕ) (W₁ : Kernel4 c ic kH kW) (b₁ : Vec c) (W₂ : Kernel4 c c kH kW) (b₂ : Vec c) (W₃ : Mat (c * h * w) d1) (b₃ : Vec d1) (W₄ : Mat d1 d1) (b₄ : Vec d1) (xB : Vec (N * (ic * (2 * h) * (2 * w)))) :
                                      Equations
                                      Instances For
                                        def Proofs.CnnFoldB.a4B {ic c h w d1 kH kW : ℕ} (N : ℕ) (W₁ : Kernel4 c ic kH kW) (b₁ : Vec c) (W₂ : Kernel4 c c kH kW) (b₂ : Vec c) (W₃ : Mat (c * h * w) d1) (b₃ : Vec d1) (W₄ : Mat d1 d1) (b₄ : Vec d1) (xB : Vec (N * (ic * (2 * h) * (2 * w)))) :
                                        Equations
                                        Instances For
                                          def Proofs.CnnFoldB.logitsB {ic c h w d1 nClasses kH kW : ℕ} (N : ℕ) (W₁ : Kernel4 c ic kH kW) (b₁ : Vec c) (W₂ : Kernel4 c c kH kW) (b₂ : Vec c) (W₃ : Mat (c * h * w) d1) (b₃ : Vec d1) (W₄ : Mat d1 d1) (b₄ : Vec d1) (W₅ : Mat d1 nClasses) (b₅ : Vec nClasses) (xB : Vec (N * (ic * (2 * h) * (2 * w)))) :
                                          StableHLO.SHlo (N * nClasses)
                                          Equations
                                          • One or more equations did not get rendered due to their size.
                                          Instances For
                                            noncomputable def Proofs.CnnFoldB.cotB {ic c h w d1 nClasses kH kW : ℕ} (N : ℕ) (W₁ : Kernel4 c ic kH kW) (b₁ : Vec c) (W₂ : Kernel4 c c kH kW) (b₂ : Vec c) (W₃ : Mat (c * h * w) d1) (b₃ : Vec d1) (W₄ : Mat d1 d1) (b₄ : Vec d1) (W₅ : Mat d1 nClasses) (b₅ : Vec nClasses) (xB : Vec (N * (ic * (2 * h) * (2 * w)))) (label : Fin N → Fin nClasses) :
                                            StableHLO.SHlo (N * nClasses)
                                            Equations
                                            • One or more equations did not get rendered due to their size.
                                            Instances For
                                              theorem Proofs.CnnFoldB.hc1B_slice {ic c h w kH kW : ℕ} (N : ℕ) (W₁ : Kernel4 c ic kH kW) (b₁ : Vec c) (xB : Vec (N * (ic * (2 * h) * (2 * w)))) (k : Fin N) :
                                              StableHLO.batchSlice N (c * (2 * h) * (2 * w)) (StableHLO.den (hc1B N W₁ b₁ xB)) k = hc1 N W₁ b₁ xB k
                                              theorem Proofs.CnnFoldB.ac1B_slice {ic c h w kH kW : ℕ} (N : ℕ) (W₁ : Kernel4 c ic kH kW) (b₁ : Vec c) (xB : Vec (N * (ic * (2 * h) * (2 * w)))) (k : Fin N) :
                                              StableHLO.batchSlice N (c * (2 * h) * (2 * w)) (StableHLO.den (ac1B N W₁ b₁ xB)) k = ac1 N W₁ b₁ xB k
                                              theorem Proofs.CnnFoldB.hc2B_slice {ic c h w kH kW : ℕ} (N : ℕ) (W₁ : Kernel4 c ic kH kW) (b₁ : Vec c) (W₂ : Kernel4 c c kH kW) (b₂ : Vec c) (xB : Vec (N * (ic * (2 * h) * (2 * w)))) (k : Fin N) :
                                              StableHLO.batchSlice N (c * (2 * h) * (2 * w)) (StableHLO.den (hc2B N W₁ b₁ W₂ b₂ xB)) k = hc2 N W₁ b₁ W₂ b₂ xB k
                                              theorem Proofs.CnnFoldB.ac2B_slice {ic c h w kH kW : ℕ} (N : ℕ) (W₁ : Kernel4 c ic kH kW) (b₁ : Vec c) (W₂ : Kernel4 c c kH kW) (b₂ : Vec c) (xB : Vec (N * (ic * (2 * h) * (2 * w)))) (k : Fin N) :
                                              StableHLO.batchSlice N (c * (2 * h) * (2 * w)) (StableHLO.den (ac2B N W₁ b₁ W₂ b₂ xB)) k = ac2 N W₁ b₁ W₂ b₂ xB k
                                              theorem Proofs.CnnFoldB.poolB_slice {ic c h w kH kW : ℕ} (N : ℕ) (W₁ : Kernel4 c ic kH kW) (b₁ : Vec c) (W₂ : Kernel4 c c kH kW) (b₂ : Vec c) (xB : Vec (N * (ic * (2 * h) * (2 * w)))) (k : Fin N) :
                                              StableHLO.batchSlice N (c * h * w) (StableHLO.den (poolB N W₁ b₁ W₂ b₂ xB)) k = pool N W₁ b₁ W₂ b₂ xB k
                                              theorem Proofs.CnnFoldB.h3B_slice {ic c h w d1 kH kW : ℕ} (N : ℕ) (W₁ : Kernel4 c ic kH kW) (b₁ : Vec c) (W₂ : Kernel4 c c kH kW) (b₂ : Vec c) (W₃ : Mat (c * h * w) d1) (b₃ : Vec d1) (xB : Vec (N * (ic * (2 * h) * (2 * w)))) (k : Fin N) :
                                              StableHLO.batchSlice N d1 (StableHLO.den (h3B N W₁ b₁ W₂ b₂ W₃ b₃ xB)) k = h3 N W₁ b₁ W₂ b₂ W₃ b₃ xB k
                                              theorem Proofs.CnnFoldB.a3B_slice {ic c h w d1 kH kW : ℕ} (N : ℕ) (W₁ : Kernel4 c ic kH kW) (b₁ : Vec c) (W₂ : Kernel4 c c kH kW) (b₂ : Vec c) (W₃ : Mat (c * h * w) d1) (b₃ : Vec d1) (xB : Vec (N * (ic * (2 * h) * (2 * w)))) (k : Fin N) :
                                              StableHLO.batchSlice N d1 (StableHLO.den (a3B N W₁ b₁ W₂ b₂ W₃ b₃ xB)) k = relu d1 (h3 N W₁ b₁ W₂ b₂ W₃ b₃ xB k)
                                              theorem Proofs.CnnFoldB.h4B_slice {ic c h w d1 kH kW : ℕ} (N : ℕ) (W₁ : Kernel4 c ic kH kW) (b₁ : Vec c) (W₂ : Kernel4 c c kH kW) (b₂ : Vec c) (W₃ : Mat (c * h * w) d1) (b₃ : Vec d1) (W₄ : Mat d1 d1) (b₄ : Vec d1) (xB : Vec (N * (ic * (2 * h) * (2 * w)))) (k : Fin N) :
                                              StableHLO.batchSlice N d1 (StableHLO.den (h4B N W₁ b₁ W₂ b₂ W₃ b₃ W₄ b₄ xB)) k = h4 N W₁ b₁ W₂ b₂ W₃ b₃ W₄ b₄ xB k
                                              theorem Proofs.CnnFoldB.a4B_slice {ic c h w d1 kH kW : ℕ} (N : ℕ) (W₁ : Kernel4 c ic kH kW) (b₁ : Vec c) (W₂ : Kernel4 c c kH kW) (b₂ : Vec c) (W₃ : Mat (c * h * w) d1) (b₃ : Vec d1) (W₄ : Mat d1 d1) (b₄ : Vec d1) (xB : Vec (N * (ic * (2 * h) * (2 * w)))) (k : Fin N) :
                                              StableHLO.batchSlice N d1 (StableHLO.den (a4B N W₁ b₁ W₂ b₂ W₃ b₃ W₄ b₄ xB)) k = a4 N W₁ b₁ W₂ b₂ W₃ b₃ W₄ b₄ xB k
                                              theorem Proofs.CnnFoldB.logitsB_slice {ic c h w d1 nClasses kH kW : ℕ} (N : ℕ) (W₁ : Kernel4 c ic kH kW) (b₁ : Vec c) (W₂ : Kernel4 c c kH kW) (b₂ : Vec c) (W₃ : Mat (c * h * w) d1) (b₃ : Vec d1) (W₄ : Mat d1 d1) (b₄ : Vec d1) (W₅ : Mat d1 nClasses) (b₅ : Vec nClasses) (xB : Vec (N * (ic * (2 * h) * (2 * w)))) (k : Fin N) :
                                              StableHLO.batchSlice N nClasses (StableHLO.den (logitsB N W₁ b₁ W₂ b₂ W₃ b₃ W₄ b₄ W₅ b₅ xB)) k = mnistLinear W₅ b₅ (a4 N W₁ b₁ W₂ b₂ W₃ b₃ W₄ b₄ xB k)
                                              theorem Proofs.CnnFoldB.cotB_slice {ic c h w d1 nClasses kH kW : ℕ} (N : ℕ) (W₁ : Kernel4 c ic kH kW) (b₁ : Vec c) (W₂ : Kernel4 c c kH kW) (b₂ : Vec c) (W₃ : Mat (c * h * w) d1) (b₃ : Vec d1) (W₄ : Mat d1 d1) (b₄ : Vec d1) (W₅ : Mat d1 nClasses) (b₅ : Vec nClasses) (xB : Vec (N * (ic * (2 * h) * (2 * w)))) (label : Fin N → Fin nClasses) (k : Fin N) (j : Fin nClasses) :
                                              StableHLO.den (cotB N W₁ b₁ W₂ b₂ W₃ b₃ W₄ b₄ W₅ b₅ xB label) (finProdFinEquiv (k, j)) = gk N W₁ b₁ W₂ b₂ W₃ b₃ W₄ b₄ W₅ b₅ xB label k j
                                              theorem Proofs.CnnFoldB.batchSlice_cotB {ic c h w d1 nClasses kH kW : ℕ} (N : ℕ) (W₁ : Kernel4 c ic kH kW) (b₁ : Vec c) (W₂ : Kernel4 c c kH kW) (b₂ : Vec c) (W₃ : Mat (c * h * w) d1) (b₃ : Vec d1) (W₄ : Mat d1 d1) (b₄ : Vec d1) (W₅ : Mat d1 nClasses) (b₅ : Vec nClasses) (xB : Vec (N * (ic * (2 * h) * (2 * w)))) (label : Fin N → Fin nClasses) (k : Fin N) :
                                              StableHLO.batchSlice N nClasses (StableHLO.den (cotB N W₁ b₁ W₂ b₂ W₃ b₃ W₄ b₄ W₅ b₅ xB label)) k = gk N W₁ b₁ W₂ b₂ W₃ b₃ W₄ b₄ W₅ b₅ xB label k

                                              The batched backward chain — each piece a node over an operand leaf carrying the previous #

                                              piece's den, as the renderer threads them

                                              noncomputable def Proofs.CnnFoldB.dy4B {ic c h w d1 nClasses kH kW : ℕ} (N : ℕ) (W₁ : Kernel4 c ic kH kW) (b₁ : Vec c) (W₂ : Kernel4 c c kH kW) (b₂ : Vec c) (W₃ : Mat (c * h * w) d1) (b₃ : Vec d1) (W₄ : Mat d1 d1) (b₄ : Vec d1) (W₅ : Mat d1 nClasses) (b₅ : Vec nClasses) (xB : Vec (N * (ic * (2 * h) * (2 * w)))) (label : Fin N → Fin nClasses) (nm : Names) :

                                              relu'(h4) ⊙ (W₅ · dy).

                                              Equations
                                              • One or more equations did not get rendered due to their size.
                                              Instances For
                                                noncomputable def Proofs.CnnFoldB.dy3B {ic c h w d1 nClasses kH kW : ℕ} (N : ℕ) (W₁ : Kernel4 c ic kH kW) (b₁ : Vec c) (W₂ : Kernel4 c c kH kW) (b₂ : Vec c) (W₃ : Mat (c * h * w) d1) (b₃ : Vec d1) (W₄ : Mat d1 d1) (b₄ : Vec d1) (W₅ : Mat d1 nClasses) (b₅ : Vec nClasses) (xB : Vec (N * (ic * (2 * h) * (2 * w)))) (label : Fin N → Fin nClasses) (nm : Names) :

                                                relu'(h3) ⊙ (W₄ · dy4).

                                                Equations
                                                • One or more equations did not get rendered due to their size.
                                                Instances For
                                                  noncomputable def Proofs.CnnFoldB.dx3B {ic c h w d1 nClasses kH kW : ℕ} (N : ℕ) (W₁ : Kernel4 c ic kH kW) (b₁ : Vec c) (W₂ : Kernel4 c c kH kW) (b₂ : Vec c) (W₃ : Mat (c * h * w) d1) (b₃ : Vec d1) (W₄ : Mat d1 d1) (b₄ : Vec d1) (W₅ : Mat d1 nClasses) (b₅ : Vec nClasses) (xB : Vec (N * (ic * (2 * h) * (2 * w)))) (label : Fin N → Fin nClasses) (nm : Names) :
                                                  StableHLO.SHlo (N * (c * h * w))

                                                  W₃ · dy3, the cotangent at the pool output.

                                                  Equations
                                                  • One or more equations did not get rendered due to their size.
                                                  Instances For
                                                    noncomputable def Proofs.CnnFoldB.dac2B {ic c h w d1 nClasses kH kW : ℕ} (N : ℕ) (W₁ : Kernel4 c ic kH kW) (b₁ : Vec c) (W₂ : Kernel4 c c kH kW) (b₂ : Vec c) (W₃ : Mat (c * h * w) d1) (b₃ : Vec d1) (W₄ : Mat d1 d1) (b₄ : Vec d1) (W₅ : Mat d1 nClasses) (b₅ : Vec nClasses) (xB : Vec (N * (ic * (2 * h) * (2 * w)))) (label : Fin N → Fin nClasses) (nm : Names) :
                                                    StableHLO.SHlo (N * (c * (2 * h) * (2 * w)))

                                                    The select-and-scatter pool backward at the saved pool input.

                                                    Equations
                                                    • One or more equations did not get rendered due to their size.
                                                    Instances For
                                                      noncomputable def Proofs.CnnFoldB.dhc2B {ic c h w d1 nClasses kH kW : ℕ} (N : ℕ) (W₁ : Kernel4 c ic kH kW) (b₁ : Vec c) (W₂ : Kernel4 c c kH kW) (b₂ : Vec c) (W₃ : Mat (c * h * w) d1) (b₃ : Vec d1) (W₄ : Mat d1 d1) (b₄ : Vec d1) (W₅ : Mat d1 nClasses) (b₅ : Vec nClasses) (xB : Vec (N * (ic * (2 * h) * (2 * w)))) (label : Fin N → Fin nClasses) (nm : Names) :
                                                      StableHLO.SHlo (N * (c * (2 * h) * (2 * w)))

                                                      relu'(hc2) ⊙ dac2, the cotangent at conv₂'s output.

                                                      Equations
                                                      • One or more equations did not get rendered due to their size.
                                                      Instances For
                                                        noncomputable def Proofs.CnnFoldB.dac1B {ic c h w d1 nClasses kH kW : ℕ} (N : ℕ) (W₁ : Kernel4 c ic kH kW) (b₁ : Vec c) (W₂ : Kernel4 c c kH kW) (b₂ : Vec c) (W₃ : Mat (c * h * w) d1) (b₃ : Vec d1) (W₄ : Mat d1 d1) (b₄ : Vec d1) (W₅ : Mat d1 nClasses) (b₅ : Vec nClasses) (xB : Vec (N * (ic * (2 * h) * (2 * w)))) (label : Fin N → Fin nClasses) (nm : Names) :
                                                        StableHLO.SHlo (N * (c * (2 * h) * (2 * w)))

                                                        The conv₂ input-VJP (the convBackP descriptor: .convBack's text at the batched index).

                                                        Equations
                                                        • One or more equations did not get rendered due to their size.
                                                        Instances For
                                                          noncomputable def Proofs.CnnFoldB.dhc1B {ic c h w d1 nClasses kH kW : ℕ} (N : ℕ) (W₁ : Kernel4 c ic kH kW) (b₁ : Vec c) (W₂ : Kernel4 c c kH kW) (b₂ : Vec c) (W₃ : Mat (c * h * w) d1) (b₃ : Vec d1) (W₄ : Mat d1 d1) (b₄ : Vec d1) (W₅ : Mat d1 nClasses) (b₅ : Vec nClasses) (xB : Vec (N * (ic * (2 * h) * (2 * w)))) (label : Fin N → Fin nClasses) (nm : Names) :
                                                          StableHLO.SHlo (N * (c * (2 * h) * (2 * w)))

                                                          relu'(hc1) ⊙ dac1, the cotangent at conv₁'s output.

                                                          Equations
                                                          • One or more equations did not get rendered due to their size.
                                                          Instances For
                                                            theorem Proofs.CnnFoldB.dy4B_slice {ic c h w d1 nClasses kH kW : ℕ} (N : ℕ) (W₁ : Kernel4 c ic kH kW) (b₁ : Vec c) (W₂ : Kernel4 c c kH kW) (b₂ : Vec c) (W₃ : Mat (c * h * w) d1) (b₃ : Vec d1) (W₄ : Mat d1 d1) (b₄ : Vec d1) (W₅ : Mat d1 nClasses) (b₅ : Vec nClasses) (xB : Vec (N * (ic * (2 * h) * (2 * w)))) (label : Fin N → Fin nClasses) (nm : Names) (k : Fin N) :
                                                            StableHLO.batchSlice N d1 (StableHLO.den (dy4B N W₁ b₁ W₂ b₂ W₃ b₃ W₄ b₄ W₅ b₅ xB label nm)) k = (IR.mlpCotOut1 W₅ (h4 N W₁ b₁ W₂ b₂ W₃ b₃ W₄ b₄ xB k)).denote (gk N W₁ b₁ W₂ b₂ W₃ b₃ W₄ b₄ W₅ b₅ xB label k)
                                                            theorem Proofs.CnnFoldB.dy3B_slice {ic c h w d1 nClasses kH kW : ℕ} (N : ℕ) (W₁ : Kernel4 c ic kH kW) (b₁ : Vec c) (W₂ : Kernel4 c c kH kW) (b₂ : Vec c) (W₃ : Mat (c * h * w) d1) (b₃ : Vec d1) (W₄ : Mat d1 d1) (b₄ : Vec d1) (W₅ : Mat d1 nClasses) (b₅ : Vec nClasses) (xB : Vec (N * (ic * (2 * h) * (2 * w)))) (label : Fin N → Fin nClasses) (nm : Names) (k : Fin N) :
                                                            StableHLO.batchSlice N d1 (StableHLO.den (dy3B N W₁ b₁ W₂ b₂ W₃ b₃ W₄ b₄ W₅ b₅ xB label nm)) k = (IR.mlpCotOut0 W₄ W₅ (h3 N W₁ b₁ W₂ b₂ W₃ b₃ xB k) (h4 N W₁ b₁ W₂ b₂ W₃ b₃ W₄ b₄ xB k)).denote (gk N W₁ b₁ W₂ b₂ W₃ b₃ W₄ b₄ W₅ b₅ xB label k)
                                                            theorem Proofs.CnnFoldB.cnnDenseHeadCot_denote {c h w d1 nClasses : ℕ} (W₃ : Mat (c * h * w) d1) (W₄ : Mat d1 d1) (W₅ : Mat d1 nClasses) (h3v h4v : Vec d1) (g : Vec nClasses) :
                                                            (cnnDenseHeadCot W₃ W₄ W₅ h3v h4v).denote g = W₃.mulVec ((IR.mlpCotOut0 W₄ W₅ h3v h4v).denote g)

                                                            The dense head's input cotangent (cnnDenseHeadCot) is W₃ · mlpCotOut0.

                                                            theorem Proofs.CnnFoldB.dx3B_slice {ic c h w d1 nClasses kH kW : ℕ} (N : ℕ) (W₁ : Kernel4 c ic kH kW) (b₁ : Vec c) (W₂ : Kernel4 c c kH kW) (b₂ : Vec c) (W₃ : Mat (c * h * w) d1) (b₃ : Vec d1) (W₄ : Mat d1 d1) (b₄ : Vec d1) (W₅ : Mat d1 nClasses) (b₅ : Vec nClasses) (xB : Vec (N * (ic * (2 * h) * (2 * w)))) (label : Fin N → Fin nClasses) (nm : Names) (k : Fin N) :
                                                            StableHLO.batchSlice N (c * h * w) (StableHLO.den (dx3B N W₁ b₁ W₂ b₂ W₃ b₃ W₄ b₄ W₅ b₅ xB label nm)) k = (cnnDenseHeadCot W₃ W₄ W₅ (h3 N W₁ b₁ W₂ b₂ W₃ b₃ xB k) (h4 N W₁ b₁ W₂ b₂ W₃ b₃ W₄ b₄ xB k)).denote (gk N W₁ b₁ W₂ b₂ W₃ b₃ W₄ b₄ W₅ b₅ xB label k)
                                                            theorem Proofs.CnnFoldB.maxPoolBackFlat_eq_flatten {c h w : ℕ} (xv : Vec (c * (2 * h) * (2 * w))) (dyv : Vec (c * h * w)) :

                                                            maxPoolBackFlat is the flattened maxPoolBackDenote: the same first-maximum routing.

                                                            theorem Proofs.CnnFoldB.dhc2B_slice {ic c h w d1 nClasses kH kW : ℕ} (N : ℕ) (W₁ : Kernel4 c ic kH kW) (b₁ : Vec c) (W₂ : Kernel4 c c kH kW) (b₂ : Vec c) (W₃ : Mat (c * h * w) d1) (b₃ : Vec d1) (W₄ : Mat d1 d1) (b₄ : Vec d1) (W₅ : Mat d1 nClasses) (b₅ : Vec nClasses) (xB : Vec (N * (ic * (2 * h) * (2 * w)))) (label : Fin N → Fin nClasses) (nm : Names) (k : Fin N) :
                                                            StableHLO.batchSlice N (c * (2 * h) * (2 * w)) (StableHLO.den (dhc2B N W₁ b₁ W₂ b₂ W₃ b₃ W₄ b₄ W₅ b₅ xB label nm)) k = cnnChainCotW2 W₃ W₄ W₅ (h3 N W₁ b₁ W₂ b₂ W₃ b₃ xB k) (h4 N W₁ b₁ W₂ b₂ W₃ b₃ W₄ b₄ xB k) (Tensor3.unflatten (ac2 N W₁ b₁ W₂ b₂ xB k)) (hc2 N W₁ b₁ W₂ b₂ xB k) (gk N W₁ b₁ W₂ b₂ W₃ b₃ W₄ b₄ W₅ b₅ xB label k)

                                                            The conv₂-output cotangent, batched, IS cnnChainCotW2 at each example. The emitted selectPosB over maxPoolBackB over the head chain denotes, at slice k, exactly the hand-named chain cotangent CnnFold is stated at.

                                                            theorem Proofs.CnnFoldB.dhc1B_slice {ic c h w d1 nClasses kH kW : ℕ} (N : ℕ) (W₁ : Kernel4 c ic kH kW) (b₁ : Vec c) (W₂ : Kernel4 c c kH kW) (b₂ : Vec c) (W₃ : Mat (c * h * w) d1) (b₃ : Vec d1) (W₄ : Mat d1 d1) (b₄ : Vec d1) (W₅ : Mat d1 nClasses) (b₅ : Vec nClasses) (xB : Vec (N * (ic * (2 * h) * (2 * w)))) (label : Fin N → Fin nClasses) (nm : Names) (hkH : 2 * ((kH - 1) / 2) + 1 = kH) (hkW : 2 * ((kW - 1) / 2) + 1 = kW) (k : Fin N) :
                                                            StableHLO.batchSlice N (c * (2 * h) * (2 * w)) (StableHLO.den (dhc1B N W₁ b₁ W₂ b₂ W₃ b₃ W₄ b₄ W₅ b₅ xB label nm)) k = cnnChainCotW1 W₂ (hc1 N W₁ b₁ xB k) (StableHLO.batchSlice N (c * (2 * h) * (2 * w)) (StableHLO.den (dhc2B N W₁ b₁ W₂ b₂ W₃ b₃ W₄ b₄ W₅ b₅ xB label nm)) k)

                                                            The conv₁-output cotangent, batched, IS cnnChainCotW1 at each example — for odd kernels. convBackP denotes the certified conv input-VJP; cnnChainCotW1 is written with the reversed-kernel convBackDenote, and the two agree exactly when the kernel is odd (IR.conv_back_bridge).

                                                            The ten parameter nodes at batch N #

                                                            def Proofs.CnnFoldB.DenseWSgdTiedB (N : ℕ) {a cc : ℕ} (xN wN lrStr cotN : String) (x : Vec (N * a)) (W : Mat a cc) (b : Vec cc) (cot : Vec (N * cc)) (lr : ℝ) :

                                                            A batched dense weight SGD node, tied: θ − lr·Σₙ (certified ∂dense/∂W at slice n · cotₙ).

                                                            Equations
                                                            • One or more equations did not get rendered due to their size.
                                                            Instances For
                                                              def Proofs.CnnFoldB.DenseBSgdTiedB (N : ℕ) {a cc : ℕ} (bN lrStr cotN : String) (W : Mat a cc) (x : Vec (N * a)) (b : Vec cc) (cot : Vec (N * cc)) (lr : ℝ) :

                                                              A batched dense bias SGD node, tied.

                                                              Equations
                                                              • One or more equations did not get rendered due to their size.
                                                              Instances For
                                                                def Proofs.CnnFoldB.ConvWSgdTiedB {kH kW : ℕ} (N : ℕ) {ic' oc h' w' : ℕ} (xN wN lrStr cotN : String) (b : Vec oc) (x : Vec (N * (ic' * h' * w'))) (W : Kernel4 oc ic' kH kW) (cot : Vec (N * (oc * h' * w'))) (lr : ℝ) :

                                                                A batched conv weight SGD node, tied: θ − lr·Σₙ (certified ∂conv/∂W at slice n · cotₙ).

                                                                Equations
                                                                • One or more equations did not get rendered due to their size.
                                                                Instances For
                                                                  def Proofs.CnnFoldB.ConvBSgdTiedB {kH kW : ℕ} (N : ℕ) {ic' oc h' w' : ℕ} (bN lrStr cotN : String) (W : Kernel4 oc ic' kH kW) (x : Vec (N * (ic' * h' * w'))) (b : Vec oc) (cot : Vec (N * (oc * h' * w'))) (lr : ℝ) :

                                                                  A batched conv bias SGD node, tied.

                                                                  Equations
                                                                  • One or more equations did not get rendered due to their size.
                                                                  Instances For
                                                                    theorem Proofs.CnnFoldB.denseWSgdTiedB_holds (N : ℕ) {a cc : ℕ} {xN wN lrStr cotN : String} {x : Vec (N * a)} {W : Mat a cc} {b : Vec cc} {cot : Vec (N * cc)} {lr : ℝ} :
                                                                    DenseWSgdTiedB N xN wN lrStr cotN x W b cot lr
                                                                    theorem Proofs.CnnFoldB.denseBSgdTiedB_holds (N : ℕ) {a cc : ℕ} {bN lrStr cotN : String} {W : Mat a cc} {x : Vec (N * a)} {b : Vec cc} {cot : Vec (N * cc)} {lr : ℝ} :
                                                                    DenseBSgdTiedB N bN lrStr cotN W x b cot lr
                                                                    theorem Proofs.CnnFoldB.convWSgdTiedB_holds {kH kW : ℕ} (N : ℕ) {ic' oc h' w' : ℕ} {xN wN lrStr cotN : String} {b : Vec oc} {x : Vec (N * (ic' * h' * w'))} {W : Kernel4 oc ic' kH kW} {cot : Vec (N * (oc * h' * w'))} {lr : ℝ} :
                                                                    ConvWSgdTiedB N xN wN lrStr cotN b x W cot lr
                                                                    theorem Proofs.CnnFoldB.convBSgdTiedB_holds {kH kW : ℕ} (N : ℕ) {ic' oc h' w' : ℕ} {bN lrStr cotN : String} {W : Kernel4 oc ic' kH kW} {x : Vec (N * (ic' * h' * w'))} {b : Vec oc} {cot : Vec (N * (oc * h' * w'))} {lr : ℝ} :
                                                                    ConvBSgdTiedB N bN lrStr cotN W x b cot lr
                                                                    theorem Proofs.CnnFoldB.w5B_tied {ic c h w d1 nClasses kH kW : ℕ} (N : ℕ) (W₁ : Kernel4 c ic kH kW) (b₁ : Vec c) (W₂ : Kernel4 c c kH kW) (b₂ : Vec c) (W₃ : Mat (c * h * w) d1) (b₃ : Vec d1) (W₄ : Mat d1 d1) (b₄ : Vec d1) (W₅ : Mat d1 nClasses) (b₅ : Vec nClasses) (xB : Vec (N * (ic * (2 * h) * (2 * w)))) (label : Fin N → Fin nClasses) (nm : Names) (aN : String) (lr : ℝ) (i : Fin d1) (j : Fin nClasses) :
                                                                    StableHLO.den (StableHLO.SHlo.denseWeightSgdB aN "%W5" nm.lrStr (StableHLO.den (a4B N W₁ b₁ W₂ b₂ W₃ b₃ W₄ b₄ xB)) W₅ lr (StableHLO.SHlo.operand nm.dyN (StableHLO.den (cotB N W₁ b₁ W₂ b₂ W₃ b₃ W₄ b₄ W₅ b₅ xB label)))) (finProdFinEquiv (i, j)) = W₅ i j - lr * ∑ k : Fin N, pdiv (fun (v : Vec (d1 * nClasses)) (x : Fin 1) => crossEntropy nClasses (dense (Mat.unflatten v) b₅ (a4 N W₁ b₁ W₂ b₂ W₃ b₃ W₄ b₄ xB k)) (label k)) W₅.flatten (finProdFinEquiv (i, j)) 0

                                                                    Output weight at the whole loss, summed over the batch.

                                                                    theorem Proofs.CnnFoldB.cnn_train_step_tiedB {ic c h w d1 nClasses kH kW : ℕ} (N : ℕ) (W₁ : Kernel4 c ic kH kW) (b₁ : Vec c) (W₂ : Kernel4 c c kH kW) (b₂ : Vec c) (W₃ : Mat (c * h * w) d1) (b₃ : Vec d1) (W₄ : Mat d1 d1) (b₄ : Vec d1) (W₅ : Mat d1 nClasses) (b₅ : Vec nClasses) (xB : Vec (N * (ic * (2 * h) * (2 * w)))) (label : Fin N → Fin nClasses) (nm : Names) (a4N a3N poolN ac1N : String) (lr : ℝ) :
                                                                    have a4v := StableHLO.den (a4B N W₁ b₁ W₂ b₂ W₃ b₃ W₄ b₄ xB); have a3v := StableHLO.den (a3B N W₁ b₁ W₂ b₂ W₃ b₃ xB); have poolv := StableHLO.den (poolB N W₁ b₁ W₂ b₂ xB); have ac1v := StableHLO.den (ac1B N W₁ b₁ xB); have g := StableHLO.den (cotB N W₁ b₁ W₂ b₂ W₃ b₃ W₄ b₄ W₅ b₅ xB label); have dy4 := StableHLO.den (dy4B N W₁ b₁ W₂ b₂ W₃ b₃ W₄ b₄ W₅ b₅ xB label nm); have dy3 := StableHLO.den (dy3B N W₁ b₁ W₂ b₂ W₃ b₃ W₄ b₄ W₅ b₅ xB label nm); have dhc2 := StableHLO.den (dhc2B N W₁ b₁ W₂ b₂ W₃ b₃ W₄ b₄ W₅ b₅ xB label nm); have dhc1 := StableHLO.den (dhc1B N W₁ b₁ W₂ b₂ W₃ b₃ W₄ b₄ W₅ b₅ xB label nm); DenseWSgdTiedB N a4N "%W5" nm.lrStr nm.dyN a4v W₅ b₅ g lr ∧ DenseBSgdTiedB N "%b5" nm.lrStr nm.dyN W₅ a4v b₅ g lr ∧ DenseWSgdTiedB N a3N "%W4" nm.lrStr nm.dy4N a3v W₄ b₄ dy4 lr ∧ DenseBSgdTiedB N "%b4" nm.lrStr nm.dy4N W₄ a3v b₄ dy4 lr ∧ DenseWSgdTiedB N poolN "%W3" nm.lrStr nm.dy3N poolv W₃ b₃ dy3 lr ∧ DenseBSgdTiedB N "%b3" nm.lrStr nm.dy3N W₃ poolv b₃ dy3 lr ∧ ConvWSgdTiedB N ac1N "%W2" nm.lrStr nm.dhc2N b₂ ac1v W₂ dhc2 lr ∧ ConvBSgdTiedB N "%b2" nm.lrStr nm.dhc2N W₂ ac1v b₂ dhc2 lr ∧ ConvWSgdTiedB N "%x" "%W1" nm.lrStr nm.dhc1N b₁ xB W₁ dhc1 lr ∧ ConvBSgdTiedB N "%b1" nm.lrStr nm.dhc1N W₁ xB b₁ dhc1 lr

                                                                    Whole CNN train step at batch N, tied. All ten parameter nodes, each at the real batched forward activation and the slice-pinned chain cotangent: the dense head against g/mlpCotOut1/mlpCotOut0 per example (dy4B_slice, dy3B_slice), conv₂ against the emitted pool-back chain (dhc2B_slice = cnnChainCotW2), conv₁ against the emitted conv-back chain (dhc1B_slice = cnnChainCotW1 for odd kernels). The output weight folds to the whole loss in w5B_tied.