Bonami.second_moment_decomp
theoremverifiedimported Lean
Second-moment decomposition over the last coordinate. Let $f : \{0,1\}^{n+1} \to \bbr$ be a Boolean function on $n+1$ variables. Define its average and half-difference over the last coordinate as the functions on $n$ variables \[ g(x) = \tfrac12\bigl(f(x,0) + f(x,1)\bigr), \qquad h(x) = \tfrac12\bigl(f(x,0) - f(x,1)\bigr). \] Then, with the expectation on the left taken under the uniform measure on $\{0,1\}^{n+1}$ and those on the right under the uniform measure on $\{0,1\}^n$, the second moment of $f$ decomposes as \[ \E\bigl[f^2\bigr] = \E\bigl[g^2\bigr] + \E\bigl[h^2\bigr]. \]
Statement
set_option autoImplicit true in set_option relaxedAutoImplicit true in open BooleanAnalysis in lemma Bonami.second_moment_decomp {n : ℕ} (f : BooleanFunc (n + 1)) : expect (fun x => f x ^ 2) = expect (fun x => avgLast f x ^ 2) + expect (fun x => diffLast f x ^ 2)
- Source
- TCSlib, `Bonami.second_moment_decomp`
- Lean proof
- By 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.Bonami.second_moment_decomp← Bonami.second_moment_decomp (TCSlib/BooleanAnalysis/Hypercontractivity/Decomposition.lean:187): verbatim
- Verified
- 07 Oct 2026
- Axioms
Classical.choiceQuot.soundpropext- Built on 9
- BooleanAnalysis.uniformWeightThe uniform probability measure on $\{0,1\}^n$ assigns weight $2^{-n}$ to each point.
- BooleanAnalysis.expectThe expectation of $f$ under the uniform measure: \[ \E[f] \;=\; 2^{-n}\sum_{x\in\{0,1\}^n} f(x). \]
- Bonami.diffLastThe half-difference $\mathrm{diffLast}\,f$ of $f$ over its last coordinate is the function on $n$ variables given by…
- BooleanAnalysis.BoolCubeThe Boolean hypercube of dimension $n$ is $\{0,1\}^n$, represented as the function type $\mathrm{Fin}\,n \to \mathrm{Bool}$.
- Bonami.avgLastThe average $\mathrm{avgLast}\,f$ of $f$ over its last coordinate is the function on $n$ variables given by…
- Bonami.restrictLastGiven a Boolean function $f$ on $n+1$ variables and a bit $b$, the restriction $\mathrm{restrictLast}\,f\,b$ is the function on $n$…
- Bonami.sum_boolCube_succSplitting a sum over the hypercube on its last coordinate. Let $n$ be a natural number and let $\varphi \colon \{0,1\}^{n+1} \to \bbr$ be…
- Bonami.restrictLast_true_eqRecovering the true-restriction from average and half-difference. Let $f : \{0,1\}^{n+1} \to \bbr$ be a Boolean function on $n+1$…
- BooleanAnalysis.BooleanFuncA Boolean function of arity $n$ is a function $f : \{0,1\}^n \to \bbr$.
- Used by 1
- 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…
Lean source view module on GitHub
Choose a tactic — a marked line — to see the goals Lean had before and after it, as in Lean’s infoview. Step with ← → or j k.
set_option autoImplicit true inset_option relaxedAutoImplicit true inopen BooleanAnalysis in/-- Decomposes a second moment into the average and half-difference components. **Source:** [OD14, Cor. 9.6 (proof), Eq. (9.2)]. -/lemma Bonami.second_moment_decomp {n : ℕ} (f : BooleanFunc (n + 1)) : expect (fun x => f x ^ 2) = expect (fun x => avgLast f x ^ 2) + expect (fun x => diffLast f x ^ 2) := by unfold expect ring_nf have h_expand : ∑ x : BoolCube (n + 1), f x ^ 2 = ∑ x : BoolCube n, (avgLast f x + diffLast f x) ^ 2 + ∑ x : BoolCube n, (avgLast f x - diffLast f x) ^ 2 := by convert sum_boolCube_succ (fun x => f x ^ 2) using 1 congr! 2 · exact congr_arg (· ^ 2) (by unfold avgLast diffLast restrictLast ring) · simpa only [restrictLast] using congrArg (fun y : ℝ => y ^ 2) (restrictLast_true_eq f _).symm simp_all +decide [add_sq, sub_sq, Finset.sum_add_distrib, Finset.mul_sum _ _ _] ring_nf norm_num [← Finset.mul_sum _ _ _, ← Finset.sum_mul, uniformWeight] ring