boundlab.diff.zono3#
Triple-zonotope abstract interpretation for differential verification.
Two structurally identical networks are propagated together as a triple
DiffExpr3 (x, y, d), where x and y
bound each network’s activations and d bounds their difference. Because
d is tracked as a first-class zonotope over the same error symbols as the
branches, everything the two networks share cancels instead of accumulating —
which is what makes f₁(x) − f₂(x) provable at perturbation radii where
bounding each network separately gives nothing.
Affine operations need no special handling: the four
Expr primitives map over the components, biases cancel in
d, and the base ONNX operators work unchanged. Non-linearities use the
differential linearisers in this package — a nine-case ReLU split following
VeryDiff (Teuber et al., 2024), and hexagon-Chebyshev envelopes for
exp / tanh / reciprocal that bound the divided difference over the
feasible region rather than over a merged interval.
Examples
>>> import torch
>>> from torch import nn
>>> from boundlab import Error
>>> from boundlab.utils import ShapeDtype
>>> from boundlab.zono import Zono
>>> from boundlab.diff.expr import DiffExpr3
>>> from boundlab.diff.zono3 import interpret
>>> err = Error("input", ShapeDtype((4,), torch.float32))
>>> x = Zono.error(err) * 0.05 + torch.zeros(4)
>>> triple = DiffExpr3(x, x, torch.zeros(4))
>>> model = nn.Sequential(nn.Linear(4, 5), nn.ReLU(), nn.Linear(5, 3))
>>> out = interpret(model)(triple)
>>> tuple(out.diff.ub().shape)
(3,)
Module Attributes
Differential interpreter over dense zonotopes. |
Functions
Realise bounds against the input triple in the given |
|
Apply |
|
Assemble a differential interpreter over |
|
Turn a differential lineariser into an |
|
Apply |
|
Lift a domain's |
|
Pick, per element, the narrower of two sound enclosures of the difference. |
Classes
Affine enclosures for both branches and for their difference. |
|
Differential exp bounds for a |
|
Exact handler for |
|
Matrix product of differential expressions. |
|
Element-wise product of differential expressions. |
|
Differential |
|
Differential ReLU bounds for a |
|
Differential softmax over the last axis. |
|
Differential handler for |
|
Differential tanh bounds for a |
|
Exact handler for |