The existing binary subtraction word algorithm #
The public borrow, digit-pair and subtraction definitions and laws are moved unchanged from the higher arithmetic facade. No machine or computability predicate is needed for these identities. The consuming-cursor realization has the same borrow rounds without repeated indexed lookup.
Main definitions #
BinarySub.borrow,BinarySub.subStep: the existing schoolbook borrow round.BinarySub.digitPairs: the original indexed pairs of input digits.BinarySub.cursorStep: consume the remaining words and execute that same round.
Main results #
BinarySub.sub_eq: the existing truncated-subtraction correctness law.BinarySub.foldl_cursorStep: equality of the consuming and indexed realizations.BinarySub.cursorStep_lengths: remaining words never grow; one output digit is added per round.
The borrow out of a digit position: the minuend digit x minus the subtrahend digit y and
the incoming borrow c is negative.
Instances For
Truncated subtraction through the borrow of schoolbook subtraction: when the final borrow is set the difference is negative, and otherwise the digits read off the difference.