TorchLean API

NN.Proofs.RuntimeApprox.Core.Tolerance

Tolerance #

Approximation tolerances (absolute + relative).

This file defines a small, reusable tolerance object for "close enough" reasoning:

It is intentionally lightweight and independent of any specific backend (IBP/FP32/etc.).

PyTorch correspondence / citations #

PyTorch (and NumPy) commonly expose absolute + relative tolerances (often called atol/rtol) in APIs like torch.allclose / torch.testing.assert_allclose. Our approxBound follows the same pattern, but uses max |x| |y| as the relative scale so the bound is symmetric in x and y. https://pytorch.org/docs/stable/generated/torch.allclose.html https://pytorch.org/docs/stable/testing.html

Absolute/relative tolerance with an extra nonnegative slack factor.

Instances For

    Build a tolerance from reals, clamping negatives to 0 via Real.toNNReal.

    Instances For

      Default slack = 1.

      Instances For

        Absolute-only tolerance (relative = 0, slack = 1).

        Instances For

          Scalar abs+rel error budget using max |x| |y| as the scale.

          Instances For

            Scalar approximation under an abs+rel tolerance.

            Instances For
              theorem Proofs.RuntimeApprox.approxBound_mono {t₁ t₂ : ApproxTol} (habs : t₁.abs t₂.abs) (hrel : t₁.rel t₂.rel) (hslack : t₁.slack t₂.slack) (x y : ) :
              approxBound t₁ x y approxBound t₂ x y
              theorem Proofs.RuntimeApprox.approxR_mono {x y : } {t₁ t₂ : ApproxTol} (habs : t₁.abs t₂.abs) (hrel : t₁.rel t₂.rel) (hslack : t₁.slack t₂.slack) (h : approxR x y t₁) :
              approxR x y t₂
              theorem Proofs.RuntimeApprox.approxR_absOnly_iff {x y eps : } (heps : 0 eps) :
              approxR x y (ApproxTol.absOnly eps) |y - x| eps
              theorem Proofs.RuntimeApprox.approxR_absOnly_trans {x y z eps₁ eps₂ : } (h₁ : 0 eps₁) (h₂ : 0 eps₂) (hxy : approxR x y (ApproxTol.absOnly eps₁)) (hyz : approxR y z (ApproxTol.absOnly eps₂)) :
              approxR x z (ApproxTol.absOnly (eps₁ + eps₂))

              Notation #

              Use open scoped ApproxTol to enable:

              x ≈[t] y meaning: approxR x y t.