Rounding Into A Generic Format #
Rounding any real with a valid integer-rounding rule produces a value in the selected generic format. The proof separates inputs whose magnitude is at most the selected exponent from those above it.
theorem
FloatLib.Floats.Formats.Flocq.round_pos_small_cases
{β : Numerics.Radix}
{fexp : ℤ → ℤ}
[ValidExp fexp]
(rnd : ℝ → ℤ)
[ValidRnd rnd]
(x : ℝ)
(hx : 0 < x)
(hsmall : magnitude β x ≤ fexp (magnitude β x))
:
Positive inputs in the small-magnitude regime round either to zero or to one radix power.
theorem
FloatLib.Floats.Formats.Flocq.generic_format_round_pos_small
{β : Numerics.Radix}
{fexp : ℤ → ℤ}
[ValidExp fexp]
(rnd : ℝ → ℤ)
[ValidRnd rnd]
(x : ℝ)
(hx : 0 < x)
(hsmall : magnitude β x ≤ fexp (magnitude β x))
:
genericFormat β fexp (round rnd x)
Rounding in the small-magnitude regime produces a generic-format value.
theorem
FloatLib.Floats.Formats.Flocq.round_pos_large_bounds_and_generic
{β : Numerics.Radix}
{fexp : ℤ → ℤ}
[ValidExp fexp]
(rnd : ℝ → ℤ)
[ValidRnd rnd]
(x : ℝ)
(hx : 0 < x)
(hlarge : fexp (magnitude β x) < magnitude β x)
:
In the large-magnitude regime, the rounded value lies between the endpoints of the input magnitude bin, including the upper endpoint, and belongs to the generic format.
theorem
FloatLib.Floats.Formats.Flocq.generic_format_round_pos_large
{β : Numerics.Radix}
{fexp : ℤ → ℤ}
[ValidExp fexp]
(rnd : ℝ → ℤ)
[ValidRnd rnd]
(x : ℝ)
(hx : 0 < x)
(hlarge : fexp (magnitude β x) < magnitude β x)
:
genericFormat β fexp (round rnd x)
Rounding in the large-magnitude regime produces a generic-format value.
theorem
FloatLib.Floats.Formats.Flocq.generic_format_round_pos
{β : Numerics.Radix}
{fexp : ℤ → ℤ}
[ValidExp fexp]
(rnd : ℝ → ℤ)
[ValidRnd rnd]
(x : ℝ)
(hx : 0 < x)
:
genericFormat β fexp (round rnd x)
Every positive real rounds into the selected generic format.
theorem
FloatLib.Floats.Formats.Flocq.generic_format_round
{β : Numerics.Radix}
{fexp : ℤ → ℤ}
[ValidExp fexp]
(rnd : ℝ → ℤ)
[ValidRnd rnd]
(x : ℝ)
:
genericFormat β fexp (round rnd x)
Rounding any real produces a value in the selected generic format.