Directed rounding soundness for IEEE32Exec #
NN/Floats/IEEEExec/Exec32.lean defines executable directed rounding on the IEEE-754 binary32
grid:
roundDyadicDown/roundDyadicUpround an exact dyadic toward-∞/+∞.addDown/addUp,mulDown/mulUplift this to outward-rounded arithmetic for interval endpoints.
This file proves (one core piece of) the enclosure direction (“golden theorem” style): the directed rounding down kernel for positive dyadics is a sound lower bound for the exact real value.
Scope (what is proved here):
roundDyadicPosDown/roundDyadicPosUpsoundness (inEReal, to handle overflow to±∞).- Full dyadic rounding soundness:
roundDyadicDownis a lower bound androundDyadicUpis an upper bound for the exact dyadic real semantics. - Interval-endpoint soundness for
addDown/addUp/mulDown/mulUpon finite inputs, as inequalities inERealbetween the executable endpoint operation and the exact real operation.
Non-goals (not proved here yet):
- Correctly-rounded/outward-rounded transcendental functions w.r.t. a standard libm. IEEE-754 does not specify libm results; for rigorous transcendentals, prefer the Arb oracle backend.
- Division/sqrt interval primitives (substantially larger; requires separate algorithms + proofs).
References:
- IEEE 754-2019 (floating-point arithmetic): doi:10.1109/IEEESTD.2019.8766229
- Goldberg (1991), “What Every Computer Scientist Should Know About Floating-Point Arithmetic”: doi:10.1145/103162.103163
Basic helpers #
Instances For
Interpret bpow at a negative successor exponent as an inverse power of two.
A few float32 constants as reals #
Shift helpers (floor/ceil division by powers of two) #
shiftRightCeilPow2 is also controlled from above by the corresponding floor quotient:
ceil-division can overshoot by at most 1.
Soundness: directed rounding on positive dyadics #
roundDyadicPosDown is a real lower bound for a positive dyadic.
roundDyadicPosUp mant exp is an EReal upper bound for the positive dyadic (mant : ℝ) * 2^exp.
This is the “ceil” counterpart to toReal_roundDyadicPosDown_le.
toEReal respects negation on the finite/dyadic branch.
We phrase this lemma using the dyadic decode witness toDyadic? x = some d, which guarantees:
xis finite (hencetoERealagrees withtoReal), andtoReal (neg x) = -toReal x(viatoReal_neg_eq_neg).
Negation / sign-bit flip helpers #
Negation preserves “not NaN” #
If x is not a NaN then neg x is not a NaN.
We only state the direction we actually need in the directed-rounding development: negative
directed rounding is implemented as neg of a positive kernel, so we need to know this cannot
introduce a NaN when starting from a non-NaN value.
toEReal commutes with neg as long as we are not in the NaN case.
This is a small but important glue lemma: it lets us lift the positive rounding kernels to the
signed directed-rounding functions (roundDyadicDown / roundDyadicUp) without introducing new
floating-point corner cases.
Soundness of roundDyadicDown: the result is ≤ the exact dyadic real value (in EReal).
This is the key lemma needed to justify addDown/mulDown as interval lower endpoints.
roundDyadicPosDown (directed rounding toward -∞ for positive dyadics) never produces a
NaN/Inf value.
We package this as an existence statement: the output always has a dyadic decode.
This is the bridge we use later to turn toEReal into toReal (as an EReal) without unfolding
all bit-level definitions at call sites.
Soundness of roundDyadicDown: it produces an EReal lower bound for the exact dyadic value.
Informal: rounding down is monotone towards -∞, so the rounded result is always ≤ the exact
real meaning.
Soundness of roundDyadicUp: the result is ≥ the exact dyadic real value (in EReal).
This is the key lemma needed to justify addUp/mulUp as interval upper endpoints.
Lower-endpoint soundness for addDown on finite inputs:
the result is ≤ the exact real sum (in EReal), even in overflow-to--∞ scenarios.
Upper-endpoint soundness for addUp on finite inputs:
the exact real sum is ≤ the result (in EReal), with overflow rounding to +∞.