Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Reduced residue representatives and residue fibres

Definition
GreenTaoPort_Wikipedia_GreenTao_Primes_ReducedResidues

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

arithmetic-progressionsgreen-tao-port-8822number-theory

For a natural modulus WWW, the reduced residue representatives are the integers bbb with 0≤b<W0\le b<W0≤b<W and gcd⁡(W,b)=1\gcd(W,b)=1gcd(W,b)=1. In particular this set is empty when W=0W=0W=0.

For a finite set S⊆NS\subseteq\mathbb NS⊆N and natural parameters W,bW,bW,b, the residue fibre is

SW,b={n∈S:n mod W=b}.S_{W,b}=\{n\in S:n\bmod W=b\}.SW,b​={n∈S:nmodW=b}.

Applications use a positive modulus and its standard representatives. The formal definition is total: at modulus zero the natural-number remainder convention is n mod 0=nn\bmod0=nnmod0=n.

Definition code
import Mathlib.Combinatorics.Pigeonhole
import Mathlib.Data.Nat.Totient
import Mathlib.Data.ZMod.Basic
import Mathlib.NumberTheory.Primorial
import Lean

set_option autoImplicit true
set_option relaxedAutoImplicit false
set_option maxSynthPendingDepth 3


namespace Wikipedia.SzemeredisTheorem

open Finset

/-- The reduced residue system modulo `W`, represented by its standard
natural-number representatives in `[0, W)`. -/
def reducedResidues (W : ℕ) : Finset ℕ :=
  {b ∈ Finset.range W | W.Coprime b}







/-- The elements of `S` lying in the standard residue class `b` modulo
`W`. -/
def residueFiber (S : Finset ℕ) (W b : ℕ) : Finset ℕ :=
  {n ∈ S | n % W = b}

















end Wikipedia.SzemeredisTheorem


/- Materialize compiler-generated declarations promised by this bundle. -/
run_meta do
  for requiredName in #[
    `Wikipedia.SzemeredisTheorem.reducedResidues.eq_1,
    `Wikipedia.SzemeredisTheorem.residueFiber.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/GreenTao/Primes/ReducedResidues.lean#L10-L35

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