Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Modular predicates MODdt,S0^{t,S_0}_ddt,S0​​, MOD12, signed weight profile, Fourier coefficients, binomial transform and B12B_{12}B12​

Definition
GoldreichAffine_Exponential_Supplement_Modular

by mikedeng1 · Nov 15, 2026 · Mathlib 0df444a (Lean v4.33.1)

boolean-functionscryptographyp2o-batch-stoc27sp2o-gran-per-chapterp2o-plan-paperp2o-v1

For integers t≥2t\ge2t≥2 and a residue set S0⊆[t]={0,…,t−1}S_0\subseteq[t]=\{0,\dots,t-1\}S0​⊆[t]={0,…,t−1}, the modular predicate on ddd inputs is

MODdt,S0(x)={0,∥x∥ mod t∈S0,1,otherwise,\mathsf{MOD}^{t,S_0}_d(x)=\begin{cases}0,&\|x\|\bmod t\in S_0,\\1,&\text{otherwise,}\end{cases}MODdt,S0​​(x)={0,1,​∥x∥modt∈S0​,otherwise,​

where ∥x∥\|x\|∥x∥ is the Hamming weight. MOD12b=MODb12,S0\mathsf{MOD12}_b=\mathsf{MOD}^{12,S_0}_bMOD12b​=MODb12,S0​​ with S0={0,1,3,4,6,9}S_0=\{0,1,3,4,6,9\}S0​={0,1,3,4,6,9}.

The signed weight profile is gt,S0(w)=1g_{t,S_0}(w)=1gt,S0​​(w)=1 if w mod t∈S0w\bmod t\in S_0wmodt∈S0​ and −1-1−1 otherwise, for w≥0w\ge0w≥0. Its Fourier coefficients are

g^ν=1t∑w=0t−1g(w) ω−νw,ω=e2πi/t,0≤ν<t.\widehat g_\nu=\frac1t\sum_{w=0}^{t-1}g(w)\,\omega^{-\nu w},\qquad\omega=e^{2\pi i/t},\quad0\le\nu<t .g​ν​=t1​w=0∑t−1​g(w)ω−νw,ω=e2πi/t,0≤ν<t.

For a binary sequence a=(a(h))h≥0a=(a(h))_{h\ge0}a=(a(h))h≥0​ over F2\mathbb F_2F2​, its binomial transform is

λja(w)=∑h=0j(jh)a(w+h)(mod2),j,w≥0.\lambda^a_j(w)=\sum_{h=0}^{j}\binom jh a(w+h)\pmod 2,\qquad j,w\ge0 .λja​(w)=h=0∑j​(hj​)a(w+h)(mod2),j,w≥0.

For MODt,S0\mathsf{MOD}^{t,S_0}MODt,S0​ the paper uses a(h)=(1−g(h))/2a(h)=(1-g(h))/2a(h)=(1−g(h))/2, which is 111 exactly when h mod t∉S0h\bmod t\notin S_0hmodt∈/S0​ (the predicate's value at weight hhh); the resulting λj(w)\lambda_j(w)λj​(w) is the common coefficient of all degree-jjj monomials in the algebraic normal form of a residual whose fixed inputs have weight www.

Finally, for b′≥1b'\ge1b′≥1,

B12(b′)=26[(cos⁡π12)b′+(sin⁡π12)b′+2−b′/2]+13(32)b′.B_{12}(b')=\frac{\sqrt2}{6}\Big[\Big(\cos\frac\pi{12}\Big)^{b'}+\Big(\sin\frac\pi{12}\Big)^{b'}+2^{-b'/2}\Big]+\frac1{\sqrt3}\Big(\frac{\sqrt3}{2}\Big)^{b'} .B12​(b′)=62​​[(cos12π​)b′+(sin12π​)b′+2−b′/2]+3​1​(23​​)b′.

These objects state Lemma 5, Theorems 3 and 6, and Lemmas 7–8.

Formalization Note The output bit 000 is false and 111 is true; the paper's polarity (000 on S0S_0S0​) is kept. Residue sets are finite sets of naturals; the standing condition S0⊆[t]S_0\subseteq[t]S0​⊆[t] is a hypothesis of each theorem. F2\mathbb F_2F2​ is ZMod 2, and 2−b′/22^{-b'/2}2−b′/2 is a real power.

Definition code
import Definitions.Def_GoldreichAffine_Exponential_BooleanCore
open scoped BigOperators
open MatousekLP.Codes (Word weight)
set_option autoImplicit false

namespace GoldreichAffine.Exponential.Supplement

/-- MOD^{t,S0}_d (printed p.3 / PDF p.4): value 0 (false) iff ‖x‖ mod t ∈ S0, else 1 (true). -/
def modPredicate (t : ℕ) (S0 : Finset ℕ) (d : ℕ) : Predicate d :=
  fun x => !decide (weight x % t ∈ S0)

/-- The residue set S0 = {0,1,3,4,6,9} of MOD12 (printed p.10 / PDF p.11). -/
def mod12Residues : Finset ℕ := {0, 1, 3, 4, 6, 9}

/-- MOD12_b = MOD^{12,S0}_b with S0 = {0,1,3,4,6,9}. -/
def mod12 (b : ℕ) : Predicate b := modPredicate 12 mod12Residues b

/-- Signed weight profile g_{t,S0}(w) = 1 if w mod t ∈ S0, -1 otherwise (printed p.25 / PDF p.26). -/
def signedProfile (t : ℕ) (S0 : Finset ℕ) (w : ℕ) : ℤ :=
  if w % t ∈ S0 then 1 else -1

/-- Fourier coefficient ĝ_ν = (1/t) Σ_{w=0}^{t-1} g(w) ω^{-νw}, ω = exp(2πi/t). -/
noncomputable def fourierCoeff (t : ℕ) (S0 : Finset ℕ) (ν : ℕ) : ℂ :=
  (1 / (t : ℂ)) * ∑ w ∈ Finset.range t,
    (signedProfile t S0 w : ℂ) * Complex.exp (-(2 * Real.pi * Complex.I * (ν : ℂ) * (w : ℂ) / (t : ℂ)))

/-- Binomial transform of a binary sequence a over F₂:
    λ^a_j(w) = Σ_{h=0}^{j} C(j,h) a(w+h)  (printed p.30 / PDF p.31). -/
def binomialTransform (a : ℕ → ZMod 2) (j w : ℕ) : ZMod 2 :=
  ∑ h ∈ Finset.range (j + 1), (j.choose h : ZMod 2) * a (w + h)

/-- The binary sequence (1 - g_{t,S0}(h))/2: 1 iff h mod t ∉ S0, i.e. the MOD value at weight h.
    So binomialTransform (modSequence t S0) j w is the paper's λ_j(w). -/
def modSequence (t : ℕ) (S0 : Finset ℕ) (h : ℕ) : ZMod 2 :=
  if h % t ∈ S0 then 0 else 1

/-- The sequence of MOD12: its binomial transform gives λ_j(w) for MOD12_b. -/
def mod12Sequence : ℕ → ZMod 2 := modSequence 12 mod12Residues

/-- B12(b') of Theorem 6 (printed pp.10–11 / PDF pp.11–12), exactly as printed;
    2^{-b'/2} is a real power. -/
noncomputable def B12 (b' : ℕ) : ℝ :=
  Real.sqrt 2 / 6 * (Real.cos (Real.pi / 12) ^ b' + Real.sin (Real.pi / 12) ^ b'
      + (2 : ℝ) ^ (-(b' : ℝ) / 2))
    + 1 / Real.sqrt 3 * (Real.sqrt 3 / 2) ^ b'

end GoldreichAffine.Exponential.Supplement
Source
Ximing Fu, Mo Li, Shihan Lyu, Affine Advantage in Guess-type Attacks on Goldreich’s PRGs: Generalization, Characterization and Countermeasures, STOC 2027 submission #579 (October 2026), PDF SHA-256 c6e5f1bfbc08adde62b9863b4417adb47a894635ef9e887e40be2e7fcd8c0594, p. 3 (PDF p. 4) MOD definition; p. 10 (PDF p. 11) MOD12 and Theorem 6 (B12); App. B.1 p. 25 (PDF p. 26) signed profile and Fourier coefficients; App. B.3 p. 30 (PDF p. 31) λ_j(w)

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