77 Communication Complexity — Bit String
77.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.
77.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.
Let \(x\) and \(y\) be \(n\)-bit strings. Then the number of coordinates on which \(x\) and \(y\) agree, together with their Hamming distance \(d(x, y)\) — the number of coordinates on which they differ — sums to the length:
Let \(x, y : \mathrm{Fin}\, n \to \mathrm{Bool}\) be two \(n\)-bit strings, with agreement count \(\mathrm{agr}(x,y)\) the number of coordinates on which they coincide and \(d_H(x,y)\) their Hamming distance (the number of coordinates on which they differ). Then, as an identity of integers,
Let \(x, y\) be two \(n\)-bit strings, that is, functions from \(\{ 0, 1, \dots , n-1\} \) to \(\{ 0,1\} \), and let \(d(x,y)\) denote their Hamming distance, the number of coordinates on which they disagree. Then their signed inner product — the sum over all coordinates of \(+1\) where \(x\) and \(y\) agree and \(-1\) where they disagree — satisfies
Let \(x\) and \(y\) be two \(n\)-bit strings. Their signed inner product \(\langle x, y\rangle \) is the integer \(\sum _{i} \varepsilon _i\), where \(\varepsilon _i = +1\) at each coordinate \(i\) on which \(x_i = y_i\) and \(\varepsilon _i = -1\) at each coordinate on which \(x_i \neq y_i\). Writing \(a(x,y)\) for the agreement count of \(x\) and \(y\), the number of coordinates on which they agree, and \(d_H(x,y)\) for the Hamming distance between them, the number of coordinates on which they differ, one has
an equality of integers in which the two counts are regarded as integers.
Let \(x_1, y_1 : \mathrm{Fin}\, m \to \mathrm{Bool}\) be \(m\)-bit strings and \(x_2, y_2 : \mathrm{Fin}\, n \to \mathrm{Bool}\) be \(n\)-bit strings, and write \(x_1 \frown x_2\) for the length-\((m+n)\) string obtained by concatenation, whose first \(m\) coordinates are those of \(x_1\) and whose last \(n\) coordinates are those of \(x_2\). Writing \(\langle x, y\rangle \) for the signed inner product of two equal-length bit strings — the number of coordinates on which they agree minus the number on which they disagree — the signed inner product of the two concatenations splits as the sum of the block-wise signed inner products:
Let \(m\) and \(n\) be natural numbers with \(m = n\), and let \(x, y \colon \mathrm{Fin}\, n \to \mathrm{Bool}\) be two \(n\)-bit strings, writing \(\langle x, y\rangle \) for their signed inner product. The equality \(m = n\) gives a bijection \(\sigma \colon \mathrm{Fin}\, m \to \mathrm{Fin}\, n\), and precomposing with it turns \(x\) and \(y\) into the \(m\)-bit strings \(x \circ \sigma \) and \(y \circ \sigma \). Then reindexing both strings in this way leaves the signed inner product unchanged:
Let \(x, y \colon \{ 0, \dots , n-1\} \to \{ 0,1\} \) be two \(n\)-bit strings, and write \(\langle x, y\rangle \) for their signed inner product, the integer \(\sum _{i} \sigma _i\) where \(\sigma _i = +1\) when \(x_i = y_i\) and \(\sigma _i = -1\) otherwise. For a natural number \(a\), let \(x^{(a)}\) and \(y^{(a)}\) denote the \(an\)-bit strings obtained by concatenating \(a\) consecutive copies of \(x\) and of \(y\), respectively. Then