Counting out the value of a bit string #
A verifier turns its coins into an index — into a list of edges, say — and an index has to be counted out in unary before a polynomial-time loop can use it. This module does that: it reads a bit string as a little-endian binary number and writes that many marks.
The conversion is only polynomial time when the value is, which is why the result is clamped: the fold's state is truncated to a width the caller supplies. On strings short enough for the clamp — logarithmically many coins, say — the answer is exact.
Main definitions #
Complexity.unaryVal— the value of a bit string, in unary
Main results #
Complexity.unaryVal_eq— it is exact when the clamp is wide enoughComplexity.unaryVal_mem_FP— it is polynomial time
Reading a zero: the value doubles.
Equations
Instances For
Reading a one: the value doubles and gains one.
Equations
Instances For
The value of a bit string, in unary, computed on pair anything bits.
Equations
Instances For
theorem
Complexity.unaryVal_eq
{p : Polynomial ℕ}
{z : List Bool}
(h : 2 ^ (pairSnd z).length ≤ Polynomial.eval z.length p)
:
The conversion is exact when the clamp is wide enough for the value.