Directed rounding (down/up) for Flocq-style formats #
For interval propagation under a discrete numeric grid (float, fixed-point, quantization), one typically wants directed rounding at interval endpoints:
down xis a representable value with $\operatorname{down}(x)\le x$,up xis a representable value with $x\le\operatorname{up}(x)$.
In IEEE-754 hardware this corresponds to rounding modes “toward $-\infty$” and
“toward $+\infty$”. In TorchLean’s proof-oriented model we represent this with Flocq-style
rounding on $\mathbb{R}$ via neuralRound together with
the floor/ceil rounding functions from NN/Floats/NeuralFloat/Rounding/Core.lean.
This file is format-generic: it works for any radix $\beta$ and exponent selection
function fexp satisfying NeuralValidExp.
References:
- IEEE 754-2019 (rounding modes; directed rounding).
- Higham, Accuracy and Stability of Numerical Algorithms, 2nd ed., SIAM, 2002.
- Flocq (rounded arithmetic on reals).
Format-directed rounding down to the $(\beta,\mathtt{fexp})$ grid (via floor rounding of the scaled mantissa).
Instances For
Format-directed rounding up to the $(\beta,\mathtt{fexp})$ grid (via ceil rounding of the scaled mantissa).
Instances For
Correctness of directed rounding down: roundDown x is an enclosure lower bound.
This is the format-generic analogue of the IEEE-754 fact that rounding toward $-\infty$ never exceeds the exact real value.
Correctness of directed rounding up: roundUp x is an enclosure upper bound.
This is the format-generic analogue of the IEEE-754 fact that rounding toward $+\infty$ is never below the exact real value.
Canonical rounder for the $(\beta,\mathtt{fexp})$ format via roundDown/roundUp.