TorchLean API

NN.Verification.Builtin.Proved.Correctness.Eval.LoweringPayload

Lowering pass Payload Insertion #

The forward-fragment lowering pass emits an IR node and, when the node needs external data, records that data in the verifier ParamStore at the same fresh node id. These lemmas pin down that insertion step for the payload-backed constructors in the proved forward fragment.

Lowering a literal constant stores its flattened tensor at the fresh IR node id.

theorem NN.Verification.Builtin.Proved.Correctness.IRStep.lowerNode_paramConst_payload {α : Type} [TorchLean.Storage α] [Context α] {paramShapes : List Spec.Shape} {inShape : Spec.Shape} {ss : List Spec.Shape} {s : Spec.Shape} (id : ) (wf : s.WellFormed) (p : Idx paramShapes s) (params : TorchLean.TensorPack α paramShapes) (ps : MLTheory.CROWN.Graph.ParamStore α) :
(lowerNode id (Node.paramConst wf p) params ps).2.constVals.get? id = some (flatOfTensor wf (getParam params p))

Lowering a parameter constant stores the selected parameter tensor at the fresh IR node id.

theorem NN.Verification.Builtin.Proved.Correctness.IRStep.lowerNode_linear_payload {α : Type} [TorchLean.Storage α] [Context α] {paramShapes : List Spec.Shape} {inShape : Spec.Shape} {ss : List Spec.Shape} (id inDim outDim : ) (w : Idx paramShapes (Spec.Shape.dim outDim (Spec.Shape.dim inDim Spec.Shape.scalar))) (b : Idx paramShapes (Spec.Shape.dim outDim Spec.Shape.scalar)) (x : Idx (Ctx inShape ss) (Spec.Shape.dim inDim Spec.Shape.scalar)) (params : TorchLean.TensorPack α paramShapes) (ps : MLTheory.CROWN.Graph.ParamStore α) :
(lowerNode id (Node.linear inDim outDim w b x) params ps).2.linearWB.get? id = some { m := outDim, n := inDim, w := getParam params w, b := getParam params b }

Lowering a linear node stores exactly the selected weight and bias tensors.

theorem NN.Verification.Builtin.Proved.Correctness.IRStep.lowerNode_const_node {α : Type} [TorchLean.Storage α] [Context α] {paramShapes : List Spec.Shape} {inShape : Spec.Shape} {ss : List Spec.Shape} {s : Spec.Shape} (id : ) (wf : s.WellFormed) (t : TorchLean.Tensor α s) (params : TorchLean.TensorPack α paramShapes) (ps : MLTheory.CROWN.Graph.ParamStore α) :
(lowerNode id (Node.const wf t) params ps).1 = { id := id, parents := #[], kind := IR.OpKind.const s, outShape := s }

The lowered IR node for a literal constant is the corresponding payload-backed const node.

theorem NN.Verification.Builtin.Proved.Correctness.IRStep.lowerNode_paramConst_node {α : Type} [TorchLean.Storage α] [Context α] {paramShapes : List Spec.Shape} {inShape : Spec.Shape} {ss : List Spec.Shape} {s : Spec.Shape} (id : ) (wf : s.WellFormed) (p : Idx paramShapes s) (params : TorchLean.TensorPack α paramShapes) (ps : MLTheory.CROWN.Graph.ParamStore α) :
(lowerNode id (Node.paramConst wf p) params ps).1 = { id := id, parents := #[], kind := IR.OpKind.const s, outShape := s }

The lowered IR node for a parameter constant is the corresponding payload-backed const node.

theorem NN.Verification.Builtin.Proved.Correctness.IRStep.lowerNode_linear_node {α : Type} [TorchLean.Storage α] [Context α] {paramShapes : List Spec.Shape} {inShape : Spec.Shape} {ss : List Spec.Shape} (id inDim outDim : ) (w : Idx paramShapes (Spec.Shape.dim outDim (Spec.Shape.dim inDim Spec.Shape.scalar))) (b : Idx paramShapes (Spec.Shape.dim outDim Spec.Shape.scalar)) (x : Idx (Ctx inShape ss) (Spec.Shape.dim inDim Spec.Shape.scalar)) (params : TorchLean.TensorPack α paramShapes) (ps : MLTheory.CROWN.Graph.ParamStore α) :
(lowerNode id (Node.linear inDim outDim w b x) params ps).1 = { id := id, parents := #[x.id], kind := IR.OpKind.linear, outShape := Spec.Shape.dim outDim Spec.Shape.scalar }

The lowered IR node for a linear source node has one activation parent and external payload.

Lowering a suffix preserves already-existing constant payload lookups seen by IR evaluation.

Lowering a suffix preserves already-existing linear payload lookups seen by IR evaluation.

Lowering a suffix preserves already-existing convolution payload lookups seen by IR evaluation.

Lowering a suffix preserves already-existing BatchNorm payload lookups seen by IR evaluation.

Lowering a suffix preserves already-existing LayerNorm payload lookups seen by IR evaluation.