Descriptor-indexed binary-interchange proof model #
Model fmt is the bit-exact specification carrier for the binary-interchange family. Statically
declared formats use FloatLib.Floats.ExecFloat F, whose runtime representation is selected by
EncodedFormat F.
This model stores BitVec fmt.bitWidth so descriptor-generic specifications and refinement proofs
can quantify over a runtime-selected layout. Concrete format packages bridge their direct runtime
codes to this model at the proof boundary.
References #
- IEEE Standard for Floating-Point Arithmetic, IEEE 754-2019, Sections 3.4 and 6.2, https://doi.org/10.1109/IEEESTD.2019.8766229.
Instances For
Wrap a storage word as a Model.
Instances For
Wrap a Nat pattern, reduced to the format's exact bit width.
Instances For
Extract the raw storage word.
Instances For
Return the encoded bit pattern as a natural number.
Instances For
Every encoded word lies below the radix determined by its stored width.
Wrap a UInt32 pattern, truncating it when the destination has fewer than 32 bits.
Instances For
Re-encoding the exact natural-number bit pattern preserves a binary value.
An in-range natural-number pattern is not changed by fixed-width encoding.
Wrapping a storage word and reading it back is the identity.
Rewrapping the storage word of a value is the identity.
Field extraction and classification #
Whether the sign bit is set.
Instances For
The executable sign test is the most significant bit of the storage word.
The biased exponent field as a natural number.
Instances For
The low fracWidth bits of the fraction field.
Instances For
Whether x has an IEEE NaN bit pattern.
Instances For
Whether x has an IEEE quiet-NaN bit pattern.
Instances For
Whether x has an IEEE signaling-NaN bit pattern.
Instances For
Whether x has an IEEE infinity bit pattern.
Instances For
Whether x has an IEEE signed-zero bit pattern.
Instances For
Whether x has an IEEE finite bit pattern.
Instances For
Policy-aware classification #
Whether x is one of the NaN encodings selected by its complete format.
Instances For
Whether x is a quiet NaN.
The non-IEEE policies represented by FloatFormat.Encoding do not distinguish signaling from
quiet NaNs, so every NaN in those formats is classified as quiet.
Instances For
Whether x is a signaling NaN. Only the IEEE encoding has signaling NaNs.
Instances For
A value that is not a NaN cannot be a signaling NaN.
Whether x is an infinity. Only the IEEE encoding contains infinities.
Instances For
Whether x denotes zero under its complete format.
Instances For
Whether x denotes a finite value under its complete format.
Instances For
Whether x is a finite subnormal under its complete format.
Instances For
Encoding and constants #
Pack a sign, biased exponent, and fraction into one exact-width storage word.
Instances For
Construct a value from its sign, exponent, and fraction fields.
Instances For
Positive zero.
Instances For
The negative-zero bit pattern, which denotes NaN in FNUZ formats.
Instances For
Positive one.
Instances For
Negative one.
Instances For
The positive-infinity IEEE bit pattern. Use infinity? for policy-aware construction.
Instances For
The negative-infinity IEEE bit pattern. Use infinity? for policy-aware construction.
Instances For
Finite value of greatest magnitude with the requested sign.
Instances For
Largest finite positive value.
Instances For
Finite value with the largest negative magnitude.
Instances For
The canonical IEEE quiet-NaN bit pattern. Use canonicalNaN? for other encodings.
Instances For
Policy-aware constants #
Signed zero, canonicalizing negative zero when the format has only one zero.
Instances For
Signed infinity when the format supports it.
Instances For
A canonical NaN when the format has a NaN encoding.
Instances For
Total result for an invalid operation in the complete format descriptor.
Formats with a NaN encoding use their canonical NaN. A format whose every bit pattern is numeric uses positive zero because it has no exceptional result to encode.
Instances For
Signed infinity when the format supports it, otherwise the same-sign largest finite value.
This constructs a range boundary for saturation and interval endpoints. Nonsaturating
conversion, arithmetic, and exact reductions use nativeOverflow, which may return NaN
when the format reserves an exceptional encoding.
Instances For
Conventional IEEE invalid operations return the canonical NaN.
NaN propagation #
Set the quiet bit of a NaN, leaving non-NaN values unchanged.
Instances For
The IEEE 754 §9.7 payload of a binary NaN fraction field: the field without its quiet bit.
The quiet bit is the most significant fraction bit. It is therefore the highest set bit of a quiet NaN's field and clear in a signaling NaN's field, so the payload is recovered without knowing the fraction width. A zero field has payload zero. Non-IEEE encodings have no diagnostic payload bits, so their payload is zero.
Instances For
Diagnostic payload of a binary NaN, excluding its quiet bit.
Instances For
A quiet NaN of fmt carrying a source NaN's sign and payload, following IEEE 754-2019 §6.2.3.
IEEE encodings keep the sign, set the quiet bit, and keep the payload when it fits below the quiet
bit. A payload that does not fit is replaced by zero, the canonical payload. The maximum-NaN
encoding keeps only the sign, FNUZ has a single NaN, and a fully finite encoding returns
invalidResult fmt, positive zero.
Instances For
Return x quieted when it is a NaN.
Instances For
Select signaling NaNs before quiet NaNs, breaking ties from left to right.
Instances For
Ternary NaN selection used by fused multiply-add.
Instances For
Return a selected NaN, or continue with evidence that NaN selection produced no result.
The continuation proof is erased. Operations use it to rule out impossible ordinary branches without duplicating selection logic.
Instances For
A failed NaN selection enters the ordinary operation.
A successful NaN selection returns the selected NaN.
Sign and adjacency #
Flip only the stored sign bit, without interpreting the format's encoding policy.
Instances For
Toggling the stored sign bit preserves the fraction field.
Toggling the stored sign bit preserves the exponent field.
Toggling the stored sign bit complements the decoded sign.
Toggling the stored sign bit twice restores the original word.
Toggling the stored sign bit preserves IEEE NaN classification.
Toggling the stored sign bit preserves IEEE infinity classification.
Toggling the stored sign bit preserves IEEE zero classification.
Toggling the stored sign bit preserves IEEE finiteness.
Negate an encoded value according to its format.
Formats with signed zero use the flat sign-bit operation. An unsigned-zero format preserves its single zero and reserved NaN encodings instead of exchanging them.
Instances For
Formats with signed zero implement negation as a flat stored-sign toggle.
An unsigned-zero format preserves a NaN under negation.
An unsigned-zero format preserves its single zero under negation.
A value that is neither NaN nor zero is negated by the raw stored-sign toggle.
Negation preserves the fraction field of every encoded value, including NaNs.
Negation preserves the exponent field of every encoded value, including infinities and NaNs.
Negation toggles the sign unless an unsigned-zero format preserves zero or NaN.
Negation preserves IEEE NaN classification.
Negation preserves IEEE infinity classification.
Negation preserves IEEE zero classification.
Negation preserves IEEE finiteness.
Copy the numerical sign of signSource onto magnitude.
For formats with signed zero, this is the usual quiet sign-bit operation. An unsigned-zero format uses its sign-bit word as the NaN encoding, so zero and NaN are preserved instead of being changed into one another. Every other finite value receives the requested stored sign.
Instances For
Copying an already equal sign leaves the complete encoded word unchanged.
An unsigned-zero format preserves its zero when a sign is copied onto it.
An unsigned-zero format preserves its reserved NaN word when a sign is copied onto it.
Absolute value under the complete format policy.
This clears an ordinary stored sign. In an unsigned-zero encoding it leaves the unique zero and reserved NaN word intact, avoiding the raw-bit alias between those two encodings.
Instances For
The smallest positive subnormal encoding.
Instances For
The negative subnormal of smallest magnitude.
Instances For
The next representable value strictly greater than x, the kernel of Model.nextUp x.
A quiet NaN and the positive endpoint are fixed. A signaling NaN becomes the corresponding quiet
NaN, and the invalid signal IEEE 754-2019 §5.3.1 owes to a signaling operand is reported by
Model.nextUp x (status := true) in Operations.Runtime. Formats without infinity saturate at
their largest finite value. In an unsigned-zero encoding, the word immediately below the negative
minimum subnormal is reserved for NaN, so that transition goes directly to the format's unique
zero.
Instances For
The next representable value strictly less than x, the kernel of Model.nextDown x.
A quiet NaN and the negative endpoint are fixed. A signaling NaN becomes the corresponding quiet
NaN, and the invalid signal it owes is reported by Model.nextDown x (status := true) in
Operations.Runtime. Formats without infinity saturate at their most negative finite value.