Executable exact-intermediate finite arithmetic #
Storage and accumulation may use different precisions. For example, mulAddFinite? can read FP8
operands and accumulate their product in FP32. These operations separate the exact intermediate
calculation from destination rounding:
- inputs are decoded to exact dyadics;
- addition and multiplication occur in the exact integer intermediate;
- the result is rounded once into the selected destination format and policy.
The checked operations return Option. none means that an input was NaN or infinity, or that
division encountered a zero denominator. A successful result can still overflow according to the
selected output policy. This avoids inventing arithmetic rules for
storage formats whose standards specify encodings and conversions but no standalone arithmetic.
A hardware-specific layer can add its documented exceptional-value behavior and prove refinement
to these finite paths.
Exact dyadic product used before destination-format rounding.
Instances For
Add two finite values exactly and round once into their common format.
Instances For
Subtract two finite values exactly and round once into their common format.
Instances For
Logical specification of finite multiplication.
Compiled format-specific dispatchers may replace the public entry point, but tables and proofs use this definition directly so their initialization cannot recurse through the compiled dispatcher.
Instances For
Compiled finite multiplication.
Nearest-even finite multiplication reuses the canonical Model.mul, including its native
word and exhaustive tiny-table backends. Every other policy retains the generic exact dyadic
implementation.
Instances For
Multiply two finite values exactly and round once into their common format.
Instances For
The compiled nearest-even finite path is extensionally equal to generic exact multiplication.
This theorem installs the canonical operation in generated code while proofs continue to unfold
mulFinite? to the format-independent policy specification.
Exact finite x * y + z, followed by one rounding step.
Instances For
Divide two finite values and round the exact rational quotient once.
Instances For
Fused multiply-add from one storage format into a potentially wider accumulator format.
For example, x and y may be FP8 while acc is BF16, FP16,
FP32, or a custom wider format. There is no intermediate rounding of the product.