TorchLean API

NN.Proofs.RuntimeApprox.Graph.NumericalCertificate.Contracts

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.

Instances For

    Proof-free data for one graph node's numerical range.

    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
        def Proofs.RuntimeApprox.NumericalCertificate.ArraysRelated {α β : Type} (relation : αβProp) (xs : Array α) (ys : Array β) :

        Pointwise relation between two equally sized runtime arrays.

        Instances For

          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

                          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.

                          Instances For

                            Classify an IR operation for numerical-contract lookup.

                            Instances For

                              Read-only state supplied to one local range transfer.

                              Instances For
                                @[reducible, inline]

                                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.

                                  Instances For

                                    Deterministic registry used by graph certificate generation and replay.

                                    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.

                                              Instances For

                                                Architecture-independent coverage report obtained after lowering a model to NN.IR.Graph.

                                                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

                                                          Reusable contract constructor for value-preserving graph 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

                                                                                  Absolute-value interval contract.

                                                                                  Instances For

                                                                                    Square-root contract with a checked nonnegative domain.

                                                                                    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.

                                                                                                    Instances For