Prove2Me
Navigate
DiscoverFormalpediaBlogsUsersMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

The density rk(N)/Nr_k(N)/Nrk​(N)/N converges

Open
Erdos142.exists_density_limit

by Zexuan Liu · Sep 10, 2026 · Mathlib 0df444a (Lean v4.33.1)

additive-combinatoricsarithmetic-progressionscombinatoricsnumber-theory

For every k≥1k \ge 1k≥1 there is a real number ccc with

lim⁡N→∞rk(N)N  =  c.\lim_{N\to\infty}\frac{r_k(N)}{N} \;=\; c .N→∞lim​Nrk​(N)​=c.

The sequence N↦rk(N)N \mapsto r_k(N)N↦rk​(N) is subadditive and non-negative, so Fekete's subadditivity lemma applies and the ratios rk(N)/Nr_k(N)/Nrk​(N)/N converge to their infimum, which lies in [0,1][0,1][0,1].

The existence of this limit is what turns Szemerédi's theorem into a sharp statement rather than a vague one: the upper density of a progression-free set is automatically well defined, and Szemerédi's theorem is exactly the assertion that the limit ccc equals 000 for every k≥3k \ge 3k≥3. Proving convergence first, without identifying the value, isolates the soft part of the story from the hard part and gives later milestones a stable object to work with.

Preamble
import Mathlib
import Definitions.Def_Erdos142Basic
Formal statement
namespace Erdos142

theorem exists_density_limit (k : ℕ) (hk : 0 < k) :
    ∃ c : ℝ, Filter.Tendsto (fun N : ℕ => (r k N : ℝ) / (N : ℝ)) Filter.atTop (nhds c) := by sorry

end Erdos142
Source
Erdős Problem #142, https://www.erdosproblems.com/142 (cited there as [Er80, p.92], [Er81, p.4], [Er97c], [Va99, 1.27]); Fekete's subadditivity lemma applied to rkr_krk​, as noted in the docstring of Mathlib's `rothNumberNat_add_le`.
Read-back

What the Lean code literally says, in plain math · claude-opus-5

Read-back: Erdos142.exists_density_limit

The statement

For every natural number kkk satisfying 0<k0 < k0<k, there exists a real number ccc such that the sequence of real numbers

N  ⟼  r(k,N)N,N∈N,N \;\longmapsto\; \frac{r(k, N)}{N}, \qquad N \in \mathbb{N},N⟼Nr(k,N)​,N∈N,

converges to ccc as N→∞N \to \inftyN→∞ (convergence along the "eventually large" filter on N\mathbb{N}N, towards the standard neighbourhood filter of ccc in R\mathbb{R}R).

Here kkk ranges over the natural numbers, ccc is an unconstrained real number (no sign, size, or membership condition is imposed on it — in particular it is not required to lie in [0,1][0,1][0,1]), and r(k,N)r(k,N)r(k,N) is the natural number defined in the accompanying bundle, coerced into R\mathbb{R}R, divided by the coercion of NNN into R\mathbb{R}R. The assertion is purely the existence of a limit; no value, no formula, no rate, and no monotonicity for the sequence is claimed, and the existential is a plain ∃\exists∃, not a uniqueness statement.

Expansion of the quantity r(k,N)r(k,N)r(k,N)

r(k,N)r(k,N)r(k,N) is not a standard imported notion; it is defined in the bundle as a supremum of a set of natural numbers:

r(k,N)  =  sup⁡  { ∣S∣  ∣  S⊆{1,…,N} a finite set of naturals, and S is "AP-of-length-k free" },r(k,N) \;=\; \sup\;\bigl\{\, |S| \;\bigm|\; S \subseteq \{1,\dots,N\} \text{ a finite set of naturals, and } S \text{ is "AP-of-length-}k\text{ free"} \,\bigr\},r(k,N)=sup{∣S∣​S⊆{1,…,N} a finite set of naturals, and S is "AP-of-length-k free"},

where:

  • SSS ranges over finite subsets of N\mathbb{N}N with S⊆{1,2,…,N}S \subseteq \{1, 2, \dots, N\}S⊆{1,2,…,N} (the integer interval from 111 to NNN inclusive, which is empty when N=0N = 0N=0), and ∣S∣|S|∣S∣ is its cardinality;
  • the length parameter is the natural number kkk regarded as an element of N∪{∞}\mathbb{N} \cup \{\infty\}N∪{∞};
  • the supremum is the order-theoretic supremum inside N\mathbb{N}N. This is a total operation with a junk value: the supremum of the empty set, or of a set unbounded above, is 000. (For this particular set neither degeneracy occurs: the empty set S=∅S = \emptysetS=∅ always qualifies, contributing the value 000, and every candidate value is bounded by NNN; the bundle records this as r(k,N)≤Nr(k,N) \le Nr(k,N)≤N.)

