Nearest Rounding with a Tie Choice #
nearestChoice chooseUp rounds to a nearest integer. At an exact midpoint, chooseUp f
decides whether the lower integer f or the upper integer f + 1 is selected. This is the native
Lean counterpart of Flocq's Znearest choice.
theorem
FloatLib.Floats.Formats.Flocq.nearestChoice_eq_floor_or_ceil
(chooseUp : ℤ → Bool)
(x : ℝ)
:
Choice-based nearest rounding always selects floor or ceiling.
Choice-based nearest rounding lies between floor and floor plus one.
@[simp]
Choice-based nearest rounding fixes integers.
Every tie choice has absolute error at most one half.
theorem
FloatLib.Floats.Formats.Flocq.nearestChoice_mono
(chooseUp : ℤ → Bool)
{x y : ℝ}
(hxy : x ≤ y)
:
Choice-based nearest rounding is monotone.
instance
FloatLib.Floats.Formats.Flocq.nearestChoiceValid
(chooseUp : ℤ → Bool)
:
ValidRndToNearest (nearestChoice chooseUp)
Every tie-choice nearest mode is a valid nearest rounding mode.