Counting the parities of a random string with one bit of a #P value #
The second half of Toda's theorem Toda, Arora and Barak, Section 17.4:
for numbers f r of accepted witnesses, given for the random strings r of length R, the
number G of random strings with f r odd is read off one bit of a single counting function.
Modulus amplification by binomial coefficients #
Toda's amplifier uses residues 0 modulo 2 ^ K for even counts and -1 for odd counts.
This module uses the opposite sign: 0 for even counts and +1 for odd counts. Negating our
amplifier modulo 2 ^ K recovers the 0/-1 convention. All subsequent counts and bit
extraction here use the +1 convention, from the binomial expansion of (1 - 2) ^ c
(Cslib.BitString.sum_range_neg_two_pow_mul_choose):
[c odd] = ∑ i < c, (-2) ^ i * choose c (i + 1),
whose terms with i ≥ K vanish modulo 2 ^ K
(Cslib.BitString.sum_range_neg_two_pow_mul_choose_zmod). The coefficients (-2) ^ i are
replaced by naturals equal to them modulo 2 ^ K (Cslib.Complexity.Toda.parityCoeff), and
choose (f r) k counts the k-element sets of accepted witnesses, written as strictly
increasing lists of k words for the lexicographic order
(Cslib.BitString.card_filter_strictMono, Cslib.BitString.wordLt_ofFn_iff). So
the words accepted by Cslib.Complexity.Toda.countingTest — a size k ≤ K in unary, one of
parityCoeff K (k - 1) coefficient words, a random string r and a strictly increasing list of
k accepted witnesses, padded with zero words — number
H = ∑ i < K, parityCoeff K i * ∑ r, choose (f r) (i + 1)
(Cslib.Complexity.Toda.card_filter_countingTest), and with K = R + 1, H is G modulo
2 ^ (R + 1) (Cslib.Complexity.Toda.cast_card_filter_countingTest).
One bit decides the majority #
Cslib.Complexity.Toda.sharpTest accepts 2 H + 2 ^ R - 1 words
(Cslib.Complexity.Toda.card_filter_sharpTest). Since G ≤ 2 ^ R, the bit R + 1 of this
number says whether 2 G > 2 ^ R, that is whether more than half of the random strings have an
odd number of accepted witnesses (Cslib.Complexity.Toda.testBit_card_filter_sharpTest).
Main definitions #
Cslib.Complexity.Toda.parityCoeff: the coefficients of the amplification.Cslib.Complexity.Toda.countingTest,Cslib.Complexity.Toda.sharpTest: the word tests of the counting functions.
Main results #
Cslib.Complexity.Toda.cast_card_filter_countingTest: the count isGmodulo2 ^ (R + 1).Cslib.Complexity.Toda.testBit_card_filter_sharpTest: one bit says whether2 G > 2 ^ R.
References #
Modulus amplification #
Natural coefficients equal to (-2) ^ i modulo 2 ^ K, for i ≤ K: 2 ^ i for even i
and 2 ^ K - 2 ^ i for odd i.
Instances For
Subsets as strictly increasing tuples #
The counting test #
The counting test: a size k in unary in the first K bits, a coefficient word in the
next K, a random string r in the next R, and a k-subset of words accepted by accept r
in K rows of Z bits.
Instances For
The count of the counting test: ∑ i < K, parityCoeff K i * ∑ r, choose (f r) (i + 1),
where f r counts the words accepted by accept r.
One bit of the #P count decides the majority: the bit R + 1 of the number of words
accepted by the #P test says whether more than half of the random strings r of length R
have an odd number of words accepted by accept r.
Polynomial time #
Toda's counting verifier has a plain polynomial-time certificate with the same captured input, two unary width parameters and word encoding as its machine-construction certificate.