Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Normalized weighted counts of cyclic arithmetic progressions

Definition
GreenTaoPort_Wikipedia_SzemeredisTheorem_ArithmeticProgression_Count

by kmehltretter82 · Nov 14, 2026 · Mathlib c5ea003 (Lean v4.30.0)

arithmetic-progressionscombinatoricsgreen-tao-port-8822

For a natural length kkk and residues a,d∈Z/NZa,d\in\mathbb Z/N\mathbb Za,d∈Z/NZ, the jjjth progression term is a+jda+jda+jd. A real weight fff assigns the progression the product

Pf(a,d)=∏j=0k−1f(a+jd).P_f(a,d)=\prod_{j=0}^{k-1}f(a+jd).Pf​(a,d)=j=0∏k−1​f(a+jd).

When N>0N>0N>0, the normalized cyclic count is the average of Pf(a,d)P_f(a,d)Pf​(a,d) over both aaa and ddd. It includes the constant progressions with d=0d=0d=0. Empty products give value one at length zero; the weight is not assumed nonnegative in these definitions.

Definition code
import Definitions.Def_GreenTaoPort_Wikipedia_SzemeredisTheorem_Finite_Mean
import Mathlib.Algebra.Order.BigOperators.GroupWithZero.Finset
import Mathlib.Data.ZMod.Basic
import Lean
import Mathlib.Algebra.BigOperators.Expect
import Mathlib.Data.Fintype.Card
import Mathlib.Tactic

set_option autoImplicit true
set_option relaxedAutoImplicit false
set_option maxSynthPendingDepth 3


/-!
# Weighted arithmetic-progression counts

The transference argument is most naturally stated as a lower bound for a
normalized weighted count of progressions in `ZMod N`.  This file defines
that count and proves its elementary positivity and monotonicity properties.
-/

namespace Wikipedia.SzemeredisTheorem

open scoped BigOperators

/-- The `j`th term of a cyclic arithmetic progression. -/
def cyclicAPTerm {k N : ℕ} (a d : ZMod N) (j : Fin k) : ZMod N :=
  a + (j : ZMod N) * d

/-- The weight contributed by one cyclic `k`-term progression. -/
def cyclicAPProduct (k N : ℕ) (f : ZMod N → ℝ)
    (a d : ZMod N) : ℝ :=
  ∏ j : Fin k, f (cyclicAPTerm a d j)

/-- The normalized weighted count of cyclic `k`-term progressions. The
average includes the diagonal `d = 0`. -/
noncomputable def cyclicAPCount (k N : ℕ) [NeZero N]
    (f : ZMod N → ℝ) : ℝ :=
  mean₂ (fun a d => cyclicAPProduct k N f a d)

















end Wikipedia.SzemeredisTheorem


/- Materialize compiler-generated declarations promised by this bundle. -/
run_meta do
  for requiredName in #[
    `Wikipedia.SzemeredisTheorem.cyclicAPCount.congr_simp,
    `Wikipedia.SzemeredisTheorem.cyclicAPCount.eq_1,
    `Wikipedia.SzemeredisTheorem.cyclicAPProduct.eq_1
  ] do
    let actualName ← Lean.realizeGlobalConstNoOverloadCore requiredName
    unless actualName == requiredName do
      throwError "Generated companion resolved to an unexpected name"
Source
https://github.com/plby/lean-proofs/blob/8822f7ddef30fadbd92e1c6ab4ed897af356af5e/src/latest/Wikipedia/SzemeredisTheorem/ArithmeticProgression/Count.lean#L17-L30

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