Binary-power arithmetic circuits #
Binary powering computes each intermediate power once and shares it between the two inputs
of a squaring gate. Every further binary digit adds one squaring and, for a one bit, a
multiplication by the retained original input. A positive exponent e uses at most
2 * Nat.log2 e gates, all multiplications. Exponent zero uses a single named constant gate;
exponent one uses only the input wire.
The constant symbol denoting one is an explicit parameter. Its interpretation is required to equal one only in the correctness theorem. Arbitrary weighted costs, including constant costs, are accounted for exactly. These are circuit-size results, not uniform TM-time certificates for circuit generation or evaluation.
Main definitions #
Cslib.Circuits.binaryPowerCircuit: the shared binary-power circuit.Cslib.Circuits.binaryMultiplicationCount: its exact multiplication count.
Main results #
Cslib.Circuits.eval_binaryPowerCircuit: correctness over a monoid with addition.Cslib.Circuits.cost_program_binaryPowerCircuit: exact cost for any operation weights.Cslib.Circuits.size_binaryPowerCircuit_le: logarithmic gate count for positive exponents.
References #
- Ported from Basis/Arithmetic/Power.lean in S. Schlesinger, Algebraic circuit formalizations in Complexitylib.
Add a binary digit to a shared power: square, then multiply by the original input for a one bit.
Instances For
Binary powering with a specified constant symbol for one.
Instances For
Exact multiplication count of binary powering: one squaring per nonleading bit and one further multiplication per nonleading one bit.
Instances For
Exact weighted cost, charging the constant gate for exponent zero.
Every gate at a positive exponent is a multiplication; exponent zero has one constant.
The multiplication count includes multiplication by scalars.
Binary powering uses at most twice the base-two logarithm many multiplications.
A positive exponent needs at most 2 * log₂ e gates, all multiplications.