75 Boolean Analysis — Bool Fourier
75.1 Overview
This module develops Fourier analysis on the Boolean hypercube \(\{ 0,1\} ^n\), building on top of TCSlib.BooleanAnalysis.Basic. It introduces type aliases for the hypercube and Boolean functions, the group structure (XOR), the uniform expectation operator, the inner product and \(L^2\) norm, Fourier–Walsh characters, Fourier coefficients, and proves the fundamental theorems: orthonormality of characters, the Walsh expansion, Parseval’s identity, and the convolution theorem.
75.2 Declarations
The Boolean hypercube of dimension \(n\) is the type \(\{ 0,1\} ^n\), defined as an abbreviation for BooleanAnalysis.BoolCube \(n\).
A Boolean function of arity \(n\) is an element of type \(\{ 0,1\} ^n \to \mathbb {R}\), defined as an abbreviation for BooleanAnalysis.BooleanFunc \(n\).
The map \(\mathrm{BoolToPM1} : \mathrm{Bool} \to \mathbb {R}\) sends \(\mathtt{false}\) to \(1\) and \(\mathtt{true}\) to \(-1\), realising the standard identification \(\{ 0,1\} \cong \{ \pm 1\} \).
The partial inverse \(\mathrm{PM1ToBool?} : \mathbb {R} \to \mathrm{Option}\, \mathrm{Bool}\) returns \(\mathtt{some}\, \mathtt{true}\) on \(-1\), \(\mathtt{some}\, \mathtt{false}\) on \(1\), and \(\mathtt{none}\) on all other real numbers.
\(\mathrm{zero\_ vec}(n) : \{ 0,1\} ^n\) is the constant-\(\mathtt{false}\) function, serving as the additive identity of the group \((\mathbb {F}_2)^n\).
For \(x, y \in \{ 0,1\} ^n\), the vector \(\mathrm{xor\_ vec}(x,y)_i = x_i \oplus y_i\) is the componentwise XOR, giving the group operation on \((\mathbb {F}_2)^n\).
For every \(n : \mathbb {N}\), the Boolean hypercube satisfies \(|\{ 0,1\} ^n| = 2^n\).
The average of the two values of the \(\pm 1\) embedding is zero:
For every \(b : \mathrm{Bool}\), \(\mathrm{BoolToPM1}(b)^2 = 1\).
For every \(b : \mathrm{Bool}\), \(\mathrm{BoolToPM1}(\lnot b) = -\mathrm{BoolToPM1}(b)\).
For all \(a, b : \mathrm{Bool}\), \(\mathrm{BoolToPM1}(a \oplus b) = \mathrm{BoolToPM1}(a) \cdot \mathrm{BoolToPM1}(b)\); that is, XOR corresponds to multiplication in \(\{ \pm 1\} \subset \mathbb {R}\).
For \(f : \{ 0,1\} ^n \to \mathbb {R}\), the uniform expectation is
If \(g : \mathrm{Fin}\, n \to \mathrm{Bool} \to \mathbb {R}\) and \(f(x) = \prod _{i} g_i(x_i)\), then
The inner product of \(f, g : \{ 0,1\} ^n \to \mathbb {R}\) is
The squared \(L^2\) norm of \(f : \{ 0,1\} ^n \to \mathbb {R}\) is
The convolution of \(f, g : \{ 0,1\} ^n \to \mathbb {R}\) is the function
For a set \(S \subseteq [n]\), the Walsh character \(\chi _S : \{ 0,1\} ^n \to \mathbb {R}\) is
defined as an alias for BooleanAnalysis.chiS.
For every \(S \subseteq [n]\), \(\chi _S(\mathbf{0}) = 1\).
For every \(S \subseteq [n]\) and \(x \in \{ 0,1\} ^n\), \(\chi _S(x)^2 = 1\).
\(\chi _\emptyset = \mathbf{1}\), the constant function equal to \(1\).
For all \(S, T \subseteq [n]\) and \(x \in \{ 0,1\} ^n\),
where \(S \mathbin {\triangle } T\) denotes the symmetric difference.
For every \(x \in \{ 0,1\} ^n\) with \(x \ne \mathbf{0}\),
\(\mathbb {E}[\chi _\emptyset ] = 1\).
If \(S \ne \emptyset \), then \(\mathbb {E}[\chi _S] = 0\).
For every \(S \subseteq [n]\), \(\langle \chi _S, \chi _S \rangle = 1\).
If \(S \ne T\), then \(\langle \chi _S, \chi _T \rangle = 0\).
The Fourier coefficient of \(f : \{ 0,1\} ^n \to \mathbb {R}\) at \(S \subseteq [n]\) is
For every \(S \subseteq [n]\), \(\widehat{\chi _S}(S) = 1\).
If \(S \ne T\), then \(\widehat{\chi _S}(T) = 0\).
The locally-defined expectation BoolFourier.expectation agrees with BooleanAnalysis.expect: for every \(f\), \(\mathbb {E}[f] = \mathrm{expect}(f)\).
For every \(f\) and \(S\), \(\mathrm{fourier\_ coeff}(f, S) = \mathrm{fourierCoeff}(f, S)\), bridging the local and upstream definitions.
Every Boolean function \(f : \{ 0,1\} ^n \to \mathbb {R}\) expands in the Walsh–Fourier basis:
For every \(f : \{ 0,1\} ^n \to \mathbb {R}\),
For all \(f, g : \{ 0,1\} ^n \to \mathbb {R}\) and \(S \subseteq [n]\),
75.3 Additional declarations
For every \(S \subseteq [n]\) and every \(x \in \{ 0,1\} ^n\), \(\chi _S(x)^2 = 1\). This is the squaring form (with exponent \(2\) rather than an explicit product) of the fact that Walsh characters take values in \(\{ \pm 1\} \).
As functions of \(S\), the evaluation of characters at the all-zeros vector is constant:
Let \(x \in \{ 0,1\} ^n\) with \(x \ne \mathbf{0}\) and let \(i\) be a coordinate with \(x_i = \mathtt{true}\). Then the sum of all characters at \(x\) equals the sum of their negations:
For a non-empty \(S \subseteq [n]\), the uniform expectation of the character \(\chi _S\) factorises over the coordinates of \(S\):
For every \(f : \{ 0,1\} ^n \to \mathbb {R}\), the locally-defined squared \(L^2\) norm agrees with the upstream inner product of \(f\) with itself:
For all \(f, g : \{ 0,1\} ^n \to \mathbb {R}\) and \(S \subseteq [n]\), the double sum defining the unnormalised convolution coefficient may be reordered:
For all \(x, y \in \{ 0,1\} ^n\) and \(S \subseteq [n]\),
expressing that \(\chi _S\) is a character of the group \((\mathbb {F}_2)^n\). The statement also carries the (unused) Fubini hypothesis of the enclosing proof.
Let \(f, g : \{ 0,1\} ^n \to \mathbb {R}\), let \(S \subseteq [n]\), assume the Fubini interchange for the convolution coefficient, and let \(y \in \{ 0,1\} ^n\). Then translating the argument of \(g\) by \(y\) only multiplies the character-weighted sum by \(\chi _S(y)\):