File: Mathlib/Combinatorics/Schnirelmann.lean

full_name: schnirelmannDensity
code: /-- The Schnirelmann density is defined as the infimum of |A ∩ {1, ..., n}| / n as n ranges over
the positive naturals. -/
noncomputable def schnirelmannDensity (A : Set ℕ) [DecidablePred (· ∈ A)] : ℝ 
goal: ℝ

full_name: schnirelmannDensity_nonneg
code: lemma schnirelmannDensity_nonneg : 0 ≤ schnirelmannDensity A 
goal: 0 ≤ schnirelmannDensity A

full_name: schnirelmannDensity_le_div
code: lemma schnirelmannDensity_le_div {n : ℕ} (hn : n ≠ 0) :
    schnirelmannDensity A ≤ ((Ioc 0 n).filter (· ∈ A)).card / n 
goal: schnirelmannDensity A ≤ ↑(Finset.filter (fun x => x ∈ A) (Finset.Ioc 0 n)).card / ↑n

full_name: schnirelmannDensity_mul_le_card_filter
code: /--
For any natural `n`, the Schnirelmann density multiplied by `n` is bounded by `|A ∩ {1, ..., n}|`.
Note this property fails for the natural density.
-/
lemma schnirelmannDensity_mul_le_card_filter {n : ℕ} :
    schnirelmannDensity A * n ≤ ((Ioc 0 n).filter (· ∈ A)).card 
goal: schnirelmannDensity A * ↑n ≤ ↑(Finset.filter (fun x => x ∈ A) (Finset.Ioc 0 n)).card

full_name: schnirelmannDensity_le_of_le
code: /--
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`.
-/
lemma schnirelmannDensity_le_of_le {x : ℝ} (n : ℕ) (hn : n ≠ 0)
    (hx : ((Ioc 0 n).filter (· ∈ A)).card / n ≤ x) : schnirelmannDensity A ≤ x 
goal: schnirelmannDensity A ≤ x

full_name: schnirelmannDensity_le_one
code: lemma schnirelmannDensity_le_one : schnirelmannDensity A ≤ 1 
goal: schnirelmannDensity A ≤ 1

full_name: schnirelmannDensity_le_of_not_mem
code: /--
If `k` is omitted from the set, its Schnirelmann density is upper bounded by `1 - k⁻¹`.
-/
lemma schnirelmannDensity_le_of_not_mem {k : ℕ} (hk : k ∉ A) :
    schnirelmannDensity A ≤ 1 - (k⁻¹ : ℝ) 
goal: schnirelmannDensity A ≤ 1 - (↑k)⁻¹

full_name: schnirelmannDensity_eq_zero_of_one_not_mem
code: /-- The Schnirelmann density of a set not containing `1` is `0`. -/
lemma schnirelmannDensity_eq_zero_of_one_not_mem (h : 1 ∉ A) : schnirelmannDensity A = 0 
goal: schnirelmannDensity A = 0

full_name: schnirelmannDensity_le_of_subset
code: /-- The Schnirelmann density is increasing with the set. -/
lemma schnirelmannDensity_le_of_subset {B : Set ℕ} [DecidablePred (· ∈ B)] (h : A ⊆ B) :
    schnirelmannDensity A ≤ schnirelmannDensity B 
goal: schnirelmannDensity A ≤ schnirelmannDensity B

full_name: schnirelmannDensity_eq_one_iff
code: /-- The Schnirelmann density of `A` is `1` if and only if `A` contains all the positive naturals. -/
lemma schnirelmannDensity_eq_one_iff : schnirelmannDensity A = 1 ↔ {0}ᶜ ⊆ A 
goal: schnirelmannDensity A = 1 ↔ {0}ᶜ ⊆ A

full_name: schnirelmannDensity_eq_one_iff_of_zero_mem
code: /-- The Schnirelmann density of `A` containing `0` is `1` if and only if `A` is the naturals. -/
lemma schnirelmannDensity_eq_one_iff_of_zero_mem (hA : 0 ∈ A) :
    schnirelmannDensity A = 1 ↔ A = Set.univ 
goal: schnirelmannDensity A = 1 ↔ A = Set.univ

full_name: le_schnirelmannDensity_iff
code: lemma le_schnirelmannDensity_iff {x : ℝ} :
    x ≤ schnirelmannDensity A ↔ ∀ n : ℕ, 0 < n → x ≤ ((Ioc 0 n).filter (· ∈ A)).card / n 
goal: x ≤ schnirelmannDensity A ↔ ∀ (n : ℕ), 0 < n → x ≤ ↑(Finset.filter (fun x => x ∈ A) (Finset.Ioc 0 n)).card / ↑n

full_name: schnirelmannDensity_lt_iff
code: lemma schnirelmannDensity_lt_iff {x : ℝ} :
    schnirelmannDensity A < x ↔ ∃ n : ℕ, 0 < n ∧ ((Ioc 0 n).filter (· ∈ A)).card / n < x 
goal: schnirelmannDensity A < x ↔ ∃ n, 0 < n ∧ ↑(Finset.filter (fun x => x ∈ A) (Finset.Ioc 0 n)).card / ↑n < x

full_name: schnirelmannDensity_le_iff_forall
code: lemma schnirelmannDensity_le_iff_forall {x : ℝ} :
    schnirelmannDensity A ≤ x ↔
      ∀ ε : ℝ, 0 < ε → ∃ n : ℕ, 0 < n ∧ ((Ioc 0 n).filter (· ∈ A)).card / n < x + ε 
goal: schnirelmannDensity A ≤ x ↔
  ∀ (ε : ℝ), 0 < ε → ∃ n, 0 < n ∧ ↑(Finset.filter (fun x => x ∈ A) (Finset.Ioc 0 n)).card / ↑n < x + ε

full_name: schnirelmannDensity_congr'
code: lemma schnirelmannDensity_congr' {B : Set ℕ} [DecidablePred (· ∈ B)]
    (h : ∀ n > 0, n ∈ A ↔ n ∈ B) : schnirelmannDensity A = schnirelmannDensity B 
goal: schnirelmannDensity A = schnirelmannDensity B

full_name: schnirelmannDensity_insert_zero
code: /-- The Schnirelmann density is unaffected by adding `0`. -/
@[simp] lemma schnirelmannDensity_insert_zero [DecidablePred (· ∈ insert 0 A)] :
    schnirelmannDensity (insert 0 A) = schnirelmannDensity A 
goal: schnirelmannDensity (insert 0 A) = schnirelmannDensity A

full_name: schnirelmannDensity_diff_singleton_zero
code: /-- The Schnirelmann density is unaffected by removing `0`. -/
lemma schnirelmannDensity_diff_singleton_zero [DecidablePred (· ∈ A \ {0})] :
    schnirelmannDensity (A \ {0}) = schnirelmannDensity A 
goal: schnirelmannDensity (A \ {0}) = schnirelmannDensity A

full_name: schnirelmannDensity_congr
code: lemma schnirelmannDensity_congr {B : Set ℕ} [DecidablePred (· ∈ B)] (h : A = B) :
    schnirelmannDensity A = schnirelmannDensity B 
goal: schnirelmannDensity A = schnirelmannDensity B

full_name: exists_of_schnirelmannDensity_eq_zero
code: /--
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}ᶜ`.
-/
lemma exists_of_schnirelmannDensity_eq_zero {ε : ℝ} (hε : 0 < ε) (hA : schnirelmannDensity A = 0) :
    ∃ n, 0 < n ∧ ((Ioc 0 n).filter (· ∈ A)).card / n < ε 
