Truth tables read from a random string #
A family of Boolean functions f v : BooleanFunction (ℓ v), one for each v : Fin n, can be read
from a string of bits laid out in blocks of width B: the table of f v occupies the bits
v * B + equivFin y for the inputs y of f v, numbered by BitString.equivFin
(BitString.decodeTables). Positions past the end of the string read false, so every list
decodes to some family.
When every table fits in its block (2 ^ ℓ v ≤ B) and the blocks fit in the string (n * B ≤ p),
decoding a uniformly random string of p bits gives a uniformly random family: each family is
decoded from exactly 2 ^ p / 2 ^ (∑ v, 2 ^ ℓ v) strings. In counting form, a set S of families
is hit by #S * 2 ^ p / 2 ^ (∑ v, 2 ^ ℓ v) strings (BitString.card_filter_decodeTables_mem_mul).
This turns a count of bad families into a count of bad random strings, which is what a randomized
reduction that samples functions from its random bits needs.
The proof is the library's count of functions by a property of their restriction along an
injection (Nat.card_subtype_comp_injective_mul), applied to the positions of the tables
(BitString.tablePos).
Main definitions #
Cslib.BitString.decodeTables: the family of truth tables read from a list of bits.Cslib.BitString.tablePos: the position of an entry of a table in the block layout.
Main results #
Cslib.BitString.card_functionTables: there are2 ^ (∑ v, 2 ^ ℓ v)families of tables.Cslib.BitString.card_filter_decodeTables_mem_mul: decoding a random string hits a set of families in proportion to its size.Cslib.BitString.mul_card_filter_decodeTables_mem_le: the same as an inequality: rare families are decoded from rare strings.
Truth tables read from a list of bits, in blocks of width B: the table of v is read
from the bits v * B + equivFin y, for the inputs y of v's function in the order
BitString.equivFin. Missing bits read false, so every list decodes.
Decoding the bits of a string of length p reads them at the positions tablePos.
There are 2 ^ (∑ v, 2 ^ ℓ v) families of truth tables.
Decoding a random string hits a set of families in proportion to its size. If every table
fits in a block of width B and the n blocks fit in p bits, the strings r of p bits whose
decoding lies in S are a #S / 2 ^ (∑ v, 2 ^ ℓ v) fraction of all 2 ^ p strings.
Rare families are decoded from rare strings. If at most a b / a fraction of the
families lie in S, then at most a b / a fraction of the strings of p bits decode into S.