Compiler certificates for restoring quotient loops #
The logical restoring loop is convenient for proofs, while the primitive-word accumulator avoids
allocating a state at every generated quotient bit. This module proves the one- and two-limb loops
extensionally equal and registers the optimized direction with @[csimp].
Keeping this certificate separate from Quotient.Proof matters for executable clients: they can
enable the verified compiler rewrite without importing the much larger rational-arithmetic proof
development.
The unboxed one-word accumulators preserve every step of the restoring recurrence.
The one-word implementation agrees for every state and iteration count.
Compile one-word restoring division through primitive accumulators.
Compile scaled quotient rounding through the same accumulator.
This equation also replaces calls whose original body was compiled before the loop certificate was imported.
The primitive-word accumulator implements the logical two-limb restoring recurrence.
Compile the logical two-limb quotient loop through its verified word accumulator.