Unary arithmetic by loops #
The routines the pipeline's parameter computations need, whose running time is polynomial in the
value of their input rather than its size: writing a binary number in unary (toUnaryProg)
and raising a unary number to a binary power (powProg). Both are whileProg loops
(MIPRE/Foundations/Cost/While) of polynomial-time steps.
A unary numeral, read off its encoding.
Equations
Instances For
Binary to unary #
One step of the conversion, on (x, acc): stop with acc at x = 0, else move one unit.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Binary to unary: encode x ↦ encode (unary x).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Powers #
One step of the power, on (e, acc, b): stop with acc at e = 0, else multiply by b.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The power: encode (b, e) ↦ encode (unary (|b|^e)).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Stages #
A stage of a routine: split the input into an argument and a context, run p on the
argument, and combine the context with its answer.
Equations
- MIPRE.Pipeline.stageProg pre p post = MIPRE.Cost.seqProg pre.code (p.callWithContext post)