Limb arrays: value semantics of the shifts #
The shifts of Shift.Runtime build each result limb from two source limbs, so their toNat
statements are proved bit by bit: shiftLeftLimb_testBit and shiftRightLimb_testBit read one
bit of a result limb as one bit of the source value, and Nat.eq_of_testBit_eq turns those
readings into toNat_shiftLeft and toNat_shiftRight.
toNat_roundShiftRightEven then combines the shift with the guard-and-sticky form of nearest-even
rounding from FloatLib.Numerics.ShiftRightJam.Proof. The guard bit, sticky test, and quotient
parity determine whether to increment the truncated quotient.
Machine-word shift bits #
Left shift #
One bit of a result limb of the left shift is the corresponding bit of the source value.
Right shift #
A right shift keeps the limb count.
Each limb of a right shift is the corresponding shiftRightLimb value inside the size and
zero above it.
The right shift divides the value by 2^k.
Nearest-even rounding #
Rounding a right shift keeps the limb count of the shifted array.
The limb rounder agrees with the width-generic nearest-even shift.