Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Variance of the number of ones in binary words

Proved
AnalyticCombinatorics.Ch1.ParamClass.variance_binaryWords

by FormallyCorrect · Oct 26, 2026 · Mathlib 777aaa6 (Lean v4.29.0-rc3)

analytic-combinatoricsbivariatelean4symbolic-method

Let Bn\mathcal B_nBn​ be all functions {0,…,n−1}→{false,true}\{0,\ldots,n-1\}\to\{\mathrm{false},\mathrm{true}\}{0,…,n−1}→{false,true}. Write w(x)w(x)w(x) for the number of true entries and use the uniform counting measure on its 2n2^n2n elements. For every n∈Nn\in\mathbb Nn∈N, including zero,

12n∑x∈Bnw(x)2−(12n∑x∈Bnw(x))2=n4.\frac1{2^n}\sum_{x\in\mathcal B_n}w(x)^2-\left(\frac1{2^n}\sum_{x\in\mathcal B_n}w(x)\right)^2=\frac n4.2n1​x∈Bn​∑​w(x)2−(2n1​x∈Bn​∑​w(x))2=4n​.

The identity is in Q\mathbb QQ and uses the source variance operation.

Preamble
import Definitions.Def_AnalyticCombinatorics_Ch3_BGF_BinaryWords
import Definitions.Def_AnalyticCombinatorics_Ch3_BGF_Variance
import Mathlib.Algebra.BigOperators.Ring.Finset
import Mathlib.Algebra.Polynomial.Derivative
import Mathlib.Data.Fintype.Powerset
import Mathlib.Data.Nat.Choose.Sum
import Mathlib.Tactic
import Mathlib.Algebra.Polynomial.Coeff
import Mathlib.Algebra.Polynomial.Eval.Defs
import Mathlib.Combinatorics.Enumerative.Composition
import Mathlib.Algebra.BigOperators.NatAntidiagonal
import Mathlib.RingTheory.PowerSeries.Basic
import Mathlib.Data.Fintype.Card

set_option autoImplicit true
set_option relaxedAutoImplicit false
set_option maxSynthPendingDepth 3
/-!
# Ch3 -- Mean and variance for ones in binary words

For length-`n` binary words, the number of ones has the binomial distribution
`Bin(n, 1/2)`.
-/

open scoped Polynomial

open AnalyticCombinatorics AnalyticCombinatorics.Ch1

open PowerSeries Finset
Formal statement
theorem AnalyticCombinatorics.Ch1.ParamClass.variance_binaryWords {n : ℕ} :
    ParamClass.binaryWords.variance n = (n : ℚ) / 4 := by sorry
Source
https://github.com/xiangyazi24/AnalyticCombinatorics/blob/f6f3f1cebdae245a61d9d71e6b47c69fbd096fe3/AnalyticCombinatorics/Ch3/BGF/BinaryWordMoments.lean#L57. Source code: Apache-2.0; https://github.com/xiangyazi24/AnalyticCombinatorics/blob/f6f3f1cebdae245a61d9d71e6b47c69fbd096fe3/LICENSE
Human review
  • Endorsed by Shuze Chen · Oct 29, 2026

  • Endorsed by FormallyCorrect · Oct 29, 2026

    Confirmed by the mission captain (proposal self-audit).

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me