Checked integer quantization #
Acceptance is equivalent to representability of the rounded integer, rather than representability of the rational input. The same characterization covers arbitrary inclusive intervals and either word signedness.
theorem
FloatLib.Numerics.IntegerRange.round?_eq_some_iff
(range : IntegerRange)
(round : ℚ → ℤ)
(value : ℚ)
(integer : ℤ)
:
Acceptance preserves the chosen rounded integer and certifies its range. The rational input itself need not lie in the destination interval.
theorem
FloatLib.Numerics.IntegerRange.round?_eq_none_iff
(range : IntegerRange)
(round : ℚ → ℤ)
(value : ℚ)
:
Rejection depends only on the rounded integer lying outside the inclusive range. An empty range therefore rejects every input, independently of the rounding rule.
theorem
FloatLib.Numerics.IntegerFormat.zero_inRange
(destination : IntegerFormat)
:
destination.InRange 0
Zero is representable in every signed or unsigned word format, including width zero.
theorem
FloatLib.Numerics.IntegerFormat.toNat_ofNat_of_inRange
{width : ℕ}
{value : ℤ}
(hr : (unsigned width).InRange value)
:
Checked unsigned packing is exact, including width zero.