Documentation

CslibFrontier.Computability.WordRAM.Power

Native natural powers #

Main definitions #

Main results #

@[reducible, inline]

Result accumulator, initially one.

@[reducible, inline]

Number of completed multiplications.

@[reducible, inline]

Input base.

@[reducible, inline]

Input exponent.

@[reducible, inline]

Constant one, initialized by the routine.

One multiplication and one counter increment.

A fixed program for natural exponentiation by repeated multiplication.

def Cslib.WordRAM.Power.Post (b n : ℕ) (x y : Data 5) :

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)) :
∃ (y : Data 5), ExecWithin w program x y (4 * n + 5) ∧ Post b n x y

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.