Flocq-style generic formats as ordinary FloatLib formats #
The radix/exponent-function model of FloatRep supplies a representation-independent
EncodedFormat interface.
The runtime code is a canonical integer-mantissa/integer-exponent pair. Lean erases its proof of
canonicality, and its denotation is the corresponding real number. The central theorem
representable_iff_genericFormat proves that common-system representability coincides with
genericFormat.
The definitions mirror the separation in Flocq between:
generic_format, which characterizes representable real values,Valid_exp, which constrains exponent-selection functions,- a rounding operator proved to return a generic-format value.
Primary references:
- S. Boldo and G. Melquiond, “Flocq: A Unified Library for Proving Floating-Point Algorithms in Coq,” ARITH 2011, pp. 243–252, §III-D, DOI 10.1109/ARITH.2011.40.
- Flocq 4.2.2 release,
src/Core/Generic_fmt.v, definitionsgeneric_formatandValid_exp: https://flocq.gitlabpages.inria.fr/releases/flocq-4.2.2.tar.gz. - Flocq project documentation: https://flocq.gitlabpages.inria.fr/flocq/.
Type-level identity of the generic radix/exponent-function format.
The constructor carries no format data. The radix and exponent function are type parameters, so specialized users do not pass a runtime descriptor through arithmetic kernels.
- format {β : Numerics.Radix} {fexp : ℤ → ℤ} : GenericFormat β fexp
Instances For
Canonical mantissa/exponent codes of a valid Flocq-style generic format.
Instances For
A canonical code represents exactly the real obtained from its mantissa and exponent.
Common FloatLib representability coincides with the Flocq-style generic_format
predicate.
Choose a canonical code for a value already known to belong to the generic format.
It is noncomputable and meant for proofs. Concrete fixed-precision format families supply their own executable packing kernels.
Instances For
encodeGeneric denotes the real value from which it was chosen.
Round a real input and choose a canonical code for the rounded generic-format value.
Instances For
The selected code denotes the rounded result in the given direction.
Relational quantization contract for the six rounding directions of IEEERoundingMode.
Instances For
roundCode implements the common relational quantization contract.
Rounding an already representable real denotes that same real.