NN.MLTheory.Robustness.Spec #
Scalar-polymorphic definitions of norms/distances and basic robustness vocabulary on TorchLean's shape-indexed tensors.
Robustness specifications (polymorphic) #
This file defines a small vocabulary for specifying robustness properties of tensor-valued functions.
All definitions are scalar-polymorphic in α via [Context α], so the same spec can be
instantiated for:
ℝ(paper-style theorems),Float(fast, executable sanity checks),Interval(sound enclosures for verification),- executable IEEE-754 backends (bit-level runtime semantics).
We keep this module definition-focused: whether these norms/distances satisfy the usual metric
laws depends on additional algebraic/order assumptions on α, and those theorems belong in
dedicated proof developments.
The Float specializations of these definitions live in NN.MLTheory.Robustness.Runtime.
Verified bounds/certificates are proved in dedicated developments (e.g. Lipschitz bounds in
NN.Proofs.Analysis.Lipschitz, and certified robustness procedures in NN.MLTheory.CROWN).
References #
- Adversarial examples and threat models: Szegedy et al. (2013/2014); Goodfellow, Shlens & Szegedy (2015, FGSM); Madry et al. (2017).
- Certified robustness / verification: Wong & Kolter (2018); Cohen, Rosenfeld & Kolter (2019).
- Lipschitz-based viewpoints (one entry point): Hein & Andriushchenko (2017).
Norms on spec tensors #
L∞ norm of a shape-indexed tensor.
If you flatten the tensor entries into a vector tᵢ, this is maxᵢ |tᵢ|.
Instances For
L2 (Euclidean) norm of a shape-indexed tensor.
If you flatten the tensor entries into a vector tᵢ, this is sqrt (∑ᵢ tᵢ²).
Instances For
Instances For
Distances and balls #
Distance induced by a tensor norm:
dist(t1,t2) = ‖t1 - t2‖.
Instances For
Instances For
Closed ε-ball around center for the given norm:
{ t | dist(center,t) ≤ ε }.
Instances For
Continuity / robustness specifications #
Lipschitz continuity (global), phrased using tensor_distance.
If f is L-Lipschitz and tensor_distance norm₁ x₀ x ≤ ε, then
tensor_distance norm₂ (f x₀) (f x) ≤ L*ε.
Instances For
Local Lipschitz continuity within the ε-ball around x₀.
Instances For
Adversarial robustness at a point x₀.
f is (ε,δ)-robust at x₀ if every input within distance ε of x₀ maps to an output within
distance δ of f x₀.
Instances For
Certified robustness for a classifier: the prediction is constant on the ε-ball around x₀.
For neural networks, classifier is typically argmax on a logits tensor.
Instances For
Uniform adversarial robustness over a finite list of inputs.
Instances For
Contraction mapping under a norm: f shrinks distances by contraction_factor < 1.
This is a standard sufficient condition for convergence of iterated dynamics and robustness of fixed points.
Instances For
Sensitivity ratio for a specific additive perturbation.
This is the local “output change divided by input change” quantity:
‖f(x) - f(x + perturbation)‖ / ‖perturbation‖.