Verified Neural Network Propagation #
This file defines neural network layers and provides verified interval propagation, enabling robustness verification for neural networks.
Main definitions #
Layer- A dense layer with weights and biasforwardInterval- Interval propagation through a layerforwardReal- Real-valued forward pass
Main theorems #
mem_layerForwardInterval- Soundness of single layer propagation
Design Notes #
We keep the network definition simple by using lists. Dimension compatibility is checked at runtime and encoded in theorem hypotheses. This avoids complex dependent types while still providing verified soundness.
A dense layer: y = ReLU(W·x + b) weights is a list of rows, each row has inputDim elements bias has outputDim elements (= number of rows in weights)
Weight matrix (outputDim × inputDim), stored as list of rows
Bias vector (outputDim elements)
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- LeanCert.ML.instReprLayer = { reprPrec := LeanCert.ML.instReprLayer.repr }
Forward pass through a layer (real values): y = ReLU(W·x + b)
Equations
- l.forwardReal x = List.map (fun (y : ℝ) => max 0 y) (LeanCert.Engine.IntervalVector.realAddBias (LeanCert.Engine.IntervalVector.realMatVecMul l.weights x) l.bias)
Instances For
Forward pass through a layer (interval arithmetic)
Equations
- l.forwardInterval x prec = LeanCert.ML.IntervalVector.reluVector ((LeanCert.Engine.IntervalVector.matVecMul l.weights x prec).addBias l.bias prec)
Instances For
Length of interval forward pass output
Soundness of layer forward pass. If x ∈ I (component-wise), then forwardReal(x) ∈ forwardInterval(I).
A two-layer network for simple examples
Instances For
Forward pass through two layers
Equations
- net.forwardReal x = net.layer2.forwardReal (net.layer1.forwardReal x)
Instances For
Interval forward pass through two layers
Equations
- net.forwardInterval x prec = net.layer2.forwardInterval (net.layer1.forwardInterval x prec) prec
Instances For
Network is well-formed if layers are well-formed and dimensions match
Equations
Instances For
Soundness theorem for two-layer network