TorchLean API

NN.Floats.NeuralFloat.Analysis.Ulp

Unit in the Last Place #

Format-generic properties of neuralUlp, including the lower-exponent witness used to define ulp 0. The definitions and hypotheses follow Flocq's Core/Ulp.v.

theorem TorchLean.Floats.neuralNegligibleExp_value_unique {fexp : } [NeuralValidExp fexp] {n m : } (hn : IsNeuralNegligibleExp fexp n) (hm : IsNeuralNegligibleExp 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 TorchLean.Floats.neuralUlp_neg {β : NeuralRadix} {fexp : } [NeuralValidExp fexp] (x : ) :
neuralUlp β fexp (-x) = neuralUlp β fexp x

ULP is invariant under negation.

@[simp]
theorem TorchLean.Floats.neuralUlp_abs {β : NeuralRadix} {fexp : } [NeuralValidExp fexp] (x : ) :
neuralUlp β fexp |x| = neuralUlp β fexp x

ULP is invariant under absolute value.

theorem TorchLean.Floats.neuralUlp_bpow {β : NeuralRadix} {fexp : } [NeuralValidExp fexp] (e : ) :
neuralUlp β fexp (neuralBpow β e) = neuralBpow β (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
Instances

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

    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 TorchLean.Floats.neuralUlp_le_abs_of_generic {β : NeuralRadix} {fexp : } [NeuralValidExp fexp] {x : } (hx0 : x 0) (hx : neuralGenericFormat β fexp x) :
    neuralUlp β fexp x |x|

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

    theorem TorchLean.Floats.neuralUlp_mono_pos {β : NeuralRadix} {fexp : } [NeuralValidExp fexp] [NeuralMonotoneExp fexp] {x y : } (hx : 0 < x) (hxy : x y) :
    neuralUlp β fexp x neuralUlp β fexp y

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