FloatRep core (Flocq-style rounded arithmetic) #
The rounded-real model separates representation, value, and format:
- represent a value with integer mantissa $m$ and exponent $e$,
- interpret it as the real number $m\beta^e$,
- describe the format via an exponent-selection function
fexp : ℤ → ℤand a rounding operator.
This decomposition is the same one used by the Coq library Flocq. It makes many theorems reusable across formats (fixed-point, unbounded floats, and lower-exponent-bounded floats) and aligns well with ULP-style error bounds from numerical analysis.
For executable, bit-level binary semantics (NaN/Inf/signed zero), see
FloatLib/Floats/Formats/BinaryInterchange/.
References #
- Flocq project (documentation + sources): https://flocq.gitlabpages.inria.fr/flocq/
- S. Boldo, G. Melquiond, “Flocq: a unified Coq library for proving floating-point algorithms correct” (ARITH 2011), DOI: 10.1109/ARITH.2011.40
- IEEE Standard for Floating-Point Arithmetic (IEEE 754-2019)
- N. J. Higham, Accuracy and Stability of Numerical Algorithms, 2nd ed., SIAM, 2002
A radix-$\beta$ floating-point representation with integer mantissa and exponent.
Instances For
Structural zero test (mantissa is exactly 0).
Instances For
Sign of the mantissa (matches the sign of toReal since $\beta^e>0$).
Instances For
Base power: $\beta^e$ as a real number.
This is Flocq's bpow concept: the scaling factor used to interpret mantissa/exponent pairs.
Instances For
Base powers are positive: $\beta^e>0$ for any exponent $e$.
Base powers are nonnegative: $\beta^e\ge0$ for any exponent $e$.
Base powers are never zero.
Exponent addition law: $\beta^{e_1+e_2}=\beta^{e_1}\beta^{e_2}$.
Negating the exponent inverts the base power: $\beta^{-e}=(\beta^e)^{-1}$.
Exponent subtraction corresponds to division of radix powers.
Interpret a FloatRep as the real number $m\beta^e$.
Instances For
toReal is zero iff the mantissa is zero (since $\beta^e\ne0$).
Magnitude in base $\beta$ of a real number.
This matches the usual definition
$\operatorname{mag}(x)=\lfloor\log_\beta|x|\rfloor+1$ for $x\ne0$, and $0$ for $x=0$.
It is the bridge between a real input $x$ and the exponent-selection function fexp.
Instances For
Validity predicate for exponent-selection functions.
This is the exponent-validity condition used by Flocq. Properties that are not consequences of validity, such as monotonicity, are separate classes so generic results do not acquire unnecessary hypotheses.
- flocq_valid (k : ℤ) : (fexp k < k → fexp (k + 1) ≤ k) ∧ (k ≤ fexp k → fexp (fexp k + 1) ≤ fexp k ∧ ∀ l ≤ fexp k, fexp l = fexp k)
Exponent compatibility at successive magnitudes and below a negligible exponent.
Instances
A selected negligible exponent satisfies $n\le\mathtt{fexp}(n)$.
A format has no selected negligible exponent exactly when no negligible exponent exists.
Canonical exponent (cexp in Flocq terminology).
Apply fexp to the input's magnitude; at zero this gives fexp 0. The ValidExp instance
restricts the API to valid exponent functions, although evaluating this expression needs only
fexp.
Instances For
A float representation is canonical when its stored exponent is the exponent selected for its value.
Instances For
Scaled mantissa $x\beta^{-\operatorname{cexp}(x)}$.
Intuitively: rescale x so that rounding “happens around exponent 0”, which is where rnd acts.
Instances For
Generic format predicate (Flocq-style).
This says that $x$ is exactly representable in the format picked out by $\beta$ and fexp.
One way to read it is: the scaled mantissa is an integer (so there is no rounding error).
Instances For
Unit in the last place (ULP) associated with $x$ and the format selected by fexp.
This is the scale of the “one ulp” step at the exponent selected by cexp. For round-to-nearest,
many standard bounds have the shape
$|\operatorname{round}(x)-x|\le\operatorname{ulp}(x)/2$.
At zero, a negligible exponent determines the spacing when one exists; otherwise the ULP is zero.
Instances For
ulp is always nonnegative.
Informally: an ulp is a step size on a real grid, so it cannot be negative.
ulp is strictly positive away from zero.
If $x\ne0$, the exponent selection $\operatorname{cexp}(x)$ picks a power of $\beta$, which is strictly positive.
The ULP at zero is determined by the format's negligible exponent, when one exists.