Documentation

CslibFrontier.Foundations.Data.BitString.Sign.BigOperators

Signs of sums of bits and sign correlations #

In the two-element Boolean ring, where a + b = (a ^^ b), the sign of a sum of bits is the product of their signs (BitString.signVal_sum), and the value of a product of bits is the product of their values (BitString.bitVal_prod).

The sign correlation ∑ x, signVal (f x) * signVal (g x) of two words f g : X → Bool counts the positions where they agree minus those where they differ. It is 2 #{x | f x = g x} - |X| (BitString.sum_signVal_mul_signVal_eq_two_mul_card_sub) and |X| - 2 d(f, g) for the Hamming distance d (BitString.sum_signVal_mul_signVal_eq_card_sub) [O'Donnell, Section 1.4][ODonnell2014]. So f agrees with g on at least a 1 / 2 + ε fraction of the positions exactly when their correlation is at least 2 ε |X|.

Main results #

References #

theorem Cslib.BitString.signVal_sum {α : Type u_1} (s : Finset α) (f : α → Bool) :
signVal (∑ a ∈ s, f a) = ∏ a ∈ s, signVal (f a)

The sign of a sum in the two-element Boolean ring is the product of the signs.

theorem Cslib.BitString.bitVal_prod {α : Type u_1} (s : Finset α) (f : α → Bool) :
bitVal ℝ (∏ a ∈ s, f a) = ∏ a ∈ s, bitVal ℝ (f a)

Reading a product of bits as a real number gives the product of the readings.

theorem Cslib.BitString.sum_signVal_mul_signVal_eq_two_mul_card_sub {X : Type u_1} [Fintype X] (f g : X → Bool) :
∑ x : X, signVal (f x) * signVal (g x) = 2 * ↑{x : X | f x = g x}.card - ↑(Fintype.card X)

Correlation counts agreements: the sign correlation of two words is twice the number of positions where they agree, minus the number of positions.

theorem Cslib.BitString.sum_signVal_mul_signVal_eq_card_sub {X : Type u_1} [Fintype X] (f g : X → Bool) :
∑ x : X, signVal (f x) * signVal (g x) = ↑(Fintype.card X) - 2 * ↑(hammingDist f g)

Correlation is the length minus twice the distance: the sign correlation of two words is the number of positions minus twice their Hamming distance.