The areas / V30. Combinatorics
Mathlib.Combinatorics.Schnirelmann
30 declarations and 6 deprecated aliases. Mathlib docs · Source
Schnirelmann density
We define the Schnirelmann density of a set A of natural numbers as
$inf_{n > 0} |A ∩ {1,...,n}| / n$. As this density is very sensitive to changes in small values,
we must exclude 0 from the infimum, and from the intersection.
Main statements
- Simple bounds on the Schnirelmann density, that it is between 0 and 1 are given in
schnirelmannDensity_nonnegandschnirelmannDensity_le_one. schnirelmannDensity_le_of_notMem: Ifk ∉ A, the density can be easily upper-bounded by1 - k⁻¹
Implementation notes
Despite the definition being noncomputable, we include a decidable instance argument, since this
makes the definition easier to use in explicit cases.
Further, we use Finset.Ioc rather than a set intersection since the set is finite by construction,
which reduces the proof obligations later that would arise with Nat.card.
TODO
- Give other calculations of the density, for example powers and their sumsets.
- Define other densities like the lower and upper asymptotic density, and the natural density, and show how these relate to the Schnirelmann density.
- Prove Schnirelmann's theorem and Mann's theorem on the subadditivity of this density.
References
- [Ruzsa, Imre, Sumsets and structure][ruzsa2009]
theorem schnirelmannDensity.congr_simp E1 #
∀ (A A_1 : Set ℕ),
A = A_1 →
∀ {inst : DecidablePred fun x ↦ x ∈ A} [inst_1 : DecidablePred fun x ↦ x ∈ A_1],
schnirelmannDensity A = schnirelmannDensity A_1
def schnirelmannDensity E1 #
(A : Set ℕ) → [DecidablePred fun x ↦ x ∈ A] → ℝ
The Schnirelmann density is defined as the infimum of $|A ∩ {1, ..., n}| / n$ as n ranges over the positive naturals.
theorem schnirelmannDensity_nonneg E3 #
∀ {A : Set ℕ} [inst : DecidablePred fun x ↦ x ∈ A], 0 ≤ schnirelmannDensity A
theorem schnirelmannDensity_le_div E1 #
∀ {A : Set ℕ} [inst : DecidablePred fun x ↦ x ∈ A] {n : ℕ},
n ≠ 0 → schnirelmannDensity A ≤ ↑{a ∈ Finset.Ioc 0 n | a ∈ A}.card / ↑n
theorem schnirelmannDensity_mul_le_card_filter E1 #
∀ {A : Set ℕ} [inst : DecidablePred fun x ↦ x ∈ A] {n : ℕ},
schnirelmannDensity A * ↑n ≤ ↑{a ∈ Finset.Ioc 0 n | a ∈ A}.card
For any natural n, the Schnirelmann density multiplied by n is bounded by |A ∩ {1, ..., n}|.
Note this property fails for the natural density.
theorem schnirelmannDensity_le_of_le E2 #
∀ {A : Set ℕ} [inst : DecidablePred fun x ↦ x ∈ A] {x : ℝ} (n : ℕ),
n ≠ 0 → ↑{a ∈ Finset.Ioc 0 n | a ∈ A}.card / ↑n ≤ x → schnirelmannDensity A ≤ x
To show the Schnirelmann density is upper bounded by x, it suffices to show
|A ∩ {1, ..., n}| / n ≤ x, for any chosen positive value of n.
We provide n explicitly here to make this lemma more easily usable in apply or refine.
This lemma is analogous to ciInf_le_of_le.
theorem schnirelmannDensity_le_one E3 #
∀ {A : Set ℕ} [inst : DecidablePred fun x ↦ x ∈ A], schnirelmannDensity A ≤ 1
theorem schnirelmannDensity_le_of_notMem E3 #
∀ {A : Set ℕ} [inst : DecidablePred fun x ↦ x ∈ A] {k : ℕ}, k ∉ A → schnirelmannDensity A ≤ 1 - (↑k)⁻¹
If k is omitted from the set, its Schnirelmann density is upper bounded by 1 - k⁻¹.
theorem schnirelmannDensity_eq_zero_of_one_notMem E1 #
∀ {A : Set ℕ} [inst : DecidablePred fun x ↦ x ∈ A], 1 ∉ A → schnirelmannDensity A = 0
The Schnirelmann density of a set not containing 1 is 0.
theorem schnirelmannDensity_le_of_subset E1 #
∀ {A : Set ℕ} [inst : DecidablePred fun x ↦ x ∈ A] {B : Set ℕ} [inst_1 : DecidablePred fun x ↦ x ∈ B],
A ⊆ B → schnirelmannDensity A ≤ schnirelmannDensity B
The Schnirelmann density is increasing with the set.
theorem schnirelmannDensity_eq_one_iff E0 #
∀ {A : Set ℕ} [inst : DecidablePred fun x ↦ x ∈ A], schnirelmannDensity A = 1 ↔ {0}ᶜ ⊆ A
The Schnirelmann density of A is 1 if and only if A contains all the positive naturals.
theorem schnirelmannDensity_eq_one_iff_of_zero_mem E1 #
∀ {A : Set ℕ} [inst : DecidablePred fun x ↦ x ∈ A], 0 ∈ A → (schnirelmannDensity A = 1 ↔ A = Set.univ)
The Schnirelmann density of A containing 0 is 1 if and only if A is the naturals.
theorem le_schnirelmannDensity_iff E0 #
∀ {A : Set ℕ} [inst : DecidablePred fun x ↦ x ∈ A] {x : ℝ},
x ≤ schnirelmannDensity A ↔ ∀ (n : ℕ), 0 < n → x ≤ ↑{a ∈ Finset.Ioc 0 n | a ∈ A}.card / ↑n
theorem schnirelmannDensity_lt_iff E0 #
∀ {A : Set ℕ} [inst : DecidablePred fun x ↦ x ∈ A] {x : ℝ},
schnirelmannDensity A < x ↔ ∃ n, 0 < n ∧ ↑{a ∈ Finset.Ioc 0 n | a ∈ A}.card / ↑n < x
theorem schnirelmannDensity_le_iff_forall E1 #
∀ {A : Set ℕ} [inst : DecidablePred fun x ↦ x ∈ A] {x : ℝ},
schnirelmannDensity A ≤ x ↔ ∀ (ε : ℝ), 0 < ε → ∃ n, 0 < n ∧ ↑{a ∈ Finset.Ioc 0 n | a ∈ A}.card / ↑n < x + ε
theorem schnirelmannDensity_congr' E1 #
∀ {A : Set ℕ} [inst : DecidablePred fun x ↦ x ∈ A] {B : Set ℕ} [inst_1 : DecidablePred fun x ↦ x ∈ B],
(∀ n > 0, n ∈ A ↔ n ∈ B) → schnirelmannDensity A = schnirelmannDensity B
theorem schnirelmannDensity_insert_zero E0 #
∀ {A : Set ℕ} [inst : DecidablePred fun x ↦ x ∈ A] [inst_1 : DecidablePred fun x ↦ x ∈ insert 0 A],
schnirelmannDensity (insert 0 A) = schnirelmannDensity A
The Schnirelmann density is unaffected by adding 0.
theorem schnirelmannDensity_sdiff_singleton_zero E1 #
∀ {A : Set ℕ} [inst : DecidablePred fun x ↦ x ∈ A] [inst_1 : DecidablePred fun x ↦ x ∈ A \ {0}],
schnirelmannDensity (A \ {0}) = schnirelmannDensity A
The Schnirelmann density is unaffected by removing 0.
theorem schnirelmannDensity_congr E1 #
∀ {A : Set ℕ} [inst : DecidablePred fun x ↦ x ∈ A] {B : Set ℕ} [inst_1 : DecidablePred fun x ↦ x ∈ B],
A = B → schnirelmannDensity A = schnirelmannDensity B
theorem exists_of_schnirelmannDensity_eq_zero E1 #
∀ {A : Set ℕ} [inst : DecidablePred fun x ↦ x ∈ A] {ε : ℝ},
0 < ε → schnirelmannDensity A = 0 → ∃ n, 0 < n ∧ ↑{a ∈ Finset.Ioc 0 n | a ∈ A}.card / ↑n < ε
If the Schnirelmann density is 0, there is a positive natural for which
|A ∩ {1, ..., n}| / n < ε, for any positive ε.
Note this cannot be improved to ∃ᶠ n : ℕ in atTop, as can be seen by A = {1}ᶜ.
theorem schnirelmannDensity_empty E0 #
schnirelmannDensity ∅ = 0
theorem schnirelmannDensity_finset E1 #
∀ (A : Finset ℕ), schnirelmannDensity ↑A = 0
The Schnirelmann density of any finset is 0.
theorem schnirelmannDensity_finite E1 #
∀ {A : Set ℕ} [inst : DecidablePred fun x ↦ x ∈ A], A.Finite → schnirelmannDensity A = 0
The Schnirelmann density of any finite set is 0.
theorem schnirelmannDensity_univ E0 #
schnirelmannDensity Set.univ = 1
theorem schnirelmannDensity_setOfPred_even E1 #
schnirelmannDensity (Set.ofPred Even) = 0
theorem schnirelmannDensity_setOfPred_prime E1 #
schnirelmannDensity (Set.ofPred Nat.Prime) = 0
theorem schnirelmannDensity_setOfPred_mod_eq_one E1 #
∀ {m : ℕ}, m ≠ 1 → schnirelmannDensity {n | n % m = 1} = (↑m)⁻¹
The Schnirelmann density of the set of naturals which are 1 mod m is m⁻¹, for any m ≠ 1.
Note that if m = 1, this set is empty.
theorem schnirelmannDensity_setOfPred_modeq_one E1 #
∀ {m : ℕ}, schnirelmannDensity {n | n ≡ 1 [MOD m]} = (↑m)⁻¹
theorem schnirelmannDensity_setOfPred_Odd E1 #
schnirelmannDensity (Set.ofPred Odd) = 2⁻¹
theorem add_eq_univ_of_one_le_schirelmannDensity_add_schnirelmannDensity E1 #
∀ {A B : Set ℕ} [inst : DecidablePred fun x ↦ x ∈ A] [inst_1 : DecidablePred fun x ↦ x ∈ B],
0 ∈ A → 0 ∈ B → 1 ≤ schnirelmannDensity A + schnirelmannDensity B → A + B = Set.univ
If two sets A and B have Schnirelmann densities with sum at least 1, and both sets
contain zero, then every natural number is sum of an element of A and an element of B.
Note that we cannot omit the assumption that both sets contain zero, as shown by the
counterexample A = B = Odd.
Deprecated aliases
| Name | New name | Since |
|---|---|---|
schnirelmannDensity_diff_singleton_zero | schnirelmannDensity_sdiff_singleton_zero | 2026-06-03 |
schnirelmannDensity_setOf_Odd | schnirelmannDensity_setOfPred_Odd | 2026-07-09 |
schnirelmannDensity_setOf_even | schnirelmannDensity_setOfPred_even | 2026-07-09 |
schnirelmannDensity_setOf_mod_eq_one | schnirelmannDensity_setOfPred_mod_eq_one | 2026-07-09 |
schnirelmannDensity_setOf_modeq_one | schnirelmannDensity_setOfPred_modeq_one | 2026-07-09 |
schnirelmannDensity_setOf_prime | schnirelmannDensity_setOfPred_prime | 2026-07-09 |