rndP — round-to-nearest on the unbounded-exponent p-bit grid #
The rounding operator behind the named float models (binary32, fp8E4M3 in
Binary32Instance.lean) and the bf16 sharding lemmas (DataParallel.SyncBf16), with the
standard model |rndP p x − x| ≤ 2⁻¹⁻ᵖ·|x| proved, and its commuting with scaling by 2^z
(rndP_zpow_mul, which the bf16 divisor step uses). A leaf on Mathlib alone, so a consumer that
needs only the operator does not import FloatBridge.
Round-to-nearest on the unbounded-exponent p-bit-significand grid.
For x ≠ 0 with binade exponent e = Int.log 2 |x| (i.e. 2^e ≤ |x| < 2^(e+1)),
round x to the nearest multiple of 2^(e−p) — a significand of p fractional
bits, every exponent available. Ties go toward +∞ (Mathlib's round); IEEE's
ties-to-even differs only at ties, where the error bound is the same. Overflow and
subnormals are idealized away, as in the standard model.
Equations
Instances For
The standard model, PROVED (formerly the ieeeRnd_err axiom):
|rndP p x − x| ≤ 2⁻¹⁻ᵖ·|x|. The grid spacing at x is 2^(e−p), nearest-rounding
contributes half a step 2^(e−p−1), and 2^e ≤ |x| turns that into the relative
bound. Mathlib-only: Int.zpow_log_le_self + abs_sub_round.
The repo's rounding model commutes with scaling by a power of two — the grid at
2^z·x is the grid at x scaled by 2^z, because the exponent is unbounded. The
exponent z is an integer, so this covers the multiplier R = 2^k and the divisor
1/R = 2^(-k) alike.