Packing finite values in Lean's float model #
Lean's Float.Model.UnpackedFloat.pack assumes that finite inputs have already been normalized for
the selected format. This module proves exact round trips for representable normal and subnormal
values in Lean's width-parameterized IEEE model. Agreement with the descriptor's real decoder
requires fmt.isIEEE = true.
Numerical rounding is handled separately by the rounding semantics.
If packing a finite logical value produces a finite executable value, the biased exponent did not reach the all-ones encoding. This observable side condition keeps overflow handling out of arithmetic refinement proofs.
Packing and unpacking a representable normal value preserves the unpacked value exactly.
Packing a representable normal model value preserves its exact real value.
Packing and unpacking a nonzero subnormal preserves its sign, mantissa, and exponent.
Packing and unpacking any nonzero value on the minimum-exponent grid is exact up to and including
the smallest normal value. The endpoint 2^p changes encoding class, but not its unpacked logical
value.
Packing a representable nonzero subnormal preserves its exact real value.
Every nonzero value on the minimum-exponent grid up to the smallest normal value keeps its exact real value when packed.