Native natural powers #
Main definitions #
Power.program: repeated native multiplication, with base and exponent in registers.
Main results #
Power.exec:b^nwithin4n+5instructions, with input-derived intermediate fits.
@[reducible, inline]
Number of completed multiplications.
@[reducible, inline]
Constant one, initialized by the routine.
One multiplication and one counter increment.
A fixed program for natural exponentiation by repeated multiplication.
Output value, loop counters, input readback and memory after exponentiation.
theorem Cslib.WordRAM.Power.exec {w : ℕ} (b n : ℕ) (hb : 1 ≤ b) (x : Data 5) (hx : x.regs base = b) (hn : x.regs exponent = n) (hfit : Fits w (b ^ n + n + 2)) :
The routine is uniform in its arguments and preserves memory and both input registers. Every multiplication fit follows from the final power and exponent bound.