Chapter 1: Boolean functions and the Fourier expansion — Definitions #
This file contains the core definitions for Fourier analysis of Boolean functions following Chapter 1 of "Analysis of Boolean Functions" by Ryan O'Donnell.
We work with the Hamming cube modeled as Fin n → ZMod 2, with the encoding
χ : ZMod 2 → ℝ sending 0 ↦ 1 and 1 ↦ -1. This corresponds to the book's
convention of representing the cube as {-1, 1}^n via the map b ↦ (-1)^b.
The space BooleanFunction n of real-valued functions on the Boolean cube carries
the uniform-measure L² inner product ⟪f, g⟫ = 𝔼[f·g] = (1/2ⁿ) · ∑_x f(x)·g(x)
(Definition 1.3), realized as a Mathlib InnerProductSpace ℝ. The def (rather
than abbrev) for BooleanFunction blocks typeclass resolution from seeing through
to Cube n → ℝ, avoiding a norm diamond with Mathlib's Pi-type sup norm.
Notation #
Within the BooleanAnalysis namespace, we provide notation that mirrors
the book's conventions:
𝔼[f]— uniform expectation over the Hamming cube⟪f, g⟫— inner product𝔼[f·g](Mathlib'sinneronBooleanFunction n)‖f‖₂— L² norm√⟪f, f⟫(Mathlib'snormonBooleanFunction n)χ S— parity function on setS𝓕 f S— Fourier coefficient offonS𝐖 f k— Fourier weight offat degreekVar[f]— variance offCov[f, g]— covariance offandgf ⊛ g— convolution𝟙 P— indicator function of predicatePPr[P]— uniform probability𝔼[𝟙 P]Pr₂[P]— joint uniform probability over pairs
Basic types #
BooleanFunction n is the space of real-valued functions on the Boolean cube 𝔽₂ⁿ,
equipped with the uniform-measure L² inner product ⟪f, g⟫ = 𝔼[f·g]
(Definition 1.3 in O'Donnell).
The def (rather than abbrev) blocks typeclass resolution from seeing through
to Cube n → ℝ, preventing a norm diamond with Mathlib's Pi-type sup norm
while still allowing the kernel to see through for type checking.
Equations
Instances For
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- Complexity.BooleanAnalysis.BooleanFunction.instFunLikeCubeReal = { coe := fun (f : Complexity.BooleanAnalysis.BooleanFunction n) => f, coe_injective' := ⋯ }
Evaluate a Finset sum of BooleanFunctions pointwise.
Extract the underlying function from a BooleanFunction.
Instances For
Inner product space structure #
The inner product on BooleanFunction n is the uniform-measure inner product
⟪f, g⟫ = (1/2ⁿ) · ∑_x f(x)·g(x), matching O'Donnell's Definition 1.3.
This is the expectation 𝔼[f·g] under the uniform distribution on 𝔽₂ⁿ.
The uniform-measure inner product: ⟪f, g⟫ = (1/2ⁿ) · ∑_x f(x)·g(x).
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- Complexity.BooleanAnalysis.BooleanFunction.instFullCore = { toCore := Complexity.BooleanAnalysis.BooleanFunction.instCore, definite := ⋯ }
Notation #
The book uses ⟪f, g⟫ for the inner product (Definition 1.3) and ‖f‖₂ for the
L² norm (§1.3, page 24). These map to Mathlib's inner and norm on
BooleanFunction n.
⟪f, g⟫ — the inner product 𝔼[f·g] on BooleanFunction n (Definition 1.3).
Equations
- One or more equations did not get rendered due to their size.
Instances For
‖f‖₂ — the L² norm √⟪f, f⟫ on BooleanFunction n (§1.3, page 24).
This equals Mathlib's ‖f‖ since the InnerProductSpace instance makes
norm the L² norm. We use the subscript to match the book's convention
and to distinguish from other norms that may appear in later chapters.
Equations
- One or more equations did not get rendered due to their size.
Instances For
§1.2 The encoding and parity functions #
A function f : 𝔽₂ⁿ → ℝ is Boolean-valued if its range is {-1, 1}.
In the ±1 encoding, this means f(x) = ±1 for all x.
Equations
- Complexity.BooleanAnalysis.IsBooleanValued f = ∀ (x : Complexity.BooleanAnalysis.Cube n), f x = 1 ∨ f x = -1
Instances For
The parity function χ S : 𝔽₂ⁿ → ℝ for S ⊆ [n], defined by
(χ S)(x) = ∏_{i ∈ S} χ(xᵢ) = (-1)^(∑_{i ∈ S} xᵢ). (Definition 1.2)
Equations
- Complexity.BooleanAnalysis.parityFun S x = ∏ i ∈ S, Complexity.BooleanAnalysis.chi (x i)
Instances For
χ S — the parity function on the coordinate set S.
Equations
- One or more equations did not get rendered due to their size.
Instances For
§1.3–1.4 Expectation, Fourier coefficients #
The uniform expectation 𝔼[f] = 2⁻ⁿ · ∑_x f(x).
Equations
Instances For
𝔼[f] — the uniform expectation of f over the Hamming cube.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The Fourier coefficient 𝓕 f S = ⟪f, χ S⟫.
(Proposition 1.8 / our definition)
Equations
Instances For
𝓕 f S — the Fourier coefficient of f on the coordinate set S.
Equations
- Complexity.BooleanAnalysis.term𝓕 = Lean.ParserDescr.node `Complexity.BooleanAnalysis.term𝓕 1024 (Lean.ParserDescr.symbol "𝓕")
Instances For
Bridge lemmas #
Unfold 𝔼[f] to the explicit sum form 1/2^n · ∑_x f(x).
The inner product equals the expectation of the product.
This is the book's Definition 1.3: ⟪f, g⟫ = 𝔼[f·g].
§1.4 Mean, variance, covariance #
A function f : 𝔽₂ⁿ → ℝ is unbiased (or balanced) if 𝔼[f] = 0.
(Definition 1.11)
Equations
Instances For
The variance of f : 𝔽₂ⁿ → ℝ, defined as
Var[f] = 𝔼[f²] - 𝔼[f]². (Proposition 1.13)
Equations
- Complexity.BooleanAnalysis.variance f = (Complexity.BooleanAnalysis.expect fun (x : Complexity.BooleanAnalysis.Cube n) => f x ^ 2) - Complexity.BooleanAnalysis.expect f ^ 2
Instances For
Var[f] — the variance of f.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The covariance of f, g : 𝔽₂ⁿ → ℝ, defined as
Cov[f, g] = 𝔼[f·g] - 𝔼[f]·𝔼[g]. (Proposition 1.16)
Equations
- One or more equations did not get rendered due to their size.
Instances For
Cov[f, g] — the covariance of f and g.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The 0-1 indicator function of a predicate P on 𝔽₂ⁿ.
(𝟙 P)(x) = 1 if P x, else 0.
The book (Definition 1.22) defines 𝟙_A for a set A ⊆ 𝔽₂ⁿ. We generalize
to predicates so that probability expressions like Pr_x[P(x)] = 𝔼[𝟙 P]
read cleanly without Finset.univ.filter boilerplate. For the set version,
use 𝟙 (· ∈ A).
Equations
- Complexity.BooleanAnalysis.indicator P x = if P x then 1 else 0
Instances For
𝟙 P — the 0-1 indicator function of predicate P.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The uniform probability Pr_x[P(x)] = 𝔼[𝟙 P].
Equations
Instances For
Pr[P] — the uniform probability of predicate P.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The joint uniform probability Pr_{x,y}[P(x,y)] = 𝔼_x[𝔼_y[𝟙 (P x)]].
Equivalent to the uniform probability over the product space by Fubini.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Pr₂[P] — the joint uniform probability of P over pairs.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The relative Hamming distance between functions f and g,
dist(f, g) = Pr_x[f(x) ≠ g(x)]. (Definition 1.10)
Equations
- Complexity.BooleanAnalysis.hammingDist f g = Complexity.BooleanAnalysis.prob fun (x : Complexity.BooleanAnalysis.Cube n) => f x ≠ g x
Instances For
§1.4 Fourier weight distribution #
The Fourier weight of f on set S, defined as (𝓕 f S)².
(Definition 1.17)
Equations
Instances For
The Fourier weight of f at degree k:
𝐖 f k = ∑_{|S|=k} (𝓕 f S)². (Definition 1.19)
Equations
- Complexity.BooleanAnalysis.fourierWeightAtDegree f k = ∑ S : Finset (Fin n) with S.card = k, Complexity.BooleanAnalysis.fourierWeight f S
Instances For
𝐖 f k — the Fourier weight of f at degree k.
Equations
- Complexity.BooleanAnalysis.«term𝐖» = Lean.ParserDescr.node `Complexity.BooleanAnalysis.«term𝐖» 1024 (Lean.ParserDescr.symbol "𝐖")
Instances For
The degree-k part of f: f^{=k} = ∑_{|S|=k} 𝓕 f S · χ S.
(Definition 1.19)
Equations
- Complexity.BooleanAnalysis.degreePart f k x = ∑ S : Finset (Fin n) with S.card = k, Complexity.BooleanAnalysis.fourierCoeff f S * Complexity.BooleanAnalysis.parityFun S x
Instances For
The degree-at-most-k part of f: f^{≤k} = ∑_{|S|≤k} 𝓕 f S · χ S.
(Definition 1.19)
Equations
- Complexity.BooleanAnalysis.lowDegreePart f k x = ∑ S : Finset (Fin n) with S.card ≤ k, Complexity.BooleanAnalysis.fourierCoeff f S * Complexity.BooleanAnalysis.parityFun S x
Instances For
The Fourier weight of f at degrees above k:
𝐖^{>k}[f] = ∑_{|S|>k} (𝓕 f S)². (Definition 1.19)
Equations
- Complexity.BooleanAnalysis.fourierWeightAbove f k = ∑ S : Finset (Fin n) with S.card > k, Complexity.BooleanAnalysis.fourierWeight f S
Instances For
The (real) degree of f : 𝔽₂ⁿ → ℝ:
deg(f) = max { |S| : 𝓕 f S ≠ 0 }. (Exercise 1.10, referenced in main text)
Returns ⊥ for the zero function (which has no nonzero Fourier coefficients).
The book leaves the degree undefined in this case. We use WithBot ℕ so that
degree comparisons integrate cleanly with Mathlib's order theory.
Equations
- Complexity.BooleanAnalysis.degree f = {S : Finset (Fin n) | Complexity.BooleanAnalysis.fourierCoeff f S ≠ 0}.sup fun (S : Finset (Fin n)) => ↑S.card
Instances For
§1.5 Probability densities and convolution #
A probability density on 𝔽₂ⁿ is a nonneg function with
𝔼[φ] = 1. (Definition 1.20)
Instances For
The density function associated to a nonempty set A ⊆ 𝔽₂ⁿ:
φ_A = (1 / 𝔼[𝟙 A]) · 𝟙 A. (Definition 1.22)
Warning: This definition is junk when A = ∅, since it divides by
𝔼[𝟙 ∅] = 0. The book requires A to be nonempty. Theorems using
setDensity should include a hypothesis A.Nonempty where needed.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The convolution of f, g : 𝔽₂ⁿ → ℝ, defined by
(f ⊛ g)(x) = 𝔼_y[f(y)·g(x + y)]. (Definition 1.24)
Equations
- Complexity.BooleanAnalysis.convolution f g x = Complexity.BooleanAnalysis.expect fun (y : Complexity.BooleanAnalysis.Cube n) => f y * g (x + y)
Instances For
f ⊛ g — the convolution of f and g.
Equations
- One or more equations did not get rendered due to their size.
Instances For
§1.6 Linearity and the BLR test #
A function f : 𝔽₂ⁿ → 𝔽₂ (encoded as BooleanFunction n with ±1 values)
is linear if it equals some parity function χ S. (Definition 1.28)
Equations
- Complexity.BooleanAnalysis.IsLinear f = ∃ (S : Finset (Fin n)), ∀ (x : Complexity.BooleanAnalysis.Cube n), f x = Complexity.BooleanAnalysis.parityFun S x
Instances For
A function f : 𝔽₂ⁿ → ℝ is multiplicative if f(x+y) = f(x)·f(y) for all
x, y. This generalizes property (1) from Definition 1.28 to real-valued
functions; the equivalence with IsLinear requires IsBooleanValued
(see isLinear_iff_isMultiplicative).
Equations
- Complexity.BooleanAnalysis.IsMultiplicative f = ∀ (x y : Complexity.BooleanAnalysis.Cube n), f (x + y) = f x * f y
Instances For
Two Boolean-valued functions are ε-close if dist(f, g) ≤ ε.
(Definition 1.29)
Equations
Instances For
A Boolean-valued function is ε-close to a property P if there
exists g satisfying P with dist(f, g) ≤ ε. (Definition 1.29)
Equations
- Complexity.BooleanAnalysis.IsCloseToProperty f P ε = ∃ (g : Complexity.BooleanAnalysis.BooleanFunction n), P g ∧ Complexity.BooleanAnalysis.IsClose f g ε
Instances For
The BLR acceptance probability: Pr_{x,y}[f(x)·f(y) = f(x+y)],
which equals 1/2 + 1/2 · ∑_S 𝓕 f S ^ 3.
Equations
- Complexity.BooleanAnalysis.blrAcceptProb f = Complexity.BooleanAnalysis.prob₂ fun (x y : Complexity.BooleanAnalysis.Cube n) => f x * f y = f (x + y)