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 reusable 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 consistency 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^\infty$ norm of a shape-indexed tensor.
If you flatten the tensor entries into a vector $t_i$, this is $\max_i |t_i|$.
Instances For
$L^2$ (Euclidean) norm of a shape-indexed tensor.
If you flatten the tensor entries into a vector $t_i$, this is $\sqrt{\sum_i t_i^2}$.
Instances For
Instances For
Distances and balls #
Distance induced by a tensor norm:
$$ \operatorname{dist}(t_1,t_2)=\lVert t_1-t_2\rVert. $$
Instances For
Instances For
Closed $\varepsilon$-ball around center for the given norm:
$$ \{t\mid \operatorname{dist}(\mathrm{center},t)\leq\varepsilon\}. $$
Instances For
Continuity / robustness specifications #
Lipschitz continuity (global), phrased using tensor_distance.
If $f$ is $L$-Lipschitz and $d_1(x_0,x)\leq\varepsilon$, then $d_2(f(x_0),f(x))\leq L\varepsilon$.
Instances For
Local Lipschitz continuity within the $\varepsilon$-ball around $x_0$.
Instances For
Adversarial robustness at a point $x_0$.
$f$ is $(\varepsilon,\delta)$-robust at $x_0$ if every input within distance $\varepsilon$ of $x_0$ maps to an output within distance $\delta$ of $f(x_0)$.
Instances For
Certified robustness for a classifier: the prediction is constant on the $\varepsilon$-ball around $x_0$.
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 a factor $c<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:
$$ \frac{\lVert f(x)-f(x+\mathrm{perturbation})\rVert} {\lVert\mathrm{perturbation}\rVert}. $$