Verified single-word primitives for executable numerical arithmetic #
Native-word shifts, bit operations, and restoring square-root state have exact natural-number
interpretations. Nearest-even rounding is proved in Core.Proof.Rounding; wider two-limb values
and exact 64 × 64 → 128 multiplication are proved in Core.Proof.UInt128.
Mathematical meaning of a restoring square-root state, independent of the native carrier used by the executable loop.
Instances For
The root component of a valid restoring state fits in the requested precision whenever the processed radicand fits in twice that precision.
The root component of a valid restoring state is the exact floor square root, independently of the machine-word carrier used by the executable loop.
A valid restoring state contains the exact floor square root and its square remainder.
Machine-word nearest-even selection has the same natural-number code as the shared scalar selector.
Native UInt64.log2 has the same natural-number value as Nat.log2.
Shifting the native word 1 within range represents the corresponding power of two.
Moving the low inner bits of a word to the high end has the expected natural-number value.
This is the wrapped half of a cross-limb right shift. Keeping it in the fixed-word core lets every multi-limb backend share the same machine-word argument.
Joining the two halves of a cross-limb right shift has the expected natural-number value.
Positional weight of one base-four digit.
Instances For
Value reconstructed from the first steps digits of any machine-word base-four source.
Concrete radicand layouts provide only their digit reader; the positional recurrence and loop proof are shared across one-word and multi-word square-root kernels.
Instances For
Base-four digit selected from a machine word; indices below 32 avoid shift-count wraparound.
Instances For
Value reconstructed from the first steps base-four digits of a machine word.
Instances For
Generic refinement of a restoring loop from a proved digit step.
Only the carrier-specific step theorem and recursive equations are supplied by a backend. The base-four accumulation and induction are independent of word width.
Reconstructing the low base-four digits is reduction modulo their total width.
Natural value of a machine-indexed low-bit mask below the carrier width.
Masking a native word to a Nat-indexed low-bit field agrees with reduction modulo the
corresponding power of two.
This theorem bridges kernels whose control flow uses Nat to the shared machine-indexed
lowBitsWord primitive; the executable data path remains on unboxed UInt64 values.
Machine-indexed right shift agrees with natural-number right shift in range.
Machine-width leading-zero counting has the corresponding natural-number value.
The nonzero branch proves that log2 + 1 is at most the retained field width before interpreting
the machine subtraction. This is the capacity invariant that rules out unsigned wraparound.
Machine-width equal-bit run counting reduces to the shared leading-zero primitive.