P3109 formats #
P3109 descriptors have four parameters from the interim report: bit width, precision,
signedness, and finite or extended domain. Every valid descriptor produces an exact-width
codebook and an ExecFloat carrier.
This module covers representation and exact decoding. The arithmetic and projection modules supply operations and rounding policies.
The finite magnitude formula agrees with ordinary binary scientific notation after fields have
been extracted. Classification does not: P3109 unsigned formats omit the sign bit, while signed
formats use the midpoint code for their single NaN and mirror finite magnitudes across the upper
half of the code space. P3109 also admits field widths excluded by
BinaryInterchange.FloatFormat, so it needs its own field classification.
Reference #
- IEEE Working Group P3109, Interim Report on Arithmetic Formats for Machine Learning,
version 4.0.3 (1 September 2026), Sections 3.1 and 4.7.2, repository revision
34f5964, https://github.com/P3109/Public/tree/34f5964d9bb2382b2665d15467fc3517b990b308.tests/oracles/format-standards.shcompares decoding with the published value tables.
Whether a P3109 format represents negative finite values.
- signed : Signedness
- unsigned : Signedness
Instances For
Instances For
Whether a P3109 format represents infinities as well as finite values and NaN.
Instances For
A validated descriptor for the complete four-parameter P3109 format family.
One value of this structure selects a profile; there is no separate Lean type or decoder for each
bit width. The proof fields rule out precisely the invalid (K, P, signedness) combinations from
the report before any value can be constructed.
- bitWidth : ℕ
Total number of encoded bits (
Kin the report). - precision : ℕ
Significand precision including the implicit leading bit (
Pin the report). - signedness : Signedness
Signed or unsigned datum set.
- domain : Domain
Finite or extended datum set.
P3109 requires more than two encoded bits.
P3109 requires positive precision.
- precision_bound : match self.signedness with | Signedness.signed => self.precision < self.bitWidth | Signedness.unsigned => self.precision ≤ self.bitWidth
Signed formats require
P < K; unsigned formats allowP = K.
Instances For
Number of explicitly stored trailing significand bits.
Instances For
Width of the biased exponent field.
Unsigned formats gain the bit that a signed format uses to divide positive and negative codes.
Instances For
P3109 exponent bias, derived from the exponent-field width.
Instances For
Smallest leading exponent used by a normal finite value.
Instances For
Quantum exponent of the smallest positive finite value.
Instances For
Number of code points in the format.
Instances For
First code in the negative half of a signed format.
Instances For
Code point assigned to the format's single NaN.
Instances For
Code point assigned to positive infinity when the domain is extended.
Instances For
Code point assigned to negative infinity in a signed extended format.
Instances For
Construct a signed P3109 descriptor.
Instances For
Construct an unsigned P3109 descriptor.
Instances For
Validate parameters supplied at runtime and construct the corresponding P3109 descriptor.
Use signed or unsigned when the parameters are fixed in Lean code and their constraints can
be discharged at elaboration time. This checked constructor is for parsers, generated format
matrices, and other callers whose parameters are ordinary runtime values.
Instances For
Exact positive finite value decoded from one in-range magnitude.
Informally, row zero is subnormal and uses the stored trailing bits directly. Every other row
prepends the implicit leading bit and subtracts the descriptor's exponent bias. Exceptional-code
classification and negative mirroring happen in decodeNat, outside this shared mathematical
formula.
Instances For
Decode an in-range natural-number code point according to P3109 Section 4.7.2.
Callers with arbitrary natural numbers should first construct a BitVec format.bitWidth; the
public decode and ExecFloat.P3109.ofNatBits functions do this automatically.
Instances For
Exact P3109 denotation of one width-bounded code point.
Instances For
Complete codebook induced by a P3109 descriptor.
Instances For
P3109 as a family-independent exact numerical system.
Instances For
Executable exact-width carrier for any valid P3109 descriptor.
Generic exact-expression operations can use this type as a destination through its conversion capability. The representation layer does not install a separate arithmetic interface.
Instances For
Construct P3109's unique zero without exposing its stored word.
Instances For
Construct P3109's sole NaN without exposing its descriptor-dependent code point.
Instances For
Construct positive infinity when the descriptor has an extended domain.
Using this function with a statically finite-only descriptor fails during elaboration.
Instances For
Construct negative infinity when the descriptor is both signed and extended.
Using this function with an unsigned or finite-only descriptor fails during elaboration.
Instances For
Construct a finite P3109 value from named representation fields.
biasedExponent and trailing are checked against the descriptor widths. The constructor also
rejects a negative request for an unsigned format and every field combination reserved for NaN or
infinity. It is the structured alternative to ofNatBits when an application already has decoded
P3109 fields; it does not perform numerical rounding.
Instances For
Construct a P3109 value from the low K bits of a serialized word.
Prefer the named semantic constructors or ofFiniteFields? in ordinary code.
Instances For
Read a P3109 value as its natural-number code point.
Instances For
Decode a P3109 value to its exact finite, infinity, or NaN semantics.