TorchLean API

FloatLib.Floats.Formats.Flocq.Theory.Analysis.Ulp

Unit in the Last Place #

The format-generic ulp laws cover the negligible-exponent witness used to define ulp 0, invariance under sign, representability, and the relationship to adjacent rounded values. The definitions and hypotheses follow Flocq's Core/Ulp.v.

These are mathematical analysis lemmas rather than executable kernels. Keeping them in the Flocq theory namespace makes the provenance and theorem correspondence visible while allowing runtime formats to depend on smaller exact-arithmetic modules.

theorem FloatLib.Floats.Formats.Flocq.negligibleExp_value_unique {fexp : } [ValidExp fexp] {n m : } (hn : IsNegligibleExp fexp n) (hm : IsNegligibleExp fexp m) :
fexp n = fexp m

Two negligible-exponent witnesses select the same format exponent.

Absence of a negligible exponent means fexp n < n at every exponent.

@[simp]
theorem FloatLib.Floats.Formats.Flocq.ulp_neg {β : Numerics.Radix} {fexp : } [ValidExp fexp] (x : ) :
ulp β fexp (-x) = ulp β fexp x

ULP is invariant under negation.

@[simp]
theorem FloatLib.Floats.Formats.Flocq.ulp_abs {β : Numerics.Radix} {fexp : } [ValidExp fexp] (x : ) :
ulp β fexp |x| = ulp β fexp x

ULP is invariant under absolute value.

theorem FloatLib.Floats.Formats.Flocq.ulp_bpow {β : Numerics.Radix} {fexp : } [ValidExp fexp] (e : ) :
ulp β fexp (bpow β e) = bpow β (fexp (e + 1))

The ULP of a radix power is selected at the next magnitude.

Exponent functions for which ULP values themselves remain representable.

  • ulpExponent (e : ) : fexp (fexp e + 1) fexp e

    The radix power selected as a ULP is representable at its own magnitude.

Instances

    The zero ULP is representable, including the FLX case where it equals zero.

    theorem FloatLib.Floats.Formats.Flocq.generic_format_ulp {β : Numerics.Radix} {fexp : } [ValidExp fexp] [ExpNotFlushToZero fexp] (x : ) :
    genericFormat β fexp (ulp β fexp x)

    Under the non-flush-to-zero condition, every ULP is representable.

    For a nonrepresentable input, directed-up and directed-down rounding differ by one ULP.

    theorem FloatLib.Floats.Formats.Flocq.ulp_le_abs_of_generic {β : Numerics.Radix} {fexp : } [ValidExp fexp] {x : } (hx0 : x 0) (hx : genericFormat β fexp x) :
    ulp β fexp x |x|

    One ULP is no larger than the absolute value of a nonzero representable number.

    theorem FloatLib.Floats.Formats.Flocq.ulp_mono_pos {β : Numerics.Radix} {fexp : } [ValidExp fexp] [MonotoneExp fexp] {x y : } (hx : 0 < x) (hxy : x y) :
    ulp β fexp x ulp β fexp y

    ULP is monotone on positive inputs when the exponent selector is monotone.