Exact representable square roots #
On a finer decimal grid, a representable root has an integer coefficient. Squaring that integer identifies the scaled radicand exactly, so every rounding mode recovers the same root. No test for irrationality is needed.
theorem
FloatLib.Floats.Formats.DecimalInterchange.sqrtRound_lt_coefficientBound_of_valid
(f : Format)
(mode : RoundingMode)
(s : Bool)
(c : ℕ)
(q : ℤ)
(hvalid : Datum.Valid f (Datum.finite s c q))
:
The coefficient of an exact representable root cannot require a carry.
theorem
FloatLib.Floats.Formats.DecimalInterchange.sqrtPair_quantum_le_of_valid
(f : Format)
(mode : RoundingMode)
(s : Bool)
(c : ℕ)
(q : ℤ)
(hvalid : Datum.Valid f (Datum.finite s c q))
:
An exact root's normalized grid is no coarser than any valid representation of that root.
theorem
FloatLib.Floats.Formats.DecimalInterchange.sqrtPair_exact_value
(f : Format)
(mode : RoundingMode)
(s : Bool)
(c : ℕ)
(q : ℤ)
(hvalid : Datum.Valid f (Datum.finite s c q))
:
All five modes recover every representable nonnegative root exactly.
theorem
FloatLib.Floats.Formats.DecimalInterchange.sqrtMagnitude_exact_status
(f : Format)
(mode : RoundingMode)
(s : Bool)
(c : ℕ)
(q preferred : ℤ)
(hvalid : Datum.Valid f (Datum.finite s c q))
:
Exact representable roots raise none of the five default exception flags.
theorem
FloatLib.Floats.Formats.DecimalInterchange.sqrtMagnitude_exact
(f : Format)
(mode : RoundingMode)
(s : Bool)
(c : ℕ)
(q preferred : ℤ)
(hvalid : Datum.Valid f (Datum.finite s c q))
:
Exact square-root projection returns the nonnegative root, regardless of its representation.