TorchLean API

NN.API.Public.Facade.Base.Verification

TorchLean Verification Facade #

Public verification APIs reachable from the NN umbrella.

@[reducible, inline]

TorchLean-to-verifier compiled IR bundle.

Instances For
    @[reducible, inline]

    Verifier-side parameter store used by IBP/CROWN workflows.

    Instances For
      @[reducible, inline]

      Flat input box used to seed verifier input bounds.

      Instances For
        @[reducible, inline]

        Input-node metadata required by affine/CROWN verifier passes.

        Instances For
          @[reducible, inline]

          Output of the forward affine pass for one verifier node.

          Instances For
            @[reducible, inline]

            Output of the CROWN forward pass for one verifier node.

            Instances For

              Compile a sequential TorchLean model into verifier IR with one distinguished input.

              This is the public bridge for the common “train a model, then run IBP/CROWN on its forward pass” workflow.

              Instances For
                def TorchLean.Verification.compileProgram1 {α : Type} [NN.API.Semantics.Scalar α] [DecidableEq Shape] {paramShapes : List Shape} {σ τ : Shape} (program : Runtime.Autograd.TorchLean.Program α (paramShapes ++ [σ]) τ) (params : ParamTensors α paramShapes) :

                Compile a custom TorchLean forward program into verifier IR with one distinguished input.

                Use this when the checked verification target is not a plain nn.Sequential, for example a hand-written TorchLean loss program or an attention fragment built directly from TorchLean.Ops.

                Instances For

                  Seed the distinguished verifier input with an explicit input box.

                  This is the standard follow-up after compileForward1: insert the box at compiled.inputId and hand the returned store to IBP/CROWN passes.

                  Instances For
                    def TorchLean.Verification.lInfBox {α : Type} [NN.API.Semantics.Scalar α] {s : Shape} (center radius : Spec.Tensor α s) :

                    Flatten a center tensor and radius tensor into the verifier-side FlatBox expected by IBP/CROWN.

                    This is the standard public API for turning a shaped TorchLean input plus a shaped perturbation radius into a verifier input box.

                    Instances For
                      def TorchLean.Verification.lInfBall {α : Type} [NN.API.Semantics.Scalar α] {s : Shape} (center : Spec.Tensor α s) (eps : α) :

                      Build a uniform ℓ∞ box around a shaped TorchLean input tensor.

                      This fills the input shape with the scalar radius eps and then flattens the result into the verifier-side FlatBox.

                      Instances For
                        def TorchLean.Verification.seedLInfBall {α : Type} [NN.API.Semantics.Scalar α] {s : Shape} (compiled : CompiledIR α) (center : Spec.Tensor α s) (eps : α) :

                        Seed the compiled verifier input with a uniform ℓ∞ box around a shaped TorchLean input tensor.

                        Instances For

                          Shape of the distinguished verifier input node.

                          Instances For

                            Flattened dimension of the distinguished verifier input node.

                            Instances For

                              Checked affine context for the distinguished verifier input.

                              Instances For

                                Compatibility affine context for the distinguished verifier input.

                                Instances For

                                  Run IBP on a compiled verifier graph.

                                  Instances For
                                    def TorchLean.Verification.outputBox? {α : Type} [Context α] (compiled : CompiledIR α) (boxes : Array (Option (FlatBox α))) :

                                    Read the verifier output box from an IBP result array.

                                    Instances For
                                      def TorchLean.Verification.outputBoxOrThrow {α : Type} [Context α] (compiled : CompiledIR α) (boxes : Array (Option (FlatBox α))) :
                                      IO (FlatBox α)

                                      Read the verifier output box, throwing an IO.userError if it is missing.

                                      Instances For

                                        Run the forward affine pass on a compiled verifier graph.

                                        Instances For

                                          Checked variant of runAffine that validates the compiled input node first.

                                          Instances For

                                            Read the verifier output affine form from a forward affine result array.

                                            Instances For

                                              Run CROWN on a compiled verifier graph.

                                              Instances For

                                                Checked variant of runCROWN that validates the compiled input node first.

                                                Instances For

                                                  Read the verifier output CROWN bounds from a CROWN result array.

                                                  Instances For

                                                    Run forward CROWN and evaluate the verifier output bounds on the compiled input box.

                                                    Instances For

                                                      Run forward CROWN and return the evaluated verifier output box, throwing on failure.

                                                      Instances For

                                                        Run backward CROWN for a scalar objective and evaluate it on the compiled input box.

                                                        Instances For

                                                          Compute the conservative two-class margin lower bound lo[class0] - hi[class1].

                                                          This is the usual public robustness check for binary logits: if the result is positive, class class0 is certified against class1 over the input box.

                                                          Instances For

                                                            Decide whether the two-class margin lower bound is strictly positive.

                                                            Instances For