Proof contracts for explicit conversion and mixed arithmetic #
The preparation theorems compose the supplied decoder, exact-domain operations, and destination
quantization relation. They establish one quantizer call on successful preparation and preserve
preparation failures. Numerical preservation by ExactMap, the arithmetic instances and the
context-dependent addition and subtraction hooks is left to family-specific laws.
Runtime-only clients may import Conversion.Runtime, and FloatLib.Floats.ExecFloat exports both
execution and these contracts.
The merged inexact flag is raised exactly when either input raised it.
The merged overflow flag is raised exactly when either input raised it.
The merged underflow flag is raised exactly when either input raised it.
The merged saturation flag is raised exactly when either input raised it.
The merged wrapping flag is raised exactly when either input raised it.
The merged special-value flag is raised exactly when either input raised it.
The merged invalid flag is raised exactly when either input raised it.
An empty first status contributes no flags.
An empty second status contributes no flags.
Status accumulation is associative, so grouping a successful pipeline is irrelevant.
Mapping a successful outcome transforms only its value.
Mapping a failed outcome preserves its failure reason.
Binding a successful outcome runs the continuation and accumulates successful status.
Binding a failed outcome does not run the continuation.
Binding a successful outcome that carries no flags applies the continuation.
Extracting the value of a successful outcome returns that value.
A failed outcome contains no successful value.
Extracting status from a successful outcome returns its stored flags.
A failed outcome contains no successful status.
A successful outcome contains no failure reason.
Extracting failure information returns the stored reason.
Mapping the identity function leaves an outcome unchanged.
Extracting a value after map agrees with mapping the extracted option.
Mapping a successful value does not alter its status.
Mapping a successful value does not alter a failure reason.
Grouping consecutive successful binds does not change values, failures, or accumulated flags.
Decoding a natural number for conversion produces that exact finite value.
Decoding an integer for conversion produces that exact finite value.
Decoding a rational for conversion introduces no rounding.
Decoding a dyadic value for conversion preserves its exact binary representation.
decodeTo is exact decoding followed by the selected finite-value embedding.
Decoding into the source's own exact domain performs no semantic transformation.
The executable destination quantizer satisfies its declared relation.
Generic conversion satisfies the destination's declared quantization relation in the context it
uses. For a call without context, that context is ModeContext.context for its mode.
ExecFloat conversion satisfies the destination's declared relation in the context it uses.
A finite observation passes through preparation unchanged.
Infinity is rejected at the supplied operand position.
An exceptional observation is rejected at the supplied operand position.
Finite exact division rejects any denominator satisfying the domain's zero predicate.
Finite exact division applies the domain's / when the denominator is not zero.
Finite exact division reports division by zero exactly for declared-zero denominators.
A successfully prepared exact observation is passed to the destination quantizer.
A preparation failure reaches the public outcome unchanged.
On successful preparation, PreparedSpec is the destination relation.
On preparation failure, PreparedSpec requires the same public failure.
Preparation followed by the executable quantizer satisfies PreparedSpec.
A finite decoded operand enters an exact expression unchanged.
A decoded infinity identifies the numbered operand that made the expression invalid.
A decoded exceptional value identifies the numbered operand that caused rejection.
A successful exact expression becomes a finite input to the sole quantization step.
An exact-expression failure is preserved before quantization.
Checked exact division rejects any denominator satisfying the domain's zero predicate.
Checked exact division reports division by canonical zero.
Checked exact division applies the exact domain's / when the denominator is nonzero.
The premise uses the exact domain's declared zero proposition. A domain such as SignedRat can
therefore recognize several zero representations and prove a bridge from that proposition to its
numerical meaning.
Checked exact division reports division by zero exactly for declared-zero denominators.
An exact expression followed by one quantization satisfies the destination's declared relation in the context used, or returns the expression's failure unchanged.
A successful expression goes to the quantizer as one finite exact value.
An exact-expression failure bypasses the destination quantizer unchanged.
The context's addition hook followed by one quantization satisfies the composed relation.
The context's subtraction hook followed by one quantization satisfies the composed relation.
Exact multiplication followed by one quantization satisfies the composed relational contract.
Exact division followed by one quantization satisfies the composed relational contract.
Exact fused multiply-add followed by one quantization satisfies the composed contract.