Documentation

TCSlib.BooleanAnalysis.Basic

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 #

Main results #

Notation #

References #

Setup: the Boolean hypercube #

@[reducible, inline]

The Boolean hypercube {0,1}ⁿ.

Equations
Instances For
    @[reducible, inline]

    A Boolean function f : {0,1}ⁿ → ℝ.

    Equations
    Instances For

      Uniform measure and expectation #

      noncomputable def BooleanAnalysis.uniformWeight (n : ) :

      The uniform probability measure on {0,1}ⁿ assigns weight 2⁻ⁿ to each point.

      Equations
      Instances For
        noncomputable def BooleanAnalysis.expect {n : } (f : BooleanFunc n) :

        Expectation of f under the uniform measure on {0,1}ⁿ. 𝔼[f] = 2⁻ⁿ · ∑_{x ∈ {0,1}ⁿ} f(x).

        Equations
        Instances For
          noncomputable def BooleanAnalysis.innerProduct {n : } (f g : BooleanFunc n) :

          The inner product on Boolean functions with respect to the uniform measure: ⟪f, g⟫ = 𝔼[f · g] = 2⁻ⁿ · ∑_x f(x) g(x).

          Equations
          Instances For
            Equations
            • One or more equations did not get rendered due to their size.
            Instances For
              noncomputable def BooleanAnalysis.l2Norm {n : } (f : BooleanFunc n) :

              The norm of a Boolean function: ‖f‖ = √(⟪f, f⟫).

              Equations
              Instances For

                Walsh–Fourier characters #

                Convert a Bool to {-1, 1} ⊆ ℝ: false ↦ 1, true ↦ -1.

                Equations
                Instances For
                  noncomputable def BooleanAnalysis.chiS {n : } (S : Finset (Fin n)) :

                  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
                  Instances For
                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For
                      @[simp]
                      theorem BooleanAnalysis.chiS_empty {n : } :
                      chiS = fun (x : BoolCube n) => 1

                      The character χ_∅ is the constant function 1.

                      @[simp]
                      theorem BooleanAnalysis.chiS_singleton {n : } (i : Fin n) (x : BoolCube n) :
                      chiS {i} x = boolToSign (x i)

                      The character χ_{i} for a singleton {i} equals (-1)^{x_i}.

                      theorem BooleanAnalysis.chiS_sq_eq_one {n : } (S : Finset (Fin n)) (x : BoolCube n) :
                      chiS S x ^ 2 = 1

                      Walsh characters take values in {-1, 1}.

                      theorem BooleanAnalysis.chiS_mul_of_disjoint {n : } (S T : Finset (Fin n)) (hST : Disjoint S T) (x : BoolCube n) :
                      chiS (S T) x = chiS S x * chiS T x

                      Walsh characters are multiplicative: χ_{S ∪ T}(x) = χ_S(x) · χ_T(x) when S and T are disjoint.

                      theorem BooleanAnalysis.chiS_mul_chiS {n : } (S T : Finset (Fin n)) (x : BoolCube n) :
                      chiS S x * chiS T x = chiS (symmDiff S T) x

                      The pointwise product of two Walsh characters is another Walsh character (up to sign), specifically χ_S · χ_T = χ_{S Δ T} where Δ denotes symmetric difference.

                      Fourier coefficients #

                      noncomputable def BooleanAnalysis.fourierCoeff {n : } (f : BooleanFunc n) (S : Finset (Fin n)) :

                      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) #

                          theorem BooleanAnalysis.walsh_expansion {n : } (f : BooleanFunc n) (x : BoolCube n) :
                          f x = S : Finset (Fin n), fourierCoeff f S * chiS S x

                          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 #

                          theorem BooleanAnalysis.fourier_coeff_chi {n : } (S T : Finset (Fin n)) :
                          innerProduct (chiS S) (chiS T) = if S = T then 1 else 0

                          Orthonormality: ⟪χ_S, χ_T⟫ = [S = T].

                          The Walsh characters form an orthonormal system in L²({0,1}ⁿ, uniform).

                          @[simp]

                          Self inner product of a Walsh character is 1.

                          theorem BooleanAnalysis.parseval {n : } (f : BooleanFunc n) :
                          innerProduct f f = S : Finset (Fin n), fourierCoeff f S ^ 2

                          Parseval's Identity: ‖f‖² = ∑_{S ⊆ [n]} f̂(S)².

                          The sum of squared Fourier coefficients equals the squared norm.

                          def BooleanAnalysis.flipBit {n : } (x : BoolCube n) (i : Fin n) :

                          Flip the i-th bit of x : {0,1}ⁿ.

                          Equations
                          Instances For
                            @[simp]
                            theorem BooleanAnalysis.flipBit_flipBit {n : } (x : BoolCube n) (i : Fin n) :
                            flipBit (flipBit x i) i = x
                            theorem BooleanAnalysis.flipBit_ne {n : } (x : BoolCube n) (i j : Fin n) (h : i j) :
                            flipBit x i j = x j

                            Influence of a coordinate #

                            noncomputable def BooleanAnalysis.influence {n : } (i : Fin n) (f : BooleanFunc n) :

                            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
                            Instances For
                              noncomputable def BooleanAnalysis.totalInfluence {n : } (f : BooleanFunc n) :

                              The total influence of f: I[f] = ∑_{i=1}^{n} Inf_i[f].

                              Equations
                              Instances For
                                theorem BooleanAnalysis.influence_chi {n : } (i : Fin n) (S : Finset (Fin n)) :
                                influence i (chiS S) = if i S then 1 else 0

                                The influence of i on the Walsh character χ_S is [i ∈ S].

                                theorem BooleanAnalysis.influence_eq_sum_fourier {n : } (i : Fin n) (f : BooleanFunc n) :
                                influence i f = S : Finset (Fin n), if i S then fourierCoeff f S ^ 2 else 0

                                Influence via Fourier: Inf_i[f] = ∑_{S ∋ i} f̂(S)².

                                Total Influence via Fourier: I[f] = ∑_S |S| · f̂(S)².

                                Noise operator #

                                noncomputable def BooleanAnalysis.noiseOp {n : } (ρ : ) (f : BooleanFunc n) :

                                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
                                Instances For
                                  theorem BooleanAnalysis.noiseOp_fourier {n : } (ρ : ) (f : BooleanFunc n) (S : Finset (Fin n)) :

                                  Noise operator in Fourier domain: (T_ρ f)̂(S) = ρ^{|S|} · f̂(S).

                                  theorem BooleanAnalysis.stability_formula {n : } (ρ : ) (f : BooleanFunc n) :
                                  innerProduct f (noiseOp ρ f) = S : Finset (Fin n), ρ ^ S.card * fourierCoeff f S ^ 2

                                  Stability formula: ⟪f, T_ρ f⟫ = ∑_S ρ^{|S|} · f̂(S)².

                                  Linearity and combinatorial properties #

                                  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 #

                                  noncomputable def BooleanAnalysis.dictator {n : } (i : Fin n) :

                                  The dictator function for coordinate i: f(x) = (-1)^{x_i}. Its only nonzero Fourier coefficient is f̂({i}) = 1.

                                  Equations
                                  Instances For

                                    The dictator function equals the Walsh character χ_{i}.

                                    noncomputable def BooleanAnalysis.parity (n : ) :

                                    The parity function f(x) = (-1)^{x_1 + ⋯ + x_n}. Its only nonzero Fourier coefficient is f̂([n]) = 1.

                                    Equations
                                    Instances For

                                      The parity function equals χ_{Finset.univ}.

                                      noncomputable def BooleanAnalysis.majority (k : ) :
                                      BooleanFunc (2 * k + 1)

                                      The majority function on {0,1}^{2k+1}: outputs 1 if more than half the bits are 0, and -1 otherwise.

                                      Equations
                                      Instances For

                                        Sensitivity and block sensitivity #

                                        noncomputable def BooleanAnalysis.sensitivity {n : } (f : BooleanFunc n) (x : BoolCube n) :

                                        The sensitivity of f at x: the number of coordinates i such that flipping bit i changes the value of f.

                                        Equations
                                        Instances For
                                          noncomputable def BooleanAnalysis.maxSensitivity {n : } (f : BooleanFunc n) :

                                          The maximum sensitivity of f over all inputs.

                                          Equations
                                          Instances For
                                            theorem BooleanAnalysis.influence_le_one {n : } (i : Fin n) (f : BooleanFunc n) (hf : ∀ (x : BoolCube n), f x {-1, 1}) :

                                            Influence bounds sensitivity: Inf_i[f] ≤ 1.

                                            theorem BooleanAnalysis.max_influence_lower_bound {n : } (f : BooleanFunc n) (hn : 0 < n) :
                                            ∃ (i : Fin n), totalInfluence f / n influence i f

                                            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 #

                                            theorem BooleanAnalysis.chiS_neg {n : } (S : Finset (Fin n)) (x : BoolCube n) :
                                            (chiS S fun (i : Fin n) => !x i) = (-1) ^ S.card * chiS S x

                                            Flipping all bits of x multiplies χ_S(x) by (-1)^|S|.

                                            A Boolean function is odd if flipping all inputs negates the output. Models the antisymmetry requirement in social choice.

                                            Equations
                                            Instances For

                                              A Boolean function takes values in {-1, 1}.

                                              Equations
                                              Instances For
                                                theorem BooleanAnalysis.fourierCoeff_odd_even {n : } (f : BooleanFunc n) (hodd : isOddFunc f) (S : Finset (Fin n)) (heven : Even S.card) :

                                                For an odd function, the Fourier coefficient at any even-cardinality set is zero.

                                                For a ±1-valued function, the self-inner-product equals 1.

                                                theorem BooleanAnalysis.parseval_pm_one {n : } (f : BooleanFunc n) (hf : isPmOne f) :
                                                S : Finset (Fin n), fourierCoeff f S ^ 2 = 1

                                                Parseval for ±1-valued functions: ∑_S f̂(S)² = 1.

                                                noncomputable def BooleanAnalysis.weightLevel {n : } (k : ) (f : BooleanFunc n) :

                                                Fourier weight concentrated on level k: W_k[f] = ∑_{|S|=k} f̂(S)².

                                                Equations
                                                Instances For