Linear-time canonical binary subtraction -- pure proofs #
The raw scan is verified through the standard full-subtractor invariant. Its
final borrow decides underflow, while trimming is proved to recover the
canonical Nat.bits representation of the raw fixed-width value.
Arithmetic invariant for the fixed-width borrow scan. The final borrow is the coefficient of the width-sized wraparound term.
Appending a redundant high zero does not change canonical trimming.
Trimming arbitrary little-endian bits produces the canonical bits of their decoded natural value.
The complete subtractor is linear in the sum of the operand widths.