TorchLean API

NN.Proofs.RuntimeApprox.FP32.Layers

FP32 Layer Approximation #

Specialize the generic NF bounds to TorchLean.Floats.FP32 and compose matrix-vector multiplication with bias addition. linearErrorBudget exposes the resulting infinity-norm bound for use in the MLP and CROWN/IBP proofs.

This rounded-real model uses nearest-even binary32 precision without an upper exponent bound or NaN/Inf values. Applying these bounds to native or encoded IEEE execution requires a separate refinement excluding exceptional results. See NN/Floats/IEEEExec/Bridge/Finite.lean and NN/Proofs/RuntimeApprox/IEEE32/Arithmetic.lean.

@[reducible, inline]

Runtime scalar type: float32 rounding model (TorchLean.Floats.FP32).

Instances For
    @[reducible, inline]

    Radix for the FP32 rounding model (binary).

    Instances For
      @[reducible, inline]

      Exponent function used by the FP32 rounding model.

      Instances For
        @[reducible, inline]
        noncomputable abbrev NN.Proofs.RuntimeApprox.FP32.rnd :
        ℝ → ℤ

        Round-to-nearest-even function used by the FP32 rounding model.

        Instances For
          @[reducible, inline]
          noncomputable abbrev NN.Proofs.RuntimeApprox.FP32.toSpec :
          R → ℝ

          Interpretation of runtime scalars as real spec scalars, specialized to FP32.

          Instances For
            noncomputable def NN.Proofs.RuntimeApprox.FP32.linearErrorBudget {inDim outDim : ℕ} (epsW epsb epsx : ℝ) (WR : Spec.LinearSpec R inDim outDim) (xR : TorchLean.Tensor R [inDim]) :

            Explicit expression for the propagated infinity-norm error of an FP32 linear layer.

            Instances For

              Forward error bound for a linear layer y = Wx + b under the FP32 rounding semantics.

              Inputs:

              • hW, hb, and hx say the runtime weights, bias, and input approximate their real-spec counterparts.

              The conclusion exposes linearErrorBudget, rather than hiding the propagated quantity behind an existential. It combines the matrix-vector product budget with the final rounded bias addition.

              This is the base layer theorem used by the MLP and CROWN/IBP FP32 wrappers.