goal: ∃ n, 0 < n ∧ ↑(Finset.filter (fun x => x ∈ A) (Finset.Ioc 0 n)).card / ↑n < ε

full_name: schnirelmannDensity_empty
code: @[simp] lemma schnirelmannDensity_empty : schnirelmannDensity ∅ = 0 
goal: schnirelmannDensity ∅ = 0

full_name: schnirelmannDensity_finset
code: /-- The Schnirelmann density of any finset is `0`. -/
lemma schnirelmannDensity_finset (A : Finset ℕ) : schnirelmannDensity A = 0 
goal: schnirelmannDensity ↑A = 0

full_name: schnirelmannDensity_finite
code: /-- The Schnirelmann density of any finite set is `0`. -/
lemma schnirelmannDensity_finite {A : Set ℕ} [DecidablePred (· ∈ A)] (hA : A.Finite) :
    schnirelmannDensity A = 0 
goal: schnirelmannDensity A = 0

full_name: schnirelmannDensity_univ
code: @[simp] lemma schnirelmannDensity_univ : schnirelmannDensity Set.univ = 1 
goal: schnirelmannDensity Set.univ = 1

full_name: schnirelmannDensity_setOf_even
code: lemma schnirelmannDensity_setOf_even : schnirelmannDensity (setOf Even) = 0 
goal: schnirelmannDensity (setOf Even) = 0

full_name: schnirelmannDensity_setOf_prime
code: lemma schnirelmannDensity_setOf_prime : schnirelmannDensity (setOf Nat.Prime) = 0 
goal: schnirelmannDensity (setOf Nat.Prime) = 0

full_name: schnirelmannDensity_setOf_mod_eq_one
code: /--
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.
-/
lemma schnirelmannDensity_setOf_mod_eq_one {m : ℕ} (hm : m ≠ 1) :
    schnirelmannDensity {n | n % m = 1} = (m⁻¹ : ℝ) 
goal: schnirelmannDensity {n | n % m = 1} = (↑m)⁻¹

full_name: schnirelmannDensity_setOf_modeq_one
code: lemma schnirelmannDensity_setOf_modeq_one {m : ℕ} :
    schnirelmannDensity {n | n ≡ 1 [MOD m]} = (m⁻¹ : ℝ) 
goal: schnirelmannDensity {n | n ≡ 1 [MOD m]} = (↑m)⁻¹

full_name: schnirelmannDensity_setOf_Odd
code: lemma schnirelmannDensity_setOf_Odd : schnirelmannDensity (setOf Odd) = 2⁻¹ 
goal: schnirelmannDensity (setOf Odd) = 2⁻¹