Correctness of packed native-word Posit square root #
The storage adapter decodes once, scales the exact significand into four fixed words, and runs the shared restoring square-root kernel. Its proved root and remainder are jammed into the common guard/sticky rounder, giving the executable word path exactly the arbitrary-width direct square-root semantics.
theorem
FloatLib.Floats.Formats.Posit.Model.NativeWordArithmetic.PackedSquareRoot.roundFieldsWord_toNat_eq_direct
(format : Format)
(heligible : NativeWord.Eligible format)
(negative : Bool)
(significand : UInt64)
(exponent : ℤ)
:
(roundFieldsWord format heligible negative significand exponent).toNat = if { negative := negative, significand := significand.toNat, exponent := exponent }.isLess Numerics.Dyadic.zero = true then
format.signMaskNat
else DirectDyadicSquareRoot.roundCode format
{ negative := negative, significand := significand.toNat, exponent := exponent }
Native field rounding is exactly the common direct square-root domain rule.
theorem
FloatLib.Floats.Formats.Posit.Model.NativeWordArithmetic.PackedSquareRoot.sqrtWordCodeValid_eq
{format : Format}
(heligible : NativeWord.Eligible format)
(value : UInt64)
(hvalue : value.toNat < format.modulus)
:
The packed scalar adapter is exactly the stored-word square-root kernel.
theorem
FloatLib.Floats.Formats.Posit.Model.NativeWordArithmetic.PackedSquareRoot.sqrtWordCodeValid_lt_modulus
{format : Format}
(heligible : NativeWord.Eligible format)
(value : UInt64)
(hvalue : value.toNat < format.modulus)
:
Every packed scalar square root is a complete in-range Posit encoding.
theorem
FloatLib.Floats.Formats.Posit.Model.NativeWordArithmetic.PackedSquareRoot.sqrtWordCodeWordValid_toNat
{format : Format}
(heligible : NativeWord.Eligible format)
(value : UInt64)
(hvalue : value.toNat < format.modulus)
:
The word-valued and natural-number views of the complete root code are identical.