Correctness of IEEE exception status #
The executable status kernels in Status.Runtime satisfy cross-flag invariants and
operation-level specifications. Import BinaryInterchange.Status for the combined public
interface.
The rounding-status classifiers compare an exact dyadic or scaled rational with the supplied rounded value. Operation wrappers compute that exact witness alongside the value-only operation. This file proves cross-flag invariants, preservation of the ordinary result, real-order tininess boundaries, and operation-specific invalid and divide-by-zero conditions.
Constructors and rounding-status invariants #
The direct result classifier recognizes exactly finite zero and subnormal encodings.
The underflow midpoint is exactly halfway between the unbounded-grid predecessor and the smallest normal value.
Both gaps are one 2^(minSubnormalExponent - 2) step. Besides documenting the quarter-subnormal
offset used by nearest-even, the equalities rule out an off-by-one significand or exponent in the
three executable boundary constants.
Real-order specification of after-rounding dyadic tininess.
An already tiny encoding is accepted immediately. Otherwise nearest-even uses the underflow
midpoint, rounding toward zero uses the smallest normal, and a directed mode uses either the
unbounded-grid predecessor or the smallest normal according to whether it rounds this sign away
from zero. This theorem is the semantic boundary for the executable comparisons in
dyadicIsTinyAfterRounding.
Real-order specification of after-rounding tininess for scaled rationals.
The denominator premise excludes the malformed representation for which the executable comparator
returns none. For every valid rational, the optimized leading-exponent comparison has the same
mode-sensitive boundaries as the dyadic classifier above.
The dyadic and scaled-rational tininess classifiers agree when the rational has denominator one.
This bridge lets operation proofs choose the representation natural to their exact arithmetic without creating two notions of IEEE underflow.
outcomeWithInvalid preserves its supplied floating-point value.
outcomeWithInvalid records exactly its supplied invalid-operation condition.
outcomeWithInvalid never raises divide-by-zero.
After-rounding dyadic underflow implies inexactness.
Dyadic rounding reports overflow when rounding crosses the format's overflow threshold or when the supplied rounded result is an infinity.
For a finite result, dyadic overflow is exactly the exact-value overflow classification.
Dyadic rounding overflow always raises inexact.
A dyadic rounding result cannot simultaneously signal overflow and underflow.
After-rounding scaled rational underflow implies inexactness.
Scaled rational rounding reports overflow when rounding crosses the format's overflow threshold or when the supplied rounded result is an infinity.
For a finite result, scaled rational overflow is exactly the exact-value overflow classification.
Scaled rational overflow always raises inexact.
Scaled rational rounding cannot signal overflow and underflow together.
After-rounding rational underflow implies inexactness.
Rational rounding reports overflow when rounding crosses the format's overflow threshold or when the supplied rounded result is an infinity.
For a finite result, rational overflow is exactly the exact-value overflow classification.
Rational overflow always raises inexact.
Rational rounding cannot signal overflow and underflow together.
Dyadic rounding is invalid exactly for an unclassified non-finite, non-infinite result.
A finite dyadic rounding result cannot raise invalid.
Rounding an exact dyadic never raises divideByZero.
Scaled rational rounding is invalid exactly for an unclassified non-finite, non-infinite result.
A finite scaled rational rounding result cannot raise invalid.
Rounding an exact scaled rational never raises divideByZero.
Result projection #
Status-bearing addition returns the same value as value-only directed addition.
Status-bearing subtraction returns the same value as value-only directed subtraction.
Status-bearing multiplication returns the same value as value-only directed multiplication.
Status-bearing division returns the same value as value-only directed division.
Status-bearing FMA returns the same value as value-only directed FMA.
Status-bearing square root returns the same value as value-only directed square root.
Operation-specific exceptional status #
Finite addition exposes exactly its dyadic rounding status.
Complete invalid-status classification for addition.
Finite operands expose the rounded result's classification directly. Exceptional operands raise invalid exactly for a signaling NaN or opposite-signed infinities when no NaN was supplied.
Finite multiplication exposes exactly its dyadic rounding status.
Complete invalid-status classification for multiplication.
Finite operands expose the rounded result's classification directly. Exceptional operands raise invalid exactly for a signaling NaN or an infinity-times-zero operation without an input NaN.
Finite FMA exposes exactly its dyadic rounding status.
Complete invalid-status classification for fused multiply-add.
Finite operands expose the singly rounded result's classification directly. Exceptional operands use the IEEE signaling-NaN, infinity-times-zero, and opposite-infinity rules. For the implementation-defined quiet-NaN case, this library raises invalid for infinity times zero even when the addend is a quiet NaN; an input NaN suppresses the opposite-infinity condition.
Finite nonzero division exposes exactly its scaled-rational rounding status.
Complete invalid-status classification for division.
The finite branch distinguishes zero-over-zero, exact zero, and nonzero rational rounding. Exceptional operands use the signaling-NaN and infinity-over-infinity rules.
Division raises divide-by-zero exactly for a finite nonzero numerator over finite zero.
Square root raises invalid exactly for an sNaN or a negative nonzero non-NaN input.
Dividing two finite zeros raises invalid.
Dividing a finite nonzero value by a finite zero raises divide-by-zero.
The square root of a negative nonzero non-NaN value raises invalid.