Verified two-limb rounding #
These theorems connect the native UInt128 shifts, increments, and nearest-even rounding
operations to their natural-number meanings.
The runtime uses two UInt64 limbs; the proof model interprets them as one Nat.
Carry propagation, cross-limb shifts, low-bit insertion, and ties-to-even rounding preserve that
interpretation under the stated capacity bounds.
Limb-local primitives #
Cross-limb shifts #
@[simp]
The native two-word shift is exact division by two.
Nearest-even right shifts #
theorem
FloatLib.Numerics.FixedWord.UInt128.roundShiftRightEven_toNat
(value : UInt128)
(shift : ℕ)
(hpositive : 0 < shift)
(hshift : shift < 64)
(hhigh : value.hi.toNat < 2 ^ shift)
(hincrementFit : value.toNat >>> shift + 1 < 2 ^ 64)
:
The one-limb result of native two-limb nearest-even rounding agrees with the common mathematical rounder whenever the stated bounds exclude overflow.