import Erdos824.Final import Erdos821.P7.Support /- The cardinal estimates below adapt Yao Xu's Count/Count.lean (Apache-2.0) to count the literal support before its projection to smooth successor primes. -/ noncomputable section open scoped BigOperators open Filter Erdos821.Blueprint Erdos821.Blueprint.Analytic attribute [local instance] Classical.propDecidable namespace Erdos824Marked def supported (C : CandidateData) (x : ℝ) (j : ℕ) : Finset ℕ := ((Finset.Icc 1 ⌊2*x⌋₊).filter (fun u => Nat.Prime (2*u-1))).filter (fun u => C.weighted x j u ≠ 0) theorem row_factors (C : CandidateData) {δ x : ℝ} (hG : C.Geometry δ) {j u : ℕ} (hj : C.j₀ ≤ j) (hu : 0 < u) (hw : C.weighted x j u ≠ 0) : 3 ≤ C.bands.r₀ ∧ ∃ f : Fin C.bands.r₀ → ℕ, (∀ i, f i ∈ C.bands.band x 0) ∧ (∏ i, f i) ∣ u := by have hcnt := hG.1.2.2.2.2.2.2.1 rw [hG.2.1, hG.2.2.1, hG.2.2.2.1] at hcnt have hreal : (3 : ℝ) ≤ C.bands.r₀ := by linarith have h0 : 0 < j := lt_of_lt_of_le (Nat.zero_lt_of_lt hG.2.2.2.2.2.2.2.1) hj have hcoef : C.bands.aQ x j (groupFreePart (C.bands.groups x) u) ≠ 0 := (mul_ne_zero_iff.mp (mul_ne_zero_iff.mp hw).1).1 obtain ⟨z, hz⟩ := Erdos821.P7Core.exists_list_of_coefficient_ne_zero C.bands x j _ hcoef let zrow : Fin (C.bands.last x + 1) := 0 refine ⟨by exact_mod_cast hreal, fun i => (z (zrow,i)).val, ?_, ?_⟩ · intro i have hm := (z (zrow,i)).property simpa [BandData.slotValues, zrow, Nat.ne_of_gt h0, Ne.symm (Nat.ne_of_gt h0)] using hm · have hd : (∏ i, (z (zrow,i)).val) ∣ C.bands.listProduct z := by unfold BandData.listProduct rw [Fintype.prod_prod_type] exact Finset.dvd_prod_of_mem (fun j' => ∏ i, (z (j',i)).val) (Finset.mem_univ zrow) rw [hz] at hd exact hd.trans (Erdos821.S56Core.groupFreePart_dvd _ _ hu) theorem support_mass {x : ℝ} {C : CandidateData} {jstar : ℕ} {K : ℝ} (hup : ∀ u : ℕ, C.weighted x jstar u ≤ Real.exp (K * Real.sqrt (L x))) : C.succPrimeMass x jstar ≤ ((supported C x jstar).card : ℝ) * Real.exp (K * Real.sqrt (L x)) := by set F : Finset ℕ := (Finset.Icc 1 ⌊2 * x⌋₊).filter (fun u => Nat.Prime (2 * u - 1)) with hFdef set S : Finset ℕ := F.filter (fun u => C.weighted x jstar u ≠ 0) with hSdef set W : ℝ := Real.exp (K * Real.sqrt (Erdos821.Blueprint.Analytic.L x)) with hWdef have hprime_eq : C.succPrimeMass x jstar = ∑ u ∈ F, C.weighted x jstar u := rfl have hSF : S ⊆ F := Finset.filter_subset _ _ have hsum_eq : ∑ u ∈ F, C.weighted x jstar u = ∑ u ∈ S, C.weighted x jstar u := by symm apply Finset.sum_subset hSF intro u huF huS have hne : ¬ (C.weighted x jstar u ≠ 0) := by intro hne exact huS (Finset.mem_filter.mpr ⟨huF, hne⟩) exact not_ne_iff.mp hne have hsum_le : ∑ u ∈ S, C.weighted x jstar u ≤ (S.card : ℝ) * W := by have h := Finset.sum_le_card_nsmul S (fun u => C.weighted x jstar u) W (fun u _ => hup u) rw [nsmul_eq_mul] at h exact h exact hprime_eq.le.trans (hsum_eq.le.trans hsum_le) theorem supply (δ : ℝ) (hδ : 0 < δ) (hδ' : δ < 1 / 4) : ∃ C : CandidateData, C.Geometry δ ∧ C.Bounds δ ∧ ∃ j : ℕ, C.j₀ ≤ j ∧ ∀ σ : ℝ, 0 < σ → ∀ᶠ x : ℝ in atTop, x ^ (1-σ) ≤ ((supported C x j).card : ℝ) := by have h := Erdos824.Final.packageInterfaces have hc := h.classical have hs := h.sieve hc have hii := h.typeII hc (h.shift hc hs (h.transference hc) (h.ideal hc)) obtain ⟨C, hC⟩ := h.candidateGeometry δ hδ hδ' have hb := h.candidateBounds δ C hC have hp := h.extraction hc hs hii (h.proxies hc hs) δ C hC hb (h.candidateTypeI δ C hC hb) (h.balanced δ C hC hb) refine ⟨C, hC, hb, ?_⟩ rcases hb with ⟨K, CA, cmin, cmax, hK, _, _, hBounds⟩ rcases hp with ⟨jstar, hjstar, c, hc, hPrime⟩ refine ⟨jstar, hjstar, ?_⟩ intro σ hσ have hBj := hBounds jstar hjstar have hAbs := Erdos824.Succ.Count.absorb K (CA + 1) σ c hK hσ hc have hGe5 : ∀ᶠ x : ℝ in atTop, (5 : ℝ) ≤ x := Filter.eventually_ge_atTop 5 filter_upwards [hBj, hPrime, hAbs, hGe5] with x hB hP hA h5 rcases hB with ⟨hmass_lo, _, _, _, hup, hsupp_full⟩ have hxpos : 0 < x := by linarith have hxnn : 0 ≤ x := le_of_lt hxpos have hLpos : 0 < Erdos821.Blueprint.Analytic.L x := Real.log_pos (by linarith : (1 : ℝ) < x) have hLnn : 0 ≤ Erdos821.Blueprint.Analytic.L x := le_of_lt hLpos have hWpos : 0 < Real.exp (K * Real.sqrt (Erdos821.Blueprint.Analytic.L x)) := Real.exp_pos _ have hWnn : 0 ≤ Real.exp (K * Real.sqrt (Erdos821.Blueprint.Analytic.L x)) := le_of_lt hWpos -- Upper bound: prime mass by smooth count times maximal weight. have hle1 : C.succPrimeMass x jstar ≤ ((supported C x jstar).card : ℝ) * Real.exp (K * Real.sqrt (Erdos821.Blueprint.Analytic.L x)) := support_mass hup -- Lower bound chain: `c * (x * L ^ (-CA)) / L ≤ card * W`. have hLneg : Erdos821.Blueprint.Analytic.L x ^ (-CA) = (Erdos821.Blueprint.Analytic.L x ^ CA)⁻¹ := Real.rpow_neg hLnn CA have hLrpow_pos : 0 < Erdos821.Blueprint.Analytic.L x ^ CA := Real.rpow_pos_of_pos hLpos CA have hLneg_pos : 0 < Erdos821.Blueprint.Analytic.L x ^ (-CA) := Real.rpow_pos_of_pos hLpos (-CA) have hlow : c * (x * Erdos821.Blueprint.Analytic.L x ^ (-CA)) / Erdos821.Blueprint.Analytic.L x ≤ ((supported C x jstar).card : ℝ) * Real.exp (K * Real.sqrt (Erdos821.Blueprint.Analytic.L x)) := by have h1 : c * (x * Erdos821.Blueprint.Analytic.L x ^ (-CA)) ≤ c * C.mass x jstar := by apply mul_le_mul_of_nonneg_left _ (le_of_lt hc) exact hmass_lo have h3 : c * (x * Erdos821.Blueprint.Analytic.L x ^ (-CA)) / Erdos821.Blueprint.Analytic.L x ≤ c * C.mass x jstar / Erdos821.Blueprint.Analytic.L x := by have hLinvnn : 0 ≤ (Erdos821.Blueprint.Analytic.L x)⁻¹ := inv_nonneg.mpr (le_of_lt hLpos) calc c * (x * Erdos821.Blueprint.Analytic.L x ^ (-CA)) / Erdos821.Blueprint.Analytic.L x = (c * (x * Erdos821.Blueprint.Analytic.L x ^ (-CA))) * (Erdos821.Blueprint.Analytic.L x)⁻¹ := by rw [div_eq_mul_inv] _ ≤ (c * C.mass x jstar) * (Erdos821.Blueprint.Analytic.L x)⁻¹ := mul_le_mul_of_nonneg_right h1 hLinvnn _ = c * C.mass x jstar / Erdos821.Blueprint.Analytic.L x := by rw [div_eq_mul_inv] exact le_trans h3 (le_trans hP hle1) -- Combine with absorption to get `x ^ (1 - σ) ≤ card`. have hLadd : Erdos821.Blueprint.Analytic.L x ^ (CA + 1) = Erdos821.Blueprint.Analytic.L x ^ CA * Erdos821.Blueprint.Analytic.L x := by have h := Real.rpow_add hLpos CA (1 : ℝ) rwa [Real.rpow_one] at h have hLadd_pos : 0 < Erdos821.Blueprint.Analytic.L x ^ (CA + 1) := Real.rpow_pos_of_pos hLpos (CA + 1) set D : ℝ := Erdos821.Blueprint.Analytic.L x ^ (CA + 1) * Real.exp (K * Real.sqrt (Erdos821.Blueprint.Analytic.L x)) * c⁻¹ with hDdef have hDpos : 0 < D := by rw [hDdef] exact mul_pos (mul_pos hLadd_pos hWpos) (inv_pos.mpr hc) have hDnn : 0 ≤ D := le_of_lt hDpos have hAle : D ≤ x ^ σ := hA -- `x / D ≤ card`: from `hlow` via `x / D = (c * (x * L ^ (-CA)) / L) / W`. have hEq : x / D = (c * (x * Erdos821.Blueprint.Analytic.L x ^ (-CA)) / Erdos821.Blueprint.Analytic.L x) / Real.exp (K * Real.sqrt (Erdos821.Blueprint.Analytic.L x)) := by rw [hDdef, hLadd, hLneg] field_simp have hxD : x / D ≤ ((supported C x jstar).card : ℝ) := by rw [hEq] exact (div_le_iff₀ hWpos).mpr hlow -- `x ^ (1 - σ) = x / x ^ σ ≤ x / D`. have hxσpos : 0 < x ^ σ := Real.rpow_pos_of_pos hxpos σ have hrw : x ^ (1 - σ) = x / x ^ σ := by have h1 : x ^ (1 - σ) = x ^ (1 : ℝ) / x ^ σ := Real.rpow_sub hxpos 1 σ rwa [Real.rpow_one] at h1 calc x ^ (1 - σ) = x / x ^ σ := hrw _ ≤ x / D := div_le_div_of_nonneg_left hxnn hDpos hAle _ ≤ ((supported C x jstar).card : ℝ) := hxD #print axioms row_factors #print axioms supply end Erdos824Marked