Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Claim 5.3, p. 34:36 — a random subset sum of l uniform elements of G is on average within √(|G|/2^l) of uniform

Proved
RegevLWE.SubsetSum.claim_5_3

by mikedeng1 · Oct 6, 2026 · Mathlib 0df444a (Lean v4.33.1)

finite-abelian-groupleftover-hash-lemmap2o-batch-pfp2bp2o-gran-per-chapterp2o-plan-paperp2o-v1statistical-distance

Let GGG be a finite abelian group and l≥0l \ge 0l≥0 an integer. For g=(g1,…,gl)∈Glg = (g_1, \dots, g_l) \in G^lg=(g1​,…,gl​)∈Gl let

Pg(h)=12l ∣{ b∈{0,1}l∣∑ibigi=h }∣P_g(h) = \frac{1}{2^l}\,\bigl|\{\, b \in \{0,1\}^l \mid \textstyle\sum_i b_i g_i = h \,\}\bigr|Pg​(h)=2l1​​{b∈{0,1}l∣∑i​bi​gi​=h}​

be the distribution of the sum of a uniformly random subset of g1,…,glg_1, \dots, g_lg1​,…,gl​, and let Δ(g)=∑h∈G∣Pg(h)−1/∣G∣∣\Delta(g) = \sum_{h \in G} |P_g(h) - 1/|G||Δ(g)=∑h∈G​∣Pg​(h)−1/∣G∣∣ be its statistical distance from the uniform distribution on GGG. Choose g1,…,gl∈Gg_1, \dots, g_l \in Gg1​,…,gl​∈G uniformly and independently. Then

  1. the expected statistical distance is at most ∣G∣/2l\sqrt{|G|/2^l}∣G∣/2l​:
Expg[Δ(g)]≤∣G∣2l;\mathop{\mathrm{Exp}}_g\bigl[\Delta(g)\bigr] \le \sqrt{\frac{|G|}{2^l}};Expg​[Δ(g)]≤2l∣G∣​​;
  1. the probability that the statistical distance is more than ∣G∣/2l4\sqrt[4]{|G|/2^l}4∣G∣/2l​ is at most ∣G∣/2l4\sqrt[4]{|G|/2^l}4∣G∣/2l​:
Pr⁡g[Δ(g)>∣G∣/2l4]≤∣G∣2l4.\Pr_g\Bigl[\Delta(g) > \sqrt[4]{|G|/2^l}\Bigr] \le \sqrt[4]{\frac{|G|}{2^l}}.gPr​[Δ(g)>4∣G∣/2l​]≤42l∣G∣​​.

This is the special case of the leftover hash lemma of Impagliazzo and Zuckerman (1989) that Regev uses to prove the semantic security of his LWE-based public-key cryptosystem: once 2l2^l2l is much larger than ∣G∣|G|∣G∣, a random subset sum of a random public key is close to uniform for almost every key.

Formalization Note Expg\mathrm{Exp}_gExpg​ and Pr⁡g\Pr_gPrg​ are exact averages over all ∣G∣l|G|^l∣G∣l tuples ggg (the probability is the number of tuples with Δ(g)>∣G∣/2l4\Delta(g) > \sqrt[4]{|G|/2^l}Δ(g)>4∣G∣/2l​ divided by ∣G∣l|G|^l∣G∣l). The statistical distance has no factor 12\tfrac1221​. The fourth root is written Real.sqrt (Real.sqrt x). No hypothesis is added: ∣G∣≥1|G| \ge 1∣G∣≥1 holds for every group, and l=0l = 0l=0 is allowed.

Preamble
import Mathlib
import Definitions.Def_RegevLWE_SubsetSum_Basic

open Finset
Formal statement
namespace RegevLWE.SubsetSum

/-- Claim 5.3 (Regev, J. ACM 2009, p. 34:36). Let `G` be a finite abelian group and `l ≥ 0`. For
`g = (g₁, …, g_l) ∈ G^l` let `P_g` be the distribution of the sum of a uniformly random subset of
`g₁, …, g_l`, and `Δ(g) = ∑_h |P_g(h) − 1/|G||` its statistical distance from uniform. Over a uniform
choice of `g ∈ G^l`:
1. `Exp_g[Δ(g)] ≤ √(|G|/2^l)`;
2. `Pr_g[Δ(g) > ⁴√(|G|/2^l)] ≤ ⁴√(|G|/2^l)`,
with the fourth root written `√(√·)`. -/
theorem claim_5_3 {G : Type*} [AddCommGroup G] [Fintype G] [DecidableEq G] (l : ℕ) :
    expectG (fun g : Fin l → G => statDistUniform g) ≤
        Real.sqrt ((Fintype.card G : ℝ) / 2 ^ l) ∧
      ((univ.filter fun g : Fin l → G =>
            Real.sqrt (Real.sqrt ((Fintype.card G : ℝ) / 2 ^ l)) < statDistUniform g).card : ℝ) /
          (Fintype.card G : ℝ) ^ l ≤
        Real.sqrt (Real.sqrt ((Fintype.card G : ℝ) / 2 ^ l)) := by sorry

end RegevLWE.SubsetSum
Source
Regev, On Lattices, Learning with Errors, Random Linear Codes, and Cryptography, J. ACM 56(6) (2009), Article 34, p. 34:36, Claim 5.3
Human review
  • Endorsed by Shuze Chen · Oct 7, 2026

    Confirmed by the moderator at approval.

  • Endorsed by mikedeng1 · Oct 7, 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