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, arithmetic instances, and the
context-dependent addition and subtraction hooks requires the separate family-specific laws
described in Conversion.Core.
Runtime-only clients may import Conversion.Runtime; the public Conversion module 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.
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.
A successful outcome with no prior flags binds exactly like direct continuation application.
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.
Explicit generic conversion satisfies the destination's declared quantization relation.
Default-context generic conversion satisfies the declared quantization relation.
Explicit ExecFloat conversion satisfies the destination's declared relation.
Default-context ExecFloat conversion satisfies the declared relation.
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 exactly 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 explicit-context quantization satisfies the destination's declared relation, or returns the expression's failure unchanged.
An exact expression followed by the default quantization context satisfies the same composed contract.
A successful expression is sent directly 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 default-context addition hook satisfies the same composed relation.
The context's subtraction hook followed by one quantization satisfies the composed relation.
The default-context subtraction hook satisfies the same composed relation.
Exact multiplication followed by one quantization satisfies the composed relational contract.
Default-context exact multiplication satisfies the composed relational contract.
Exact division followed by one quantization satisfies the composed relational contract.
Default-context exact division satisfies the same composed relational contract.
Exact fused multiply-add followed by one quantization satisfies the composed contract.
Default-context exact fused multiply-add satisfies the same composed relational contract.