TorchLean API

NN.Verification.VNNComp.MnistFC

VNN-COMP MNIST-FC Checker #

VNN-COMP-style mini-suite checker for the MNIST-FC benchmark.

The command consumes exported ONNX/VNNLIB JSON artifacts, runs TorchLean IBP or CROWN bounds on the imported MLP, and checks the VNNLIB disjunction-of-conjunctions constraints using a sufficient condition on the output box.

The checker expects exported JSON artifacts. Keep large VNN-COMP snapshots outside git, for example under _external/vnncomp/mnist_fc/, and pass explicit paths when needed.

Run (Lean): lake exe verify -- vnncomp-mnistfc

Bound propagation/checking mode for the MNIST-FC mini-suite.

  • ibp : Mode

    IBP only: fast but loose.

  • crown : Mode

    Forward CROWN output box.

  • crownObj : Mode

    Backward CROWN objective pass for each VNNLIB row.

  • crownObjAlpha : Mode

    Backward CROWN objective pass with imported ReLU slopes.

Instances For

    CLI spelling for a VNN-COMP checker mode.

    Instances For

      Parse the --mode value accepted by the MNIST-FC checker.

      Instances For

        Default ignored-local MNIST-FC weights export.

        Instances For

          Default ignored-local MNIST-FC suite export.

          Instances For

            Command-line options for the MNIST-FC VNN-COMP mini-suite verifier.

            The defaults point at ignored local artifact paths under _external/vnncomp/mnist_fc/.

            • weights : String

              Path to exported weights (model_weights.json).

            • suite : String

              Path to exported instance suite (suite.json).

            • max :

              Maximum number of instances to check (useful for local checks).

            • mode : Mode

              Bound propagation mode:

              • ibp: IBP only (fast, loose)
              • crown: forward CROWN (still produces just an output box)
              • crownobj: backward objective pass for each spec row
              • crownobj-alpha: objective pass with precomputed ReLU slopes (--alphas)
            • alphas : String

              Path to exported alpha slopes JSON (required for mode = crownobj-alpha).

            Instances For

              Usage text printed by this tool (returned as an error message on --help).

              Instances For

                Fail early with a helpful message when an external artifact is missing.

                Instances For

                  Weights for one exported fully-connected layer (y = Wx + b).

                  This is the lightest data structure we need to rebuild a CROWN Graph for MNIST-FC.

                  Instances For

                    State-dict keys for the i-th linear layer exported by the Python script.

                    Instances For

                      Deduplicate a sorted list of natural numbers (used to normalize layer indices discovered from JSON keys).

                      Instances For

                        Load an exported MNIST-FC model from JSON weights.

                        This expects keys like layers.0.weight, layers.0.bias, etc, and checks that the linear layer dimensions form a consistent chain.

                        Instances For

                          One set of precomputed ReLU alpha slopes for crownobj-alpha mode.

                          This checker assumes the MNIST-FC graph has ReLU nodes at fixed ids (2 and 4), so we store the alpha vectors in a format that can be mapped back to those nodes.

                          • id :

                            Instance id this alpha payload applies to.

                          • alpha2 : Array (Array Float)

                            Alpha vectors for ReLU node 2, indexed by disjunct term.

                          • alpha4 : Array (Array Float)

                            Alpha vectors for ReLU node 4, indexed by disjunct term.

                          Instances For

                            Load the exported alpha slopes database (for mode = crownobj-alpha).

                            This expects the mnist_fc_crownobj_alpha_v0_1 format produced by the Python export script.

                            Instances For

                              Lower the loaded weights into a CROWN Graph + ParamStore.

                              For MNIST-FC we build: input -> linear -> relu -> linear -> relu -> linear and return the graph plus the inferred inDim, outDim, and output node id.

                              Instances For

                                Compute an output interval box using IBP (fast, loose).

                                Instances For

                                  Compute an output interval box by running forward CROWN and evaluating the affine bounds on the input box.

                                  Instances For

                                    Compute per-node interval boxes to be used by the backward objective pass.

                                    We start from IBP boxes and (when the input dimension is small) refine a small set of parent-node intervals by evaluating forward CROWN affines on the input box. This makes objective bounds tighter without paying the full cost of "evaluate every affine on the input box".

                                    Instances For

                                      Try to refute a single spec row using a backward CROWN objective bound.

                                      We build an objective obj = row and lower-bound rowᵀ y over the input box. If the lower bound is strictly greater than rhs, then the constraint rowᵀ y <= rhs cannot hold.

                                      Instances For

                                        Like refutesRowByCROWNObjective, but use precomputed ReLU alpha slopes.

                                        This is a workflow hook for comparing against "fixed alpha" CROWN objective bounds exported from a reference implementation.

                                        Instances For

                                          Refute a VNNLIB disjunction-of-conjunctions spec using per-row CROWN objective bounds.

                                          This is strictly stronger than checking an output interval box, but it is also slower.

                                          Instances For

                                            Refute a VNNLIB spec using CROWN objectives with externally-provided ReLU alphas.

                                            This mode is meant for apples-to-apples comparisons against alpha-CROWN style tools where the alphas are optimized elsewhere and then imported into TorchLean for checking.

                                            Instances For

                                              CLI entry point.

                                              This is wired into lake exe verify -- vnncomp-mnistfc.

                                              Instances For