AFTD Auto-Formalizing Theoretical Domains

BooleanAnalysis.expect

defimported Lean

The expectation of $f$ under the uniform measure: \[ \E[f] \;=\; 2^{-n}\sum_{x\in\{0,1\}^n} f(x). \]

Statement

set_option maxHeartbeats 400000 in
open scoped BigOperators in
variable {n : ℕ} in
noncomputable def BooleanAnalysis.expect (f : BooleanFunc n) : ℝ
Defined in
TCSlib, `BooleanAnalysis.expect`
Lean proof
By Jingzhen Sha, Allan Li, Hydroxyi, Mina, Owen McGinty (from the file's git history), from github.com/Shilun-Allan-Li/tcslib at c8a02591b1e5 (Apache-2.0). Compiled here against leanprover/lean4:v4.33.1, Mathlib v4.33.1; written for leanprover/lean4:v4.25.0.
Verified
07 Oct 2026
Axioms
none listed
Built on 3
Used by 25
  • BooleanAnalysis.walsh_expansionWalsh–Fourier expansion of a Boolean function. Let $f:\{0,1\}^n\to\bbr$ be a Boolean function of arity $n$. Then at every point…
  • Bonami.fourierCoeff_diffLastFourier coefficient of the half-difference over the last coordinate. Let $f\colon\{0,1\}^{n+1}\to\bbr$ be a Boolean function on $n+1$…
  • KKL.friedgut_juntaFriedgut's junta theorem. Let $f : \{0,1\}^n \to \{-1,1\}$ be a $\pm 1$-valued Boolean function with total influence $I[f]$, and let…
  • KKL.lowDegree_l2_error$L^2$ error of the low-degree truncation. Let $f : \{0,1\}^n \to \bbr$ be a Boolean function, and for a natural number $k$ let…
  • Bonami.degree_avgLastAveraging over a coordinate preserves the degree bound. Let $f\colon\{0,1\}^{n+1}\to\bbr$ be a Boolean function on $n+1$ variables, and…
  • Bonami.degree_zero_fourth_momentFourth moment of a degree-zero Boolean function. Let $f:\{0,1\}^n\to\bbr$ be a Boolean function of degree at most $0$, meaning that every…
  • BooleanAnalysis.influenceThe influence of coordinate $i$ on $f$ measures how often flipping bit $i$ changes the output:…
  • BooleanAnalysis.influence_eq_sum_fourierInfluence via Fourier coefficients. Let $f:\{0,1\}^n\to\bbr$ be a Boolean function and fix a coordinate $i\in[n]$. Then the influence of…
  • Bonami.expect_succ_eqExpectation splits over the last coordinate. Let $\varphi : \{0,1\}^{n+1} \to \bbr$ be a Boolean function on $n+1$ variables, and for a…
  • BooleanAnalysis.plancherelPlancherel's identity. Let $f, g : \{0,1\}^n \to \bbr$ be Boolean functions. Then their $L^2$ inner product with respect to the uniform…
  • Bonami.second_moment_decompSecond-moment decomposition over the last coordinate. Let $f : \{0,1\}^{n+1} \to \bbr$ be a Boolean function on $n+1$ variables. Define…
  • Bonami.moment_eq_expectMoments equal expectations under the uniform law. Let $f : \{0,1\}^n \to \bbr$ be a Boolean function of arity $n$, let $p$ be a natural…
  • Bonami.bonami_expectBonami inequality in expectation form. Let $f : \{0,1\}^n \to \bbr$ be a Boolean function of degree at most $k$, meaning that every…
  • BoolFourier.expectation_eq_expectAgreement of two definitions of the uniform expectation. Let $n$ be a natural number and let $f : \{0,1\}^n \to \bbr$ be a Boolean…
  • BooleanAnalysis.innerProductThe $L^2$ inner product of two Boolean functions with respect to the uniform measure:…
  • BooleanAnalysis.fourierCoeff_emptyEmpty-set Fourier coefficient is the mean. Let $f\colon\{0,1\}^n\to\bbr$ be a Boolean function. Then its Fourier–Walsh coefficient at the…
  • Bonami.expect_sq_nonnegNonnegativity of the mean square. For every Boolean function $f : \{0,1\}^n \to \bbr$, the expectation of $f^2$ under the uniform measure…
  • KKL.fourierCoeff_lowDegreePartFourier coefficients of the low-degree truncation. Let $f\colon\{0,1\}^n\to\bbr$ be a Boolean function and $k$ a natural number. For every…
  • KKL.lowDegreePart_depends_on_influentialLow-degree part is close to a junta on the influential coordinates. Let $f:\{0,1\}^n\to\bbr$ be a Boolean function, let $k$ be a natural…
  • Bonami.expect_sq_nonneg_prodNonnegativity of the expectation of a product of squares. For any two Boolean functions $g, h : \{0,1\}^n \to \bbr$, the expectation of…
  • KKL.l2DistSqThe squared $L^2$ distance between two Boolean functions is $\E\big[(f(x) - g(x))^2\big]$ under the uniform measure on the cube.
  • Bonami.fourth_moment_decompFourth-moment decomposition over the last coordinate. Let $f : \{0,1\}^{n+1} \to \bbr$ be a Boolean function on $n+1$ variables, and let…
  • BooleanAnalysis.parsevalParseval's identity for Boolean functions. Let $f : \{0,1\}^n \to \bbr$ be a Boolean function, and equip $\{0,1\}^n$ with the uniform…
  • Bonami.expect_fourth_nonnegNonnegativity of the fourth moment. Let $f : \{0,1\}^n \to \bbr$ be a Boolean function on the Boolean hypercube. Then its fourth moment…
  • Bonami.expect_cs_sqCauchy–Schwarz for the uniform expectation. Let $g, h : \{0,1\}^n \to \bbr$ be Boolean functions, and let $\E[\,\cdot\,]$ denote the…

Lean source view module on GitHub

set_option maxHeartbeats 400000 in
open scoped BigOperators in
variable {n : ℕ} in
/-- Expectation of `f` under the uniform measure on `{0,1}ⁿ`. `𝔼[f] = 2⁻ⁿ · ∑_{x ∈ {0,1}ⁿ} f(x)`. **Source:** [OD14, §1.1]. -/
noncomputable def BooleanAnalysis.expect (f : BooleanFunc n) : ℝ :=
  uniformWeight n * ∑ x : BoolCube n, f x
See it in the graphDiscuss this resultChallenge it