Boolean Analysis #
This file develops the basic theory of Boolean functions f : {-1, 1}ⁿ → ℝ (or equivalently
f : {0, 1}ⁿ → ℝ) and their Fourier–Walsh expansion over the real numbers.
Main definitions #
BooleanFunc n: the type of functions(Fin n → Bool) → ℝ.innerProduct f g: the inner product𝔼[f · g] = 2⁻ⁿ ∑_{x} f(x) g(x).chiS n S: the Walsh–Fourier characterχ_S(x) = (-1)^{|S ∩ supp(x)|}forS : Finset (Fin n).fourierCoeff f S: the Fourier coefficientf̂(S) = ⟪f, χ_S⟫.influence i f: the influence of coordinateionf,Inf_i[f] = 𝔼[(f(x) - f(xⁱ))² / 4]wherexⁱisxwith bitiflipped.totalInfluence f: the total influenceI[f] = ∑ᵢ Inf_i[f].noise f ρ: the noise operatorT_ρ f(x) = 𝔼_y[f(y)]where each bit ofyisxindependently with probability(1+ρ)/2and flipped with probability(1-ρ)/2.
Main results #
walsh_expansion: every Boolean function has a unique Fourier–Walsh expansionf = ∑_{S ⊆ [n]} f̂(S) χ_S.parseval: Parseval's identity‖f‖² = ∑_S f̂(S)².fourier_coeff_chi: orthonormality of the Walsh characters,⟪χ_S, χ_T⟫ = [S = T].totalInfluence_eq_sum_sq_deg:I[f] = ∑_S |S| · f̂(S)².
Notation #
𝔹 nforFin n → Bool(the Boolean hypercube).⟪f, g⟫_𝔹for the Boolean inner product.χ_[S]for the Walsh character ofS.
References #
- Ryan O'Donnell, Analysis of Boolean Functions, Cambridge University Press, 2014.
Setup: the Boolean hypercube #
The Boolean hypercube {0,1}ⁿ.
Equations
- BooleanAnalysis.BoolCube n = (Fin n → Bool)
Instances For
A Boolean function f : {0,1}ⁿ → ℝ.
Equations
Instances For
Uniform measure and expectation #
The uniform probability measure on {0,1}ⁿ assigns weight 2⁻ⁿ to each point.
Equations
Instances For
Expectation of f under the uniform measure on {0,1}ⁿ.
𝔼[f] = 2⁻ⁿ · ∑_{x ∈ {0,1}ⁿ} f(x).
Equations
- BooleanAnalysis.expect f = BooleanAnalysis.uniformWeight n * ∑ x : BooleanAnalysis.BoolCube n, f x
Instances For
The L² inner product on Boolean functions with respect to the uniform measure:
⟪f, g⟫ = 𝔼[f · g] = 2⁻ⁿ · ∑_x f(x) g(x).
Equations
- BooleanAnalysis.innerProduct f g = BooleanAnalysis.expect fun (x : BooleanAnalysis.BoolCube n) => f x * g x
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
The L² norm of a Boolean function: ‖f‖ = √(⟪f, f⟫).
Equations
Instances For
Walsh–Fourier characters #
The Walsh–Fourier character χ_S : {0,1}ⁿ → ℝ associated to a set S ⊆ [n].
χ_S(x) = ∏_{i ∈ S} (-1)^{x_i}.
This forms an orthonormal basis for L²({0,1}ⁿ, uniform).
Equations
- BooleanAnalysis.chiS S x = ∏ i ∈ S, BooleanAnalysis.boolToSign (x i)
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
The character χ_{i} for a singleton {i} equals (-1)^{x_i}.
Fourier coefficients #
The Fourier–Walsh coefficient of f at frequency S:
f̂(S) = ⟪f, χ_S⟫ = 2⁻ⁿ · ∑_x f(x) · χ_S(x).
Equations
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
The Fourier coefficient at ∅ equals the expectation of f.
Fourier inversion (Walsh expansion) #
Walsh Expansion: every Boolean function f : {0,1}ⁿ → ℝ can be written as
f(x) = ∑_{S ⊆ [n]} f̂(S) · χ_S(x).
This is the Fourier inversion formula for the uniform measure on {0,1}ⁿ.
Parseval's identity #
Orthonormality of Walsh characters #
Self inner product of a Walsh character is 1.
Parseval's Identity: ‖f‖² = ∑_{S ⊆ [n]} f̂(S)².
The sum of squared Fourier coefficients equals the squared L² norm.
Flip the i-th bit of x : {0,1}ⁿ.
Equations
- BooleanAnalysis.flipBit x i = Function.update x i !x i
Instances For
Influence of a coordinate #
The influence of coordinate i on f:
Inf_i[f] = Pr_x[f(x) ≠ f(xⁱ)]
where xⁱ denotes x with the i-th bit flipped.
For {-1,1}-valued functions this equals 𝔼[(f(x) - f(xⁱ))² / 4].
Equations
- BooleanAnalysis.influence i f = BooleanAnalysis.expect fun (x : BooleanAnalysis.BoolCube n) => (f x - f (BooleanAnalysis.flipBit x i)) ^ 2 / 4
Instances For
The total influence of f:
I[f] = ∑_{i=1}^{n} Inf_i[f].
Equations
- BooleanAnalysis.totalInfluence f = ∑ i : Fin n, BooleanAnalysis.influence i f
Instances For
Influence via Fourier: Inf_i[f] = ∑_{S ∋ i} f̂(S)².
Total Influence via Fourier: I[f] = ∑_S |S| · f̂(S)².
Noise operator #
The noise operator T_ρ with noise rate ρ ∈ [-1, 1]:
T_ρ f(x) = 𝔼_y[f(y)] where each coordinate of y independently equals
x_i with probability (1+ρ)/2 and ¬x_i with probability (1-ρ)/2.
In the Fourier domain: (T_ρ f)̂(S) = ρ^{|S|} · f̂(S).
Equations
- BooleanAnalysis.noiseOp ρ f x = ∑ S : Finset (Fin n), ρ ^ S.card * BooleanAnalysis.fourierCoeff f S * BooleanAnalysis.chiS S x
Instances For
Noise operator in Fourier domain: (T_ρ f)̂(S) = ρ^{|S|} · f̂(S).
Stability formula: ⟪f, T_ρ f⟫ = ∑_S ρ^{|S|} · f̂(S)².
Linearity and combinatorial properties #
Boolean functions form an ℝ-vector space.
Equations
- BooleanAnalysis.instModuleRealBooleanFunc = Pi.module (BooleanAnalysis.BoolCube n) (fun (a : BooleanAnalysis.BoolCube n) => ℝ) ℝ
The inner product is bilinear in the first argument.
The inner product is symmetric.
The inner product is nonneg on the diagonal.
The Walsh characters {χ_S}_{S ⊆ [n]} span L²({0,1}ⁿ).
There are exactly 2ⁿ characters, matching the dimension of L²({0,1}ⁿ) ≅ ℝ^{2ⁿ}.
Dictator and parity functions #
The dictator function for coordinate i: f(x) = (-1)^{x_i}.
Its only nonzero Fourier coefficient is f̂({i}) = 1.
Equations
Instances For
The parity function f(x) = (-1)^{x_1 + ⋯ + x_n}.
Its only nonzero Fourier coefficient is f̂([n]) = 1.
Equations
- BooleanAnalysis.parity n x = ∏ i : Fin n, BooleanAnalysis.boolToSign (x i)
Instances For
The parity function equals χ_{Finset.univ}.
Sensitivity and block sensitivity #
The sensitivity of f at x: the number of coordinates i such that
flipping bit i changes the value of f.
Equations
- BooleanAnalysis.sensitivity f x = {i : Fin n | f x ≠ f (BooleanAnalysis.flipBit x i)}.card
Instances For
The maximum sensitivity of f over all inputs.
Equations
Instances For
For any Boolean function f, the maximum individual influence is at least the average: max_i Inf_i[f] ≥ I[f] / n.
Additional lemmas for Arrow's theorem #
boolToSign negates under Bool.not.
A Boolean function is odd if flipping all inputs negates the output. Models the antisymmetry requirement in social choice.
Equations
- BooleanAnalysis.isOddFunc f = ∀ (x : BooleanAnalysis.BoolCube n), (f fun (i : Fin n) => !x i) = -f x
Instances For
A Boolean function takes values in {-1, 1}.
Equations
- BooleanAnalysis.isPmOne f = ∀ (x : BooleanAnalysis.BoolCube n), f x = 1 ∨ f x = -1
Instances For
For an odd function, the Fourier coefficient at any even-cardinality set is zero.
For a ±1-valued function, the L² self-inner-product equals 1.
Parseval for ±1-valued functions: ∑_S f̂(S)² = 1.
Fourier weight concentrated on level k: W_k[f] = ∑_{|S|=k} f̂(S)².