SpecApprox #
Spec/runtime approximation bridge with explicit error bounds.
This is a spec-level statement: runtime values are mapped into Real and compared
against the spec using a chosen norm.
Trust boundary:
- This file is purely about stating approximation predicates. Turning it into an end-to-end theorem requires per-op approximation lemmas and a composition argument.
- For Lean
Float, such lemmas would require a formal semantics of IEEE-754 operations; we do not prove those here, soFloatexecution is treated as trusted. - The intended proof-relevant path is to use rounding-model backends (
NeuralFloat/NF) where rounding error bounds are explicit and can be composed.
PyTorch correspondence / citations #
Conceptually, approxWith / approxTTol are theorem-level versions of “runtime tensor is close to spec
tensor under a chosen norm”, similar to how PyTorch uses norms and rtol/atol style checks in
testing/validation.
https://pytorch.org/docs/stable/generated/torch.linalg.vector_norm.html
https://pytorch.org/docs/stable/generated/torch.allclose.html
Convert a runtime tensor into the spec scalar by mapping a scalar function.
Instances For
Linf norm on spec tensors.
Instances For
Approximation predicate with an explicit error bound.
Instances For
Abs+rel approximation predicate with a ApproxTol budget (scaled by max ‖spec‖ ‖runtime‖).
Instances For
Default abs+rel tensor approximation (uses linf_norm).
Instances For
Notation #
Use open scoped ApproxTol to enable:
spec ≈ᵀ[toSpec, tol] runtime meaning: approxTTol toSpec spec runtime tol.
Packaged approximation witness (defaults to Linf on spec tensors).
- toSpec : α → Spec.SpecScalar
to Spec.
- spec : Spec.SpecTensor s
spec.
- runtime : Spec.Tensor α s
runtime.
- eps : Spec.SpecScalar
eps.
- bound : approxWith self.toSpec (fun {s : Spec.Shape} => linfNorm) self.spec self.runtime self.eps
bound.
Instances For
Map NeuralFloat tensors to spec scalars.
Instances For
Linf bound over NeuralFloat error markers.
Instances For
NeuralFloat runtime approximation to the spec with explicit epsilon bound.