Correctness of two-word finite addition #
Under Eligible, every accepted result of Addition.Runtime is the exact finite kernel's answer.
The proof follows the one-word addition proof NativeSmallWordAdd: the two-word rounder computes
the natural-number normal specification NativeSmallWordAdd.normalSpec?, the aligned and sticky
combinations match FiniteScaleAdd.roundMagnitudes, and the decoded storage fields are those of
FiniteKernel.decode?. The natural-number lemmas about sticky alignment are shared with the
one-word kernel.
Constants #
alignOffset equals FiniteKernel.finiteScaleOffset as a natural number.
shiftLimit equals 126 - fracWidth as a natural number.
Rounding #
Carry normalization, overflow, and packing agree with the generic rounder's normal branch.
The two-word rounder computes the natural-number normal specification of the one-word kernel.
An accepted two-word rounding is the unsigned-scale rounding of the exact kernel.
Signed magnitudes #
All-zero storage words are positive zero.
An accepted aligned combination is the exact kernel's signed-magnitude combination.
Sticky alignment #
An accepted sticky alignment is the exact signed-magnitude combination of the same fields.
Field addition #
An accepted two-word field addition is the exact unsigned-scale sum of the same fields.
Storage-word decoding #
The two-word significand of a stored value is the generic kernel's decoded significand.
A decoded two-word significand has at most fracWidth + 1 bits.
The generic finite decoder sees the fields the two-word kernel reads from the storage words.
Negating a finite value keeps its stored exponent and significand and toggles its sign.
An accepted two-word sum or difference is the answer of the compact finite kernel
FiniteKernel.add?.
negateRight selects subtraction: the kernel toggles the right sign on the storage word, and the
theorem states the corresponding claim about neg y.
Model entry points #
An accepted storage-word sum is the model-level two-word sum.
An accepted storage-word difference is the model-level two-word difference.
Two-word addition and the generic finite kernel agree on every input.
Two-word subtraction and generic addition of the negated right operand agree.