Correctness of bounded fixed-point semantics #
The bounded fixed-point kernels satisfy the rational contracts defined in Semantics.Core. The
operation contracts distinguish three policies:
- wrapping operations denote centered reduction of the exact coefficient;
- checked operations denote exact rational arithmetic when the destination coefficient fits;
- saturating operations denote exact coefficient arithmetic followed by signed-range clamping.
The wrapping addition, subtraction, and multiplication kernels use direct BitVec operations.
The storage scale is always positive.
The storage scale is nonzero.
Bounded decoding is valueOfCoefficient applied to the stored signed coefficient.
Coefficient recovery is exact on every bounded fixed-point code.
Forgetting the coefficient bound preserves the exact rational value.
Representation in the bounded system is equality of decoded rational values.
Decoding wrapping addition exposes centered coefficient reduction modulo 2 ^ width.
Decoding wrapping subtraction exposes centered coefficient reduction modulo 2 ^ width.
Wrapping multiplication stores the exact coefficient product modulo 2 ^ outWidth.
Decoding wrapping multiplication exposes the reduced product at the composed scale.
Checked multiplication returns the exact product when it fits the destination width.
Decoding saturating addition exposes exact coefficient addition followed by clamping.
Decoding saturating subtraction exposes exact coefficient subtraction followed by clamping.
Decoding saturating multiplication exposes the clamped product at the composed scale.
Decoding a wrapped sum whose exact coefficient fits the width gives the exact rational sum.
Decoding a wrapped difference whose exact coefficient fits the width gives the exact rational difference.
Encoding an exact coefficient product that fits the destination width decodes to the rational product at the composed scale.
A checked binary kernel satisfies a rational specification under a precondition once, on operands meeting the precondition, it returns a code decoding to the specified value.
Wrapping addition refines centered coefficient reduction.
Wrapping subtraction refines centered coefficient reduction.
Cross-width wrapping multiplication refines centered coefficient reduction.
Checked addition returns the exact rational sum whenever its coefficient fits.
Checked subtraction returns the exact rational difference whenever its coefficient fits.
Checked multiplication returns the exact rational product whenever its coefficient fits.
Saturating addition refines exact coefficient addition followed by clamping.
Saturating subtraction refines exact coefficient subtraction followed by clamping.
Saturating multiplication refines exact coefficient multiplication followed by clamping.