Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Lemma 4 (48)

Open
QAlgorithms.Papers.Independent.Advance50.P28.iid_finite_extractor

by Gohan · Oct 29, 2026 · Mathlib 0df444a (Lean v4.33.1)

prove2quantum

All logarithms are natural and d1d_1d1​ is the full L1L^1L1 distance. Let PPP be a normalized law on a finite nonempty alphabet AAA, and let UMU_MUM​ be the uniform law on M≥1M\ge1M≥1 symbols. For a map fff, write f∗Pf_*Pf∗​P for its pushforward. Fix n≥1n\ge1n≥1 and M≥1M\ge1M≥1. Let TnT_nTn​ be the realized empirical types, Tn(Q)T_n(Q)Tn​(Q) their word classes, vQ=∏aP(a)nQ(a)v_Q=\prod_aP(a)^{nQ(a)}vQ​=∏a​P(a)nQ(a) their common atom probability, and mQ=Pn(Tn(Q))m_Q=P^n(T_n(Q))mQ​=Pn(Tn​(Q)). Set Tn1[M]={Q:vQ≤1/M}T_n^1[M]=\{Q:v_Q\le1/M\}Tn1​[M]={Q:vQ​≤1/M} and Tn2[M]={Q:mQ<1/M}T_n^2[M]=\{Q:m_Q<1/M\}Tn2​[M]={Q:mQ​<1/M}. There exists f:An→{1,…,M}f:A^n\to\{1,\ldots,M\}f:An→{1,…,M} with

d1(f∗Pn,UM)≤2Pn{Pn(x)≥1/M}+2∑Q∈Tn1[M]MvQmQ+2∣Tn∣max⁡Q∈Tn2[M]vQ.d_1(f_*P^n,U_M)\le2P^n\{P^n(x)\ge1/M\}+2\sum_{Q\in T_n^1[M]}Mv_Qm_Q+2|T_n|\max_{Q\in T_n^2[M]}v_Q.d1​(f∗​Pn,UM​)≤2Pn{Pn(x)≥1/M}+2Q∈Tn1​[M]∑​MvQ​mQ​+2∣Tn​∣Q∈Tn2​[M]max​vQ​.

An impossible type has vQ=0v_Q=0vQ​=0 and an empty maximum is zero. The two displayed type sets may overlap. This retains every term of (48).

Preamble
import Definitions.Def_QAlgorithms_Papers_Independent_Advance50_P28
Formal statement
noncomputable section

open MeasureTheory Filter

open scoped BigOperators ENNReal Topology

namespace QAlgorithms.Papers.Independent.Advance50.P28

open QAlgorithms.Papers.Independent.Information100.P56 (IsLaw)

attribute [local instance] Classical.propDecidable Classical.decEq

/-- Hayashi, PDF pp.8–9, Lemma 4, (48): all three terms and overlapping type sets. -/
theorem iid_finite_extractor {A : Type*} [Fintype A] [Nonempty A]
    (P : A → ℝ) (hP : IsLaw P) (n M : ℕ) (hn : 0 < n) (hM : 0 < M) :
    ∃ f : (Fin n → A) → Fin M,
      extractionError (iid P n) f ≤
        2 * (∑ x : Fin n → A, if 1 / (M : ℝ) ≤ iid P n x then iid P n x else 0) +
        2 * (∑ q ∈ firstTypes P n M, (M : ℝ) * typeAtom P q * typeMass P n q) +
        2 * ((types A n).card : ℝ) * rareTypePeak P n M := by sorry

end QAlgorithms.Papers.Independent.Advance50.P28

end
Source
Tight exponential analysis of universally composable privacy amplification and its applications, arXiv:1010.1358v5, PDF p. 8, Lemma 4 (48)
Read-back

What the Lean code literally says, in plain math · gpt-6.1-sol

Let AAA be any finite nonempty type, let P:A→RP:A\to\mathbb RP:A→R satisfy P(a)≥0P(a)\ge0P(a)≥0 and ∑aP(a)=1\sum_aP(a)=1∑a​P(a)=1, and let n,Mn,Mn,M be positive natural numbers. Write Pn(x)=∏i=0n−1P(x(i))P_n(x)=\prod_{i=0}^{n-1}P(x(i))Pn​(x)=∏i=0n−1​P(x(i)) for x∈Anx\in A^nx∈An, let Tn\mathcal T_nTn​ be the finite set of functions q:A→Nq:A\to\mathbb Nq:A→N arising as q(a)=∣{i:x(i)=a}∣q(a)=|\{i:x(i)=a\}|q(a)=∣{i:x(i)=a}∣, and define

aP(q)=∏aP(a)q(a),mP,n(q)=∑x∈Ancount function of x=qPn(x),rP,n,M=max⁡({0}∪{aP(q):q∈Tn, mP,n(q)<1/M}).a_P(q)=\prod_aP(a)^{q(a)},\qquad m_{P,n}(q)=\sum_{\substack{x\in A^n\\\text{count function of }x=q}}P_n(x), \qquad r_{P,n,M}=\max\Bigl(\{0\}\cup \{a_P(q):q\in\mathcal T_n,\ m_{P,n}(q)<1/M\}\Bigr).aP​(q)=a∏​P(a)q(a),mP,n​(q)=x∈Ancount function of x=q​∑​Pn​(x),rP,n,M​=max({0}∪{aP​(q):q∈Tn​, mP,n​(q)<1/M}).

Then there exists a function f:An→{0,…,M−1}f:A^n\to\{0,\ldots,M-1\}f:An→{0,…,M−1} such that

∑b=0M−1∣∑x:f(x)=bPn(x)−1M∣≤2∑x∈An1/M≤Pn(x)Pn(x)+2∑q∈TnaP(q)≤1/MM aP(q) mP,n(q)+2∣Tn∣ rP,n,M.\sum_{b=0}^{M-1} \left|\sum_{x:f(x)=b}P_n(x)-\frac1M\right| \le 2\sum_{\substack{x\in A^n\\1/M\le P_n(x)}}P_n(x) + 2\sum_{\substack{q\in\mathcal T_n\\a_P(q)\le1/M}} M\,a_P(q)\,m_{P,n}(q) + 2|\mathcal T_n|\,r_{P,n,M}.b=0∑M−1​​x:f(x)=b∑​Pn​(x)−M1​​≤2x∈An1/M≤Pn​(x)​∑​Pn​(x)+2q∈Tn​aP​(q)≤1/M​∑​MaP​(q)mP,n​(q)+2∣Tn​∣rP,n,M​.

The first two thresholds are inclusive, while the threshold defining rP,n,Mr_{P,n,M}rP,n,M​ is strict; if its qualifying set is empty, that maximum is 000. Zero values of PPP are permitted, with 00=10^0=100=1 in the products defining aPa_PaP​.

Human review
  • Endorsed by Shuze Chen · Oct 29, 2026

    Confirmed by the moderator at approval.

  • Endorsed by Gohan · 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