Correctness of exact-dyadic posit rounding #
The executable posit rounder searches codes using exact dyadic comparisons, chooses between
neighbors with ties-to-even, restores the sign, and packs the final model value. This module proves
that the complete pipeline is equal to the simple rational specification in Rounding.Proof.
Using dyadics avoids constructing large rational numerators in the runtime, but it does not change the rounding rule. The lemmas here are the common semantic boundary for arbitrary-precision, native-word, and fixed-limb posit backends, so specialized kernels need only prove that their local comparisons agree with this rounder.
A positive code below the sign mask takes the ordinary finite branch of the totalized decoder.
Native-word and fixed-limb backends use this shared fact after proving that their direct field
decoder agrees with Model.decodeFields; the exceptional-value argument therefore lives in one
place rather than being duplicated by every representation backend.
Dyadic code decoding has the same rational denotation as the reference helper.
The dyadic and rational lower-code searches are extensionally identical.
A locally bracketed candidate is exactly the lower code selected by bisection.
This is a property of the exact dyadic specification, not of any execution backend. Direct packers use it to prove their field constructors once, then execute without searching.
Decoding code 1 yields the closed minimum-positive dyadic fields.
The smallest positive posit is a unit significand at the bottom regime scale.
This closed form is shared by every execution backend, so underflow tests do not decode the
fixed encoding 1 on each arithmetic operation.
The executable closed form equals the standard decoding of code 1.
The smallest positive posit's exponent is a lower bound for every ordinary nonzero posit scale.
The negative-regime case uses the mandatory terminator bit: a nonzero magnitude cannot consume the complete payload as a run of leading zeros. This is the representation fact needed to align an exact product of two posits with the associated quire.
The dyadic minimum has exactly the reference minimum's rational denotation.
The dyadic threshold has exactly the reference threshold's rational denotation.
Single-comparison nearest-even selection equals the reference two-predicate decision tree.
Nearest-even selection returns one of the two supplied neighboring codes.
Positive dyadic rounding selects exactly the code chosen by the rational specification.
The hypotheses are the invariant established by round: zero has already been handled and the
temporary magnitude has its sign cleared.
Positive exact-dyadic rounding re-encodes every nonnegative finite posit code.
This is the dyadic counterpart of Model.roundPositiveCode_nonnegativeRatAt. Native execution
backends use it to return an exactly representable direct candidate without decoding its
successor or the one-bit-wider rounding boundary.
Positive dyadic model rounding refines the reference rational model rounding.
Clearing the sign leaves the integer significand unchanged.
The magnitude of a dyadic has a clear sign bit.
Direct sign restoration preserves the configured posit word width.
Packing a sign-restored code agrees with whole-word model negation.
Exact-dyadic rounding returns exactly the reference rational specification.