Fixed-width bit runs in positive Posit encodings #
Representation lemmas describe bit runs in the nonnegative half of a Posit Standard encoding.
Exact-width leading runs are reduced to Nat.log2; a run of one bits is reduced to the
leading-zero run of the fixed-width complement using mathlib's BitVec complement theorems; and
equal or ordered regime prefixes are related to the remaining encoded tail.
These facts are independent of the storage carrier. Tail-order and rounding proofs use them alongside native execution backends.
Exact rational value of the posit word with unsigned code code.
Codes in [0, format.signMaskNat) are the nonnegative finite posits. The function is total on
naturals: it first reduces the code modulo the format's modulus, then maps zero and NaR to zero
and other words to their signed rational value.
Instances For
A positive code below the sign mask takes the finite branch of exact posit decoding.
Fixed-width bit runs #
For a positive value bounded by 2 ^ width, the leading-zero run is the width minus its binary
length.
A leading-run scan depends only on the low width bits being scanned.
A leading-one run is the leading-zero run of the complement inside the same fixed width.
The all-zero word has a zero-bit run occupying the complete inspected width.
Within a fixed width, increasing an unsigned word can only shorten its leading-zero run.
Within a fixed width, increasing an unsigned word can only lengthen its leading-one run.
Appending a low zero bit to a positive bounded word preserves its leading regime run.
For the all-ones word the appended zero becomes the first terminator, and the run length is again unchanged.
The regime bit of a nonnegative code is the top bit of its payload.
The regime bit of a nonnegative code is set exactly when the code is at least the code of one.
The regime run of a nonnegative code is the leading run of its top payload bit.
Unsigned code order below the sign mask induces nondecreasing signed regime values.
Below the code of one, leading-zero runs shorten as codes rise; at and above it, leading-one runs lengthen.
Two decoded words have the same regime value exactly when both the regime bit and run length agree.
The positivity of every regime run separates the negative zero-run regimes from the nonnegative one-run regimes.
Equal regimes have equal trailing widths and equal high-bit prefixes.
The second conclusion says that division by the trailing-field modulus leaves the same regime prefix in both magnitudes. It is the representation lemma that turns unsigned code order into strict order of the low exponent/fraction fields.