80 Communication Complexity — Bit String
80.1 Overview
This module introduces \(n\)-bit strings as Boolean-valued functions on \(\mathrm{Fin}\, n\) and develops the signed inner product of two such strings under the standard \(\{ 0,1\} \to \{ \pm 1\} \) correspondence. The main results relate the signed inner product to the Hamming distance: it equals \(n - 2\, \mathrm{hammingDist}(x,y)\), and it is additive under concatenation and multiplicative under repetition.
80.2 Declarations
An \(n\)-bit string is a function \(x : \mathrm{Fin}\, n \to \mathrm{Bool}\). The type \(\texttt{CommunicationComplexity.BitString}\, n\) is an abbreviation for \(\mathrm{Fin}\, n \to \mathrm{Bool}\).
Given two \(n\)-bit strings \(x, y : \mathrm{Fin}\, n \to \mathrm{Bool}\), their signed inner product is the integer
Each coordinate where \(x\) and \(y\) agree contributes \(+1\), and each disagreeing coordinate contributes \(-1\).
The agreement count of two \(n\)-bit strings \(x\) and \(y\) is the number of coordinates \(i \in \mathrm{Fin}\, n\) on which \(x_i = y_i\), i.e., \(\# \{ i : x_i = y_i\} \) as a natural number.
For any two \(n\)-bit strings \(x\) and \(y\),
The agreeing and disagreeing coordinates partition \(\{ 0, \ldots , n-1\} \).
For any two \(n\)-bit strings \(x\) and \(y\), the agreement count satisfies
as an equality of integers (after casting the natural numbers to \(\mathbb {Z}\)).
For any two \(n\)-bit strings \(x\) and \(y\),
For any two \(n\)-bit strings \(x\) and \(y\),
That is, the signed inner product equals the number of agreeing coordinates minus the number of disagreeing coordinates.
For strings \(x_1, y_1 : \mathrm{Fin}\, m \to \mathrm{Bool}\) and \(x_2, y_2 : \mathrm{Fin}\, n \to \mathrm{Bool}\),
Concatenating both pairs of bit strings adds their signed inner products.
If \(m = n\) and \(x, y : \mathrm{Fin}\, n \to \mathrm{Bool}\), then
Reindexing both inputs along a \(\mathrm{Fin.cast}\) does not change the signed inner product.
For any \(n\)-bit strings \(x\) and \(y\) and any \(a : \mathbb {N}\),
Repeating both inputs \(a\) times multiplies the signed inner product by \(a\).