Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Rank-two conditions for affine coefficient families modulo a prime

Definition
GreenTaoPort_Wikipedia_GreenTao_Sieve_GoodPrimeAffineRank

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

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

For a finite family of integer affine forms (ψq)(\psi_q)(ψq​), a rank-two good prime is a natural prime ppp such that every two distinct form indices q,rq,rq,r admit variable indices i,ji,ji,j with

ψq,iψr,j−ψq,jψr,i≠0in Z/pZ.\psi_{q,i}\psi_{r,j}-\psi_{q,j}\psi_{r,i}\ne0 \quad\text{in }\mathbb Z/p\mathbb Z.ψq,i​ψr,j​−ψq,j​ψr,i​=0in Z/pZ.

The selected-family predicate requires the existence of one such distinct pair inside a specified finite subset of form indices. This second predicate does not itself require ppp to be prime. Both conditions concern coefficient vectors; affine constant terms do not enter the minors, and repeating an index cannot supply the required rank.

Definition code
import Definitions.Def_GreenTaoPort_Wikipedia_GreenTao_Sieve_PairedLocalFactors
import Mathlib.Algebra.BigOperators.Expect
import Mathlib.Algebra.Field.ZMod
import Mathlib.Algebra.GCDMonoid.FinsetLemmas
import Mathlib.Algebra.Order.BigOperators.Group.Finset
import Mathlib.Analysis.Calculus.BumpFunction.InnerProduct
import Mathlib.Analysis.Calculus.ContDiff.Deriv
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Analysis.Calculus.Deriv.Support
import Mathlib.Analysis.SpecialFunctions.Log.Basic
import Mathlib.Combinatorics.Pigeonhole
import Mathlib.Data.Fintype.BigOperators
import Mathlib.Data.Fintype.Card
import Mathlib.Data.Fintype.Pi
import Mathlib.Data.Int.Lemmas
import Mathlib.Data.Nat.GCD.Prime
import Mathlib.Data.Nat.Squarefree
import Mathlib.Data.Nat.Totient
import Mathlib.Data.ZMod.Basic
import Mathlib.Data.ZMod.QuotientRing
import Mathlib.GroupTheory.Index
import Mathlib.LinearAlgebra.Pi
import Mathlib.Logic.Equiv.Fin.Basic
import Mathlib.MeasureTheory.Integral.Bochner.Set
import Mathlib.MeasureTheory.Integral.IntegralEqImproper
import Mathlib.NumberTheory.ArithmeticFunction.Moebius
import Mathlib.NumberTheory.Divisors
import Mathlib.NumberTheory.Primorial
import Mathlib.Tactic

set_option autoImplicit true
set_option relaxedAutoImplicit false
set_option maxSynthPendingDepth 3


/-!
# Rank-two affine densities at good primes

For a finite system of affine forms, failure of rank two modulo `p` is
detected by the vanishing of every two-by-two coefficient minor for some
distinct pair.  This file isolates a finite, explicit exceptional set using
the sum of the absolute values of all such minors.

Outside that set, pairwise independent integer coefficient vectors remain
rank two modulo `p`.  Thus every selected subfamily containing two distinct
indices has common-zero density at most `1 / p²`: its common-zero set is
contained in the common-zero set of one rank-two pair.  This is the actual
higher-order density estimate needed for the CFZ family.  Repeated indices do
not create rank, so the hypotheses use a `Finset` and explicitly require it
to be nontrivial.

The final results instantiate
`HasGoodPrimeHigherOrderDensityEstimate` for the CFZ forms and package the
estimate together with the exact local-factor inclusion--exclusion formula.
-/

namespace Wikipedia.SzemeredisTheorem

open scoped BigOperators

/-! ## An explicit finite exceptional set for rank two -/











/-- Every two distinct forms have a nonzero two-by-two minor modulo a
rank-two good prime. -/
def AffineRankTwoGoodPrime
    {κ ι : Type*} [Fintype κ] [Fintype ι]
    (p : ℕ) (forms : κ → AffineForm ι ℤ) : Prop :=
  p.Prime ∧
    ∀ {q r : κ}, q ≠ r →
      ∃ i j : ι,
        (((forms q).coefficientMinor (forms r) i j : ℤ) :
          ZMod p) ≠ 0







/-! ## Selected-family rank and density -/

/-- A selected family has rank at least two modulo `p` when it contains two
distinct indices with a nonvanishing coefficient minor.  Repetition alone
cannot witness this predicate. -/
def SelectedAffineFamilyHasRankAtLeastTwo
    {κ ι : Type*} [Fintype ι]
    (p : ℕ) (forms : κ → AffineForm ι ℤ)
    (s : Finset κ) : Prop :=
  ∃ q ∈ s, ∃ r ∈ s, q ≠ r ∧
    ∃ i j : ι,
      (((forms q).coefficientMinor (forms r) i j : ℤ) :
        ZMod p) ≠ 0















/-! ## CFZ specialization -/



















end Wikipedia.SzemeredisTheorem
Source
https://github.com/plby/lean-proofs/blob/8822f7ddef30fadbd92e1c6ab4ed897af356af5e/src/latest/Wikipedia/GreenTao/Sieve/GoodPrimeAffineRank.lean#L134-L209

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