TorchLean API

NN.MLTheory.CROWN.Graph.Engine.CROWN

Forward CROWN Bounds #

This module computes lower and upper affine bounds for each graph node. The pass is DeepPoly/CROWN-style: linear nodes compose exactly, nonlinear nodes attach local relaxations, and unsupported cases fall back to constant affine bounds derived from the already-computed IBP box.

For a chosen flattened input node ctx.inputId, the pass computes a pair of affine forms loAff(x) ≤ node(x) ≤ hiAff(x) for each supported node. The transfer rules below use the usual CROWN/DeepPoly ingredients:

Unsupported axes or shape mismatches fall back to constant affine bounds derived from the IBP box.

Exact lower and upper affine bounds for the identity node.

Instances For

    Constant affine bounds with zero coefficient matrix and explicit lower/upper offsets.

    Instances For

      Positive part of a matrix, used for sign-splitting affine bounds through linear layers.

      Instances For

        Negative part of a matrix, used with matPos to propagate lower and upper affine forms.

        Instances For
          def NN.MLTheory.CROWN.Graph.materializeAffineVec {α : Type} {inDim outDim : } (a : AffineVec α inDim outDim) :
          AffineVec α inDim outDim

          Materialize an affine vector so later graph passes do not accumulate deep tensor closures.

          Instances For

            Propagate affine lower/upper bounds through an affine layer W*x + b.

            Instances For
              def NN.MLTheory.CROWN.Graph.affApplyDiag {α : Type} [Context α] {inDim outDim : } (slopes bias : Spec.Tensor α (Spec.Shape.dim outDim Spec.Shape.scalar)) (aff : AffineVec α inDim outDim) :
              AffineVec α inDim outDim

              Compose an affine form with a diagonal affine relaxation slope * x + bias.

              Instances For
                def NN.MLTheory.CROWN.Graph.affApplyDiagSignedUpper {α : Type} [Context α] {inDim outDim : } (slopes bias : Spec.Tensor α (Spec.Shape.dim outDim Spec.Shape.scalar)) (xLo xHi : AffineVec α inDim outDim) :
                AffineVec α inDim outDim

                Apply a diagonal relaxation for an upper bound, selecting parent rows by slope sign.

                Instances For
                  def NN.MLTheory.CROWN.Graph.affApplyDiagSignedLower {α : Type} [Context α] {inDim outDim : } (slopes bias : Spec.Tensor α (Spec.Shape.dim outDim Spec.Shape.scalar)) (xLo xHi : AffineVec α inDim outDim) :
                  AffineVec α inDim outDim

                  Apply a diagonal relaxation for a lower bound, selecting parent rows by slope sign.

                  Instances For
                    def NN.MLTheory.CROWN.Graph.sigmoidLineBounds {α : Type} [Context α] (l u : α) :
                    α × α × α × α

                    One-dimensional sigmoid linear bounds on an interval [l,u].

                    Returns (a_lo, b_lo, a_hi, b_hi) for lower and upper affine lines.

                    Instances For

                      Propagate CROWN bounds through ReLU using standard per-neuron triangle relaxations.

                      Instances For

                        Propagate ReLU bounds with externally supplied α slopes for crossing neurons.

                        Instances For

                          Propagate CROWN bounds through exp using tangent/secant relaxations.

                          Instances For

                            Propagate CROWN bounds through log on the positive-domain convention used by the verifier.

                            Instances For

                              Propagate CROWN bounds through sigmoid with convex/concave one-dimensional relaxations.

                              Instances For

                                Propagate CROWN bounds through tanh with convex/concave one-dimensional relaxations.

                                Instances For
                                  def NN.MLTheory.CROWN.Graph.permuteAffineOut {α : Type} {inDim outDim : } (perm : Fin outDimFin outDim) (aff : AffineVec α inDim outDim) :
                                  AffineVec α inDim outDim

                                  Permute the output coordinates of an affine bound when the output shape permutation is valid.

                                  Instances For

                                    Conservative CROWN-style affine bounds for softmax along the last tensor axis.

                                    Instances For

                                      Conservative affine bounds for layer normalization over the last tensor axis.

                                      Instances For
                                        def NN.MLTheory.CROWN.Graph.propagateMulElemBounds {α : Type} [Context α] (Bx By : FlatBox α) (xB yB : FlatAffineBounds α) (houtX : xB.outDim = Bx.dim) (houtY : yB.outDim = By.dim) :

                                        Propagate affine bounds through componentwise multiplication using per-coordinate product planes.

                                        Instances For
                                          def NN.MLTheory.CROWN.Graph.propagateCROWNNode {α : Type} [Context α] (nodes : Array Node) (ps : ParamStore α) (ibp : Array (Option (FlatBox α))) (bounds : Array (Option (FlatAffineBounds α))) (ctx : AffineCtx) (id : ) :

                                          Propagate a single node’s affine bounds (lower/upper) given parent bounds.

                                          This is the CROWN/DeepPoly-style transfer step used by runCROWN. For node kinds without a dedicated rule, we fall back to the IBP enclosure (turned into a constant affine bound).

                                          Instances For

                                            Run the basic CROWN affine-bounds pass; requires prior IBP for per-node intervals.

                                            Instances For
                                              def NN.MLTheory.CROWN.Graph.evalCROWNOutputBox? {α : Type} [Context α] [BoundOps α] (bounds : Array (Option (FlatAffineBounds α))) (xB : FlatBox α) (outputId inputDim : ) :

                                              Evaluate already-computed CROWN output affine bounds on an input box.

                                              Instances For
                                                def NN.MLTheory.CROWN.Graph.outputBoxCROWN? {α : Type} [Context α] [BoundOps α] (g : Graph) (ps : ParamStore α) (xB : FlatBox α) (inputId outputId inputDim : ) :

                                                Run IBP, run forward CROWN, and evaluate the output affine bounds on the selected input box.

                                                This is the common "forward CROWN output box" workflow. It keeps callers from open-coding the same output-array lookup and input-dimension proof checks around runCROWN.

                                                Instances For
                                                  def NN.MLTheory.CROWN.Graph.ParamStore.outputBoxCROWN? {α : Type} [Context α] [BoundOps α] (ps : ParamStore α) (g : Graph) (xB : FlatBox α) (inputId outputId inputDim : ) :

                                                  Run outputBoxCROWN? from an input-seeded parameter store.

                                                  This method form reads naturally at call sites that already thread a ParamStore.

                                                  Instances For