Executable width-generic finite arithmetic #
Arbitrary-precision kernels decode finite fields into a compact unsigned-scale representation.
Compiled arithmetic uses their allocation-reduced entry points for addition, multiplication,
division, and fused multiply-add. Refinement theorems live in Kernel.Proof.
Decoded finite fields before conversion to a signed dyadic exponent.
For a nonzero value, the magnitude is
mantissa * 2^(scale exponent - finiteScaleOffset fmt), with the subtraction interpreted in Int.
The separate sign field determines its sign.
- sign : Bool
Sign bit of the encoded value.
- exponent : ℕ
Biased exponent field; zero also identifies zeros and subnormals.
- mantissa : ℕ
Integer significand, including the implicit bit for a normal value.
Instances For
Instances For
Nonnegative scale associated with a finite exponent field.
Instances For
Common nonnegative offset used by the compact finite-field scale.
Instances For
Signed dyadic exponent associated with a finite exponent field, including subnormals.
Instances For
Decode the integer significand from finite exponent and fraction fields.
Subnormal values use the stored fraction directly. Normal values restore the implicit leading bit. The formula is width-generic and shared by every natural-number finite decoder.
Instances For
Convert compact finite components to the exact dyadic representation used by proofs.
Instances For
Decode the sign, exponent, and significand of a finite value.
none means the complete format descriptor classifies the input as non-finite. No
precision-specific constant occurs here.
Instances For
Run k on scalar fields when x is finite.
The IEEE branch converts the storage word to Nat once and does not allocate an intermediate
Components value. Other encodings retain the descriptor-aware decoder.
Instances For
Compiled finite addition aligns unsigned field scales before entering the rounder.
For non-IEEE descriptors it evaluates the same exact-dyadic definition used in the logic.
Instances For
Add two already-decoded finite values and round once to fmt.
The exact dyadic sum is rounded by the descriptor-generic integer implementation. Importing
Kernel.Proof also enables the verified compiler substitution to addComponentsImpl, which
uses unsigned scale alignment on IEEE descriptors.
Instances For
Finite addition through the compact decoder.
The component operation is kept separate so fixed-width storage backends can reuse the same exact dyadic addition and rounding policy after a cheaper field decode.
Instances For
Finite multiplication using compact field scales.
The exact significand product remains a Nat, preserving arbitrary precision. Only the two
operand decodes and exponent algebra are fused; final rounding still uses the generic rounder.
Instances For
Finite division using compact field scales.
The format-dependent exponent offset cancels between numerator and denominator. The quotient still uses the exact arbitrary-precision rational rounder; only decoding and exponent construction are fused.
Instances For
Decode finite operands once, then apply divComponents.
Instances For
Exact product used by the finite fused-multiply-add kernel.
The exponent is expressed with nonnegative field scales. When either significand is zero this
exponent is observationally irrelevant: addDyadic identifies a zero from its mantissa and applies
the same signed-zero rule as the public dyadic path.
Instances For
Compiled finite FMA adds the exact product and addend in one unsigned scale coordinate.
The addend scale receives one format offset so both operands use the product rounder's two-offset coordinate. No intermediate dyadic exponent is allocated on the IEEE fast path.
Instances For
Exact finite fused multiply-add from three already-decoded values.
The exact dyadic result is rounded once by the descriptor-generic integer implementation.
Importing Kernel.Proof also enables the verified compiler substitution to fmaComponentsImpl,
which uses unsigned scale alignment on IEEE descriptors.
Instances For
Finite fused multiply-add using compact field scales for the exact product.
All three inputs are decoded once. The product and addend remain exact dyadics and the result is rounded only once, so this is still a true fused operation at every supported precision.
Instances For
Scalar-field compiled entry points #
Add finite scalar fields without materializing decoded component records on IEEE formats.
Instances For
Compiled finite addition with scalar field decoding.
Instances For
Multiply finite scalar fields using the compact product scale.
Instances For
Compiled finite multiplication with scalar field decoding.
Instances For
Divide finite scalar fields using the compact exponent difference.
Instances For
Compiled finite division with scalar field decoding.
Instances For
FMA on finite scalar fields without allocating decoded component records on IEEE formats.
Instances For
Compiled finite FMA with scalar field decoding.
Instances For
Straight-line IEEE FMA decoder.
This calls the same fmaFields kernel as fmaRuntime?, with the three decodes written directly
instead of through nested continuations. fmaRuntimeFlat_eq proves their equality.