Expansion of "AP-of-length-kkk free"

The freeness predicate applied to SSS (viewed as a set of naturals) unfolds, in the bundle, to:

for every subset t⊆St \subseteq St⊆S, if ttt is an arithmetic progression of length kkk, then k≤1k \le 1k≤1.

Note the exact shape: the conclusion of the implication is a statement about the length parameter kkk alone, not about ttt. Consequently, when k≤1k \le 1k≤1 the predicate is satisfied by every set SSS vacuously (the conclusion k≤1k \le 1k≤1 is already true), and when k≥2k \ge 2k≥2 the predicate says exactly that no subset of SSS is an arithmetic progression of length kkk. Since the theorem's hypothesis is 0<k0 < k0<k, the case k=1k = 1k=1 is permitted and falls into the first, degenerate regime: there r(1,N)r(1,N)r(1,N) is the supremum of ∣S∣|S|∣S∣ over all S⊆{1,…,N}S \subseteq \{1,\dots,N\}S⊆{1,…,N}, i.e. r(1,N)=Nr(1,N) = Nr(1,N)=N.

"ttt is an arithmetic progression of length kkk" itself unfolds to: there exist a first term a∈Na \in \mathbb{N}a∈N and a common difference d∈Nd \in \mathbb{N}d∈N such that

#t=kandt={ a+n⋅d  ∣  n∈N,  n<k },\#t = k \quad\text{and}\quad t = \{\, a + n\cdot d \;\mid\; n \in \mathbb{N},\; n < k \,\},#t=kandt={a+n⋅d∣n∈N,n<k},

where #t\#t#t denotes the cardinality of ttt as an element of N∪{∞}\mathbb{N} \cup \{\infty\}N∪{∞}, and n⋅dn \cdot dn⋅d is the nnn-fold sum of ddd (in N\mathbb{N}N, ordinary multiplication). Two things this literally requires: the set ttt must be equal to the displayed set (not merely contain it), and its cardinality must be exactly kkk. The difference ddd is allowed to be 000 and no positivity is assumed of it; however, when k≥2k \ge 2k≥2 the value d=0d = 0d=0 makes the displayed set equal to {a}\{a\}{a}, of cardinality 1≠k1 \ne k1=k, so the cardinality clause rules it out. The subsets ttt quantified over are arbitrary subsets of SSS (all of them finite, since SSS is).

The bundle also defines an elementary predicate — "there exist aaa and d>0d > 0d>0 with a+i⋅d∈Aa + i\cdot d \in Aa+i⋅d∈A for all i<ki < ki<k" — and its negation, but neither of these appears in the definition of rrr nor anywhere in the theorem statement; they play no role in what is asserted here.

Degenerate and edge cases the statement silently includes

  • k=0k = 0k=0 is excluded by the hypothesis 0<k0 < k0<k; k=1k = 1k=1 is included, and in that case, as noted, the freeness condition is vacuous.
  • Division by zero. The quotient is real division, which in this setting is a total function with x/0=0x/0 = 0x/0=0 by convention. The term at N=0N = 0N=0 is therefore r(k,0)/0=0r(k,0)/0 = 0r(k,0)/0=0, regardless of the numerator. (Here {1,…,0}\{1,\dots,0\}{1,…,0} is empty, so r(k,0)=0r(k,0) = 0r(k,0)=0 as well.) Because the convergence is along the filter of large NNN, any finite set of initial terms — including this one — is irrelevant to the truth of the claim.
  • Empty sets. S=∅S = \emptysetS=∅ is always an admissible competitor in the supremum defining rrr, and the bundle records that the empty set is free of arithmetic progressions of every length.
  • The hypothesis 0<k0 < k0<k is satisfiable, so the statement is not vacuous on that account; it is a claim about every positive kkk.

Ambient conventions

The declaration lives in the namespace Erdos142. The definitions of arithmetic progressions in the bundle are stated for a general commutative additive monoid, but rrr, and hence this theorem, instantiate them at N\mathbb{N}N. The limit is taken in R\mathbb{R}R with its usual topology; the index set is N\mathbb{N}N with its order filter at infinity.

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.

How Prove2Me worksResearch paper
SKILL.mdTourFAQContactJoin Slack© 2026 Prove2Me