Numerical certificate contracts #
Canonical local range rules, numerical operation contracts, contract registries, and graph range
trace construction. Most users should import
NN.Proofs.RuntimeApprox.Graph.NumericalCertificate.
Canonical local transfer rules #
How a node enclosure was obtained from source assumptions or earlier nodes.
The rule is recorded to make certificate diagnostics useful. It is not accepted on faith:
check reconstructs the rule and endpoints from the graph.
- source : RangeRule
- preserve (parent : ℕ) : RangeRule
- add (left right : ℕ) : RangeRule
- sub (left right : ℕ) : RangeRule
- mul (left right : ℕ) : RangeRule
- inv (parent : ℕ) : RangeRule
- hull (parents : Array ℕ) : RangeRule
- hullZero (parent : ℕ) : RangeRule
- sumLeft (parent count : ℕ) : RangeRule
- meanLeft (parent count : ℕ) : RangeRule
- matmulLeft (left right innerDim : ℕ) : RangeRule
- averageWindowLeft (parent windowSize : ℕ) (includesPadding : Bool) : RangeRule
- mseLeft (prediction target count : ℕ) : RangeRule
- layerNormLeft (parent axis normalizedSize : ℕ) : RangeRule
- softmaxUnit (parent axis : ℕ) : RangeRule
- relu (parent : ℕ) : RangeRule
- abs (parent : ℕ) : RangeRule
- sqrtNonnegative (parent : ℕ) : RangeRule
- unitBound (parent : ℕ) : RangeRule
- signedUnitBound (parent : ℕ) : RangeRule
Instances For
Instances For
Instances For
Proof-free data for one graph node's numerical range.
- nodeId : ℕ
- outShape : Spec.Shape
- rule : RangeRule
- enclosure : TorchLean.Floats.IEEE754.IEEE32Exec.Interval32
Instances For
Instances For
A node range whose executable interval has passed the finite/order check.
Instances For
Check a dynamic graph value against the declared shape and interval of one certificate row.
Instances For
A real dynamic graph value has the shape declared by a certificate row and is enclosed by its interval. The equality witness makes the dependent tensor cast explicit.
Instances For
Pointwise approximation relation for real and IEEE dynamic graph values at one certificate row.
Instances For
One successful dynamic replay row yields a pointwise error bound whenever the corresponding real graph value has the proved enclosure.
Check every value produced by IR.Graph.denoteAll against the corresponding certificate row.
Instances For
A successful replay check is exactly a size match plus a successful check at every node.
Graph-wide pointwise approximation evidence, one row per intermediate value.
Instances For
Compose real enclosure proofs and successful IEEE replay checks into an error trace.
Compare a checked canonical row with untrusted raw certificate data.
Instances For
Read a previously checked parent enclosure. Graph well-formedness guarantees that successful lookups refer only to earlier rows; the explicit error still protects this API when called alone.
Instances For
Read the complete checked row for a parent node.
Instances For
Outward-rounded left-fold range for a sum of count values from one enclosure. The initial
point interval at positive zero matches Tensor.sumSpec.
Instances For
Left-fold mean range, using the same binary32 conversion of the divisor as the tensor context.
Instances For
Numerical policy selected for a runtime-relevant graph node.
Instances For
Reductions are propagated only when the selected capsule promises the same fixed left fold as
the canonical tensor semantics. Other schedules need the order-independent reduction bound from
NN.Proofs.RuntimeApprox.Reductions.IEEE32 and are rejected here rather than mislabeled as
deterministic.
Instances For
Inner accumulation length for the rank-2 and batched rank-3 matrix products implemented by
IR.Graph.denoteAll. The graph shape checker has already validated matching dimensions; retaining
the checks here gives callers of deriveNodeRange a precise error instead of relying on that
ambient invariant.
Instances For
Hull of a nonempty array of parent ranges.
Instances For
Graph range contracts #
Architectures do not participate in range propagation directly. They lower to NN.IR.Graph, and
each graph node is handled by a reusable operation contract. This keeps MLPs, convolutional
networks, transformers, and future model families on one checker path: adding a model requires no
new certificate traversal, while adding a genuinely new primitive requires one local contract.
The registry is an explicit value rather than global mutable state. Certificate generation and checking therefore use the same inspectable rule set, and downstream projects may extend it without changing TorchLean's graph walker.
Stable key for a numerical range contract.
Input-like nodes share the source contract, detach uses the structural identity contract, and
runtime operations use the same BackendOp vocabulary as kernel capsules and execution plans.
- source : NumericalOpKey
- structural : NumericalOpKey
- wholeSum : NumericalOpKey
- maxPool : NumericalOpKey
- maxPoolPad : NumericalOpKey
- averagePool : NumericalOpKey
- averagePoolPad : NumericalOpKey
- backend (op : NN.Backend.BackendOp) : NumericalOpKey
- unclassified : NumericalOpKey
Instances For
Instances For
Instances For
Classify an IR operation for numerical-contract lookup.
Instances For
Read-only state supplied to one local range transfer.
- sources : Array CheckedSourceRange
- ranges : Array CheckedNodeRange
Instances For
Result computed by one numerical operation contract.
Instances For
Executable range transfer for one operation family.
The proof-facing meaning of the resulting row remains SomeTensorEnclosed; local soundness lemmas
for interval arithmetic and NF approximation are kept in their mathematical modules. The contract
contains only executable dispatch and a stable key, so serializable certificates cannot inject
proof evidence.
- key : NumericalOpKey
- name : String
- derive : NumericalRangeContext → NN.IR.Node → Except String RangeTransferResult
Instances For
Deterministic registry used by graph certificate generation and replay.
- name : String
- contracts : Array GraphRangeContract
Instances For
Empty named registry for downstream composition.
Instances For
Find the unique contract associated with a numerical operation key.
Instances For
Add one contract, rejecting duplicate keys so dispatch never depends on registration order.
Instances For
Build a registry while checking key uniqueness.
Instances For
One graph node for which a numerical registry has no local transfer.
- nodeId : ℕ
- operation : String
- key : NumericalOpKey
Instances For
Architecture-independent coverage report obtained after lowering a model to NN.IR.Graph.
- registryName : String
- nodeCount : ℕ
- coveredCount : ℕ
- missing : Array MissingNumericalContract
Instances For
Inspect contract coverage without attempting interval propagation.
Instances For
Reject a graph before propagation when any primitive lacks a numerical contract.
Instances For
Standard diagnostic for a contract whose graph arity does not match its operation.
Instances For
Shared source-node contract. The source interval remains an explicit certificate assumption.
Instances For
Structural identity used by detach.
Instances For
Reusable contract constructor for value-preserving graph operations.
Instances For
Reusable contract constructor for pointwise binary interval operations.
Instances For
Reusable contract for operations whose output is enclosed by the hull of their parents.
Instances For
Max pooling without padding selects existing values and therefore preserves the input hull.
Instances For
Padded max pooling may additionally select the padding value zero.
Instances For
Shared average-pooling contract constructor.
Instances For
Reciprocal contract with an explicit nonzero-domain check.
Instances For
Whole-tensor fixed-left sum contract.
Instances For
Axis reduction contract shared by sum and mean.
Instances For
Matrix multiplication contract using the selected fixed-left accumulation schedule.
Instances For
Mean-squared-error contract with nonnegativity restored after dependent squaring.
Instances For
Pure LayerNorm contract over an arbitrary normalized suffix.
Instances For
Softmax contract: exact-real outputs lie in the unit interval on every nonempty axis.
Instances For
ReLU interval contract.
Instances For
Absolute-value interval contract.
Instances For
Square-root contract with a checked nonnegative domain.
Instances For
Constructor for bounded transcendental contracts.
Instances For
Built-in numerical contracts. Grouping is by operation semantics, never by architecture.
Instances For
TorchLean's built-in numerical registry. Construction is checked once at use sites so a future duplicate produces an explicit configuration failure.
Instances For
Compute one node range using an explicit numerical contract registry.
Instances For
Compute one node range using TorchLean's built-in registry.
Instances For
Construct and validate the canonical range trace using an explicit contract registry.
Instances For
Construct and validate the canonical range trace using TorchLean's built-in contracts.
Instances For
Erase validity proofs from a checked trace.
Instances For
Compare a canonical checked trace with untrusted raw rows.