A natural-scalar basis with standard word-RAM implementations #
model supplies the scalar operations and comparisons used by cached-height AVL algorithms.
scalars implements them by ordinary word-RAM instructions, with no heap effects. Zero costs
one instruction; maximum-plus-one and the height-gap comparison cost at most five; the other
comparisons cost at most three. Operand and destination registers may coincide, including
compiler temporaries. Operands are consumed before the selected temporary is overwritten.
Only the height-gap test needs extra admissibility: the truncated difference must fit a word.
In particular it does not compute b + 1, which could overflow at the largest word value.
Natural scalar operations used for cached subtree heights.
Natural scalar keys, payloads and heights; pointers remain in a separate machine bank.
Concrete standard word-RAM scalar certificate for model, using the identity encoding.
Every operation is admissible when its result fits. The height-gap comparison requires only
its truncated difference to fit; strict and nonstrict comparisons require no extra headroom.