8.5. Verification
This part of the map follows proofs from local algebra to executable checkers. A solid dependency edge means the later statement uses the earlier definition or theorem. Runtime checkers that lack a proved acceptance-to-semantics bridge are described beside the matching proof work, without adding a dependency edge.
For autograd, the first step is a local identity between a Jacobian-vector product (JVP) and a vector-Jacobian product (VJP). Graph induction extends that identity to a whole computation. Derivative theorems additionally require the local operations to be differentiable, and runtime theorems identify which executable accumulation agrees with the proved graph. The entries below keep these steps separate so that the assumptions needed for each conclusion remain visible.
Read a linked declaration as a function from assumptions to a conclusion. A binder such as
(h : TopoSorted g) asks the caller for evidence about this particular graph; a result quantified
by ∀ x applies to every input satisfying its later premises. The proof entries explain where
that evidence comes from. This matters when following an application backward: an enclosure
result may need both a theorem about the propagation rule and a separate theorem identifying the
program whose values it encloses.
Each node in an algebraic proof graph carries forward, JVP, and VJP functions together with the local dot-product identity relating its JVP and VJP.
Here the tangent describes a perturbation of the node's inputs, and the output cotangent chooses a scalar combination of its outputs. The identity says that evaluating this combination after a JVP gives the same scalar as pairing the input perturbation with the VJP. Requiring it for every tangent and cotangent lets later proofs use the node in any surrounding graph.
Lean code for Definition8.5.1●1 definition
Associated Lean declarations
-
Proofs.Autograd.Algebra.Node[complete]
-
Proofs.Autograd.Algebra.Node[complete]
-
structuredefined in NN/Proofs/Autograd/Tape/Algebra/Soundness.leancomplete
structure Proofs.Autograd.Algebra.Node {α : Type} [TorchLean.Storage α] [CommSemiring α] (Δ : Type) (Γ : List Spec.Shape) (τ : Spec.Shape) : Type
structure Proofs.Autograd.Algebra.Node {α : Type} [TorchLean.Storage α] [CommSemiring α] (Δ : Type) (Γ : List Spec.Shape) (τ : Spec.Shape) : Type
Proof-carrying node: `NodeData` plus the local adjointness law. The field `correct` is the algebraic version of the standard JVP/VJP inner-product law.
Extends
-
Proofs.Autograd.Algebra.NodeData α Δ Γ τ
Fields
forward : TorchLean.TensorPack α Γ → Δ → TorchLean.Tensor α τ
Inherited from-
Proofs.Autograd.Algebra.NodeData
jvp : TorchLean.TensorPack α Γ → TorchLean.TensorPack α Γ → Δ → TorchLean.Tensor α τ
Inherited from-
Proofs.Autograd.Algebra.NodeData
vjp : TorchLean.TensorPack α Γ → Δ → TorchLean.Tensor α τ → TorchLean.TensorPack α Γ
Inherited from-
Proofs.Autograd.Algebra.NodeData
validate : TorchLean.TensorPack α Γ → Δ → Except String Unit
Inherited from-
Proofs.Autograd.Algebra.NodeData
correct : ∀ (x dx : TorchLean.TensorPack α Γ) (d : Δ) (δ : TorchLean.Tensor α τ), Proofs.TensorAlgebra.dot (self.jvp x dx d) δ = Proofs.Autograd.Algebra.TensorPack.dotList dx (self.vjp x d δ)
The node's JVP and VJP satisfy the local dot-product adjoint identity.
-
GraphData stores a typed sequence of executable forward, JVP, and VJP node operations without
local correctness proofs.
The type parameter Γ lists the differentiable input shapes; Δ holds auxiliary data that is
kept fixed. A trainable weight must belong to the differentiable context if its cotangent is to
be returned. Storing that weight only in Δ changes the differentiation problem even when forward
evaluation computes the same numbers.
Lean code for Definition8.5.2●1 definition
Associated Lean declarations
-
Proofs.Autograd.Algebra.GraphData[complete]
-
Proofs.Autograd.Algebra.GraphData[complete]
-
inductivedefined in NN/Proofs/Autograd/Tape/Algebra/Soundness.leancomplete
inductive Proofs.Autograd.Algebra.GraphData (α : Type) [TorchLean.Storage α] (Δ : Type) (Γ : List Spec.Shape) : List Spec.Shape → Type
inductive Proofs.Autograd.Algebra.GraphData (α : Type) [TorchLean.Storage α] (Δ : Type) (Γ : List Spec.Shape) : List Spec.Shape → Type
Executable-only graph: a snoc-list of `NodeData`.
Constructors
Proofs.Autograd.Algebra.GraphData.nil {α : Type} [TorchLean.Storage α] {Δ : Type} {Γ : List Spec.Shape} : Proofs.Autograd.Algebra.GraphData α Δ Γ []
A graph with no computed nodes; its context consists only of the inputs `Γ`.
Proofs.Autograd.Algebra.GraphData.snoc {α : Type} [TorchLean.Storage α] {Δ : Type} {Γ ss : List Spec.Shape} {τ : Spec.Shape} : Proofs.Autograd.Algebra.GraphData α Δ Γ ss → Proofs.Autograd.Algebra.NodeData α Δ (Γ ++ ss) τ → Proofs.Autograd.Algebra.GraphData α Δ Γ (ss ++ [τ])
Append one node whose inputs may use the original and previously computed values.
A proof-carrying algebraic graph is a typed sequence of locally correct nodes. Its output-shape list records each intermediate added to the graph.
Lean code for Definition8.5.3●1 definition
Associated Lean declarations
-
Proofs.Autograd.Algebra.Graph[complete]
-
Proofs.Autograd.Algebra.Graph[complete]
-
inductivedefined in NN/Proofs/Autograd/Tape/Algebra/Soundness.leancomplete
inductive Proofs.Autograd.Algebra.Graph {α : Type} [TorchLean.Storage α] [CommSemiring α] (Δ : Type) (Γ : List Spec.Shape) : List Spec.Shape → Type
inductive Proofs.Autograd.Algebra.Graph {α : Type} [TorchLean.Storage α] [CommSemiring α] (Δ : Type) (Γ : List Spec.Shape) : List Spec.Shape → Type
A proof-carrying tape/SSA graph. Nodes are appended in topological order and may reference any previously computed value.
Constructors
Proofs.Autograd.Algebra.Graph.nil {α : Type} [TorchLean.Storage α] [CommSemiring α] {Δ : Type} {Γ : List Spec.Shape} : Proofs.Autograd.Algebra.Graph Δ Γ []
A graph with no computed nodes; its context consists only of the inputs `Γ`.
Proofs.Autograd.Algebra.Graph.snoc {α : Type} [TorchLean.Storage α] [CommSemiring α] {Δ : Type} {Γ ss : List Spec.Shape} {τ : Spec.Shape} : Proofs.Autograd.Algebra.Graph Δ Γ ss → Proofs.Autograd.Algebra.Node Δ (Γ ++ ss) τ → Proofs.Autograd.Algebra.Graph Δ Γ (ss ++ [τ])
Append one locally correct node that may use the inputs and all preceding results.
OpSpecCorrect packages a unary tensor operation, its JVP, and the local inner-product identity
relating that JVP to the operation's VJP.
Lean code for Definition8.5.4●1 definition
Associated Lean declarations
-
Proofs.Autograd.Algebra.OpSpecCorrect[complete]
-
Proofs.Autograd.Algebra.OpSpecCorrect[complete]
-
structuredefined in NN/Proofs/Autograd/Core/SemiringCorrectness.leancomplete
structure Proofs.Autograd.Algebra.OpSpecCorrect (α : Type) [TorchLean.Storage α] [CommSemiring α] (σ τ : Spec.Shape) : Type
structure Proofs.Autograd.Algebra.OpSpecCorrect (α : Type) [TorchLean.Storage α] [CommSemiring α] (σ τ : Spec.Shape) : Type
An `OpSpec` together with a matching JVP and a proof of VJP/JVP adjointness. This is the backend-generic analogue of `Proofs.Autograd.OpSpecCorrect` from `NN.Proofs.Autograd.Core.RealCorrectness`.
Fields
op : Spec.OpSpec α σ τ
The operation being certified, forward and backward together.
jvp : TorchLean.Tensor α σ → TorchLean.Tensor α σ → TorchLean.Tensor α τ
Forward-mode derivative at a basepoint, applied to a tangent.
correct : Proofs.Autograd.Algebra.VJPCorrect self.op.forward self.jvp self.op.backward
The adjointness proof. Bundling it with the operation is what makes a value of this type a certificate: you cannot obtain one without having shown the backward pass is the transpose.
The unary-operation adapter places an
OpSpecCorrect value at a typed input index and
produces a proof-carrying graph node.
Lean code for Definition8.5.5●1 definition
Associated Lean declarations
-
defdefined in NN/Proofs/Autograd/Tape/Algebra/Nodes.leancomplete
def Proofs.Autograd.Algebra.Node.ofOpSpecCorrect {α Δ : Type} [TorchLean.Storage α] [CommSemiring α] {Γ : List Spec.Shape} {σ τ : Spec.Shape} (idx : Proofs.Idx Γ σ) (op : Proofs.Autograd.Algebra.OpSpecCorrect α σ τ) : Proofs.Autograd.Algebra.Node Δ Γ τ
def Proofs.Autograd.Algebra.Node.ofOpSpecCorrect {α Δ : Type} [TorchLean.Storage α] [CommSemiring α] {Γ : List Spec.Shape} {σ τ : Spec.Shape} (idx : Proofs.Idx Γ σ) (op : Proofs.Autograd.Algebra.OpSpecCorrect α σ τ) : Proofs.Autograd.Algebra.Node Δ Γ τ
Build a proof-carrying unary node from an `OpSpecCorrect`.
For an algebraic graph over a commutative semiring, reverse accumulation is adjoint to the graph JVP.
The commutative-semiring assumption supplies the laws for rearranging finite sums and products. No limit or topology enters this statement. It establishes the relationship between the supplied JVP and VJP implementations; the analytic graph theorem below additionally identifies the JVP with the derivative of the forward function.
Lean code for Theorem8.5.6●1 theorem
Associated Lean declarations
-
theoremdefined in NN/Proofs/Autograd/Tape/Algebra/Soundness.leancomplete
theorem Proofs.Autograd.Algebra.Graph.backprop_correct {α : Type} [TorchLean.Storage α] [CommSemiring α] {Δ : Type} {Γ ss : List Spec.Shape} (g : Proofs.Autograd.Algebra.Graph Δ Γ ss) (x dx : TorchLean.TensorPack α Γ) (d : Δ) (seed : TorchLean.TensorPack α (Γ ++ ss)) : Proofs.Autograd.Algebra.TensorPack.dotList (g.jvpCtx x dx d) seed = Proofs.Autograd.Algebra.TensorPack.dotList dx (g.backpropCtx x d seed)
theorem Proofs.Autograd.Algebra.Graph.backprop_correct {α : Type} [TorchLean.Storage α] [CommSemiring α] {Δ : Type} {Γ ss : List Spec.Shape} (g : Proofs.Autograd.Algebra.Graph Δ Γ ss) (x dx : TorchLean.TensorPack α Γ) (d : Δ) (seed : TorchLean.TensorPack α (Γ ++ ss)) : Proofs.Autograd.Algebra.TensorPack.dotList (g.jvpCtx x dx d) seed = Proofs.Autograd.Algebra.TensorPack.dotList dx (g.backpropCtx x d seed)
Global tape soundness (algebraic form). Assuming each node satisfies its local adjointness law, `backpropCtx` is the adjoint of `jvpCtx` with respect to `TensorPack.dotList`.
Graph induction expands the JVP and VJP at each node, then closes the new step with that node's local adjoint law.
The linear operation satisfies the unary operation contract over any commutative semiring. Its correctness field applies matrix-vector adjointness and commutativity of the tensor dot product.
Lean code for Definition8.5.7●1 definition
Associated Lean declarations
-
Proofs.Autograd.Algebra.linearCorrect[complete]
-
Proofs.Autograd.Algebra.linearCorrect[complete]
-
defdefined in NN/Proofs/Autograd/Core/SemiringCorrectness.leancomplete
def Proofs.Autograd.Algebra.linearCorrect {α : Type} [TorchLean.Storage α] [CommSemiring α] {inDim outDim : ℕ} (m : Spec.LinearSpec α inDim outDim) : Proofs.Autograd.Algebra.OpSpecCorrect α (Spec.Shape.dim inDim Spec.Shape.scalar) (Spec.Shape.dim outDim Spec.Shape.scalar)
def Proofs.Autograd.Algebra.linearCorrect {α : Type} [TorchLean.Storage α] [CommSemiring α] {inDim outDim : ℕ} (m : Spec.LinearSpec α inDim outDim) : Proofs.Autograd.Algebra.OpSpecCorrect α (Spec.Shape.dim inDim Spec.Shape.scalar) (Spec.Shape.dim outDim Spec.Shape.scalar)
Correctness of a linear layer’s backward rule (matrix–vector multiply), stated generically over `α`. This is purely algebraic: it relies only on semiring laws and the adjointness lemma for matrix multiplication in `TensorAlgebra`. PyTorch analogue: the affine map implemented by `torch.nn.Linear`.
Lowering an algebraic graph to the runtime tape and running dense backward returns the graph's proved reverse accumulator after its typed tensor context is converted to the runtime array representation.
Lean code for Theorem8.5.8●1 theorem
Associated Lean declarations
-
theoremdefined in NN/Proofs/Autograd/Runtime/Link/BackwardGraph.leancomplete
theorem Proofs.Autograd.Algebra.Graph.backwardDenseFrom_lowerGraphToTape_eq_backpropAllCtx {α Δ : Type} [TorchLean.Storage α] [CommSemiring α] {Γ ss : List Spec.Shape} (g : Proofs.Autograd.Algebra.Graph Δ Γ ss) (x : TorchLean.TensorPack α Γ) (d0 : Δ) (seed : TorchLean.TensorPack α (Γ ++ ss)) : (g.lowerGraphToTape x d0).1.backwardDenseFrom seed.toShapeErasedArray = Except.ok (g.backpropAllCtx x d0 seed).toShapeErasedArray
theorem Proofs.Autograd.Algebra.Graph.backwardDenseFrom_lowerGraphToTape_eq_backpropAllCtx {α Δ : Type} [TorchLean.Storage α] [CommSemiring α] {Γ ss : List Spec.Shape} (g : Proofs.Autograd.Algebra.Graph Δ Γ ss) (x : TorchLean.TensorPack α Γ) (d0 : Δ) (seed : TorchLean.TensorPack α (Γ ++ ss)) : (g.lowerGraphToTape x d0).1.backwardDenseFrom seed.toShapeErasedArray = Except.ok (g.backpropAllCtx x d0 seed).toShapeErasedArray
**Main runtime/link theorem**: running the runtime dense backward loop on a tape produced by `lowerGraphToTape` matches the proved “full backpropagation” `backpropAllCtx`. This is the formal statement that the executable engine implements the same reverse-mode accumulation semantics as the proved tape model.
Induction over the graph maintains the index and context correspondence of the runtime tape through reverse accumulation.
For a real proof-carrying tape, the inner product of a JVP with a cotangent seed equals the inner product of the input tangent with reverse accumulation.
Lean code for Theorem8.5.9●1 theorem
Associated Lean declarations
-
theoremdefined in NN/Proofs/Autograd/Tape/Core/FDeriv.leancomplete
theorem Proofs.Autograd.Graph.backprop_correct_inner {Γ ss : List Spec.Shape} (g : Proofs.Autograd.Graph Γ ss) (xV dxV : Proofs.Autograd.CtxVec Γ) (seedV : Proofs.Autograd.CtxVec (Γ ++ ss)) : inner ℝ (g.jvpVec xV dxV) seedV = inner ℝ dxV (g.backpropVec xV seedV)
theorem Proofs.Autograd.Graph.backprop_correct_inner {Γ ss : List Spec.Shape} (g : Proofs.Autograd.Graph Γ ss) (xV dxV : Proofs.Autograd.CtxVec Γ) (seedV : Proofs.Autograd.CtxVec (Γ ++ ss)) : inner ℝ (g.jvpVec xV dxV) seedV = inner ℝ dxV (g.backpropVec xV seedV)
Vectorized tape soundness: `⟪jvp, seed⟫ = ⟪dx, backprop seed⟫`.
Tape induction applies each real node's local vector adjoint law while preserving the Euclidean inner product across context append and split operations.
For differentiable real graph nodes, reverse accumulation equals the adjoint Fréchet derivative at the chosen point.
Lean code for Theorem8.5.10●1 theorem
Associated Lean declarations
-
theoremdefined in NN/Proofs/Autograd/Tape/Core/FDeriv.leancomplete
theorem Proofs.Autograd.Graph.backpropVec_eq_adjoint_fderiv_at {Γ ss : List Spec.Shape} (g : Proofs.Autograd.Graph Γ ss) (xV : Proofs.Autograd.CtxVec Γ) (seedV : Proofs.Autograd.CtxVec (Γ ++ ss)) : ∀ (a : Proofs.Autograd.GraphFDerivCorrectAt g xV), g.backpropVec xV seedV = (ContinuousLinearMap.adjoint (fderiv ℝ g.evalVec xV)) seedV
theorem Proofs.Autograd.Graph.backpropVec_eq_adjoint_fderiv_at {Γ ss : List Spec.Shape} (g : Proofs.Autograd.Graph Γ ss) (xV : Proofs.Autograd.CtxVec Γ) (seedV : Proofs.Autograd.CtxVec (Γ ++ ss)) : ∀ (a : Proofs.Autograd.GraphFDerivCorrectAt g xV), g.backpropVec xV seedV = (ContinuousLinearMap.adjoint (fderiv ℝ g.evalVec xV)) seedV
Pointwise version of `backpropVec_eq_adjoint_fderiv`.
Real tape soundness supplies the inner-product identity. The analytic hypotheses identify the graph JVP with a Fréchet derivative, and the adjoint is then characterized by its inner products.
For a real algebraic graph at a differentiable execution point, lowering the graph and running the exact dense tape returns the full algebraic reverse context. Its input prefix is the adjoint Fréchet derivative of graph evaluation applied to the output seed.
Lean code for Theorem8.5.11●1 theorem
Associated Lean declarations
-
theoremdefined in NN/Proofs/Autograd/Runtime/Link/FDeriv.leancomplete
theorem Proofs.Autograd.Algebra.Graph.backwardDenseFrom_lowerGraphToTape_adjoint_fderiv_at {Δ : Type} {Γ ss : List Spec.Shape} (g : Proofs.Autograd.Algebra.Graph Δ Γ ss) (x : TorchLean.TensorPack ℝ Γ) (d0 : Δ) (seed : TorchLean.TensorPack ℝ (Γ ++ ss)) (hg : Proofs.Autograd.GraphFDerivCorrectAt (g.toReal d0) (Proofs.Autograd.flattenCtx x)) : (g.lowerGraphToTape x d0).1.backwardDenseFrom seed.toShapeErasedArray = Except.ok (g.backpropAllCtx x d0 seed).toShapeErasedArray ∧ Proofs.Autograd.flattenCtx (Proofs.Autograd.Algebra.TensorPack.takeLeft (g.backpropAllCtx x d0 seed)) = (ContinuousLinearMap.adjoint (fderiv ℝ (g.toReal d0).evalVec (Proofs.Autograd.flattenCtx x))) (Proofs.Autograd.flattenCtx seed)
theorem Proofs.Autograd.Algebra.Graph.backwardDenseFrom_lowerGraphToTape_adjoint_fderiv_at {Δ : Type} {Γ ss : List Spec.Shape} (g : Proofs.Autograd.Algebra.Graph Δ Γ ss) (x : TorchLean.TensorPack ℝ Γ) (d0 : Δ) (seed : TorchLean.TensorPack ℝ (Γ ++ ss)) (hg : Proofs.Autograd.GraphFDerivCorrectAt (g.toReal d0) (Proofs.Autograd.flattenCtx x)) : (g.lowerGraphToTape x d0).1.backwardDenseFrom seed.toShapeErasedArray = Except.ok (g.backpropAllCtx x d0 seed).toShapeErasedArray ∧ Proofs.Autograd.flattenCtx (Proofs.Autograd.Algebra.TensorPack.takeLeft (g.backpropAllCtx x d0 seed)) = (ContinuousLinearMap.adjoint (fderiv ℝ (g.toReal d0).evalVec (Proofs.Autograd.flattenCtx x))) (Proofs.Autograd.flattenCtx seed)
Pointwise variant of `backwardDenseFrom_lowerGraphToTape_adjoint_fderiv`.
The real, environment-free algebraic graph and the analytic graph convert in both directions while preserving evaluation, JVPs, and reverse accumulation. The tape-lowering correctness theorem gives the full cotangent context; prefix extraction identifies its input block with analytic backprop, and the analytic graph theorem identifies that value with the adjoint Fréchet derivative.
Every tape produced by lowering an
algebraic graph over a commutative semiring is zero preserving:
each lowered node's backward closure sends a zero cotangent to zero contributions of its parents'
shapes. This is the hypothesis under which the executed sweep backwardDenseAll agrees with the
proved sweep backwardDenseFrom.
Lean code for Theorem8.5.12●1 theorem
Associated Lean declarations
-
theoremdefined in NN/Proofs/Autograd/Runtime/Link/BackwardDenseGraph.leancomplete
theorem Proofs.Autograd.Algebra.Graph.lowerGraphToTape_zeroPreserving {α : Type} [TorchLean.Storage α] [CommSemiring α] {Δ : Type} {Γ ss : List Spec.Shape} (g : Proofs.Autograd.Algebra.Graph Δ Γ ss) (x : TorchLean.TensorPack α Γ) (d0 : Δ) : Proofs.Autograd.Algebra.Graph.ZeroPreserving (g.lowerGraphToTape x d0).1
theorem Proofs.Autograd.Algebra.Graph.lowerGraphToTape_zeroPreserving {α : Type} [TorchLean.Storage α] [CommSemiring α] {Δ : Type} {Γ ss : List Spec.Shape} (g : Proofs.Autograd.Algebra.Graph Δ Γ ss) (x : TorchLean.TensorPack α Γ) (d0 : Δ) : Proofs.Autograd.Algebra.Graph.ZeroPreserving (g.lowerGraphToTape x d0).1
Every tape produced by `lowerGraphToTape` is `ZeroPreserving`: leaves have no contributions, and a lowered node's `backward` on its zero cotangent runs the stored VJP at zero, which is the zero context by `node_vjp_full_zero`, so every emitted contribution is a parent's zero cotangent.
A node's adjointness law gives
dot (jvp x dx d) δ = dotList dx (vjp x d δ); with δ = 0 the left side vanishes for every dx,
and nondegeneracy of the tensor pairing over a commutative semiring forces vjp x d 0 = 0.
For an algebraic graph over a commutative semiring, the
executed dense sweep Tape.backwardDenseAll on the lowered
tape, seeded at any typed output index with any seed of the
output's shape, returns exactly backpropAllCtx of the one-hot seed context, converted to the
tape's shape-erased array. This is the sweep the runtime runs, not only the proof-side sweep.
Lean code for Theorem8.5.13●1 theorem
Associated Lean declarations
-
theoremdefined in NN/Proofs/Autograd/Runtime/Link/BackwardDenseGraph.leancomplete
theorem Proofs.Autograd.Algebra.Graph.backwardDenseAll_lowerGraphToTape_eq_backpropAllCtx {α : Type} [TorchLean.Storage α] [CommSemiring α] {Δ : Type} {Γ ss : List Spec.Shape} (g : Proofs.Autograd.Algebra.Graph Δ Γ ss) (x : TorchLean.TensorPack α Γ) (d0 : Δ) {τ : Spec.Shape} (output : Proofs.Idx (Γ ++ ss) τ) (seed : TorchLean.Tensor α τ) : (g.lowerGraphToTape x d0).1.backwardDenseAll (↑output.i) (Spec.SomeTensor.ofTensor seed) = Except.ok (g.backpropAllCtx x d0 (Proofs.Autograd.Algebra.TensorPack.single output seed)).toShapeErasedArray
theorem Proofs.Autograd.Algebra.Graph.backwardDenseAll_lowerGraphToTape_eq_backpropAllCtx {α : Type} [TorchLean.Storage α] [CommSemiring α] {Δ : Type} {Γ ss : List Spec.Shape} (g : Proofs.Autograd.Algebra.Graph Δ Γ ss) (x : TorchLean.TensorPack α Γ) (d0 : Δ) {τ : Spec.Shape} (output : Proofs.Idx (Γ ++ ss) τ) (seed : TorchLean.Tensor α τ) : (g.lowerGraphToTape x d0).1.backwardDenseAll (↑output.i) (Spec.SomeTensor.ofTensor seed) = Except.ok (g.backpropAllCtx x d0 (Proofs.Autograd.Algebra.TensorPack.single output seed)).toShapeErasedArray
**Executed backward pass on a lowered graph = proved backpropagation.** Running the trainer's `Tape.backwardDenseAll` on the tape produced by `lowerGraphToTape`, seeded at any typed output index `output` with cotangent `seed`, succeeds and returns the shape erasure of `backpropAllCtx` of the one-hot seed context. Unlike `backwardDenseFrom_lowerGraphToTape_eq_backpropAllCtx`, this is about the variant that skips unreached nodes; the two agree by `lowerGraphToTape_zeroPreserving`.
Zero preservation lets the executed sweep be rewritten as the proved sweep started from the one-hot seed array; the proved-sweep theorem then identifies that sweep with graph backpropagation.
A one-hot seed context is zero at every graph value except the selected output. The seed in that output block can be an arbitrary tensor, so this is enough to ask for a particular output coordinate or a weighted combination. When several later nodes use the same parent, their cotangent contributions accumulate at the same parent entry.
For a real algebraic graph whose nodes satisfy the analytic
GraphFDerivCorrect hypothesis, the executed dense sweep on the lowered tape returns the full
reverse context, and the input block of that context is the adjoint Fréchet derivative of the
graph's forward map applied to the output seed. The statement is about the exact tape model over
ℝ; it says nothing about Float rounding or the CUDA path.
Lean code for Theorem8.5.14●1 theorem
Associated Lean declarations
-
theoremdefined in NN/Proofs/Autograd/Runtime/Link/BackwardDenseGraph.leancomplete
theorem Proofs.Autograd.Algebra.Graph.backwardDenseAll_lowerGraphToTape_adjoint_fderiv {Δ : Type} {Γ ss : List Spec.Shape} (g : Proofs.Autograd.Algebra.Graph Δ Γ ss) (x : TorchLean.TensorPack ℝ Γ) (d0 : Δ) {τ : Spec.Shape} (output : Proofs.Idx (Γ ++ ss) τ) (seed : TorchLean.Tensor ℝ τ) (hg : Proofs.Autograd.GraphFDerivCorrect (g.toReal d0)) : (g.lowerGraphToTape x d0).1.backwardDenseAll (↑output.i) (Spec.SomeTensor.ofTensor seed) = Except.ok (g.backpropAllCtx x d0 (Proofs.Autograd.Algebra.TensorPack.single output seed)).toShapeErasedArray ∧ Proofs.Autograd.flattenCtx (Proofs.Autograd.Algebra.TensorPack.takeLeft (g.backpropAllCtx x d0 (Proofs.Autograd.Algebra.TensorPack.single output seed))) = (ContinuousLinearMap.adjoint (fderiv ℝ (g.toReal d0).evalVec (Proofs.Autograd.flattenCtx x))) (Proofs.Autograd.flattenCtx (Proofs.Autograd.Algebra.TensorPack.single output seed))
theorem Proofs.Autograd.Algebra.Graph.backwardDenseAll_lowerGraphToTape_adjoint_fderiv {Δ : Type} {Γ ss : List Spec.Shape} (g : Proofs.Autograd.Algebra.Graph Δ Γ ss) (x : TorchLean.TensorPack ℝ Γ) (d0 : Δ) {τ : Spec.Shape} (output : Proofs.Idx (Γ ++ ss) τ) (seed : TorchLean.Tensor ℝ τ) (hg : Proofs.Autograd.GraphFDerivCorrect (g.toReal d0)) : (g.lowerGraphToTape x d0).1.backwardDenseAll (↑output.i) (Spec.SomeTensor.ofTensor seed) = Except.ok (g.backpropAllCtx x d0 (Proofs.Autograd.Algebra.TensorPack.single output seed)).toShapeErasedArray ∧ Proofs.Autograd.flattenCtx (Proofs.Autograd.Algebra.TensorPack.takeLeft (g.backpropAllCtx x d0 (Proofs.Autograd.Algebra.TensorPack.single output seed))) = (ContinuousLinearMap.adjoint (fderiv ℝ (g.toReal d0).evalVec (Proofs.Autograd.flattenCtx x))) (Proofs.Autograd.flattenCtx (Proofs.Autograd.Algebra.TensorPack.single output seed))
**Executed backward pass = adjoint of the Fréchet derivative.** Over `ℝ`, the trainer's `Tape.backwardDenseAll` on a lowered graph, seeded at a typed output index, succeeds with the full backpropagation context, whose input (`Γ`-prefix) block is the adjoint of the Fréchet derivative of the graph's forward evaluation applied to the one-hot seed. This composes `backwardDenseAll_lowerGraphToTape_eq_backpropAllCtx` with `backwardDenseFrom_lowerGraphToTape_adjoint_fderiv`.
The first conjunct is the executed-sweep link; the second is the proved-sweep Fréchet theorem read through the same one-hot seed context.
The verified source language is a typed sequence of supported tensor operations with one input and shape-indexed intermediate values.
The source type already records which shapes each operation consumes and produces. Lowering changes how those values are named and stored: a typed position becomes a node reference in the IR. The two theorems below check complementary consequences of that change. Well-formedness makes the references structurally valid; semantic equality shows that they still name the intended computations.
Lean code for Definition8.5.15●1 definition
Associated Lean declarations
-
abbrevdefined in NN/Verification/Builtin/Proved/Syntax.leancomplete
abbrev NN.Verification.Builtin.Proved.ForwardProgram (α : Type) [TorchLean.Storage α] (paramShapes : List Spec.Shape) (inShape outShape : Spec.Shape) : Type
abbrev NN.Verification.Builtin.Proved.ForwardProgram (α : Type) [TorchLean.Storage α] (paramShapes : List Spec.Shape) (inShape outShape : Spec.Shape) : Type
A closed program in the proved forward fragment, from `inShape` to `outShape`.
lowerForwardProgramToIR lowers the verified source program to
the shared IR while preserving its typed node order.
Lean code for Definition8.5.16●1 definition
Associated Lean declarations
-
defdefined in NN/Verification/Builtin/Proved/Lowering.leancomplete
def NN.Verification.Builtin.Proved.lowerForwardProgramToIR {α : Type} [TorchLean.Storage α] [Context α] {paramShapes : List Spec.Shape} {inShape outShape : Spec.Shape} (p : NN.Verification.Builtin.Proved.ForwardProgram α paramShapes inShape outShape) (params : TorchLean.TensorPack α paramShapes) : NN.Verification.Builtin.LoweredIR α
def NN.Verification.Builtin.Proved.lowerForwardProgramToIR {α : Type} [TorchLean.Storage α] [Context α] {paramShapes : List Spec.Shape} {inShape outShape : Spec.Shape} (p : NN.Verification.Builtin.Proved.ForwardProgram α paramShapes inShape outShape) (params : TorchLean.TensorPack α paramShapes) : NN.Verification.Builtin.LoweredIR α
Lower a proved forward-fragment program into the verifier IR. The resulting `LoweredIR` can be executed by the IR evaluator, and we prove (in this file) that its denotation agrees with `evalForward`.
Every graph produced by the verified forward lowering passes the IR structural well-formedness predicate.
Lean code for Theorem8.5.17●1 theorem
Associated Lean declarations
-
theoremdefined in NN/Verification/Builtin/Proved/Correctness/WellFormed.leancomplete
theorem NN.Verification.Builtin.Proved.Correctness.lowerForwardProgramToIR_wellFormed {α : Type} [TorchLean.Storage α] [Context α] {paramShapes : List Spec.Shape} {inShape outShape : Spec.Shape} (p : NN.Verification.Builtin.Proved.ForwardProgram α paramShapes inShape outShape) (params : TorchLean.TensorPack α paramShapes) : (NN.Verification.Builtin.Proved.lowerForwardProgramToIR p params).graph.wellFormed = true
theorem NN.Verification.Builtin.Proved.Correctness.lowerForwardProgramToIR_wellFormed {α : Type} [TorchLean.Storage α] [Context α] {paramShapes : List Spec.Shape} {inShape outShape : Spec.Shape} (p : NN.Verification.Builtin.Proved.ForwardProgram α paramShapes inShape outShape) (params : TorchLean.TensorPack α paramShapes) : (NN.Verification.Builtin.Proved.lowerForwardProgramToIR p params).graph.wellFormed = true
Graphs produced by `lowerForwardProgramToIR` satisfy the IR structural discipline (`Graph.wellFormed = true`).
Induction over the source program shows that the lowering preserves the node-index invariant at every append.
Running the output of the verified forward lowering with the IR semantics gives the same result as evaluating the source forward program.
Lean code for Theorem8.5.18●1 theorem
Associated Lean declarations
-
theoremdefined in NN/Verification/Builtin/Proved/Correctness/Eval/Main.leancomplete
theorem NN.Verification.Builtin.Proved.Correctness.runForwardIR_eq_evalForward {α : Type} [TorchLean.Storage α] [Context α] {paramShapes : List Spec.Shape} {inShape outShape : Spec.Shape} (p : NN.Verification.Builtin.Proved.ForwardProgram α paramShapes inShape outShape) (params : TorchLean.TensorPack α paramShapes) (x : TorchLean.Tensor α inShape) : NN.Verification.Builtin.runForwardIR (NN.Verification.Builtin.Proved.lowerForwardProgramToIR p params) x = NN.Verification.Builtin.Proved.evalForward p params x
theorem NN.Verification.Builtin.Proved.Correctness.runForwardIR_eq_evalForward {α : Type} [TorchLean.Storage α] [Context α] {paramShapes : List Spec.Shape} {inShape outShape : Spec.Shape} (p : NN.Verification.Builtin.Proved.ForwardProgram α paramShapes inShape outShape) (params : TorchLean.TensorPack α paramShapes) (x : TorchLean.Tensor α inShape) : NN.Verification.Builtin.runForwardIR (NN.Verification.Builtin.Proved.lowerForwardProgramToIR p params) x = NN.Verification.Builtin.Proved.evalForward p params x
**Main lowering correctness theorem (verified forward fragment).** In words: lowering a first-order forward program `p` into the verifier IR and then evaluating the lowered graph yields the same output as directly evaluating `p` with `evalForward`.
Induction over the source program relates each lowered step to its matching IR denotation rule.
A topologically sorted supported graph over shape-indexed tensors and ordered real scalars encloses every computed node value when its local semantic and box certificates are sound.
Lean code for Theorem8.5.19●1 theorem
Associated Lean declarations
-
theoremdefined in NN/MLTheory/CROWN/Proofs/GraphCertSoundness/Main.leancomplete
theorem NN.MLTheory.CROWN.Graph.CertSoundness.cert_encloses_semantics (g : NN.MLTheory.CROWN.Graph) (ps : NN.MLTheory.CROWN.Graph.ParamStore ℝ) (cert : Array (Option (NN.MLTheory.CROWN.FlatBox ℝ))) (inputs : Std.HashMap ℕ NN.MLTheory.CROWN.Graph.CertSoundness.Val) (vals : Array (Option NN.MLTheory.CROWN.Graph.CertSoundness.Val)) (htopo : NN.MLTheory.CROWN.Graph.CertSoundness.TopoSorted g) (hsupp : NN.MLTheory.CROWN.Graph.CertSoundness.Supported g) (hcert : NN.MLTheory.CROWN.Graph.CertSoundness.CertLocalOK g ps cert) (hsem : NN.MLTheory.CROWN.Graph.CertSoundness.SemLocalOK g ps inputs vals) (hinputs : NN.MLTheory.CROWN.Graph.CertSoundness.InputsEnclosed g ps inputs) (id : ℕ) : id < g.nodes.size → match cert[id]!, vals[id]! with | some B, some v => NN.MLTheory.CROWN.Graph.CertSoundness.EnclosesBox B v | x, x_1 => True
theorem NN.MLTheory.CROWN.Graph.CertSoundness.cert_encloses_semantics (g : NN.MLTheory.CROWN.Graph) (ps : NN.MLTheory.CROWN.Graph.ParamStore ℝ) (cert : Array (Option (NN.MLTheory.CROWN.FlatBox ℝ))) (inputs : Std.HashMap ℕ NN.MLTheory.CROWN.Graph.CertSoundness.Val) (vals : Array (Option NN.MLTheory.CROWN.Graph.CertSoundness.Val)) (htopo : NN.MLTheory.CROWN.Graph.CertSoundness.TopoSorted g) (hsupp : NN.MLTheory.CROWN.Graph.CertSoundness.Supported g) (hcert : NN.MLTheory.CROWN.Graph.CertSoundness.CertLocalOK g ps cert) (hsem : NN.MLTheory.CROWN.Graph.CertSoundness.SemLocalOK g ps inputs vals) (hinputs : NN.MLTheory.CROWN.Graph.CertSoundness.InputsEnclosed g ps inputs) (id : ℕ) : id < g.nodes.size → match cert[id]!, vals[id]! with | some B, some v => NN.MLTheory.CROWN.Graph.CertSoundness.EnclosesBox B v | x, x_1 => True
Enclosure of every certified node box around the corresponding semantic value. The conclusion matches on `cert[id]!` and `vals[id]!` and is trivially true when either entry is missing. This shape is kept because downstream files instantiate it directly with the runtime arrays produced by `runIBP?` and the evaluator, where presence of an entry is not known up front. See `cert_encloses_semantics_of_some` for the explicitly quantified form.
Topological induction follows the graph's tensor values and applies each local enclosure result using the order from the real scalar setting.
The proof-side real runIBP? pass supplies the certificates required by
the local soundness theorem, so on a topologically sorted
supported graph with enclosed inputs every box it produces encloses the value computed by the
recursive evaluator evalGraphRec.
Lean code for Theorem8.5.20●1 theorem
Associated Lean declarations
-
theoremdefined in NN/MLTheory/CROWN/Proofs/GraphRunibpEndToEnd.leancomplete
theorem NN.MLTheory.CROWN.Graph.CertSoundness.runIBP?_encloses_evalGraphRec (g : NN.MLTheory.CROWN.Graph) (ps : NN.MLTheory.CROWN.Graph.ParamStore ℝ) (inputs : Std.HashMap ℕ NN.MLTheory.CROWN.Graph.CertSoundness.Val) (htopo : NN.MLTheory.CROWN.Graph.CertSoundness.TopoSorted g) (hsupp : NN.MLTheory.CROWN.Graph.CertSoundness.Supported g) (hinputs : NN.MLTheory.CROWN.Graph.CertSoundness.InputsEnclosed g ps inputs) (id : ℕ) : id < g.nodes.size → match (NN.MLTheory.CROWN.Graph.CertSoundness.runIBP? g ps)[id]!, (NN.MLTheory.CROWN.Graph.CertSoundness.evalGraphRec g ps inputs)[id]! with | some B, some v => NN.MLTheory.CROWN.Graph.CertSoundness.EnclosesBox B v | x, x_1 => True
theorem NN.MLTheory.CROWN.Graph.CertSoundness.runIBP?_encloses_evalGraphRec (g : NN.MLTheory.CROWN.Graph) (ps : NN.MLTheory.CROWN.Graph.ParamStore ℝ) (inputs : Std.HashMap ℕ NN.MLTheory.CROWN.Graph.CertSoundness.Val) (htopo : NN.MLTheory.CROWN.Graph.CertSoundness.TopoSorted g) (hsupp : NN.MLTheory.CROWN.Graph.CertSoundness.Supported g) (hinputs : NN.MLTheory.CROWN.Graph.CertSoundness.InputsEnclosed g ps inputs) (id : ℕ) : id < g.nodes.size → match (NN.MLTheory.CROWN.Graph.CertSoundness.runIBP? g ps)[id]!, (NN.MLTheory.CROWN.Graph.CertSoundness.evalGraphRec g ps inputs)[id]! with | some B, some v => NN.MLTheory.CROWN.Graph.CertSoundness.EnclosesBox B v | x, x_1 => True
The pass is shown to produce the local certificates required by the generic soundness theorem.
On graphs whose nodes are all in EngineCore (input, constant, detach, addition, subtraction,
elementwise multiplication, ReLU, linear, matrix multiplication, softplus, and safe logarithm),
when the semantic guard accepts the graph and the proof-side pass produced a box at every node
(IBPCovers), the
executable engine's runIBP computes exactly the proof-side runIBP?. Coverage rules out the
engine's default-box path at a missing parent.
The Option entries matter here. some box supplies an enclosure candidate, while none records
an absent result. A fallback value in an executable array access is not evidence that the missing
parent was enclosed. IBPCovers ensures that the engine reads boxes actually produced by the
proved pass at every node needed by this correspondence.
Lean code for Theorem8.5.21●1 theorem
Associated Lean declarations
-
theoremdefined in NN/MLTheory/CROWN/Proofs/GraphRunibpEndToEnd.leancomplete
theorem NN.MLTheory.CROWN.Graph.CertSoundness.runIBP_eq_runIBP? (g : NN.MLTheory.CROWN.Graph) (ps : NN.MLTheory.CROWN.Graph.ParamStore ℝ) (htopo : NN.MLTheory.CROWN.Graph.CertSoundness.TopoSorted g) (hcore : NN.MLTheory.CROWN.Graph.CertSoundness.EngineCore g) (hguard : g.crownGraphSemanticsSupported ps = true) (hcov : NN.MLTheory.CROWN.Graph.CertSoundness.IBPCovers g (NN.MLTheory.CROWN.Graph.CertSoundness.runIBP? g ps)) : g.runIBP ps = NN.MLTheory.CROWN.Graph.CertSoundness.runIBP? g ps
theorem NN.MLTheory.CROWN.Graph.CertSoundness.runIBP_eq_runIBP? (g : NN.MLTheory.CROWN.Graph) (ps : NN.MLTheory.CROWN.Graph.ParamStore ℝ) (htopo : NN.MLTheory.CROWN.Graph.CertSoundness.TopoSorted g) (hcore : NN.MLTheory.CROWN.Graph.CertSoundness.EngineCore g) (hguard : g.crownGraphSemanticsSupported ps = true) (hcov : NN.MLTheory.CROWN.Graph.CertSoundness.IBPCovers g (NN.MLTheory.CROWN.Graph.CertSoundness.runIBP? g ps)) : g.runIBP ps = NN.MLTheory.CROWN.Graph.CertSoundness.runIBP? g ps
The engine's `runIBP` computes exactly the proof-side `runIBP?` on engine-core graphs, provided the semantic guard accepts the graph and the proof-side pass produced a box at every node. Coverage is needed because `propagateIBPNode` reads parents with `get!`: at a node whose parent box is missing, the engine would compute from a default box while `certStepNode?` returns `none`.
Induction over the node prefix: on each EngineCore kind the engine step and the proof-side step
compute the same box once their parents agree.
Under TopoSorted, EngineCore, IBPCovers, and InputsEnclosed, every box produced by the
executable runIBP over ℝ encloses the matching value of evalGraphRec. The theorem covers the
executable IBP engine at the real scalar. Transcendental node kinds outside EngineCore and
floating-point rounding require separate results.
Lean code for Theorem8.5.22●1 theorem
Associated Lean declarations
-
theoremdefined in NN/MLTheory/CROWN/Proofs/GraphRunibpEndToEnd.leancomplete
theorem NN.MLTheory.CROWN.Graph.CertSoundness.runIBP_encloses_evalGraphRec (g : NN.MLTheory.CROWN.Graph) (ps : NN.MLTheory.CROWN.Graph.ParamStore ℝ) (inputs : Std.HashMap ℕ NN.MLTheory.CROWN.Graph.CertSoundness.Val) (htopo : NN.MLTheory.CROWN.Graph.CertSoundness.TopoSorted g) (hcore : NN.MLTheory.CROWN.Graph.CertSoundness.EngineCore g) (hcov : NN.MLTheory.CROWN.Graph.CertSoundness.IBPCovers g (NN.MLTheory.CROWN.Graph.CertSoundness.runIBP? g ps)) (hinputs : NN.MLTheory.CROWN.Graph.CertSoundness.InputsEnclosed g ps inputs) (id : ℕ) : id < g.nodes.size → ∀ (B : NN.MLTheory.CROWN.FlatBox ℝ) (v : NN.MLTheory.CROWN.Graph.CertSoundness.Val), (g.runIBP ps)[id]! = some B → (NN.MLTheory.CROWN.Graph.CertSoundness.evalGraphRec g ps inputs)[id]! = some v → NN.MLTheory.CROWN.Graph.CertSoundness.EnclosesBox B v
theorem NN.MLTheory.CROWN.Graph.CertSoundness.runIBP_encloses_evalGraphRec (g : NN.MLTheory.CROWN.Graph) (ps : NN.MLTheory.CROWN.Graph.ParamStore ℝ) (inputs : Std.HashMap ℕ NN.MLTheory.CROWN.Graph.CertSoundness.Val) (htopo : NN.MLTheory.CROWN.Graph.CertSoundness.TopoSorted g) (hcore : NN.MLTheory.CROWN.Graph.CertSoundness.EngineCore g) (hcov : NN.MLTheory.CROWN.Graph.CertSoundness.IBPCovers g (NN.MLTheory.CROWN.Graph.CertSoundness.runIBP? g ps)) (hinputs : NN.MLTheory.CROWN.Graph.CertSoundness.InputsEnclosed g ps inputs) (id : ℕ) : id < g.nodes.size → ∀ (B : NN.MLTheory.CROWN.FlatBox ℝ) (v : NN.MLTheory.CROWN.Graph.CertSoundness.Val), (g.runIBP ps)[id]! = some B → (NN.MLTheory.CROWN.Graph.CertSoundness.evalGraphRec g ps inputs)[id]! = some v → NN.MLTheory.CROWN.Graph.CertSoundness.EnclosesBox B v
End-to-end soundness of the engine's IBP pass: every box computed by `runIBP` encloses the value computed by the total evaluator `evalGraphRec` at the same node. The statement quantifies over node ids at which the engine produced a box `B` and the evaluator a value `v`, so it cannot hold through a missing entry. The semantic guard needs no hypothesis: if `crownGraphSemanticsSupported` rejects the graph, `runIBP` produces no boxes and there is nothing to prove. Coverage of the proof-side pass is needed for the reason given at `runIBP_eq_runIBP?`.
For the bridged node kinds, when the IR payload matches the CROWN parameter store and the IR input is lifted to the CROWN input map, a successful step of the IR node evaluator equals the CROWN node evaluator on the lifted value table. Linear nodes additionally require vector-shaped parents. This is the per-node link between the shared IR semantics and the graph semantics that the bound theorems above are stated against.
Lean code for Theorem8.5.23●1 theorem
Associated Lean declarations
-
theoremdefined in NN/MLTheory/CROWN/Proofs/GraphRuntimeBridge.leancomplete
theorem NN.MLTheory.CROWN.Graph.CertSoundness.evalNode_bridge (nodes : Array NN.MLTheory.CROWN.Graph.Node) (payload : NN.IR.Payload ℝ) (ps : NN.MLTheory.CROWN.Graph.ParamStore ℝ) (input : Spec.SomeTensor ℝ) (inputs : Std.HashMap ℕ NN.MLTheory.CROWN.Graph.CertSoundness.Val) (rvals : Array (Spec.SomeTensor ℝ)) (i : ℕ) (n : NN.MLTheory.CROWN.Graph.Node) (t : Spec.SomeTensor ℝ) (hps : NN.MLTheory.CROWN.Graph.CertSoundness.PayloadMatches payload ps) (hin : NN.MLTheory.CROWN.Graph.CertSoundness.InputsLift nodes input inputs) (hi : i < nodes.size) (hn : nodes[i]! = n) (hid : n.id = i) (hkind : NN.MLTheory.CROWN.Graph.CertSoundness.Bridged n.kind) (hvec : n.kind = NN.IR.OpKind.linear → ∀ p ∈ n.parents, ∀ (r : Spec.SomeTensor ℝ), rvals[p]? = some r → NN.MLTheory.CROWN.Graph.CertSoundness.IsVector r) (heval : NN.IR.Graph.evalNode payload input rvals i n = Except.ok t) : NN.MLTheory.CROWN.Graph.CertSoundness.evalNode? nodes ps inputs (NN.MLTheory.CROWN.Graph.CertSoundness.liftVals rvals) i = some (NN.MLTheory.CROWN.Graph.CertSoundness.flatOfSome t)
theorem NN.MLTheory.CROWN.Graph.CertSoundness.evalNode_bridge (nodes : Array NN.MLTheory.CROWN.Graph.Node) (payload : NN.IR.Payload ℝ) (ps : NN.MLTheory.CROWN.Graph.ParamStore ℝ) (input : Spec.SomeTensor ℝ) (inputs : Std.HashMap ℕ NN.MLTheory.CROWN.Graph.CertSoundness.Val) (rvals : Array (Spec.SomeTensor ℝ)) (i : ℕ) (n : NN.MLTheory.CROWN.Graph.Node) (t : Spec.SomeTensor ℝ) (hps : NN.MLTheory.CROWN.Graph.CertSoundness.PayloadMatches payload ps) (hin : NN.MLTheory.CROWN.Graph.CertSoundness.InputsLift nodes input inputs) (hi : i < nodes.size) (hn : nodes[i]! = n) (hid : n.id = i) (hkind : NN.MLTheory.CROWN.Graph.CertSoundness.Bridged n.kind) (hvec : n.kind = NN.IR.OpKind.linear → ∀ p ∈ n.parents, ∀ (r : Spec.SomeTensor ℝ), rvals[p]? = some r → NN.MLTheory.CROWN.Graph.CertSoundness.IsVector r) (heval : NN.IR.Graph.evalNode payload input rvals i n = Except.ok t) : NN.MLTheory.CROWN.Graph.CertSoundness.evalNode? nodes ps inputs (NN.MLTheory.CROWN.Graph.CertSoundness.liftVals rvals) i = some (NN.MLTheory.CROWN.Graph.CertSoundness.flatOfSome t)
A successful runtime evaluation of a bridged node is reproduced by the proof-side semantics on the flattened value table. Hypotheses: the node record `n` sits at index `i` with `n.id = i` (the id discipline that `Graph.denoteAll` checks), the parameter stores agree (`PayloadMatches`), the proof-side inputs are the flattened runtime input (`InputsLift`), the node kind is bridged, and a `linear` node has a vector-shaped parent. The conclusion is exact equality of flat values, so this theorem can be used to establish `SemLocalOK` for the flattened runtime trace.
Case analysis over the bridged operation kinds, unfolding both evaluators and the flattening of shape-tagged tensors to flat values.
An affine transfer implementation satisfies this contract when each backward transfer preserves the represented lower and upper bounds.
Lean code for Definition8.5.24●1 definition
Associated Lean declarations
-
defdefined in NN/MLTheory/CROWN/Proofs/GraphCrownCertSoundness.leancomplete
def NN.MLTheory.CROWN.Graph.CrownCertSoundness.CrownTransferSound (g : NN.MLTheory.CROWN.Graph) (_ps : NN.MLTheory.CROWN.Graph.ParamStore ℝ) (_inputs : Std.HashMap ℕ NN.MLTheory.CROWN.Graph.CertSoundness.Val) (vals : Array (Option NN.MLTheory.CROWN.Graph.CertSoundness.Val)) (ctx : NN.MLTheory.CROWN.Graph.AffineCtx) (x : TorchLean.Tensor ℝ [ctx.inputDim]) (step : Array (Option (NN.MLTheory.CROWN.Graph.FlatAffineBounds ℝ)) → ℕ → Option (NN.MLTheory.CROWN.Graph.FlatAffineBounds ℝ)) (cert : Array (Option (NN.MLTheory.CROWN.Graph.FlatAffineBounds ℝ))) : Prop
def NN.MLTheory.CROWN.Graph.CrownCertSoundness.CrownTransferSound (g : NN.MLTheory.CROWN.Graph) (_ps : NN.MLTheory.CROWN.Graph.ParamStore ℝ) (_inputs : Std.HashMap ℕ NN.MLTheory.CROWN.Graph.CertSoundness.Val) (vals : Array (Option NN.MLTheory.CROWN.Graph.CertSoundness.Val)) (ctx : NN.MLTheory.CROWN.Graph.AffineCtx) (x : TorchLean.Tensor ℝ [ctx.inputDim]) (step : Array (Option (NN.MLTheory.CROWN.Graph.FlatAffineBounds ℝ)) → ℕ → Option (NN.MLTheory.CROWN.Graph.FlatAffineBounds ℝ)) (cert : Array (Option (NN.MLTheory.CROWN.Graph.FlatAffineBounds ℝ))) : Prop
Each node's step rule is sound: parents enclosing their values force the node to enclose its own. This is the assumption a certificate format has to discharge to reuse the checker theorem.
A locally consistent real affine certificate encloses graph semantics when its transfer step
satisfies CrownTransferSound.
Lean code for Theorem8.5.25●1 theorem
Associated Lean declarations
-
theoremdefined in NN/MLTheory/CROWN/Proofs/GraphCrownCertSoundness.leancomplete
theorem NN.MLTheory.CROWN.Graph.CrownCertSoundness.crown_checker_encloses_semantics (g : NN.MLTheory.CROWN.Graph) (ps : NN.MLTheory.CROWN.Graph.ParamStore ℝ) (step : Array (Option (NN.MLTheory.CROWN.Graph.FlatAffineBounds ℝ)) → ℕ → Option (NN.MLTheory.CROWN.Graph.FlatAffineBounds ℝ)) (cert : Array (Option (NN.MLTheory.CROWN.Graph.FlatAffineBounds ℝ))) (inputs : Std.HashMap ℕ NN.MLTheory.CROWN.Graph.CertSoundness.Val) (vals : Array (Option NN.MLTheory.CROWN.Graph.CertSoundness.Val)) (ctx : NN.MLTheory.CROWN.Graph.AffineCtx) (x : TorchLean.Tensor ℝ [ctx.inputDim]) (htopo : NN.MLTheory.CROWN.Graph.CertSoundness.TopoSorted g) (hsem : NN.MLTheory.CROWN.Graph.CertSoundness.SemLocalOK g ps inputs vals) (hcert : NN.MLTheory.CROWN.Graph.CrownCertSoundness.CrownCertLocalOK g step cert) (hsound : NN.MLTheory.CROWN.Graph.CrownCertSoundness.CrownTransferSound g ps inputs vals ctx x step cert) (id : ℕ) : id < g.nodes.size → ∀ (b : NN.MLTheory.CROWN.Graph.FlatAffineBounds ℝ) (v : NN.MLTheory.CROWN.Graph.CertSoundness.Val), cert[id]! = some b → vals[id]! = some v → NN.MLTheory.CROWN.Graph.CrownCertSoundness.EnclosesAtInput ctx x b v
theorem NN.MLTheory.CROWN.Graph.CrownCertSoundness.crown_checker_encloses_semantics (g : NN.MLTheory.CROWN.Graph) (ps : NN.MLTheory.CROWN.Graph.ParamStore ℝ) (step : Array (Option (NN.MLTheory.CROWN.Graph.FlatAffineBounds ℝ)) → ℕ → Option (NN.MLTheory.CROWN.Graph.FlatAffineBounds ℝ)) (cert : Array (Option (NN.MLTheory.CROWN.Graph.FlatAffineBounds ℝ))) (inputs : Std.HashMap ℕ NN.MLTheory.CROWN.Graph.CertSoundness.Val) (vals : Array (Option NN.MLTheory.CROWN.Graph.CertSoundness.Val)) (ctx : NN.MLTheory.CROWN.Graph.AffineCtx) (x : TorchLean.Tensor ℝ [ctx.inputDim]) (htopo : NN.MLTheory.CROWN.Graph.CertSoundness.TopoSorted g) (hsem : NN.MLTheory.CROWN.Graph.CertSoundness.SemLocalOK g ps inputs vals) (hcert : NN.MLTheory.CROWN.Graph.CrownCertSoundness.CrownCertLocalOK g step cert) (hsound : NN.MLTheory.CROWN.Graph.CrownCertSoundness.CrownTransferSound g ps inputs vals ctx x step cert) (id : ℕ) : id < g.nodes.size → ∀ (b : NN.MLTheory.CROWN.Graph.FlatAffineBounds ℝ) (v : NN.MLTheory.CROWN.Graph.CertSoundness.Val), cert[id]! = some b → vals[id]! = some v → NN.MLTheory.CROWN.Graph.CrownCertSoundness.EnclosesAtInput ctx x b v
Wherever both a certificate entry and a semantic value are present, the entry encloses the value. This is the partial form of the main theorem: it says nothing about nodes the checker skipped, which is exactly why `crown_checker_encloses_all_nodes` below also takes a coverage hypothesis.
Reverse topological induction composes the certified affine forms and discharges each node with the transfer-soundness premise.
On a topologically sorted graph with locally consistent semantic values, matching inputs,
enclosing IBP boxes, and valid slopes (AlphaOK), the concrete real α-CROWN transfer step satisfies
the generic transfer contract.
For the supplied α vectors, AlphaOK requires each component to lie between zero and one. These
are admissible slopes for the relaxation; the theorem does not ask how the slopes were selected.
An optimizer can search for tighter bounds while this local condition remains the same proof
obligation for every candidate.
Lean code for Theorem8.5.26●1 theorem
Associated Lean declarations
-
theoremdefined in NN/MLTheory/CROWN/Proofs/GraphAlphaCrownTransferSoundness/Alpha.leancomplete
theorem NN.MLTheory.CROWN.Graph.AlphaCrownTransferSoundness.alphaCrown_transfer_sound (g : NN.MLTheory.CROWN.Graph) (ps : NN.MLTheory.CROWN.Graph.ParamStore ℝ) (ibp : Array (Option (NN.MLTheory.CROWN.FlatBox ℝ))) (alpha : Array (Option (NN.MLTheory.CROWN.Graph.FlatTensor ℝ))) (cert : Array (Option (NN.MLTheory.CROWN.Graph.FlatAffineBounds ℝ))) (inputs : Std.HashMap ℕ NN.MLTheory.CROWN.Graph.CertSoundness.Val) (vals : Array (Option NN.MLTheory.CROWN.Graph.CertSoundness.Val)) (ctx : NN.MLTheory.CROWN.Graph.AffineCtx) (x : TorchLean.Tensor ℝ [ctx.inputDim]) (htopo : NN.MLTheory.CROWN.Graph.CertSoundness.TopoSorted g) (hsem : NN.MLTheory.CROWN.Graph.CertSoundness.SemLocalOK g ps inputs vals) (hinputs : NN.MLTheory.CROWN.Graph.AlphaCrownTransferSoundness.InputsMatch inputs ctx x) (hibp : NN.MLTheory.CROWN.Graph.AlphaCrownTransferSoundness.IBPEnclosesVals ibp vals) (halpha : NN.MLTheory.CROWN.Graph.AlphaCrownTransferSoundness.AlphaOK alpha) : NN.MLTheory.CROWN.Graph.CrownCertSoundness.CrownTransferSound g ps inputs vals ctx x (NN.MLTheory.CROWN.Graph.AlphaCrownTransferSoundness.stepAlpha g ps ibp alpha ctx) cert
theorem NN.MLTheory.CROWN.Graph.AlphaCrownTransferSoundness.alphaCrown_transfer_sound (g : NN.MLTheory.CROWN.Graph) (ps : NN.MLTheory.CROWN.Graph.ParamStore ℝ) (ibp : Array (Option (NN.MLTheory.CROWN.FlatBox ℝ))) (alpha : Array (Option (NN.MLTheory.CROWN.Graph.FlatTensor ℝ))) (cert : Array (Option (NN.MLTheory.CROWN.Graph.FlatAffineBounds ℝ))) (inputs : Std.HashMap ℕ NN.MLTheory.CROWN.Graph.CertSoundness.Val) (vals : Array (Option NN.MLTheory.CROWN.Graph.CertSoundness.Val)) (ctx : NN.MLTheory.CROWN.Graph.AffineCtx) (x : TorchLean.Tensor ℝ [ctx.inputDim]) (htopo : NN.MLTheory.CROWN.Graph.CertSoundness.TopoSorted g) (hsem : NN.MLTheory.CROWN.Graph.CertSoundness.SemLocalOK g ps inputs vals) (hinputs : NN.MLTheory.CROWN.Graph.AlphaCrownTransferSoundness.InputsMatch inputs ctx x) (hibp : NN.MLTheory.CROWN.Graph.AlphaCrownTransferSoundness.IBPEnclosesVals ibp vals) (halpha : NN.MLTheory.CROWN.Graph.AlphaCrownTransferSoundness.AlphaOK alpha) : NN.MLTheory.CROWN.Graph.CrownCertSoundness.CrownTransferSound g ps inputs vals ctx x (NN.MLTheory.CROWN.Graph.AlphaCrownTransferSoundness.stepAlpha g ps ibp alpha ctx) cert
Pointwise soundness of the graph-dialect α-CROWN transfer rule. Fix a graph `g`, parameters `ps`, an input point `x`, and a locally consistent value semantics array `vals` (that is, `vals[id]` agrees with evaluating node `id` from its parents' values). Assume: - the designated input node in `inputs` matches `x` (`InputsMatch`), - the IBP boxes `ibp` enclose the semantic values in `vals` (`IBPEnclosesVals`), and - the α parameters are well-formed (`AlphaOK`). Then the concrete step function `alphaCrownStepNode?` satisfies the abstract `CrownTransferSound` requirement: whenever every parent `p` is enclosed by its certificate entry, the current node `id` is enclosed by the step-produced certificate entry as well. This is the key lemma that lets `alphaCrownStepNode?` plug into the generic end-to-end checker theorem in `NN.MLTheory.CROWN.Proofs.GraphCrownCertSoundness`.
The proof checks the affine relaxation chosen for each supported operation against the generic transfer contract.
Under the same graph, semantic, input, box, and slope hypotheses, the α/β-CROWN transfer step satisfies the transfer contract. Unchanged nodes reduce to the α-CROWN transfer theorem.
Lean code for Theorem8.5.27●1 theorem
Associated Lean declarations
-
theoremdefined in NN/MLTheory/CROWN/Proofs/GraphAlphaCrownTransferSoundness/AlphaBeta.leancomplete
theorem NN.MLTheory.CROWN.Graph.AlphaCrownTransferSoundness.alphaBetaCrown_transfer_sound (g : NN.MLTheory.CROWN.Graph) (ps : NN.MLTheory.CROWN.Graph.ParamStore ℝ) (ibp : Array (Option (NN.MLTheory.CROWN.FlatBox ℝ))) (alpha : Array (Option (NN.MLTheory.CROWN.Graph.FlatTensor ℝ))) (beta : Array (Option (Array ℤ))) (cert : Array (Option (NN.MLTheory.CROWN.Graph.FlatAffineBounds ℝ))) (inputs : Std.HashMap ℕ NN.MLTheory.CROWN.Graph.CertSoundness.Val) (vals : Array (Option NN.MLTheory.CROWN.Graph.CertSoundness.Val)) (ctx : NN.MLTheory.CROWN.Graph.AffineCtx) (x : TorchLean.Tensor ℝ [ctx.inputDim]) (htopo : NN.MLTheory.CROWN.Graph.CertSoundness.TopoSorted g) (hsem : NN.MLTheory.CROWN.Graph.CertSoundness.SemLocalOK g ps inputs vals) (hinputs : NN.MLTheory.CROWN.Graph.AlphaCrownTransferSoundness.InputsMatch inputs ctx x) (hibp : NN.MLTheory.CROWN.Graph.AlphaCrownTransferSoundness.IBPEnclosesVals ibp vals) (halpha : NN.MLTheory.CROWN.Graph.AlphaCrownTransferSoundness.AlphaOK alpha) : NN.MLTheory.CROWN.Graph.CrownCertSoundness.CrownTransferSound g ps inputs vals ctx x (NN.MLTheory.CROWN.Graph.AlphaCrownTransferSoundness.stepAlphaBeta g ps ibp alpha beta ctx) cert
theorem NN.MLTheory.CROWN.Graph.AlphaCrownTransferSoundness.alphaBetaCrown_transfer_sound (g : NN.MLTheory.CROWN.Graph) (ps : NN.MLTheory.CROWN.Graph.ParamStore ℝ) (ibp : Array (Option (NN.MLTheory.CROWN.FlatBox ℝ))) (alpha : Array (Option (NN.MLTheory.CROWN.Graph.FlatTensor ℝ))) (beta : Array (Option (Array ℤ))) (cert : Array (Option (NN.MLTheory.CROWN.Graph.FlatAffineBounds ℝ))) (inputs : Std.HashMap ℕ NN.MLTheory.CROWN.Graph.CertSoundness.Val) (vals : Array (Option NN.MLTheory.CROWN.Graph.CertSoundness.Val)) (ctx : NN.MLTheory.CROWN.Graph.AffineCtx) (x : TorchLean.Tensor ℝ [ctx.inputDim]) (htopo : NN.MLTheory.CROWN.Graph.CertSoundness.TopoSorted g) (hsem : NN.MLTheory.CROWN.Graph.CertSoundness.SemLocalOK g ps inputs vals) (hinputs : NN.MLTheory.CROWN.Graph.AlphaCrownTransferSoundness.InputsMatch inputs ctx x) (hibp : NN.MLTheory.CROWN.Graph.AlphaCrownTransferSoundness.IBPEnclosesVals ibp vals) (halpha : NN.MLTheory.CROWN.Graph.AlphaCrownTransferSoundness.AlphaOK alpha) : NN.MLTheory.CROWN.Graph.CrownCertSoundness.CrownTransferSound g ps inputs vals ctx x (NN.MLTheory.CROWN.Graph.AlphaCrownTransferSoundness.stepAlphaBeta g ps ibp alpha beta ctx) cert
Pointwise soundness of the graph-dialect α/β-CROWN transfer rule. This is the β-extended analog of `alphaCrown_transfer_sound`. The step function additionally receives a `beta` array of per-ReLU phase constraints (active, inactive, unstable). At a ReLU node with a β vector, `phaseRelaxVec?` checks each phase against the IBP pre-activation interval via `phaseConsistentScalar?` (inactive needs `u ≤ 0`, active needs `0 ≤ l`) and, if every phase passes, uses the phase's exact affine rule for that unit; an inconsistent phase rejects the step rather than falling back to another relaxation. All other nodes use the α-CROWN rule. What the β relaxation contributes here, and what it does not. Because a phase is accepted only when the IBP interval already implies it, a β vector can never certify a sign that the supplied `ibp` box does not fix on its own; for such stable units the phase rule coincides with the standard relaxation. The theorem therefore establishes two things about β: the exact rules are sound whenever the consistency check passes, and inconsistent phase vectors are rejected. It does not model branch-and-bound split constraints. A split that tightens beyond IBP would have to be reflected in a tighter `ibp` argument, which this theorem takes as given through `IBPEnclosesVals`. The theorem states that this concrete step function satisfies `CrownTransferSound`, and thus can be used as the trusted checker semantics in `crown_checker_encloses_semantics`.
Split constraints are handled directly. The remaining operations reuse the α-CROWN transfer proof.
The transfer theorems assume IBPEnclosesVals: every IBP box present at a node encloses the
semantic value there. On a topologically sorted supported graph with locally consistent boxes and
values and enclosed inputs, that assumption follows from
IBP soundness.
Lean code for Theorem8.5.28●1 theorem
Associated Lean declarations
-
theoremdefined in NN/MLTheory/CROWN/Proofs/GraphAlphaCrownTransferSoundness/EndToEnd.leancomplete
theorem NN.MLTheory.CROWN.Graph.AlphaCrownTransferSoundness.ibp_encloses_vals_of_cert_local_ok (g : NN.MLTheory.CROWN.Graph) (ps : NN.MLTheory.CROWN.Graph.ParamStore ℝ) (ibp : Array (Option (NN.MLTheory.CROWN.FlatBox ℝ))) (inputs : Std.HashMap ℕ NN.MLTheory.CROWN.Graph.CertSoundness.Val) (vals : Array (Option NN.MLTheory.CROWN.Graph.CertSoundness.Val)) (htopo : NN.MLTheory.CROWN.Graph.CertSoundness.TopoSorted g) (hsupp : NN.MLTheory.CROWN.Graph.CertSoundness.Supported g) (hibp : NN.MLTheory.CROWN.Graph.CertSoundness.CertLocalOK g ps ibp) (hsem : NN.MLTheory.CROWN.Graph.CertSoundness.SemLocalOK g ps inputs vals) (hinputs : NN.MLTheory.CROWN.Graph.CertSoundness.InputsEnclosed g ps inputs) : NN.MLTheory.CROWN.Graph.AlphaCrownTransferSoundness.IBPEnclosesVals ibp vals
theorem NN.MLTheory.CROWN.Graph.AlphaCrownTransferSoundness.ibp_encloses_vals_of_cert_local_ok (g : NN.MLTheory.CROWN.Graph) (ps : NN.MLTheory.CROWN.Graph.ParamStore ℝ) (ibp : Array (Option (NN.MLTheory.CROWN.FlatBox ℝ))) (inputs : Std.HashMap ℕ NN.MLTheory.CROWN.Graph.CertSoundness.Val) (vals : Array (Option NN.MLTheory.CROWN.Graph.CertSoundness.Val)) (htopo : NN.MLTheory.CROWN.Graph.CertSoundness.TopoSorted g) (hsupp : NN.MLTheory.CROWN.Graph.CertSoundness.Supported g) (hibp : NN.MLTheory.CROWN.Graph.CertSoundness.CertLocalOK g ps ibp) (hsem : NN.MLTheory.CROWN.Graph.CertSoundness.SemLocalOK g ps inputs vals) (hinputs : NN.MLTheory.CROWN.Graph.CertSoundness.InputsEnclosed g ps inputs) : NN.MLTheory.CROWN.Graph.AlphaCrownTransferSoundness.IBPEnclosesVals ibp vals
A locally consistent IBP certificate encloses every locally consistent semantic interpretation. This is `CertSoundness.cert_encloses_semantics` repackaged in the shape the α-CROWN transfer theorems expect. The hypotheses are exactly those of the IBP theorem: the graph is topologically sorted and uses only supported ops, the IBP boxes replay the checker step at every node, the values replay the evaluator at every node, and the input values lie inside their seed boxes.
The IBP theorem is repackaged in the shape the transfer theorems expect.
On a topologically sorted supported graph, given locally consistent IBP boxes and values, enclosed
inputs, an input matching the affine context, valid slopes (AlphaOK), and an affine certificate
that replays the α-CROWN step (CrownCertLocalOK), every certificate entry encloses the matching
semantic value at the input. Unlike the transfer theorem, no IBPEnclosesVals hypothesis remains.
Lean code for Theorem8.5.29●1 theorem
Associated Lean declarations
-
theoremdefined in NN/MLTheory/CROWN/Proofs/GraphAlphaCrownTransferSoundness/EndToEnd.leancomplete
theorem NN.MLTheory.CROWN.Graph.AlphaCrownTransferSoundness.alphaCrown_cert_encloses_semantics (g : NN.MLTheory.CROWN.Graph) (ps : NN.MLTheory.CROWN.Graph.ParamStore ℝ) (ibp : Array (Option (NN.MLTheory.CROWN.FlatBox ℝ))) (alpha : Array (Option (NN.MLTheory.CROWN.Graph.FlatTensor ℝ))) (cert : Array (Option (NN.MLTheory.CROWN.Graph.FlatAffineBounds ℝ))) (inputs : Std.HashMap ℕ NN.MLTheory.CROWN.Graph.CertSoundness.Val) (vals : Array (Option NN.MLTheory.CROWN.Graph.CertSoundness.Val)) (ctx : NN.MLTheory.CROWN.Graph.AffineCtx) (x : TorchLean.Tensor ℝ [ctx.inputDim]) (htopo : NN.MLTheory.CROWN.Graph.CertSoundness.TopoSorted g) (hsupp : NN.MLTheory.CROWN.Graph.CertSoundness.Supported g) (hibp : NN.MLTheory.CROWN.Graph.CertSoundness.CertLocalOK g ps ibp) (hsem : NN.MLTheory.CROWN.Graph.CertSoundness.SemLocalOK g ps inputs vals) (hinputsEnc : NN.MLTheory.CROWN.Graph.CertSoundness.InputsEnclosed g ps inputs) (hinputs : NN.MLTheory.CROWN.Graph.AlphaCrownTransferSoundness.InputsMatch inputs ctx x) (halpha : NN.MLTheory.CROWN.Graph.AlphaCrownTransferSoundness.AlphaOK alpha) (hcert : NN.MLTheory.CROWN.Graph.CrownCertSoundness.CrownCertLocalOK g (NN.MLTheory.CROWN.Graph.AlphaCrownTransferSoundness.stepAlpha g ps ibp alpha ctx) cert) (id : ℕ) : id < g.nodes.size → ∀ (b : NN.MLTheory.CROWN.Graph.FlatAffineBounds ℝ) (v : NN.MLTheory.CROWN.Graph.CertSoundness.Val), cert[id]! = some b → vals[id]! = some v → NN.MLTheory.CROWN.Graph.CrownCertSoundness.EnclosesAtInput ctx x b v
theorem NN.MLTheory.CROWN.Graph.AlphaCrownTransferSoundness.alphaCrown_cert_encloses_semantics (g : NN.MLTheory.CROWN.Graph) (ps : NN.MLTheory.CROWN.Graph.ParamStore ℝ) (ibp : Array (Option (NN.MLTheory.CROWN.FlatBox ℝ))) (alpha : Array (Option (NN.MLTheory.CROWN.Graph.FlatTensor ℝ))) (cert : Array (Option (NN.MLTheory.CROWN.Graph.FlatAffineBounds ℝ))) (inputs : Std.HashMap ℕ NN.MLTheory.CROWN.Graph.CertSoundness.Val) (vals : Array (Option NN.MLTheory.CROWN.Graph.CertSoundness.Val)) (ctx : NN.MLTheory.CROWN.Graph.AffineCtx) (x : TorchLean.Tensor ℝ [ctx.inputDim]) (htopo : NN.MLTheory.CROWN.Graph.CertSoundness.TopoSorted g) (hsupp : NN.MLTheory.CROWN.Graph.CertSoundness.Supported g) (hibp : NN.MLTheory.CROWN.Graph.CertSoundness.CertLocalOK g ps ibp) (hsem : NN.MLTheory.CROWN.Graph.CertSoundness.SemLocalOK g ps inputs vals) (hinputsEnc : NN.MLTheory.CROWN.Graph.CertSoundness.InputsEnclosed g ps inputs) (hinputs : NN.MLTheory.CROWN.Graph.AlphaCrownTransferSoundness.InputsMatch inputs ctx x) (halpha : NN.MLTheory.CROWN.Graph.AlphaCrownTransferSoundness.AlphaOK alpha) (hcert : NN.MLTheory.CROWN.Graph.CrownCertSoundness.CrownCertLocalOK g (NN.MLTheory.CROWN.Graph.AlphaCrownTransferSoundness.stepAlpha g ps ibp alpha ctx) cert) (id : ℕ) : id < g.nodes.size → ∀ (b : NN.MLTheory.CROWN.Graph.FlatAffineBounds ℝ) (v : NN.MLTheory.CROWN.Graph.CertSoundness.Val), cert[id]! = some b → vals[id]! = some v → NN.MLTheory.CROWN.Graph.CrownCertSoundness.EnclosesAtInput ctx x b v
A locally replayed α-CROWN certificate encloses every corresponding graph value, with the IBP boxes justified rather than assumed. Compared with `alphaCrown_transfer_sound`, the hypothesis `IBPEnclosesVals` is replaced by the IBP-side hypotheses `Supported g`, `CertLocalOK g ps ibp`, and `InputsEnclosed g ps inputs`. The conclusion is stated for every node id at which the certificate has an entry `b` and the semantics has a value `v`; a node missing either one carries no claim.
The generic checker theorem is applied with the α-CROWN transfer, whose IBP hypothesis is discharged by the enclosure lemma.
When the IBP boxes are the proof-side runIBP? g ps and the values are evalGraphRec g ps inputs,
the α-CROWN certificate encloses the semantics under only TopoSorted, Supported, the input
conditions, AlphaOK, and CrownCertLocalOK. The local-consistency hypotheses on boxes and values
are discharged by the definitions of the two passes.
The conclusion quantifies over a node index, a stored affine bound, and a semantic value. The
premises saying that the corresponding entries are some b and some v identify which records
the enclosure relates. To apply the result to a model output, one supplies its node index and
these lookup equalities, then evaluates the affine bound at the chosen enclosed input.
Lean code for Theorem8.5.30●1 theorem
Associated Lean declarations
-
theoremdefined in NN/MLTheory/CROWN/Proofs/GraphAlphaCrownTransferSoundness/EndToEnd.leancomplete
theorem NN.MLTheory.CROWN.Graph.AlphaCrownTransferSoundness.alphaCrown_cert_encloses_evalGraphRec (g : NN.MLTheory.CROWN.Graph) (ps : NN.MLTheory.CROWN.Graph.ParamStore ℝ) (alpha : Array (Option (NN.MLTheory.CROWN.Graph.FlatTensor ℝ))) (cert : Array (Option (NN.MLTheory.CROWN.Graph.FlatAffineBounds ℝ))) (inputs : Std.HashMap ℕ NN.MLTheory.CROWN.Graph.CertSoundness.Val) (ctx : NN.MLTheory.CROWN.Graph.AffineCtx) (x : TorchLean.Tensor ℝ [ctx.inputDim]) (htopo : NN.MLTheory.CROWN.Graph.CertSoundness.TopoSorted g) (hsupp : NN.MLTheory.CROWN.Graph.CertSoundness.Supported g) (hinputsEnc : NN.MLTheory.CROWN.Graph.CertSoundness.InputsEnclosed g ps inputs) (hinputs : NN.MLTheory.CROWN.Graph.AlphaCrownTransferSoundness.InputsMatch inputs ctx x) (halpha : NN.MLTheory.CROWN.Graph.AlphaCrownTransferSoundness.AlphaOK alpha) (hcert : NN.MLTheory.CROWN.Graph.CrownCertSoundness.CrownCertLocalOK g (NN.MLTheory.CROWN.Graph.AlphaCrownTransferSoundness.stepAlpha g ps (NN.MLTheory.CROWN.Graph.CertSoundness.runIBP? g ps) alpha ctx) cert) (id : ℕ) : id < g.nodes.size → ∀ (b : NN.MLTheory.CROWN.Graph.FlatAffineBounds ℝ) (v : NN.MLTheory.CROWN.Graph.CertSoundness.Val), cert[id]! = some b → (NN.MLTheory.CROWN.Graph.CertSoundness.evalGraphRec g ps inputs)[id]! = some v → NN.MLTheory.CROWN.Graph.CrownCertSoundness.EnclosesAtInput ctx x b v
theorem NN.MLTheory.CROWN.Graph.AlphaCrownTransferSoundness.alphaCrown_cert_encloses_evalGraphRec (g : NN.MLTheory.CROWN.Graph) (ps : NN.MLTheory.CROWN.Graph.ParamStore ℝ) (alpha : Array (Option (NN.MLTheory.CROWN.Graph.FlatTensor ℝ))) (cert : Array (Option (NN.MLTheory.CROWN.Graph.FlatAffineBounds ℝ))) (inputs : Std.HashMap ℕ NN.MLTheory.CROWN.Graph.CertSoundness.Val) (ctx : NN.MLTheory.CROWN.Graph.AffineCtx) (x : TorchLean.Tensor ℝ [ctx.inputDim]) (htopo : NN.MLTheory.CROWN.Graph.CertSoundness.TopoSorted g) (hsupp : NN.MLTheory.CROWN.Graph.CertSoundness.Supported g) (hinputsEnc : NN.MLTheory.CROWN.Graph.CertSoundness.InputsEnclosed g ps inputs) (hinputs : NN.MLTheory.CROWN.Graph.AlphaCrownTransferSoundness.InputsMatch inputs ctx x) (halpha : NN.MLTheory.CROWN.Graph.AlphaCrownTransferSoundness.AlphaOK alpha) (hcert : NN.MLTheory.CROWN.Graph.CrownCertSoundness.CrownCertLocalOK g (NN.MLTheory.CROWN.Graph.AlphaCrownTransferSoundness.stepAlpha g ps (NN.MLTheory.CROWN.Graph.CertSoundness.runIBP? g ps) alpha ctx) cert) (id : ℕ) : id < g.nodes.size → ∀ (b : NN.MLTheory.CROWN.Graph.FlatAffineBounds ℝ) (v : NN.MLTheory.CROWN.Graph.CertSoundness.Val), cert[id]! = some b → (NN.MLTheory.CROWN.Graph.CertSoundness.evalGraphRec g ps inputs)[id]! = some v → NN.MLTheory.CROWN.Graph.CrownCertSoundness.EnclosesAtInput ctx x b v
α-CROWN enclosure against the total IBP pass and the total evaluator. Here the IBP boxes are `runIBP? g ps` and the values are `evalGraphRec g ps inputs`, so the only remaining hypotheses about the graph are `TopoSorted`, `Supported`, and the input conditions.
The α-CROWN corollary with the local-consistency lemmas for
runIBP? and evalGraphRec, the same lemmas that drive
the IBP end-to-end theorem.
The α/β-CROWN analogue of the α-CROWN corollary: with a branch
vector beta and a certificate replaying the α/β step, every certificate entry encloses the
semantic value, with the IBP enclosure hypothesis discharged rather than assumed.
Lean code for Theorem8.5.31●1 theorem
Associated Lean declarations
-
theoremdefined in NN/MLTheory/CROWN/Proofs/GraphAlphaCrownTransferSoundness/EndToEnd.leancomplete
theorem NN.MLTheory.CROWN.Graph.AlphaCrownTransferSoundness.alphaBetaCrown_cert_encloses_semantics' (g : NN.MLTheory.CROWN.Graph) (ps : NN.MLTheory.CROWN.Graph.ParamStore ℝ) (ibp : Array (Option (NN.MLTheory.CROWN.FlatBox ℝ))) (alpha : Array (Option (NN.MLTheory.CROWN.Graph.FlatTensor ℝ))) (beta : Array (Option (Array ℤ))) (cert : Array (Option (NN.MLTheory.CROWN.Graph.FlatAffineBounds ℝ))) (inputs : Std.HashMap ℕ NN.MLTheory.CROWN.Graph.CertSoundness.Val) (vals : Array (Option NN.MLTheory.CROWN.Graph.CertSoundness.Val)) (ctx : NN.MLTheory.CROWN.Graph.AffineCtx) (x : TorchLean.Tensor ℝ [ctx.inputDim]) (htopo : NN.MLTheory.CROWN.Graph.CertSoundness.TopoSorted g) (hsupp : NN.MLTheory.CROWN.Graph.CertSoundness.Supported g) (hibp : NN.MLTheory.CROWN.Graph.CertSoundness.CertLocalOK g ps ibp) (hsem : NN.MLTheory.CROWN.Graph.CertSoundness.SemLocalOK g ps inputs vals) (hinputsEnc : NN.MLTheory.CROWN.Graph.CertSoundness.InputsEnclosed g ps inputs) (hinputs : NN.MLTheory.CROWN.Graph.AlphaCrownTransferSoundness.InputsMatch inputs ctx x) (halpha : NN.MLTheory.CROWN.Graph.AlphaCrownTransferSoundness.AlphaOK alpha) (hcert : NN.MLTheory.CROWN.Graph.CrownCertSoundness.CrownCertLocalOK g (NN.MLTheory.CROWN.Graph.AlphaCrownTransferSoundness.stepAlphaBeta g ps ibp alpha beta ctx) cert) (id : ℕ) : id < g.nodes.size → ∀ (b : NN.MLTheory.CROWN.Graph.FlatAffineBounds ℝ) (v : NN.MLTheory.CROWN.Graph.CertSoundness.Val), cert[id]! = some b → vals[id]! = some v → NN.MLTheory.CROWN.Graph.CrownCertSoundness.EnclosesAtInput ctx x b v
theorem NN.MLTheory.CROWN.Graph.AlphaCrownTransferSoundness.alphaBetaCrown_cert_encloses_semantics' (g : NN.MLTheory.CROWN.Graph) (ps : NN.MLTheory.CROWN.Graph.ParamStore ℝ) (ibp : Array (Option (NN.MLTheory.CROWN.FlatBox ℝ))) (alpha : Array (Option (NN.MLTheory.CROWN.Graph.FlatTensor ℝ))) (beta : Array (Option (Array ℤ))) (cert : Array (Option (NN.MLTheory.CROWN.Graph.FlatAffineBounds ℝ))) (inputs : Std.HashMap ℕ NN.MLTheory.CROWN.Graph.CertSoundness.Val) (vals : Array (Option NN.MLTheory.CROWN.Graph.CertSoundness.Val)) (ctx : NN.MLTheory.CROWN.Graph.AffineCtx) (x : TorchLean.Tensor ℝ [ctx.inputDim]) (htopo : NN.MLTheory.CROWN.Graph.CertSoundness.TopoSorted g) (hsupp : NN.MLTheory.CROWN.Graph.CertSoundness.Supported g) (hibp : NN.MLTheory.CROWN.Graph.CertSoundness.CertLocalOK g ps ibp) (hsem : NN.MLTheory.CROWN.Graph.CertSoundness.SemLocalOK g ps inputs vals) (hinputsEnc : NN.MLTheory.CROWN.Graph.CertSoundness.InputsEnclosed g ps inputs) (hinputs : NN.MLTheory.CROWN.Graph.AlphaCrownTransferSoundness.InputsMatch inputs ctx x) (halpha : NN.MLTheory.CROWN.Graph.AlphaCrownTransferSoundness.AlphaOK alpha) (hcert : NN.MLTheory.CROWN.Graph.CrownCertSoundness.CrownCertLocalOK g (NN.MLTheory.CROWN.Graph.AlphaCrownTransferSoundness.stepAlphaBeta g ps ibp alpha beta ctx) cert) (id : ℕ) : id < g.nodes.size → ∀ (b : NN.MLTheory.CROWN.Graph.FlatAffineBounds ℝ) (v : NN.MLTheory.CROWN.Graph.CertSoundness.Val), cert[id]! = some b → vals[id]! = some v → NN.MLTheory.CROWN.Graph.CrownCertSoundness.EnclosesAtInput ctx x b v
A locally replayed α/β-CROWN certificate encloses every corresponding graph value, with the IBP boxes justified rather than assumed. This is `alphaBetaCrown_cert_encloses_semantics` with `IBPEnclosesVals` discharged from the IBP soundness theorem; see `alphaCrown_cert_encloses_semantics` for the hypothesis trade.
The α/β transfer theorem composed with the enclosure lemma through the generic checker theorem.
-
NN.MLTheory.CROWN.Cert.runAlphaBetaCROWN[complete]
The native fixed-relaxation runner computes IBP bounds, infers stable ReLU phases, and replays the α/β-CROWN affine pass. Unstable phases remain unsplit; this runner does not implement the external optimizer's branch-and-bound search.
Lean code for Definition8.5.32●1 definition
Associated Lean declarations
-
NN.MLTheory.CROWN.Cert.runAlphaBetaCROWN[complete]
-
NN.MLTheory.CROWN.Cert.runAlphaBetaCROWN[complete]
-
defdefined in NN/MLTheory/CROWN/Cert/AlphaBetaCROWN.leancomplete
def NN.MLTheory.CROWN.Cert.runAlphaBetaCROWN {α : Type} [TorchLean.Storage α] [Context α] (g : NN.MLTheory.CROWN.Graph) (ps : NN.MLTheory.CROWN.Graph.ParamStore α) (ctx : NN.MLTheory.CROWN.Graph.AffineCtx) (ibp : Array (Option (NN.MLTheory.CROWN.FlatBox α))) : Array (Option (NN.MLTheory.CROWN.Graph.FlatAffineBounds α))
def NN.MLTheory.CROWN.Cert.runAlphaBetaCROWN {α : Type} [TorchLean.Storage α] [Context α] (g : NN.MLTheory.CROWN.Graph) (ps : NN.MLTheory.CROWN.Graph.ParamStore α) (ctx : NN.MLTheory.CROWN.Graph.AffineCtx) (ibp : Array (Option (NN.MLTheory.CROWN.FlatBox α))) : Array (Option (NN.MLTheory.CROWN.Graph.FlatAffineBounds α))
Run the fixed-relaxation α/β-CROWN graph pass. Stable ReLU phases come from IBP and are checked again by `alphaBetaCrownStepNode?`. Unstable neurons use the default α-CROWN lower relaxation.
The executable checker parses and replays a FloatLib binary32 node certificate. Its final acceptance decision has a proved bridge to the proposition-level local replay condition. Connecting that binary32 condition to the real enclosure in Theorem 8.5.25 still requires the refinement assumptions for the operations in the graph.
Lean code for Definition8.5.33●1 definition
Associated Lean declarations
-
defdefined in NN/Verification/Cert/CROWNNodeCertAlphaBeta.leancomplete
def NN.Verification.CROWNNodeCertAlphaBeta.checkAlphaBetaCROWNNodeCertificate (g : NN.MLTheory.CROWN.Graph) (ps : NN.MLTheory.CROWN.Graph.ParamStore (FloatLib.Floats.ExecFloat.Binary 8 23 FloatLib.Floats.Formats.BinaryInterchange.FloatFormat.Encoding.ieee (FloatLib.Floats.Formats.BinaryInterchange.FloatFormat.Encoding.ieee.defaultBias 8) NN.Verification.CROWNNodeCertAlphaBeta.AlphaBetaCROWNNodeCertificate._proof_1 NN.Verification.CROWNNodeCertAlphaBeta.AlphaBetaCROWNNodeCertificate._proof_2 NN.Verification.CROWNNodeCertAlphaBeta.AlphaBetaCROWNNodeCertificate._proof_3 NN.Verification.CROWNNodeCertAlphaBeta.AlphaBetaCROWNNodeCertificate._proof_4)) (path : String) : IO Bool
def NN.Verification.CROWNNodeCertAlphaBeta.checkAlphaBetaCROWNNodeCertificate (g : NN.MLTheory.CROWN.Graph) (ps : NN.MLTheory.CROWN.Graph.ParamStore (FloatLib.Floats.ExecFloat.Binary 8 23 FloatLib.Floats.Formats.BinaryInterchange.FloatFormat.Encoding.ieee (FloatLib.Floats.Formats.BinaryInterchange.FloatFormat.Encoding.ieee.defaultBias 8) NN.Verification.CROWNNodeCertAlphaBeta.AlphaBetaCROWNNodeCertificate._proof_1 NN.Verification.CROWNNodeCertAlphaBeta.AlphaBetaCROWNNodeCertificate._proof_2 NN.Verification.CROWNNodeCertAlphaBeta.AlphaBetaCROWNNodeCertificate._proof_3 NN.Verification.CROWNNodeCertAlphaBeta.AlphaBetaCROWNNodeCertificate._proof_4)) (path : String) : IO Bool
Check a per-node α/β-CROWN certificate against Lean's propagation rules. Returns `true` iff every supplied IBP box contains Lean's authoritative recomputation and every node's affine replay data agrees exactly with Lean's α/β-CROWN step.
Acceptance of the in-memory α/β-CROWN decision implies CrownCertLocalOK for the exact
FloatLib binary32 replay step used by the checker.
Lean code for Theorem8.5.34●1 theorem
Associated Lean declarations
-
theoremdefined in NN/Verification/Cert/CROWNNodeCertAlphaBeta.leancomplete
theorem NN.Verification.CROWNNodeCertAlphaBeta.AlphaBetaCROWNNodeCertificate.accepts_eq_true (cert : NN.Verification.CROWNNodeCertAlphaBeta.AlphaBetaCROWNNodeCertificate) (g : NN.MLTheory.CROWN.Graph) (ps : NN.MLTheory.CROWN.Graph.ParamStore (FloatLib.Floats.ExecFloat.Binary 8 23 FloatLib.Floats.Formats.BinaryInterchange.FloatFormat.Encoding.ieee (FloatLib.Floats.Formats.BinaryInterchange.FloatFormat.Encoding.ieee.defaultBias 8) NN.Verification.CROWNNodeCertAlphaBeta.AlphaBetaCROWNNodeCertificate._proof_1 NN.Verification.CROWNNodeCertAlphaBeta.AlphaBetaCROWNNodeCertificate._proof_2 NN.Verification.CROWNNodeCertAlphaBeta.AlphaBetaCROWNNodeCertificate._proof_3 NN.Verification.CROWNNodeCertAlphaBeta.AlphaBetaCROWNNodeCertificate._proof_4)) (authoritativeIbp : Array (Option (NN.MLTheory.CROWN.FlatBox (FloatLib.Floats.ExecFloat.Binary 8 23 FloatLib.Floats.Formats.BinaryInterchange.FloatFormat.Encoding.ieee (FloatLib.Floats.Formats.BinaryInterchange.FloatFormat.Encoding.ieee.defaultBias 8) NN.Verification.CROWNNodeCertAlphaBeta.AlphaBetaCROWNNodeCertificate._proof_1 NN.Verification.CROWNNodeCertAlphaBeta.AlphaBetaCROWNNodeCertificate._proof_2 NN.Verification.CROWNNodeCertAlphaBeta.AlphaBetaCROWNNodeCertificate._proof_3 NN.Verification.CROWNNodeCertAlphaBeta.AlphaBetaCROWNNodeCertificate._proof_4)))) (diagnosticsOk : Bool) (haccept : cert.accepts g ps authoritativeIbp diagnosticsOk = true) : NN.MLTheory.CROWN.Graph.CrownCertSoundness.CrownCertLocalOK g (NN.Verification.CROWNNodeCertAlphaBeta.replayStep g ps authoritativeIbp cert) cert.crown
theorem NN.Verification.CROWNNodeCertAlphaBeta.AlphaBetaCROWNNodeCertificate.accepts_eq_true (cert : NN.Verification.CROWNNodeCertAlphaBeta.AlphaBetaCROWNNodeCertificate) (g : NN.MLTheory.CROWN.Graph) (ps : NN.MLTheory.CROWN.Graph.ParamStore (FloatLib.Floats.ExecFloat.Binary 8 23 FloatLib.Floats.Formats.BinaryInterchange.FloatFormat.Encoding.ieee (FloatLib.Floats.Formats.BinaryInterchange.FloatFormat.Encoding.ieee.defaultBias 8) NN.Verification.CROWNNodeCertAlphaBeta.AlphaBetaCROWNNodeCertificate._proof_1 NN.Verification.CROWNNodeCertAlphaBeta.AlphaBetaCROWNNodeCertificate._proof_2 NN.Verification.CROWNNodeCertAlphaBeta.AlphaBetaCROWNNodeCertificate._proof_3 NN.Verification.CROWNNodeCertAlphaBeta.AlphaBetaCROWNNodeCertificate._proof_4)) (authoritativeIbp : Array (Option (NN.MLTheory.CROWN.FlatBox (FloatLib.Floats.ExecFloat.Binary 8 23 FloatLib.Floats.Formats.BinaryInterchange.FloatFormat.Encoding.ieee (FloatLib.Floats.Formats.BinaryInterchange.FloatFormat.Encoding.ieee.defaultBias 8) NN.Verification.CROWNNodeCertAlphaBeta.AlphaBetaCROWNNodeCertificate._proof_1 NN.Verification.CROWNNodeCertAlphaBeta.AlphaBetaCROWNNodeCertificate._proof_2 NN.Verification.CROWNNodeCertAlphaBeta.AlphaBetaCROWNNodeCertificate._proof_3 NN.Verification.CROWNNodeCertAlphaBeta.AlphaBetaCROWNNodeCertificate._proof_4)))) (diagnosticsOk : Bool) (haccept : cert.accepts g ps authoritativeIbp diagnosticsOk = true) : NN.MLTheory.CROWN.Graph.CrownCertSoundness.CrownCertLocalOK g (NN.Verification.CROWNNodeCertAlphaBeta.replayStep g ps authoritativeIbp cert) cert.crown
Acceptance of the concrete α/β-CROWN decision supplies graph-level local consistency.
The checker compares every dependent affine record bit-for-bit. Soundness of the tensor, matrix, affine-vector, and optional-record comparisons turns the successful Boolean replay into equality at every graph node.
The type of accepts_eq_true fixes the graph, parameter store, authoritative IBP array, and
certificate before asking for acceptance. Its result refers to the replay step built from those
same arguments. This prevents a successful check for one parameter store from being reused as a
local-consistency proof for a different checkpoint.
The specification softmax Activation.softmaxSpec 0 on a real vector, which uses the numerically
stable max-shifted form, is Fréchet differentiable after vectorization, with the derivative of the
analytic softmaxVec. The log-softmax kernel has the same theorem.
Lean code for Theorem8.5.35●1 theorem
Associated Lean declarations
-
theoremdefined in NN/Proofs/Autograd/FDeriv/SoftmaxSpec.leancomplete
theorem Proofs.Autograd.hasFDerivAt_softmaxSpec_vec {n : ℕ} (xV : Proofs.Autograd.Vec n) : HasFDerivAt (fun xV => Proofs.Autograd.getScalarE (Activation.softmaxSpec 0 (Proofs.Autograd.ofFnE xV))) (Proofs.Autograd.softmaxDerivCLM xV) xV
theorem Proofs.Autograd.hasFDerivAt_softmaxSpec_vec {n : ℕ} (xV : Proofs.Autograd.Vec n) : HasFDerivAt (fun xV => Proofs.Autograd.getScalarE (Activation.softmaxSpec 0 (Proofs.Autograd.ofFnE xV))) (Proofs.Autograd.softmaxDerivCLM xV) xV
Axis-`0` spec softmax on vectors is Fréchet-differentiable with derivative `softmaxDerivCLM`.
The spec kernel is identified coordinatewise with the analytic softmax; the max shift cancels in the quotient, and the analytic derivative transfers.
This avoids differentiating the maximum itself at tied coordinates. Multiplying every
exponential by the same positive factor leaves the normalized quotient unchanged, so the smooth
analytic function describes the entire shifted implementation, including ties. HasFDerivAt
then records that function, its continuous linear derivative, and the input point where the
claim holds.
The specification backward rule Activation.softmaxBackwardSpec 0 on a real vector is the
vector-Jacobian product of the specification softmax at that point. The same holds for
log-softmax.
Lean code for Theorem8.5.36●1 theorem
Associated Lean declarations
-
theoremdefined in NN/Proofs/Autograd/FDeriv/SoftmaxSpec.leancomplete
theorem Proofs.Autograd.softmaxBackwardSpec_eq_vjp {n : ℕ} (x δ : TorchLean.Tensor ℝ [n]) : Proofs.Autograd.getScalarE (Activation.softmaxBackwardSpec 0 x δ) = (Proofs.Autograd.vjp (fun xV => Proofs.Autograd.getScalarE (Activation.softmaxSpec 0 (Proofs.Autograd.ofFnE xV))) (Proofs.Autograd.getScalarE x)) (Proofs.Autograd.getScalarE δ)
theorem Proofs.Autograd.softmaxBackwardSpec_eq_vjp {n : ℕ} (x δ : TorchLean.Tensor ℝ [n]) : Proofs.Autograd.getScalarE (Activation.softmaxBackwardSpec 0 x δ) = (Proofs.Autograd.vjp (fun xV => Proofs.Autograd.getScalarE (Activation.softmaxSpec 0 (Proofs.Autograd.ofFnE xV))) (Proofs.Autograd.getScalarE x)) (Proofs.Autograd.getScalarE δ)
The spec softmax backward is the vector-Jacobian product of the spec softmax forward.
softmaxFDerivCorrect packages the kernel as an OpSpecFDerivCorrect using
the derivative theorem; its backward_eq_adjoint_fderiv field gives
the identity.
Over ℝ, hard-masked softmax with the all-true Boolean mask equals plain axis-one softmax of the
scores. The two code paths of Spec.scaledDotProductAttention therefore agree wherever both apply.
Lean code for Theorem8.5.37●1 theorem
Associated Lean declarations
-
theoremdefined in NN/Proofs/Models/Attention/HardMask.leancomplete
theorem NN.Proofs.Models.Attention.hardMaskedSoftmaxSpec_allTrueMask {nQ nK : ℕ} (scores : TorchLean.Tensor ℝ [nQ, nK]) : Spec.hardMaskedSoftmaxSpec scores (Spec.allTrueMask nQ nK) = Activation.softmaxSpec 1 scores
theorem NN.Proofs.Models.Attention.hardMaskedSoftmaxSpec_allTrueMask {nQ nK : ℕ} (scores : TorchLean.Tensor ℝ [nQ, nK]) : Spec.hardMaskedSoftmaxSpec scores (Spec.allTrueMask nQ nK) = Activation.softmaxSpec 1 scores
Hard-masked softmax with the all-true mask is the unmasked axis-`1` softmax.
The row scan of the hard mask computes the fold of max over the row, which is the shift used by
the stable softmax; with every position allowed the numerators and denominators coincide.
For a nonempty sequence, the tape reverse pass on the proof-carrying scaled dot-product attention
graph, seeded on the output block, is the adjoint Fréchet derivative of
Spec.scaledDotProductAttention without a mask and with the canonical inverse square-root scale.
A companion theorem covers the masked code path with the all-true mask through
the hard-mask identity.
Lean code for Theorem8.5.38●1 theorem
Associated Lean declarations
-
theoremdefined in NN/Proofs/Autograd/Tape/Ops/Attention/SpecBridge.leancomplete
theorem Proofs.Autograd.Attention.backpropVec_eq_adjoint_fderiv_scaledDotProductAttention {m d : ℕ} (hm : m ≠ 0) (xV : Proofs.Autograd.CtxVec (Proofs.Autograd.Attention.ΓQKV m d)) (δ : Proofs.Autograd.Vec (Spec.Shape.dim m (Spec.Shape.dim d Spec.Shape.scalar)).size) : (Proofs.Autograd.Attention.scaledDotProductGraph (1 / Spec.attentionScaleDenom d)).backpropVec xV (Proofs.Autograd.CtxVec.single (Proofs.Autograd.Attention.sdpaOutIdx m d) δ) = (ContinuousLinearMap.adjoint (fderiv ℝ (fun xV => Proofs.Autograd.tensorToVec (Spec.scaledDotProductAttention { Q := Proofs.Autograd.Attention.ctxQ xV, K := Proofs.Autograd.Attention.ctxK xV, V := Proofs.Autograd.Attention.ctxV xV, mask := none })) xV)) δ
theorem Proofs.Autograd.Attention.backpropVec_eq_adjoint_fderiv_scaledDotProductAttention {m d : ℕ} (hm : m ≠ 0) (xV : Proofs.Autograd.CtxVec (Proofs.Autograd.Attention.ΓQKV m d)) (δ : Proofs.Autograd.Vec (Spec.Shape.dim m (Spec.Shape.dim d Spec.Shape.scalar)).size) : (Proofs.Autograd.Attention.scaledDotProductGraph (1 / Spec.attentionScaleDenom d)).backpropVec xV (Proofs.Autograd.CtxVec.single (Proofs.Autograd.Attention.sdpaOutIdx m d) δ) = (ContinuousLinearMap.adjoint (fderiv ℝ (fun xV => Proofs.Autograd.tensorToVec (Spec.scaledDotProductAttention { Q := Proofs.Autograd.Attention.ctxQ xV, K := Proofs.Autograd.Attention.ctxK xV, V := Proofs.Autograd.Attention.ctxV xV, mask := none })) xV)) δ
Tape backprop is the vector-Jacobian product of unmasked `Spec.scaledDotProductAttention`.
The output block of the graph evaluation is shown to be the vectorized specification forward pass, node by node, and the analytic graph theorem then identifies the tape reverse pass with the adjoint derivative; the softmax bridge supplies the softmax node.
For positive row and feature counts, the output block of the proof-carrying LayerNorm graph
evaluated on packed inputs equals the vectorized Spec.layerNorm of those inputs.
Lean code for Theorem8.5.39●1 theorem
Associated Lean declarations
-
theoremdefined in NN/Proofs/Autograd/Tape/Ops/Norm/LayerNorm.leancomplete
theorem Proofs.Autograd.LayerNorm.outputCLM_evalVec_layerNormGraph {m n : ℕ} (hm : 0 < m) (hn : 0 < n) (ε : ℝ) (xV : Proofs.Autograd.CtxVec (Proofs.Autograd.LayerNorm.ΓLN m n)) : Proofs.Autograd.LayerNorm.outputCLM ((Proofs.Autograd.LayerNorm.layerNormGraph ε).evalVec xV) = Proofs.Autograd.LayerNorm.specLayerNormVec hm hn ε xV
theorem Proofs.Autograd.LayerNorm.outputCLM_evalVec_layerNormGraph {m n : ℕ} (hm : 0 < m) (hn : 0 < n) (ε : ℝ) (xV : Proofs.Autograd.CtxVec (Proofs.Autograd.LayerNorm.ΓLN m n)) : Proofs.Autograd.LayerNorm.outputCLM ((Proofs.Autograd.LayerNorm.layerNormGraph ε).evalVec xV) = Proofs.Autograd.LayerNorm.specLayerNormVec hm hn ε xV
Forward bridge: the output block of the LayerNorm graph is `Spec.layerNorm` of the packed inputs.
Both sides are reduced to the same closed form for each matrix entry: centered value, inverse stabilized standard deviation, scale, and shift.
Packing puts the input matrix, scale vector, and bias vector in one differentiation context. The output projection selects the normalized matrix from a context that also contains intermediates. Thus the equality aligns both the numerical formula and the placement of its arguments before a derivative theorem is applied to the composed graph.
For positive row and feature counts, the specification LayerNorm JVP paired with an output
cotangent equals the sum of the three
pairings of the input, scale, and bias tangents with the corresponding components of
Spec.layerNormBackward. The backward rule is therefore the adjoint of the JVP.
Lean code for Theorem8.5.40●1 theorem
Associated Lean declarations
-
theoremdefined in NN/Proofs/Autograd/Tape/Ops/Norm/LayerNormAdjoint.leancomplete
theorem Proofs.Autograd.LayerNorm.layerNormJvp_layerNormBackward_adjoint {m n : ℕ} (hm : 0 < m) (hn : 0 < n) (x tangent gradOutput : TorchLean.Tensor ℝ [m, n]) (gamma dgamma beta dbeta : TorchLean.Tensor ℝ [n]) (ε : ℝ) : Spec.dot (Spec.layerNormJvp hm hn x tangent gamma dgamma beta dbeta ε) gradOutput = Spec.dot tangent (Spec.layerNormBackward hm hn x gamma gradOutput ε).inputGradient + Spec.dot dgamma (Spec.layerNormBackward hm hn x gamma gradOutput ε).scaleGradient + Spec.dot dbeta (Spec.layerNormBackward hm hn x gamma gradOutput ε).biasGradient
theorem Proofs.Autograd.LayerNorm.layerNormJvp_layerNormBackward_adjoint {m n : ℕ} (hm : 0 < m) (hn : 0 < n) (x tangent gradOutput : TorchLean.Tensor ℝ [m, n]) (gamma dgamma beta dbeta : TorchLean.Tensor ℝ [n]) (ε : ℝ) : Spec.dot (Spec.layerNormJvp hm hn x tangent gamma dgamma beta dbeta ε) gradOutput = Spec.dot tangent (Spec.layerNormBackward hm hn x gamma gradOutput ε).inputGradient + Spec.dot dgamma (Spec.layerNormBackward hm hn x gamma gradOutput ε).scaleGradient + Spec.dot dbeta (Spec.layerNormBackward hm hn x gamma gradOutput ε).biasGradient
The LayerNorm reverse rule is adjoint to its forward differential. Pairing the input tangent and both parameter tangents with `Spec.layerNormJvp` gives the same scalar as pairing the upstream gradient with the three outputs of `Spec.layerNormBackward`.
The two pairings are expanded into finite sums over matrix entries and matched term by term; the row-statistics terms are regrouped so that each input tangent coordinate meets the corresponding entry of the specification backward rule.
Scale and bias are shared across rows, so their cotangents sum contributions from every row; input cotangents retain the full matrix shape. The three pairings in the conclusion express these different shapes in one scalar equality. This adjoint identity permits arbitrary epsilon as written; identifying the formula with an analytic derivative needs the separate conditions that make the stabilized denominator differentiable.
For a well-formed channel-first shape and 0 < \varepsilon, the map sending input, scale, and
shift to Spec.batchNorm is Fréchet differentiable on the flattened vectors.
Lean code for Theorem8.5.41●1 theorem
Associated Lean declarations
-
theoremdefined in NN/Proofs/Autograd/Tape/Ops/Norm/BatchNormFDeriv.leancomplete
theorem Proofs.Autograd.BatchNorm.hasFDerivAt_batchNorm {channels : ℕ} {sSpatial : Spec.Shape} [(Spec.Shape.dim channels sSpatial).WellFormed] {ε : ℝ} (hε : 0 < ε) (x : TorchLean.Tensor ℝ (Spec.Shape.dim channels sSpatial)) (gamma beta : TorchLean.Tensor ℝ [channels]) : HasFDerivAt (Proofs.Autograd.BatchNorm.bnVec ε) (Proofs.Autograd.BatchNorm.bnD (Proofs.Autograd.BatchNorm.matVec (Proofs.Autograd.tensorToVec x)) (Proofs.Autograd.tensorToVec gamma) ε) (Proofs.Autograd.tensorToVec x, Proofs.Autograd.tensorToVec gamma, Proofs.Autograd.tensorToVec beta)
theorem Proofs.Autograd.BatchNorm.hasFDerivAt_batchNorm {channels : ℕ} {sSpatial : Spec.Shape} [(Spec.Shape.dim channels sSpatial).WellFormed] {ε : ℝ} (hε : 0 < ε) (x : TorchLean.Tensor ℝ (Spec.Shape.dim channels sSpatial)) (gamma beta : TorchLean.Tensor ℝ [channels]) : HasFDerivAt (Proofs.Autograd.BatchNorm.bnVec ε) (Proofs.Autograd.BatchNorm.bnD (Proofs.Autograd.BatchNorm.matVec (Proofs.Autograd.tensorToVec x)) (Proofs.Autograd.tensorToVec gamma) ε) (Proofs.Autograd.tensorToVec x, Proofs.Autograd.tensorToVec gamma, Proofs.Autograd.tensorToVec beta)
`Spec.batchNorm` is Fréchet differentiable in `(x, gamma, beta)` for positive `ε`.
BatchNorm flattens the spatial axes to a channel-by-position matrix and normalizes each row; the derivative of one normalized row entry is composed with the reshaping and affine stages, and the clamps in the specification are shown inactive because the variance is a mean of squares.
Positive epsilon makes the stabilized variance strictly positive even when every value in a channel is identical. That is where the hypothesis enters the calculus: square root and reciprocal are differentiated away from their singular points. The channel-first shape hypothesis separately justifies which coordinates are collected into each normalization row.
Under the hypotheses of the differentiability theorem, the Fréchet
derivative of BatchNorm applied to a tangent equals the specification Spec.batchNormJvp.
Lean code for Theorem8.5.42●1 theorem
Associated Lean declarations
-
theoremdefined in NN/Proofs/Autograd/Tape/Ops/Norm/BatchNormFDeriv.leancomplete
theorem Proofs.Autograd.BatchNorm.fderiv_batchNorm_eq_batchNormJvp {channels : ℕ} {sSpatial : Spec.Shape} [(Spec.Shape.dim channels sSpatial).WellFormed] {ε : ℝ} (hε : 0 < ε) (x dx : TorchLean.Tensor ℝ (Spec.Shape.dim channels sSpatial)) (gamma dgamma beta dbeta : TorchLean.Tensor ℝ [channels]) : (fderiv ℝ (Proofs.Autograd.BatchNorm.bnVec ε) (Proofs.Autograd.tensorToVec x, Proofs.Autograd.tensorToVec gamma, Proofs.Autograd.tensorToVec beta)) (Proofs.Autograd.tensorToVec dx, Proofs.Autograd.tensorToVec dgamma, Proofs.Autograd.tensorToVec dbeta) = Proofs.Autograd.tensorToVec (Spec.batchNormJvp x dx gamma dgamma beta dbeta ε)
theorem Proofs.Autograd.BatchNorm.fderiv_batchNorm_eq_batchNormJvp {channels : ℕ} {sSpatial : Spec.Shape} [(Spec.Shape.dim channels sSpatial).WellFormed] {ε : ℝ} (hε : 0 < ε) (x dx : TorchLean.Tensor ℝ (Spec.Shape.dim channels sSpatial)) (gamma dgamma beta dbeta : TorchLean.Tensor ℝ [channels]) : (fderiv ℝ (Proofs.Autograd.BatchNorm.bnVec ε) (Proofs.Autograd.tensorToVec x, Proofs.Autograd.tensorToVec gamma, Proofs.Autograd.tensorToVec beta)) (Proofs.Autograd.tensorToVec dx, Proofs.Autograd.tensorToVec dgamma, Proofs.Autograd.tensorToVec dbeta) = Proofs.Autograd.tensorToVec (Spec.batchNormJvp x dx gamma dgamma beta dbeta ε)
The Fréchet derivative of `Spec.batchNorm` in `(x, gamma, beta)` applied to a tangent triple is `Spec.batchNormJvp`, for positive `ε`.
The derivative is read off entrywise and compared with the closed-form row differential that defines the JVP.
A Lyapunov certificate is valid for a pair of functions when its two intervals enclose the function and orbital-derivative values throughout the stated region.
Lean code for Definition8.5.43●1 definition
Associated Lean declarations
-
structuredefined in NN/MLTheory/CROWN/Lyapunov/Certificate.leancomplete
structure NN.MLTheory.CROWN.Lyapunov.LyapunovCert.ValidFor {α : Type} [TorchLean.Storage α] [Context α] {n : ℕ} (cert : NN.MLTheory.CROWN.Lyapunov.LyapunovCert α n) (lyap : NN.MLTheory.CROWN.Lyapunov.NeuralLyapunov α n) : Prop
structure NN.MLTheory.CROWN.Lyapunov.LyapunovCert.ValidFor {α : Type} [TorchLean.Storage α] [Context α] {n : ℕ} (cert : NN.MLTheory.CROWN.Lyapunov.LyapunovCert α n) (lyap : NN.MLTheory.CROWN.Lyapunov.NeuralLyapunov α n) : Prop
Proof object produced by a semantic certificate checker. Parsing a certificate or checking the signs of its endpoints cannot construct this structure. Its two fields require enclosure proofs for the actual functions named by `lyap` on the actual region stored in `cert`.
Fields
valueBounds : ∀ (x : TorchLean.Tensor α (Spec.Shape.dim n Spec.Shape.scalar)), cert.region.contains x → cert.vLower ≤ lyap.value x ∧ lyap.value x ≤ cert.vUpper
The checked interval for the Lyapunov candidate.
orbitalDerivativeBounds : ∀ (x : TorchLean.Tensor α (Spec.Shape.dim n Spec.Shape.scalar)), cert.region.contains x → cert.derivativeLower ≤ lyap.orbitalDerivative x ∧ lyap.orbitalDerivative x ≤ cert.derivativeUpper
The checked interval for the orbital derivative.
Certificate thresholds imply positive Lyapunov values and negative derivatives on the certified region, conditional on the certificate validity predicate.
Lean code for Theorem8.5.44●1 theorem
Associated Lean declarations
-
theoremdefined in NN/MLTheory/CROWN/Lyapunov/Verification.leancomplete
theorem NN.MLTheory.CROWN.Lyapunov.Real.lyapunov_conditions {n : ℕ} (lyap : NN.MLTheory.CROWN.Lyapunov.NeuralLyapunov ℝ n) (cert : NN.MLTheory.CROWN.Lyapunov.LyapunovCert ℝ n) (hcert : cert.ValidFor lyap) (h_V_pos : cert.vLower > 0) (h_Vdot_neg : cert.derivativeUpper < 0) : (∀ (x : TorchLean.Tensor ℝ (Spec.Shape.dim n Spec.Shape.scalar)), cert.region.contains x → lyap.value x > 0) ∧ ∀ (x : TorchLean.Tensor ℝ (Spec.Shape.dim n Spec.Shape.scalar)), cert.region.contains x → lyap.orbitalDerivative x < 0
theorem NN.MLTheory.CROWN.Lyapunov.Real.lyapunov_conditions {n : ℕ} (lyap : NN.MLTheory.CROWN.Lyapunov.NeuralLyapunov ℝ n) (cert : NN.MLTheory.CROWN.Lyapunov.LyapunovCert ℝ n) (hcert : cert.ValidFor lyap) (h_V_pos : cert.vLower > 0) (h_Vdot_neg : cert.derivativeUpper < 0) : (∀ (x : TorchLean.Tensor ℝ (Spec.Shape.dim n Spec.Shape.scalar)), cert.region.contains x → lyap.value x > 0) ∧ ∀ (x : TorchLean.Tensor ℝ (Spec.Shape.dim n Spec.Shape.scalar)), cert.region.contains x → lyap.orbitalDerivative x < 0
Positivity and decay follow from valid strict certificate margins.
The enclosures in the validity hypothesis are compared with the certificate thresholds and strengthened to strict sign conditions.
The conclusion gives two pointwise statements for every state inside cert.region. To use
them in a stability argument, the region and dynamics must be the ones of interest, and the
validity proof must enclose the stated orbital derivative there. Strict positivity of the lower
value bound also means that a zero-valued equilibrium cannot lie in this certified region.
Let x^\star be a root of the update map g, let \eta be the step size, and set
q(\eta,\mu,L)=1-2\eta\mu+\eta^2L^2. Under the stated strong-monotonicity and Lipschitz
hypotheses, with 0\le\eta and 0\le q(\eta,\mu,L), the iterates satisfy
\left\lVert \operatorname{step}_{\eta}(g)^{\,k}(x)-x^\star\right\rVert^2
\leq q(\eta,\mu,L)^k\left\lVert x-x^\star\right\rVert^2.
Here k counts update steps. The bound gives geometric decay when q<1; the next theorem
provides step-size conditions that establish that inequality.
Lean code for Theorem8.5.45●1 theorem
Associated Lean declarations
-
Optim.GD.dist_sq_iterate_le_of_q_nonneg[complete]
-
Optim.GD.dist_sq_iterate_le_of_q_nonneg[complete]
-
theoremdefined in NN/MLTheory/Optimization/StronglyConvexGD.leancomplete
theorem Optim.GD.dist_sq_iterate_le_of_q_nonneg {E : Type} [NormedAddCommGroup E] [InnerProductSpace ℝ E] (η μ : ℝ) (hη : 0 ≤ η) {L : NNReal} (g : E → E) (hmono : Optim.GD.StrongMonotone μ g) (hlip : LipschitzWith L g) {xStar x : E} (hxStar : g xStar = 0) (hq : 0 ≤ Optim.GD.q η μ L) (k : ℕ) : ‖(Optim.GD.step η g)^[k] x - xStar‖ ^ 2 ≤ Optim.GD.q η μ L ^ k * ‖x - xStar‖ ^ 2
theorem Optim.GD.dist_sq_iterate_le_of_q_nonneg {E : Type} [NormedAddCommGroup E] [InnerProductSpace ℝ E] (η μ : ℝ) (hη : 0 ≤ η) {L : NNReal} (g : E → E) (hmono : Optim.GD.StrongMonotone μ g) (hlip : LipschitzWith L g) {xStar x : E} (hxStar : g xStar = 0) (hq : 0 ≤ Optim.GD.q η μ L) (k : ℕ) : ‖(Optim.GD.step η g)^[k] x - xStar‖ ^ 2 ≤ Optim.GD.q η μ L ^ k * ‖x - xStar‖ ^ 2
Iterated contraction bound in squared norm. If $q(\eta,\mu,L)\geq 0$, then after $k$ steps we have $$ \left\lVert \operatorname{step}_\eta(g)^{\,k}(x)-x^\star\right\rVert^2 \leq q(\eta,\mu,L)^k\lVert x-x^\star\rVert^2. $$
The one-step contraction is iterated, and nonnegativity of q(\eta,\mu,L) controls
multiplication by the geometric factor.
-
Optim.GD.dist_sq_iterate_le_of_step_size[complete]
For a \mu-strongly monotone, L-Lipschitz update map with root x^\star, if
0\le\mu\le L, 0<\eta, and \eta L^2<2\mu, then the geometric bound of
the iterate theorem holds and, in addition,
q(\eta,\mu,L)<1, so the squared distance to the root decreases geometrically. This packages the
step-size conditions a caller must check instead of assuming the contraction factor is below one.
Lean code for Theorem8.5.46●1 theorem
Associated Lean declarations
-
Optim.GD.dist_sq_iterate_le_of_step_size[complete]
-
Optim.GD.dist_sq_iterate_le_of_step_size[complete]
-
theoremdefined in NN/MLTheory/Optimization/StronglyConvexGD.leancomplete
theorem Optim.GD.dist_sq_iterate_le_of_step_size {E : Type} [NormedAddCommGroup E] [InnerProductSpace ℝ E] (η μ : ℝ) {L : NNReal} (g : E → E) (hmono : Optim.GD.StrongMonotone μ g) (hlip : LipschitzWith L g) {xStar x : E} (hxStar : g xStar = 0) (hμ : 0 ≤ μ) (hμL : μ ≤ ↑L) (hη : 0 < η) (hstep : η * ↑L ^ 2 < 2 * μ) (k : ℕ) : ‖(Optim.GD.step η g)^[k] x - xStar‖ ^ 2 ≤ Optim.GD.q η μ L ^ k * ‖x - xStar‖ ^ 2 ∧ Optim.GD.q η μ L < 1
theorem Optim.GD.dist_sq_iterate_le_of_step_size {E : Type} [NormedAddCommGroup E] [InnerProductSpace ℝ E] (η μ : ℝ) {L : NNReal} (g : E → E) (hmono : Optim.GD.StrongMonotone μ g) (hlip : LipschitzWith L g) {xStar x : E} (hxStar : g xStar = 0) (hμ : 0 ≤ μ) (hμL : μ ≤ ↑L) (hη : 0 < η) (hstep : η * ↑L ^ 2 < 2 * μ) (k : ℕ) : ‖(Optim.GD.step η g)^[k] x - xStar‖ ^ 2 ≤ Optim.GD.q η μ L ^ k * ‖x - xStar‖ ^ 2 ∧ Optim.GD.q η μ L < 1
Linear convergence of gradient descent under an explicit step-size condition. Assuming `0 ≤ μ ≤ L`, `0 < η`, and `η * L ^ 2 < 2 * μ`, the contraction factor satisfies `0 ≤ q η μ L < 1` and the iterates converge linearly to any root `xStar` of `g`.
q-1=\eta(\eta L^2-2\mu) gives q<1 from the step-size condition; \mu\le L gives
q\ge 0; the iterate theorem supplies the bound.
Measurable post-processing preserves (\varepsilon,\delta)-differential privacy.
Lean code for Theorem8.5.47●1 theorem
Associated Lean declarations
-
theoremdefined in NN/MLTheory/LearningTheory/DifferentialPrivacy/Core.leancomplete
theorem NN.MLTheory.LearningTheory.differentialPrivacy_postprocess {α β γ : Type} {Adj : α → α → Prop} [MeasurableSpace β] [MeasurableSpace γ] {M : NN.MLTheory.LearningTheory.Mechanism α β} {ε : ℝ} {δ : ENNReal} {f : β → γ} (hf : Measurable f) : NN.MLTheory.LearningTheory.DifferentialPrivacy Adj M ε δ → NN.MLTheory.LearningTheory.DifferentialPrivacy Adj (NN.MLTheory.LearningTheory.postprocess M f hf) ε δ
theorem NN.MLTheory.LearningTheory.differentialPrivacy_postprocess {α β γ : Type} {Adj : α → α → Prop} [MeasurableSpace β] [MeasurableSpace γ] {M : NN.MLTheory.LearningTheory.Mechanism α β} {ε : ℝ} {δ : ENNReal} {f : β → γ} (hf : Measurable f) : NN.MLTheory.LearningTheory.DifferentialPrivacy Adj M ε δ → NN.MLTheory.LearningTheory.DifferentialPrivacy Adj (NN.MLTheory.LearningTheory.postprocess M f hf) ε δ
Post-processing theorem: measurable mappings of outputs preserve DP. Proof idea (the standard one): - the probability of an event `S` under the mapped output is the probability of the preimage `f ⁻¹' S` under the original output; - apply DP for `M` to the measurable set `f ⁻¹' S`.
The proof rewrites measurable preimages through the post-processing map and reuses the original privacy inequality.
An observable event after post-processing corresponds to its preimage before post-processing. Measurability makes that preimage a legal event for the original privacy bound. The deterministic map receives only the mechanism's output in this theorem; a function that also consults the private dataset would require a different argument.
Assuming real approximation, parameter quantization, and IEEE32 execution budgets for a two-layer ReLU network, the total error is bounded by their sum.
Lean code for Theorem8.5.48●1 theorem
Associated Lean declarations
-
theoremdefined in NN/MLTheory/Proofs/Approximation/Universal/UniversalApproximationIEEE32ExecTwoLayerMlp.leancomplete
theorem NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecTwoLayerMLP.relu_twoLayerMlp_ieee32exec_threeTerm {n hidDim : ℕ} (D : Set (TorchLean.Tensor (FloatLib.Floats.ExecFloat.Binary 8 23 FloatLib.Floats.Formats.BinaryInterchange.FloatFormat.Encoding.ieee (FloatLib.Floats.Formats.BinaryInterchange.FloatFormat.Encoding.ieee.defaultBias 8) NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecTwoLayerMLP.relu_twoLayerMlp_ieee32exec_threeTerm._proof_1 NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecTwoLayerMLP.relu_twoLayerMlp_ieee32exec_threeTerm._proof_2 NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecTwoLayerMLP.relu_twoLayerMlp_ieee32exec_threeTerm._proof_3 NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecTwoLayerMLP.relu_twoLayerMlp_ieee32exec_threeTerm._proof_4) [n])) (f : TorchLean.Tensor ℝ [n] → ℝ) (l1R : Spec.LinearSpec ℝ n hidDim) (l2R : Spec.LinearSpec ℝ hidDim 1) (l1I : Spec.LinearSpec (FloatLib.Floats.ExecFloat.Binary 8 23 FloatLib.Floats.Formats.BinaryInterchange.FloatFormat.Encoding.ieee (FloatLib.Floats.Formats.BinaryInterchange.FloatFormat.Encoding.ieee.defaultBias 8) NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecTwoLayerMLP.relu_twoLayerMlp_ieee32exec_threeTerm._proof_1 NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecTwoLayerMLP.relu_twoLayerMlp_ieee32exec_threeTerm._proof_2 NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecTwoLayerMLP.relu_twoLayerMlp_ieee32exec_threeTerm._proof_3 NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecTwoLayerMLP.relu_twoLayerMlp_ieee32exec_threeTerm._proof_4) n hidDim) (l2I : Spec.LinearSpec (FloatLib.Floats.ExecFloat.Binary 8 23 FloatLib.Floats.Formats.BinaryInterchange.FloatFormat.Encoding.ieee (FloatLib.Floats.Formats.BinaryInterchange.FloatFormat.Encoding.ieee.defaultBias 8) NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecTwoLayerMLP.relu_twoLayerMlp_ieee32exec_threeTerm._proof_1 NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecTwoLayerMLP.relu_twoLayerMlp_ieee32exec_threeTerm._proof_2 NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecTwoLayerMLP.relu_twoLayerMlp_ieee32exec_threeTerm._proof_3 NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecTwoLayerMLP.relu_twoLayerMlp_ieee32exec_threeTerm._proof_4) hidDim 1) (εApprox εQ εR : ℝ) (hApprox : ∀ xI ∈ D, have xR := NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecCore.tensorToReal xI; |f xR - NN.MLTheory.Proofs.ReLUMlpBridge.mlpEval l1R l2R xR| ≤ εApprox) (hQ : ∀ xI ∈ D, have xR := NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecCore.tensorToReal xI; |NN.MLTheory.Proofs.ReLUMlpBridge.mlpEval l1R l2R xR - NN.MLTheory.Proofs.ReLUMlpBridge.mlpEval (NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecCore.linearSpecToReal l1I) (NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecCore.linearSpecToReal l2I) xR| ≤ εQ) (hR : ∀ xI ∈ D, have xR := NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecCore.tensorToReal xI; |(FloatLib.Floats.ExecFloat.Binary.toModel (NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecCore.mlpEvalIEEE32Exec l1I l2I xI)).toReal - NN.MLTheory.Proofs.ReLUMlpBridge.mlpEval (NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecCore.linearSpecToReal l1I) (NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecCore.linearSpecToReal l2I) xR| ≤ εR) (xI : TorchLean.Tensor (FloatLib.Floats.ExecFloat.Binary 8 23 FloatLib.Floats.Formats.BinaryInterchange.FloatFormat.Encoding.ieee (FloatLib.Floats.Formats.BinaryInterchange.FloatFormat.Encoding.ieee.defaultBias 8) NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecTwoLayerMLP.relu_twoLayerMlp_ieee32exec_threeTerm._proof_1 NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecTwoLayerMLP.relu_twoLayerMlp_ieee32exec_threeTerm._proof_2 NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecTwoLayerMLP.relu_twoLayerMlp_ieee32exec_threeTerm._proof_3 NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecTwoLayerMLP.relu_twoLayerMlp_ieee32exec_threeTerm._proof_4) [n]) : xI ∈ D → have xR := NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecCore.tensorToReal xI; |f xR - (FloatLib.Floats.ExecFloat.Binary.toModel (NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecCore.mlpEvalIEEE32Exec l1I l2I xI)).toReal| ≤ εApprox + εQ + εR
theorem NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecTwoLayerMLP.relu_twoLayerMlp_ieee32exec_threeTerm {n hidDim : ℕ} (D : Set (TorchLean.Tensor (FloatLib.Floats.ExecFloat.Binary 8 23 FloatLib.Floats.Formats.BinaryInterchange.FloatFormat.Encoding.ieee (FloatLib.Floats.Formats.BinaryInterchange.FloatFormat.Encoding.ieee.defaultBias 8) NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecTwoLayerMLP.relu_twoLayerMlp_ieee32exec_threeTerm._proof_1 NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecTwoLayerMLP.relu_twoLayerMlp_ieee32exec_threeTerm._proof_2 NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecTwoLayerMLP.relu_twoLayerMlp_ieee32exec_threeTerm._proof_3 NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecTwoLayerMLP.relu_twoLayerMlp_ieee32exec_threeTerm._proof_4) [n])) (f : TorchLean.Tensor ℝ [n] → ℝ) (l1R : Spec.LinearSpec ℝ n hidDim) (l2R : Spec.LinearSpec ℝ hidDim 1) (l1I : Spec.LinearSpec (FloatLib.Floats.ExecFloat.Binary 8 23 FloatLib.Floats.Formats.BinaryInterchange.FloatFormat.Encoding.ieee (FloatLib.Floats.Formats.BinaryInterchange.FloatFormat.Encoding.ieee.defaultBias 8) NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecTwoLayerMLP.relu_twoLayerMlp_ieee32exec_threeTerm._proof_1 NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecTwoLayerMLP.relu_twoLayerMlp_ieee32exec_threeTerm._proof_2 NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecTwoLayerMLP.relu_twoLayerMlp_ieee32exec_threeTerm._proof_3 NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecTwoLayerMLP.relu_twoLayerMlp_ieee32exec_threeTerm._proof_4) n hidDim) (l2I : Spec.LinearSpec (FloatLib.Floats.ExecFloat.Binary 8 23 FloatLib.Floats.Formats.BinaryInterchange.FloatFormat.Encoding.ieee (FloatLib.Floats.Formats.BinaryInterchange.FloatFormat.Encoding.ieee.defaultBias 8) NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecTwoLayerMLP.relu_twoLayerMlp_ieee32exec_threeTerm._proof_1 NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecTwoLayerMLP.relu_twoLayerMlp_ieee32exec_threeTerm._proof_2 NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecTwoLayerMLP.relu_twoLayerMlp_ieee32exec_threeTerm._proof_3 NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecTwoLayerMLP.relu_twoLayerMlp_ieee32exec_threeTerm._proof_4) hidDim 1) (εApprox εQ εR : ℝ) (hApprox : ∀ xI ∈ D, have xR := NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecCore.tensorToReal xI; |f xR - NN.MLTheory.Proofs.ReLUMlpBridge.mlpEval l1R l2R xR| ≤ εApprox) (hQ : ∀ xI ∈ D, have xR := NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecCore.tensorToReal xI; |NN.MLTheory.Proofs.ReLUMlpBridge.mlpEval l1R l2R xR - NN.MLTheory.Proofs.ReLUMlpBridge.mlpEval (NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecCore.linearSpecToReal l1I) (NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecCore.linearSpecToReal l2I) xR| ≤ εQ) (hR : ∀ xI ∈ D, have xR := NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecCore.tensorToReal xI; |(FloatLib.Floats.ExecFloat.Binary.toModel (NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecCore.mlpEvalIEEE32Exec l1I l2I xI)).toReal - NN.MLTheory.Proofs.ReLUMlpBridge.mlpEval (NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecCore.linearSpecToReal l1I) (NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecCore.linearSpecToReal l2I) xR| ≤ εR) (xI : TorchLean.Tensor (FloatLib.Floats.ExecFloat.Binary 8 23 FloatLib.Floats.Formats.BinaryInterchange.FloatFormat.Encoding.ieee (FloatLib.Floats.Formats.BinaryInterchange.FloatFormat.Encoding.ieee.defaultBias 8) NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecTwoLayerMLP.relu_twoLayerMlp_ieee32exec_threeTerm._proof_1 NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecTwoLayerMLP.relu_twoLayerMlp_ieee32exec_threeTerm._proof_2 NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecTwoLayerMLP.relu_twoLayerMlp_ieee32exec_threeTerm._proof_3 NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecTwoLayerMLP.relu_twoLayerMlp_ieee32exec_threeTerm._proof_4) [n]) : xI ∈ D → have xR := NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecCore.tensorToReal xI; |f xR - (FloatLib.Floats.ExecFloat.Binary.toModel (NN.MLTheory.Proofs.UniversalApproximation.IEEE32ExecCore.mlpEvalIEEE32Exec l1I l2I xI)).toReal| ≤ εApprox + εQ + εR
After interpreting the IEEE32 result as a real value, two triangle inequalities split the target error into the three assumed budgets.
A comparison argument encloses a clamped scalar ODE solution with constant extension outside the integration interval.
Lean code for Theorem8.5.49●1 theorem
Associated Lean declarations
-
theoremdefined in NN/Proofs/Verification/ODE/Enclosure.leancomplete
theorem NN.Proofs.Verification.ODE.Enclosure.extendedSolutionEnclosed_fromClampedDynamics {T τ : ℝ} (hT : 0 ≤ T) (hτ : T ≤ τ) {f : ℝ → ℝ → ℝ} {u uL uU uL' uU' : ℝ → ℝ} {a : ℝ} (hu_cont : ContinuousOn u (Set.Icc 0 τ)) (hu_der : ∀ t ∈ Set.Ico 0 τ, HasDerivWithinAt u (f t (NN.Proofs.Verification.ODE.Enclosure.clampToCorridor (NN.Proofs.Verification.ODE.Enclosure.constantExtensionAfter T uL) (NN.Proofs.Verification.ODE.Enclosure.constantExtensionAfter T uU) t (u t))) (Set.Ici t) t) (hu0 : u 0 = a) (hL_cont : ContinuousOn uL (Set.Icc 0 T)) (hL_der : ∀ t ∈ Set.Ico 0 T, HasDerivWithinAt uL (uL' t) (Set.Ici t) t) (hL_sub : ∀ t ∈ Set.Ico 0 T, uL' t ≤ f t (uL t)) (hL0 : uL 0 ≤ a) (hU_cont : ContinuousOn uU (Set.Icc 0 T)) (hU_der : ∀ t ∈ Set.Ico 0 T, HasDerivWithinAt uU (uU' t) (Set.Ici t) t) (hU_sup : ∀ t ∈ Set.Ico 0 T, f t (uU t) ≤ uU' t) (hU0 : a ≤ uU 0) (hLU : ∀ t ∈ Set.Icc 0 T, uL t ≤ uU t) (hLower : ∀ (t : ℝ), T < t → 0 ≤ f T (uL T) ∧ f T (uL T) ≤ f t (uL T)) (hUpper : ∀ (t : ℝ), T < t → f t (uU T) ≤ f T (uU T) ∧ f T (uU T) ≤ 0) : (∀ t ∈ Set.Icc 0 τ, NN.Proofs.Verification.ODE.Enclosure.constantExtensionAfter T uL t ≤ u t ∧ u t ≤ NN.Proofs.Verification.ODE.Enclosure.constantExtensionAfter T uU t) ∧ ∀ t ∈ Set.Ico 0 τ, HasDerivWithinAt u (f t (u t)) (Set.Ici t) t
theorem NN.Proofs.Verification.ODE.Enclosure.extendedSolutionEnclosed_fromClampedDynamics {T τ : ℝ} (hT : 0 ≤ T) (hτ : T ≤ τ) {f : ℝ → ℝ → ℝ} {u uL uU uL' uU' : ℝ → ℝ} {a : ℝ} (hu_cont : ContinuousOn u (Set.Icc 0 τ)) (hu_der : ∀ t ∈ Set.Ico 0 τ, HasDerivWithinAt u (f t (NN.Proofs.Verification.ODE.Enclosure.clampToCorridor (NN.Proofs.Verification.ODE.Enclosure.constantExtensionAfter T uL) (NN.Proofs.Verification.ODE.Enclosure.constantExtensionAfter T uU) t (u t))) (Set.Ici t) t) (hu0 : u 0 = a) (hL_cont : ContinuousOn uL (Set.Icc 0 T)) (hL_der : ∀ t ∈ Set.Ico 0 T, HasDerivWithinAt uL (uL' t) (Set.Ici t) t) (hL_sub : ∀ t ∈ Set.Ico 0 T, uL' t ≤ f t (uL t)) (hL0 : uL 0 ≤ a) (hU_cont : ContinuousOn uU (Set.Icc 0 T)) (hU_der : ∀ t ∈ Set.Ico 0 T, HasDerivWithinAt uU (uU' t) (Set.Ici t) t) (hU_sup : ∀ t ∈ Set.Ico 0 T, f t (uU t) ≤ uU' t) (hU0 : a ≤ uU 0) (hLU : ∀ t ∈ Set.Icc 0 T, uL t ≤ uU t) (hLower : ∀ (t : ℝ), T < t → 0 ≤ f T (uL T) ∧ f T (uL T) ≤ f t (uL T)) (hUpper : ∀ (t : ℝ), T < t → f t (uU T) ≤ f T (uU T) ∧ f T (uU T) ≤ 0) : (∀ t ∈ Set.Icc 0 τ, NN.Proofs.Verification.ODE.Enclosure.constantExtensionAfter T uL t ≤ u t ∧ u t ≤ NN.Proofs.Verification.ODE.Enclosure.constantExtensionAfter T uU t) ∧ ∀ t ∈ Set.Ico 0 τ, HasDerivWithinAt u (f t (u t)) (Set.Ici t) t
Constant-extension enclosure theorem: Assume we have `uL,uU` on `[0,T]` satisfying the local corridor hypotheses, and assume the paper's extra sign/monotonicity conditions for `f` beyond `T`. Then for any `τ ≥ T`, any solution `u` of the clamped ODE built from the constant extensions is enclosed on `[0,τ]` and is a genuine solution of `u' = f(t,u)` on `[0,τ]`. This is the reusable Lean form of the paper's global-in-time step: after the verified horizon, the walls stop moving, and the vector field points inward at those frozen walls.
The proof combines the in-interval differential inequality with the two constant-extension cases.
The hypotheses include the initial value between the walls, continuity and one-sided derivative bounds up to the horizon, and inward-pointing inequalities at the frozen walls afterward. The result both encloses the supplied clamped solution and shows that it satisfies the original ODE. Once the solution lies between the walls, clamping its value has no effect on the vector field.
Acceptance by the boolean 3D box and camera checker over
shape-indexed inputs yields a Verified3DBox certificate.
Lean code for Theorem8.5.50●1 theorem
Associated Lean declarations
-
theoremdefined in NN/Verification/Geometry3D/Box3D.leancomplete
theorem NN.Verification.Geometry3D.Box3D.checkCert_sound {α : Type} [TorchLean.Storage α] [OfNat α 0] [OfNat α 1] [Add α] [Sub α] [Mul α] [Div α] [LE α] [LT α] [DecidableRel fun x1 x2 => x1 ≤ x2] [DecidableRel fun x1 x2 => x1 < x2] {cert : NN.Verification.Geometry3D.Box3D.BoxCameraCert α} (h : NN.Verification.Geometry3D.Box3D.checkCert cert = true) : NN.Verification.Geometry3D.Box3D.Verified3DBox cert
theorem NN.Verification.Geometry3D.Box3D.checkCert_sound {α : Type} [TorchLean.Storage α] [OfNat α 0] [OfNat α 1] [Add α] [Sub α] [Mul α] [Div α] [LE α] [LT α] [DecidableRel fun x1 x2 => x1 ≤ x2] [DecidableRel fun x1 x2 => x1 < x2] {cert : NN.Verification.Geometry3D.Box3D.BoxCameraCert α} (h : NN.Verification.Geometry3D.Box3D.checkCert cert = true) : NN.Verification.Geometry3D.Box3D.Verified3DBox cert
Soundness of the executable checker. This is the main theorem for the implementation: if the Boolean checker accepts an artifact, the artifact satisfies the mathematical `Verified3DBox` predicate.
Each boolean guard over the tensor inputs is reflected into its proposition and assembled into the certificate structure.
The resulting fields record positive image dimensions and corner depths, an ordered box inside the image, projected corners inside the image, and their enclosure by the box with its stated tolerance. These are properties of the supplied camera artifact. They can be inspected separately when a downstream geometric argument needs, for example, the positive-depth premise for a projection.