AFTD Auto-Formalizing Theoretical Domains

BoolFourier.expectation_eq_expect

theoremverifiedimported Lean

Agreement of two definitions of the uniform expectation. Let $n$ be a natural number and let $f : \{0,1\}^n \to \bbr$ be a Boolean function of arity $n$. Then the two forms of the uniform expectation of $f$ coincide, namely \[ \frac{1}{2^n} \sum_{x \in \{0,1\}^n} f(x) \;=\; 2^{-n} \sum_{x \in \{0,1\}^n} f(x). \]

Statement

set_option relaxedAutoImplicit false in
set_option autoImplicit false in
open Finset BooleanAnalysis in
lemma BoolFourier.expectation_eq_expect {n : ℕ} (f : BoolFun n) :
    expectation f = expect f
Source
TCSlib, `BoolFourier.expectation_eq_expect`
Lean proof
By Prastik Mohanraj, from github.com/Shilun-Allan-Li/tcslib at c8a02591b1e5 (Copyright (c) 2026 Prastik Mohanraj. All rights reserved, 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
Classical.choiceQuot.soundpropext
Built on 5
  • BoolFourier.expectationFor $f : \{0,1\}^n \to \mathbb{R}$, the uniform expectation is \[ \mathbb{E}[f] = \frac{1}{2^n} \sum_{x \in \{0,1\}^n} f(x). \]
  • 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). \]
  • BooleanAnalysis.fourierCoeffThe Fourier--Walsh coefficient of $f$ at frequency $S$ is…
  • BoolFourier.BoolFunA Boolean function of arity $n$ is an element of type $\{0,1\}^n \to \mathbb{R}$, defined as an abbreviation for…
Used by 2
  • BoolFourier.parseval_identity_aux_hL2$L^2$ norm squared as a self inner product. Let $f : \{0,1\}^n \to \bbr$ be a real-valued function on the Boolean hypercube, and equip…
  • BoolFourier.fourier_coeff_eqAgreement of two Fourier coefficient definitions. Let $f : \{0,1\}^n \to \bbr$ be a Boolean function of arity $n$, and let…

Lean source view module on GitHub

set_option relaxedAutoImplicit false inset_option autoImplicit false inopen Finset BooleanAnalysis inlemma BoolFourier.expectation_eq_expect {n : ℕ} (f : BoolFun n) :    expectation f = expect f := by  unfold expectation BooleanAnalysis.expect BooleanAnalysis.uniformWeight  rw [div_eq_mul_inv, ← inv_pow, mul_comm]-- Bridge: BoolFourier.fourier_coeff ↔ BooleanAnalysis.fourierCoeff
See it in the graphDiscuss this resultChallenge it