TorchLean API

FloatLib.Floats.Formats.BinaryInterchange.Rounding.NearestEven

Nearest-even rounding lemmas #

Format-independent integer primitives in Numerics agree with FloatLib's rounded-real nearest-even operation under the stated bounds.

Generic shift-rounding equations and floor bounds live in Numerics.Quantization.Deterministic.ShiftRight, where fixed-point and other binary quantizations can reuse them. This module adds normalized-significand bounds, oddness of nearestEven, and its agreement with executable rounding of nonnegative rationals.

theorem FloatLib.Floats.Formats.BinaryInterchange.Model.roundShiftRightEven_add_normalized_bounds (precision left right : ) (hleft : 2 ^ precision left left < 2 ^ (precision + 1)) (hright : 2 ^ precision right right < 2 ^ (precision + 1)) :
2 ^ precision Numerics.roundShiftRightEven (left + right) 1 Numerics.roundShiftRightEven (left + right) 1 < 2 ^ (precision + 1)

Nearest-even averaging preserves the normalized interval for every significand precision.

Nearest-even integer rounding commutes with negation.

Nearest-even rounding never exceeds a natural upper bound of its argument.

Nearest-even rounding never drops below a natural lower bound of its argument.

theorem FloatLib.Floats.Formats.BinaryInterchange.Model.floor_real_nat_div (num den : ) :
num / den = ↑(num / den)

The floor of a quotient of natural numbers in is their natural-number quotient.

Nearest-even rounding of a nonnegative rational agrees with roundQuotientEven.

Nearest-even rounding after division by 2^shift is executable shift rounding.