Correctness of nearest-even real rounding #
For conventional IEEE descriptors, Model.roundDyadic delegates normalization to Lean's generic
logical float model. This module relates that executable result to the independent Flocq-style
rounded-real semantics in FloatLib.Floats.Formats.Flocq.FloatRep. Exponent and fraction widths
remain symbolic. The grid membership and preservation results also cover custom biases and
encoding policies; the executable rounding refinement requires fmt.isIEEE = true.
The rounded-real model has gradual underflow but no infinities. Consequently refinement theorems carry an explicit hypothesis that the executable result is finite; an overflowing IEEE result cannot equal a real-valued rounding function.
References #
- IEEE Standard for Floating-Point Arithmetic, IEEE 754-2019, Section 4.3.1.
- S. Boldo and G. Melquiond, "Flocq: A Unified Library for Proving Floating-Point Algorithms in Coq," ARITH 2011. https://doi.org/10.1109/ARITH.2011.40
- Lean 4,
Init.Data.Float.Model.Unpacked.Round.
Precision and gradual-underflow grid using the descriptor’s declared exponent bias.
Instances For
Nearest-even rounding with the descriptor's precision, bias, and gradual underflow.
The real grid has no upper exponent bound. Overflow and exceptional encodings belong to the
executable operation; its equality to roundAt needs the corresponding refinement hypotheses.
Instances For
Nearest-even rounding on a binary format fixes zero.
Nearest-even rounding on a binary format commutes with negation.
Nearest-even rounding is monotone on the exact real input.
Every finite decoded word belongs to its descriptor's precision and gradual-underflow grid. The result includes custom biases, FNUZ, and finite-only encodings.
The absolute value of a dyadic ignores its stored sign bit.
A nonzero dyadic has the leading exponent predicted by its integer mantissa.
Lean's model and the rounded-real format choose the same exponent for a nonzero dyadic.
The canonical scaled mantissa of a dyadic is its signed magnitude at the target exponent.
Nearest-even rounding of a nonnegative dyadic agrees with executable shift-and-round.
Nearest-even rounding commutes with the sign stored in a dyadic value.
The executable natural power of two has the same real value as the binary radix power.
Rounded-real semantics of a nonzero dyadic at a conventional IEEE descriptor.
The integer on the right is computed entirely by shifts and nearest-even rounding. The exponent is
chosen by Lean's generic logical float model and independently characterized by fexpOf.
Real value of a finished rounded mantissa on the subnormal grid.
The mantissa may be zero, in which case the packed value is a signed zero, or reach
2 ^ fracWidth, in which case it is the least normal value; both have the stated real value.
Real value of a finished normalized rounded mantissa with leading bit at unbiased exponent k.
The mantissa lies in [2 ^ fracWidth, 2 ^ (fracWidth + 1)]; the upper endpoint is the carry that
finishRoundedMantissa renormalizes to exponent k + 1. The finiteness hypothesis excludes IEEE
overflow, which has no value in ℝ.
Executable dyadic rounding refines the rounded-real semantics for conventional IEEE descriptors.
The finiteness hypothesis excludes the one case that has no value in ℝ: IEEE overflow to
infinity. Both the IEEE-descriptor condition and result finiteness are explicit hypotheses; custom
widths are allowed when they satisfy that descriptor condition.