Documentation

Complexity.Computability.Circuit.Boolean.Iteration.ModulusCounter.Remainders

Modular-counter remainders, short-exponent circuits, and variable-time equivalence #

Computing ModulusCounter.power T on 2 k bits is equivalent up to O(k) gates to computing the fixed-integer remainder x ↦ T % x on k-bit moduli (ModulusCounter.remainder_of_power, ModulusCounter.power_of_remainder, counter_powers_compute_remainders). Likewise, variable-time iteration of counterStep k for an m-bit input time is equivalent up to O(k) gates to m-bit division remainder (variable_time_counter_iff_remainder).

Hardwiring m numerator bits into the streaming remainder circuit of Remainder.lean shows that any exponent T < 2 ^ m has a power circuit of size at most 110 * (m + 1) * (k + 1) (ModulusCounter.short_power_circuit). Consequently, every hard power requires an exponent of binary length m = Ω(2 ^ k / k ^ 2) (ModulusCounter.hard_power_requires_long_exponent, ModulusCounter.hard_power_exponent_capacity).

Main definitions #

Main results #

References #

Fixed-integer remainders and equivalence with counter powers #

Fixed-integer remainder x ↦ T % x on k-bit words, with 0 on modulus 0.

Instances For

    A circuit for power T yields a circuit for remainder T with at most one extra gate.

    A circuit for remainder T yields a circuit for power T with at most 100 * (k + 1) extra gates.

    Short-exponent upper bounds and exponent-length lower bounds #

    theorem Cslib.Circuits.Boolean.Iteration.ModulusCounter.short_remainder_circuit (k m T : ℕ) (hT : T < 2 ^ m) :
    ∃ (out : Circuit signature k k), out.Computes interpretation (remainder T) ∧ out.size ≤ m * (51 * (k + 1) + 4) + 10 * (k + 1)

    Hardwiring m numerator bits into bounded_modulus_remainder and masking modulus zero gives a circuit for remainder T of size linear in m * (k + 1).

    theorem Cslib.Circuits.Boolean.Iteration.ModulusCounter.short_power_circuit (k m T : ℕ) (hT : T < 2 ^ m) :
    ∃ (out : Circuit signature (k + k) (k + k)), out.Computes interpretation (power T) ∧ out.size ≤ 110 * (m + 1) * (k + 1)

    A fixed exponent T < 2 ^ m gives a circuit for power T of size at most 110 * (m + 1) * (k + 1).

    theorem Cslib.Circuits.Boolean.Iteration.ModulusCounter.hard_power_requires_long_exponent (k m T : ℕ) (hT : T < 2 ^ m) (hard : ∀ (c : Circuit signature (k + k) (k + k)), c.Computes interpretation (power T) → lowerBudget k < c.size) :
    lowerBudget k < 110 * (m + 1) * (k + 1)

    Any exponent whose counter power requires more than lowerBudget k gates needs lowerBudget k < 110 * (m + 1) * (k + 1).

    theorem Cslib.Circuits.Boolean.Iteration.ModulusCounter.hard_power_exponent_capacity (k m T : ℕ) (hT : T < 2 ^ m) (hard : ∀ (c : Circuit signature (k + k) (k + k)), c.Computes interpretation (power T) → lowerBudget k < c.size) :
    2 ^ k < 112640 * (m + 1) * (k + 1) ^ 2

    Explicit exponential lower bound on the binary length m of any hard exponent T < 2 ^ m.

    Remainder helpers and variable-time equivalence #

    Pack a k-bit modulus x with initial counter state 0.

    Instances For

      Extract the k-bit counter state from a 2 k-bit state.

      Instances For

        Computing ModulusCounter.power T and computing ModulusCounter.remainder T are equivalent up to linear additive overhead.

        Two-input remainder function on m numerator bits followed by k modulus bits, returning 0 when the modulus is 0.

        Instances For

          Variable-time iteration of counterStep k for an m-bit input time is equivalent up to O(k) gates to computing the m-bit remainder inputTimeRemainder m k.