Core conversion capabilities and outcomes #
A source's ExactDecoder gives its exact value. An ExactMap embeds that value into the
destination's exact domain, and a Quantizer rounds it under an explicit policy.
ConversionOutcome retains the resulting value and flags, or the reason conversion failed.
The entry points are in Conversion.Runtime; their correctness theorems and the laws for
composing outcomes are in Conversion.Proof.
Location of an input that prevented a conversion or mixed operation.
- source : InputPosition
The sole input of a conversion.
- left : InputPosition
The left input of a binary or fused operation.
- right : InputPosition
The right input of a binary or fused operation.
- addend : InputPosition
The third input of a fused multiply-add.
- operand
(index : ℕ)
: InputPosition
A zero-based input of a user-defined exact expression.
Instances For
Instances For
Instances For
Why an explicit conversion or mixed-format operation produced no destination value.
- infinity
(position : InputPosition)
(negative : Bool)
: ConversionFailure
An infinity reached an operation that requires an ordinary finite input.
- exceptional
(position : InputPosition)
(value : Numerics.ExceptionalValue)
: ConversionFailure
An exceptional value reached an operation that requires an ordinary finite input.
- divisionByZero : ConversionFailure
Exact division was requested with a zero denominator.
- outOfRange : ConversionFailure
A finite exact result is outside a destination configured to reject overflow.
- unsupportedPolicy : ConversionFailure
The requested family-specific conversion policy is not implemented by the destination.
Instances For
Instances For
Instances For
An exact scalar computation that may reject a non-finite input or an undefined operation.
Successful expressions contain an unrounded value in the destination's exact domain. Applying
roundOnce or roundOnceWith quantizes the result once. The Except alias supports ordinary
do notation and stops at the first failure.
Instances For
Representation-independent information about a successful quantization.
Flags describe one conversion. saturated and wrapped distinguish clamping from modular
reduction; either can also be inexact. Composing successful outcomes with bind combines their
flags with Boolean OR. A failed continuation returns its failure reason without accumulated flags.
- inexact : Bool
The stored destination does not denote the exact finite input.
- overflow : Bool
The rounded result did not fit the destination's finite range. Binary destinations set this after rounding, in the IEEE 754 sense; each quantizer documents its own rule.
- underflow : Bool
The result was tiny. Binary destinations use the IEEE 754 rule, tiny after rounding and inexact; P3109 reports a nonzero exact input below its least positive datum.
- saturated : Bool
The result was clamped to a finite endpoint.
- wrapped : Bool
The result was reduced modulo a bounded storage width.
- mappedSpecial : Bool
A source infinity or exceptional value was mapped to another value class.
Instances For
Instances For
Instances For
Combine the flags raised by two successful conversion steps.
Instances For
Result of an explicit conversion or destination-driven mixed operation.
- success
{α : Type u}
(value : α)
(status : ConversionStatus := { })
: ConversionOutcome α
A destination value together with conversion status.
- failure
{α : Type u}
(reason : ConversionFailure)
: ConversionOutcome α
A conversion rejected by its explicit policy or by finite-only mixed arithmetic.
Instances For
Instances For
Instances For
Transform a successful value while preserving status and failure information.
Instances For
Continue from a successful value, accumulating status from both successful steps.
A failure short-circuits unchanged. Because ConversionOutcome.failure does not carry status,
flags from an earlier success are unavailable when a later step fails.
Instances For
Extract a successful destination value.
Instances For
Extract status from a successful conversion.
Instances For
Extract the reason for a failed conversion.
Instances For
Executable exact interpretation of a source value.
Exact is an output parameter so the source type selects its canonical executable exact domain.
For example, configured binary sources select SignedRat to retain signed zero, posit sources
select Rat, and a shared-scale block may select Vector Rat lanes.
- decode : Source → Numerics.NumericalValue Exact
Decode every source value, retaining infinity and exceptional observations.
Instances
Natural numbers enter explicit conversion as exact finite natural values.
Integers enter explicit conversion as exact finite integer values.
Rationals enter explicit conversion without an intermediate floating-point approximation.
Dyadic values enter explicit conversion with their exact significand and binary exponent.
Context-indexed quantization capability for one destination value type.
The specification is relational so stochastic, state-indexed, and otherwise nondeterministic
mathematics remain expressible even when run chooses one executable result.
Exact is an output parameter: a destination has one canonical mathematical input domain.
Alternative execution backends must refine that same semantics rather than changing the domain
seen by users. Sources with a different exact domain reach it through an explicit ExactMap.
Mixed addition and subtraction also consult this context before quantization. The default
operations are those of Exact; a signed-zero domain can refine the sign of an exact cancellation
without changing its numerical value. Multiplication and division use the exact domain directly.
Preservation of the numerical sum and difference is a separate family-specific proof obligation.
correct relates run to spec; it does not constrain these arithmetic hooks. The generic
prepared-spec theorems compose quantization with the supplied hooks. An arithmetic correctness
result also needs their numerical preservation lemmas, as supplied by the binary instances.
The relation's content is a separate obligation: choosing Spec.ofFunction run makes correct
reflexive and supplies no independent rounding property. A family contract can expose denotation,
coefficient, or policy predicates while retaining complete output and status equality. The generic
conversion theorems transport precisely the clauses that the installed relation contains.
- Context : Type
Family-specific context, such as rounding policy, entropy, overflow rule, or block exponent.
- run : Context Destination → Numerics.NumericalValue Exact → ConversionOutcome Destination
Executable quantizer.
- spec : Numerics.Quantization.Spec (Context Destination) (Numerics.NumericalValue Exact) (ConversionOutcome Destination)
Mathematical relation implemented by
run. - correct : spec.Implements run
The executable quantizer always chooses a result permitted by
spec. Exact addition under the destination context, including any direction-dependent zero sign.
A family overriding this operation must retain the numerical sum in its exact domain.
Exact subtraction under the destination context, including any direction-dependent zero sign.
A family overriding this operation must retain the numerical difference in its exact domain.
Instances
The default context used when a conversion omits an explicit policy.
- defaultContext : Quantizer.Context Destination
Context selected by the context-free
castand mixed-operation helpers.