end Bounty /-! Erdos 416(i): proof adapted to the restricted conjectures.io submission format. Modified from Erdos416Submission (3).lean. Supporting proofs and dependency license notices are retained. The server supplies the imports and outer namespace. The separate verification harness checks the target type and permitted axioms. -/ /- Consolidated component: Erdos416.lean. -/ section /- Foundational lemmas for the distinct-totient doubling law. The unconditional real-variable limit is proved at the end of this file. Only established lemmas are included below; there are no admitted analytic inputs. -/ open Filter open scoped Topology BigOperators Classical namespace Erdos416Proof /- Original line 41: Erdos416Proof.totientsUpTo -/ noncomputable def totientsUpTo (x : ℝ) : Finset ℕ := open scoped Classical in (Finset.Icc 1 ⌊x⌋₊).filter (fun n => ∃ m : ℕ, m.totient = n) /-- The exact distinct-totient counting function in Erdős 416(i). -/ /- Original line 46: Erdos416Proof.V -/ noncomputable def V (x : ℝ) : ℝ := (totientsUpTo x).card /- Original line 48: Erdos416Proof.mem_totientsUpTo -/ theorem mem_totientsUpTo {x : ℝ} (hx : 0 ≤ x) {n : ℕ} : n ∈ totientsUpTo x ↔ 0 < n ∧ (n : ℝ) ≤ x ∧ ∃ m : ℕ, 0 < m ∧ m.totient = n := by classical simp only [totientsUpTo, Finset.mem_filter, Finset.mem_Icc] constructor · rintro ⟨⟨hn, hnx⟩, m, hm⟩ refine ⟨by omega, (Nat.le_floor_iff hx).mp hnx, m, ?_, hm⟩ exact Nat.totient_pos.mp (by omega) · rintro ⟨hn, hnx, m, _, hm⟩ exact ⟨⟨by omega, (Nat.le_floor_iff hx).mpr hnx⟩, m, hm⟩ /- Original line 60: Erdos416Proof.totientsUpTo_mono -/ theorem totientsUpTo_mono : Monotone totientsUpTo := by classical intro x y hxy n hn simp only [totientsUpTo, Finset.mem_filter, Finset.mem_Icc] at hn ⊢ exact ⟨⟨hn.1.1, hn.1.2.trans (Nat.floor_mono hxy)⟩, hn.2⟩ /- Original line 66: Erdos416Proof.V_nonneg -/ theorem V_nonneg (x : ℝ) : 0 ≤ V x := by exact Nat.cast_nonneg _ /- Original line 69: Erdos416Proof.V_mono -/ theorem V_mono : Monotone V := by intro x y hxy unfold V exact_mod_cast Finset.card_le_card (totientsUpTo_mono hxy) /- Original line 74: Erdos416Proof.V_pos -/ theorem V_pos {x : ℝ} (hx : 1 ≤ x) : 0 < V x := by have hm : 1 ∈ totientsUpTo x := (mem_totientsUpTo (by linarith)).mpr ⟨by norm_num, by simpa using hx, 1, by norm_num, Nat.totient_one⟩ unfold V exact_mod_cast Finset.card_pos.mpr ⟨1, hm⟩ /- Original line 81: Erdos416Proof.eventually_V_pos -/ theorem eventually_V_pos : ∀ᶠ x : ℝ in atTop, 0 < V x := (eventually_ge_atTop 1).mono fun _ hx => V_pos hx open scoped Classical in /- Original line 85: Erdos416Proof.V_eq_standard_count -/ theorem V_eq_standard_count (x : ℝ) : V x = ((Finset.Icc 1 ⌊x⌋₊).filter (fun n => ∃ m : ℕ, m.totient = n)).card := by classical rfl /- Largest prime factors, with the convention P⁺(1) = 1. -/ /- Original line 93: Erdos416Proof.largestPrimeFactor -/ def largestPrimeFactor (n : ℕ) : ℕ := max 1 (n.primeFactors.sup id) /- Original line 95: Erdos416Proof.largestPrimeFactor_one -/ theorem largestPrimeFactor_one : largestPrimeFactor 1 = 1 := by simp [largestPrimeFactor] /- Original line 98: Erdos416Proof.one_le_largestPrimeFactor -/ theorem one_le_largestPrimeFactor (n : ℕ) : 1 ≤ largestPrimeFactor n := le_max_left _ _ /- Original line 101: Erdos416Proof.prime_le_largestPrimeFactor -/ theorem prime_le_largestPrimeFactor {n p : ℕ} (hn : 0 < n) (hp : p.Prime) (hpn : p ∣ n) : p ≤ largestPrimeFactor n := (Finset.le_sup (f := id) (hp.mem_primeFactors hpn (Nat.ne_of_gt hn))).trans (le_max_right _ _) /- Original line 106: Erdos416Proof.largestPrimeFactor_prime -/ theorem largestPrimeFactor_prime {p : ℕ} (hp : p.Prime) : largestPrimeFactor p = p := by simp [Erdos416Proof.largestPrimeFactor_one, largestPrimeFactor, hp.primeFactors, hp.one_le] /- Original line 110: Erdos416Proof.largestPrimeFactor_mul -/ theorem largestPrimeFactor_mul {m n : ℕ} (hm : 0 < m) (hn : 0 < n) : largestPrimeFactor (m * n) = max (largestPrimeFactor m) (largestPrimeFactor n) := by simp [Erdos416Proof.largestPrimeFactor_one, largestPrimeFactor, Nat.primeFactors_mul (Nat.ne_of_gt hm) (Nat.ne_of_gt hn), Finset.sup_union, max_assoc, max_left_comm, max_comm] /- Original line 115: Erdos416Proof.coprime_of_largestPrimeFactor_lt -/ theorem coprime_of_largestPrimeFactor_lt {n p : ℕ} (hn : 0 < n) (hp : p.Prime) (h : largestPrimeFactor n < p) : p.Coprime n := by rw [hp.coprime_iff_not_dvd] intro hdvd exact (not_le_of_gt h) (prime_le_largestPrimeFactor hn hp hdvd) /- Original line 121: Erdos416Proof.mem_factored_range_iff -/ theorem mem_factored_range_iff {P n : ℕ} (hP : 1 ≤ P) : n ∈ Nat.factoredNumbers (Finset.range (P + 1)) ↔ 0 < n ∧ largestPrimeFactor n ≤ P := by rw [Nat.mem_factoredNumbers_iff_primeFactors_subset] constructor · rintro ⟨hn, hs⟩ refine ⟨Nat.pos_of_ne_zero hn, max_le hP ?_⟩ apply Finset.sup_le intro p hp exact Nat.le_of_lt_succ (Finset.mem_range.mp (hs hp)) · rintro ⟨hn, hmax⟩ refine ⟨Nat.ne_of_gt hn, fun p hp => Finset.mem_range.mpr ?_⟩ apply Nat.lt_succ_of_le exact (Finset.le_sup (f := id) hp).trans ((le_max_right _ _).trans hmax) /- Original line 136: Erdos416Proof.totient_prod_primes -/ theorem totient_prod_primes (s : Finset ℕ) (hs : ∀ p ∈ s, p.Prime) : (∏ p ∈ s, p).totient = ∏ p ∈ s, (p - 1) := by revert hs induction s using Finset.induction with | empty => simp | @insert p s hps ih => intro hs have hp : p.Prime := hs p (Finset.mem_insert_self _ _) have hs' : ∀ q ∈ s, q.Prime := fun q hq => hs q (Finset.mem_insert_of_mem hq) have hcop : p.Coprime (∏ q ∈ s, q) := by apply Nat.coprime_prod_right_iff.mpr intro q hq rw [hp.coprime_iff_not_dvd] intro hdvd have heq : p = q := (Nat.prime_dvd_prime_iff_eq hp (hs' q hq)).mp hdvd exact hps (heq.symm ▸ hq) rw [Finset.prod_insert hps, Nat.totient_mul hcop, Nat.totient_prime hp, ih hs', Finset.prod_insert hps] /- Original line 155: Erdos416Proof.totient_core -/ theorem totient_core (r : ℕ) (s : Finset ℕ) (hs : ∀ p ∈ s, p.Prime) (hcop : ∀ p ∈ s, p.Coprime r) : (r * ∏ p ∈ s, p).totient = r.totient * ∏ p ∈ s, (p - 1) := by rw [Nat.totient_mul (Nat.coprime_prod_left_iff.mpr hcop).symm, totient_prod_primes s hs] /- Original line 161: Erdos416Proof.top_prime_extension -/ theorem top_prime_extension {a p : ℕ} (ha : 0 < a) (hp : p.Prime) (htop : largestPrimeFactor a < p) : (p * a).totient = (p - 1) * a.totient ∧ largestPrimeFactor (p * a) = p := by constructor · rw [Nat.totient_mul (coprime_of_largestPrimeFactor_lt ha hp htop), Nat.totient_prime hp] · rw [largestPrimeFactor_mul hp.pos ha, largestPrimeFactor_prime hp, max_eq_left htop.le] /- The finite-prime reciprocal-tail lemma (Lemma 5 of the manuscript). -/ /- Original line 172: Erdos416Proof.invTotient -/ noncomputable def invTotient (n : ℕ) : ℝ := (n.totient : ℝ)⁻¹ /- Original line 174: Erdos416Proof.invTotient_one -/ theorem invTotient_one : invTotient 1 = 1 := by simp [invTotient] /- Original line 177: Erdos416Proof.invTotient_nonneg -/ theorem invTotient_nonneg (n : ℕ) : 0 ≤ invTotient n := by unfold invTotient positivity /- Original line 181: Erdos416Proof.invTotient_mul -/ theorem invTotient_mul {m n : ℕ} (h : m.Coprime n) : invTotient (m * n) = invTotient m * invTotient n := by simp [Erdos416Proof.invTotient_one, invTotient, Nat.totient_mul h, mul_comm] /- Original line 185: Erdos416Proof.invTotient_prime_pow_succ -/ theorem invTotient_prime_pow_succ {p : ℕ} (hp : p.Prime) (e : ℕ) : invTotient (p ^ (e + 1)) = ((p : ℝ) - 1)⁻¹ * ((p : ℝ)⁻¹) ^ e := by simp [Erdos416Proof.invTotient_one, invTotient, Nat.totient_prime_pow_succ hp, Nat.cast_sub hp.one_le, mul_comm] /- Original line 190: Erdos416Proof.hasSum_invTotient_prime_pow -/ theorem hasSum_invTotient_prime_pow {p : ℕ} (hp : p.Prime) : HasSum (fun e : ℕ => invTotient (p ^ e)) (1 + (p : ℝ) / ((p : ℝ) - 1) ^ 2) := by have hp1 : 1 < (p : ℝ) := by exact_mod_cast hp.one_lt have hp0 : 0 < (p : ℝ) := by linarith have hpinv : (p : ℝ)⁻¹ < 1 := by exact (inv_lt_one₀ hp0).mpr hp1 have hgeo := (hasSum_geometric_of_lt_one (inv_nonneg.mpr hp0.le) hpinv).mul_left (((p : ℝ) - 1)⁻¹) have halgebra : ((p : ℝ) - 1)⁻¹ * (1 - (p : ℝ)⁻¹)⁻¹ = (p : ℝ) / ((p : ℝ) - 1) ^ 2 := by have hpne : (p : ℝ) ≠ 0 := ne_of_gt hp0 have hpne1 : (p : ℝ) - 1 ≠ 0 := by linarith field_simp rw [halgebra] at hgeo have htail : HasSum (fun e : ℕ => invTotient (p ^ (e + 1))) ((p : ℝ) / ((p : ℝ) - 1) ^ 2) := by simpa only [invTotient_prime_pow_succ hp] using hgeo simpa only [Finset.sum_range_one, pow_zero, invTotient_one, add_comm] using (hasSum_nat_add_iff (f := fun e : ℕ => invTotient (p ^ e)) 1).mp htail /- Original line 211: Erdos416Proof.summable_invTotient_factored -/ theorem summable_invTotient_factored (s : Finset ℕ) : Summable (fun n : Nat.factoredNumbers s => invTotient n) := by have h := EulerProduct.summable_and_hasSum_factoredNumbers_prod_filter_prime_tsum invTotient_one (@invTotient_mul) (fun hp => (hasSum_invTotient_prime_pow hp).summable.norm) s exact h.1.of_norm /- Original line 218: Erdos416Proof.tsum_invTotient_factored -/ theorem tsum_invTotient_factored (s : Finset ℕ) : (∑' n : Nat.factoredNumbers s, invTotient n) = ∏ p ∈ s with p.Prime, (1 + (p : ℝ) / ((p : ℝ) - 1) ^ 2) := by have h := EulerProduct.summable_and_hasSum_factoredNumbers_prod_filter_prime_tsum invTotient_one (@invTotient_mul) (fun hp => (hasSum_invTotient_prime_pow hp).summable.norm) s rw [h.2.tsum_eq] apply Finset.prod_congr rfl intro p hp exact (hasSum_invTotient_prime_pow (Finset.mem_filter.mp hp).2).tsum_eq /- Original line 229: Erdos416Proof.invTotient_factored_tail -/ theorem invTotient_factored_tail (s : Finset ℕ) {ε : ℝ} (hε : 0 < ε) : ∃ R : ℕ, ∀ t : Finset ℕ, (∀ n ∈ t, n ∈ Nat.factoredNumbers s) → (∀ n ∈ t, R < n) → ∑ n ∈ t, invTotient n < ε := by classical have hs : Summable ((Nat.factoredNumbers s).indicator invTotient) := summable_subtype_iff_indicator.mp (summable_invTotient_factored s) obtain ⟨t₀, ht₀⟩ := summable_iff_vanishing_norm.mp hs ε hε refine ⟨t₀.sup id, fun t ht htR => ?_⟩ have hdis : Disjoint t t₀ := by apply Finset.disjoint_left.mpr intro n hnt hn₀ exact (not_lt_of_ge (Finset.le_sup (f := id) hn₀)) (htR n hnt) have hbound := ht₀ t hdis have hsum : (∑ n ∈ t, (Nat.factoredNumbers s).indicator invTotient n) = ∑ n ∈ t, invTotient n := by apply Finset.sum_congr rfl intro n hn exact Set.indicator_of_mem (ht n hn) _ rw [hsum, Real.norm_eq_abs, abs_of_nonneg (Finset.sum_nonneg fun n _ => invTotient_nonneg n)] at hbound exact hbound /- Original line 253: Erdos416Proof.bounded_prime_tail -/ theorem bounded_prime_tail {P : ℕ} (hP : 1 ≤ P) {ε : ℝ} (hε : 0 < ε) : ∃ R : ℕ, ∀ t : Finset ℕ, (∀ n ∈ t, 0 < n ∧ largestPrimeFactor n ≤ P) → (∀ n ∈ t, R < n) → ∑ n ∈ t, (n.totient : ℝ)⁻¹ < ε := by obtain ⟨R, hR⟩ := invTotient_factored_tail (Finset.range (P + 1)) hε refine ⟨R, fun t ht htR => hR t ?_ htR⟩ intro n hn exact (mem_factored_range_iff hP).mpr (ht n hn) /- Finite witness assignment used before the collision sieve. -/ /- Original line 265: Erdos416Proof.HasPeer -/ def HasPeer {α β : Type*} (f : α → β) (a : α) : Prop := ∃ b, f b = f a ∧ b ≠ a /- Original line 268: Erdos416Proof.exists_fiber_permutation -/ theorem exists_fiber_permutation {α β : Type*} [Fintype α] (f : α → β) : ∃ π : Equiv.Perm α, (∀ a, f (π a) = f a) ∧ ∀ a, HasPeer f a → π a ≠ a := by classical have hfib : ∀ b : β, ∃ σ : Equiv.Perm {a : α // f a = b}, ∀ x y, x ≠ y → σ x ≠ x := by intro b obtain ⟨σ, hσ, _⟩ := (Finset.univ : Finset {a : α // f a = b}).exists_cycleOn refine ⟨σ, fun x y hxy => hσ.apply_ne ?_ (by simp)⟩ exact ⟨x, by simp, y, by simp, hxy⟩ choose σ hσ using hfib let e := Equiv.sigmaFiberEquiv f let π : Equiv.Perm α := e.symm.trans ((Equiv.sigmaCongrRight σ).trans e) refine ⟨π, ?_, ?_⟩ · intro a change f (σ (f a) ⟨a, rfl⟩).val = f a exact (σ (f a) ⟨a, rfl⟩).property · intro a ⟨b, hfb, hba⟩ hπ have hne : (⟨a, rfl⟩ : {a' : α // f a' = f a}) ≠ ⟨b, hfb⟩ := by intro h exact hba (congrArg Subtype.val h).symm apply hσ (f a) ⟨a, rfl⟩ ⟨b, hfb⟩ hne apply Subtype.ext exact hπ /-- Cyclic witnesses on nonsingleton fibres and arbitrary witnesses on singleton fibres can be combined without losing injectivity. -/ /- Original line 296: Erdos416Proof.exists_injective_witness -/ theorem exists_injective_witness {α β γ : Type*} [Fintype α] (f : α → β) (g : γ → β) (canonical : α → γ) (hcanonical : Function.Injective canonical) (hvalue : ∀ a, g (canonical a) = f a) (relation : α → γ → Prop) (hpeer : ∀ a b, f b = f a → b ≠ a → relation a (canonical b)) (hwitness : ∀ a, ∃ z, g z = f a ∧ relation a z) : ∃ w : α → γ, Function.Injective w ∧ (∀ a, g (w a) = f a ∧ relation a (w a)) ∧ ∀ a, HasPeer f a → ∃ b, w a = canonical b := by classical obtain ⟨π, hπvalue, hπmove⟩ := exists_fiber_permutation f choose initial hinitialValue hinitialRel using hwitness let w : α → γ := fun a => if HasPeer f a then canonical (π a) else initial a have hwvalue (a : α) : g (w a) = f a := by by_cases ha : HasPeer f a · simp only [w, if_pos ha, hvalue, hπvalue] · simp only [w, if_neg ha, hinitialValue] refine ⟨w, ?_, ?_, ?_⟩ · intro a b hab by_cases heq : a = b · exact heq have hfab : f a = f b := by rw [← hwvalue a, ← hwvalue b, hab] have ha : HasPeer f a := ⟨b, hfab.symm, Ne.symm heq⟩ have hb : HasPeer f b := ⟨a, hfab, heq⟩ apply π.injective apply hcanonical simpa only [w, if_pos ha, if_pos hb] using hab · intro a refine ⟨hwvalue a, ?_⟩ by_cases ha : HasPeer f a · simpa only [w, if_pos ha] using hpeer a (π a) (hπvalue a) (hπmove a ha) · simpa only [w, if_neg ha] using hinitialRel a · intro a ha exact ⟨π a, by simp only [w, if_pos ha]⟩ /- Original line 333: Erdos416Proof.value_injective_on_singleton_fibres -/ theorem value_injective_on_singleton_fibres {α β : Type*} (f : α → β) : Set.InjOn f {a | ¬ HasPeer f a} := by intro a ha b _ hab by_contra hne exact ha ⟨b, hab.symm, Ne.symm hne⟩ open scoped Classical in /- Original line 340: Erdos416Proof.collisionPoints -/ noncomputable def collisionPoints {α β : Type*} (s : Finset α) (f : α → β) : Finset α := s.filter fun a => ∃ b ∈ s, b ≠ a ∧ f b = f a /- Original line 344: Erdos416Proof.injective_off_collisionPoints -/ theorem injective_off_collisionPoints {α β : Type*} (s : Finset α) (f : α → β) : Set.InjOn f ↑(s \ collisionPoints s f) := by classical intro a ha b hb hab simp only [Finset.mem_coe, Finset.mem_sdiff] at ha hb by_contra hne apply ha.2 exact Finset.mem_filter.mpr ⟨ha.1, b, hb.1, Ne.symm hne, hab.symm⟩ /- Original line 353: Erdos416Proof.card_le_of_injective_off_bad -/ theorem card_le_of_injective_off_bad {α β : Type*} (s bad : Finset α) (t : Finset β) (f : α → β) (hmap : ∀ a ∈ s, f a ∈ t) (hinj : Set.InjOn f ↑(s \ bad)) : s.card ≤ t.card + bad.card := by classical have hgood : (s \ bad).card ≤ t.card := by apply Finset.card_le_card_of_injOn f ?_ hinj intro a ha exact hmap a (Finset.mem_sdiff.mp ha).1 have hpart := Finset.card_sdiff_add_card_inter s bad have hbad : (s ∩ bad).card ≤ bad.card := Finset.card_le_card Finset.inter_subset_right omega open MeasureTheory open scoped Pointwise /- Original line 371: Erdos416Proof.one_sub_pow_le -/ theorem one_sub_pow_le (n : ℕ) {t : ℝ} (ht₀ : 0 ≤ t) (ht₁ : t ≤ 1) : 1 - t ^ n ≤ n * (1 - t) := by induction n with | zero => simp | succ n ih => have hp : t ^ n ≤ 1 := pow_le_one₀ ht₀ ht₁ have hterm : t ^ n * (1 - t) ≤ 1 - t := mul_le_of_le_one_left (sub_nonneg.mpr ht₁) hp rw [pow_succ, Nat.cast_add, Nat.cast_one] nlinarith /- Original line 382: Erdos416Proof.volume_real_smul_nonneg -/ theorem volume_real_smul_nonneg {L : ℕ} {t : ℝ} (ht : 0 ≤ t) (K : Set (Fin L → ℝ)) : volume.real (t • K) = t ^ L * volume.real K := by simp only [measureReal_def, Measure.addHaar_smul_of_nonneg volume ht, Module.finrank_pi, Fintype.card_fin, ENNReal.toReal_mul, ENNReal.toReal_ofReal (pow_nonneg ht L)] /-- The part of a convex body above a linear cutoff avoids an inner dilation. -/ /- Original line 390: Erdos416Proof.outer_shell_volume -/ theorem outer_shell_volume {L : ℕ} (K : Set (Fin L → ℝ)) (hK : IsCompact K) (hconv : Convex ℝ K) (hzero : 0 ∈ K) (A : (Fin L → ℝ) →ₗ[ℝ] ℝ) {b c t : ℝ} (ht₀ : 0 ≤ t) (ht₁ : t ≤ 1) (hbound : ∀ x ∈ K, A x ≤ b) (hcut : t * b ≤ c) : volume.real (K ∩ {x | c < A x}) ≤ (1 - t ^ L) * volume.real K := by have hscaled : t • K ⊆ K := by rintro x ⟨y, hy, rfl⟩ exact hconv.smul_mem_of_zero_mem hzero hy ⟨ht₀, ht₁⟩ have hcompact : IsCompact (t • K) := hK.image (continuous_id.const_smul t) have hfinite : volume K ≠ ⊤ := hK.measure_lt_top.ne have hshell : K ∩ {x | c < A x} ⊆ K \ (t • K) := by rintro x ⟨hx, hcx⟩ refine ⟨hx, ?_⟩ rintro ⟨z, hz, rfl⟩ have hzbound := (mul_le_mul_of_nonneg_left (hbound z hz) ht₀).trans hcut simp only [Set.mem_ofPred_eq, map_smul, smul_eq_mul] at hcx exact not_lt_of_ge hzbound hcx calc volume.real (K ∩ {x | c < A x}) ≤ volume.real (K \ (t • K)) := measureReal_mono hshell (measure_ne_top_of_subset Set.sdiff_subset hfinite) _ = volume.real K - volume.real (t • K) := measureReal_sdiff hscaled hcompact.measurableSet hfinite _ = (1 - t ^ L) * volume.real K := by rw [volume_real_smul_nonneg ht₀] ring /- Original line 418: Erdos416Proof.outer_shell_volume_linear -/ theorem outer_shell_volume_linear {L : ℕ} (K : Set (Fin L → ℝ)) (hK : IsCompact K) (hconv : Convex ℝ K) (hzero : 0 ∈ K) (A : (Fin L → ℝ) →ₗ[ℝ] ℝ) {b c t : ℝ} (ht₀ : 0 ≤ t) (ht₁ : t ≤ 1) (hbound : ∀ x ∈ K, A x ≤ b) (hcut : t * b ≤ c) : volume.real (K ∩ {x | c < A x}) ≤ L * (1 - t) * volume.real K := (outer_shell_volume K hK hconv hzero A ht₀ ht₁ hbound hcut).trans (mul_le_mul_of_nonneg_right (one_sub_pow_le L ht₀ ht₁) (measureReal_nonneg)) /-- Explicit form of the shell estimate, including thickening in an arbitrary compact convex symmetric-error set. -/ /- Original line 429: Erdos416Proof.thickened_outer_shell_volume -/ theorem thickened_outer_shell_volume {L : ℕ} (hL : 1 ≤ L) (E D : Set (Fin L → ℝ)) (hE : IsCompact E) (hD : IsCompact D) (hconvE : Convex ℝ E) (hconvD : Convex ℝ D) (hzeroE : 0 ∈ E) (hzeroD : 0 ∈ D) (A : (Fin L → ℝ) →ₗ[ℝ] ℝ) {ξ δ η : ℝ} (hξ : 1 ≤ ξ) (hδ : 0 ≤ δ) (hη : 0 ≤ η) (hbound : ∀ x ∈ E, A x ≤ ξ) (herror : ∀ z ∈ D, |A z| ≤ η) : volume.real ((E ∩ {x | 1 - δ < A x}) + D) ≤ 2 * L * (δ + ξ - 1 + η) * volume.real (E + D) := by let K := E + D have hcompact : IsCompact K := hE.add hD have hconv : Convex ℝ K := hconvE.add hconvD have hzero : 0 ∈ K := by simpa only [zero_add] using Set.add_mem_add hzeroE hzeroD have hfinite : volume K ≠ ⊤ := hcompact.measure_lt_top.ne have hKbound : ∀ x ∈ K, A x ≤ ξ + η := by rintro x ⟨u, hu, z, hz, rfl⟩ rw [map_add] exact add_le_add (hbound u hu) (abs_le.mp (herror z hz)).2 have hshell : (E ∩ {x | 1 - δ < A x}) + D ⊆ K ∩ {x | 1 - δ - η < A x} := by rintro x ⟨u, ⟨hu, hAu⟩, z, hz, rfl⟩ refine ⟨Set.add_mem_add hu hz, ?_⟩ change 1 - δ - η < A (u + z) rw [map_add] have hzlower := (abs_le.mp (herror z hz)).1 change 1 - δ < A u at hAu linarith have hsubset : (E ∩ {x | 1 - δ < A x}) + D ⊆ K := hshell.trans Set.inter_subset_left have hnonneg : 0 ≤ volume.real K := measureReal_nonneg have hLreal : (1 : ℝ) ≤ L := by exact_mod_cast hL have htotal : 0 ≤ δ + ξ - 1 + η := by linarith by_cases hc : 0 < 1 - δ - η · have hb : 0 < ξ + η := by linarith let t := (1 - δ - η) / (ξ + η) have ht₀ : 0 ≤ t := (div_pos hc hb).le have ht₁ : t ≤ 1 := (div_le_one hb).mpr (by linarith) have hcut : t * (ξ + η) ≤ 1 - δ - η := by exact le_of_eq (div_mul_cancel₀ _ hb.ne') have hwidth : 1 - t ≤ 2 * (δ + ξ - 1 + η) := by have htprod : t * (ξ + η) = 1 - δ - η := div_mul_cancel₀ _ hb.ne' have hb₁ : 1 ≤ ξ + η := by linarith have hpositive : 0 ≤ 1 - t := sub_nonneg.mpr ht₁ have hproduct := mul_le_mul_of_nonneg_left hb₁ hpositive nlinarith calc volume.real ((E ∩ {x | 1 - δ < A x}) + D) ≤ volume.real (K ∩ {x | 1 - δ - η < A x}) := measureReal_mono hshell (measure_ne_top_of_subset Set.inter_subset_left hfinite) _ ≤ L * (1 - t) * volume.real K := outer_shell_volume_linear K hcompact hconv hzero A ht₀ ht₁ hKbound hcut _ ≤ 2 * L * (δ + ξ - 1 + η) * volume.real K := by apply mul_le_mul_of_nonneg_right _ hnonneg nlinarith [mul_le_mul_of_nonneg_left hwidth (by positivity : (0 : ℝ) ≤ L)] · have hone : 1 ≤ δ + ξ - 1 + η := by linarith have hfactor : 1 ≤ 2 * L * (δ + ξ - 1 + η) := by nlinarith calc volume.real ((E ∩ {x | 1 - δ < A x}) + D) ≤ volume.real K := measureReal_mono hsubset hfinite _ ≤ 2 * L * (δ + ξ - 1 + η) * volume.real K := le_mul_of_one_le_left hnonneg hfactor /- Original line 494: Erdos416Proof.weightedForm -/ def weightedForm {L : ℕ} (a : Fin L → ℝ) : (Fin L → ℝ) →ₗ[ℝ] ℝ where toFun x := ∑ idx, a idx * x idx map_add' x y := by simp [mul_add, Finset.sum_add_distrib] map_smul' t x := by simp [Finset.mul_sum, mul_left_comm] /- Original line 499: Erdos416Proof.weightedForm_apply -/ theorem weightedForm_apply {L : ℕ} (a x : Fin L → ℝ) : weightedForm a x = ∑ idx, a idx * x idx := rfl /- Original line 502: Erdos416Proof.errorCube -/ def errorCube (L : ℕ) (τ : ℝ) : Set (Fin L → ℝ) := Set.Icc (fun _ => -τ) (fun _ => τ) /- Original line 505: Erdos416Proof.weightedForm_errorCube_bound -/ theorem weightedForm_errorCube_bound {L : ℕ} (a : Fin L → ℝ) (ha : ∀ idx, 0 ≤ a idx) {τ : ℝ} {z : Fin L → ℝ} (hz : z ∈ errorCube L τ) : |weightedForm a z| ≤ (∑ idx, a idx) * τ := by change |∑ idx, a idx * z idx| ≤ _ calc |∑ idx, a idx * z idx| ≤ ∑ idx, |a idx * z idx| := Finset.abs_sum_le_sum_abs _ _ _ ≤ ∑ idx, a idx * τ := by apply Finset.sum_le_sum intro idx _ rw [abs_mul, abs_of_nonneg (ha idx)] exact mul_le_mul_of_nonneg_left (abs_le.mpr ⟨hz.1 idx, hz.2 idx⟩) (ha idx) _ = (∑ idx, a idx) * τ := (Finset.sum_mul _ _ _).symm /- Original line 518: Erdos416Proof.thickened_outer_shell_cube -/ theorem thickened_outer_shell_cube {L : ℕ} (hL : 1 ≤ L) (E : Set (Fin L → ℝ)) (hE : IsCompact E) (hconvE : Convex ℝ E) (hzeroE : 0 ∈ E) (a : Fin L → ℝ) (ha : ∀ idx, 0 ≤ a idx) {ξ δ τ : ℝ} (hξ : 1 ≤ ξ) (hδ : 0 ≤ δ) (hτ : 0 ≤ τ) (hbound : ∀ x ∈ E, weightedForm a x ≤ ξ) : volume.real ((E ∩ {x | 1 - δ < weightedForm a x}) + errorCube L τ) ≤ 2 * L * (δ + ξ - 1 + (∑ idx, a idx) * τ) * volume.real (E + errorCube L τ) := by have hzeroD : (0 : Fin L → ℝ) ∈ errorCube L τ := by exact ⟨fun _ => neg_nonpos.mpr hτ, fun _ => hτ⟩ exact thickened_outer_shell_volume hL E (errorCube L τ) hE isCompact_Icc hconvE (convex_Icc _ _) hzeroE hzeroD (weightedForm a) hξ hδ (mul_nonneg (Finset.sum_nonneg fun idx _ => ha idx) hτ) hbound (fun _ hz => weightedForm_errorCube_bound a ha hz) /-- The elementary last step only; this does not establish the totient estimates. -/ /- Original line 536: Erdos416Proof.ratio_error_bound -/ theorem ratio_error_bound {v w a b δ : ℝ} (hv : 0 < v) (hδ : 0 ≤ δ) (hsmall : δ ≤ 1 / 4) (ha₁ : (1 - δ) * v ≤ a) (ha₂ : a ≤ (1 + δ) * v) (hb₁ : (1 - δ) * w ≤ b) (hb₂ : b ≤ (1 + δ) * w) (hscale₁ : (2 - δ) * a ≤ b) (hscale₂ : b ≤ (2 + δ) * a) : |w / v - 2| ≤ 8 * δ := by have h₁ : 0 < 1 - δ := by linarith have h₂ : 0 < 1 + δ := by linarith have hδv : 0 ≤ δ * v := mul_nonneg hδ hv.le have hδδv : 0 ≤ δ ^ 2 * v := mul_nonneg (sq_nonneg δ) hv.le have hsmallv : δ ^ 2 * v ≤ (δ * v) / 4 := by nlinarith [mul_nonneg (sub_nonneg.mpr hsmall) hδv] have hl : (2 - 8 * δ) * v ≤ w := by apply le_of_mul_le_mul_left (a := 1 + δ) (a0 := h₂) calc (1 + δ) * ((2 - 8 * δ) * v) ≤ (2 - δ) * ((1 - δ) * v) := by nlinarith _ ≤ (2 - δ) * a := mul_le_mul_of_nonneg_left ha₁ (by linarith) _ ≤ b := hscale₁ _ ≤ (1 + δ) * w := hb₂ have hu : w ≤ (2 + 8 * δ) * v := by apply le_of_mul_le_mul_left (a := 1 - δ) (a0 := h₁) calc (1 - δ) * w ≤ b := hb₁ _ ≤ (2 + δ) * a := hscale₂ _ ≤ (2 + δ) * ((1 + δ) * v) := mul_le_mul_of_nonneg_left ha₂ (by linarith) _ ≤ (1 - δ) * ((2 + 8 * δ) * v) := by nlinarith have hlo : 2 - 8 * δ ≤ w / v := (le_div_iff₀ hv).mpr hl have hhi : w / v ≤ 2 + 8 * δ := (div_le_iff₀ hv).mpr hu exact abs_le.mpr ⟨by linarith, by linarith⟩ /-- A conditional reduction to the pair-count estimates proposed in the manuscript. The hypothesis `hcounts` is substantial and is NOT proved in this file. -/ /- Original line 570: Erdos416Proof.doubling_of_pair_counts -/ theorem doubling_of_pair_counts (V : ℝ → ℝ) (hcounts : ∀ δ : ℝ, 0 < δ → ∀ᶠ x in atTop, ∃ a b : ℝ, 0 < V x ∧ (1 - δ) * V x ≤ a ∧ a ≤ (1 + δ) * V x ∧ (1 - δ) * V (2 * x) ≤ b ∧ b ≤ (1 + δ) * V (2 * x) ∧ (2 - δ) * a ≤ b ∧ b ≤ (2 + δ) * a) : Tendsto (fun x => V (2 * x) / V x) atTop (𝓝 2) := by apply Metric.tendsto_nhds.mpr intro ε hε let δ : ℝ := min (1 / 4) (ε / 16) have hδ : 0 < δ := lt_min (by norm_num) (by positivity) have hsmall : δ ≤ 1 / 4 := min_le_left _ _ have hεbound : 8 * δ < ε := by have : δ ≤ ε / 16 := min_le_right _ _ linarith filter_upwards [hcounts δ hδ] with x hx rcases hx with ⟨a, b, hv, ha₁, ha₂, hb₁, hb₂, hs₁, hs₂⟩ rw [Real.dist_eq] exact lt_of_le_of_lt (ratio_error_bound hv hδ.le hsmall ha₁ ha₂ hb₁ hb₂ hs₁ hs₂) hεbound /-- Prime factors in the half-open interval (u, v], counted with multiplicity. -/ /- Original line 594: Erdos416Proof.omegaInterval -/ noncomputable def omegaInterval (n : ℕ) (u v : ℝ) : ℕ := n.primeFactorsList.countP (fun p : ℕ => decide (u < (p : ℝ) ∧ (p : ℝ) ≤ v)) /- Original line 597: Erdos416Proof.omegaInterval_one -/ theorem omegaInterval_one (u v : ℝ) : omegaInterval 1 u v = 0 := by simp [omegaInterval] /- Original line 600: Erdos416Proof.omegaInterval_mul -/ theorem omegaInterval_mul {m n : ℕ} (hm : m ≠ 0) (hn : n ≠ 0) (u v : ℝ) : omegaInterval (m * n) u v = omegaInterval m u v + omegaInterval n u v := by unfold omegaInterval rw [(Nat.perm_primeFactorsList_mul hm hn).countP_eq, List.countP_append] /- Original line 605: Erdos416Proof.omegaInterval_prod -/ theorem omegaInterval_prod {ι : Type*} (s : Finset ι) (f : ι → ℕ) (hf : ∀ idx ∈ s, f idx ≠ 0) (u v : ℝ) : omegaInterval (∏ idx ∈ s, f idx) u v = ∑ idx ∈ s, omegaInterval (f idx) u v := by classical induction s using Finset.induction with | empty => simp[Erdos416Proof.omegaInterval_one] | @insert idx s hi ih => have hs : ∀ j ∈ s, f j ≠ 0 := fun j hj => hf j (Finset.mem_insert_of_mem hj) rw [Finset.prod_insert hi, omegaInterval_mul (hf idx (Finset.mem_insert_self _ _)) (Finset.prod_ne_zero_iff.mpr hs), ih hs, Finset.sum_insert hi] /- Original line 616: Erdos416Proof.omegaInterval_eq_zero_of_support -/ theorem omegaInterval_eq_zero_of_support {n : ℕ} {u v : ℝ} (h : ∀ p ∈ n.primeFactorsList, (p : ℝ) ≤ u) : omegaInterval n u v = 0 := by unfold omegaInterval apply List.countP_eq_zero.mpr intro p hp simp only [decide_eq_true_eq] exact fun hmem => not_lt_of_ge (h p hp) hmem.1 /- Original line 625: Erdos416Proof.omegaInterval_eq_zero_of_bounds -/ theorem omegaInterval_eq_zero_of_bounds (n : ℕ) {u v : ℝ} (h : v ≤ u) : omegaInterval n u v = 0 := by unfold omegaInterval apply List.countP_eq_zero.mpr intro p _ simp only [decide_eq_true_eq] exact fun hmem => not_lt_of_ge (hmem.2.trans h) hmem.1 /- Original line 633: Erdos416Proof.omegaInterval_nonneg -/ theorem omegaInterval_nonneg (n : ℕ) (u v : ℝ) : (0 : ℝ) ≤ omegaInterval n u v := Nat.cast_nonneg _ /- Original line 636: Erdos416Proof.omegaInterval_le_cardFactors -/ theorem omegaInterval_le_cardFactors (n : ℕ) (u v : ℝ) : omegaInterval n u v ≤ ArithmeticFunction.cardFactors n := List.countP_le_length /-- Ford's normality predicate with its actual prime-factor counting function. -/ /- Original line 641: Erdos416Proof.SNormal -/ def SNormal (S : ℝ) (p : ℕ) : Prop := p.Prime ∧ (omegaInterval (p - 1) 1 S : ℝ) ≤ 2 * Real.log (Real.log S) ∧ ∀ u v : ℝ, S ≤ u → u < v → v ≤ (p - 1 : ℕ) → |(omegaInterval (p - 1) u v : ℝ) - (Real.log (Real.log v) - Real.log (Real.log u))| < Real.sqrt (Real.log (Real.log S) * Real.log (Real.log v)) /- Original line 649: Erdos416Proof.SNormal_of_small_prime -/ theorem SNormal_of_small_prime {S : ℝ} {p : ℕ} (hp : p.Prime) (hsmall : (p : ℝ) ≤ S) (hcount : (ArithmeticFunction.cardFactors (p - 1) : ℝ) ≤ 2 * Real.log (Real.log S)) : SNormal S p := by refine ⟨hp, ?_, ?_⟩ · have hle : (omegaInterval (p - 1) 1 S : ℝ) ≤ ArithmeticFunction.cardFactors (p - 1) := by exact_mod_cast omegaInterval_le_cardFactors (p - 1) 1 S exact hle.trans hcount · intro u v hSu huv hv have hp₁ : ((p - 1 : ℕ) : ℝ) < p := by exact_mod_cast Nat.sub_lt hp.pos (by decide) linarith /- Original line 663: Erdos416Proof.eventually_fixed_prime_normal -/ theorem eventually_fixed_prime_normal {p : ℕ} (hp : p.Prime) : ∀ᶠ S : ℝ in atTop, SNormal S p := by have hlog : Tendsto (fun S : ℝ => 2 * Real.log (Real.log S)) atTop atTop := Tendsto.const_mul_atTop (by norm_num) (Real.tendsto_log_atTop.comp Real.tendsto_log_atTop) filter_upwards [eventually_ge_atTop (p : ℝ), hlog.eventually (eventually_ge_atTop (ArithmeticFunction.cardFactors (p - 1) : ℝ))] with S hpS hcount exact SNormal_of_small_prime hp hpS hcount /-- The elementary contradiction used when the two ordered lists fail to match. -/ /- Original line 673: Erdos416Proof.interval_matching_gap_bound -/ theorem interval_matching_gap_bound {idx : ℕ} {gap δ T mass : ℝ} (hT : 0 < T) (hlower : (idx + 1 : ℝ) * (gap - δ) * T ≤ mass) (hupper : mass ≤ (idx : ℝ) * (gap + δ) * T) : gap ≤ (2 * idx + 1) * δ := by have h := (mul_le_mul_iff_of_pos_right hT).mp (hlower.trans hupper) nlinarith /- The finite single-scale construction, with the actual totient value map. -/ /- Original line 683: Erdos416Proof.corePairValue -/ def corePairValue (bp : ℕ × ℕ) : ℕ := (bp.2 - 1) * bp.1 /- Original line 685: Erdos416Proof.corePairs -/ noncomputable def corePairs (cores : Finset ℕ) (lo hi : ℝ) : Finset (ℕ × ℕ) := (cores.product (Finset.range (⌊hi⌋₊ + 2))).filter fun bp => bp.2.Prime ∧ lo < (corePairValue bp : ℝ) ∧ (corePairValue bp : ℝ) ≤ hi /- Original line 689: Erdos416Proof.mem_corePairs -/ theorem mem_corePairs {cores : Finset ℕ} {lo hi : ℝ} (hhi : 0 ≤ hi) (hcores : ∀ b ∈ cores, 0 < b) {bp : ℕ × ℕ} : bp ∈ corePairs cores lo hi ↔ bp.1 ∈ cores ∧ bp.2.Prime ∧ lo < (corePairValue bp : ℝ) ∧ (corePairValue bp : ℝ) ≤ hi := by rcases bp with ⟨b, p⟩ simp only [corePairs, Finset.mem_filter, Finset.product_eq_sprod, Finset.mem_product, Finset.mem_range] constructor · rintro ⟨⟨hb, _⟩, hp, hlo, hupper⟩ exact ⟨hb, hp, hlo, hupper⟩ · rintro ⟨hb, hp, hlo, hupper⟩ refine ⟨⟨hb, ?_⟩, hp, hlo, hupper⟩ have hbpos := hcores b hb have hfloor := (Nat.le_floor_iff hhi).mpr hupper have hle : p - 1 ≤ corePairValue (b, p) := by unfold corePairValue nlinarith omega /- Original line 708: Erdos416Proof.corePairValue_pos -/ theorem corePairValue_pos {bp : ℕ × ℕ} (hb : 0 < bp.1) (hp : bp.2.Prime) : 0 < corePairValue bp := Nat.mul_pos (by have := hp.one_lt; omega) hb /- Original line 712: Erdos416Proof.corePair_eq_of_same_prime -/ theorem corePair_eq_of_same_prime {a b : ℕ × ℕ} (ha : a.2.Prime) (hprime : a.2 = b.2) (hvalue : corePairValue a = corePairValue b) : a = b := by apply Prod.ext _ hprime unfold corePairValue at hvalue rw [← hprime] at hvalue exact mul_left_cancel₀ (by have := ha.one_lt; omega : a.2 - 1 ≠ 0) hvalue /- Original line 720: Erdos416Proof.corePair_distinct_primes_of_collision -/ theorem corePair_distinct_primes_of_collision {a b : ℕ × ℕ} (ha : a.2.Prime) (hne : a ≠ b) (hvalue : corePairValue a = corePairValue b) : a.2 ≠ b.2 := fun hp => hne (corePair_eq_of_same_prime ha hp hvalue) /- Original line 725: Erdos416Proof.corePairValue_is_totient -/ theorem corePairValue_is_totient {bp : ℕ × ℕ} (hp : bp.2.Prime) {a : ℕ} (ha : 0 < a) (hvalue : a.totient = bp.1) (htop : largestPrimeFactor a < bp.2) : ∃ n : ℕ, 0 < n ∧ n.totient = corePairValue bp := by refine ⟨bp.2 * a, Nat.mul_pos hp.pos ha, ?_⟩ rw [(top_prime_extension ha hp htop).1, hvalue] rfl /- Original line 733: Erdos416Proof.corePairs_card_le_V_add_collisions -/ theorem corePairs_card_le_V_add_collisions {cores : Finset ℕ} {lo hi : ℝ} (hhi : 0 ≤ hi) (hcores : ∀ b ∈ cores, 0 < b) (hrecords : ∀ bp ∈ corePairs cores lo hi, ∃ a : ℕ, 0 < a ∧ a.totient = bp.1 ∧ largestPrimeFactor a < bp.2) : ((corePairs cores lo hi).card : ℝ) ≤ V hi + (collisionPoints (corePairs cores lo hi) corePairValue).card := by have hmap : ∀ bp ∈ corePairs cores lo hi, corePairValue bp ∈ totientsUpTo hi := by intro bp hbp obtain ⟨hb, hp, _, hupper⟩ := (mem_corePairs hhi hcores).mp hbp obtain ⟨a, ha, hvalue, htop⟩ := hrecords bp hbp exact (mem_totientsUpTo hhi).mpr ⟨corePairValue_pos (hcores _ hb) hp, hupper, corePairValue_is_totient hp ha hvalue htop⟩ have hcard := card_le_of_injective_off_bad (corePairs cores lo hi) (collisionPoints (corePairs cores lo hi) corePairValue) (totientsUpTo hi) corePairValue hmap (injective_off_collisionPoints (corePairs cores lo hi) corePairValue) unfold V exact_mod_cast hcard /- Original line 752: Erdos416Proof.V_le_corePairs_card_add_uncovered -/ theorem V_le_corePairs_card_add_uncovered (cores bad : Finset ℕ) (lo hi : ℝ) (hcoverage : ∀ m ∈ totientsUpTo hi \ bad, ∃ bp ∈ corePairs cores lo hi, corePairValue bp = m) : V hi ≤ ((corePairs cores lo hi).card : ℝ) + bad.card := by have hsurj : Set.SurjOn corePairValue ↑(corePairs cores lo hi) ↑(totientsUpTo hi \ bad) := by intro m hm obtain ⟨bp, hbp, hm⟩ := hcoverage m hm exact ⟨bp, hbp, hm⟩ have hgood := Finset.card_le_card_of_surjOn corePairValue hsurj have hpart := Finset.card_sdiff_add_card_inter (totientsUpTo hi) bad have hbad : ((totientsUpTo hi) ∩ bad).card ≤ bad.card := Finset.card_le_card Finset.inter_subset_right have hcard : (totientsUpTo hi).card ≤ (corePairs cores lo hi).card + bad.card := by omega unfold V exact_mod_cast hcard /- Original line 771: Erdos416Proof.RankedAt -/ def RankedAt {ι : Type*} [Preorder ι] (f : ι → ℕ) (idx : ι) : Prop := (∀ j, j ≤ idx → f idx ≤ f j) ∧ ∀ j, idx ≤ j → f j ≤ f idx /- Original line 774: Erdos416Proof.rankedAt_of_antitone -/ theorem rankedAt_of_antitone {ι : Type*} [Preorder ι] {f : ι → ℕ} (hf : Antitone f) (idx : ι) : RankedAt f idx := ⟨fun _ h => hf h, fun _ h => hf h⟩ /- Original line 778: Erdos416Proof.logLog -/ noncomputable def logLog (x : ℝ) : ℝ := Real.log (Real.log x) /- Original line 780: Erdos416Proof.logLog_mono -/ theorem logLog_mono {x y : ℝ} (hx : 1 < x) (hxy : x ≤ y) : logLog x ≤ logLog y := Real.log_le_log (Real.log_pos hx) (Real.log_le_log (by linarith) hxy) /- Original line 784: Erdos416Proof.logLog_nonneg -/ theorem logLog_nonneg {x : ℝ} (hx : Real.exp 1 ≤ x) : 0 ≤ logLog x := by have h := Real.log_le_log (Real.exp_pos 1) hx rw [Real.log_exp] at h exact Real.log_nonneg h /- Original line 789: Erdos416Proof.largestPrimeFactor_le -/ theorem largestPrimeFactor_le {n : ℕ} (hn : 0 < n) : largestPrimeFactor n ≤ n := by apply max_le hn apply Finset.sup_le intro p hp exact Nat.le_of_dvd hn (Nat.dvd_of_mem_primeFactors hp) /- Original line 795: Erdos416Proof.primeFactorsList_le_largestPrimeFactor -/ theorem primeFactorsList_le_largestPrimeFactor {n p : ℕ} (hp : p ∈ n.primeFactorsList) : p ≤ largestPrimeFactor n := by obtain ⟨hprime, hdvd, hn⟩ := Nat.mem_primeFactorsList'.mp hp exact prime_le_largestPrimeFactor (Nat.pos_of_ne_zero hn) hprime hdvd /- Original line 800: Erdos416Proof.omegaInterval_eq_zero_of_largestPrimeFactor_le -/ theorem omegaInterval_eq_zero_of_largestPrimeFactor_le (n : ℕ) {u v : ℝ} (hn : (largestPrimeFactor n : ℝ) ≤ u) : omegaInterval n u v = 0 := by apply omegaInterval_eq_zero_of_support intro p hp have hle : (p : ℝ) ≤ largestPrimeFactor n := by exact_mod_cast primeFactorsList_le_largestPrimeFactor hp exact hle.trans hn /- Original line 808: Erdos416Proof.omegaInterval_truncate -/ theorem omegaInterval_truncate (n : ℕ) (u : ℝ) {v : ℝ} (hn : (n : ℝ) ≤ v) : omegaInterval n u v = omegaInterval n u n := by apply List.countP_congr intro p hp simp only [decide_eq_true_eq] have hpn : (p : ℝ) ≤ n := by exact_mod_cast Nat.le_of_mem_primeFactorsList hp exact ⟨fun h => ⟨h.1, hpn⟩, fun h => ⟨h.1, h.2.trans hn⟩⟩ /- Original line 816: Erdos416Proof.SNormal.interval_bounds -/ theorem SNormal.interval_bounds {S T : ℝ} {p : ℕ} (hp : SNormal S p) (hS : Real.exp 1 ≤ S) {u v : ℝ} (hSu : S ≤ u) (huv : u < v) (hvT : logLog v ≤ T) (hvp : v ≤ (p - 1 : ℕ)) : logLog v - logLog u - Real.sqrt (logLog S * T) ≤ (omegaInterval (p - 1) u v : ℝ) ∧ (omegaInterval (p - 1) u v : ℝ) ≤ logLog v - logLog u + Real.sqrt (logLog S * T) := by have hnormal := hp.2.2 u v hSu huv hvp have herror : Real.sqrt (logLog S * logLog v) ≤ Real.sqrt (logLog S * T) := Real.sqrt_le_sqrt (mul_le_mul_of_nonneg_left hvT (logLog_nonneg hS)) have habs : |(omegaInterval (p - 1) u v : ℝ) - (logLog v - logLog u)| ≤ Real.sqrt (logLog S * T) := hnormal.le.trans herror constructor <;> have h := abs_le.mp habs <;> linarith /-- The normality upper bound remains valid when the interval is truncated at the full shifted prime p - 1. -/ /- Original line 833: Erdos416Proof.SNormal.interval_upper -/ theorem SNormal.interval_upper {S T : ℝ} {p : ℕ} (hp : SNormal S p) (hS : Real.exp 1 ≤ S) {u v : ℝ} (hSu : S ≤ u) (huv : u < v) (hvT : logLog v ≤ T) : (omegaInterval (p - 1) u v : ℝ) ≤ logLog v - logLog u + Real.sqrt (logLog S * T) := by have hSone : 1 < S := (Real.one_lt_exp_iff.mpr (by norm_num : (0 : ℝ) < 1)).trans_le hS have huone : 1 < u := hSone.trans_le hSu have hloguv : logLog u ≤ logLog v := logLog_mono huone huv.le by_cases hpu : ((p - 1 : ℕ) : ℝ) ≤ u · have hzero : omegaInterval (p - 1) u v = 0 := by apply omegaInterval_eq_zero_of_support intro q hq have hqp : (q : ℝ) ≤ (p - 1 : ℕ) := by exact_mod_cast Nat.le_of_mem_primeFactorsList hq exact hqp.trans hpu rw [hzero, Nat.cast_zero] linarith [Real.sqrt_nonneg (logLog S * T)] · have hup : u < ((p - 1 : ℕ) : ℝ) := lt_of_not_ge hpu by_cases hvp : v ≤ (p - 1 : ℕ) · exact (hp.interval_bounds hS hSu huv hvT hvp).2 · have hpv : ((p - 1 : ℕ) : ℝ) ≤ v := le_of_not_ge hvp have hlogpv : logLog (p - 1 : ℕ) ≤ logLog v := logLog_mono (huone.trans hup) hpv rw [omegaInterval_truncate (p - 1) u hpv] exact (hp.interval_bounds hS hSu hup (hlogpv.trans hvT) le_rfl).2.trans (by linarith) /- Original line 861: Erdos416Proof.SNormal.sum_interval_upper -/ theorem SNormal.sum_interval_upper {m : ℕ} (p : Fin m → ℕ) {S T u v : ℝ} (hp : ∀ j, SNormal S (p j)) (hS : Real.exp 1 ≤ S) (hSu : S ≤ u) (huv : u < v) (hvT : logLog v ≤ T) : (∑ j, (omegaInterval (p j - 1) u v : ℝ)) ≤ m * (logLog v - logLog u + Real.sqrt (logLog S * T)) := by calc (∑ j, (omegaInterval (p j - 1) u v : ℝ)) ≤ ∑ _j : Fin m, (logLog v - logLog u + Real.sqrt (logLog S * T)) := Finset.sum_le_sum fun j _ => (hp j).interval_upper hS hSu huv hvT _ = _ := by simp [Erdos416Proof.omegaInterval_one, mul_add] /- Original line 872: Erdos416Proof.SNormal.sum_interval_upper_of_tail -/ theorem SNormal.sum_interval_upper_of_tail {m : ℕ} (p : Fin m → ℕ) {S T u v : ℝ} (hp : ∀ j, SNormal S (p j)) (hS : Real.exp 1 ≤ S) (idx : Fin m) (hcut : ∀ j, idx ≤ j → (largestPrimeFactor (p j - 1) : ℝ) ≤ u) (hSu : S ≤ u) (huv : u < v) (hvT : logLog v ≤ T) : (∑ j, (omegaInterval (p j - 1) u v : ℝ)) ≤ idx.val * (logLog v - logLog u + Real.sqrt (logLog S * T)) := by have hrestrict : (∑ j ∈ Finset.Iio idx, (omegaInterval (p j - 1) u v : ℝ)) = ∑ j, (omegaInterval (p j - 1) u v : ℝ) := by apply Finset.sum_subset (Finset.subset_univ _) intro j _ hji have hij : idx ≤ j := le_of_not_gt (by simpa only [Finset.mem_Iio] using hji) rw [omegaInterval_eq_zero_of_largestPrimeFactor_le (p j - 1) (hcut j hij)] simp[Erdos416Proof.largestPrimeFactor_one, Erdos416Proof.omegaInterval_one] rw [← hrestrict] calc (∑ j ∈ Finset.Iio idx, (omegaInterval (p j - 1) u v : ℝ)) ≤ ∑ _j ∈ Finset.Iio idx, (logLog v - logLog u + Real.sqrt (logLog S * T)) := Finset.sum_le_sum fun j _ => (hp j).interval_upper hS hSu huv hvT _ = _ := by simp [Erdos416Proof.largestPrimeFactor_one, Erdos416Proof.omegaInterval_one, mul_add] /- Original line 892: Erdos416Proof.SNormal.sum_interval_upper_of_cutoff -/ theorem SNormal.sum_interval_upper_of_cutoff {m : ℕ} (p : Fin m → ℕ) {S T u v : ℝ} (hp : ∀ j, SNormal S (p j)) (hS : Real.exp 1 ≤ S) (idx : Fin m) (horder : RankedAt (fun j => largestPrimeFactor (p j - 1)) idx) (hcut : (largestPrimeFactor (p idx - 1) : ℝ) ≤ u) (hSu : S ≤ u) (huv : u < v) (hvT : logLog v ≤ T) : (∑ j, (omegaInterval (p j - 1) u v : ℝ)) ≤ idx.val * (logLog v - logLog u + Real.sqrt (logLog S * T)) := by apply SNormal.sum_interval_upper_of_tail p hp hS idx ?_ hSu huv hvT intro j hij have hPj : (largestPrimeFactor (p j - 1) : ℝ) ≤ largestPrimeFactor (p idx - 1) := by exact_mod_cast horder.2 j hij exact hPj.trans hcut /- Original line 905: Erdos416Proof.SNormal.sum_interval_lower_of_cutoff -/ theorem SNormal.sum_interval_lower_of_cutoff {m : ℕ} (p : Fin m → ℕ) {S T u v : ℝ} (hp : ∀ j, SNormal S (p j)) (hS : Real.exp 1 ≤ S) (idx : Fin m) (horder : RankedAt (fun j => largestPrimeFactor (p j - 1)) idx) (hcut : v ≤ (largestPrimeFactor (p idx - 1) : ℝ)) (hSu : S ≤ u) (huv : u < v) (hvT : logLog v ≤ T) : (idx.val + 1 : ℝ) * (logLog v - logLog u - Real.sqrt (logLog S * T)) ≤ ∑ j, (omegaInterval (p j - 1) u v : ℝ) := by have hpoint : ∀ j ∈ Finset.Iic idx, logLog v - logLog u - Real.sqrt (logLog S * T) ≤ (omegaInterval (p j - 1) u v : ℝ) := by intro j hj have hPj : (largestPrimeFactor (p idx - 1) : ℝ) ≤ largestPrimeFactor (p j - 1) := by exact_mod_cast horder.1 j (Finset.mem_Iic.mp hj) have hpos : 0 < p j - 1 := by have := (hp j).1.one_lt; omega have hPbound : (largestPrimeFactor (p j - 1) : ℝ) ≤ (p j - 1 : ℕ) := by exact_mod_cast largestPrimeFactor_le hpos exact ((hp j).interval_bounds hS hSu huv hvT (hcut.trans (hPj.trans hPbound))).1 calc (idx.val + 1 : ℝ) * (logLog v - logLog u - Real.sqrt (logLog S * T)) = ∑ _j ∈ Finset.Iic idx, (logLog v - logLog u - Real.sqrt (logLog S * T)) := by simp [Erdos416Proof.largestPrimeFactor_one, Erdos416Proof.omegaInterval_one, mul_sub] _ ≤ ∑ j ∈ Finset.Iic idx, (omegaInterval (p j - 1) u v : ℝ) := Finset.sum_le_sum hpoint _ ≤ ∑ j, (omegaInterval (p j - 1) u v : ℝ) := Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ _) (fun j _ _ => omegaInterval_nonneg (p j - 1) u v) /-- Ordered shifted largest prime factors on equal multiplicative sides cannot differ by more than the accumulated normality error. -/ /- Original line 934: Erdos416Proof.ordered_matching_one_sided -/ theorem ordered_matching_one_sided {m n : ℕ} (p : Fin m → ℕ) (q : Fin n → ℕ) {S T : ℝ} (hp : ∀ j, SNormal S (p j)) (hq : ∀ j, SNormal S (q j)) (hS : Real.exp 1 ≤ S) (idx : Fin m) (j : Fin n) (hij : idx.val = j.val) (horderP : RankedAt (fun k => largestPrimeFactor (p k - 1)) idx) (horderQ : RankedAt (fun k => largestPrimeFactor (q k - 1)) j) (hPi : S ≤ (largestPrimeFactor (p idx - 1) : ℝ)) (hQj : S ≤ (largestPrimeFactor (q j - 1) : ℝ)) (hQT : logLog (largestPrimeFactor (q j - 1)) ≤ T) (hbalance : ∀ u v : ℝ, S ≤ u → u < v → (∑ k, omegaInterval (p k - 1) u v) = ∑ k, omegaInterval (q k - 1) u v) : logLog (largestPrimeFactor (q j - 1)) - logLog (largestPrimeFactor (p idx - 1)) ≤ (2 * idx.val + 1 : ℝ) * Real.sqrt (logLog S * T) := by let P : ℝ := largestPrimeFactor (p idx - 1) let Q : ℝ := largestPrimeFactor (q j - 1) have hSone : 1 < S := (Real.one_lt_exp_iff.mpr (by norm_num : (0 : ℝ) < 1)).trans_le hS by_cases hQP : Q ≤ P · have hlogs : logLog Q ≤ logLog P := logLog_mono (hSone.trans_le hQj) hQP have herr : 0 ≤ (2 * idx.val + 1 : ℝ) * Real.sqrt (logLog S * T) := by positivity exact (sub_nonpos.mpr hlogs).trans herr · have hPQ : P < Q := lt_of_not_ge hQP have hupper := SNormal.sum_interval_upper_of_cutoff p hp hS idx horderP (le_refl P) hPi hPQ hQT have hlower := SNormal.sum_interval_lower_of_cutoff q hq hS j horderQ (le_refl Q) hPi hPQ hQT have hmass : (∑ k, (omegaInterval (p k - 1) P Q : ℝ)) = ∑ k, (omegaInterval (q k - 1) P Q : ℝ) := by exact_mod_cast hbalance P Q hPi hPQ rw [hmass] at hupper rw [← hij] at hlower change logLog Q - logLog P ≤ _ nlinarith /- Original line 968: Erdos416Proof.ordered_matching_bound -/ theorem ordered_matching_bound {m n : ℕ} (p : Fin m → ℕ) (q : Fin n → ℕ) {S T : ℝ} (hp : ∀ j, SNormal S (p j)) (hq : ∀ j, SNormal S (q j)) (hS : Real.exp 1 ≤ S) (idx : Fin m) (j : Fin n) (hij : idx.val = j.val) (horderP : RankedAt (fun k => largestPrimeFactor (p k - 1)) idx) (horderQ : RankedAt (fun k => largestPrimeFactor (q k - 1)) j) (hPi : S ≤ (largestPrimeFactor (p idx - 1) : ℝ)) (hQj : S ≤ (largestPrimeFactor (q j - 1) : ℝ)) (hPT : logLog (largestPrimeFactor (p idx - 1)) ≤ T) (hQT : logLog (largestPrimeFactor (q j - 1)) ≤ T) (hbalance : ∀ u v : ℝ, S ≤ u → u < v → (∑ k, omegaInterval (p k - 1) u v) = ∑ k, omegaInterval (q k - 1) u v) : |logLog (largestPrimeFactor (p idx - 1)) - logLog (largestPrimeFactor (q j - 1))| ≤ (2 * idx.val + 1 : ℝ) * Real.sqrt (logLog S * T) := by have hright := ordered_matching_one_sided q p hq hp hS j idx hij.symm horderQ horderP hQj hPi hPT (fun u v hu huv => (hbalance u v hu huv).symm) have hleft := ordered_matching_one_sided p q hp hq hS idx j hij horderP horderQ hPi hQj hQT hbalance rw [← hij] at hright exact abs_le.mpr ⟨by linarith, hright⟩ /-- The interval-count equality follows from equality of the actual integer products after factors supported below S have been removed. -/ /- Original line 991: Erdos416Proof.shifted_product_interval_balance -/ theorem shifted_product_interval_balance {m n : ℕ} (p : Fin m → ℕ) (q : Fin n → ℕ) (hp : ∀ idx, (p idx).Prime) (hq : ∀ idx, (q idx).Prime) {d e : ℕ} (hd : d ≠ 0) (he : e ≠ 0) (hprod : d * (∏ idx, (p idx - 1)) = e * (∏ idx, (q idx - 1))) {S : ℝ} (hdS : (largestPrimeFactor d : ℝ) ≤ S) (heS : (largestPrimeFactor e : ℝ) ≤ S) {u v : ℝ} (hSu : S ≤ u) : (∑ idx, omegaInterval (p idx - 1) u v) = ∑ idx, omegaInterval (q idx - 1) u v := by have hpne : ∀ idx ∈ Finset.univ, p idx - 1 ≠ 0 := by intro idx _ have := (hp idx).one_lt omega have hqne : ∀ idx ∈ Finset.univ, q idx - 1 ≠ 0 := by intro idx _ have := (hq idx).one_lt omega have h := congrArg (fun a => omegaInterval a u v) hprod rw [omegaInterval_mul hd (Finset.prod_ne_zero_iff.mpr hpne), omegaInterval_mul he (Finset.prod_ne_zero_iff.mpr hqne), omegaInterval_eq_zero_of_largestPrimeFactor_le d (hdS.trans hSu), omegaInterval_eq_zero_of_largestPrimeFactor_le e (heS.trans hSu), zero_add, zero_add, omegaInterval_prod Finset.univ _ hpne, omegaInterval_prod Finset.univ _ hqne] at h exact h /-- A sufficiently separated left-hand prime forces the corresponding right-hand index to exist; no padding by a fictitious prime is used. -/ /- Original line 1018: Erdos416Proof.enough_matching_indices -/ theorem enough_matching_indices {m n : ℕ} (p : Fin m → ℕ) (q : Fin n → ℕ) {S T : ℝ} (hp : ∀ j, SNormal S (p j)) (hq : ∀ j, SNormal S (q j)) (hS : Real.exp 1 ≤ S) (idx : Fin m) (horderP : RankedAt (fun k => largestPrimeFactor (p k - 1)) idx) (hPi : S < (largestPrimeFactor (p idx - 1) : ℝ)) (hPT : logLog (largestPrimeFactor (p idx - 1)) ≤ T) (hgap : (2 * idx.val + 1 : ℝ) * Real.sqrt (logLog S * T) < logLog (largestPrimeFactor (p idx - 1)) - logLog S) (hbalance : ∀ u v : ℝ, S ≤ u → u < v → (∑ k, omegaInterval (p k - 1) u v) = ∑ k, omegaInterval (q k - 1) u v) : idx.val < n := by by_contra hn have hnle : (n : ℝ) ≤ idx.val := by exact_mod_cast Nat.le_of_not_gt hn let P : ℝ := largestPrimeFactor (p idx - 1) have hSone : 1 < S := (Real.one_lt_exp_iff.mpr (by norm_num : (0 : ℝ) < 1)).trans_le hS have hC : 0 ≤ logLog P - logLog S + Real.sqrt (logLog S * T) := by have hlog := logLog_mono hSone hPi.le linarith [Real.sqrt_nonneg (logLog S * T)] have hlower := SNormal.sum_interval_lower_of_cutoff p hp hS idx horderP (le_refl P) le_rfl hPi hPT have hupper := (SNormal.sum_interval_upper q hq hS le_rfl hPi hPT).trans (mul_le_mul_of_nonneg_right hnle hC) have hmass : (∑ k, (omegaInterval (p k - 1) S P : ℝ)) = ∑ k, (omegaInterval (q k - 1) S P : ℝ) := by exact_mod_cast hbalance S P le_rfl hPi rw [hmass] at hlower change (2 * idx.val + 1 : ℝ) * Real.sqrt (logLog S * T) < logLog P - logLog S at hgap nlinarith /-- The tail cutoff follows by comparing i active left factors with i+1 right factors across a sufficiently wide normality interval. -/ /- Original line 1050: Erdos416Proof.matching_tail_cutoff -/ theorem matching_tail_cutoff {m n : ℕ} (p : Fin m → ℕ) (q : Fin n → ℕ) {S T u v : ℝ} (hp : ∀ j, SNormal S (p j)) (hq : ∀ j, SNormal S (q j)) (hS : Real.exp 1 ≤ S) (idx : Fin m) (j : Fin n) (hij : idx.val = j.val) (horderQ : RankedAt (fun k => largestPrimeFactor (q k - 1)) j) (htailP : ∀ k, idx ≤ k → (largestPrimeFactor (p k - 1) : ℝ) ≤ u) (hSu : S ≤ u) (huv : u < v) (hvT : logLog v ≤ T) (hgap : (2 * idx.val + 1 : ℝ) * Real.sqrt (logLog S * T) < logLog v - logLog u) (hbalance : ∀ a b : ℝ, S ≤ a → a < b → (∑ k, omegaInterval (p k - 1) a b) = ∑ k, omegaInterval (q k - 1) a b) : (largestPrimeFactor (q j - 1) : ℝ) < v := by by_contra hQ have hvQ : v ≤ (largestPrimeFactor (q j - 1) : ℝ) := le_of_not_gt hQ have hupper := SNormal.sum_interval_upper_of_tail p hp hS idx htailP hSu huv hvT have hlower := SNormal.sum_interval_lower_of_cutoff q hq hS j horderQ hvQ hSu huv hvT have hmass : (∑ k, (omegaInterval (p k - 1) u v : ℝ)) = ∑ k, (omegaInterval (q k - 1) u v : ℝ) := by exact_mod_cast hbalance u v hSu huv rw [hmass] at hupper rw [← hij] at hlower nlinarith /- Original line 1073: Erdos416Proof.largestPrimeFactor_mem_primeFactors -/ theorem largestPrimeFactor_mem_primeFactors {n : ℕ} (h : 1 < largestPrimeFactor n) : largestPrimeFactor n ∈ n.primeFactors := by have hs : n.primeFactors.Nonempty := by apply Finset.nonempty_iff_ne_empty.mpr intro hs simp [Erdos416Proof.largestPrimeFactor_one, largestPrimeFactor, hs] at h obtain ⟨p, hp, hsup⟩ := Finset.exists_mem_eq_sup n.primeFactors hs id have hprime := Nat.prime_of_mem_primeFactors hp simpa only [largestPrimeFactor, hsup, id_eq, max_eq_right hprime.one_le] using hp /- Original line 1083: Erdos416Proof.largestPrimeFactor_isPrime -/ theorem largestPrimeFactor_isPrime {n : ℕ} (h : 1 < largestPrimeFactor n) : (largestPrimeFactor n).Prime := Nat.prime_of_mem_primeFactors (largestPrimeFactor_mem_primeFactors h) /- Original line 1087: Erdos416Proof.largestPrimeFactor_dvd -/ theorem largestPrimeFactor_dvd (n : ℕ) : largestPrimeFactor n ∣ n := by by_cases h : largestPrimeFactor n = 1 · rw [h] exact one_dvd n · have hlarge : 1 < largestPrimeFactor n := by have := one_le_largestPrimeFactor n omega exact Nat.dvd_of_mem_primeFactors (largestPrimeFactor_mem_primeFactors hlarge) /- Original line 1096: Erdos416Proof.largestPrimeFactor_pow_le -/ theorem largestPrimeFactor_pow_le {n : ℕ} (hn : 0 < n) (k : ℕ) : largestPrimeFactor (n ^ k) ≤ largestPrimeFactor n := by induction k with | zero => simpa only [pow_zero, largestPrimeFactor_one] using one_le_largestPrimeFactor n | succ k ih => rw [pow_succ, largestPrimeFactor_mul (Nat.pow_pos hn) hn] exact max_le ih le_rfl /- Original line 1104: Erdos416Proof.largestPrimeFactor_prod_le -/ theorem largestPrimeFactor_prod_le {ι : Type*} (s : Finset ι) (f : ι → ℕ) {S : ℝ} (hS : 1 ≤ S) (hf : ∀ idx ∈ s, 0 < f idx) (hbound : ∀ idx ∈ s, (largestPrimeFactor (f idx) : ℝ) ≤ S) : (largestPrimeFactor (∏ idx ∈ s, f idx) : ℝ) ≤ S := by classical revert hf hbound induction s using Finset.induction with | empty => simpa [Erdos416Proof.largestPrimeFactor_one] using hS | @insert idx s hi ih => intro hf hbound have hs : ∀ j ∈ s, 0 < f j := fun j hj => hf j (Finset.mem_insert_of_mem hj) rw [Finset.prod_insert hi, largestPrimeFactor_mul (hf idx (Finset.mem_insert_self _ _)) (Finset.prod_pos hs), Nat.cast_max] exact max_le (hbound idx (Finset.mem_insert_self _ _)) (ih hs (fun j hj => hbound j (Finset.mem_insert_of_mem hj))) /- Original line 1121: Erdos416Proof.NoLargePrimeSquare -/ def NoLargePrimeSquare (n : ℕ) (S : ℝ) : Prop := ∀ p : ℕ, p.Prime → S < (p : ℝ) → ¬p ^ 2 ∣ n /- Original line 1124: Erdos416Proof.NoLargePrimeSquare.mono -/ theorem NoLargePrimeSquare.mono {n : ℕ} {S T : ℝ} (h : NoLargePrimeSquare n S) (hST : S ≤ T) : NoLargePrimeSquare n T := fun p hp hTp => h p hp (hST.trans_lt hTp) /- Original line 1128: Erdos416Proof.large_prime_factorization_eq_one -/ theorem large_prime_factorization_eq_one {n p : ℕ} {S : ℝ} (hn : n ≠ 0) (hsquare : NoLargePrimeSquare n S) (hp : p.Prime) (hpn : p ∣ n) (hSp : S < (p : ℝ)) : n.factorization p = 1 := by have hlower := (hp.dvd_iff_one_le_factorization hn).mp hpn have hupper : ¬2 ≤ n.factorization p := by intro h exact hsquare p hp hSp ((hp.pow_dvd_iff_le_factorization hn).mpr h) omega /- Original line 1138: Erdos416Proof.largeShiftPrimes -/ noncomputable def largeShiftPrimes (n : ℕ) (S : ℝ) : Finset ℕ := n.primeFactors.filter fun p => S < (largestPrimeFactor (p - 1) : ℝ) /- Original line 1141: Erdos416Proof.smallShiftPart -/ noncomputable def smallShiftPart (n : ℕ) (S : ℝ) : ℕ := ∏ p ∈ n.primeFactors with (largestPrimeFactor (p - 1) : ℝ) ≤ S, p ^ (n.factorization p - 1) * (p - 1) /- Original line 1145: Erdos416Proof.mem_largeShiftPrimes -/ theorem mem_largeShiftPrimes {n p : ℕ} {S : ℝ} : p ∈ largeShiftPrimes n S ↔ p ∈ n.primeFactors ∧ S < (largestPrimeFactor (p - 1) : ℝ) := Finset.mem_filter /- Original line 1149: Erdos416Proof.largeShiftPrime_gt -/ theorem largeShiftPrime_gt {n p : ℕ} {S : ℝ} (hp : p ∈ largeShiftPrimes n S) : S < (p : ℝ) := by obtain ⟨hpn, hSp⟩ := mem_largeShiftPrimes.mp hp have hprime := Nat.prime_of_mem_primeFactors hpn have hpos : 0 < p - 1 := by have := hprime.one_lt; omega have hle : (largestPrimeFactor (p - 1) : ℝ) ≤ p := by exact_mod_cast (largestPrimeFactor_le hpos).trans (Nat.sub_le p 1) exact hSp.trans_le hle /- Original line 1158: Erdos416Proof.largeShiftPrime_factorization_eq_one -/ theorem largeShiftPrime_factorization_eq_one {n p : ℕ} {S : ℝ} (hn : n ≠ 0) (hsquare : NoLargePrimeSquare n S) (hp : p ∈ largeShiftPrimes n S) : n.factorization p = 1 := by have hpn := (mem_largeShiftPrimes.mp hp).1 exact large_prime_factorization_eq_one hn hsquare (Nat.prime_of_mem_primeFactors hpn) (Nat.dvd_of_mem_primeFactors hpn) (largeShiftPrime_gt hp) /- Original line 1165: Erdos416Proof.totient_split_largeShiftPrimes -/ theorem totient_split_largeShiftPrimes {n : ℕ} {S : ℝ} (hn : n ≠ 0) (hsquare : NoLargePrimeSquare n S) : n.totient = (∏ p ∈ largeShiftPrimes n S, (p - 1)) * smallShiftPart n S := by have hphi := Nat.totient_eq_prod_factorization hn change n.totient = ∏ p ∈ n.primeFactors, p ^ (n.factorization p - 1) * (p - 1) at hphi rw [← Finset.prod_filter_mul_prod_filter_not n.primeFactors (fun p => S < (largestPrimeFactor (p - 1) : ℝ))] at hphi have hlarge : (∏ p ∈ largeShiftPrimes n S, p ^ (n.factorization p - 1) * (p - 1)) = ∏ p ∈ largeShiftPrimes n S, (p - 1) := by apply Finset.prod_congr rfl intro p hp rw [largeShiftPrime_factorization_eq_one hn hsquare hp] simp[Erdos416Proof.largestPrimeFactor_one] simp only [largeShiftPrimes] at hlarge rw [hlarge] at hphi simpa only [not_lt, largeShiftPrimes, smallShiftPart] using hphi /- Original line 1182: Erdos416Proof.smallShiftPart_pos -/ theorem smallShiftPart_pos (n : ℕ) (S : ℝ) : 0 < smallShiftPart n S := by unfold smallShiftPart apply Finset.prod_pos intro p hp have hprime := Nat.prime_of_mem_primeFactors (Finset.mem_filter.mp hp).1 apply Nat.mul_pos (Nat.pow_pos hprime.pos) have := hprime.one_lt omega /- Original line 1191: Erdos416Proof.smallShiftPart_smooth -/ theorem smallShiftPart_smooth {n : ℕ} {S : ℝ} (hn : n ≠ 0) (hS : 1 ≤ S) (hsquare : NoLargePrimeSquare n S) : (largestPrimeFactor (smallShiftPart n S) : ℝ) ≤ S := by unfold smallShiftPart apply largestPrimeFactor_prod_le _ _ hS · intro p hp have hprime := Nat.prime_of_mem_primeFactors (Finset.mem_filter.mp hp).1 exact Nat.mul_pos (Nat.pow_pos hprime.pos) (by have := hprime.one_lt; omega) · intro p hp obtain ⟨hpn, hsmall⟩ := Finset.mem_filter.mp hp have hprime := Nat.prime_of_mem_primeFactors hpn by_cases hpS : (p : ℝ) ≤ S · have hpos : 0 < p - 1 := by have := hprime.one_lt; omega rw [largestPrimeFactor_mul (Nat.pow_pos hprime.pos) hpos, Nat.cast_max] apply max_le _ hsmall have hpow : largestPrimeFactor (p ^ (n.factorization p - 1)) ≤ p := by simpa only [largestPrimeFactor_prime hprime] using largestPrimeFactor_pow_le hprime.pos (n.factorization p - 1) have hpowReal : (largestPrimeFactor (p ^ (n.factorization p - 1)) : ℝ) ≤ p := by exact_mod_cast hpow exact hpowReal.trans hpS · have hfac := large_prime_factorization_eq_one hn hsquare hprime (Nat.dvd_of_mem_primeFactors hpn) (lt_of_not_ge hpS) simpa only [hfac, Nat.sub_self, pow_zero, one_mul] using hsmall /-- Distinct large shifted prime factors are forced by the absence of large prime squares in the totient, regardless of multiplicities in n. -/ /- Original line 1218: Erdos416Proof.largeShiftPrimes_P_injective -/ theorem largeShiftPrimes_P_injective {n : ℕ} {S : ℝ} (hS : 1 ≤ S) (hsquare : NoLargePrimeSquare n.totient S) : Set.InjOn (fun p => largestPrimeFactor (p - 1)) ↑(largeShiftPrimes n S) := by intro p hp q hq hPQ change largestPrimeFactor (p - 1) = largestPrimeFactor (q - 1) at hPQ by_contra hpq obtain ⟨hpn, hSP⟩ := mem_largeShiftPrimes.mp hp obtain ⟨hqn, _⟩ := mem_largeShiftPrimes.mp hq have hprimeP := Nat.prime_of_mem_primeFactors hpn have hprimeQ := Nat.prime_of_mem_primeFactors hqn have hcop : p.Coprime q := by apply hprimeP.coprime_iff_not_dvd.mpr intro hdvd exact hpq ((Nat.prime_dvd_prime_iff_eq hprimeP hprimeQ).mp hdvd) have hpqN : p * q ∣ n := hcop.mul_dvd_of_dvd_of_dvd (Nat.dvd_of_mem_primeFactors hpn) (Nat.dvd_of_mem_primeFactors hqn) have hphi := Nat.totient_dvd_of_dvd hpqN rw [Nat.totient_mul hcop, Nat.totient_prime hprimeP, Nat.totient_prime hprimeQ] at hphi have hlarge : 1 < largestPrimeFactor (p - 1) := by exact_mod_cast hS.trans_lt hSP have hQp := largestPrimeFactor_dvd (p - 1) have hQq : largestPrimeFactor (p - 1) ∣ q - 1 := by rw [hPQ] exact largestPrimeFactor_dvd (q - 1) apply hsquare (largestPrimeFactor (p - 1)) (largestPrimeFactor_isPrime hlarge) hSP simpa only [pow_two] using (mul_dvd_mul hQp hQq).trans hphi /- Original line 1246: Erdos416Proof.top_prime_not_dvd_of_square_bound -/ theorem top_prime_not_dvd_of_square_bound {n p : ℕ} (hn : 0 < n) (hp : p.Prime) (hsize : n ≤ p ^ 2) (hneq : largestPrimeFactor n ≠ p) : ¬p ∣ n := by intro hpn have hpP : p ≤ largestPrimeFactor n := prime_le_largestPrimeFactor hn hp hpn have hpPstrict : p < largestPrimeFactor n := by omega have hPprime : (largestPrimeFactor n).Prime := largestPrimeFactor_isPrime (hp.one_lt.trans hpPstrict) have hcop : p.Coprime (largestPrimeFactor n) := by apply hp.coprime_iff_not_dvd.mpr intro hdvd exact hneq ((Nat.prime_dvd_prime_iff_eq hp hPprime).mp hdvd).symm have hproduct := hcop.mul_dvd_of_dvd_of_dvd hpn (largestPrimeFactor_dvd n) have hbound := Nat.le_of_dvd hn hproduct nlinarith [hp.pos] /- Original line 1261: Erdos416Proof.exists_decreasing_enumeration -/ theorem exists_decreasing_enumeration (s : Finset ℕ) (f : ℕ → ℕ) (hf : Set.InjOn f ↑s) : ∃ e : Fin s.card ≃ s, StrictAnti (fun idx => f (e idx)) := by classical let fS : s → (s.image f) := fun a => ⟨f a, Finset.mem_image.mpr ⟨a, a.property, rfl⟩⟩ have hfS : Function.Bijective fS := by constructor · intro a b hab apply Subtype.ext exact hf a.property b.property (congrArg Subtype.val hab) · rintro ⟨b, hb⟩ obtain ⟨a, ha, hab⟩ := Finset.mem_image.mp hb exact ⟨⟨a, ha⟩, Subtype.ext hab⟩ let e := Equiv.ofBijective fS hfS let o := (s.image f).orderIsoOfFin (Finset.card_image_of_injOn hf) let enumeration : Fin s.card ≃ s := (Fin.revPerm.trans o.toEquiv).trans e.symm have hvalue (idx : Fin s.card) : f (enumeration idx) = (o idx.rev).val := by change (e (e.symm (o idx.rev))).val = (o idx.rev).val exact congrArg Subtype.val (e.apply_symm_apply (o idx.rev)) refine ⟨enumeration, ?_⟩ intro idx j hij change f (enumeration j) < f (enumeration idx) rw [hvalue, hvalue] exact o.strictMono (Fin.rev_lt_rev.mpr hij) /- Original line 1287: Erdos416Proof.prod_enumeration -/ theorem prod_enumeration (s : Finset ℕ) (e : Fin s.card ≃ s) (f : ℕ → ℕ) : (∏ idx, f (e idx)) = ∏ p ∈ s, f p := by calc (∏ idx, f (e idx)) = ∏ p : s, f p := Fintype.prod_equiv e _ _ (fun _ => rfl) _ = _ := by simp only [Finset.univ_eq_attach, Finset.prod_attach] /-- A pruned preimage has an actual strictly ordered list of its large shifted prime factors, each occurring to the first power, and a smooth residual factor. -/ /- Original line 1295: Erdos416Proof.exists_normal_preimage_list -/ theorem exists_normal_preimage_list {n : ℕ} {S : ℝ} (hn : 0 < n) (hS : 1 ≤ S) (hnormal : ∀ p ∈ n.primeFactors, SNormal S p) (hsquareN : NoLargePrimeSquare n S) (hsquarePhi : NoLargePrimeSquare n.totient S) : ∃ q : Fin (largeShiftPrimes n S).card → ℕ, (∀ idx, SNormal S (q idx)) ∧ Function.Injective q ∧ StrictAnti (fun idx => largestPrimeFactor (q idx - 1)) ∧ (∀ idx, S < (largestPrimeFactor (q idx - 1) : ℝ)) ∧ (∀ idx, n.factorization (q idx) = 1) ∧ n.totient = smallShiftPart n S * (∏ idx, (q idx - 1)) ∧ 0 < smallShiftPart n S ∧ (largestPrimeFactor (smallShiftPart n S) : ℝ) ≤ S := by obtain ⟨e, he⟩ := exists_decreasing_enumeration (largeShiftPrimes n S) (fun p => largestPrimeFactor (p - 1)) (largeShiftPrimes_P_injective hS hsquarePhi) let q : Fin (largeShiftPrimes n S).card → ℕ := fun idx => (e idx).val have hmem (idx) : q idx ∈ largeShiftPrimes n S := (e idx).property refine ⟨q, ?_, ?_, he, ?_, ?_, ?_, smallShiftPart_pos n S, smallShiftPart_smooth hn.ne' hS hsquareN⟩ · intro idx exact hnormal (q idx) (mem_largeShiftPrimes.mp (hmem idx)).1 · intro idx j hij exact e.injective (Subtype.ext hij) · intro idx exact (mem_largeShiftPrimes.mp (hmem idx)).2 · intro idx exact largeShiftPrime_factorization_eq_one hn.ne' hsquareN (hmem idx) · rw [totient_split_largeShiftPrimes hn.ne' hsquareN] rw [show (∏ idx, (q idx - 1)) = ∏ p ∈ largeShiftPrimes n S, (p - 1) from prod_enumeration (largeShiftPrimes n S) e (fun p => p - 1)] exact mul_comm _ _ /- Original line 1326: Erdos416Proof.NormalPreimageList -/ structure NormalPreimageList (n : ℕ) (S : ℝ) where primes : Fin (largeShiftPrimes n S).card → ℕ normal : ∀ idx, SNormal S (primes idx) injective : Function.Injective primes sorted : StrictAnti (fun idx => largestPrimeFactor (primes idx - 1)) large : ∀ idx, S < (largestPrimeFactor (primes idx - 1) : ℝ) occurs_once : ∀ idx, n.factorization (primes idx) = 1 phi_eq : n.totient = smallShiftPart n S * (∏ idx, (primes idx - 1)) residual_pos : 0 < smallShiftPart n S residual_smooth : (largestPrimeFactor (smallShiftPart n S) : ℝ) ≤ S /- Original line 1337: Erdos416Proof.exists_NormalPreimageList -/ theorem exists_NormalPreimageList {n : ℕ} {S : ℝ} (hn : 0 < n) (hS : 1 ≤ S) (hnormal : ∀ p ∈ n.primeFactors, SNormal S p) (hsquareN : NoLargePrimeSquare n S) (hsquarePhi : NoLargePrimeSquare n.totient S) : Nonempty (NormalPreimageList n S) := by obtain ⟨q, hq, hinj, horder, hlarge, hone, hprod, hepos, hesmooth⟩ := exists_normal_preimage_list hn hS hnormal hsquareN hsquarePhi exact ⟨⟨q, hq, hinj, horder, hlarge, hone, hprod, hepos, hesmooth⟩⟩ /- Original line 1346: Erdos416Proof.NormalPreimageList.interval_balance -/ theorem NormalPreimageList.interval_balance {n : ℕ} {S : ℝ} (Q : NormalPreimageList n S) {m : ℕ} (p : Fin m → ℕ) (hp : ∀ idx, (p idx).Prime) {d : ℕ} (hd : d ≠ 0) (hdS : (largestPrimeFactor d : ℝ) ≤ S) (hphi : n.totient = d * (∏ idx, (p idx - 1))) {u v : ℝ} (hSu : S ≤ u) : (∑ idx, omegaInterval (p idx - 1) u v) = ∑ idx, omegaInterval (Q.primes idx - 1) u v := shifted_product_interval_balance p Q.primes hp (fun idx => (Q.normal idx).1) hd Q.residual_pos.ne' (hphi.symm.trans Q.phi_eq) hdS Q.residual_smooth hSu /- Original line 1355: Erdos416Proof.NormalPreimageList.shifted_le_totient -/ theorem NormalPreimageList.shifted_le_totient {n : ℕ} {S : ℝ} (Q : NormalPreimageList n S) (hn : 0 < n) (idx : Fin (largeShiftPrimes n S).card) : largestPrimeFactor (Q.primes idx - 1) ≤ n.totient := by have hp := (Q.normal idx).1 have hpn : Q.primes idx ∣ n := (hp.dvd_iff_one_le_factorization hn.ne').mpr (by rw [Q.occurs_once]) have hphi := Nat.totient_dvd_of_dvd hpn rw [Nat.totient_prime hp] at hphi have hpos : 0 < Q.primes idx - 1 := by have := hp.one_lt; omega exact (largestPrimeFactor_le hpos).trans (Nat.le_of_dvd (Nat.totient_pos.mpr hn) hphi) /- Original line 1366: Erdos416Proof.NormalPreimageList.logLog_shifted_le -/ theorem NormalPreimageList.logLog_shifted_le {n : ℕ} {S : ℝ} (Q : NormalPreimageList n S) (hn : 0 < n) (hS : 1 ≤ S) (idx : Fin (largeShiftPrimes n S).card) : logLog (largestPrimeFactor (Q.primes idx - 1)) ≤ logLog n.totient := by apply logLog_mono (hS.trans_lt (Q.large idx)) exact_mod_cast Q.shifted_le_totient hn idx /-- The matching estimate applied to a genuine totient preimage, with all interval identities supplied by its proved multiplicative factorization. -/ /- Original line 1375: Erdos416Proof.NormalPreimageList.matching -/ theorem NormalPreimageList.matching {n : ℕ} {S T : ℝ} (Q : NormalPreimageList n S) (hn : 0 < n) (hS : Real.exp 1 ≤ S) {m : ℕ} (p : Fin m → ℕ) (hp : ∀ idx, SNormal S (p idx)) {d : ℕ} (hd : d ≠ 0) (hdS : (largestPrimeFactor d : ℝ) ≤ S) (hphi : n.totient = d * (∏ idx, (p idx - 1))) (hT : logLog n.totient ≤ T) (idx : Fin m) (horderP : RankedAt (fun k => largestPrimeFactor (p k - 1)) idx) (hPi : S < (largestPrimeFactor (p idx - 1) : ℝ)) (hPT : logLog (largestPrimeFactor (p idx - 1)) ≤ T) (hgap : (2 * idx.val + 1 : ℝ) * Real.sqrt (logLog S * T) < logLog (largestPrimeFactor (p idx - 1)) - logLog S) : ∃ j : Fin (largeShiftPrimes n S).card, j.val = idx.val ∧ |logLog (largestPrimeFactor (p idx - 1)) - logLog (largestPrimeFactor (Q.primes j - 1))| ≤ (2 * idx.val + 1 : ℝ) * Real.sqrt (logLog S * T) := by have hbalance : ∀ u v : ℝ, S ≤ u → u < v → (∑ k, omegaInterval (p k - 1) u v) = ∑ k, omegaInterval (Q.primes k - 1) u v := fun _ _ hu _ => Q.interval_balance p (fun k => (hp k).1) hd hdS hphi hu have hexists := enough_matching_indices p Q.primes hp Q.normal hS idx horderP hPi hPT hgap hbalance let j : Fin (largeShiftPrimes n S).card := ⟨idx.val, hexists⟩ have hSone : 1 ≤ S := (Real.one_lt_exp_iff.mpr (by norm_num : (0 : ℝ) < 1)).le.trans hS refine ⟨j, rfl, ordered_matching_bound p Q.primes hp Q.normal hS idx j rfl horderP (rankedAt_of_antitone Q.sorted.antitone j) hPi.le (Q.large j).le hPT ?_ hbalance⟩ exact (Q.logLog_shifted_le hn hSone j).trans hT open Asymptotics /- Original line 1407: Erdos416Proof.log_pow_mul_rpow_littleO -/ theorem log_pow_mul_rpow_littleO (k : ℕ) {a b : ℝ} (hab : a < b) : (fun T : ℝ => Real.log T ^ k * T ^ a) =o[atTop] (fun T => T ^ b) := by have h := (isLittleO_log_rpow_rpow_atTop (k : ℝ) (sub_pos.mpr hab)).mul_isBigO (isBigO_refl (fun T : ℝ => T ^ a) atTop) refine h.congr' (Eventually.of_forall fun T => ?_) ?_ · simp only [Real.rpow_natCast] · filter_upwards [eventually_gt_atTop (0 : ℝ)] with T hT rw [← Real.rpow_add hT] congr 1 ring /- Original line 1418: Erdos416Proof.normalityScale -/ noncomputable def normalityScale (T : ℝ) : ℝ := Real.exp (Real.exp (Real.log T ^ 10)) /- Original line 1421: Erdos416Proof.normalityDelta -/ noncomputable def normalityDelta (T : ℝ) : ℝ := 2 * Real.log T ^ 5 / Real.sqrt T /- Original line 1424: Erdos416Proof.logLog_normalityScale -/ theorem logLog_normalityScale (T : ℝ) : Real.log (Real.log (normalityScale T)) = Real.log T ^ 10 := by simp only [normalityScale, Real.log_exp] /- Original line 1428: Erdos416Proof.normalityScale_ge_exp_one -/ theorem normalityScale_ge_exp_one (T : ℝ) : Real.exp 1 ≤ normalityScale T := by apply Real.exp_le_exp.mpr exact Real.one_le_exp_iff.mpr (by positivity) /- Original line 1432: Erdos416Proof.normalityDelta_nonneg -/ theorem normalityDelta_nonneg {T : ℝ} (hT : 1 ≤ T) : 0 ≤ normalityDelta T := div_nonneg (mul_nonneg (by norm_num) (pow_nonneg (Real.log_nonneg hT) 5)) (Real.sqrt_nonneg T) /- Original line 1436: Erdos416Proof.normality_error_exact -/ theorem normality_error_exact {T : ℝ} (hT : 1 ≤ T) : Real.sqrt (Real.log (Real.log (normalityScale T)) * T) = Real.log T ^ 5 * Real.sqrt T := by rw [logLog_normalityScale] have hp : Real.log T ^ 10 = (Real.log T ^ 5) ^ 2 := by ring rw [hp, Real.sqrt_mul (sq_nonneg _), Real.sqrt_sq (pow_nonneg (Real.log_nonneg hT) 5)] /- Original line 1443: Erdos416Proof.normality_error_le_delta -/ theorem normality_error_le_delta {T : ℝ} (hT : 1 ≤ T) : Real.sqrt (Real.log (Real.log (normalityScale T)) * T) ≤ normalityDelta T * T := by have hTpos : 0 < T := by linarith have hsqrt : 0 < Real.sqrt T := Real.sqrt_pos.mpr hTpos have hnonneg : 0 ≤ Real.log T ^ 5 * Real.sqrt T := mul_nonneg (pow_nonneg (Real.log_nonneg hT) 5) hsqrt.le have heq : normalityDelta T * T = 2 * (Real.log T ^ 5 * Real.sqrt T) := by unfold normalityDelta apply (mul_right_cancel₀ hsqrt.ne') rw [div_mul_eq_mul_div, div_mul_cancel₀ _ hsqrt.ne'] nlinarith [Real.sq_sqrt hTpos.le] rw [normality_error_exact hT, heq] linarith /- Original line 1457: Erdos416Proof.dimension_delta_littleO_boxGap -/ theorem dimension_delta_littleO_boxGap : (fun T : ℝ => Real.log T * normalityDelta T) =o[atTop] (fun T => T ^ (-2 / 5 : ℝ)) := by have h := (log_pow_mul_rpow_littleO 6 (show (-1 / 2 : ℝ) < -2 / 5 by norm_num)).const_mul_left (2 : ℝ) refine h.congr' ?_ (Eventually.of_forall fun _ => rfl) filter_upwards [eventually_gt_atTop (0 : ℝ)] with T hT rw [show (-1 / 2 : ℝ) = -(1 / 2 : ℝ) by ring, Real.rpow_neg hT.le] simp only [normalityDelta, Real.sqrt_eq_rpow, div_eq_mul_inv] ring /-- The estimate is uniform over all integral dimensions in the allowed range. -/ /- Original line 1469: Erdos416Proof.dimension_delta_small -/ theorem dimension_delta_small (A : ℝ) {η : ℝ} (hη : 0 < η) : ∀ᶠ T : ℝ in atTop, ∀ L : ℕ, (L : ℝ) ≤ A * Real.log T → L * normalityDelta T ≤ η * T ^ (-2 / 5 : ℝ) := by have h := dimension_delta_littleO_boxGap.const_mul_left A filter_upwards [h.def hη, eventually_ge_atTop (1 : ℝ)] with T hbound hT intro L hL have hTzero : 0 ≤ T := by linarith simp only [Real.norm_eq_abs, abs_of_nonneg (Real.rpow_nonneg hTzero (-2 / 5 : ℝ))] at hbound have hproduct := mul_le_mul_of_nonneg_right hL (normalityDelta_nonneg hT) have habs := le_abs_self (A * (Real.log T * normalityDelta T)) nlinarith /-- An envelope for the prefactor and exponent losses after bounding the number of sieve variables by a constant times log T. -/ /- Original line 1484: Erdos416Proof.sieveErrorEnvelope -/ noncomputable def sieveErrorEnvelope (T : ℝ) : ℝ := Real.log T ^ 2 * T ^ (2 / 3 : ℝ) + Real.log T ^ 8 * T ^ (1 / 2 : ℝ) + Real.log T ^ 2 /- Original line 1488: Erdos416Proof.sieveErrorEnvelope_littleO -/ theorem sieveErrorEnvelope_littleO {b : ℝ} (hb : (2 / 3 : ℝ) < b) : sieveErrorEnvelope =o[atTop] (fun T : ℝ => T ^ b) := by have h₁ := log_pow_mul_rpow_littleO 2 hb have h₂ := log_pow_mul_rpow_littleO 8 (show (1 / 2 : ℝ) < b by linarith) have h₃ : (fun T : ℝ => Real.log T ^ 2) =o[atTop] (fun T => T ^ b) := by simpa only [Real.rpow_zero, mul_one] using log_pow_mul_rpow_littleO 2 (show (0 : ℝ) < b by linarith) exact (h₁.add h₂).add h₃ /- Original line 1497: Erdos416Proof.sieveErrorEnvelope_littleO_three_quarters -/ theorem sieveErrorEnvelope_littleO_three_quarters : sieveErrorEnvelope =o[atTop] (fun T : ℝ => T ^ (3 / 4 : ℝ)) := sieveErrorEnvelope_littleO (by norm_num) /-- Every fixed multiple of these losses is eventually absorbed by one quarter of the strict-facet saving. -/ /- Original line 1503: Erdos416Proof.sieve_exponent_saving -/ theorem sieve_exponent_saving (C : ℝ) : ∀ᶠ T : ℝ in atTop, -(1 / 2 : ℝ) * T ^ (7 / 8 : ℝ) + C * sieveErrorEnvelope T ≤ -(1 / 4 : ℝ) * T ^ (7 / 8 : ℝ) := by have h := (sieveErrorEnvelope_littleO (b := (7 / 8 : ℝ)) (by norm_num)).const_mul_left C filter_upwards [h.def (show (0 : ℝ) < 1 / 4 by norm_num), eventually_ge_atTop (0 : ℝ)] with T hbound hT simp only [Real.norm_eq_abs, abs_of_nonneg (Real.rpow_nonneg hT (7 / 8 : ℝ))] at hbound have hle : C * sieveErrorEnvelope T ≤ (1 / 4 : ℝ) * T ^ (7 / 8 : ℝ) := (le_abs_self _).trans hbound linarith /- Original line 1517: Erdos416Proof.omegaInterval_eq_cardFactors_of_support -/ theorem omegaInterval_eq_cardFactors_of_support {n : ℕ} {v : ℝ} (hv : (largestPrimeFactor n : ℝ) ≤ v) : omegaInterval n 1 v = ArithmeticFunction.cardFactors n := by apply List.countP_eq_length.mpr intro p hp have hpone : (1 : ℝ) < p := by exact_mod_cast (Nat.prime_of_mem_primeFactorsList hp).one_lt have hpP : (p : ℝ) ≤ largestPrimeFactor n := by exact_mod_cast primeFactorsList_le_largestPrimeFactor hp have hpv : (p : ℝ) ≤ v := hpP.trans hv simpa only [decide_eq_true_eq] using And.intro hpone hpv /- Original line 1529: Erdos416Proof.cardFactors_split_at -/ theorem cardFactors_split_at {n : ℕ} {S v : ℝ} (hv : (largestPrimeFactor n : ℝ) ≤ v) : ArithmeticFunction.cardFactors n = omegaInterval n 1 S + omegaInterval n S v := by change n.primeFactorsList.length = _ + _ rw [List.length_eq_countP_add_countP (fun p : ℕ => decide ((p : ℝ) ≤ S))] congr 1 <;> apply List.countP_congr <;> intro p hp · have hpone : (1 : ℝ) < p := by exact_mod_cast (Nat.prime_of_mem_primeFactorsList hp).one_lt simp [Erdos416Proof.largestPrimeFactor_one, Erdos416Proof.omegaInterval_one, hpone] · have hpP : (p : ℝ) ≤ largestPrimeFactor n := by exact_mod_cast primeFactorsList_le_largestPrimeFactor hp have hpv : (p : ℝ) ≤ v := hpP.trans hv simp [Erdos416Proof.largestPrimeFactor_one, Erdos416Proof.omegaInterval_one, hpv, not_le] /-- Normality controls the total factor count even when p - 1 exceeds v: it suffices that every prime factor of p - 1 is at most v. -/ /- Original line 1545: Erdos416Proof.SNormal.cardFactors_le_of_support -/ theorem SNormal.cardFactors_le_of_support {S v : ℝ} {p : ℕ} (hp : SNormal S p) (hS : Real.exp 1 ≤ S) (hSv : S ≤ v) (hPv : (largestPrimeFactor (p - 1) : ℝ) ≤ v) : (ArithmeticFunction.cardFactors (p - 1) : ℝ) ≤ logLog v + logLog S + Real.sqrt (logLog S * logLog v) := by by_cases hlt : S < v · have hint := hp.interval_upper hS le_rfl hlt (T := logLog v) le_rfl have hsmall := hp.2.1 rw [cardFactors_split_at (S := S) hPv, Nat.cast_add] change (omegaInterval (p - 1) 1 S : ℝ) ≤ 2 * logLog S at hsmall linarith · have heq : v = S := (le_of_not_gt hlt).antisymm hSv subst v rw [← omegaInterval_eq_cardFactors_of_support hPv] have hsmall := hp.2.1 change (omegaInterval (p - 1) 1 S : ℝ) ≤ 2 * logLog S at hsmall linarith [Real.sqrt_nonneg (logLog S * logLog S)] /- Original line 1563: Erdos416Proof.SNormal.cardFactors_le_three_mul -/ theorem SNormal.cardFactors_le_three_mul {S v T : ℝ} {p : ℕ} (hp : SNormal S p) (hS : Real.exp 1 ≤ S) (hSv : S ≤ v) (hPv : (largestPrimeFactor (p - 1) : ℝ) ≤ v) (hT : logLog v ≤ T) : (ArithmeticFunction.cardFactors (p - 1) : ℝ) ≤ 3 * T := by have hSone : 1 < S := (Real.one_lt_exp_iff.mpr (by norm_num : (0 : ℝ) < 1)).trans_le hS have hLS := logLog_nonneg hS have hLSv := logLog_mono hSone hSv have hLv : 0 ≤ logLog v := hLS.trans hLSv have hTzero : 0 ≤ T := hLv.trans hT have hsqrt : Real.sqrt (logLog S * logLog v) ≤ T := by apply (Real.sqrt_le_iff).mpr constructor · exact hTzero · nlinarith [mul_le_mul (hLSv.trans hT) hT hLv hTzero] have hcount := hp.cardFactors_le_of_support hS hSv hPv linarith /- Original line 1581: Erdos416Proof.le_largestPrimeFactor_pow_cardFactors -/ theorem le_largestPrimeFactor_pow_cardFactors {n : ℕ} (hn : n ≠ 0) : n ≤ largestPrimeFactor n ^ ArithmeticFunction.cardFactors n := by simpa only [Nat.prod_primeFactorsList hn, ArithmeticFunction.cardFactors_apply] using List.prod_le_pow_card n.primeFactorsList (largestPrimeFactor n) (fun _ hp => primeFactorsList_le_largestPrimeFactor hp) /- Original line 1587: Erdos416Proof.log_le_cardFactors_mul_log_largestPrimeFactor -/ theorem log_le_cardFactors_mul_log_largestPrimeFactor {n : ℕ} (hn : 0 < n) : Real.log n ≤ ArithmeticFunction.cardFactors n * Real.log (largestPrimeFactor n) := by have hbound : (n : ℝ) ≤ (largestPrimeFactor n : ℝ) ^ ArithmeticFunction.cardFactors n := by exact_mod_cast le_largestPrimeFactor_pow_cardFactors hn.ne' have hlog := Real.log_le_log (by exact_mod_cast hn) hbound simpa only [Real.log_pow] using hlog /- Original line 1595: Erdos416Proof.largestPrimeFactor_one_lt -/ theorem largestPrimeFactor_one_lt {n : ℕ} (hn : 1 < n) : 1 < largestPrimeFactor n := by have hbound := le_largestPrimeFactor_pow_cardFactors (by omega : n ≠ 0) have hbase : 1 ≤ largestPrimeFactor n := le_max_left _ _ by_contra h have heq : largestPrimeFactor n = 1 := by omega simp only [heq, one_pow] at hbound omega /-- A quantitative logarithmic form of the largest-factor estimate. The factor count is a proved input to this elementary implication. -/ /- Original line 1606: Erdos416Proof.logLog_gap_le_log_factor_bound -/ theorem logLog_gap_le_log_factor_bound {n : ℕ} (hn : 1 < n) {H : ℝ} (hH : (ArithmeticFunction.cardFactors n : ℝ) ≤ H) : logLog n - logLog (largestPrimeFactor n) ≤ Real.log H := by have hnlog : 0 < Real.log n := Real.log_pos (by exact_mod_cast hn) have hPlog : 0 < Real.log (largestPrimeFactor n) := Real.log_pos (by exact_mod_cast largestPrimeFactor_one_lt hn) have hHpos : 0 < H := by have hc : (0 : ℝ) < ArithmeticFunction.cardFactors n := by exact_mod_cast ArithmeticFunction.cardFactors_pos_iff_one_lt.mpr hn exact hc.trans_le hH have hmul : Real.log n ≤ H * Real.log (largestPrimeFactor n) := (log_le_cardFactors_mul_log_largestPrimeFactor (by omega)).trans (mul_le_mul_of_nonneg_right hH hPlog.le) have hlog := Real.log_le_log hnlog hmul rw [Real.log_mul hHpos.ne' hPlog.ne'] at hlog change logLog n ≤ Real.log H + logLog (largestPrimeFactor n) at hlog linarith /- Original line 1624: Erdos416Proof.log_le_five_quarters_log_sub_one -/ theorem log_le_five_quarters_log_sub_one {p : ℕ} (hp : 17 ≤ p) : Real.log p ≤ (5 / 4 : ℝ) * Real.log (p - 1 : ℕ) := by have hnp : 0 < p - 1 := by omega have hnr : (0 : ℝ) < (p - 1 : ℕ) := by exact_mod_cast hnp have hshift : (p : ℝ) ≤ 2 * (p - 1 : ℕ) := by exact_mod_cast (show p ≤ 2 * (p - 1) by omega) have hlog := Real.log_le_log (by exact_mod_cast (show 0 < p by omega)) hshift rw [Real.log_mul (by norm_num : (2 : ℝ) ≠ 0) hnr.ne'] at hlog have hbase : (2 : ℝ) ^ 4 ≤ (p - 1 : ℕ) := by norm_num exact_mod_cast (show 16 ≤ p - 1 by omega) have hlogbase := Real.log_le_log (by norm_num : (0 : ℝ) < 2 ^ 4) hbase rw [Real.log_pow] at hlogbase norm_num only [Nat.cast_ofNat] at hlogbase linarith /- Original line 1640: Erdos416Proof.shifted_largestPrimeFactor_log_bound -/ theorem shifted_largestPrimeFactor_log_bound {p : ℕ} (hp : 17 ≤ p) {T : ℝ} (hcount : (ArithmeticFunction.cardFactors (p - 1) : ℝ) ≤ 4 * T) : Real.log p ≤ 5 * T * Real.log (largestPrimeFactor (p - 1)) := by have hPlog : 0 < Real.log (largestPrimeFactor (p - 1)) := Real.log_pos (by exact_mod_cast largestPrimeFactor_one_lt (show 1 < p - 1 by omega)) have hbound := (log_le_cardFactors_mul_log_largestPrimeFactor (show 0 < p - 1 by omega)).trans (mul_le_mul_of_nonneg_right hcount hPlog.le) have hshift := log_le_five_quarters_log_sub_one hp nlinarith /- Original line 1651: Erdos416Proof.shifted_largestPrimeFactor_logLog_gap -/ theorem shifted_largestPrimeFactor_logLog_gap {p : ℕ} (hp : 17 ≤ p) {T : ℝ} (hcount : (ArithmeticFunction.cardFactors (p - 1) : ℝ) ≤ 4 * T) : logLog p - logLog (largestPrimeFactor (p - 1)) ≤ Real.log (5 * T) := by have hcp : (0 : ℝ) < ArithmeticFunction.cardFactors (p - 1) := by exact_mod_cast ArithmeticFunction.cardFactors_pos_iff_one_lt.mpr (show 1 < p - 1 by omega) have hT : 0 < T := by linarith have hPlog : 0 < Real.log (largestPrimeFactor (p - 1)) := Real.log_pos (by exact_mod_cast largestPrimeFactor_one_lt (show 1 < p - 1 by omega)) have hpLog : 0 < Real.log p := Real.log_pos (by exact_mod_cast (show 1 < p by omega)) have hlog := Real.log_le_log hpLog (shifted_largestPrimeFactor_log_bound hp hcount) rw [Real.log_mul (by positivity : 5 * T ≠ 0) hPlog.ne'] at hlog change logLog p ≤ Real.log (5 * T) + logLog (largestPrimeFactor (p - 1)) at hlog linarith /- Original line 1666: Erdos416Proof.shifted_largestPrimeFactor_rpow_bound -/ theorem shifted_largestPrimeFactor_rpow_bound {p : ℕ} (hp : 17 ≤ p) {T : ℝ} (hcount : (ArithmeticFunction.cardFactors (p - 1) : ℝ) ≤ 4 * T) : (p : ℝ) ^ (1 / (5 * T)) ≤ largestPrimeFactor (p - 1) := by have hcp : (0 : ℝ) < ArithmeticFunction.cardFactors (p - 1) := by exact_mod_cast ArithmeticFunction.cardFactors_pos_iff_one_lt.mpr (show 1 < p - 1 by omega) have hT : 0 < T := by linarith have hp0 : (0 : ℝ) < p := by exact_mod_cast (show 0 < p by omega) have hP0 : (0 : ℝ) < largestPrimeFactor (p - 1) := by exact_mod_cast (show 0 < largestPrimeFactor (p - 1) from lt_of_lt_of_le (by norm_num) (le_max_left _ _)) apply (Real.log_le_log_iff (Real.rpow_pos_of_pos hp0 _) hP0).mp rw [Real.log_rpow hp0] have hlog := shifted_largestPrimeFactor_log_bound hp hcount calc 1 / (5 * T) * Real.log p = Real.log p / (5 * T) := by ring _ ≤ Real.log (largestPrimeFactor (p - 1)) := (div_le_iff₀ (by positivity : 0 < 5 * T)).mpr (by nlinarith) /- Original line 1685: Erdos416Proof.normality_cardFactors_eventually -/ theorem normality_cardFactors_eventually : ∀ᶠ T : ℝ in atTop, ∀ p : ℕ, SNormal (normalityScale T) p → (p : ℝ) ≤ Real.exp (Real.exp (T + 1)) → (ArithmeticFunction.cardFactors (p - 1) : ℝ) ≤ 4 * T := by have hsmall : ∀ᶠ T : ℝ in atTop, Real.log T ^ 10 ≤ T := by have h := log_pow_mul_rpow_littleO 10 (show (0 : ℝ) < 1 by norm_num) filter_upwards [h.def (show (0 : ℝ) < 1 by norm_num), eventually_ge_atTop (0 : ℝ)] with T hbound hT simpa only [Real.rpow_zero, mul_one, Real.rpow_one, Real.norm_eq_abs, abs_of_nonneg (by positivity : 0 ≤ Real.log T ^ 10), abs_of_nonneg hT, one_mul] using hbound filter_upwards [hsmall, eventually_ge_atTop (3 : ℝ)] with T hsmall hT intro p hp hpbound have hS : normalityScale T ≤ Real.exp (Real.exp (T + 1)) := by apply Real.exp_le_exp.mpr apply Real.exp_le_exp.mpr linarith have hPp : (largestPrimeFactor (p - 1) : ℝ) ≤ p := by have hnat : largestPrimeFactor (p - 1) ≤ p := (largestPrimeFactor_le (by have := hp.1.one_lt; omega)).trans (Nat.sub_le _ _) exact_mod_cast hnat have hcount := hp.cardFactors_le_three_mul (normalityScale_ge_exp_one T) hS (hPp.trans hpbound) (T := T + 1) (by simp [Erdos416Proof.largestPrimeFactor_one, Erdos416Proof.omegaInterval_one, logLog]) linarith /- Original line 1710: Erdos416Proof.inverse_totient_scale_envelope -/ theorem inverse_totient_scale_envelope (c : ℝ) : ∀ᶠ T : ℝ in atTop, c * Real.exp (Real.exp T) * T ≤ Real.exp (Real.exp (T + 1)) := by have h := (Real.isLittleO_pow_exp_atTop (n := 1)).const_mul_left c filter_upwards [h.def (show (0 : ℝ) < 1 by norm_num)] with T hbound simp only [pow_one, Real.norm_eq_abs, abs_of_pos (Real.exp_pos T), one_mul] at hbound have hc : c * T ≤ Real.exp T := (le_abs_self _).trans hbound have hTE : T ≤ Real.exp T := by linarith [Real.add_one_le_exp T] have hcY : c * T ≤ Real.exp (Real.exp T) := hc.trans (Real.exp_le_exp.mpr hTE) have heone : (2 : ℝ) ≤ Real.exp 1 := by linarith [Real.add_one_le_exp (1 : ℝ)] calc c * Real.exp (Real.exp T) * T = (c * T) * Real.exp (Real.exp T) := by ring _ ≤ Real.exp (Real.exp T) * Real.exp (Real.exp T) := mul_le_mul_of_nonneg_right hcY (Real.exp_pos _).le _ = Real.exp (2 * Real.exp T) := by rw [← Real.exp_add]; congr 1; ring _ ≤ Real.exp (Real.exp (T + 1)) := by apply Real.exp_le_exp.mpr rw [Real.exp_add] nlinarith [Real.exp_pos T] /-- Uniform over all primes in the actual inverse-totient size range. -/ /- Original line 1731: Erdos416Proof.normality_largestPrimeFactor_eventually -/ theorem normality_largestPrimeFactor_eventually (c : ℝ) : ∀ᶠ T : ℝ in atTop, ∀ p : ℕ, SNormal (normalityScale T) p → 17 ≤ p → (p : ℝ) ≤ c * Real.exp (Real.exp T) * T → (ArithmeticFunction.cardFactors (p - 1) : ℝ) ≤ 4 * T ∧ (p : ℝ) ^ (1 / (5 * T)) ≤ largestPrimeFactor (p - 1) ∧ logLog p - logLog (largestPrimeFactor (p - 1)) ≤ Real.log (5 * T) := by filter_upwards [normality_cardFactors_eventually, inverse_totient_scale_envelope c] with T hcount hscale intro p hp hp17 hpsize have hc := hcount p hp (hpsize.trans hscale) exact ⟨hc, shifted_largestPrimeFactor_rpow_bound hp17 hc, shifted_largestPrimeFactor_logLog_gap hp17 hc⟩ /-- Two labelled lists in disjoint real intervals can share an element only at the same label. Injectivity of the real-valued statistic is not needed. -/ /- Original line 1749: Erdos416Proof.eq_index_of_separated_boxes -/ theorem eq_index_of_separated_boxes {ι α : Type*} [LinearOrder ι] (p q : ι → α) (f : α → ℝ) (ζ : ι → ℝ) {η : ℝ} (hsep : ∀ idx j, idx < j → 2 * η < ζ idx - ζ j) (hp : ∀ idx, |f (p idx) - ζ idx| ≤ η) (hq : ∀ idx, |f (q idx) - ζ idx| ≤ η) {idx j : ι} (heq : p idx = q j) : idx = j := by have hpi := abs_le.mp (hp idx) have hqj := abs_le.mp (hq j) rw [← heq] at hqj rcases lt_trichotomy idx j with hij | hij | hij · have := hsep idx j hij linarith · exact hij · have := hsep j idx hij linarith /- Original line 1765: Erdos416Proof.injective_of_separated_boxes -/ theorem injective_of_separated_boxes {ι α : Type*} [LinearOrder ι] (p : ι → α) (f : α → ℝ) (ζ : ι → ℝ) {η : ℝ} (hsep : ∀ idx j, idx < j → 2 * η < ζ idx - ζ j) (hp : ∀ idx, |f (p idx) - ζ idx| ≤ η) : Function.Injective p := fun _ _ heq => eq_index_of_separated_boxes p p f ζ hsep hp hp heq /- Original line 1771: Erdos416Proof.head_ne_tail_of_boxes -/ theorem head_ne_tail_of_boxes {ι κ α : Type*} (head : ι → α) (tail : κ → α) (f : α → ℝ) (ζ : ι → ℝ) {η b : ℝ} (hhead : ∀ idx, |f (head idx) - ζ idx| ≤ η) (htail : ∀ j, f (tail j) ≤ b) (hgap : ∀ idx, b + η < ζ idx) (idx : ι) (j : κ) : head idx ≠ tail j := by intro heq have hh := (abs_le.mp (hhead idx)).1 have ht := htail j have hg := hgap idx rw [heq] at hh linarith /- Original line 1783: Erdos416Proof.matching_box_bound -/ theorem matching_box_bound {a b ζ e r : ℝ} (ha : |a - ζ| ≤ e) (hab : |a - b| ≤ r) : |b - ζ| ≤ r + e := by have h₁ := abs_le.mp ha have h₂ := abs_le.mp hab exact abs_le.mpr ⟨by linarith, by linarith⟩ /- Original line 1789: Erdos416Proof.rounded_box_bound -/ theorem rounded_box_bound {a ζ e : ℝ} (hlo : a ≤ ζ) (hhi : ζ ≤ a + e) : |a - ζ| ≤ e := abs_le.mpr ⟨by linarith, by linarith⟩ /- Original line 1792: Erdos416Proof.separated_boxes_of_adjacent -/ theorem separated_boxes_of_adjacent {k : ℕ} (ζ : Fin k → ℝ) {g : ℝ} (hanti : Antitone ζ) (hstep : ∀ idx : Fin k, ∀ h : idx.val + 1 < k, g < ζ idx - ζ ⟨idx.val + 1, h⟩) : ∀ idx j, idx < j → g < ζ idx - ζ j := by intro idx j hij have hnext : idx.val + 1 < k := lt_of_le_of_lt (show idx.val + 1 ≤ j.val by exact hij) j.isLt have hle : (⟨idx.val + 1, hnext⟩ : Fin k) ≤ j := by exact show idx.val + 1 ≤ j.val from hij have hmono := hanti hle have hgap := hstep idx hnext linarith /- Original line 1806: Erdos416Proof.totient_prod_injective_primes -/ theorem totient_prod_injective_primes {ι : Type*} (s : Finset ι) (p : ι → ℕ) (hp : ∀ idx ∈ s, (p idx).Prime) (hinj : Set.InjOn p s) : (∏ idx ∈ s, p idx).totient = ∏ idx ∈ s, (p idx - 1) := by have hprime : ∀ q ∈ s.image p, q.Prime := by intro q hq obtain ⟨idx, hi, rfl⟩ := Finset.mem_image.mp hq exact hp idx hi have h := totient_prod_primes (s.image p) hprime rw [Finset.prod_image hinj, Finset.prod_image hinj] at h exact h /- Original line 1817: Erdos416Proof.commonIndices -/ noncomputable def commonIndices {ι : Type*} (s : Finset ι) (p q : ι → ℕ) : Finset ι := s.filter (fun idx => p idx = q idx) /- Original line 1820: Erdos416Proof.mem_commonIndices -/ theorem mem_commonIndices {ι : Type*} {s : Finset ι} {p q : ι → ℕ} {idx : ι} : idx ∈ commonIndices s p q ↔ idx ∈ s ∧ p idx = q idx := Finset.mem_filter /- Original line 1824: Erdos416Proof.remaining_paired_primes_ne -/ theorem remaining_paired_primes_ne {ι : Type*} {s : Finset ι} {p q : ι → ℕ} {idx : ι} (hi : idx ∈ s \ commonIndices s p q) : p idx ≠ q idx := by have h := Finset.mem_sdiff.mp hi exact fun heq => h.2 (mem_commonIndices.mpr ⟨h.1, heq⟩) /- Original line 1829: Erdos416Proof.remaining_cross_primes_ne -/ theorem remaining_cross_primes_ne {ι : Type*} {s : Finset ι} {p q : ι → ℕ} (halign : ∀ idx ∈ s, ∀ j ∈ s, p idx = q j → idx = j) {idx j : ι} (hi : idx ∈ s \ commonIndices s p q) (hj : j ∈ s) : p idx ≠ q j := by intro heq have hij := halign idx (Finset.mem_sdiff.mp hi).1 j hj heq subst j exact remaining_paired_primes_ne hi heq /- Original line 1837: Erdos416Proof.common_prime_product_reconstructs -/ theorem common_prime_product_reconstructs {ι : Type*} (s : Finset ι) (p q : ι → ℕ) : (∏ idx ∈ commonIndices s p q, p idx) * (∏ idx ∈ s \ commonIndices s p q, p idx) = ∏ idx ∈ s, p idx := by rw [mul_comm] exact Finset.prod_sdiff (Finset.filter_subset _ _) /-- Cancellation takes place in the natural numbers, before introducing the real-valued sieve bound. The common factor is a genuine totient. -/ /- Original line 1845: Erdos416Proof.cancel_common_shifted_primes -/ theorem cancel_common_shifted_primes {ι : Type*} (s : Finset ι) (p q : ι → ℕ) (hp : ∀ idx ∈ s, (p idx).Prime) (hinj : Set.InjOn p s) {a b : ℕ} (heq : a * (∏ idx ∈ s, (p idx - 1)) = b * (∏ idx ∈ s, (q idx - 1))) : a * (∏ idx ∈ s \ commonIndices s p q, (p idx - 1)) = b * (∏ idx ∈ s \ commonIndices s p q, (q idx - 1)) ∧ a * (∏ idx ∈ s, (p idx - 1)) = (∏ idx ∈ commonIndices s p q, p idx).totient * (a * (∏ idx ∈ s \ commonIndices s p q, (p idx - 1))) := by let c := commonIndices s p q have hcs : c ⊆ s := Finset.filter_subset _ _ have hcpos : 0 < ∏ idx ∈ c, (p idx - 1) := by apply Finset.prod_pos intro idx hi have := (hp idx (hcs hi)).one_lt omega have hcprod : (∏ idx ∈ c, (q idx - 1)) = ∏ idx ∈ c, (p idx - 1) := by apply Finset.prod_congr rfl intro idx hi rw [(mem_commonIndices.mp hi).2] have hpfactor : (∏ idx ∈ s, (p idx - 1)) = (∏ idx ∈ s \ c, (p idx - 1)) * (∏ idx ∈ c, (p idx - 1)) := (Finset.prod_sdiff hcs).symm have hqfactor : (∏ idx ∈ s, (q idx - 1)) = (∏ idx ∈ s \ c, (q idx - 1)) * (∏ idx ∈ c, (p idx - 1)) := by rw [← Finset.prod_sdiff hcs, hcprod] constructor · apply mul_right_cancel₀ hcpos.ne' simpa only [hpfactor, hqfactor, mul_assoc] using heq · have hphi := totient_prod_injective_primes c p (fun idx hi => hp idx (hcs hi)) (hinj.mono hcs) change _ = (∏ idx ∈ c, p idx).totient * _ rw [hphi, hpfactor] ring /- Original line 1879: Erdos416Proof.cancel_common_shifted_primes_le -/ theorem cancel_common_shifted_primes_le {ι : Type*} (s : Finset ι) (p q : ι → ℕ) (hp : ∀ idx ∈ s, (p idx).Prime) (hinj : Set.InjOn p s) {a b : ℕ} {Y : ℝ} (heq : a * (∏ idx ∈ s, (p idx - 1)) = b * (∏ idx ∈ s, (q idx - 1))) (hY : (a * (∏ idx ∈ s, (p idx - 1)) : ℕ) ≤ Y) : (a * (∏ idx ∈ s \ commonIndices s p q, (p idx - 1)) : ℕ) ≤ Y / (∏ idx ∈ commonIndices s p q, p idx).totient := by have hfactor := (cancel_common_shifted_primes s p q hp hinj heq).2 have hmpos : 0 < ∏ idx ∈ commonIndices s p q, p idx := Finset.prod_pos fun idx hi => (hp idx (mem_commonIndices.mp hi).1).pos have hphipos : (0 : ℝ) < (∏ idx ∈ commonIndices s p q, p idx).totient := by exact_mod_cast Nat.totient_pos.mpr hmpos apply (le_div_iff₀ hphipos).mpr rw [hfactor, Nat.cast_mul] at hY simpa only [mul_comm] using hY /-- An ordered prime tuple is determined by its product, including multiplicities. -/ /- Original line 1896: Erdos416Proof.antitone_prime_tuple_eq_of_prod_eq -/ theorem antitone_prime_tuple_eq_of_prod_eq {k : ℕ} (p q : Fin k → ℕ) (hp : ∀ idx, (p idx).Prime) (hq : ∀ idx, (q idx).Prime) (hpanti : Antitone p) (hqanti : Antitone q) (hprod : (∏ idx, p idx) = ∏ idx, q idx) : p = q := by have hpp : ∀ a ∈ List.ofFn p, a.Prime := by intro a ha obtain ⟨idx, rfl⟩ := List.mem_ofFn.mp ha exact hp idx have hqp : ∀ a ∈ List.ofFn q, a.Prime := by intro a ha obtain ⟨idx, rfl⟩ := List.mem_ofFn.mp ha exact hq idx have h₁ := Nat.primeFactorsList_unique (List.prod_ofFn (f := p)) hpp have h₂ := Nat.primeFactorsList_unique (List.prod_ofFn (f := q)) hqp rw [hprod] at h₁ have hperm : (List.ofFn p).Perm (List.ofFn q) := h₁.trans h₂.symm have hpsorted : (List.ofFn p).Pairwise (fun a b => b ≤ a) := List.pairwise_ofFn.mpr (fun _ _ hij => hpanti hij.le) have hqsorted : (List.ofFn q).Pairwise (fun a b => b ≤ a) := List.pairwise_ofFn.mpr (fun _ _ hij => hqanti hij.le) exact List.ofFn_injective (hperm.eq_of_pairwise' hpsorted hqsorted) /- Original line 1918: Erdos416Proof.prod_ordered_enumeration -/ theorem prod_ordered_enumeration {ι : Type*} [LinearOrder ι] (s : Finset ι) (f : ι → ℕ) : (∏ idx : Fin s.card, f (s.orderIsoOfFin rfl idx)) = ∏ idx ∈ s, f idx := by calc (∏ idx : Fin s.card, f (s.orderIsoOfFin rfl idx)) = ∏ idx : s, f idx := Fintype.prod_equiv (s.orderIsoOfFin rfl).toEquiv _ _ (fun _ => rfl) _ = _ := by simp only [Finset.univ_eq_attach, Finset.prod_attach] /- Original line 1926: Erdos416Proof.antitone_prime_tuple_eq_on_of_prod_eq -/ theorem antitone_prime_tuple_eq_on_of_prod_eq {k : ℕ} (s : Finset (Fin k)) (p q : Fin k → ℕ) (hp : ∀ idx ∈ s, (p idx).Prime) (hq : ∀ idx ∈ s, (q idx).Prime) (hpanti : Antitone p) (hqanti : Antitone q) (hprod : (∏ idx ∈ s, p idx) = ∏ idx ∈ s, q idx) : ∀ idx ∈ s, p idx = q idx := by let e := s.orderIsoOfFin rfl have hp' : ∀ idx : Fin s.card, (p (e idx)).Prime := fun idx => hp _ (e idx).property have hq' : ∀ idx : Fin s.card, (q (e idx)).Prime := fun idx => hq _ (e idx).property have hpa : Antitone (fun idx => p (e idx)) := fun _ _ hij => hpanti (e.monotone hij) have hqa : Antitone (fun idx => q (e idx)) := fun _ _ hij => hqanti (e.monotone hij) have hprod' : (∏ idx : Fin s.card, p (e idx)) = ∏ idx : Fin s.card, q (e idx) := by change (∏ idx : Fin s.card, p (s.orderIsoOfFin rfl idx)) = ∏ idx : Fin s.card, q (s.orderIsoOfFin rfl idx) rw [prod_ordered_enumeration, prod_ordered_enumeration, hprod] have heq := antitone_prime_tuple_eq_of_prod_eq _ _ hp' hq' hpa hqa hprod' intro idx hi have h := congrFun heq (e.symm ⟨idx, hi⟩) simpa only [e.apply_symm_apply] using h /-- Fixing the product of the cancelled primes and the remaining entries recovers the entire decreasing prime tuple. -/ /- Original line 1948: Erdos416Proof.prime_tuple_eq_of_cancelled_data -/ theorem prime_tuple_eq_of_cancelled_data {k : ℕ} (s : Finset (Fin k)) (p q : Fin k → ℕ) (hp : ∀ idx, (p idx).Prime) (hq : ∀ idx, (q idx).Prime) (hpanti : Antitone p) (hqanti : Antitone q) (hcommon : (∏ idx ∈ s, p idx) = ∏ idx ∈ s, q idx) (hremaining : ∀ idx ∉ s, p idx = q idx) : p = q := by have hc := antitone_prime_tuple_eq_on_of_prod_eq s p q (fun idx _ => hp idx) (fun idx _ => hq idx) hpanti hqanti hcommon funext idx by_cases hi : idx ∈ s · exact hc idx hi · exact hremaining idx hi /- Original line 1960: Erdos416Proof.increasing_index_val_le -/ theorem increasing_index_val_le {m n : ℕ} (f : Fin m → Fin n) (hf : StrictMono f) (idx : Fin m) : idx.val ≤ (f idx).val := by obtain ⟨idx, hi⟩ := idx induction idx with | zero => exact Nat.zero_le _ | succ idx ih => have hi' : idx < m := by omega have hprev := ih hi' change idx ≤ (f ⟨idx, hi'⟩).val at hprev have hstep := hf (show (⟨idx, hi'⟩ : Fin m) < ⟨idx + 1, hi⟩ from Nat.lt_succ_self idx) change (f ⟨idx, hi'⟩).val < (f ⟨idx + 1, hi⟩).val at hstep change idx + 1 ≤ (f ⟨idx + 1, hi⟩).val omega /- Original line 1974: Erdos416Proof.ordered_enumeration_first_zero -/ theorem ordered_enumeration_first_zero {m : ℕ} (s : Finset (Fin (m + 1))) (hzero : 0 ∈ s) : s.orderEmbOfFin rfl ⟨0, Finset.card_pos.mpr ⟨0, hzero⟩⟩ = 0 := by let e := s.orderIsoOfFin rfl have hbound : (e ⟨0, Finset.card_pos.mpr ⟨0, hzero⟩⟩).val ≤ (0 : Fin (m + 1)) := by calc _ ≤ (e (e.symm ⟨0, hzero⟩)).val := e.monotone (by change (0 : ℕ) ≤ _ exact Nat.zero_le _) _ = 0 := congrArg Subtype.val (e.apply_symm_apply ⟨0, hzero⟩) exact le_antisymm hbound (Fin.zero_le _) /- Original line 1986: Erdos416Proof.first_index_survives_cancellation -/ theorem first_index_survives_cancellation {k : ℕ} (p q : Fin (k + 1) → ℕ) (hneq : p 0 ≠ q 0) : 0 ∈ Finset.univ \ commonIndices Finset.univ p q := by simp [Erdos416Proof.mem_commonIndices, hneq] /-- The full powers of the primes satisfying A in n. -/ /- Original line 1995: Erdos416Proof.primePart -/ noncomputable def primePart (n : ℕ) (A : ℕ → Prop) : ℕ := (n.primeFactorsList.filter (fun p : ℕ => decide (A p))).prod /- Original line 1998: Erdos416Proof.primePart_factors_perm -/ theorem primePart_factors_perm (n : ℕ) (A : ℕ → Prop) : (n.primeFactorsList.filter (fun p : ℕ => decide (A p))).Perm (primePart n A).primeFactorsList := by apply Nat.primeFactorsList_unique rfl intro p hp exact Nat.prime_of_mem_primeFactorsList (List.mem_filter.mp hp).1 /- Original line 2005: Erdos416Proof.primePart_pos -/ theorem primePart_pos (n : ℕ) (A : ℕ → Prop) : 0 < primePart n A := by apply List.prod_pos intro p hp exact (Nat.prime_of_mem_primeFactorsList (List.mem_filter.mp hp).1).pos /- Original line 2010: Erdos416Proof.mem_primeFactorsList_primePart -/ theorem mem_primeFactorsList_primePart (n p : ℕ) (A : ℕ → Prop) : p ∈ (primePart n A).primeFactorsList ↔ p ∈ n.primeFactorsList ∧ A p := by rw [← (primePart_factors_perm n A).mem_iff] simp only [List.mem_filter, decide_eq_true_eq] /- Original line 2015: Erdos416Proof.primePart_mul_compl -/ theorem primePart_mul_compl {n : ℕ} (hn : n ≠ 0) (A : ℕ → Prop) : primePart n A * primePart n (fun p => ¬A p) = n := by have h := List.prod_map_filter_mul_prod_map_filter_not A id n.primeFactorsList simpa only [primePart, List.map_id, Nat.prod_primeFactorsList hn, decide_not] using h /- Original line 2020: Erdos416Proof.primePart_dvd -/ theorem primePart_dvd {n : ℕ} (hn : n ≠ 0) (A : ℕ → Prop) : primePart n A ∣ n := ⟨primePart n (fun p => ¬A p), (primePart_mul_compl hn A).symm⟩ /- Original line 2023: Erdos416Proof.primePart_mul -/ theorem primePart_mul {m n : ℕ} (hm : m ≠ 0) (hn : n ≠ 0) (A : ℕ → Prop) : primePart (m * n) A = primePart m A * primePart n A := by have h := ((Nat.perm_primeFactorsList_mul hm hn).filter (fun p : ℕ => decide (A p))).prod_eq simpa only [primePart, List.filter_append, List.prod_append] using h /- Original line 2029: Erdos416Proof.primePart_primePart -/ theorem primePart_primePart (n : ℕ) (A B : ℕ → Prop) : primePart (primePart n A) B = primePart n (fun p => A p ∧ B p) := by have h := ((primePart_factors_perm n A).symm.filter (fun p : ℕ => decide (B p))).prod_eq simpa [primePart, List.filter_filter, Bool.and_comm] using h /- Original line 2035: Erdos416Proof.primePart_eq_self -/ theorem primePart_eq_self {n : ℕ} (hn : n ≠ 0) (A : ℕ → Prop) (hA : ∀ p ∈ n.primeFactorsList, A p) : primePart n A = n := by unfold primePart rw [List.filter_eq_self.mpr (by simpa only [decide_eq_true_eq] using hA), Nat.prod_primeFactorsList hn] /- Original line 2041: Erdos416Proof.primePart_cardFactors -/ theorem primePart_cardFactors (n : ℕ) (A : ℕ → Prop) : ArithmeticFunction.cardFactors (primePart n A) = n.primeFactorsList.countP (fun p : ℕ => decide (A p)) := by rw [ArithmeticFunction.cardFactors_apply, List.countP_eq_length_filter] exact (primePart_factors_perm n A).length_eq.symm /- Original line 2047: Erdos416Proof.largestPrimeFactor_le_of_support -/ theorem largestPrimeFactor_le_of_support {n : ℕ} {v : ℝ} (hv : 1 ≤ v) (h : ∀ p ∈ n.primeFactorsList, (p : ℝ) ≤ v) : (largestPrimeFactor n : ℝ) ≤ v := by by_cases hP : 1 < largestPrimeFactor n · apply h have hmem := largestPrimeFactor_mem_primeFactors hP simpa only [Nat.primeFactors, List.mem_toFinset] using hmem · have hPle : (largestPrimeFactor n : ℝ) ≤ 1 := by exact_mod_cast (le_of_not_gt hP) exact hPle.trans hv /- Original line 2058: Erdos416Proof.primePart_largestPrimeFactor_le -/ theorem primePart_largestPrimeFactor_le (n : ℕ) (A : ℕ → Prop) {v : ℝ} (hv : 1 ≤ v) (hA : ∀ p ∈ n.primeFactorsList, A p → (p : ℝ) ≤ v) : (largestPrimeFactor (primePart n A) : ℝ) ≤ v := by apply largestPrimeFactor_le_of_support hv intro p hp obtain ⟨hpn, hAp⟩ := (mem_primeFactorsList_primePart n p A).mp hp exact hA p hpn hAp /- Original line 2066: Erdos416Proof.primePart_squarefree_of_no_large_square -/ theorem primePart_squarefree_of_no_large_square {n : ℕ} (hn : n ≠ 0) {u : ℝ} (hsq : NoLargePrimeSquare n u) (A : ℕ → Prop) (hA : ∀ p ∈ n.primeFactorsList, A p → u < (p : ℝ)) : Squarefree (primePart n A) := by apply Nat.squarefree_iff_prime_squarefree.mpr intro p hp hpp have hpdvd : p ∣ primePart n A := (dvd_mul_right p p).trans hpp have hmem := (Nat.mem_primeFactorsList (primePart_pos n A).ne').mpr ⟨hp, hpdvd⟩ obtain ⟨hpn, hAp⟩ := (mem_primeFactorsList_primePart n p A).mp hmem apply hsq p hp (hA p hpn hAp) simpa only [pow_two] using hpp.trans (primePart_dvd hn A) /- Original line 2078: Erdos416Proof.lowPrimePart -/ noncomputable def lowPrimePart (n : ℕ) (v : ℝ) : ℕ := primePart n (fun p => (p : ℝ) ≤ v) /- Original line 2081: Erdos416Proof.highPrimePart -/ noncomputable def highPrimePart (n : ℕ) (v : ℝ) : ℕ := primePart n (fun p => v < (p : ℝ)) /- Original line 2084: Erdos416Proof.low_mul_high -/ theorem low_mul_high {n : ℕ} (hn : n ≠ 0) (v : ℝ) : lowPrimePart n v * highPrimePart n v = n := by simpa only [lowPrimePart, highPrimePart, not_le] using primePart_mul_compl hn (fun p : ℕ => (p : ℝ) ≤ v) /- Original line 2089: Erdos416Proof.lowPrimePart_cardFactors -/ theorem lowPrimePart_cardFactors (n : ℕ) (v : ℝ) : ArithmeticFunction.cardFactors (lowPrimePart n v) = omegaInterval n 1 v := by rw [lowPrimePart, primePart_cardFactors] apply List.countP_congr intro p hp have hp1 : (1 : ℝ) < p := by exact_mod_cast (Nat.prime_of_mem_primeFactorsList hp).one_lt simp [Erdos416Proof.omegaInterval_one, hp1] /- Original line 2098: Erdos416Proof.lowPrimePart_largestPrimeFactor_le -/ theorem lowPrimePart_largestPrimeFactor_le (n : ℕ) {v : ℝ} (hv : 1 ≤ v) : (largestPrimeFactor (lowPrimePart n v) : ℝ) ≤ v := primePart_largestPrimeFactor_le n _ hv (fun _ _ h => h) /- Original line 2102: Erdos416Proof.lowPrimePart_log_bound -/ theorem lowPrimePart_log_bound (n : ℕ) {v : ℝ} (hv : 1 ≤ v) : Real.log (lowPrimePart n v) ≤ omegaInterval n 1 v * Real.log v := by have hbound := log_le_cardFactors_mul_log_largestPrimeFactor (primePart_pos n (fun p : ℕ => (p : ℝ) ≤ v)) change Real.log (lowPrimePart n v) ≤ ArithmeticFunction.cardFactors (lowPrimePart n v) * Real.log (largestPrimeFactor (lowPrimePart n v)) at hbound rw [lowPrimePart_cardFactors] at hbound have hPpos : (0 : ℝ) < largestPrimeFactor (lowPrimePart n v) := by exact_mod_cast (lt_of_lt_of_le Nat.zero_lt_one (le_max_left _ _)) exact hbound.trans (mul_le_mul_of_nonneg_left (Real.log_le_log hPpos (lowPrimePart_largestPrimeFactor_le n hv)) (Nat.cast_nonneg _)) /- Original line 2115: Erdos416Proof.omegaInterval_add -/ theorem omegaInterval_add (n : ℕ) {u v w : ℝ} (huv : u ≤ v) (hvw : v ≤ w) : omegaInterval n u w = omegaInterval n u v + omegaInterval n v w := by unfold omegaInterval rw [List.countP_eq_countP_filter_add _ _ (fun p : ℕ => decide ((p : ℝ) ≤ v))] simp only [List.countP_filter] congr 1 <;> apply List.countP_congr <;> intro p _ · simp only [Bool.and_eq_true, decide_eq_true_eq] constructor · rintro ⟨⟨hup, _⟩, hpv⟩ exact ⟨hup, hpv⟩ · rintro ⟨hup, hpv⟩ exact ⟨⟨hup, hpv.trans hvw⟩, hpv⟩ · simp only [Bool.and_eq_true, decide_eq_true_eq] have hnot : (!decide ((p : ℝ) ≤ v)) = true ↔ v < (p : ℝ) := by simp[Erdos416Proof.omegaInterval_one] rw [hnot] constructor · rintro ⟨⟨_, hpw⟩, hvp⟩ exact ⟨hvp, hpw⟩ · rintro ⟨hvp, hpw⟩ exact ⟨⟨huv.trans_lt hvp, hpw⟩, hvp⟩ /- Original line 2136: Erdos416Proof.SNormal.initial_interval_bound -/ theorem SNormal.initial_interval_bound {S v : ℝ} {p : ℕ} (hp : SNormal S p) (hS : Real.exp 1 ≤ S) (hSv : S ≤ v) : (omegaInterval (p - 1) 1 v : ℝ) ≤ logLog v + logLog S + Real.sqrt (logLog S * logLog v) := by have hSone : 1 ≤ S := (Real.one_lt_exp_iff.mpr (by norm_num : (0 : ℝ) < 1)).le.trans hS by_cases hlt : S < v · rw [omegaInterval_add (p - 1) hSone hSv, Nat.cast_add] have hsmall := hp.2.1 change (omegaInterval (p - 1) 1 S : ℝ) ≤ 2 * logLog S at hsmall have hlarge := hp.interval_upper hS le_rfl hlt (T := logLog v) le_rfl linarith · have heq : v = S := (le_of_not_gt hlt).antisymm hSv subst v have hsmall := hp.2.1 change (omegaInterval (p - 1) 1 S : ℝ) ≤ 2 * logLog S at hsmall linarith [Real.sqrt_nonneg (logLog S * logLog S)] /- Original line 2154: Erdos416Proof.SNormal.initial_interval_le_three_mul -/ theorem SNormal.initial_interval_le_three_mul {S v T : ℝ} {p : ℕ} (hp : SNormal S p) (hS : Real.exp 1 ≤ S) (hSv : S ≤ v) (hvT : logLog v ≤ T) : (omegaInterval (p - 1) 1 v : ℝ) ≤ 3 * T := by have hSone : 1 < S := (Real.one_lt_exp_iff.mpr (by norm_num : (0 : ℝ) < 1)).trans_le hS have hLS := logLog_nonneg hS have hLSv := logLog_mono hSone hSv have hLv : 0 ≤ logLog v := hLS.trans hLSv have hT : 0 ≤ T := hLv.trans hvT have hsqrt : Real.sqrt (logLog S * logLog v) ≤ T := by apply Real.sqrt_le_iff.mpr exact ⟨hT, (mul_le_mul (hLSv.trans hvT) hvT hLv hT).trans_eq (sq T).symm⟩ have hbound := hp.initial_interval_bound hS hSv linarith /- Original line 2169: Erdos416Proof.SNormal.lowPrimePart_log_bound -/ theorem SNormal.lowPrimePart_log_bound {S v T : ℝ} {p : ℕ} (hp : SNormal S p) (hS : Real.exp 1 ≤ S) (hSv : S ≤ v) (hvT : logLog v ≤ T) : Real.log (lowPrimePart (p - 1) v) ≤ 3 * T * Real.log v := by have hvone : 1 ≤ v := ((Real.one_lt_exp_iff.mpr (by norm_num : (0 : ℝ) < 1)).le.trans hS).trans hSv exact (Erdos416Proof.lowPrimePart_log_bound (p - 1) hvone).trans (mul_le_mul_of_nonneg_right (hp.initial_interval_le_three_mul hS hSv hvT) (Real.log_nonneg hvone)) /-- The large divisor required in the multivariable sieve is an explicitly constructed integer, containing every prime power above the cutoff. -/ /- Original line 2180: Erdos416Proof.SNormal.large_rough_divisor -/ theorem SNormal.large_rough_divisor {p : ℕ} {S v T Y : ℝ} (hp : SNormal S p) (hS : Real.exp 1 ≤ S) (hSv : S ≤ v) (hvT : logLog v ≤ T) (hY : 0 < Y) (hcut : 10 * T * Real.log v ≤ Real.log Y) (hsize : Y ^ (4 / 5 : ℝ) ≤ (p - 1 : ℕ)) : ∃ D : ℕ, 0 < D ∧ D ∣ p - 1 ∧ Y ^ (1 / 2 : ℝ) ≤ D ∧ ∀ r : ℕ, r.Prime → r ∣ D → v < (r : ℝ) := by have hn : 0 < p - 1 := by have := hp.1.one_lt; omega let D := highPrimePart (p - 1) v have hDpos : 0 < D := primePart_pos _ _ have hDdiv : D ∣ p - 1 := primePart_dvd hn.ne' _ refine ⟨D, hDpos, hDdiv, ?_, ?_⟩ · have hlow : Real.log (lowPrimePart (p - 1) v) ≤ (3 / 10 : ℝ) * Real.log Y := by have h := hp.lowPrimePart_log_bound hS hSv hvT nlinarith have hhighsize : (4 / 5 : ℝ) * Real.log Y ≤ Real.log (p - 1 : ℕ) := by have h := Real.log_le_log (Real.rpow_pos_of_pos hY (4 / 5 : ℝ)) hsize simpa only [Real.log_rpow hY] using h have hfactor : (lowPrimePart (p - 1) v : ℝ) * D = (p - 1 : ℕ) := by exact_mod_cast low_mul_high hn.ne' v have hlogfactor := congrArg Real.log hfactor rw [Real.log_mul (by exact_mod_cast (primePart_pos (p - 1) (fun r : ℕ => (r : ℝ) ≤ v)).ne') (by exact_mod_cast hDpos.ne')] at hlogfactor apply (Real.log_le_log_iff (Real.rpow_pos_of_pos hY _) (by exact_mod_cast hDpos)).mp rw [Real.log_rpow hY] linarith · intro r hr hrd have hmem := (Nat.mem_primeFactorsList hDpos.ne').mpr ⟨hr, hrd⟩ exact ((mem_primeFactorsList_primePart (p - 1) r (fun r : ℕ => v < (r : ℝ))).mp hmem).2 /- Original line 2212: Erdos416Proof.rpow_gap_eventually -/ theorem rpow_gap_eventually : ∀ᶠ Y : ℝ in atTop, Y ^ (4 / 5 : ℝ) + 1 ≤ Y ^ (9 / 10 : ℝ) := by have h := log_pow_mul_rpow_littleO 0 (show (4 / 5 : ℝ) < 9 / 10 by norm_num) have hlarge := (tendsto_rpow_atTop (show (0 : ℝ) < 9 / 10 by norm_num)).eventually (eventually_ge_atTop (2 : ℝ)) filter_upwards [h.def (show (0 : ℝ) < 1 / 2 by norm_num), hlarge, eventually_ge_atTop (0 : ℝ)] with Y hbound hlarge hY simp only [pow_zero, one_mul, Real.norm_eq_abs, abs_of_nonneg (Real.rpow_nonneg hY (4 / 5 : ℝ)), abs_of_nonneg (Real.rpow_nonneg hY (9 / 10 : ℝ))] at hbound linarith /- Original line 2225: Erdos416Proof.large_rough_divisor_eventually -/ theorem large_rough_divisor_eventually : ∀ᶠ Y : ℝ in atTop, ∀ p : ℕ, ∀ S v : ℝ, SNormal S p → Real.exp 1 ≤ S → S ≤ v → v ≤ Y ^ (1 / (10 * logLog Y)) → Y ^ (9 / 10 : ℝ) < p → ∃ D : ℕ, 0 < D ∧ D ∣ p - 1 ∧ Y ^ (1 / 2 : ℝ) ≤ D ∧ ∀ r : ℕ, r.Prime → r ∣ D → v < (r : ℝ) := by filter_upwards [rpow_gap_eventually, eventually_ge_atTop (Real.exp (Real.exp 1))] with Y hgap hYY intro p S v hp hS hSv hcut htop have hYpos : 0 < Y := (Real.exp_pos _).trans_le hYY have hYone : 1 ≤ Y := (Real.one_le_exp (by positivity)).trans hYY have hT : 1 ≤ logLog Y := by have h := logLog_mono (show 1 < Real.exp (Real.exp 1) from Real.one_lt_exp_iff.mpr (Real.exp_pos 1)) hYY simpa only [logLog, Real.log_exp] using h have hTpos : 0 < logLog Y := by linarith have hvone : 1 < v := ((Real.one_lt_exp_iff.mpr (by norm_num : (0 : ℝ) < 1)).trans_le hS).trans_le hSv have hexp : 1 / (10 * logLog Y) ≤ 1 := by apply (div_le_iff₀ (by positivity : 0 < 10 * logLog Y)).mpr linarith have hvY : v ≤ Y := hcut.trans (Real.rpow_le_self_of_one_le hYone hexp) have hlogcut : 10 * logLog Y * Real.log v ≤ Real.log Y := by have h := Real.log_le_log (by linarith : 0 < v) hcut rw [Real.log_rpow hYpos] at h have h' : Real.log v ≤ Real.log Y / (10 * logLog Y) := by convert h using 1 ring have h'' := (le_div_iff₀ (by positivity : 0 < 10 * logLog Y)).mp h' nlinarith have hpsize : Y ^ (4 / 5 : ℝ) ≤ (p - 1 : ℕ) := by rw [Nat.cast_sub hp.1.one_le, Nat.cast_one] linarith exact hp.large_rough_divisor hS hSv (logLog_mono hvone hvY) hYpos hlogcut hpsize /- Original line 2264: Erdos416Proof.fordWeight -/ noncomputable def fordWeight (idx : ℕ) : ℝ := ((idx : ℝ) + 1) * Real.log ((idx : ℝ) + 1) - idx * Real.log idx - 1 /- Original line 2267: Erdos416Proof.fordWeight_bounds -/ theorem fordWeight_bounds {idx : ℕ} (hi : 1 ≤ idx) : 0 ≤ fordWeight idx ∧ fordWeight idx ≤ Real.log ((idx : ℝ) + 1) := by have hi1 : (1 : ℝ) ≤ idx := by exact_mod_cast hi have hi0 : (0 : ℝ) < idx := by linarith have hip : (0 : ℝ) < (idx : ℝ) + 1 := by positivity have hlow := Real.one_sub_inv_le_log_of_pos (div_pos hip hi0) have hupp := Real.log_le_sub_one_of_pos (div_pos hip hi0) rw [Real.log_div hip.ne' hi0.ne', inv_div] at hlow rw [Real.log_div hip.ne' hi0.ne'] at hupp have hl := mul_le_mul_of_nonneg_left hlow hip.le have hu := mul_le_mul_of_nonneg_left hupp hi0.le have hid₁ : ((idx : ℝ) + 1) * (1 - (idx : ℝ) / ((idx : ℝ) + 1)) = 1 := by field_simp ring have hid₂ : (idx : ℝ) * (((idx : ℝ) + 1) / (idx : ℝ) - 1) = 1 := by field_simp ring rw [hid₁] at hl rw [hid₂] at hu unfold fordWeight constructor <;> nlinarith [Real.log_nonneg hi1] /- Original line 2289: Erdos416Proof.sum_fordWeight -/ theorem sum_fordWeight (L : ℕ) : (∑ idx ∈ Finset.Icc 1 L, fordWeight idx) = ((L : ℝ) + 1) * Real.log ((L : ℝ) + 1) - L := by induction L with | zero => simp | succ L ih => rw [Finset.sum_Icc_succ_top (by omega), ih] simp only [fordWeight, Nat.cast_add, Nat.cast_one] ring /- Original line 2299: Erdos416Proof.sum_fordWeight_le -/ theorem sum_fordWeight_le (L : ℕ) : (∑ idx ∈ Finset.Icc 1 L, fordWeight idx) ≤ L * Real.log ((L : ℝ) + 1) := by calc (∑ idx ∈ Finset.Icc 1 L, fordWeight idx) ≤ ∑ _i ∈ Finset.Icc 1 L, Real.log ((L : ℝ) + 1) := by apply Finset.sum_le_sum intro idx hi have hb := Finset.mem_Icc.mp hi exact (fordWeight_bounds hb.1).2.trans (Real.log_le_log (by positivity) (by exact_mod_cast Nat.add_le_add_right hb.2 1)) _ = L * Real.log ((L : ℝ) + 1) := by simp /- Original line 2311: Erdos416Proof.sum_fordWeight_perturbation -/ theorem sum_fordWeight_perturbation {k L : ℕ} (hk : k ≤ L + 1) (ζ ν : ℕ → ℝ) {r : ℝ} (hr : 0 ≤ r) (hζ : ∀ idx ∈ Finset.Icc 1 L, 0 ≤ ζ idx) (hν : ∀ idx ∈ Finset.Icc 1 (k - 1), ν idx ≤ ζ idx + r) : (∑ idx ∈ Finset.Icc 1 (k - 1), fordWeight idx * ν idx) ≤ (∑ idx ∈ Finset.Icc 1 L, fordWeight idx * ζ idx) + r * L * Real.log ((L : ℝ) + 1) := by have hs : Finset.Icc 1 (k - 1) ⊆ Finset.Icc 1 L := by intro idx hi have := Finset.mem_Icc.mp hi exact Finset.mem_Icc.mpr ⟨this.1, by omega⟩ calc (∑ idx ∈ Finset.Icc 1 (k - 1), fordWeight idx * ν idx) ≤ ∑ idx ∈ Finset.Icc 1 (k - 1), fordWeight idx * (ζ idx + r) := Finset.sum_le_sum fun idx hi => mul_le_mul_of_nonneg_left (hν idx hi) (fordWeight_bounds (Finset.mem_Icc.mp hi).1).1 _ ≤ ∑ idx ∈ Finset.Icc 1 L, fordWeight idx * (ζ idx + r) := by apply Finset.sum_le_sum_of_subset_of_nonneg hs intro idx hi _ exact mul_nonneg (fordWeight_bounds (Finset.mem_Icc.mp hi).1).1 (add_nonneg (hζ idx hi) hr) _ = (∑ idx ∈ Finset.Icc 1 L, fordWeight idx * ζ idx) + r * (∑ idx ∈ Finset.Icc 1 L, fordWeight idx) := by simp only [mul_add, Finset.sum_add_distrib, Finset.mul_sum] congr 1 apply Finset.sum_congr rfl intro _ _ ring _ ≤ _ := by nlinarith [mul_le_mul_of_nonneg_left (sum_fordWeight_le L) hr] /- Original line 2340: Erdos416Proof.sum_sieve_error_weights_le -/ theorem sum_sieve_error_weights_le {k L : ℕ} (hk : k ≤ L + 1) : (∑ idx ∈ Finset.Icc 2 k, ((idx : ℝ) * Real.log idx + idx)) ≤ ((L : ℝ) + 1) ^ 2 * (Real.log ((L : ℝ) + 1) + 1) := by have hlog : 0 ≤ Real.log ((L : ℝ) + 1) := Real.log_nonneg (by linarith [show (0 : ℝ) ≤ L from Nat.cast_nonneg L]) have hterm : ∀ idx ∈ Finset.Icc 2 k, (idx : ℝ) * Real.log idx + idx ≤ ((L : ℝ) + 1) * (Real.log ((L : ℝ) + 1) + 1) := by intro idx hi have hb := Finset.mem_Icc.mp hi have hi0 : (0 : ℝ) < idx := by exact_mod_cast (show 0 < idx by omega) have hiL : (idx : ℝ) ≤ (L : ℝ) + 1 := by exact_mod_cast hb.2.trans hk have hlogi := Real.log_le_log hi0 hiL have himul := mul_le_mul hiL (add_le_add_right hlogi 1) (by have := Real.log_nonneg (show (1 : ℝ) ≤ idx by exact_mod_cast (show 1 ≤ idx by omega)) linarith) (by positivity : 0 ≤ (L : ℝ) + 1) nlinarith have hcard : ((Finset.Icc 2 k).card : ℝ) ≤ (L : ℝ) + 1 := by exact_mod_cast (show (Finset.Icc 2 k).card ≤ L + 1 by simp; omega) calc (∑ idx ∈ Finset.Icc 2 k, ((idx : ℝ) * Real.log idx + idx)) ≤ ∑ _i ∈ Finset.Icc 2 k, ((L : ℝ) + 1) * (Real.log ((L : ℝ) + 1) + 1) := Finset.sum_le_sum hterm _ = ((Finset.Icc 2 k).card : ℝ) * (((L : ℝ) + 1) * (Real.log ((L : ℝ) + 1) + 1)) := by simp _ ≤ ((L : ℝ) + 1) * (((L : ℝ) + 1) * (Real.log ((L : ℝ) + 1) + 1)) := mul_le_mul_of_nonneg_right hcard (by positivity) _ = _ := by ring /- Original line 2369: Erdos416Proof.fordSieveError -/ noncomputable def fordSieveError (k : ℕ) (δ : ℝ) (ν μ : ℕ → ℝ) : ℝ := δ * (∑ idx ∈ Finset.Icc 2 k, ((idx : ℝ) * Real.log idx + idx)) + 2 * ∑ idx ∈ Finset.Icc 1 (k - 1), (ν idx - μ idx) /- Original line 2373: Erdos416Proof.fordSieveError_le -/ theorem fordSieveError_le {k L : ℕ} (hk : k ≤ L + 1) {δ w : ℝ} (hδ : 0 ≤ δ) (hw : 0 ≤ w) (ν μ : ℕ → ℝ) (hwidth : ∀ idx ∈ Finset.Icc 1 (k - 1), ν idx - μ idx ≤ w) : fordSieveError k δ ν μ ≤ δ * ((L : ℝ) + 1) ^ 2 * (Real.log ((L : ℝ) + 1) + 1) + 2 * L * w := by have hs : (∑ idx ∈ Finset.Icc 1 (k - 1), (ν idx - μ idx)) ≤ L * w := by calc (∑ idx ∈ Finset.Icc 1 (k - 1), (ν idx - μ idx)) ≤ ∑ _i ∈ Finset.Icc 1 (k - 1), w := Finset.sum_le_sum hwidth _ = (k - 1 : ℕ) * w := by simp _ ≤ L * w := mul_le_mul_of_nonneg_right (by exact_mod_cast (show k - 1 ≤ L by omega)) hw have he := mul_le_mul_of_nonneg_left (sum_sieve_error_weights_le hk) hδ unfold fordSieveError nlinarith /-- The exponent in the published sieve, with the rounding and normality errors kept explicit. -/ /- Original line 2391: Erdos416Proof.ford_sieve_exponent_le -/ theorem ford_sieve_exponent_le {k L : ℕ} (hk : k ≤ L + 1) (ζ ν μ : ℕ → ℝ) {δ r w σ : ℝ} (hδ : 0 ≤ δ) (hr : 0 ≤ r) (hw : 0 ≤ w) (hζ : ∀ idx ∈ Finset.Icc 1 L, 0 ≤ ζ idx) (hν : ∀ idx ∈ Finset.Icc 1 (k - 1), ν idx ≤ ζ idx + r) (hwidth : ∀ idx ∈ Finset.Icc 1 (k - 1), ν idx - μ idx ≤ w) (hfacet : (∑ idx ∈ Finset.Icc 1 L, fordWeight idx * ζ idx) ≤ 1 - σ) : -2 + (∑ idx ∈ Finset.Icc 1 (k - 1), fordWeight idx * ν idx) + fordSieveError k δ ν μ ≤ -1 - σ + r * L * Real.log ((L : ℝ) + 1) + δ * ((L : ℝ) + 1) ^ 2 * (Real.log ((L : ℝ) + 1) + 1) + 2 * L * w := by have h₁ := sum_fordWeight_perturbation hk ζ ν hr hζ hν have h₂ := fordSieveError_le hk hδ hw ν μ hwidth linarith /- Original line 2405: Erdos416Proof.normalitySieveLoss -/ noncomputable def normalitySieveLoss (T : ℝ) (L : ℕ) : ℝ := (((2 * L + 1 : ℝ) * normalityDelta T) * L * Real.log ((L : ℝ) + 1) + normalityDelta T * ((L : ℝ) + 1) ^ 2 * (Real.log ((L : ℝ) + 1) + 1) + 2 * L * ((4 * L + 2 : ℝ) * normalityDelta T + 1 / T)) * T /- Original line 2410: Erdos416Proof.normalityDelta_mul_self -/ theorem normalityDelta_mul_self {T : ℝ} (hT : 0 < T) : normalityDelta T * T = 2 * Real.log T ^ 5 * Real.sqrt T := by have hsqrt := Real.sqrt_pos.mpr hT unfold normalityDelta apply mul_right_cancel₀ hsqrt.ne' rw [div_mul_eq_mul_div, div_mul_cancel₀ _ hsqrt.ne'] calc 2 * Real.log T ^ 5 * T = 2 * Real.log T ^ 5 * Real.sqrt T ^ 2 := by rw [Real.sq_sqrt hT.le] _ = _ := by ring /- Original line 2421: Erdos416Proof.normalitySieveLoss_bound -/ theorem normalitySieveLoss_bound {T B : ℝ} {L : ℕ} (hT : 1 ≤ T) (hU : 1 ≤ Real.log T) (hL : (L : ℝ) + 1 ≤ B * Real.log T) (hlogL : Real.log ((L : ℝ) + 1) ≤ Real.log T) : normalitySieveLoss T L ≤ 34 * B ^ 2 * (Real.log T ^ 8 * Real.sqrt T) + 2 * B * Real.log T := by have hTpos : 0 < T := by linarith have hδ := normalityDelta_nonneg hT have hU0 : 0 ≤ Real.log T := by linarith have hL0 : (0 : ℝ) ≤ L := Nat.cast_nonneg L have hlogL0 : 0 ≤ Real.log ((L : ℝ) + 1) := Real.log_nonneg (by linarith) have h₁ : (2 * L + 1 : ℝ) * normalityDelta T * L * Real.log ((L : ℝ) + 1) ≤ 3 * ((L : ℝ) + 1) ^ 2 * normalityDelta T * Real.log T := by calc _ ≤ (3 * ((L : ℝ) + 1)) * normalityDelta T * ((L : ℝ) + 1) * Real.log T := by gcongr <;> linarith _ = _ := by ring have h₂ : normalityDelta T * ((L : ℝ) + 1) ^ 2 * (Real.log ((L : ℝ) + 1) + 1) ≤ 2 * ((L : ℝ) + 1) ^ 2 * normalityDelta T * Real.log T := by have h := mul_le_mul_of_nonneg_left (show Real.log ((L : ℝ) + 1) + 1 ≤ 2 * Real.log T by linarith) (mul_nonneg hδ (sq_nonneg ((L : ℝ) + 1))) nlinarith have h₃ : 2 * L * ((4 * L + 2 : ℝ) * normalityDelta T + 1 / T) ≤ 12 * ((L : ℝ) + 1) ^ 2 * normalityDelta T * Real.log T + 2 * ((L : ℝ) + 1) / T := by calc _ ≤ 2 * ((L : ℝ) + 1) * (6 * ((L : ℝ) + 1) * normalityDelta T + 1 / T) := by gcongr <;> linarith _ = 12 * ((L : ℝ) + 1) ^ 2 * normalityDelta T + 2 * ((L : ℝ) + 1) / T := by ring _ ≤ _ := by nlinarith [mul_le_mul_of_nonneg_left hU (show 0 ≤ 12 * ((L : ℝ) + 1) ^ 2 * normalityDelta T by positivity)] have hpre : normalitySieveLoss T L ≤ 17 * ((L : ℝ) + 1) ^ 2 * normalityDelta T * Real.log T * T + 2 * ((L : ℝ) + 1) := by unfold normalitySieveLoss have hsum := mul_le_mul_of_nonneg_right (add_le_add (add_le_add h₁ h₂) h₃) hTpos.le have hdiv : (2 * ((L : ℝ) + 1) / T) * T = 2 * ((L : ℝ) + 1) := div_mul_cancel₀ _ hTpos.ne' nlinarith calc normalitySieveLoss T L ≤ 17 * ((L : ℝ) + 1) ^ 2 * normalityDelta T * Real.log T * T + 2 * ((L : ℝ) + 1) := hpre _ ≤ 17 * (B * Real.log T) ^ 2 * normalityDelta T * Real.log T * T + 2 * (B * Real.log T) := by gcongr _ = 34 * B ^ 2 * (Real.log T ^ 8 * Real.sqrt T) + 2 * B * Real.log T := by calc _ = 17 * B ^ 2 * Real.log T ^ 3 * (normalityDelta T * T) + 2 * B * Real.log T := by ring _ = _ := by rw [normalityDelta_mul_self hTpos]; ring /- Original line 2477: Erdos416Proof.dimension_log_bounds_eventually -/ theorem dimension_log_bounds_eventually (A : ℝ) : ∀ᶠ T : ℝ in atTop, ∀ L : ℕ, (L : ℝ) ≤ A * Real.log T → (L : ℝ) + 1 ≤ (A + 1) * Real.log T ∧ Real.log ((L : ℝ) + 1) ≤ Real.log T := by have h := Real.isLittleO_log_id_atTop.const_mul_left (A + 1) filter_upwards [h.def (show (0 : ℝ) < 1 by norm_num), eventually_ge_atTop (Real.exp 1)] with T hbound hT intro L hL have hT0 : 0 < T := (Real.exp_pos _).trans_le hT have hU : 1 ≤ Real.log T := by have h := Real.log_le_log (Real.exp_pos 1) hT simpa using h dsimp only [id] at hbound simp only [Real.norm_eq_abs, abs_of_pos hT0, one_mul] at hbound have hbig : (A + 1) * Real.log T ≤ T := (le_abs_self _).trans hbound have hL' : (L : ℝ) + 1 ≤ (A + 1) * Real.log T := by nlinarith exact ⟨hL', Real.log_le_log (by positivity) (hL'.trans hbig)⟩ /- Original line 2495: Erdos416Proof.normalitySieveLoss_eventually -/ theorem normalitySieveLoss_eventually (A : ℝ) (hA : 0 ≤ A) : ∀ᶠ T : ℝ in atTop, ∀ L : ℕ, (L : ℝ) ≤ A * Real.log T → normalitySieveLoss T L ≤ (34 * (A + 1) ^ 2 + 2 * (A + 1)) * sieveErrorEnvelope T := by filter_upwards [dimension_log_bounds_eventually A, eventually_ge_atTop (Real.exp 1)] with T hdim hT intro L hL have hT0 : 0 < T := (Real.exp_pos _).trans_le hT have hT1 : 1 ≤ T := (Real.one_le_exp (by norm_num : (0 : ℝ) ≤ 1)).trans hT have hU : 1 ≤ Real.log T := by have h := Real.log_le_log (Real.exp_pos 1) hT simpa using h have hbounds := hdim L hL have hbound := normalitySieveLoss_bound hT1 hU hbounds.1 hbounds.2 have henv₁ : Real.log T ^ 8 * Real.sqrt T ≤ sieveErrorEnvelope T := by unfold sieveErrorEnvelope rw [Real.sqrt_eq_rpow] have h₁ : 0 ≤ Real.log T ^ 2 * T ^ (2 / 3 : ℝ) := by positivity have h₂ : 0 ≤ Real.log T ^ 2 := by positivity linarith have henv₂ : Real.log T ≤ sieveErrorEnvelope T := by have hU₂ : Real.log T ≤ Real.log T ^ 2 := by nlinarith unfold sieveErrorEnvelope have h₁ : 0 ≤ Real.log T ^ 2 * T ^ (2 / 3 : ℝ) := by positivity have h₂ : 0 ≤ Real.log T ^ 8 * T ^ (1 / 2 : ℝ) := by positivity linarith nlinarith [mul_le_mul_of_nonneg_left henv₁ (by positivity : 0 ≤ 34 * (A + 1) ^ 2), mul_le_mul_of_nonneg_left henv₂ (by positivity : 0 ≤ 2 * (A + 1))] /- Original line 2525: Erdos416Proof.sieve_tail_coordinate_eventually -/ theorem sieve_tail_coordinate_eventually (A : ℝ) : ∀ᶠ T : ℝ in atTop, ∀ L : ℕ, ∀ ζ : ℝ, (L : ℝ) ≤ A * Real.log T → ζ ≤ T ^ (-1 / 3 : ℝ) → ζ + (2 * L + 3 : ℝ) * normalityDelta T ≤ 2 * T ^ (-1 / 3 : ℝ) := by filter_upwards [dimension_delta_small (A + 2) (η := 1 / 2) (by norm_num), eventually_ge_atTop (Real.exp 1)] with T hsmall hT intro L ζ hL hζ have hT1 : 1 ≤ T := (Real.one_le_exp (by norm_num : (0 : ℝ) ≤ 1)).trans hT have hU : 1 ≤ Real.log T := by have h := Real.log_le_log (Real.exp_pos 1) hT simpa using h have hδ := normalityDelta_nonneg hT1 have hL2 : ((L + 2 : ℕ) : ℝ) ≤ (A + 2) * Real.log T := by push_cast nlinarith have h := hsmall (L + 2) hL2 push_cast at h have hpowers : T ^ (-2 / 5 : ℝ) ≤ T ^ (-1 / 3 : ℝ) := Real.rpow_le_rpow_of_exponent_le hT1 (by norm_num) nlinarith /- Original line 2546: Erdos416Proof.fordLogPrefactor -/ noncomputable def fordLogPrefactor (T ν c : ℝ) (k l D : ℕ) : ℝ := 6 * k * Real.log (c * T) + D * Real.log ((k : ℝ) + 1) + (20 * (k + l : ℕ) * Real.log (k + l : ℕ) + 1) * ν * T /- Original line 2550: Erdos416Proof.fordLogPrefactor_bound -/ theorem fordLogPrefactor_bound {T ν c B : ℝ} {k l D : ℕ} (hT : 0 < T) (hU : 1 ≤ Real.log T) (hc : 0 < c) (hB : 0 ≤ B) (hkl1 : 1 ≤ k + l) (hk : (k : ℝ) ≤ B * Real.log T) (hkl : (k + l : ℕ) ≤ B * Real.log T) (hlogk : Real.log ((k : ℝ) + 1) ≤ Real.log T) (hlogkl : Real.log (k + l : ℕ) ≤ Real.log T) (hν : ν ≤ 2 * T ^ (-1 / 3 : ℝ)) : fordLogPrefactor T ν c k l D ≤ 6 * B * (|Real.log c| + 1) * Real.log T ^ 2 + D * Real.log T + 42 * B * (Real.log T ^ 2 * T ^ (2 / 3 : ℝ)) := by have hU0 : 0 ≤ Real.log T := by linarith have hkl0 : (1 : ℝ) ≤ (k + l : ℕ) := by exact_mod_cast hkl1 have hlogkl0 := Real.log_nonneg hkl0 have hlogc : Real.log (c * T) ≤ (|Real.log c| + 1) * Real.log T := by rw [Real.log_mul hc.ne' hT.ne'] nlinarith [le_abs_self (Real.log c), abs_nonneg (Real.log c), mul_le_mul_of_nonneg_left hU (abs_nonneg (Real.log c))] have h₁ : 6 * k * Real.log (c * T) ≤ 6 * B * (|Real.log c| + 1) * Real.log T ^ 2 := by calc _ ≤ 6 * k * ((|Real.log c| + 1) * Real.log T) := mul_le_mul_of_nonneg_left hlogc (by positivity) _ ≤ 6 * (B * Real.log T) * ((|Real.log c| + 1) * Real.log T) := by gcongr _ = _ := by ring have h₂ : D * Real.log ((k : ℝ) + 1) ≤ D * Real.log T := mul_le_mul_of_nonneg_left hlogk (Nat.cast_nonneg D) have hmon := mul_le_mul hkl hlogkl hlogkl0 (mul_nonneg hB hU0) have hBU : 1 ≤ B * Real.log T ^ 2 := by have hBU1 : 1 ≤ B * Real.log T := hkl0.trans hkl nlinarith [mul_le_mul_of_nonneg_left hU (mul_nonneg hB hU0)] have hcoeff : 20 * (k + l : ℕ) * Real.log (k + l : ℕ) + 1 ≤ 21 * B * Real.log T ^ 2 := by nlinarith have hcoeff0 : 0 ≤ 20 * (k + l : ℕ) * Real.log (k + l : ℕ) + 1 := by positivity have hνT : ν * T ≤ 2 * T ^ (2 / 3 : ℝ) := by calc ν * T ≤ (2 * T ^ (-1 / 3 : ℝ)) * T := mul_le_mul_of_nonneg_right hν hT.le _ = 2 * (T ^ (-1 / 3 : ℝ) * T ^ (1 : ℝ)) := by rw [Real.rpow_one]; ring _ = 2 * T ^ ((-1 / 3 : ℝ) + 1) := by rw [Real.rpow_add hT] _ = _ := by congr 2; norm_num have h₃ : (20 * (k + l : ℕ) * Real.log (k + l : ℕ) + 1) * ν * T ≤ 42 * B * (Real.log T ^ 2 * T ^ (2 / 3 : ℝ)) := by calc _ = (20 * (k + l : ℕ) * Real.log (k + l : ℕ) + 1) * (ν * T) := by ring _ ≤ (20 * (k + l : ℕ) * Real.log (k + l : ℕ) + 1) * (2 * T ^ (2 / 3 : ℝ)) := mul_le_mul_of_nonneg_left hνT hcoeff0 _ ≤ (21 * B * Real.log T ^ 2) * (2 * T ^ (2 / 3 : ℝ)) := mul_le_mul_of_nonneg_right hcoeff (by positivity) _ = _ := by ring unfold fordLogPrefactor linarith /- Original line 2601: Erdos416Proof.fordPrefactorConstant -/ noncomputable def fordPrefactorConstant (A c : ℝ) (D : ℕ) : ℝ := 6 * (A + 2) * (|Real.log c| + 1) + D + 42 * (A + 2) /- Original line 2604: Erdos416Proof.fordLogPrefactor_eventually -/ theorem fordLogPrefactor_eventually {A c : ℝ} (hA : 0 ≤ A) (hc : 0 < c) (D : ℕ) : ∀ᶠ T : ℝ in atTop, ∀ k l L : ℕ, ∀ ν : ℝ, 1 ≤ k + l → k + l ≤ L + 1 → (L : ℝ) ≤ A * Real.log T → ν ≤ 2 * T ^ (-1 / 3 : ℝ) → fordLogPrefactor T ν c k l D ≤ fordPrefactorConstant A c D * sieveErrorEnvelope T := by filter_upwards [dimension_log_bounds_eventually (A + 1), eventually_ge_atTop (Real.exp 1)] with T hdim hT intro k l L ν hkl1 hklL hL hν have hT0 : 0 < T := (Real.exp_pos 1).trans_le hT have hU : 1 ≤ Real.log T := by have h := Real.log_le_log (Real.exp_pos 1) hT simpa using h have hL1 : ((L + 1 : ℕ) : ℝ) ≤ (A + 1) * Real.log T := by push_cast nlinarith have hdim' := hdim (L + 1) hL1 push_cast at hdim' have hk : (k : ℝ) ≤ (A + 2) * Real.log T := by have hkL : k ≤ L + 2 := by omega have hkL' : (k : ℝ) ≤ (L : ℝ) + 2 := by exact_mod_cast hkL nlinarith [hdim'.1] have hkl : ((k + l : ℕ) : ℝ) ≤ (A + 2) * Real.log T := by have hkl' : ((k + l : ℕ) : ℝ) ≤ (L : ℝ) + 1 := by exact_mod_cast hklL nlinarith [hdim'.1] have hlogk : Real.log ((k : ℝ) + 1) ≤ Real.log T := by apply (Real.log_le_log (by positivity) (show (k : ℝ) + 1 ≤ (L : ℝ) + 1 + 1 by exact_mod_cast (show k + 1 ≤ L + 1 + 1 by omega))).trans hdim'.2 have hlogkl : Real.log (k + l : ℕ) ≤ Real.log T := by apply (Real.log_le_log (by exact_mod_cast (show 0 < k + l by omega)) (show ((k + l : ℕ) : ℝ) ≤ (L : ℝ) + 1 + 1 by exact_mod_cast (show k + l ≤ L + 1 + 1 by omega))).trans hdim'.2 have hbound := fordLogPrefactor_bound hT0 hU hc (by linarith : 0 ≤ A + 2) hkl1 hk hkl hlogk hlogkl hν (D := D) have henv₁ : Real.log T ^ 2 ≤ sieveErrorEnvelope T := by unfold sieveErrorEnvelope have h₁ : 0 ≤ Real.log T ^ 2 * T ^ (2 / 3 : ℝ) := by positivity have h₂ : 0 ≤ Real.log T ^ 8 * T ^ (1 / 2 : ℝ) := by positivity linarith have henv₂ : Real.log T ≤ sieveErrorEnvelope T := (show Real.log T ≤ Real.log T ^ 2 by nlinarith).trans henv₁ have henv₃ : Real.log T ^ 2 * T ^ (2 / 3 : ℝ) ≤ sieveErrorEnvelope T := by unfold sieveErrorEnvelope have h₁ : 0 ≤ Real.log T ^ 8 * T ^ (1 / 2 : ℝ) := by positivity have h₂ : 0 ≤ Real.log T ^ 2 := by positivity linarith unfold fordPrefactorConstant nlinarith [mul_le_mul_of_nonneg_left henv₁ (by positivity : 0 ≤ 6 * (A + 2) * (|Real.log c| + 1)), mul_le_mul_of_nonneg_left henv₂ (Nat.cast_nonneg D), mul_le_mul_of_nonneg_left henv₃ (by positivity : 0 ≤ 42 * (A + 2))] /- Original line 2655: Erdos416Proof.fordSievePrefactor -/ noncomputable def fordSievePrefactor (T ν c : ℝ) (k l D : ℕ) : ℝ := (c * T) ^ (6 * k) * ((k : ℝ) + 1) ^ D * (Real.exp (ν * T)) ^ (20 * (k + l : ℕ) * Real.log (k + l : ℕ) + 1) /- Original line 2659: Erdos416Proof.log_fordSievePrefactor -/ theorem log_fordSievePrefactor {T c : ℝ} (hT : 0 < T) (hc : 0 < c) (ν : ℝ) (k l D : ℕ) : Real.log (fordSievePrefactor T ν c k l D) = fordLogPrefactor T ν c k l D := by unfold fordSievePrefactor fordLogPrefactor rw [Real.log_mul (by positivity) (by positivity), Real.log_mul (by positivity) (by positivity)] rw [Real.log_pow, Real.log_pow, Real.log_rpow (Real.exp_pos _), Real.log_exp] push_cast ring /-- The explicit prefactor and normality/rounding losses are absorbed uniformly over every permitted tuple length. K allows an additional fixed multiple of the same envelope, such as the later summation over boxes and common products. -/ /- Original line 2672: Erdos416Proof.ford_sieve_losses_absorbed -/ theorem ford_sieve_losses_absorbed {A c : ℝ} (hA : 0 ≤ A) (hc : 0 < c) (D : ℕ) (K : ℝ) : ∀ᶠ T : ℝ in atTop, ∀ k l L : ℕ, ∀ ζ : ℝ, 1 ≤ k + l → k + l ≤ L + 1 → (L : ℝ) ≤ A * Real.log T → ζ ≤ T ^ (-1 / 3 : ℝ) → -(1 / 2 : ℝ) * T ^ (7 / 8 : ℝ) + normalitySieveLoss T L + fordLogPrefactor T (ζ + (2 * L + 3 : ℝ) * normalityDelta T) c k l D + K * sieveErrorEnvelope T ≤ -(1 / 4 : ℝ) * T ^ (7 / 8 : ℝ) := by filter_upwards [normalitySieveLoss_eventually A hA, fordLogPrefactor_eventually hA hc D, sieve_tail_coordinate_eventually A, sieve_exponent_saving (34 * (A + 1) ^ 2 + 2 * (A + 1) + fordPrefactorConstant A c D + K)] with T hnormal hpref htail hsave intro k l L ζ hkl1 hklL hL hζ have h₁ := hnormal L hL have h₂ := hpref k l L _ hkl1 hklL hL (htail L ζ hL hζ) linarith end Erdos416Proof /- Adapted from PrimeNumberTheoremAnd, Apache-2.0. Authors and source history: https://github.com/AlexKontorovich/PrimeNumberTheoremAnd Pinned revision: a5154676af9aa3095150ee410cdda80555aa0642. The Apache-2.0 license from PNT-LICENSE.txt is reproduced at the end of this file. Ported to Lean 4.33.1; compatibility changes are recorded in work/prepare_pnt_port.py. Selected proofs use no added axioms. -/ section PNTDependencyPort /- Source module: Mathlib/Analysis/Asymptotics/Asymptotics -/ section PNTSource_0 open Filter Topology namespace Asymptotics variable {α : Type*} {β : Type*} {E : Type*} {F : Type*} {G : Type*} {E' : Type*} {F' : Type*} {G' : Type*} {E'' : Type*} {F'' : Type*} {G'' : Type*} {R : Type*} {R' : Type*} {𝕜 : Type*} {𝕜' : Type*} variable [Norm E] [Norm F] [Norm G] variable [SeminormedAddCommGroup E'] [SeminormedAddCommGroup F'] [SeminormedAddCommGroup G'] [NormedAddCommGroup E''] [NormedAddCommGroup F''] [NormedAddCommGroup G''] [SeminormedRing R] [SeminormedRing R'] /- Original line 2725: Asymptotics.isLittleO_const_id_cocompact -/ theorem isLittleO_const_id_cocompact [ProperSpace F''] (c : E'') : (fun _x : F'' => c) =o[cocompact F''] id := isLittleO_const_left.2 <| Or.inr tendsto_norm_cocompact_atTop -- to replace existing `isLittleO_const_id_atTop` /- Original line 2730: Asymptotics.isLittleO_const_id_atTop2 -/ theorem isLittleO_const_id_atTop2 [LinearOrder F''] [NoMaxOrder F''] [ClosedIciTopology F''] [ProperSpace F''] (c : E'') : (fun _x : F'' => c) =o[atTop] id := (isLittleO_const_id_cocompact c).mono atTop_le_cocompact -- to replace existing `isLittleO_const_id_atBot` /- Original line 2735: Asymptotics.isLittleO_const_id_atBot2 -/ theorem isLittleO_const_id_atBot2 [LinearOrder F''] [NoMinOrder F''] [ClosedIicTopology F''] [ProperSpace F''] (c : E'') : (fun _x : F'' => c) =o[atBot] id := (isLittleO_const_id_cocompact c).mono atBot_le_cocompact /- Original line 2739: Asymptotics._root_.Filter.Eventually.natCast -/ theorem _root_.Filter.Eventually.natCast {f : ℝ → Prop} (hf : ∀ᶠ x in atTop, f x) : ∀ᶠ n : ℕ in atTop, f n := tendsto_natCast_atTop_atTop.eventually hf /- Original line 2743: Asymptotics.IsBigO.natCast -/ theorem IsBigO.natCast {f g : ℝ → E} (h : f =O[atTop] g) : (fun n : ℕ => f n) =O[atTop] fun n : ℕ => g n := h.comp_tendsto tendsto_natCast_atTop_atTop end Asymptotics end PNTSource_0 /- Source module: Mathlib/Analysis/SpecialFunctions/Log/Basic -/ section PNTSource_1 open Filter Real /-- log^b x / x^a goes to zero at infinity if a is positive. -/ /- Original line 2757: Real.tendsto_pow_log_div_pow_atTop -/ theorem Real.tendsto_pow_log_div_pow_atTop (a : ℝ) (b : ℝ) (ha : 0 < a) : Filter.Tendsto (fun x ↦ log x ^ b / x^a) Filter.atTop (nhds 0) := by apply Asymptotics.isLittleO_iff_tendsto' _|>.mp <| isLittleO_log_rpow_rpow_atTop _ ha filter_upwards [eventually_gt_atTop 0] with x hx intro h rw [rpow_eq_zero hx.le ha.ne.symm] at h exfalso linarith end PNTSource_1 /- Source module: Mathlib/Algebra/Notation/Support -/ section PNTSource_2 namespace Function variable {α : Type*} [Zero α] /- Original line 2775: Function.support_id -/ theorem support_id : support (id : α → α) = {0}ᶜ := by ext; simp /- Original line 2778: Function.support_id' -/ theorem support_id' {α : Type*} [Zero α] : support (fun x : α ↦ x) = {0}ᶜ := support_id end Function end PNTSource_2 /- Source module: Sobolev -/ section PNTSource_3 open Real Complex MeasureTheory Filter Topology BoundedContinuousFunction SchwartzMap BigOperators open scoped ContDiff variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] {n : ℕ} /- Original line 2793: CS -/ structure CS (n : ℕ) (E : Type*) [NormedAddCommGroup E] [NormedSpace ℝ E] where toFun : ℝ → E h1 : ContDiff ℝ n toFun h2 : HasCompactSupport toFun theorem CS.ext {n : ℕ} {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] {f g : CS n E} (h : f.toFun = g.toFun) : f = g := by cases f cases g cases h rfl /- Original line 2798: trunc -/ structure trunc extends (CS 2 ℝ) where h3 : (Set.Icc (-1) (1)).indicator 1 ≤ toFun h4 : toFun ≤ Set.indicator (Set.Ioo (-2) (2)) 1 /- Original line 2802: W1 -/ structure W1 (n : ℕ) (E : Type*) [NormedAddCommGroup E] [NormedSpace ℝ E] where toFun : ℝ → E smooth : ContDiff ℝ n toFun integrable : ∀ ⦃k⦄, k ≤ n → Integrable (iteratedDeriv k toFun) /- Original line 2807: W21 -/ abbrev W21 := W1 2 ℂ section lemmas /- Original line 2811: funscale -/ noncomputable def funscale {E : Type*} (g : ℝ → E) (R x : ℝ) : E := g (R⁻¹ • x) /- Original line 2813: contDiff_ofReal -/ theorem contDiff_ofReal : ContDiff ℝ ∞ ofReal := by have key x : HasDerivAt ofReal 1 x := hasDerivAt_id x |>.ofReal_comp have key' : deriv ofReal = fun _ => 1 := by ext x ; exact (key x).deriv refine contDiff_infty_iff_deriv.mpr ⟨fun x => (key x).differentiableAt, ?_⟩ simpa [key'] using contDiff_const omit [NormedSpace ℝ E] in /- Original line 2820: tendsto_funscale -/ theorem tendsto_funscale {f : ℝ → E} (hf : ContinuousAt f 0) (x : ℝ) : Tendsto (fun R => funscale f R x) atTop (𝓝 (f 0)) := hf.tendsto.comp (by simpa using tendsto_inv_atTop_zero.mul_const x) end lemmas namespace CS variable {f : CS n E} {R x v : ℝ} /- Original line 2830: CS.__anonymous_2830 -/ abbrev instCoeFunForallReal : CoeFun (CS n E) (fun _ => ℝ → E) where coe := CS.toFun /- Original line 2832: CS.__anonymous_2832 -/ noncomputable abbrev instCoeRealComplex : letI := @_root_.CS.instCoeFunForallReal Coe (CS n ℝ) (CS n ℂ) := by letI := @_root_.CS.instCoeFunForallReal exact { coe f := ⟨fun x => f x, contDiff_ofReal.of_le (mod_cast le_top) |>.comp f.h1, f.h2.comp_left (g := ofReal) rfl⟩ } /- Original line 2835: CS.neg -/ noncomputable def neg : letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex ∀ (f : CS n E), CS n E := by intro f letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex exact { toFun := -f h1 := f.h1.neg h2 := by simpa [HasCompactSupport, tsupport] using f.h2 } /- Original line 2840: CS.__anonymous_2840 -/ noncomputable abbrev instNeg : letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex Neg (CS n E) := by letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex exact { neg := neg } /- Original line 2842: CS.neg_apply -/ theorem neg_apply : letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg ∀ {x : ℝ}, (-f) x = - (f x) := by intro x letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg exact rfl /- Original line 2844: CS.smul -/ noncomputable def smul : letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg ∀ (R : ℝ) (f : CS n E), CS n E := by intro R f letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg exact ⟨R • f, f.h1.const_smul R, f.h2.smul_left⟩ /- Original line 2846: CS.__anonymous_2846 -/ noncomputable abbrev instHSMulReal : letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg HSMul ℝ (CS n E) (CS n E) := by letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg exact { hSMul := smul } /- Original line 2848: CS.smul_apply -/ theorem smul_apply : letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal (R • f) x = R • f x := by letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal exact rfl /- Original line 2850: CS.continuous -/ theorem continuous : letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal ∀ (f : CS n E), Continuous f := by intro f letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal exact f.h1.continuous /- Original line 2852: CS.deriv -/ noncomputable def deriv : letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal ∀ (f : CS (n + 1) E), CS n E := by intro f letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal exact { toFun := _root_.deriv f h1 := (contDiff_succ_iff_deriv.mp f.h1).2.2 h2 := f.h2.deriv } /- Original line 2857: CS.hasDerivAt -/ theorem hasDerivAt : letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal ∀ (f : CS (n + 1) E) (x : ℝ), HasDerivAt f (f.deriv x) x := by intro f x letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal exact (f.h1.differentiable (by simp[CS.neg_apply, CS.smul_apply] )).differentiableAt.hasDerivAt /- Original line 2860: CS.deriv_apply -/ theorem deriv_apply : letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal ∀ {f : CS (n + 1) E} {x : ℝ}, f.deriv x = _root_.deriv f x := by intro f x letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal exact rfl /- Original line 2862: CS.deriv_smul -/ theorem deriv_smul : letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal ∀ {f : CS (n + 1) E}, (R • f).deriv = R • f.deriv := by intro f letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal exact by apply CS.ext; funext x ; exact (f.hasDerivAt x |>.const_smul R).deriv /- Original line 2865: CS.scale -/ noncomputable def scale : letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal ∀ (g : CS n E) (R : ℝ), CS n E := by intro g R letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal exact by by_cases h : R = 0 · exact ⟨0, contDiff_const, by simp [CS.neg_apply, CS.smul_apply, HasCompactSupport, tsupport]⟩ · refine ⟨fun x => funscale g R x, ?_, ?_⟩ · exact g.h1.comp (contDiff_const_smul R⁻¹) · exact g.h2.comp_smul (inv_ne_zero h) /- Original line 2872: CS.deriv_scale -/ theorem deriv_scale : letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal ∀ {f : CS (n + 1) E}, (f.scale R).deriv = R⁻¹ • f.deriv.scale R := by intro f letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal exact by apply CS.ext; funext v ; by_cases hR : R = 0 · simp [CS.neg_apply, CS.smul_apply, hR, scale, deriv] · simp only [scale, hR, ↓reduceDIte, smul_apply] exact ((f.hasDerivAt (R⁻¹ • v)).scomp v (by simpa [CS.neg_apply, CS.smul_apply] using! (hasDerivAt_id v).const_smul R⁻¹)).deriv /- Original line 2879: CS.deriv_scale' -/ theorem deriv_scale' : letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal ∀ {f : CS (n + 1) E}, (f.scale R).deriv v = R⁻¹ • f.deriv (R⁻¹ • v) := by intro f letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal exact by rw [deriv_scale, smul_apply] by_cases hR : R = 0 <;> simp [CS.neg_apply, CS.smul_apply, hR, scale, funscale] /- Original line 2884: CS.hasDerivAt_scale -/ theorem hasDerivAt_scale : letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal ∀ (f : CS (n + 1) E) (R x : ℝ), HasDerivAt (f.scale R) (R⁻¹ • _root_.deriv f (R⁻¹ • x)) x := by intro f R x letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal exact by convert hasDerivAt (f.scale R) x ; rw [deriv_scale'] ; rfl /- Original line 2888: CS.tendsto_scale -/ theorem tendsto_scale : letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal ∀ (f : CS n E) (x : ℝ), Tendsto (fun R => f.scale R x) atTop (𝓝 (f 0)) := by intro f x letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal exact by apply (tendsto_funscale f.continuous.continuousAt x).congr' filter_upwards [eventually_ne_atTop 0] with R hR ; simp [CS.neg_apply, CS.smul_apply, scale, hR] /- Original line 2892: CS.bounded -/ theorem bounded : letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal ∃ C, ∀ v, ‖f v‖ ≤ C := by letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal exact by obtain ⟨x, hx⟩ := (continuous_norm.comp f.continuous).exists_forall_ge_of_hasCompactSupport f.h2.norm exact ⟨_, hx⟩ end CS namespace trunc /- Original line 2901: trunc.__anonymous_2901 -/ noncomputable abbrev instCoeFunForallReal : letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal CoeFun trunc (fun _ => ℝ → ℝ) := by letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal exact { coe f := f.toFun } /- Original line 2903: trunc.__anonymous_2903 -/ noncomputable abbrev instCoeCSOfNatNatReal : letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal Coe trunc (CS 2 ℝ) := by letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal exact { coe := trunc.toCS } /- Original line 2905: trunc.nonneg -/ theorem nonneg : letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal ∀ (g : trunc) (x : ℝ), 0 ≤ g x := by intro g x letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal exact (Set.indicator_nonneg (by simp) x).trans (g.h3 x) /- Original line 2907: trunc.le_one -/ theorem le_one : letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal ∀ (g : trunc) (x : ℝ), g x ≤ 1 := by intro g x letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal exact (g.h4 x).trans <| Set.indicator_le_self' (by simp) x /- Original line 2910: trunc.zero -/ theorem zero : letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal ∀ (g : trunc), g =ᶠ[𝓝 0] 1 := by intro g letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal exact by have : Set.Icc (-1) 1 ∈ 𝓝 (0 : ℝ) := by apply Icc_mem_nhds <;> linarith exact eventually_of_mem this (fun x hx => le_antisymm (g.le_one x) (by simpa [hx] using g.h3 x)) /- Original line 2914: trunc.zero_at -/ theorem zero_at : letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal ∀ {g : trunc}, g 0 = 1 := by intro g letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal exact g.zero.eq_of_nhds end trunc namespace W1 /- Original line 2920: W1.__anonymous_2920 -/ noncomputable abbrev instCoeFunForallReal : letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal CoeFun (W1 n E) (fun _ => ℝ → E) := by letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal exact { coe := W1.toFun } /- Original line 2922: W1.continuous -/ theorem continuous : letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal ∀ (f : W1 n E), Continuous f := by intro f letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal exact f.smooth.continuous /- Original line 2924: W1.differentiable -/ theorem differentiable : letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal ∀ (f : W1 (n + 1) E), Differentiable ℝ f := by intro f letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal exact f.smooth.differentiable (by simp) /- Original line 2927: W1.iteratedDeriv_sub -/ theorem iteratedDeriv_sub : letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal ∀ {f g : ℝ → E} (hf : ContDiff ℝ n f) (hg : ContDiff ℝ n g), iteratedDeriv n (f - g) = iteratedDeriv n f - iteratedDeriv n g := by intro f g hf hg letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal exact by induction n generalizing f g with | zero => rfl | succ n ih => have hf' : ContDiff ℝ n (deriv f) := hf.iterate_deriv' n 1 have hg' : ContDiff ℝ n (deriv g) := hg.iterate_deriv' n 1 have hfg : deriv (f - g) = deriv f - deriv g := by ext x ; apply deriv_sub · exact (hf.differentiable (by simp)).differentiableAt · exact (hg.differentiable (by simp)).differentiableAt simp_rw [iteratedDeriv_succ', ← ih hf' hg', hfg] /- Original line 2940: W1.deriv -/ noncomputable def deriv : letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal ∀ (f : W1 (n + 1) E), W1 n E := by intro f letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal exact { toFun := _root_.deriv f smooth := contDiff_succ_iff_deriv.mp f.smooth |>.2.2 integrable k hk := by simpa [iteratedDeriv_succ'] using f.integrable (Nat.succ_le_succ hk) } /- Original line 2946: W1.hasDerivAt -/ theorem hasDerivAt : letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal ∀ (f : W1 (n + 1) E) (x : ℝ), HasDerivAt f (f.deriv x) x := by intro f x letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal exact f.differentiable.differentiableAt.hasDerivAt /- Original line 2949: W1.sub -/ noncomputable def sub : letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal ∀ (f g : W1 n E), W1 n E := by intro f g letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal exact { toFun := f - g smooth := f.smooth.sub g.smooth integrable k hk := by have hf : ContDiff ℝ k f := f.smooth.of_le (by simp [hk]) have hg : ContDiff ℝ k g := g.smooth.of_le (by simp [hk]) simpa [iteratedDeriv_sub hf hg] using (f.integrable hk).sub (g.integrable hk) } /- Original line 2957: W1.__anonymous_2957 -/ noncomputable abbrev instSub : letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal Sub (W1 n E) := by letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal exact { sub := sub } /- Original line 2959: W1.integrable_iteratedDeriv_Schwarz -/ theorem integrable_iteratedDeriv_Schwarz : letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal letI := @_root_.W1.instSub ∀ {f : 𝓢(ℝ, ℂ)}, Integrable (iteratedDeriv n f) := by intro f letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal letI := @_root_.W1.instSub exact by induction n generalizing f with | zero => exact f.integrable | succ n ih => simpa [iteratedDeriv_succ'] using! ih (f := SchwartzMap.derivCLM ℝ ℂ f) /- Original line 2964: W1.of_Schwartz -/ noncomputable def of_Schwartz : letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal letI := @_root_.W1.instSub ∀ (f : 𝓢(ℝ, ℂ)), W1 n ℂ := by intro f letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal letI := @_root_.W1.instSub exact { toFun := f smooth := f.smooth n integrable _ _ := integrable_iteratedDeriv_Schwarz } end W1 namespace W21 variable {f : W21} /- Original line 2975: W21.norm -/ noncomputable def norm : letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal letI := @_root_.W1.instSub ∀ (f : ℝ → ℂ), ℝ := by intro f letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal letI := @_root_.W1.instSub exact (∫ v, ‖f v‖) + (4 * π ^ 2)⁻¹ * (∫ v, ‖deriv (deriv f) v‖) /- Original line 2978: W21.norm_nonneg -/ theorem norm_nonneg : letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal letI := @_root_.W1.instSub ∀ {f : ℝ → ℂ}, 0 ≤ norm f := by intro f letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal letI := @_root_.W1.instSub exact add_nonneg (integral_nonneg (fun t => by simp)) (mul_nonneg (by positivity) (integral_nonneg (fun t => by simp))) /- Original line 2982: W21.__anonymous_2982 -/ noncomputable abbrev instNorm : letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal letI := @_root_.W1.instSub Norm W21 := by letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal letI := @_root_.W1.instSub exact { norm := norm ∘ W1.toFun } /- Original line 2984: W21.__anonymous_2984 -/ noncomputable abbrev instCoeSchwartzMapRealComplex : letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal letI := @_root_.W1.instSub letI := @_root_.W21.instNorm Coe 𝓢(ℝ, ℂ) W21 := by letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal letI := @_root_.W1.instSub letI := @_root_.W21.instNorm exact { coe := W1.of_Schwartz } /- Original line 2986: W21.ofCS2 -/ noncomputable def ofCS2 : letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal letI := @_root_.W1.instSub letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex ∀ (f : CS 2 ℂ), W21 := by intro f letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal letI := @_root_.W1.instSub letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex exact by refine ⟨f, f.h1, fun k hk => ?_⟩ ; match k with | 0 => exact f.h1.continuous.integrable_of_hasCompactSupport f.h2 | 1 => simpa [CS.neg_apply, CS.smul_apply] using (f.h1.continuous_deriv one_le_two).integrable_of_hasCompactSupport f.h2.deriv | 2 => simpa [CS.neg_apply, CS.smul_apply, iteratedDeriv_succ] using (f.h1.iterate_deriv' 0 2).continuous.integrable_of_hasCompactSupport f.h2.deriv.deriv /- Original line 2993: W21.__anonymous_2993 -/ noncomputable abbrev instCoeCSOfNatNatComplex : letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal letI := @_root_.W1.instSub letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex Coe (CS 2 ℂ) W21 := by letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal letI := @_root_.W1.instSub letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex exact { coe := ofCS2 } /- Original line 2995: W21.__anonymous_2995 -/ noncomputable abbrev instHMulCSOfNatNatComplex : letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal letI := @_root_.W1.instSub letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex HMul (CS 2 ℂ) W21 (CS 2 ℂ) := by letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal letI := @_root_.W1.instSub letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex exact { hMul g f := ⟨g * f, g.h1.mul f.smooth, g.h2.mul_right⟩ } /- Original line 2998: W21.__anonymous_2998 -/ noncomputable abbrev instHMulCSOfNatNatRealComplex : letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal letI := @_root_.W1.instSub letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex HMul (CS 2 ℝ) W21 (CS 2 ℂ) := by letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal letI := @_root_.W1.instSub letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex exact { hMul g f := (g : CS 2 ℂ) * f } /- Original line 3000: W21.hf -/ theorem hf : letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal letI := @_root_.W1.instSub letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex ∀ (f : W21), Integrable f := by intro f letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal letI := @_root_.W1.instSub letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex exact f.integrable zero_le_two /- Original line 3002: W21.hf' -/ theorem hf' : letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal letI := @_root_.W1.instSub letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex ∀ (f : W21), Integrable (deriv f) := by intro f letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal letI := @_root_.W1.instSub letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex exact by simpa [iteratedDeriv_succ] using f.integrable one_le_two /- Original line 3005: W21.hf'' -/ theorem hf'' : letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal letI := @_root_.W1.instSub letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex ∀ (f : W21), Integrable (deriv (deriv f)) := by intro f letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal letI := @_root_.W1.instSub letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex exact by simpa [iteratedDeriv_succ] using f.integrable le_rfl end W21 /- Original line 3010: W21_approximation -/ theorem W21_approximation : letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal letI := @_root_.W1.instSub letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex ∀ (f : W21) (g : trunc), Tendsto (fun R => ‖f - (g.scale R * f : W21)‖) atTop (𝓝 0) := by intro f g letI := @_root_.CS.instCoeFunForallReal letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg letI := @_root_.CS.instHSMulReal letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal letI := @_root_.W1.instSub letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex exact by -- Definitions let f' := f.deriv let f'' := f'.deriv let g' := (g : CS 2 ℝ).deriv let g'' := g'.deriv let h R v := 1 - g.scale R v let h' R := - (g.scale R).deriv let h'' R := - (g.scale R).deriv.deriv -- Properties of h have ch {R} : Continuous (fun v => (h R v : ℂ)) := continuous_ofReal.comp <| continuous_const.sub (CS.continuous _) have ch' {R} : Continuous (fun v => (h' R v : ℂ)) := continuous_ofReal.comp (CS.continuous _) have ch'' {R} : Continuous (fun v => (h'' R v : ℂ)) := continuous_ofReal.comp (CS.continuous _) have dh R v : HasDerivAt (h R) (h' R v) v := by convert! CS.hasDerivAt_scale (g : CS 2 ℝ) R v |>.const_sub 1 using 1 simp [CS.neg_apply, CS.smul_apply, trunc.zero_at, h', CS.deriv_scale', show g.deriv.toFun = deriv g.toFun from rfl] have dh' R v : HasDerivAt (h' R) (h'' R v) v := ((g.scale R).deriv.hasDerivAt v).neg have hh1 R v : |h R v| ≤ 1 := by by_cases hR : R = 0 <;> simp only [CS.scale, funscale, smul_eq_mul, hR, ↓reduceDIte, Pi.zero_apply, sub_zero, abs_one, le_refl, h] rw [abs_le] ; constructor <;> linarith [g.le_one (R⁻¹ * v), g.nonneg (R⁻¹ * v)] have vR v : Tendsto (fun R : ℝ => v * R⁻¹) atTop (𝓝 0) := by simpa [CS.neg_apply, CS.smul_apply, trunc.zero_at] using tendsto_inv_atTop_zero.const_mul v -- Proof convert_to Tendsto (fun R => W21.norm (fun v => h R v * f v)) atTop (𝓝 0) · ext R ; change W21.norm _ = _ ; congr ; ext v ; simp [CS.neg_apply, CS.smul_apply, trunc.zero_at, h, sub_mul] ; rfl rw [show (0 : ℝ) = 0 + ((4 * π ^ 2)⁻¹ : ℝ) * 0 by simp[CS.neg_apply, CS.smul_apply, trunc.zero_at] ] refine Tendsto.add ?_ (Tendsto.const_mul _ ?_) · let F R v := ‖h R v * f v‖ have eh v : ∀ᶠ R in atTop, h R v = 0 := by filter_upwards [(vR v).eventually g.zero, eventually_ne_atTop 0] with R hR hR' simp [CS.neg_apply, CS.smul_apply, trunc.zero_at, h, hR, CS.scale, hR', funscale, mul_comm R⁻¹] have e1 : ∀ᶠ (n : ℝ) in atTop, AEStronglyMeasurable (F n) volume := by apply Eventually.of_forall ; intro R exact (ch.mul f.continuous).norm.aestronglyMeasurable have e2 : ∀ᶠ (n : ℝ) in atTop, ∀ᵐ (a : ℝ), ‖F n a‖ ≤ ‖f a‖ := by apply Eventually.of_forall ; intro R apply Eventually.of_forall ; intro v simpa [CS.neg_apply, CS.smul_apply, trunc.zero_at, F] using mul_le_mul (hh1 R v) le_rfl (by simp[CS.neg_apply, CS.smul_apply, trunc.zero_at] ) zero_le_one have e4 : ∀ᵐ (a : ℝ), Tendsto (fun n ↦ F n a) atTop (𝓝 0) := by apply Eventually.of_forall ; intro v apply tendsto_nhds_of_eventually_eq ; filter_upwards [eh v] with R hR ; simp [CS.neg_apply, CS.smul_apply, trunc.zero_at, F, hR] simpa [CS.neg_apply, CS.smul_apply, trunc.zero_at, F] using tendsto_integral_filter_of_dominated_convergence _ e1 e2 f.hf.norm e4 · let F R v := ‖h'' R v * f v + 2 * h' R v * f' v + h R v * f'' v‖ convert_to Tendsto (fun R ↦ ∫ (v : ℝ), F R v) atTop (𝓝 0) · have this R v : deriv (deriv (fun v => h R v * f v)) v = h'' R v * f v + 2 * h' R v * f' v + h R v * f'' v := by have df v : HasDerivAt f (f' v) v := f.hasDerivAt v have df' v : HasDerivAt f' (f'' v) v := f'.hasDerivAt v have l3 v : HasDerivAt (fun v => h R v * f v) (h' R v * f v + h R v * f' v) v := (dh R v).ofReal_comp.mul (df v) have l5 : HasDerivAt (fun v => h' R v * f v) (h'' R v * f v + h' R v * f' v) v := (dh' R v).ofReal_comp.mul (df v) have l7 : HasDerivAt (fun v => h R v * f' v) (h' R v * f' v + h R v * f'' v) v := (dh R v).ofReal_comp.mul (df' v) have d1 : deriv (fun v => h R v * f v) = fun v => h' R v * f v + h R v * f' v := funext (fun v => (l3 v).deriv) rw [d1] ; convert! (l5.add l7).deriv using 1 ; ring simp_rw [this, F] obtain ⟨c1, mg'⟩ := g'.bounded obtain ⟨c2, mg''⟩ := g''.bounded let bound v := c2 * ‖f v‖ + 2 * c1 * ‖f' v‖ + ‖f'' v‖ have e1 : ∀ᶠ (n : ℝ) in atTop, AEStronglyMeasurable (F n) volume := by apply Eventually.of_forall ; intro R ; apply (Continuous.norm ?_).aestronglyMeasurable exact ((ch''.mul f.continuous).add ((continuous_const.mul ch').mul f.deriv.continuous)).add (ch.mul f.deriv.deriv.continuous) have e2 : ∀ᶠ R in atTop, ∀ᵐ (a : ℝ), ‖F R a‖ ≤ bound a := by have hc1 : ∀ᶠ R in atTop, ∀ v, |h' R v| ≤ c1 := by filter_upwards [eventually_ge_atTop 1] with R hR v have hR' : R ≠ 0 := by linarith have : 0 ≤ R := by linarith simp only [CS.deriv_scale, CS.neg_apply, CS.smul_apply, smul_eq_mul, abs_neg, abs_mul, abs_inv, abs_eq_self.mpr this, ge_iff_le, h'] simp only [CS.scale, hR', ↓reduceDIte, funscale, smul_eq_mul] convert_to _ ≤ c1 * 1 · simp[CS.neg_apply, CS.smul_apply, trunc.zero_at] · rw [mul_comm] apply mul_le_mul (mg' _) (inv_le_of_inv_le₀ (by linarith) (by simpa [CS.neg_apply, CS.smul_apply, trunc.zero_at] using hR)) (by positivity) exact (abs_nonneg _).trans (mg' 0) have hc2 : ∀ᶠ R in atTop, ∀ v, |h'' R v| ≤ c2 := by filter_upwards [eventually_ge_atTop 1] with R hR v have e1 : 0 ≤ R := by linarith have e2 : R⁻¹ ≤ 1 := inv_le_of_inv_le₀ (by linarith) (by simpa [CS.neg_apply, CS.smul_apply, trunc.zero_at] using hR) have e3 : R ≠ 0 := by linarith simp only [CS.deriv_scale, CS.deriv_smul, CS.neg_apply, CS.smul_apply, smul_eq_mul, abs_neg, abs_mul, abs_inv, abs_eq_self.mpr e1, ge_iff_le, h''] convert_to _ ≤ 1 * (1 * c2) · simp[CS.neg_apply, CS.smul_apply, trunc.zero_at] apply mul_le_mul e2 ?_ (by positivity) zero_le_one apply mul_le_mul e2 ?_ (by positivity) zero_le_one simp only [CS.scale, e3, ↓reduceDIte, funscale, smul_eq_mul] ; apply mg'' filter_upwards [hc1, hc2] with R hc1 hc2 apply Eventually.of_forall ; intro v ; specialize hc1 v ; specialize hc2 v simp only [F, bound, norm_norm] refine (norm_add_le _ _).trans ?_ ; apply add_le_add · refine (norm_add_le _ _).trans ?_ ; apply add_le_add <;> simp only [Complex.norm_mul, Complex.norm_ofNat, norm_real, norm_eq_abs] <;> gcongr · simpa [CS.neg_apply, CS.smul_apply, trunc.zero_at] using mul_le_mul (hh1 R v) le_rfl (by simp[CS.neg_apply, CS.smul_apply, trunc.zero_at] ) zero_le_one have e3 : Integrable bound volume := (((f.hf.norm).const_mul _).add ((f.hf'.norm).const_mul _)).add f.hf''.norm have e4 : ∀ᵐ (a : ℝ), Tendsto (fun n ↦ F n a) atTop (𝓝 0) := by apply Eventually.of_forall ; intro v have evg' : g' =ᶠ[𝓝 0] 0 := by convert! ← g.zero.deriv ; exact deriv_const' _ have evg'' : g'' =ᶠ[𝓝 0] 0 := by convert! ← evg'.deriv ; exact deriv_const' _ refine tendsto_norm_zero.comp <| (ZeroAtFilter.add ?_ ?_).add ?_ · have eh'' v : ∀ᶠ R in atTop, h'' R v = 0 := by filter_upwards [(vR v).eventually evg'', eventually_ne_atTop 0] with R hR hR' simp only [CS.deriv_scale, CS.deriv_smul, CS.neg_apply, CS.smul_apply, smul_eq_mul, neg_eq_zero, mul_eq_zero, inv_eq_zero, hR', false_or, h''] simp only [CS.scale, hR', ↓reduceDIte, funscale, smul_eq_mul, mul_comm R⁻¹] exact hR apply tendsto_nhds_of_eventually_eq filter_upwards [eh'' v] with R hR ; simp [CS.neg_apply, CS.smul_apply, trunc.zero_at, hR] · have eh' v : ∀ᶠ R in atTop, h' R v = 0 := by filter_upwards [(vR v).eventually evg'] with R hR simp [CS.neg_apply, CS.smul_apply, trunc.zero_at, g'] at hR simp [CS.neg_apply, CS.smul_apply, trunc.zero_at, h', CS.deriv_scale', mul_comm R⁻¹, hR] apply tendsto_nhds_of_eventually_eq filter_upwards [eh' v] with R hR ; simp [CS.neg_apply, CS.smul_apply, trunc.zero_at, hR] · simpa [CS.neg_apply, CS.smul_apply, trunc.zero_at, h] using! ((g.tendsto_scale v).const_sub 1).ofReal.mul tendsto_const_nhds simpa [CS.neg_apply, CS.smul_apply, trunc.zero_at, F] using tendsto_integral_filter_of_dominated_convergence bound e1 e2 e3 e4 end PNTSource_3 /- Source module: Fourier -/ section PNTSource_4 open FourierTransform Real Complex MeasureTheory Filter Topology BoundedContinuousFunction SchwartzMap VectorFourier BigOperators /- Original line 3152: __anonymous_3152 -/ noncomputable abbrev realFunctionCoeFourier : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex ∀ {E : Type*}, Coe (E → ℝ) (E → ℂ) := by intro E letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex exact ⟨fun f n => f n⟩ section lemmas /- Original line 3156: nnnorm_eq_of_mem_circle -/ theorem nnnorm_eq_of_mem_circle : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.realFunctionCoeFourier.{0} ∀ (z : Circle), ‖z.val‖₊ = 1 := by intro z letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.realFunctionCoeFourier.{0} exact NNReal.coe_eq_one.mp (Circle.norm_coe z) /- Original line 3160: nnnorm_circle_smul -/ theorem nnnorm_circle_smul : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.realFunctionCoeFourier.{0} ∀ (z : Circle) (s : ℂ), ‖z • s‖₊ = ‖s‖₊ := by intro z s letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.realFunctionCoeFourier.{0} exact by simp [nnnorm_eq_of_mem_circle, show z • s = z.val * s from rfl] /- Original line 3164: e -/ noncomputable def e : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.realFunctionCoeFourier.{0} ∀ (u : ℝ), ℝ →ᵇ ℂ := by intro u letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.realFunctionCoeFourier.{0} exact { toFun v := 𝐞 (-v * u) map_bounded' := ⟨2, fun x y => (dist_le_norm_add_norm _ _).trans (by norm_num [Circle.norm_coe])⟩ } /- Original line 3169: e_apply -/ theorem e_apply : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.realFunctionCoeFourier.{0} ∀ (u : ℝ) (v : ℝ), e u v = 𝐞 (-v * u) := by intro u v letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.realFunctionCoeFourier.{0} exact rfl /- Original line 3171: hasDerivAt_e -/ theorem hasDerivAt_e : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.realFunctionCoeFourier.{0} ∀ {u x : ℝ}, HasDerivAt (e u) (-2 * π * u * I * e u x) x := by intro u x letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.realFunctionCoeFourier.{0} exact by have l2 : HasDerivAt (fun v => -v * u) (-u) x := by simpa only [neg_mul_comm] using hasDerivAt_mul_const (-u) convert! (hasDerivAt_fourierChar (-x * u)).scomp x l2 using 1 change _ = ((-u : ℝ) : ℂ) * _ -- `scomp` introduces ℝ-smul on ℂ, which we undo simp [e_apply] ; ring /- Original line 3178: fourierIntegral_deriv_aux2 -/ theorem fourierIntegral_deriv_aux2 : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.realFunctionCoeFourier.{0} ∀ (e : ℝ →ᵇ ℂ) {f : ℝ → ℂ} (hf : Integrable f), Integrable (⇑e * f) := by intro e f hf letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.realFunctionCoeFourier.{0} exact hf.bdd_mul e.continuous.aestronglyMeasurable (ae_of_all _ e.norm_coe_le_norm) /- Original line 3182: F_neg -/ theorem F_neg : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.realFunctionCoeFourier.{0} ∀ {f : ℝ → ℂ} {u : ℝ}, 𝓕 (fun x => -f x) u = - 𝓕 f u := by intro f u letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.realFunctionCoeFourier.{0} exact by simp [fourier_eq, integral_neg] /- Original line 3185: F_add -/ theorem F_add : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.realFunctionCoeFourier.{0} ∀ {f g : ℝ → ℂ} (hf : Integrable f) (hg : Integrable g) (x : ℝ), 𝓕 (fun x => f x + g x) x = 𝓕 f x + 𝓕 g x := by intro f g hf hg x letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.realFunctionCoeFourier.{0} exact by have : Continuous fun p : ℝ × ℝ ↦ ((innerₗ ℝ) p.1) p.2 := continuous_inner have := fourierIntegral_add continuous_fourierChar this hf hg exact congr_fun this x /- Original line 3191: F_sub -/ theorem F_sub : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.realFunctionCoeFourier.{0} ∀ {f g : ℝ → ℂ} (hf : Integrable f) (hg : Integrable g) (x : ℝ), 𝓕 (fun x => f x - g x) x = 𝓕 f x - 𝓕 g x := by intro f g hf hg x letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.realFunctionCoeFourier.{0} exact by simpa [F_add, F_neg, sub_eq_add_neg, Pi.neg_def] using F_add hf hg.neg x /- Original line 3195: F_mul -/ theorem F_mul : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.realFunctionCoeFourier.{0} ∀ {f : ℝ → ℂ} {c : ℂ} {u : ℝ}, 𝓕 (fun x => c * f x) u = c * 𝓕 f u := by intro f c u letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.realFunctionCoeFourier.{0} exact by exact congr_fun (VectorFourier.fourierIntegral_const_smul 𝐞 _ _ f c) u end lemmas /- Original line 3201: fourierIntegral_self_add_deriv_deriv -/ theorem fourierIntegral_self_add_deriv_deriv : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.realFunctionCoeFourier.{0} ∀ (f : W21) (u : ℝ), (1 + u ^ 2) * 𝓕 (f : ℝ → ℂ) u = 𝓕 (fun u : ℝ => (f u - (1 / (4 * π ^ 2)) * deriv^[2] f u : ℂ)) u := by intro f u letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.realFunctionCoeFourier.{0} exact by have l1 : Integrable (fun x => (((π : ℂ) ^ 2)⁻¹ * 4⁻¹) * deriv (deriv f) x) := by apply Integrable.const_mul ; simpa [F_mul, F_sub, iteratedDeriv_succ] using f.integrable le_rfl have l4 : Differentiable ℝ f := f.differentiable have l5 : Differentiable ℝ (deriv f) := f.deriv.differentiable simp [F_mul, F_sub, f.hf, l1, add_mul, Real.fourier_deriv f.hf' l5 f.hf'', Real.fourier_deriv f.hf l4 f.hf'] field_simp [pi_ne_zero] ; ring_nf ; simp[F_mul, F_sub] /- Original line 3211: deriv_ofReal -/ theorem deriv_ofReal : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.realFunctionCoeFourier.{0} deriv ofReal = fun _ => 1 := by letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.realFunctionCoeFourier.{0} exact by ext x ; exact ((hasDerivAt_id x).ofReal_comp).deriv /-- If, eventually in `T`, the integrand `f T` is bounded on `uIoc lo hi` by `B T` and `B T * |hi - lo| → 0`, then the interval integral `∫ x in lo..hi, f T x → 0`. -/ /- Original line 3216: tendsto_intervalIntegral_zero_of_uniform_norm_bound -/ theorem tendsto_intervalIntegral_zero_of_uniform_norm_bound : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.realFunctionCoeFourier.{0} ∀ {f : ℝ → ℝ → ℂ} {lo hi : ℝ} {B : ℝ → ℝ} (hB : Filter.Tendsto (fun T : ℝ => B T * |hi - lo|) Filter.atTop (nhds 0)) (hf : ∀ᶠ T in Filter.atTop, ∀ x ∈ Set.uIoc lo hi, ‖f T x‖ ≤ B T), Filter.Tendsto (fun T : ℝ => ∫ x in lo..hi, f T x) Filter.atTop (nhds 0) := by intro f lo hi B hB hf letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.realFunctionCoeFourier.{0} exact by rw [tendsto_zero_iff_norm_tendsto_zero] refine squeeze_zero' (Eventually.of_forall fun T => norm_nonneg _) ?_ hB filter_upwards [hf] with T hT exact intervalIntegral.norm_integral_le_of_norm_le_const (fun x hx => hT x hx) /-- The decay `K * (log (T + 2) / (T + 2)) → 0` as `T → ∞`, for any constant `K`. -/ /- Original line 3227: tendsto_const_mul_log_add_two_div_add_two_atTop -/ theorem tendsto_const_mul_log_add_two_div_add_two_atTop : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.realFunctionCoeFourier.{0} ∀ (K : ℝ), Filter.Tendsto (fun T : ℝ => K * (Real.log (T + 2) / (T + 2))) Filter.atTop (nhds 0) := by intro K letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.realFunctionCoeFourier.{0} exact by have h0 : Filter.Tendsto (fun x : ℝ => Real.log x / x) Filter.atTop (nhds 0) := by simpa using (Real.tendsto_pow_log_div_mul_add_atTop 1 0 1 (by norm_num : (1 : ℝ) ≠ 0)) have hshift : Filter.Tendsto (fun T : ℝ => Real.log (T + 2) / (T + 2)) Filter.atTop (nhds 0) := by have := h0.comp (tendsto_atTop_add_const_right Filter.atTop 2 tendsto_id) simpa [Function.comp_def] using this simpa using hshift.const_mul K /-- Fourier-transform decay from an integrable derivative: for integrable, differentiable `g` with integrable derivative, `‖𝓕 g w‖ ≤ (∫ ‖deriv g x‖) / (2π·|w|)`. -/ /- Original line 3240: norm_fourier_le_integral_deriv_div -/ theorem norm_fourier_le_integral_deriv_div : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.realFunctionCoeFourier.{0} ∀ (g : ℝ → ℂ) (hg : Integrable g) (hdiff : Differentiable ℝ g) (hg' : Integrable (deriv g)) {w : ℝ} (hw : w ≠ 0), ‖𝓕 g w‖ ≤ (∫ x, ‖deriv g x‖ ∂volume) / ((2 * Real.pi) * |w|) := by intro g hg hdiff hg' w hw letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.realFunctionCoeFourier.{0} exact by have hmul : 𝓕 (deriv g) w = (2 * Real.pi * Complex.I * (w : ℂ)) * 𝓕 g w := by have h := congrFun (Real.fourier_deriv hg hdiff hg') w simpa [smul_eq_mul, mul_assoc] using h have h_fourier : ‖𝓕 (deriv g) w‖ ≤ ∫ x, ‖deriv g x‖ ∂volume := by exact VectorFourier.norm_fourierIntegral_le_integral_norm 𝐞 volume (innerₗ ℝ) (deriv g) w have hleft : ((2 * Real.pi) * |w|) * ‖𝓕 g w‖ = ‖(2 * Real.pi * Complex.I * (w : ℂ)) * 𝓕 g w‖ := by have htwopi : ‖(2 * ↑Real.pi : ℂ)‖ = 2 * Real.pi := by rw [norm_mul, Complex.norm_two, Complex.norm_of_nonneg Real.pi_pos.le] have hwc : ‖(w : ℂ)‖ = |w| := by rw [norm_real, Real.norm_eq_abs] rw [norm_mul, norm_mul, norm_mul, htwopi, norm_I, hwc] ring have hmain : ((2 * Real.pi) * |w|) * ‖𝓕 g w‖ ≤ ∫ x, ‖deriv g x‖ ∂volume := by rw [hleft, ← hmul] exact h_fourier have hpos : 0 < (2 * Real.pi) * |w| := by positivity exact (le_div_iff₀ hpos).mpr (by simpa [mul_comm, mul_left_comm, mul_assoc] using hmain) /-- The oscillatory-integral form of the decay bound: for `0 < T`, `‖∫ g y · exp(T·i·y)‖ ≤ (∫ ‖deriv g x‖) / T`. -/ /- Original line 3269: norm_oscillatory_integral_le_integral_deriv_div -/ theorem norm_oscillatory_integral_le_integral_deriv_div : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.realFunctionCoeFourier.{0} ∀ (g : ℝ → ℂ) (hg : Integrable g) (hdiff : Differentiable ℝ g) (hg' : Integrable (deriv g)) {T : ℝ} (hT : 0 < T), ‖∫ y, g y * exp ((T : ℂ) * Complex.I * (y : ℂ)) ∂volume‖ ≤ (∫ x, ‖deriv g x‖ ∂volume) / T := by intro g hg hdiff hg' T hT letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.realFunctionCoeFourier.{0} exact by have hw : -T / (2 * Real.pi) ≠ 0 := by exact div_ne_zero (neg_ne_zero.mpr hT.ne') (mul_ne_zero two_ne_zero Real.pi_ne_zero) have hfourier := norm_fourier_le_integral_deriv_div g hg hdiff hg' hw have heq : (∫ y, g y * exp ((T : ℂ) * Complex.I * (y : ℂ)) ∂volume) = 𝓕 g (-T / (2 * Real.pi)) := by rw [Real.fourier_real_eq_integral_exp_smul] apply integral_congr_ae filter_upwards with y rw [smul_eq_mul] rw [mul_comm (g y)] congr 1 congr 1 push_cast field_simp [Real.pi_ne_zero] rw [heq] refine hfourier.trans_eq ?_ congr 1 have hden : (2 * Real.pi) * |-T / (2 * Real.pi)| = T := by have htwopi_pos : 0 < 2 * Real.pi := by positivity have hneg : -T / (2 * Real.pi) < 0 := div_neg_of_neg_of_pos (neg_neg_of_pos hT) htwopi_pos rw [abs_of_neg hneg] field_simp [Real.pi_ne_zero] rw [hden] /-- The `|T|` variant of the oscillatory-integral decay bound: for `T ≠ 0`, `‖∫ g y · exp(T·i·y)‖ ≤ (∫ ‖deriv g x‖) / |T|`. -/ /- Original line 3301: norm_oscillatory_integral_le_integral_deriv_div_abs -/ theorem norm_oscillatory_integral_le_integral_deriv_div_abs : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.realFunctionCoeFourier.{0} ∀ (g : ℝ → ℂ) (hg : Integrable g) (hdiff : Differentiable ℝ g) (hg' : Integrable (deriv g)) {T : ℝ} (hT : T ≠ 0), ‖∫ y, g y * exp ((T : ℂ) * Complex.I * (y : ℂ)) ∂volume‖ ≤ (∫ x, ‖deriv g x‖ ∂volume) / |T| := by intro g hg hdiff hg' T hT letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.realFunctionCoeFourier.{0} exact by have hw : -T / (2 * Real.pi) ≠ 0 := by exact div_ne_zero (neg_ne_zero.mpr hT) (mul_ne_zero two_ne_zero Real.pi_ne_zero) have hfourier := norm_fourier_le_integral_deriv_div g hg hdiff hg' hw have heq : (∫ y, g y * exp ((T : ℂ) * Complex.I * (y : ℂ)) ∂volume) = 𝓕 g (-T / (2 * Real.pi)) := by rw [Real.fourier_real_eq_integral_exp_smul] apply integral_congr_ae filter_upwards with y rw [smul_eq_mul] rw [mul_comm (g y)] congr 1 congr 1 push_cast field_simp [Real.pi_ne_zero] rw [heq] refine hfourier.trans_eq ?_ congr 1 have hden : (2 * Real.pi) * |-T / (2 * Real.pi)| = |T| := by have htwopi_pos : 0 < 2 * Real.pi := by positivity rw [abs_div, abs_neg, abs_of_pos htwopi_pos] field_simp [Real.pi_ne_zero] rw [hden] end PNTSource_4 /- Source module: SmoothExistence -/ section PNTSource_5 open MeasureTheory Set Real open scoped ContDiff /- Original line 3340: smooth_urysohn_support_Ioo -/ theorem smooth_urysohn_support_Ioo : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex ∀ {a b c d : ℝ} (h1 : a < b) (h3 : c < d), ∃ Ψ : ℝ → ℝ, (ContDiff ℝ ∞ Ψ) ∧ (HasCompactSupport Ψ) ∧ Set.indicator (Set.Icc b c) 1 ≤ Ψ ∧ Ψ ≤ Set.indicator (Set.Ioo a d) 1 ∧ (Function.support Ψ = Set.Ioo a d) := by intro a b c d h1 h3 letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex exact by have := exists_contMDiff_zero_iff_one_iff_of_isClosed (n := ⊤) (modelWithCornersSelf ℝ ℝ) (s := Set.Iic a ∪ Set.Ici d) (t := Set.Icc b c) (IsClosed.union isClosed_Iic isClosed_Ici) isClosed_Icc (by simp_rw [Set.disjoint_union_left, Set.disjoint_iff, Set.subset_def, Set.mem_inter_iff, Set.mem_Iic, Set.mem_Icc, Set.mem_empty_iff_false, and_imp, imp_false, not_le, Set.mem_Ici] constructor <;> intros <;> linarith) obtain ⟨Ψ, hΨSmooth, hΨrange, hΨ0, hΨ1⟩ := this simp only [Set.mem_union, Set.mem_Iic, Set.mem_Ici, Set.mem_Icc] at * use Ψ simp only [range_subset_iff, mem_Icc] at hΨrange refine ⟨ContMDiff.contDiff hΨSmooth, ?_, ?_, ?_, ?_⟩ · apply HasCompactSupport.of_support_subset_isCompact (K := Set.Icc a d) isCompact_Icc simp only [Function.support_subset_iff, ne_eq, mem_Icc, ← hΨ0, not_or] bound · apply Set.indicator_le' · intro x hx rw [hΨ1 x |>.mp, Pi.one_apply] simpa using hx · exact fun x _ ↦ (hΨrange x).1 · intro x apply Set.le_indicator_apply · exact fun _ ↦ (hΨrange x).2 · intro hx rw [← hΨ0 x |>.mp] simpa [-not_and, mem_Ioo, not_and_or, not_lt] using hx · ext x simp only [Function.mem_support, ne_eq, mem_Ioo, ← hΨ0, not_or, not_le] /- Original line 3377: SmoothExistence -/ theorem SmoothExistence : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex ∃ (ν : ℝ → ℝ), (ContDiff ℝ ∞ ν) ∧ (∀ x, 0 ≤ ν x) ∧ ν.support ⊆ Icc (1 / 2) 2 ∧ ∫ x in Ici 0, ν x / x = 1 := by letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex exact by suffices h : ∃ (ν : ℝ → ℝ), (ContDiff ℝ ∞ ν) ∧ (∀ x, 0 ≤ ν x) ∧ ν.support ⊆ Set.Icc (1 / 2) 2 ∧ 0 < ∫ x in Set.Ici 0, ν x / x by obtain ⟨ν, hν, hνnonneg, hνsupp, hνpos⟩ := h let c := (∫ x in Ici 0, ν x / x) use fun y ↦ ν y / c refine ⟨hν.div_const c, fun y ↦ div_nonneg (hνnonneg y) (le_of_lt hνpos), ?_, ?_⟩ · rw [Function.support_div, Function.support_const (ne_of_lt hνpos).symm, inter_univ] convert hνsupp · simp only [div_right_comm _ c _, integral_div c, div_self <| ne_of_gt hνpos, c] have := smooth_urysohn_support_Ioo (a := 1 / 2) (b := 1) (c := 3 / 2) (d := 2) (by linarith) (by linarith) obtain ⟨ν, hνContDiff, _, hν0, hν1, hνSupport⟩ := this use ν, hνContDiff unfold indicator at hν0 hν1 simp only [mem_Icc, Pi.one_apply, Pi.le_def, mem_Ioo] at hν0 hν1 simp only [hνSupport, subset_def, mem_Ioo, mem_Icc, and_imp] split_ands · exact fun x ↦ le_trans (by simp [apply_ite]) (hν0 x) · exact fun y hy hy' ↦ ⟨by linarith, by linarith⟩ · rw [integral_pos_iff_support_of_nonneg] · simp only [Function.support_div, measurableSet_Ici, Measure.restrict_apply', hνSupport, Function.support_id'] have : (Ioo (1 / 2 : ℝ) 2 ∩ {0}ᶜ ∩ Ici 0) = Ioo (1 / 2) 2 := by ext x simp only [one_div, mem_inter_iff, mem_Ioo, mem_compl_iff, mem_singleton_iff, mem_Ici] bound simp only [this, volume_Ioo, ENNReal.ofReal_pos, sub_pos, gt_iff_lt] linarith · simp_rw [Pi.le_def, Pi.zero_apply] intro y by_cases h : y ∈ Function.support ν · apply div_nonneg <| le_trans (by simp [apply_ite]) (hν0 y) rw [hνSupport, mem_Ioo] at h linarith [h.left] · simp only [Function.mem_support, ne_eq, not_not] at h simp [h] · have : (fun x ↦ ν x / x).support ⊆ Icc (1 / 2) 2 := by rw [Function.support_div, hνSupport] exact (inter_subset_left).trans Ioo_subset_Icc_self apply (integrableOn_iff_integrable_of_support_subset this).mp apply ContinuousOn.integrableOn_compact isCompact_Icc apply hνContDiff.continuous.continuousOn.div continuousOn_id ?_ simp only [mem_Icc, ne_eq, and_imp, id_eq] intros; linarith end PNTSource_5 /- Source module: Wiener -/ section PNTSource_6 -- note: the opening of ArithmeticFunction introduces a notation σ that seems -- impossible to hide, and hence parameters that are traditionally called σ will -- have to be called σ' instead in this file. open Real BigOperators ArithmeticFunction MeasureTheory Filter Set FourierTransform LSeries Asymptotics SchwartzMap open Complex hiding log open scoped Topology open scoped ContDiff open scoped ComplexConjugate variable {n : ℕ} {A a b c d u x y t σ' : ℝ} {ψ Ψ : ℝ → ℂ} {F G : ℂ → ℂ} {f : ℕ → ℂ} {𝕜 : Type} [RCLike 𝕜] /- Original line 3449: nterm -/ noncomputable def nterm : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex ∀ (f : ℕ → ℂ) (σ' : ℝ) (n : ℕ), ℝ := by intro f σ' n letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex exact if n = 0 then 0 else ‖f n‖ / n ^ σ' /- Original line 3452: nterm_eq_norm_term -/ theorem nterm_eq_norm_term : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex ∀ {f : ℕ → ℂ}, nterm f σ' n = ‖term f σ' n‖ := by intro f letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex exact by by_cases h : n = 0 <;> simp [nterm, term, h] /- Original line 3455: norm_term_eq_nterm_re -/ theorem norm_term_eq_nterm_re : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex ∀ (s : ℂ), ‖term f s n‖ = nterm f (s.re) n := by intro s letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex exact by simp only [nterm, term, apply_ite (‖·‖), norm_zero, norm_div] apply ite_congr rfl (fun _ ↦ rfl) intro h congr refine norm_natCast_cpow_of_pos (by omega) s /- Original line 3463: hf_coe1 -/ theorem hf_coe1 : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex ∀ (hf : ∀ (σ' : ℝ), 1 < σ' → Summable (nterm f σ')) (hσ : 1 < σ'), ∑' idx, (‖term f σ' idx‖₊ : ENNReal) ≠ ⊤ := by intro hf hσ letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex exact by simp_rw [ENNReal.tsum_coe_ne_top_iff_summable_coe, ← norm_toNNReal] norm_cast apply Summable.toNNReal convert hf σ' hσ with idx simp [nterm_eq_norm_term] /- Original line 3471: instMeasurableSpace -/ noncomputable abbrev instMeasurableSpace : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex MeasurableSpace Circle := by letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex exact inferInstanceAs <| MeasurableSpace <| Subtype _ /- Original line 3473: instBorelSpace -/ noncomputable abbrev instBorelSpace : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace BorelSpace Circle := by letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace exact inferInstanceAs <| BorelSpace <| Subtype (· ∈ Metric.sphere (0 : ℂ) 1) -- TODO - add to mathlib /- Original line 3479: first_fourier_aux1 -/ theorem first_fourier_aux1 : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (hψ : AEMeasurable ψ) {x : ℝ} (n : ℕ), AEMeasurable fun (u : ℝ) ↦ (‖fourierChar (-(u * ((1 : ℝ) / ((2 : ℝ) * π) * (n / x).log))) • ψ u‖ₑ : ENNReal) := by intro hψ x n letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by fun_prop /- Original line 3483: first_fourier_aux2a -/ theorem first_fourier_aux2a : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace (2 : ℂ) * π * -(y * (1 / (2 * π) * Real.log ((n) / x))) = -(y * ((n) / x).log) := by letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by calc _ = -(y * (((2 : ℂ) * π) / (2 * π) * Real.log ((n) / x))) := by ring _ = _ := by rw [div_self (by norm_num), one_mul] /- Original line 3489: first_fourier_aux2 -/ theorem first_fourier_aux2 : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (hx : 0 < x) (n : ℕ), term f σ' n * 𝐞 (-(y * (1 / (2 * π) * Real.log (n / x)))) • ψ y = term f (σ' + y * I) n • (ψ y * x ^ (y * I)) := by intro hx n letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by by_cases hn : n = 0 · simp [term, hn] simp only [term, hn, ↓reduceIte] calc _ = (f n * (cexp ((2 * π * -(y * (1 / (2 * π) * Real.log (n / x)))) * I) / ↑((n : ℝ) ^ σ'))) • ψ y := by rw [Circle.smul_def, fourierChar_apply, ofReal_cpow (by norm_num)] simp only [one_div, mul_inv_rev, mul_neg, ofReal_neg, ofReal_mul, ofReal_ofNat, ofReal_inv, neg_mul, smul_eq_mul, ofReal_natCast] ring _ = (f n * (x ^ (y * I) / n ^ (σ' + y * I))) • ψ y := by congr 2 have l1 : 0 < (n : ℝ) := by simpa using Nat.pos_iff_ne_zero.mpr hn have l2 : (x : ℂ) ≠ 0 := by simp [hx.ne.symm] have l3 : (n : ℂ) ≠ 0 := by simp [hn] rw [Real.rpow_def_of_pos l1, Complex.cpow_def_of_ne_zero l2, Complex.cpow_def_of_ne_zero l3] push_cast simp_rw [← Complex.exp_sub] congr 1 rw [first_fourier_aux2a, Real.log_div l1.ne.symm hx.ne.symm] push_cast rw [Complex.ofReal_log hx.le] ring _ = _ := by simp ; group /- Original line 3519: first_fourier -/ theorem first_fourier : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (hf : ∀ (σ' : ℝ), 1 < σ' → Summable (nterm f σ')) (hsupp : Integrable ψ) (hx : 0 < x) (hσ : 1 < σ'), ∑' n : ℕ, term f σ' n * (𝓕 (ψ : ℝ → ℂ) (1 / (2 * π) * log (n / x))) = ∫ t : ℝ, LSeries f (σ' + t * I) * ψ t * x ^ (t * I) := by intro hf hsupp hx hσ letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by calc _ = ∑' n, term f σ' n * ∫ (v : ℝ), 𝐞 (-(v * ((1 : ℝ) / ((2 : ℝ) * π) * Real.log (n / x)))) • ψ v := by simp only [Real.fourier_eq] simp only [one_div, mul_inv_rev, RCLike.inner_apply', conj_trivial] _ = ∑' n, ∫ (v : ℝ), term f σ' n * 𝐞 (-(v * ((1 : ℝ) / ((2 : ℝ) * π) * Real.log (n / x)))) • ψ v := by simp [nnnorm_circle_smul, integral_const_mul] _ = ∫ (v : ℝ), ∑' n, term f σ' n * 𝐞 (-(v * ((1 : ℝ) / ((2 : ℝ) * π) * Real.log (n / x)))) • ψ v := by refine (integral_tsum ?_ ?_).symm · refine fun _ ↦ AEMeasurable.aestronglyMeasurable ?_ have := hsupp.aemeasurable fun_prop · simp only [enorm_mul] simp_rw [lintegral_const_mul'' _ (first_fourier_aux1 hsupp.aemeasurable _)] calc _ = (∑' (idx : ℕ), ‖term f σ' idx‖ₑ) * ∫⁻ (a : ℝ), ‖ψ a‖ₑ ∂volume := by simp [nnnorm_circle_smul, ENNReal.tsum_mul_right, enorm_eq_nnnorm] _ ≠ ⊤ := ENNReal.mul_ne_top (hf_coe1 hf hσ) (ne_top_of_lt hsupp.2) _ = _ := by congr 1; ext y simp_rw [mul_assoc (LSeries _ _), ← smul_eq_mul (a := (LSeries _ _)), LSeries] rw [← Summable.tsum_smul_const] · simp_rw [first_fourier_aux2 hx] · apply Summable.of_norm convert hf σ' hσ with n rw [norm_term_eq_nterm_re] simp[nnnorm_circle_smul] /- Original line 3557: continuous_multiplicative_ofAdd -/ theorem continuous_multiplicative_ofAdd : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace Continuous (⇑Multiplicative.ofAdd : ℝ → ℝ) := by letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact ⟨fun _ ↦ id⟩ /- Original line 3562: second_fourier_integrable_aux1a -/ theorem second_fourier_integrable_aux1a : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (hσ : 1 < σ'), IntegrableOn (fun (x : ℝ) ↦ cexp (-((x : ℂ) * ((σ' : ℂ) - 1)))) (Ici (-Real.log x)) := by intro hσ letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by norm_cast suffices IntegrableOn (fun (x : ℝ) ↦ (rexp (-(x * (σ' - 1))))) (Ici (-x.log)) _ from this.ofReal simp_rw [fun (a x : ℝ) ↦ (by ring : -(x * a) = -a * x)] rw [integrableOn_Ici_iff_integrableOn_Ioi] apply exp_neg_integrableOn_Ioi linarith /- Original line 3571: second_fourier_integrable_aux1 -/ theorem second_fourier_integrable_aux1 : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (hcont : Measurable ψ) (hsupp : Integrable ψ) (hσ : 1 < σ'), let ν : Measure (ℝ × ℝ) := (volume.restrict (Ici (-Real.log x))).prod volume Integrable (Function.uncurry fun (u : ℝ) (a : ℝ) ↦ ((rexp (-u * (σ' - 1))) : ℂ) • (𝐞 (Multiplicative.ofAdd (-(a * (u / (2 * π))))) : ℂ) • ψ a) ν := by intro hcont hsupp hσ letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by intro ν have hContinuousFourier := Real.continuous_fourierChar have hMeasurableCoe := measurable_coe_nnreal_ennreal constructor · apply Measurable.aestronglyMeasurable change Measurable (fun z : ℝ × ℝ => ((rexp (-z.1 * (σ' - 1))) : ℂ) * (((𝐞 (-(z.2 * (z.1 / (2 * π))))) : ℂ) * ψ z.2)) fun_prop · let f1 : ℝ → ENNReal := fun a1 ↦ ‖cexp (-(↑a1 * (↑σ' - 1)))‖ₑ let f2 : ℝ → ENNReal := fun a2 ↦ ‖ψ a2‖ₑ suffices ∫⁻ (a : ℝ × ℝ), f1 a.1 * f2 a.2 ∂ν < ⊤ by simpa [nnnorm_eq_of_mem_circle, hasFiniteIntegral_iff_enorm, enorm_eq_nnnorm, Function.uncurry] refine (lintegral_prod_mul ?_ ?_).trans_lt ?_ <;> try fun_prop exact ENNReal.mul_lt_top (second_fourier_integrable_aux1a hσ).2 hsupp.2 /- Original line 3589: second_fourier_integrable_aux2 -/ theorem second_fourier_integrable_aux2 : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (hσ : 1 < σ'), IntegrableOn (fun (u : ℝ) ↦ cexp ((1 - ↑σ' - ↑t * I) * ↑u)) (Ioi (-Real.log x)) := by intro hσ letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by refine (integrable_norm_iff (Measurable.aestronglyMeasurable <| by fun_prop)).mp ?_ suffices IntegrableOn (fun a ↦ rexp (-(σ' - 1) * a)) (Ioi (-x.log)) _ by simpa [Complex.norm_exp] apply exp_neg_integrableOn_Ioi linarith /- Original line 3596: second_fourier_aux -/ theorem second_fourier_aux : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (hx : 0 < x), -(cexp (-((1 - ↑σ' - ↑t * I) * ↑(Real.log x))) / (1 - ↑σ' - ↑t * I)) = ↑(x ^ (σ' - 1)) * (↑σ' + ↑t * I - 1)⁻¹ * ↑x ^ (↑t * I) := by intro hx letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by calc _ = cexp (↑(Real.log x) * ((↑σ' - 1) + ↑t * I)) * (↑σ' + ↑t * I - 1)⁻¹ := by rw [← div_neg]; ring_nf _ = (x ^ ((↑σ' - 1) + ↑t * I)) * (↑σ' + ↑t * I - 1)⁻¹ := by rw [Complex.cpow_def_of_ne_zero (ofReal_ne_zero.mpr (ne_of_gt hx)), Complex.ofReal_log hx.le] _ = (x ^ ((σ' : ℂ) - 1)) * (x ^ (↑t * I)) * (↑σ' + ↑t * I - 1)⁻¹ := by rw [Complex.cpow_add _ _ (ofReal_ne_zero.mpr (ne_of_gt hx))] _ = _ := by rw [ofReal_cpow hx.le]; push_cast; ring /- Original line 3610: second_fourier -/ theorem second_fourier : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (hcont : Measurable ψ) (hsupp : Integrable ψ) {x σ' : ℝ} (hx : 0 < x) (hσ : 1 < σ'), ∫ u in Ici (-log x), Real.exp (-u * (σ' - 1)) * 𝓕 (ψ : ℝ → ℂ) (u / (2 * π)) = (x^(σ' - 1) : ℝ) * ∫ t, (1 / (σ' + t * I - 1)) * ψ t * x^(t * I) ∂ volume := by intro hcont hsupp x σ' hx hσ letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by conv in ↑(rexp _) * _ => { rw [Real.fourier_real_eq, ← smul_eq_mul, ← integral_smul] } rw [MeasureTheory.integral_integral_swap] swap · exact second_fourier_integrable_aux1 hcont hsupp hσ rw [← integral_const_mul] congr 1; ext t have hkernel (a : ℝ) : (↑(rexp (-a * (σ' - 1))) : ℂ) • (𝐞 (-(t * (a / (2 * π))))) • ψ t = (cexp (↑(2 * π * -(t * (a / (2 * π)))) * I) * ↑(rexp (-a * (σ' - 1)))) * ψ t := by rw [Circle.smul_def, Real.fourierChar_apply] simp only [smul_eq_mul] ring simp_rw [hkernel, integral_mul_const] rw [fun (a b d : ℂ) ↦ show a * (b * (ψ t) * d) = (a * b * d) * ψ t by ring] congr 1 push_cast simp_rw [← Complex.exp_add] have (u : ℝ) : 2 * ↑π * -(↑t * (↑u / (2 * ↑π))) * I + -↑u * (↑σ' - 1) = (1 - σ' - t * I) * u := calc _ = -↑u * (↑σ' - 1) + (2 * ↑π) / (2 * ↑π) * -(↑t * ↑u) * I := by ring _ = -↑u * (↑σ' - 1) + 1 * -(↑t * ↑u) * I := by rw [div_self (by norm_num)] _ = _ := by ring simp_rw [this] let c : ℂ := (1 - ↑σ' - ↑t * I) have : c ≠ 0 := by simp [Complex.ext_iff, c, sub_ne_zero.mpr hσ.ne] let f' (u : ℝ) := cexp (c * u) let f := fun (u : ℝ) ↦ (f' u) / c have hderiv : ∀ u ∈ Ici (-Real.log x), HasDerivAt f (f' u) u := by intro u _ rw [show f' u = cexp (c * u) * (c * 1) / c by simp only [f']; field_simp] exact (hasDerivAt_id' u).ofReal_comp.const_mul c |>.cexp.div_const c have hf : Tendsto f atTop (𝓝 0) := by apply tendsto_zero_iff_norm_tendsto_zero.mpr suffices Tendsto (fun (x : ℝ) ↦ ‖cexp (c * ↑x)‖ / ‖c‖) atTop (𝓝 (0 / ‖c‖)) by simpa [f, f'] using this apply Filter.Tendsto.div_const suffices Tendsto (· * (1 - σ')) atTop atBot by simpa [Complex.norm_exp, mul_comm (1 - σ'), c] exact Tendsto.atTop_mul_const_of_neg (by linarith) fun ⦃s⦄ h ↦ h rw [integral_Ici_eq_integral_Ioi, integral_Ioi_of_hasDerivAt_of_tendsto' hderiv (second_fourier_integrable_aux2 hσ) hf] simpa [f, f'] using second_fourier_aux hx /- Original line 3660: one_add_sq_pos -/ theorem one_add_sq_pos : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (u : ℝ), 0 < 1 + u ^ 2 := by intro u letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact zero_lt_one.trans_le (by simpa using sq_nonneg u) /- Original line 3663: prelim_decay -/ theorem prelim_decay : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (ψ : ℝ → ℂ) (u : ℝ), ‖𝓕 (ψ : ℝ → ℂ) u‖ ≤ ∫ t, ‖ψ t‖ := by intro ψ u letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact VectorFourier.norm_fourierIntegral_le_integral_norm .. /- Original line 3667: decay_bounds_key -/ theorem decay_bounds_key : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (f : W21) (u : ℝ), ‖𝓕 (f : ℝ → ℂ) u‖ ≤ ‖f‖ * (1 + u ^ 2)⁻¹ := by intro f u letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by have l1 : 0 < 1 + u ^ 2 := one_add_sq_pos _ have l2 : 1 + u ^ 2 = ‖(1 : ℂ) + u ^ 2‖ := by norm_cast ; simp only [Real.norm_eq_abs, abs_eq_self.2 l1.le] have l3 : ‖1 / ((4 : ℂ) * ↑π ^ 2)‖ ≤ (4 * π ^ 2)⁻¹ := by simp[F_mul, F_sub] have key := fourierIntegral_self_add_deriv_deriv f u simp only [Function.iterate_succ _ 1, Function.iterate_one, Function.comp_apply] at key rw [F_sub f.hf (f.hf''.const_mul (1 / (4 * ↑π ^ 2)))] at key rw [← div_eq_mul_inv, le_div_iff₀ l1, mul_comm, l2, ← norm_mul, key, sub_eq_add_neg] apply norm_add_le _ _ |>.trans change _ ≤ W21.norm _ rw [norm_neg, F_mul, norm_mul, W21.norm] gcongr <;> apply VectorFourier.norm_fourierIntegral_le_integral_norm /- Original line 3681: decay_bounds_aux -/ theorem decay_bounds_aux : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {f : ℝ → ℂ} (hf : AEStronglyMeasurable f volume) (h : ∀ t, ‖f t‖ ≤ A * (1 + t ^ 2)⁻¹), ∫ t, ‖f t‖ ≤ π * A := by intro f hf h letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by have l1 : Integrable (fun x ↦ A * (1 + x ^ 2)⁻¹) := integrable_inv_one_add_sq.const_mul A simp_rw [← integral_univ_inv_one_add_sq, mul_comm, ← integral_const_mul] exact integral_mono (l1.mono' hf (Eventually.of_forall h)).norm l1 h /- Original line 3688: decay_bounds_W21 -/ theorem decay_bounds_W21 : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (f : W21) (hA : ∀ t, ‖f t‖ ≤ A / (1 + t ^ 2)) (hA' : ∀ t, ‖deriv (deriv f) t‖ ≤ A / (1 + t ^ 2)) (u), ‖𝓕 (f : ℝ → ℂ) u‖ ≤ (π + 1 / (4 * π)) * A / (1 + u ^ 2) := by intro f hA hA' u letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by have l0 : 1 * (4 * π)⁻¹ * A = (4 * π ^ 2)⁻¹ * (π * A) := by field_simp have l1 : ∫ (v : ℝ), ‖f v‖ ≤ π * A := by apply decay_bounds_aux f.continuous.aestronglyMeasurable simp_rw [← div_eq_mul_inv] ; exact hA have l2 : ∫ (v : ℝ), ‖deriv (deriv f) v‖ ≤ π * A := by apply decay_bounds_aux f.deriv.deriv.continuous.aestronglyMeasurable simp_rw [← div_eq_mul_inv] ; exact hA' apply decay_bounds_key f u |>.trans change W21.norm _ * _ ≤ _ simp_rw [W21.norm, div_eq_mul_inv, add_mul, l0] ; gcongr /- Original line 3703: decay_bounds -/ theorem decay_bounds : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (ψ : CS 2 ℂ) (hA : ∀ t, ‖ψ t‖ ≤ A / (1 + t ^ 2)) (hA' : ∀ t, ‖deriv^[2] ψ t‖ ≤ A / (1 + t ^ 2)), ‖𝓕 (ψ : ℝ → ℂ) u‖ ≤ (π + 1 / (4 * π)) * A / (1 + u ^ 2) := by intro ψ hA hA' letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by exact decay_bounds_W21 ψ hA hA' u /- Original line 3708: decay_bounds_cor_aux -/ theorem decay_bounds_cor_aux : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (ψ : CS 2 ℂ), ∃ C : ℝ, ∀ u, ‖ψ u‖ ≤ C / (1 + u ^ 2) := by intro ψ letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by have l1 : HasCompactSupport (fun u : ℝ => ((1 + u ^ 2) : ℝ) * ψ u) := by exact ψ.h2.mul_left have := ψ.h1.continuous obtain ⟨C, hC⟩ := l1.exists_bound_of_continuous (by fun_prop) refine ⟨C, fun u => ?_⟩ specialize hC u simp only [norm_mul, Complex.norm_real, norm_of_nonneg (one_add_sq_pos u).le] at hC rwa [le_div_iff₀' (one_add_sq_pos _)] /- Original line 3717: decay_bounds_cor -/ theorem decay_bounds_cor : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (ψ : W21), ∃ C : ℝ, ∀ u, ‖𝓕 (ψ : ℝ → ℂ) u‖ ≤ C / (1 + u ^ 2) := by intro ψ letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by simpa only [div_eq_mul_inv] using ⟨_, decay_bounds_key ψ⟩ /- Original line 3722: continuous_FourierIntegral -/ theorem continuous_FourierIntegral : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (ψ : W21), Continuous (𝓕 (ψ : ℝ → ℂ)) := by intro ψ letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact VectorFourier.fourierIntegral_continuous continuous_fourierChar (by simp only [innerₗ_apply_apply, RCLike.inner_apply', conj_trivial, continuous_mul]) ψ.hf /- Original line 3727: W21.integrable_fourier -/ theorem W21.integrable_fourier : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (ψ : W21) (hc : c ≠ 0), Integrable fun u ↦ 𝓕 (ψ : ℝ → ℂ) (u / c) := by intro ψ hc letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by have l1 (C) : Integrable (fun u ↦ C / (1 + (u / c) ^ 2)) volume := by simpa using! (integrable_inv_one_add_sq.comp_div hc).const_mul C have l2 : AEStronglyMeasurable (fun u ↦ 𝓕 (ψ : ℝ → ℂ) (u / c)) volume := by exact ((continuous_FourierIntegral ψ).comp (continuous_id.div_const c)).aestronglyMeasurable obtain ⟨C, h⟩ := decay_bounds_cor ψ apply @Integrable.mono' ℝ ℂ _ volume _ _ (fun u => C / (1 + (u / c) ^ 2)) (l1 C) l2 ?_ apply Eventually.of_forall (fun x => h _) /- Original line 3741: continuous_LSeries_aux -/ theorem continuous_LSeries_aux : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (hf : Summable (nterm f σ')), Continuous fun x : ℝ => LSeries f (σ' + x * I) := by intro hf letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by have l1 idx : Continuous fun x : ℝ ↦ term f (σ' + x * I) idx := by by_cases h : idx = 0 · simpa [h] using continuous_const · simpa [h] using! continuous_const.div (continuous_const.cpow (by fun_prop) (by simp [h])) (fun x => by simp [h]) have l2 n (x : ℝ) : ‖term f (σ' + x * I) n‖ = nterm f σ' n := by by_cases h : n = 0 · simp [h, nterm] · simp [h, nterm, cpow_add _ _ (Nat.cast_ne_zero.mpr h), Complex.norm_natCast_cpow_of_pos (Nat.pos_of_ne_zero h)] exact continuous_tsum l1 hf (fun n x => le_of_eq (l2 n x)) -- Here compact support is used but perhaps it is not necessary /- Original line 3758: limiting_fourier_aux -/ theorem limiting_fourier_aux : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (hG' : Set.EqOn G (fun s ↦ LSeries f s - A / (s - 1)) {s | 1 < s.re}) (hf : ∀ (σ' : ℝ), 1 < σ' → Summable (nterm f σ')) (ψ : CS 2 ℂ) (hx : 1 ≤ x) (σ' : ℝ) (hσ' : 1 < σ'), ∑' n, term f σ' n * 𝓕 (ψ : ℝ → ℂ) (1 / (2 * π) * log (n / x)) - A * (x ^ (1 - σ') : ℝ) * ∫ u in Ici (- log x), rexp (-u * (σ' - 1)) * 𝓕 (ψ : ℝ → ℂ) (u / (2 * π)) = ∫ t : ℝ, G (σ' + t * I) * ψ t * x ^ (t * I) := by intro hG' hf ψ hx σ' hσ' letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by have hint : Integrable ψ := ψ.h1.continuous.integrable_of_hasCompactSupport ψ.h2 have l3 : 0 < x := zero_lt_one.trans_le hx have l1 (σ') (hσ' : 1 < σ') := first_fourier hf hint l3 hσ' have l2 (σ') (hσ' : 1 < σ') := second_fourier ψ.h1.continuous.measurable hint l3 hσ' have l8 : Continuous fun t : ℝ ↦ (x : ℂ) ^ (t * I) := continuous_const.cpow (continuous_ofReal.mul continuous_const) (by simp [CS.neg_apply, CS.smul_apply, l3]) have l6 : Continuous fun t : ℝ ↦ LSeries f (↑σ' + ↑t * I) * ψ t * ↑x ^ (↑t * I) := by apply ((continuous_LSeries_aux (hf _ hσ')).mul ψ.h1.continuous).mul l8 have l4 : Integrable fun t : ℝ ↦ LSeries f (↑σ' + ↑t * I) * ψ t * ↑x ^ (↑t * I) := by exact l6.integrable_of_hasCompactSupport ψ.h2.mul_left.mul_right have e2 (u : ℝ) : σ' + u * I - 1 ≠ 0 := by intro h ; have := congr_arg Complex.re h ; simp [CS.neg_apply, CS.smul_apply] at this ; linarith have l7 : Continuous fun a ↦ A * ↑(x ^ (1 - σ')) * (↑(x ^ (σ' - 1)) * (1 / (σ' + a * I - 1) * ψ a * x ^ (a * I))) := by simp only [one_div, ← mul_assoc] refine ((continuous_const.mul <| Continuous.inv₀ ?_ e2).mul ψ.h1.continuous).mul l8 fun_prop have l5 : Integrable fun a ↦ A * ↑(x ^ (1 - σ')) * (↑(x ^ (σ' - 1)) * (1 / (σ' + a * I - 1) * ψ a * x ^ (a * I))) := by apply l7.integrable_of_hasCompactSupport exact ψ.h2.mul_left.mul_right.mul_left.mul_left simp_rw [l1 σ' hσ', l2 σ' hσ', ← integral_const_mul, ← integral_sub l4 l5] apply integral_congr_ae apply Eventually.of_forall intro u have e1 : 1 < ((σ' : ℂ) + (u : ℂ) * I).re := by simp [CS.neg_apply, CS.smul_apply, hσ'] simp_rw [hG' e1, sub_mul, ← mul_assoc] simp only [one_div, sub_right_inj, mul_eq_mul_right_iff, cpow_eq_zero_iff, ofReal_eq_zero, ne_eq, mul_eq_zero, I_ne_zero, or_false] left ; left field_simp [e2] norm_cast simp [CS.neg_apply, CS.smul_apply, mul_assoc, ← rpow_add l3] section nabla variable {α E : Type*} [OfNat α 1] [Add α] [Sub α] {u : α → ℂ} /- Original line 3803: cumsum -/ noncomputable def cumsum : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ [AddCommMonoid E] (u : ℕ → E) (n : ℕ), E := by intro _localClass0 u n letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact ∑ idx ∈ Finset.range n, u idx /- Original line 3805: nabla -/ noncomputable def nabla : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ [Sub E] (u : α → E) (n : α), E := by intro _localClass0 u n letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact u (n + 1) - u n /- `nnabla` is the backward difference `u n - u (n+1)`; kept alongside `nabla` for summation-by-parts identities that prefer that orientation. -/ /- Original line 3809: nnabla -/ noncomputable def nnabla : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ [Sub E] (u : α → E) (n : α), E := by intro _localClass0 u n letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact u n - u (n + 1) /- Original line 3811: shift -/ noncomputable def shift : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (u : α → E) (n : α), E := by intro u n letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact u (n + 1) /- Original line 3813: cumsum_zero -/ theorem cumsum_zero : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ [AddCommMonoid E] {u : ℕ → E}, cumsum u 0 = 0 := by intro _localClass0 u letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by simp [cumsum] /- Original line 3815: cumsum_succ -/ theorem cumsum_succ : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ [AddCommMonoid E] {u : ℕ → E} (n : ℕ), cumsum u (n + 1) = cumsum u n + u n := by intro _localClass0 u n letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by simp [cumsum_zero, cumsum, Finset.sum_range_succ] /- Original line 3819: nabla_cumsum -/ theorem nabla_cumsum : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ [AddCommGroup E] {u : ℕ → E}, nabla (cumsum u) = u := by intro _localClass0 u letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by ext n ; simp [cumsum_zero, nabla, cumsum, Finset.range_add_one] /- Original line 3822: neg_cumsum -/ theorem neg_cumsum : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ [AddCommGroup E] {u : ℕ → E}, -(cumsum u) = cumsum (-u) := by intro _localClass0 u letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact funext (fun n => by simp [cumsum_zero, nabla_cumsum, cumsum]) /- Original line 3825: cumsum_nonneg -/ theorem cumsum_nonneg : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {u : ℕ → ℝ} (hu : 0 ≤ u), 0 ≤ cumsum u := by intro u hu letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact fun _ => Finset.sum_nonneg (fun idx _ => hu idx) omit [Sub α] in /- Original line 3829: neg_nabla -/ theorem neg_nabla : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ [Ring E] {u : α → E}, -(nabla u) = nnabla u := by intro _localClass0 u letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by ext n ; simp [nabla_cumsum, nabla, nnabla] omit [Sub α] in /- Original line 3832: nabla_mul -/ theorem nabla_mul : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ [Ring E] {u : α → E} {c : E}, nabla (fun n => c * u n) = c • nabla u := by intro _localClass0 u c letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by ext n ; simp [nabla_cumsum, nabla, mul_sub] omit [Sub α] in /- Original line 3836: nnabla_mul -/ theorem nnabla_mul : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ [Ring E] {u : α → E} {c : E}, nnabla (fun n => c * u n) = c • nnabla u := by intro _localClass0 u c letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by ext n ; simp [nnabla, mul_sub] /- Original line 3840: nnabla_cast -/ theorem nnabla_cast : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (u : ℝ → E) [Sub E], nnabla u ∘ ((↑) : ℕ → ℝ) = nnabla (u ∘ (↑)) := by intro u _localClass1 letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by ext n ; simp [nnabla_mul, nnabla] end nabla /- Original line 3845: Finset.sum_shift_front -/ theorem Finset.sum_shift_front : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {E : Type*} [Ring E] {u : ℕ → E} {n : ℕ}, cumsum u (n + 1) = u 0 + cumsum (shift u) n := by intro E _localClass1 u n letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by simp_rw [add_comm n, cumsum, sum_range_add, sum_range_one, add_comm 1] ; rfl /- Original line 3849: Finset.sum_shift_front' -/ theorem Finset.sum_shift_front' : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {E : Type*} [Ring E] {u : ℕ → E}, shift (cumsum u) = (fun _ => u 0) + cumsum (shift u) := by intro E _localClass1 u letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by ext n ; apply Finset.sum_shift_front /- Original line 3853: Finset.sum_shift_back -/ theorem Finset.sum_shift_back : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {E : Type*} [Ring E] {u : ℕ → E} {n : ℕ}, cumsum u (n + 1) = cumsum u n + u n := by intro E _localClass1 u n letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by simp [cumsum_zero, nabla_cumsum, cumsum, Finset.range_add_one, add_comm] /- Original line 3857: Finset.sum_shift_back' -/ theorem Finset.sum_shift_back' : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {E : Type*} [Ring E] {u : ℕ → E}, shift (cumsum u) = cumsum u + u := by intro E _localClass1 u letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by ext n ; apply Finset.sum_shift_back /- Original line 3861: summation_by_parts -/ theorem summation_by_parts : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {E : Type*} [Ring E] {a A b : ℕ → E} (ha : a = nabla A) {n : ℕ}, cumsum (a * b) (n + 1) = A (n + 1) * b n - A 0 * b 0 - cumsum (shift A * fun idx => (b (idx + 1) - b idx)) n := by intro E _localClass1 a A b ha n letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by have l1 : ∑ x ∈ Finset.range (n + 1), A (x + 1) * b x = ∑ x ∈ Finset.range n, A (x + 1) * b x + A (n + 1) * b n := Finset.sum_shift_back have l2 : ∑ x ∈ Finset.range (n + 1), A x * b x = A 0 * b 0 + ∑ x ∈ Finset.range n, A (x + 1) * b (x + 1) := Finset.sum_shift_front simp only [cumsum, ha, Pi.mul_apply, nabla, sub_mul, Finset.sum_sub_distrib, l1, l2, shift, mul_sub] abel /- Original line 3874: summation_by_parts' -/ theorem summation_by_parts' : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {E : Type*} [Ring E] {a b : ℕ → E} {n : ℕ}, cumsum (a * b) (n + 1) = cumsum a (n + 1) * b n - cumsum (shift (cumsum a) * nabla b) n := by intro E _localClass1 a b n letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by simpa [cumsum_zero, nabla_cumsum, nabla_mul] using! summation_by_parts (a := a) (b := b) (A := cumsum a) (by simp[cumsum_zero, nabla_cumsum, nabla_mul] ) /- Original line 3878: summation_by_parts'' -/ theorem summation_by_parts'' : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {E : Type*} [Ring E] {a b : ℕ → E}, shift (cumsum (a * b)) = shift (cumsum a) * b - cumsum (shift (cumsum a) * nabla b) := by intro E _localClass1 a b letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by ext n ; apply summation_by_parts' /- Original line 3882: summable_iff_bounded -/ theorem summable_iff_bounded : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {u : ℕ → ℝ} (hu : 0 ≤ u), Summable u ↔ BoundedAtFilter atTop (cumsum u) := by intro u hu letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by have l1 : (cumsum u =O[atTop] 1) ↔ _ := isBigO_one_nat_atTop_iff have l2 n : ‖cumsum u n‖ = cumsum u n := by simpa [cumsum_zero, nabla_cumsum] using cumsum_nonneg hu n simp only [BoundedAtFilter, l1, l2] constructor <;> intro ⟨C, h1⟩ · exact ⟨C, fun n => sum_le_hasSum _ (fun idx _ => hu idx) h1⟩ · exact summable_of_sum_range_le hu h1 /- Original line 3891: Filter.EventuallyEq.summable -/ theorem Filter.EventuallyEq.summable : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {u v : ℕ → ℝ} (h : u =ᶠ[atTop] v) (hu : Summable v), Summable u := by intro u v h hu letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact summable_of_isBigO_nat hu h.isBigO /- Original line 3895: summable_congr_ae -/ theorem summable_congr_ae : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {u v : ℕ → ℝ} (huv : u =ᶠ[atTop] v), Summable u ↔ Summable v := by intro u v huv letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by constructor <;> intro h <;> simp [huv.summable, huv.symm.summable, h] /- Original line 3898: BoundedAtFilter.add_const -/ theorem BoundedAtFilter.add_const : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {u : ℕ → ℝ} {c : ℝ}, BoundedAtFilter atTop (fun n => u n + c) ↔ BoundedAtFilter atTop u := by intro u c letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by have : u = fun n => (u n + c) + (-c) := by ext n ; ring simp only [BoundedAtFilter] constructor <;> intro h on_goal 1 => rw [this] all_goals { exact h.add (const_boundedAtFilter _ _) } /- Original line 3906: BoundedAtFilter.comp_add -/ theorem BoundedAtFilter.comp_add : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {u : ℕ → ℝ} {N : ℕ}, BoundedAtFilter atTop (fun n => u (n + N)) ↔ BoundedAtFilter atTop u := by intro u N letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by simp only [BoundedAtFilter, isBigO_iff, norm_eq_abs, Pi.one_apply, eventually_atTop] constructor <;> intro ⟨C, n₀, h⟩ <;> use C · refine ⟨n₀ + N, fun n hn => ?_⟩ obtain ⟨k, rfl⟩ := Nat.exists_eq_add_of_le' (m := N) (n := n) (by grind) exact h _ <| Nat.add_le_add_iff_right.mp hn · exact ⟨n₀, fun n hn => h _ (by grind)⟩ /- Original line 3916: summable_iff_bounded' -/ theorem summable_iff_bounded' : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {u : ℕ → ℝ} (hu : ∀ᶠ n in atTop, 0 ≤ u n), Summable u ↔ BoundedAtFilter atTop (cumsum u) := by intro u hu letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by obtain ⟨N, hu⟩ := eventually_atTop.mp hu have e2 : cumsum (fun idx ↦ u (idx + N)) = fun n => cumsum u (n + N) - cumsum u N := by ext n ; simp_rw [cumsum, add_comm _ N, Finset.sum_range_add] ; ring rw [← summable_nat_add_iff N, summable_iff_bounded (fun n => hu _ <| Nat.le_add_left N n), e2] simp_rw [sub_eq_add_neg, BoundedAtFilter.add_const, BoundedAtFilter.comp_add] /- Original line 3924: bounded_of_shift -/ theorem bounded_of_shift : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {u : ℕ → ℝ} (h : BoundedAtFilter atTop (shift u)), BoundedAtFilter atTop u := by intro u h letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by simp only [BoundedAtFilter, isBigO_iff, eventually_atTop] at h ⊢ obtain ⟨C, N, hC⟩ := h refine ⟨C, N + 1, fun n hn => ?_⟩ simp only [shift] at hC have r1 : n - 1 ≥ N := Nat.le_sub_one_of_lt hn have r2 : n - 1 + 1 = n := Nat.sub_add_cancel (by omega) simpa [r2] using hC (n - 1) r1 /- Original line 3934: dirichlet_test' -/ theorem dirichlet_test' : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {a b : ℕ → ℝ} (ha : 0 ≤ a) (hb : 0 ≤ b) (hAb : BoundedAtFilter atTop (shift (cumsum a) * b)) (hbb : ∀ᶠ n in atTop, b (n + 1) ≤ b n) (h : Summable (shift (cumsum a) * nnabla b)), Summable (a * b) := by intro a b ha hb hAb hbb h letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by have l1 : ∀ᶠ n in atTop, 0 ≤ (shift (cumsum a) * nnabla b) n := by filter_upwards [hbb] with n hb exact mul_nonneg (by simpa [cumsum_zero, nabla_cumsum, nabla_mul, nnabla_mul, shift] using! Finset.sum_nonneg' ha) (sub_nonneg.mpr hb) rw [summable_iff_bounded (mul_nonneg ha hb)] rw [summable_iff_bounded' l1] at h apply bounded_of_shift simpa only [summation_by_parts'', sub_eq_add_neg, neg_cumsum, ← mul_neg, neg_nabla] using hAb.add h /- Original line 3946: exists_antitone_of_eventually -/ theorem exists_antitone_of_eventually : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {u : ℕ → ℝ} (hu : ∀ᶠ n in atTop, u (n + 1) ≤ u n), ∃ v : ℕ → ℝ, range v ⊆ range u ∧ Antitone v ∧ v =ᶠ[atTop] u := by intro u hu letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by obtain ⟨N, hN⟩ := eventually_atTop.mp hu let v (n : ℕ) := u (if n < N then N else n) refine ⟨v, ?_, ?_, ?_⟩ · exact fun x ⟨n, hn⟩ => ⟨if n < N then N else n, hn⟩ · refine antitone_nat_of_succ_le (fun n => ?_) by_cases h : n < N · by_cases h' : n + 1 < N <;> simp [v, h, h'] have : n + 1 = N := by linarith simp [this] · have : ¬(n + 1 < N) := by linarith simp only [this, ↓reduceIte, h, ge_iff_le, v] ; apply hN ; linarith · have : ∀ᶠ n in atTop, ¬(n < N) := by simpa using ⟨N, fun b hb => by linarith⟩ filter_upwards [this] with n hn ; simp [v, hn] /- Original line 3962: summable_inv_mul_log_sq -/ theorem summable_inv_mul_log_sq : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace Summable (fun n : ℕ => (n * (Real.log n) ^ 2)⁻¹) := by letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by let u (n : ℕ) := (n * (Real.log n) ^ 2)⁻¹ have l7 : ∀ᶠ n : ℕ in atTop, 1 ≤ Real.log n := tendsto_atTop.mp (tendsto_log_atTop.comp tendsto_natCast_atTop_atTop) 1 have l8 : ∀ᶠ n : ℕ in atTop, 1 ≤ n := eventually_ge_atTop 1 have l9 : ∀ᶠ n in atTop, u (n + 1) ≤ u n := by filter_upwards [l7, l8] with n l2 l8; dsimp [u]; gcongr <;> simp obtain ⟨v, l1, l2, l3⟩ := exists_antitone_of_eventually l9 rw [summable_congr_ae l3.symm] have l4 (n : ℕ) : 0 ≤ v n := by obtain ⟨k, hk⟩ := l1 ⟨n, rfl⟩ ; rw [← hk] ; positivity apply (summable_condensed_iff_of_nonneg l4 (fun _ _ _ a ↦ l2 a)).mp suffices this : ∀ᶠ k : ℕ in atTop, 2 ^ k * v (2 ^ k) = ((k : ℝ) ^ 2)⁻¹ * ((Real.log 2) ^ 2)⁻¹ by exact (summable_congr_ae this).mpr <| (Real.summable_nat_pow_inv.mpr one_lt_two).mul_right _ have l5 : ∀ᶠ k in atTop, v (2 ^ k) = u (2 ^ k) := l3.comp_tendsto <| tendsto_pow_atTop_atTop_of_one_lt Nat.le.refl filter_upwards [l5, l8] with k l5 l8 simp only [l5, mul_inv_rev, Nat.cast_pow, Nat.cast_ofNat, log_pow, u] field_simp /- Original line 3981: tendsto_mul_add_atTop -/ theorem tendsto_mul_add_atTop : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {a : ℝ} (ha : 0 < a) (b : ℝ), Tendsto (fun x => a * x + b) atTop atTop := by intro a ha b letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact tendsto_atTop_add_const_right _ b (tendsto_id.const_mul_atTop ha) /- Original line 3985: isLittleO_const_of_tendsto_atTop -/ theorem isLittleO_const_of_tendsto_atTop : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {α : Type*} [Preorder α] (a : ℝ) {f : α → ℝ} (hf : Tendsto f atTop atTop), (fun _ => a) =o[atTop] f := by intro α _localClass1 a f hf letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by simp [tendsto_norm_atTop_atTop.comp hf] /- Original line 3989: isBigO_pow_pow_of_le -/ theorem isBigO_pow_pow_of_le : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {m n : ℕ} (h : m ≤ n), (fun x : ℝ => x ^ m) =O[atTop] (fun x : ℝ => x ^ n) := by intro m n h letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by apply IsBigO.of_bound 1 filter_upwards [eventually_ge_atTop 1] with x l1 simpa [abs_eq_self.mpr (zero_le_one.trans l1)] using pow_le_pow_right₀ l1 h /- Original line 3995: isLittleO_mul_add_sq -/ theorem isLittleO_mul_add_sq : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (a b : ℝ), (fun x => a * x + b) =o[atTop] (fun x => x ^ 2) := by intro a b letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by apply IsLittleO.add · apply IsLittleO.const_mul_left ; simpa using isLittleO_pow_pow_atTop_of_lt (𝕜 := ℝ) one_lt_two · apply isLittleO_const_of_tendsto_atTop _ <| tendsto_pow_atTop (by linarith) /- Original line 4000: log_mul_add_isBigO_log -/ theorem log_mul_add_isBigO_log : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {a : ℝ} (ha : 0 < a) (b : ℝ), (fun x => Real.log (a * x + b)) =O[atTop] Real.log := by intro a ha b letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by apply IsBigO.of_bound (2 : ℕ) have l2 : ∀ᶠ x : ℝ in atTop, 0 ≤ log x := tendsto_atTop.mp tendsto_log_atTop 0 have l3 : ∀ᶠ x : ℝ in atTop, 0 ≤ log (a * x + b) := tendsto_atTop.mp (tendsto_log_atTop.comp (tendsto_mul_add_atTop ha b)) 0 have l5 : ∀ᶠ x : ℝ in atTop, 1 ≤ a * x + b := tendsto_atTop.mp (tendsto_mul_add_atTop ha b) 1 have l1 : ∀ᶠ x : ℝ in atTop, a * x + b ≤ x ^ 2 := by filter_upwards [(isLittleO_mul_add_sq a b).eventuallyLE, l5] with x r2 l5 simpa [abs_eq_self.mpr (zero_le_one.trans l5)] using r2 filter_upwards [l1, l2, l3, l5] with x l1 l2 l3 l5 simpa [abs_eq_self.mpr l2, abs_eq_self.mpr l3, Real.log_pow] using Real.log_le_log (by linarith) l1 /- Original line 4014: isBigO_log_mul_add -/ theorem isBigO_log_mul_add : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {a : ℝ} (ha : 0 < a) (b : ℝ), Real.log =O[atTop] (fun x => Real.log (a * x + b)) := by intro a ha b letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by convert! (log_mul_add_isBigO_log (b := -b / a) (inv_pos.mpr ha)).comp_tendsto (tendsto_mul_add_atTop (b := b) ha) using 1 ext x simp only [Function.comp_apply] congr field_simp simp /- Original line 4024: log_isbigo_log_div -/ theorem log_isbigo_log_div : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {d : ℝ} (hb : 0 < d), (fun n ↦ Real.log n) =O[atTop] (fun n ↦ Real.log (n / d)) := by intro d hb letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by convert isBigO_log_mul_add (inv_pos.mpr hb) 0 using 1; simp only [add_zero]; field_simp /- Original line 4028: Asymptotics.IsBigO.add_isLittleO_right -/ theorem Asymptotics.IsBigO.add_isLittleO_right {f g : ℝ → ℝ} (h : g =o[atTop] f) : f =O[atTop] (f + g) := by rw [isLittleO_iff] at h ; specialize h (c := 2⁻¹) (by norm_num) rw [isBigO_iff''] refine ⟨2⁻¹, by norm_num, ?_⟩ filter_upwards [h] with x h simp only [norm_eq_abs, Pi.add_apply] at h ⊢ calc _ = |f x| - 2⁻¹ * |f x| := by ring _ ≤ |f x| - |g x| := by linarith _ ≤ |(|f x| - |g x|)| := le_abs_self _ _ ≤ _ := by rw [← sub_neg_eq_add, ← abs_neg (g x)] ; exact abs_abs_sub_abs_le (f x) (-g x) /- Original line 4040: Asymptotics.IsBigO.sq -/ theorem Asymptotics.IsBigO.sq : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {α : Type*} [Preorder α] {f g : α → ℝ} (h : f =O[atTop] g), (fun n ↦ f n ^ 2) =O[atTop] (fun n => g n ^ 2) := by intro α _localClass1 f g h letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by simpa [pow_two] using h.mul h /- Original line 4044: log_sq_isbigo_mul -/ theorem log_sq_isbigo_mul : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {a b : ℝ} (hb : 0 < b), (fun x ↦ Real.log x ^ 2) =O[atTop] (fun x ↦ a + Real.log (x / b) ^ 2) := by intro a b hb letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by apply (log_isbigo_log_div hb).sq.trans ; simp_rw [add_comm a] refine IsBigO.add_isLittleO_right <| isLittleO_const_of_tendsto_atTop _ ?_ exact (tendsto_pow_atTop two_ne_zero).comp <| tendsto_log_atTop.comp <| tendsto_id.atTop_div_const hb /- Original line 4051: log_add_div_isBigO_log -/ theorem log_add_div_isBigO_log : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (a : ℝ) {b : ℝ} (hb : 0 < b), (fun x ↦ Real.log ((x + a) / b)) =O[atTop] fun x ↦ Real.log x := by intro a b hb letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by convert log_mul_add_isBigO_log (inv_pos.mpr hb) (a / b) using 3 ; ring /- Original line 4055: log_add_one_sub_log_le -/ theorem log_add_one_sub_log_le : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {x : ℝ} (hx : 0 < x), nabla Real.log x ≤ x⁻¹ := by intro x hx letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by have l1 : ContinuousOn Real.log (Icc x (x + 1)) := by apply continuousOn_log.mono ; intro t ⟨h1, _⟩ ; simp [nabla_cumsum, nabla_mul] ; linarith have l2 t (ht : t ∈ Ioo x (x + 1)) : HasDerivAt Real.log t⁻¹ t := Real.hasDerivAt_log (by linarith [ht.1]) obtain ⟨t, ⟨ht1, _⟩, htx⟩ := exists_hasDerivAt_eq_slope Real.log (·⁻¹) (by linarith) l1 l2 simp only [add_sub_cancel_left, div_one] at htx rw [nabla, ← htx, inv_le_inv₀ (by linarith) hx] exact ht1.le /- Original line 4065: nabla_log_main -/ theorem nabla_log_main : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace nabla Real.log =O[atTop] fun x ↦ 1 / x := by letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by apply IsBigO.of_bound 1 filter_upwards [eventually_gt_atTop 0] with x l1 have l2 : log x ≤ log (x + 1) := log_le_log l1 (by linarith) simpa [nabla_cumsum, nabla_mul, nabla, abs_eq_self.mpr l1.le, abs_eq_self.mpr (sub_nonneg.mpr l2)] using log_add_one_sub_log_le l1 /- Original line 4072: nabla_log -/ theorem nabla_log : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {b : ℝ} (hb : 0 < b), nabla (fun x => Real.log (x / b)) =O[atTop] (fun x => 1 / x) := by intro b hb letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by refine EventuallyEq.trans_isBigO ?_ nabla_log_main filter_upwards [eventually_gt_atTop 0] with x l2 rw [nabla, log_div (by linarith) (by linarith), log_div l2.ne.symm (by linarith), nabla] ; ring /- Original line 4078: nnabla_mul_log_sq -/ theorem nnabla_mul_log_sq : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (a : ℝ) {b : ℝ} (hb : 0 < b), nabla (fun x => x * (a + Real.log (x / b) ^ 2)) =O[atTop] (fun x => Real.log x ^ 2) := by intro a b hb letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by have l1 : nabla (fun n => n * (a + Real.log (n / b) ^ 2)) = fun n => a + Real.log ((n + 1) / b) ^ 2 + (n * (Real.log ((n + 1) / b) ^ 2 - Real.log (n / b) ^ 2)) := by ext n ; simp [nabla_cumsum, nabla_mul, nabla] ; ring have l2 := (isLittleO_const_of_tendsto_atTop a ((tendsto_pow_atTop two_ne_zero).comp tendsto_log_atTop)).isBigO have l3 := (log_add_div_isBigO_log 1 hb).sq have l4 : (fun x => Real.log ((x + 1) / b) + Real.log (x / b)) =O[atTop] Real.log := by simpa [nabla_cumsum, nabla_mul] using (log_add_div_isBigO_log _ hb).add (log_add_div_isBigO_log 0 hb) have e2 : (fun x : ℝ => x * (Real.log x * (1 / x))) =ᶠ[atTop] Real.log := by filter_upwards [eventually_ge_atTop 1] with x hx using by field_simp have l5 : (fun n ↦ n * (Real.log n * (1 / n))) =O[atTop] (fun n ↦ (Real.log n) ^ 2) := e2.trans_isBigO (by simpa [nabla_cumsum, nabla_mul] using! (isLittleO_mul_add_sq 1 0).isBigO.comp_tendsto Real.tendsto_log_atTop) simp_rw [l1, _root_.sq_sub_sq] exact ((l2.add l3).add (isBigO_refl (·) atTop |>.mul (l4.mul (nabla_log hb)) |>.trans l5)) /- Original line 4099: nnabla_bound_aux1 -/ theorem nnabla_bound_aux1 : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (a : ℝ) {b : ℝ} (hb : 0 < b), Tendsto (fun x => x * (a + Real.log (x / b) ^ 2)) atTop atTop := by intro a b hb letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact tendsto_id.atTop_mul_atTop₀ <| tendsto_atTop_add_const_left _ _ <| (tendsto_pow_atTop two_ne_zero).comp <| tendsto_log_atTop.comp <| tendsto_id.atTop_div_const hb /- Original line 4104: nnabla_bound_aux2 -/ theorem nnabla_bound_aux2 : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (a : ℝ) {b : ℝ} (hb : 0 < b), ∀ᶠ x in atTop, 0 < x * (a + Real.log (x / b) ^ 2) := by intro a b hb letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact (nnabla_bound_aux1 a hb).eventually (eventually_gt_atTop 0) /- Original line 4108: Real.log_eventually_gt_atTop -/ theorem Real.log_eventually_gt_atTop : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (a : ℝ), ∀ᶠ x in atTop, a < Real.log x := by intro a letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact Real.tendsto_log_atTop.eventually (eventually_gt_atTop a) /-- Should this be a gcongr lemma? -/ /- Original line 4113: norm_lt_norm_of_nonneg -/ theorem norm_lt_norm_of_nonneg : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (x y : ℝ) (hx : 0 ≤ x) (hxy : x ≤ y), ‖x‖ ≤ ‖y‖ := by intro x y hx hxy letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by simp_rw [Real.norm_eq_abs] apply abs_le_abs hxy linarith /- Original line 4120: nnabla_bound_aux -/ theorem nnabla_bound_aux : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {x : ℝ} (hx : 0 < x), nnabla (fun n ↦ 1 / (n * ((2 * π) ^ 2 + Real.log (n / x) ^ 2))) =O[atTop] (fun n ↦ 1 / (Real.log n ^ 2 * n ^ 2)) := by intro x hx letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by let d n : ℝ := n * ((2 * π) ^ 2 + Real.log (n / x) ^ 2) change (fun x_1 ↦ nnabla (fun n ↦ 1 / d n) x_1) =O[atTop] _ have l2 : ∀ᶠ n in atTop, 0 < d n := (nnabla_bound_aux2 ((2 * π) ^ 2) hx) have l3 : ∀ᶠ n in atTop, 0 < d (n + 1) := (tendsto_atTop_add_const_right atTop (1 : ℝ) tendsto_id).eventually l2 have l1 : ∀ᶠ n : ℝ in atTop, nnabla (fun n ↦ 1 / d n) n = (d (n + 1) - d n) * (d n)⁻¹ * (d (n + 1))⁻¹ := by filter_upwards [l2, l3] with n l2 l3 rw [nnabla, one_div, one_div, inv_sub_inv l2.ne.symm l3.ne.symm, div_eq_mul_inv, mul_inv, mul_assoc] have l4 : (fun n => (d n)⁻¹) =O[atTop] (fun n => (n * (Real.log n) ^ 2)⁻¹) := by apply IsBigO.inv_rev · refine (isBigO_refl _ _).mul <| (log_sq_isbigo_mul hx) · filter_upwards [Real.log_eventually_gt_atTop 0, eventually_gt_atTop 0] with x hx hx' rw [← not_imp_not] intro _ positivity have l5 : (fun n => (d (n + 1))⁻¹) =O[atTop] (fun n => (n * (Real.log n) ^ 2)⁻¹) := by refine IsBigO.trans ?_ l4 rw [isBigO_iff]; use 1 have e3 : ∀ᶠ n in atTop, d n ≤ d (n + 1) := by filter_upwards [eventually_ge_atTop x] with n hn have e2 : 1 ≤ n / x := (one_le_div hx).mpr hn have : 0 ≤ n := hx.le.trans hn simp only [d] gcongr <;> simp [nnabla_mul, Real.log_nonneg, *] filter_upwards [l2, l3, e3] with n e1 e2 e3 simp_rw [one_mul] apply norm_lt_norm_of_nonneg _ _ (by positivity) gcongr have l6 : (fun n => d (n + 1) - d n) =O[atTop] (fun n => (Real.log n) ^ 2) := by simpa [nnabla_mul, d, nabla] using! (nnabla_mul_log_sq ((2 * π) ^ 2) hx) apply EventuallyEq.trans_isBigO l1 apply ((l6.mul l4).mul l5).trans_eventuallyEq filter_upwards [eventually_ge_atTop 2, Real.log_eventually_gt_atTop 0] with n hn hn' field_simp /- Original line 4165: nnabla_bound -/ theorem nnabla_bound : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (C : ℝ) {x : ℝ} (hx : 0 < x), nnabla (fun n => C / (1 + (Real.log (n / x) / (2 * π)) ^ 2) / n) =O[atTop] (fun n => (n ^ 2 * (Real.log n) ^ 2)⁻¹) := by intro C x hx letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by field_simp simp only [div_eq_mul_inv, mul_inv, nnabla_mul, one_mul] apply IsBigO.const_mul_left simpa [nnabla_mul, div_eq_mul_inv, mul_pow, mul_comm] using nnabla_bound_aux hx /- Original line 4173: chebyWith -/ noncomputable def chebyWith : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (C : ℝ) (f : ℕ → ℂ), Prop := by intro C f letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact ∀ n, cumsum (‖f ·‖) n ≤ C * n /- Original line 4175: cheby -/ noncomputable def cheby : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (f : ℕ → ℂ), Prop := by intro f letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact ∃ C, chebyWith C f /- Original line 4177: cheby.bigO -/ theorem cheby.bigO : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (h : cheby f), cumsum (‖f ·‖) =O[atTop] ((↑) : ℕ → ℝ) := by intro h letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by have l1 : 0 ≤ cumsum (‖f ·‖) := cumsum_nonneg (fun _ => norm_nonneg _) obtain ⟨C, hC⟩ := h apply isBigO_of_le' (c := C) atTop intro n rw [Real.norm_eq_abs, abs_eq_self.mpr (l1 n)] simpa [cumsum_zero, nabla_cumsum] using hC n /- Original line 4185: limiting_fourier_lim1_aux -/ theorem limiting_fourier_lim1_aux : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (hcheby : cheby f) (hx : 0 < x) (C : ℝ) (hC : 0 ≤ C), Summable fun n ↦ ‖f n‖ / ↑n * (C / (1 + (1 / (2 * π) * Real.log (↑n / x)) ^ 2)) := by intro hcheby hx C hC letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by let a (n : ℕ) := (C / (1 + (Real.log (↑n / x) / (2 * π)) ^ 2) / ↑n) replace hcheby := hcheby.bigO have l1 : shift (cumsum (‖f ·‖)) =O[atTop] (fun n : ℕ => (↑(n + 1) : ℝ)) := hcheby.comp_tendsto <| tendsto_add_atTop_nat 1 have l2 : shift (cumsum (‖f ·‖)) =O[atTop] (fun n => (n : ℝ)) := l1.trans (by simpa [cumsum_zero, nabla_cumsum, nnabla_mul] using (isBigO_refl _ _).add <| isBigO_iff.mpr ⟨1, by simpa [cumsum_zero, nabla_cumsum, nnabla_mul] using ⟨1, by tauto⟩⟩) have l5 : BoundedAtFilter atTop (fun n : ℕ => C / (1 + (Real.log (↑n / x) / (2 * π)) ^ 2)) := by simp only [BoundedAtFilter] field_simp apply isBigO_of_le' (c := C) ; intro n have : 0 ≤ 2 ^ 2 * π ^ 2 + Real.log (n / x) ^ 2 := by positivity simp only [norm_div, norm_mul, norm_eq_abs, abs_eq_self.mpr hC, norm_pow, abs_eq_self.mpr pi_nonneg, abs_eq_self.mpr this, Pi.one_apply, one_mem, CStarRing.norm_of_mem_unitary, mul_one, ge_iff_le, Nat.abs_ofNat] apply div_le_of_le_mul₀ this hC rw [mul_add, ← mul_assoc] apply le_add_of_le_of_nonneg le_rfl positivity have l3 : a =O[atTop] (fun n => 1 / (n : ℝ)) := by simpa [cumsum_zero, nabla_cumsum, nnabla_mul, a] using! IsBigO.mul l5 (isBigO_refl (fun n : ℕ => 1 / (n : ℝ)) _) have l4 : nnabla a =O[atTop] (fun n : ℕ => (n ^ 2 * (Real.log n) ^ 2)⁻¹) := by convert (nnabla_bound C hx).natCast ; simp [cumsum_zero, nabla_cumsum, nnabla_mul, nnabla, a] simp_rw [div_mul_eq_mul_div, mul_div_assoc, one_mul] apply dirichlet_test' · intro n ; exact norm_nonneg _ · intro n ; positivity · apply (l2.mul l3).trans_eventuallyEq apply eventually_of_mem (Ici_mem_atTop 1) intro x (hx : 1 ≤ x) have : x ≠ 0 := Nat.one_le_iff_ne_zero.mp hx simp [cumsum_zero, nabla_cumsum, nnabla_mul, this] · have : ∀ᶠ n : ℕ in atTop, x ≤ n := by simpa [cumsum_zero, nabla_cumsum, nnabla_mul] using eventually_ge_atTop ⌈x⌉₊ filter_upwards [this] with n hn have e1 : 0 < (n : ℝ) := by linarith have e2 : 1 ≤ n / x := (one_le_div hx).mpr hn have e3 := Nat.le_succ n gcongr refine div_nonneg (Real.log_nonneg e2) (by norm_num [pi_nonneg]) · apply summable_of_isBigO_nat summable_inv_mul_log_sq apply (l2.mul l4).trans_eventuallyEq apply eventually_of_mem (Ici_mem_atTop 2) intro x (hx : 2 ≤ x) have : (x : ℝ) ≠ 0 := by simp [cumsum_zero, nabla_cumsum, nnabla_mul] ; linarith have : Real.log x ≠ 0 := by have ll : 2 ≤ (x : ℝ) := by simp [cumsum_zero, nabla_cumsum, nnabla_mul, hx] simp[cumsum_zero, nabla_cumsum, nnabla_mul] grind field_simp /- Original line 4240: limiting_fourier_lim1 -/ theorem limiting_fourier_lim1 : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (hcheby : cheby f) (ψ : W21) (hx : 0 < x), Tendsto (fun σ' : ℝ ↦ ∑' n, term f σ' n * 𝓕 (ψ : ℝ → ℂ) (1 / (2 * π) * Real.log (n / x))) (𝓝[>] 1) (𝓝 (∑' n, f n / n * 𝓕 (ψ : ℝ → ℂ) (1 / (2 * π) * Real.log (n / x)))) := by intro hcheby ψ hx letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by obtain ⟨C, hC⟩ := decay_bounds_cor ψ have : 0 ≤ C := by simpa using (norm_nonneg _).trans (hC 0) refine tendsto_tsum_of_dominated_convergence (limiting_fourier_lim1_aux hcheby hx C this) (fun n => ?_) ?_ · apply Tendsto.mul_const by_cases h : n = 0 <;> simp only [term, h, ↓reduceIte, CharP.cast_eq_zero, div_zero, tendsto_const_nhds_iff] refine tendsto_const_nhds.div ?_ (by simp [h]) simpa using ((continuous_ofReal.tendsto 1).mono_left nhdsWithin_le_nhds).const_cpow · rw [eventually_nhdsWithin_iff] apply Eventually.of_forall intro σ' (hσ' : 1 < σ') n rw [norm_mul, ← nterm_eq_norm_term] refine mul_le_mul ?_ (hC _) (norm_nonneg _) (div_nonneg (norm_nonneg _) (Nat.cast_nonneg _)) by_cases h : n = 0 <;> simp only [nterm, h, ↓reduceIte, CharP.cast_eq_zero, div_zero, le_refl] have : 1 ≤ (n : ℝ) := by simpa using! Nat.pos_iff_ne_zero.mpr h refine div_le_div₀ (norm_nonneg _) le_rfl (by simpa [Nat.pos_iff_ne_zero]) ?_ simpa using Real.rpow_le_rpow_of_exponent_le this hσ'.le /- Original line 4264: limiting_fourier_lim2_aux -/ theorem limiting_fourier_lim2_aux : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (x : ℝ) (C : ℝ), Integrable (fun t ↦ max |x| 1 * (C / (1 + (t / (2 * π)) ^ 2))) (Measure.restrict volume (Ici (-Real.log x))) := by intro x C letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by simp_rw [div_eq_mul_inv C] exact (((integrable_inv_one_add_sq.comp_div (by simp [pi_ne_zero])).const_mul _).const_mul _).restrict /- Original line 4271: limiting_fourier_lim2 -/ theorem limiting_fourier_lim2 : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (A : ℝ) (ψ : W21) (hx : 1 ≤ x), Tendsto (fun σ' ↦ A * ↑(x ^ (1 - σ')) * ∫ u in Ici (-Real.log x), rexp (-u * (σ' - 1)) * 𝓕 (ψ : ℝ → ℂ) (u / (2 * π))) (𝓝[>] 1) (𝓝 (A * ∫ u in Ici (-Real.log x), 𝓕 (ψ : ℝ → ℂ) (u / (2 * π)))) := by intro A ψ hx letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by obtain ⟨C, hC⟩ := decay_bounds_cor ψ apply Tendsto.mul · suffices h : Tendsto (fun σ' : ℝ ↦ ofReal (x ^ (1 - σ'))) (𝓝[>] 1) (𝓝 1) by simpa using h.const_mul ↑A suffices h : Tendsto (fun σ' : ℝ ↦ x ^ (1 - σ')) (𝓝[>] 1) (𝓝 1) from (continuous_ofReal.tendsto 1).comp h have : Tendsto (fun σ' : ℝ ↦ σ') (𝓝 1) (𝓝 1) := fun _ a ↦ a have : Tendsto (fun σ' : ℝ ↦ 1 - σ') (𝓝[>] 1) (𝓝 0) := tendsto_nhdsWithin_of_tendsto_nhds (by simpa using this.const_sub 1) simpa using tendsto_const_nhds.rpow this (Or.inl (zero_lt_one.trans_le hx).ne.symm) · refine tendsto_integral_filter_of_dominated_convergence _ ?_ ?_ (limiting_fourier_lim2_aux x C) ?_ · apply Eventually.of_forall ; intro σ' apply Continuous.aestronglyMeasurable have := continuous_FourierIntegral ψ continuity · apply eventually_of_mem (U := Ioo 1 2) · apply Ioo_mem_nhdsGT_of_mem ; simp · intro σ' ⟨h1, h2⟩ rw [ae_restrict_iff' measurableSet_Ici] apply Eventually.of_forall intro t (ht : - Real.log x ≤ t) rw [norm_mul] have hdom_nonneg : 0 ≤ max |x| 1 := by exact (abs_nonneg x).trans (le_max_left _ _) refine mul_le_mul ?_ (hC _) (norm_nonneg _) hdom_nonneg simp only [neg_mul, ofReal_exp, ofReal_neg, ofReal_mul, ofReal_sub, ofReal_one, norm_exp, neg_re, mul_re, ofReal_re, sub_re, one_re, ofReal_im, sub_im, one_im, sub_self, mul_zero, sub_zero] have : -Real.log x * (σ' - 1) ≤ t * (σ' - 1) := mul_le_mul_of_nonneg_right ht (by linarith) have : -(t * (σ' - 1)) ≤ Real.log x * (σ' - 1) := by simpa using neg_le_neg this have := Real.exp_monotone this apply this.trans have l1 : σ' - 1 ≤ 1 := by linarith have : 0 ≤ Real.log x := Real.log_nonneg hx have := mul_le_mul_of_nonneg_left l1 this refine (Real.exp_monotone this).trans ?_ have hxabs : |x| = x := abs_of_nonneg (zero_le_one.trans hx) calc Real.exp (Real.log x * 1) = |x| := by simpa [mul_one, hxabs] using (Real.exp_log (zero_lt_one.trans_le hx)) _ ≤ max |x| 1 := le_max_left _ _ · apply Eventually.of_forall intro x suffices h : Tendsto (fun n ↦ ((rexp (-x * (n - 1))) : ℂ)) (𝓝[>] 1) (𝓝 1) by simpa using h.mul_const _ apply Tendsto.mono_left ?_ nhdsWithin_le_nhds suffices h : Continuous (fun n ↦ ((rexp (-x * (n - 1))) : ℂ)) by simpa using h.tendsto 1 continuity /- Original line 4326: limiting_fourier_lim3 -/ theorem limiting_fourier_lim3 : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (hG : ContinuousOn G {s | 1 ≤ s.re}) (ψ : CS 2 ℂ) (hx : 1 ≤ x), Tendsto (fun σ' : ℝ ↦ ∫ t : ℝ, G (σ' + t * I) * ψ t * x ^ (t * I)) (𝓝[>] 1) (𝓝 (∫ t : ℝ, G (1 + t * I) * ψ t * x ^ (t * I))) := by intro hG ψ hx letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by by_cases hh : tsupport ψ = ∅ · simp [CS.neg_apply, CS.smul_apply, tsupport_eq_empty_iff.mp hh] obtain ⟨a₀, ha₀⟩ := Set.nonempty_iff_ne_empty.mpr hh let S : Set ℂ := reProdIm (Icc 1 2) (tsupport ψ) have l1 : IsCompact S := by refine Metric.isCompact_iff_isClosed_bounded.mpr ⟨?_, ?_⟩ · exact isClosed_Icc.reProdIm (isClosed_tsupport ψ) · exact (Metric.isBounded_Icc 1 2).reProdIm ψ.h2.isBounded have l2 : S ⊆ {s : ℂ | 1 ≤ s.re} := fun z hz => (mem_reProdIm.mp hz).1.1 have l3 : ContinuousOn (‖G ·‖) S := (hG.mono l2).norm have l4 : S.Nonempty := ⟨1 + a₀ * I, by simp [CS.neg_apply, CS.smul_apply, S, mem_reProdIm, ha₀]⟩ obtain ⟨z, -, hmax⟩ := l1.exists_isMaxOn l4 l3 let MG := ‖G z‖ let bound (a : ℝ) : ℝ := MG * ‖ψ a‖ apply tendsto_integral_filter_of_dominated_convergence (bound := bound) · apply eventually_of_mem (U := Icc 1 2) (Icc_mem_nhdsGT_of_mem (by simp[CS.neg_apply, CS.smul_apply] )) ; intro u hu apply Continuous.aestronglyMeasurable apply Continuous.mul · exact (hG.comp_continuous (by fun_prop) (by simp [CS.neg_apply, CS.smul_apply, hu.1])).mul ψ.h1.continuous · apply Continuous.const_cpow (by fun_prop) ; simp [CS.neg_apply, CS.smul_apply] ; linarith · apply eventually_of_mem (U := Icc 1 2) (Icc_mem_nhdsGT_of_mem (by simp[CS.neg_apply, CS.smul_apply] )) intro u hu apply Eventually.of_forall ; intro v by_cases h : v ∈ tsupport ψ · have r1 : u + v * I ∈ S := by simp [CS.neg_apply, CS.smul_apply, S, mem_reProdIm, hu.1, hu.2, h] have r2 := isMaxOn_iff.mp hmax _ r1 have r4 : (x : ℂ) ≠ 0 := by simp [CS.neg_apply, CS.smul_apply] ; linarith have r5 : arg x = 0 := by simp [CS.neg_apply, CS.smul_apply, arg_eq_zero_iff] ; linarith have r3 : ‖(x : ℂ) ^ (v * I)‖ = 1 := by simp [CS.neg_apply, CS.smul_apply, norm_cpow_of_ne_zero r4, r5] simp_rw [norm_mul, r3, mul_one] exact mul_le_mul_of_nonneg_right r2 (norm_nonneg _) · have : v ∉ Function.support ψ := fun a ↦ h (subset_tsupport ψ a) simp [CS.neg_apply, CS.smul_apply] at this ; simp [CS.neg_apply, CS.smul_apply, this, bound] · suffices h : Continuous bound by exact h.integrable_of_hasCompactSupport ψ.h2.norm.mul_left have := ψ.h1.continuous ; fun_prop · apply Eventually.of_forall ; intro t apply Tendsto.mul_const apply Tendsto.mul_const refine (hG (1 + t * I) (by simp[CS.neg_apply, CS.smul_apply] )).tendsto.comp <| tendsto_nhdsWithin_iff.mpr ⟨?_, ?_⟩ · exact ((continuous_ofReal.tendsto _).add tendsto_const_nhds).mono_left nhdsWithin_le_nhds · exact eventually_nhdsWithin_of_forall (fun x (hx : 1 < x) => by simp [CS.neg_apply, CS.smul_apply, hx.le]) /- Original line 4376: limiting_fourier -/ theorem limiting_fourier : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (hcheby : cheby f) (hG : ContinuousOn G {s | 1 ≤ s.re}) (hG' : Set.EqOn G (fun s ↦ LSeries f s - A / (s - 1)) {s | 1 < s.re}) (hf : ∀ (σ' : ℝ), 1 < σ' → Summable (nterm f σ')) (ψ : CS 2 ℂ) (hx : 1 ≤ x), ∑' n, f n / n * 𝓕 (ψ : ℝ → ℂ) (1 / (2 * π) * log (n / x)) - A * ∫ u in Set.Ici (-log x), 𝓕 (ψ : ℝ → ℂ) (u / (2 * π)) = ∫ (t : ℝ), (G (1 + t * I)) * (ψ t) * x ^ (t * I) := by intro hcheby hG hG' hf ψ hx letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by have l1 := limiting_fourier_lim1 hcheby ψ (by linarith) have l2 := limiting_fourier_lim2 A ψ hx have l3 := limiting_fourier_lim3 hG ψ hx apply tendsto_nhds_unique_of_eventuallyEq (l1.sub l2) l3 simpa [CS.neg_apply, CS.smul_apply, eventuallyEq_nhdsWithin_iff] using! Eventually.of_forall (limiting_fourier_aux hG' hf ψ hx) /- Original line 4394: limiting_cor_aux -/ theorem limiting_cor_aux {f : ℝ → ℂ} : Tendsto (fun x : ℝ ↦ ∫ t, f t * x ^ (t * I)) atTop (𝓝 0) := by have l1 : ∀ᶠ x : ℝ in atTop, ∀ t : ℝ, x ^ (t * I) = exp (log x * t * I) := by filter_upwards [eventually_ne_atTop 0, eventually_ge_atTop 0] with x hx hx' t rw [Complex.cpow_def_of_ne_zero (ofReal_ne_zero.mpr hx), ofReal_log hx'] ; ring_nf have l2 : ∀ᶠ x : ℝ in atTop, ∫ t, f t * x ^ (t * I) = ∫ t, f t * exp (log x * t * I) := by filter_upwards [l1] with x hx refine integral_congr_ae (Eventually.of_forall (fun x => by simp [hx])) have hFourier (x : ℝ) : (∫ t, f t * exp (log x * t * I)) = 𝓕 f (-Real.log x / (2 * π)) := by rw [Real.fourier_real_eq_integral_exp_smul] apply integral_congr_ae filter_upwards [] with t have hangle : -2 * π * t * (-Real.log x / (2 * π)) = Real.log x * t := by field_simp [Real.pi_ne_zero] <;> ring rw [hangle] simp only [ofReal_mul, smul_eq_mul] exact mul_comm _ _ simp_rw [tendsto_congr' l2, hFourier] refine (Real.zero_at_infty_fourier f).comp <| Tendsto.mono_right ?_ _root_.atBot_le_cocompact exact (tendsto_neg_atBot_iff.mpr tendsto_log_atTop).atBot_mul_const (inv_pos.mpr two_pi_pos) /- Original line 4416: limiting_cor -/ theorem limiting_cor : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (ψ : CS 2 ℂ) (hf : ∀ (σ' : ℝ), 1 < σ' → Summable (nterm f σ')) (hcheby : cheby f) (hG : ContinuousOn G {s | 1 ≤ s.re}) (hG' : Set.EqOn G (fun s ↦ LSeries f s - A / (s - 1)) {s | 1 < s.re}), Tendsto (fun x : ℝ ↦ ∑' n, f n / n * 𝓕 (ψ : ℝ → ℂ) (1 / (2 * π) * log (n / x)) - A * ∫ u in Set.Ici (-log x), 𝓕 (ψ : ℝ → ℂ) (u / (2 * π))) atTop (𝓝 0) := by intro ψ hf hcheby hG hG' letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by apply limiting_cor_aux.congr' filter_upwards [eventually_ge_atTop 1] with x hx using limiting_fourier hcheby hG hG' hf ψ hx |>.symm /- Original line 4431: smooth_urysohn -/ theorem smooth_urysohn : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (a b c d : ℝ) (h1 : a < b) (h3 : c < d), ∃ Ψ : ℝ → ℝ, (ContDiff ℝ ∞ Ψ) ∧ (HasCompactSupport Ψ) ∧ Set.indicator (Set.Icc b c) 1 ≤ Ψ ∧ Ψ ≤ Set.indicator (Set.Ioo a d) 1 := by intro a b c d h1 h3 letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by obtain ⟨ψ, l1, l2, l3, l4, -⟩ := smooth_urysohn_support_Ioo h1 h3 refine ⟨ψ, l1, l2, l3, l4⟩ /- Original line 4440: exists_trunc -/ noncomputable def exists_trunc : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace trunc := by letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by choose ψ h1 h2 h3 h4 using smooth_urysohn (-2) (-1) (1) (2) (by linarith) (by linarith) exact ⟨⟨ψ, h1.of_le (by norm_cast), h2⟩, h3, h4⟩ /- Original line 4444: one_div_sub_one -/ theorem one_div_sub_one : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (n : ℕ), 1 / (↑(n - 1) : ℝ) ≤ 2 / n := by intro n letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by match n with | 0 => simp | 1 => simp | n + 2 => { norm_cast ; rw [div_le_div_iff₀] <;> simp [mul_add] <;> linarith } /- Original line 4450: quadratic_pos -/ theorem quadratic_pos : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (a b c x : ℝ) (ha : 0 < a) (hΔ : discrim a b c < 0), 0 < a * x ^ 2 + b * x + c := by intro a b c x ha hΔ letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by have l1 : a * x ^ 2 + b * x + c = a * (x + b / (2 * a)) ^ 2 - discrim a b c / (4 * a) := by simp only [discrim]; field_simp; ring have l2 : 0 < - discrim a b c := by linarith rw [l1, sub_eq_add_neg, ← neg_div] ; positivity /- Original line 4457: pp -/ noncomputable def pp : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (a x : ℝ), ℝ := by intro a x letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact a ^ 2 * (x + 1) ^ 2 + (1 - a) * (1 + a) /- Original line 4459: pp' -/ noncomputable def pp' : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (a x : ℝ), ℝ := by intro a x letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact a ^ 2 * (2 * (x + 1)) /- Original line 4461: pp_pos -/ theorem pp_pos : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {a : ℝ} (ha : a ∈ Ioo (-1) 1) (x : ℝ), 0 < pp a x := by intro a ha x letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by simp only [pp] have : 0 < 1 - a := by linarith [ha.2] have : 0 < 1 + a := by linarith [ha.1] positivity /- Original line 4467: pp_deriv -/ theorem pp_deriv : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (a x : ℝ), HasDerivAt (pp a) (pp' a x) x := by intro a x letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by unfold pp pp' simpa using hasDerivAt_id x |>.add_const 1 |>.pow 2 |>.const_mul _ /- Original line 4471: pp_deriv_eq -/ theorem pp_deriv_eq : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (a : ℝ), deriv (pp a) = pp' a := by intro a letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by ext x ; exact pp_deriv a x |>.deriv /- Original line 4474: pp'_deriv -/ theorem pp'_deriv : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (a x : ℝ), HasDerivAt (pp' a) (a ^ 2 * 2) x := by intro a x letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by simpa using! hasDerivAt_id x |>.add_const 1 |>.const_mul 2 |>.const_mul (a ^ 2) /- Original line 4477: pp'_deriv_eq -/ theorem pp'_deriv_eq : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (a : ℝ), deriv (pp' a) = fun _ => a ^ 2 * 2 := by intro a letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by ext x ; exact pp'_deriv a x |>.deriv /- Original line 4480: hh -/ noncomputable def hh : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (a t : ℝ), ℝ := by intro a t letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact (t * (1 + (a * log t) ^ 2))⁻¹ /- Original line 4482: hh' -/ noncomputable def hh' : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (a t : ℝ), ℝ := by intro a t letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact - pp a (log t) * hh a t ^ 2 /- Original line 4484: hh_nonneg -/ theorem hh_nonneg : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (a : ℝ) {t : ℝ} (ht : 0 ≤ t), 0 ≤ hh a t := by intro a t ht letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by dsimp only [hh] ; positivity /- Original line 4486: hh_le -/ theorem hh_le : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (a t : ℝ) (ht : 0 ≤ t), |hh a t| ≤ t⁻¹ := by intro a t ht letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by by_cases h0 : t = 0 · simp [hh, h0] replace ht : 0 < t := lt_of_le_of_ne ht (by tauto) unfold hh rw [abs_inv, inv_le_inv₀ (by positivity) ht, abs_mul, abs_eq_self.mpr ht.le] convert_to! t * 1 ≤ _ · simp apply mul_le_mul le_rfl ?_ zero_le_one ht.le rw [abs_eq_self.mpr (by positivity)] simp only [le_add_iff_nonneg_right] positivity /- Original line 4499: hh_deriv -/ theorem hh_deriv : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (a : ℝ) {t : ℝ} (ht : t ≠ 0), HasDerivAt (hh a) (hh' a t) t := by intro a t ht letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by have e1 : t * (1 + (a * log t) ^ 2) ≠ 0 := mul_ne_zero ht (_root_.ne_of_lt (by positivity)).symm have l5 : HasDerivAt (fun t : ℝ => log t) t⁻¹ t := Real.hasDerivAt_log ht have l4 : HasDerivAt (fun t : ℝ => a * log t) (a * t⁻¹) t := l5.const_mul _ have l3 : HasDerivAt (fun t : ℝ => (a * log t) ^ 2) (2 * a ^ 2 * t⁻¹ * log t) t := by convert! l4.pow 2 using 1 ; ring have l2 : HasDerivAt (fun t : ℝ => 1 + (a * log t) ^ 2) (2 * a ^ 2 * t⁻¹ * log t) t := l3.const_add _ have l1 : HasDerivAt (fun t : ℝ => t * (1 + (a * log t) ^ 2)) (1 + 2 * a ^ 2 * log t + a ^ 2 * log t ^ 2) t := by convert! (hasDerivAt_id' t).mul l2 using 1; field_simp; ring convert! l1.inv e1 using 1; simp only [hh', pp, hh]; field_simp; ring /- Original line 4512: hh_continuous -/ theorem hh_continuous : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (a : ℝ), ContinuousOn (hh a) (Ioi 0) := by intro a letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact fun t (ht : 0 < t) => (hh_deriv a ht.ne.symm).continuousAt.continuousWithinAt /- Original line 4515: hh'_nonpos -/ theorem hh'_nonpos : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {a x : ℝ} (ha : a ∈ Ioo (-1) 1), hh' a x ≤ 0 := by intro a x ha letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by have := pp_pos ha (log x) simp only [hh', neg_mul, Left.neg_nonpos_iff, ge_iff_le] positivity /- Original line 4520: hh_antitone -/ theorem hh_antitone : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {a : ℝ} (ha : a ∈ Ioo (-1) 1), AntitoneOn (hh a) (Ioi 0) := by intro a ha letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by have l1 x (hx : x ∈ interior (Ioi 0)) : HasDerivWithinAt (hh a) (hh' a x) (interior (Ioi 0)) x := by have : x ≠ 0 := by contrapose! hx ; simp [hx] exact (hh_deriv a this).hasDerivWithinAt apply antitoneOn_of_hasDerivWithinAt_nonpos (convex_Ioi _) (hh_continuous _) l1 (fun x _ => hh'_nonpos ha) /- Original line 4528: gg -/ noncomputable def gg : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (x idx : ℝ), ℝ := by intro x idx letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact 1 / idx * (1 + (1 / (2 * π) * log (idx / x)) ^ 2)⁻¹ /- Original line 4530: gg_of_hh -/ theorem gg_of_hh : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {x : ℝ} (hx : x ≠ 0) (idx : ℝ), gg x idx = x⁻¹ * hh (1 / (2 * π)) (idx / x) := by intro x hx idx letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by simp only [gg, hh] field_simp /- Original line 4534: gg_l1 -/ theorem gg_l1 : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {x : ℝ} (hx : 0 < x) (n : ℕ), |gg x n| ≤ 1 / n := by intro x hx n letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by simp only [gg_of_hh hx.ne.symm, one_div, mul_inv_rev, abs_mul] apply mul_le_mul le_rfl (hh_le _ _ (by positivity)) (by positivity) (by positivity) |>.trans (le_of_eq ?_) simp [abs_inv, abs_eq_self.mpr hx.le] ; field_simp /- Original line 4540: gg_le_one -/ theorem gg_le_one : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (idx : ℕ), gg x idx ≤ 1 := by intro idx letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by by_cases hi : idx = 0 <;> simp only [gg, hi, CharP.cast_eq_zero, div_zero, one_div, mul_inv_rev, zero_div, Real.log_zero, mul_zero, ne_eq, OfNat.ofNat_ne_zero, not_false_eq_true, zero_pow, add_zero, inv_one, mul_one, zero_le_one] have l1 : 1 ≤ (idx : ℝ) := by simp ; omega have l2 : 1 ≤ 1 + (π⁻¹ * 2⁻¹ * Real.log (↑idx / x)) ^ 2 := by simp only [le_add_iff_nonneg_right] ; positivity rw [← mul_inv] ; apply inv_le_one_of_one_le₀ ; simpa using mul_le_mul l1 l2 zero_le_one (by simp) /- Original line 4549: one_div_two_pi_mem_Ioo -/ theorem one_div_two_pi_mem_Ioo : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace 1 / (2 * π) ∈ Ioo (-1) 1 := by letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by constructor · trans 0 · linarith · positivity · rw [div_lt_iff₀ (by positivity)] convert_to! 1 * 1 < 2 * π · simp · simp apply mul_lt_mul one_lt_two ?_ zero_lt_one zero_le_two trans 2 · exact one_le_two · exact two_le_pi /- Original line 4563: sum_telescopic -/ theorem sum_telescopic : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (a : ℕ → ℝ) (n : ℕ), ∑ idx ∈ Finset.range n, (a (idx + 1) - a idx) = a n - a 0 := by intro a n letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by apply Finset.sum_range_sub /- Original line 4566: cancel_aux -/ theorem cancel_aux : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {C : ℝ} {f g : ℕ → ℝ} (hf : 0 ≤ f) (hg : 0 ≤ g) (hf' : ∀ n, cumsum f n ≤ C * n) (hg' : Antitone g) (n : ℕ), ∑ idx ∈ Finset.range n, f idx * g idx ≤ g (n - 1) * (C * n) + (C * (↑(n - 1 - 1) + 1) * g 0 - C * (↑(n - 1 - 1) + 1) * g (n - 1) - ((n - 1 - 1) • (C * g 0) - ∑ x ∈ Finset.range (n - 1 - 1), C * g (x + 1))) := by intro C f g hf hg hf' hg' n letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by have l1 (n : ℕ) : (g n - g (n + 1)) * ∑ idx ∈ Finset.range (n + 1), f idx ≤ (g n - g (n + 1)) * (C * (n + 1)) := by apply mul_le_mul le_rfl (by simpa [cumsum_zero, nabla_cumsum] using! hf' (n + 1)) (Finset.sum_nonneg' hf) ?_ simp only [sub_nonneg] ; apply hg' ; simp[cumsum_zero, nabla_cumsum] have l2 (x : ℕ) : C * (↑(x + 1) + 1) - C * (↑x + 1) = C := by simp [cumsum_zero, nabla_cumsum] ; ring have l3 (n : ℕ) : 0 ≤ cumsum f n := Finset.sum_nonneg' hf convert_to ∑ idx ∈ Finset.range n, (g idx) • (f idx) ≤ _ · simp [cumsum_zero, nabla_cumsum, mul_comm] rw [Finset.sum_range_by_parts, sub_eq_add_neg, ← Finset.sum_neg_distrib] simp_rw [← neg_smul, neg_sub, smul_eq_mul] apply _root_.add_le_add · exact mul_le_mul le_rfl (hf' n) (l3 n) (hg _) · apply Finset.sum_le_sum (fun n _ => l1 n) |>.trans convert_to! ∑ idx ∈ Finset.range (n - 1), (C * (↑idx + 1)) • (g idx - g (idx + 1)) ≤ _ · congr ; ext idx ; simp [cumsum_zero, nabla_cumsum] ; ring rw [Finset.sum_range_by_parts] simp_rw [Finset.sum_range_sub', l2, smul_sub, smul_eq_mul, Finset.sum_sub_distrib, Finset.sum_const, Finset.card_range] apply le_of_eq ; ring_nf /- Original line 4593: sum_range_succ -/ theorem sum_range_succ : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (a : ℕ → ℝ) (n : ℕ), ∑ idx ∈ Finset.range n, a (idx + 1) = (∑ idx ∈ Finset.range (n + 1), a idx) - a 0 := by intro a n letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by have := Finset.sum_range_sub a n rw [Finset.sum_sub_distrib, sub_eq_iff_eq_add] at this rw [Finset.sum_range_succ, this] ; ring /- Original line 4599: cancel_aux' -/ theorem cancel_aux' : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {C : ℝ} {f g : ℕ → ℝ} (hf : 0 ≤ f) (hg : 0 ≤ g) (hf' : ∀ n, cumsum f n ≤ C * n) (hg' : Antitone g) (n : ℕ), ∑ idx ∈ Finset.range n, f idx * g idx ≤ C * n * g (n - 1) + C * cumsum g (n - 1 - 1 + 1) - C * (↑(n - 1 - 1) + 1) * g (n - 1) := by intro C f g hf hg hf' hg' n letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by have := cancel_aux hf hg hf' hg' n simp only [nsmul_eq_mul, ← Finset.mul_sum, sum_range_succ] at this convert this using 1 ; unfold cumsum ; ring /- Original line 4610: cancel_main -/ theorem cancel_main : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {C : ℝ} {f g : ℕ → ℝ} (hf : 0 ≤ f) (hg : 0 ≤ g) (hf' : ∀ n, cumsum f n ≤ C * n) (hg' : Antitone g) (n : ℕ) (hn : 2 ≤ n), cumsum (f * g) n ≤ C * cumsum g n := by intro C f g hf hg hf' hg' n hn letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by convert! cancel_aux' hf hg hf' hg' n using 1 match n with | n + 2 => simp only [cumsum_succ] ; push_cast ; ring /- Original line 4617: cancel_main' -/ theorem cancel_main' {C : ℝ} {f g : ℕ → ℝ} (hf : 0 ≤ f) (hf0 : f 0 = 0) (hg : 0 ≤ g) (hf' : ∀ n, cumsum f n ≤ C * n) (hg' : Antitone g) (n : ℕ) : cumsum (f * g) n ≤ C * cumsum g n := by match n with | 0 => simp [cumsum_zero, nabla_cumsum, cumsum] | 1 => specialize hg 0 ; specialize hf' 1 ; simp only [cumsum, Finset.range_one, Finset.sum_singleton, hf0, Nat.cast_one, mul_one, Pi.zero_apply, Pi.mul_apply, zero_mul, ge_iff_le] at hf' hg ⊢ ; positivity | n + 2 => convert! cancel_aux' hf hg hf' hg' (n + 2) using 1 ; simp [cumsum_zero, nabla_cumsum, cumsum_succ] ; ring /- Original line 4627: sum_le_integral -/ theorem sum_le_integral : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {x₀ : ℝ} {f : ℝ → ℝ} {n : ℕ} (hf : AntitoneOn f (Ioc x₀ (x₀ + n))) (hfi : IntegrableOn f (Icc x₀ (x₀ + n))), (∑ idx ∈ Finset.range n, f (x₀ + ↑(idx + 1))) ≤ ∫ x in x₀..x₀ + n, f x := by intro x₀ f n hf hfi letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by cases n with simp only [Nat.cast_add, Nat.cast_one, CharP.cast_eq_zero, add_zero, lt_self_iff_false, not_false_eq_true, Ioc_eq_empty, Finset.range_zero, Nat.cast_add, Nat.cast_one, Finset.sum_empty, intervalIntegral.integral_same, le_refl] at hf ⊢ | succ n => have : Finset.range (n + 1) = {0} ∪ Finset.Ico 1 (n + 1) := by ext idx ; by_cases hi : idx = 0 <;> simp [hi] ; omega simp only [this, Finset.singleton_union, Finset.mem_Ico, nonpos_iff_eq_zero, one_ne_zero, lt_add_iff_pos_left, add_pos_iff, zero_lt_one, or_true, and_true, not_false_eq_true, Finset.sum_insert, CharP.cast_eq_zero, zero_add, ge_iff_le] have l4 : IntervalIntegrable f volume x₀ (x₀ + 1) := by apply IntegrableOn.intervalIntegrable simp only [le_add_iff_nonneg_right, zero_le_one, uIcc_of_le] apply hfi.mono_set apply Icc_subset_Icc le_rfl simp have l5 x (hx : x ∈ Ioc x₀ (x₀ + 1)) : (fun x ↦ f (x₀ + 1)) x ≤ f x := by rcases hx with ⟨hx1, hx2⟩ refine hf ⟨hx1, by linarith⟩ ⟨by linarith, by linarith⟩ hx2 have l6 : ∫ x in x₀..x₀ + 1, f (x₀ + 1) = f (x₀ + 1) := by simp have l1 : f (x₀ + 1) ≤ ∫ x in x₀..x₀ + 1, f x := by rw [← l6] ; apply intervalIntegral.integral_mono_ae_restrict (by linarith) (by simp) l4 apply eventually_of_mem _ l5 have : (Ioc x₀ (x₀ + 1))ᶜ ∩ Icc x₀ (x₀ + 1) = {x₀} := by simp [← sdiff_eq_compl_inter] rw [mem_ae_iff, Measure.restrict_apply measurableSet_Ioc.compl, this] exact measure_singleton x₀ have l2 : AntitoneOn (fun x ↦ f (x₀ + x)) (Icc 1 ↑(n + 1)) := by intro u ⟨hu1, _⟩ v ⟨_, hv2⟩ huv ; push_cast at hv2 refine hf ⟨?_, ?_⟩ ⟨?_, ?_⟩ ?_ <;> linarith have l3 := @AntitoneOn.sum_le_integral_Ico 1 (n + 1) (fun x => f (x₀ + x)) (by simp) (by simpa using l2) simp only [Nat.cast_add, Nat.cast_one, intervalIntegral.integral_comp_add_left] at l3 convert! _root_.add_le_add l1 l3 have := @intervalIntegral.integral_comp_mul_add ℝ _ _ 1 (n + 1) 1 f one_ne_zero x₀ rw [intervalIntegral.integral_add_adjacent_intervals] · exact l4 · apply IntegrableOn.intervalIntegrable simp only [add_le_add_iff_left, le_add_iff_nonneg_left, Nat.cast_nonneg, uIcc_of_le] apply hfi.mono_set apply Icc_subset_Icc · linarith · simp /- Original line 4680: hh_integrable_aux -/ theorem hh_integrable_aux : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (ha : 0 < a) (hb : 0 < b) (hc : 0 < c), (IntegrableOn (fun t ↦ a * hh b (t / c)) (Ici 0)) ∧ (∫ (t : ℝ) in Ioi 0, a * hh b (t / c) = a * c / b * π) := by intro ha hb hc letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by rw [integrableOn_Ici_iff_integrableOn_Ioi] simp only [hh] let g (x : ℝ) := (a * c / b) * Real.arctan (b * log (x / c)) let g₀ (x : ℝ) := if x = 0 then ((a * c / b) * (- (π / 2))) else g x let g' (x : ℝ) := a * (x / c * (1 + (b * Real.log (x / c)) ^ 2))⁻¹ have l3 (x) (hx : 0 < x) : HasDerivAt Real.log x⁻¹ x := by apply Real.hasDerivAt_log (by linarith) have l4 (x) : HasDerivAt (fun t => t / c) (1 / c) x := (hasDerivAt_id x).div_const c have l2 (x) (hx : 0 < x) : HasDerivAt (fun t => log (t / c)) x⁻¹ x := by have := @HasDerivAt.comp _ _ _ _ _ _ (fun t => t / c) _ _ _ (l3 (x / c) (by positivity)) (l4 x) convert! this using 1 ; field_simp have l5 (x) (hx : 0 < x) := (l2 x hx).const_mul b have l1 (x) (hx : 0 < x) := (l5 x hx).arctan have l6 (x) (hx : 0 < x) : HasDerivAt g (g' x) x := by convert! (l1 x hx).const_mul (a * c / b) using 1 simp only [g'] field_simp have key (x) (hx : 0 < x) : HasDerivAt g₀ (g' x) x := by apply (l6 x hx).congr_of_eventuallyEq apply eventually_of_mem <| Ioi_mem_nhds hx intro y (hy : 0 < y) simp [g₀, hy.ne.symm] have k1 : Tendsto g₀ atTop (𝓝 ((a * c / b) * (π / 2))) := by have : g =ᶠ[atTop] g₀ := by apply eventually_of_mem (Ioi_mem_atTop 0) intro y (hy : 0 < y) simp [g₀, hy.ne.symm] apply Tendsto.congr' this apply Tendsto.const_mul apply (tendsto_arctan_atTop.mono_right nhdsWithin_le_nhds).comp apply Tendsto.const_mul_atTop hb apply tendsto_log_atTop.comp apply Tendsto.atTop_div_const hc apply tendsto_id have k2 : Tendsto g₀ (𝓝[>] 0) (𝓝 (g₀ 0)) := by have : g =ᶠ[𝓝[>] 0] g₀ := by apply eventually_of_mem self_mem_nhdsWithin intro x (hx : 0 < x) ; simp [g₀, hx.ne.symm] simp only [g₀] apply Tendsto.congr' this apply Tendsto.const_mul apply (tendsto_arctan_atBot.mono_right nhdsWithin_le_nhds).comp apply Tendsto.const_mul_atBot hb apply tendsto_log_nhdsGT_zero.comp rw [Metric.tendsto_nhdsWithin_nhdsWithin] intro ε hε refine ⟨c * ε, by positivity, fun x hx1 hx2 => ⟨?_, ?_⟩⟩ · simp only [mem_Ioi] at hx1 ⊢ ; positivity · simp only [dist_zero_right, norm_eq_abs, norm_div, abs_eq_self.mpr hc.le] at hx2 ⊢ rwa [div_lt_iff₀ hc, mul_comm] have k3 : ContinuousWithinAt g₀ (Ici 0) 0 := by rw [Metric.continuousWithinAt_iff] rw [Metric.tendsto_nhdsWithin_nhds] at k2 peel k2 with ε hε δ hδ x h intro (hx : 0 ≤ x) have := le_iff_lt_or_eq.mp hx cases this with | inl hx => exact h hx | inr hx => simp [g₀, hx.symm, hε] have k4 : ∀ x ∈ Ioi 0, 0 ≤ g' x := by intro x (hx : 0 < x) ; simp only [mul_inv_rev, inv_div, g'] ; positivity constructor · convert_to IntegrableOn g' _ exact integrableOn_Ioi_deriv_of_nonneg k3 key k4 k1 · have := integral_Ioi_of_hasDerivAt_of_nonneg k3 key k4 k1 simp only [mul_inv_rev, inv_div, mul_neg, ↓reduceIte, sub_neg_eq_add, g', g₀] at this ⊢ convert this using 1 ; field_simp ; ring /- Original line 4758: hh_integrable -/ theorem hh_integrable : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (ha : 0 < a) (hb : 0 < b) (hc : 0 < c), IntegrableOn (fun t ↦ a * hh b (t / c)) (Ici 0) := by intro ha hb hc letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact hh_integrable_aux ha hb hc |>.1 /- Original line 4762: hh_integral -/ theorem hh_integral : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (ha : 0 < a) (hb : 0 < b) (hc : 0 < c), ∫ (t : ℝ) in Ioi 0, a * hh b (t / c) = a * c / b * π := by intro ha hb hc letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact hh_integrable_aux ha hb hc |>.2 /- Original line 4766: hh_integral' -/ theorem hh_integral' : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∫ t in Ioi 0, hh (1 / (2 * π)) t = 2 * π ^ 2 := by letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by have := hh_integral (a := 1) (b := 1 / (2 * π)) (c := 1) (by positivity) (by positivity) (by positivity) convert this using 1 <;> simp ; ring /- Original line 4771: bound_sum_log -/ theorem bound_sum_log : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {C : ℝ} (hf0 : f 0 = 0) (hf : chebyWith C f) {x : ℝ} (hx : 1 ≤ x), ∑' idx, ‖f idx‖ / idx * (1 + (1 / (2 * π) * log (idx / x)) ^ 2)⁻¹ ≤ C * (1 + ∫ t in Ioi 0, hh (1 / (2 * π)) t) := by intro C hf0 hf x hx letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by let ggg (idx : ℕ) : ℝ := if idx = 0 then 1 else gg x idx have l0 : x ≠ 0 := by linarith have l1 idx : 0 ≤ ggg idx := by by_cases hi : idx = 0 <;> simp only [gg, one_div, mul_inv_rev, hi, ↓reduceIte, zero_le_one, ggg] ; positivity have l2 : Antitone ggg := by intro idx j hij ; by_cases hi : idx = 0 <;> by_cases hj : j = 0 <;> simp only [hj, ↓reduceIte, hi, le_refl, ggg] · exact gg_le_one _ · omega · simp only [gg_of_hh l0] gcongr apply hh_antitone one_div_two_pi_mem_Ioo · simp only [mem_Ioi] ; positivity · simp only [mem_Ioi] ; positivity · gcongr have l3 : 0 ≤ C := by simpa [cumsum_zero, nabla_cumsum, cumsum, hf0] using hf 1 have l4 : 0 ≤ ∫ (t : ℝ) in Ioi 0, hh (π⁻¹ * 2⁻¹) t := setIntegral_nonneg measurableSet_Ioi (fun x hx => hh_nonneg _ (LT.lt.le hx)) have l5 {n : ℕ} : AntitoneOn (fun t ↦ x⁻¹ * hh (1 / (2 * π)) (t / x)) (Ioc 0 n) := by intro u ⟨hu1, _⟩ v ⟨hv1, _⟩ huv simp only apply mul_le_mul le_rfl ?_ (hh_nonneg _ (by positivity)) (by positivity) apply hh_antitone one_div_two_pi_mem_Ioo (by simp only [mem_Ioi] ; positivity) (by simp only [mem_Ioi] ; positivity) apply (div_le_div_iff_of_pos_right (by positivity)).mpr huv have l6 {n : ℕ} : IntegrableOn (fun t ↦ x⁻¹ * hh (π⁻¹ * 2⁻¹) (t / x)) (Icc 0 n) volume := by apply IntegrableOn.mono_set (hh_integrable (by positivity) (by positivity) (by positivity)) Icc_subset_Ici_self apply Real.tsum_le_of_sum_range_le (fun n => by positivity) ; intro n convert_to! ∑ idx ∈ Finset.range n, ‖f idx‖ * ggg idx ≤ _ · congr ; ext idx by_cases hi : idx = 0 · simp [cumsum_zero, nabla_cumsum, hi, hf0] · simp only [gg, hi, ↓reduceIte, ggg] field_simp apply cancel_main' (fun _ => norm_nonneg _) (by simp [cumsum_zero, nabla_cumsum, hf0]) l1 hf l2 n |>.trans gcongr ; simp only [cumsum, gg_of_hh l0, one_div, mul_inv_rev, ggg] by_cases hn : n = 0 · simp only [hn, Finset.range_zero, Finset.sum_empty] ; positivity replace hn : 0 < n := by omega have : Finset.range n = {0} ∪ Finset.Ico 1 n := by ext idx ; simp [cumsum_zero, nabla_cumsum] ; by_cases hi : idx = 0 <;> simp [cumsum_zero, nabla_cumsum, hi, hn] ; omega simp only [this, Finset.singleton_union, Finset.mem_Ico, nonpos_iff_eq_zero, one_ne_zero, false_and, not_false_eq_true, Finset.sum_insert, ↓reduceIte, add_le_add_iff_left, ge_iff_le] convert_to! ∑ x_1 ∈ Finset.Ico 1 n, x⁻¹ * hh (π⁻¹ * 2⁻¹) (↑x_1 / x) ≤ _ · apply Finset.sum_congr rfl (fun idx hi => ?_) simp [cumsum_zero, nabla_cumsum] at hi have : idx ≠ 0 := by omega simp [cumsum_zero, nabla_cumsum, this] simp_rw [Finset.sum_Ico_eq_sum_range, add_comm 1] have := @sum_le_integral 0 (fun t => x⁻¹ * hh (π⁻¹ * 2⁻¹) (t / x)) (n - 1) (by simpa [cumsum_zero, nabla_cumsum] using l5) (by simpa [cumsum_zero, nabla_cumsum] using l6) simp only [zero_add] at this apply this.trans rw [@intervalIntegral.integral_comp_div ℝ _ _ 0 ↑(n - 1) x (fun t => x⁻¹ * hh (π⁻¹ * 2⁻¹) (t)) l0] simp only [zero_div, intervalIntegral.integral_const_mul, smul_eq_mul, ← mul_assoc, mul_inv_cancel₀ l0, one_mul] have : (0 : ℝ) ≤ ↑(n - 1) / x := by positivity rw [intervalIntegral.intervalIntegral_eq_integral_uIoc] simp only [this, ↓reduceIte, uIoc_of_le, smul_eq_mul, one_mul, ge_iff_le] apply integral_mono_measure · apply Measure.restrict_mono Ioc_subset_Ioi_self le_rfl · apply eventually_of_mem (self_mem_ae_restrict measurableSet_Ioi) intro x (hx : 0 < x) apply hh_nonneg _ hx.le · have := (@hh_integrable 1 (1 / (2 * π)) 1 (by positivity) (by positivity) (by positivity)) simpa [cumsum_zero, nabla_cumsum] using! this.mono_set Ioi_subset_Ici_self /- Original line 4850: bound_sum_log0 -/ theorem bound_sum_log0 : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {C : ℝ} (hf : chebyWith C f) {x : ℝ} (hx : 1 ≤ x), ∑' idx, ‖f idx‖ / idx * (1 + (1 / (2 * π) * log (idx / x)) ^ 2)⁻¹ ≤ C * (1 + ∫ t in Ioi 0, hh (1 / (2 * π)) t) := by intro C hf x hx letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by let f0 idx := if idx = 0 then 0 else f idx have l1 : chebyWith C f0 := by intro n ; refine Finset.sum_le_sum (fun idx _ => ?_) |>.trans (hf n) by_cases hi : idx = 0 <;> simp [hi, f0] have l2 idx : ‖f idx‖ / idx = ‖f0 idx‖ / idx := by by_cases hi : idx = 0 <;> simp [hi, f0] simp_rw [l2] ; apply bound_sum_log rfl l1 hx /- Original line 4861: bound_sum_log' -/ theorem bound_sum_log' : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {C : ℝ} (hf : chebyWith C f) {x : ℝ} (hx : 1 ≤ x), ∑' idx, ‖f idx‖ / idx * (1 + (1 / (2 * π) * log (idx / x)) ^ 2)⁻¹ ≤ C * (1 + 2 * π ^ 2) := by intro C hf x hx letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by simpa only [hh_integral'] using bound_sum_log0 hf hx variable (f x) in /- Original line 4866: summable_fourier_aux -/ theorem summable_fourier_aux : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (ψ : W21) (idx : ℕ), ‖f idx / idx * 𝓕 (ψ : ℝ → ℂ) (1 / (2 * π) * Real.log (idx / x))‖ ≤ W21.norm ψ * (‖f idx‖ / idx * (1 + (1 / (2 * π) * log (idx / x)) ^ 2)⁻¹) := by intro ψ idx letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by convert! mul_le_mul_of_nonneg_left (decay_bounds_key ψ (1 / (2 * π) * log (idx / x))) (norm_nonneg (f idx / idx)) using 1 · simp · change _ = _ * (W21.norm ψ * _) simp only [W21.norm, mul_inv_rev, one_div, Complex.norm_div, RCLike.norm_natCast] ring /- Original line 4876: summable_fourier -/ theorem summable_fourier : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (x : ℝ) (hx : 0 < x) (ψ : W21) (hcheby : cheby f), Summable fun idx ↦ ‖f idx / ↑idx * 𝓕 (ψ : ℝ → ℂ) (1 / (2 * π) * Real.log (↑idx / x))‖ := by intro x hx ψ hcheby letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by have l5 : Summable fun idx ↦ ‖f idx‖ / ↑idx * ((1 + (1 / (2 * ↑π) * ↑(Real.log (↑idx / x))) ^ 2)⁻¹) := by simpa using limiting_fourier_lim1_aux hcheby hx 1 (zero_le_one' ℝ) have l6 := summable_fourier_aux x f ψ exact Summable.of_nonneg_of_le (fun _ => norm_nonneg _) l6 (by simpa using l5.const_smul (W21.norm ψ)) /- Original line 4884: bound_I1 -/ theorem bound_I1 : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (x : ℝ) (hx : 0 < x) (ψ : W21) (hcheby : cheby f), ‖∑' n, f n / n * 𝓕 (ψ : ℝ → ℂ) (1 / (2 * π) * log (n / x))‖ ≤ W21.norm ψ • ∑' idx, ‖f idx‖ / idx * (1 + (1 / (2 * π) * log (idx / x)) ^ 2)⁻¹ := by intro x hx ψ hcheby letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by have l5 : Summable fun idx ↦ ‖f idx‖ / ↑idx * ((1 + (1 / (2 * ↑π) * ↑(Real.log (↑idx / x))) ^ 2)⁻¹) := by simpa using limiting_fourier_lim1_aux hcheby hx 1 (zero_le_one' ℝ) have l6 := summable_fourier_aux x f ψ have l1 : Summable fun idx ↦ ‖f idx / ↑idx * 𝓕 (ψ : ℝ → ℂ) (1 / (2 * π) * Real.log (↑idx / x))‖ := by exact summable_fourier x hx ψ hcheby apply (norm_tsum_le_tsum_norm l1).trans simpa only [← Summable.tsum_const_smul _ l5] using! Summable.tsum_mono l1 (by simpa using l5.const_smul (W21.norm ψ)) l6 /- Original line 4897: bound_I1' -/ theorem bound_I1' : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {C : ℝ} (x : ℝ) (hx : 1 ≤ x) (ψ : W21) (hcheby : chebyWith C f), ‖∑' n, f n / n * 𝓕 (ψ : ℝ → ℂ) (1 / (2 * π) * log (n / x))‖ ≤ W21.norm ψ * C * (1 + 2 * π ^ 2) := by intro C x hx ψ hcheby letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by apply bound_I1 x (by linarith) ψ ⟨_, hcheby⟩ |>.trans rw [smul_eq_mul, mul_assoc] apply mul_le_mul le_rfl (bound_sum_log' hcheby hx) ?_ W21.norm_nonneg apply tsum_nonneg (fun idx => by positivity) /- Original line 4906: bound_I2 -/ theorem bound_I2 : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (x : ℝ) (ψ : W21), ‖∫ u in Set.Ici (-log x), 𝓕 (ψ : ℝ → ℂ) (u / (2 * π))‖ ≤ W21.norm ψ * (2 * π ^ 2) := by intro x ψ letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by have key a : ‖𝓕 (ψ : ℝ → ℂ) (a / (2 * π))‖ ≤ W21.norm ψ * (1 + (a / (2 * π)) ^ 2)⁻¹ := decay_bounds_key ψ _ have twopi : 0 ≤ 2 * π := by simp [pi_nonneg] have l3 : Integrable (fun a ↦ (1 + (a / (2 * π)) ^ 2)⁻¹) := integrable_inv_one_add_sq.comp_div (by norm_num [pi_ne_zero]) have l2 : IntegrableOn (fun idx ↦ W21.norm ψ * (1 + (idx / (2 * π)) ^ 2)⁻¹) (Ici (-Real.log x)) := by exact (l3.const_mul _).integrableOn have l1 : IntegrableOn (fun idx ↦ ‖𝓕 (ψ : ℝ → ℂ) (idx / (2 * π))‖) (Ici (-Real.log x)) := by refine ((l3.const_mul (W21.norm ψ)).mono' ?_ ?_).integrableOn · exact ((continuous_FourierIntegral ψ).comp (continuous_id.div_const (2 * π))).norm.aestronglyMeasurable · simp only [norm_norm, key] ; simp have l5 : 0 ≤ᵐ[volume] fun a ↦ (1 + (a / (2 * π)) ^ 2)⁻¹ := by apply Eventually.of_forall ; intro x ; positivity refine (norm_integral_le_integral_norm _).trans <| (setIntegral_mono l1 l2 key).trans ?_ rw [integral_const_mul] ; gcongr · apply W21.norm_nonneg refine (setIntegral_le_integral l3 l5).trans ?_ rw [Measure.integral_comp_div (fun x => (1 + x ^ 2)⁻¹) (2 * π)] simp [abs_eq_self.mpr twopi] ; ring_nf ; rfl /- Original line 4929: bound_main -/ theorem bound_main : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {C : ℝ} (A : ℂ) (x : ℝ) (hx : 1 ≤ x) (ψ : W21) (hcheby : chebyWith C f), ‖∑' n, f n / n * 𝓕 (ψ : ℝ → ℂ) (1 / (2 * π) * log (n / x)) - A * ∫ u in Set.Ici (-log x), 𝓕 (ψ : ℝ → ℂ) (u / (2 * π))‖ ≤ W21.norm ψ * (C * (1 + 2 * π ^ 2) + ‖A‖ * (2 * π ^ 2)) := by intro C A x hx ψ hcheby letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by have l1 := bound_I1' x hx ψ hcheby have l2 := mul_le_mul (le_refl ‖A‖) (bound_I2 x ψ) (by positivity) (by positivity) apply norm_sub_le _ _ |>.trans ; rw [norm_mul] convert _root_.add_le_add l1 l2 using 1 ; ring /- Original line 4942: limiting_cor_W21 -/ theorem limiting_cor_W21 : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (ψ : W21) (hf : ∀ (σ' : ℝ), 1 < σ' → Summable (nterm f σ')) (hcheby : cheby f) (hG : ContinuousOn G {s | 1 ≤ s.re}) (hG' : Set.EqOn G (fun s ↦ LSeries f s - A / (s - 1)) {s | 1 < s.re}), Tendsto (fun x : ℝ ↦ ∑' n, f n / n * 𝓕 (ψ : ℝ → ℂ) (1 / (2 * π) * log (n / x)) - A * ∫ u in Set.Ici (-log x), 𝓕 (ψ : ℝ → ℂ) (u / (2 * π))) atTop (𝓝 0) := by intro ψ hf hcheby hG hG' letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by -- Shorter notation for clarity let S1 x (ψ : ℝ → ℂ) := ∑' (n : ℕ), f n / ↑n * 𝓕 (ψ : ℝ → ℂ) (1 / (2 * π) * Real.log (↑n / x)) let S2 x (ψ : ℝ → ℂ) := ↑A * ∫ (u : ℝ) in Ici (-Real.log x), 𝓕 (ψ : ℝ → ℂ) (u / (2 * π)) let S x ψ := S1 x ψ - S2 x ψ ; change Tendsto (fun x ↦ S x ψ) atTop (𝓝 0) -- Build the truncation obtain g := exists_trunc let Ψ R := g.scale R * ψ have key R : Tendsto (fun x ↦ S x (Ψ R)) atTop (𝓝 0) := limiting_cor (Ψ R) hf hcheby hG hG' -- Choose the truncation radius obtain ⟨C, hcheby⟩ := hcheby have hC : 0 ≤ C := by have : ‖f 0‖ ≤ C := by simpa [CS.neg_apply, CS.smul_apply, cumsum_zero, nabla_cumsum, cumsum] using hcheby 1 have : 0 ≤ ‖f 0‖ := by positivity linarith have key2 : Tendsto (fun R ↦ W21.norm (ψ - Ψ R)) atTop (𝓝 0) := W21_approximation ψ g simp_rw [Metric.tendsto_nhds] at key key2 ⊢ ; intro ε hε let M := C * (1 + 2 * π ^ 2) + ‖(A : ℂ)‖ * (2 * π ^ 2) obtain ⟨R, hRψ⟩ := (key2 ((ε / 2) / (1 + M)) (by positivity)).exists simp only [dist_zero_right, Real.norm_eq_abs, abs_eq_self.mpr W21.norm_nonneg] at hRψ key -- Apply the compact support case filter_upwards [eventually_ge_atTop 1, key R (ε / 2) (by positivity)] with x hx key -- Control the tail term have key3 : ‖S x (ψ - Ψ R)‖ < ε / 2 := by have : ‖S x _‖ ≤ _ * M := @bound_main f C A x hx (ψ - Ψ R) hcheby apply this.trans_lt apply (mul_le_mul (d := 1 + M) le_rfl (by simp[CS.neg_apply, CS.smul_apply, cumsum_zero, nabla_cumsum] ) (by positivity) W21.norm_nonneg).trans_lt have : 0 < 1 + M := by positivity convert! (mul_lt_mul_iff_left₀ this).mpr hRψ using 1 ; field_simp -- Conclude the proof have S1_sub_1 x : 𝓕 (⇑ψ - ⇑(Ψ R)) x = 𝓕 (ψ : ℝ → ℂ) x - 𝓕 ⇑(Ψ R) x := by have l1 : AEStronglyMeasurable (fun x_1 : ℝ ↦ cexp (-(2 * ↑π * (↑x_1 * ↑x) * I))) volume := by refine (Continuous.mul ?_ continuous_const).neg.cexp.aestronglyMeasurable apply continuous_const.mul <| contDiff_ofReal.continuous.mul continuous_const simp only [Real.fourier_eq', neg_mul, RCLike.inner_apply', conj_trivial, ofReal_neg, ofReal_mul, ofReal_ofNat, Pi.sub_apply, smul_eq_mul, mul_sub] apply integral_sub · apply ψ.hf.bdd_mul (c := 1) l1 ; simp [CS.neg_apply, CS.smul_apply, cumsum_zero, nabla_cumsum, Complex.norm_exp] · apply (Ψ R : W21) |>.hf |>.bdd_mul (c := 1) l1 simp [CS.neg_apply, CS.smul_apply, cumsum_zero, nabla_cumsum, Complex.norm_exp] have S1_sub : S1 x (ψ - Ψ R) = S1 x ψ - S1 x (Ψ R) := by simp only [one_div, mul_inv_rev, S1_sub_1, mul_sub, S1] ; apply Summable.tsum_sub · have := summable_fourier x (by positivity) ψ ⟨_, hcheby⟩ rw [summable_norm_iff] at this simpa [CS.neg_apply, CS.smul_apply, cumsum_zero, nabla_cumsum] using this · have := summable_fourier x (by positivity) (Ψ R) ⟨_, hcheby⟩ rw [summable_norm_iff] at this simpa [CS.neg_apply, CS.smul_apply, cumsum_zero, nabla_cumsum] using! this have S2_sub : S2 x (ψ - Ψ R) = S2 x ψ - S2 x (Ψ R) := by simp only [S1_sub_1, S2] ; rw [integral_sub] · ring · exact ψ.integrable_fourier (by positivity) |>.restrict · exact (Ψ R : W21).integrable_fourier (by positivity) |>.restrict have S_sub : S x (ψ - Ψ R) = S x ψ - S x (Ψ R) := by simp [CS.neg_apply, CS.smul_apply, cumsum_zero, nabla_cumsum, S, S1_sub, S2_sub] ; ring simpa [CS.neg_apply, CS.smul_apply, cumsum_zero, nabla_cumsum, S_sub, Ψ] using norm_add_le _ _ |>.trans_lt (_root_.add_lt_add key3 key) /- Original line 5012: limiting_cor_schwartz -/ theorem limiting_cor_schwartz : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (ψ : 𝓢(ℝ, ℂ)) (hf : ∀ (σ' : ℝ), 1 < σ' → Summable (nterm f σ')) (hcheby : cheby f) (hG : ContinuousOn G {s | 1 ≤ s.re}) (hG' : Set.EqOn G (fun s ↦ LSeries f s - A / (s - 1)) {s | 1 < s.re}), Tendsto (fun x : ℝ ↦ ∑' n, f n / n * 𝓕 (ψ : ℝ → ℂ) (1 / (2 * π) * log (n / x)) - A * ∫ u in Set.Ici (-log x), 𝓕 (ψ : ℝ → ℂ) (u / (2 * π))) atTop (𝓝 0) := by intro ψ hf hcheby hG hG' letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact limiting_cor_W21 ψ hf hcheby hG hG' -- just the surjectivity is stated here, as this is all that is needed for the current -- application, but perhaps one should state and prove bijectivity instead /- Original line 5027: fourier_surjection_on_schwartz -/ theorem fourier_surjection_on_schwartz : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (f : 𝓢(ℝ, ℂ)), ∃ g : 𝓢(ℝ, ℂ), 𝓕 g = f := by intro f letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by refine ⟨𝓕⁻ f, ?_⟩ exact FourierTransform.fourier_fourierInv_eq f /- Original line 5034: toSchwartz -/ noncomputable def toSchwartz : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (f : ℝ → ℂ) (h1 : ContDiff ℝ ∞ f) (h2 : HasCompactSupport f), 𝓢(ℝ, ℂ) := by intro f h1 h2 letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact { toFun := f smooth' := h1 decay' k n := by have l1 : Continuous (fun x => ‖x‖ ^ k * ‖iteratedFDeriv ℝ n f x‖) := by have : ContDiff ℝ ∞ (iteratedFDeriv ℝ n f) := h1.iteratedFDeriv_right (mod_cast le_top) exact Continuous.mul (by continuity) this.continuous.norm have l2 : HasCompactSupport (fun x ↦ ‖x‖ ^ k * ‖iteratedFDeriv ℝ n f x‖) := (h2.iteratedFDeriv _).norm.mul_left simpa using l1.bounded_above_of_compact_support l2 } /- Original line 5046: toSchwartz_apply -/ theorem toSchwartz_apply : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (f : ℝ → ℂ) {h1 h2 x}, SchwartzMap.mk f h1 h2 x = f x := by intro f h1 h2 x letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact rfl /- Original line 5048: comp_exp_support0 -/ theorem comp_exp_support0 : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {Ψ : ℝ → ℂ} (hplus : closure (Function.support Ψ) ⊆ Ioi 0), ∀ᶠ x in 𝓝 0, Ψ x = 0 := by intro Ψ hplus letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact notMem_tsupport_iff_eventuallyEq.mp (fun h => lt_irrefl 0 <| mem_Ioi.mp (hplus h)) /- Original line 5052: comp_exp_support1 -/ theorem comp_exp_support1 : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {Ψ : ℝ → ℂ} (hplus : closure (Function.support Ψ) ⊆ Ioi 0), ∀ᶠ x in atBot, Ψ (exp x) = 0 := by intro Ψ hplus letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact Real.tendsto_exp_atBot <| comp_exp_support0 hplus /- Original line 5056: comp_exp_support2 -/ theorem comp_exp_support2 : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {Ψ : ℝ → ℂ} (hsupp : HasCompactSupport Ψ), ∀ᶠ (x : ℝ) in atTop, (Ψ ∘ rexp) x = 0 := by intro Ψ hsupp letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by simp only [hasCompactSupport_iff_eventuallyEq, coclosedCompact_eq_cocompact, cocompact_eq_atBot_atTop] at hsupp exact Real.tendsto_exp_atTop hsupp.2 /- Original line 5062: comp_exp_support -/ theorem comp_exp_support : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {Ψ : ℝ → ℂ} (hsupp : HasCompactSupport Ψ) (hplus : closure (Function.support Ψ) ⊆ Ioi 0), HasCompactSupport (Ψ ∘ rexp) := by intro Ψ hsupp hplus letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by simp only [hasCompactSupport_iff_eventuallyEq, coclosedCompact_eq_cocompact, cocompact_eq_atBot_atTop] exact ⟨comp_exp_support1 hplus, comp_exp_support2 hsupp⟩ /- Original line 5069: wiener_ikehara_smooth_aux -/ theorem wiener_ikehara_smooth_aux : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (l0 : Continuous Ψ) (hsupp : HasCompactSupport Ψ) (hplus : closure (Function.support Ψ) ⊆ Ioi 0) (x : ℝ) (hx : 0 < x), ∫ (u : ℝ) in Ioi (-Real.log x), ↑(rexp u) * Ψ (rexp u) = ∫ (y : ℝ) in Ioi (1 / x), Ψ y := by intro l0 hsupp hplus x hx letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by have l1 : ContinuousOn rexp (Ici (-Real.log x)) := by fun_prop have l2 : Tendsto rexp atTop atTop := Real.tendsto_exp_atTop have l3 t (_ : t ∈ Ioi (-log x)) : HasDerivWithinAt rexp (rexp t) (Ioi t) t := (Real.hasDerivAt_exp t).hasDerivWithinAt have l4 : ContinuousOn Ψ (rexp '' Ioi (-Real.log x)) := by fun_prop have l5 : IntegrableOn Ψ (rexp '' Ici (-Real.log x)) volume := (l0.integrable_of_hasCompactSupport hsupp).integrableOn have l6 : IntegrableOn (fun x ↦ rexp x • (Ψ ∘ rexp) x) (Ici (-Real.log x)) volume := by refine (Continuous.integrable_of_hasCompactSupport (by fun_prop) ?_).integrableOn change HasCompactSupport (rexp • (Ψ ∘ rexp)) exact (comp_exp_support hsupp hplus).smul_left have := MeasureTheory.integral_deriv_smul_comp_Ioi l1 l2 l3 l4 l5 l6 simpa [Real.exp_neg, Real.exp_log hx] using this /- Original line 5087: wiener_ikehara_smooth_sub -/ theorem wiener_ikehara_smooth_sub : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (h1 : Integrable Ψ) (hplus : closure (Function.support Ψ) ⊆ Ioi 0), Tendsto (fun x ↦ (↑A * ∫ (y : ℝ) in Ioi x⁻¹, Ψ y) - ↑A * ∫ (y : ℝ) in Ioi 0, Ψ y) atTop (𝓝 0) := by intro h1 hplus letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by obtain ⟨ε, hε, hh⟩ := Metric.eventually_nhds_iff.mp <| comp_exp_support0 hplus apply tendsto_nhds_of_eventually_eq ; filter_upwards [eventually_gt_atTop ε⁻¹] with x hxε have l1 : Integrable (indicator (Ioi x⁻¹) (fun x : ℝ => Ψ x)) := h1.indicator measurableSet_Ioi have l2 : Integrable (indicator (Ioi 0) (fun x : ℝ => Ψ x)) := h1.indicator measurableSet_Ioi simp_rw [← MeasureTheory.integral_indicator measurableSet_Ioi, ← mul_sub, ← integral_sub l1 l2] simp only [mul_eq_zero, ofReal_eq_zero] right apply MeasureTheory.integral_eq_zero_of_ae apply Eventually.of_forall intro t simp only [Pi.zero_apply] have hε' : 0 < ε⁻¹ := by positivity have hx : 0 < x := by linarith have hx' : 0 < x⁻¹ := by positivity have hεx : x⁻¹ < ε := (inv_lt_comm₀ hε hx).mp hxε have l3 : Ioi 0 = Ioc 0 x⁻¹ ∪ Ioi x⁻¹ := by ext t ; simp only [mem_Ioi, mem_union, mem_Ioc] ; constructor <;> intro h · simp [h, le_or_gt] · cases h with | inl h => exact h.1 | inr h => exact hx'.trans h have l4 : Disjoint (Ioc 0 x⁻¹) (Ioi x⁻¹) := by simp have l5 := Set.indicator_union_of_disjoint l4 Ψ rw [l3, l5] simp only rw [add_comm, sub_add_cancel_left] by_cases ht : t ∈ Ioc 0 x⁻¹ · simp only [ht, indicator_of_mem, neg_eq_zero] apply hh ; simp only [mem_Ioc, dist_zero_right, norm_eq_abs] at ht ⊢ apply hεx.trans_le' rw [abs_le] ; constructor <;> linarith simp [ht] /- Original line 5132: wiener_ikehara_smooth -/ theorem wiener_ikehara_smooth : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (hf : ∀ (σ' : ℝ), 1 < σ' → Summable (nterm f σ')) (hcheby : cheby f) (hG : ContinuousOn G {s | 1 ≤ s.re}) (hG' : Set.EqOn G (fun s ↦ LSeries f s - A / (s - 1)) {s | 1 < s.re}) (hsmooth : ContDiff ℝ ∞ Ψ) (hsupp : HasCompactSupport Ψ) (hplus : closure (Function.support Ψ) ⊆ Set.Ioi 0), Tendsto (fun x : ℝ ↦ (∑' n, f n * Ψ (n / x)) / x - A * ∫ y in Set.Ioi 0, Ψ y) atTop (𝓝 0) := by intro hf hcheby hG hG' hsmooth hsupp hplus letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by let h (x : ℝ) : ℂ := rexp (2 * π * x) * Ψ (exp (2 * π * x)) have h1 : ContDiff ℝ ∞ h := by have : ContDiff ℝ ∞ (fun x : ℝ => (rexp (2 * π * x))) := (contDiff_const.mul contDiff_id).exp exact (contDiff_ofReal.comp this).mul (hsmooth.comp this) have h2 : HasCompactSupport h := by have : 2 * π ≠ 0 := by simp [pi_ne_zero] simpa using! (comp_exp_support hsupp hplus).comp_smul this |>.mul_left obtain ⟨g, hg⟩ := fourier_surjection_on_schwartz (toSchwartz h h1 h2) have l1 {y} (hy : 0 < y) : y * Ψ y = 𝓕 g (1 / (2 * π) * Real.log y) := by simp only [one_div, mul_inv_rev, hg, toSchwartz, ofReal_exp, ofReal_mul, ofReal_ofNat, toSchwartz_apply, ofReal_inv, h] field_simp norm_cast rw [Real.exp_log hy] have key := limiting_cor_schwartz g hf hcheby hG hG' have l2 : ∀ᶠ x in atTop, ∑' (n : ℕ), f n / ↑n * 𝓕 g (1 / (2 * π) * Real.log (↑n / x)) = ∑' (n : ℕ), f n * Ψ (↑n / x) / x := by filter_upwards [eventually_gt_atTop 0] with x hx congr ; ext n by_cases hn : n = 0 · simp [hn, (comp_exp_support0 hplus).self_of_nhds] rw [← l1 (by positivity)] have : (n : ℂ) ≠ 0 := by simpa using hn have : (x : ℂ) ≠ 0 := by simpa using hx.ne.symm simp only [ofReal_div, ofReal_natCast] field_simp have l3 : ∀ᶠ x in atTop, ↑A * ∫ (u : ℝ) in Ici (-Real.log x), 𝓕 g (u / (2 * π)) = ↑A * ∫ (y : ℝ) in Ioi x⁻¹, Ψ y := by filter_upwards [eventually_gt_atTop 0] with x hx congr 1 simp only [hg, toSchwartz, ofReal_exp, ofReal_mul, ofReal_ofNat, toSchwartz_apply, ofReal_div, h] norm_cast ; field_simp; norm_cast rw [MeasureTheory.integral_Ici_eq_integral_Ioi] exact wiener_ikehara_smooth_aux hsmooth.continuous hsupp hplus x hx have l4 : Tendsto (fun x => (↑A * ∫ (y : ℝ) in Ioi x⁻¹, Ψ y) - ↑A * ∫ (y : ℝ) in Ioi 0, Ψ y) atTop (𝓝 0) := by exact wiener_ikehara_smooth_sub (hsmooth.continuous.integrable_of_hasCompactSupport hsupp) hplus simpa [tsum_div_const] using (key.congr' <| EventuallyEq.sub l2 l3) |>.add l4 /- Original line 5188: wiener_ikehara_smooth' -/ theorem wiener_ikehara_smooth' : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (hf : ∀ (σ' : ℝ), 1 < σ' → Summable (nterm f σ')) (hcheby : cheby f) (hG : ContinuousOn G {s | 1 ≤ s.re}) (hG' : Set.EqOn G (fun s ↦ LSeries f s - A / (s - 1)) {s | 1 < s.re}) (hsmooth : ContDiff ℝ ∞ Ψ) (hsupp : HasCompactSupport Ψ) (hplus : closure (Function.support Ψ) ⊆ Set.Ioi 0), Tendsto (fun x : ℝ ↦ (∑' n, f n * Ψ (n / x)) / x) atTop (nhds (A * ∫ y in Set.Ioi 0, Ψ y)) := by intro hf hcheby hG hG' hsmooth hsupp hplus letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact tendsto_sub_nhds_zero_iff.mp <| wiener_ikehara_smooth hf hcheby hG hG' hsmooth hsupp hplus /- Original line 5196: __anonymous_5196 -/ noncomputable abbrev realFunctionCoeWiener : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {E : Type*}, Coe (E → ℝ) (E → ℂ) := by intro E letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact ⟨fun f n => f n⟩ /- Original line 5198: set_integral_ofReal -/ theorem set_integral_ofReal : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} ∀ {f : ℝ → ℝ} {s : Set ℝ}, ∫ x in s, (f x : ℂ) = ∫ x in s, f x := by intro f s letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} exact integral_ofReal /- Original line 5202: wiener_ikehara_smooth_real -/ theorem wiener_ikehara_smooth_real : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} ∀ {f : ℕ → ℝ} {Ψ : ℝ → ℝ} (hf : ∀ (σ' : ℝ), 1 < σ' → Summable (nterm f σ')) (hcheby : cheby f) (hG : ContinuousOn G {s | 1 ≤ s.re}) (hG' : Set.EqOn G (fun s ↦ LSeries f s - A / (s - 1)) {s | 1 < s.re}) (hsmooth : ContDiff ℝ ∞ Ψ) (hsupp : HasCompactSupport Ψ) (hplus : closure (Function.support Ψ) ⊆ Set.Ioi 0), Tendsto (fun x : ℝ ↦ (∑' n, f n * Ψ (n / x)) / x) atTop (nhds (A * ∫ y in Set.Ioi 0, Ψ y)) := by intro f Ψ hf hcheby hG hG' hsmooth hsupp hplus letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} exact by let Ψ' := ofReal ∘ Ψ have l1 : ContDiff ℝ ∞ Ψ' := contDiff_ofReal.comp hsmooth have l2 : HasCompactSupport Ψ' := hsupp.comp_left rfl have l3 : closure (Function.support Ψ') ⊆ Ioi 0 := by rwa [Function.support_comp_eq] ; simp have key := (continuous_re.tendsto _).comp (@wiener_ikehara_smooth' A Ψ G f hf hcheby hG hG' l1 l2 l3) simp at key ; norm_cast at key /- Original line 5218: interval_approx_inf -/ theorem interval_approx_inf (ha : 0 < a) (hab : a < b) : ∀ᶠ ε in 𝓝[>] 0, ∃ ψ : ℝ → ℝ, ContDiff ℝ ∞ ψ ∧ HasCompactSupport ψ ∧ closure (Function.support ψ) ⊆ Set.Ioi 0 ∧ ψ ≤ indicator (Ico a b) 1 ∧ b - a - ε ≤ ∫ y in Ioi 0, ψ y := by have l1 : Iio ((b - a) / 3) ∈ 𝓝[>] 0 := nhdsWithin_le_nhds <| Iio_mem_nhds <| by rw [← sub_pos] at hab positivity filter_upwards [self_mem_nhdsWithin, l1] with ε (hε : 0 < ε) (hε' : ε < (b - a) / 3) have l2 : a < a + ε / 2 := by simp [hε] have l3 : b - ε / 2 < b := by simp [hε] obtain ⟨ψ, h1, h2, h3, h4, h5⟩ := smooth_urysohn_support_Ioo l2 l3 refine ⟨ψ, h1, h2, ?_, ?_, ?_⟩ · simp [h5, hab.ne, Icc_subset_Ioi_iff hab.le, ha] · exact h4.trans <| indicator_le_indicator_of_subset Ioo_subset_Ico_self (by simp) · have l4 : 0 ≤ b - a - ε := by linarith have l5 : Icc (a + ε / 2) (b - ε / 2) ⊆ Ioi 0 := by intro t ht simp only [mem_Icc, mem_Ioi] at ht ⊢ exact ha.trans <| l2.trans_le <| ht.1 have l6 : Icc (a + ε / 2) (b - ε / 2) ∩ Ioi 0 = Icc (a + ε / 2) (b - ε / 2) := inter_eq_left.mpr l5 have l7 : ∫ y in Ioi 0, indicator (Icc (a + ε / 2) (b - ε / 2)) 1 y = b - a - ε := by simp only [measurableSet_Icc, integral_indicator_one, measureReal_restrict_apply, l6, volume_real_Icc] convert max_eq_left l4 using 1 ; ring_nf have l8 : IntegrableOn ψ (Ioi 0) volume := (h1.continuous.integrable_of_hasCompactSupport h2).integrableOn rw [← l7] ; apply setIntegral_mono ?_ l8 h3 rw [IntegrableOn, integrable_indicator_iff measurableSet_Icc] apply IntegrableOn.mono ?_ subset_rfl Measure.restrict_le_self apply integrableOn_const <;> simp /- Original line 5252: interval_approx_sup -/ theorem interval_approx_sup : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} ∀ (ha : 0 < a) (hab : a < b), ∀ᶠ ε in 𝓝[>] 0, ∃ ψ : ℝ → ℝ, ContDiff ℝ ∞ ψ ∧ HasCompactSupport ψ ∧ closure (Function.support ψ) ⊆ Set.Ioi 0 ∧ indicator (Ico a b) 1 ≤ ψ ∧ ∫ y in Ioi 0, ψ y ≤ b - a + ε := by intro ha hab letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} exact by have l1 : Iio (a / 2) ∈ 𝓝[>] 0 := nhdsWithin_le_nhds <| Iio_mem_nhds (by linarith) filter_upwards [self_mem_nhdsWithin, l1] with ε (hε : 0 < ε) (hε' : ε < a / 2) have l2 : a - ε / 2 < a := by linarith have l3 : b < b + ε / 2 := by linarith obtain ⟨ψ, h1, h2, h3, h4, h5⟩ := smooth_urysohn_support_Ioo l2 l3 refine ⟨ψ, h1, h2, ?_, ?_, ?_⟩ · have l4 : a - ε / 2 < b + ε / 2 := by linarith have l5 : ε / 2 < a := by linarith simp [h5, l4.ne, Icc_subset_Ioi_iff l4.le, l5] · apply le_trans ?_ h3 apply indicator_le_indicator_of_subset Ico_subset_Icc_self (by simp) · have l4 : 0 ≤ b - a + ε := by linarith have l5 : Ioo (a - ε / 2) (b + ε / 2) ⊆ Ioi 0 := by intro t ht ; simp at ht ⊢ ; linarith have l6 : Ioo (a - ε / 2) (b + ε / 2) ∩ Ioi 0 = Ioo (a - ε / 2) (b + ε / 2) := inter_eq_left.mpr l5 have l7 : ∫ y in Ioi 0, indicator (Ioo (a - ε / 2) (b + ε / 2)) 1 y = b - a + ε := by simp only [measurableSet_Ioo, integral_indicator_one, measureReal_restrict_apply, l6, volume_real_Ioo] convert max_eq_left l4 using 1 ; ring_nf have l8 : IntegrableOn ψ (Ioi 0) volume := (h1.continuous.integrable_of_hasCompactSupport h2).integrableOn rw [← l7] refine setIntegral_mono l8 ?_ h4 rw [IntegrableOn, integrable_indicator_iff measurableSet_Ioo] apply IntegrableOn.mono ?_ subset_rfl Measure.restrict_le_self apply integrableOn_const <;> simp /- Original line 5283: WI_summable -/ theorem WI_summable : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} ∀ {f : ℕ → ℝ} {g : ℝ → ℝ} (hg : HasCompactSupport g) (hx : 0 < x), Summable (fun n => f n * g (n / x)) := by intro f g hg hx letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} exact by obtain ⟨M, hM⟩ := hg.bddAbove.mono subset_closure apply summable_of_hasFiniteSupport unfold Function.HasFiniteSupport simp only [Function.support_mul] ; apply Finite.inter_of_right ; rw [finite_iff_bddAbove] exact ⟨Nat.ceil (M * x), fun idx hi => by simpa using Nat.ceil_mono ((div_le_iff₀ hx).mp (hM hi))⟩ /- Original line 5291: WI_sum_le -/ theorem WI_sum_le : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} ∀ {f : ℕ → ℝ} {g₁ g₂ : ℝ → ℝ} (hf : 0 ≤ f) (hg : g₁ ≤ g₂) (hx : 0 < x) (hg₁ : HasCompactSupport g₁) (hg₂ : HasCompactSupport g₂), (∑' n, f n * g₁ (n / x)) / x ≤ (∑' n, f n * g₂ (n / x)) / x := by intro f g₁ g₂ hf hg hx hg₁ hg₂ letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} exact by apply div_le_div_of_nonneg_right ?_ hx.le exact Summable.tsum_le_tsum (fun n => mul_le_mul_of_nonneg_left (hg _) (hf _)) (WI_summable hg₁ hx) (WI_summable hg₂ hx) /- Original line 5298: WI_sum_Iab_le -/ theorem WI_sum_Iab_le : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} ∀ {f : ℕ → ℝ} (hpos : 0 ≤ f) {C : ℝ} (hcheby : chebyWith C f) (hb : 0 < b) (hxb : 2 / b < x), (∑' n, f n * indicator (Ico a b) 1 (n / x)) / x ≤ C * 2 * b := by intro f hpos C hcheby hb hxb letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} exact by have hb' : 0 < 2 / b := by positivity have hx : 0 < x := by linarith have hxb' : 2 < x * b := (div_lt_iff₀ hb).mp hxb have l1 (idx : ℕ) (hi : idx ∉ Finset.range ⌈b * x⌉₊) : f idx * indicator (Ico a b) 1 (idx / x) = 0 := by simp_all [cumsum_zero, nabla_cumsum, le_div_iff₀ hx] have l2 (idx : ℕ) (_ : idx ∈ Finset.range ⌈b * x⌉₊) : f idx * indicator (Ico a b) 1 (idx / x) ≤ |f idx| := by rw [abs_eq_self.mpr (hpos _)] convert_to _ ≤ f idx * 1 · ring apply mul_le_mul_of_nonneg_left ?_ (hpos _) by_cases hi : (idx / x) ∈ (Ico a b) <;> simp [cumsum_zero, nabla_cumsum, hi] rw [tsum_eq_sum l1, div_le_iff₀ hx, mul_assoc, mul_assoc] apply Finset.sum_le_sum l2 |>.trans have := hcheby ⌈b * x⌉₊ ; simp only [norm_real, norm_eq_abs] at this ; apply this.trans have : 0 ≤ C := by have := hcheby 1 ; simp only [cumsum, Finset.range_one, norm_real, Finset.sum_singleton, Nat.cast_one, mul_one] at this ; exact (abs_nonneg _).trans this refine mul_le_mul_of_nonneg_left ?_ this apply (Nat.ceil_lt_add_one (by positivity)).le.trans linarith /- Original line 5320: WI_sum_Iab_le' -/ theorem WI_sum_Iab_le' : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} ∀ {f : ℕ → ℝ} (hpos : 0 ≤ f) {C : ℝ} (hcheby : chebyWith C f) (hb : 0 < b), ∀ᶠ x : ℝ in atTop, (∑' n, f n * indicator (Ico a b) 1 (n / x)) / x ≤ C * 2 * b := by intro f hpos C hcheby hb letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} exact by filter_upwards [eventually_gt_atTop (2 / b)] with x hx using WI_sum_Iab_le hpos hcheby hb hx /- Original line 5324: le_of_eventually_nhdsWithin -/ theorem le_of_eventually_nhdsWithin : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} ∀ {a b : ℝ} (h : ∀ᶠ c in 𝓝[>] b, a ≤ c), a ≤ b := by intro a b h letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} exact by apply le_of_forall_gt ; intro d hd have key : ∀ᶠ c in 𝓝[>] b, c < d := by apply eventually_of_mem (U := Iio d) ?_ (fun x hx => hx) rw [mem_nhdsWithin] refine ⟨Iio d, isOpen_Iio, hd, inter_subset_left⟩ obtain ⟨x, h1, h2⟩ := (h.and key).exists linarith /- Original line 5333: ge_of_eventually_nhdsWithin -/ theorem ge_of_eventually_nhdsWithin : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} ∀ {a b : ℝ} (h : ∀ᶠ c in 𝓝[<] b, c ≤ a), b ≤ a := by intro a b h letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} exact by apply le_of_forall_lt ; intro d hd have key : ∀ᶠ c in 𝓝[<] b, c > d := by apply eventually_of_mem (U := Ioi d) ?_ (fun x hx => hx) rw [mem_nhdsWithin] refine ⟨Ioi d, isOpen_Ioi, hd, inter_subset_left⟩ obtain ⟨x, h1, h2⟩ := (h.and key).exists linarith /- Original line 5342: WI_tendsto_aux -/ theorem WI_tendsto_aux : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} ∀ (a b : ℝ) {A : ℝ} (hA : 0 < A), Tendsto (fun c => c / A - (b - a)) (𝓝[>] (A * (b - a))) (𝓝[>] 0) := by intro a b A hA letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} exact by rw [Metric.tendsto_nhdsWithin_nhdsWithin] intro ε hε refine ⟨A * ε, by positivity, ?_⟩ intro x hx1 hx2 constructor · simpa [lt_div_iff₀' hA] · simp only [Real.dist_eq, dist_zero_right, Real.norm_eq_abs] at hx2 ⊢ have : |x / A - (b - a)| = |x - A * (b - a)| / A := by rw [← abs_eq_self.mpr hA.le, ← abs_div, abs_eq_self.mpr hA.le] ; congr ; field_simp rwa [this, div_lt_iff₀' hA] /- Original line 5355: WI_tendsto_aux' -/ theorem WI_tendsto_aux' : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} ∀ (a b : ℝ) {A : ℝ} (hA : 0 < A), Tendsto (fun c => (b - a) - c / A) (𝓝[<] (A * (b - a))) (𝓝[>] 0) := by intro a b A hA letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} exact by rw [Metric.tendsto_nhdsWithin_nhdsWithin] intro ε hε refine ⟨A * ε, by positivity, ?_⟩ intro x hx1 hx2 constructor · simpa [div_lt_iff₀' hA] · simp only [Real.dist_eq, dist_zero_right, norm_eq_abs] at hx2 ⊢ have : |(b - a) - x / A| = |A * (b - a) - x| / A := by rw [← abs_eq_self.mpr hA.le, ← abs_div, abs_eq_self.mpr hA.le] ; congr ; field_simp rwa [this, div_lt_iff₀' hA, ← neg_sub, abs_neg] /- Original line 5368: residue_nonneg -/ theorem residue_nonneg : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} ∀ {f : ℕ → ℝ} (hpos : 0 ≤ f) (hf : ∀ (σ' : ℝ), 1 < σ' → Summable (nterm (fun n ↦ ↑(f n)) σ')) (hcheby : cheby fun n ↦ ↑(f n)) (hG : ContinuousOn G {s | 1 ≤ s.re}) (hG' : EqOn G (fun s ↦ LSeries (fun n ↦ ↑(f n)) s - ↑A / (s - 1)) {s | 1 < s.re}), 0 ≤ A := by intro f hpos hf hcheby hG hG' letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} exact by let S (g : ℝ → ℝ) (x : ℝ) := (∑' n, f n * g (n / x)) / x have hSnonneg {g : ℝ → ℝ} (hg : 0 ≤ g) : ∀ᶠ x : ℝ in atTop, 0 ≤ S g x := by filter_upwards [eventually_ge_atTop 0] with x hx exact div_nonneg (tsum_nonneg (fun idx => mul_nonneg (hpos _) (hg _))) hx obtain ⟨ε, ψ, h1, h2, h3, h4, -⟩ := (interval_approx_sup zero_lt_one one_lt_two).exists have key := @wiener_ikehara_smooth_real A G f ψ hf hcheby hG hG' h1 h2 h3 have l2 : 0 ≤ ψ := by apply le_trans _ h4 ; apply indicator_nonneg ; simp have l1 : ∀ᶠ x in atTop, 0 ≤ S ψ x := hSnonneg l2 have l3 : 0 ≤ A * ∫ (y : ℝ) in Ioi 0, ψ y := ge_of_tendsto key l1 have l4 : 0 < ∫ (y : ℝ) in Ioi 0, ψ y := by have r1 : 0 ≤ᵐ[Measure.restrict volume (Ioi 0)] ψ := Eventually.of_forall l2 have r2 : IntegrableOn (fun y ↦ ψ y) (Ioi 0) volume := (h1.continuous.integrable_of_hasCompactSupport h2).integrableOn have r3 : Ico 1 2 ⊆ Function.support ψ := by intro x hx ; have := h4 x ; simp [hx] at this ⊢ ; linarith have r4 : Ico 1 2 ⊆ Function.support ψ ∩ Ioi 0 := by simp only [subset_inter_iff, r3, true_and] ; apply Ico_subset_Icc_self.trans ; rw [Icc_subset_Ioi_iff] <;> linarith have r5 : 1 ≤ volume ((Function.support fun y ↦ ψ y) ∩ Ioi 0) := by convert! volume.mono r4 ; norm_num simpa [setIntegral_pos_iff_support_of_nonneg_ae r1 r2] using! zero_lt_one.trans_le r5 have := div_nonneg l3 l4.le ; field_simp at this ; exact this /- Original line 5394: WienerIkeharaInterval -/ theorem WienerIkeharaInterval : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} ∀ {f : ℕ → ℝ} (hpos : 0 ≤ f) (hf : ∀ (σ' : ℝ), 1 < σ' → Summable (nterm f σ')) (hcheby : cheby f) (hG : ContinuousOn G {s | 1 ≤ s.re}) (hG' : Set.EqOn G (fun s ↦ LSeries f s - A / (s - 1)) {s | 1 < s.re}) (ha : 0 < a) (hb : a ≤ b), Tendsto (fun x : ℝ ↦ (∑' n, f n * (indicator (Ico a b) 1 (n / x))) / x) atTop (nhds (A * (b - a))) := by intro f hpos hf hcheby hG hG' ha hb letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} exact by -- Take care of the trivial case `a = b` by_cases hab : a = b · simp [hab] replace hb : a < b := lt_of_le_of_ne hb hab ; clear hab -- Notation to make the proof more readable let S (g : ℝ → ℝ) (x : ℝ) := (∑' n, f n * g (n / x)) / x have hSnonneg {g : ℝ → ℝ} (hg : 0 ≤ g) : ∀ᶠ x : ℝ in atTop, 0 ≤ S g x := by filter_upwards [eventually_ge_atTop 0] with x hx refine div_nonneg ?_ hx refine tsum_nonneg (fun idx => mul_nonneg (hpos _) (hg _)) have hA : 0 ≤ A := residue_nonneg hpos hf hcheby hG hG' -- A few facts about the indicator function of `Icc a b` let Iab : ℝ → ℝ := indicator (Ico a b) 1 change Tendsto (S Iab) atTop (𝓝 (A * (b - a))) have hIab : HasCompactSupport Iab := by simpa [Iab, HasCompactSupport, tsupport, hb.ne] using isCompact_Icc have Iab_nonneg : ∀ᶠ x : ℝ in atTop, 0 ≤ S Iab x := hSnonneg (indicator_nonneg (by simp)) have Iab2 : IsBoundedUnder (· ≤ ·) atTop (S Iab) := by obtain ⟨C, hC⟩ := hcheby ; exact ⟨C * 2 * b, WI_sum_Iab_le' hpos hC (by linarith)⟩ have Iab3 : IsBoundedUnder (· ≥ ·) atTop (S Iab) := ⟨0, Iab_nonneg⟩ have Iab0 : IsCoboundedUnder (· ≥ ·) atTop (S Iab) := Iab2.isCoboundedUnder_ge have Iab1 : IsCoboundedUnder (· ≤ ·) atTop (S Iab) := Iab3.isCoboundedUnder_le -- Bound from above by a smooth function have sup_le : limsup (S Iab) atTop ≤ A * (b - a) := by have l_sup : ∀ᶠ ε in 𝓝[>] 0, limsup (S Iab) atTop ≤ A * (b - a + ε) := by filter_upwards [interval_approx_sup ha hb] with ε ⟨ψ, h1, h2, h3, h4, h6⟩ have l1 : Tendsto (S ψ) atTop _ := wiener_ikehara_smooth_real hf hcheby hG hG' h1 h2 h3 have l6 : S Iab ≤ᶠ[atTop] S ψ := by filter_upwards [eventually_gt_atTop 0] with x hx using WI_sum_le hpos h4 hx hIab h2 have l5 : IsBoundedUnder (· ≤ ·) atTop (S ψ) := l1.isBoundedUnder_le have l3 : limsup (S Iab) atTop ≤ limsup (S ψ) atTop := limsup_le_limsup l6 Iab1 l5 apply l3.trans ; rw [l1.limsup_eq] ; gcongr obtain rfl | h := eq_or_ne A 0 · simpa using l_sup apply le_of_eventually_nhdsWithin have key : 0 < A := lt_of_le_of_ne hA h.symm filter_upwards [WI_tendsto_aux a b key l_sup] with x hx simpa [mul_div_cancel₀ _ h] using hx -- Bound from below by a smooth function have le_inf : A * (b - a) ≤ liminf (S Iab) atTop := by have l_inf : ∀ᶠ ε in 𝓝[>] 0, A * (b - a - ε) ≤ liminf (S Iab) atTop := by filter_upwards [interval_approx_inf ha hb] with ε ⟨ψ, h1, h2, h3, h5, h6⟩ have l1 : Tendsto (S ψ) atTop _ := wiener_ikehara_smooth_real hf hcheby hG hG' h1 h2 h3 have l2 : S ψ ≤ᶠ[atTop] S Iab := by filter_upwards [eventually_gt_atTop 0] with x hx using WI_sum_le hpos h5 hx h2 hIab have l4 : IsBoundedUnder (· ≥ ·) atTop (S ψ) := l1.isBoundedUnder_ge have l3 : liminf (S ψ) atTop ≤ liminf (S Iab) atTop := liminf_le_liminf l2 l4 Iab0 apply le_trans ?_ l3 ; rw [l1.liminf_eq] ; gcongr obtain rfl | h := eq_or_ne A 0 · simpa using l_inf apply ge_of_eventually_nhdsWithin have key : 0 < A := lt_of_le_of_ne hA h.symm filter_upwards [WI_tendsto_aux' a b key l_inf] with x hx simpa [mul_div_cancel₀ _ h] using hx -- Combine the two bounds have : liminf (S Iab) atTop ≤ limsup (S Iab) atTop := liminf_le_limsup Iab2 Iab3 refine tendsto_of_liminf_eq_limsup ?_ ?_ Iab2 Iab3 <;> linarith /- Original line 5463: le_floor_mul_iff -/ theorem le_floor_mul_iff : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} ∀ (hb : 0 ≤ b) (hx : 0 < x), n ≤ ⌊b * x⌋₊ ↔ n / x ≤ b := by intro hb hx letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} exact by rw [div_le_iff₀ hx, Nat.le_floor_iff] ; positivity /- Original line 5466: lt_ceil_mul_iff -/ theorem lt_ceil_mul_iff : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} ∀ (hx : 0 < x), n < ⌈b * x⌉₊ ↔ n / x < b := by intro hx letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} exact by rw [div_lt_iff₀ hx, Nat.lt_ceil] /- Original line 5469: ceil_mul_le_iff -/ theorem ceil_mul_le_iff : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} ∀ (hx : 0 < x), ⌈a * x⌉₊ ≤ n ↔ a ≤ n / x := by intro hx letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} exact by rw [le_div_iff₀ hx, Nat.ceil_le] /- Original line 5472: mem_Icc_iff_div -/ theorem mem_Icc_iff_div : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} ∀ (hb : 0 ≤ b) (hx : 0 < x), n ∈ Finset.Icc ⌈a * x⌉₊ ⌊b * x⌋₊ ↔ n / x ∈ Icc a b := by intro hb hx letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} exact by rw [Finset.mem_Icc, mem_Icc, ceil_mul_le_iff hx, le_floor_mul_iff hb hx] /- Original line 5475: mem_Ico_iff_div -/ theorem mem_Ico_iff_div : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} ∀ (hx : 0 < x), n ∈ Finset.Ico ⌈a * x⌉₊ ⌈b * x⌉₊ ↔ n / x ∈ Ico a b := by intro hx letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} exact by rw [Finset.mem_Ico, mem_Ico, ceil_mul_le_iff hx, lt_ceil_mul_iff hx] /- Original line 5478: tsum_indicator -/ theorem tsum_indicator : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} ∀ {f : ℕ → ℝ} (hx : 0 < x), ∑' n, f n * (indicator (Ico a b) 1 (n / x)) = ∑ n ∈ Finset.Ico ⌈a * x⌉₊ ⌈b * x⌉₊, f n := by intro f hx letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} exact by have l1 : ∀ n ∉ Finset.Ico ⌈a * x⌉₊ ⌈b * x⌉₊, f n * indicator (Ico a b) 1 (↑n / x) = 0 := by simp [mem_Ico_iff_div hx] ; tauto rw [tsum_eq_sum l1] ; apply Finset.sum_congr rfl ; simp only [mem_Ico_iff_div hx] ; intro n hn ; simp [hn] /- Original line 5484: WienerIkeharaInterval_discrete -/ theorem WienerIkeharaInterval_discrete : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} ∀ {f : ℕ → ℝ} (hpos : 0 ≤ f) (hf : ∀ (σ' : ℝ), 1 < σ' → Summable (nterm f σ')) (hcheby : cheby f) (hG : ContinuousOn G {s | 1 ≤ s.re}) (hG' : Set.EqOn G (fun s ↦ LSeries f s - A / (s - 1)) {s | 1 < s.re}) (ha : 0 < a) (hb : a ≤ b), Tendsto (fun x : ℝ ↦ (∑ n ∈ Finset.Ico ⌈a * x⌉₊ ⌈b * x⌉₊, f n) / x) atTop (nhds (A * (b - a))) := by intro f hpos hf hcheby hG hG' ha hb letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} exact by apply (WienerIkeharaInterval hpos hf hcheby hG hG' ha hb).congr' filter_upwards [eventually_gt_atTop 0] with x hx rw [tsum_indicator hx] /- Original line 5492: WienerIkeharaInterval_discrete' -/ theorem WienerIkeharaInterval_discrete' : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} ∀ {f : ℕ → ℝ} (hpos : 0 ≤ f) (hf : ∀ (σ' : ℝ), 1 < σ' → Summable (nterm f σ')) (hcheby : cheby f) (hG : ContinuousOn G {s | 1 ≤ s.re}) (hG' : Set.EqOn G (fun s ↦ LSeries f s - A / (s - 1)) {s | 1 < s.re}) (ha : 0 < a) (hb : a ≤ b), Tendsto (fun N : ℕ ↦ (∑ n ∈ Finset.Ico ⌈a * N⌉₊ ⌈b * N⌉₊, f n) / N) atTop (nhds (A * (b - a))) := by intro f hpos hf hcheby hG hG' ha hb letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} exact WienerIkeharaInterval_discrete hpos hf hcheby hG hG' ha hb |>.comp tendsto_natCast_atTop_atTop -- TODO with `Ico` /-- A version of the *Wiener-Ikehara Tauberian Theorem*: If `f` is a nonnegative arithmetic function whose L-series has a simple pole at `s = 1` with residue `A` and otherwise extends continuously to the closed half-plane `re s ≥ 1`, then `∑ n < N, f n` is asymptotic to `A*N`. -/ /- Original line 5506: tendsto_mul_ceil_div -/ theorem tendsto_mul_ceil_div : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} Tendsto (fun (p : ℝ × ℕ) => ⌈p.1 * p.2⌉₊ / (p.2 : ℝ)) (𝓝[>] 0 ×ˢ atTop) (𝓝 0) := by letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} exact by rw [Metric.tendsto_nhds] ; intro δ hδ have l1 : ∀ᶠ ε : ℝ in 𝓝[>] 0, ε ∈ Ioo 0 (δ / 2) := inter_mem_nhdsWithin _ (Iio_mem_nhds (by positivity)) have l2 : ∀ᶠ N : ℕ in atTop, 1 ≤ δ / 2 * N := by apply Tendsto.eventually_ge_atTop exact tendsto_natCast_atTop_atTop.const_mul_atTop (by positivity) filter_upwards [l1.prod_mk l2] with (ε, N) ⟨⟨hε, h1⟩, h2⟩ ; dsimp only at * have l3 : 0 < (N : ℝ) := by simp only [Nat.cast_pos, Nat.pos_iff_ne_zero] ; rintro rfl ; simp [zero_lt_one.not_ge] at h2 have l5 : 0 ≤ ε * ↑N := by positivity have l6 : ε * N ≤ δ / 2 * N := mul_le_mul h1.le le_rfl (by positivity) (by positivity) simp only [dist_zero_right, norm_div, RCLike.norm_natCast, div_lt_iff₀ l3, gt_iff_lt] convert (Nat.ceil_lt_add_one l5).trans_le (add_le_add l6 h2) using 1 ; ring /- Original line 5521: S -/ noncomputable def S : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} ∀ (f : ℕ → 𝕜) (ε : ℝ) (N : ℕ), 𝕜 := by intro f ε N letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} exact (∑ n ∈ Finset.Ico ⌈ε * N⌉₊ N, f n) / N /- Original line 5523: S_sub_S -/ theorem S_sub_S : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} ∀ {f : ℕ → 𝕜} {ε : ℝ} {N : ℕ} (hε : ε ≤ 1), S f 0 N - S f ε N = cumsum f ⌈ε * N⌉₊ / N := by intro f ε N hε letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} exact by have hceilN : ⌈ε * N⌉₊ ≤ N := by simp only [Nat.ceil_le] exact mul_le_of_le_one_left N.cast_nonneg hε have r1 : Finset.range N = Finset.range ⌈ε * N⌉₊ ∪ Finset.Ico ⌈ε * N⌉₊ N := by ext n simp only [Finset.mem_range, Finset.mem_union, Finset.mem_Ico] omega have r2 : Disjoint (Finset.range ⌈ε * N⌉₊) (Finset.Ico ⌈ε * N⌉₊ N) := by rw [Finset.range_eq_Ico] ; apply Finset.Ico_disjoint_Ico_consecutive simp [cumsum_zero, nabla_cumsum, S, r1, Finset.sum_union r2, cumsum, add_div] /- Original line 5535: tendsto_S_S_zero -/ theorem tendsto_S_S_zero : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} ∀ {f : ℕ → ℝ} (hpos : 0 ≤ f) (hcheby : cheby f), TendstoUniformlyOnFilter (S f) (S f 0) (𝓝[>] 0) atTop := by intro f hpos hcheby letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} exact by rw [Metric.tendstoUniformlyOnFilter_iff] ; intro δ hδ obtain ⟨C, hC⟩ := hcheby have l1 : ∀ᶠ (p : ℝ × ℕ) in 𝓝[>] 0 ×ˢ atTop, C * ⌈p.1 * p.2⌉₊ / p.2 < δ := by have r1 := tendsto_mul_ceil_div.const_mul C simp only [mul_div_assoc', mul_zero] at r1 ; exact r1 (Iio_mem_nhds hδ) have : Ioc 0 1 ∈ 𝓝[>] (0 : ℝ) := inter_mem_nhdsWithin _ (Iic_mem_nhds zero_lt_one) filter_upwards [l1, Eventually.prod_inl this _] with (ε, N) h1 h2 have l2 : ‖cumsum f ⌈ε * ↑N⌉₊ / ↑N‖ ≤ C * ⌈ε * N⌉₊ / N := by have r1 := hC ⌈ε * N⌉₊ have r2 : 0 ≤ cumsum f ⌈ε * N⌉₊ := by apply cumsum_nonneg hpos simp only [norm_real, norm_of_nonneg (hpos _), norm_div, norm_of_nonneg r2, Real.norm_natCast] at r1 ⊢ apply div_le_div_of_nonneg_right r1 (by positivity) simpa [cumsum_zero, nabla_cumsum, ← S_sub_S h2.2] using! l2.trans_lt h1 /- Original line 5553: WienerIkeharaTheorem' -/ theorem WienerIkeharaTheorem' : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} ∀ {f : ℕ → ℝ} (hpos : 0 ≤ f) (hf : ∀ (σ' : ℝ), 1 < σ' → Summable (nterm f σ')) (hcheby : cheby f) (hG : ContinuousOn G {s | 1 ≤ s.re}) (hG' : Set.EqOn G (fun s ↦ LSeries f s - A / (s - 1)) {s | 1 < s.re}), Tendsto (fun N => cumsum f N / N) atTop (𝓝 A) := by intro f hpos hf hcheby hG hG' letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} exact by convert_to Tendsto (S f 0) atTop (𝓝 A) ; · ext N ; simp [cumsum_zero, nabla_cumsum, S, cumsum] apply (tendsto_S_S_zero hpos hcheby).tendsto_of_eventually_tendsto · have L0 : Ioc 0 1 ∈ 𝓝[>] (0 : ℝ) := inter_mem_nhdsWithin _ (Iic_mem_nhds zero_lt_one) apply eventually_of_mem L0 · intro ε hε simpa [cumsum_zero, nabla_cumsum] using! WienerIkeharaInterval_discrete' hpos hf hcheby hG hG' hε.1 hε.2 · have : Tendsto (fun ε : ℝ => ε) (𝓝[>] 0) (𝓝 0) := nhdsWithin_le_nhds simpa [cumsum_zero, nabla_cumsum] using (this.const_sub 1).const_mul A /- Original line 5568: vonMangoldt_cheby -/ theorem vonMangoldt_cheby : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} cheby Λ := by letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} exact by use Real.log 4 + 4 intro N by_cases! h : N = 0 · simp [cumsum_zero, nabla_cumsum, h, cumsum] simp only [cumsum, norm_real, norm_eq_abs] rw [Nat.range_eq_Icc_zero_sub_one _ h, (by simp [cumsum_zero, nabla_cumsum] : N - 1 = ⌊(N : ℝ) - 1⌋₊)] simp_rw [abs_of_nonneg vonMangoldt_nonneg] rw [← Chebyshev.psi_eq_sum_Icc] grw [Chebyshev.psi_le_const_mul_self <| sub_nonneg_of_le <| Nat.one_le_cast_iff_ne_zero.mpr h] gcongr linarith -- Proof extracted from the `EulerProducts` project so we can adapt it to the -- version of the Wiener-Ikehara theorem proved above (with the `cheby` -- hypothesis) /- Original line 5588: WeakPNT -/ theorem WeakPNT : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} Tendsto (fun N ↦ cumsum Λ N / N) atTop (𝓝 1) := by letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace letI := @_root_.realFunctionCoeWiener.{0} exact by let F := vonMangoldt.LFunctionResidueClassAux (q := 1) 1 have hnv := riemannZeta_ne_zero_of_one_le_re have l1 (n : ℕ) : 0 ≤ Λ n := vonMangoldt_nonneg have l2 s (hs : 1 < s.re) : F s = LSeries Λ s - 1 / (s - 1) := by have := vonMangoldt.eqOn_LFunctionResidueClassAux (q := 1) isUnit_one hs simp only [F, this, vonMangoldt.residueClass, Nat.totient_one, Nat.cast_one, inv_one, one_div, sub_left_inj] apply LSeries_congr intro n _ simp only [ofReal_inj, indicator_apply_eq_self, mem_ofPred_eq] exact fun hn ↦ absurd (Subsingleton.eq_one _) hn have l3 : ContinuousOn F {s | 1 ≤ s.re} := vonMangoldt.continuousOn_LFunctionResidueClassAux 1 have l4 : cheby Λ := vonMangoldt_cheby have l5 (σ' : ℝ) (hσ' : 1 < σ') : Summable (nterm Λ σ') := by simpa only [← nterm_eq_norm_term] using (@ArithmeticFunction.LSeriesSummable_vonMangoldt σ' hσ').norm apply WienerIkeharaTheorem' l1 l5 l4 l3 l2 -- #print axioms WeakPNT end PNTSource_6 /- Source module: Consequences -/ section PNTSource_7 open ArithmeticFunction hiding log open _root_.Nat hiding log open Finset open BigOperators Filter Real Classical Asymptotics MeasureTheory intervalIntegral open scoped ArithmeticFunction.Moebius ArithmeticFunction.Omega Chebyshev /- Original line 5621: Set.Ico_subset_Ico_of_Icc_subset_Icc -/ theorem Set.Ico_subset_Ico_of_Icc_subset_Icc : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {a b c d : ℝ} (h : Set.Icc a b ⊆ Set.Icc c d), Set.Ico a b ⊆ Set.Ico c d := by intro a b c d h letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by intro z hz have hz' := Set.Ico_subset_Icc_self.trans h hz have hcd : c ≤ d := by contrapose! hz' rw [Icc_eq_empty_of_lt hz'] exact notMem_empty _ simp only [mem_Ico, mem_Icc] at * refine ⟨hz'.1, hz'.2.eq_or_lt.resolve_left ?_⟩ rintro rfl apply hz.2.not_ge have := h <| right_mem_Icc.mpr (hz.1.trans hz.2.le) simp only [mem_Icc] at this exact this.2 /- Original line 5637: th43_b -/ theorem th43_b : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (x : ℝ) (hx : 2 ≤ x), Nat.primeCounting ⌊x⌋₊ = θ x / log x + ∫ t in Set.Icc 2 x, θ t / (t * (Real.log t) ^ 2) := by intro x hx letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by rw [integral_Icc_eq_integral_Ioc, ← intervalIntegral.integral_of_le hx] exact Chebyshev.primeCounting_eq_theta_div_log_add_integral hx /- Original line 5644: finsum_range_eq_sum_range -/ theorem finsum_range_eq_sum_range : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {R : Type*} [AddCommMonoid R] {f : ArithmeticFunction R} (x : ℝ), ∑ᶠ (n : ℕ) (_: n < x), f n = ∑ n ∈ range ⌈x⌉₊, f n := by intro R _localClass1 f x letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by apply finsum_cond_eq_sum_of_cond_iff f intros simp only [mem_range] exact Iff.symm Nat.lt_ceil /- Original line 5651: finsum_range_eq_sum_range' -/ theorem finsum_range_eq_sum_range' : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {R : Type*} [AddCommMonoid R] {f : ArithmeticFunction R} (x : ℝ), ∑ᶠ (n : ℕ) (_ : n ≤ x), f n = ∑ n ∈ Iic ⌊x⌋₊, f n := by intro R _localClass1 f x letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by apply finsum_cond_eq_sum_of_cond_iff f intro n h simp only [mem_Iic] exact Iff.symm <| Nat.le_floor_iff' fun (hc : n = 0) ↦ (h : f n ≠ 0) <| (congrArg f hc).trans ArithmeticFunction.map_zero /- Original line 5660: log2_pos -/ theorem log2_pos : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace 0 < log 2 := by letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by rw [Real.log_pos_iff zero_le_two] exact one_lt_two /-- If u ~ v and w-u = o(v) then w ~ v. -/ /- Original line 5666: Asymptotics.IsEquivalent.add_isLittleO' -/ theorem Asymptotics.IsEquivalent.add_isLittleO' : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {α : Type*} {β : Type*} [NormedAddCommGroup β] {u : α → β} {v : α → β} {w : α → β} {l : Filter α} (huv : Asymptotics.IsEquivalent l u v) (hwu : (w - u) =o[l] v), Asymptotics.IsEquivalent l w v := by intro α β _localClass2 u v w l huv hwu letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by rw [← add_sub_cancel u w] exact add_isLittleO huv hwu /-- If u ~ v and u-w = o(v) then w ~ v. -/ /- Original line 5674: Asymptotics.IsEquivalent.add_isLittleO'' -/ theorem Asymptotics.IsEquivalent.add_isLittleO'' : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {α : Type*} {β : Type*} [NormedAddCommGroup β] {u : α → β} {v : α → β} {w : α → β} {l : Filter α} (huv : Asymptotics.IsEquivalent l u v) (hwu : (u - w) =o[l] v), Asymptotics.IsEquivalent l w v := by intro α β _localClass2 u v w l huv hwu letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by rw [← sub_sub_self u w] exact sub_isLittleO huv hwu /- Original line 5681: WeakPNT' -/ theorem WeakPNT' : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace Tendsto (fun N ↦ (∑ n ∈ Iic N, Λ n) / N) atTop (nhds 1) := by letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by have : (fun N ↦ (∑ n ∈ Iic N, Λ n) / N) = (fun N ↦ (∑ n ∈ range N, Λ n)/N + Λ N / N) := by ext N have : N ∈ Iic N := mem_Iic.mpr (le_refl _) rw [← Finset.sum_erase_add _ _ this, ← Nat.Iio_eq_range, Iic_erase] exact add_div _ _ _ rw [this, ← add_zero 1] apply Tendsto.add WeakPNT convert squeeze_zero (f := fun N ↦ Λ N / N) (g := fun N ↦ log N / N) (t₀ := atTop) ?_ ?_ ?_ · intro N exact div_nonneg vonMangoldt_nonneg (cast_nonneg N) · intro N exact div_le_div_of_nonneg_right vonMangoldt_le_log (cast_nonneg N) have := Real.tendsto_pow_log_div_pow_atTop 1 1 Real.zero_lt_one simp only [rpow_one] at this exact Tendsto.comp this tendsto_natCast_atTop_atTop /-- An alternate form of the Weak PNT. -/ /- Original line 5701: WeakPNT'' -/ theorem WeakPNT'' : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ψ ~[atTop] (fun x ↦ x) := by letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by rw [(by rfl : ψ = (fun x ↦ ψ x))] simp_rw [Chebyshev.psi_eq_sum_Icc] apply IsEquivalent.trans (v := fun x ↦ (⌊x⌋₊:ℝ)) · rw [isEquivalent_iff_tendsto_one] · convert! Tendsto.comp WeakPNT' tendsto_nat_floor_atTop infer_instance rw [eventually_iff] simp only [ne_eq, cast_eq_zero, floor_eq_zero, not_lt, mem_atTop_sets, Set.mem_ofPred_eq] use 1 simp only [imp_self, implies_true] apply IsLittleO.isEquivalent rw [← isLittleO_neg_left] apply IsLittleO.of_bound intro ε hε simp only [Pi.sub_apply, neg_sub, norm_eq_abs, eventually_atTop] use ε⁻¹ intro b hb have hb' : 0 ≤ b := le_of_lt (lt_of_lt_of_le (inv_pos_of_pos hε) hb) rw [abs_of_nonneg, abs_of_nonneg hb'] · apply LE.le.trans _ ((inv_le_iff_one_le_mul₀' hε).mp hb) linarith [Nat.lt_floor_add_one b] rw [sub_nonneg] exact floor_le hb' /-- `√x · log x = o(x)` as `x → ∞`. -/ /- Original line 5728: isLittleO_sqrt_mul_log -/ theorem isLittleO_sqrt_mul_log : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace (fun x : ℝ ↦ x.sqrt * x.log) =o[atTop] _root_.id := by letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by have : (fun x : ℝ ↦ x.sqrt * x.log) =o[atTop] fun x ↦ x := by refine (isLittleO_mul_iff_isLittleO_div ?_).mpr ?_ · filter_upwards [eventually_gt_atTop 0] with x hx; exact (sqrt_ne_zero hx.le).mpr hx.ne' · convert! isLittleO_log_rpow_atTop (by norm_num : (0 : ℝ) < 1 / 2) using 2 with x rw [div_sqrt, sqrt_eq_rpow] exact this /-- `(⌊x⌋₊ + 1) / x → 1` as `x → ∞`. -/ /- Original line 5737: tendsto_floor_add_one_div_self -/ theorem tendsto_floor_add_one_div_self : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace Tendsto (fun x : ℝ ↦ (⌊x⌋₊ + 1 : ℝ) / x) atTop (nhds 1) := by letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by have h := Asymptotics.isEquivalent_nat_floor (R := ℝ) have h' : IsEquivalent atTop (fun x : ℝ ↦ (⌊x⌋₊ : ℝ) + 1) _root_.id := h.add_isLittleO (isLittleO_const_id_atTop 1) rwa [isEquivalent_iff_tendsto_one (by filter_upwards [eventually_gt_atTop 0] with x hx a; simp only [_root_.id] at a; linarith)] at h' /-- `x =Θ x / c` for nonzero constant `c`. -/ /- Original line 5745: isTheta_self_div_const -/ theorem isTheta_self_div_const : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ {c : ℝ} (hc : c ≠ 0), (fun x : ℝ ↦ x) =Θ[atTop] fun x ↦ x / c := by intro c hc letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by have : (fun x : ℝ ↦ x / c) = fun x ↦ c⁻¹ * x := by ext x; ring exact this ▸ (isTheta_const_mul_left (inv_ne_zero hc)).mpr (isTheta_refl ..) |>.symm /-- Filtered sum over `Iic n` equals filtered sum over `Icc 1 n` for primes. -/ /- Original line 5750: filter_prime_Iic_eq_Icc -/ theorem filter_prime_Iic_eq_Icc : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (n : ℕ), filter Prime (Iic n) = filter Prime (Icc 1 n) := by intro n letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by ext p; simp only [mem_filter, mem_Iic, mem_Icc, and_congr_left_iff] exact fun hp ↦ ⟨fun h ↦ ⟨hp.one_lt.le, h⟩, fun ⟨_, h⟩ ↦ h⟩ /-- `Icc 0 n = insert 0 (Icc 1 n)` -/ /- Original line 5755: Icc_zero_eq_insert -/ theorem Icc_zero_eq_insert : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (n : ℕ), Icc 0 n = insert 0 (Icc 1 n) := by intro n letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by ext m; simp [mem_Icc]; omega /- Original line 5759: chebyshev_asymptotic -/ theorem chebyshev_asymptotic : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace θ ~[atTop] id := by letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by refine WeakPNT''.add_isLittleO'' (IsBigO.trans_isLittleO (g := fun x ↦ 2 * x.sqrt * x.log) ?_ ?_) · rw [isBigO_iff']; refine ⟨1, one_pos, ?_⟩ simp only [one_mul, eventually_atTop] exact ⟨2, fun x hx ↦ by rw [Pi.sub_apply, norm_eq_abs, norm_eq_abs, abs_of_nonneg (by bound : 0 ≤ 2 * √x * log x)] exact (abs_of_nonneg (sub_nonneg.mpr (Chebyshev.theta_le_psi x))).symm ▸ Chebyshev.abs_psi_sub_theta_le_sqrt_mul_log (by linarith : 1 ≤ x)⟩ · simpa only [mul_assoc] using! isLittleO_sqrt_mul_log.const_mul_left 2 /- Original line 5769: chebyshev_asymptotic_finsum -/ theorem chebyshev_asymptotic_finsum : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace (fun x ↦ ∑ᶠ (p : ℕ) (_ : p ≤ x) (_ : Nat.Prime p), log p) ~[atTop] fun x ↦ x := by letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by have hReal : (fun x : ℝ ↦ ∑ᶠ (p : ℕ) (_ : (p : ℝ) ≤ x) (_ : p.Prime), log (p : ℝ)) ~[atTop] fun x ↦ x := by have h x : ∑ᶠ (p : ℕ) (_ : (p : ℝ) ≤ x) (_ : p.Prime), log (p : ℝ) = θ x := by rw [Chebyshev.theta_eq_sum_Icc] have hfin : {p : ℕ | (p : ℝ) ≤ x ∧ p.Prime}.Finite := (Iic ⌊x⌋₊).finite_toSet.subset fun p ⟨hpx, _⟩ ↦ mem_Iic.mpr (Nat.le_floor hpx) calc ∑ᶠ (p : ℕ) (_ : (p : ℝ) ≤ x) (_ : p.Prime), log (p : ℝ) = ∑ᶠ (p : ℕ) (_ : (p : ℝ) ≤ x ∧ p.Prime), log (p : ℝ) := finsum_congr fun p ↦ by by_cases hp : p.Prime <;> simp [hp] _ = ∑ p ∈ hfin.toFinset, log (p : ℝ) := finsum_mem_eq_finite_toFinset_sum _ hfin _ = _ := sum_congr (by ext p; simp only [Set.Finite.mem_toFinset, Set.mem_ofPred_eq, mem_filter, mem_Icc, and_congr_left_iff]; exact fun hp ↦ ⟨fun hpx ↦ ⟨Nat.zero_le _, Nat.le_floor hpx⟩, fun ⟨_, hpn⟩ ↦ (le_or_gt 0 x).elim (fun hx ↦ (Nat.floor_le hx).trans' (Nat.cast_le.mpr hpn)) fun hx ↦ absurd (Nat.le_zero.mp (Nat.floor_eq_zero.mpr (hx.trans_le zero_le_one) ▸ hpn)) hp.ne_zero⟩) (fun _ _ ↦ rfl) have heq : (fun x : ℝ ↦ ∑ᶠ (p : ℕ) (_ : (p : ℝ) ≤ x) (_ : p.Prime), log (p : ℝ)) =ᶠ[atTop] θ := Filter.Eventually.of_forall h exact chebyshev_asymptotic.congr_left heq.symm simp only [IsEquivalent, show (fun n : ℕ ↦ ∑ᶠ (p : ℕ) (_ : p ≤ n) (_ : p.Prime), log (p : ℝ)) = (fun x : ℝ ↦ ∑ᶠ (p : ℕ) (_ : (p : ℝ) ≤ x) (_ : p.Prime), log (p : ℝ)) ∘ Nat.cast from funext fun _ ↦ finsum_congr fun _ ↦ by simp] exact hReal.isLittleO.comp_tendsto tendsto_natCast_atTop_atTop /- Original line 5799: chebyshev_asymptotic' -/ theorem chebyshev_asymptotic' : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∃ (f : ℝ → ℝ), (∀ ε > (0 : ℝ), (f =o[atTop] fun t ↦ ε * t)) ∧ (∀ (x : ℝ), 2 ≤ x → IntegrableOn f (Set.Icc 2 x)) ∧ ∀ (x : ℝ), θ x = x + f x := by letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by have H := chebyshev_asymptotic rw [IsEquivalent, isLittleO_iff] at H let f := (fun x ↦ θ x - x) have integrable (x : ℝ) (hx : 2 ≤ x) : IntegrableOn f (Set.Icc 2 x) := by rw [IntegrableOn] refine Integrable.sub ?_ (ContinuousOn.integrableOn_Icc (continuousOn_id' _)) refine Chebyshev.integrableOn_theta_div_id_mul_log_sq x |>.mul_continuousOn (g' := fun t => t * log t ^ 2) (ContinuousOn.mul (continuousOn_id' _) (ContinuousOn.pow (continuousOn_log |>.mono <| by rintro t ⟨ht1, _⟩ simp only [Set.mem_compl_iff, Set.mem_singleton_iff] linarith) 2)) isCompact_Icc |>.congr_fun_ae ?_ simp only [measurableSet_Icc, ae_restrict_eq, EventuallyEq, eventually_inf_principal] refine .of_forall fun t ⟨ht1, _⟩ => ?_ rw [div_mul_cancel₀] simpa only [ne_eq, _root_.mul_eq_zero, OfNat.ofNat_ne_zero, not_false_eq_true, pow_eq_zero_iff, log_eq_zero, _root_.or_self_left, not_or] using ⟨by linarith, by linarith, by linarith⟩ refine ⟨f, fun ε hε ↦ ?_, integrable, ?_⟩ · rw [isLittleO_iff] intro c hc specialize @H (c * ε) (mul_pos hc hε) simp only [Pi.sub_apply, norm_eq_abs, mul_assoc, eventually_atTop, norm_mul, abs_of_pos hε, f] at H ⊢ exact H refine fun r => by simp [f] /- Original line 5829: chebyshev_asymptotic'' -/ theorem chebyshev_asymptotic'' : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∃ (f : ℝ → ℝ), (∀ ε > (0 : ℝ), (f =o[atTop] fun _ ↦ ε)) ∧ (∀ (x : ℝ), 2 ≤ x → IntegrableOn f (Set.Icc 2 x)) ∧ ∀ x > (0 : ℝ), θ x = x + x * (f x) := by letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by obtain ⟨f, hf1, inte, hf2⟩ := chebyshev_asymptotic' refine ⟨fun t => f t / t, fun ε hε ↦ ?_, ?_, ?_⟩ · simp only [isLittleO_iff, norm_eq_abs, norm_mul, eventually_atTop, norm_div] at hf1 ⊢ intro r hr replace hf1 := hf1 ε hε obtain ⟨N, hN⟩ := hf1 hr use |N| + 1 intro x hx have hx' : |N| + 1 ≤ |x| := by rwa [abs_of_nonneg (a := x) (le_trans (by positivity) hx)] rw [div_le_iff₀ (lt_of_lt_of_le (by positivity) hx'), mul_assoc] exact hN x (le_trans (le_trans (le_abs_self N) (by linarith)) hx) · intro x hx refine inte x hx |>.mul_continuousOn (g' := fun t : ℝ => t⁻¹) (continuousOn_inv₀ |>.mono <| by rintro t ⟨ht1, _⟩ simp only [Set.mem_compl_iff, Set.mem_singleton_iff] linarith) isCompact_Icc |>.congr_fun_ae <| .of_forall <| by simp [div_eq_mul_inv] intro x hx rw [hf2, mul_div_cancel₀] linarith -- one could also consider adding a version with p < x instead of p \leq x /- Original line 5861: primorial_bounds -/ theorem primorial_bounds : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∃ E : ℝ → ℝ, E =o[atTop] (fun x ↦ x) ∧ ∀ x : ℝ, ∏ p ∈ (Iic ⌊x⌋₊).filter Nat.Prime, p = exp (x + E x) := by letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by use (fun x ↦ ∑ p ∈ (filter Nat.Prime (Iic ⌊x⌋₊)), log p - x) constructor · exact Asymptotics.IsEquivalent.isLittleO chebyshev_asymptotic intro x simp only [cast_prod, add_sub_cancel, exp_sum] apply Finset.prod_congr rfl intros x hx rw[Real.exp_log] rw[Finset.mem_filter] at hx norm_cast exact Nat.Prime.pos hx.right /- Original line 5876: primorial_bounds_finprod -/ theorem primorial_bounds_finprod : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∃ E : ℝ → ℝ, E =o[atTop] (fun x ↦ x) ∧ ∀ x : ℝ, ∏ᶠ (p : ℕ) (_ : p ≤ x) (_ : Nat.Prime p), p = exp (x + E x) := by letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by obtain ⟨E, hE, hprod⟩ := primorial_bounds refine ⟨E, hE, fun x ↦ ?_⟩ have hfin : {p : ℕ | (p : ℝ) ≤ x ∧ p.Prime}.Finite := (Iic ⌊x⌋₊).finite_toSet.subset fun p ⟨hpx, _⟩ ↦ mem_Iic.mpr <| le_floor hpx have heq : ∏ᶠ (p : ℕ) (_ : (p : ℝ) ≤ x) (_ : p.Prime), p = ∏ p ∈ (Iic ⌊x⌋₊).filter Prime, p := by calc ∏ᶠ (p : ℕ) (_ : (p : ℝ) ≤ x) (_ : p.Prime), p = ∏ᶠ (p : ℕ) (_ : (p : ℝ) ≤ x ∧ p.Prime), p := finprod_congr fun p ↦ by by_cases hp : p.Prime <;> simp [hp] _ = ∏ p ∈ hfin.toFinset, p := finprod_mem_eq_finite_toFinset_prod _ hfin _ = _ := prod_congr (by ext p; simp only [Set.Finite.mem_toFinset, Set.mem_ofPred_eq, mem_filter, mem_Iic, and_congr_left_iff]; exact fun hp ↦ ⟨le_floor, fun hpn ↦ (le_or_gt 0 x).elim (fun hx ↦ (Nat.floor_le hx).trans' (cast_le.mpr hpn)) fun hx ↦ absurd (le_zero.mp (floor_eq_zero.mpr (hx.trans_le zero_le_one) ▸ hpn)) hp.ne_zero⟩) (fun _ _ ↦ rfl) simp only [heq, hprod] /- Original line 5897: continuousOn_log0 -/ theorem continuousOn_log0 : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ContinuousOn (fun x ↦ -1 / (x * log x ^ 2)) {0, 1, -1}ᶜ := by letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by refine fun t ht ↦ ContinuousAt.continuousWithinAt ?_ fun_prop (disch := simp_all) /- Original line 5902: continuousOn_log1 -/ theorem continuousOn_log1 : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ContinuousOn (fun x ↦ (log x ^ 2)⁻¹ * x⁻¹) {0, 1, -1}ᶜ := by letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by refine fun t ht ↦ ContinuousAt.continuousWithinAt ?_ fun_prop (disch := simp_all) /- Original line 5906: integral_log_inv -/ theorem integral_log_inv (a b : ℝ) (ha : 2 ≤ a) (hb : a ≤ b) : ∫ t in a..b, (log t)⁻¹ = ((log b)⁻¹ * b) - ((log a)⁻¹ * a) + ∫ t in a..b, ((log t)^2)⁻¹ := by rw [le_iff_lt_or_eq] at hb rcases hb with hb | rfl; swap · simp only [intervalIntegral.integral_same, sub_self, add_zero] · have := intervalIntegral.integral_mul_deriv_eq_deriv_mul (u := fun x => (log x)⁻¹) (u' := fun x => -1 / (x * (log x)^2)) (v := fun x => x) (v' := fun _ => 1) (a := a) (b := b) (fun x hx => by rw [Set.uIcc_eq_union, Set.Icc_eq_empty (lt_iff_not_ge |>.1 hb), Set.union_empty] at hx obtain ⟨hx1, _⟩ := hx rw [show (-1 / (x * log x ^ 2)) = (-1 / log x ^ 2) * (x⁻¹) by rw [mul_comm x]; field_simp] apply HasDerivAt.comp (h := fun t => log t) (h₂ := fun t => t⁻¹) (x := x) · simpa using! HasDerivAt.inv (c := fun t : ℝ => t) (c' := 1) (x := log x) (hasDerivAt_id' (log x)) (by simp only [ne_eq, log_eq_zero, not_or]; refine ⟨?_, ?_, ?_⟩ <;> linarith) · apply hasDerivAt_log; linarith) (fun x _ => hasDerivAt_id' x) (by rw [intervalIntegrable_iff_integrableOn_Icc_of_le (le_of_lt hb)] apply ContinuousOn.integrableOn_Icc refine continuousOn_log0.mono fun x hx ↦ ?_ simp only [Set.mem_Icc, Set.mem_compl_iff, Set.mem_insert_iff, Set.mem_singleton_iff, not_or] at hx ⊢ refine ⟨?_, ?_, ?_⟩ <;> linarith) (by constructor <;> apply MeasureTheory.integrable_const) simp only [mul_one] at this rw [this] simp_rw [neg_div, neg_mul] rw [sub_eq_add_neg] congr 1 rw [intervalIntegral.integral_of_le (le_of_lt hb), intervalIntegral.integral_of_le (le_of_lt hb), ← MeasureTheory.integral_neg] simp_rw [neg_neg] refine integral_congr_ae ?_ · rw [ae_restrict_eq, eventuallyEq_inf_principal_iff] · refine .of_forall fun x hx => ?_ simp only [Set.mem_Ioc, one_div, mul_inv_rev, mul_assoc] at hx ⊢ rw [inv_mul_cancel₀, mul_one] linarith exact measurableSet_Ioc /- Original line 5957: integral_log_inv' -/ theorem integral_log_inv' : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (a b : ℝ) (ha : 2 ≤ a) (hb : a ≤ b), ∫ t in Set.Icc a b, (log t)⁻¹ = ((log b)⁻¹ * b) - ((log a)⁻¹ * a) + ∫ t in Set.Icc a b, ((log t)^2)⁻¹ := by intro a b ha hb letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by have := integral_log_inv a b ha hb simp only [intervalIntegral.intervalIntegral_eq_integral_uIoc, if_pos hb, Set.uIoc_of_le hb, smul_eq_mul, one_mul] at this rw [integral_Icc_eq_integral_Ioc, integral_Icc_eq_integral_Ioc] rw [this] /- Original line 5967: integral_log_inv'' -/ theorem integral_log_inv'' : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (a b : ℝ) (ha : 2 ≤ a) (hb : a ≤ b), (log a)⁻¹ * a + ∫ t in Set.Icc a b, (log t)⁻¹ = ((log b)⁻¹ * b) + ∫ t in Set.Icc a b, ((log t)^2)⁻¹ := by intro a b ha hb letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by rw [integral_log_inv' a b ha hb] group /- Original line 5973: integral_log_inv_pos -/ theorem integral_log_inv_pos : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (x : ℝ) (hx : 2 < x), 0 < ∫ t in Set.Icc 2 x, (log t)⁻¹ := by intro x hx letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by classical rw [MeasureTheory.integral_pos_iff_support_of_nonneg_ae] · simp only [Function.support_inv, measurableSet_Icc, Measure.restrict_apply'] rw [show Function.support log ∩ Set.Icc 2 x = Set.Icc 2 x by rw [Set.inter_eq_right] intro t ht simp only [Set.mem_Icc, Function.mem_support, ne_eq, log_eq_zero, not_or] at ht ⊢ exact ⟨by linarith, by linarith, by linarith⟩] simpa · simp only [measurableSet_Icc, ae_restrict_eq, EventuallyLE, eventually_inf_principal] refine .of_forall fun t (ht : _ ∧ _) => ?_ simpa only [Pi.zero_apply, inv_nonneg] using log_nonneg (by linarith) · apply ContinuousOn.integrableOn_Icc apply ContinuousOn.inv₀ · exact (continuousOn_log).mono <| by aesop · rintro t ⟨ht, -⟩ simp only [ne_eq, log_eq_zero, not_or] exact ⟨by linarith, by linarith, by linarith⟩ /- Original line 5995: integral_log_inv_ne_zero -/ theorem integral_log_inv_ne_zero : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (x : ℝ) (hx : 2 < x), ∫ t in Set.Icc 2 x, (log t)⁻¹ ≠ 0 := by intro x hx letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by have := integral_log_inv_pos x hx linarith /- Original line 6000: pi_asymp_aux -/ theorem pi_asymp_aux : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (x : ℝ) (hx : 2 ≤ x), Nat.primeCounting ⌊x⌋₊ = (log x)⁻¹ * θ x + ∫ t in Set.Icc 2 x, θ t * (t * log t ^ 2)⁻¹ := by intro x hx letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by rw [th43_b _ hx] simp_rw [div_eq_mul_inv, Chebyshev.theta_eq_sum_Icc] ring_nf! /- Original line 6006: pi_asymp'' -/ theorem pi_asymp'' : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace (fun x => ((Nat.primeCounting ⌊x⌋₊ : ℝ) / ∫ t in Set.Icc 2 x, 1 / log t) - (1 : ℝ)) =o[atTop] fun _ => (1 : ℝ) := by letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by obtain ⟨f, hf, f_int, hf'⟩ := chebyshev_asymptotic'' have eq1 : ∀ᶠ (x : ℝ) in atTop, ⌊x⌋₊.primeCounting = (log x)⁻¹ * (x + x * f x) + (∫ t in Set.Icc 2 x, (t + t * f t) * (t * log t ^ 2)⁻¹) := by filter_upwards [eventually_ge_atTop 2] with x hx rw [pi_asymp_aux x hx, hf' x (by linarith)] congr 1 apply setIntegral_congr_fun measurableSet_Icc fun t ht ↦ ?_ rw [hf' t (by grind)] replace eq1 : ∀ᶠ (x : ℝ) in atTop, ⌊x⌋₊.primeCounting = (log x)⁻¹ * (x + x * f x) + ((∫ t in Set.Icc 2 x, (log t ^ 2)⁻¹) + (∫ t in Set.Icc 2 x, (f t) * (log t ^ 2)⁻¹)) := by filter_upwards [eq1, eventually_ge_atTop 2] with x eq1 hx rw [eq1] congr simp_rw [mul_inv_rev, add_mul] rw [MeasureTheory.integral_add] · congr 1 all_goals apply setIntegral_congr_fun measurableSet_Icc fun t ht ↦ ?_ field [show t ≠ 0 by grind] · apply IntegrableOn.mul_continuousOn (hg := ContinuousOn.integrableOn_Icc <| continuousOn_id' _) (hK := isCompact_Icc) apply continuousOn_log1.mono ?_ intro y h simp only [Set.mem_Icc, Set.mem_compl_iff, Set.mem_insert_iff, Set.mem_singleton_iff, not_or] at h ⊢ exact ⟨by linarith, by linarith, by linarith⟩ · rw [show (fun t ↦ t * f t * ((log t ^ 2)⁻¹ * t⁻¹)) = fun t ↦ f t * (t * (log t ^ 2)⁻¹ * t⁻¹) by ext; ring] apply IntegrableOn.mul_continuousOn (hK := isCompact_Icc) · apply f_int x (by linarith) · simp_rw [mul_assoc] refine ContinuousOn.mul (continuousOn_id' (Set.Icc 2 x)) ?_ apply continuousOn_log1.mono ?_ intro y h simp only [Set.mem_Icc, Set.mem_compl_iff, Set.mem_insert_iff, Set.mem_singleton_iff, not_or] at h ⊢ exact ⟨by linarith, by linarith, by linarith⟩ simp_rw [mul_add] at eq1 simp_rw [show ∀ (x : ℝ), (log x)⁻¹ * x + (log x)⁻¹ * (x * f x) + ((∫ (t : ℝ) in Set.Icc 2 x, (log t ^ 2)⁻¹) + ∫ (t : ℝ) in Set.Icc 2 x, f t * (log t ^ 2)⁻¹) = ((log x)⁻¹ * x + (∫ (t : ℝ) in Set.Icc 2 x, (log t ^ 2)⁻¹)) + ((log x)⁻¹ * (x * f x) + ∫ (t : ℝ) in Set.Icc 2 x, f t * (log t ^ 2)⁻¹) by intros; ring] at eq1 replace eq1 : ∃ (C : ℝ), ∀ᶠ (x : ℝ) in atTop, ⌊x⌋₊.primeCounting = (∫ (t : ℝ) in Set.Icc 2 x, (log t)⁻¹) + ((log x)⁻¹ * (x * f x) + ∫ (t : ℝ) in Set.Icc 2 x, f t * (log t ^ 2)⁻¹) + C := by use ((log 2)⁻¹ * 2) filter_upwards [eq1, eventually_ge_atTop 2] with x eq1 hx rw [eq1, ← integral_log_inv'' _ _ (by rfl) hx] ring replace eq1 : ∃ (C : ℝ), ∀ᶠ (x : ℝ) in atTop, (⌊x⌋₊.primeCounting / ∫ (t : ℝ) in Set.Icc 2 x, (log t)⁻¹) - 1 = ((log x)⁻¹ * (x * f x) / (∫ (t : ℝ) in Set.Icc 2 x, (log t)⁻¹) + (∫ (t : ℝ) in Set.Icc 2 x, f t * (log t ^ 2)⁻¹) / (∫ (t : ℝ) in Set.Icc 2 x, (log t)⁻¹)) + C / (∫ (t : ℝ) in Set.Icc 2 x, (log t)⁻¹) := by obtain ⟨C, hC⟩ := eq1 use C filter_upwards [hC, eventually_gt_atTop 2] with x hC hx rw [hC] field [integral_log_inv_ne_zero] simp_rw [isLittleO_iff] at hf choose C hC using eq1 simp_rw [← one_div] at hC apply isLittleO_congr hC (by rfl) |>.mpr have ineq1 (ε : ℝ) (hε : 0 < ε) (c : ℝ) (hc : 0 < c) : ∀ᶠ(x : ℝ) in atTop, (log x)⁻¹ * x * |f x| ≤ c * ε * ((log x)⁻¹ * x) := by filter_upwards [eventually_ge_atTop 2, hf ε hε hc] with x hx hM simp only [norm_eq_abs] at hM rw [abs_of_pos hε] at hM rw [mul_comm (c * ε)] gcongr bound have int_flog {a b : ℝ} (ha: 2 ≤ a) (hb : 2 ≤ b) : IntegrableOn (fun t ↦ |f t| * (log t ^ 2)⁻¹) (Set.Icc a b) volume := by apply IntegrableOn.mul_continuousOn · apply Integrable.abs <| f_int b hb |>.mono (Set.Icc_subset_Icc_left ha) (by rfl) · refine ContinuousOn.inv₀ (ContinuousOn.pow (continuousOn_log |>.mono ?_) 2) ?_ · simp grind · intro t ht simp only [Set.mem_Icc, ne_eq, OfNat.ofNat_ne_zero, not_false_eq_true, pow_eq_zero_iff, log_eq_zero, not_or] at ht ⊢ exact ⟨by linarith, by linarith, by linarith⟩ · exact isCompact_Icc have int_inv_log_sq {a b : ℝ} (ha : 2 ≤ a) (hb : 2 ≤ b) : IntegrableOn (fun t ↦ (log t ^ 2)⁻¹) (Set.Icc a b) volume := by refine ContinuousOn.integrableOn_Icc <| ContinuousOn.inv₀ (ContinuousOn.pow (continuousOn_log |>.mono ?_) 2) ?_ · grind · intro t ht simp only [Set.mem_Icc, ne_eq, OfNat.ofNat_ne_zero, not_false_eq_true, pow_eq_zero_iff, log_eq_zero, not_or] at ht ⊢ exact ⟨by linarith, by linarith, by linarith⟩ simp_rw [eventually_atTop] at hf choose M hM using hf have ineq2 (ε : ℝ) (hε : 0 < ε) (c : ℝ) (hc : 0 < c) : ∃ (D : ℝ), ∀ᶠ (x : ℝ) in atTop, |∫ (t : ℝ) in Set.Icc 2 x, f t * (log t ^ 2)⁻¹| ≤ c * ε * ((∫ (t : ℝ) in Set.Icc 2 x, (log t)⁻¹) - (log x)⁻¹ * x) + D := by use (((∫ (t : ℝ) in Set.Icc 2 (max 2 (M ε hε hc)), |f t| * (log t ^ 2)⁻¹) - c * ε * ∫ (t : ℝ) in Set.Icc 2 (max 2 (M ε hε hc)), (log t ^ 2)⁻¹) + c * ε * ((log 2)⁻¹ * 2)) filter_upwards [eventually_gt_atTop (max 2 (M ε hε hc))] with x hx calc _ _ ≤ ∫ (t : ℝ) in Set.Icc 2 x, |f t * (log t ^ 2)⁻¹| := norm_integral_le_integral_norm fun a ↦ f a * (log a ^ 2)⁻¹ _ = ∫ (t : ℝ) in Set.Icc 2 x, |f t| * (log t ^ 2)⁻¹ := by apply setIntegral_congr_fun measurableSet_Icc fun t ht ↦ ?_ rw [abs_mul, abs_of_nonneg (a := (log t ^ 2)⁻¹)] norm_num apply pow_nonneg exact log_nonneg <| by grind _ = (∫ (t : ℝ) in Set.Icc 2 (max 2 (M ε hε hc)), |f t| * (log t ^ 2)⁻¹) + (∫ (t : ℝ) in Set.Icc (max 2 (M ε hε hc)) x, |f t| * (log t ^ 2)⁻¹) := by rw [← setIntegral_union₀, Set.Icc_union_Icc_eq_Icc (le_max_left ..) hx.le] · rw [AEDisjoint, Set.Icc_inter_Icc_eq_singleton (le_max_left ..) hx.le, volume_singleton] · simp only [measurableSet_Icc, MeasurableSet.nullMeasurableSet] · apply int_flog (by rfl) (le_max_left ..) · apply int_flog (le_max_left ..) (le_trans (le_max_left ..) hx.le) _ ≤ (∫ (t : ℝ) in Set.Icc 2 (max 2 (M ε hε hc)), |f t| * (log t ^ 2)⁻¹) + (∫ (t : ℝ) in Set.Icc (max 2 (M ε hε hc)) x, (c * ε) * (log t ^ 2)⁻¹) := by gcongr 1 apply setIntegral_mono_on · apply int_flog (le_max_left ..) (le_trans (le_max_left ..) hx.le) · rw [IntegrableOn, integrable_const_mul_iff] · apply int_inv_log_sq (le_max_left ..) (le_trans (le_max_left ..) hx.le) · simp only [isUnit_iff_ne_zero, ne_eq, _root_.mul_eq_zero, not_or] exact ⟨by linarith, by linarith⟩ · exact measurableSet_Icc · intro t ht simp only [Set.mem_Icc, sup_le_iff] at ht apply mul_le_mul_of_nonneg_right · refine hM ε hε hc t ht.1.2 |>.trans ?_ simp only [norm_eq_abs, abs_of_pos hε, le_refl] · norm_num refine pow_nonneg (log_nonneg <| by linarith) 2 _ = (∫ (t : ℝ) in Set.Icc 2 (max 2 (M ε hε hc)), |f t| * (log t ^ 2)⁻¹) + ((c * ε) * ∫ (t : ℝ) in Set.Icc (max 2 (M ε hε hc)) x, (log t ^ 2)⁻¹) := by congr 1 exact integral_const_mul (c * ε) _ _ = (∫ (t : ℝ) in Set.Icc 2 (max 2 (M ε hε hc)), |f t| * (log t ^ 2)⁻¹) + ((c * ε) * ((∫ (t : ℝ) in Set.Icc (max 2 (M ε hε hc)) x, (log t ^ 2)⁻¹) + ((∫ (t : ℝ) in Set.Icc 2 (max 2 (M ε hε hc)), (log t ^ 2)⁻¹)) - ((∫ (t : ℝ) in Set.Icc 2 (max 2 (M ε hε hc)), (log t ^ 2)⁻¹)))) := by ring _ = (∫ (t : ℝ) in Set.Icc 2 (max 2 (M ε hε hc)), |f t| * (log t ^ 2)⁻¹) + ((c * ε) * ((∫ (t : ℝ) in Set.Icc 2 x, (log t ^ 2)⁻¹) - ((∫ (t : ℝ) in Set.Icc 2 (max 2 (M ε hε hc)), (log t ^ 2)⁻¹)))) := by congr 3 rw [add_comm, ← setIntegral_union₀, Set.Icc_union_Icc_eq_Icc (le_max_left ..) hx.le] · rw [AEDisjoint, Set.Icc_inter_Icc_eq_singleton (le_max_left ..) hx.le, volume_singleton] · simp only [measurableSet_Icc, MeasurableSet.nullMeasurableSet] · apply int_inv_log_sq (by rfl) (le_max_left ..) · apply int_inv_log_sq (le_max_left ..) (le_trans (le_max_left ..) hx.le) _ = ((c * ε) * (∫ (t : ℝ) in Set.Icc 2 x, (log t ^ 2)⁻¹)) + ((∫ (t : ℝ) in Set.Icc 2 (max 2 (M ε hε hc)), |f t| * (log t ^ 2)⁻¹) - (c * ε) * (∫ (t : ℝ) in Set.Icc 2 (max 2 (M ε hε hc)), (log t ^ 2)⁻¹)) := by ring _ = ((c * ε) * ((∫ (t : ℝ) in Set.Icc 2 x, (log t)⁻¹) + ((log 2)⁻¹ * 2) - ((log x)⁻¹ * x))) + ((∫ (t : ℝ) in Set.Icc 2 (max 2 (M ε hε hc)), |f t| * (log t ^ 2)⁻¹) - (c * ε) * (∫ (t : ℝ) in Set.Icc 2 (max 2 (M ε hε hc)), (log t ^ 2)⁻¹)) := by congr 2 rw [integral_log_inv' _ _ (by rfl)] · ring · simp only [max_lt_iff] at hx linarith _ = _ := by ring choose D hD using ineq2 have ineq4 (const : ℝ) (ε : ℝ) (hε : 0 < ε) : ∀ᶠ x in atTop, |const / (∫ (t : ℝ) in Set.Icc 2 x, (log t)⁻¹)| ≤ 1/2 * ε := by obtain rfl|hconst := eq_or_ne const 0 · filter_upwards with x simp[hε.le] have ineq (x : ℝ) (hx : 2 < x) := calc (∫ (t : ℝ) in Set.Icc 2 x, (log t)⁻¹) _ ≥ (∫ (_ : ℝ) in Set.Icc 2 x, (log x)⁻¹) := by apply setIntegral_mono_on (integrable_const _) · refine ContinuousOn.integrableOn_Icc <| ContinuousOn.inv₀ (continuousOn_log |>.mono ?_) ?_ · simp only [Set.subset_compl_singleton_iff, Set.mem_Icc, not_and, not_le, isEmpty_Prop, ofNat_pos, IsEmpty.forall_iff] · intro t ht simp only [Set.mem_Icc, ne_eq, log_eq_zero, not_or] at ht ⊢ exact ⟨by linarith, by linarith, by linarith⟩ · exact measurableSet_Icc · intro t ⟨ht1, ht2⟩ gcongr bound _ = (x - 2) * (log x)⁻¹ := by rw [MeasureTheory.integral_const] simp only [MeasurableSet.univ, Measure.restrict_apply, Set.univ_inter, volume_Icc, smul_eq_mul, mul_eq_mul_right_iff, ENNReal.toReal_ofReal_eq_iff, sub_nonneg, inv_eq_zero, log_eq_zero, Measure.real] refine Or.inl (le_of_lt hx) simp_rw [abs_div] have ineq (x : ℝ) (hx : 2 < x) : |const| / |∫ (t : ℝ) in Set.Icc 2 x, (log t)⁻¹| ≤ |const| / ((x - 2) * (log x)⁻¹) := by apply div_le_div₀ (abs_nonneg _) (by rfl) · apply mul_pos · linarith · norm_num rw [Real.log_pos_iff] · linarith · linarith · rw [abs_of_pos (integral_log_inv_pos _ hx)] exact ineq x hx have ineq (x : ℝ) (hx : 2 < x) : |const| / |∫ (t : ℝ) in Set.Icc 2 x, (log t)⁻¹| ≤ |const| * (log x / ((x - 2))) := by refine ineq x hx |>.trans <| le_of_eq ?_ field_simp have lim := Real.tendsto_pow_log_div_mul_add_atTop 1 (-2) 1 (by norm_num) simp only [pow_one, one_mul, ← sub_eq_add_neg] at lim rw [tendsto_atTop_nhds] at lim specialize lim (Metric.ball 0 ((1/2) * ε / |const| : ℝ)) (by simp only [Metric.mem_ball, _root_.dist_self] apply _root_.div_pos · linarith · simpa only [abs_pos, ne_eq]) Metric.isOpen_ball obtain ⟨M, hM⟩ := lim rw [eventually_atTop] refine ⟨max 3 M, ?_⟩ intro x hx simp only [Metric.mem_ball, _root_.dist_zero_right, max_le_iff, norm_eq_abs] at hM hx refine ineq x (by linarith) |>.trans ?_ specialize hM x hx.2 rw [abs_of_nonneg (by apply div_nonneg · refine log_nonneg (by linarith) · linarith)] at hM have ineq' : |const| * (log x / (x - 2)) < |const| * ((1/2) * ε / |const|) := by rw [mul_lt_mul_iff_right₀] · exact hM · simpa only [abs_pos, ne_eq] rw [mul_div_cancel₀] at ineq' · refine le_of_lt ineq' · simpa only [ne_eq, abs_eq_zero] rw [isLittleO_iff] intro ε hε specialize ineq4 (|D ε hε (1/2) (by linarith)| + |C|) ε hε simp only [one_div, norm_eq_abs, norm_one, mul_one] filter_upwards [eventually_gt_atTop 2, ineq4, ineq1 ε hε (1 / 2) (by norm_num), hD ε hε (1 / 2) (by norm_num)] with x hx hB ineq1 hD have := integral_log_inv_pos x (by linarith) |>.le calc _ _ ≤ |((log x)⁻¹ * (x * f x) / ∫ (t : ℝ) in Set.Icc 2 x, (log t)⁻¹)| + |(∫ (t : ℝ) in Set.Icc 2 x, f t * (log t ^ 2)⁻¹) / ∫ (t : ℝ) in Set.Icc 2 x, (log t)⁻¹| + |C / ∫ (t : ℝ) in Set.Icc 2 x, (log t)⁻¹| := by apply abs_add_three _ = |(log x)⁻¹ * (x * f x)| / |∫ (t : ℝ) in Set.Icc 2 x, (log t)⁻¹| + |(∫ (t : ℝ) in Set.Icc 2 x, f t * (log t ^ 2)⁻¹)| / |∫ (t : ℝ) in Set.Icc 2 x, (log t)⁻¹| + |C| / |∫ (t : ℝ) in Set.Icc 2 x, (log t)⁻¹| := by rw [abs_div, abs_div, abs_div] _ = |(log x)⁻¹ * (x * f x)| / (∫ (t : ℝ) in Set.Icc 2 x, (log t)⁻¹) + |(∫ (t : ℝ) in Set.Icc 2 x, f t * (log t ^ 2)⁻¹)| / (∫ (t : ℝ) in Set.Icc 2 x, (log t)⁻¹) + |C| / (∫ (t : ℝ) in Set.Icc 2 x, (log t)⁻¹) := by repeat rw [abs_of_pos <| integral_log_inv_pos _ (by linarith)] _ = ((log x)⁻¹ * x * |f x|) / (∫ (t : ℝ) in Set.Icc 2 x, (log t)⁻¹) + |(∫ (t : ℝ) in Set.Icc 2 x, f t * (log t ^ 2)⁻¹)| / (∫ (t : ℝ) in Set.Icc 2 x, (log t)⁻¹) + |C| / (∫ (t : ℝ) in Set.Icc 2 x, (log t)⁻¹) := by congr rw [abs_mul, abs_mul, abs_of_nonneg (by bound), abs_of_nonneg (by linarith), mul_assoc] _ ≤ ((1/2) * ε * ((log x)⁻¹ * x)) / (∫ (t : ℝ) in Set.Icc 2 x, (log t)⁻¹) + ((1/2) * ε * ((∫ (t : ℝ) in Set.Icc 2 x, (log t)⁻¹) - (log x)⁻¹ * x) + D ε hε (1/2) (by linarith)) / (∫ (t : ℝ) in Set.Icc 2 x, (log t)⁻¹) + |C| / (∫ (t : ℝ) in Set.Icc 2 x, (log t)⁻¹) := by gcongr _ = ((1/2) * ε * (∫ (t : ℝ) in Set.Icc 2 x, (log t)⁻¹)) / (∫ (t : ℝ) in Set.Icc 2 x, (log t)⁻¹) + (D ε hε (1/2) (by linarith) + |C|) / (∫ (t : ℝ) in Set.Icc 2 x, (log t)⁻¹) := by ring _ = (1/2) * ε + (D ε hε (1/2) (by linarith) + |C|) / (∫ (t : ℝ) in Set.Icc 2 x, (log t)⁻¹) := by congr 1 rw [mul_div_assoc, div_self, mul_one] apply integral_log_inv_ne_zero linarith _ ≤ (1/2) * ε + (|D ε hε (1/2) (by linarith)| + |C|) / (∫ (t : ℝ) in Set.Icc 2 x, (log t)⁻¹) := by gcongr apply le_abs_self _ ≤ (1/2) * ε + (1/2) * ε := by rw [abs_div, abs_of_nonneg, abs_of_pos (a := ∫ _ in _, _)] at hB · gcongr · apply integral_log_inv_pos; linarith · positivity _ = ε := by field /- Original line 6340: pi_asymp -/ theorem pi_asymp : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∃ c : ℝ → ℝ, c =o[atTop] (fun _ ↦ (1 : ℝ)) ∧ ∀ᶠ (x : ℝ) in atTop, Nat.primeCounting ⌊x⌋₊ = (1 + c x) * ∫ t in (2 : ℝ)..x, 1 / (log t) := by letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by refine ⟨_, pi_asymp'', ?_⟩ filter_upwards [eventually_ge_atTop 3] with x hx rw [intervalIntegral.integral_of_le (by linarith), ← MeasureTheory.integral_Icc_eq_integral_Ioc] field [(integral_log_inv_pos x (by linarith)).ne'] /- Original line 6350: inv_div_log_asy -/ theorem inv_div_log_asy : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∃ c, ∀ᶠ (x : ℝ) in atTop, ∫ (t : ℝ) in Set.Icc 2 x, 1 / log t ^ 2 ≤ c * (x / log x ^ 2) := by letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by have := Chebyshev.integral_one_div_log_sq_isBigO rw [isBigO_iff] at this obtain ⟨c, hc⟩ := this use c filter_upwards [hc, eventually_ge_atTop 2] with x hc hx rw [integral_Icc_eq_integral_Ioc, ← intervalIntegral.integral_of_le hx] apply le_trans (by apply le_norm_self) nth_rewrite 2 [norm_of_nonneg (by positivity)] at hc exact hc /- Original line 6362: integral_log_inv_pialt -/ theorem integral_log_inv_pialt : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∀ (x : ℝ) (hx : 4 ≤ x), ∫ (t : ℝ) in Set.Icc 2 x, 1 / log t = x / log x - 2 / log 2 + ∫ (t : ℝ) in Set.Icc 2 x, 1 / (log t) ^ 2 := by intro x hx letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by have := integral_log_inv 2 x (by norm_num) (by linarith) rw [MeasureTheory.integral_Icc_eq_integral_Ioc, ← intervalIntegral.integral_of_le (by linarith [hx]), MeasureTheory.integral_Icc_eq_integral_Ioc, ← intervalIntegral.integral_of_le (by linarith [hx]), ← mul_one_div, one_div, ← mul_one_div, one_div] simp only [one_div, this, mul_comm] /- Original line 6372: integral_div_log_asymptotic -/ theorem integral_div_log_asymptotic : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∃ c : ℝ → ℝ, c =o[atTop] (fun _ ↦ (1:ℝ)) ∧ ∀ᶠ (x : ℝ) in atTop, ∫ t in Set.Icc 2 x, 1 / (log t) = (1 + c x) * x / (log x) := by letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by obtain ⟨c, hc⟩ := inv_div_log_asy use fun x => ((∫ (t : ℝ) in Set.Icc 2 x, 1 / log t ^ 2) - 2 / log 2) * log x / x constructor · simp_rw [mul_div_assoc, mul_comm] apply isLittleO_mul_iff_isLittleO_div _|>.mpr · simp_rw [one_div_div] apply IsLittleO.sub · apply IsBigO.trans_isLittleO (g := (fun x ↦ x / log x ^ 2)) · rw [isBigO_iff] use c filter_upwards [eventually_ge_atTop 2, hc] with x hx hc simp only [norm_eq_abs] rwa [abs_of_nonneg, abs_of_nonneg] · bound · apply setIntegral_nonneg measurableSet_Icc fun t ht ↦ (by bound) apply isLittleO_of_tendsto · simp apply tendsto_log_atTop.inv_tendsto_atTop.congr' filter_upwards [eventually_ne_atTop 0] with x hx simp only [Pi.inv_apply] field apply isLittleO_mul_iff_isLittleO_div _|>.mp · conv => arg 2; ext; rw [mul_comm] apply IsLittleO.const_mul_left isLittleO_log_id_atTop · filter_upwards [eventually_ge_atTop 2] with x hx simp; grind filter_upwards [eventually_ge_atTop 2] with x hx simp grind · filter_upwards [eventually_ge_atTop 4] with x hx rw [integral_log_inv_pialt x hx] field [show log x ≠ 0 by simp; grind] /- Original line 6408: pi_alt -/ theorem pi_alt : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace ∃ c : ℝ → ℝ, c =o[atTop] (fun _ ↦ (1 : ℝ)) ∧ ∀ x : ℝ, Nat.primeCounting ⌊x⌋₊ = (1 + c x) * x / log x := by letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by obtain ⟨f, hf, h⟩ := pi_asymp obtain ⟨f', hf', h'⟩ := integral_div_log_asymptotic use (fun x => (log x / x) * ⌊x⌋₊.primeCounting - 1) constructor · apply IsLittleO.congr' (f₁ := (fun x ↦ f x + f x * f' x + f' x)) _ _ (by rfl) · apply IsLittleO.add _ hf' apply IsLittleO.add hf convert! hf.mul hf' ring · filter_upwards [eventually_ge_atTop 2, h, h'] with x hx h h' rw [h, intervalIntegral.integral_of_le hx, ← integral_Icc_eq_integral_Ioc, h'] have : log x ≠ 0 := by simp; grind field · intro x obtain rfl|hx := eq_or_ne x 0 · simp obtain rfl|hx := eq_or_ne x 1 · simp obtain rfl|hx := eq_or_ne x (-1 : ℝ) · simp norm_num have : log x ≠ 0 := by simp_all field /- Original line 6434: pi_alt' -/ theorem pi_alt' : letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace (fun (x : ℝ) ↦ (primeCounting ⌊x⌋₊ : ℝ)) ~[atTop] (fun x ↦ x / log x) := by letI := @_root_.CS.instCoeFunForallReal.{0} letI := @_root_.CS.instCoeRealComplex letI := @_root_.CS.instNeg.{0} letI := @_root_.CS.instHSMulReal.{0} letI := @_root_.trunc.instCoeFunForallReal letI := @_root_.trunc.instCoeCSOfNatNatReal letI := @_root_.W1.instCoeFunForallReal.{0} letI := @_root_.W1.instSub.{0} letI := @_root_.W21.instNorm letI := @_root_.W21.instCoeSchwartzMapRealComplex letI := @_root_.W21.instCoeCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatComplex letI := @_root_.W21.instHMulCSOfNatNatRealComplex letI := @_root_.instMeasurableSpace letI := @_root_.instBorelSpace exact by obtain ⟨f, ⟨hf1, hf2⟩⟩ := pi_alt simp_rw [hf2, IsEquivalent] have : ((fun x ↦ (1 + f x) * x / log x) - fun x ↦ x / log x) = (fun x ↦ f x * x / log x) := by ext simp ring rw [this] convert hf1.mul_isBigO (f₂ := (fun x ↦ x / log x)) (g₂ := (fun x ↦ x /log x)) (isBigO_refl ..) using 2 all_goals first | ring | rfl end PNTSource_7 end PNTDependencyPort namespace Erdos416Proof /-- Ordinary prime number theorem, supplied by the fully proved dependency above. Prime counting uses the natural floor for real arguments. -/ /- Original line 6457: Erdos416Proof.prime_counting_asymptotic -/ theorem prime_counting_asymptotic : Asymptotics.IsEquivalent Filter.atTop (fun x : ℝ => (Nat.primeCounting ⌊x⌋₊ : ℝ)) (fun x => x / Real.log x) := pi_alt' /- Original line 6462: Erdos416Proof.prime_counting_ratio -/ theorem prime_counting_ratio : Filter.Tendsto (fun x : ℝ => (Nat.primeCounting ⌊x⌋₊ : ℝ) / (x / Real.log x)) Filter.atTop (nhds 1) := by apply (Asymptotics.isEquivalent_iff_tendsto_one ?_).mp prime_counting_asymptotic filter_upwards [Filter.eventually_gt_atTop (1 : ℝ)] with x hx exact div_ne_zero (by linarith) (ne_of_gt (Real.log_pos hx)) end Erdos416Proof open Filter open scoped Topology BigOperators Classical namespace Erdos416Proof /- Original line 6477: Erdos416Proof.core_quotient_tendsto_atTop -/ theorem core_quotient_tendsto_atTop {α : Type*} {l : Filter α} {y b : α → ℝ} (hy : Tendsto y l atTop) (hb : ∀ᶠ a in l, 0 < b a) (hlog : Tendsto (fun a => Real.log (b a) / Real.log (y a)) l (nhds 0)) : Tendsto (fun a => y a / b a) l atTop := by have hylog := Real.tendsto_log_atTop.comp hy have hfactor : Tendsto (fun a => 1 - Real.log (b a) / Real.log (y a)) l (nhds 1) := by simpa using tendsto_const_nhds.sub hlog have hglog : Tendsto (fun a => Real.log (y a / b a)) l atTop := by apply (hylog.atTop_mul_pos (by norm_num : (0 : ℝ) < 1) hfactor).congr' filter_upwards [hy.eventually_gt_atTop 1, hb] with a hya hba rw [Real.log_div (by linarith) (ne_of_gt hba)] dsimp only [Function.comp_apply] field_simp [ne_of_gt (Real.log_pos hya)] apply (Real.tendsto_exp_atTop.comp hglog).congr' filter_upwards [hy.eventually_gt_atTop 0, hb] with a hya hba exact Real.exp_log (div_pos hya hba) /- Original line 6495: Erdos416Proof.log_scaled_core_ratio -/ theorem log_scaled_core_ratio {α : Type*} {l : Filter α} {y b : α → ℝ} (hy : Tendsto y l atTop) (hb : ∀ᶠ a in l, 0 < b a) (hlog : Tendsto (fun a => Real.log (b a) / Real.log (y a)) l (nhds 0)) {t : ℝ} (ht : 0 < t) : Tendsto (fun a => Real.log (t * (y a / b a)) / Real.log (y a)) l (nhds 1) := by have h := ((Real.tendsto_log_atTop.comp hy).const_div_atTop (Real.log t)).add (tendsto_const_nhds (x := (1 : ℝ))) have h' : Tendsto (fun a => Real.log t / Real.log (y a) + 1 - Real.log (b a) / Real.log (y a)) l (nhds 1) := by simpa using h.sub hlog apply h'.congr' filter_upwards [hy.eventually_gt_atTop 1, hb] with a hya hba rw [Real.log_mul (ne_of_gt ht) (ne_of_gt (div_pos (by linarith) hba)), Real.log_div (by linarith) (ne_of_gt hba)] field_simp [ne_of_gt (Real.log_pos hya)] ring /- Original line 6513: Erdos416Proof.log_shifted_scaled_core_ratio -/ theorem log_shifted_scaled_core_ratio {α : Type*} {l : Filter α} {y b : α → ℝ} (hy : Tendsto y l atTop) (hb : ∀ᶠ a in l, 0 < b a) (hlog : Tendsto (fun a => Real.log (b a) / Real.log (y a)) l (nhds 0)) {t : ℝ} (ht : 0 < t) : Tendsto (fun a => Real.log (1 + t * (y a / b a)) / Real.log (y a)) l (nhds 1) := by have hg := (core_quotient_tendsto_atTop hy hb hlog).const_mul_atTop ht have hdiff := ((Real.tendsto_log_comp_add_sub_log 1).comp hg).div_atTop (Real.tendsto_log_atTop.comp hy) simp only [Function.comp_apply, add_comm (t * _) 1] at hdiff have h := hdiff.add (log_scaled_core_ratio hy hb hlog ht) simpa only [sub_div, sub_add_cancel, zero_add] using h /- Original line 6527: Erdos416Proof.shifted_scaled_core_ratio -/ theorem shifted_scaled_core_ratio {α : Type*} {l : Filter α} {y b : α → ℝ} (hy : Tendsto y l atTop) (hb : ∀ᶠ a in l, 0 < b a) (hlog : Tendsto (fun a => Real.log (b a) / Real.log (y a)) l (nhds 0)) (t : ℝ) : Tendsto (fun a => (1 + t * (y a / b a)) / (y a / b a)) l (nhds t) := by have h : Tendsto (fun a => 1 / (y a / b a) + t) l (nhds t) := by simpa using ((core_quotient_tendsto_atTop hy hb hlog).const_div_atTop 1).add_const t apply h.congr' filter_upwards [hy.eventually_gt_atTop 0, hb] with a hya hba field_simp [ne_of_gt hya, ne_of_gt hba] /- Original line 6539: Erdos416Proof.primeCountReal -/ noncomputable def primeCountReal (x : ℝ) : ℝ := Nat.primeCounting ⌊x⌋₊ /- Original line 6541: Erdos416Proof.primeCountReal_nonneg -/ theorem primeCountReal_nonneg (x : ℝ) : 0 ≤ primeCountReal x := Nat.cast_nonneg _ /- Original line 6543: Erdos416Proof.primeCountReal_mono -/ theorem primeCountReal_mono : Monotone primeCountReal := by intro x y hxy unfold primeCountReal exact_mod_cast Nat.monotone_primeCounting (Nat.floor_mono hxy) /- Original line 6548: Erdos416Proof.prime_counting_fixed_core_scale -/ theorem prime_counting_fixed_core_scale {α : Type*} {l : Filter α} {y b : α → ℝ} (hy : Tendsto y l atTop) (hb : ∀ᶠ a in l, 0 < b a) (hlog : Tendsto (fun a => Real.log (b a) / Real.log (y a)) l (nhds 0)) {t : ℝ} (ht : 0 < t) : Tendsto (fun a => primeCountReal (1 + t * (y a / b a)) / (y a / (b a * Real.log (y a)))) l (nhds t) := by have hz : Tendsto (fun a => 1 + t * (y a / b a)) l atTop := tendsto_const_nhds.add_atTop ((core_quotient_tendsto_atTop hy hb hlog).const_mul_atTop ht) have h : Tendsto (fun a => ((Nat.primeCounting ⌊1 + t * (y a / b a)⌋₊ : ℝ) / ((1 + t * (y a / b a)) / Real.log (1 + t * (y a / b a)))) * ((1 + t * (y a / b a)) / (y a / b a)) / (Real.log (1 + t * (y a / b a)) / Real.log (y a))) l (nhds t) := by simpa only [Function.comp_apply, Pi.div_apply, one_mul, div_one] using! ((prime_counting_ratio.comp hz).mul (shifted_scaled_core_ratio hy hb hlog t)).div (log_shifted_scaled_core_ratio hy hb hlog ht) (by norm_num) apply h.congr' filter_upwards [hy.eventually_gt_atTop 1, hb, hz.eventually_gt_atTop 1] with a hya hba hza unfold primeCountReal generalize hzval : 1 + t * (y a / b a) = z at hza ⊢ field_simp [ne_of_gt hba, ne_of_gt (Real.log_pos hya), ne_of_gt (Real.log_pos hza), show y a ≠ 0 by linarith, show z ≠ 0 by linarith] /- Original line 6573: Erdos416Proof.prime_counting_small_core_scale -/ theorem prime_counting_small_core_scale {α : Type*} {l : Filter α} {y b s : α → ℝ} (hy : Tendsto y l atTop) (hb : ∀ᶠ a in l, 0 < b a) (hlog : Tendsto (fun a => Real.log (b a) / Real.log (y a)) l (nhds 0)) (hs : Tendsto s l (nhds 0)) : Tendsto (fun a => primeCountReal (1 + s a * (y a / b a)) / (y a / (b a * Real.log (y a)))) l (nhds 0) := by apply tendsto_order.mpr constructor · intro c hc filter_upwards [hy.eventually_gt_atTop 1, hb] with a hya hba exact hc.trans_le (div_nonneg (primeCountReal_nonneg _) (by exact div_nonneg (by linarith) (mul_nonneg hba.le (Real.log_pos hya).le))) · intro c hc have hp := prime_counting_fixed_core_scale hy hb hlog (half_pos hc) filter_upwards [hy.eventually_gt_atTop 1, hb, hs.eventually (gt_mem_nhds (half_pos hc)), hp.eventually (gt_mem_nhds (half_lt_self hc))] with a hya hba hsa hpa apply lt_of_le_of_lt _ hpa apply div_le_div_of_nonneg_right _ (by exact div_nonneg (by linarith) (mul_nonneg hba.le (Real.log_pos hya).le)) apply primeCountReal_mono exact add_le_add_right (mul_le_mul_of_nonneg_right hsa.le (div_nonneg (show 0 ≤ y a by linarith) hba.le)) 1 /-- All real cores in the prescribed logarithmic range, with a single eventual threshold in the scale variable. This permits core families to vary with y. -/ /- Original line 6600: Erdos416Proof.coreScaleFilter -/ def coreScaleFilter (G : ℝ → ℝ) : Filter (ℝ × ℝ) := Filter.comap Prod.fst atTop ⊓ Filter.principal {z | 1 ≤ z.2 ∧ Real.log z.2 ≤ G z.1} /- Original line 6603: Erdos416Proof.coreScaleFilter_eventually_iff -/ theorem coreScaleFilter_eventually_iff (G : ℝ → ℝ) (P : ℝ × ℝ → Prop) : (∀ᶠ z in coreScaleFilter G, P z) ↔ ∀ᶠ y : ℝ in atTop, ∀ b : ℝ, 1 ≤ b → Real.log b ≤ G y → P (y, b) := by rw [coreScaleFilter, eventually_inf_principal, eventually_comap] constructor · intro h exact h.mono fun y hy b hb hGb => hy (y, b) rfl ⟨hb, hGb⟩ · intro h exact h.mono fun y hy z hz ⟨hb, hGb⟩ => by rcases z with ⟨x, b⟩ dsimp at hz hb hGb ⊢ subst x exact hy b hb hGb /- Original line 6617: Erdos416Proof.coreScaleFilter_tendsto_fst -/ theorem coreScaleFilter_tendsto_fst (G : ℝ → ℝ) : Tendsto Prod.fst (coreScaleFilter G) atTop := tendsto_comap.mono_left inf_le_left /- Original line 6621: Erdos416Proof.coreScaleFilter_bounds -/ theorem coreScaleFilter_bounds (G : ℝ → ℝ) : ∀ᶠ z in coreScaleFilter G, 1 ≤ z.2 ∧ Real.log z.2 ≤ G z.1 := by rw [coreScaleFilter_eventually_iff] exact Eventually.of_forall fun y b hb hGb => ⟨hb, hGb⟩ /- Original line 6626: Erdos416Proof.coreScaleFilter_log_ratio -/ theorem coreScaleFilter_log_ratio {G : ℝ → ℝ} (hG : Tendsto (fun y => G y / Real.log y) atTop (nhds 0)) : Tendsto (fun z : ℝ × ℝ => Real.log z.2 / Real.log z.1) (coreScaleFilter G) (nhds 0) := by have hy := coreScaleFilter_tendsto_fst G apply tendsto_const_nhds.squeeze' (hG.comp hy) · filter_upwards [coreScaleFilter_bounds G, hy.eventually_gt_atTop 1] with z hz hzy exact div_nonneg (Real.log_nonneg hz.1) (Real.log_pos hzy).le · filter_upwards [coreScaleFilter_bounds G, hy.eventually_gt_atTop 1] with z hz hzy exact (div_le_div_iff_of_pos_right (Real.log_pos hzy)).mpr hz.2 /- Original line 6636: Erdos416Proof.prime_counting_core_interval_uniform -/ theorem prime_counting_core_interval_uniform {G s : ℝ → ℝ} (hG : Tendsto (fun y => G y / Real.log y) atTop (nhds 0)) (hs : Tendsto s atTop (nhds 0)) {t : ℝ} (ht : 0 < t) {ε : ℝ} (hε : 0 < ε) : ∀ᶠ y : ℝ in atTop, ∀ b : ℝ, 1 ≤ b → Real.log b ≤ G y → |(primeCountReal (1 + t * (y / b)) - primeCountReal (1 + s y * (y / b))) / (y / (b * Real.log y)) - t| < ε := by have hy := coreScaleFilter_tendsto_fst G have hb : ∀ᶠ z in coreScaleFilter G, 0 < z.2 := (coreScaleFilter_bounds G).mono fun z hz => lt_of_lt_of_le zero_lt_one hz.1 have hlog := coreScaleFilter_log_ratio hG have h := (prime_counting_fixed_core_scale hy hb hlog ht).sub (prime_counting_small_core_scale hy hb hlog (hs.comp hy)) have he := (Metric.tendsto_nhds.mp h) ε hε apply (coreScaleFilter_eventually_iff G (fun z => |(primeCountReal (1 + t * (z.1 / z.2)) - primeCountReal (1 + s z.1 * (z.1 / z.2))) / (z.1 / (z.2 * Real.log z.1)) - t| < ε)).mp simpa only [Real.dist_eq, Function.comp_apply, sub_zero, ← sub_div] using he /- Original line 6655: Erdos416Proof.logCoreBound -/ noncomputable def logCoreBound (R A θ y : ℝ) : ℝ := Real.log R + A * Real.log (Real.log (Real.log y)) * (Real.log y) ^ θ /- Original line 6658: Erdos416Proof.logCoreBound_small -/ theorem logCoreBound_small (R A : ℝ) {θ : ℝ} (hθ : θ < 1) : Tendsto (fun y => logCoreBound R A θ y / Real.log y) atTop (nhds 0) := by have hmajor : Tendsto (fun z : ℝ => Real.log z * z ^ θ / z) atTop (nhds 0) := by simpa only [pow_one, Real.rpow_one] using (log_pow_mul_rpow_littleO 1 hθ).tendsto_div_nhds_zero have hminor : Tendsto (fun z : ℝ => Real.log (Real.log z) * z ^ θ / z) atTop (nhds 0) := by apply tendsto_const_nhds.squeeze' hmajor · filter_upwards [Real.tendsto_log_atTop.eventually_ge_atTop 1, eventually_gt_atTop (0 : ℝ)] with z hlog hz exact div_nonneg (mul_nonneg (Real.log_nonneg hlog) (Real.rpow_nonneg hz.le _)) hz.le · filter_upwards [eventually_gt_atTop (0 : ℝ), Real.tendsto_log_atTop.eventually_ge_atTop 1] with z hz hlog exact div_le_div_of_nonneg_right (mul_le_mul_of_nonneg_right (Real.log_le_self (by linarith)) (Real.rpow_nonneg hz.le _)) hz.le have h := (Real.tendsto_log_atTop.const_div_atTop (Real.log R)).add ((hminor.comp Real.tendsto_log_atTop).const_mul A) convert h using 1 · funext y dsimp [logCoreBound] ring · simp /- Original line 6682: Erdos416Proof.coreLowerFraction -/ noncomputable def coreLowerFraction (y : ℝ) : ℝ := 1 / Real.sqrt (Real.log (Real.log y)) /- Original line 6685: Erdos416Proof.coreLowerFraction_tendsto -/ theorem coreLowerFraction_tendsto : Tendsto coreLowerFraction atTop (nhds 0) := (Real.tendsto_sqrt_atTop.comp (Real.tendsto_log_atTop.comp Real.tendsto_log_atTop)).const_div_atTop 1 /- Original line 6689: Erdos416Proof.coreLowerFraction_nonneg -/ theorem coreLowerFraction_nonneg (y : ℝ) : 0 ≤ coreLowerFraction y := by exact div_nonneg zero_le_one (Real.sqrt_nonneg _) /- Original line 6692: Erdos416Proof.core_prime_interval_uniform -/ theorem core_prime_interval_uniform (R A : ℝ) {θ : ℝ} (hθ : θ < 1) {t ε : ℝ} (ht : 0 < t) (hε : 0 < ε) : ∀ᶠ y : ℝ in atTop, ∀ b : ℝ, 1 ≤ b → Real.log b ≤ logCoreBound R A θ y → |(primeCountReal (1 + t * (y / b)) - primeCountReal (1 + coreLowerFraction y * (y / b))) / (y / (b * Real.log y)) - t| < ε := prime_counting_core_interval_uniform (logCoreBound_small R A hθ) coreLowerFraction_tendsto ht hε /- Original line 6701: Erdos416Proof.corePairValue_bounds_iff -/ theorem corePairValue_bounds_iff {b p : ℕ} (hb : 0 < b) (hp : p.Prime) (lo hi : ℝ) : (lo < (corePairValue (b, p) : ℝ) ∧ (corePairValue (b, p) : ℝ) ≤ hi) ↔ 1 + lo / b < (p : ℝ) ∧ (p : ℝ) ≤ 1 + hi / b := by have hbR : (0 : ℝ) < b := by exact_mod_cast hb have hval : (corePairValue (b, p) : ℝ) = ((p : ℝ) - 1) * b := by simp only [corePairValue, Nat.cast_mul, Nat.cast_sub hp.one_le, Nat.cast_one] rw [hval] constructor · rintro ⟨hl, hu⟩ constructor · have := (div_lt_iff₀ hbR).mpr hl linarith · have := (le_div_iff₀ hbR).mpr hu linarith · rintro ⟨hl, hu⟩ constructor · exact (div_lt_iff₀ hbR).mp (by linarith) · exact (le_div_iff₀ hbR).mp (by linarith) /- Original line 6720: Erdos416Proof.corePairs_card_prime_count -/ theorem corePairs_card_prime_count {cores : Finset ℕ} {lo hi : ℝ} (hcores : ∀ b ∈ cores, 0 < b) (hlo : 0 ≤ lo) (hhi : lo ≤ hi) : ((corePairs cores lo hi).card : ℝ) = ∑ b ∈ cores, (primeCountReal (1 + hi / b) - primeCountReal (1 + lo / b)) := by classical have hhipos : 0 ≤ hi := hlo.trans hhi have hmap : ∀ bp ∈ corePairs cores lo hi, bp.1 ∈ cores := by intro bp hbp exact ((mem_corePairs hhipos hcores).mp hbp).1 rw [Finset.card_eq_sum_card_fiberwise hmap, Nat.cast_sum] apply Finset.sum_congr rfl intro b hb have hbpos := hcores b hb have hbR : (0 : ℝ) < b := by exact_mod_cast hbpos have hl : 0 ≤ 1 + lo / (b : ℝ) := by positivity have hu : 0 ≤ 1 + hi / (b : ℝ) := by positivity have hlu : 1 + lo / (b : ℝ) ≤ 1 + hi / (b : ℝ) := by gcongr have hprimes : Nat.primesLE ⌊1 + lo / (b : ℝ)⌋₊ ⊆ Nat.primesLE ⌊1 + hi / (b : ℝ)⌋₊ := Nat.primesLE_mono (Nat.floor_mono hlu) have hcard : ((corePairs cores lo hi).filter (fun bp => bp.1 = b)).card = ((Nat.primesLE ⌊1 + hi / (b : ℝ)⌋₊) \ Nat.primesLE ⌊1 + lo / (b : ℝ)⌋₊).card := by apply Finset.card_bij (fun bp _ => bp.2) · intro bp hbp obtain ⟨hbp, hbEq⟩ := Finset.mem_filter.mp hbp obtain ⟨_, hp, hlv, huv⟩ := (mem_corePairs hhipos hcores).mp hbp rcases bp with ⟨b', p⟩ dsimp at hbEq subst b' obtain ⟨hlp, hup⟩ := (corePairValue_bounds_iff hbpos hp lo hi).mp ⟨hlv, huv⟩ simp only [Finset.mem_sdiff, Nat.mem_primesLE, Nat.le_floor_iff hu, Nat.le_floor_iff hl] exact ⟨⟨hup, hp⟩, fun h => (not_le_of_gt hlp) h.1⟩ · intro a ha b' hb' hpEq apply Prod.ext _ hpEq exact (Finset.mem_filter.mp ha).2.trans (Finset.mem_filter.mp hb').2.symm · intro p hp simp only [Finset.mem_sdiff, Nat.mem_primesLE, Nat.le_floor_iff hu, Nat.le_floor_iff hl] at hp have hlp : 1 + lo / (b : ℝ) < p := lt_of_not_ge fun h => hp.2 ⟨h, hp.1.2⟩ have hv := (corePairValue_bounds_iff hbpos hp.1.2 lo hi).mpr ⟨hlp, hp.1.1⟩ refine ⟨(b, p), Finset.mem_filter.mpr ⟨?_, rfl⟩, rfl⟩ exact (mem_corePairs hhipos hcores).mpr ⟨hb, hp.1.2, hv.1, hv.2⟩ rw [hcard, Finset.card_sdiff_of_subset hprimes, Nat.cast_sub (Finset.card_le_card hprimes)] simp only [Nat.primesLE_card_eq_primeCounting, primeCountReal] /- Original line 6764: Erdos416Proof.finite_weighted_ratio_bound -/ theorem finite_weighted_ratio_bound {ι : Type*} {s : Finset ι} {f w : ι → ℝ} {t ε : ℝ} (hw : ∀ idx ∈ s, 0 < w idx) (hs : s.Nonempty) (hf : ∀ idx ∈ s, |f idx / w idx - t| ≤ ε) : |(∑ idx ∈ s, f idx) / (∑ idx ∈ s, w idx) - t| ≤ ε := by have hsum : 0 < ∑ idx ∈ s, w idx := Finset.sum_pos hw hs have hbounds : ∀ idx ∈ s, (t - ε) * w idx ≤ f idx ∧ f idx ≤ (t + ε) * w idx := by intro idx hi obtain ⟨hl, hu⟩ := abs_le.mp (hf idx hi) exact ⟨(le_div_iff₀ (hw idx hi)).mp (by linarith), (div_le_iff₀ (hw idx hi)).mp (by linarith)⟩ have hl := Finset.sum_le_sum fun idx hi => (hbounds idx hi).1 have hu := Finset.sum_le_sum fun idx hi => (hbounds idx hi).2 rw [← Finset.mul_sum] at hl hu exact abs_le.mpr ⟨by have := (le_div_iff₀ hsum).mpr hl; linarith, by have := (div_le_iff₀ hsum).mpr hu; linarith⟩ /- Original line 6780: Erdos416Proof.corePrimeMass -/ noncomputable def corePrimeMass (cores : Finset ℕ) (y : ℝ) : ℝ := ∑ b ∈ cores, y / ((b : ℝ) * Real.log y) /- Original line 6783: Erdos416Proof.corePrimeMass_eq -/ theorem corePrimeMass_eq (cores : Finset ℕ) (y : ℝ) : corePrimeMass cores y = y / Real.log y * ∑ b ∈ cores, 1 / (b : ℝ) := by rw [Finset.mul_sum] apply Finset.sum_congr rfl intro b hb ring /- Original line 6790: Erdos416Proof.corePrimeMass_pos -/ theorem corePrimeMass_pos {cores : Finset ℕ} (hc : ∀ b ∈ cores, 0 < b) (hn : cores.Nonempty) {y : ℝ} (hy : 1 < y) : 0 < corePrimeMass cores y := by apply Finset.sum_pos _ hn intro b hb have hbR : (0 : ℝ) < b := by exact_mod_cast hc b hb exact div_pos (by linarith) (mul_pos hbR (Real.log_pos hy)) /- Original line 6797: Erdos416Proof.corePairs_count_asymptotic -/ theorem corePairs_count_asymptotic {C : ℝ → Finset ℕ} {G s : ℝ → ℝ} (hG : Tendsto (fun y => G y / Real.log y) atTop (nhds 0)) (hs : Tendsto s atTop (nhds 0)) (hspos : ∀ᶠ y in atTop, 0 ≤ s y) (hC : ∀ᶠ y in atTop, ∀ b ∈ C y, 0 < b ∧ Real.log b ≤ G y) (hn : ∀ᶠ y in atTop, (C y).Nonempty) {t : ℝ} (ht : 0 < t) : Tendsto (fun y => ((corePairs (C y) (s y * y) (t * y)).card : ℝ) / corePrimeMass (C y) y) atTop (nhds t) := by apply Metric.tendsto_nhds.mpr intro ε hε filter_upwards [prime_counting_core_interval_uniform hG hs ht (half_pos hε), hC, hn, eventually_gt_atTop (1 : ℝ), hspos, hs.eventually (gt_mem_nhds ht)] with y huniform hCy hny hy hs0 hst have hc : ∀ b ∈ C y, 0 < b := fun b hb => (hCy b hb).1 have hyl : 0 ≤ s y * y := mul_nonneg hs0 (by linarith) have hlu : s y * y ≤ t * y := mul_le_mul_of_nonneg_right hst.le (by linarith) rw [Real.dist_eq, corePairs_card_prime_count hc hyl hlu] apply lt_of_le_of_lt (finite_weighted_ratio_bound (w := fun b : ℕ => y / ((b : ℝ) * Real.log y)) (s := C y) ?_ hny ?_) (half_lt_self hε) · intro b hb have hbR : (0 : ℝ) < b := by exact_mod_cast hc b hb exact div_pos (by linarith) (mul_pos hbR (Real.log_pos hy)) · intro b hb have hb1 : (1 : ℝ) ≤ b := by exact_mod_cast hc b hb simpa only [mul_div_assoc] using (huniform b hb1 (hCy b hb).2).le /-- PNT supplies the ratio of the actual pair counts for any nonempty varying core family satisfying the manuscript's uniform size bound. Coverage and collision control are separate obligations before this implies a limit for V. -/ /- Original line 6825: Erdos416Proof.corePairs_doubling_ratio -/ theorem corePairs_doubling_ratio {C : ℝ → Finset ℕ} (R A : ℝ) {θ : ℝ} (hθ : θ < 1) (hC : ∀ᶠ y in atTop, ∀ b ∈ C y, 0 < b ∧ Real.log b ≤ logCoreBound R A θ y) (hn : ∀ᶠ y in atTop, (C y).Nonempty) : Tendsto (fun y => ((corePairs (C y) (coreLowerFraction y * y) y).card : ℝ) / ((corePairs (C y) (coreLowerFraction y * y) (y / 2)).card : ℝ)) atTop (nhds 2) := by have hpos : ∀ᶠ y in atTop, 0 ≤ coreLowerFraction y := Eventually.of_forall coreLowerFraction_nonneg have h₁ := corePairs_count_asymptotic (logCoreBound_small R A hθ) coreLowerFraction_tendsto hpos hC hn (show (0 : ℝ) < 1 by norm_num) have h₂ := corePairs_count_asymptotic (logCoreBound_small R A hθ) coreLowerFraction_tendsto hpos hC hn (show (0 : ℝ) < 1 / 2 by norm_num) have h := h₁.div h₂ (by norm_num : (1 / 2 : ℝ) ≠ 0) have h' : Tendsto (fun y => (((corePairs (C y) (coreLowerFraction y * y) y).card : ℝ) / corePrimeMass (C y) y) / (((corePairs (C y) (coreLowerFraction y * y) (y / 2)).card : ℝ) / corePrimeMass (C y) y)) atTop (nhds 2) := by simpa only [one_mul, one_div, inv_mul_eq_div, one_div_div, inv_inv] using! h apply h'.congr' filter_upwards [hC, hn, eventually_gt_atTop (1 : ℝ)] with y hCy hny hy exact div_div_div_cancel_right₀ (ne_of_gt (corePrimeMass_pos (fun b hb => (hCy b hb).1) hny hy)) _ _ /- Original line 6850: Erdos416Proof.logCoreBound_of_size -/ theorem logCoreBound_of_size {R A θ y : ℝ} (hR : 0 < R) {b : ℕ} (hb : 0 < b) (hsize : (b : ℝ) ≤ R * Real.exp (A * Real.log (Real.log (Real.log y)) * (Real.log y) ^ θ)) : Real.log b ≤ logCoreBound R A θ y := by have hbR : (0 : ℝ) < b := by exact_mod_cast hb have h := Real.log_le_log hbR hsize simpa only [Real.log_mul (ne_of_gt hR) (ne_of_gt (Real.exp_pos _)), Real.log_exp, logCoreBound] using h /- Original line 6858: Erdos416Proof.corePairs_doubling_ratio_of_size_bound -/ theorem corePairs_doubling_ratio_of_size_bound {C : ℝ → Finset ℕ} {R : ℝ} (hR : 0 < R) (A : ℝ) {θ : ℝ} (hθ : θ < 1) (hC : ∀ᶠ y in atTop, ∀ b ∈ C y, 0 < b ∧ (b : ℝ) ≤ R * Real.exp (A * Real.log (Real.log (Real.log y)) * (Real.log y) ^ θ)) (hn : ∀ᶠ y in atTop, (C y).Nonempty) : Tendsto (fun y => ((corePairs (C y) (y / Real.sqrt (Real.log (Real.log y))) y).card : ℝ) / ((corePairs (C y) (y / Real.sqrt (Real.log (Real.log y))) (y / 2)).card : ℝ)) atTop (nhds 2) := by have hClog : ∀ᶠ y in atTop, ∀ b ∈ C y, 0 < b ∧ Real.log b ≤ logCoreBound R A θ y := hC.mono fun y hy b hb => ⟨(hy b hb).1, logCoreBound_of_size hR (hy b hb).1 (hy b hb).2⟩ simpa only [coreLowerFraction, one_div, inv_mul_eq_div] using corePairs_doubling_ratio R A hθ hClog hn /- Original line 6872: Erdos416Proof.primeCountReal_le_V -/ theorem primeCountReal_le_V {x : ℝ} (hx : 0 ≤ x) : primeCountReal x ≤ V x := by have hcard : (Nat.primesLE ⌊x⌋₊).card ≤ (totientsUpTo x).card := by apply Finset.card_le_card_of_injOn (fun p : ℕ => p - 1) · intro p hp obtain ⟨hpx, hpprime⟩ := Nat.mem_primesLE.mp hp have hp1 := hpprime.one_lt refine (mem_totientsUpTo hx).mpr ⟨Nat.sub_pos_of_lt hp1, ?_, p, hpprime.pos, Nat.totient_prime hpprime⟩ have hpr : (p : ℝ) ≤ x := (Nat.le_floor_iff hx).mp hpx have hle : ((p - 1 : ℕ) : ℝ) ≤ p := by exact_mod_cast Nat.sub_le p 1 exact hle.trans hpr · intro p hp q hq heq have hp1 := Nat.one_lt_of_mem_primesLE hp have hq1 := Nat.one_lt_of_mem_primesLE hq change p - 1 = q - 1 at heq omega simpa only [Nat.primesLE_card_eq_primeCounting, primeCountReal, V] using (show ((Nat.primesLE ⌊x⌋₊).card : ℝ) ≤ (totientsUpTo x).card by exact_mod_cast hcard) /- Original line 6891: Erdos416Proof.V_lower_bound_eventually -/ theorem V_lower_bound_eventually : ∀ᶠ x : ℝ in atTop, x / (2 * Real.log x) ≤ V x := by filter_upwards [eventually_gt_atTop (1 : ℝ), prime_counting_ratio.eventually (lt_mem_nhds (by norm_num : (1 / 2 : ℝ) < 1))] with x hx hp have hmain : 0 < x / Real.log x := div_pos (by linarith) (Real.log_pos hx) have h := ((lt_div_iff₀ hmain).mp hp).le.trans (primeCountReal_le_V (by linarith)) calc x / (2 * Real.log x) = (1 / 2 : ℝ) * (x / Real.log x) := by ring _ ≤ V x := h /- Original line 6902: Erdos416Proof.exists_primeCountReal_upper_bound -/ theorem exists_primeCountReal_upper_bound : ∃ C : ℝ, 0 < C ∧ ∀ x : ℝ, 2 ≤ x → primeCountReal x ≤ C * x / Real.log x := by obtain ⟨X, hX⟩ := eventually_atTop.mp (prime_counting_ratio.eventually (gt_mem_nhds (by norm_num : (1 : ℝ) < 2))) let Z : ℝ := max 2 X let C : ℝ := primeCountReal Z + 2 have hC : 2 ≤ C := by dsimp [C]; linarith [primeCountReal_nonneg Z] refine ⟨C, by linarith, ?_⟩ intro x hx have hx1 : 1 < x := by linarith have hx0 : 0 < x := by linarith have hmain : 0 < x / Real.log x := div_pos hx0 (Real.log_pos hx1) rw [mul_div_assoc] by_cases hZx : Z ≤ x · have hp := hX x ((le_max_right 2 X).trans hZx) exact ((div_lt_iff₀ hmain).mp hp).le.trans (mul_le_mul_of_nonneg_right hC hmain.le) · have hp : primeCountReal x ≤ C := by have := primeCountReal_mono (le_of_not_ge hZx) dsimp [C] linarith have hratio : 1 ≤ x / Real.log x := by apply (le_div_iff₀ (Real.log_pos hx1)).mpr simpa only [one_mul] using Real.log_le_self hx0.le exact hp.trans (by nlinarith) end Erdos416Proof /- Adapted from AlexKontorovich/PrimeNumberTheoremAnd, Apache-2.0. Pinned revision: a5154676af9aa3095150ee410cdda80555aa0642. See PNT-LICENSE.txt and work/prepare_mertens_port.py for provenance. Ported to Lean 4.33.1 and checked with no added axioms. -/ section MertensDependencyPort /- Source module: EulerMaclaurin -/ section MertensSource_0 /- We prove the 1st order Euler-Maclaurin formula by specialising Abel summation and manipulating integrals. -/ open Finset Interval MeasureTheory variable {𝕜 : Type*} [RCLike 𝕜] {f : ℝ → 𝕜} {a b : ℝ} /-- The 1st Bernoulli function. -/ /- Original line 6955: B1 -/ noncomputable def B1 (x : ℝ) : ℝ := x - ⌊x⌋₊ - 1 / 2 /- Original line 6957: aestronglyMeasurable_B1 -/ theorem aestronglyMeasurable_B1 : AEStronglyMeasurable B1 := by unfold B1 fun_prop /- Original line 6962: abs_B1_le_half -/ theorem abs_B1_le_half {x : ℝ} (hx : 0 ≤ x) : |B1 x| ≤ 1 / 2 := by unfold B1 refine abs_le.mpr ⟨?_, ?_⟩ · grind [Nat.floor_le hx] · grind [Nat.lt_succ_floor x] /- Original line 6968: integral_deriv_mul_add_const -/ theorem integral_deriv_mul_add_const (c : 𝕜) (hab : a ≤ b) (h_int : IntervalIntegrable (deriv f) volume a b) (hf_diff : ∀ t ∈ Set.Icc a b, DifferentiableAt ℝ f t) : ∫ t in a..b, (t + c) * deriv f t = (b + c) * f b - (a + c) * f a - ∫ t in a..b, f t := by rw [← Set.uIcc_of_le hab] at hf_diff have : ∀ t ∈ [[a, b]], HasDerivAt (fun (t : ℝ) ↦ t + c) 1 t := by intro t ht simp only [hasDerivAt_add_const_iff] convert! ContinuousLinearMap.hasDerivAt (RCLike.ofRealCLM (K := 𝕜)) using 1 simp replace hf_diff := fun t ht ↦ (hf_diff t ht).hasDerivAt rw [intervalIntegral.integral_mul_deriv_eq_deriv_mul this hf_diff (by simp) h_int] simp /- Original line 6981: intervalIntegrable_deriv_mul_B1 -/ theorem intervalIntegrable_deriv_mul_B1 (ha : 0 ≤ a) (hab : a ≤ b) (h_cont : ContinuousOn (deriv f) [[a, b]]) : IntervalIntegrable (fun t ↦ deriv f t * B1 t) volume a b := by refine IntervalIntegrable.continuousOn_mul ?_ h_cont rw [intervalIntegrable_iff'] apply MeasureTheory.Measure.integrableOn_of_bounded (by simp) (by have hB1 := aestronglyMeasurable_B1; fun_prop) (M := 1 / 2) filter_upwards [self_mem_ae_restrict (by measurability)] with x hx rw [Set.uIcc_of_le hab, Set.mem_Icc] at hx norm_cast exact abs_B1_le_half (by linarith) /- Original line 6991: integral_deriv_mul_floor_add_one -/ theorem integral_deriv_mul_floor_add_one (ha : 0 ≤ a) (hab : a ≤ b) (hf_diff : ∀ t ∈ Set.Icc a b, DifferentiableAt ℝ f t) (h_cont : ContinuousOn (deriv f) [[a, b]]) : ∫ t in a..b, deriv f t * (⌊t⌋₊ + 1) = (b + 1 / 2) * f b - (a + 1 / 2) * f a - (∫ t in a..b, f t) - ∫ t in a..b, deriv f t * B1 t := by calc _ = ∫ t in a..b, (deriv f t * (t + 1 / 2) -deriv f t * B1 t) := by congr ext simp only [B1] push_cast ring _ = (∫ t in a..b, deriv f t * (t + 1 / 2)) - ∫ t in a..b, deriv f t * B1 t := by exact intervalIntegral.integral_sub (ContinuousOn.intervalIntegrable (by fun_prop)) (intervalIntegrable_deriv_mul_B1 ha hab h_cont) _ = _ := by conv => lhs; arg 1; arg 1; ext; rw [mul_comm] rw [integral_deriv_mul_add_const _ hab h_cont.intervalIntegrable hf_diff] /- Original line 7007: sum_eq_integral_add_integral_deriv -/ theorem sum_eq_integral_add_integral_deriv (ha : 0 ≤ a) (hab : a ≤ b) (hf_diff : ∀ t ∈ Set.Icc a b, DifferentiableAt ℝ f t) (h_cont : ContinuousOn (deriv f) [[a, b]]) : ∑ k ∈ Ioc ⌊a⌋₊ ⌊b⌋₊, f k = f a * B1 a - f b * B1 b + (∫ t in a..b, f t) + ∫ t in a..b, deriv f t * B1 t := by have := sum_mul_eq_sub_sub_integral_mul (fun _ ↦ 1) ha hab hf_diff (Set.uIcc_of_le hab ▸ h_cont).integrableOn_Icc simp only [mul_one, sum_const, Nat.card_Icc, tsub_zero, nsmul_eq_mul, Nat.cast_add, Nat.cast_one] at this rw [this, ← intervalIntegral.integral_of_le hab] rw [integral_deriv_mul_floor_add_one ha hab hf_diff h_cont] unfold B1 push_cast ring end MertensSource_0 /- Source module: IEANTN/Mertens -/ section MertensSource_1 /- Original line 7027: Filter.EventuallyEq.iff_eventually -/ theorem Filter.EventuallyEq.iff_eventually {α : Type _} {β : Type _} {l : Filter α} {f g : α → β} : f =ᶠ[l] g ↔ ∀ᶠ (x : α) in l, f x = g x := by rfl namespace Real open Filter Asymptotics /- Original line 7034: Real.inv_log_eq_o_one -/ theorem inv_log_eq_o_one : (fun x ↦ 1 / log x) =o[atTop] (fun _ ↦ (1:ℝ)) := by rw [isLittleO_one_iff] convert tendsto_log_atTop.inv_tendsto_atTop using 1 ext; simp /- Original line 7039: Real.one_eq_o_log_log -/ theorem one_eq_o_log_log : (fun _ ↦ (1:ℝ)) =o[atTop] (fun x ↦ log (log x)) := by simp only [isLittleO_one_left_iff, norm_eq_abs] exact tendsto_abs_atTop_atTop.comp (tendsto_log_atTop.comp tendsto_log_atTop) end Real section Issue1584 open MeasureTheory Set Filter Topology /-- The integrand `log v * exp (-v)` is integrable on `Ioi 0`. -/ /- Original line 7049: integrableOn_log_mul_exp_neg -/ private theorem integrableOn_log_mul_exp_neg : IntegrableOn (fun v : ℝ => Real.log v * Real.exp (-v)) (Ioi 0) := by rw [← Set.Ioc_union_Ioi_eq_Ioi (zero_le_one' ℝ), integrableOn_union] constructor · -- On `Ioc 0 1`: dominate by `|log v|`, which is integrable. have hlog : IntegrableOn (fun v : ℝ => Real.log v) (Ioc 0 1) volume := by have := (intervalIntegral.intervalIntegrable_log' (a := 0) (b := 1)) rwa [intervalIntegrable_iff_integrableOn_Ioc_of_le (zero_le_one' ℝ)] at this apply Integrable.mono' hlog.norm · apply (Measurable.aestronglyMeasurable ?_) exact (Real.measurable_log.mul (Real.measurable_exp.comp measurable_neg)) · filter_upwards [self_mem_ae_restrict measurableSet_Ioc] with v hv rw [norm_mul, Real.norm_eq_abs, Real.norm_eq_abs] have h1 : |Real.exp (-v)| = Real.exp (-v) := abs_of_pos (Real.exp_pos _) have h2 : Real.exp (-v) ≤ 1 := Real.exp_le_one_iff.mpr (by linarith [hv.1]) rw [h1] nlinarith [abs_nonneg (Real.log v), Real.exp_pos (-v)] · -- On `Ioi 1`: dominate by `2 * exp (-v/2)`, integrable. have hexp : IntegrableOn (fun v : ℝ => (2 : ℝ) * Real.exp ((-1/2) * v)) (Ioi 1) volume := by exact (integrableOn_exp_mul_Ioi (by norm_num : (-1/2 : ℝ) < 0) 1).const_mul 2 apply Integrable.mono' hexp · apply (Measurable.aestronglyMeasurable ?_) exact (Real.measurable_log.mul (Real.measurable_exp.comp measurable_neg)) · filter_upwards [self_mem_ae_restrict measurableSet_Ioi] with v hv have hv1 : (1 : ℝ) ≤ v := le_of_lt hv have hvpos : (0 : ℝ) < v := by linarith rw [norm_mul, Real.norm_eq_abs, Real.norm_eq_abs] have hlogabs : |Real.log v| = Real.log v := abs_of_nonneg (Real.log_nonneg hv1) have hexpabs : |Real.exp (-v)| = Real.exp (-v) := abs_of_pos (Real.exp_pos _) rw [hlogabs, hexpabs] -- `log v ≤ v` have hlogv : Real.log v ≤ v := (Real.log_le_sub_one_of_pos hvpos).trans (by linarith) -- `v ≤ 2 * exp (v/2)` have hvexp : v ≤ 2 * Real.exp (v/2) := by have := Real.add_one_le_exp (v/2) nlinarith [Real.exp_pos (v/2)] -- combine: log v * exp(-v) ≤ v * exp(-v) ≤ 2 exp(v/2) exp(-v) = 2 exp(-v/2) have hstep : Real.log v * Real.exp (-v) ≤ 2 * Real.exp (v/2) * Real.exp (-v) := by apply mul_le_mul_of_nonneg_right (hlogv.trans hvexp) (le_of_lt (Real.exp_pos _)) have heq : 2 * Real.exp (v/2) * Real.exp (-v) = 2 * Real.exp ((-1/2) * v) := by rw [mul_assoc, ← Real.exp_add] ring_nf rw [heq] at hstep exact hstep /-- Helper: `∫_0^∞ log t · e^{-t} dt = Γ'(1)` (real). -/ /- Original line 7096: integral_log_mul_exp_neg_eq_deriv_Gamma -/ private theorem integral_log_mul_exp_neg_eq_deriv_Gamma : ∫ t in Ioi (0:ℝ), Real.log t * Real.exp (-t) = deriv Real.Gamma 1 := by set I : ℝ := ∫ t in Ioi (0:ℝ), Real.log t * Real.exp (-t) with hI -- Step 1: derivative of GammaIntegral at 1. have h1 := Complex.hasDerivAt_GammaIntegral (s := (1 : ℂ)) (by norm_num) -- Step 2: simplify the integrand to `↑(log t * exp (-t))` and pull out `ofReal`. have hval : (∫ t : ℝ in Ioi 0, (↑t : ℂ) ^ ((1 : ℂ) - 1) * (↑(Real.log t) * ↑(Real.exp (-t)))) = (I : ℂ) := by have key : ∀ t : ℝ, (↑t : ℂ) ^ ((1 : ℂ) - 1) * (↑(Real.log t) * ↑(Real.exp (-t))) = ((Real.log t * Real.exp (-t) : ℝ) : ℂ) := by intro t rw [sub_self, Complex.cpow_zero, one_mul, Complex.ofReal_mul] simp_rw [key] rw [integral_complex_ofReal, hI] rw [hval] at h1 -- Step 3: transfer to Complex.Gamma (agrees with GammaIntegral on `{re > 0}`). have h2 : HasDerivAt Complex.Gamma (I : ℂ) 1 := by apply h1.congr_of_eventuallyEq filter_upwards [(isOpen_lt continuous_const Complex.continuous_re).mem_nhds (show (0:ℝ) < (1:ℂ).re by norm_num)] with z hz exact Complex.Gamma_eq_integral hz -- Step 4: transfer ℂ → ℝ. have h3 := h2.real_of_complex have h4 : HasDerivAt Real.Gamma I 1 := by have hcongr : (fun x : ℝ => (Complex.Gamma ↑x).re) = Real.Gamma := by funext x rw [Complex.Gamma_ofReal, Complex.ofReal_re] rw [hcongr, Complex.ofReal_re] at h3 exact h3 rw [← h4.deriv] /-- Core of #1584, stated with explicit qualifiers (outside `namespace Mertens`, where `Finset` is open and would clash with `Set.Ioi`). -/ /- Original line 7129: mul_integ_log_log_eq_aux -/ private theorem mul_integ_log_log_eq_aux (s : ℝ) (hs : 1 < s) : (s - 1) * ∫ x in Ioi (1:ℝ), Real.log (Real.log x) * x ^ (-s) = - Real.log (s - 1) + deriv Real.Gamma 1 := by have hs0 : 0 < s - 1 := by linarith set f : ℝ → ℝ := fun x => (s - 1) * Real.log x with hf_def set f' : ℝ → ℝ := fun x => (s - 1) / x with hf'_def set g : ℝ → ℝ := fun u => (Real.log u - Real.log (s - 1)) * Real.exp (-u) with hg_def -- f 1 = 0 have hf1 : f 1 = 0 := by simp [hf_def] -- ContinuousOn f (Ici 1) have hf_cont : ContinuousOn f (Ici 1) := by apply ContinuousOn.mul continuousOn_const apply Real.continuousOn_log.mono intro x hx simp only [mem_Ici] at hx simp only [Set.mem_compl_iff, Set.mem_singleton_iff] linarith -- Tendsto f atTop atTop have hft : Tendsto f atTop atTop := by apply Filter.Tendsto.const_mul_atTop hs0 exact Real.tendsto_log_atTop -- HasDerivWithinAt f (f' x) (Ioi x) x for x ∈ Ioi 1 have hff' : ∀ x ∈ Ioi (1:ℝ), HasDerivWithinAt f (f' x) (Ioi x) x := by intro x hx simp only [mem_Ioi] at hx have hxne : x ≠ 0 := by linarith have := (Real.hasDerivAt_log hxne).const_mul (s - 1) have h2 : HasDerivAt f ((s - 1) * x⁻¹) x := this have : (s - 1) * x⁻¹ = f' x := by rw [hf'_def]; field_simp rw [this] at h2 exact h2.hasDerivWithinAt -- image facts: f strictly mono on Ici 1 have hmono : StrictMonoOn f (Ici 1) := by intro a ha b hb hab simp only [mem_Ici] at ha hb apply mul_lt_mul_of_pos_left _ hs0 exact Real.log_lt_log (by linarith) hab have himg_Ioi : f '' Ioi 1 = Ioi 0 := by ext y simp only [Set.mem_image, mem_Ioi] constructor · rintro ⟨x, hx, rfl⟩ have : 0 < Real.log x := Real.log_pos hx positivity · intro hy refine ⟨Real.exp (y / (s - 1)), ?_, ?_⟩ · exact Real.one_lt_exp_iff.mpr (div_pos hy hs0) · rw [hf_def] simp only [Real.log_exp] field_simp have himg_Ici : f '' Ici 1 = Ici 0 := by ext y simp only [Set.mem_image, mem_Ici] constructor · rintro ⟨x, hx, rfl⟩ have : 0 ≤ Real.log x := Real.log_nonneg hx rw [hf_def]; positivity · intro hy refine ⟨Real.exp (y / (s - 1)), ?_, ?_⟩ · exact Real.one_le_exp_iff.mpr (div_nonneg hy hs0.le) · rw [hf_def] simp only [Real.log_exp] field_simp -- ContinuousOn g (f '' Ioi 1) = ContinuousOn g (Ioi 0) have hg_cont : ContinuousOn g (f '' Ioi 1) := by rw [himg_Ioi] apply ContinuousOn.mul · apply ContinuousOn.sub _ continuousOn_const apply Real.continuousOn_log.mono intro u hu simp only [mem_Ioi] at hu simp only [Set.mem_compl_iff, Set.mem_singleton_iff] linarith · exact (Real.continuous_exp.comp continuous_neg).continuousOn -- IntegrableOn g (f '' Ici 1) = IntegrableOn g (Ici 0) have hg1 : IntegrableOn g (f '' Ici 1) := by rw [himg_Ici, integrableOn_Ici_iff_integrableOn_Ioi] have e1 : IntegrableOn (fun u => Real.log u * Real.exp (-u)) (Ioi 0) := integrableOn_log_mul_exp_neg have e2 : IntegrableOn (fun u => Real.log (s - 1) * Real.exp (-u)) (Ioi 0) := (integrableOn_exp_neg_Ioi 0).const_mul _ have : g = fun u => Real.log u * Real.exp (-u) - Real.log (s - 1) * Real.exp (-u) := by funext u; rw [hg_def]; ring rw [this] exact e1.sub e2 -- IntegrableOn (fun x => (g ∘ f) x * f' x) (Ici 1) have hg2 : IntegrableOn (fun x => (g ∘ f) x * f' x) (Ici 1) := by -- HasDerivWithinAt f (f' x) (Ici 1) x for x ∈ Ici 1. have hff'_Ici : ∀ x ∈ Ici (1:ℝ), HasDerivWithinAt f (f' x) (Ici 1) x := by intro x hx simp only [mem_Ici] at hx have hxne : x ≠ 0 := by linarith have hd : HasDerivAt f ((s - 1) * x⁻¹) x := (Real.hasDerivAt_log hxne).const_mul (s - 1) have heq : (s - 1) * x⁻¹ = f' x := by rw [hf'_def]; field_simp rw [heq] at hd exact hd.hasDerivWithinAt -- f injective on Ici 1. have hinj : InjOn f (Ici 1) := hmono.injOn -- transfer hg1 through the integrability change of variables. have hiff := integrableOn_image_iff_integrableOn_abs_deriv_smul (s := Ici (1:ℝ)) (f := f) (f' := f') measurableSet_Ici hff'_Ici hinj g rw [hiff] at hg1 -- relate to our integrand on Ici 1. apply hg1.congr filter_upwards [self_mem_ae_restrict measurableSet_Ici] with x hx simp only [mem_Ici] at hx have hxpos : (0:ℝ) < x := by linarith have hf'pos : 0 < f' x := by rw [hf'_def]; positivity simp only [smul_eq_mul, Function.comp, abs_of_pos hf'pos] ring -- Apply change of variables. have hcov := integral_comp_mul_deriv_Ioi hf_cont hft hff' hg_cont hg1 hg2 rw [hf1] at hcov -- RHS: ∫ u in Ioi 0, g u = deriv Gamma 1 - log (s-1) have hrhs : ∫ u in Ioi (0:ℝ), g u = deriv Real.Gamma 1 - Real.log (s - 1) := by have e1 : IntegrableOn (fun u => Real.log u * Real.exp (-u)) (Ioi 0) := integrableOn_log_mul_exp_neg have e2 : IntegrableOn (fun u => Real.log (s - 1) * Real.exp (-u)) (Ioi 0) := (integrableOn_exp_neg_Ioi 0).const_mul _ have hsplit : (fun u => g u) = fun u => Real.log u * Real.exp (-u) - Real.log (s - 1) * Real.exp (-u) := by funext u; rw [hg_def]; ring rw [show (∫ u in Ioi (0:ℝ), g u) = ∫ u in Ioi (0:ℝ), (Real.log u * Real.exp (-u) - Real.log (s - 1) * Real.exp (-u)) from by rw [hsplit]] rw [integral_sub e1 e2, integral_log_mul_exp_neg_eq_deriv_Gamma] rw [integral_const_mul, integral_exp_neg_Ioi_zero, mul_one] -- LHS: ∫ x in Ioi 1, (g∘f) x * f' x = (s-1) * ∫ x in Ioi 1, log(log x) * x^(-s) have hlhs : ∫ x in Ioi (1:ℝ), (g ∘ f) x * f' x = (s - 1) * ∫ x in Ioi (1:ℝ), Real.log (Real.log x) * x ^ (-s) := by have hpt : ∀ x ∈ Ioi (1:ℝ), (g ∘ f) x * f' x = (s - 1) * (Real.log (Real.log x) * x ^ (-s)) := by intro x hx simp only [mem_Ioi] at hx have hxpos : (0:ℝ) < x := by linarith have hlogpos : 0 < Real.log x := Real.log_pos hx have hlogne : Real.log x ≠ 0 := ne_of_gt hlogpos have hs1ne : s - 1 ≠ 0 := ne_of_gt hs0 simp only [Function.comp, hf_def, hg_def, hf'_def] -- log ((s-1) * log x) - log (s-1) = log (log x) rw [Real.log_mul hs1ne hlogne] -- exp (-((s-1) * log x)) = x ^ (-(s-1)) have hexp : Real.exp (-((s - 1) * Real.log x)) = x ^ (-(s - 1)) := by rw [Real.rpow_def_of_pos hxpos] ring_nf rw [hexp] -- x ^ (-(s-1)) * ((s-1)/x) = (s-1) * x^(-s) have hx1 : x ^ (-(s - 1)) * ((s - 1) / x) = (s - 1) * x ^ (-s) := by rw [div_eq_mul_inv, ← Real.rpow_neg_one x] rw [show x ^ (-(s - 1)) * ((s - 1) * x ^ (-1 : ℝ)) = (s - 1) * (x ^ (-(s - 1)) * x ^ (-1 : ℝ)) by ring] rw [← Real.rpow_add hxpos] ring_nf rw [show (Real.log (s - 1) + Real.log (Real.log x) - Real.log (s - 1)) = Real.log (Real.log x) by ring] linear_combination Real.log (Real.log x) * hx1 rw [setIntegral_congr_fun measurableSet_Ioi hpt, integral_const_mul] rw [hlhs, hrhs] at hcov rw [hcov] ring end Issue1584 namespace Mertens open Real Finset Filter Asymptotics Topology open ArithmeticFunction hiding log /- Original line 7300: Mertens.sum_Ioc_one_eq_sum_Ioc_zero -/ theorem sum_Ioc_one_eq_sum_Ioc_zero {f : ℕ → ℝ} {x : ℕ} (hx : 1 ≤ x) (hf : f 1 = 0) : ∑ n ∈ Ioc 1 x, f n = ∑ n ∈ Ioc 0 x, f n := by rw [(by rfl : Ioc 0 x = Icc 1 x), ← add_sum_Ioc_eq_sum_Icc hx] simpa /- Original line 7306: Mertens.sum_log_eq -/ theorem sum_log_eq {x : ℝ} (hx : 1 ≤ x) : ∑ n ∈ Ioc 0 ⌊ x ⌋₊, log n = x * log x - (x - ⌊x⌋₊ - 1 / 2) * log x - x + 1 + ∫ t in 1..x, (t - ⌊t⌋₊ - 1 / 2) / t := by rw [← sum_Ioc_one_eq_sum_Ioc_zero (Nat.le_floor (by grind)) (by simp)] have : 1 = ⌊(1 : ℝ)⌋₊ := by simp nth_rw 1 [this] rw [sum_eq_integral_add_integral_deriv (by norm_num) hx (fun _ _ ↦ (by fun_prop (disch := grind)))] · simp only [log_one, B1, Nat.floor_one, Nat.cast_one, sub_self, zero_sub, RCLike.ofReal_real_eq_id, id_eq, mul_neg, zero_mul, neg_zero, integral_log, mul_zero, sub_zero, deriv_log'] ring_nf congr ext ring · simp only [deriv_log', Set.uIcc_of_le hx] fun_prop (disch := grind) /- Original line 7324: Mertens.sum_log_le -/ theorem sum_log_le {x : ℝ} (hx : 1 ≤ x) : ∑ n ∈ Ioc 0 ⌊ x ⌋₊, log n ≤ x * log x := by calc _ ≤ ∑ n ∈ Ioc 0 ⌊ x ⌋₊, log x := by refine sum_le_sum fun n hn ↦ ?_ simp only [mem_Ioc] at hn exact log_le_log (by exact_mod_cast hn.1) (Nat.le_floor_iff (by linarith)|>.mp hn.2) _ = ⌊x⌋₊ * log x := by simp _ ≤ _ := by gcongr · exact log_nonneg hx · exact Nat.floor_le (by linarith) /- Original line 7338: Mertens.integral_log_le -/ theorem integral_log_le {a b : ℝ} (ha : 1 ≤ a) (hab : a ≤ b) : ∫ t in a..b, log t ≤ log b * (b - a) := by apply le_of_abs_le have : ∀ t ∈ Set.uIoc a b, ‖log t‖ ≤ log b := by intro t ht rw [Set.uIoc_of_le hab, Set.mem_Ioc] at ht rw [norm_of_nonneg <| log_nonneg (by linarith)] gcongr <;> linarith grw [← norm_eq_abs, intervalIntegral.norm_integral_le_of_norm_le_const this, abs_of_nonneg (by linarith)] /- Original line 7350: Mertens.sum_log_ge -/ theorem sum_log_ge {x : ℝ} (hx : 1 ≤ x) : ∑ n ∈ Ioc 0 ⌊ x ⌋₊, log n ≥ x * log x - 2 * x := by have one_le_floor : 1 ≤ ⌊x⌋₊ := by simpa calc _ = ∑ n ∈ Icc 1 ⌊ x ⌋₊, log n := by rfl _ = ∑ n ∈ Ico (1 + 1) (⌊ x ⌋₊ + 1), log n := by rw [← add_sum_Ioc_eq_sum_Icc one_le_floor] simp rfl _ = ∑ n ∈ Ico 1 ⌊ x ⌋₊, log ((n + 1 : ℕ)) := by rw [← Finset.sum_Ico_add'] _ ≥ ∫ t in 1..⌊x⌋₊, log t := by convert MonotoneOn.integral_le_sum_Ico one_le_floor ?_|>.ge · norm_cast · exact StrictMonoOn.monotoneOn (strictMonoOn_log.mono fun y hy ↦ (by simp_all; linarith)) _ = (∫ t in 1..x, log t) - ∫ t in ⌊x⌋₊..x, log t := by nth_rw 3 [intervalIntegral.integral_symm] rw [sub_neg_eq_add, intervalIntegral.integral_add_adjacent_intervals] <;> exact intervalIntegral.intervalIntegrable_log' _ ≥ (∫ t in 1..x, log t) - log x := by gcongr grw [integral_log_le (by simpa) (Nat.floor_le (by linarith))] nth_rw 2 [← mul_one (log x)] gcongr · exact log_nonneg hx · linarith [Nat.lt_floor_add_one x] _ ≥ x * log x - x - log x := by simp only [integral_log, log_one, mul_zero, sub_zero, ge_iff_le, tsub_le_iff_right, sub_add_cancel, le_add_iff_nonneg_right, zero_le_one] _ ≥ _ := by linarith [log_le_self (by linarith : 0 ≤ x)] /- Original line 7380: Mertens.sum_log_eq_log_factorial -/ theorem sum_log_eq_log_factorial (x : ℝ) : ∑ n ∈ Ioc 0 ⌊ x ⌋₊, log n = log (Nat.floor x).factorial := by rw [←prod_Ico_id_eq_factorial, ←log_prod, prod_natCast] · congr intro x hx simp at hx ⊢; grind /- Original line 7388: Mertens.sum_log_eq_sum_mangoldt -/ theorem sum_log_eq_sum_mangoldt {x : ℝ} : ∑ n ∈ Ioc 0 ⌊x⌋₊, log n = ∑ d ∈ Ioc 0 ⌊x⌋₊, Λ d * ⌊x / d⌋₊ := by have : ∀ n : ℕ, log n = (Λ * zeta) n := by simp [vonMangoldt_mul_zeta] simp_rw [this, sum_Ioc_mul_zeta_eq_sum, ← Nat.floor_div_natCast] /- Original line 7394: Mertens.E₁Λ -/ noncomputable abbrev E₁Λ (x : ℝ) : ℝ := ∑ d ∈ Ioc 0 ⌊ x ⌋₊, (Λ d) / d - log x /- Original line 7396: Mertens.sum_mangoldt_div_eq -/ theorem sum_mangoldt_div_eq (x : ℝ) : ∑ d ∈ Ioc 0 ⌊ x ⌋₊, (Λ d) / d = log x + E₁Λ x := by grind /- Original line 7400: Mertens.E₁Λ.ge -/ theorem E₁Λ.ge {x : ℝ} (hx : 1 ≤ x) : E₁Λ x ≥ -2 := by unfold E₁Λ suffices x * ∑ d ∈ Ioc 0 ⌊x⌋₊, Λ d / d ≥ x * (log x - 2) by linarith [le_of_mul_le_mul_left this (by linarith)] calc _ = ∑ d ∈ Ioc 0 ⌊x⌋₊, Λ d * (x / d) := by rw [Finset.mul_sum] ring_nf _ ≥ ∑ d ∈ Ioc 0 ⌊x⌋₊, Λ d * ⌊x / d⌋₊ := by gcongr exact Nat.floor_le <| div_nonneg (by linarith) (by linarith) _ ≥ x * log x - 2 * x := sum_log_eq_sum_mangoldt ▸ sum_log_ge hx _ = _ := by ring /- Original line 7419: Mertens.E₁Λ.le -/ theorem E₁Λ.le {x : ℝ} (hx : 1 ≤ x) : E₁Λ x ≤ log 4 + 4 := by unfold E₁Λ suffices x * ∑ d ∈ Ioc 0 ⌊x⌋₊, Λ d / d ≤ x * (log x + log 4 + 4) by linarith [le_of_mul_le_mul_left this (by linarith)] calc _ = ∑ d ∈ Ioc 0 ⌊x⌋₊, Λ d * (x / d) := by rw [Finset.mul_sum] ring_nf _ ≤ ∑ d ∈ Ioc 0 ⌊x⌋₊, Λ d * (⌊x / d⌋₊ + 1) := by gcongr exact Nat.lt_floor_add_one _|>.le _ = (∑ d ∈ Ioc 0 ⌊x⌋₊, log d) + ∑ d ∈ Ioc 0 ⌊x⌋₊, Λ d := by simp_rw [mul_add, mul_one] rw [Finset.sum_add_distrib, sum_log_eq_sum_mangoldt] _ ≤ x * log x + (log 4 + 4) * x := by gcongr · exact sum_log_le hx · exact Chebyshev.psi_le_const_mul_self (by linarith) _ = _ := by ring /- Original line 7441: Mertens.sum_mangoldt_div_eq_log -/ theorem sum_mangoldt_div_eq_log {x : ℝ} (hx : 1 ≤ x) : |∑ d ∈ Ioc 0 ⌊ x ⌋₊, (Λ d) / d - log x| ≤ log 4 + 4 := by grind [E₁Λ.le hx, E₁Λ.ge hx, log_nonneg] /- Original line 7445: Mertens.E₁Λ.bounded' -/ theorem E₁Λ.bounded' : ∃ c > 0, ∀ x ≥ 1, |E₁Λ x| ≤ c := by exact ⟨log 4 + 4, (by positivity), fun x hx ↦ sum_mangoldt_div_eq_log hx⟩ /- Original line 7451: Mertens.E₁Λ.bounded -/ theorem E₁Λ.bounded : E₁Λ =O[atTop] (fun _ ↦ (1:ℝ)) := by simp only [isBigO_iff, norm_eq_abs, norm_one, mul_one, eventually_atTop] exact ⟨log 4 + 4, 1, fun _ hx ↦ sum_mangoldt_div_eq_log hx⟩ /- Original line 7456: Mertens.one_eq_o_log -/ theorem one_eq_o_log : (fun _ ↦ (1:ℝ)) =o[atTop] (fun x ↦ log x) := by simp only [isLittleO_one_left_iff, norm_eq_abs] exact tendsto_abs_atTop_atTop.comp tendsto_log_atTop /- Original line 7461: Mertens.sum_mangoldt_div_eq_log' -/ theorem sum_mangoldt_div_eq_log' : (fun x ↦ ∑ d ∈ Ioc 0 ⌊ x ⌋₊, (Λ d) / d) ~[atTop] (fun x ↦ log x) := by apply IsLittleO.isEquivalent (IsBigO.trans_isLittleO _ one_eq_o_log) convert! E₁Λ.bounded using 1 /- Original line 7467: Mertens.E₁p -/ noncomputable abbrev E₁p (x : ℝ) : ℝ := ∑ p ∈ Ioc 0 ⌊ x ⌋₊ with p.Prime, (log p) / p - log x /- Original line 7469: Mertens.sum_log_prime_div_eq -/ theorem sum_log_prime_div_eq (x : ℝ) : ∑ p ∈ Ioc 0 ⌊ x ⌋₊ with p.Prime, (log p) / p = log x + E₁p x := by grind /- Original line 7473: Mertens.E₁p.le_E₁Λ -/ theorem E₁p.le_E₁Λ (x : ℝ) : E₁p x ≤ E₁Λ x := by unfold E₁p E₁Λ; rw [sum_filter] gcongr with p _ split_ifs with hp · simp [vonMangoldt_apply_prime hp] have : 0 ≤ Λ p := vonMangoldt_nonneg positivity /- Original line 7483: Mertens.E₁p.le -/ theorem E₁p.le {x : ℝ} (hx : 1 ≤ x) : E₁p x ≤ log 4 + 4 := by linarith [E₁Λ.le hx, E₁p.le_E₁Λ x] /- Original line 7487: Mertens.E₁ -/ noncomputable abbrev E₁ : ℝ := ∑' p : ℕ, if p.Prime then (log p) / (p*(p-1)) else 0 /- Original line 7489: Mertens.E₁.summand_nonneg -/ theorem E₁.summand_nonneg (p : ℕ) : 0 ≤ if p.Prime then (log p) / (p*(p-1)) else 0 := by split_ifs with h · refine div_nonneg (log_natCast_nonneg _) (mul_nonneg (Nat.cast_nonneg _) ?_) suffices 1 ≤ (p : ℝ) by linarith exact_mod_cast h.one_le · rfl /- Original line 7497: Mertens.E₁.summable -/ theorem E₁.summable : Summable (fun p : ℕ ↦ if p.Prime then (log p) / (p*(p-1)) else 0) := by refine (Real.summable_one_div_nat_rpow.mpr (by norm_num: 1 < (3 : ℝ) / 2)|>.const_div 4).of_nonneg_of_le E₁.summand_nonneg fun n ↦ ?_ split_ifs with h · grw [Real.log_le_rpow_div (Nat.cast_nonneg _) (by norm_num : 0 < (1 : ℝ) / 2)] · have denom : (n : ℝ) * ((n : ℝ) - 1) ≥ n ^ 2/ 2 := by rw [sq, mul_div_assoc] gcongr suffices (n : ℝ) ≥ 2 by linarith exact_mod_cast h.two_le grw [denom] · apply le_of_eq rw [← Real.rpow_natCast] field_simp rw [mul_div_assoc, ← Real.rpow_sub (mod_cast h.pos)] norm_num rw [Real.rpow_neg (Nat.cast_nonneg _)] field · exact div_pos (pow_pos (mod_cast h.pos) _) (by norm_num) · apply mul_nonneg (Nat.cast_nonneg _) suffices 1 ≤ (n : ℝ) by linarith exact_mod_cast h.one_le · positivity /- Original line 7521: Mertens.antitoneOn_log_div_sq -/ private theorem antitoneOn_log_div_sq : AntitoneOn (fun t ↦ log (t + 2) / (t + 2) ^ 2) (Set.Ici 0) := by apply antitoneOn_of_deriv_nonpos (convex_Ici 0) · refine fun t ht ↦ ContinuousAt.continuousWithinAt ?_ simp at ht have : (t + 2) ≠ 0 := by simp; linarith fun_prop (disch := grind) · refine fun t ht ↦ DifferentiableAt.differentiableWithinAt ?_ simp at ht have : (t + 2) ^ 2 ≠ 0 := by simp; grind fun_prop (disch := grind) · intro t ht simp at ht rw [deriv_fun_div (by fun_prop (disch := grind)) (by fun_prop) (by simp; grind), deriv_comp_add_const, deriv_log] simp field_simp simp only [mul_zero, tsub_le_iff_right, zero_add] rw [← log_rpow (by linarith), ← log_exp 1, rpow_ofNat] gcongr nlinarith [exp_one_lt_three] /- Original line 7542: Mertens.log_div_sq_nonneg -/ private theorem log_div_sq_nonneg : ∀ t ∈ Set.Ioi 0, 0 ≤ log (t + 2) / (t + 2) ^ 2 := by exact fun t ht ↦ div_nonneg (log_nonneg (by simp_all; linarith)) (by positivity) /- Original line 7546: Mertens.log_div_sq_is_deriv -/ private theorem log_div_sq_is_deriv : ∀ x ∈ Set.Ici 0, HasDerivAt (fun t ↦ (-log (t + 2) - 1) / (t + 2)) (log (x + 2) / (x + 2) ^ 2) x := by intro t ht simp at ht apply HasDerivAt.comp_add_const (f := (fun t ↦ (-log t - 1)/ t)) t 2 convert! HasDerivAt.fun_div (c' := -1 / (t + 2)) (d' := (1 : ℝ)) _ _ _ using 1 · field · apply HasDerivAt.sub_const convert! (hasDerivAt_log (by linarith : t + 2 ≠ 0)).neg using 1 ring_nf · exact hasDerivAt_id _ · linarith /- Original line 7559: Mertens.tendsto_antideriv_log_div_sq -/ private theorem tendsto_antideriv_log_div_sq : Tendsto (fun t ↦ (-log (t + 2) - 1) / (t + 2)) atTop (nhds 0) := by have : Tendsto (fun (t : ℝ) ↦ t + 2) atTop atTop := by exact tendsto_atTop_add_const_right atTop 2 tendsto_id apply Tendsto.comp (g := (fun t ↦ (-log t - 1) / t)) _ this convert! Tendsto.sub (f := (fun t ↦ -log t / t)) (a := 0) _ tendsto_inv_atTop_zero using 1 · ring_nf · ring_nf · convert! (Real.tendsto_pow_log_div_mul_add_atTop 1 0 1 (by linarith)).neg using 1 · ext; ring · simp /- Original line 7570: Mertens.integrableOn_log_div_sq -/ private theorem integrableOn_log_div_sq : MeasureTheory.IntegrableOn (fun t ↦ log (t + 2) / (t + 2) ^ 2) (Set.Ioi 0) := by exact MeasureTheory.integrableOn_Ioi_deriv_of_nonneg' log_div_sq_is_deriv log_div_sq_nonneg tendsto_antideriv_log_div_sq /- Original line 7574: Mertens.integral_log_div_sq -/ private theorem integral_log_div_sq : ∫ t in Set.Ioi 0, log (t + 2) / (t + 2) ^ 2 = (log 2 + 1) / 2 := by rw [MeasureTheory.integral_Ioi_of_hasDerivAt_of_nonneg' log_div_sq_is_deriv log_div_sq_nonneg tendsto_antideriv_log_div_sq] ring_nf /- Original line 7579: Mertens.summable_log_div_sq -/ private theorem summable_log_div_sq : Summable (fun (n : ℕ)↦ log (n + 3) / (n + 3) ^ 2) := by let g : ℝ → ℝ := (fun n ↦ log (n + 2) / (n + 2) ^ 2) suffices Summable (fun (n : ℕ) ↦ g n ) by convert! summable_nat_add_iff 1|>.mpr this using 2 unfold g push_cast ring_nf exact antitoneOn_log_div_sq.summable_of_integrableOn_Ioi_zero integrableOn_log_div_sq log_div_sq_nonneg /- Original line 7589: Mertens.sum_log_div_sq_le -/ private theorem sum_log_div_sq_le : ∑' (n : ℕ), log (n + 3) / (n + 3) ^2 ≤ (log 2 + 1) / 2 := by let g : ℝ → ℝ := (fun n ↦ log (n + 2) / (n + 2) ^ 2) calc _ = ∑' (n : ℕ), g (n + 1 : ℕ):= by unfold g congr push_cast ring_nf _ ≤ ∫ x in Set.Ioi 0, g x := by exact antitoneOn_log_div_sq.tsum_add_one_le_integral integrableOn_log_div_sq log_div_sq_nonneg _ = _ := by exact integral_log_div_sq /- Original line 7604: Mertens.E₁.le -/ theorem E₁.le : E₁ ≤ (5 * log 2 + 3) / 4 := by unfold E₁ calc _ = log 2 / 2 + ∑' (n : ℕ), if (n + 3).Prime then log (n + 3) / ((n + 3) * (n + 2)) else 0 := by rw [← E₁.summable.sum_add_tsum_nat_add 3, (by rfl : range 3 = {0, 1, 2})] simp [Nat.prime_two] ring_nf _ ≤ log 2 / 2 + ∑' (n : ℕ), (3 / 2) * (log (n + 3) / (n + 3) ^ 2) := by gcongr with n · convert! summable_nat_add_iff 3|>.mpr E₁.summable using 4 · norm_cast · push_cast; ring · exact summable_log_div_sq.mul_left _ · split_ifs with h · grw [(by linarith : (n + 2 : ℝ) ≥ 2 * (n + 3) / 3)] · field_simp rfl · exact log_nonneg (by grind) · exact mul_nonneg (by norm_num) (div_nonneg (log_nonneg (by grind)) (by positivity)) _ = log 2 / 2 + (3 / 2) * ∑' (n : ℕ), log (n + 3) / (n + 3) ^ 2 := by rw [tsum_mul_left] _ ≤ _ := by grw [sum_log_div_sq_le] ring_nf rfl /- Original line 7630: Mertens.E₁.nonneg -/ theorem E₁.nonneg : E₁ ≥ 0 := tsum_nonneg E₁.summand_nonneg /- Original line 7634: Mertens.E₁Λ.le_E₁p_add_E₁ -/ theorem E₁Λ.le_E₁p_add_E₁ {x : ℝ} (hx : 1 ≤ x) : E₁Λ x ≤ E₁p x + E₁ := by unfold E₁Λ E₁p suffices ∑ d ∈ Ioc 0 ⌊x⌋₊, Λ d / d ≤ ∑ p ∈ Ioc 0 ⌊x⌋₊ with Nat.Prime p, log p / p + E₁ by linarith simp_rw [vonMangoldt_apply, ite_div, zero_div, ← sum_filter, Chebyshev.sum_PrimePow_eq_sum_sum _ (by linarith)] calc _ = ∑ k ∈ Icc 1 ⌊log x / log 2⌋₊, ∑ p ∈ Ioc 0 ⌊x ^ (1 / (k : ℝ))⌋₊ with Nat.Prime p, log p / (p ^ k : ℕ) := by refine sum_congr rfl fun k hk ↦ sum_congr rfl fun p hp ↦ ?_ rw [Nat.Prime.pow_minFac (by simp_all) (by simp_all; linarith)] _ ≤ ∑ k ∈ Icc 1 ⌊log x / log 2⌋₊, ∑ p ∈ Ioc 0 ⌊x⌋₊ with Nat.Prime p, log p / (p ^ k : ℕ) := by gcongr with k hk apply rpow_le_self_of_one_le hx simp only [mem_Icc] at hk exact div_le_one₀ (by norm_cast; linarith)|>.mpr (mod_cast hk.1) _ ≤ ∑ k ∈ Icc 1 (max 1 ⌊log x / log 2⌋₊), ∑ p ∈ Ioc 0 ⌊x⌋₊ with Nat.Prime p, log p / (p ^ k : ℕ) := by apply sum_le_sum_of_subset_of_nonneg · gcongr exact le_max_right .. · exact fun _ _ _ ↦ sum_nonneg fun _ _ ↦ (by positivity) _ = ∑ p ∈ Ioc 0 ⌊x⌋₊ with Nat.Prime p, (log p / p) + ∑ k ∈ Ioc 1 (max 1 ⌊log x / log 2⌋₊), ∑ p ∈ Ioc 0 ⌊x⌋₊ with Nat.Prime p, log p / (p ^ k : ℕ) := by rw [← add_sum_Ioc_eq_sum_Icc (le_max_left ..)] simp _ ≤ _ := by gcongr rw [sum_comm] conv => lhs; arg 2; ext p; arg 2; ext k; rw [← mul_one_div, Nat.cast_pow, ← one_div_pow] simp_rw [← mul_sum] calc _ ≤ ∑ p ∈ Ioc 0 ⌊x⌋₊ with Nat.Prime p, log p / (p * (p - 1)) := by gcongr with p hp simp only [mem_filter, mem_Ioc] at hp conv => rhs; rw [← mul_one_div] gcongr rw [(by rfl : Ioc 1 (max 1 ⌊log x / log 2⌋₊) = Ico 2 (max 1 ⌊log x / log 2⌋₊ + 1))] grw [geom_sum_Ico_le_of_lt_one (by simp)] · apply le_of_eq have : (p : ℝ) ≠ 0 := by exact_mod_cast hp.1.1.ne.symm field · simpa using inv_lt_one_of_one_lt₀ (mod_cast hp.2.one_lt) _ ≤ _ := by rw [sum_filter] exact E₁.summable.sum_le_tsum _ fun p hp ↦ E₁.summand_nonneg p /- Original line 7677: Mertens.E₁p.ge -/ theorem E₁p.ge {x : ℝ} (hx : 1 ≤ x) : E₁p x ≥ -2 - E₁ := by linarith [E₁Λ.le_E₁p_add_E₁ hx, E₁Λ.ge hx] /- Original line 7683: Mertens.sum_log_prime_div_eq_log -/ theorem sum_log_prime_div_eq_log {x : ℝ} (hx : 1 ≤ x) : |∑ p ∈ Ioc 0 ⌊ x ⌋₊ with p.Prime, (log p) / p - log x| ≤ log 4 + 4 := by rw [abs_le'] refine ⟨ E₁p.le hx, ?_ ⟩ have : log 2 > 0 := by apply log_pos; norm_num have : log 4 = 2 * log 2 := by rw [←Real.log_rpow (by norm_num)]; norm_num grind [E₁p.ge hx, E₁.le] /- Original line 7691: Mertens.E₁p.bounded -/ theorem E₁p.bounded : ∃ c > 0, ∀ x ≥ 1, |E₁p x| ≤ c := by exact ⟨log 4 + 4, (by positivity), fun _ hx ↦ sum_log_prime_div_eq_log hx⟩ /- Original line 7695: Mertens.sum_log_prime_div_eq_log' -/ theorem sum_log_prime_div_eq_log' : E₁p =O[atTop] (fun _ ↦ (1:ℝ)) := by simp only [isBigO_iff, norm_eq_abs, one_mem, CStarRing.norm_of_mem_unitary, mul_one, eventually_atTop, E₁p] exact ⟨ log 4 + 4, 1, fun _ ↦ sum_log_prime_div_eq_log ⟩ /- Original line 7701: Mertens.sum_log_prime_div_eq_log'' -/ theorem sum_log_prime_div_eq_log'' : (fun x ↦ ∑ p ∈ Ioc 0 ⌊ x ⌋₊ with p.Prime, (log p) / p) ~[atTop] (fun x ↦ log x) := by apply IsLittleO.isEquivalent (IsBigO.trans_isLittleO _ one_eq_o_log) convert! sum_log_prime_div_eq_log' using 1 /- Original line 7706: Mertens.γ -/ noncomputable abbrev γ : ℝ := (∫ t in Set.Ioi 2, E₁Λ t / (t * log t^2)) + 1 - log (log 2) /- Original line 7709: Mertens.E₂Λ -/ noncomputable abbrev E₂Λ (x : ℝ) : ℝ := ∑ d ∈ Ioc 0 ⌊ x ⌋₊, (Λ d) / (d * log d) - log (log x) - γ /- Original line 7711: Mertens.sum_Ioc_one_eq_sum_Icc_zero -/ theorem sum_Ioc_one_eq_sum_Icc_zero {f : ℕ → ℝ} {x : ℕ} (hx : 1 ≤ x) (hf1 : f 1 = 0) (hf0 : f 0 = 0) : ∑ n ∈ Ioc 1 x, f n = ∑ n ∈ Icc 0 x, f n := by rw [sum_Ioc_one_eq_sum_Ioc_zero hx hf1, ← add_sum_Ioc_eq_sum_Icc (by linarith)] simpa /- Original line 7717: Mertens.sum_div_log_eq -/ private theorem sum_div_log_eq {x : ℝ} (hx : 2 ≤ x) (f : ℕ → ℝ) : ∑ n ∈ Ioc 1 ⌊ x ⌋₊, f n / log n = (∑ n ∈ Ioc 1 ⌊ x ⌋₊, f n) / log x + ∫ t in 2..x, (∑ n ∈ Ioc 1 ⌊ t ⌋₊, f n) / (t * log t^2) := by let g : ℕ → ℝ := (fun n ↦ if n < 2 then 0 else f n) trans ∑ n ∈ Icc 0 ⌊ x ⌋₊, (log n)⁻¹ * g n · rw [← sum_Ioc_one_eq_sum_Icc_zero (Nat.le_floor (by grind)) (by simp) (by simp)] refine sum_congr rfl fun n hn ↦ ?_ have : ¬(n ≤ 1) := by simp_all simp [g, this] field rw [sum_mul_eq_sub_integral_mul₁ g (f := (fun n ↦ (log n)⁻¹)) (by simp [g]) (by simp [g])] · rw [intervalIntegral.integral_of_le hx, mul_comm, ← div_eq_mul_inv, ← sub_neg_eq_add] simp_rw [deriv_inv_log] congr 1 · rw [← sum_Ioc_one_eq_sum_Icc_zero (Nat.le_floor (by grind)) (by simp [g]) (by simp [g])] congr 1 refine sum_congr rfl fun n hn ↦ ?_ simp only [mem_Ioc] at hn have : ¬(n ≤ 1) := by linarith simp [g, this] · rw [← MeasureTheory.integral_neg] refine MeasureTheory.setIntegral_congr_fun (by measurability) fun t ht ↦ ?_ simp only [Set.mem_Ioc] at ht rw [← sum_Ioc_one_eq_sum_Icc_zero (Nat.le_floor (by grind)) (by simp [g]) (by simp [g])] field_simp congr 2 refine sum_congr rfl fun n hn ↦ ?_ simp only [mem_Ioc] at hn have : ¬(n ≤ 1) := by linarith simp [g, this] · intro t ht simp only [Set.mem_Icc] at ht have : log t ≠ 0 := by simp; grind fun_prop (disch := grind) · refine ContinuousOn.integrableOn_Icc fun t ht ↦ ContinuousAt.continuousWithinAt ?_ simp only [Set.mem_Icc] at ht conv => arg 1; ext x; rw [deriv_inv_log] have : log t ^2 ≠ 0 := by simp; grind fun_prop (disch := grind) /- Original line 7757: Mertens.integrable_const_div_mul_log_sq -/ private theorem integrable_const_div_mul_log_sq {x : ℝ} (c : ℝ) (hx : 2 ≤ x) : MeasureTheory.IntegrableOn (fun x ↦ c / (x * log x ^ 2)) (Set.Ioi x) MeasureTheory.volume := by conv => arg 1; ext t; rw [← mul_one_div] apply MeasureTheory.Integrable.const_mul refine MeasureTheory.integrableOn_Ioi_deriv_of_nonneg' ?_ ?_ tendsto_log_atTop.inv_tendsto_atTop.neg · intro t ht simp only [Set.mem_Ici] at ht have : log t ≠ 0 := by simp; grind have : DifferentiableAt ℝ (fun t ↦ -(log t)⁻¹) t := by fun_prop (disch := grind) convert! this.hasDerivAt using 1 simp [deriv_inv_log] field · intro t ht simp only [Set.mem_Ioi] at ht exact one_div_nonneg.mpr <| mul_nonneg (by linarith) (sq_nonneg _) /- Original line 7776: Mertens.integrable_E₁Λ_div_mul_log_sq -/ private theorem integrable_E₁Λ_div_mul_log_sq {x : ℝ} (hx : 2 ≤ x) : MeasureTheory.IntegrableOn (fun x ↦ E₁Λ x / (x * log x ^ 2)) (Set.Ioi x) MeasureTheory.volume := by obtain ⟨c, hc1, hc2⟩ := E₁Λ.bounded' apply MeasureTheory.Integrable.mono (integrable_const_div_mul_log_sq c hx) · exact Measurable.aestronglyMeasurable (by fun_prop) · filter_upwards [MeasureTheory.ae_restrict_mem (by measurability)] with t ht simp only [Set.mem_Ioi] at ht simp only [norm_div, norm_eq_abs, norm_mul, norm_pow, sq_abs, abs_of_pos hc1] gcongr exact hc2 t (by linarith) /- Original line 7787: Mertens.integrable_E₁p_div_mul_log_sq -/ private theorem integrable_E₁p_div_mul_log_sq {x : ℝ} (hx : 2 ≤ x) : MeasureTheory.IntegrableOn (fun x ↦ E₁p x / (x * log x ^ 2)) (Set.Ioi x) MeasureTheory.volume := by obtain ⟨c, hc1, hc2⟩ := E₁p.bounded apply MeasureTheory.Integrable.mono (integrable_const_div_mul_log_sq c hx) · exact Measurable.aestronglyMeasurable (by fun_prop) · filter_upwards [MeasureTheory.ae_restrict_mem (by measurability)] with t ht simp only [Set.mem_Ioi] at ht simp only [norm_div, norm_eq_abs, norm_mul, norm_pow, sq_abs, abs_of_pos hc1] gcongr exact hc2 t (by linarith) /- Original line 7798: Mertens.deriv_log_log -/ theorem deriv_log_log {x : ℝ} (hx : 1 < x) : deriv (fun t ↦ log (log t)) x = 1 / (x * log x) := by rw [deriv.log (differentiableAt_log (by linarith)) (by simp; grind), deriv_log] field /- Original line 7803: Mertens.integral_one_div_mul_log -/ theorem integral_one_div_mul_log {x : ℝ} (hx : 2 ≤ x) : ∫ t in 2..x, 1 / (t * log t) = log (log x) - log (log 2) := by rw [← intervalIntegral.integral_deriv_eq_sub (f := fun t ↦ log (log t))] · refine intervalIntegral.integral_congr fun t ht ↦ ?_ rw [deriv_log_log] rw [Set.uIcc_of_le hx, Set.mem_Icc] at ht linarith · intro t ht rw [Set.uIcc_of_le hx, Set.mem_Icc] at ht have : log t ≠ 0 := by simp; grind fun_prop (disch := grind) · refine ContinuousOn.intervalIntegrable ?_ apply ContinuousOn.congr (f := (fun t ↦ 1 / (t * log t))) · refine fun t ht ↦ ContinuousAt.continuousWithinAt ?_ rw [Set.uIcc_of_le hx, Set.mem_Icc] at ht have : log t ≠ 0 := by simp; grind fun_prop (disch := grind) · intro t ht rw [Set.uIcc_of_le hx, Set.mem_Icc] at ht exact deriv_log_log (by linarith) /- Original line 7824: Mertens.intervalIntegrable_one_div_mul_log -/ theorem intervalIntegrable_one_div_mul_log {x : ℝ} (hx : 2 ≤ x) : IntervalIntegrable (fun t ↦ 1 / (t * log t)) MeasureTheory.volume 2 x := by refine ContinuousOn.intervalIntegrable fun t ht ↦ ContinuousAt.continuousWithinAt ?_ rw [Set.uIcc_of_le hx, Set.mem_Icc] at ht have : log t ≠ 0 := by simp; grind fun_prop (disch := grind) /- Original line 7832: Mertens.E₂Λ.eq -/ theorem E₂Λ.eq {x : ℝ} (hx : 2 ≤ x) : E₂Λ x = E₁Λ x / log x - ∫ t in Set.Ioi x, E₁Λ t / (t * log t^2) := by unfold E₂Λ rw [← sum_Ioc_one_eq_sum_Ioc_zero (Nat.le_floor (by grind)) (by simp)] conv => lhs; arg 1; arg 1; arg 2; ext n; rw [(by field : Λ n / (n * log n) = (Λ n / n) / log n)] rw [sum_div_log_eq hx] rw [sum_Ioc_one_eq_sum_Ioc_zero (Nat.le_floor (by grind)) (by simp), sum_mangoldt_div_eq] have : ∫ t in 2..x, (∑ n ∈ Ioc 1 ⌊t⌋₊, Λ n / n) / (t * log t ^ 2) = ∫ t in 2..x, (1 / (t * log t) + E₁Λ t / (t * log t ^ 2)) := by refine intervalIntegral.integral_congr fun t ht ↦ ?_ rw [Set.uIcc_of_le hx, Set.mem_Icc] at ht rw [sum_Ioc_one_eq_sum_Ioc_zero (Nat.le_floor (by grind)) (by simp), sum_mangoldt_div_eq] field rw [this, intervalIntegral.integral_add] · rw [integral_one_div_mul_log hx, add_div, div_self (by simp; grind)] unfold γ calc _ = E₁Λ x / log x + (∫ (x : ℝ) in 2..x, E₁Λ x / (x * log x ^ 2)) - ((∫ (t : ℝ) in Set.Ioi 2, E₁Λ t / (t * log t ^ 2))) := by ring _ = _ := by rw [← intervalIntegral.integral_interval_add_Ioi (integrable_E₁Λ_div_mul_log_sq (by rfl)) (integrable_E₁Λ_div_mul_log_sq hx)] ring · exact intervalIntegrable_one_div_mul_log hx · rw [intervalIntegrable_iff, Set.uIoc_of_le hx] exact integrable_E₁Λ_div_mul_log_sq (x := 2) (by rfl)|>.mono (by grind) (by rfl) /- Original line 7857: Mertens.integ_div_mul_log_sq -/ private theorem integ_div_mul_log_sq {x : ℝ} (c : ℝ) (hx : 2 ≤ x) : ∫ t in Set.Ioi x, c / (t * log t^2) = c / log x := by convert! MeasureTheory.integral_Ioi_of_hasDerivAt_of_tendsto' (m := 0) (f := fun x ↦ - c / log x) ?_ (integrable_const_div_mul_log_sq c hx) ?_ using 1 · grind · intro t ht; simp at ht convert! HasDerivAt.fun_div (hasDerivAt_const _ (-c)) (hasDerivAt_log (by linarith)) ?_ using 1 · grind simp; grind convert! tendsto_log_atTop.inv_tendsto_atTop.const_mul (-c) using 1 simp /- Original line 7870: Mertens.E₂Λ.abs_le -/ theorem E₂Λ.abs_le {x : ℝ} (hx : 2 ≤ x) : |E₂Λ x| ≤ (log 4 + 6) / log x := by have : 0 < log x := by apply log_pos; linarith rw [E₂Λ.eq hx, abs_le'] constructor · grw [E₁Λ.le (by linarith)] have : ∫ t in Set.Ioi x, E₁Λ t / (t * log t^2) ≥ - 2 / log x := calc _ ≥ ∫ t in Set.Ioi x, (-2) / (t * log t^2) := by apply MeasureTheory.setIntegral_mono_on (integrable_const_div_mul_log_sq (-2) hx) (integrable_E₁Λ_div_mul_log_sq hx) (by measurability) intro y hy; simp at hy have : 1 < y := by linarith have : 0 < log y := log_pos this gcongr; exact E₁Λ.ge (by linarith) _ = _ := integ_div_mul_log_sq (-2) hx grw [this] grind grw [E₁Λ.ge (by linarith)] have : ∫ t in Set.Ioi x, E₁Λ t / (t * log t^2) ≤ (log 4 + 4) / log x := calc _ ≤ ∫ t in Set.Ioi x, (log 4 + 4) / (t * log t^2) := by apply MeasureTheory.setIntegral_mono_on (integrable_E₁Λ_div_mul_log_sq hx) (integrable_const_div_mul_log_sq (log 4 + 4) hx) (by measurability) intro y hy; simp at hy have : 1 < y := by linarith have : 0 < log y := log_pos this gcongr; exact E₁Λ.le (by linarith) _ = _ := integ_div_mul_log_sq (log 4 + 4) hx grw [this] grind /- Original line 7902: Mertens.E₂Λ.bound -/ theorem E₂Λ.bound : E₂Λ =O[atTop] (fun x ↦ 1 / log x) := by simp only [one_div, isBigO_iff, norm_eq_abs, norm_inv, eventually_atTop] use log 4 + 6, 2 intro x hx convert E₂Λ.abs_le hx using 1 have : 0 < log x := by apply log_pos; linarith grind [abs_of_pos this] /- Original line 7911: Mertens.E₂Λ.bound' -/ theorem E₂Λ.bound' : E₂Λ =o[atTop] (fun _ ↦ (1:ℝ)) := E₂Λ.bound.trans_isLittleO inv_log_eq_o_one /- Original line 7914: Mertens.log_zeta_eq_sum -/ theorem log_zeta_eq_sum (s : ℝ) (hs : 1 < s) : log (riemannZeta (s:ℂ)).re = ∑' n, Λ n / (n^s * log n) := by have hsc : (1 : ℝ) < ((s : ℂ)).re := by simpa using hs -- (II) Euler log product have hep := riemannZeta_eulerProduct_exp_log (s := (s : ℂ)) hsc set S : ℂ := ∑' p : Nat.Primes, -Complex.log (1 - (p : ℂ) ^ (-(s : ℂ))) with hS -- bridge: prime cpow equals real rpow have hcpow : ∀ p : Nat.Primes, (p : ℂ) ^ (-(s : ℂ)) = (((p : ℝ) ^ (-s) : ℝ) : ℂ) := by intro p rw [Complex.ofReal_cpow (by positivity)] push_cast; ring_nf -- the real value of each prime term set z : Nat.Primes → ℝ := fun p => (p : ℝ) ^ (-s) with hz -- z p ∈ (0,1) have hz_pos : ∀ p : Nat.Primes, 0 < z p := fun p => by have : (0 : ℝ) < (p : ℝ) := by exact_mod_cast p.prop.pos positivity have hz_lt_one : ∀ p : Nat.Primes, z p < 1 := by intro p have hp1 : (1 : ℝ) < (p : ℝ) := by exact_mod_cast p.prop.one_lt change (p : ℝ) ^ (-s) < 1 rw [Real.rpow_neg (by positivity), inv_lt_one_iff₀] right exact (Real.one_lt_rpow_iff_of_pos (by positivity)).mpr (Or.inl ⟨hp1, by linarith⟩) -- each summand is the ofReal of a real number have hterm : ∀ p : Nat.Primes, -Complex.log (1 - (p : ℂ) ^ (-(s : ℂ))) = ((-Real.log (1 - z p) : ℝ) : ℂ) := by intro p rw [hcpow p] have h1z : (0 : ℝ) < 1 - z p := by have := hz_lt_one p; linarith rw [show (1 : ℂ) - ((z p : ℝ) : ℂ) = (((1 - z p : ℝ)) : ℂ) by push_cast; ring] rw [← Complex.ofReal_log h1z.le] push_cast; ring -- (III) S is real: S = (Sr : ℂ) with Sr the real sum set Sr : ℝ := ∑' p : Nat.Primes, -Real.log (1 - z p) with hSr have hSeq : S = (Sr : ℂ) := by rw [hS, hSr, Complex.ofReal_tsum] exact tsum_congr hterm have hSim : S.im = 0 := by rw [hSeq]; exact Complex.ofReal_im _ have hSre : S.re = Sr := by rw [hSeq]; exact Complex.ofReal_re _ -- (IV) invert exp: log ζ = S have hlog_zeta : Complex.log (riemannZeta (s : ℂ)) = S := by rw [← hep, Complex.log_exp (by rw [hSim]; exact neg_lt_zero.mpr Real.pi_pos) (by rw [hSim]; exact Real.pi_pos.le)] -- relate Real.log ζ.re to S.re = Sr have hkey : Real.log (riemannZeta (s : ℂ)).re = Sr := by have hζim : (riemannZeta (s : ℂ)).im = 0 := riemannZeta_im_eq_zero_of_one_lt hs have hζeq : riemannZeta (s : ℂ) = ((riemannZeta (s : ℂ)).re : ℂ) := by apply Complex.ext <;> simp [hζim] have : Real.log (riemannZeta (s : ℂ)).re = (Complex.log (riemannZeta (s : ℂ))).re := by conv_rhs => rw [hζeq] rw [Complex.log_ofReal_re] rw [this, hlog_zeta, hSre] rw [hkey] -- now goal: Sr = ∑' n, Λ n / (n^s * log n) -- (V) expand each prime term via real Taylor series have habs : ∀ p : Nat.Primes, |z p| < 1 := by intro p rw [abs_of_pos (hz_pos p)]; exact hz_lt_one p have htaylor : ∀ p : Nat.Primes, HasSum (fun n : ℕ => (z p) ^ (n + 1) / (n + 1)) (-Real.log (1 - z p)) := fun p => hasSum_pow_div_log_of_abs_lt_one (habs p) have hSr_double : Sr = ∑' (p : Nat.Primes) (n : ℕ), (z p) ^ (n + 1) / (n + 1) := by rw [hSr] exact tsum_congr fun p => ((htaylor p).tsum_eq).symm -- summability of the prime sum ∑ z p have hsummable_z : Summable z := Nat.Primes.summable_rpow.mpr (by linarith) -- summability of ∑ p, -log(1 - z p) have hsummable_prime : Summable (fun p : Nat.Primes => -Real.log (1 - z p)) := by have := Real.summable_log_one_add_of_summable hsummable_z.neg convert! this.neg using 1 -- summability of g over the product have hg_nonneg : ∀ pk : Nat.Primes × ℕ, 0 ≤ (z pk.1) ^ (pk.2 + 1) / (pk.2 + 1) := by intro pk; positivity [hz_pos pk.1] have hsummable_g : Summable (fun pk : Nat.Primes × ℕ => (z pk.1) ^ (pk.2 + 1) / (pk.2 + 1)) := by rw [summable_prod_of_nonneg hg_nonneg] refine ⟨fun p => (htaylor p).summable, ?_⟩ refine hsummable_prime.congr (fun p => ?_) exact ((htaylor p).tsum_eq).symm -- pointwise: F (p^(n+1)) = g (p, n) have hpoint : ∀ (p : Nat.Primes) (n : ℕ), Λ ((p : ℕ) ^ (n + 1)) / ((((p : ℕ) ^ (n + 1) : ℕ) : ℝ) ^ s * Real.log (((p : ℕ) ^ (n + 1) : ℕ) : ℝ)) = (z p) ^ (n + 1) / (n + 1) := by intro p n have hp1 : (1 : ℝ) < (p : ℝ) := by exact_mod_cast p.prop.one_lt have hlogp : 0 < Real.log (p : ℝ) := Real.log_pos hp1 rw [vonMangoldt_apply_pow (Nat.succ_ne_zero n), vonMangoldt_apply_prime p.prop] have hcast : (((p : ℕ) ^ (n + 1) : ℕ) : ℝ) = (p : ℝ) ^ (n + 1) := by push_cast; ring rw [hcast, Real.log_pow] rw [show (z p) ^ (n + 1) = ((p : ℝ) ^ (n + 1)) ^ (-s) by rw [hz]; rw [← Real.rpow_natCast ((p : ℝ) ^ (-s)) (n + 1), ← Real.rpow_natCast ((p : ℝ)) (n + 1), ← Real.rpow_mul (by positivity), ← Real.rpow_mul (by positivity)]; ring_nf] rw [Real.rpow_neg (by positivity)] field_simp push_cast ring -- (VI) reindex via the prime-power equivalence set F : ℕ → ℝ := fun n => Λ n / ((n : ℝ) ^ s * Real.log n) with hF -- support of F is contained in prime powers have hsupp : Function.support F ⊆ {n : ℕ | IsPrimePow n} := by intro n hn rw [Function.mem_support] at hn simp only [Set.mem_ofPred_eq] by_contra hpp apply hn simp only [hF, vonMangoldt_eq_zero_iff.mpr hpp, zero_div] -- the product sum equals the subtype sum have hprod_eq : (∑' pk : Nat.Primes × ℕ, (z pk.1) ^ (pk.2 + 1) / (pk.2 + 1)) = ∑' m : {n : ℕ // IsPrimePow n}, F m.val := by rw [← Equiv.tsum_eq Nat.Primes.prodNatEquiv (fun m : {n : ℕ // IsPrimePow n} => F m.val)] apply tsum_congr intro pk rw [Nat.Primes.coe_prodNatEquiv_apply, hF] exact (hpoint pk.1 pk.2).symm -- assemble rw [hSr_double, ← hsummable_g.tsum_prod' (fun p => (htaylor p).summable), hprod_eq] exact tsum_subtype_eq_of_support_subset hsupp section open MeasureTheory Set -- Helpers for `log_zeta_eq_integ` (#1583): Abel summation / sum-integral interchange. namespace LogZetaInteg /-- The summatory coefficient `Λ d / (d log d)`. -/ /- Original line 8042: Mertens.LogZetaInteg.c -/ private noncomputable def c (d : ℕ) : ℝ := Λ d / (d * Real.log d) /-- The per-index integrand: `c d` times the rpow restricted to `Ici (d:ℝ)`. -/ /- Original line 8045: Mertens.LogZetaInteg.f -/ private noncomputable def f (s : ℝ) (d : ℕ) (x : ℝ) : ℝ := c d * (Set.Ici (d:ℝ)).indicator (fun x => x ^ (-s)) x /- Original line 8048: Mertens.LogZetaInteg.c_zero -/ private theorem c_zero : c 0 = 0 := by simp [c] /- Original line 8049: Mertens.LogZetaInteg.c_one -/ private theorem c_one : c 1 = 0 := by simp [c, vonMangoldt_apply_one] /-- `c d ≥ 0` for all `d`. -/ /- Original line 8052: Mertens.LogZetaInteg.c_nonneg -/ private theorem c_nonneg (d : ℕ) : 0 ≤ c d := by unfold c rcases Nat.eq_zero_or_pos d with hd | hd · subst hd; simp · apply div_nonneg vonMangoldt_nonneg have : (0:ℝ) ≤ (d:ℝ) := Nat.cast_nonneg d have hlog : 0 ≤ Real.log d := Real.log_natCast_nonneg d positivity /-- General comparison majorant: `(log n)^a / n^s` is summable for any real `a` and `s > 1`, since `(log x)^a = o(x^ε)` for every `ε > 0`. All the summability conditions below reduce to this by domination. -/ /- Original line 8064: Mertens.LogZetaInteg.summable_log_rpow_div_rpow -/ private theorem summable_log_rpow_div_rpow (a : ℝ) {s : ℝ} (hs : 1 < s) : Summable (fun n : ℕ => (Real.log n) ^ a / (n:ℝ) ^ s) := by have hε : (0:ℝ) < (s - 1) / 2 := by linarith refine summable_of_isBigO_nat (g := fun n : ℕ => (n:ℝ) ^ ((s - 1) / 2 - s)) ?_ ?_ · rw [Real.summable_nat_rpow]; linarith · have ho : (fun x : ℝ => (Real.log x) ^ a) =O[atTop] (fun x : ℝ => x ^ ((s - 1) / 2)) := (isLittleO_log_rpow_rpow_atTop a hε).isBigO have hmul : (fun x : ℝ => (Real.log x) ^ a / x ^ s) =O[atTop] (fun x : ℝ => x ^ ((s - 1) / 2) / x ^ s) := by simpa only [div_eq_mul_inv] using ho.mul (isBigO_refl (fun x : ℝ => (x ^ s)⁻¹) atTop) have heq : (fun x : ℝ => x ^ ((s - 1) / 2) / x ^ s) =ᶠ[atTop] (fun x : ℝ => x ^ ((s - 1) / 2 - s)) := by filter_upwards [eventually_gt_atTop 0] with x hx rw [← Real.rpow_sub hx] exact (hmul.trans_eventuallyEq heq).natCast_atTop /-- Real summability of `Λ n / n^s` for `s > 1`: dominated by `log n / n^s` via `Λ n ≤ log n`. -/ /- Original line 8081: Mertens.LogZetaInteg.summable_vonMangoldt_div_rpow -/ private theorem summable_vonMangoldt_div_rpow (s : ℝ) (hs : 1 < s) : Summable (fun n : ℕ => (Λ n : ℝ) / (n:ℝ) ^ s) := by refine Summable.of_nonneg_of_le (fun n => div_nonneg vonMangoldt_nonneg (by positivity)) ?_ (summable_log_rpow_div_rpow 1 hs) intro n rw [Real.rpow_one] gcongr exact vonMangoldt_le_log /-- Real summability of `Λ n / (n^s * log n)` for `s > 1` (compare with the previous lemma). -/ /- Original line 8091: Mertens.LogZetaInteg.summable_c_term -/ private theorem summable_c_term (s : ℝ) (hs : 1 < s) : Summable (fun d : ℕ => c d * ((d:ℝ) ^ (1 - s) / (s - 1))) := by have hs1 : (0:ℝ) < s - 1 := by linarith have hlog2 : (0:ℝ) < Real.log 2 := Real.log_pos (by norm_num) -- Majorise by `(1/(log 2·(s-1)))·(Λ d/d^s)`, summable by `summable_vonMangoldt_div_rpow`. refine Summable.of_nonneg_of_le (fun d => ?_) (fun d => ?_) ((summable_vonMangoldt_div_rpow s hs).mul_left (1 / (Real.log 2 * (s - 1)))) · -- `0 ≤ c d * (d^(1-s)/(s-1))` refine mul_nonneg (c_nonneg d) (div_nonneg ?_ hs1.le) rcases eq_or_ne (d:ℝ) 0 with hd | hd · rw [hd, Real.zero_rpow (by linarith : (1 - s) ≠ 0)] · positivity · -- `c d * (d^(1-s)/(s-1)) ≤ (1/(log 2·(s-1)))·(Λ d/d^s)` rcases lt_or_ge d 2 with hd | hd · have hc : c d = 0 := by interval_cases d <;> simp [c_zero, c_one] rw [hc, zero_mul] exact mul_nonneg (by positivity) (div_nonneg vonMangoldt_nonneg (by positivity)) · have hd2 : (2:ℝ) ≤ (d:ℝ) := by exact_mod_cast hd have hd0 : (0:ℝ) < (d:ℝ) := by linarith have hlogge : Real.log 2 ≤ Real.log d := Real.log_le_log (by norm_num) hd2 have hds : (0:ℝ) < (d:ℝ) ^ s := Real.rpow_pos_of_pos hd0 s have hkey : c d * ((d:ℝ) ^ (1 - s) / (s - 1)) = Λ d / ((d:ℝ) ^ s * Real.log d * (s - 1)) := by unfold c rw [show (1 - s : ℝ) = -s + 1 by ring, Real.rpow_add hd0, Real.rpow_one, Real.rpow_neg hd0.le] field_simp -- `Λ d / (d^s·log d·(s-1)) ≤ Λ d / (d^s·log 2·(s-1))` since `log 2 ≤ log d`. have hcb : (d:ℝ) ^ s * Real.log 2 * (s - 1) ≤ (d:ℝ) ^ s * Real.log d * (s - 1) := mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left hlogge hds.le) hs1.le rw [hkey, show (1 / (Real.log 2 * (s - 1))) * ((Λ d : ℝ) / (d:ℝ) ^ s) = Λ d / ((d:ℝ) ^ s * Real.log 2 * (s - 1)) from by field_simp] exact div_le_div_of_nonneg_left vonMangoldt_nonneg (by positivity) hcb /-- The integration-by-parts identity (#1583), with explicit qualifiers. -/ /- Original line 8124: Mertens.LogZetaInteg.log_zeta_eq_integ_aux -/ theorem log_zeta_eq_integ_aux (s : ℝ) (hs : 1 < s) : Real.log (riemannZeta (s:ℂ)).re = (s - 1) * ∫ x in Set.Ioi 1, (Real.log (Real.log x) + γ + E₂Λ x) * x ^ (-s) := by rw [Mertens.log_zeta_eq_sum s hs] symm have hstep1 : ∀ x ∈ Set.Ioi (1:ℝ), (Real.log (Real.log x) + γ + E₂Λ x) * x ^ (-s) = (∑ d ∈ Finset.Ioc 0 ⌊x⌋₊, c d) * x ^ (-s) := by intro x hx simp only [Mertens.E₂Λ, c] ring have hstep2 : ∀ x ∈ Set.Ioi (1:ℝ), (Real.log (Real.log x) + γ + E₂Λ x) * x ^ (-s) = ∑' d : ℕ, f s d x := by intro x hx rw [hstep1 x hx] simp only [f] rw [Finset.sum_mul] have hx0 : (0:ℝ) ≤ x := by have := hx; simp only [Set.mem_Ioi] at this; linarith rw [tsum_eq_sum (s := Finset.Ioc 0 ⌊x⌋₊) ?_] · apply Finset.sum_congr rfl intro d hd simp only [Finset.mem_Ioc] at hd have hdx : (d:ℝ) ≤ x := by rw [← Nat.le_floor_iff hx0]; exact hd.2 rw [Set.indicator_of_mem (by simpa [Mertens.LogZetaInteg.c_zero] using hdx)] · intro d hd simp only [Finset.mem_Ioc, not_and, not_le] at hd rcases Nat.eq_zero_or_pos d with hd0 | hd0 · subst hd0; simp[Mertens.LogZetaInteg.c_zero] · have hfloor : ⌊x⌋₊ < d := hd hd0 have hdx : x < (d:ℝ) := by rw [← Nat.floor_lt hx0]; exact hfloor rw [Set.indicator_of_notMem (by simpa [Mertens.LogZetaInteg.c_zero] using not_le.mpr hdx)] ring rw [MeasureTheory.setIntegral_congr_fun measurableSet_Ioi hstep2] have hperterm : ∀ d : ℕ, ∫ x in Set.Ioi (1:ℝ), f s d x = c d * ((d:ℝ) ^ (1 - s) / (s - 1)) := by intro d rcases Nat.eq_zero_or_pos d with hd0 | hd0 · subst hd0; simp [Mertens.LogZetaInteg.c_zero, f] simp only [f] rw [MeasureTheory.integral_const_mul, MeasureTheory.setIntegral_indicator measurableSet_Ici] congr 1 have hdR : (1:ℝ) ≤ (d:ℝ) := by exact_mod_cast hd0 have hdR0 : (0:ℝ) < (d:ℝ) := by exact_mod_cast hd0 set A : Set ℝ := Set.Ioi (1:ℝ) ∩ Set.Ici (d:ℝ) with hA have hae : A =ᵐ[volume] Set.Ioi (d:ℝ) := by have h1 : A =ᵐ[volume] (Set.Ici (1:ℝ) ∩ Set.Ici (d:ℝ) : Set ℝ) := MeasureTheory.ae_eq_set_inter MeasureTheory.Ioi_ae_eq_Ici (ae_eq_refl _) rw [Set.Ici_inter_Ici, max_eq_right hdR] at h1 exact h1.trans MeasureTheory.Ioi_ae_eq_Ici.symm rw [MeasureTheory.setIntegral_congr_set hae] rw [integral_Ioi_rpow_of_lt (by linarith : (-s:ℝ) < -1) hdR0, show (-s + 1 : ℝ) = 1 - s by ring] have hs1 : (1 - s) ≠ 0 := by linarith have hs2 : (s - 1) ≠ 0 := by linarith field_simp ring have hint : ∀ d : ℕ, MeasureTheory.IntegrableOn (f s d) (Set.Ioi (1:ℝ)) := by intro d unfold f apply MeasureTheory.Integrable.const_mul rw [show MeasureTheory.Integrable ((Set.Ici (d:ℝ)).indicator fun x => x ^ (-s)) (volume.restrict (Set.Ioi (1:ℝ))) ↔ MeasureTheory.IntegrableOn ((Set.Ici (d:ℝ)).indicator fun x => x ^ (-s)) (Set.Ioi (1:ℝ)) volume from Iff.rfl, MeasureTheory.integrableOn_indicator_iff measurableSet_Ici] apply MeasureTheory.IntegrableOn.mono_set (integrableOn_Ioi_rpow_of_lt (by linarith : (-s:ℝ) < -1) (by norm_num : (0:ℝ) < 1/2)) intro x hx simp only [Set.mem_inter_iff, Set.mem_Ici, Set.mem_Ioi] at hx ⊢ linarith [hx.2] have hnorm_int : ∀ d : ℕ, ∫ x in Set.Ioi (1:ℝ), ‖f s d x‖ = c d * ((d:ℝ) ^ (1 - s) / (s - 1)) := by intro d rw [← hperterm d] apply MeasureTheory.setIntegral_congr_fun measurableSet_Ioi intro x hx simp only [Set.mem_Ioi] at hx have hfnn : 0 ≤ f s d x := by simp only [f] apply mul_nonneg (c_nonneg d) by_cases hxd : (d:ℝ) ≤ x · rw [Set.indicator_of_mem (by simpa [Mertens.LogZetaInteg.c_zero] using hxd)] exact le_of_lt (Real.rpow_pos_of_pos (by linarith) _) · rw [Set.indicator_of_notMem (by simpa [Mertens.LogZetaInteg.c_zero] using hxd)] change ‖f s d x‖ = f s d x rw [Real.norm_eq_abs, abs_of_nonneg hfnn] have hinterchange : ∫ x in Set.Ioi (1:ℝ), ∑' d : ℕ, f s d x = ∑' d : ℕ, ∫ x in Set.Ioi (1:ℝ), f s d x := by refine (MeasureTheory.integral_tsum_of_summable_integral_norm hint ?_).symm apply (summable_c_term s hs).congr intro d exact (hnorm_int d).symm rw [hinterchange] simp_rw [hperterm] rw [← tsum_mul_left] apply tsum_congr intro d rcases Nat.eq_zero_or_pos d with hd0 | hd0 · subst hd0; simp[Mertens.LogZetaInteg.c_zero] · have hdR : (0:ℝ) < (d:ℝ) := by exact_mod_cast hd0 have hsub : (d:ℝ) ^ (1 - s) = (d:ℝ) ^ (-s) * (d:ℝ) := by rw [show (1 - s : ℝ) = -s + 1 by ring, Real.rpow_add hdR, Real.rpow_one] have hs1 : s - 1 ≠ 0 := by linarith have hneg : (d:ℝ) ^ (-s) = ((d:ℝ) ^ s)⁻¹ := by rw [Real.rpow_neg (le_of_lt hdR)] unfold c rw [hsub, hneg] field_simp end LogZetaInteg end /- Original line 8238: Mertens.log_zeta_eq_integ -/ private theorem log_zeta_eq_integ (s : ℝ) (hs : 1 < s) : log (riemannZeta (s:ℂ)).re = (s - 1) * ∫ x in .Ioi 1, (log (log x) + γ + E₂Λ x) * x^(-s) := LogZetaInteg.log_zeta_eq_integ_aux s hs /- Original line 8243: Mertens.mul_integ_log_log_eq -/ private theorem mul_integ_log_log_eq (s : ℝ) (hs : 1 < s) : (s - 1) * ∫ x in .Ioi 1, log (log x) * x^(-s) = - log (s - 1) + deriv Gamma 1 := mul_integ_log_log_eq_aux s hs /- Original line 8248: Mertens.mul_integ_gamma_eq -/ private theorem mul_integ_gamma_eq (s) (hs : 1 < s) : (s - 1) * ∫ x in .Ioi 1, γ * x^(-s) = γ := by rw [MeasureTheory.integral_const_mul γ (· ^ (-s)), @integral_Ioi_rpow_of_lt (-s), one_rpow] <;> grind -- Integrability helpers for the integral splitting in `log_zeta_eq` (#1319). -- Each summand of `(log (log x) + γ + E₂Λ x) * x^(-s)` is separately integrable on `Ioi 1`. /-- Comparison test for `x ^ (-s)` decay: if `f` is measurable and dominated by `B * x ^ a` on `Set.Ioi c` (with `0 < c` and `a + 1 < s`), then `fun x ↦ f x * x ^ (-s)` is integrable there. This is the integral analogue of the summability of `O(x ^ a / x ^ s)` series and packages the decay estimate reused for each tail in `log_zeta_eq`. -/ /- Original line 8259: Mertens.integrableOn_Ioi_mul_rpow_neg_of_abs_le -/ private theorem integrableOn_Ioi_mul_rpow_neg_of_abs_le {c B a s : ℝ} (hc : 0 < c) (has : a + 1 < s) {f : ℝ → ℝ} (hf : Measurable f) (hbound : ∀ x ∈ Set.Ioi c, |f x| ≤ B * x ^ a) : MeasureTheory.IntegrableOn (fun x => f x * x ^ (-s)) (Set.Ioi c) := by have hg : MeasureTheory.IntegrableOn (fun x => B * x ^ (a - s)) (Set.Ioi c) := (integrableOn_Ioi_rpow_of_lt (by linarith : a - s < -1) hc).const_mul B refine MeasureTheory.Integrable.mono' hg (hf.mul (measurable_id.pow_const (-s))).aestronglyMeasurable ?_ filter_upwards [MeasureTheory.ae_restrict_mem measurableSet_Ioi] with x hx have hxpos : (0:ℝ) < x := hc.trans hx have hxs : (0:ℝ) < x ^ (-s) := Real.rpow_pos_of_pos hxpos _ rw [norm_mul, norm_eq_abs, norm_eq_abs, abs_of_pos hxs] calc |f x| * x ^ (-s) ≤ B * x ^ a * x ^ (-s) := mul_le_mul_of_nonneg_right (hbound x hx) hxs.le _ = B * x ^ (a - s) := by rw [mul_assoc, ← Real.rpow_add hxpos, sub_eq_add_neg] /-- `log (log x) * x ^ (-s)` is integrable on `Ioi 1` for `s > 1` (log-log singularity at `1` is integrable; `x^(-s)` gives decay). -/ /- Original line 8277: Mertens.integrableOn_log_log_mul_rpow -/ private theorem integrableOn_log_log_mul_rpow (s : ℝ) (hs : 1 < s) : MeasureTheory.IntegrableOn (fun x => log (log x) * x ^ (-s)) (Set.Ioi 1) := by rw [← Set.Ioc_union_Ioi_eq_Ioi (by norm_num : (1:ℝ) ≤ 2)] apply MeasureTheory.IntegrableOn.union · -- Near `1`: `log (log x)` is integrable (log-log singularity) and `x^(-s) ≤ 1`. have hll : MeasureTheory.IntegrableOn (fun x => log (log x)) (Set.Ioc 1 2) := by have h : IntervalIntegrable (log ∘ log) MeasureTheory.volume 1 2 := by apply MeromorphicOn.intervalIntegrable_log intro x hx rw [Set.uIcc_of_le (by norm_num : (1:ℝ) ≤ 2)] at hx exact (analyticAt_log (by linarith [hx.1] : 0 < x)).meromorphicAt exact (intervalIntegrable_iff_integrableOn_Ioc_of_le (by norm_num)).mp h have hmul : MeasureTheory.IntegrableOn (fun x => x ^ (-s) * log (log x)) (Set.Ioc 1 2) := by apply hll.bdd_mul (c := 1) · fun_prop · filter_upwards [MeasureTheory.ae_restrict_mem measurableSet_Ioc] with x hx rw [norm_eq_abs, abs_of_nonneg (Real.rpow_nonneg (by linarith [hx.1] : (0:ℝ) ≤ x) _)] calc x ^ (-s) ≤ (1:ℝ) ^ (-s) := Real.rpow_le_rpow_of_nonpos (by norm_num) hx.1.le (by linarith) _ = 1 := Real.one_rpow _ simpa [mul_comm] using hmul · -- Tail (`Ioi 2`): `|log (log x)| ≤ (1/ε + |log (log 2)|)·x^ε` with `ε = (s-1)/2`, `ε + 1 < s`. set ε := (s - 1) / 2 with hε have hεpos : 0 < ε := by rw [hε]; linarith refine integrableOn_Ioi_mul_rpow_neg_of_abs_le (a := ε) (B := 1 / ε + |log (log 2)|) (by norm_num) (by rw [hε]; linarith) (Real.measurable_log.comp Real.measurable_log) ?_ intro x hx simp only [Set.mem_Ioi] at hx have hx1 : (1:ℝ) ≤ x ^ ε := Real.one_le_rpow (by linarith) hεpos.le have hlogx : 0 < log x := Real.log_pos (by linarith) have hlog2 : 0 < log 2 := Real.log_pos (by norm_num) have hmono : log 2 ≤ log x := Real.log_le_log (by norm_num) (by linarith) have hub : log (log x) ≤ x ^ ε / ε := calc log (log x) ≤ log x := (Real.log_le_sub_one_of_pos hlogx).trans (by linarith) _ ≤ x ^ ε / ε := Real.log_le_rpow_div (by linarith) hεpos have hlb : log (log 2) ≤ log (log x) := Real.log_le_log hlog2 hmono have hxε : 0 ≤ x ^ ε / ε := by positivity calc |log (log x)| ≤ x ^ ε / ε + |log (log 2)| := by rw [abs_le] exact ⟨by linarith [neg_abs_le (log (log 2))], by linarith [abs_nonneg (log (log 2))]⟩ _ ≤ (1 / ε + |log (log 2)|) * x ^ ε := by have h2 : |log (log 2)| ≤ |log (log 2)| * x ^ ε := le_mul_of_one_le_right (abs_nonneg _) hx1 have h1 : x ^ ε / ε = 1 / ε * x ^ ε := by ring rw [add_mul]; linarith /-- `γ * x ^ (-s)` is integrable on `Ioi 1` for `s > 1`. -/ /- Original line 8324: Mertens.integrableOn_γ_mul_rpow -/ private theorem integrableOn_γ_mul_rpow (s : ℝ) (hs : 1 < s) : MeasureTheory.IntegrableOn (fun x => γ * x ^ (-s)) (Set.Ioi 1) := by exact (integrableOn_Ioi_rpow_of_lt (by linarith : -s < -1) one_pos).const_mul γ /-- `E₂Λ x * x ^ (-s)` is integrable on `Ioi 1` for `s > 1` (`E₂Λ ~ -log(log x)` near `1`, and `E₂Λ = O(1/log x)` at `∞`). -/ /- Original line 8330: Mertens.integrableOn_E₂Λ_mul_rpow -/ private theorem integrableOn_E₂Λ_mul_rpow (s : ℝ) (hs : 1 < s) : MeasureTheory.IntegrableOn (fun x => E₂Λ x * x ^ (-s)) (Set.Ioi 1) := by rw [← Set.Ioo_union_Ici_eq_Ioi (by norm_num : (1:ℝ) < 2)] apply MeasureTheory.IntegrableOn.union · -- Near `1`: `⌊x⌋₊ = 1`, the sum is `0`, so `E₂Λ x = -log (log x) - γ`. have hsub : Set.Ioo (1:ℝ) 2 ⊆ Set.Ioi 1 := fun x hx => hx.1 have h1 := (integrableOn_γ_mul_rpow s hs).mono_set hsub have h2 := (integrableOn_log_log_mul_rpow s hs).mono_set hsub have hb : MeasureTheory.IntegrableOn (fun x => -(log (log x) * x ^ (-s)) - γ * x ^ (-s)) (Set.Ioo 1 2) := h2.neg.sub h1 apply hb.congr_fun _ measurableSet_Ioo intro x hx simp only [Set.mem_Ioo] at hx have hfloor : ⌊ x ⌋₊ = 1 := by rw [Nat.floor_eq_iff (by linarith)] exact ⟨by push_cast; linarith [hx.1], by push_cast; linarith [hx.2]⟩ have hsum : (∑ d ∈ Ioc 0 ⌊ x ⌋₊, (Λ d) / ((d:ℝ) * log d)) = 0 := by rw [hfloor]; norm_num change -(log (log x) * x ^ (-s)) - γ * x ^ (-s) = (∑ d ∈ Ioc 0 ⌊ x ⌋₊, (Λ d) / (d * log d) - log (log x) - γ) * x ^ (-s) rw [hsum]; ring · -- Tail: `|E₂Λ x| ≤ (log 4 + 6)/log x ≤ (log 4 + 6)/log 2` is bounded (`a = 0`), times decay. rw [integrableOn_Ici_iff_integrableOn_Ioi] refine integrableOn_Ioi_mul_rpow_neg_of_abs_le (a := 0) (B := (log 4 + 6) / log 2) (by norm_num) (by linarith) (by fun_prop) ?_ intro x hx simp only [Set.mem_Ioi] at hx have hlog2 : 0 < log 2 := Real.log_pos (by norm_num) have hc : 0 ≤ log 4 + 6 := by positivity rw [Real.rpow_zero, mul_one] have hb2 : (log 4 + 6) / log x ≤ (log 4 + 6) / log 2 := div_le_div_of_nonneg_left hc hlog2 (Real.log_le_log (by norm_num) (le_of_lt hx)) exact (E₂Λ.abs_le (le_of_lt hx)).trans hb2 /- Original line 8365: Mertens.log_zeta_eq -/ private theorem log_zeta_eq (s : ℝ) (hs : 1 < s) : log (riemannZeta (s:ℂ)).re = - log (s - 1) + deriv Gamma 1 + γ + (s - 1) * ∫ x in Set.Ioi 1, E₂Λ x * x^(-s) := by -- Start from the integration-by-parts identity (#1583). rw [log_zeta_eq_integ s hs] -- Linearity of the integral: split into the three summands (uses the integrability helpers). have key : (∫ x in Set.Ioi 1, (log (log x) + γ + E₂Λ x) * x ^ (-s)) = (∫ x in Set.Ioi 1, log (log x) * x ^ (-s)) + (∫ x in Set.Ioi 1, γ * x ^ (-s)) + (∫ x in Set.Ioi 1, E₂Λ x * x ^ (-s)) := by rw [← MeasureTheory.integral_add (integrableOn_log_log_mul_rpow s hs) (integrableOn_γ_mul_rpow s hs)] rw [← MeasureTheory.integral_add (f := fun x => log (log x) * x ^ (-s) + γ * x ^ (-s)) (g := fun x => E₂Λ x * x ^ (-s)) ((integrableOn_log_log_mul_rpow s hs).add (integrableOn_γ_mul_rpow s hs)) (integrableOn_E₂Λ_mul_rpow s hs)] apply MeasureTheory.setIntegral_congr_fun measurableSet_Ioi intro x _ ring -- Apply sublemmas #1584 and #1585, then finish algebraically. rw [key, mul_add, mul_add, mul_integ_log_log_eq s hs, mul_integ_gamma_eq s hs] /- Original line 8386: Mertens.zeta_pole_mul_re_tendsto_one -/ private theorem zeta_pole_mul_re_tendsto_one : Filter.Tendsto (fun s : ℝ => (s - 1) * (riemannZeta (s : ℂ)).re) (nhdsWithin 1 (Set.Ioi 1)) (nhds 1) := by have hofReal : Filter.Tendsto (fun s : ℝ => (s : ℂ)) (nhdsWithin 1 (Set.Ioi 1)) (nhdsWithin (1 : ℂ) ({1} : Set ℂ)ᶜ) := by refine tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within _ ?_ ?_ · exact (Complex.continuous_ofReal.tendsto 1).mono_left nhdsWithin_le_nhds · filter_upwards [self_mem_nhdsWithin] with s hs exact Set.mem_compl_singleton_iff.mpr (by norm_num exact ne_of_gt (Set.mem_Ioi.mp hs)) have hcomplex : Filter.Tendsto (fun s : ℝ => ((s : ℂ) - 1) * riemannZeta (s : ℂ)) (nhdsWithin 1 (Set.Ioi 1)) (nhds 1) := riemannZeta_residue_one.comp hofReal have hreal : Filter.Tendsto (fun s : ℝ => (((s : ℂ) - 1) * riemannZeta (s : ℂ)).re) (nhdsWithin 1 (Set.Ioi 1)) (nhds (1 : ℝ)) := (Complex.continuous_re.tendsto (1 : ℂ)).comp hcomplex simpa [Complex.ofReal_sub, Complex.ofReal_mul] using hreal /- Original line 8410: Mertens.log_zeta_limit -/ private theorem log_zeta_limit : Filter.Tendsto (fun s : ℝ => Real.log (riemannZeta (s : ℂ)).re + Real.log (s - 1)) (nhdsWithin 1 (Set.Ioi 1)) (nhds 0) := by have hlog : Filter.Tendsto (fun s : ℝ => Real.log ((s - 1) * (riemannZeta (s : ℂ)).re)) (nhdsWithin 1 (Set.Ioi 1)) (nhds (Real.log 1)) := (Real.continuousAt_log (by norm_num : (1 : ℝ) ≠ 0)).tendsto.comp zeta_pole_mul_re_tendsto_one have hEq : (fun s : ℝ => Real.log (riemannZeta (s : ℂ)).re + Real.log (s - 1)) =ᶠ[nhdsWithin 1 (Set.Ioi 1)] fun s : ℝ => Real.log ((s - 1) * (riemannZeta (s : ℂ)).re) := by filter_upwards [self_mem_nhdsWithin] with s hs have hspos : 0 < s - 1 := sub_pos.mpr (Set.mem_Ioi.mp hs) have hzpos : 0 < (riemannZeta (s : ℂ)).re := riemannZeta_re_pos_of_one_lt (Set.mem_Ioi.mp hs) rw [Real.log_mul hspos.ne' hzpos.ne'] ring simpa using hlog.congr' (hEq.mono fun s hs => hs.symm) -- Helpers for `deriv_gamma_add_γ_eq_zero` (#1320): take `s → 1⁺` in `log_zeta_eq`. section open MeasureTheory Set /-- `E₂Λ` is measurable: its Mangoldt-sum part factors through `⌊·⌋₊` and the rest is continuous/measurable. -/ /- Original line 8438: Mertens.measurable_E₂Λ -/ private theorem measurable_E₂Λ : Measurable E₂Λ := by fun_prop /-- On `(1,2)` the Mangoldt sum is empty (`⌊x⌋₊ = 1`), so `E₂Λ x = - log (log x) - γ`. -/ /- Original line 8441: Mertens.E₂Λ_eq_on_Ioo -/ private theorem E₂Λ_eq_on_Ioo {x : ℝ} (hx : x ∈ Set.Ioo (1 : ℝ) 2) : E₂Λ x = - log (log x) - γ := by obtain ⟨h1, h2⟩ := hx have hf : ⌊x⌋₊ = 1 := by rw [Nat.floor_eq_iff (by linarith)] exact ⟨by exact_mod_cast h1.le, by exact_mod_cast h2⟩ unfold E₂Λ rw [hf] simp /-- Domination of `|E₂Λ|` near `1`: for `x ∈ (1,2)`, `|E₂Λ x| ≤ |log (x-1)| + log 2 + |γ|`, the RHS being integrable on `(1,2)` (the `log (x-1)` is integrable across the singularity at `1`). -/ /- Original line 8453: Mertens.abs_E₂Λ_le_on_Ioo -/ private theorem abs_E₂Λ_le_on_Ioo {x : ℝ} (hx : x ∈ Set.Ioo (1 : ℝ) 2) : |E₂Λ x| ≤ |log (x - 1)| + log 2 + |γ| := by obtain ⟨hx1, hx2⟩ := hx have hloglog : |log (log x)| ≤ |log (x - 1)| + log 2 := by have hxpos : (0:ℝ) < x := by linarith have hlogx_pos : 0 < log x := Real.log_pos hx1 have hxm1 : 0 < x - 1 := by linarith have hub : log x ≤ x - 1 := by have := Real.log_le_sub_one_of_pos hxpos; linarith have hlb2 : (x - 1) / 2 ≤ log x := by have h := Real.log_le_sub_one_of_pos (x := 1 / x) (by positivity) rw [Real.log_div one_ne_zero (by positivity), Real.log_one] at h simp only [zero_sub] at h have h12 : (x - 1) / 2 ≤ 1 - 1 / x := by rw [← sub_nonneg] have e : (1 - 1 / x) - (x - 1) / 2 = (3 * x - 2 - x ^ 2) / (2 * x) := by field_simp; ring rw [e]; exact div_nonneg (by nlinarith [hx1, hx2]) (by positivity) linarith have hupper : log (log x) ≤ log (x - 1) := Real.log_le_log hlogx_pos hub have hlower : log (x - 1) - log 2 ≤ log (log x) := by have := Real.log_le_log (show (0:ℝ) < (x - 1) / 2 by positivity) hlb2 rwa [Real.log_div (by linarith) (by norm_num)] at this have h2 : (0:ℝ) ≤ log 2 := Real.log_nonneg (by norm_num) rw [abs_le] exact ⟨by have := neg_abs_le (log (x - 1)); linarith, by have := le_abs_self (log (x - 1)); linarith⟩ rw [E₂Λ_eq_on_Ioo ⟨hx1, hx2⟩] have htri : |(- log (log x) - γ)| ≤ |log (log x)| + |γ| := by have h := abs_sub (-log (log x)) γ rwa [abs_neg] at h linarith /-- Constant bound on `|E₂Λ|` for `2 ≤ x`, sharpening `E₂Λ.abs_le` via `log 2 ≤ log x`. -/ /- Original line 8485: Mertens.abs_E₂Λ_le_const -/ private theorem abs_E₂Λ_le_const {x : ℝ} (hx : 2 ≤ x) : |E₂Λ x| ≤ (log 4 + 6) / log 2 := (E₂Λ.abs_le hx).trans <| div_le_div_of_nonneg_left (by positivity) (Real.log_pos (by norm_num)) (Real.log_le_log (by norm_num) hx) /-- The near-1 dominating function `|log (x-1)| + log 2 + |γ|` is integrable on `(1,2)` (it dominates `|E₂Λ|` there, handling the log-log singularity at `1`). -/ /- Original line 8492: Mertens.integrableOn_log_sub_one_bound -/ private theorem integrableOn_log_sub_one_bound : IntegrableOn (fun x => |log (x - 1)| + log 2 + |γ|) (Set.Ioo 1 2) volume := by have hlog : IntegrableOn (fun x => |log (x - 1)|) (Set.Ioo 1 2) volume := by have h0 : IntervalIntegrable (fun x => log x) volume 0 1 := intervalIntegral.intervalIntegrable_log' have h1 : IntervalIntegrable (fun x => log (x - 1)) volume (0 + 1) (1 + 1) := h0.comp_sub_right 1 norm_num at h1 exact (h1.1.mono_set Set.Ioo_subset_Ioc_self).abs have hc : IntegrableOn (fun _ : ℝ => log 2 + |γ|) (Set.Ioo (1 : ℝ) 2) volume := integrableOn_const (measure_Ioo_lt_top).ne (by finiteness) have hsum : IntegrableOn (fun x => |log (x - 1)| + (log 2 + |γ|)) (Set.Ioo 1 2) volume := hlog.add hc exact hsum.congr_fun (fun x _ => by ring) measurableSet_Ioo /-- `E₂Λ` is integrable on every bounded interval `(1, X)` (`X ≥ 2`): log-log singularity near `1` plus boundedness on `[2, X]`. -/ /- Original line 8509: Mertens.integrableOn_E₂Λ_Ioo -/ private theorem integrableOn_E₂Λ_Ioo {X : ℝ} (_hX : 2 ≤ X) : IntegrableOn E₂Λ (Set.Ioo 1 X) volume := by have hsub : Set.Ioo (1 : ℝ) X ⊆ Set.Ioo 1 2 ∪ Set.Icc 2 X := by intro x hx; simp only [Set.mem_Ioo, Set.mem_union, Set.mem_Icc] at * rcases lt_or_ge x 2 with h | h · exact Or.inl ⟨hx.1, h⟩ · exact Or.inr ⟨h, hx.2.le⟩ apply IntegrableOn.mono_set _ hsub apply IntegrableOn.union · have hg := integrableOn_log_sub_one_bound refine Integrable.mono' hg measurable_E₂Λ.aestronglyMeasurable ?_ filter_upwards [self_mem_ae_restrict measurableSet_Ioo] with x hx rw [Real.norm_eq_abs]; exact abs_E₂Λ_le_on_Ioo hx · refine Integrable.mono' (g := fun _ => (log 4 + 6) / log 2) ?_ measurable_E₂Λ.aestronglyMeasurable ?_ · exact integrableOn_const (by rw [Real.volume_Icc]; exact ENNReal.ofReal_ne_top) (by finiteness) · filter_upwards [self_mem_ae_restrict measurableSet_Icc] with x hx rw [Real.norm_eq_abs]; exact abs_E₂Λ_le_const hx.1 /-- The error integral, scaled by `(s-1)`, vanishes as `s → 1⁺` (uses `E₂Λ =o(1)`). -/ /- Original line 8529: Mertens.sub_one_mul_integral_E₂Λ_tendsto -/ private theorem sub_one_mul_integral_E₂Λ_tendsto : Filter.Tendsto (fun s : ℝ => (s - 1) * ∫ x in Set.Ioi 1, E₂Λ x * x ^ (-s)) (nhdsWithin 1 (Set.Ioi 1)) (nhds 0) := by rw [Metric.tendsto_nhdsWithin_nhds] intro ε hε -- Choose `X ≥ 2` so that `|E₂Λ x| ≤ ε/2` for `x ≥ X` (from `E₂Λ =o(1)`). obtain ⟨X₀, hX₀⟩ : ∃ X, ∀ x ≥ X, |E₂Λ x| ≤ ε / 2 := by have := E₂Λ.bound'.def (by positivity : (0:ℝ) < ε / 2) simp only [Real.norm_eq_abs, abs_one, mul_one] at this rw [Filter.eventually_atTop] at this; exact this set X := max X₀ 2 with hXdef have hX2 : 2 ≤ X := le_max_right _ _ have hXge : ∀ x ≥ X, |E₂Λ x| ≤ ε / 2 := fun x hx => hX₀ x (le_trans (le_max_left _ _) hx) -- `B` is the (finite) mass of `|E₂Λ|` on `(1, X)`. set B := ∫ x in Set.Ioo 1 X, |E₂Λ x| with hBdef have hB0 : 0 ≤ B := setIntegral_nonneg measurableSet_Ioo (fun x _ => abs_nonneg _) refine ⟨min 1 (ε / 2 / (B + 1)), by positivity, ?_⟩ intro s hs hdist simp only [Set.mem_Ioi] at hs rw [Real.dist_eq] at hdist have hs1 : s - 1 < min 1 (ε / 2 / (B + 1)) := by rw [abs_of_pos (by linarith)] at hdist; exact hdist have hsm1 : 0 < s - 1 := by linarith -- `|E₂Λ|·x^(-s)` is integrable on `(1,∞)` and its subintervals. have hintAbs : IntegrableOn (fun x => |E₂Λ x| * x ^ (-s)) (Set.Ioi 1) volume := by have h2 : IntegrableOn (fun x => |E₂Λ x * x ^ (-s)|) (Set.Ioi 1) volume := (integrableOn_E₂Λ_mul_rpow s hs).abs refine h2.congr_fun ?_ measurableSet_Ioi intro x hx; simp only [Set.mem_Ioi] at hx change |E₂Λ x * x ^ (-s)| = |E₂Λ x| * x ^ (-s) rw [abs_mul, abs_of_nonneg (Real.rpow_nonneg (by linarith) _)] have hintAbsIoc : IntegrableOn (fun x => |E₂Λ x| * x ^ (-s)) (Set.Ioc 1 X) volume := hintAbs.mono_set Set.Ioc_subset_Ioi_self have hintAbsIoiX : IntegrableOn (fun x => |E₂Λ x| * x ^ (-s)) (Set.Ioi X) volume := hintAbs.mono_set (Set.Ioi_subset_Ioi (by linarith)) -- Split `∫_{(1,∞)} = ∫_{(1,X]} + ∫_{(X,∞)}`. have hsplit : ∫ x in Set.Ioi 1, |E₂Λ x| * x ^ (-s) = (∫ x in Set.Ioc 1 X, |E₂Λ x| * x ^ (-s)) + ∫ x in Set.Ioi X, |E₂Λ x| * x ^ (-s) := by have hu : Set.Ioi (1:ℝ) = Set.Ioc 1 X ∪ Set.Ioi X := (Set.Ioc_union_Ioi_eq_Ioi (by linarith)).symm rw [hu, setIntegral_union (Set.Ioc_disjoint_Ioi le_rfl) measurableSet_Ioi (hintAbs.mono_set (by rw [hu]; exact Set.subset_union_left)) (hintAbs.mono_set (by rw [hu]; exact Set.subset_union_right))] -- Piece 1: on `(1,X]`, `x^(-s) ≤ 1`, so the integral is `≤ B`. have hp1 : ∫ x in Set.Ioc 1 X, |E₂Λ x| * x ^ (-s) ≤ B := by rw [hBdef] have ha : IntegrableOn (fun x => |E₂Λ x|) (Set.Ioo 1 X) volume := (integrableOn_E₂Λ_Ioo hX2).abs have habsIoc : IntegrableOn (fun x => |E₂Λ x|) (Set.Ioc 1 X) volume := ha.congr_set_ae (Ioo_ae_eq_Ioc).symm rw [← integral_Ioc_eq_integral_Ioo] apply setIntegral_mono_on hintAbsIoc habsIoc measurableSet_Ioc intro x hx have hx1 : (1:ℝ) ≤ x := by have := hx.1; linarith have hle1 : x ^ (-s) ≤ 1 := Real.rpow_le_one_of_one_le_of_nonpos hx1 (by linarith) calc |E₂Λ x| * x ^ (-s) ≤ |E₂Λ x| * 1 := by gcongr _ = |E₂Λ x| := mul_one _ -- Piece 2: on `(X,∞)`, `|E₂Λ| ≤ ε/2`, and `∫_{(X,∞)} x^(-s) = X^(1-s)/(s-1)`. have hp2 : ∫ x in Set.Ioi X, |E₂Λ x| * x ^ (-s) ≤ (ε / 2) * (X ^ (1 - s) / (s - 1)) := by have hrpow_int : IntegrableOn (fun x : ℝ => x ^ (-s)) (Set.Ioi X) volume := integrableOn_Ioi_rpow_of_lt (by linarith) (by linarith : (0:ℝ) < X) have hval : ∫ x in Set.Ioi X, x ^ (-s) = X ^ (1 - s) / (s - 1) := by rw [integral_Ioi_rpow_of_lt (by linarith) (by linarith : (0:ℝ) < X), show -s + 1 = 1 - s by ring, show (1:ℝ) - s = -(s - 1) by ring] rw [div_neg, neg_div, neg_neg] rw [← hval, ← integral_const_mul] apply setIntegral_mono_on hintAbsIoiX (hrpow_int.const_mul (ε / 2)) measurableSet_Ioi intro x hx have hxpos : (0:ℝ) < x := by simp only [Set.mem_Ioi] at hx; linarith have hnn : 0 ≤ x ^ (-s) := Real.rpow_nonneg hxpos.le _ have hb : |E₂Λ x| ≤ ε / 2 := hXge x (by simp only [Set.mem_Ioi] at hx; linarith) gcongr have hXpow : X ^ (1 - s) ≤ 1 := Real.rpow_le_one_of_one_le_of_nonpos (by linarith) (by linarith) -- Assemble: `(s-1)·∫|E₂Λ|·x^(-s) ≤ (s-1)·B + ε/2`. have hbound : (s - 1) * ∫ x in Set.Ioi 1, |E₂Λ x| * x ^ (-s) ≤ (s - 1) * B + ε / 2 := by rw [hsplit, mul_add] have ht2 : (s - 1) * ∫ x in Set.Ioi X, |E₂Λ x| * x ^ (-s) ≤ ε / 2 := by calc (s - 1) * ∫ x in Set.Ioi X, |E₂Λ x| * x ^ (-s) ≤ (s - 1) * ((ε / 2) * (X ^ (1 - s) / (s - 1))) := mul_le_mul_of_nonneg_left hp2 hsm1.le _ = (ε / 2) * X ^ (1 - s) := by have hne : s - 1 ≠ 0 := by linarith field_simp _ ≤ (ε / 2) * 1 := by gcongr _ = ε / 2 := mul_one _ have ht1 : (s - 1) * ∫ x in Set.Ioc 1 X, |E₂Λ x| * x ^ (-s) ≤ (s - 1) * B := mul_le_mul_of_nonneg_left hp1 hsm1.le linarith -- `|(s-1)·∫ E₂Λ·x^(-s)| ≤ (s-1)·∫|E₂Λ|·x^(-s)`. have habs_le : |(s - 1) * ∫ x in Set.Ioi 1, E₂Λ x * x ^ (-s)| ≤ (s - 1) * ∫ x in Set.Ioi 1, |E₂Λ x| * x ^ (-s) := by rw [abs_mul, abs_of_pos hsm1] gcongr rw [← Real.norm_eq_abs] refine (norm_integral_le_integral_norm _).trans_eq ?_ refine setIntegral_congr_fun measurableSet_Ioi (fun x hx => ?_) simp only [Set.mem_Ioi] at hx change ‖E₂Λ x * x ^ (-s)‖ = |E₂Λ x| * x ^ (-s) rw [Real.norm_eq_abs, abs_mul, abs_of_nonneg (Real.rpow_nonneg (by linarith) _)] rw [Real.dist_eq, sub_zero] -- `(s-1)·B + ε/2 < ε` since `s - 1 < ε/2/(B+1)`. have hfin : (s - 1) * B + ε / 2 < ε := by have hlt : s - 1 < ε / 2 / (B + 1) := lt_of_lt_of_le hs1 (min_le_right _ _) have hBp : 0 < B + 1 := by linarith have h1 : (s - 1) * B ≤ (s - 1) * (B + 1) := by nlinarith have h2 : (s - 1) * (B + 1) < (ε / 2 / (B + 1)) * (B + 1) := mul_lt_mul_of_pos_right hlt hBp have h3 : (ε / 2 / (B + 1)) * (B + 1) = ε / 2 := by field_simp linarith calc |(s - 1) * ∫ x in Set.Ioi 1, E₂Λ x * x ^ (-s)| ≤ (s - 1) * ∫ x in Set.Ioi 1, |E₂Λ x| * x ^ (-s) := habs_le _ ≤ (s - 1) * B + ε / 2 := hbound _ < ε := hfin end /- Original line 8645: Mertens.deriv_gamma_add_γ_eq_zero -/ theorem deriv_gamma_add_γ_eq_zero : deriv Gamma 1 + γ = 0 := by -- For `s > 1`, `log_zeta_eq` rearranges to a constant identity. have key : ∀ s : ℝ, 1 < s → (Real.log (riemannZeta (s:ℂ)).re + Real.log (s - 1)) - (s - 1) * ∫ x in Set.Ioi 1, E₂Λ x * x ^ (-s) = deriv Gamma 1 + γ := by intro s hs have h := log_zeta_eq s hs linarith -- The LHS is eventually constant, so its limit is that constant. have hconst : Filter.Tendsto (fun s : ℝ => (Real.log (riemannZeta (s:ℂ)).re + Real.log (s - 1)) - (s - 1) * ∫ x in Set.Ioi 1, E₂Λ x * x ^ (-s)) (nhdsWithin 1 (Set.Ioi 1)) (nhds (deriv Gamma 1 + γ)) := by refine Filter.Tendsto.congr' ?_ tendsto_const_nhds filter_upwards [self_mem_nhdsWithin] with s hs exact (key s hs).symm -- But the same function tends to `0 - 0` by the two limit lemmas. have hlim := log_zeta_limit.sub sub_one_mul_integral_E₂Λ_tendsto rw [sub_zero] at hlim exact tendsto_nhds_unique hconst hlim /- Original line 8666: Mertens.γ.eq_eulerMascheroni -/ theorem γ.eq_eulerMascheroni : γ = eulerMascheroniConstant := by linarith [Real.eulerMascheroniConstant_eq_neg_deriv, deriv_gamma_add_γ_eq_zero] /- Original line 8669: Mertens.sum_mangoldt_div_log_eq -/ theorem sum_mangoldt_div_log_eq (x : ℝ) : ∑ d ∈ Ioc 0 ⌊ x ⌋₊, (Λ d) / (d * log d) = log (log x) + eulerMascheroniConstant + E₂Λ x := by grind [γ.eq_eulerMascheroni] /- Original line 8673: Mertens.sum_mangoldt_div_log_eq_log_log -/ theorem sum_mangoldt_div_log_eq_log_log : ∃ C, ∀ x, 2 ≤ x → |∑ d ∈ Ioc 0 ⌊ x ⌋₊, (Λ d) / (d * log d) - log (log x)| ≤ C := by use (log 4 + 6)/log 2 + |eulerMascheroniConstant| intro x hx rw [sum_mangoldt_div_log_eq] calc _ = |E₂Λ x + eulerMascheroniConstant| := by ring_nf _ ≤ (log 4 + 6)/log x + |eulerMascheroniConstant| := by grw [abs_add_le, E₂Λ.abs_le hx] _ ≤ _ := by gcongr /- Original line 8684: Mertens.sum_mangoldt_div_log_eq_log_log' -/ theorem sum_mangoldt_div_log_eq_log_log' : (fun x ↦ ∑ d ∈ Ioc 0 ⌊ x ⌋₊, (Λ d) / (d * log d) - log (log x)) =O[atTop] (fun _ ↦ (1:ℝ)) := by simp only [isBigO_iff, norm_eq_abs, one_mem, CStarRing.norm_of_mem_unitary, mul_one, eventually_atTop] obtain ⟨ C, _ ⟩ := sum_mangoldt_div_log_eq_log_log use C, 2 /- Original line 8692: Mertens.sum_mangoldt_div_log_eq_log_log'' -/ theorem sum_mangoldt_div_log_eq_log_log'' : (fun x ↦ ∑ d ∈ Ioc 0 ⌊ x ⌋₊, (Λ d) / (d * log d)) ~[atTop] (fun x ↦ log (log x)) := by apply IsLittleO.isEquivalent (IsBigO.trans_isLittleO _ one_eq_o_log_log) convert! sum_mangoldt_div_log_eq_log_log' using 1 /- Original line 8697: Mertens.M -/ noncomputable def M : ℝ := (∫ t in Set.Ioi 2, E₁p t / (t * log t^2)) + 1 - log (log 2) /- Original line 8700: Mertens.M.le -/ theorem M.le : M ≤ (log 4 + 4) / log 2 + 1 - log (log 2) := calc _ ≤ (∫ t in Set.Ioi 2, (log 4 + 4) / (t * log t^2)) + 1 - log (log 2) := by unfold M; gcongr with x hx · exact integrable_E₁p_div_mul_log_sq (by norm_num) · exact integrable_const_div_mul_log_sq _ (by norm_num) · measurability · simp at hx; positivity simp at hx; exact E₁p.le (by linarith) _ = _ := by rw [integ_div_mul_log_sq _ (by norm_num)] /- Original line 8711: Mertens.M.ge -/ theorem M.ge : M ≥ (-2 - E₁) / log 2 + 1 - log (log 2) := calc _ ≥ (∫ t in Set.Ioi 2, (-2 - E₁) / (t * log t^2)) + 1 - log (log 2) := by unfold M; gcongr with x hx · exact integrable_const_div_mul_log_sq _ (by norm_num) · exact integrable_E₁p_div_mul_log_sq (by norm_num) · measurability · simp at hx; positivity simp at hx; exact E₁p.ge (by linarith) _ = _ := by rw [integ_div_mul_log_sq _ (by norm_num)] /- Original line 8722: Mertens.E₂p -/ noncomputable abbrev E₂p (x : ℝ) : ℝ := ∑ p ∈ Ioc 0 ⌊ x ⌋₊ with p.Prime, (1:ℝ) / p - log (log x) - M /- Original line 8724: Mertens.sum_prime_div_eq -/ theorem sum_prime_div_eq (x : ℝ) : ∑ p ∈ Ioc 0 ⌊ x ⌋₊ with p.Prime, (1:ℝ) / p = log (log x) + M + E₂p x := by ring /- Original line 8728: Mertens.E₂p.eq -/ theorem E₂p.eq {x : ℝ} (hx : 2 ≤ x) : E₂p x = E₁p x / log x - ∫ t in Set.Ioi x, E₁p t / (t * log t^2) := by unfold E₂p rw [sum_filter, ← sum_Ioc_one_eq_sum_Ioc_zero (Nat.le_floor (by grind)) (by simp [Nat.not_prime_one])] have (n : ℕ) : (if Nat.Prime n then (1 : ℝ) / n else 0) = (if Nat.Prime n then log n / n else 0) / log n := by split_ifs with h · have : log n ≠ 0 := by simp; grind [h.two_le] field · simp simp_rw [this] rw [sum_div_log_eq hx, sum_Ioc_one_eq_sum_Ioc_zero (Nat.le_floor (by grind)) (by simp), ← sum_filter] rw [sum_log_prime_div_eq] have : ∫ t in 2..x, (∑ n ∈ Ioc 1 ⌊t⌋₊, if Nat.Prime n then log ↑n / ↑n else 0) / (t * log t ^ 2) = ∫ t in 2..x, (1 / (t * log t) + E₁p t / (t * log t ^2)) := by refine intervalIntegral.integral_congr fun t ht ↦ ?_ rw [Set.uIcc_of_le hx, Set.mem_Icc] at ht rw [sum_Ioc_one_eq_sum_Ioc_zero (Nat.le_floor (by grind)) (by simp), ← sum_filter, sum_log_prime_div_eq] field rw [this, intervalIntegral.integral_add] · rw [integral_one_div_mul_log hx, add_div, div_self (by simp; grind)] unfold M calc _ = E₁p x / log x + (∫ (x : ℝ) in 2..x, E₁p x / (x * log x ^ 2)) - ((∫ (t : ℝ) in Set.Ioi 2, E₁p t / (t * log t ^ 2))) := by ring _ = _ := by rw [← intervalIntegral.integral_interval_add_Ioi (integrable_E₁p_div_mul_log_sq (by rfl)) (integrable_E₁p_div_mul_log_sq hx)] ring · exact intervalIntegrable_one_div_mul_log hx · rw [intervalIntegrable_iff, Set.uIoc_of_le hx] exact integrable_E₁p_div_mul_log_sq (x := 2) (by rfl)|>.mono (by grind) (by rfl) /- Original line 8759: Mertens.E₂p.abs_le -/ theorem E₂p.abs_le {x : ℝ} (hx : 2 ≤ x) : |E₂p x| ≤ (log 4 + 6 + E₁) / log x := by have : 0 < log x := by apply log_pos; linarith rw [E₂p.eq hx, abs_le'] constructor · grw [E₁p.le (by linarith)] have : ∫ t in Set.Ioi x, E₁p t / (t * log t^2) ≥ (- 2 - E₁) / log x := calc _ ≥ ∫ t in Set.Ioi x, (-2 - E₁) / (t * log t^2) := by apply MeasureTheory.setIntegral_mono_on (integrable_const_div_mul_log_sq (-2 - E₁) hx) (integrable_E₁p_div_mul_log_sq hx) (by measurability) intro y hy; simp at hy have : 1 < y := by linarith have : 0 < log y := log_pos this gcongr; exact E₁p.ge (by linarith) _ = _ := integ_div_mul_log_sq (-2 - E₁) hx grw [this] grind grw [E₁p.ge (by linarith)] have : ∫ t in Set.Ioi x, E₁p t / (t * log t^2) ≤ (log 4 + 4) / log x := calc _ ≤ ∫ t in Set.Ioi x, (log 4 + 4) / (t * log t^2) := by apply MeasureTheory.setIntegral_mono_on (integrable_E₁p_div_mul_log_sq hx) (integrable_const_div_mul_log_sq (log 4 + 4) hx) (by measurability) intro y hy; simp at hy have : 1 < y := by linarith have : 0 < log y := log_pos this gcongr; exact E₁p.le (by linarith) _ = _ := integ_div_mul_log_sq (log 4 + 4) hx grw [this] grind /- Original line 8790: Mertens.E₂p.bound -/ theorem E₂p.bound : E₂p =O[atTop] (fun x ↦ 1 / log x) := by simp only [one_div, isBigO_iff, norm_eq_abs, norm_inv, eventually_atTop] use log 4 + 6 + E₁, 2 intro x hx convert E₂p.abs_le hx using 1 have : 0 < log x := by apply log_pos; linarith grind [abs_of_pos this] /- Original line 8799: Mertens.E₂p.bound' -/ theorem E₂p.bound' : E₂p =o[atTop] (fun _ ↦ (1:ℝ)) := E₂p.bound.trans_isLittleO inv_log_eq_o_one /- Original line 8802: Mertens.sum_prime_div_eq_log_log -/ theorem sum_prime_div_eq_log_log : ∃ C, ∀ x, 2 ≤ x → |∑ p ∈ Ioc 0 ⌊x⌋₊ with p.Prime, (1:ℝ) / p - log (log x)| ≤ C := by use |M| + (log 4 + 6 + E₁) / log 2 intro x hx rw [sum_prime_div_eq] calc _ = |M + E₂p x| := by ring_nf _ ≤ |M| + (log 4 + 6 + E₁) / log x := by grw [abs_add_le, E₂p.abs_le hx] _ ≤ _ := by gcongr have : 0 < log 4 := by apply log_pos; norm_num linarith [E₁.nonneg] /- Original line 8816: Mertens.sum_prime_div_eq_log_log' -/ theorem sum_prime_div_eq_log_log' : (fun x ↦ ∑ p ∈ Ioc 0 ⌊x⌋₊ with p.Prime, (1:ℝ) / p - log (log x)) =O[atTop] (fun _ ↦ (1:ℝ)) := by simp only [isBigO_iff, norm_eq_abs, one_mem, CStarRing.norm_of_mem_unitary, mul_one, eventually_atTop] obtain ⟨ C, hC ⟩ := sum_prime_div_eq_log_log use C, 2 /- Original line 8823: Mertens.sum_prime_div_eq_log_log'' -/ theorem sum_prime_div_eq_log_log'' : (fun x ↦ ∑ p ∈ Ioc 0 ⌊x⌋₊ with p.Prime, (1:ℝ) / p) ~[atTop] (fun x ↦ log (log x)) := by apply IsLittleO.isEquivalent (IsBigO.trans_isLittleO _ one_eq_o_log_log) convert! sum_prime_div_eq_log_log' using 1 /- Original line 8827: Mertens.HasSum_log_one_sub_one_div_prime -/ theorem HasSum_log_one_sub_one_div_prime {p : ℕ} (hp : p.Prime) : HasSum (fun n : ℕ ↦ (-1 : ℝ) / (( n + 1) * p ^ (n + 1))) (log (1 - 1 / p)) := by convert! Real.hasSum_pow_div_log_of_abs_lt_one (x := 1 / p) _|>.neg using 1 · ext rw [div_pow, one_pow, div_div] ring · ring · simp only [one_div, abs_inv, Nat.abs_cast] exact inv_lt_one_of_one_lt₀ (mod_cast hp.one_lt) /- Original line 8837: Mertens.E₂Λ_sub_E₂p_tendsto -/ theorem E₂Λ_sub_E₂p_tendsto : Tendsto (E₂Λ - E₂p) atTop (nhds 0) := by exact isLittleO_one_iff ℝ|>.mp <| E₂Λ.bound'.sub E₂p.bound' /-- Function used in the proof of `M.eq`, `Λ n / n * log n` restricted to not primes. -/ /- Original line 8842: Mertens.M_eq_f -/ noncomputable abbrev M_eq_f (n : ℕ) := if ¬n.Prime then Λ n /(n * log n) else 0 /- Original line 8845: Mertens.E₂Λ_sub_E₂p_eq -/ theorem E₂Λ_sub_E₂p_eq (x : ℝ) : E₂Λ x - E₂p x = ∑ n ∈ Ioc 0 ⌊x⌋₊, M_eq_f n - (γ - M) := by calc _ = ∑ n ∈ Ioc 0 ⌊x⌋₊, Λ n / (n * log n) - ∑ p ∈ Ioc 0 ⌊x⌋₊ with p.Prime, (1 : ℝ) / p - (γ - M) := by ring _ = _ := by rw [sum_filter, ← sum_sub_distrib] congr ext n split_ifs with hn · rw [vonMangoldt_apply_prime hn] have : log n ≠ 0 := by simp; grind [hn.two_le] field · ring /- Original line 8859: Mertens.M_eq_f.sum_tendsto -/ theorem M_eq_f.sum_tendsto : Tendsto (fun (x : ℝ) ↦ ∑ n ∈ Ioc 0 ⌊x⌋₊, M_eq_f n) atTop (nhds (γ - M)) := by apply tendsto_sub_nhds_zero_iff.mp convert E₂Λ_sub_E₂p_tendsto using 1 ext rw [← E₂Λ_sub_E₂p_eq] simp /- Original line 8867: Mertens.M_eq_f.sum_tendsto' -/ theorem M_eq_f.sum_tendsto' : Tendsto (fun (N : ℕ) ↦ ∑ n ∈ range N, M_eq_f n) atTop (nhds (γ - M)) := by have : Tendsto (fun (N : ℕ) ↦ (∑ n ∈ Ioc 0 ⌊(N : ℝ)⌋₊, M_eq_f n)) atTop (nhds (γ - M)) := M_eq_f.sum_tendsto.comp tendsto_natCast_atTop_atTop simp_rw [Nat.floor_natCast] at this apply (this.comp (tendsto_sub_atTop_nat 1)).congr' filter_upwards [eventually_ge_atTop 1] with N hn rw [Nat.range_eq_Icc_zero_sub_one, ← add_sum_Ioc_eq_sum_Icc] <;> grind /- Original line 8875: Mertens.M_eq_f.HasSum -/ theorem M_eq_f.HasSum : HasSum M_eq_f (γ - M) := by refine hasSum_iff_tendsto_nat_of_nonneg (fun n ↦ ?_) _|>.mpr M_eq_f.sum_tendsto' unfold M_eq_f split_ifs with hn · rfl · exact div_nonneg vonMangoldt_nonneg (by positivity) /- Original line 8883: Mertens.M_eq_f.sum_primes -/ theorem M_eq_f.sum_primes : ∑' (p : Nat.Primes), M_eq_f p = 0 := by convert! tsum_zero with p grind /- Original line 8888: Mertens.tsum_primes_eq_tsum_ite -/ theorem tsum_primes_eq_tsum_ite (f : ℕ → ℝ) : ∑' (n : Nat.Primes), f n = ∑' (n : ℕ), if n.Prime then f n else 0 := by convert! _root_.tsum_subtype Nat.Prime f using 2 ext simp [Set.indicator] congr /- Original line 8895: Mertens.tsum_M_eq_f_eq_tsum -/ theorem tsum_M_eq_f_eq_tsum : -∑' (n : ℕ), M_eq_f n = ∑' p : ℕ, if p.Prime then log (1 - 1 / p) + 1 / p else 0 := by rw [tsum_eq_tsum_primes_add_tsum_primes_of_support_subset_prime_powers M_eq_f.HasSum.summable (fun n hn ↦ (by simp_all [vonMangoldt_ne_zero_iff])), M_eq_f.sum_primes, zero_add, tsum_primes_eq_tsum_ite (fun p ↦ ∑' (k : ℕ), M_eq_f (p ^ (k + 2))), ← tsum_neg] refine tsum_congr fun n ↦ ?_ split_ifs with hn · rw [← HasSum_log_one_sub_one_div_prime hn|>.tsum_eq, HasSum_log_one_sub_one_div_prime hn|>.summable.tsum_eq_zero_add] simp only [ite_not, Nat.cast_pow, log_pow, Nat.cast_add, Nat.cast_ofNat, CharP.cast_eq_zero, zero_add, pow_one, one_mul, Nat.cast_one, one_div] trans -∑' (k : ℕ), (1 : ℝ) / ((k + 2) * n ^ (k + 2)) · congr ext k have : ¬(Nat.Prime (n ^ (k + 2))) := by exact Nat.Prime.not_prime_pow (by grind) simp only [this, ↓reduceIte, one_div, mul_inv_rev] rw [vonMangoldt_apply_pow (by grind), vonMangoldt_apply_prime hn] have : log n ≠ 0 := by simp; grind [hn.two_le] field · rw [← tsum_neg] ring_nf congr ext ring_nf · ring /- Original line 8921: Mertens.M.eq -/ theorem M.eq : M = γ + ∑' p : ℕ, if p.Prime then log (1 - 1 / p) + 1 / p else 0 := by rw [← tsum_M_eq_f_eq_tsum, M_eq_f.HasSum.tsum_eq] ring /- Original line 8926: Mertens.E₃ -/ noncomputable def E₃ (x : ℝ) : ℝ := ∑ p ∈ Ioc 0 ⌊ x ⌋₊ with p.Prime, log (1 - (1:ℝ) / p) + log (log x) + eulerMascheroniConstant /- Original line 8929: Mertens.prod_one_minus_div_prime_eq -/ theorem prod_one_minus_div_prime_eq {x : ℝ} (hx : 1 < x) : ∏ p ∈ Ioc 0 ⌊x⌋₊ with p.Prime, (1 - (1 : ℝ) / p) = exp (-eulerMascheroniConstant) * exp (E₃ x) / log x := by have hlog : 0 < log x := log_pos hx have hpos : ∀ {p : ℕ}, p.Prime → (0 : ℝ) < 1 - 1 / p := fun {p} hp ↦ by have : (2 : ℝ) ≤ p := mod_cast hp.two_le grind [one_div_le_one_div_of_le two_pos this] rw [E₃, exp_add, exp_add, exp_sum, exp_log hlog, exp_neg, prod_congr rfl fun p hp ↦ exp_log (hpos (mem_filter.mp hp).2)] field_simp /- Original line 8940: Mertens.M_eq_summand -/ noncomputable abbrev M_eq_summand (p : ℕ) := if p.Prime then log (1 - 1 / p) + 1 / p else 0 /- Original line 8942: Mertens.M_eq_summand_bound -/ theorem M_eq_summand_bound (n : ℕ) : |M_eq_summand n| ≤ 2 / n ^ 2 := by unfold M_eq_summand split_ifs with h · trans 1 / n ^ 2 / (1 - 1 / n) · convert abs_log_sub_add_sum_range_le (x := 1 / n) _ 1 using 1 · rw [add_comm] simp · rw [abs_of_nonneg (by simp)] ring · simpa using inv_lt_one_of_one_lt₀ (mod_cast h.one_lt) rw [(by ring : (2 : ℝ) / n ^ 2 = 1 / n ^ 2 / (1 / 2))] gcongr suffices (1 : ℝ) / n ≤ 1 / 2 by linarith gcongr exact_mod_cast h.two_le · rw [abs_zero] positivity /- Original line 8961: Mertens.M_eq_summable -/ theorem M_eq_summable : Summable M_eq_summand := by apply Summable.of_abs exact Summable.of_nonneg_of_le (by simp) M_eq_summand_bound (Summable.const_div (by simp) _) /- Original line 8965: Mertens.tsum_M_eq_summand_eq -/ theorem tsum_M_eq_summand_eq : ∑' (n : ℕ), M_eq_summand n = M - γ := by rw [M.eq] grind /- Original line 8970: Mertens.sum_one_div_sq_le -/ theorem sum_one_div_sq_le {N : ℝ} (hN : 1 ≤ N) : ∑' (n : ℕ), (1 : ℝ) / (n + N) ^ 2 ≤ 2 / N := by grw [AntitoneOn.tsum_le_integral (f := (fun t ↦ 1 / (t + N) ^ 2))] · have hd : ∀ x ∈ Set.Ici 0, HasDerivAt (fun t ↦ -1 / (t + N)) (1 / (x + N) ^ 2) x := by intro t ht convert! HasDerivAt.fun_div (d' := (1 : ℝ)) (hasDerivAt_const ..) _ _ using 1 · ring · simpa using hasDerivAt_id' t · simp at ht linarith have lim : Tendsto (fun t ↦ -1 / (t + N)) atTop (nhds 0) := by exact (tendsto_atTop_add_const_right atTop N tendsto_id).const_div_atTop _ rw [MeasureTheory.integral_Ioi_of_hasDerivAt_of_nonneg' hd (fun _ _ ↦ (by positivity)) lim] ring_nf rw [mul_two] gcongr field_simp exact hN · unfold AntitoneOn intro a ha b hb h beta_reduce simp at ha hb gcongr · convert! integrableOn_add_rpow_Ioi_of_lt (by norm_num : (-2 : ℝ) < -1) (by linarith : -N < 0) using 2 simp · exact fun _ _ ↦ (by positivity) /- Original line 8997: Mertens.sum_M_eq_summand_le -/ theorem sum_M_eq_summand_le {N : ℕ} (hN : 0 < N) : |∑ n ∈ range N, M_eq_summand n - (M - γ)| ≤ 4 / N := by rw [← tsum_M_eq_summand_eq, ← M_eq_summable.sum_add_tsum_nat_add N] simp only [sub_add_cancel_left, abs_neg] rw [← norm_eq_abs] have summable := summable_nat_add_iff N|>.mpr M_eq_summable.norm apply norm_tsum_le_tsum_norm summable|>.trans apply Summable.tsum_le_tsum (fun _ ↦ M_eq_summand_bound _) summable _|>.trans · conv => lhs; arg 1; ext; rw [← mul_one_div] rw [tsum_mul_left] push_cast grw [sum_one_div_sq_le (mod_cast hN)] ring_nf rfl · exact (summable_nat_add_iff N|>.mpr (summable_one_div_nat_pow.mpr one_lt_two))|>.const_div _ /- Original line 9013: Mertens.sum_M_eq_summand_le' -/ theorem sum_M_eq_summand_le' {x : ℝ} (hx : 2 ≤ x) : |∑ n ∈ Ioc 0 ⌊x⌋₊, M_eq_summand n - (M - γ)| ≤ 4 / x := by have := sum_M_eq_summand_le (by grind : 0 < ⌊x⌋₊ + 1) rw [Nat.range_eq_Icc_zero_sub_one _ (by grind), ← add_sum_Ioc_eq_sum_Icc (by grind), (by simp : M_eq_summand 0 = 0), zero_add] at this simp only [add_tsub_cancel_right, Nat.cast_add, Nat.cast_one] at this grw [this] gcongr exact Nat.lt_floor_add_one _|>.le /- Original line 9024: Mertens.E₃.abs_le -/ theorem E₃.abs_le : ∃ C, ∀ x, 2 ≤ x → |E₃ x| ≤ C / log x := by unfold E₃ refine ⟨4 + (log 4 + 6 + E₁), fun x hx ↦ ?_⟩ calc _ = |(∑ n ∈ Ioc 0 ⌊x⌋₊, M_eq_summand n - (M - γ)) - E₂p x| := by unfold E₂p have (n : ℕ) : M_eq_summand n = (if n.Prime then log (1 - 1 / n) else 0) + (if n.Prime then (1 : ℝ) / n else 0) := by unfold M_eq_summand split_ifs · rfl · ring simp_rw [this] rw [sum_filter, sum_filter, sum_add_distrib, γ.eq_eulerMascheroni] ring_nf _ ≤ _ := by grw [abs_sub, E₂p.abs_le hx, sum_M_eq_summand_le' hx] have : 4 / x ≤ 4 / log x := by gcongr · exact log_pos (by linarith) · exact log_le_self (by linarith) grw [this] rw [← add_div] /- Original line 9048: Mertens.E₃.bound -/ theorem E₃.bound : E₃ =O[atTop] (fun x ↦ 1 / log x) := by simp only [isBigO_iff, norm_eq_abs, eventually_atTop] obtain ⟨ C, hC ⟩ := E₃.abs_le use C, 2 convert hC using 3 with x hx have : 0 < log x := by apply log_pos; linarith have : 0 < 1 / log x := by positivity grind [abs_of_pos this] /- Original line 9058: Mertens.E₃.bound' -/ theorem E₃.bound' : E₃ =o[atTop] (fun _ ↦ (1:ℝ)) := E₃.bound.trans_isLittleO inv_log_eq_o_one /- Original line 9061: Mertens.E₃.bound'' -/ theorem E₃.bound'' : (fun x ↦ ∏ p ∈ Ioc 0 ⌊ x ⌋₊ with p.Prime, (1 - (1:ℝ) / p)) ~[atTop] (fun x ↦ exp (-eulerMascheroniConstant) / log x) := by rw [isEquivalent_iff_tendsto_one] · convert Tendsto.congr' ?_ (Tendsto.rexp ((isLittleO_one_iff ℝ).mp E₃.bound')) using 2 with x · simp simp only [EventuallyEq.iff_eventually, Pi.div_apply, eventually_atTop]; use 2; intro x hx rw [prod_one_minus_div_prime_eq (by linarith)] have : 0 < log x := by apply log_pos; linarith field_simp simp only [ne_eq, div_eq_zero_iff, exp_ne_zero, log_eq_zero, eventually_atTop]; use 2 grind /- Original line 9073: Mertens.E₃.bound''' -/ theorem E₃.bound''' : (fun x ↦ ∏ p ∈ Ioc 0 ⌊ x ⌋₊ with p.Prime, (1 - (1:ℝ) / p) - exp (-eulerMascheroniConstant) / log x) =O[atTop] (fun x ↦ 1 / (log x)^2) := by obtain ⟨c, hc⟩ := E₃.abs_le rw [isBigO_iff] refine ⟨exp (-eulerMascheroniConstant) * 2 * c, ?_⟩ filter_upwards [eventually_ge_atTop 2, eventually_ge_atTop c.exp] with x hx hx2 rw [prod_one_minus_div_prime_eq (by linarith)] specialize hc x hx rw [norm_eq_abs, norm_eq_abs] calc _ = |exp (-eulerMascheroniConstant) / log x * (exp (E₃ x) - 1)| := by ring_nf _ = |exp (-eulerMascheroniConstant) / log x| * |exp (E₃ x) - 1| := by rw [abs_mul] _ ≤ _ := by have : |E₃ x| ≤ 1 := by apply hc.trans have := log_le_log (exp_pos _) hx2 rw [log_exp] at this apply div_le_one_iff.mpr <| Or.inl ⟨log_pos (by linarith), this⟩ grw [abs_exp_sub_one_le this, hc] apply le_of_eq rw [abs_div, abs_div, abs_one, abs_of_nonneg (exp_nonneg _), abs_of_nonneg (log_nonneg (by linarith)), abs_of_nonneg (sq_nonneg _)] ring end Mertens end MertensSource_1 end MertensDependencyPort namespace Erdos416Proof /- Original line 9104: Erdos416Proof.primesLE_eq_Ioc_filter -/ theorem primesLE_eq_Ioc_filter (n : ℕ) : Nat.primesLE n = (Finset.Ioc 0 n).filter Nat.Prime := by ext p simp only [Nat.mem_primesLE, Finset.mem_filter, Finset.mem_Ioc] exact ⟨fun h => ⟨⟨h.2.pos, h.1⟩, h.2⟩, fun h => ⟨h.1.2, h.2⟩⟩ /-- Mertens' reciprocal-prime bound, with its proved dependency above. -/ /- Original line 9111: Erdos416Proof.prime_reciprocal_mertens -/ theorem prime_reciprocal_mertens : ∃ C : ℝ, ∀ x : ℝ, 2 ≤ x → |(∑ p ∈ Nat.primesLE ⌊x⌋₊, (1 : ℝ) / p) - Real.log (Real.log x)| ≤ C := by simpa only [primesLE_eq_Ioc_filter] using Mertens.sum_prime_div_eq_log_log /-- Mertens' product asymptotic, using the actual primes up to the real bound. -/ /- Original line 9116: Erdos416Proof.prime_euler_product_asymptotic -/ theorem prime_euler_product_asymptotic : Asymptotics.IsEquivalent Filter.atTop (fun x : ℝ => ∏ p ∈ Nat.primesLE ⌊x⌋₊, (1 - (1 : ℝ) / p)) (fun x => Real.exp (-Real.eulerMascheroniConstant) / Real.log x) := by simpa only [primesLE_eq_Ioc_filter] using Mertens.E₃.bound'' end Erdos416Proof open Filter open scoped Topology BigOperators Classical namespace Erdos416Proof /- Original line 9131: Erdos416Proof.shifted_prime_reciprocal_bound -/ theorem shifted_prime_reciprocal_bound : ∃ C : ℝ, 0 < C ∧ ∀ x : ℝ, Real.exp (Real.exp 1) ≤ x → (∑ p ∈ Nat.primesLE ⌊x⌋₊, (1 : ℝ) / ((p : ℝ) - 1)) ≤ C * Real.log (Real.log x) := by obtain ⟨B, hB⟩ := prime_reciprocal_mertens refine ⟨2 * (1 + |B|), by positivity, ?_⟩ intro x hx have hx2 : 2 ≤ x := by linarith [Real.add_one_le_exp 1, Real.add_one_le_exp (Real.exp 1)] have hlogx : Real.exp 1 ≤ Real.log x := by simpa only [Real.log_exp] using Real.log_le_log (Real.exp_pos (Real.exp 1)) hx have hLL : 1 ≤ Real.log (Real.log x) := by simpa only [Real.log_exp] using Real.log_le_log (Real.exp_pos 1) hlogx have hsum := (abs_le.mp (hB x hx2)).2 have hcompare : (∑ p ∈ Nat.primesLE ⌊x⌋₊, (1 : ℝ) / ((p : ℝ) - 1)) ≤ 2 * ∑ p ∈ Nat.primesLE ⌊x⌋₊, (1 : ℝ) / p := by rw [Finset.mul_sum] apply Finset.sum_le_sum intro p hp have hpprime := Nat.prime_of_mem_primesLE hp have hp2 : (2 : ℝ) ≤ p := by exact_mod_cast hpprime.two_le rw [← mul_div_assoc, mul_one] apply (div_le_div_iff₀ (by linarith) (by linarith : (0 : ℝ) < p)).mpr nlinarith nlinarith [le_abs_self B, mul_le_mul_of_nonneg_left hLL (abs_nonneg B)] /- Original line 9156: Erdos416Proof.truncated_powerset_weight_bound -/ theorem truncated_powerset_weight_bound {ι : Type*} (P : Finset ι) (w : ι → ℝ) (hw : ∀ idx ∈ P, 0 ≤ w idx) (k : ℕ) : (∑ s ∈ P.powerset.filter (fun s => s.card ≤ k), ∏ idx ∈ s, w idx) ≤ Real.exp 1 * (1 + ∑ idx ∈ P, w idx) ^ k := by classical let a : ℝ := 1 + ∑ idx ∈ P, w idx have ha : 1 ≤ a := by dsimp [a]; linarith [Finset.sum_nonneg hw] have ha0 : 0 < a := by linarith have hscaled : ∀ s ∈ P.powerset.filter (fun s => s.card ≤ k), (∏ idx ∈ s, w idx) ≤ a ^ k * ∏ idx ∈ s, (w idx / a) := by intro s hs obtain ⟨hsP, hsk⟩ := Finset.mem_filter.mp hs have hsub := Finset.mem_powerset.mp hsP have hnonneg : 0 ≤ ∏ idx ∈ s, (w idx / a) := Finset.prod_nonneg fun idx hi => div_nonneg (hw idx (hsub hi)) ha0.le calc (∏ idx ∈ s, w idx) = a ^ s.card * ∏ idx ∈ s, (w idx / a) := by rw [Finset.prod_div_distrib, Finset.prod_const] field_simp [ne_of_gt ha0] _ ≤ a ^ k * ∏ idx ∈ s, (w idx / a) := mul_le_mul_of_nonneg_right (pow_le_pow_right₀ ha hsk) hnonneg have hall : (∑ s ∈ P.powerset.filter (fun s => s.card ≤ k), ∏ idx ∈ s, (w idx / a)) ≤ ∑ s ∈ P.powerset, ∏ idx ∈ s, (w idx / a) := by apply Finset.sum_le_sum_of_subset_of_nonneg (Finset.filter_subset _ _) intro s hs _ exact Finset.prod_nonneg fun idx hi => div_nonneg (hw idx ((Finset.mem_powerset.mp hs) hi)) ha0.le have hprod : (∏ idx ∈ P, (1 + w idx / a)) ≤ Real.exp 1 := by calc (∏ idx ∈ P, (1 + w idx / a)) ≤ ∏ idx ∈ P, Real.exp (w idx / a) := by apply Finset.prod_le_prod · intro idx hi have := div_nonneg (hw idx hi) ha0.le linarith · intro idx hi simpa only [add_comm] using Real.add_one_le_exp (w idx / a) _ = Real.exp (∑ idx ∈ P, w idx / a) := (Real.exp_sum _ _).symm _ ≤ Real.exp 1 := by apply Real.exp_le_exp.mpr rw [← Finset.sum_div, div_le_one ha0] dsimp [a] linarith calc _ ≤ ∑ s ∈ P.powerset.filter (fun s => s.card ≤ k), a ^ k * ∏ idx ∈ s, (w idx / a) := Finset.sum_le_sum hscaled _ = a ^ k * ∑ s ∈ P.powerset.filter (fun s => s.card ≤ k), ∏ idx ∈ s, (w idx / a) := (Finset.mul_sum _ _ _).symm _ ≤ a ^ k * ∑ s ∈ P.powerset, ∏ idx ∈ s, (w idx / a) := mul_le_mul_of_nonneg_left hall (pow_nonneg ha0.le _) _ = a ^ k * ∏ idx ∈ P, (1 + w idx / a) := by rw [Finset.prod_one_add] _ ≤ a ^ k * Real.exp 1 := mul_le_mul_of_nonneg_left hprod (pow_nonneg ha0.le _) _ = _ := by dsimp [a]; ring /- Original line 9209: Erdos416Proof.invTotient_squarefree -/ theorem invTotient_squarefree {n : ℕ} (hn : Squarefree n) : invTotient n = ∏ p ∈ n.primeFactors, (1 : ℝ) / ((p : ℝ) - 1) := by have ht := totient_prod_primes n.primeFactors (fun p hp => Nat.prime_of_mem_primeFactors hp) rw [Nat.prod_primeFactors_of_squarefree hn] at ht rw [invTotient, ht, Nat.cast_prod, ← Finset.prod_inv_distrib] apply Finset.prod_congr rfl intro p hp rw [Nat.cast_sub (Nat.prime_of_mem_primeFactors hp).one_le, Nat.cast_one, one_div] /- Original line 9218: Erdos416Proof.squarefree_reciprocal_sum_bound -/ theorem squarefree_reciprocal_sum_bound (M P : Finset ℕ) (k : ℕ) (hP : ∀ p ∈ P, p.Prime) (hM : ∀ n ∈ M, Squarefree n ∧ n.primeFactors ⊆ P ∧ n.primeFactors.card ≤ k) : (∑ n ∈ M, invTotient n) ≤ Real.exp 1 * (1 + ∑ p ∈ P, (1 : ℝ) / ((p : ℝ) - 1)) ^ k := by classical let w : ℕ → ℝ := fun p => 1 / ((p : ℝ) - 1) have hw : ∀ p ∈ P, 0 ≤ w p := by intro p hp have hp1 : (1 : ℝ) < p := by exact_mod_cast (hP p hp).one_lt exact div_nonneg zero_le_one (by linarith) have hinj : Set.InjOn Nat.primeFactors (M : Set ℕ) := by intro n hn m hm hnm calc n = ∏ p ∈ n.primeFactors, p := (Nat.prod_primeFactors_of_squarefree (hM n hn).1).symm _ = ∏ p ∈ m.primeFactors, p := congrArg (fun s : Finset ℕ => ∏ p ∈ s, p) hnm _ = m := Nat.prod_primeFactors_of_squarefree (hM m hm).1 have hsub : M.image Nat.primeFactors ⊆ P.powerset.filter (fun s => s.card ≤ k) := by intro s hs obtain ⟨n, hn, rfl⟩ := Finset.mem_image.mp hs exact Finset.mem_filter.mpr ⟨Finset.mem_powerset.mpr (hM n hn).2.1, (hM n hn).2.2⟩ calc _ = ∑ n ∈ M, ∏ p ∈ n.primeFactors, w p := Finset.sum_congr rfl fun n hn => invTotient_squarefree (hM n hn).1 _ = ∑ s ∈ M.image Nat.primeFactors, ∏ p ∈ s, w p := (Finset.sum_image (f := fun s : Finset ℕ => ∏ p ∈ s, w p) hinj).symm _ ≤ ∑ s ∈ P.powerset.filter (fun s => s.card ≤ k), ∏ p ∈ s, w p := by apply Finset.sum_le_sum_of_subset_of_nonneg hsub intro s hs _ have hsP := Finset.mem_powerset.mp (Finset.mem_filter.mp hs).1 exact Finset.prod_nonneg fun p hp => hw p (hsP hp) _ ≤ _ := truncated_powerset_weight_bound P w hw k /-- A uniform reciprocal-totient bound for the common products in the sieve, using their squarefreeness and their bounded number of prime factors. -/ /- Original line 9253: Erdos416Proof.common_product_sum_bound -/ theorem common_product_sum_bound : ∃ C : ℝ, 0 < C ∧ ∀ x : ℝ, Real.exp (Real.exp 1) ≤ x → ∀ M : Finset ℕ, ∀ k : ℕ, (∀ n ∈ M, Squarefree n ∧ n.primeFactors ⊆ Nat.primesLE ⌊x⌋₊ ∧ n.primeFactors.card ≤ k) → (∑ n ∈ M, invTotient n) ≤ Real.exp 1 * (1 + C * Real.log (Real.log x)) ^ k := by obtain ⟨C, hC, hbound⟩ := shifted_prime_reciprocal_bound refine ⟨C, hC, ?_⟩ intro x hx M k hM have h := squarefree_reciprocal_sum_bound M (Nat.primesLE ⌊x⌋₊) k (fun p hp => Nat.prime_of_mem_primesLE hp) hM apply h.trans gcongr · apply add_nonneg zero_le_one exact Finset.sum_nonneg fun p hp => by have hp1 : (1 : ℝ) < p := by exact_mod_cast (Nat.prime_of_mem_primesLE hp).one_lt positivity · exact hbound x hx /- Original line 9271: Erdos416Proof.common_product_sum_eventually -/ theorem common_product_sum_eventually (A : ℝ) : ∀ᶠ T : ℝ in atTop, ∀ x : ℝ, Real.exp (Real.exp 1) ≤ x → Real.log (Real.log x) ≤ 2 * T → ∀ M : Finset ℕ, ∀ k : ℕ, (k : ℝ) ≤ A * Real.log T → (∀ n ∈ M, Squarefree n ∧ n.primeFactors ⊆ Nat.primesLE ⌊x⌋₊ ∧ n.primeFactors.card ≤ k) → (∑ n ∈ M, invTotient n) ≤ Real.exp ((2 * A + 1) * (Real.log T) ^ 2) := by obtain ⟨C, hC, hbound⟩ := common_product_sum_bound filter_upwards [eventually_ge_atTop (Real.exp 1), eventually_ge_atTop (1 + 2 * C)] with T hT hTC have hT1 : 1 ≤ T := by linarith [Real.add_one_le_exp 1] have hT0 : 0 < T := by linarith have hlog : 1 ≤ Real.log T := by simpa only [Real.log_exp] using Real.log_le_log (Real.exp_pos 1) hT intro x hx hLL M k hk hM have hbnonneg : 0 ≤ 1 + C * Real.log (Real.log x) := by have hlogx : Real.exp 1 ≤ Real.log x := by simpa only [Real.log_exp] using Real.log_le_log (Real.exp_pos _) hx have hLL0 : 0 ≤ Real.log (Real.log x) := Real.log_nonneg (by linarith [Real.add_one_le_exp 1]) positivity have hb : 1 + C * Real.log (Real.log x) ≤ T ^ 2 := by have h₁ := mul_le_mul_of_nonneg_left hLL hC.le have h₂ := mul_le_mul_of_nonneg_right hTC hT0.le nlinarith calc _ ≤ Real.exp 1 * (1 + C * Real.log (Real.log x)) ^ k := hbound x hx M k hM _ ≤ Real.exp 1 * (T ^ 2) ^ k := by gcongr _ ≤ Real.exp ((2 * A + 1) * (Real.log T) ^ 2) := by apply (Real.log_le_log_iff (by positivity) (Real.exp_pos _)).mp rw [Real.log_mul (ne_of_gt (Real.exp_pos 1)) (by positivity), Real.log_exp, Real.log_pow, Real.log_pow, Real.log_exp] have hmul := mul_le_mul_of_nonneg_right hk (show 0 ≤ Real.log T by linarith) norm_num nlinarith [sq_nonneg (Real.log T - 1)] /- Original line 9307: Erdos416Proof.common_product_sum_inverse_totient_scale -/ theorem common_product_sum_inverse_totient_scale (A : ℝ) {c : ℝ} (hc : 0 < c) : ∀ᶠ T : ℝ in atTop, ∀ M : Finset ℕ, ∀ k : ℕ, (k : ℝ) ≤ A * Real.log T → (∀ n ∈ M, Squarefree n ∧ n.primeFactors ⊆ Nat.primesLE ⌊c * Real.exp (Real.exp T) * T⌋₊ ∧ n.primeFactors.card ≤ k) → (∑ n ∈ M, invTotient n) ≤ Real.exp ((2 * A + 1) * (Real.log T) ^ 2) := by have hx : Tendsto (fun T : ℝ => c * Real.exp (Real.exp T) * T) atTop atTop := ((Real.tendsto_exp_atTop.comp Real.tendsto_exp_atTop).const_mul_atTop hc).atTop_mul_atTop₀ tendsto_id filter_upwards [common_product_sum_eventually A, inverse_totient_scale_envelope c, hx.eventually_ge_atTop (Real.exp (Real.exp 1)), eventually_ge_atTop (1 : ℝ)] with T hbound henv hX hT intro M k hk hM apply hbound _ hX _ M k hk hM have hX1 : 1 < c * Real.exp (Real.exp T) * T := (Real.one_lt_exp_iff.mpr (Real.exp_pos 1)).trans_le hX have hLL := logLog_mono hX1 henv simp only [logLog, Real.log_exp] at hLL linarith end Erdos416Proof open Filter open scoped Topology BigOperators Classical namespace Erdos416Proof /- Original line 9336: Erdos416Proof.totientFactor -/ noncomputable def totientFactor (p : ℕ) : ℝ := (p : ℝ) / ((p : ℝ) - 1) /- Original line 9338: Erdos416Proof.totientFactor_pos -/ theorem totientFactor_pos {p : ℕ} (hp : p.Prime) : 0 < totientFactor p := by have hp1 : (1 : ℝ) < p := by exact_mod_cast hp.one_lt exact div_pos (by linarith) (by linarith) /- Original line 9342: Erdos416Proof.one_le_totientFactor -/ theorem one_le_totientFactor {p : ℕ} (hp : p.Prime) : 1 ≤ totientFactor p := by have hp1 : (1 : ℝ) < p := by exact_mod_cast hp.one_lt apply (le_div_iff₀ (show (0 : ℝ) < p - 1 by linarith)).mpr linarith /- Original line 9347: Erdos416Proof.totientFactor_eq_inv -/ theorem totientFactor_eq_inv {p : ℕ} (hp : p.Prime) : totientFactor p = (1 - (1 : ℝ) / p)⁻¹ := by have hp1 : (1 : ℝ) < p := by exact_mod_cast hp.one_lt unfold totientFactor field_simp /- Original line 9353: Erdos416Proof.totient_ratio_eq_prod -/ theorem totient_ratio_eq_prod {n : ℕ} (hn : 0 < n) : (n : ℝ) / n.totient = ∏ p ∈ n.primeFactors, totientFactor p := by have hφ : (n.totient : ℝ) ≠ 0 := by exact_mod_cast (Nat.totient_pos.mpr hn).ne' have hprod : (∏ p ∈ n.primeFactors, ((p : ℝ) - 1)) ≠ 0 := by apply Finset.prod_ne_zero_iff.mpr intro p hp have hp1 : (1 : ℝ) < p := by exact_mod_cast (Nat.prime_of_mem_primeFactors hp).one_lt linarith have h := congrArg (fun a : ℕ => (a : ℝ)) (Nat.totient_mul_prod_primeFactors n) simp only [Nat.cast_mul, Nat.cast_prod] at h have hpred : (∏ p ∈ n.primeFactors, ((p - 1 : ℕ) : ℝ)) = ∏ p ∈ n.primeFactors, ((p : ℝ) - 1) := by apply Finset.prod_congr rfl intro p hp rw [Nat.cast_sub (Nat.prime_of_mem_primeFactors hp).one_le, Nat.cast_one] rw [hpred] at h unfold totientFactor rw [Finset.prod_div_distrib] exact (div_eq_div_iff hφ hprod).mpr (h.symm.trans (mul_comm _ _)) /- Original line 9373: Erdos416Proof.totientFactor_le_exp -/ theorem totientFactor_le_exp {p : ℕ} (hp : p.Prime) : totientFactor p ≤ Real.exp (2 / (p : ℝ)) := by have hp2 : (2 : ℝ) ≤ p := by exact_mod_cast hp.two_le have hfrac : (1 : ℝ) / ((p : ℝ) - 1) ≤ 2 / p := by apply (div_le_div_iff₀ (by linarith) (by linarith : (0 : ℝ) < p)).mpr linarith have heq : totientFactor p = 1 + (1 : ℝ) / ((p : ℝ) - 1) := by unfold totientFactor field_simp [show (p : ℝ) - 1 ≠ 0 by linarith] ring rw [heq] exact (add_le_add_right hfrac 1).trans (by simpa only [add_comm] using Real.add_one_le_exp (2 / (p : ℝ))) /- Original line 9386: Erdos416Proof.primeFactors_card_mul_log_two -/ theorem primeFactors_card_mul_log_two {n : ℕ} (hn : 0 < n) : (n.primeFactors.card : ℝ) * Real.log 2 ≤ Real.log n := by have hpow : 2 ^ n.primeFactors.card ≤ n := by calc _ = ∏ _ ∈ n.primeFactors, 2 := (Finset.prod_const 2).symm _ ≤ ∏ p ∈ n.primeFactors, p := Finset.prod_le_prod' fun p hp => (Nat.prime_of_mem_primeFactors hp).two_le _ ≤ n := Nat.le_of_dvd hn (Nat.prod_primeFactors_dvd n) have hR : (2 : ℝ) ^ n.primeFactors.card ≤ n := by exact_mod_cast hpow simpa only [Real.log_pow] using Real.log_le_log (by positivity) hR /- Original line 9397: Erdos416Proof.large_totientFactor_product_le -/ theorem large_totientFactor_product_le {n : ℕ} (hn : 1 < n) : (∏ p ∈ n.primeFactors.filter (fun p : ℕ => ¬ (p : ℝ) ≤ Real.log n), totientFactor p) ≤ Real.exp (2 / Real.log 2) := by classical have hn1 : (1 : ℝ) < n := by exact_mod_cast hn have hlog : 0 < Real.log n := Real.log_pos hn1 have hlog2 : 0 < Real.log 2 := Real.log_pos (by norm_num) let s := n.primeFactors.filter fun p : ℕ => ¬ (p : ℝ) ≤ Real.log n have hcard : (s.card : ℝ) ≤ n.primeFactors.card := by exact_mod_cast (Finset.card_le_card (Finset.filter_subset _ _) : s.card ≤ n.primeFactors.card) have hcardlog := primeFactors_card_mul_log_two (by omega : 0 < n) calc _ ≤ ∏ _ ∈ s, Real.exp (2 / Real.log n) := by apply Finset.prod_le_prod · intro p hp exact (totientFactor_pos (Nat.prime_of_mem_primeFactors (Finset.mem_filter.mp hp).1)).le · intro p hp obtain ⟨hpn, hp⟩ := Finset.mem_filter.mp hp apply (totientFactor_le_exp (Nat.prime_of_mem_primeFactors hpn)).trans apply Real.exp_le_exp.mpr exact div_le_div_of_nonneg_left (by norm_num) hlog (le_of_not_ge hp) _ = Real.exp ((s.card : ℝ) * (2 / Real.log n)) := by rw [← Real.exp_sum] simp _ ≤ Real.exp (2 / Real.log 2) := by apply Real.exp_le_exp.mpr have hcardbound : (s.card : ℝ) * Real.log 2 ≤ Real.log n := (mul_le_mul_of_nonneg_right hcard hlog2.le).trans hcardlog apply (le_div_iff₀ hlog2).mpr rw [← mul_div_assoc, div_mul_eq_mul_div] apply (div_le_iff₀ hlog).mpr nlinarith /- Original line 9430: Erdos416Proof.inverse_prime_euler_product_bound -/ theorem inverse_prime_euler_product_bound : ∃ C : ℝ, 0 < C ∧ ∀ᶠ x : ℝ in atTop, (∏ p ∈ Nat.primesLE ⌊x⌋₊, totientFactor p) ≤ C * Real.log x := by have heq (x : ℝ) : (∏ p ∈ Nat.primesLE ⌊x⌋₊, totientFactor p) = (∏ p ∈ Nat.primesLE ⌊x⌋₊, (1 - (1 : ℝ) / p))⁻¹ := by rw [← Finset.prod_inv_distrib] exact Finset.prod_congr rfl fun p hp => totientFactor_eq_inv (Nat.prime_of_mem_primesLE hp) obtain ⟨B, hB, hbound⟩ := prime_euler_product_asymptotic.inv.isBigO.exists_pos refine ⟨B / Real.exp (-Real.eulerMascheroniConstant), by positivity, ?_⟩ filter_upwards [hbound.bound, eventually_gt_atTop (1 : ℝ)] with x h hx have hprod : 0 < ∏ p ∈ Nat.primesLE ⌊x⌋₊, totientFactor p := Finset.prod_pos fun p hp => totientFactor_pos (Nat.prime_of_mem_primesLE hp) change ‖(∏ p ∈ Nat.primesLE ⌊x⌋₊, (1 - (1 : ℝ) / p))⁻¹‖ ≤ B * ‖(Real.exp (-Real.eulerMascheroniConstant) / Real.log x)⁻¹‖ at h rw [← heq, Real.norm_eq_abs, abs_of_pos hprod, inv_div, Real.norm_eq_abs, abs_of_pos (div_pos (Real.log_pos hx) (Real.exp_pos _))] at h convert h using 1 ring /- Original line 9448: Erdos416Proof.small_totientFactor_product_le -/ theorem small_totientFactor_product_le (n : ℕ) : (∏ p ∈ n.primeFactors.filter (fun p : ℕ => (p : ℝ) ≤ Real.log n), totientFactor p) ≤ ∏ p ∈ Nat.primesLE ⌊Real.log n⌋₊, totientFactor p := by apply Finset.prod_le_prod_of_subset_of_one_le · intro p hp obtain ⟨hpn, hpl⟩ := Finset.mem_filter.mp hp exact Nat.mem_primesLE.mpr ⟨Nat.le_floor hpl, Nat.prime_of_mem_primeFactors hpn⟩ · intro p hp exact (totientFactor_pos (Nat.prime_of_mem_primeFactors (Finset.mem_filter.mp hp).1)).le · intro p hp _ exact one_le_totientFactor (Nat.prime_of_mem_primesLE hp) /- Original line 9460: Erdos416Proof.totient_ratio_logLog_bound_eventually -/ theorem totient_ratio_logLog_bound_eventually : ∃ C : ℝ, 0 < C ∧ ∀ᶠ n : ℕ in atTop, (n : ℝ) / n.totient ≤ C * Real.log (Real.log n) := by obtain ⟨C, hC, hbound⟩ := inverse_prime_euler_product_bound refine ⟨C * Real.exp (2 / Real.log 2), by positivity, ?_⟩ filter_upwards [(Real.tendsto_log_atTop.comp tendsto_natCast_atTop_atTop).eventually hbound, eventually_gt_atTop (1 : ℕ)] with n hsmall hn rw [totient_ratio_eq_prod (by omega : 0 < n)] rw [← Finset.prod_filter_mul_prod_filter_not n.primeFactors (fun p : ℕ => (p : ℝ) ≤ Real.log n)] have hs := (small_totientFactor_product_le n).trans hsmall have hl := large_totientFactor_product_le hn calc _ ≤ (C * Real.log (Real.log n)) * Real.exp (2 / Real.log 2) := by exact mul_le_mul hs hl (Finset.prod_nonneg fun p hp => (totientFactor_pos (Nat.prime_of_mem_primeFactors (Finset.mem_filter.mp hp).1)).le) ((Finset.prod_pos fun p hp => totientFactor_pos (Nat.prime_of_mem_primeFactors (Finset.mem_filter.mp hp).1)).le.trans hs) _ = _ := by ring /- Original line 9478: Erdos416Proof.logLog_mul_const_le_sqrt_eventually -/ theorem logLog_mul_const_le_sqrt_eventually {C : ℝ} (hC : 0 ≤ C) : ∀ᶠ x : ℝ in atTop, C * Real.log (Real.log x) ≤ Real.sqrt x := by have h := (log_pow_mul_rpow_littleO 1 (show (0 : ℝ) < 1 / 2 by norm_num)).const_mul_left C filter_upwards [h.bound (by norm_num : (0 : ℝ) < 1), eventually_gt_atTop (1 : ℝ)] with x hx hx1 simp only [pow_one, Real.rpow_zero, mul_one, one_mul, Real.norm_eq_abs] at hx rw [abs_of_nonneg (mul_nonneg hC (Real.log_pos hx1).le), abs_of_nonneg (Real.rpow_nonneg (by linarith) _), ← Real.sqrt_eq_rpow] at hx exact (mul_le_mul_of_nonneg_left (Real.log_le_self (Real.log_pos hx1).le) hC).trans hx /-- The uniform inverse-totient size estimate required for both original and auxiliary preimages. The cutoff depends on neither n nor its representation. -/ /- Original line 9490: Erdos416Proof.inverse_totient_bound_eventually -/ theorem inverse_totient_bound_eventually : ∃ D : ℝ, 0 < D ∧ ∀ᶠ y : ℝ in atTop, ∀ n : ℕ, 0 < n → (n.totient : ℝ) ≤ y → (n : ℝ) ≤ D * y * Real.log (Real.log y) := by obtain ⟨C, hC, hratio⟩ := totient_ratio_logLog_bound_eventually have hsqrt := tendsto_natCast_atTop_atTop.eventually (logLog_mul_const_le_sqrt_eventually hC.le) obtain ⟨N, hN⟩ := eventually_atTop.mp ((hratio.and hsqrt).and (eventually_gt_atTop (1 : ℕ))) let D : ℝ := max (2 * C) 1 have hD1 : 1 ≤ D := le_max_right _ _ have hDC : 2 * C ≤ D := le_max_left _ _ refine ⟨D, by linarith, ?_⟩ filter_upwards [eventually_ge_atTop (N : ℝ), eventually_gt_atTop (1 : ℝ), (Real.tendsto_log_atTop.comp Real.tendsto_log_atTop).eventually_ge_atTop 1] with y hNy hy hLLy dsimp only [Function.comp_apply] at hLLy intro n hn hφy have hy0 : 0 < y := by linarith by_cases hnN : n < N · have hny : (n : ℝ) ≤ y := (by exact_mod_cast hnN.le : (n : ℝ) ≤ N).trans hNy apply hny.trans nlinarith [mul_le_mul_of_nonneg_right hD1 hy0.le, mul_le_mul_of_nonneg_left hLLy (show 0 ≤ D * y by positivity)] · obtain ⟨⟨hr, hs⟩, hn1⟩ := hN n (by omega) have hnR : (0 : ℝ) < n := by exact_mod_cast hn have hφR : (0 : ℝ) < n.totient := by exact_mod_cast Nat.totient_pos.mpr hn have hnr : (n : ℝ) ≤ C * Real.log (Real.log n) * n.totient := (div_le_iff₀ hφR).mp hr have hnroot : (n : ℝ) ≤ Real.sqrt n * y := hnr.trans (mul_le_mul hs hφy hφR.le (Real.sqrt_nonneg _)) have hsroot : Real.sqrt n ≤ y := by have hspos : 0 < Real.sqrt n := Real.sqrt_pos.mpr hnR have hsq := Real.sq_sqrt hnR.le nlinarith have hnysq : (n : ℝ) ≤ y ^ 2 := by have hsq := Real.sq_sqrt hnR.le nlinarith [mul_self_le_mul_self (Real.sqrt_nonneg n) hsroot] have hn1R : (1 : ℝ) < n := by exact_mod_cast hn1 have hLLn := logLog_mono hn1R hnysq have hlog2 : Real.log 2 ≤ 1 := by have := Real.log_le_sub_one_of_pos (by norm_num : (0 : ℝ) < 2) linarith simp only [logLog, Real.log_pow, Nat.cast_ofNat, Real.log_mul (by norm_num : (2 : ℝ) ≠ 0) (ne_of_gt (Real.log_pos hy))] at hLLn have hLL : Real.log (Real.log n) ≤ 2 * Real.log (Real.log y) := by linarith have hCd : C * Real.log (Real.log n) ≤ D * Real.log (Real.log y) := by have h₁ := mul_le_mul_of_nonneg_left hLL hC.le have h₂ := mul_le_mul_of_nonneg_right hDC (show 0 ≤ Real.log (Real.log y) by linarith) nlinarith calc (n : ℝ) ≤ C * Real.log (Real.log n) * n.totient := hnr _ ≤ (D * Real.log (Real.log y)) * y := mul_le_mul hCd hφy hφR.le (by positivity) _ = _ := by ring /- Original line 9542: Erdos416Proof.cardFactors_finset_prod -/ theorem cardFactors_finset_prod {ι : Type*} (s : Finset ι) (f : ι → ℕ) (hf : ∀ idx ∈ s, f idx ≠ 0) : ArithmeticFunction.cardFactors (∏ idx ∈ s, f idx) = ∑ idx ∈ s, ArithmeticFunction.cardFactors (f idx) := by classical induction s using Finset.induction with | empty => simp | @insert idx s hi ih => have hs : ∀ j ∈ s, f j ≠ 0 := fun j hj => hf j (Finset.mem_insert_of_mem hj) rw [Finset.prod_insert hi, ArithmeticFunction.cardFactors_mul (hf idx (Finset.mem_insert_self _ _)) (Finset.prod_ne_zero_iff.mpr hs), ih hs, Finset.sum_insert hi] /- Original line 9554: Erdos416Proof.cardFactors_totient_decomposition -/ theorem cardFactors_totient_decomposition {n : ℕ} (hn : 0 < n) : ArithmeticFunction.cardFactors n.totient = ∑ p ∈ n.primeFactors, (n.factorization p - 1 + ArithmeticFunction.cardFactors (p - 1)) := by rw [Nat.totient_eq_prod_factorization hn.ne'] change ArithmeticFunction.cardFactors (∏ p ∈ n.primeFactors, p ^ (n.factorization p - 1) * (p - 1)) = _ have hpos (p : ℕ) (hp : p ∈ n.primeFactors) : 0 < p ^ (n.factorization p - 1) * (p - 1) := by have hprime := Nat.prime_of_mem_primeFactors hp exact Nat.mul_pos (pow_pos hprime.pos _) (Nat.sub_pos_of_lt hprime.one_lt) rw [cardFactors_finset_prod _ _ (fun p hp => (hpos p hp).ne')] apply Finset.sum_congr rfl intro p hp have hprime := Nat.prime_of_mem_primeFactors hp rw [ArithmeticFunction.cardFactors_mul (pow_ne_zero _ hprime.ne_zero) (Nat.sub_pos_of_lt hprime.one_lt).ne', ArithmeticFunction.cardFactors_apply_prime_pow hprime] /-- In fact the total number of prime factors of a positive preimage is at most one more than that of its totient. The only possible loss comes from 2. -/ /- Original line 9572: Erdos416Proof.cardFactors_le_totient_add_one -/ theorem cardFactors_le_totient_add_one (n : ℕ) : ArithmeticFunction.cardFactors n ≤ ArithmeticFunction.cardFactors n.totient + 1 := by classical by_cases hn0 : n = 0 · simp [hn0] have hn : 0 < n := Nat.pos_of_ne_zero hn0 have hpoint : ∀ p ∈ n.primeFactors, n.factorization p ≤ n.factorization p - 1 + ArithmeticFunction.cardFactors (p - 1) + if p = 2 then 1 else 0 := by intro p hp have hprime := Nat.prime_of_mem_primeFactors hp have he : 0 < n.factorization p := hprime.factorization_pos_of_dvd hn0 (Nat.dvd_of_mem_primeFactors hp) by_cases hp2 : p = 2 · simp only [hp2, Nat.reduceSub, ArithmeticFunction.cardFactors_one, add_zero, ↓reduceIte] omega · have hp1 : 1 < p - 1 := by have := hprime.two_le; omega have hΩ := ArithmeticFunction.cardFactors_pos_iff_one_lt.mpr hp1 simp only [hp2, ↓reduceIte, add_zero] omega have hsum := Finset.sum_le_sum hpoint have hΩn : ArithmeticFunction.cardFactors n = ∑ p ∈ n.primeFactors, n.factorization p := ArithmeticFunction.cardFactors_eq_sum_factorization rw [Finset.sum_add_distrib, ← hΩn, ← cardFactors_totient_decomposition hn] at hsum have hpenalty : (∑ p ∈ n.primeFactors, if p = 2 then 1 else 0 : ℕ) ≤ 1 := by by_cases h2 : 2 ∈ n.primeFactors <;> simp [h2] omega /- Original line 9599: Erdos416Proof.cardFactors_le_twice_totient_add_two -/ theorem cardFactors_le_twice_totient_add_two (n : ℕ) : ArithmeticFunction.cardFactors n ≤ 2 * ArithmeticFunction.cardFactors n.totient + 2 := by have := cardFactors_le_totient_add_one n omega end Erdos416Proof open Filter open scoped BigOperators Classical Topology namespace Erdos416Proof /- Original line 9613: Erdos416Proof.finite_sum_ge_two_cases -/ theorem finite_sum_ge_two_cases {ι : Type*} (s : Finset ι) (f : ι → ℕ) (hs : 2 ≤ ∑ idx ∈ s, f idx) : (∃ idx ∈ s, 2 ≤ f idx) ∨ (∃ idx ∈ s, ∃ j ∈ s, idx ≠ j ∧ 0 < f idx ∧ 0 < f j) := by classical by_cases hbig : ∃ idx ∈ s, 2 ≤ f idx · exact Or.inl hbig right push Not at hbig obtain ⟨idx, hi, hfi⟩ := Finset.sum_pos_iff.mp (show 0 < ∑ idx ∈ s, f idx by omega) by_cases hj : ∃ j ∈ s, j ≠ idx ∧ 0 < f j · obtain ⟨j, hj, hji, hfj⟩ := hj exact ⟨idx, hi, j, hj, hji.symm, hfi, hfj⟩ have hsingle : ∑ j ∈ s, f j = f idx := by apply Finset.sum_eq_single idx · intro j hjs hji by_contra hzero exact hj ⟨j, hjs, hji, Nat.pos_of_ne_zero hzero⟩ · exact fun h => (h hi).elim have := hbig idx hi omega /- Original line 9634: Erdos416Proof.factorization_totient_at_prime_of_no_square -/ theorem factorization_totient_at_prime_of_no_square {n q : ℕ} (hn : 0 < n) (hq : q.Prime) (hsq : ¬ q ^ 2 ∣ n) : n.totient.factorization q = ∑ p ∈ n.primeFactors, (p - 1).factorization q := by have hnq : n.factorization q ≤ 1 := by have := hq.pow_dvd_iff_le_factorization hn.ne' (k := 2) omega rw [Nat.totient_eq_prod_factorization hn.ne'] change (∏ p ∈ n.primeFactors, p ^ (n.factorization p - 1) * (p - 1)).factorization q = _ rw [Nat.factorization_prod_apply] · apply Finset.sum_congr rfl intro p hp have hprime := Nat.prime_of_mem_primeFactors hp have hpred : p - 1 ≠ 0 := (Nat.sub_pos_of_lt hprime.one_lt).ne' have hnpow : ¬ q ∣ p ^ (n.factorization p - 1) := by by_cases hpq : p = q · subst p have he : n.factorization q - 1 = 0 := by omega simpa [he] using hq.not_dvd_one · intro h have hqp := (Nat.prime_dvd_prime_iff_eq hq hprime).mp (hq.dvd_of_dvd_pow h) exact hpq hqp.symm rw [Nat.factorization_mul (pow_ne_zero _ hprime.ne_zero) hpred, Finsupp.add_apply, Nat.factorization_eq_zero_of_not_dvd hnpow, zero_add] · intro p hp have hprime := Nat.prime_of_mem_primeFactors hp exact mul_ne_zero (pow_ne_zero _ hprime.ne_zero) (Nat.sub_pos_of_lt hprime.one_lt).ne' /-- A squared prime in a totient comes from the original integer, one shifted prime factor, or two different shifted prime factors. -/ /- Original line 9663: Erdos416Proof.prime_square_totient_cases -/ theorem prime_square_totient_cases {n q : ℕ} (hn : 0 < n) (hq : q.Prime) (hφ : q ^ 2 ∣ n.totient) : q ^ 2 ∣ n ∨ (∃ p ∈ n.primeFactors, q ^ 2 ∣ p - 1) ∨ (∃ p ∈ n.primeFactors, ∃ r ∈ n.primeFactors, p ≠ r ∧ q ∣ p - 1 ∧ q ∣ r - 1) := by by_cases hsq : q ^ 2 ∣ n · exact Or.inl hsq right have hsum : 2 ≤ ∑ p ∈ n.primeFactors, (p - 1).factorization q := by rw [← factorization_totient_at_prime_of_no_square hn hq hsq] exact (hq.pow_dvd_iff_le_factorization (Nat.totient_pos.mpr hn).ne').mp hφ rcases finite_sum_ge_two_cases n.primeFactors (fun p => (p - 1).factorization q) hsum with h | h · obtain ⟨p, hp, hpf⟩ := h exact Or.inl ⟨p, hp, (hq.pow_dvd_iff_le_factorization (Nat.sub_pos_of_lt (Nat.prime_of_mem_primeFactors hp).one_lt).ne').mpr hpf⟩ · obtain ⟨p, hp, r, hr, hpr, hpf, hrf⟩ := h exact Or.inr ⟨p, hp, r, hr, hpr, (hq.dvd_iff_one_le_factorization (Nat.sub_pos_of_lt (Nat.prime_of_mem_primeFactors hp).one_lt).ne').mpr hpf, (hq.dvd_iff_one_le_factorization (Nat.sub_pos_of_lt (Nat.prime_of_mem_primeFactors hr).one_lt).ne').mpr hrf⟩ /- Original line 9685: Erdos416Proof.reciprocal_naturals_sum_le_log -/ theorem reciprocal_naturals_sum_le_log (N : ℕ) : (∑ j ∈ Finset.Icc 1 N, (1 : ℝ) / j) ≤ 1 + Real.log N := by simpa only [harmonic_eq_sum_Icc, Rat.cast_sum, Rat.cast_inv, Rat.cast_natCast, one_div] using harmonic_le_one_add_log N /-- An elementary, uniform bound suffices when the large-square cutoff is (log y)^4. It uses only the embedding p = 1 + k j and the harmonic sum. -/ /- Original line 9692: Erdos416Proof.prime_progression_reciprocal_elementary -/ theorem prime_progression_reciprocal_elementary (N k : ℕ) (hk : 0 < k) : (∑ p ∈ (Nat.primesLE N).filter (fun p => k ∣ p - 1), (1 : ℝ) / p) ≤ (1 + Real.log N) / k := by classical let s := (Nat.primesLE N).filter (fun p => k ∣ p - 1) let j : ℕ → ℕ := fun p => (p - 1) / k have hj (p : ℕ) (hp : p ∈ s) : p = k * j p + 1 := by obtain ⟨hpN, hkp⟩ := Finset.mem_filter.mp hp have hprime := Nat.prime_of_mem_primesLE hpN have hp1 := hprime.one_le dsimp [j] rw [Nat.mul_div_cancel' hkp] omega have hjpos (p : ℕ) (hp : p ∈ s) : 0 < j p := by have hprime := Nat.prime_of_mem_primesLE (Finset.mem_filter.mp hp).1 have := hj p hp nlinarith [hprime.two_le] have hinj : Set.InjOn j (s : Set ℕ) := by intro p hp r hr heq rw [hj p hp, hj r hr, heq] have hsub : s.image j ⊆ Finset.Icc 1 N := by intro t ht obtain ⟨p, hp, rfl⟩ := Finset.mem_image.mp ht exact Finset.mem_Icc.mpr ⟨hjpos p hp, (Nat.div_le_self _ _).trans ((Nat.sub_le p 1).trans (Nat.le_of_mem_primesLE (Finset.mem_filter.mp hp).1))⟩ calc _ ≤ ∑ p ∈ s, (1 : ℝ) / (k * j p) := by apply Finset.sum_le_sum intro p hp apply one_div_le_one_div_of_le · exact_mod_cast Nat.mul_pos hk (hjpos p hp) · exact_mod_cast ((Nat.le_add_right (k * j p) 1).trans_eq (hj p hp).symm) _ = (∑ t ∈ s.image j, (1 : ℝ) / t) / k := by rw [Finset.sum_image hinj, Finset.sum_div] apply Finset.sum_congr rfl intro p hp ring _ ≤ (∑ t ∈ Finset.Icc 1 N, (1 : ℝ) / t) / k := by apply div_le_div_of_nonneg_right _ (Nat.cast_nonneg _) exact Finset.sum_le_sum_of_subset_of_nonneg hsub (by intros; positivity) _ ≤ _ := div_le_div_of_nonneg_right (reciprocal_naturals_sum_le_log N) (Nat.cast_nonneg _) /- Original line 9735: Erdos416Proof.positiveMultiples -/ def positiveMultiples (N d : ℕ) : Finset ℕ := (Finset.Icc 1 N).filter (fun n => d ∣ n) /- Original line 9738: Erdos416Proof.positiveMultiples_card -/ theorem positiveMultiples_card (N d : ℕ) : (positiveMultiples N d).card = N / d := by simpa only [positiveMultiples, ← Finset.Icc_add_one_left_eq_Ioc, Nat.zero_add] using Nat.Ioc_filter_dvd_card_eq_div N d /- Original line 9742: Erdos416Proof.positiveMultiples_card_le -/ theorem positiveMultiples_card_le (N d : ℕ) : ((positiveMultiples N d).card : ℝ) ≤ (N : ℝ) / d := by rw [positiveMultiples_card] exact Nat.cast_div_le /- Original line 9747: Erdos416Proof.primeSquareBad -/ def primeSquareBad (N q : ℕ) : Finset ℕ := (Finset.Icc 1 N).filter (fun n => q ^ 2 ∣ n ∨ q ^ 2 ∣ n.totient) /- Original line 9750: Erdos416Proof.primeSquareBad_card_le_progressions -/ theorem primeSquareBad_card_le_progressions {N q : ℕ} (hq : q.Prime) : ((primeSquareBad N q).card : ℝ) ≤ (N : ℝ) * ((1 : ℝ) / (q : ℝ) ^ 2 + (∑ p ∈ (Nat.primesLE N).filter (fun p => q ^ 2 ∣ p - 1), (1 : ℝ) / p) + (∑ p ∈ (Nat.primesLE N).filter (fun p => q ∣ p - 1), (1 : ℝ) / p) ^ 2) := by classical let P₁ := (Nat.primesLE N).filter (fun p => q ∣ p - 1) let P₂ := (Nat.primesLE N).filter (fun p => q ^ 2 ∣ p - 1) let B₂ := P₂.biUnion (positiveMultiples N) let B₃ := P₁.biUnion fun p => P₁.biUnion fun r => positiveMultiples N (p * r) have hcover : primeSquareBad N q ⊆ positiveMultiples N (q ^ 2) ∪ B₂ ∪ B₃ := by intro n hn obtain ⟨hnN, hbad⟩ := Finset.mem_filter.mp hn have hnpos : 0 < n := (Finset.mem_Icc.mp hnN).1 have hprimeN (p : ℕ) (hp : p ∈ n.primeFactors) : p ∈ Nat.primesLE N := Nat.mem_primesLE.mpr ⟨(Nat.le_of_mem_primeFactors hp).trans (Finset.mem_Icc.mp hnN).2, Nat.prime_of_mem_primeFactors hp⟩ have hcases : q ^ 2 ∣ n ∨ (∃ p ∈ n.primeFactors, q ^ 2 ∣ p - 1) ∨ (∃ p ∈ n.primeFactors, ∃ r ∈ n.primeFactors, p ≠ r ∧ q ∣ p - 1 ∧ q ∣ r - 1) := hbad.elim Or.inl (prime_square_totient_cases hnpos hq) rcases hcases with hs | ⟨p, hp, hps⟩ | ⟨p, hp, r, hr, hpr, hpq, hrq⟩ · exact Finset.mem_union_left _ (Finset.mem_union_left _ (Finset.mem_filter.mpr ⟨hnN, hs⟩)) · apply Finset.mem_union_left apply Finset.mem_union_right exact Finset.mem_biUnion.mpr ⟨p, Finset.mem_filter.mpr ⟨hprimeN p hp, hps⟩, Finset.mem_filter.mpr ⟨hnN, Nat.dvd_of_mem_primeFactors hp⟩⟩ · apply Finset.mem_union_right apply Finset.mem_biUnion.mpr refine ⟨p, Finset.mem_filter.mpr ⟨hprimeN p hp, hpq⟩, ?_⟩ apply Finset.mem_biUnion.mpr refine ⟨r, Finset.mem_filter.mpr ⟨hprimeN r hr, hrq⟩, Finset.mem_filter.mpr ⟨hnN, ?_⟩⟩ exact ((Nat.coprime_primes (Nat.prime_of_mem_primeFactors hp) (Nat.prime_of_mem_primeFactors hr)).mpr hpr).mul_dvd_of_dvd_of_dvd (Nat.dvd_of_mem_primeFactors hp) (Nat.dvd_of_mem_primeFactors hr) have hnat : (primeSquareBad N q).card ≤ (positiveMultiples N (q ^ 2)).card + (∑ p ∈ P₂, (positiveMultiples N p).card) + (∑ p ∈ P₁, ∑ r ∈ P₁, (positiveMultiples N (p * r)).card) := by calc _ ≤ (positiveMultiples N (q ^ 2) ∪ B₂ ∪ B₃).card := Finset.card_le_card hcover _ ≤ (positiveMultiples N (q ^ 2)).card + B₂.card + B₃.card := (Finset.card_union_le _ _).trans (Nat.add_le_add_right (Finset.card_union_le _ _) _) _ ≤ _ := Nat.add_le_add (Nat.add_le_add_left Finset.card_biUnion_le _) (Finset.card_biUnion_le.trans (Finset.sum_le_sum fun _ _ => Finset.card_biUnion_le)) have hreal : ((primeSquareBad N q).card : ℝ) ≤ ((positiveMultiples N (q ^ 2)).card : ℝ) + (∑ p ∈ P₂, ((positiveMultiples N p).card : ℝ)) + (∑ p ∈ P₁, ∑ r ∈ P₁, ((positiveMultiples N (p * r)).card : ℝ)) := by exact_mod_cast hnat calc _ ≤ _ := hreal _ ≤ (N : ℝ) / (q : ℝ) ^ 2 + (∑ p ∈ P₂, (N : ℝ) / p) + ∑ p ∈ P₁, ∑ r ∈ P₁, (N : ℝ) / ((p : ℝ) * r) := by apply add_le_add · apply add_le_add · convert positiveMultiples_card_le N (q ^ 2) using 1 <;> push_cast <;> rfl · exact Finset.sum_le_sum fun p hp => positiveMultiples_card_le N p · apply Finset.sum_le_sum intro p hp apply Finset.sum_le_sum intro r hr simpa only [Nat.cast_mul] using positiveMultiples_card_le N (p * r) _ = _ := by change _ = (N : ℝ) * (1 / (q : ℝ) ^ 2 + (∑ p ∈ P₂, 1 / (p : ℝ)) + (∑ p ∈ P₁, 1 / (p : ℝ)) ^ 2) simp only [div_eq_mul_inv, mul_inv, pow_two, mul_add, Finset.mul_sum, mul_comm, mul_one] /- Original line 9817: Erdos416Proof.primeSquareBad_card_le -/ theorem primeSquareBad_card_le {N q : ℕ} (hN : 0 < N) (hq : q.Prime) : ((primeSquareBad N q).card : ℝ) ≤ 3 * N * (1 + Real.log N) ^ 2 / (q : ℝ) ^ 2 := by have hL : 1 ≤ 1 + Real.log N := by have h := Real.log_nonneg (show (1 : ℝ) ≤ N by exact_mod_cast hN) linarith have hqR : (0 : ℝ) < q := by exact_mod_cast hq.pos have h₁ := prime_progression_reciprocal_elementary N q hq.pos have h₂ := prime_progression_reciprocal_elementary N (q ^ 2) (pow_pos hq.pos 2) simp only [Nat.cast_pow] at h₂ have h₁sq : (∑ p ∈ (Nat.primesLE N).filter (fun p => q ∣ p - 1), (1 : ℝ) / p) ^ 2 ≤ ((1 + Real.log N) / q) ^ 2 := pow_le_pow_left₀ (Finset.sum_nonneg fun _ _ => by positivity) h₁ 2 apply (primeSquareBad_card_le_progressions hq).trans calc _ ≤ (N : ℝ) * (1 / (q : ℝ) ^ 2 + (1 + Real.log N) / (q : ℝ) ^ 2 + ((1 + Real.log N) / q) ^ 2) := by gcongr _ = (N : ℝ) * (1 + (1 + Real.log N) + (1 + Real.log N) ^ 2) / (q : ℝ) ^ 2 := by ring _ ≤ _ := by apply div_le_div_of_nonneg_right _ (sq_nonneg _) have hpoly : 1 + (1 + Real.log N) + (1 + Real.log N) ^ 2 ≤ 3 * (1 + Real.log N) ^ 2 := by nlinarith nlinarith [mul_le_mul_of_nonneg_left hpoly (Nat.cast_nonneg N)] /- Original line 9841: Erdos416Proof.finite_inverse_square_tail -/ theorem finite_inverse_square_tail (Q : Finset ℕ) {H : ℕ} (hH : 0 < H) (hQ : ∀ q ∈ Q, H ≤ q) : (∑ q ∈ Q, (1 : ℝ) / (q : ℝ) ^ 2) ≤ 2 / H := by classical have hinj : Set.InjOn (fun q => q - H) (Q : Set ℕ) := by intro q hq r hr heq change q - H = r - H at heq have := hQ q hq have := hQ r hr omega have heq : (∑ q ∈ Q, (1 : ℝ) / (q : ℝ) ^ 2) = ∑ j ∈ Q.image (fun q => q - H), (1 : ℝ) / ((j : ℝ) + H) ^ 2 := by rw [Finset.sum_image hinj] apply Finset.sum_congr rfl intro q hq rw [← Nat.cast_add, Nat.sub_add_cancel (hQ q hq)] rw [heq] have hs : Summable (fun j : ℕ => (1 : ℝ) / ((j : ℝ) + H) ^ 2) := by simpa only [Nat.cast_add] using (summable_nat_add_iff H).mpr (Real.summable_one_div_nat_pow.mpr (by norm_num : 1 < 2)) exact (hs.sum_le_tsum _ (by intros; positivity)).trans (Mertens.sum_one_div_sq_le (by exact_mod_cast hH)) /- Original line 9864: Erdos416Proof.largePrimeSquareBad -/ noncomputable def largePrimeSquareBad (N : ℕ) (H : ℝ) : Finset ℕ := (Finset.Icc 1 N).filter (fun n => ∃ q : ℕ, q.Prime ∧ H < q ∧ (q ^ 2 ∣ n ∨ q ^ 2 ∣ n.totient)) /- Original line 9868: Erdos416Proof.largePrimeSquareBad_card_le -/ theorem largePrimeSquareBad_card_le {N : ℕ} (hN : 0 < N) {H : ℝ} (hH : 2 ≤ H) : ((largePrimeSquareBad N H).card : ℝ) ≤ 12 * N * (1 + Real.log N) ^ 2 / H := by classical let Q := (Nat.primesLE N).filter (fun q : ℕ => H < q) have hcover : largePrimeSquareBad N H ⊆ Q.biUnion (primeSquareBad N) := by intro n hn obtain ⟨hnN, q, hq, hHq, hsq⟩ := Finset.mem_filter.mp hn have hnpos : 0 < n := (Finset.mem_Icc.mp hnN).1 have hqle : q ≤ N := by have hsqn : q ^ 2 ≤ n := by rcases hsq with hs | hs · exact Nat.le_of_dvd hnpos hs · exact (Nat.le_of_dvd (Nat.totient_pos.mpr hnpos) hs).trans (Nat.totient_le n) have hq2 := hq.two_le have := (Finset.mem_Icc.mp hnN).2 nlinarith exact Finset.mem_biUnion.mpr ⟨q, Finset.mem_filter.mpr ⟨Nat.mem_primesLE.mpr ⟨hqle, hq⟩, hHq⟩, Finset.mem_filter.mpr ⟨hnN, hsq⟩⟩ have hsum : ((largePrimeSquareBad N H).card : ℝ) ≤ ∑ q ∈ Q, ((primeSquareBad N q).card : ℝ) := by exact_mod_cast (Finset.card_le_card hcover).trans Finset.card_biUnion_le have hfloor : 0 < ⌊H⌋₊ := Nat.floor_pos.mpr (by linarith) have htail : (∑ q ∈ Q, (1 : ℝ) / (q : ℝ) ^ 2) ≤ 4 / H := by apply (finite_inverse_square_tail Q hfloor ?_).trans · have hF : (0 : ℝ) < ⌊H⌋₊ := by exact_mod_cast hfloor apply (div_le_div_iff₀ hF (by linarith : 0 < H)).mpr have := Nat.lt_floor_add_one H linarith · intro q hq have hqR := (Finset.mem_filter.mp hq).2 exact_mod_cast (Nat.floor_le (by linarith : 0 ≤ H)).trans hqR.le calc _ ≤ _ := hsum _ ≤ ∑ q ∈ Q, 3 * N * (1 + Real.log N) ^ 2 / (q : ℝ) ^ 2 := by apply Finset.sum_le_sum intro q hq exact primeSquareBad_card_le hN (Nat.prime_of_mem_primesLE (Finset.mem_filter.mp hq).1) _ = (3 * N * (1 + Real.log N) ^ 2) * (∑ q ∈ Q, (1 : ℝ) / (q : ℝ) ^ 2) := by rw [Finset.mul_sum] apply Finset.sum_congr rfl intro q hq ring _ ≤ (3 * N * (1 + Real.log N) ^ 2) * (4 / H) := mul_le_mul_of_nonneg_left htail (by positivity) _ = _ := by ring /-- The enlarged elementary square cutoff remains below the normality scale. Every later use of the original cutoff required only this comparison. -/ /- Original line 9917: Erdos416Proof.fourth_log_cutoff_lt_normalityScale -/ theorem fourth_log_cutoff_lt_normalityScale : ∀ᶠ y : ℝ in atTop, Real.log y ^ 4 < normalityScale (Real.log (Real.log y)) := by have hT := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop have hU := Real.tendsto_log_atTop.comp hT filter_upwards [hU.eventually_ge_atTop 4, hT.eventually_gt_atTop 0, eventually_gt_atTop (1 : ℝ)] with y hU hTpos hy dsimp only [Function.comp_apply] at hU hTpos have hy0 : 0 < y := by linarith have hlog : 0 < Real.log y := Real.log_pos hy have hUone : 1 ≤ Real.log (Real.log (Real.log y)) := by linarith have hp : Real.log (Real.log (Real.log y)) ^ 2 ≤ Real.log (Real.log (Real.log y)) ^ 10 := pow_le_pow_right₀ hUone (by norm_num) have hlog4 : Real.log 4 ≤ 3 := by have := Real.log_le_sub_one_of_pos (by norm_num : (0 : ℝ) < 4) linarith have hU : Real.log 4 + Real.log (Real.log (Real.log y)) < Real.log (Real.log (Real.log y)) ^ 10 := by nlinarith have hinner : 4 * Real.log (Real.log y) < Real.exp (Real.log (Real.log (Real.log y)) ^ 10) := by have hh := Real.exp_lt_exp.mpr hU simpa only [Real.exp_add, Real.exp_log (by norm_num : (0 : ℝ) < 4), Real.exp_log hTpos] using hh apply (Real.log_lt_log_iff (by positivity) (Real.exp_pos (Real.exp (Real.log (Real.log (Real.log y)) ^ 10)))).mp simpa only [Real.log_pow, Nat.cast_ofNat, normalityScale, Real.log_exp] using hinner /- Original line 9942: Erdos416Proof.largePrimeSquareBad_uniform_bound -/ theorem largePrimeSquareBad_uniform_bound {c : ℝ} (hc : 0 < c) : ∀ᶠ y : ℝ in atTop, ∀ N : ℕ, (N : ℝ) ≤ c * y * Real.log (Real.log y) → ((largePrimeSquareBad N (Real.log y ^ 4)).card : ℝ) ≤ (12 * c * (1 + Real.exp 1) ^ 2) * y * Real.log (Real.log y) / Real.log y ^ 2 := by have hT := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [hT.eventually_gt_atTop 0, hT.eventually (inverse_totient_scale_envelope c), Real.tendsto_log_atTop.eventually_ge_atTop 2, eventually_gt_atTop (1 : ℝ)] with y hTpos henv hlog2 hy dsimp only [Function.comp_apply] at hTpos henv have hy0 : 0 < y := by linarith have hlog : 0 < Real.log y := Real.log_pos hy have hExpT : Real.exp (Real.log (Real.log y)) = Real.log y := Real.exp_log hlog have hExpExpT : Real.exp (Real.exp (Real.log (Real.log y))) = y := by rw [hExpT, Real.exp_log hy0] rw [hExpExpT] at henv intro N hN by_cases hN0 : N = 0 · subst N simp only [largePrimeSquareBad, Finset.Icc_eq_empty_of_lt (by norm_num : (0 : ℕ) < 1), Finset.filter_empty, Finset.card_empty, Nat.cast_zero] positivity have hNpos : 0 < N := Nat.pos_of_ne_zero hN0 have hNR : (0 : ℝ) < N := by exact_mod_cast hNpos have hlogN := Real.log_le_log hNR (hN.trans henv) rw [Real.log_exp, Real.exp_add, hExpT] at hlogN have hLN : 0 ≤ 1 + Real.log N := by have := Real.log_nonneg (show (1 : ℝ) ≤ N by exact_mod_cast hNpos) linarith have hLbound : 1 + Real.log N ≤ (1 + Real.exp 1) * Real.log y := by nlinarith have hcut : 2 ≤ Real.log y ^ 4 := by have := pow_le_pow_left₀ (by norm_num : (0 : ℝ) ≤ 2) hlog2 4 norm_num at this linarith calc _ ≤ 12 * N * (1 + Real.log N) ^ 2 / Real.log y ^ 4 := largePrimeSquareBad_card_le hNpos hcut _ ≤ 12 * (c * y * Real.log (Real.log y)) * ((1 + Real.exp 1) * Real.log y) ^ 2 / Real.log y ^ 4 := by apply div_le_div_of_nonneg_right _ (pow_nonneg hlog.le 4) exact mul_le_mul (mul_le_mul_of_nonneg_left hN (by norm_num)) (pow_le_pow_left₀ hLN hLbound 2) (sq_nonneg _) (by positivity) _ = _ := by field_simp /- Original line 9985: Erdos416Proof.largeSquareExceptionalCount -/ noncomputable def largeSquareExceptionalCount (c y : ℝ) : ℝ := (largePrimeSquareBad ⌊c * y * Real.log (Real.log y)⌋₊ (Real.log y ^ 4)).card /-- The complete large-square exceptional estimate, with an elementary replacement cutoff. The count covers all positive integers, including every possible original or auxiliary preimage in the inverse-totient size range. -/ /- Original line 9991: Erdos416Proof.large_prime_square_pruning -/ theorem large_prime_square_pruning {c : ℝ} (hc : 0 < c) : (largeSquareExceptionalCount c) =o[atTop] (fun y : ℝ => y / (Real.log y * Real.log (Real.log y) ^ 2)) := by let K : ℝ := 12 * c * (1 + Real.exp 1) ^ 2 have hT := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop have hpos : ∀ᶠ y : ℝ in atTop, 0 < y ∧ 0 < Real.log y ∧ 0 < Real.log (Real.log y) := by filter_upwards [eventually_gt_atTop (1 : ℝ), hT.eventually_gt_atTop 0] with y hy hTpos exact ⟨by linarith, Real.log_pos hy, hTpos⟩ have hlim : Tendsto (fun y : ℝ => K * (Real.log (Real.log y) ^ 3 / Real.log y)) atTop (nhds 0) := by have hbase := (log_pow_mul_rpow_littleO 3 (show (0 : ℝ) < 1 by norm_num)).tendsto_div_nhds_zero have h := (hbase.comp Real.tendsto_log_atTop).const_mul K simpa only [Function.comp_apply, Real.rpow_zero, Real.rpow_one, mul_one, mul_zero] using h apply (Asymptotics.isLittleO_iff_tendsto' ?_).mpr · refine squeeze_zero' ?_ ?_ hlim · filter_upwards [hpos] with y hy rcases hy with ⟨hy, hlog, hTpos⟩ exact div_nonneg (Nat.cast_nonneg _) (by positivity) · filter_upwards [largePrimeSquareBad_uniform_bound hc, hpos] with y hbound hy rcases hy with ⟨hy, hlog, hTpos⟩ have hfloor : (⌊c * y * Real.log (Real.log y)⌋₊ : ℝ) ≤ c * y * Real.log (Real.log y) := Nat.floor_le (by positivity) have hB := hbound _ hfloor have hgpos : 0 < y / (Real.log y * Real.log (Real.log y) ^ 2) := by positivity apply (div_le_div_of_nonneg_right hB hgpos.le).trans_eq dsimp only [K] field_simp [hy.ne', hlog.ne', hTpos.ne'] · filter_upwards [hpos] with y hy rcases hy with ⟨hy, hlog, hTpos⟩ intro hzero have : 0 < y / (Real.log y * Real.log (Real.log y) ^ 2) := by positivity exact (this.ne' hzero).elim end Erdos416Proof open Filter open scoped BigOperators Classical Topology namespace Erdos416Proof /- Original line 10033: Erdos416Proof.cofactorSet -/ def cofactorSet (F : Finset ℕ) (p : ℕ → ℕ) : Finset ℕ := F.image (fun n => n / p n) /-- Uniform counting by a selected large prime and its cofactor. No factorial form of the Hardy-Ramanujan estimate is required for this bound. -/ /- Original line 10038: Erdos416Proof.prime_cofactor_count_bound -/ theorem prime_cofactor_count_bound : ∃ C : ℝ, 0 < C ∧ ∀ (F : Finset ℕ) (p : ℕ → ℕ) (z a : ℝ), 0 < z → 0 < a → (∀ n ∈ F, 0 < n ∧ (n : ℝ) ≤ z ∧ (p n).Prime ∧ p n ∣ n ∧ a ≤ Real.log (p n)) → (F.card : ℝ) ≤ C * z / a * ∑ b ∈ cofactorSet F p, (1 : ℝ) / b := by classical obtain ⟨C, hC, hprime⟩ := exists_primeCountReal_upper_bound refine ⟨C, hC, ?_⟩ intro F p z a hz ha hF let B := cofactorSet F p have hbpos (n : ℕ) (hn : n ∈ F) : 0 < n / p n := by obtain ⟨hnpos, _, hp, hd, _⟩ := hF n hn exact Nat.div_pos (Nat.le_of_dvd hnpos hd) hp.pos have hple (n : ℕ) (hn : n ∈ F) : (p n : ℝ) ≤ z / (n / p n : ℕ) := by have hbR : (0 : ℝ) < (n / p n : ℕ) := by exact_mod_cast hbpos n hn apply (le_div_iff₀ hbR).mpr have hmul : (p n : ℝ) * (n / p n : ℕ) = n := by exact_mod_cast Nat.mul_div_cancel' (hF n hn).2.2.2.1 exact hmul.trans_le (hF n hn).2.1 have hB (b : ℕ) (hb : b ∈ B) : 0 < b ∧ 2 ≤ z / b ∧ a ≤ Real.log (z / b) := by obtain ⟨n, hn, rfl⟩ := Finset.mem_image.mp hb obtain ⟨hnpos, hnz, hp, hd, hlog⟩ := hF n hn refine ⟨hbpos n hn, (by exact_mod_cast hp.two_le : (2 : ℝ) ≤ p n).trans (hple n hn), ?_⟩ exact hlog.trans (Real.log_le_log (by exact_mod_cast hp.pos) (hple n hn)) let S : Finset (Σ _ : ℕ, ℕ) := B.sigma fun b => Nat.primesLE ⌊z / b⌋₊ have hcard : F.card ≤ S.card := by apply Finset.card_le_card_of_injOn (fun n => (⟨n / p n, p n⟩ : Σ _ : ℕ, ℕ)) · intro n hn exact Finset.mem_sigma.mpr ⟨Finset.mem_image.mpr ⟨n, hn, rfl⟩, Nat.mem_primesLE.mpr ⟨Nat.le_floor (hple n hn), (hF n hn).2.2.1⟩⟩ · intro n hn m hm heq have hb : n / p n = m / p m := congrArg Sigma.fst heq have hp : p n = p m := congrArg (fun x : Σ _ : ℕ, ℕ => x.2) heq calc n = (n / p n) * p n := (Nat.div_mul_cancel (hF n hn).2.2.2.1).symm _ = (m / p m) * p m := by rw [hb, hp] _ = m := Nat.div_mul_cancel (hF m hm).2.2.2.1 have hsum : (F.card : ℝ) ≤ ∑ b ∈ B, primeCountReal (z / b) := by have hR : (F.card : ℝ) ≤ (S.card : ℝ) := by exact_mod_cast hcard simpa only [S, Finset.card_sigma, Nat.cast_sum, Nat.primesLE_card_eq_primeCounting, primeCountReal] using hR calc _ ≤ _ := hsum _ ≤ ∑ b ∈ B, (C * z / a) * ((1 : ℝ) / b) := by apply Finset.sum_le_sum intro b hb obtain ⟨hbpos, hx2, halog⟩ := hB b hb have hbR : (0 : ℝ) < b := by exact_mod_cast hbpos calc _ ≤ C * (z / b) / Real.log (z / b) := hprime _ hx2 _ ≤ C * (z / b) / a := div_le_div_of_nonneg_left (by positivity) ha halog _ = _ := by ring _ = _ := (Finset.mul_sum _ _ _).symm /- Original line 10093: Erdos416Proof.primeFactors_card_le_cardFactors -/ theorem primeFactors_card_le_cardFactors (n : ℕ) : n.primeFactors.card ≤ ArithmeticFunction.cardFactors n := by change n.primeFactorsList.toFinset.card ≤ n.primeFactorsList.length exact List.toFinset_card_le (l := n.primeFactorsList) /- Original line 10098: Erdos416Proof.reciprocal_le_invTotient -/ theorem reciprocal_le_invTotient {n : ℕ} (hn : 0 < n) : (1 : ℝ) / n ≤ invTotient n := by rw [invTotient, ← one_div] exact one_div_le_one_div_of_le (by exact_mod_cast Nat.totient_pos.mpr hn) (by exact_mod_cast Nat.totient_le n) /-- A coarse substitute for the squarefree factor-count estimate. Its loss is exponential in k log(log(log z)), which is sufficient when k = O(log_3 z). -/ /- Original line 10105: Erdos416Proof.squarefree_bounded_factors_card_le -/ theorem squarefree_bounded_factors_card_le : ∃ C : ℝ, 0 < C ∧ ∀ (F : Finset ℕ) (z : ℝ) (k : ℕ), 4 ≤ z → 0 < k → (∀ n ∈ F, Squarefree n ∧ (n : ℝ) ≤ z ∧ ArithmeticFunction.cardFactors n ≤ k) → (F.card : ℝ) ≤ Real.sqrt z + (2 * C * k * z / Real.log z) * (Real.exp 1 * (1 + ∑ p ∈ Nat.primesLE ⌊z⌋₊, (1 : ℝ) / ((p : ℝ) - 1)) ^ k) := by classical obtain ⟨C, hC, hcount⟩ := prime_cofactor_count_bound refine ⟨C, hC, ?_⟩ intro F z k hz hk hF have hzpos : 0 < z := by linarith have hlog : 0 < Real.log z := Real.log_pos (by linarith) have hkR : (0 : ℝ) < k := by exact_mod_cast hk have hsqrt2 : (2 : ℝ) ≤ Real.sqrt z := Real.le_sqrt_of_sq_le (by norm_num; exact hz) let G := F.filter (fun n : ℕ => Real.sqrt z < n) let E := F.filter (fun n : ℕ => ¬ Real.sqrt z < n) let B := cofactorSet G largestPrimeFactor let a := Real.log z / (2 * (k : ℝ)) have ha : 0 < a := by dsimp [Erdos416Proof.invTotient_one, Erdos416Proof.largestPrimeFactor_one, a]; positivity have hG (n : ℕ) (hn : n ∈ G) : 0 < n ∧ (n : ℝ) ≤ z ∧ (largestPrimeFactor n).Prime ∧ largestPrimeFactor n ∣ n ∧ a ≤ Real.log (largestPrimeFactor n) := by obtain ⟨hnF, hnlarge⟩ := Finset.mem_filter.mp hn obtain ⟨hnSF, hnz, hnk⟩ := hF n hnF have hnpos : 0 < n := Nat.pos_of_ne_zero hnSF.ne_zero have hn1 : 1 < n := by have hnR : (1 : ℝ) < n := by linarith exact_mod_cast hnR have hp := largestPrimeFactor_isPrime (largestPrimeFactor_one_lt hn1) refine ⟨hnpos, hnz, hp, largestPrimeFactor_dvd n, ?_⟩ have hln : Real.log z / 2 ≤ Real.log n := by have h := Real.log_le_log (Real.sqrt_pos.mpr hzpos) hnlarge.le simpa only [Real.log_sqrt hzpos.le] using h have hΩ := log_le_cardFactors_mul_log_largestPrimeFactor hnpos have hpLog : 0 ≤ Real.log (largestPrimeFactor n) := Real.log_nonneg (by exact_mod_cast hp.one_le) have hklog := mul_le_mul_of_nonneg_right (show (ArithmeticFunction.cardFactors n : ℝ) ≤ k by exact_mod_cast hnk) hpLog apply (div_le_iff₀ (by positivity : 0 < 2 * (k : ℝ))).mpr nlinarith have hB (b : ℕ) (hb : b ∈ B) : Squarefree b ∧ b.primeFactors ⊆ Nat.primesLE ⌊z⌋₊ ∧ b.primeFactors.card ≤ k := by obtain ⟨n, hn, rfl⟩ := Finset.mem_image.mp hb obtain ⟨hnpos, hnz, hp, hpn, _⟩ := hG n hn obtain ⟨hnSF, _, hnk⟩ := hF n (Finset.mem_filter.mp hn).1 have hd : n / largestPrimeFactor n ∣ n := Nat.div_dvd_of_dvd hpn refine ⟨hnSF.squarefree_of_dvd hd, ?_, ?_⟩ · intro q hq have hqn : q ≤ n := (Nat.le_of_mem_primeFactors hq).trans (Nat.div_le_self _ _) have hqnR : (q : ℝ) ≤ n := by exact_mod_cast hqn exact Nat.mem_primesLE.mpr ⟨Nat.le_floor (hqnR.trans hnz), Nat.prime_of_mem_primeFactors hq⟩ · exact (Finset.card_le_card (Nat.primeFactors_mono hd hnSF.ne_zero)).trans ((primeFactors_card_le_cardFactors n).trans hnk) have hrecip : (∑ b ∈ B, (1 : ℝ) / b) ≤ Real.exp 1 * (1 + ∑ p ∈ Nat.primesLE ⌊z⌋₊, (1 : ℝ) / ((p : ℝ) - 1)) ^ k := by calc _ ≤ ∑ b ∈ B, invTotient b := Finset.sum_le_sum fun b hb => reciprocal_le_invTotient (Nat.pos_of_ne_zero (hB b hb).1.ne_zero) _ ≤ _ := squarefree_reciprocal_sum_bound B (Nat.primesLE ⌊z⌋₊) k (fun p hp => Nat.prime_of_mem_primesLE hp) hB have hlarge : (G.card : ℝ) ≤ (2 * C * k * z / Real.log z) * (Real.exp 1 * (1 + ∑ p ∈ Nat.primesLE ⌊z⌋₊, (1 : ℝ) / ((p : ℝ) - 1)) ^ k) := by have hc := hcount G largestPrimeFactor z a hzpos ha hG calc _ ≤ (C * z / a) * ∑ b ∈ B, (1 : ℝ) / b := hc _ ≤ (C * z / a) * _ := mul_le_mul_of_nonneg_left hrecip (by positivity) _ = _ := by dsimp [Erdos416Proof.invTotient_one, Erdos416Proof.largestPrimeFactor_one, a]; field_simp have hsmall : (E.card : ℝ) ≤ Real.sqrt z := by have hsub : E ⊆ Finset.Icc 1 ⌊Real.sqrt z⌋₊ := by intro n hn obtain ⟨hnF, hnsmall⟩ := Finset.mem_filter.mp hn exact Finset.mem_Icc.mpr ⟨Nat.one_le_iff_ne_zero.mpr (hF n hnF).1.ne_zero, Nat.le_floor (le_of_not_gt hnsmall)⟩ calc _ ≤ ((Finset.Icc 1 ⌊Real.sqrt z⌋₊).card : ℝ) := by exact_mod_cast Finset.card_le_card hsub _ = (⌊Real.sqrt z⌋₊ : ℝ) := by simp[Erdos416Proof.invTotient_one, Erdos416Proof.largestPrimeFactor_one] _ ≤ _ := Nat.floor_le (Real.sqrt_nonneg _) have hcard : (G.card : ℝ) + E.card = F.card := by exact_mod_cast Finset.card_filter_add_card_filter_not (s := F) (fun n : ℕ => Real.sqrt z < n) linarith /- Original line 10184: Erdos416Proof.squarefree_natural_reciprocal_sum_bound -/ theorem squarefree_natural_reciprocal_sum_bound (M P : Finset ℕ) (k : ℕ) (hP : ∀ p ∈ P, p.Prime) (hM : ∀ n ∈ M, Squarefree n ∧ n.primeFactors ⊆ P ∧ n.primeFactors.card ≤ k) : (∑ n ∈ M, (1 : ℝ) / n) ≤ Real.exp 1 * (1 + ∑ p ∈ P, (1 : ℝ) / ((p : ℝ) - 1)) ^ k := by calc _ ≤ ∑ n ∈ M, invTotient n := Finset.sum_le_sum fun n hn => reciprocal_le_invTotient (Nat.pos_of_ne_zero (hM n hn).1.ne_zero) _ ≤ _ := squarefree_reciprocal_sum_bound M P k hP hM /-- The reciprocal weight of squarefree cofactors with an exceptional prime divisor is bounded by the exceptional-prime reciprocal weight times an unrestricted cofactor sum. -/ /- Original line 10197: Erdos416Proof.squarefree_exceptional_reciprocal_sum_bound -/ theorem squarefree_exceptional_reciprocal_sum_bound (M P Q : Finset ℕ) (k : ℕ) (hP : ∀ p ∈ P, p.Prime) (hM : ∀ n ∈ M, Squarefree n ∧ n.primeFactors ⊆ P ∧ n.primeFactors.card ≤ k) (hbad : ∀ n ∈ M, ∃ q ∈ Q, q ∣ n) : (∑ n ∈ M, (1 : ℝ) / n) ≤ (∑ q ∈ Q, (1 : ℝ) / q) * (Real.exp 1 * (1 + ∑ p ∈ P, (1 : ℝ) / ((p : ℝ) - 1)) ^ k) := by classical let B (q : ℕ) := (M.filter (fun n => q ∣ n)).image (fun n => n / q) have hB (q : ℕ) : ∀ b ∈ B q, Squarefree b ∧ b.primeFactors ⊆ P ∧ b.primeFactors.card ≤ k := by intro b hb obtain ⟨n, hn, rfl⟩ := Finset.mem_image.mp hb obtain ⟨hnM, hqn⟩ := Finset.mem_filter.mp hn obtain ⟨hnSF, hnP, hnk⟩ := hM n hnM have hd : n / q ∣ n := Nat.div_dvd_of_dvd hqn have hsub := Nat.primeFactors_mono hd hnSF.ne_zero exact ⟨hnSF.squarefree_of_dvd hd, hsub.trans hnP, (Finset.card_le_card hsub).trans hnk⟩ have hsubsum (q : ℕ) : (∑ n ∈ M.filter (fun n => q ∣ n), (1 : ℝ) / n) = ((1 : ℝ) / q) * ∑ b ∈ B q, (1 : ℝ) / b := by have hinj : Set.InjOn (fun n : ℕ => n / q) ((M.filter (fun n => q ∣ n)) : Set ℕ) := by intro n hn m hm hnm change n / q = m / q at hnm have hnprod := Nat.div_mul_cancel (Finset.mem_filter.mp hn).2 have hmprod := Nat.div_mul_cancel (Finset.mem_filter.mp hm).2 rw [hnm, hmprod] at hnprod exact hnprod.symm change _ = ((1 : ℝ) / q) * ∑ b ∈ (M.filter (fun n => q ∣ n)).image (fun n => n / q), (1 : ℝ) / b rw [Finset.sum_image hinj, Finset.mul_sum] apply Finset.sum_congr rfl intro n hn have hnprod : ((n / q : ℕ) : ℝ) * q = n := by exact_mod_cast Nat.div_mul_cancel (Finset.mem_filter.mp hn).2 calc _ = 1 / (((n / q : ℕ) : ℝ) * q) := by rw [hnprod] _ = _ := by ring have hcover : (∑ n ∈ M, (1 : ℝ) / n) ≤ ∑ q ∈ Q, ∑ n ∈ M.filter (fun n => q ∣ n), (1 : ℝ) / n := by simp only [Finset.sum_filter] rw [Finset.sum_comm] apply Finset.sum_le_sum intro n hn obtain ⟨q, hq, hqn⟩ := hbad n hn have h := Finset.single_le_sum (s := Q) (f := fun q : ℕ => if q ∣ n then (1 : ℝ) / n else 0) (fun r hr => by split_ifs <;> positivity) hq simpa only [if_pos hqn] using h calc _ ≤ _ := hcover _ = ∑ q ∈ Q, ((1 : ℝ) / q) * ∑ b ∈ B q, (1 : ℝ) / b := Finset.sum_congr rfl (fun q _ => hsubsum q) _ ≤ ∑ q ∈ Q, ((1 : ℝ) / q) * (Real.exp 1 * (1 + ∑ p ∈ P, (1 : ℝ) / ((p : ℝ) - 1)) ^ k) := by apply Finset.sum_le_sum intro q hq exact mul_le_mul_of_nonneg_left (squarefree_natural_reciprocal_sum_bound (B q) P k hP (hB q)) (by positivity) _ = _ := (Finset.sum_mul _ _ _).symm end Erdos416Proof open Filter Asymptotics open scoped BigOperators Classical Topology namespace Erdos416Proof /- Original line 10265: Erdos416Proof.largeSquareFailures -/ noncomputable def largeSquareFailures {ι : Type*} (F : Finset ι) (w : ι → ℕ) (H : ℝ) : Finset ι := F.filter (fun idx => ∃ q : ℕ, q.Prime ∧ H < q ∧ (q ^ 2 ∣ w idx ∨ q ^ 2 ∣ (w idx).totient)) /- Original line 10268: Erdos416Proof.largeSquareFailures_card_le -/ theorem largeSquareFailures_card_le {ι : Type*} (F : Finset ι) (w : ι → ℕ) (x H : ℝ) (hw : Set.InjOn w (F : Set ι)) (hsize : ∀ idx ∈ F, 0 < w idx ∧ (w idx : ℝ) ≤ x) : (largeSquareFailures F w H).card ≤ (largePrimeSquareBad ⌊x⌋₊ H).card := by classical apply Finset.card_le_card_of_injOn w · intro idx hi obtain ⟨hiF, hbad⟩ := Finset.mem_filter.mp hi exact Finset.mem_filter.mpr ⟨Finset.mem_Icc.mpr ⟨(hsize idx hiF).1, Nat.le_floor (hsize idx hiF).2⟩, hbad⟩ · intro idx hi j hj hij exact hw (Finset.mem_filter.mp hi).1 (Finset.mem_filter.mp hj).1 hij /-- The pruning estimate applies uniformly to any varying family of distinct positive preimages. Their size bound is proved from phi(w) <= y, rather than assumed as an extra analytic input. -/ /- Original line 10283: Erdos416Proof.large_square_pruning_for_injective_preimages -/ theorem large_square_pruning_for_injective_preimages {ι : Type*} (F : ℝ → Finset ι) (w : ℝ → ι → ℕ) (hpre : ∀ᶠ y : ℝ in atTop, ∀ idx ∈ F y, 0 < w y idx ∧ ((w y idx).totient : ℝ) ≤ y) (hinj : ∀ᶠ y : ℝ in atTop, Set.InjOn (w y) (F y : Set ι)) : (fun y : ℝ => ((largeSquareFailures (F y) (w y) (Real.log y ^ 4)).card : ℝ)) =o[atTop] (fun y : ℝ => y / (Real.log y * Real.log (Real.log y) ^ 2)) := by obtain ⟨c, hc, hsize⟩ := inverse_totient_bound_eventually have hbound : (fun y : ℝ => ((largeSquareFailures (F y) (w y) (Real.log y ^ 4)).card : ℝ)) =O[atTop] largeSquareExceptionalCount c := by apply IsBigO.of_bound 1 filter_upwards [hpre, hinj, hsize] with y hpre hinj hsize have hcard := largeSquareFailures_card_le (F y) (w y) (c * y * Real.log (Real.log y)) (Real.log y ^ 4) hinj (fun idx hi => ⟨(hpre idx hi).1, hsize _ (hpre idx hi).1 (hpre idx hi).2⟩) simp only [Real.norm_eq_abs, Nat.abs_cast, largeSquareExceptionalCount, one_mul] exact_mod_cast hcard exact hbound.trans_isLittleO (large_prime_square_pruning hc) /- Original line 10301: Erdos416Proof.square_pruning_scale_isBigO_V -/ theorem square_pruning_scale_isBigO_V : (fun y : ℝ => y / (Real.log y * Real.log (Real.log y) ^ 2)) =O[atTop] V := by apply IsBigO.of_bound 2 have hT := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [V_lower_bound_eventually, eventually_gt_atTop (1 : ℝ), hT.eventually_ge_atTop 1] with y hV hy hLL dsimp only [Function.comp_apply] at hLL have hy0 : 0 < y := by linarith have hlog : 0 < Real.log y := Real.log_pos hy have hLL0 : 0 < Real.log (Real.log y) := by linarith have hLLsq : 1 ≤ Real.log (Real.log y) ^ 2 := by nlinarith simp only [Real.norm_eq_abs, abs_of_nonneg (V_nonneg y), abs_of_pos (by positivity : 0 < y / (Real.log y * Real.log (Real.log y) ^ 2))] have hmain : y / Real.log y ≤ 2 * V y := by rw [show y / (2 * Real.log y) = (1 / 2 : ℝ) * (y / Real.log y) by ring] at hV linarith calc _ = (y / Real.log y) / Real.log (Real.log y) ^ 2 := by ring _ ≤ y / Real.log y := div_le_self (by positivity) hLLsq _ ≤ _ := hmain /- Original line 10322: Erdos416Proof.large_square_pruning_negligible_in_V -/ theorem large_square_pruning_negligible_in_V {ι : Type*} (F : ℝ → Finset ι) (w : ℝ → ι → ℕ) (hpre : ∀ᶠ y : ℝ in atTop, ∀ idx ∈ F y, 0 < w y idx ∧ ((w y idx).totient : ℝ) ≤ y) (hinj : ∀ᶠ y : ℝ in atTop, Set.InjOn (w y) (F y : Set ι)) : (fun y : ℝ => ((largeSquareFailures (F y) (w y) (Real.log y ^ 4)).card : ℝ)) =o[atTop] V := (large_square_pruning_for_injective_preimages F w hpre hinj).trans_isBigO square_pruning_scale_isBigO_V end Erdos416Proof open Filter Asymptotics open scoped BigOperators Classical Topology namespace Erdos416Proof /- Original line 10339: Erdos416Proof.finiteCountBelow -/ noncomputable def finiteCountBelow (Q : Finset ℕ) (x : ℝ) : ℝ := (Q.filter (fun q : ℕ => (q : ℝ) ≤ x)).card /- Original line 10342: Erdos416Proof.restricted_prime_cofactor_count_bound -/ theorem restricted_prime_cofactor_count_bound (F : Finset ℕ) (p : ℕ → ℕ) (Q : Finset ℕ) {D z a : ℝ} (hD : 0 ≤ D) (hz : 0 < z) (ha : 0 < a) (hF : ∀ n ∈ F, 0 < n ∧ (n : ℝ) ≤ z ∧ (p n).Prime ∧ p n ∣ n ∧ a ≤ Real.log (p n) ∧ p n ∈ Q) (hdensity : ∀ x : ℝ, 2 ≤ x → x ≤ z → finiteCountBelow Q x ≤ D * x / Real.log x) : (F.card : ℝ) ≤ D * z / a * ∑ b ∈ cofactorSet F p, (1 : ℝ) / b := by classical let B := cofactorSet F p have hbpos (n : ℕ) (hn : n ∈ F) : 0 < n / p n := by obtain ⟨hnpos, _, hp, hd, _⟩ := hF n hn exact Nat.div_pos (Nat.le_of_dvd hnpos hd) hp.pos have hple (n : ℕ) (hn : n ∈ F) : (p n : ℝ) ≤ z / (n / p n : ℕ) := by have hbR : (0 : ℝ) < (n / p n : ℕ) := by exact_mod_cast hbpos n hn apply (le_div_iff₀ hbR).mpr have hmul : (p n : ℝ) * (n / p n : ℕ) = n := by exact_mod_cast Nat.mul_div_cancel' (hF n hn).2.2.2.1 exact hmul.trans_le (hF n hn).2.1 have hB (b : ℕ) (hb : b ∈ B) : 0 < b ∧ 2 ≤ z / b ∧ z / b ≤ z ∧ a ≤ Real.log (z / b) := by obtain ⟨n, hn, rfl⟩ := Finset.mem_image.mp hb obtain ⟨hnpos, hnz, hp, hd, hlog, _⟩ := hF n hn refine ⟨hbpos n hn, (by exact_mod_cast hp.two_le : (2 : ℝ) ≤ p n).trans (hple n hn), ?_, ?_⟩ · exact div_le_self hz.le (by exact_mod_cast hbpos n hn) · exact hlog.trans (Real.log_le_log (by exact_mod_cast hp.pos) (hple n hn)) let S : Finset (Σ _ : ℕ, ℕ) := B.sigma fun b => Q.filter (fun q : ℕ => (q : ℝ) ≤ z / b) have hcard : F.card ≤ S.card := by apply Finset.card_le_card_of_injOn (fun n => (⟨n / p n, p n⟩ : Σ _ : ℕ, ℕ)) · intro n hn exact Finset.mem_sigma.mpr ⟨Finset.mem_image.mpr ⟨n, hn, rfl⟩, Finset.mem_filter.mpr ⟨(hF n hn).2.2.2.2.2, hple n hn⟩⟩ · intro n hn m hm heq have hb : n / p n = m / p m := congrArg Sigma.fst heq have hp : p n = p m := congrArg (fun x : Σ _ : ℕ, ℕ => x.2) heq calc n = (n / p n) * p n := (Nat.div_mul_cancel (hF n hn).2.2.2.1).symm _ = (m / p m) * p m := by rw [hb, hp] _ = m := Nat.div_mul_cancel (hF m hm).2.2.2.1 have hsum : (F.card : ℝ) ≤ ∑ b ∈ B, finiteCountBelow Q (z / b) := by have hR : (F.card : ℝ) ≤ (S.card : ℝ) := by exact_mod_cast hcard simpa only [S, Finset.card_sigma, Nat.cast_sum, finiteCountBelow] using hR calc _ ≤ _ := hsum _ ≤ ∑ b ∈ B, (D * z / a) * ((1 : ℝ) / b) := by apply Finset.sum_le_sum intro b hb obtain ⟨hbpos, hx2, hxz, halog⟩ := hB b hb have hbR : (0 : ℝ) < b := by exact_mod_cast hbpos calc _ ≤ D * (z / b) / Real.log (z / b) := hdensity _ hx2 hxz _ ≤ D * (z / b) / a := div_le_div_of_nonneg_left (by positivity) ha halog _ = _ := by ring _ = _ := (Finset.mul_sum _ _ _).symm /- Original line 10395: Erdos416Proof.largest_prime_log_lower_bound -/ theorem largest_prime_log_lower_bound {z : ℝ} (hz : 4 ≤ z) {k n : ℕ} (hk : 0 < k) (hn : Real.sqrt z < (n : ℝ)) (hΩ : ArithmeticFunction.cardFactors n ≤ k) : 0 < n ∧ (largestPrimeFactor n).Prime ∧ Real.log z / (2 * (k : ℝ)) ≤ Real.log (largestPrimeFactor n) := by have hzpos : 0 < z := by linarith have hsqrt2 : (2 : ℝ) ≤ Real.sqrt z := Real.le_sqrt_of_sq_le (by norm_num; exact hz) have hn1 : 1 < n := by exact_mod_cast (show (1 : ℝ) < n by linarith) have hnpos : 0 < n := by omega have hp := largestPrimeFactor_isPrime (largestPrimeFactor_one_lt hn1) refine ⟨hnpos, hp, ?_⟩ have hln : Real.log z / 2 ≤ Real.log n := by have h := Real.log_le_log (Real.sqrt_pos.mpr hzpos) hn.le simpa only [Real.log_sqrt hzpos.le] using h have hnlog := log_le_cardFactors_mul_log_largestPrimeFactor hnpos have hpLog : 0 ≤ Real.log (largestPrimeFactor n) := Real.log_nonneg (by exact_mod_cast hp.one_le) have hklog := mul_le_mul_of_nonneg_right (show (ArithmeticFunction.cardFactors n : ℝ) ≤ k by exact_mod_cast hΩ) hpLog apply (div_le_iff₀ (by exact_mod_cast Nat.mul_pos (by norm_num : 0 < 2) hk)).mpr nlinarith /- Original line 10415: Erdos416Proof.squarefree_cofactor_data -/ theorem squarefree_cofactor_data {F : Finset ℕ} {p : ℕ → ℕ} {z : ℝ} {k : ℕ} (hF : ∀ n ∈ F, Squarefree n ∧ (n : ℝ) ≤ z ∧ ArithmeticFunction.cardFactors n ≤ k ∧ p n ∣ n) : ∀ b ∈ cofactorSet F p, Squarefree b ∧ b.primeFactors ⊆ Nat.primesLE ⌊z⌋₊ ∧ b.primeFactors.card ≤ k := by intro b hb obtain ⟨n, hn, rfl⟩ := Finset.mem_image.mp hb obtain ⟨hnSF, hnz, hnk, hpn⟩ := hF n hn have hd : n / p n ∣ n := Nat.div_dvd_of_dvd hpn have hsub := Nat.primeFactors_mono hd hnSF.ne_zero refine ⟨hnSF.squarefree_of_dvd hd, ?_, ?_⟩ · intro q hq have hqn : q ≤ n := (Nat.le_of_mem_primeFactors hq).trans (Nat.div_le_self _ _) have hqnR : (q : ℝ) ≤ n := by exact_mod_cast hqn exact Nat.mem_primesLE.mpr ⟨Nat.le_floor (hqnR.trans hnz), Nat.prime_of_mem_primeFactors hq⟩ · exact (Finset.card_le_card hsub).trans ((primeFactors_card_le_cardFactors n).trans hnk) /-- All dependence on an exceptional-prime set is isolated in its counting density and reciprocal sum. This is a finite counting theorem for actual squarefree integers, not an assumed estimate for abstract tuples. -/ /- Original line 10434: Erdos416Proof.squarefree_exceptional_count_bound -/ theorem squarefree_exceptional_count_bound : ∃ C : ℝ, 0 < C ∧ ∀ (F Q : Finset ℕ) (z D : ℝ) (k : ℕ), 4 ≤ z → 0 ≤ D → 0 < k → (∀ q ∈ Q, q.Prime) → (∀ n ∈ F, Squarefree n ∧ (n : ℝ) ≤ z ∧ ArithmeticFunction.cardFactors n ≤ k ∧ ∃ q ∈ Q, q ∣ n) → (∀ x : ℝ, 2 ≤ x → x ≤ z → finiteCountBelow Q x ≤ D * x / Real.log x) → (F.card : ℝ) ≤ Real.sqrt z + (2 * k * z / Real.log z) * (Real.exp 1 * (1 + ∑ p ∈ Nat.primesLE ⌊z⌋₊, (1 : ℝ) / ((p : ℝ) - 1)) ^ k) * (D + C * ∑ q ∈ Q, (1 : ℝ) / q) := by classical obtain ⟨C, hC, hcount⟩ := prime_cofactor_count_bound refine ⟨C, hC, ?_⟩ intro F Q z D k hz hD hk hQ hF hdensity have hzpos : 0 < z := by linarith have hlog : 0 < Real.log z := Real.log_pos (by linarith) have hkR : (0 : ℝ) < k := by exact_mod_cast hk let G := F.filter (fun n : ℕ => Real.sqrt z < n) let E := F.filter (fun n : ℕ => ¬ Real.sqrt z < n) let A := G.filter (fun n => largestPrimeFactor n ∈ Q) let B := G.filter (fun n => ¬ largestPrimeFactor n ∈ Q) let W := Real.exp 1 * (1 + ∑ p ∈ Nat.primesLE ⌊z⌋₊, (1 : ℝ) / ((p : ℝ) - 1)) ^ k let a := Real.log z / (2 * (k : ℝ)) have ha : 0 < a := by dsimp [Erdos416Proof.largestPrimeFactor_one, a]; positivity have hG (n : ℕ) (hn : n ∈ G) : 0 < n ∧ (n : ℝ) ≤ z ∧ (largestPrimeFactor n).Prime ∧ largestPrimeFactor n ∣ n ∧ a ≤ Real.log (largestPrimeFactor n) := by obtain ⟨hnF, hnlarge⟩ := Finset.mem_filter.mp hn have hnData := hF n hnF obtain ⟨hnpos, hp, hplog⟩ := largest_prime_log_lower_bound hz hk hnlarge hnData.2.2.1 exact ⟨hnpos, hnData.2.1, hp, largestPrimeFactor_dvd n, hplog⟩ have hdata (J : Finset ℕ) (hJ : J ⊆ G) : ∀ b ∈ cofactorSet J largestPrimeFactor, Squarefree b ∧ b.primeFactors ⊆ Nat.primesLE ⌊z⌋₊ ∧ b.primeFactors.card ≤ k := by apply squarefree_cofactor_data intro n hn have hnF := (Finset.mem_filter.mp (hJ hn)).1 exact ⟨(hF n hnF).1, (hF n hnF).2.1, (hF n hnF).2.2.1, largestPrimeFactor_dvd n⟩ have hA : (A.card : ℝ) ≤ (D * z / a) * W := by have hc := restricted_prime_cofactor_count_bound A largestPrimeFactor Q hD hzpos ha (fun n hn => by have hg := hG n (Finset.mem_filter.mp hn).1 exact ⟨hg.1, hg.2.1, hg.2.2.1, hg.2.2.2.1, hg.2.2.2.2, (Finset.mem_filter.mp hn).2⟩) hdensity exact hc.trans (mul_le_mul_of_nonneg_left (squarefree_natural_reciprocal_sum_bound (cofactorSet A largestPrimeFactor) (Nat.primesLE ⌊z⌋₊) k (fun p hp => Nat.prime_of_mem_primesLE hp) (hdata A (Finset.filter_subset _ _))) (by positivity)) have hBbad : ∀ b ∈ cofactorSet B largestPrimeFactor, ∃ q ∈ Q, q ∣ b := by intro b hb obtain ⟨n, hn, rfl⟩ := Finset.mem_image.mp hb obtain ⟨hnG, hnQ⟩ := Finset.mem_filter.mp hn have hnF := (Finset.mem_filter.mp hnG).1 obtain ⟨q, hq, hqn⟩ := (hF n hnF).2.2.2 refine ⟨q, hq, ?_⟩ have hnprod := Nat.mul_div_cancel' (largestPrimeFactor_dvd n) have hdiv : q ∣ largestPrimeFactor n * (n / largestPrimeFactor n) := by rw [hnprod] exact hqn rcases (hQ q hq).dvd_mul.mp hdiv with hqp | hqb · have heq := (Nat.prime_dvd_prime_iff_eq (hQ q hq) (hG n hnG).2.2.1).mp hqp exact (hnQ (heq ▸ hq)).elim · exact hqb have hB : (B.card : ℝ) ≤ (C * z / a) * ((∑ q ∈ Q, (1 : ℝ) / q) * W) := by have hc := hcount B largestPrimeFactor z a hzpos ha (fun n hn => hG n (Finset.mem_filter.mp hn).1) exact hc.trans (mul_le_mul_of_nonneg_left (squarefree_exceptional_reciprocal_sum_bound (cofactorSet B largestPrimeFactor) (Nat.primesLE ⌊z⌋₊) Q k (fun p hp => Nat.prime_of_mem_primesLE hp) (hdata B (Finset.filter_subset _ _)) hBbad) (by positivity)) have hE : (E.card : ℝ) ≤ Real.sqrt z := by have hsub : E ⊆ Finset.Icc 1 ⌊Real.sqrt z⌋₊ := by intro n hn obtain ⟨hnF, hnsmall⟩ := Finset.mem_filter.mp hn exact Finset.mem_Icc.mpr ⟨Nat.one_le_iff_ne_zero.mpr (hF n hnF).1.ne_zero, Nat.le_floor (le_of_not_gt hnsmall)⟩ calc _ ≤ ((Finset.Icc 1 ⌊Real.sqrt z⌋₊).card : ℝ) := by exact_mod_cast Finset.card_le_card hsub _ = (⌊Real.sqrt z⌋₊ : ℝ) := by simp[Erdos416Proof.largestPrimeFactor_one] _ ≤ _ := Nat.floor_le (Real.sqrt_nonneg _) have hcardG : (A.card : ℝ) + B.card = G.card := by exact_mod_cast Finset.card_filter_add_card_filter_not (s := G) (fun n => largestPrimeFactor n ∈ Q) have hcardF : (G.card : ℝ) + E.card = F.card := by exact_mod_cast Finset.card_filter_add_card_filter_not (s := F) (fun n : ℕ => Real.sqrt z < n) have htotal : (F.card : ℝ) ≤ Real.sqrt z + (D * z / a) * W + (C * z / a) * ((∑ q ∈ Q, (1 : ℝ) / q) * W) := by linarith apply htotal.trans_eq dsimp only [a, W] field_simp ring /- Original line 10522: Erdos416Proof.sum_indicator_eq_finiteCountBelow -/ theorem sum_indicator_eq_finiteCountBelow (Q : Finset ℕ) (h0 : 0 ∉ Q) (x : ℝ) : (∑ n ∈ Finset.Icc 0 ⌊x⌋₊, if n ∈ Q then (1 : ℝ) else 0) = finiteCountBelow Q x := by classical by_cases hx : 0 ≤ x · have hset : (Finset.Icc 0 ⌊x⌋₊).filter (fun n => n ∈ Q) = Q.filter (fun n : ℕ => (n : ℝ) ≤ x) := by ext n simp only [Finset.mem_filter, Finset.mem_Icc, Nat.zero_le, true_and, Nat.le_floor_iff hx, and_comm] simpa only [Finset.sum_boole, finiteCountBelow] using congrArg (fun s : Finset ℕ => (s.card : ℝ)) hset · have hfloor : ⌊x⌋₊ = 0 := Nat.floor_eq_zero.mpr (by linarith) have hset : Q.filter (fun n : ℕ => (n : ℝ) ≤ x) = ∅ := by apply Finset.filter_eq_empty_iff.mpr intro n hn hnx linarith [Nat.cast_nonneg (α := ℝ) n] simp only [hfloor, Finset.Icc_self, Finset.sum_singleton, if_neg h0, finiteCountBelow, hset, Finset.card_empty, Nat.cast_zero] open MeasureTheory in /- Original line 10542: Erdos416Proof.finite_reciprocal_abel -/ theorem finite_reciprocal_abel (Q : Finset ℕ) {z : ℝ} (hz : 2 ≤ z) (hQ : ∀ q ∈ Q, 2 ≤ q ∧ (q : ℝ) ≤ z) : IntervalIntegrable (fun t : ℝ => finiteCountBelow Q t / t ^ 2) volume 2 z ∧ (∑ q ∈ Q, (1 : ℝ) / q) = finiteCountBelow Q z / z + ∫ t : ℝ in (2 : ℝ)..z, finiteCountBelow Q t / t ^ 2 := by classical have h0 : 0 ∉ Q := by intro h; have := (hQ 0 h).1; omega have h1 : 1 ∉ Q := by intro h; have := (hQ 1 h).1; omega let c : ℕ → ℝ := fun n => if n ∈ Q then 1 else 0 have hcont : ContinuousOn (fun t : ℝ => (t ^ 2)⁻¹) (Set.Icc 2 z) := by apply ContinuousOn.inv₀ (continuousOn_id.pow 2) intro t ht change (t ^ 2) ≠ 0 exact pow_ne_zero 2 (by linarith [ht.1]) have hcountint : IntegrableOn (fun t : ℝ => finiteCountBelow Q t / t ^ 2) (Set.Icc 2 z) := by have hi := integrableOn_mul_sum_Icc c (m := 0) (by norm_num : (0 : ℝ) ≤ 2) hcont.integrableOn_Icc simpa only [c, sum_indicator_eq_finiteCountBelow Q h0, div_eq_mul_inv, mul_comm] using hi refine ⟨(intervalIntegrable_iff_integrableOn_Icc_of_le hz).mpr hcountint, ?_⟩ have hdiff : ∀ t ∈ Set.Icc (2 : ℝ) z, DifferentiableAt ℝ (fun t : ℝ => t⁻¹) t := by intro t ht exact (hasDerivAt_inv (by linarith [ht.1] : t ≠ 0)).differentiableAt have hderivint : IntegrableOn (deriv (fun t : ℝ => t⁻¹)) (Set.Icc 2 z) := by simpa only [deriv_inv', Pi.neg_apply] using! hcont.neg.integrableOn_Icc have h := sum_mul_eq_sub_integral_mul₁ c (by simp [c, h0]) (by simp [c, h1]) z hdiff hderivint have hsub : Q ⊆ Finset.Icc 0 ⌊z⌋₊ := by intro q hq exact Finset.mem_Icc.mpr ⟨Nat.zero_le _, Nat.le_floor (hQ q hq).2⟩ have hsum : (∑ n ∈ Finset.Icc 0 ⌊z⌋₊, (n : ℝ)⁻¹ * c n) = ∑ q ∈ Q, (1 : ℝ) / q := by simp only [c, mul_ite, mul_one, mul_zero, ← Finset.sum_filter] rw [Finset.filter_mem_eq_inter, Finset.inter_eq_right.mpr hsub] simp only [one_div] rw [hsum] at h simp_rw [c, sum_indicator_eq_finiteCountBelow Q h0, deriv_inv', neg_mul] at h rw [MeasureTheory.integral_neg, sub_neg_eq_add, ← intervalIntegral.integral_of_le hz] at h simpa only [div_eq_mul_inv, mul_comm] using h open MeasureTheory in /- Original line 10580: Erdos416Proof.finite_reciprocal_bound_of_density -/ theorem finite_reciprocal_bound_of_density (Q : Finset ℕ) {z D : ℝ} (hz : 2 ≤ z) (hD : 0 ≤ D) (hQ : ∀ q ∈ Q, 2 ≤ q ∧ (q : ℝ) ≤ z) (hdensity : ∀ x : ℝ, 2 ≤ x → x ≤ z → finiteCountBelow Q x ≤ D * x / Real.log x) : (∑ q ∈ Q, (1 : ℝ) / q) ≤ D * (1 / Real.log 2 + Real.log (Real.log z) - Real.log (Real.log 2)) := by obtain ⟨hI, hAbel⟩ := finite_reciprocal_abel Q hz hQ have hzpos : 0 < z := by linarith have hlog2 : 0 < Real.log 2 := Real.log_pos (by norm_num) have hlogz : 0 < Real.log z := Real.log_pos (by linarith) have hcont : ContinuousOn (fun t : ℝ => D * (t⁻¹ / Real.log t)) (Set.Icc 2 z) := by have hnonzero : ∀ t ∈ Set.Icc (2 : ℝ) z, t ≠ 0 := by intro t ht linarith [ht.1] have hlogne : ∀ t ∈ Set.Icc (2 : ℝ) z, Real.log t ≠ 0 := by intro t ht exact ne_of_gt (Real.log_pos (by linarith [ht.1])) exact continuousOn_const.mul ((continuousOn_id.inv₀ hnonzero).div (continuousOn_id.log hnonzero) hlogne) have hJ : IntervalIntegrable (fun t : ℝ => D * (t⁻¹ / Real.log t)) volume 2 z := (intervalIntegrable_iff_integrableOn_Icc_of_le hz).mpr hcont.integrableOn_Icc have hIntegral := intervalIntegral.integral_mono_on hz hI hJ (fun t ht => by have htpos : 0 < t := by linarith [ht.1] calc finiteCountBelow Q t / t ^ 2 ≤ (D * t / Real.log t) / t ^ 2 := div_le_div_of_nonneg_right (hdensity t ht.1 ht.2) (sq_nonneg _) _ = D * (t⁻¹ / Real.log t) := by field_simp) rw [intervalIntegral.integral_const_mul, integral_inv_div_log (by norm_num : (1 : ℝ) < 2) (by linarith : 1 < z)] at hIntegral have hend : finiteCountBelow Q z / z ≤ D / Real.log 2 := by calc _ ≤ (D * z / Real.log z) / z := div_le_div_of_nonneg_right (hdensity z hz le_rfl) hzpos.le _ = D / Real.log z := by field_simp _ ≤ _ := div_le_div_of_nonneg_left hD hlog2 (Real.log_le_log (by norm_num) hz) rw [hAbel] calc _ ≤ D / Real.log 2 + D * (Real.log (Real.log z) - Real.log (Real.log 2)) := add_le_add hend hIntegral _ = _ := by ring /- Original line 10619: Erdos416Proof.exists_finite_reciprocal_density_constant -/ theorem exists_finite_reciprocal_density_constant : ∃ K : ℝ, 0 < K ∧ ∀ (Q : Finset ℕ) (z D : ℝ), Real.exp 1 ≤ z → 0 ≤ D → (∀ q ∈ Q, 2 ≤ q ∧ (q : ℝ) ≤ z) → (∀ x : ℝ, 2 ≤ x → x ≤ z → finiteCountBelow Q x ≤ D * x / Real.log x) → (∑ q ∈ Q, (1 : ℝ) / q) ≤ K * D * (1 + Real.log (Real.log z)) := by let K : ℝ := 1 / Real.log 2 + |Real.log (Real.log 2)| + 1 have hlog2 : 0 < Real.log 2 := Real.log_pos (by norm_num) have hK1 : 1 ≤ K := by have hr : 0 ≤ 1 / Real.log 2 := by positivity dsimp [K] linarith [abs_nonneg (Real.log (Real.log 2))] refine ⟨K, by linarith, ?_⟩ intro Q z D hz hD hQ hdensity have he2 : (2 : ℝ) ≤ Real.exp 1 := by linarith [Real.add_one_le_exp (1 : ℝ)] have hLL : 0 ≤ Real.log (Real.log z) := logLog_nonneg hz apply (finite_reciprocal_bound_of_density Q (he2.trans hz) hD hQ hdensity).trans have hpoly : 1 / Real.log 2 + Real.log (Real.log z) - Real.log (Real.log 2) ≤ K * (1 + Real.log (Real.log z)) := by have habs := neg_le_abs (Real.log (Real.log 2)) have hmul := mul_le_mul_of_nonneg_right hK1 hLL dsimp [K] at * nlinarith nlinarith [mul_le_mul_of_nonneg_left hpoly hD] /-- Combining partial summation with the largest-prime split gives a single bound in terms of the exceptional-prime counting density. -/ /- Original line 10645: Erdos416Proof.squarefree_exceptional_count_bound_of_density -/ theorem squarefree_exceptional_count_bound_of_density : ∃ C : ℝ, 0 < C ∧ ∀ (F Q : Finset ℕ) (z D : ℝ) (k : ℕ), 4 ≤ z → Real.exp 1 ≤ z → 0 ≤ D → 0 < k → (∀ q ∈ Q, q.Prime ∧ (q : ℝ) ≤ z) → (∀ n ∈ F, Squarefree n ∧ (n : ℝ) ≤ z ∧ ArithmeticFunction.cardFactors n ≤ k ∧ ∃ q ∈ Q, q ∣ n) → (∀ x : ℝ, 2 ≤ x → x ≤ z → finiteCountBelow Q x ≤ D * x / Real.log x) → (F.card : ℝ) ≤ Real.sqrt z + C * k * z / Real.log z * (Real.exp 1 * (1 + ∑ p ∈ Nat.primesLE ⌊z⌋₊, (1 : ℝ) / ((p : ℝ) - 1)) ^ k) * D * (1 + Real.log (Real.log z)) := by obtain ⟨C, hC, hcount⟩ := squarefree_exceptional_count_bound obtain ⟨K, hK, hrecip⟩ := exists_finite_reciprocal_density_constant refine ⟨2 * (1 + C * K), by positivity, ?_⟩ intro F Q z D k hz hez hD hk hQ hF hdensity have hLL : 0 ≤ Real.log (Real.log z) := logLog_nonneg hez have hr := hrecip Q z D hez hD (fun q hq => ⟨(hQ q hq).1.two_le, (hQ q hq).2⟩) hdensity have hfactor : D + C * (∑ q ∈ Q, (1 : ℝ) / q) ≤ (1 + C * K) * D * (1 + Real.log (Real.log z)) := by have hmul := mul_le_mul_of_nonneg_left hr hC.le nlinarith [mul_nonneg hD hLL] apply (hcount F Q z D k hz hD hk (fun q hq => (hQ q hq).1) hF hdensity).trans have hlogz : 0 < Real.log z := Real.log_pos (by linarith) have hW : 0 ≤ Real.exp 1 * (1 + ∑ p ∈ Nat.primesLE ⌊z⌋₊, (1 : ℝ) / ((p : ℝ) - 1)) ^ k := by have hsum : 0 ≤ ∑ p ∈ Nat.primesLE ⌊z⌋₊, (1 : ℝ) / ((p : ℝ) - 1) := by apply Finset.sum_nonneg intro p hp have hp1 : (1 : ℝ) < p := by exact_mod_cast (Nat.prime_of_mem_primesLE hp).one_lt positivity exact mul_nonneg (Real.exp_pos _).le (pow_nonneg (add_nonneg zero_le_one hsum) k) calc _ ≤ Real.sqrt z + (2 * k * z / Real.log z) * (Real.exp 1 * (1 + ∑ p ∈ Nat.primesLE ⌊z⌋₊, (1 : ℝ) / ((p : ℝ) - 1)) ^ k) * ((1 + C * K) * D * (1 + Real.log (Real.log z))) := by gcongr _ = _ := by ring /-- The full truncated Euler-product envelope, uniformly for k = O(log T). -/ /- Original line 10683: Erdos416Proof.truncated_prime_product_eventually -/ theorem truncated_prime_product_eventually (A : ℝ) : ∀ᶠ T : ℝ in atTop, ∀ x : ℝ, Real.exp (Real.exp 1) ≤ x → Real.log (Real.log x) ≤ 2 * T → ∀ k : ℕ, (k : ℝ) ≤ A * Real.log T → Real.exp 1 * (1 + ∑ p ∈ Nat.primesLE ⌊x⌋₊, (1 : ℝ) / ((p : ℝ) - 1)) ^ k ≤ Real.exp ((2 * A + 1) * (Real.log T) ^ 2) := by obtain ⟨C, hC, hbound⟩ := shifted_prime_reciprocal_bound filter_upwards [eventually_ge_atTop (Real.exp 1), eventually_ge_atTop (1 + 2 * C)] with T hT hTC have hT1 : 1 ≤ T := by linarith [Real.add_one_le_exp 1] have hT0 : 0 < T := by linarith have hlog : 1 ≤ Real.log T := by simpa only [Real.log_exp] using Real.log_le_log (Real.exp_pos 1) hT intro x hx hLL k hk have hsum0 : 0 ≤ ∑ p ∈ Nat.primesLE ⌊x⌋₊, (1 : ℝ) / ((p : ℝ) - 1) := by apply Finset.sum_nonneg intro p hp have hp1 : (1 : ℝ) < p := by exact_mod_cast (Nat.prime_of_mem_primesLE hp).one_lt positivity have hb : 1 + ∑ p ∈ Nat.primesLE ⌊x⌋₊, (1 : ℝ) / ((p : ℝ) - 1) ≤ T ^ 2 := by have h₁ := mul_le_mul_of_nonneg_left hLL hC.le have h₂ := mul_le_mul_of_nonneg_right hTC hT0.le have h₃ := hbound x hx nlinarith calc _ ≤ Real.exp 1 * (T ^ 2) ^ k := by gcongr _ ≤ Real.exp ((2 * A + 1) * (Real.log T) ^ 2) := by apply (Real.log_le_log_iff (by positivity) (Real.exp_pos _)).mp rw [Real.log_mul (ne_of_gt (Real.exp_pos 1)) (by positivity), Real.log_exp, Real.log_pow, Real.log_pow, Real.log_exp] have hmul := mul_le_mul_of_nonneg_right hk (show 0 ≤ Real.log T by linarith) norm_num nlinarith [sq_nonneg (Real.log T - 1)] /-- The normality saving absorbs every fixed polynomial in T, including the exp(O((log T)^2)) combinatorial factors in the manuscript. -/ /- Original line 10718: Erdos416Proof.normality_saving_dominates -/ theorem normality_saving_dominates (B : ℝ) (n : ℕ) : Tendsto (fun T : ℝ => T ^ n * Real.exp (B * Real.log T ^ 2 - Real.log T ^ 10 / 6)) atTop (nhds 0) := by have h₂ : (fun u : ℝ => u ^ 2) =o[atTop] (fun u => u ^ 10) := isLittleO_pow_pow_atTop_of_lt (by norm_num) have h₁ : (fun u : ℝ => u ^ 1) =o[atTop] (fun u => u ^ 10) := isLittleO_pow_pow_atTop_of_lt (by norm_num) have hpoly : (fun u : ℝ => B * u ^ 2 + (n : ℝ) * u) =o[atTop] (fun u => u ^ 10) := by simpa only [pow_one] using (h₂.const_mul_left B).add (h₁.const_mul_left (n : ℝ)) have hpow : Tendsto (fun T : ℝ => Real.log T ^ 10) atTop atTop := (tendsto_pow_atTop (by norm_num : (10 : ℕ) ≠ 0)).comp Real.tendsto_log_atTop have hneg : Tendsto (fun T : ℝ => -(Real.log T ^ 10) / 12) atTop atBot := (tendsto_neg_atTop_atBot.comp hpow).atBot_div_const (by norm_num) apply squeeze_zero' ?_ ?_ (Real.tendsto_exp_atBot.comp hneg) · filter_upwards [eventually_ge_atTop (0 : ℝ)] with T hT positivity · filter_upwards [Real.tendsto_log_atTop.eventually (hpoly.def (by norm_num : (0 : ℝ) < 1 / 12)), eventually_gt_atTop (0 : ℝ)] with T hsmall hT have hpow0 : 0 ≤ Real.log T ^ 10 := by positivity simp only [Real.norm_eq_abs, abs_of_nonneg hpow0] at hsmall have hle := (le_abs_self _).trans hsmall calc _ = Real.exp ((n : ℝ) * Real.log T + B * Real.log T ^ 2 - Real.log T ^ 10 / 6) := by rw [show (n : ℝ) * Real.log T + B * Real.log T ^ 2 - Real.log T ^ 10 / 6 = (n : ℝ) * Real.log T + (B * Real.log T ^ 2 - Real.log T ^ 10 / 6) by ring, Real.exp_add, Real.exp_nat_mul, Real.exp_log hT] _ ≤ Real.exp (-(Real.log T ^ 10) / 12) := Real.exp_le_exp.mpr (by linarith) /- Original line 10746: Erdos416Proof.nonNormalPrimes -/ noncomputable def nonNormalPrimes (S z : ℝ) : Finset ℕ := (Nat.primesLE ⌊z⌋₊).filter (fun p => ¬ SNormal S p) /- Original line 10749: Erdos416Proof.mem_nonNormalPrimes -/ theorem mem_nonNormalPrimes {S z : ℝ} {p : ℕ} (hz : 0 ≤ z) : p ∈ nonNormalPrimes S z ↔ p.Prime ∧ (p : ℝ) ≤ z ∧ ¬ SNormal S p := by classical simp only [nonNormalPrimes, Finset.mem_filter, Nat.mem_primesLE, Nat.le_floor_iff hz] tauto /- Original line 10755: Erdos416Proof.finiteCountBelow_nonNormalPrimes -/ theorem finiteCountBelow_nonNormalPrimes {S z x : ℝ} (hx : 0 ≤ x) (hxz : x ≤ z) : finiteCountBelow (nonNormalPrimes S z) x = ((nonNormalPrimes S x).card : ℝ) := by classical have hz : 0 ≤ z := hx.trans hxz have hset : (nonNormalPrimes S z).filter (fun p : ℕ => (p : ℝ) ≤ x) = nonNormalPrimes S x := by ext p simp only [Finset.mem_filter, mem_nonNormalPrimes hz, mem_nonNormalPrimes hx] constructor · rintro ⟨⟨hp, _, hbad⟩, hpx⟩ exact ⟨hp, hpx, hbad⟩ · rintro ⟨hp, hpx, hbad⟩ exact ⟨⟨hp, hpx.trans hxz, hbad⟩, hpx⟩ simp only [finiteCountBelow, hset] /- Original line 10770: Erdos416Proof.two_SNormal -/ theorem two_SNormal {S : ℝ} (hS : Real.exp 1 ≤ S) : SNormal S 2 := by apply SNormal_of_small_prime Nat.prime_two (Real.exp_one_gt_two.le.trans hS) have hLL : 0 ≤ Real.log (Real.log S) := logLog_nonneg hS norm_num linarith /- Original line 10776: Erdos416Proof.nonNormalPrimes_eq_empty_of_lt_three -/ theorem nonNormalPrimes_eq_empty_of_lt_three {S x : ℝ} (hS : Real.exp 1 ≤ S) (hx0 : 0 ≤ x) (hx3 : x < 3) : nonNormalPrimes S x = ∅ := by apply Finset.eq_empty_iff_forall_notMem.mpr intro p hp obtain ⟨hpprime, hpx, hpbad⟩ := (mem_nonNormalPrimes hx0).mp hp have hp3 : p < 3 := by exact_mod_cast hpx.trans_lt hx3 have hp2 : p = 2 := by have := hpprime.two_le; omega subst p exact hpbad (two_SNormal hS) /-- Freezing the slowly varying factor at the upper endpoint turns the published normal-prime estimate into the density hypothesis of the finite counting theorem. The estimate in the hypothesis remains explicit. -/ /- Original line 10789: Erdos416Proof.nonNormalPrimes_density_frozen -/ theorem nonNormalPrimes_density_frozen {S z C : ℝ} (hS : Real.exp 1 ≤ S) (hz : 3 ≤ z) (hC : 0 ≤ C) (hdensity : ∀ x : ℝ, 3 ≤ x → x ≤ z → ((nonNormalPrimes S x).card : ℝ) ≤ C * x / Real.log x * (1 + Real.log (Real.log x)) ^ 5 * Real.exp (-Real.log (Real.log S) / 6)) : ∀ x : ℝ, 2 ≤ x → x ≤ z → finiteCountBelow (nonNormalPrimes S z) x ≤ (C * (1 + Real.log (Real.log z)) ^ 5 * Real.exp (-Real.log (Real.log S) / 6)) * x / Real.log x := by intro x hx hxz have hx0 : 0 < x := by linarith have hlogx : 0 < Real.log x := Real.log_pos (by linarith) have hLLz : 0 ≤ Real.log (Real.log z) := logLog_nonneg (Real.exp_one_lt_three.le.trans hz) rw [finiteCountBelow_nonNormalPrimes hx0.le hxz] by_cases hx3 : 3 ≤ x · have hLLx : 0 ≤ Real.log (Real.log x) := logLog_nonneg (Real.exp_one_lt_three.le.trans hx3) have hLL : Real.log (Real.log x) ≤ Real.log (Real.log z) := logLog_mono (by linarith) hxz calc _ ≤ C * x / Real.log x * (1 + Real.log (Real.log x)) ^ 5 * Real.exp (-Real.log (Real.log S) / 6) := hdensity x hx3 hxz _ ≤ C * x / Real.log x * (1 + Real.log (Real.log z)) ^ 5 * Real.exp (-Real.log (Real.log S) / 6) := by gcongr _ = _ := by ring · rw [nonNormalPrimes_eq_empty_of_lt_three hS hx0.le (lt_of_not_ge hx3), Finset.card_empty, Nat.cast_zero] positivity /- Original line 10816: Erdos416Proof.squarefreeNonNormalIntegers -/ noncomputable def squarefreeNonNormalIntegers (S z : ℝ) (k : ℕ) : Finset ℕ := (Finset.Icc 1 ⌊z⌋₊).filter (fun n => Squarefree n ∧ ArithmeticFunction.cardFactors n ≤ k ∧ ∃ q : ℕ, q.Prime ∧ q ∣ n ∧ ¬ SNormal S q) /- Original line 10820: Erdos416Proof.squarefreeNonNormalIntegers_data -/ theorem squarefreeNonNormalIntegers_data {S z : ℝ} {k : ℕ} (hz : 0 ≤ z) : ∀ n ∈ squarefreeNonNormalIntegers S z k, Squarefree n ∧ (n : ℝ) ≤ z ∧ ArithmeticFunction.cardFactors n ≤ k ∧ ∃ q ∈ nonNormalPrimes S z, q ∣ n := by intro n hn obtain ⟨hnrange, hnSF, hnk, q, hq, hqn, hbad⟩ := Finset.mem_filter.mp hn obtain ⟨hnpos, hnz⟩ := Finset.mem_Icc.mp hnrange have hnzR : (n : ℝ) ≤ z := (Nat.le_floor_iff hz).mp hnz refine ⟨hnSF, hnzR, hnk, q, ?_, hqn⟩ apply (mem_nonNormalPrimes hz).mpr exact ⟨hq, (by exact_mod_cast Nat.le_of_dvd hnpos hqn : (q : ℝ) ≤ n).trans hnzR, hbad⟩ /-- The published normal-prime estimate, expressed with the actual finite prime set. This definition is a proposition, not a postulated proof of it. -/ /- Original line 10833: Erdos416Proof.NormalPrimeDensityEstimate -/ def NormalPrimeDensityEstimate (C : ℝ) : Prop := ∀ S x : ℝ, Real.exp 1 ≤ S → 3 ≤ x → ((nonNormalPrimes S x).card : ℝ) ≤ C * x / Real.log x * (1 + Real.log (Real.log x)) ^ 5 * Real.exp (-Real.log (Real.log S) / 6) /-- Uniform counting of all squarefree exceptional integers with at most A log_3(y) + 1 factors. The only number-theoretic hypothesis left in this replacement of the Hardy--Ramanujan argument is the stated prime density. -/ /- Original line 10841: Erdos416Proof.squarefree_non_normal_bound_of_density -/ theorem squarefree_non_normal_bound_of_density {A c C : ℝ} (hA : 0 < A) (hc : 0 < c) (hC : 0 < C) (hdensity : NormalPrimeDensityEstimate C) : ∃ K : ℝ, 0 < K ∧ ∀ᶠ y : ℝ in atTop, ∀ k : ℕ, 0 < k → (k : ℝ) ≤ A * Real.log (Real.log (Real.log y)) + 1 → ((squarefreeNonNormalIntegers (normalityScale (Real.log (Real.log y))) (c * y * Real.log (Real.log y)) k).card : ℝ) ≤ Real.sqrt (c * y * Real.log (Real.log y)) + K * y / Real.log y * Real.log (Real.log y) ^ 8 * Real.exp ((2 * A + 3) * Real.log (Real.log (Real.log y)) ^ 2 - Real.log (Real.log (Real.log y)) ^ 10 / 6) := by obtain ⟨B, hB, hcount⟩ := squarefree_exceptional_count_bound_of_density let K := B * (A + 1) * c * C * 3 ^ 6 refine ⟨K, by dsimp [K]; positivity, ?_⟩ have hT := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [hT.eventually (truncated_prime_product_eventually (A + 1)), hT.eventually (inverse_totient_scale_envelope c), hT.eventually_ge_atTop (Real.exp 1), hT.eventually_ge_atTop (1 / c), eventually_ge_atTop (Real.exp (Real.exp 1)), eventually_ge_atTop (4 : ℝ)] with y hproduct henv hTlarge hcT hylarge hy4 dsimp only [Function.comp_apply] at hproduct henv hTlarge hcT let T := Real.log (Real.log y) let z := c * y * T let S := normalityScale T have hT1 : 1 ≤ T := by dsimp [T]; linarith [Real.add_one_le_exp (1 : ℝ)] have hTpos : 0 < T := by linarith have hypos : 0 < y := by linarith have hlogy : 0 < Real.log y := Real.log_pos (by linarith) have hU1 : 1 ≤ Real.log T := by simpa only [Real.log_exp] using Real.log_le_log (Real.exp_pos 1) hTlarge have hcT1 : 1 ≤ c * T := by have hh := (div_le_iff₀ hc).mp hcT nlinarith have hyz : y ≤ z := by dsimp [z]; nlinarith have hz4 : 4 ≤ z := hy4.trans hyz have hz3 : 3 ≤ z := by linarith have hzpos : 0 < z := hypos.trans_le hyz have hzlarge : Real.exp (Real.exp 1) ≤ z := hylarge.trans hyz have hze : Real.exp 1 ≤ z := Real.exp_one_lt_three.le.trans hz3 have hlogz : 0 < Real.log z := Real.log_pos (by linarith) have hExpT : Real.exp T = Real.log y := Real.exp_log hlogy have hExpExpT : Real.exp (Real.exp T) = y := by rw [hExpT, Real.exp_log hypos] have hzEnv : z ≤ Real.exp (Real.exp (T + 1)) := by change c * Real.exp (Real.exp T) * T ≤ Real.exp (Real.exp (T + 1)) at henv simpa only [hExpExpT] using henv have hLLz : Real.log (Real.log z) ≤ 2 * T := by have hh := logLog_mono (by linarith : 1 < z) hzEnv simp only [logLog, Real.log_exp] at hh linarith have hLLz0 : 0 ≤ Real.log (Real.log z) := logLog_nonneg hze have hLL3 : 1 + Real.log (Real.log z) ≤ 3 * T := by linarith have hUL : Real.log T ≤ T := Real.log_le_self hTpos.le have hlogyz : Real.log y ≤ Real.log z := Real.log_le_log hypos hyz have hzratio : z / Real.log z ≤ c * y * T / Real.log y := div_le_div_of_nonneg_left hzpos.le hlogy hlogyz let D := C * (1 + Real.log (Real.log z)) ^ 5 * Real.exp (-Real.log (Real.log S) / 6) have hD : 0 ≤ D := by dsimp [D]; positivity have hDsmall : D ≤ C * (3 * T) ^ 5 * Real.exp (-Real.log T ^ 10 / 6) := by dsimp only [D, S] rw [logLog_normalityScale] gcongr have hden := nonNormalPrimes_density_frozen (normalityScale_ge_exp_one T) hz3 hC.le (fun x hx _ => hdensity S x (normalityScale_ge_exp_one T) hx) intro k hk hksize have hkU : (k : ℝ) ≤ (A + 1) * Real.log T := by change (k : ℝ) ≤ A * Real.log T + 1 at hksize nlinarith only [hksize, hU1] have hkT : (k : ℝ) ≤ (A + 1) * T := hkU.trans (by gcongr) have hW := hproduct z hzlarge hLLz k hkU have hW0 : 0 ≤ Real.exp 1 * (1 + ∑ p ∈ Nat.primesLE ⌊z⌋₊, (1 : ℝ) / ((p : ℝ) - 1)) ^ k := by have hs : 0 ≤ ∑ p ∈ Nat.primesLE ⌊z⌋₊, (1 : ℝ) / ((p : ℝ) - 1) := by apply Finset.sum_nonneg intro p hp have hp1 : (1 : ℝ) < p := by exact_mod_cast (Nat.prime_of_mem_primesLE hp).one_lt positivity exact mul_nonneg (Real.exp_pos _).le (pow_nonneg (by linarith) k) have hmain := hcount (squarefreeNonNormalIntegers S z k) (nonNormalPrimes S z) z D k hz4 hze hD hk (fun q hq => ⟨((mem_nonNormalPrimes hzpos.le).mp hq).1, ((mem_nonNormalPrimes hzpos.le).mp hq).2.1⟩) (squarefreeNonNormalIntegers_data hzpos.le) hden change ((squarefreeNonNormalIntegers S z k).card : ℝ) ≤ Real.sqrt z + K * y / Real.log y * T ^ 8 * Real.exp ((2 * A + 3) * Real.log T ^ 2 - Real.log T ^ 10 / 6) calc _ ≤ Real.sqrt z + (B * k * (z / Real.log z)) * (Real.exp 1 * (1 + ∑ p ∈ Nat.primesLE ⌊z⌋₊, (1 : ℝ) / ((p : ℝ) - 1)) ^ k) * D * (1 + Real.log (Real.log z)) := by convert hmain using 1; ring _ ≤ Real.sqrt z + (B * ((A + 1) * T) * (c * y * T / Real.log y)) * Real.exp ((2 * (A + 1) + 1) * Real.log T ^ 2) * (C * (3 * T) ^ 5 * Real.exp (-Real.log T ^ 10 / 6)) * (3 * T) := by gcongr _ = _ := by dsimp only [K] simp only [Real.exp_sub, neg_div, Real.exp_neg] have he : 2 * (A + 1) + 1 = 2 * A + 3 := by ring rw [he] ring /-- The small-integer term introduced by the largest-prime split is negligible throughout the inverse-totient size range. -/ /- Original line 10941: Erdos416Proof.sqrt_inverse_totient_scale_negligible -/ theorem sqrt_inverse_totient_scale_negligible {c : ℝ} (hc : 0 < c) : (fun y : ℝ => Real.sqrt (c * y * Real.log (Real.log y))) =o[atTop] (fun y => y / (Real.log y * Real.log (Real.log y) ^ 2)) := by let g : ℝ → ℝ := fun y => y / (Real.log y * Real.log (Real.log y) ^ 2) have hT := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop have hpos : ∀ᶠ y : ℝ in atTop, 0 < y ∧ 0 < Real.log y ∧ 0 < Real.log (Real.log y) := by filter_upwards [eventually_gt_atTop (1 : ℝ), hT.eventually_gt_atTop 0] with y hy hTpos exact ⟨by linarith, Real.log_pos hy, hTpos⟩ have hlim : Tendsto (fun y : ℝ => c * (Real.log y ^ 7 / y)) atTop (nhds 0) := by have h := ((log_pow_mul_rpow_littleO 7 (show (0 : ℝ) < 1 by norm_num)).tendsto_div_nhds_zero).const_mul c simpa only [Real.rpow_zero, Real.rpow_one, mul_one, mul_zero] using h have hsq : (fun y : ℝ => c * y * Real.log (Real.log y)) =o[atTop] (fun y => g y ^ 2) := by apply (isLittleO_iff_tendsto' ?_).mpr · apply squeeze_zero' ?_ ?_ hlim · filter_upwards [hpos] with y hy exact div_nonneg (by rcases hy with ⟨hy, hlog, hTpos⟩; positivity) (sq_nonneg _) · filter_upwards [hpos] with y hy rcases hy with ⟨hy, hlog, hTpos⟩ have hTle : Real.log (Real.log y) ≤ Real.log y := Real.log_le_self hlog.le calc _ = c * (Real.log y ^ 2 * Real.log (Real.log y) ^ 5) / y := by dsimp only [g] field_simp [hy.ne', hlog.ne', hTpos.ne'] _ ≤ c * (Real.log y ^ 2 * Real.log y ^ 5) / y := by gcongr _ = _ := by ring · filter_upwards [hpos] with y hy hzero rcases hy with ⟨hy, hlog, hTpos⟩ have hg : 0 < g y ^ 2 := by dsimp [g]; positivity exact (hg.ne' hzero).elim have hroot := hsq.sqrt (Eventually.of_forall fun y => sq_nonneg (g y)) refine hroot.congr' (Eventually.of_forall fun _ => rfl) ?_ filter_upwards [hpos] with y hy rcases hy with ⟨hy, hlog, hTpos⟩ exact Real.sqrt_sq (by dsimp [g]; positivity : 0 ≤ g y) /- Original line 10976: Erdos416Proof.squarefreeNonNormalCount -/ noncomputable def squarefreeNonNormalCount (A c y : ℝ) : ℝ := (squarefreeNonNormalIntegers (normalityScale (Real.log (Real.log y))) (c * y * Real.log (Real.log y)) (⌊A * Real.log (Real.log (Real.log y))⌋₊ + 1)).card /-- A complete reduction of exceptional-integer pruning to Ford's normal-prime density estimate. The latter is an explicit hypothesis, and has not been admitted or assumed as an axiom. -/ /- Original line 10983: Erdos416Proof.normal_prime_pruning_of_density -/ theorem normal_prime_pruning_of_density {A c C : ℝ} (hA : 0 < A) (hc : 0 < c) (hC : 0 < C) (hdensity : NormalPrimeDensityEstimate C) : squarefreeNonNormalCount A c =o[atTop] (fun y : ℝ => y / (Real.log y * Real.log (Real.log y) ^ 2)) := by obtain ⟨K, hK, hbound⟩ := squarefree_non_normal_bound_of_density hA hc hC hdensity let g : ℝ → ℝ := fun y => y / (Real.log y * Real.log (Real.log y) ^ 2) let E : ℝ → ℝ := fun y => K * y / Real.log y * Real.log (Real.log y) ^ 8 * Real.exp ((2 * A + 3) * Real.log (Real.log (Real.log y)) ^ 2 - Real.log (Real.log (Real.log y)) ^ 10 / 6) have hT := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop have hpos : ∀ᶠ y : ℝ in atTop, 0 < y ∧ 0 < Real.log y ∧ 0 < Real.log (Real.log y) := by filter_upwards [eventually_gt_atTop (1 : ℝ), hT.eventually_gt_atTop 0] with y hy hTpos exact ⟨by linarith, Real.log_pos hy, hTpos⟩ have hE : E =o[atTop] g := by apply (isLittleO_iff_tendsto' ?_).mpr · have hlim := ((normality_saving_dominates (2 * A + 3) 10).comp hT).const_mul K simp only [mul_zero] at hlim apply hlim.congr' filter_upwards [hpos] with y hy rcases hy with ⟨hy, hlog, hTpos⟩ dsimp only [E, g, Function.comp_apply] field_simp [hy.ne', hlog.ne', hTpos.ne'] · filter_upwards [hpos] with y hy hzero rcases hy with ⟨hy, hlog, hTpos⟩ have hg : 0 < g y := by dsimp [g]; positivity exact (hg.ne' hzero).elim have hdom : squarefreeNonNormalCount A c =O[atTop] (fun y => Real.sqrt (c * y * Real.log (Real.log y)) + E y) := by apply IsBigO.of_norm_eventuallyLE filter_upwards [hbound, hpos, (Real.tendsto_log_atTop.comp hT).eventually_ge_atTop 0] with y hbound hy hU rcases hy with ⟨hy, hlog, hTpos⟩ have hAU : 0 ≤ A * Real.log (Real.log (Real.log y)) := mul_nonneg hA.le hU have hk : (⌊A * Real.log (Real.log (Real.log y))⌋₊ + 1 : ℕ) ≤ A * Real.log (Real.log (Real.log y)) + (1 : ℝ) := by push_cast linarith [Nat.floor_le hAU] have hh := hbound _ (Nat.succ_pos _) hk have hE0 : 0 ≤ E y := by dsimp [E]; positivity have hf0 : 0 ≤ squarefreeNonNormalCount A c y := Nat.cast_nonneg _ change squarefreeNonNormalCount A c y ≤ Real.sqrt (c * y * Real.log (Real.log y)) + E y at hh simpa only [Real.norm_eq_abs, abs_of_nonneg hf0, abs_of_nonneg (add_nonneg (Real.sqrt_nonneg _) hE0)] using hh exact hdom.trans_isLittleO ((sqrt_inverse_totient_scale_negligible hc).add hE) /- Original line 11028: Erdos416Proof.normalPrimeFailures -/ noncomputable def normalPrimeFailures (F : Finset ℕ) (S : ℝ) : Finset ℕ := F.filter (fun n => ∃ q : ℕ, q.Prime ∧ q ∣ n ∧ ¬ SNormal S q) /-- Apply the pruning estimate to an arbitrary varying family of squarefree preimages. Their size bound follows from the proved inverse-totient theorem. -/ /- Original line 11033: Erdos416Proof.normal_prime_pruning_for_squarefree_preimages_of_density -/ theorem normal_prime_pruning_for_squarefree_preimages_of_density {A C : ℝ} (hA : 0 < A) (hC : 0 < C) (hdensity : NormalPrimeDensityEstimate C) (F : ℝ → Finset ℕ) (hF : ∀ᶠ y : ℝ in atTop, ∀ n ∈ F y, Squarefree n ∧ (n.totient : ℝ) ≤ y ∧ (ArithmeticFunction.cardFactors n : ℝ) ≤ A * Real.log (Real.log (Real.log y)) + 1) : (fun y : ℝ => ((normalPrimeFailures (F y) (normalityScale (Real.log (Real.log y)))).card : ℝ)) =o[atTop] (fun y => y / (Real.log y * Real.log (Real.log y) ^ 2)) := by obtain ⟨c, hc, hsize⟩ := inverse_totient_bound_eventually apply IsBigO.trans_isLittleO (g := squarefreeNonNormalCount A c) ?_ (normal_prime_pruning_of_density hA hc hC hdensity) apply IsBigO.of_norm_eventuallyLE have hU := Real.tendsto_log_atTop.comp (Real.tendsto_log_atTop.comp Real.tendsto_log_atTop) filter_upwards [hF, hsize, hU.eventually_ge_atTop 0] with y hF hsize hU have hAU : 0 ≤ A * Real.log (Real.log (Real.log y)) := mul_nonneg hA.le hU have hsub : normalPrimeFailures (F y) (normalityScale (Real.log (Real.log y))) ⊆ squarefreeNonNormalIntegers (normalityScale (Real.log (Real.log y))) (c * y * Real.log (Real.log y)) (⌊A * Real.log (Real.log (Real.log y))⌋₊ + 1) := by intro n hn obtain ⟨hnF, hbad⟩ := Finset.mem_filter.mp hn obtain ⟨hnSF, hnφ, hnΩ⟩ := hF n hnF have hnpos := Nat.pos_of_ne_zero hnSF.ne_zero have hnz := hsize n hnpos hnφ have hnk : ArithmeticFunction.cardFactors n ≤ ⌊A * Real.log (Real.log (Real.log y))⌋₊ + 1 := by rw [← Nat.floor_add_one hAU] exact Nat.le_floor hnΩ exact Finset.mem_filter.mpr ⟨Finset.mem_Icc.mpr ⟨hnpos, Nat.le_floor hnz⟩, hnSF, hnk, hbad⟩ have hcard : ((normalPrimeFailures (F y) (normalityScale (Real.log (Real.log y)))).card : ℝ) ≤ squarefreeNonNormalCount A c y := by dsimp only [squarefreeNonNormalCount] exact_mod_cast Finset.card_le_card hsub simpa only [Real.norm_eq_abs, abs_of_nonneg (Nat.cast_nonneg _ : (0 : ℝ) ≤ (normalPrimeFailures (F y) (normalityScale (Real.log (Real.log y)))).card), abs_of_nonneg (Nat.cast_nonneg _ : (0 : ℝ) ≤ squarefreeNonNormalCount A c y)] using hcard /- Original line 11067: Erdos416Proof.normal_prime_pruning_negligible_in_V_of_density -/ theorem normal_prime_pruning_negligible_in_V_of_density {A C : ℝ} (hA : 0 < A) (hC : 0 < C) (hdensity : NormalPrimeDensityEstimate C) (F : ℝ → Finset ℕ) (hF : ∀ᶠ y : ℝ in atTop, ∀ n ∈ F y, Squarefree n ∧ (n.totient : ℝ) ≤ y ∧ (ArithmeticFunction.cardFactors n : ℝ) ≤ A * Real.log (Real.log (Real.log y)) + 1) : (fun y : ℝ => ((normalPrimeFailures (F y) (normalityScale (Real.log (Real.log y)))).card : ℝ)) =o[atTop] V := (normal_prime_pruning_for_squarefree_preimages_of_density hA hC hdensity F hF).trans_isBigO square_pruning_scale_isBigO_V end Erdos416Proof /- Adapted from AlexKontorovich/PrimeNumberTheoremAnd, Apache-2.0. Pinned revision: a5154676af9aa3095150ee410cdda80555aa0642. See PNT-LICENSE.txt and work/prepare_selberg_port.py for provenance. The selected dependency source and its two-form application have been verified. This does not by itself establish Ford's specialized prime-counting theorems. -/ section SelbergDependencyPort /- Source module: Sieve/AuxResults -/ section SelbergSource_0 /- Copyright (c) 2023 Arend Mellendijk. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Author: Arend Mellendijk ! This file was ported from Lean 3 source module aux_results -/ noncomputable section open scoped BigOperators ArithmeticFunction ArithmeticFunction.Moebius ArithmeticFunction.omega open _root_.Nat ArithmeticFunction Finset namespace ArithmeticFunction.IsMultiplicative variable {R : Type*} /- Original line 11114: ArithmeticFunction.IsMultiplicative.prod_factors_of_mult -/ theorem prod_factors_of_mult (f : ArithmeticFunction ℝ) (h_mult : ArithmeticFunction.IsMultiplicative f) {l : ℕ} (hl : Squarefree l) : ∏ a ∈ l.primeFactors, f a = f l := by rw [←IsMultiplicative.map_prod_of_subset_primeFactors h_mult l _ Finset.Subset.rfl, Nat.prod_primeFactors_of_squarefree hl] end ArithmeticFunction.IsMultiplicative namespace Aux /- Original line 11123: Aux.sum_over_dvd_ite -/ theorem sum_over_dvd_ite {α : Type _} [Ring α] {P : ℕ} (hP : P ≠ 0) {n : ℕ} (hn : n ∣ P) {f : ℕ → α} : ∑ d ∈ n.divisors, f d = ∑ d ∈ P.divisors, if d ∣ n then f d else 0 := by rw [←Finset.sum_filter, Nat.divisors_filter_dvd_of_dvd hP hn] /- Original line 11128: Aux.ite_sum_zero -/ theorem ite_sum_zero {p : Prop} [Decidable p] (s : Finset ℕ) (f : ℕ → ℝ) : (if p then (∑ x ∈ s, f x) else 0) = ∑ x ∈ s, if p then f x else 0 := by split_ifs <;> simp /- Original line 11132: Aux.conv_lambda_sq_larger_sum -/ theorem conv_lambda_sq_larger_sum (f : ℕ → ℕ → ℕ → ℝ) (n : ℕ) : (∑ d ∈ n.divisors, ∑ d1 ∈ d.divisors, ∑ d2 ∈ d.divisors, if d = Nat.lcm d1 d2 then f d1 d2 d else 0) = ∑ d ∈ n.divisors, ∑ d1 ∈ n.divisors, ∑ d2 ∈ n.divisors, if d = Nat.lcm d1 d2 then f d1 d2 d else 0 := by apply sum_congr rfl; intro d hd rw [mem_divisors] at hd simp_rw [←Nat.divisors_filter_dvd_of_dvd hd.2 hd.1, sum_filter, ←ite_and, ite_sum_zero, ←ite_and] congr with d1 congr with d2 congr rw [eq_iff_iff] refine ⟨fun ⟨_, _, h⟩ ↦ h, ?_⟩ rintro rfl exact ⟨Nat.dvd_lcm_left d1 d2, Nat.dvd_lcm_right d1 d2, rfl⟩ /- Original line 11151: Aux.moebius_inv_dvd_lower_bound -/ theorem moebius_inv_dvd_lower_bound (l m : ℕ) (hm : Squarefree m) : (∑ d ∈ m.divisors, if l ∣ d then (μ d:ℤ) else 0) = if l = m then (μ l:ℤ) else 0 := by have hm_pos : 0 < m := Nat.pos_of_ne_zero hm.ne_zero revert hm revert m apply (ArithmeticFunction.sum_eq_iff_sum_smul_moebius_eq_on {n | Squarefree n} (fun _ _ => Squarefree.squarefree_of_dvd)).mpr intro m hm_pos hm rw [sum_divisorsAntidiagonal' (f:= fun x y => μ x • if l=y then μ l else 0)]-- by_cases hl : l ∣ m · rw [if_pos hl, sum_eq_single l] · have hmul : m / l * l = m := Nat.div_mul_cancel hl rw [if_pos rfl, smul_eq_mul, ←isMultiplicative_moebius.map_mul_of_coprime, hmul] apply coprime_of_squarefree_mul; rw [hmul]; exact hm · intro d _ hdl; rw [if_neg hdl.symm, smul_zero] · intro h; rw[mem_divisors] at h; exfalso; exact h ⟨hl, (Nat.ne_of_lt hm_pos).symm⟩ · rw [if_neg hl, sum_eq_zero]; intro d hd rw [if_neg, smul_zero] by_contra h; rw [←h] at hd; exact hl (dvd_of_mem_divisors hd) /- Original line 11174: Aux.moebius_inv_dvd_lower_bound' -/ theorem moebius_inv_dvd_lower_bound' {P : ℕ} (hP : Squarefree P) (l m : ℕ) (hm : m ∣ P) : (∑ d ∈ P.divisors, if l ∣ d ∧ d ∣ m then μ d else 0) = if l = m then μ l else 0 := by rw [←moebius_inv_dvd_lower_bound _ _ (Squarefree.squarefree_of_dvd hm hP), sum_over_dvd_ite hP.ne_zero hm] simp_rw[ite_and, ←sum_filter, filter_comm] /- Original line 11180: Aux.moebius_inv_dvd_lower_bound_real -/ theorem moebius_inv_dvd_lower_bound_real {P : ℕ} (hP : Squarefree P) (l m : ℕ) (hm : m ∣ P) : (∑ d ∈ P.divisors, if l ∣ d ∧ d ∣ m then (μ d : ℝ) else 0) = if l = m then (μ l : ℝ) else 0 := by norm_cast apply moebius_inv_dvd_lower_bound' hP l m hm /- Original line 11186: Aux.multiplicative_zero_of_zero_dvd -/ theorem multiplicative_zero_of_zero_dvd (f : ArithmeticFunction ℝ) (h_mult : IsMultiplicative f) {m n : ℕ} (h_sq : Squarefree n) (hmn : m ∣ n) (h_zero : f m = 0) : f n = 0 := by rcases hmn with ⟨k, rfl⟩ simp only [MulZeroClass.zero_mul, h_mult.map_mul_of_coprime (coprime_of_squarefree_mul h_sq), h_zero] /- Original line 11192: Aux.div_mult_of_dvd_squarefree -/ theorem div_mult_of_dvd_squarefree (f : ArithmeticFunction ℝ) (h_mult : IsMultiplicative f) (l d : ℕ) (hdl : d ∣ l) (hl : Squarefree l) (hd : f d ≠ 0) : f l / f d = f (l / d) := by apply div_eq_of_eq_mul hd rw [← h_mult.right, Nat.div_mul_cancel hdl] apply coprime_of_squarefree_mul convert hl exact Nat.div_mul_cancel hdl /- Original line 11200: Aux.inv_sub_antitoneOn_gt -/ theorem inv_sub_antitoneOn_gt {R : Type*} [Field R] [LinearOrder R] [IsStrictOrderedRing R] (c : R) : AntitoneOn (fun x:R ↦ (x-c)⁻¹) (Set.Ioi c) := by refine antitoneOn_iff_forall_lt.mpr ?_ intro a ha b hb hab rw [Set.mem_Ioi] at ha hb gcongr /- Original line 11208: Aux.inv_sub_antitoneOn_Icc -/ theorem inv_sub_antitoneOn_Icc {R : Type*} [Field R] [LinearOrder R] [IsStrictOrderedRing R] (a b c : R) (ha : c < a) : AntitoneOn (fun x ↦ (x-c)⁻¹) (Set.Icc a b) := by by_cases hab : a ≤ b · exact inv_sub_antitoneOn_gt c |>.mono <| (Set.Icc_subset_Ioi_iff hab).mpr ha · simp [hab, Set.Subsingleton.antitoneOn] /- Original line 11216: Aux.inv_antitoneOn_pos -/ theorem inv_antitoneOn_pos {R : Type*} [Field R] [LinearOrder R] [IsStrictOrderedRing R] : AntitoneOn (fun x:R ↦ x⁻¹) (Set.Ioi 0) := by convert inv_sub_antitoneOn_gt (R:=R) 0; ring /- Original line 11220: Aux.inv_antitoneOn_Icc -/ theorem inv_antitoneOn_Icc {R : Type*} [Field R] [LinearOrder R] [IsStrictOrderedRing R] (a b : R) (ha : 0 < a) : AntitoneOn (fun x ↦ x⁻¹) (Set.Icc a b) := by convert inv_sub_antitoneOn_Icc a b 0 ha; ring /- Original line 11225: Aux.log_add_one_le_sum_inv -/ theorem log_add_one_le_sum_inv (n : ℕ) : Real.log ↑(n+1) ≤ ∑ d ∈ Finset.Icc 1 n, (d:ℝ)⁻¹ := by calc _ = ∫ x in (1)..↑(n+1), x⁻¹ := ?_ _ = ∫ x in (1:ℕ)..↑(n+1), x⁻¹ := ?_ _ ≤ _ := ?_ · rw[integral_inv (by simp[(show ¬ (1:ℝ) ≤ 0 by norm_num)] )]; congr; ring · congr; norm_num · apply AntitoneOn.integral_le_sum_Ico (by norm_num) apply inv_antitoneOn_Icc norm_num /- Original line 11236: Aux.log_le_sum_inv -/ theorem log_le_sum_inv (y : ℝ) (hy : 1 ≤ y) : Real.log y ≤ ∑ d ∈ Finset.Icc 1 (⌊y⌋₊), (d:ℝ)⁻¹ := by calc _ ≤ Real.log ↑(Nat.floor y + 1) := ?_ _ ≤ _ := ?_ · gcongr apply (le_ceil y).trans norm_cast exact ceil_le_floor_add_one y · apply log_add_one_le_sum_inv /- Original line 11246: Aux.sum_inv_le_log -/ theorem sum_inv_le_log (n : ℕ) (hn : 1 ≤ n) : ∑ d ∈ Finset.Icc 1 n, (d : ℝ)⁻¹ ≤ 1 + Real.log ↑n := by rw [← Finset.sum_erase_add (Icc 1 n) _ (by simp [hn] : 1 ∈ Icc 1 n), add_comm] gcongr · norm_num simp only [Icc_erase_left] calc ∑ d ∈ Ico 2 (n + 1), (d : ℝ)⁻¹ = ∑ d ∈ Ico 2 (n + 1), (↑(d + 1) - 1)⁻¹ := ?_ _ ≤ ∫ x in (2).. ↑(n + 1), (x - 1)⁻¹ := ?_ _ = Real.log ↑n := ?_ · congr; norm_num; · apply @AntitoneOn.sum_le_integral_Ico 2 (n + 1) fun x : ℝ => (x - 1)⁻¹ · linarith [hn] apply inv_sub_antitoneOn_Icc; norm_num rw [intervalIntegral.integral_comp_sub_right _ 1, integral_inv] · norm_num norm_num; simp[hn, show (0:ℝ) < 1 by norm_num] /- Original line 11265: Aux.sum_inv_le_log_real -/ theorem sum_inv_le_log_real (y : ℝ) (hy : 1 ≤ y) : ∑ d ∈ Finset.Icc 1 (⌊y⌋₊), (d:ℝ)⁻¹ ≤ 1 + Real.log y := by trans (1 + Real.log (⌊y⌋₊)) · apply sum_inv_le_log (⌊y⌋₊) apply le_floor; norm_cast gcongr · norm_cast; apply Nat.lt_of_succ_le; apply le_floor; norm_cast · apply floor_le; linarith -- Lemma 3.1 in Heath-Brown's notes /- Original line 11275: Aux.sum_pow_cardDistinctFactors_div_self_le_log_pow -/ theorem sum_pow_cardDistinctFactors_div_self_le_log_pow {P k : ℕ} (x : ℝ) (hx : 1 ≤ x) (hP : Squarefree P) : (∑ d ∈ P.divisors, if d ≤ x then (k:ℝ) ^ (ω d) / (d : ℝ) else (0 : ℝ)) ≤ (1 + Real.log x) ^ k := by have hx_pos : 0 < x := by linarith calc _ = ∑ d ∈ P.divisors, ∑ a ∈ Fintype.piFinset fun _i : Fin k => P.divisors, if ∏ idx, a idx = d ∧ d ∣ P then if ↑d ≤ x then (d : ℝ)⁻¹ else 0 else 0 := ?_ _ = ∑ a ∈ Fintype.piFinset fun _i : Fin k => P.divisors, if ∏ idx, a idx ∣ P then if ↑(∏ idx, a idx) ≤ x then ∏ idx, (a idx : ℝ)⁻¹ else 0 else 0 := ?_ _ ≤ ∑ a ∈ Fintype.piFinset fun _i : Fin k => P.divisors, if ↑(∏ idx, a idx) ≤ x then ∏ idx, (a idx : ℝ)⁻¹ else 0 := ?_ -- do we need this one? _ ≤ ∑ a ∈ Fintype.piFinset fun _i : Fin k => P.divisors, ∏ idx, if ↑(a idx) ≤ x then (a idx : ℝ)⁻¹ else 0 := ?_ _ = ∏ _i : Fin k, ∑ d ∈ P.divisors, if ↑d ≤ x then (d : ℝ)⁻¹ else 0 := by rw [prod_univ_sum] _ = (∑ d ∈ P.divisors, if ↑d ≤ x then (d : ℝ)⁻¹ else 0) ^ k := by rw [prod_const, Finset.card_fin] _ ≤ (1 + Real.log x) ^ k := ?_ · apply sum_congr rfl; intro d hd rw [mem_divisors] at hd simp_rw [ite_and]; rw [← sum_filter, Finset.sum_const, ← finMulAntidiag_eq_piFinset_divisors_filter hd.1 hd.2, card_finMulAntidiag_of_squarefree <| hP.squarefree_of_dvd hd.1, if_pos hd.1] simp only [div_eq_mul_inv, nsmul_eq_mul, cast_pow, mul_ite, mul_zero] · rw [sum_comm]; apply sum_congr rfl; intro a _; rw [sum_eq_single (∏ idx, a idx)] · apply if_ctx_congr _ _ (fun _ => rfl) · rw [Iff.comm, iff_and_self]; exact fun _ => rfl · intro; rw [cast_prod, ← prod_inv_distrib] · exact fun d _ hd_ne ↦ if_neg fun h => hd_ne.symm h.1 · exact fun h ↦ if_neg fun h' => h (mem_divisors.mpr ⟨h'.2, hP.ne_zero⟩) · apply sum_le_sum; intro a _ by_cases h : (∏ idx, a idx ∣ P) · rw [if_pos h] rw [if_neg h] split_ifs with h' · apply prod_nonneg; intro idx _; norm_num · rfl · apply sum_le_sum; intro a ha split_ifs with h · gcongr with idx hi rw [if_pos] apply le_trans _ h norm_cast rw [←prod_erase_mul (a:=idx) (h:= hi)] apply Nat.le_mul_of_pos_left rw [Fintype.mem_piFinset] at ha apply prod_pos; intro j _; apply pos_of_mem_divisors (ha j) · apply prod_nonneg; intro j _ split_ifs · norm_num · rfl · rw [←sum_filter] gcongr trans (∑ d ∈ Icc 1 (floor x), (d:ℝ)⁻¹) · apply sum_le_sum_of_subset_of_nonneg · intro d; rw[mem_filter, mem_Icc] intro hd constructor · rw [Nat.succ_le_iff]; exact pos_of_mem_divisors hd.1 · rw [le_floor_iff hx_pos.le] exact hd.2 · norm_num apply sum_inv_le_log_real linarith /- Original line 11343: Aux.sum_pow_cardDistinctFactors_le_self_mul_log_pow -/ theorem sum_pow_cardDistinctFactors_le_self_mul_log_pow {P h : ℕ} (x : ℝ) (hx : 1 ≤ x) (hP : Squarefree P) : (∑ d ∈ P.divisors, if ↑d ≤ x then (h : ℝ) ^ ω d else (0 : ℝ)) ≤ x * (1 + Real.log x) ^ h := by trans (∑ d ∈ P.divisors, x * if ↑d ≤ x then (h : ℝ) ^ ω d / d else (0 : ℝ)) · simp_rw [mul_ite, mul_zero, ←sum_filter] gcongr with idx hi rw [div_eq_mul_inv, mul_comm _ (idx:ℝ)⁻¹, ←mul_assoc] trans (1*(h:ℝ)^ω idx) · rw [one_mul] gcongr rw [mem_filter] at hi rw [←div_eq_mul_inv] apply one_le_div (by norm_cast; apply Nat.pos_of_mem_divisors hi.1) |>.mpr hi.2 rw [←mul_sum]; gcongr apply sum_pow_cardDistinctFactors_div_self_le_log_pow x hx hP end Aux end end SelbergSource_0 /- Source module: Sieve/Basic -/ section SelbergSource_1 /- Copyright (c) 2023 Arend Mellendijk. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Author: Arend Mellendijk ! This file was ported from Lean 3 source module sieve -/ noncomputable section open scoped BigOperators ArithmeticFunction ArithmeticFunction.Moebius open Finset Real _root_.Nat Aux BoundingSieve namespace SelbergSieve variable (s : BoundingSieve) -- S = ∑_{l|P, l≤√y} g(l) -- Used in statement of the simple form of the selberg bound /- Original line 11396: SelbergSieve.selbergTerms -/ def selbergTerms : ArithmeticFunction ℝ := s.nu.pmul (.prodPrimeFactors fun p => 1 / (1 - (BoundingSieve.nu (self := s)) p)) /- Original line 11401: SelbergSieve.selbergTerms_apply -/ theorem selbergTerms_apply (d : ℕ) : (SelbergSieve.selbergTerms s) d = (BoundingSieve.nu (self := s)) d * ∏ p ∈ d.primeFactors, 1/(1 - (BoundingSieve.nu (self := s)) p) := by unfold selbergTerms by_cases h : d=0 · rw [h]; simp rw [ArithmeticFunction.pmul_apply, ArithmeticFunction.prodPrimeFactors_apply h] section UpperBoundSieve /- Original line 11410: SelbergSieve.UpperBoundSieve -/ structure UpperBoundSieve where mk :: μPlus : ℕ → ℝ hμPlus : IsUpperMoebius μPlus /- Original line 11414: SelbergSieve.ubToμPlus -/ abbrev ubToμPlus : CoeFun UpperBoundSieve fun _ => ℕ → ℝ where coe ub := ub.μPlus /- Original line 11416: SelbergSieve.IsLowerMoebius -/ noncomputable def IsLowerMoebius : letI := @_root_.SelbergSieve.ubToμPlus ∀ (μMinus : ℕ → ℝ), Prop := by intro μMinus letI := @_root_.SelbergSieve.ubToμPlus exact ∀ n : ℕ, ∑ d ∈ n.divisors, μMinus d ≤ (if n=1 then 1 else 0) /- Original line 11419: SelbergSieve.LowerBoundSieve -/ structure LowerBoundSieve where mk :: μMinus : ℕ → ℝ hμMinus : IsLowerMoebius μMinus /- Original line 11423: SelbergSieve.lbToμMinus -/ noncomputable abbrev lbToμMinus : letI := @_root_.SelbergSieve.ubToμPlus CoeFun LowerBoundSieve fun _ => ℕ → ℝ := by letI := @_root_.SelbergSieve.ubToμPlus exact { coe lb := lb.μMinus } end UpperBoundSieve section SieveLemmas /- Original line 11429: SelbergSieve.nu_ne_zero_of_mem_divisors_prodPrimes -/ theorem nu_ne_zero_of_mem_divisors_prodPrimes : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus ∀ {d : ℕ} (hd : d ∈ divisors (BoundingSieve.prodPrimes (self := s))), (BoundingSieve.nu (self := s)) d ≠ 0 := by intro d hd letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact by apply _root_.ne_of_gt rw [mem_divisors] at hd apply nu_pos_of_dvd_prodPrimes hd.left /- Original line 11434: SelbergSieve.delta -/ noncomputable def delta : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus ∀ (n : ℕ), ℝ := by intro n letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact if n=1 then 1 else 0 /- Original line 11438: SelbergSieve.siftedSum_as_delta -/ theorem siftedSum_as_delta : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus siftedSum (s := s) = ∑ d ∈ s.support, (BoundingSieve.weights (self := s)) d * (delta) (Nat.gcd (BoundingSieve.prodPrimes (self := s)) d) := by letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact by rw [siftedSum_eq_sum_support_mul_ite] simp only [delta] -- Unused ? /- Original line 11444: SelbergSieve.nu_lt_self_of_dvd_prodPrimes -/ theorem nu_lt_self_of_dvd_prodPrimes : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus ∀ (d : ℕ) (hdP : d ∣ (BoundingSieve.prodPrimes (self := s))) (hd_ne_one : d ≠ 1), (BoundingSieve.nu (self := s)) d < 1 := by intro d hdP hd_ne_one letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact nu_lt_one_of_dvd_prodPrimes hdP hd_ne_one -- Facts about g /- Original line 11448: SelbergSieve.selbergTerms_pos -/ theorem selbergTerms_pos : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus ∀ (l : ℕ) (hl : l ∣ (BoundingSieve.prodPrimes (self := s))), 0 < (SelbergSieve.selbergTerms s) l := by intro l hl letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact by rw [selbergTerms_apply] apply mul_pos · exact nu_pos_of_dvd_prodPrimes hl apply prod_pos intro p hp rw [one_div_pos] have hp_prime : p.Prime := prime_of_mem_primeFactors hp have hp_dvd : p ∣ (BoundingSieve.prodPrimes (self := s)) := (Nat.dvd_of_mem_primeFactors hp).trans hl linarith only [s.nu_lt_one_of_prime p hp_prime hp_dvd] /- Original line 11460: SelbergSieve.selbergTerms_mult -/ theorem selbergTerms_mult : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus ArithmeticFunction.IsMultiplicative (SelbergSieve.selbergTerms s) := by letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact by unfold selbergTerms arith_mult /- Original line 11464: SelbergSieve.one_div_selbergTerms_eq_conv_moebius_nu -/ theorem one_div_selbergTerms_eq_conv_moebius_nu : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus ∀ (l : ℕ) (hl : Squarefree l) (hnu_nonzero : (BoundingSieve.nu (self := s)) l ≠ 0), 1 / (SelbergSieve.selbergTerms s) l = ∑ d ∈ l.divisors, (μ <| l / d) * ((BoundingSieve.nu (self := s)) d)⁻¹ := by intro l hl hnu_nonzero letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact by rw [selbergTerms_apply] simp only [one_div, prod_inv_distrib, mul_inv, inv_inv] rw [(s.nu_mult).prodPrimeFactors_one_sub_of_squarefree _ hl] rw [mul_sum] apply symm rw [← Nat.sum_divisorsAntidiagonal' fun d e : ℕ => ↑(μ d) * ((BoundingSieve.nu (self := s)) e)⁻¹] rw [Nat.sum_divisorsAntidiagonal fun d e : ℕ => ↑(μ d) * ((BoundingSieve.nu (self := s)) e)⁻¹] apply sum_congr rfl; intro d hd have hd_dvd : d ∣ l := dvd_of_mem_divisors hd rw [←div_mult_of_dvd_squarefree (BoundingSieve.nu (self := s)) s.nu_mult l d (dvd_of_mem_divisors hd) hl, inv_div] · ring revert hnu_nonzero; contrapose! exact multiplicative_zero_of_zero_dvd (BoundingSieve.nu (self := s)) s.nu_mult hl hd_dvd /- Original line 11481: SelbergSieve.nu_eq_conv_one_div_selbergTerms -/ theorem nu_eq_conv_one_div_selbergTerms : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus ∀ (d : ℕ) (hdP : d ∣ (BoundingSieve.prodPrimes (self := s))), ((BoundingSieve.nu (self := s)) d)⁻¹ = ∑ l ∈ divisors (BoundingSieve.prodPrimes (self := s)), if l ∣ d then 1 / (SelbergSieve.selbergTerms s) l else 0 := by intro d hdP letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact by apply symm rw [←sum_filter, Nat.divisors_filter_dvd_of_dvd prodPrimes_ne_zero hdP] have hd_pos : 0 < d := Nat.pos_of_ne_zero <| ne_zero_of_dvd_ne_zero prodPrimes_ne_zero hdP revert hdP; revert d apply (ArithmeticFunction.sum_eq_iff_sum_mul_moebius_eq_on _ (fun _ _ => Nat.dvd_trans)).mpr intro l _ hlP rw [sum_divisorsAntidiagonal' (f:=fun x y => (μ <| x) * ((BoundingSieve.nu (self := s)) y)⁻¹) (n:=l)] apply symm exact one_div_selbergTerms_eq_conv_moebius_nu _ l (Squarefree.squarefree_of_dvd hlP s.prodPrimes_squarefree) (_root_.ne_of_gt <| nu_pos_of_dvd_prodPrimes hlP) /- Original line 11495: SelbergSieve.conv_selbergTerms_eq_selbergTerms_mul_nu -/ theorem conv_selbergTerms_eq_selbergTerms_mul_nu : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus ∀ {d : ℕ} (hd : d ∣ (BoundingSieve.prodPrimes (self := s))), (∑ l ∈ divisors (BoundingSieve.prodPrimes (self := s)), if l ∣ d then (SelbergSieve.selbergTerms s) l else 0) = (SelbergSieve.selbergTerms s) d * ((BoundingSieve.nu (self := s)) d)⁻¹ := by intro d hd letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact by calc (∑ l ∈ divisors (BoundingSieve.prodPrimes (self := s)), if l ∣ d then (SelbergSieve.selbergTerms s) l else 0) = ∑ l ∈ divisors (BoundingSieve.prodPrimes (self := s)), if l ∣ d then (SelbergSieve.selbergTerms s) (d / l) else 0 := by rw [← sum_over_dvd_ite prodPrimes_ne_zero hd, ← Nat.sum_divisorsAntidiagonal fun x _ => (SelbergSieve.selbergTerms s) x, Nat.sum_divisorsAntidiagonal' fun x _ => (SelbergSieve.selbergTerms s) x, sum_over_dvd_ite prodPrimes_ne_zero hd] _ = (SelbergSieve.selbergTerms s) d * ∑ l ∈ divisors (BoundingSieve.prodPrimes (self := s)), if l ∣ d then 1 / (SelbergSieve.selbergTerms s) l else 0 := by rw [mul_sum]; apply sum_congr rfl; intro l hl rw [mul_ite_zero]; apply if_ctx_congr Iff.rfl _ (fun _ => rfl); intro h rw [← div_mult_of_dvd_squarefree (SelbergSieve.selbergTerms s) (selbergTerms_mult s) d l h] · ring · apply Squarefree.squarefree_of_dvd hd s.prodPrimes_squarefree · apply _root_.ne_of_gt; rw [mem_divisors] at hl; apply selbergTerms_pos; exact hl.left _ = (SelbergSieve.selbergTerms s) d * ((BoundingSieve.nu (self := s)) d)⁻¹ := by rw [← nu_eq_conv_one_div_selbergTerms s d hd] /- Original line 11512: SelbergSieve.upper_bound_of_UpperBoundSieve -/ theorem upper_bound_of_UpperBoundSieve : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus ∀ (μPlus : UpperBoundSieve), siftedSum (s := s) ≤ ∑ d ∈ divisors (BoundingSieve.prodPrimes (self := s)), μPlus d * multSum (s := s) d := by intro μPlus letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact siftedSum_le_sum_of_upperMoebius _ μPlus.hμPlus /- Original line 11516: SelbergSieve.siftedSum_le_mainSum_errSum_of_UpperBoundSieve -/ theorem siftedSum_le_mainSum_errSum_of_UpperBoundSieve : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus ∀ (μPlus : UpperBoundSieve), siftedSum (s := s) ≤ (BoundingSieve.totalMass (self := s)) * mainSum (s := s) μPlus + errSum (s := s) μPlus := by intro μPlus letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact by apply siftedSum_le_mainSum_errSum_of_upperMoebius _ μPlus.hμPlus end SieveLemmas -- Results about Lambda Squared Sieves section LambdaSquared /- Original line 11525: SelbergSieve.lambdaSquared -/ noncomputable def lambdaSquared : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus ∀ (weights : ℕ → ℝ), ℕ → ℝ := by intro weights letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact fun d => ∑ d1 ∈ d.divisors, ∑ d2 ∈ d.divisors, if d = Nat.lcm d1 d2 then weights d1 * weights d2 else 0 /- Original line 11529: SelbergSieve.lambdaSquared_eq_zero_of_support_wlog -/ private theorem lambdaSquared_eq_zero_of_support_wlog : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus ∀ {w : ℕ → ℝ} {y : ℝ} (hw : ∀ (d : ℕ), ¬d ^ 2 ≤ y → w d = 0) {d : ℕ} (hd : ¬↑d ≤ y) (d1 : ℕ) (d2 : ℕ) (h : d = Nat.lcm d1 d2) (hle : d1 ≤ d2), w d1 * w d2 = 0 := by intro w y hw d hd d1 d2 h hle letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact by rw [hw d2, mul_zero] by_contra hyp; apply hd apply le_trans _ hyp norm_cast calc _ ≤ (d1.lcm d2) := by rw [h] _ ≤ (d1*d2) := Nat.div_le_self _ _ _ ≤ _ := ?_ · rw [sq]; gcongr /- Original line 11542: SelbergSieve.lambdaSquared_eq_zero_of_support -/ theorem lambdaSquared_eq_zero_of_support : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus ∀ (w : ℕ → ℝ) (y : ℝ) (hw : ∀ d : ℕ, ¬d ^ 2 ≤ y → w d = 0) (d : ℕ) (hd : ¬d ≤ y), lambdaSquared w d = 0 := by intro w y hw d hd letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact by dsimp only [lambdaSquared] by_cases hy : 0 ≤ y swap · push Not at hd hy have : ∀ d' : ℕ, w d' = 0 := by intro d'; apply hw have : (0:ℝ) ≤ (d') ^ 2 := by norm_num linarith apply sum_eq_zero; intro d1 _ apply sum_eq_zero; intro d2 _ rw [this d1, this d2] simp only [mul_zero, ite_self] apply sum_eq_zero; intro d1 _ apply sum_eq_zero; intro d2 _ split_ifs with h swap · rfl rcases Nat.le_or_le d1 d2 with hle | hle · apply lambdaSquared_eq_zero_of_support_wlog hw hd d1 d2 h hle · rw [mul_comm] apply lambdaSquared_eq_zero_of_support_wlog hw hd d2 d1 (Nat.lcm_comm d1 d2 ▸ h) hle /- Original line 11568: SelbergSieve.upperMoebius_of_lambda_sq -/ theorem upperMoebius_of_lambda_sq : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus ∀ (weights : ℕ → ℝ) (hw : weights 1 = 1), IsUpperMoebius <| lambdaSquared weights := by intro weights hw letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact by dsimp [IsUpperMoebius, lambdaSquared] intro n have h_sq : (∑ d ∈ n.divisors, ∑ d1 ∈ d.divisors, ∑ d2 ∈ d.divisors, if d = Nat.lcm d1 d2 then weights d1 * weights d2 else 0) = (∑ d ∈ n.divisors, weights d) ^ 2 := by rw [sq, mul_sum, conv_lambda_sq_larger_sum _ n, sum_comm] apply sum_congr rfl; intro d1 hd1 rw [sum_mul, sum_comm] apply sum_congr rfl; intro d2 hd2 rw [sum_ite_eq_of_mem'] · ring rw [mem_divisors, Nat.lcm_dvd_iff] exact ⟨⟨dvd_of_mem_divisors hd1, dvd_of_mem_divisors hd2⟩, (mem_divisors.mp hd1).2⟩ rw [h_sq] split_ifs with hn · rw [hn]; simp [hw] · apply sq_nonneg -- set_option quotPrecheck false -- variable (s : Sieve) -- local notation3 "ν" => Sieve.nu s -- local notation3 "P" => Sieve.prodPrimes s -- local notation3 "a" => Sieve.weights s -- local notation3 "X" => Sieve.totalMass s -- local notation3 "R" => Sieve.rem s -- local notation3 "g" => Sieve.selbergTerms s /- Original line 11599: SelbergSieve.lambdaSquared_mainSum_eq_quad_form -/ theorem lambdaSquared_mainSum_eq_quad_form : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus ∀ (w : ℕ → ℝ), mainSum (s := s) (lambdaSquared w) = ∑ d1 ∈ divisors (BoundingSieve.prodPrimes (self := s)), ∑ d2 ∈ divisors (BoundingSieve.prodPrimes (self := s)), (BoundingSieve.nu (self := s)) d1 * w d1 * (BoundingSieve.nu (self := s)) d2 * w d2 * ((BoundingSieve.nu (self := s)) (d1.gcd d2))⁻¹ := by intro w letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact by dsimp only [mainSum, lambdaSquared] trans (∑ d ∈ divisors (BoundingSieve.prodPrimes (self := s)), ∑ d1 ∈ divisors d, ∑ d2 ∈ divisors d, if d = d1.lcm d2 then w d1 * w d2 * (BoundingSieve.nu (self := s)) d else 0) · rw [sum_congr rfl]; intro d _ rw [sum_mul, sum_congr rfl]; intro d1 _ rw [sum_mul, sum_congr rfl]; intro d2 _ rw [ite_zero_mul] trans (∑ d ∈ divisors (BoundingSieve.prodPrimes (self := s)), ∑ d1 ∈ divisors (BoundingSieve.prodPrimes (self := s)), ∑ d2 ∈ divisors (BoundingSieve.prodPrimes (self := s)), if d = d1.lcm d2 then w d1 * w d2 * (BoundingSieve.nu (self := s)) d else 0) · apply conv_lambda_sq_larger_sum rw [sum_comm, sum_congr rfl]; intro d1 hd1 rw [sum_comm, sum_congr rfl]; intro d2 hd2 have h : d1.lcm d2 ∣ (BoundingSieve.prodPrimes (self := s)) := Nat.lcm_dvd_iff.mpr ⟨dvd_of_mem_divisors hd1, dvd_of_mem_divisors hd2⟩ rw [sum_ite_eq_of_mem' (divisors (BoundingSieve.prodPrimes (self := s))) (d1.lcm d2) _ (mem_divisors.mpr ⟨h, prodPrimes_ne_zero⟩)] rw [s.nu_mult.map_lcm] · ring refine _root_.ne_of_gt (nu_pos_of_dvd_prodPrimes ?_) trans d1 · exact Nat.gcd_dvd_left d1 d2 · exact dvd_of_mem_divisors hd1 /- Original line 11626: SelbergSieve.lambdaSquared_mainSum_eq_diag_quad_form -/ theorem lambdaSquared_mainSum_eq_diag_quad_form : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus ∀ (w : ℕ → ℝ), mainSum (s := s) (lambdaSquared w) = ∑ l ∈ divisors (BoundingSieve.prodPrimes (self := s)), 1 / (SelbergSieve.selbergTerms s) l * (∑ d ∈ divisors (BoundingSieve.prodPrimes (self := s)), if l ∣ d then (BoundingSieve.nu (self := s)) d * w d else 0) ^ 2 := by intro w letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact by rw [lambdaSquared_mainSum_eq_quad_form s w] trans (∑ d1 ∈ divisors (BoundingSieve.prodPrimes (self := s)), ∑ d2 ∈ divisors (BoundingSieve.prodPrimes (self := s)), (∑ l ∈ divisors (BoundingSieve.prodPrimes (self := s)), if l ∣ d1.gcd d2 then 1 / (SelbergSieve.selbergTerms s) l * ((BoundingSieve.nu (self := s)) d1 * w d1) * ((BoundingSieve.nu (self := s)) d2 * w d2) else 0)) · apply sum_congr rfl; intro d1 hd1; apply sum_congr rfl; intro d2 _ have hgcd_dvd: d1.gcd d2 ∣ (BoundingSieve.prodPrimes (self := s)) := Trans.trans (Nat.gcd_dvd_left d1 d2) (dvd_of_mem_divisors hd1) rw [nu_eq_conv_one_div_selbergTerms s _ hgcd_dvd, mul_sum] apply sum_congr rfl; intro l _ rw [mul_ite_zero]; apply if_congr Iff.rfl _ rfl ring trans (∑ l ∈ divisors (BoundingSieve.prodPrimes (self := s)), ∑ d1 ∈ divisors (BoundingSieve.prodPrimes (self := s)), ∑ d2 ∈ divisors (BoundingSieve.prodPrimes (self := s)), if l ∣ Nat.gcd d1 d2 then 1 / selbergTerms s l * ((BoundingSieve.nu (self := s)) d1 * w d1) * ((BoundingSieve.nu (self := s)) d2 * w d2) else 0) · apply symm; rw [sum_comm, sum_congr rfl]; intro d1 _ rw [sum_comm] apply sum_congr rfl; intro l _ rw [sq, sum_mul, mul_sum, sum_congr rfl]; intro d1 _ rw [mul_sum, mul_sum, sum_congr rfl]; intro d2 _ rw [ite_zero_mul_ite_zero, mul_ite_zero] apply if_congr (Nat.dvd_gcd_iff) _ rfl; ring end LambdaSquared end SelbergSieve end end SelbergSource_1 /- Source module: Sieve/Selberg -/ section SelbergSource_2 /- Copyright (c) 2023 Arend Mellendijk. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Author: Arend Mellendijk ! This file was ported from Lean 3 source module selberg -/ /- # The Selberg Sieve This file proves `selberg_bound_simple`, the main theorem of the Selberg. -/ noncomputable section open scoped BigOperators Classical SelbergSieve ArithmeticFunction.Moebius ArithmeticFunction.omega open Finset Real _root_.Nat SelbergSieve.UpperBoundSieve ArithmeticFunction SelbergSieve BoundingSieve namespace SelbergSieve variable (s : SelbergSieve) /- Original line 11697: SelbergSieve.selbergBoundingSum -/ noncomputable def selbergBoundingSum : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus ℝ := by letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact ∑ l ∈ divisors (BoundingSieve.prodPrimes (self := SelbergSieve.toBoundingSieve (self := s))), if l ^ 2 ≤ (SelbergSieve.level (self := s)) then (SelbergSieve.selbergTerms (SelbergSieve.toBoundingSieve (self := s))) l else 0 /- Original line 11704: SelbergSieve.selbergBoundingSum_pos -/ theorem selbergBoundingSum_pos : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus 0 < (SelbergSieve.selbergBoundingSum s) := by letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact by dsimp only [selbergBoundingSum] rw [← sum_filter] apply sum_pos; · intro l hl rw [mem_filter, mem_divisors] at hl · apply selbergTerms_pos _ _ (hl.1.1) · simp_rw [Finset.Nonempty, mem_filter]; use 1 constructor · apply one_mem_divisors.mpr prodPrimes_ne_zero rw [cast_one, one_pow] exact s.one_le_level /- Original line 11718: SelbergSieve.selbergBoundingSum_ne_zero -/ theorem selbergBoundingSum_ne_zero : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus (SelbergSieve.selbergBoundingSum s) ≠ 0 := by letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact by apply _root_.ne_of_gt exact s.selbergBoundingSum_pos /- Original line 11722: SelbergSieve.selbergBoundingSum_nonneg -/ theorem selbergBoundingSum_nonneg : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus 0 ≤ (SelbergSieve.selbergBoundingSum s) := by letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact _root_.le_of_lt s.selbergBoundingSum_pos /- Original line 11724: SelbergSieve.selbergWeights -/ noncomputable def selbergWeights : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus ℕ → ℝ := by letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact fun d => if d ∣ (BoundingSieve.prodPrimes (self := SelbergSieve.toBoundingSieve (self := s))) then ((BoundingSieve.nu (self := SelbergSieve.toBoundingSieve (self := s))) d)⁻¹ * (SelbergSieve.selbergTerms (SelbergSieve.toBoundingSieve (self := s))) d * μ d * (SelbergSieve.selbergBoundingSum s)⁻¹ * ∑ m ∈ divisors (BoundingSieve.prodPrimes (self := SelbergSieve.toBoundingSieve (self := s))), if (d * m) ^ 2 ≤ (SelbergSieve.level (self := s)) ∧ m.Coprime d then (SelbergSieve.selbergTerms (SelbergSieve.toBoundingSieve (self := s))) m else 0 else 0 -- This notation traditionally uses λ, which is unavailable in lean /- Original line 11734: SelbergSieve.selbergWeights_eq_zero_of_not_dvd -/ theorem selbergWeights_eq_zero_of_not_dvd : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus ∀ {d : ℕ} (hd : ¬ d ∣ (BoundingSieve.prodPrimes (self := SelbergSieve.toBoundingSieve (self := s)))), (SelbergSieve.selbergWeights s) d = 0 := by intro d hd letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact by rw [selbergWeights, if_neg hd] /- Original line 11738: SelbergSieve.selbergWeights_eq_zero -/ theorem selbergWeights_eq_zero : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus ∀ (d : ℕ) (hd : ¬d ^ 2 ≤ (SelbergSieve.level (self := s))), (SelbergSieve.selbergWeights s) d = 0 := by intro d hd letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact by dsimp only [selbergWeights] split_ifs with h · rw [mul_eq_zero_of_right _] apply Finset.sum_eq_zero refine fun m hm => if_neg ?_ intro hyp have : (d^2:ℝ) ≤ (d*m)^2 := by norm_cast; refine Nat.pow_le_pow_left ?h 2 exact Nat.le_mul_of_pos_right _ (Nat.pos_of_mem_divisors hm) linarith [hyp.1] · rfl /- Original line 11753: SelbergSieve.selbergWeights_mul_mu_nonneg -/ theorem selbergWeights_mul_mu_nonneg : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus ∀ (d : ℕ) (hdP : d ∣ (BoundingSieve.prodPrimes (self := SelbergSieve.toBoundingSieve (self := s)))), 0 ≤ (SelbergSieve.selbergWeights s) d * μ d := by intro d hdP letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact by dsimp only [selbergWeights] rw [if_pos hdP, mul_assoc] trans ((μ d :ℝ)^2 * ((BoundingSieve.nu (self := SelbergSieve.toBoundingSieve (self := s))) d)⁻¹ * (SelbergSieve.selbergTerms (SelbergSieve.toBoundingSieve (self := s))) d * (SelbergSieve.selbergBoundingSum s)⁻¹ * ∑ m ∈ divisors (BoundingSieve.prodPrimes (self := SelbergSieve.toBoundingSieve (self := s))), if (d * m) ^ 2 ≤ (SelbergSieve.level (self := s)) ∧ Coprime m d then (SelbergSieve.selbergTerms (SelbergSieve.toBoundingSieve (self := s))) m else 0) swap · apply le_of_eq; ring refine mul_nonneg (div_nonneg (mul_nonneg (mul_nonneg ?_ ?_) ?_) ?_) ?_ · apply sq_nonneg · rw [inv_nonneg] exact le_of_lt <| nu_pos_of_dvd_prodPrimes hdP · exact le_of_lt <| selbergTerms_pos _ d hdP · exact s.selbergBoundingSum_nonneg apply sum_nonneg; intro m hm split_ifs with h · exact le_of_lt <| selbergTerms_pos _ m (dvd_of_mem_divisors hm) · rfl /- Original line 11773: SelbergSieve.sum_mul_subst -/ theorem sum_mul_subst : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus ∀ (k n : ℕ) {f : ℕ → ℝ} (h : ∀ l, l ∣ n → ¬ k ∣ l → f l = 0), ∑ l ∈ n.divisors, f l = ∑ m ∈ n.divisors, if k*m ∣ n then f (k*m) else 0 := by intro k n f h letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact by by_cases hn: n = 0 · simp [hn] by_cases hkn : k ∣ n swap · rw [sum_eq_zero, sum_eq_zero] · rintro m _ rw [if_neg] rintro h apply hkn exact (Nat.dvd_mul_right k m).trans h · intro l hl; apply h l (dvd_of_mem_divisors hl) apply fun hkl => hkn <| hkl.trans (dvd_of_mem_divisors hl) trans (∑ l ∈ n.divisors, ∑ m ∈ n.divisors, if l=k*m then f l else 0) · rw [sum_congr rfl]; intro l hl by_cases hkl : k ∣ l swap · rw [h l (dvd_of_mem_divisors hl) hkl, sum_eq_zero]; intro m _; rw [ite_id] rw [sum_eq_single (l/k)] · rw[if_pos]; rw [Nat.mul_div_cancel' hkl] · intro m _ hmlk apply if_neg; revert hmlk; contrapose!; intro hlkm rw [hlkm, mul_comm, Nat.mul_div_cancel]; apply Nat.pos_of_dvd_of_pos hkn (Nat.pos_of_ne_zero hn) · contrapose!; intro _ rw [mem_divisors] exact ⟨Trans.trans (Nat.div_dvd_of_dvd hkl) (dvd_of_mem_divisors hl), hn⟩ · rw [sum_comm, sum_congr rfl]; intro m _ split_ifs with hdvd · rw [sum_ite_eq_of_mem'] simp only [mem_divisors, hdvd, ne_eq, hn, not_false_eq_true, and_self] · apply sum_eq_zero; intro l hl apply if_neg; rintro rfl simp only [mem_divisors, ne_eq] at hl exact hdvd hl.1 --Important facts about the selberg weights /- Original line 11814: SelbergSieve.selbergWeights_eq_dvds_sum -/ theorem selbergWeights_eq_dvds_sum : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus ∀ (d : ℕ), (BoundingSieve.nu (self := SelbergSieve.toBoundingSieve (self := s))) d * (SelbergSieve.selbergWeights s) d = (SelbergSieve.selbergBoundingSum s)⁻¹ * μ d * ∑ l ∈ divisors (BoundingSieve.prodPrimes (self := SelbergSieve.toBoundingSieve (self := s))), if d ∣ l ∧ l ^ 2 ≤ (SelbergSieve.level (self := s)) then (SelbergSieve.selbergTerms (SelbergSieve.toBoundingSieve (self := s))) l else 0 := by intro d letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact by by_cases h_dvd : d ∣ (BoundingSieve.prodPrimes (self := SelbergSieve.toBoundingSieve (self := s))) swap · dsimp only [selbergWeights]; rw [if_neg h_dvd] rw [sum_eq_zero] · ring intro l hl; rw [mem_divisors] at hl rw [if_neg]; push Not; intro h exfalso; exact h_dvd (dvd_trans h hl.left) dsimp only [selbergWeights] rw [if_pos h_dvd] repeat rw [mul_sum] -- change of variables l=m*d apply symm rw [sum_mul_subst d (BoundingSieve.prodPrimes (self := SelbergSieve.toBoundingSieve (self := s)))] · apply sum_congr rfl intro m hm rw [mul_ite_zero, ←ite_and, mul_ite_zero, mul_ite_zero] apply if_ctx_congr _ _ fun _ => rfl · rw [coprime_comm] constructor · intro h push_cast at h exact ⟨h.2.2, coprime_of_squarefree_mul <| Squarefree.squarefree_of_dvd h.1 s.prodPrimes_squarefree⟩ · intro h push_cast exact ⟨ Coprime.mul_dvd_of_dvd_of_dvd h.2 h_dvd (dvd_of_mem_divisors hm), Nat.dvd_mul_right d m, h.1⟩ · intro h trans (((BoundingSieve.nu (self := SelbergSieve.toBoundingSieve (self := s))) d)⁻¹ * ((BoundingSieve.nu (self := SelbergSieve.toBoundingSieve (self := s))) d) * (SelbergSieve.selbergTerms (SelbergSieve.toBoundingSieve (self := s))) d * μ d / (SelbergSieve.selbergBoundingSum s) * (SelbergSieve.selbergTerms (SelbergSieve.toBoundingSieve (self := s))) m) · rw [inv_mul_cancel₀ (nu_ne_zero h_dvd), (selbergTerms_mult _).map_mul_of_coprime <| coprime_comm.mp h.2] ring ring · intro l _ hdl rw [if_neg, mul_zero] push Not; intro h; contradiction /- Original line 11856: SelbergSieve.selbergWeights_diagonalisation -/ theorem selbergWeights_diagonalisation : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus ∀ (l : ℕ) (hl : l ∈ divisors (BoundingSieve.prodPrimes (self := SelbergSieve.toBoundingSieve (self := s)))), (∑ d ∈ divisors (BoundingSieve.prodPrimes (self := SelbergSieve.toBoundingSieve (self := s))), if l ∣ d then (BoundingSieve.nu (self := SelbergSieve.toBoundingSieve (self := s))) d * (SelbergSieve.selbergWeights s) d else 0) = if l ^ 2 ≤ (SelbergSieve.level (self := s)) then (SelbergSieve.selbergTerms (SelbergSieve.toBoundingSieve (self := s))) l * μ l * (SelbergSieve.selbergBoundingSum s)⁻¹ else 0 := by intro l hl letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact by calc (∑ d ∈ divisors (BoundingSieve.prodPrimes (self := SelbergSieve.toBoundingSieve (self := s))), if l ∣ d then (BoundingSieve.nu (self := SelbergSieve.toBoundingSieve (self := s))) d * (SelbergSieve.selbergWeights s) d else 0) = ∑ d ∈ divisors (BoundingSieve.prodPrimes (self := SelbergSieve.toBoundingSieve (self := s))), ∑ k ∈ divisors (BoundingSieve.prodPrimes (self := SelbergSieve.toBoundingSieve (self := s))), if l ∣ d ∧ d ∣ k ∧ k ^ 2 ≤ (SelbergSieve.level (self := s)) then (SelbergSieve.selbergTerms (SelbergSieve.toBoundingSieve (self := s))) k * (SelbergSieve.selbergBoundingSum s)⁻¹ * (μ d:ℝ) else 0 := by apply sum_congr rfl; intro d _ rw [selbergWeights_eq_dvds_sum, ← boole_mul, mul_sum, mul_sum] apply sum_congr rfl; intro k _ rw [mul_ite_zero, ite_zero_mul_ite_zero] apply if_ctx_congr Iff.rfl _ (fun _ => rfl); intro _; ring _ = ∑ k ∈ divisors (BoundingSieve.prodPrimes (self := SelbergSieve.toBoundingSieve (self := s))), if k ^ 2 ≤ (SelbergSieve.level (self := s)) then (∑ d ∈ divisors (BoundingSieve.prodPrimes (self := SelbergSieve.toBoundingSieve (self := s))), if l ∣ d ∧ d ∣ k then (μ d:ℝ) else 0) * (SelbergSieve.selbergTerms (SelbergSieve.toBoundingSieve (self := s))) k * (SelbergSieve.selbergBoundingSum s)⁻¹ else 0 := by rw [sum_comm]; apply sum_congr rfl; intro k _ apply symm rw [← boole_mul, sum_mul, sum_mul, mul_sum, sum_congr rfl] intro d _ rw [ite_zero_mul, ite_zero_mul, ite_zero_mul, one_mul, ←ite_and] apply if_ctx_congr _ _ (fun _ => rfl) · tauto intro _; ring _ = if l ^ 2 ≤ (SelbergSieve.level (self := s)) then (SelbergSieve.selbergTerms (SelbergSieve.toBoundingSieve (self := s))) l * μ l * (SelbergSieve.selbergBoundingSum s)⁻¹ else 0 := by rw [← sum_ite_eq_of_mem' (divisors (BoundingSieve.prodPrimes (self := SelbergSieve.toBoundingSieve (self := s)))) l (fun _ => if l^2 ≤ (SelbergSieve.level (self := s)) then (SelbergSieve.selbergTerms (SelbergSieve.toBoundingSieve (self := s))) l * μ l * (SelbergSieve.selbergBoundingSum s)⁻¹ else 0) hl] apply sum_congr rfl; intro k hk rw [Aux.moebius_inv_dvd_lower_bound_real s.prodPrimes_squarefree l _ (dvd_of_mem_divisors hk), ←ite_and, ite_zero_mul, ite_zero_mul, ← ite_and] apply if_ctx_congr _ _ fun _ => rfl · rw [and_comm, eq_comm]; apply and_congr_right intro heq; rw [heq] · intro h; rw [h.1]; ring /- Original line 11890: SelbergSieve.selbergMuPlus -/ noncomputable def selbergMuPlus : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus ℕ → ℝ := by letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact lambdaSquared (SelbergSieve.selbergWeights s) /- Original line 11896: SelbergSieve.weight_one_of_selberg -/ theorem weight_one_of_selberg : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus (SelbergSieve.selbergWeights s) 1 = 1 := by letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact by dsimp only [selbergWeights] rw [if_pos (one_dvd (BoundingSieve.prodPrimes (self := SelbergSieve.toBoundingSieve (self := s)))), s.nu_mult.left, (selbergTerms_mult _).map_one] simp only [inv_one, mul_one, isUnit_one, IsUnit.squarefree, moebius_apply_of_squarefree, cardFactors_one, _root_.pow_zero, Int.cast_one, selbergBoundingSum, one_mul, coprime_one_right_eq_true, and_true, cast_one] rw [inv_mul_cancel₀] convert! s.selbergBoundingSum_ne_zero /- Original line 11905: SelbergSieve.selbergμPlus_eq_zero -/ theorem selbergμPlus_eq_zero : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus ∀ (d : ℕ) (hd : ¬d ≤ (SelbergSieve.level (self := s))), (SelbergSieve.selbergMuPlus s) d = 0 := by intro d hd letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact by apply lambdaSquared_eq_zero_of_support _ (SelbergSieve.level (self := s)) _ d hd apply s.selbergWeights_eq_zero /- Original line 11909: SelbergSieve.selbergUbSieve -/ noncomputable def selbergUbSieve : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus UpperBoundSieve := by letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact ⟨(SelbergSieve.selbergMuPlus s), upperMoebius_of_lambda_sq (SelbergSieve.selbergWeights s) (s.weight_one_of_selberg)⟩ -- proved for general lambda squared sieves /- Original line 11913: SelbergSieve.mainSum_eq_diag_quad_form -/ theorem mainSum_eq_diag_quad_form : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus mainSum (s := s.toBoundingSieve) (SelbergSieve.selbergMuPlus s) = ∑ l ∈ divisors (BoundingSieve.prodPrimes (self := SelbergSieve.toBoundingSieve (self := s))), 1 / (SelbergSieve.selbergTerms (SelbergSieve.toBoundingSieve (self := s))) l * (∑ d ∈ divisors (BoundingSieve.prodPrimes (self := SelbergSieve.toBoundingSieve (self := s))), if l ∣ d then (BoundingSieve.nu (self := SelbergSieve.toBoundingSieve (self := s))) d * (SelbergSieve.selbergWeights s) d else 0) ^ 2 := by letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact by apply lambdaSquared_mainSum_eq_diag_quad_form /- Original line 11920: SelbergSieve.selberg_bound_simple_mainSum -/ theorem selberg_bound_simple_mainSum : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus mainSum (s := s.toBoundingSieve) (SelbergSieve.selbergMuPlus s) = (SelbergSieve.selbergBoundingSum s)⁻¹ := by letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact by rw [mainSum_eq_diag_quad_form] trans (∑ l ∈ divisors (BoundingSieve.prodPrimes (self := SelbergSieve.toBoundingSieve (self := s))), (if l ^ 2 ≤ (SelbergSieve.level (self := s)) then (SelbergSieve.selbergTerms (SelbergSieve.toBoundingSieve (self := s))) l * ((SelbergSieve.selbergBoundingSum s)⁻¹) ^ 2 else 0)) · apply sum_congr rfl; intro l hl rw [s.selbergWeights_diagonalisation l hl, ite_pow, zero_pow two_ne_zero, mul_ite_zero] apply if_congr Iff.rfl _ rfl trans (1/(SelbergSieve.selbergTerms (SelbergSieve.toBoundingSieve (self := s))) l * (SelbergSieve.selbergTerms (SelbergSieve.toBoundingSieve (self := s))) l * (SelbergSieve.selbergTerms (SelbergSieve.toBoundingSieve (self := s))) l * (μ l:ℝ)^2 * ((SelbergSieve.selbergBoundingSum s)⁻¹) ^ 2) · ring norm_cast; rw [moebius_sq_eq_one_of_squarefree <| squarefree_of_mem_divisors_prodPrimes hl] rw [one_div_mul_cancel <| _root_.ne_of_gt <| selbergTerms_pos _ l <| dvd_of_mem_divisors hl] ring conv => {lhs; congr; {skip}; {ext idx; rw [← ite_zero_mul]}} dsimp only [selbergBoundingSum] rw [←sum_mul, sq, ←mul_assoc, mul_inv_cancel₀] · ring · apply _root_.ne_of_gt; apply selbergBoundingSum_pos /- Original line 11938: SelbergSieve.eq_gcd_mul_of_dvd_of_coprime -/ theorem eq_gcd_mul_of_dvd_of_coprime : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus ∀ {k d m : ℕ} (hkd : k ∣ d) (hmd : Coprime m d) (hk : k ≠ 0), k = d.gcd (k*m) := by intro k d m hkd hmd hk letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact by obtain ⟨r, hr⟩ := hkd have hrdvd : r ∣ d := by use k; rw [mul_comm]; exact hr apply symm; rw [hr, Nat.gcd_mul_left, mul_eq_left₀ hk, Nat.gcd_comm] apply Coprime.coprime_dvd_right hrdvd hmd /- Original line 11945: SelbergSieve._helper -/ private theorem _helper : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus ∀ {k m d : ℕ} (hkd : k ∣ d) (hk : k ∈ divisors (BoundingSieve.prodPrimes (self := SelbergSieve.toBoundingSieve (self := s)))) (hm : m ∈ divisors (BoundingSieve.prodPrimes (self := SelbergSieve.toBoundingSieve (self := s)))), k * m ∣ (BoundingSieve.prodPrimes (self := SelbergSieve.toBoundingSieve (self := s))) ∧ k = Nat.gcd d (k * m) ∧ (k * m) ^ 2 ≤ (SelbergSieve.level (self := s)) ↔ (k * m) ^ 2 ≤ (SelbergSieve.level (self := s)) ∧ Coprime m d := by intro k m d hkd hk hm letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact by constructor · intro h constructor · exact h.2.2 · obtain ⟨r, hr⟩ := hkd rw [hr, Nat.gcd_mul_left, eq_comm, mul_eq_left₀ (by rintro rfl; simp at hk ⊢)] at h rw [hr, coprime_comm]; apply Coprime.mul_left · apply coprime_of_squarefree_mul <| Squarefree.squarefree_of_dvd h.1 s.prodPrimes_squarefree · exact h.2.1 · intro h constructor · apply Nat.Coprime.mul_dvd_of_dvd_of_dvd · rw [coprime_comm]; exact Coprime.coprime_dvd_right hkd h.2 · exact dvd_of_mem_divisors hk · exact dvd_of_mem_divisors hm constructor · exact eq_gcd_mul_of_dvd_of_coprime hkd h.2 (by rintro rfl; simp at hk ⊢) · exact h.1 /- Original line 11967: SelbergSieve.selbergBoundingSum_ge -/ theorem selbergBoundingSum_ge : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus ∀ {d : ℕ} (hdP : d ∣ (BoundingSieve.prodPrimes (self := SelbergSieve.toBoundingSieve (self := s)))), (SelbergSieve.selbergBoundingSum s) ≥ (SelbergSieve.selbergWeights s) d * ↑(μ d) * (SelbergSieve.selbergBoundingSum s) := by intro d hdP letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact by calc _ = (∑ k ∈ divisors (BoundingSieve.prodPrimes (self := SelbergSieve.toBoundingSieve (self := s))), ∑ l ∈ divisors (BoundingSieve.prodPrimes (self := SelbergSieve.toBoundingSieve (self := s))), if k = d.gcd l ∧ l ^ 2 ≤ (SelbergSieve.level (self := s)) then (SelbergSieve.selbergTerms (SelbergSieve.toBoundingSieve (self := s))) l else 0) := by dsimp only [selbergBoundingSum] rw [sum_comm, sum_congr rfl]; intro l _ simp_rw [ite_and] rw [sum_ite_eq_of_mem'] · rw [mem_divisors] exact ⟨(Nat.gcd_dvd_left d l).trans (hdP), prodPrimes_ne_zero⟩ _ = (∑ k ∈ divisors (BoundingSieve.prodPrimes (self := SelbergSieve.toBoundingSieve (self := s))), if k ∣ d then (SelbergSieve.selbergTerms (SelbergSieve.toBoundingSieve (self := s))) k * ∑ m ∈ divisors (BoundingSieve.prodPrimes (self := SelbergSieve.toBoundingSieve (self := s))), if (k * m) ^ 2 ≤ (SelbergSieve.level (self := s)) ∧ m.Coprime d then (SelbergSieve.selbergTerms (SelbergSieve.toBoundingSieve (self := s))) m else 0 else 0) := by apply sum_congr rfl; intro k hk rw [mul_sum] split_ifs with hkd swap · rw [sum_eq_zero]; intro l _ rw [if_neg] push Not; intro h; exfalso rw [h] at hkd exact hkd <| Nat.gcd_dvd_left d l rw [sum_mul_subst k (BoundingSieve.prodPrimes (self := SelbergSieve.toBoundingSieve (self := s))), sum_congr rfl] · intro m hm rw [mul_ite_zero, ← ite_and] apply if_ctx_congr _ _ fun _ => rfl · exact_mod_cast s._helper hkd hk hm · intro h apply (selbergTerms_mult _).map_mul_of_coprime rw [gcd_comm]; apply h.2.coprime_dvd_right hkd · intro l _ hkl; apply if_neg push Not; intro h; exfalso rw [h] at hkl; exact hkl (Nat.gcd_dvd_right d l) _ ≥ (∑ k ∈ divisors (BoundingSieve.prodPrimes (self := SelbergSieve.toBoundingSieve (self := s))), if k ∣ d then (SelbergSieve.selbergTerms (SelbergSieve.toBoundingSieve (self := s))) k * ∑ m ∈ divisors (BoundingSieve.prodPrimes (self := SelbergSieve.toBoundingSieve (self := s))), if (d * m) ^ 2 ≤ (SelbergSieve.level (self := s)) ∧ m.Coprime d then (SelbergSieve.selbergTerms (SelbergSieve.toBoundingSieve (self := s))) m else 0 else 0 ) := by apply sum_le_sum; intro k _ split_ifs with hkd swap · rfl apply mul_le_mul le_rfl _ _ (le_of_lt <| selbergTerms_pos _ k <| hkd.trans hdP) · apply sum_le_sum; intro m hm split_ifs with h h' h' · rfl · exfalso; apply h' refine ⟨?_, h.2⟩ · trans ((d*m)^2:ℝ) · norm_cast; gcongr refine Nat.le_of_dvd ?_ hkd apply Nat.pos_of_ne_zero; apply ne_zero_of_dvd_ne_zero prodPrimes_ne_zero hdP exact h.1 · refine le_of_lt <| selbergTerms_pos _ m <| dvd_of_mem_divisors hm · rfl apply sum_nonneg; intro m hm split_ifs · apply le_of_lt <| selbergTerms_pos _ m <| dvd_of_mem_divisors hm · rfl _ = _ := by conv => enter [1, 2, k]; rw [← ite_zero_mul] rw [←sum_mul, conv_selbergTerms_eq_selbergTerms_mul_nu _ hdP] trans ((SelbergSieve.selbergBoundingSum s) * (SelbergSieve.selbergBoundingSum s)⁻¹ * (μ d:ℝ)^2 * ((BoundingSieve.nu (self := SelbergSieve.toBoundingSieve (self := s))) d)⁻¹ * (SelbergSieve.selbergTerms (SelbergSieve.toBoundingSieve (self := s))) d * (∑ m ∈ divisors (BoundingSieve.prodPrimes (self := SelbergSieve.toBoundingSieve (self := s))), if (d*m) ^ 2 ≤ (SelbergSieve.level (self := s)) ∧ Coprime m d then (SelbergSieve.selbergTerms (SelbergSieve.toBoundingSieve (self := s))) m else 0)) · rw [mul_inv_cancel₀, ←Int.cast_pow, moebius_sq_eq_one_of_squarefree] · ring · exact Squarefree.squarefree_of_dvd hdP s.prodPrimes_squarefree · exact _root_.ne_of_gt <| s.selbergBoundingSum_pos dsimp only [selbergWeights]; rw [if_pos hdP] ring /- Original line 12037: SelbergSieve.selberg_bound_weights -/ theorem selberg_bound_weights : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus ∀ (d : ℕ), |(SelbergSieve.selbergWeights s) d| ≤ 1 := by intro d letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact by by_cases hdP : d ∣ (BoundingSieve.prodPrimes (self := SelbergSieve.toBoundingSieve (self := s))) swap · rw [s.selbergWeights_eq_zero_of_not_dvd hdP]; simp only [zero_le_one, abs_zero] have : 1*(SelbergSieve.selbergBoundingSum s) ≥ (SelbergSieve.selbergWeights s) d * ↑(μ d) * (SelbergSieve.selbergBoundingSum s) := by rw[one_mul] exact s.selbergBoundingSum_ge hdP replace this : (SelbergSieve.selbergWeights s) d * μ d ≤ 1 := by apply le_of_mul_le_mul_of_pos_right this (s.selbergBoundingSum_pos) convert this using 1 rw [← abs_of_nonneg <| s.selbergWeights_mul_mu_nonneg d hdP, abs_mul, ←Int.cast_abs, abs_moebius_eq_one_of_squarefree <| (s.prodPrimes_squarefree.squarefree_of_dvd hdP), Int.cast_one, mul_one] /- Original line 12052: SelbergSieve.selberg_bound_muPlus -/ theorem selberg_bound_muPlus : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus ∀ (n : ℕ) (hn : n ∈ divisors (BoundingSieve.prodPrimes (self := SelbergSieve.toBoundingSieve (self := s)))), |(SelbergSieve.selbergMuPlus s) n| ≤ (3:ℝ) ^ ω n := by intro n hn letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact by let f : ℕ → ℕ → ℝ := fun x z : ℕ => if n = x.lcm z then 1 else 0 dsimp only [selbergMuPlus, lambdaSquared] calc |∑ d1 ∈ n.divisors, ∑ d2 ∈ n.divisors, if n = d1.lcm d2 then (SelbergSieve.selbergWeights s) d1 * (SelbergSieve.selbergWeights s) d2 else 0| ≤ ∑ d1 ∈ n.divisors, |∑ d2 ∈ n.divisors, if n = d1.lcm d2 then (SelbergSieve.selbergWeights s) d1 * (SelbergSieve.selbergWeights s) d2 else 0| := ?_ _ ≤ ∑ d1 ∈ n.divisors, ∑ d2 ∈ n.divisors, |if n = d1.lcm d2 then (SelbergSieve.selbergWeights s) d1 * (SelbergSieve.selbergWeights s) d2 else 0| := ?_ _ ≤ ∑ d1 ∈ n.divisors, ∑ d2 ∈ n.divisors, f d1 d2 := ?_ _ = (n.divisors ×ˢ n.divisors).sum fun p => f p.fst p.snd := ?_ _ = Finset.card ((n.divisors ×ˢ n.divisors).filter fun p : ℕ × ℕ => n = p.fst.lcm p.snd) := ?_ _ = (3:ℕ) ^ ω n := ?_ _ = (3:ℝ) ^ ω n := ?_ · apply abs_sum_le_sum_abs · gcongr; apply abs_sum_le_sum_abs · gcongr with d1 _ d2 rw [apply_ite abs, abs_zero, abs_mul] simp only [f] by_cases h : n = d1.lcm d2 · rw [if_pos h, if_pos h] apply mul_le_one₀ (s.selberg_bound_weights d1) (abs_nonneg <| (SelbergSieve.selbergWeights s) d2) (s.selberg_bound_weights d2) rw [if_neg h, if_neg h] · rw [← Finset.sum_product'] · rw [← sum_filter, Finset.sum_const, smul_one_eq_cast] · norm_cast simp [← card_pair_lcm_eq (squarefree_of_mem_divisors_prodPrimes hn), eq_comm] norm_num /- Original line 12081: SelbergSieve.selberg_bound_simple_errSum -/ theorem selberg_bound_simple_errSum : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus errSum (s := s.toBoundingSieve) (SelbergSieve.selbergMuPlus s) ≤ ∑ d ∈ divisors (BoundingSieve.prodPrimes (self := SelbergSieve.toBoundingSieve (self := s))), if (d : ℝ) ≤ (SelbergSieve.level (self := s)) then (3:ℝ) ^ ω d * |(BoundingSieve.rem (s := SelbergSieve.toBoundingSieve (self := s))) d| else 0 := by letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact by dsimp only [errSum] gcongr with d hd split_ifs with h · apply mul_le_mul _ le_rfl (abs_nonneg <| (BoundingSieve.rem (s := SelbergSieve.toBoundingSieve (self := s))) d) (pow_nonneg _ <| ω d) · apply s.selberg_bound_muPlus d hd · norm_num · rw [s.selbergμPlus_eq_zero d h, abs_zero, zero_mul] /- Original line 12092: SelbergSieve.selberg_bound_simple -/ theorem selberg_bound_simple : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus siftedSum (s := s.toBoundingSieve) ≤ (BoundingSieve.totalMass (self := SelbergSieve.toBoundingSieve (self := s))) / (SelbergSieve.selbergBoundingSum s) + ∑ d ∈ divisors (BoundingSieve.prodPrimes (self := SelbergSieve.toBoundingSieve (self := s))), if (d : ℝ) ≤ (SelbergSieve.level (self := s)) then (3:ℝ) ^ ω d * |(BoundingSieve.rem (s := SelbergSieve.toBoundingSieve (self := s))) d| else 0 := by letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact by let μPlus := s.selbergUbSieve calc siftedSum ≤ (BoundingSieve.totalMass (self := SelbergSieve.toBoundingSieve (self := s))) * mainSum μPlus + errSum μPlus := siftedSum_le_mainSum_errSum_of_UpperBoundSieve _ μPlus _ ≤ _ := ?_ gcongr · erw [s.selberg_bound_simple_mainSum, div_eq_mul_inv] · apply s.selberg_bound_simple_errSum end SelbergSieve end end SelbergSource_2 /- Source module: Sieve/SelbergBounds -/ section SelbergSource_3 /- Copyright (c) 2023 Arend Mellendijk. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Author: Arend Mellendijk -/ /- # Bounds for the Selberg sieve This file proves a number of results to help bound `Sieve.selbergSum` ## Main Results * `selbergBoundingSum_ge_sum_div`: If `ν` is completely multiplicative then `S ≥ ∑_{n ≤ √y}, ν n` * `boundingSum_ge_log`: If `ν n = 1 / n` then `S ≥ log y / 2` * `rem_sum_le_of_const`: If `R_d ≤ C` then the error term is at most `C * y * (1 + log y)^3` -/ open scoped Nat ArithmeticFunction BigOperators Classical ArithmeticFunction.zeta ArithmeticFunction.omega open BoundingSieve SelbergSieve noncomputable section namespace Sieve /- Original line 12137: Sieve.prodDistinctPrimes_squarefree -/ theorem prodDistinctPrimes_squarefree : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus ∀ (s : Finset ℕ) (h : ∀ p ∈ s, p.Prime), Squarefree (∏ p ∈ s, p) := by intro s h letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact by refine Iff.mpr Nat.squarefree_iff_prime_squarefree ?_ intro p hp; by_contra h_dvd by_cases hps : p ∈ s · rw [←Finset.mul_prod_erase (a:=p) (h := hps), mul_dvd_mul_iff_left (Nat.Prime.ne_zero hp)] at h_dvd obtain ⟨q, hq⟩ := hp.prime.exists_mem_finset_dvd h_dvd rw [Finset.mem_erase] at hq exact hq.1.1 <| symm <| (Nat.prime_dvd_prime_iff_eq hp (h q hq.1.2)).mp hq.2 · have : p ∣ ∏ p ∈ s, p := Trans.trans (dvd_mul_right p p) h_dvd obtain ⟨q, hq⟩ := hp.prime.exists_mem_finset_dvd this have heq : p = q := by rw [←Nat.prime_dvd_prime_iff_eq hp (h q hq.1)] exact hq.2 rw [heq] at hps; exact hps hq.1 /- Original line 12154: Sieve.primorial_squarefree -/ theorem primorial_squarefree : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus ∀ (n : ℕ), Squarefree (primorial n) := by intro n letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact by apply prodDistinctPrimes_squarefree simp_rw [Finset.mem_filter]; exact fun _ h => h.2 /- Original line 12159: Sieve.zeta_pos_of_prime -/ theorem zeta_pos_of_prime : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus ∀ (p : ℕ), Nat.Prime p → (0:ℝ) < (↑ζ:ArithmeticFunction ℝ) p := by letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact by intro p hp rw [ArithmeticFunction.natCoe_apply, ArithmeticFunction.zeta_apply, if_neg (Nat.Prime.ne_zero hp)] norm_num /- Original line 12164: Sieve.zeta_lt_self_of_prime -/ theorem zeta_lt_self_of_prime : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus ∀ (p : ℕ), Nat.Prime p → (↑ζ:ArithmeticFunction ℝ) p < (p:ℝ) := by letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact by intro p hp rw [ArithmeticFunction.natCoe_apply, ArithmeticFunction.zeta_apply, if_neg (Nat.Prime.ne_zero hp)] norm_num; exact Nat.succ_le_iff.mp (Nat.Prime.two_le hp) /- Original line 12170: Sieve.prime_dvd_primorial_iff -/ theorem prime_dvd_primorial_iff : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus ∀ (n p : ℕ) (hp : p.Prime), p ∣ primorial n ↔ p ≤ n := by intro n p hp letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact by unfold primorial constructor · intro h obtain ⟨q, hq⟩ : ∃ idx, idx ∈ Finset.filter Nat.Prime (Finset.range (n + 1)) ∧ p ∣ idx := hp.prime.exists_mem_finset_dvd h rw [Finset.mem_filter, Finset.mem_range] at hq rw [prime_dvd_prime_iff_eq (Nat.Prime.prime hp) (Nat.Prime.prime hq.1.2)] at hq rw [hq.2] exact Nat.lt_succ_iff.mp hq.1.1 · intro h apply Finset.dvd_prod_of_mem rw [Finset.mem_filter, Finset.mem_range] exact ⟨Nat.lt_succ_iff.mpr h, hp⟩ /- Original line 12186: Sieve.siftedSum_eq -/ theorem siftedSum_eq : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus ∀ (s : SelbergSieve) (hw : ∀ idx ∈ s.support, s.weights idx = 1) (z : ℝ) (hz : 1 ≤ z) (hP : s.prodPrimes = primorial (Nat.floor z)), siftedSum (s := s.toBoundingSieve) = (s.support.filter (fun d => ∀ p:ℕ, p.Prime → p ≤ z → ¬p ∣ d)).card := by intro s hw z hz hP letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact by dsimp only [siftedSum] rw [Finset.card_eq_sum_ones, ←Finset.sum_filter, Nat.cast_sum] apply Finset.sum_congr · rw [hP] ext d; constructor · intro hd rw [Finset.mem_filter] at * constructor · exact hd.1 · intro p hpp hpy rw [←Nat.Prime.coprime_iff_not_dvd hpp] apply Nat.Coprime.coprime_dvd_left _ hd.2 rw [prime_dvd_primorial_iff _ _ hpp] apply Nat.le_floor hpy · intro h rw [Finset.mem_filter] at * constructor · exact h.1 refine Nat.coprime_of_dvd ?_ intro p hp erw [prime_dvd_primorial_iff _ _ hp] intro hpy apply h.2 p hp trans ↑(Nat.floor z) · norm_cast · apply Nat.floor_le linarith only [hz] simp_rw [Nat.cast_one] intro x hx simp only [Finset.mem_filter] at hx apply hw x hx.1 /- Original line 12222: Sieve.CompletelyMultiplicative -/ noncomputable def CompletelyMultiplicative : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus ∀ (f : ArithmeticFunction ℝ), Prop := by intro f letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact f 1 = 1 ∧ ∀ a b, f (a*b) = f a * f b namespace CompletelyMultiplicative open ArithmeticFunction /- Original line 12227: Sieve.CompletelyMultiplicative.zeta -/ theorem zeta : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus CompletelyMultiplicative ζ := by letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact by unfold CompletelyMultiplicative simp_rw [ArithmeticFunction.natCoe_apply, ArithmeticFunction.zeta_apply, one_ne_zero, ite_false, mul_eq_zero, Nat.cast_ite, Nat.cast_one, CharP.cast_eq_zero, mul_ite, mul_zero, mul_one, true_and, ← ite_or, or_comm, implies_true] /- Original line 12233: Sieve.CompletelyMultiplicative.id -/ theorem id : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus CompletelyMultiplicative ArithmeticFunction.id := by letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact by constructor <;> simp /- Original line 12236: Sieve.CompletelyMultiplicative.pmul -/ theorem pmul : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus ∀ (f g : ArithmeticFunction ℝ) (hf : CompletelyMultiplicative f) (hg : CompletelyMultiplicative g), CompletelyMultiplicative (ArithmeticFunction.pmul f g) := by intro f g hf hg letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact by constructor · rw [pmul_apply, hf.1, hg.1, mul_one] intro a b simp_rw [pmul_apply, hf.2, hg.2]; ring /- Original line 12244: Sieve.CompletelyMultiplicative.pdiv -/ theorem pdiv : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus ∀ {f g : ArithmeticFunction ℝ} (hf : CompletelyMultiplicative f) (hg : CompletelyMultiplicative g), CompletelyMultiplicative (ArithmeticFunction.pdiv f g) := by intro f g hf hg letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact by constructor · rw [pdiv_apply, hf.1, hg.1, div_one] intro a b simp_rw [pdiv_apply, hf.2, hg.2]; ring /- Original line 12252: Sieve.CompletelyMultiplicative.isMultiplicative -/ theorem isMultiplicative : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus ∀ {f : ArithmeticFunction ℝ} (hf : CompletelyMultiplicative f), ArithmeticFunction.IsMultiplicative f := by intro f hf letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact ⟨hf.1, fun _ => hf.2 _ _⟩ /- Original line 12256: Sieve.CompletelyMultiplicative.apply_pow -/ theorem apply_pow : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus ∀ (f : ArithmeticFunction ℝ) (hf : CompletelyMultiplicative f) (a n : ℕ), f (a^n) = f a ^ n := by intro f hf a n letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact by induction n with | zero => simp_rw [pow_zero, hf.1] | succ n' ih => simp_rw [pow_succ, hf.2, ih] end CompletelyMultiplicative /- Original line 12264: Sieve.prod_factors_one_div_compMult_ge -/ theorem prod_factors_one_div_compMult_ge : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus ∀ (M : ℕ) (f : ArithmeticFunction ℝ) (hf : CompletelyMultiplicative f) (hf_nonneg : ∀ n, 0 ≤ f n) (d : ℕ) (hd : Squarefree d) (hf_size : ∀ n, n.Prime → n ∣ d → f n < 1), f d * ∏ p ∈ d.primeFactors, 1 / (1 - f p) ≥ ∏ p ∈ d.primeFactors, ∑ n ∈ Finset.Icc 1 M, f (p^n) := by intro M f hf hf_nonneg d hd hf_size letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact by calc f d * ∏ p ∈ d.primeFactors, 1 / (1 - f p) = ∏ p ∈ d.primeFactors, f p / (1 - f p) := by conv => { lhs; congr; rw [←Nat.prod_primeFactors_of_squarefree hd] } rw [hf.isMultiplicative.map_prod_of_subset_primeFactors _ _ subset_rfl, ←Finset.prod_mul_distrib] simp_rw[one_div, div_eq_mul_inv] _ ≥ ∏ p ∈ d.primeFactors, ∑ n ∈ Finset.Icc 1 M, (f p)^n := by gcongr with p hp · exact fun p _ => Finset.sum_nonneg fun n _ => pow_nonneg (hf_nonneg p) n rw [Nat.mem_primeFactors_of_ne_zero hd.ne_zero] at hp rw [← Finset.Ico_add_one_right_eq_Icc, geom_sum_Ico, ← mul_div_mul_left (c := (-1 : ℝ)) (f p ^ (M + 1) - f p ^ 1)] · gcongr · apply hf_nonneg · linarith [hf_size p hp.1 hp.2] · rw [pow_one] have : 0 ≤ f p ^ (M + 1) := by apply pow_nonneg apply hf_nonneg linarith only [this] · linarith only · norm_num · apply ne_of_lt <| hf_size p hp.1 hp.2 · apply Nat.succ_le_iff.mpr (Nat.succ_pos _) _ = ∏ p ∈ d.primeFactors, ∑ n ∈ Finset.Icc 1 M, f (p^n) := by simp_rw [hf.apply_pow] /- Original line 12297: Sieve.prod_factors_sum_pow_compMult -/ theorem prod_factors_sum_pow_compMult : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus ∀ (M : ℕ) (hM : M ≠ 0) (f : ArithmeticFunction ℝ) (hf : CompletelyMultiplicative f) (d : ℕ) (hd : Squarefree d), ∏ p ∈ d.primeFactors, ∑ n ∈ Finset.Icc 1 M, f (p^n) = ∑ m ∈ (d^M).divisors.filter (d ∣ ·), f m := by intro M hM f hf d hd letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact by rw [Finset.prod_sum] let idx : (a:_) → (ha : a ∈ Finset.pi d.primeFactors fun p => Finset.Icc 1 M) → ℕ := fun a _ => ∏ p ∈ d.primeFactors.attach, p.1 ^ (a p p.2) have hfact_i : ∀ a ha, ∀ p , Nat.factorization (idx a ha) p = if hp : p ∈ d.primeFactors then a p hp else 0 := by intro a ha p by_cases hp : p ∈ d.primeFactors · rw [dif_pos hp, Nat.factorization_prod, Finset.sum_apply', Finset.sum_eq_single ⟨p, hp⟩, Nat.factorization_pow, Finsupp.smul_apply, Nat.Prime.factorization_self (Nat.prime_of_mem_primeFactorsList <| List.mem_toFinset.mp hp)] · ring · intro q _ hq rw [Nat.factorization_pow, Finsupp.smul_apply, smul_eq_zero]; right apply Nat.factorization_eq_zero_of_not_dvd rw [Nat.Prime.dvd_iff_eq, ← exists_eq_subtype_mk_iff] · push Not exact fun _ => hq · exact Nat.prime_of_mem_primeFactorsList <| List.mem_toFinset.mp q.2 · exact (Nat.prime_of_mem_primeFactorsList <| List.mem_toFinset.mp hp).ne_one · intro h exfalso exact h (Finset.mem_attach _ _) · exact fun q _ => pow_ne_zero _ (ne_of_gt (Nat.pos_of_mem_primeFactorsList (List.mem_toFinset.mp q.2))) · rw [dif_neg hp] by_cases hpp : p.Prime swap · apply Nat.factorization_eq_zero_of_not_prime _ hpp apply Nat.factorization_eq_zero_of_not_dvd intro hp_dvd obtain ⟨⟨q, hq⟩, _, hp_dvd_pow⟩ := Prime.exists_mem_finset_dvd hpp.prime hp_dvd apply hp rw [Nat.mem_primeFactors] constructor · exact hpp refine ⟨?_, hd.ne_zero⟩ trans q · apply Nat.Prime.dvd_of_dvd_pow hpp hp_dvd_pow · apply Nat.dvd_of_mem_primeFactorsList <| List.mem_toFinset.mp hq have hi_ne_zero : ∀ (a : _) (ha : a ∈ Finset.pi d.primeFactors fun _p => Finset.Icc 1 M), idx a ha ≠ 0 := by intro a ha erw [Finset.prod_ne_zero_iff] exact fun p _ => pow_ne_zero _ (ne_of_gt (Nat.pos_of_mem_primeFactorsList (List.mem_toFinset.mp p.property))) have hi : ∀ (a : _) (ha : a ∈ Finset.pi d.primeFactors fun _p => Finset.Icc 1 M), idx a ha ∈ (d^M).divisors.filter (d ∣ ·) := by intro a ha rw [Finset.mem_filter, Nat.mem_divisors, ←Nat.factorization_le_iff_dvd hd.ne_zero (hi_ne_zero a ha),← Nat.factorization_le_iff_dvd (hi_ne_zero a ha) (pow_ne_zero _ hd.ne_zero)] constructor; constructor · rw [Finsupp.le_iff]; intro p _ rw [hfact_i a ha] by_cases hp : p ∈ d.primeFactors · rw [dif_pos hp] rw [Nat.factorization_pow, Finsupp.smul_apply] simp_rw [Finset.mem_pi, Finset.mem_Icc] at ha trans (M • 1) · norm_num exact (ha p hp).2 · gcongr rw [Nat.mem_primeFactors_of_ne_zero hd.ne_zero] at hp rw [←Nat.Prime.dvd_iff_one_le_factorization hp.1 hd.ne_zero] exact hp.2 · rw [dif_neg hp]; norm_num · apply pow_ne_zero _ hd.ne_zero · rw [Finsupp.le_iff]; intro p hp rw [Nat.support_factorization] at hp rw [hfact_i a ha] rw [dif_pos hp] trans 1 · exact hd.natFactorization_le_one p simp_rw [Finset.mem_pi, Finset.mem_Icc] at ha exact (ha p hp).1 have h : ∀ (a : _) (ha : a ∈ Finset.pi d.primeFactors fun _p => Finset.Icc 1 M), ∏ p ∈ d.primeFactors.attach, f (p.1 ^ (a p p.2)) = f (idx a ha) := by intro a ha apply symm apply hf.isMultiplicative.map_prod intro x _ y _ hxy simp_rw [Finset.mem_pi, Finset.mem_Icc, Nat.succ_le_iff] at ha apply (Nat.coprime_pow_left_iff (ha x x.2).1 ..).mpr apply (Nat.coprime_pow_right_iff (ha y y.2).1 ..).mpr have hxp := Nat.prime_of_mem_primeFactorsList (List.mem_toFinset.mp x.2) rw [Nat.Prime.coprime_iff_not_dvd hxp] rw [Nat.prime_dvd_prime_iff_eq hxp <| Nat.prime_of_mem_primeFactorsList (List.mem_toFinset.mp y.2)] exact fun hc => hxy (Subtype.ext hc) have i_inj : ∀ a ha b hb, idx a ha = idx b hb → a = b := by intro a ha b hb hiab apply_fun Nat.factorization at hiab ext p hp obtain hiabp := DFunLike.ext_iff.mp hiab p rw [hfact_i a ha, hfact_i b hb, dif_pos hp, dif_pos hp] at hiabp exact hiabp have i_surj : ∀ (b : ℕ), b ∈ (d^M).divisors.filter (d ∣ ·) → ∃ a ha, idx a ha = b := by intro b hb have h : (fun p _ => b.factorization p) ∈ Finset.pi d.primeFactors fun p => Finset.Icc 1 M := by rw [Finset.mem_pi]; intro p hp rw [Finset.mem_Icc] rw [Finset.mem_filter] at hb have hb_ne_zero : b ≠ 0 := ne_of_gt <| Nat.pos_of_mem_divisors hb.1 have hpp : p.Prime := Nat.prime_of_mem_primeFactors hp constructor · rw [←Nat.Prime.dvd_iff_one_le_factorization hpp hb_ne_zero] · exact Trans.trans (Nat.dvd_of_mem_primeFactors hp) hb.2 · rw [Nat.mem_divisors] at hb trans Nat.factorization (d^M) p · exact (Nat.factorization_le_iff_dvd hb_ne_zero hb.left.right).mpr hb.left.left p rw [Nat.factorization_pow, Finsupp.smul_apply, smul_eq_mul] have : d.factorization p ≤ 1 := by apply hd.natFactorization_le_one exact (mul_le_iff_le_one_right (Nat.pos_of_ne_zero hM)).mpr this use (fun p _ => Nat.factorization b p) use h apply Nat.eq_of_factorization_eq · apply hi_ne_zero _ h · exact ne_of_gt <| Nat.pos_of_mem_divisors (Finset.mem_filter.mp hb).1 intro p rw [hfact_i (fun p _ => (Nat.factorization b) p) h p] rw [Finset.mem_filter, Nat.mem_divisors] at hb by_cases hp : p ∈ d.primeFactors · rw [dif_pos hp] · rw [dif_neg hp, eq_comm, Nat.factorization_eq_zero_iff, ←or_assoc] rw [Nat.mem_primeFactors] at hp left push Not at hp by_cases hpp : p.Prime · right; intro h apply absurd (hp hpp) push Not exact ⟨hpp.dvd_of_dvd_pow (h.trans hb.1.1), hd.ne_zero⟩ · left; exact hpp exact Finset.sum_bij idx hi i_inj i_surj h /- Original line 12441: Sieve.prod_primes_dvd_of_dvd -/ theorem prod_primes_dvd_of_dvd : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus ∀ (P : ℕ) {s : Finset ℕ} (h : ∀ p ∈ s, p ∣ P) (h' : ∀ p ∈ s, p.Prime), ∏ p ∈ s, p ∣ P := by intro P s h h' letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact by simp_rw [Nat.prime_iff] at h' apply Finset.prod_primes_dvd _ h' h /- Original line 12446: Sieve.sqrt_le_self -/ theorem sqrt_le_self : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus ∀ (x : ℝ) (hx : 1 ≤ x), Real.sqrt x ≤ x := by intro x hx letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact by refine Iff.mpr Real.sqrt_le_iff ?_ constructor · linarith refine le_self_pow₀ hx ?right.h norm_num /- Original line 12453: Sieve.Nat.squarefree_dvd_pow -/ theorem Nat.squarefree_dvd_pow : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus ∀ (a b N : ℕ) (ha : Squarefree a) (hab : a ∣ b ^ N), a ∣ b := by intro a b N ha hab letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact by by_cases hN : N=0 · rw [hN, pow_zero, Nat.dvd_one] at hab rw [hab]; simp rw [Squarefree.dvd_pow_iff_dvd ha hN] at hab exact hab /- Proposed generalisation : theorem selbergBoundingSum_ge_sum_div (s : SelbergSieve) (hnu : CompletelyMultiplicative s.nuDivSelf) (hnu_nonneg : ∀ n, 0 ≤ s.nuDivSelf n) (hnu_lt : ∀ p, p.Prime → p ∣ s.prodPrimes → s.nuDivSelf p < 1): s.selbergBoundingSum ≥ ∑ m in (Finset.Icc 1 (Nat.floor <| Real.sqrt s.level)).filter (fun m => ∀ p, p.Prime → p ∣ m → p ∣ s.prodPrimes), s.nu m -/ /- Original line 12471: Sieve.selbergBoundingSum_ge_sum_div -/ theorem selbergBoundingSum_ge_sum_div : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus ∀ (s : SelbergSieve) (hP : ∀ p:ℕ, p.Prime → (p:ℝ) ≤ s.level → p ∣ s.prodPrimes) (hnu : CompletelyMultiplicative s.nu) (hnu_nonneg : ∀ n, 0 ≤ s.nu n) (hnu_lt : ∀ p, p.Prime → p ∣ s.prodPrimes → s.nu p < 1), s.selbergBoundingSum ≥ ∑ m ∈ Finset.Icc 1 (Nat.floor <| Real.sqrt s.level), s.nu m := by intro s hP hnu hnu_nonneg hnu_lt letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact by unfold selbergBoundingSum calc ∑ l ∈ s.prodPrimes.divisors, (if l ^ 2 ≤ s.level then selbergTerms _ l else 0) ≥ ∑ l ∈ s.prodPrimes.divisors.filter (fun (l:ℕ) => l^2 ≤ s.level), ∑ m ∈ (l^(Nat.floor s.level)).divisors.filter (l ∣ ·), s.nu m := ?_ _ ≥ ∑ m ∈ Finset.Icc 1 (Nat.floor <| Real.sqrt s.level), s.nu m := ?_ · rw [←Finset.sum_filter]; apply Finset.sum_le_sum; intro l hl rw [Finset.mem_filter, Nat.mem_divisors] at hl have hlsq : Squarefree l := Squarefree.squarefree_of_dvd hl.1.1 s.prodPrimes_squarefree trans (∏ p ∈ l.primeFactors, ∑ n ∈ Finset.Icc 1 (Nat.floor s.level), s.nu (p^n)) · rw [prod_factors_sum_pow_compMult (Nat.floor s.level) _ s.nu] · exact hnu · exact hlsq · rw [ne_eq, Nat.floor_eq_zero, not_lt] exact s.one_le_level rw [selbergTerms_apply _ l] apply prod_factors_one_div_compMult_ge _ _ hnu _ _ hlsq · intro p hpp hpl apply hnu_lt p hpp (Trans.trans hpl hl.1.1) · exact hnu_nonneg rw [←Finset.sum_biUnion] · apply Finset.sum_le_sum_of_subset_of_nonneg ?_ (fun _ _ _ => hnu_nonneg _) intro m hm have hprod_pos : 0 < (∏ p ∈ m.primeFactors, p) := by apply Finset.prod_pos; intro p hp; exact Nat.pos_of_mem_primeFactorsList <| List.mem_toFinset.mp hp have hprod_ne_zero : (∏ p ∈ m.primeFactors, p) ^ ⌊s.level⌋₊ ≠ 0 := by apply pow_ne_zero; apply ne_of_gt; apply hprod_pos rw [Finset.mem_biUnion]; simp_rw [Finset.mem_filter, Nat.mem_divisors] rw [Finset.mem_Icc, Nat.le_floor_iff] at hm · have hm_ne_zero : m ≠ 0 := by exact ne_of_gt <| Nat.succ_le_iff.mp hm.1 use ∏ p ∈ m.primeFactors, p constructor; constructor; constructor · apply prod_primes_dvd_of_dvd <;> intro p hp · apply hP p <| Nat.prime_of_mem_primeFactors hp trans (m:ℝ) · exact_mod_cast Nat.le_of_mem_primeFactors hp trans (Real.sqrt s.level) · exact hm.2 apply sqrt_le_self s.level s.one_le_level exact Nat.prime_of_mem_primeFactors hp · exact prodPrimes_ne_zero · rw [←Real.sqrt_le_sqrt_iff (by linarith only [s.one_le_level]), Real.sqrt_sq] · trans (m:ℝ) · norm_cast; apply Nat.le_of_dvd (Nat.succ_le_iff.mp hm.1) exact Nat.prod_primeFactors_dvd m exact hm.2 apply le_of_lt; norm_cast constructor; constructor · rw [←Nat.factorization_le_iff_dvd _ hprod_ne_zero, Nat.factorization_pow] · intro p have hy_mul_prod_nonneg : 0 ≤ ⌊s.level⌋₊ * (Nat.factorization (∏ p ∈ m.primeFactors, p)) p := by apply mul_nonneg · apply Nat.le_floor; norm_cast; linarith only [s.one_le_level] · norm_num trans (Nat.factorization m) p * 1 · rw [mul_one] rw [Finsupp.smul_apply, smul_eq_mul] by_cases hpp : p.Prime swap · rw [Nat.factorization_eq_zero_of_not_prime _ hpp, zero_mul]; exact hy_mul_prod_nonneg by_cases hpdvd : p ∣ m swap · rw [Nat.factorization_eq_zero_of_not_dvd hpdvd, zero_mul]; exact hy_mul_prod_nonneg apply mul_le_mul · trans m · apply le_of_lt <| Nat.factorization_lt _ _ apply hm_ne_zero apply Nat.le_floor refine le_trans hm.2 ?_ apply sqrt_le_self _ s.one_le_level · rw [←Nat.Prime.pow_dvd_iff_le_factorization hpp <| ne_of_gt hprod_pos, pow_one] apply Finset.dvd_prod_of_mem rw [Nat.mem_primeFactors] exact ⟨hpp, hpdvd, hm_ne_zero⟩ · norm_num · norm_num exact hm_ne_zero · exact hprod_ne_zero · exact Nat.prod_primeFactors_dvd m · apply Real.sqrt_nonneg · intro idx hi j hj hij t hti htj x hx simp only [Finset.bot_eq_empty, Finset.notMem_empty] specialize hti hx specialize htj hx simp_rw [Finset.mem_coe, Finset.mem_filter, Nat.mem_divisors] at * have h : ∀ idx j {n}, idx ∣ s.prodPrimes → idx ∣ x → x ∣ j ^ n → idx ∣ j := by intro idx j n hiP hix hij apply Nat.squarefree_dvd_pow idx j n (squarefree_of_dvd_prodPrimes hiP) exact Trans.trans hix hij have hidvdj : idx ∣ j := by apply h idx j hi.1.1 hti.2 htj.1.1 have hjdvdi : j ∣ idx := by apply h j idx hj.1.1 htj.2 hti.1.1 exact hij <| Nat.dvd_antisymm hidvdj hjdvdi /- Original line 12571: Sieve.boundingSum_ge_sum -/ theorem boundingSum_ge_sum : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus ∀ (s : SelbergSieve) (hnu : s.nu = (ζ : ArithmeticFunction ℝ).pdiv .id) (hP : ∀ p:ℕ, p.Prime → (p:ℝ) ≤ s.level → p ∣ s.prodPrimes), s.selbergBoundingSum ≥ ∑ m ∈ Finset.Icc 1 (Nat.floor <| Real.sqrt s.level), 1 / (m:ℝ) := by intro s hnu hP letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact by trans ∑ m ∈ Finset.Icc 1 (Nat.floor <| Real.sqrt s.level), (ζ : ArithmeticFunction ℝ).pdiv .id m · rw[←hnu] apply selbergBoundingSum_ge_sum_div · intro p hpp hple apply hP p hpp hple · rw[hnu] exact CompletelyMultiplicative.zeta.pdiv CompletelyMultiplicative.id · intro n rw[hnu] apply div_nonneg · by_cases h : n = 0 <;> simp[SelbergSieve.selbergBoundingSum, h] simp[SelbergSieve.selbergBoundingSum] · intro p hpp _ rw[hnu] simp only [ArithmeticFunction.pdiv_apply, ArithmeticFunction.natCoe_apply, ArithmeticFunction.zeta_apply, Nat.cast_ite, CharP.cast_eq_zero, Nat.cast_one, ArithmeticFunction.id_apply] rw [if_neg, one_div] · apply inv_lt_one_of_one_lt₀; norm_cast exact hpp.one_lt exact hpp.ne_zero apply le_of_eq apply Finset.sum_congr rfl intro m hm rw [Finset.mem_Icc] at hm simp only [one_div, ArithmeticFunction.pdiv_apply, ArithmeticFunction.natCoe_apply, ArithmeticFunction.zeta_apply_ne (show m ≠ 0 by omega), Nat.cast_one, ArithmeticFunction.id_apply]; /- Original line 12603: Sieve.boundingSum_ge_log -/ theorem boundingSum_ge_log : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus ∀ (s : SelbergSieve) (hnu : s.nu = (ζ : ArithmeticFunction ℝ).pdiv .id) (hP : ∀ p:ℕ, p.Prime → (p:ℝ) ≤ s.level → p ∣ s.prodPrimes), s.selbergBoundingSum ≥ Real.log (s.level) / 2 := by intro s hnu hP letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact by trans (∑ m ∈ Finset.Icc 1 (Nat.floor <| Real.sqrt s.level), 1 / (m:ℝ)) · exact boundingSum_ge_sum s hnu hP trans (Real.log <| Real.sqrt s.level) · rw [ge_iff_le]; simp_rw[one_div] apply Aux.log_le_sum_inv (Real.sqrt s.level) rw [Real.le_sqrt] <;> linarith[s.one_le_level] · apply ge_of_eq refine Real.log_sqrt ?h.hx linarith[s.one_le_level] open ArithmeticFunction /- Original line 12618: Sieve.rem_sum_le_of_const -/ theorem rem_sum_le_of_const : letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus ∀ (s : SelbergSieve) (C : ℝ) (hrem : ∀ d > 0, |rem (s := s.toBoundingSieve) d| ≤ C), ∑ d ∈ s.prodPrimes.divisors, (if (d : ℝ) ≤ s.level then (3:ℝ) ^ ω d * |rem (s := s.toBoundingSieve) d| else 0) ≤ C * s.level * (1+Real.log s.level)^3 := by intro s C hrem letI := @_root_.SelbergSieve.ubToμPlus letI := @_root_.SelbergSieve.lbToμMinus exact by rw [←Finset.sum_filter] trans (∑ d ∈ Finset.filter (fun d:ℕ => ↑d ≤ s.level) (s.prodPrimes.divisors), 3 ^ ω d * C ) · gcongr with d hd rw [Finset.mem_filter, Nat.mem_divisors] at hd apply hrem d apply Nat.pos_of_ne_zero apply ne_zero_of_dvd_ne_zero hd.1.2 hd.1.1 rw [←Finset.sum_mul, mul_comm, mul_assoc] gcongr · linarith [abs_nonneg <| rem (s := s.toBoundingSieve) 1, hrem 1 (by norm_num)] rw [Finset.sum_filter] apply Aux.sum_pow_cardDistinctFactors_le_self_mul_log_pow (hx := s.one_le_level) apply prodPrimes_squarefree end Sieve end end SelbergSource_3 end SelbergDependencyPort open Filter Asymptotics open scoped BigOperators Classical Topology namespace Erdos416Proof /- Original line 12650: Erdos416Proof.natReciprocalHom -/ noncomputable def natReciprocalHom : ℕ →* ℝ where toFun n := (n : ℝ)⁻¹ map_one' := by simp map_mul' m n := by simp [mul_comm] /- Original line 12655: Erdos416Proof.hasSum_reciprocal_factored -/ theorem hasSum_reciprocal_factored (s : Finset ℕ) : HasSum (fun n : Nat.factoredNumbers s => ((n : ℕ) : ℝ)⁻¹) (∏ p ∈ s with p.Prime, (1 - (p : ℝ)⁻¹)⁻¹) := by have h := EulerProduct.summable_and_hasSum_factoredNumbers_prod_filter_prime_geometric (f := natReciprocalHom) (fun {p} hp => by change ‖(p : ℝ)⁻¹‖ < 1 rw [Real.norm_eq_abs, abs_of_nonneg (inv_nonneg.mpr (Nat.cast_nonneg p))] exact inv_lt_one_of_one_lt₀ (by exact_mod_cast hp.one_lt)) s exact h.2 /- Original line 12665: Erdos416Proof.hasSum_reciprocal_primeFactors -/ theorem hasSum_reciprocal_primeFactors {b : ℕ} (hb : 0 < b) : HasSum (fun n : Nat.factoredNumbers b.primeFactors => ((n : ℕ) : ℝ)⁻¹) ((b : ℝ) / b.totient) := by have h := hasSum_reciprocal_factored b.primeFactors rw [Finset.filter_eq_self.mpr (fun p hp => Nat.prime_of_mem_primeFactors hp)] at h rw [totient_ratio_eq_prod hb] convert h using 1 apply Finset.prod_congr rfl intro p hp simpa only [one_div] using totientFactor_eq_inv (Nat.prime_of_mem_primeFactors hp) /- Original line 12676: Erdos416Proof.finite_reciprocal_factored_bound -/ theorem finite_reciprocal_factored_bound {b : ℕ} (hb : 0 < b) (F : Finset ℕ) (hF : ∀ n ∈ F, n ∈ Nat.factoredNumbers b.primeFactors) : (∑ n ∈ F, (n : ℝ)⁻¹) ≤ (b : ℝ) / b.totient := by have h : HasSum ((Nat.factoredNumbers b.primeFactors).indicator (fun n : ℕ => (n : ℝ)⁻¹)) ((b : ℝ) / b.totient) := (hasSum_subtype_iff_indicator (f := fun n : ℕ => (n : ℝ)⁻¹)).mp (hasSum_reciprocal_primeFactors hb) have hs := sum_le_hasSum F (fun n _ => by by_cases hn : n ∈ Nat.factoredNumbers b.primeFactors · rw [Set.indicator_of_mem hn] positivity · rw [Set.indicator_of_notMem hn]) h calc _ = ∑ n ∈ F, (Nat.factoredNumbers b.primeFactors).indicator (fun k : ℕ => (k : ℝ)⁻¹) n := Finset.sum_congr rfl (fun n hn => (Set.indicator_of_mem (hF n hn) (fun k : ℕ => (k : ℝ)⁻¹)).symm) _ ≤ _ := hs /- Original line 12694: Erdos416Proof.primePart_coprime_complement -/ theorem primePart_coprime_complement (n b : ℕ) : (primePart n (fun p => ¬ p ∣ b)).Coprime b := by apply Nat.coprime_of_dvd intro p hp hpPart hpb have hmem : p ∈ (primePart n (fun q => ¬ q ∣ b)).primeFactorsList := (Nat.mem_primeFactorsList (primePart_pos n _).ne').mpr ⟨hp, hpPart⟩ exact ((mem_primeFactorsList_primePart n p _).mp hmem).2 hpb /- Original line 12702: Erdos416Proof.primePart_mem_factored_primeFactors -/ theorem primePart_mem_factored_primeFactors (n : ℕ) {b : ℕ} (hb : 0 < b) : primePart n (fun p => p ∣ b) ∈ Nat.factoredNumbers b.primeFactors := by refine ⟨(primePart_pos n _).ne', ?_⟩ intro p hp have hdata := (mem_primeFactorsList_primePart n p _).mp hp exact (Nat.mem_primeFactors_of_ne_zero hb.ne').mpr ⟨Nat.prime_of_mem_primeFactorsList hdata.1, hdata.2⟩ /-- Uniform harmonic mass left after imposing coprimality, even when the modulus is larger than the summation range. This supplies the arithmetic factor in the lower bound for a sieve with two linear forms. -/ /- Original line 12713: Erdos416Proof.reciprocal_coprime_sum_lower_bound -/ theorem reciprocal_coprime_sum_lower_bound (N : ℕ) {b : ℕ} (hb : 0 < b) : (b.totient : ℝ) / b * (∑ n ∈ Finset.Icc 1 N, (n : ℝ)⁻¹) ≤ ∑ n ∈ (Finset.Icc 1 N).filter (fun n => n.Coprime b), (n : ℝ)⁻¹ := by classical let F := Finset.Icc 1 N let U := F.filter (fun n => n ∈ Nat.factoredNumbers b.primeFactors) let B := F.filter (fun n => n.Coprime b) let f : ℕ → ℕ × ℕ := fun n => (primePart n (fun p => p ∣ b), primePart n (fun p => ¬ p ∣ b)) have hprod (n : ℕ) (hn : n ∈ F) : (f n).1 * (f n).2 = n := primePart_mul_compl (Nat.ne_of_gt (Finset.mem_Icc.mp hn).1) _ have hinj : Set.InjOn f (F : Set ℕ) := by intro n hn m hm heq have h := congrArg (fun v : ℕ × ℕ => v.1 * v.2) heq rwa [hprod n hn, hprod m hm] at h have hsub : F.image f ⊆ U.product B := by intro pair hpair obtain ⟨n, hn, rfl⟩ := Finset.mem_image.mp hpair have hnpos : 0 < n := (Finset.mem_Icc.mp hn).1 have hbound (P : ℕ → Prop) : primePart n P ∈ F := Finset.mem_Icc.mpr ⟨primePart_pos _ _, (Nat.le_of_dvd hnpos (primePart_dvd hnpos.ne' P)).trans (Finset.mem_Icc.mp hn).2⟩ exact Finset.mem_product.mpr ⟨Finset.mem_filter.mpr ⟨hbound _, primePart_mem_factored_primeFactors n hb⟩, Finset.mem_filter.mpr ⟨hbound _, primePart_coprime_complement n b⟩⟩ have hidentity (n : ℕ) (hn : n ∈ F) : (n : ℝ)⁻¹ = ((f n).1 : ℝ)⁻¹ * ((f n).2 : ℝ)⁻¹ := by have h := congrArg (fun a : ℕ => (a : ℝ)⁻¹) (hprod n hn) simpa only [Nat.cast_mul, mul_inv_rev, mul_comm] using h.symm have hupper : (∑ n ∈ F, (n : ℝ)⁻¹) ≤ ((b : ℝ) / b.totient) * (∑ n ∈ B, (n : ℝ)⁻¹) := by calc _ = ∑ n ∈ F, ((f n).1 : ℝ)⁻¹ * ((f n).2 : ℝ)⁻¹ := Finset.sum_congr rfl hidentity _ = ∑ v ∈ F.image f, (v.1 : ℝ)⁻¹ * (v.2 : ℝ)⁻¹ := (Finset.sum_image (f := fun v : ℕ × ℕ => (v.1 : ℝ)⁻¹ * (v.2 : ℝ)⁻¹) hinj).symm _ ≤ ∑ v ∈ U.product B, (v.1 : ℝ)⁻¹ * (v.2 : ℝ)⁻¹ := by apply Finset.sum_le_sum_of_subset_of_nonneg hsub intro v _ _ positivity _ = (∑ n ∈ U, (n : ℝ)⁻¹) * (∑ n ∈ B, (n : ℝ)⁻¹) := (Finset.sum_product U B (fun v : ℕ × ℕ => (v.1 : ℝ)⁻¹ * (v.2 : ℝ)⁻¹)).trans (Finset.sum_mul_sum U B (fun n : ℕ => (n : ℝ)⁻¹) (fun n : ℕ => (n : ℝ)⁻¹)).symm _ ≤ _ := mul_le_mul_of_nonneg_right (finite_reciprocal_factored_bound hb U (fun n hn => (Finset.mem_filter.mp hn).2)) (Finset.sum_nonneg fun _ _ => by positivity) have hbR : (0 : ℝ) < b := by exact_mod_cast hb have hφR : (0 : ℝ) < b.totient := by exact_mod_cast Nat.totient_pos.mpr hb have h := mul_le_mul_of_nonneg_left hupper (show 0 ≤ (b.totient : ℝ) / b by positivity) have heq : (b.totient : ℝ) / b * ((b : ℝ) / b.totient * (∑ n ∈ B, (n : ℝ)⁻¹)) = ∑ n ∈ B, (n : ℝ)⁻¹ := by field_simp exact h.trans_eq heq /- Original line 12765: Erdos416Proof.primePart_dvd_of_dvd -/ theorem primePart_dvd_of_dvd {m n : ℕ} (hn : n ≠ 0) (hmn : m ∣ n) (A : ℕ → Prop) : primePart m A ∣ primePart n A := by obtain ⟨a, rfl⟩ := hmn have hm : m ≠ 0 := (mul_ne_zero_iff.mp hn).1 have ha : a ≠ 0 := (mul_ne_zero_iff.mp hn).2 rw [primePart_mul hm ha] exact dvd_mul_right _ _ /- Original line 12773: Erdos416Proof.card_divisors_le_two_pow_cardFactors -/ theorem card_divisors_le_two_pow_cardFactors (n : ℕ) : n.divisors.card ≤ 2 ^ ArithmeticFunction.cardFactors n := by by_cases hn : n = 0 · simp [hn] rw [Nat.card_divisors hn, ArithmeticFunction.cardFactors_eq_sum_factorization] simp only [Finsupp.sum, Nat.support_factorization] rw [← Finset.prod_pow_eq_pow_sum] exact Finset.prod_le_prod (fun _ _ => Nat.zero_le _) fun p _ => Nat.succ_le_of_lt (Nat.lt_two_pow_self (n := n.factorization p)) /- Original line 12783: Erdos416Proof.coprime_divisors_card_bound -/ theorem coprime_divisors_card_bound (n b : ℕ) : (n.divisors.filter (fun d => d.Coprime b)).card ≤ 2 ^ ArithmeticFunction.cardFactors (primePart n (fun p => ¬ p ∣ b)) := by classical by_cases hn : n = 0 · simp [hn] have hsub : n.divisors.filter (fun d => d.Coprime b) ⊆ (primePart n (fun p => ¬ p ∣ b)).divisors := by intro d hd obtain ⟨hdn, hcop⟩ := Finset.mem_filter.mp hd have hdvd := Nat.dvd_of_mem_divisors hdn have hd0 := ne_zero_of_dvd_ne_zero hn hdvd have heq : primePart d (fun p => ¬ p ∣ b) = d := by apply primePart_eq_self hd0 intro p hp hpb have hprime := Nat.prime_of_mem_primeFactorsList hp have hpd := Nat.dvd_of_mem_primeFactorsList hp exact hprime.not_dvd_one (hcop ▸ Nat.dvd_gcd hpd hpb) apply Nat.mem_divisors.mpr refine ⟨?_, (primePart_pos n _).ne'⟩ rw [← heq] exact primePart_dvd_of_dvd hn hdvd _ exact (Finset.card_le_card hsub).trans (card_divisors_le_two_pow_cardFactors _) /-- A completely multiplicative extension of the local root density for the two forms t and b*t+1. Only its squarefree values enter the sieve. -/ /- Original line 12809: Erdos416Proof.twoFormDensity -/ noncomputable def twoFormDensity (b : ℕ) : ArithmeticFunction ℝ := ⟨fun n => (2 : ℝ) ^ ArithmeticFunction.cardFactors (primePart n (fun p => ¬ p ∣ b)) / n, by simp⟩ /- Original line 12813: Erdos416Proof.twoFormDensity_apply -/ theorem twoFormDensity_apply (b n : ℕ) : twoFormDensity b n = (2 : ℝ) ^ ArithmeticFunction.cardFactors (primePart n (fun p => ¬ p ∣ b)) / n := rfl /- Original line 12816: Erdos416Proof.twoFormDensity_one -/ theorem twoFormDensity_one (b : ℕ) : twoFormDensity b 1 = 1 := by simp [twoFormDensity_apply, primePart] /- Original line 12819: Erdos416Proof.twoFormDensity_mul -/ theorem twoFormDensity_mul (b m n : ℕ) : twoFormDensity b (m * n) = twoFormDensity b m * twoFormDensity b n := by by_cases hm : m = 0 · simp [Erdos416Proof.twoFormDensity_one, hm] by_cases hn : n = 0 · simp [Erdos416Proof.twoFormDensity_one, hn] simp only [twoFormDensity_apply, primePart_mul hm hn, ArithmeticFunction.cardFactors_mul (primePart_pos m _).ne' (primePart_pos n _).ne', pow_add, Nat.cast_mul] ring /- Original line 12830: Erdos416Proof.twoFormDensity_nonneg -/ theorem twoFormDensity_nonneg (b n : ℕ) : 0 ≤ twoFormDensity b n := by rw [twoFormDensity_apply] positivity /- Original line 12834: Erdos416Proof.twoFormDensity_pos -/ theorem twoFormDensity_pos (b : ℕ) {n : ℕ} (hn : 0 < n) : 0 < twoFormDensity b n := by rw [twoFormDensity_apply] positivity /- Original line 12838: Erdos416Proof.twoFormDensity_prime -/ theorem twoFormDensity_prime (b : ℕ) {p : ℕ} (hp : p.Prime) : twoFormDensity b p = if p ∣ b then 1 / (p : ℝ) else 2 / (p : ℝ) := by by_cases hpb : p ∣ b <;> simp [Erdos416Proof.twoFormDensity_one, twoFormDensity_apply, primePart, Nat.primeFactorsList_prime hp, hpb, hp] /- Original line 12843: Erdos416Proof.twoFormDensity_prime_lt_one -/ theorem twoFormDensity_prime_lt_one {b p : ℕ} (hb : 2 ∣ b) (hp : p.Prime) : twoFormDensity b p < 1 := by rw [twoFormDensity_prime b hp] have hpR : (0 : ℝ) < p := by exact_mod_cast hp.pos split_ifs with hpb · apply (div_lt_one hpR).mpr exact_mod_cast hp.one_lt · have hpne : p ≠ 2 := by intro heq; exact hpb (heq ▸ hb) have hp3 : 2 < p := by have := hp.two_le; omega exact (div_lt_one hpR).mpr (by exact_mod_cast hp3) /- Original line 12854: Erdos416Proof.coprime_divisors_reciprocal_le_density -/ theorem coprime_divisors_reciprocal_le_density (n b : ℕ) : ((n.divisors.filter (fun d => d.Coprime b)).card : ℝ) / n ≤ twoFormDensity b n := by rw [twoFormDensity_apply] apply div_le_div_of_nonneg_right _ (Nat.cast_nonneg n) exact_mod_cast coprime_divisors_card_bound n b /-- The completely multiplicative density contains enough divisor mass for a quadratic logarithmic lower bound in the two-form Selberg sieve. -/ /- Original line 12862: Erdos416Proof.twoFormDensity_sum_lower_bound -/ theorem twoFormDensity_sum_lower_bound (N : ℕ) {b : ℕ} (hb : 0 < b) : (b.totient : ℝ) / b * (∑ n ∈ Finset.Icc 1 N, (n : ℝ)⁻¹) ^ 2 ≤ ∑ n ∈ Finset.Icc 1 (N ^ 2), twoFormDensity b n := by classical let F := Finset.Icc 1 N let B := F.filter (fun n => n.Coprime b) let P := F.product B let Q : Finset (Σ _ : ℕ, ℕ) := (Finset.Icc 1 (N ^ 2)).sigma (fun n => n.divisors.filter (fun d => d.Coprime b)) let f : ℕ × ℕ → (Σ _ : ℕ, ℕ) := fun v => ⟨v.1 * v.2, v.2⟩ have hP (v : ℕ × ℕ) (hv : v ∈ P) : 0 < v.1 ∧ v.1 ≤ N ∧ 0 < v.2 ∧ v.2 ≤ N ∧ v.2.Coprime b := by obtain ⟨hv1, hvB⟩ := Finset.mem_product.mp hv obtain ⟨hv2, hcop⟩ := Finset.mem_filter.mp hvB exact ⟨(Finset.mem_Icc.mp hv1).1, (Finset.mem_Icc.mp hv1).2, (Finset.mem_Icc.mp hv2).1, (Finset.mem_Icc.mp hv2).2, hcop⟩ have hsub : P.image f ⊆ Q := by intro v hv obtain ⟨w, hw, rfl⟩ := Finset.mem_image.mp hv obtain ⟨hw1, hwN1, hw2, hwN2, hcop⟩ := hP w hw apply Finset.mem_sigma.mpr refine ⟨Finset.mem_Icc.mpr ⟨Nat.mul_pos hw1 hw2, ?_⟩, Finset.mem_filter.mpr ⟨Nat.mem_divisors.mpr ⟨dvd_mul_left _ _, (Nat.mul_pos hw1 hw2).ne'⟩, hcop⟩⟩ simpa only [pow_two] using Nat.mul_le_mul hwN1 hwN2 have hinj : Set.InjOn f (P : Set (ℕ × ℕ)) := by intro v hv w hw heq have hprod : v.1 * v.2 = w.1 * w.2 := congrArg Sigma.fst heq have hsecond : v.2 = w.2 := congrArg (fun x : Σ _ : ℕ, ℕ => x.2) heq have hfirst : v.1 = w.1 := by rw [hsecond] at hprod exact Nat.eq_of_mul_eq_mul_right (hP w hw).2.2.1 hprod exact Prod.ext hfirst hsecond have hmass : (∑ n ∈ F, (n : ℝ)⁻¹) * (∑ n ∈ B, (n : ℝ)⁻¹) ≤ ∑ n ∈ Finset.Icc 1 (N ^ 2), twoFormDensity b n := by calc _ = ∑ v ∈ P, ((v.1 * v.2 : ℕ) : ℝ)⁻¹ := by rw [Finset.sum_mul_sum] symm calc _ = ∑ n ∈ F, ∑ m ∈ B, ((n * m : ℕ) : ℝ)⁻¹ := Finset.sum_product F B (fun v : ℕ × ℕ => ((v.1 * v.2 : ℕ) : ℝ)⁻¹) _ = _ := by simp only [Nat.cast_mul, mul_inv_rev, mul_comm] _ = ∑ v ∈ P.image f, (v.1 : ℝ)⁻¹ := (Finset.sum_image (f := fun v : Σ _ : ℕ, ℕ => (v.1 : ℝ)⁻¹) hinj).symm _ ≤ ∑ v ∈ Q, (v.1 : ℝ)⁻¹ := by apply Finset.sum_le_sum_of_subset_of_nonneg hsub intro v _ _ positivity _ = ∑ n ∈ Finset.Icc 1 (N ^ 2), ((n.divisors.filter (fun d => d.Coprime b)).card : ℝ) / n := by calc _ = ∑ n ∈ Finset.Icc 1 (N ^ 2), ∑ d ∈ n.divisors.filter (fun d => d.Coprime b), (n : ℝ)⁻¹ := Finset.sum_sigma _ _ (fun v : Σ _ : ℕ, ℕ => (v.1 : ℝ)⁻¹) _ = _ := by simp only [Finset.sum_const, nsmul_eq_mul, div_eq_mul_inv] _ ≤ _ := Finset.sum_le_sum fun n _ => coprime_divisors_reciprocal_le_density n b have hHN : 0 ≤ ∑ n ∈ F, (n : ℝ)⁻¹ := Finset.sum_nonneg fun _ _ => by positivity have hcop := mul_le_mul_of_nonneg_left (reciprocal_coprime_sum_lower_bound N hb) hHN have hstart : (b.totient : ℝ) / b * (∑ n ∈ F, (n : ℝ)⁻¹) ^ 2 ≤ (∑ n ∈ F, (n : ℝ)⁻¹) * (∑ n ∈ B, (n : ℝ)⁻¹) := by calc _ = (∑ n ∈ F, (n : ℝ)⁻¹) * ((b.totient : ℝ) / b * (∑ n ∈ F, (n : ℝ)⁻¹)) := by ring _ ≤ _ := hcop exact hstart.trans hmass end Erdos416Proof open Filter Asymptotics open scoped BigOperators Classical Topology namespace Erdos416Proof /-- The quadratic logarithmic lower bound for a two-form Selberg sieve. The modulus factor is uniform, without requiring b to be below the level. -/ /- Original line 12938: Erdos416Proof.twoForm_selberg_boundingSum_lower -/ theorem twoForm_selberg_boundingSum_lower (s : SelbergSieve) {b : ℕ} (hb : 0 < b) (hbeven : 2 ∣ b) (hnu : s.nu = twoFormDensity b) (hP : ∀ p : ℕ, p.Prime → (p : ℝ) ≤ s.level → p ∣ s.prodPrimes) : (b.totient : ℝ) / b * Real.log s.level ^ 2 / 16 ≤ s.selbergBoundingSum := by let r := Real.sqrt (Real.sqrt s.level) let N := ⌊r⌋₊ have hy0 : 0 ≤ s.level := le_trans zero_le_one s.one_le_level have hroot1 : 1 ≤ r := by have h : (1 : ℝ) ≤ Real.sqrt s.level := Real.le_sqrt_of_sq_le (by simpa only [one_pow] using s.one_le_level) exact Real.le_sqrt_of_sq_le (by simpa only [one_pow] using h) have hN : N ^ 2 ≤ ⌊Real.sqrt s.level⌋₊ := by apply Nat.le_floor push_cast have hfloor : (N : ℝ) ≤ r := Nat.floor_le (Real.sqrt_nonneg _) have hsq : r ^ 2 = Real.sqrt s.level := Real.sq_sqrt (Real.sqrt_nonneg _) nlinarith [Nat.cast_nonneg (α := ℝ) N] have hcomplete : Sieve.CompletelyMultiplicative s.nu := by rw [hnu] exact ⟨twoFormDensity_one b, twoFormDensity_mul b⟩ have hstart := Sieve.selbergBoundingSum_ge_sum_div s hP hcomplete (fun n => by rw [hnu]; exact twoFormDensity_nonneg b n) (fun p hp _ => by rw [hnu]; exact twoFormDensity_prime_lt_one hbeven hp) rw [hnu] at hstart have hsum : (∑ n ∈ Finset.Icc 1 (N ^ 2), twoFormDensity b n) ≤ ∑ n ∈ Finset.Icc 1 ⌊Real.sqrt s.level⌋₊, twoFormDensity b n := by apply Finset.sum_le_sum_of_subset_of_nonneg (Finset.Icc_subset_Icc_right hN) intro n _ _ exact twoFormDensity_nonneg b n have hlog : Real.log s.level / 4 ≤ ∑ n ∈ Finset.Icc 1 N, (n : ℝ)⁻¹ := by have h := Aux.log_le_sum_inv r hroot1 have heq : Real.log r = Real.log s.level / 4 := by dsimp [Erdos416Proof.twoFormDensity_one, SelbergSieve.selbergBoundingSum, r] rw [Real.log_sqrt (Real.sqrt_nonneg _), Real.log_sqrt hy0] ring rw [heq] at h exact h have hlog0 : 0 ≤ Real.log s.level / 4 := div_nonneg (Real.log_nonneg s.one_le_level) (by norm_num) have hcoef : 0 ≤ (b.totient : ℝ) / b := by positivity calc _ = (b.totient : ℝ) / b * (Real.log s.level / 4) ^ 2 := by ring _ ≤ (b.totient : ℝ) / b * (∑ n ∈ Finset.Icc 1 N, (n : ℝ)⁻¹) ^ 2 := by gcongr _ ≤ ∑ n ∈ Finset.Icc 1 (N ^ 2), twoFormDensity b n := twoFormDensity_sum_lower_bound N hb _ ≤ s.selbergBoundingSum := hsum.trans hstart /- Original line 12985: Erdos416Proof.twoForm_selberg_error_bound -/ theorem twoForm_selberg_error_bound (s : SelbergSieve) (hrem : ∀ d ∈ s.prodPrimes.divisors, (d : ℝ) ≤ s.level → |BoundingSieve.rem (s := s.toBoundingSieve) d| ≤ (2 : ℝ) ^ ArithmeticFunction.cardDistinctFactors d) : (∑ d ∈ s.prodPrimes.divisors, if (d : ℝ) ≤ s.level then (3 : ℝ) ^ ArithmeticFunction.cardDistinctFactors d * |BoundingSieve.rem (s := s.toBoundingSieve) d| else 0) ≤ s.level * (1 + Real.log s.level) ^ 6 := by calc _ ≤ ∑ d ∈ s.prodPrimes.divisors, if (d : ℝ) ≤ s.level then (6 : ℝ) ^ ArithmeticFunction.cardDistinctFactors d else 0 := by apply Finset.sum_le_sum intro d hd split_ifs with hdy · calc _ ≤ (3 : ℝ) ^ ArithmeticFunction.cardDistinctFactors d * (2 : ℝ) ^ ArithmeticFunction.cardDistinctFactors d := by exact mul_le_mul_of_nonneg_left (hrem d hd hdy) (by positivity) _ = _ := by rw [← mul_pow]; norm_num · rfl _ ≤ _ := Aux.sum_pow_cardDistinctFactors_le_self_mul_log_pow s.level s.one_le_level s.prodPrimes_squarefree /-- The full abstract two-form bound, with the density and remainder hypotheses spelled out. Construction from the actual two linear forms remains separate. -/ /- Original line 13009: Erdos416Proof.twoForm_selberg_bound -/ theorem twoForm_selberg_bound (s : SelbergSieve) {b : ℕ} (hb : 0 < b) (hbeven : 2 ∣ b) (hnu : s.nu = twoFormDensity b) (hP : ∀ p : ℕ, p.Prime → (p : ℝ) ≤ s.level → p ∣ s.prodPrimes) (hy : 1 < s.level) (hX : 0 ≤ s.totalMass) (hrem : ∀ d ∈ s.prodPrimes.divisors, (d : ℝ) ≤ s.level → |BoundingSieve.rem (s := s.toBoundingSieve) d| ≤ (2 : ℝ) ^ ArithmeticFunction.cardDistinctFactors d) : BoundingSieve.siftedSum (s := s.toBoundingSieve) ≤ 16 * ((b : ℝ) / b.totient) * s.totalMass / Real.log s.level ^ 2 + s.level * (1 + Real.log s.level) ^ 6 := by have hbR : (0 : ℝ) < b := by exact_mod_cast hb have hφR : (0 : ℝ) < b.totient := by exact_mod_cast Nat.totient_pos.mpr hb have hlog : 0 < Real.log s.level := Real.log_pos hy have hlow := twoForm_selberg_boundingSum_lower s hb hbeven hnu hP have hmain : s.totalMass / s.selbergBoundingSum ≤ 16 * ((b : ℝ) / b.totient) * s.totalMass / Real.log s.level ^ 2 := by calc _ ≤ s.totalMass / ((b.totient : ℝ) / b * Real.log s.level ^ 2 / 16) := div_le_div_of_nonneg_left hX (by positivity) hlow _ = _ := by field_simp exact s.selberg_bound_simple.trans (add_le_add hmain (twoForm_selberg_error_bound s hrem)) end Erdos416Proof /- The actual two-form sieve: congruence counts, the complete residue error, and the uniform bound for primes q and b*q+1. This is a proved special case needed for normal-prime estimates, not the full multivariable sieve. -/ open scoped BigOperators Classical namespace Erdos416Proof /- Original line 13043: Erdos416Proof.twoFormPolynomial -/ def twoFormPolynomial (b n : ℕ) : ℕ := n * (b * n + 1) /- Original line 13045: Erdos416Proof.twoFormPolynomial_strictMono -/ theorem twoFormPolynomial_strictMono (b : ℕ) : StrictMono (twoFormPolynomial b) := by intro m n hmn change m * (b * m + 1) < n * (b * n + 1) calc _ < n * (b * m + 1) := Nat.mul_lt_mul_of_pos_right hmn (by omega) _ ≤ _ := Nat.mul_le_mul_left n (Nat.add_le_add_right (Nat.mul_le_mul_left b hmn.le) 1) /- Original line 13052: Erdos416Proof.twoFormResidues -/ def twoFormResidues (b d : ℕ) : Finset ℕ := (Finset.range d).filter (fun n => d ∣ twoFormPolynomial b n) /- Original line 13055: Erdos416Proof.twoForm_divisibility_iff_zmod -/ theorem twoForm_divisibility_iff_zmod (b d n : ℕ) : d ∣ twoFormPolynomial b n ↔ (n : ZMod d) * ((b : ZMod d) * (n : ZMod d) + 1) = 0 := by rw [← ZMod.natCast_eq_zero_iff] simp only [twoFormPolynomial, Nat.cast_mul, Nat.cast_add, Nat.cast_one] /- Original line 13061: Erdos416Proof.twoForm_prime_zero_iff -/ theorem twoForm_prime_zero_iff {p : ℕ} (hp : p.Prime) (b : ℕ) (t : ZMod p) : t * ((b : ZMod p) * t + 1) = 0 ↔ t = 0 ∨ (¬ p ∣ b ∧ t = -(b : ZMod p)⁻¹) := by let : Fact p.Prime := ⟨hp⟩ by_cases hpb : p ∣ b · have hb : (b : ZMod p) = 0 := (ZMod.natCast_eq_zero_iff b p).mpr hpb simp [hb, hpb] have hb : (b : ZMod p) ≠ 0 := (ZMod.natCast_eq_zero_iff b p).not.mpr hpb simp only [hpb, not_false_eq_true, true_and, mul_eq_zero] apply or_congr_right constructor · intro h apply mul_left_cancel₀ hb calc (b : ZMod p) * t = -1 := eq_neg_of_add_eq_zero_left h _ = (b : ZMod p) * -(b : ZMod p)⁻¹ := by simp [hb] · rintro rfl simp [hb] /- Original line 13080: Erdos416Proof.twoForm_prime_roots_card -/ theorem twoForm_prime_roots_card (b p : ℕ) [Fact p.Prime] : ((Finset.univ : Finset (ZMod p)).filter (fun t => t * ((b : ZMod p) * t + 1) = 0)).card = if p ∣ b then 1 else 2 := by have hp : p.Prime := Fact.out by_cases hpb : p ∣ b · have hset : (Finset.univ : Finset (ZMod p)).filter (fun t => t * ((b : ZMod p) * t + 1) = 0) = {0} := by ext t simp only [Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_singleton, twoForm_prime_zero_iff hp b t, hpb, not_true_eq_false, false_and, or_false] rw [hset, Finset.card_singleton, if_pos hpb] · have hset : (Finset.univ : Finset (ZMod p)).filter (fun t => t * ((b : ZMod p) * t + 1) = 0) = {0, -(b : ZMod p)⁻¹} := by ext t simp only [Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_insert, Finset.mem_singleton, twoForm_prime_zero_iff hp b t, hpb, not_false_eq_true, true_and] have hb : (b : ZMod p) ≠ 0 := (ZMod.natCast_eq_zero_iff b p).not.mpr hpb have hneq : (0 : ZMod p) ≠ -(b : ZMod p)⁻¹ := by intro h exact inv_ne_zero hb (neg_eq_zero.mp h.symm) rw [hset, Finset.card_pair hneq, if_neg hpb] /- Original line 13102: Erdos416Proof.twoFormResidues_card_eq_zmod -/ theorem twoFormResidues_card_eq_zmod (b d : ℕ) [NeZero d] : (twoFormResidues b d).card = ((Finset.univ : Finset (ZMod d)).filter (fun t => t * ((b : ZMod d) * t + 1) = 0)).card := by let Q := (Finset.univ : Finset (ZMod d)).filter (fun t => t * ((b : ZMod d) * t + 1) = 0) have heq : Q.image ZMod.val = twoFormResidues b d := by ext n constructor · intro hn obtain ⟨t, ht, rfl⟩ := Finset.mem_image.mp hn apply Finset.mem_filter.mpr refine ⟨Finset.mem_range.mpr (ZMod.val_lt t), ?_⟩ apply (twoForm_divisibility_iff_zmod b d t.val).mpr simpa only [ZMod.natCast_zmod_val] using (Finset.mem_filter.mp ht).2 · intro hn obtain ⟨hnlt, hdiv⟩ := Finset.mem_filter.mp hn refine Finset.mem_image.mpr ⟨(n : ZMod d), ?_, ?_⟩ · exact Finset.mem_filter.mpr ⟨Finset.mem_univ _, (twoForm_divisibility_iff_zmod b d n).mp hdiv⟩ · exact ZMod.val_natCast_of_lt (Finset.mem_range.mp hnlt) rw [← heq, Finset.card_image_of_injective _ (ZMod.val_injective d)] /- Original line 13122: Erdos416Proof.twoFormResidues_prime -/ theorem twoFormResidues_prime (b : ℕ) {p : ℕ} (hp : p.Prime) : (twoFormResidues b p).card = if p ∣ b then 1 else 2 := by let : Fact p.Prime := ⟨hp⟩ rw [twoFormResidues_card_eq_zmod, twoForm_prime_roots_card] /-- Chinese remaindering preserves the actual polynomial-root condition. -/ /- Original line 13128: Erdos416Proof.twoFormRootsCRT -/ noncomputable def twoFormRootsCRT (b : ℕ) {m n : ℕ} (hcop : m.Coprime n) : {t : ZMod (m * n) // t * ((b : ZMod (m * n)) * t + 1) = 0} ≃ {t : ZMod m // t * ((b : ZMod m) * t + 1) = 0} × {t : ZMod n // t * ((b : ZMod n) * t + 1) = 0} := by let e := ZMod.chineseRemainder hcop have hmap (t : ZMod (m * n)) : t * ((b : ZMod (m * n)) * t + 1) = 0 ↔ (e t).1 * ((b : ZMod m) * (e t).1 + 1) = 0 ∧ (e t).2 * ((b : ZMod n) * (e t).2 + 1) = 0 := by constructor · intro ht have h := congrArg e ht simp only [map_mul, map_add, map_natCast, map_one, map_zero] at h exact ⟨congrArg (fun x : ZMod m × ZMod n => x.1) h, congrArg (fun x : ZMod m × ZMod n => x.2) h⟩ · rintro ⟨hm, hn⟩ apply e.injective simp only [map_mul, map_add, map_natCast, map_one, map_zero] exact Prod.ext hm hn refine { toFun := fun t => (⟨(e t.1).1, ((hmap t.1).mp t.2).1⟩, ⟨(e t.1).2, ((hmap t.1).mp t.2).2⟩) invFun := fun t => ⟨e.symm (t.1.1, t.2.1), ?_⟩ left_inv := fun t => Subtype.ext (e.symm_apply_apply t.1) right_inv := fun t => ?_ } · apply (hmap _).mpr rw [e.apply_symm_apply] exact ⟨t.1.2, t.2.2⟩ · exact Prod.ext (Subtype.ext (congrArg (fun x : ZMod m × ZMod n => x.1) (e.apply_symm_apply (t.1.1, t.2.1)))) (Subtype.ext (congrArg (fun x : ZMod m × ZMod n => x.2) (e.apply_symm_apply (t.1.1, t.2.1)))) /- Original line 13161: Erdos416Proof.twoFormResidues_mul -/ theorem twoFormResidues_mul (b : ℕ) {m n : ℕ} (hm : 0 < m) (hn : 0 < n) (hcop : m.Coprime n) : (twoFormResidues b (m * n)).card = (twoFormResidues b m).card * (twoFormResidues b n).card := by let : NeZero m := ⟨hm.ne'⟩ let : NeZero n := ⟨hn.ne'⟩ have hcard (d : ℕ) [NeZero d] : Nat.card {t : ZMod d // t * ((b : ZMod d) * t + 1) = 0} = (twoFormResidues b d).card := by rw [Nat.card_eq_fintype_card, Fintype.card_subtype, twoFormResidues_card_eq_zmod] calc _ = Nat.card {t : ZMod (m * n) // t * ((b : ZMod (m * n)) * t + 1) = 0} := (hcard _).symm _ = Nat.card ({t : ZMod m // t * ((b : ZMod m) * t + 1) = 0} × {t : ZMod n // t * ((b : ZMod n) * t + 1) = 0}) := Nat.card_congr (twoFormRootsCRT b hcop) _ = _ := by rw [Nat.card_prod, hcard m, hcard n] /- Original line 13175: Erdos416Proof.twoFormRootCount -/ def twoFormRootCount (b : ℕ) : ArithmeticFunction ℕ := ⟨fun d => (twoFormResidues b d).card, by simp [twoFormResidues]⟩ /- Original line 13178: Erdos416Proof.twoFormRootCount_apply -/ theorem twoFormRootCount_apply (b d : ℕ) : twoFormRootCount b d = (twoFormResidues b d).card := rfl /- Original line 13181: Erdos416Proof.twoFormRootCount_one -/ theorem twoFormRootCount_one (b : ℕ) : twoFormRootCount b 1 = 1 := by simp [Erdos416Proof.twoFormRootCount_apply, twoFormRootCount_apply, twoFormResidues, Finset.range_one] /- Original line 13184: Erdos416Proof.twoFormRootCount_multiplicative -/ theorem twoFormRootCount_multiplicative (b : ℕ) : (twoFormRootCount b).IsMultiplicative := by refine ⟨twoFormRootCount_one b, ?_⟩ intro m n hcop by_cases hm : m = 0 · simp [Erdos416Proof.twoFormRootCount_apply, Erdos416Proof.twoFormRootCount_one, hm] by_cases hn : n = 0 · simp [Erdos416Proof.twoFormRootCount_apply, Erdos416Proof.twoFormRootCount_one, hn] exact twoFormResidues_mul b (Nat.pos_of_ne_zero hm) (Nat.pos_of_ne_zero hn) hcop /- Original line 13194: Erdos416Proof.twoFormRootCount_squarefree -/ theorem twoFormRootCount_squarefree {b d : ℕ} (hd : Squarefree d) : twoFormRootCount b d = ∏ p ∈ d.primeFactors, if p ∣ b then 1 else 2 := by rw [← (twoFormRootCount_multiplicative b).prod_primeFactors hd] apply Finset.prod_congr rfl intro p hp exact twoFormResidues_prime b (Nat.prime_of_mem_primeFactors hp) /- Original line 13201: Erdos416Proof.twoFormRootCount_eq_density -/ theorem twoFormRootCount_eq_density {b d : ℕ} (hd : Squarefree d) : (twoFormRootCount b d : ℝ) = (d : ℝ) * twoFormDensity b d := by have hmult : (twoFormDensity b).IsMultiplicative := ⟨twoFormDensity_one b, fun {m n} _ => twoFormDensity_mul b m n⟩ have hdc : (d : ℝ) = ∏ p ∈ d.primeFactors, (p : ℝ) := by rw [← Nat.cast_prod, Nat.prod_primeFactors_of_squarefree hd] rw [← hmult.prod_primeFactors hd, hdc, ← Finset.prod_mul_distrib, twoFormRootCount_squarefree hd, Nat.cast_prod] apply Finset.prod_congr rfl intro p hp have hprime := Nat.prime_of_mem_primeFactors hp have hp0 : (p : ℝ) ≠ 0 := by exact_mod_cast hprime.ne_zero rw [twoFormDensity_prime b hprime] split_ifs <;> norm_num <;> field_simp /- Original line 13216: Erdos416Proof.twoFormRootCount_le_pow -/ theorem twoFormRootCount_le_pow {b d : ℕ} (hd : Squarefree d) : twoFormRootCount b d ≤ 2 ^ ArithmeticFunction.cardDistinctFactors d := by rw [twoFormRootCount_squarefree hd] have hcard : d.primeFactors.card = ArithmeticFunction.cardDistinctFactors d := by rw [ArithmeticFunction.cardDistinctFactors_apply, ← Nat.toFinset_factors, List.card_toFinset] calc _ ≤ ∏ _p ∈ d.primeFactors, (2 : ℕ) := by apply Finset.prod_le_prod (fun _ _ => Nat.zero_le _) intro p hp split_ifs <;> omega _ = _ := by simp [Erdos416Proof.twoFormRootCount_apply, Erdos416Proof.twoFormRootCount_one, hcard] /- Original line 13228: Erdos416Proof.twoForm_divisibility_periodic -/ theorem twoForm_divisibility_periodic (b d : ℕ) : Function.Periodic (fun n => d ∣ twoFormPolynomial b n) d := by intro n apply propext dsimp only rw [twoForm_divisibility_iff_zmod, twoForm_divisibility_iff_zmod] simp[Erdos416Proof.twoFormRootCount_one] /- Original line 13236: Erdos416Proof.periodic_count_mul -/ theorem periodic_count_mul {P : ℕ → Prop} [DecidablePred P] {d : ℕ} (hP : Function.Periodic P d) (k : ℕ) : Nat.count P (k * d) = k * Nat.count P d := by induction k with | zero => simp | succ k ih => have hshift : (fun n => P (n + k * d)) = P := funext (hP.nat_mul k) simp only [Nat.succ_mul, Nat.add_comm (k * d) d, Nat.count_add', hshift, ih] omega /- Original line 13245: Erdos416Proof.periodic_count_div_mod -/ theorem periodic_count_div_mod {P : ℕ → Prop} [DecidablePred P] {d : ℕ} (hP : Function.Periodic P d) (N : ℕ) : Nat.count P N = (N / d) * Nat.count P d + Nat.count P (N % d) := by have hshift : (fun n => P (n + (N / d) * d)) = P := funext (hP.nat_mul (N / d)) calc _ = Nat.count P (N % d + (N / d) * d) := by rw [Nat.mod_add_div'] _ = _ := by simp only [Nat.count_add', hshift, periodic_count_mul hP]; omega /-- A periodic set has a counting error bounded by its number of residues, including when the interval is shorter than one period. -/ /- Original line 13255: Erdos416Proof.periodic_count_error -/ theorem periodic_count_error {P : ℕ → Prop} [DecidablePred P] {d : ℕ} (hP : Function.Periodic P d) (hd : 0 < d) (N : ℕ) : |(Nat.count P N : ℝ) - (Nat.count P d : ℝ) / d * N| ≤ Nat.count P d := by have hdR : (0 : ℝ) < d := by exact_mod_cast hd have hrem : (N % d : ℕ) ≤ d := (Nat.mod_lt N hd).le have hremR : ((N % d : ℕ) : ℝ) ≤ d := by exact_mod_cast hrem have hcount : (Nat.count P (N % d) : ℝ) ≤ Nat.count P d := by exact_mod_cast Nat.count_monotone P hrem have hterm : 0 ≤ (Nat.count P d : ℝ) / d * (N % d : ℕ) := by positivity have htermle : (Nat.count P d : ℝ) / d * (N % d : ℕ) ≤ Nat.count P d := by calc _ ≤ (Nat.count P d : ℝ) / d * d := mul_le_mul_of_nonneg_left hremR (by positivity) _ = _ := div_mul_cancel₀ _ hdR.ne' have hN : (N : ℝ) = (N / d : ℕ) * (d : ℝ) + (N % d : ℕ) := by exact_mod_cast (by simpa only [Nat.mul_comm] using (Nat.div_add_mod N d).symm) have hdec : (Nat.count P N : ℝ) = (N / d : ℕ) * (Nat.count P d : ℝ) + (Nat.count P (N % d) : ℝ) := by exact_mod_cast periodic_count_div_mod hP N have heq : (Nat.count P N : ℝ) - (Nat.count P d : ℝ) / d * N = (Nat.count P (N % d) : ℝ) - (Nat.count P d : ℝ) / d * (N % d : ℕ) := by rw [hdec, hN] field_simp ring rw [heq, abs_le] constructor <;> linarith [Nat.cast_nonneg (Nat.count P (N % d)) (α := ℝ)] /- Original line 13282: Erdos416Proof.twoForm_congruence_error -/ theorem twoForm_congruence_error (b N : ℕ) {d : ℕ} (hd : Squarefree d) : |(((Finset.range N).filter (fun n => d ∣ twoFormPolynomial b n)).card : ℝ) - twoFormDensity b d * N| ≤ (2 : ℝ) ^ ArithmeticFunction.cardDistinctFactors d := by have herr := periodic_count_error (twoForm_divisibility_periodic b d) (Nat.pos_of_ne_zero hd.ne_zero) N simp only [Nat.count_eq_card_filter_range] at herr change |(_ : ℝ) - (twoFormRootCount b d : ℝ) / d * N| ≤ twoFormRootCount b d at herr have hcoef : (twoFormRootCount b d : ℝ) / d = twoFormDensity b d := by rw [twoFormRootCount_eq_density hd] have hdR : (d : ℝ) ≠ 0 := by exact_mod_cast hd.ne_zero field_simp rw [hcoef] at herr exact herr.trans (by exact_mod_cast twoFormRootCount_le_pow (b := b) hd) /- Original line 13296: Erdos416Proof.twoFormSieve -/ noncomputable def twoFormSieve (b N : ℕ) (L : ℝ) (hb : 2 ∣ b) (hL : 1 ≤ L) : SelbergSieve where support := (Finset.range N).image (twoFormPolynomial b) prodPrimes := primorial ⌊L⌋₊ prodPrimes_squarefree := squarefree_primorial _ weights := fun _ => 1 weights_nonneg := fun _ => zero_le_one totalMass := N nu := twoFormDensity b nu_mult := ⟨twoFormDensity_one b, fun {m n} _ => twoFormDensity_mul b m n⟩ nu_pos_of_prime := fun _ hp _ => twoFormDensity_pos b hp.pos nu_lt_one_of_prime := fun _ hp _ => twoFormDensity_prime_lt_one hb hp level := L one_le_level := hL /- Original line 13310: Erdos416Proof.twoFormSieve_multSum -/ theorem twoFormSieve_multSum (b N d : ℕ) (L : ℝ) (hb : 2 ∣ b) (hL : 1 ≤ L) : BoundingSieve.multSum (s := (twoFormSieve b N L hb hL).toBoundingSieve) d = (((Finset.range N).filter (fun n => d ∣ twoFormPolynomial b n)).card : ℝ) := by change (∑ n ∈ (Finset.range N).image (twoFormPolynomial b), if d ∣ n then (1 : ℝ) else 0) = _ rw [Finset.sum_image (fun _ _ _ _ h => (twoFormPolynomial_strictMono b).injective h)] exact Finset.sum_boole _ _ /- Original line 13317: Erdos416Proof.twoFormSieve_rem_bound -/ theorem twoFormSieve_rem_bound (b N : ℕ) (L : ℝ) (hb : 2 ∣ b) (hL : 1 ≤ L) {d : ℕ} (hd : d ∣ primorial ⌊L⌋₊) : |BoundingSieve.rem (s := (twoFormSieve b N L hb hL).toBoundingSieve) d| ≤ (2 : ℝ) ^ ArithmeticFunction.cardDistinctFactors d := by rw [BoundingSieve.rem, twoFormSieve_multSum] exact twoForm_congruence_error b N (Squarefree.squarefree_of_dvd hd (squarefree_primorial _)) /- Original line 13325: Erdos416Proof.twoFormSieve_siftedSum -/ theorem twoFormSieve_siftedSum (b N : ℕ) (L : ℝ) (hb : 2 ∣ b) (hL : 1 ≤ L) : BoundingSieve.siftedSum (s := (twoFormSieve b N L hb hL).toBoundingSieve) = (((Finset.range N).filter (fun n => (primorial ⌊L⌋₊).Coprime (twoFormPolynomial b n))).card : ℝ) := by change (∑ n ∈ (Finset.range N).image (twoFormPolynomial b), if (primorial ⌊L⌋₊).Coprime n then (1 : ℝ) else 0) = _ rw [Finset.sum_image (fun _ _ _ _ h => (twoFormPolynomial_strictMono b).injective h)] exact Finset.sum_boole _ _ /-- An unconditional bound for the actual integers surviving the two-form sieve. -/ /- Original line 13335: Erdos416Proof.twoForm_sifted_count_bound -/ theorem twoForm_sifted_count_bound {b : ℕ} (hb : 0 < b) (hbeven : 2 ∣ b) (N : ℕ) {L : ℝ} (hL : 1 < L) : (((Finset.range N).filter (fun n => (primorial ⌊L⌋₊).Coprime (twoFormPolynomial b n))).card : ℝ) ≤ 16 * ((b : ℝ) / b.totient) * N / Real.log L ^ 2 + L * (1 + Real.log L) ^ 6 := by let s := twoFormSieve b N L hbeven hL.le have hP : ∀ p : ℕ, p.Prime → (p : ℝ) ≤ s.level → p ∣ s.prodPrimes := by intro p hp hpL exact hp.dvd_primorial_iff.mpr (Nat.le_floor hpL) have hrem : ∀ d ∈ s.prodPrimes.divisors, (d : ℝ) ≤ s.level → |BoundingSieve.rem (s := s.toBoundingSieve) d| ≤ (2 : ℝ) ^ ArithmeticFunction.cardDistinctFactors d := by intro d hd _ exact twoFormSieve_rem_bound b N L hbeven hL.le (Nat.dvd_of_mem_divisors hd) have h := twoForm_selberg_bound s hb hbeven rfl hP hL (by change (0 : ℝ) ≤ N; positivity) hrem rw [twoFormSieve_siftedSum] at h exact h /- Original line 13354: Erdos416Proof.twoFormPrimePairs -/ def twoFormPrimePairs (b N : ℕ) : Finset ℕ := (Finset.range N).filter (fun n => n.Prime ∧ (b * n + 1).Prime) /- Original line 13357: Erdos416Proof.prime_pair_coprime_primorial -/ theorem prime_pair_coprime_primorial {b t z : ℕ} (hb : 0 < b) (ht : t.Prime) (hbt : (b * t + 1).Prime) (hzt : z < t) : (primorial z).Coprime (twoFormPolynomial b t) := by apply Nat.coprime_of_dvd intro p hp hpP hpF have hpz := hp.dvd_primorial_iff.mp hpP have hpt : p < t := hpz.trans_lt hzt have htbt : t < b * t + 1 := by nlinarith rcases hp.dvd_mul.mp hpF with h | h · have heq : p = t := (Nat.dvd_prime ht).mp h |>.resolve_left hp.ne_one omega · have heq : p = b * t + 1 := (Nat.dvd_prime hbt).mp h |>.resolve_left hp.ne_one omega /-- The actual prime pairs are sifted, apart from primes at most the sieve level. -/ /- Original line 13372: Erdos416Proof.twoFormPrimePairs_le_sifted -/ theorem twoFormPrimePairs_le_sifted {b : ℕ} (hb : 0 < b) (N : ℕ) {L : ℝ} (hL : 0 ≤ L) : ((twoFormPrimePairs b N).card : ℝ) ≤ (((Finset.range N).filter (fun n => (primorial ⌊L⌋₊).Coprime (twoFormPolynomial b n))).card : ℝ) + (L + 1) := by let A := (Finset.range N).filter (fun n => (primorial ⌊L⌋₊).Coprime (twoFormPolynomial b n)) have hsub : twoFormPrimePairs b N ⊆ A ∪ Finset.range (⌊L⌋₊ + 1) := by intro t ht obtain ⟨htN, htprime, hbtprime⟩ := Finset.mem_filter.mp ht by_cases htl : t ≤ ⌊L⌋₊ · exact Finset.mem_union_right _ (Finset.mem_range.mpr (by omega)) · exact Finset.mem_union_left _ (Finset.mem_filter.mpr ⟨htN, prime_pair_coprime_primorial hb htprime hbtprime (by omega)⟩) have hcard := (Finset.card_mono hsub).trans (Finset.card_union_le A (Finset.range (⌊L⌋₊ + 1))) have hcardR : ((twoFormPrimePairs b N).card : ℝ) ≤ A.card + (⌊L⌋₊ : ℝ) + 1 := by simpa only [Finset.card_range, Nat.cast_add, Nat.cast_one, add_assoc] using (show ((twoFormPrimePairs b N).card : ℝ) ≤ (A.card + (Finset.range (⌊L⌋₊ + 1)).card : ℕ) by exact_mod_cast hcard) exact hcardR.trans (by linarith [Nat.floor_le hL]) /- Original line 13393: Erdos416Proof.twoFormPrimePairs_bound -/ theorem twoFormPrimePairs_bound {b : ℕ} (hb : 0 < b) (hbeven : 2 ∣ b) (N : ℕ) {L : ℝ} (hL : 1 < L) : ((twoFormPrimePairs b N).card : ℝ) ≤ 16 * ((b : ℝ) / b.totient) * N / Real.log L ^ 2 + L * (1 + Real.log L) ^ 6 + (L + 1) := by exact (twoFormPrimePairs_le_sifted hb N (by linarith)).trans (add_le_add (twoForm_sifted_count_bound hb hbeven N hL) le_rfl) open Filter Asymptotics /- Original line 13403: Erdos416Proof.twoForm_sieve_error_eventually -/ theorem twoForm_sieve_error_eventually : ∀ᶠ x : ℝ in atTop, x ^ (1 / 2 : ℝ) * (1 + Real.log (x ^ (1 / 2 : ℝ))) ^ 6 + (x ^ (1 / 2 : ℝ) + 1) ≤ x / Real.log x ^ 2 := by have hsmall : (fun x : ℝ => Real.log x ^ 8 * x ^ (1 / 2 : ℝ)) =o[atTop] (fun x : ℝ => x) := by simpa only [Real.rpow_one] using log_pow_mul_rpow_littleO 8 (show (1 / 2 : ℝ) < 1 by norm_num) filter_upwards [hsmall.def (show (0 : ℝ) < 1 / 3 by norm_num), Real.tendsto_log_atTop.eventually (eventually_ge_atTop (2 : ℝ)), eventually_gt_atTop (1 : ℝ)] with x hs hxlog hx have hx0 : 0 < x := by linarith have hlog0 : 0 < Real.log x := by linarith have hL0 := Real.rpow_pos_of_pos hx0 (1 / 2 : ℝ) have hL1 := (Real.one_lt_rpow hx (show (0 : ℝ) < 1 / 2 by norm_num)).le have hlogL : Real.log (x ^ (1 / 2 : ℝ)) = (1 / 2 : ℝ) * Real.log x := Real.log_rpow hx0 _ have hpoly : (1 + Real.log (x ^ (1 / 2 : ℝ))) ^ 6 ≤ Real.log x ^ 6 := by rw [hlogL] gcongr linarith have hpow : (1 : ℝ) ≤ Real.log x ^ 6 := one_le_pow₀ (by linarith) have herr : x ^ (1 / 2 : ℝ) * (1 + Real.log (x ^ (1 / 2 : ℝ))) ^ 6 + (x ^ (1 / 2 : ℝ) + 1) ≤ 3 * x ^ (1 / 2 : ℝ) * Real.log x ^ 6 := by have hmul := mul_le_mul_of_nonneg_left hpoly hL0.le have hone := mul_le_mul_of_nonneg_left hpow hL0.le nlinarith simp only [Real.norm_eq_abs, abs_of_nonneg hx0.le, abs_of_nonneg (mul_nonneg (pow_nonneg hlog0.le 8) hL0.le)] at hs apply (le_div_iff₀ (sq_pos_of_pos hlog0)).mpr calc _ ≤ (3 * x ^ (1 / 2 : ℝ) * Real.log x ^ 6) * Real.log x ^ 2 := mul_le_mul_of_nonneg_right herr (sq_nonneg _) _ = 3 * (Real.log x ^ 8 * x ^ (1 / 2 : ℝ)) := by ring _ ≤ x := by linarith /- Original line 13438: Erdos416Proof.twoFormPrimePairs_eventually_bound -/ theorem twoFormPrimePairs_eventually_bound : ∀ᶠ x : ℝ in atTop, ∀ b : ℕ, 0 < b → 2 ∣ b → ((twoFormPrimePairs b (⌊x⌋₊ + 1)).card : ℝ) ≤ 129 * ((b : ℝ) / b.totient) * x / Real.log x ^ 2 := by filter_upwards [twoForm_sieve_error_eventually, eventually_gt_atTop (2 : ℝ)] with x herr hx intro b hb hbeven have hx0 : 0 < x := by linarith have hlog : 0 < Real.log x := Real.log_pos (by linarith) have hL := Real.one_lt_rpow (show 1 < x by linarith) (show (0 : ℝ) < 1 / 2 by norm_num) have hφ : (0 : ℝ) < b.totient := by exact_mod_cast Nat.totient_pos.mpr hb have hbφ : (1 : ℝ) ≤ (b : ℝ) / b.totient := by apply (le_div_iff₀ hφ).mpr simpa only [one_mul] using (show (b.totient : ℝ) ≤ b by exact_mod_cast Nat.totient_le b) have hN : ((⌊x⌋₊ + 1 : ℕ) : ℝ) ≤ 2 * x := by push_cast linarith [Nat.floor_le hx0.le] have hmain : 16 * ((b : ℝ) / b.totient) * (⌊x⌋₊ + 1 : ℕ) / Real.log (x ^ (1 / 2 : ℝ)) ^ 2 ≤ 128 * ((b : ℝ) / b.totient) * x / Real.log x ^ 2 := by calc _ ≤ 16 * ((b : ℝ) / b.totient) * (2 * x) / Real.log (x ^ (1 / 2 : ℝ)) ^ 2 := by gcongr _ = _ := by rw [Real.log_rpow hx0]; field_simp; ring have hbound := twoFormPrimePairs_bound hb hbeven (⌊x⌋₊ + 1) hL have hunit : x / Real.log x ^ 2 ≤ ((b : ℝ) / b.totient) * x / Real.log x ^ 2 := by gcongr simpa only [one_mul] using mul_le_mul_of_nonneg_right hbφ hx0.le calc _ ≤ 128 * ((b : ℝ) / b.totient) * x / Real.log x ^ 2 + x / Real.log x ^ 2 := by linarith [hmain, herr, hbound] _ ≤ 128 * ((b : ℝ) / b.totient) * x / Real.log x ^ 2 + ((b : ℝ) / b.totient) * x / Real.log x ^ 2 := add_le_add le_rfl hunit _ = _ := by ring /-- The two-prime upper bound has one absolute constant, uniform in the positive even coefficient and in every real endpoint at least two. -/ /- Original line 13473: Erdos416Proof.exists_twoFormPrimePairs_even_upper_bound -/ theorem exists_twoFormPrimePairs_even_upper_bound : ∃ C : ℝ, 0 < C ∧ ∀ (b : ℕ) (x : ℝ), 0 < b → 2 ∣ b → 2 ≤ x → ((twoFormPrimePairs b (⌊x⌋₊ + 1)).card : ℝ) ≤ C * ((b : ℝ) / b.totient) * x / Real.log x ^ 2 := by obtain ⟨X₀, hX₀⟩ := eventually_atTop.mp twoFormPrimePairs_eventually_bound let X := max 2 X₀ let C := 129 + 2 * Real.log X ^ 2 have hX : (2 : ℝ) ≤ X := le_max_left _ _ have hC129 : (129 : ℝ) ≤ C := by dsimp [C]; nlinarith [sq_nonneg (Real.log X)] have hC : 0 < C := lt_of_lt_of_le (by norm_num) hC129 refine ⟨C, hC, ?_⟩ intro b x hb hbeven hx have hx0 : 0 < x := by linarith have hlog : 0 < Real.log x := Real.log_pos (by linarith) have hφ : (0 : ℝ) < b.totient := by exact_mod_cast Nat.totient_pos.mpr hb have hbφ : (1 : ℝ) ≤ (b : ℝ) / b.totient := by apply (le_div_iff₀ hφ).mpr simpa only [one_mul] using (show (b.totient : ℝ) ≤ b by exact_mod_cast Nat.totient_le b) by_cases hxX : X ≤ x · exact (hX₀ x ((le_max_right _ _).trans hxX) b hb hbeven).trans (by gcongr) have hlogX : Real.log x ≤ Real.log X := Real.log_le_log hx0 (le_of_not_ge hxX) have hlogXsq : Real.log x ^ 2 ≤ Real.log X ^ 2 := by gcongr have hcoef : 2 * Real.log x ^ 2 ≤ C * ((b : ℝ) / b.totient) := by have hCα : C ≤ C * ((b : ℝ) / b.totient) := by simpa only [mul_one] using mul_le_mul_of_nonneg_left hbφ hC.le dsimp [C] at hCα ⊢ linarith have hcard : ((twoFormPrimePairs b (⌊x⌋₊ + 1)).card : ℝ) ≤ (⌊x⌋₊ + 1 : ℕ) := by exact_mod_cast (Finset.card_filter_le (Finset.range (⌊x⌋₊ + 1)) (fun n => n.Prime ∧ (b * n + 1).Prime)).trans_eq (Finset.card_range _) calc _ ≤ 2 * x := hcard.trans (by push_cast; linarith [Nat.floor_le hx0.le]) _ ≤ _ := by apply (le_div_iff₀ (sq_pos_of_pos hlog)).mpr nlinarith [mul_le_mul_of_nonneg_right hcoef hx0.le] /- Original line 13509: Erdos416Proof.twoFormPrimePairs_card_le_one_of_not_even -/ theorem twoFormPrimePairs_card_le_one_of_not_even {b : ℕ} (hb : 0 < b) (hbeven : ¬2 ∣ b) (N : ℕ) : (twoFormPrimePairs b N).card ≤ 1 := by have hsub : twoFormPrimePairs b N ⊆ {2} := by intro t ht obtain ⟨_, htprime, hbtprime⟩ := Finset.mem_filter.mp ht rcases htprime.eq_two_or_odd with ht2 | htodd · exact Finset.mem_singleton.mpr ht2 have hbodd : b % 2 = 1 := by have hmod := Nat.mod_lt b (show 0 < 2 by norm_num) have hnonzero : b % 2 ≠ 0 := Nat.dvd_iff_mod_eq_zero.not.mp hbeven omega have hbtmod : (b * t + 1) % 2 = 0 := by simp [Nat.add_mod, Nat.mul_mod, hbodd, htodd] have hbt2 : b * t + 1 = 2 := hbtprime.eq_two_or_odd.resolve_right (by omega) have hb1 : 1 ≤ b := hb have ht2 : 2 ≤ t := htprime.two_le exfalso nlinarith simpa only [Finset.card_singleton] using Finset.card_mono hsub /-- A uniform two-linear-form prime estimate, with no hypotheses beyond a positive natural coefficient and a real endpoint at least two. -/ /- Original line 13530: Erdos416Proof.exists_twoFormPrimePairs_upper_bound -/ theorem exists_twoFormPrimePairs_upper_bound : ∃ C : ℝ, 0 < C ∧ ∀ (b : ℕ) (x : ℝ), 0 < b → 2 ≤ x → ((twoFormPrimePairs b (⌊x⌋₊ + 1)).card : ℝ) ≤ C * ((b : ℝ) / b.totient) * x / Real.log x ^ 2 := by obtain ⟨C₀, hC₀, hbound⟩ := exists_twoFormPrimePairs_even_upper_bound let C := max 4 C₀ have hC4 : (4 : ℝ) ≤ C := le_max_left _ _ have hCC₀ : C₀ ≤ C := le_max_right _ _ have hC : 0 < C := lt_of_lt_of_le (by norm_num) hC4 refine ⟨C, hC, ?_⟩ intro b x hb hx have hx0 : 0 < x := by linarith have hlog : 0 < Real.log x := Real.log_pos (by linarith) have hφ : (0 : ℝ) < b.totient := by exact_mod_cast Nat.totient_pos.mpr hb have hbφ : (1 : ℝ) ≤ (b : ℝ) / b.totient := by apply (le_div_iff₀ hφ).mpr simpa only [one_mul] using (show (b.totient : ℝ) ≤ b by exact_mod_cast Nat.totient_le b) by_cases hbeven : 2 ∣ b · exact (hbound b x hb hbeven hx).trans (by gcongr) have hcount : ((twoFormPrimePairs b (⌊x⌋₊ + 1)).card : ℝ) ≤ 1 := by exact_mod_cast twoFormPrimePairs_card_le_one_of_not_even hb hbeven (⌊x⌋₊ + 1) have hlogBound : Real.log x ^ 2 ≤ 4 * x := by have hbase := Real.log_le_rpow_div hx0.le (show (0 : ℝ) < 1 / 2 by norm_num) have hsq : Real.log x ^ 2 ≤ (2 * x ^ (1 / 2 : ℝ)) ^ 2 := by gcongr linarith have hsqrt := Real.sq_sqrt hx0.le rw [Real.sqrt_eq_rpow] at hsqrt nlinarith have hcoef : 4 ≤ C * ((b : ℝ) / b.totient) := by have h := mul_le_mul_of_nonneg_left hbφ hC.le nlinarith apply hcount.trans apply (le_div_iff₀ (sq_pos_of_pos hlog)).mpr simpa only [one_mul] using hlogBound.trans (mul_le_mul_of_nonneg_right hcoef hx0.le) /- Original line 13566: Erdos416Proof.exists_twoFormPrimeSet_upper_bound -/ theorem exists_twoFormPrimeSet_upper_bound : ∃ C : ℝ, 0 < C ∧ ∀ (b : ℕ) (x : ℝ) (F : Finset ℕ), 0 < b → 2 ≤ x → (∀ q ∈ F, q.Prime ∧ (b * q + 1).Prime ∧ (q : ℝ) ≤ x) → (F.card : ℝ) ≤ C * ((b : ℝ) / b.totient) * x / Real.log x ^ 2 := by obtain ⟨C, hC, hcount⟩ := exists_twoFormPrimePairs_upper_bound refine ⟨C, hC, ?_⟩ intro b x F hb hx hF have hsub : F ⊆ twoFormPrimePairs b (⌊x⌋₊ + 1) := by intro q hq obtain ⟨hqprime, hbp, hqx⟩ := hF q hq exact Finset.mem_filter.mpr ⟨Finset.mem_range.mpr (Nat.lt_succ_of_le (Nat.le_floor hqx)), hqprime, hbp⟩ have hcard : (F.card : ℝ) ≤ (twoFormPrimePairs b (⌊x⌋₊ + 1)).card := by exact_mod_cast Finset.card_mono hsub exact hcard.trans (hcount b x hb hx) /-- The form needed after writing a shifted prime as `b*q`: the endpoint is the original prime's bound, and `a` is a lower bound for `log q`. -/ /- Original line 13585: Erdos416Proof.exists_prime_cofactor_sieve_bound -/ theorem exists_prime_cofactor_sieve_bound : ∃ C : ℝ, 0 < C ∧ ∀ (b : ℕ) (Y a : ℝ) (F : Finset ℕ), 0 < b → 0 ≤ Y → 0 < a → (∀ q ∈ F, q.Prime ∧ (b * q + 1).Prime ∧ ((b * q + 1 : ℕ) : ℝ) ≤ Y ∧ a ≤ Real.log q) → (F.card : ℝ) ≤ C * Y / ((b.totient : ℝ) * a ^ 2) := by obtain ⟨C, hC, hcount⟩ := exists_twoFormPrimeSet_upper_bound refine ⟨C, hC, ?_⟩ intro b Y a F hb hY ha hF have hbR : (0 : ℝ) < b := by exact_mod_cast hb have hφ : (0 : ℝ) < b.totient := by exact_mod_cast Nat.totient_pos.mpr hb by_cases hFempty : F = ∅ · simp only [hFempty, Finset.card_empty, Nat.cast_zero] positivity obtain ⟨q, hq⟩ := Finset.nonempty_iff_ne_empty.mpr hFempty have hdata : ∀ t ∈ F, t.Prime ∧ (b * t + 1).Prime ∧ (t : ℝ) ≤ Y / b := by intro t ht obtain ⟨htprime, hbtprime, hbtY, _⟩ := hF t ht refine ⟨htprime, hbtprime, (le_div_iff₀ hbR).mpr ?_⟩ push_cast at hbtY nlinarith obtain ⟨hqprime, _, hqY⟩ := hdata q hq have hx2 : (2 : ℝ) ≤ Y / b := (show (2 : ℝ) ≤ q by exact_mod_cast hqprime.two_le).trans hqY have halog : a ≤ Real.log (Y / b) := (hF q hq).2.2.2.trans (Real.log_le_log (by exact_mod_cast hqprime.pos) hqY) have hpow : a ^ 2 ≤ Real.log (Y / b) ^ 2 := by gcongr calc _ ≤ C * ((b : ℝ) / b.totient) * (Y / b) / Real.log (Y / b) ^ 2 := hcount b (Y / b) F hb hx2 hdata _ = C * Y / ((b.totient : ℝ) * Real.log (Y / b) ^ 2) := by field_simp _ ≤ _ := div_le_div_of_nonneg_left (mul_nonneg hC.le hY) (by positivity) (mul_le_mul_of_nonneg_left hpow hφ.le) end Erdos416Proof /- Factor-counting moments with inverse-totient weights and their tails. These supply the cofactor estimates for the uniform normal-prime density theorem proved later in this file. -/ open Filter Asymptotics open scoped BigOperators Classical Topology namespace Erdos416Proof /-- A completely multiplicative weight specified on the prime factors. The value at zero is chosen to be zero. -/ /- Original line 13635: Erdos416Proof.primeWeightHom -/ noncomputable def primeWeightHom (w : ℕ → ℝ) : ℕ →* ℝ where toFun n := if n = 0 then 0 else (n.primeFactorsList.map w).prod map_one' := by simp map_mul' m n := by by_cases hm : m = 0 · simp [hm] by_cases hn : n = 0 · simp [hn] simp only [mul_eq_zero, hm, hn, or_self, if_false] rw [((Nat.perm_primeFactorsList_mul hm hn).map w).prod_eq, List.map_append, List.prod_append] /- Original line 13646: Erdos416Proof.primeWeightHom_zero -/ theorem primeWeightHom_zero (w : ℕ → ℝ) : primeWeightHom w 0 = 0 := by simp [primeWeightHom] /- Original line 13649: Erdos416Proof.primeWeightHom_apply -/ theorem primeWeightHom_apply {w : ℕ → ℝ} {n : ℕ} (hn : n ≠ 0) : primeWeightHom w n = (n.primeFactorsList.map w).prod := by simp [Erdos416Proof.primeWeightHom_zero, primeWeightHom, hn] /- Original line 13653: Erdos416Proof.primeWeightHom_prime -/ theorem primeWeightHom_prime (w : ℕ → ℝ) {p : ℕ} (hp : p.Prime) : primeWeightHom w p = w p := by simp [Erdos416Proof.primeWeightHom_zero, primeWeightHom_apply hp.ne_zero, Nat.primeFactorsList_prime hp] /- Original line 13657: Erdos416Proof.primeWeightHom_nonneg -/ theorem primeWeightHom_nonneg {w : ℕ → ℝ} (hw : ∀ p : ℕ, p.Prime → 0 ≤ w p) (n : ℕ) : 0 ≤ primeWeightHom w n := by by_cases hn : n = 0 · simp [Erdos416Proof.primeWeightHom_zero, hn] rw [primeWeightHom_apply hn] apply List.prod_nonneg intro a ha obtain ⟨p, hp, rfl⟩ := List.mem_map.mp ha exact hw p (Nat.prime_of_mem_primeFactorsList hp) /- Original line 13667: Erdos416Proof.weightedInvTotient -/ noncomputable def weightedInvTotient (w : ℕ → ℝ) (n : ℕ) : ℝ := primeWeightHom w n * invTotient n /- Original line 13670: Erdos416Proof.weightedInvTotient_one -/ theorem weightedInvTotient_one (w : ℕ → ℝ) : weightedInvTotient w 1 = 1 := by simp [Erdos416Proof.invTotient_one, Erdos416Proof.primeWeightHom_zero, weightedInvTotient] /- Original line 13673: Erdos416Proof.weightedInvTotient_nonneg -/ theorem weightedInvTotient_nonneg {w : ℕ → ℝ} (hw : ∀ p : ℕ, p.Prime → 0 ≤ w p) (n : ℕ) : 0 ≤ weightedInvTotient w n := mul_nonneg (primeWeightHom_nonneg hw n) (invTotient_nonneg n) /- Original line 13677: Erdos416Proof.weightedInvTotient_mul -/ theorem weightedInvTotient_mul (w : ℕ → ℝ) {m n : ℕ} (hcop : m.Coprime n) : weightedInvTotient w (m * n) = weightedInvTotient w m * weightedInvTotient w n := by simp only [weightedInvTotient, map_mul, invTotient_mul hcop] ring /- Original line 13682: Erdos416Proof.weightedInvTotient_prime_pow_succ -/ theorem weightedInvTotient_prime_pow_succ (w : ℕ → ℝ) {p : ℕ} (hp : p.Prime) (k : ℕ) : weightedInvTotient w (p ^ (k + 1)) = (w p / ((p : ℝ) - 1)) * (w p / p) ^ k := by rw [weightedInvTotient, map_pow, primeWeightHom_prime w hp, invTotient_prime_pow_succ hp] simp only [pow_succ, div_eq_mul_inv, mul_pow] ring /- Original line 13689: Erdos416Proof.weightedTotientEulerFactor -/ noncomputable def weightedTotientEulerFactor (p : ℕ) (z : ℝ) : ℝ := (1 + z / ((p : ℝ) * ((p : ℝ) - 1))) / (1 - z / p) /- Original line 13692: Erdos416Proof.hasSum_weightedInvTotient_prime_pow -/ theorem hasSum_weightedInvTotient_prime_pow (w : ℕ → ℝ) {p : ℕ} (hp : p.Prime) (hw0 : 0 ≤ w p) (hwlt : w p < p) : HasSum (fun k : ℕ => weightedInvTotient w (p ^ k)) (weightedTotientEulerFactor p (w p)) := by have hp0 : (0 : ℝ) < p := by exact_mod_cast hp.pos have hp1 : (1 : ℝ) < p := by exact_mod_cast hp.one_lt have hratio : w p / p < 1 := (div_lt_one hp0).mpr hwlt have hgeo := (hasSum_geometric_of_lt_one (div_nonneg hw0 hp0.le) hratio).mul_left (w p / ((p : ℝ) - 1)) have htail : HasSum (fun k : ℕ => weightedInvTotient w (p ^ (k + 1))) (w p / ((p : ℝ) - 1) * (1 - w p / p)⁻¹) := by simpa only [weightedInvTotient_prime_pow_succ w hp] using hgeo have hfull := (hasSum_nat_add_iff (f := fun k : ℕ => weightedInvTotient w (p ^ k)) 1).mp htail simp only [Finset.sum_range_one, pow_zero, weightedInvTotient_one] at hfull convert! hfull using 1 unfold weightedTotientEulerFactor have hpne : (p : ℝ) ≠ 0 := hp0.ne' have hpne1 : (p : ℝ) - 1 ≠ 0 := by linarith have hrne : 1 - w p / p ≠ 0 := by linarith have hpd : (p : ℝ) - w p ≠ 0 := by linarith field_simp <;> ring /- Original line 13713: Erdos416Proof.hasSum_weightedInvTotient_factored -/ theorem hasSum_weightedInvTotient_factored (w : ℕ → ℝ) (hw : ∀ p : ℕ, p.Prime → 0 ≤ w p ∧ w p < p) (s : Finset ℕ) : HasSum (fun n : Nat.factoredNumbers s => weightedInvTotient w n) (∏ p ∈ s with p.Prime, weightedTotientEulerFactor p (w p)) := by have h := EulerProduct.summable_and_hasSum_factoredNumbers_prod_filter_prime_tsum (weightedInvTotient_one w) (@weightedInvTotient_mul w) (fun {p} hp => (hasSum_weightedInvTotient_prime_pow w hp (hw p hp).1 (hw p hp).2).summable.norm) s convert! h.2 using 1 apply Finset.prod_congr rfl intro p hp have hprime := (Finset.mem_filter.mp hp).2 exact (hasSum_weightedInvTotient_prime_pow w hprime (hw p hprime).1 (hw p hprime).2).tsum_eq.symm /- Original line 13726: Erdos416Proof.finite_weightedInvTotient_bound -/ theorem finite_weightedInvTotient_bound (w : ℕ → ℝ) (hw : ∀ p : ℕ, p.Prime → 0 ≤ w p ∧ w p < p) (s F : Finset ℕ) (hF : ∀ n ∈ F, n ∈ Nat.factoredNumbers s) : (∑ n ∈ F, weightedInvTotient w n) ≤ ∏ p ∈ s with p.Prime, weightedTotientEulerFactor p (w p) := by have hs : HasSum ((Nat.factoredNumbers s).indicator (weightedInvTotient w)) (∏ p ∈ s with p.Prime, weightedTotientEulerFactor p (w p)) := (hasSum_subtype_iff_indicator (f := weightedInvTotient w)).mp (hasSum_weightedInvTotient_factored w hw s) have hbound := sum_le_hasSum F (fun n _ => by by_cases hn : n ∈ Nat.factoredNumbers s · rw [Set.indicator_of_mem hn] exact weightedInvTotient_nonneg (fun p hp => (hw p hp).1) n · simp only [Set.indicator_of_notMem hn, le_refl]) hs simpa only [Finset.sum_congr rfl (fun n hn => Set.indicator_of_mem (hF n hn) (weightedInvTotient w))] using hbound /- Original line 13743: Erdos416Proof.inv_one_sub_le_exp_quadratic -/ theorem inv_one_sub_le_exp_quadratic {t : ℝ} (_ht0 : 0 ≤ t) (ht : t ≤ 7 / 8) : (1 - t)⁻¹ ≤ Real.exp (t + 8 * t ^ 2) := by have hden : 0 < 1 - t := by linarith have hlog := Real.log_le_sub_one_of_pos (inv_pos.mpr hden) have hinv : (1 - t)⁻¹ ≤ 8 := (inv_le_iff_one_le_mul₀ hden).mpr (by linarith) have hid : (1 - t)⁻¹ - 1 = t + t ^ 2 * (1 - t)⁻¹ := by field_simp ring apply (Real.log_le_iff_le_exp (inv_pos.mpr hden)).mp rw [hid] at hlog exact hlog.trans (by nlinarith [mul_le_mul_of_nonneg_left hinv (sq_nonneg t)]) /- Original line 13755: Erdos416Proof.weightedTotientEulerFactor_pos -/ theorem weightedTotientEulerFactor_pos {p : ℕ} (hp : p.Prime) {z : ℝ} (hz0 : 0 ≤ z) (hzp : z < p) : 0 < weightedTotientEulerFactor p z := by have hp0 : (0 : ℝ) < p := by exact_mod_cast hp.pos have hp1 : (1 : ℝ) < p := by exact_mod_cast hp.one_lt have ht : z / p < 1 := (div_lt_one hp0).mpr hzp unfold weightedTotientEulerFactor apply div_pos · positivity · linarith /- Original line 13765: Erdos416Proof.weightedTotientEulerFactor_exp_bound -/ theorem weightedTotientEulerFactor_exp_bound {p : ℕ} (hp : p.Prime) {z : ℝ} (hz0 : 0 ≤ z) (hz : z ≤ 7 / 4) : weightedTotientEulerFactor p z ≤ Real.exp (z / p + 36 / (p : ℝ) ^ 2) := by have hp2 : (2 : ℝ) ≤ p := by exact_mod_cast hp.two_le have hp0 : (0 : ℝ) < p := by linarith have hp1 : 0 < (p : ℝ) - 1 := by linarith have hz2 : z ≤ 2 := by linarith have ht0 : 0 ≤ z / p := div_nonneg hz0 hp0.le have ht : z / p ≤ 7 / 8 := (div_le_iff₀ hp0).mpr (by linarith) have hu : z / ((p : ℝ) * ((p : ℝ) - 1)) ≤ 4 / (p : ℝ) ^ 2 := by have hratio : (p : ℝ) / ((p : ℝ) - 1) ≤ 2 := (div_le_iff₀ hp1).mpr (by linarith) calc _ = (z * ((p : ℝ) / ((p : ℝ) - 1))) / (p : ℝ) ^ 2 := by field_simp _ ≤ _ := div_le_div_of_nonneg_right (by nlinarith [mul_le_mul hz2 hratio (div_nonneg hp0.le hp1.le) (by norm_num : (0 : ℝ) ≤ 2)]) (sq_nonneg _) have htsq : (z / p) ^ 2 ≤ 4 / (p : ℝ) ^ 2 := by rw [div_pow] apply div_le_div_of_nonneg_right _ (sq_nonneg _) nlinarith have hnum : 1 + z / ((p : ℝ) * ((p : ℝ) - 1)) ≤ Real.exp (z / ((p : ℝ) * ((p : ℝ) - 1))) := by simpa only [add_comm] using Real.add_one_le_exp (z / ((p : ℝ) * ((p : ℝ) - 1))) have hden : 0 ≤ (1 - z / p)⁻¹ := by apply inv_nonneg.mpr; linarith calc _ = (1 + z / ((p : ℝ) * ((p : ℝ) - 1))) * (1 - z / p)⁻¹ := by rfl _ ≤ Real.exp (z / ((p : ℝ) * ((p : ℝ) - 1))) * Real.exp (z / p + 8 * (z / p) ^ 2) := mul_le_mul hnum (inv_one_sub_le_exp_quadratic ht0 ht) hden (Real.exp_pos _).le _ = Real.exp (z / ((p : ℝ) * ((p : ℝ) - 1)) + (z / p + 8 * (z / p) ^ 2)) := (Real.exp_add _ _).symm _ ≤ _ := by apply Real.exp_le_exp.mpr ring_nf at hu htsq ⊢ linarith /-- The factor-counting generating function, with an absolute Euler-product error uniform over all prime weights in [0,7/4]. -/ /- Original line 13803: Erdos416Proof.weightedTotientEulerProduct_bound -/ theorem weightedTotientEulerProduct_bound (w : ℕ → ℝ) (hw : ∀ p : ℕ, p.Prime → 0 ≤ w p ∧ w p ≤ 7 / 4) (s : Finset ℕ) : (∏ p ∈ s with p.Prime, weightedTotientEulerFactor p (w p)) ≤ Real.exp ((∑ p ∈ s with p.Prime, w p / p) + 36) := by have hsq : (∑ p ∈ s with p.Prime, (1 : ℝ) / (p : ℝ) ^ 2) ≤ 1 := by simpa using finite_inverse_square_tail (s.filter Nat.Prime) (show 0 < 2 by norm_num) (fun p hp => (Finset.mem_filter.mp hp).2.two_le) calc _ ≤ ∏ p ∈ s with p.Prime, Real.exp (w p / p + 36 / (p : ℝ) ^ 2) := by apply Finset.prod_le_prod · intro p hp have hprime := (Finset.mem_filter.mp hp).2 have hp2 : (2 : ℝ) ≤ p := by exact_mod_cast hprime.two_le exact (weightedTotientEulerFactor_pos hprime (hw p hprime).1 (lt_of_le_of_lt (hw p hprime).2 (by linarith))).le · intro p hp exact weightedTotientEulerFactor_exp_bound (Finset.mem_filter.mp hp).2 (hw p (Finset.mem_filter.mp hp).2).1 (hw p (Finset.mem_filter.mp hp).2).2 _ = Real.exp ((∑ p ∈ s with p.Prime, w p / p) + 36 * ∑ p ∈ s with p.Prime, (1 : ℝ) / (p : ℝ) ^ 2) := by rw [← Real.exp_sum] congr 1 simp only [Finset.sum_add_distrib, Finset.mul_sum, mul_one_div] _ ≤ _ := Real.exp_le_exp.mpr (by linarith) /- Original line 13828: Erdos416Proof.finite_weightedInvTotient_exp_bound -/ theorem finite_weightedInvTotient_exp_bound (w : ℕ → ℝ) (hw : ∀ p : ℕ, p.Prime → 0 ≤ w p ∧ w p ≤ 7 / 4) (s F : Finset ℕ) (hF : ∀ n ∈ F, n ∈ Nat.factoredNumbers s) : (∑ n ∈ F, weightedInvTotient w n) ≤ Real.exp ((∑ p ∈ s with p.Prime, w p / p) + 36) := by have hwlt : ∀ p : ℕ, p.Prime → 0 ≤ w p ∧ w p < p := by intro p hp refine ⟨(hw p hp).1, ?_⟩ have hp2 : (2 : ℝ) ≤ p := by exact_mod_cast hp.two_le linarith [(hw p hp).2] exact (finite_weightedInvTotient_bound w hwlt s F hF).trans (weightedTotientEulerProduct_bound w hw s) /- Original line 13841: Erdos416Proof.primeWeightHom_const -/ theorem primeWeightHom_const (z : ℝ) {n : ℕ} (hn : n ≠ 0) : primeWeightHom (fun _ => z) n = z ^ ArithmeticFunction.cardFactors n := by simp [Erdos416Proof.primeWeightHom_zero, Erdos416Proof.weightedInvTotient_one, primeWeightHom_apply hn, ArithmeticFunction.cardFactors_apply] /-- A single constant bounds the full factor-counting generating functions uniformly for real weights in [0,7/4]. Repeated factors are included. -/ /- Original line 13847: Erdos416Proof.exists_cardFactors_totient_moment_bound -/ theorem exists_cardFactors_totient_moment_bound : ∃ K : ℝ, 0 < K ∧ ∀ (x z : ℝ) (F : Finset ℕ), 2 ≤ x → 0 ≤ z → z ≤ 7 / 4 → (∀ n ∈ F, n ∈ Nat.factoredNumbers (Nat.primesLE ⌊x⌋₊)) → (∑ n ∈ F, z ^ ArithmeticFunction.cardFactors n / (n.totient : ℝ)) ≤ K * Real.log x ^ z := by obtain ⟨B, hB⟩ := prime_reciprocal_mertens let K := Real.exp (36 + 2 * |B|) refine ⟨K, Real.exp_pos _, ?_⟩ intro x z F hx hz0 hz hF have hx1 : 1 < x := by linarith have hlog : 0 < Real.log x := Real.log_pos hx1 have hprimes : (Nat.primesLE ⌊x⌋₊).filter Nat.Prime = Nat.primesLE ⌊x⌋₊ := Finset.filter_eq_self.mpr (fun p hp => Nat.prime_of_mem_primesLE hp) have hbound := finite_weightedInvTotient_exp_bound (fun _ => z) (fun _ _ => ⟨hz0, hz⟩) (Nat.primesLE ⌊x⌋₊) F hF have hsum : (∑ n ∈ F, weightedInvTotient (fun _ => z) n) = ∑ n ∈ F, z ^ ArithmeticFunction.cardFactors n / (n.totient : ℝ) := by apply Finset.sum_congr rfl intro n hn have hn0 := (Nat.mem_factoredNumbers_iff_primeFactors_subset.mp (hF n hn)).1 simp only [weightedInvTotient, primeWeightHom_const z hn0, invTotient, div_eq_mul_inv] rw [hsum, hprimes] at hbound have hrecip : (∑ p ∈ Nat.primesLE ⌊x⌋₊, (1 : ℝ) / p) ≤ Real.log (Real.log x) + |B| := by have h := (abs_le.mp (hB x hx)).2 linarith [le_abs_self B] have hexponent : (∑ p ∈ Nat.primesLE ⌊x⌋₊, z / p) + 36 ≤ (36 + 2 * |B|) + z * Real.log (Real.log x) := by have hmul := mul_le_mul_of_nonneg_left hrecip hz0 have hBmul : z * |B| ≤ 2 * |B| := mul_le_mul_of_nonneg_right (by linarith) (abs_nonneg B) simp only [Finset.mul_sum, mul_one_div] at hmul nlinarith calc _ ≤ Real.exp ((∑ p ∈ Nat.primesLE ⌊x⌋₊, z / p) + 36) := hbound _ ≤ Real.exp ((36 + 2 * |B|) + z * Real.log (Real.log x)) := Real.exp_le_exp.mpr hexponent _ = _ := by simp only [K, Real.exp_add, Real.rpow_def_of_pos hlog, mul_comm] /- Original line 13884: Erdos416Proof.primeIntervalTilt -/ noncomputable def primeIntervalTilt (u v z : ℝ) (p : ℕ) : ℝ := if u < (p : ℝ) ∧ (p : ℝ) ≤ v then z else 1 /- Original line 13887: Erdos416Proof.primeWeightHom_intervalTilt -/ theorem primeWeightHom_intervalTilt (u v z : ℝ) {n : ℕ} (hn : n ≠ 0) : primeWeightHom (primeIntervalTilt u v z) n = z ^ omegaInterval n u v := by rw [primeWeightHom_apply hn] change (n.primeFactorsList.map (fun p : ℕ => if u < (p : ℝ) ∧ (p : ℝ) ≤ v then z else 1)).prod = _ rw [List.prod_map_ite] simp [Erdos416Proof.omegaInterval_one, Erdos416Proof.primeWeightHom_zero, Erdos416Proof.weightedInvTotient_one, omegaInterval, List.countP_eq_length_filter] /- Original line 13895: Erdos416Proof.primeIntervalTilt_sum -/ theorem primeIntervalTilt_sum (u v z : ℝ) (P : Finset ℕ) : (∑ p ∈ P, primeIntervalTilt u v z p / p) = (∑ p ∈ P, (1 : ℝ) / p) + (z - 1) * ∑ p ∈ P.filter (fun p : ℕ => u < (p : ℝ) ∧ (p : ℝ) ≤ v), (1 : ℝ) / p := by rw [Finset.sum_filter, Finset.mul_sum, ← Finset.sum_add_distrib] apply Finset.sum_congr rfl intro p hp by_cases h : u < (p : ℝ) ∧ (p : ℝ) ≤ v <;> simp [primeIntervalTilt, h] <;> ring /- Original line 13903: Erdos416Proof.primesLE_filter_interval -/ theorem primesLE_filter_interval {u v x : ℝ} (hu : 0 ≤ u) (huv : u ≤ v) (hvx : v ≤ x) : (Nat.primesLE ⌊x⌋₊).filter (fun p : ℕ => u < (p : ℝ) ∧ (p : ℝ) ≤ v) = Nat.primesLE ⌊v⌋₊ \ Nat.primesLE ⌊u⌋₊ := by have hv : 0 ≤ v := hu.trans huv have hx : 0 ≤ x := hv.trans hvx ext p simp only [Finset.mem_filter, Finset.mem_sdiff, Nat.mem_primesLE, Nat.le_floor_iff hu, Nat.le_floor_iff hv, Nat.le_floor_iff hx] constructor · rintro ⟨⟨hpx, hp⟩, hup, hpv⟩ exact ⟨⟨hpv, hp⟩, fun h => (not_le_of_gt hup) h.1⟩ · rintro ⟨⟨hpv, hp⟩, hnot⟩ refine ⟨⟨hpv.trans hvx, hp⟩, ?_, hpv⟩ by_contra h exact hnot ⟨le_of_not_gt h, hp⟩ /- Original line 13919: Erdos416Proof.prime_interval_reciprocal_error -/ theorem prime_interval_reciprocal_error {B : ℝ} (hB : ∀ x : ℝ, 2 ≤ x → |(∑ p ∈ Nat.primesLE ⌊x⌋₊, (1 : ℝ) / p) - Real.log (Real.log x)| ≤ B) {u v x : ℝ} (hu : 2 ≤ u) (huv : u ≤ v) (hvx : v ≤ x) : |(∑ p ∈ (Nat.primesLE ⌊x⌋₊).filter (fun p : ℕ => u < (p : ℝ) ∧ (p : ℝ) ≤ v), (1 : ℝ) / p) - (Real.log (Real.log v) - Real.log (Real.log u))| ≤ 2 * |B| := by rw [primesLE_filter_interval (by linarith) huv hvx, Finset.sum_sdiff_eq_sub (Nat.primesLE_mono (Nat.floor_mono huv))] have h₁ := (hB v (hu.trans huv)).trans (le_abs_self B) have h₂ := (hB u hu).trans (le_abs_self B) have h := (abs_sub ((∑ p ∈ Nat.primesLE ⌊v⌋₊, (1 : ℝ) / p) - Real.log (Real.log v)) ((∑ p ∈ Nat.primesLE ⌊u⌋₊, (1 : ℝ) / p) - Real.log (Real.log u))).trans (add_le_add h₁ h₂) convert! h using 1 <;> congr 1 <;> ring /-- An interval factor-counting moment estimate, centered at its double-log length. The finite sets can contain prime powers of arbitrary multiplicity. -/ /- Original line 13937: Erdos416Proof.exists_omegaInterval_totient_moment_bound -/ theorem exists_omegaInterval_totient_moment_bound : ∃ K : ℝ, 0 < K ∧ ∀ (x u v z : ℝ) (F : Finset ℕ), 2 ≤ u → u ≤ v → v ≤ x → 0 ≤ z → z ≤ 7 / 4 → (∀ n ∈ F, n ∈ Nat.factoredNumbers (Nat.primesLE ⌊x⌋₊)) → (∑ n ∈ F, z ^ omegaInterval n u v / (n.totient : ℝ)) ≤ K * Real.log x * Real.exp ((z - 1) * (Real.log (Real.log v) - Real.log (Real.log u))) := by obtain ⟨B, hB⟩ := prime_reciprocal_mertens let K := Real.exp (36 + 3 * |B|) refine ⟨K, Real.exp_pos _, ?_⟩ intro x u v z F hu huv hvx hz0 hz hF have hx2 : 2 ≤ x := (hu.trans huv).trans hvx have hlog : 0 < Real.log x := Real.log_pos (by linarith) have hw : ∀ p : ℕ, p.Prime → 0 ≤ primeIntervalTilt u v z p ∧ primeIntervalTilt u v z p ≤ 7 / 4 := by intro p hp unfold primeIntervalTilt split_ifs <;> constructor <;> linarith have hbound := finite_weightedInvTotient_exp_bound (primeIntervalTilt u v z) hw (Nat.primesLE ⌊x⌋₊) F hF have hsum : (∑ n ∈ F, weightedInvTotient (primeIntervalTilt u v z) n) = ∑ n ∈ F, z ^ omegaInterval n u v / (n.totient : ℝ) := by apply Finset.sum_congr rfl intro n hn have hn0 := (Nat.mem_factoredNumbers_iff_primeFactors_subset.mp (hF n hn)).1 simp only [weightedInvTotient, primeWeightHom_intervalTilt u v z hn0, invTotient, div_eq_mul_inv] have hprimes : (Nat.primesLE ⌊x⌋₊).filter Nat.Prime = Nat.primesLE ⌊x⌋₊ := Finset.filter_eq_self.mpr (fun p hp => Nat.prime_of_mem_primesLE hp) rw [hsum, hprimes, primeIntervalTilt_sum] at hbound let Δ := Real.log (Real.log v) - Real.log (Real.log u) let μ := ∑ p ∈ (Nat.primesLE ⌊x⌋₊).filter (fun p : ℕ => u < (p : ℝ) ∧ (p : ℝ) ≤ v), (1 : ℝ) / p have hI : |μ - Δ| ≤ 2 * |B| := prime_interval_reciprocal_error hB hu huv hvx have hzabs : |z - 1| ≤ 1 := by rw [abs_le]; constructor <;> linarith have hperturb : (z - 1) * (μ - Δ) ≤ 2 * |B| := by calc _ ≤ |(z - 1) * (μ - Δ)| := le_abs_self _ _ = |z - 1| * |μ - Δ| := abs_mul _ _ _ ≤ 1 * (2 * |B|) := mul_le_mul hzabs hI (abs_nonneg _) zero_le_one _ = _ := one_mul _ have hbase := (abs_le.mp (hB x hx2)).2 have hexponent : (∑ p ∈ Nat.primesLE ⌊x⌋₊, (1 : ℝ) / p) + (z - 1) * μ + 36 ≤ (36 + 3 * |B|) + Real.log (Real.log x) + (z - 1) * Δ := by nlinarith [le_abs_self B] calc _ ≤ Real.exp ((∑ p ∈ Nat.primesLE ⌊x⌋₊, (1 : ℝ) / p) + (z - 1) * μ + 36) := hbound _ ≤ Real.exp ((36 + 3 * |B|) + Real.log (Real.log x) + (z - 1) * Δ) := Real.exp_le_exp.mpr hexponent _ = _ := by rw [Real.exp_add, Real.exp_add, Real.exp_log hlog] /-- A finite exponential-moment inequality. The sign of theta selects either tail; the proof uses the elementary quadratic error bound for exp. -/ /- Original line 13987: Erdos416Proof.finite_exponential_moment_tail -/ theorem finite_exponential_moment_tail {ι : Type*} (F : Finset ι) (a w : ι → ℝ) {C μ M θ : ℝ} (hw : ∀ idx ∈ F, 0 ≤ w idx) (hC : 0 ≤ C) (hμ0 : 0 ≤ μ) (hμM : μ ≤ M) (hθ : |θ| ≤ 1) (hF : ∀ idx ∈ F, 2 * M * θ ^ 2 ≤ θ * (a idx - μ)) (hmoment : (∑ idx ∈ F, w idx * Real.exp (θ * a idx)) ≤ C * Real.exp ((Real.exp θ - 1) * μ)) : (∑ idx ∈ F, w idx) ≤ C * Real.exp (-M * θ ^ 2) := by have hweighted : Real.exp (θ * μ + 2 * M * θ ^ 2) * (∑ idx ∈ F, w idx) ≤ ∑ idx ∈ F, w idx * Real.exp (θ * a idx) := by rw [Finset.mul_sum] apply Finset.sum_le_sum intro idx hi have h := Real.exp_le_exp.mpr (show θ * μ + 2 * M * θ ^ 2 ≤ θ * a idx by nlinarith [hF idx hi]) simpa only [mul_comm] using mul_le_mul_of_nonneg_right h (hw idx hi) have hexp : Real.exp θ - 1 - θ ≤ θ ^ 2 := (le_abs_self _).trans (Real.abs_exp_sub_one_sub_id_le hθ) have hexponent : (Real.exp θ - 1) * μ - (θ * μ + 2 * M * θ ^ 2) ≤ -M * θ ^ 2 := by have h₁ := mul_le_mul_of_nonneg_right hexp hμ0 have h₂ := mul_le_mul_of_nonneg_left hμM (sq_nonneg θ) nlinarith calc _ ≤ C * Real.exp ((Real.exp θ - 1) * μ) / Real.exp (θ * μ + 2 * M * θ ^ 2) := by apply (le_div_iff₀ (Real.exp_pos _)).mpr simpa only [mul_comm] using hweighted.trans hmoment _ = C * Real.exp ((Real.exp θ - 1) * μ - (θ * μ + 2 * M * θ ^ 2)) := by rw [Real.exp_sub] ring _ ≤ _ := mul_le_mul_of_nonneg_left (Real.exp_le_exp.mpr hexponent) hC /-- A two-sided deviation estimate for the actual interval factor counts. The exponent is uniform in the interval and the finite family. -/ /- Original line 14019: Erdos416Proof.exists_omegaInterval_totient_deviation_bound -/ theorem exists_omegaInterval_totient_deviation_bound : ∃ C : ℝ, 0 < C ∧ ∀ (x u v h M : ℝ) (F : Finset ℕ), 2 ≤ u → u ≤ v → v ≤ x → 0 < h → h ≤ M → Real.log (Real.log v) - Real.log (Real.log u) ≤ M → (∀ n ∈ F, n ∈ Nat.factoredNumbers (Nat.primesLE ⌊x⌋₊)) → (∀ n ∈ F, h ≤ |(omegaInterval n u v : ℝ) - (Real.log (Real.log v) - Real.log (Real.log u))|) → (∑ n ∈ F, invTotient n) ≤ C * Real.log x * Real.exp (-h ^ 2 / (4 * M)) := by obtain ⟨K, hK, hmoment⟩ := exists_omegaInterval_totient_moment_bound refine ⟨2 * K, by positivity, ?_⟩ intro x u v h M F hu huv hvx hh hhM hΔM hF hdev let Δ := Real.log (Real.log v) - Real.log (Real.log u) have hΔ0 : 0 ≤ Δ := sub_nonneg.mpr (Real.log_le_log (Real.log_pos (by linarith)) (Real.log_le_log (by linarith) huv)) have hx2 : 2 ≤ x := (hu.trans huv).trans hvx have hlog : 0 < Real.log x := Real.log_pos (by linarith) have hM : 0 < M := hh.trans_le hhM have htail (H : Finset ℕ) (hHF : H ⊆ F) (θ : ℝ) (hθhalf : |θ| ≤ 1 / 2) (hH : ∀ n ∈ H, 2 * M * θ ^ 2 ≤ θ * ((omegaInterval n u v : ℝ) - Δ)) : (∑ n ∈ H, invTotient n) ≤ (K * Real.log x) * Real.exp (-M * θ ^ 2) := by have hθ1 : |θ| ≤ 1 := hθhalf.trans (by norm_num) have hθsq : θ ^ 2 ≤ (1 / 2 : ℝ) ^ 2 := by simpa only [sq_abs] using pow_le_pow_left₀ (abs_nonneg θ) hθhalf 2 have hexp : Real.exp θ ≤ 7 / 4 := by have h := (abs_le.mp (Real.abs_exp_sub_one_sub_id_le hθ1)).2 have hθupper := (abs_le.mp hθhalf).2 nlinarith have hm := hmoment x u v (Real.exp θ) H hu huv hvx (Real.exp_pos _).le hexp (fun n hn => hF n (hHF hn)) have hm' : (∑ n ∈ H, invTotient n * Real.exp (θ * (omegaInterval n u v : ℝ))) ≤ (K * Real.log x) * Real.exp ((Real.exp θ - 1) * Δ) := by convert! hm using 1 apply Finset.sum_congr rfl intro n hn rw [show θ * (omegaInterval n u v : ℝ) = (omegaInterval n u v : ℝ) * θ by ring, Real.exp_nat_mul] simp only [invTotient, div_eq_mul_inv, mul_comm] exact finite_exponential_moment_tail H (fun n => (omegaInterval n u v : ℝ)) invTotient (fun n _ => invTotient_nonneg n) (mul_nonneg hK.le hlog.le) hΔ0 hΔM hθ1 hH hm' let α := h / (2 * M) have hα : 0 < α := div_pos hh (by positivity) have hαhalf : α ≤ 1 / 2 := (div_le_iff₀ (by positivity : (0 : ℝ) < 2 * M)).mpr (by linarith) have hαabs : |α| ≤ 1 / 2 := by rwa [abs_of_pos hα] have hαeq : 2 * M * α ^ 2 = α * h := by dsimp [Erdos416Proof.invTotient_one, Erdos416Proof.omegaInterval_one, Erdos416Proof.weightedInvTotient_one, α]; field_simp have hαexp : -M * α ^ 2 = -h ^ 2 / (4 * M) := by dsimp [Erdos416Proof.invTotient_one, Erdos416Proof.omegaInterval_one, Erdos416Proof.weightedInvTotient_one, α]; field_simp <;> ring let P := fun n : ℕ => Δ ≤ (omegaInterval n u v : ℝ) have hplus := htail (F.filter P) (Finset.filter_subset _ _) α hαabs (by intro n hn have hdata := Finset.mem_filter.mp hn have hnonneg : 0 ≤ (omegaInterval n u v : ℝ) - Δ := sub_nonneg.mpr hdata.2 have hd := hdev n hdata.1 rw [abs_of_nonneg hnonneg] at hd rw [hαeq] exact mul_le_mul_of_nonneg_left hd hα.le) have hminus := htail (F.filter (fun n => ¬ P n)) (Finset.filter_subset _ _) (-α) (by simpa only [abs_neg] using hαabs) (by intro n hn have hdata := Finset.mem_filter.mp hn have hnonpos : (omegaInterval n u v : ℝ) - Δ ≤ 0 := by have hlt : (omegaInterval n u v : ℝ) < Δ := lt_of_not_ge hdata.2 linarith have hd := hdev n hdata.1 rw [abs_of_nonpos hnonpos] at hd rw [neg_sq, hαeq] calc _ ≤ α * -((omegaInterval n u v : ℝ) - Δ) := mul_le_mul_of_nonneg_left hd hα.le _ = _ := by ring) rw [hαexp] at hplus rw [neg_sq, hαexp] at hminus calc _ = (∑ n ∈ F.filter P, invTotient n) + (∑ n ∈ F.filter (fun n => ¬P n), invTotient n) := (Finset.sum_filter_add_sum_filter_not F P invTotient).symm _ ≤ (K * Real.log x) * Real.exp (-h ^ 2 / (4 * M)) + (K * Real.log x) * Real.exp (-h ^ 2 / (4 * M)) := add_le_add hplus hminus _ = _ := by ring /- Original line 14095: Erdos416Proof.factored_primesLE_of_positive_le -/ theorem factored_primesLE_of_positive_le {n : ℕ} {x : ℝ} (hn : 0 < n) (hx : (n : ℝ) ≤ x) : n ∈ Nat.factoredNumbers (Nat.primesLE ⌊x⌋₊) := by apply Nat.mem_factoredNumbers_iff_primeFactors_subset.mpr refine ⟨hn.ne', ?_⟩ intro p hp refine Nat.mem_primesLE.mpr ⟨Nat.le_floor ?_, Nat.prime_of_mem_primeFactors hp⟩ exact (show (p : ℝ) ≤ n by exact_mod_cast Nat.le_of_mem_primeFactors hp).trans hx /- Original line 14103: Erdos416Proof.finite_card_le_totient_reciprocal -/ theorem finite_card_le_totient_reciprocal (F : Finset ℕ) {x : ℝ} (hF : ∀ n ∈ F, 0 < n ∧ (n : ℝ) ≤ x) : (F.card : ℝ) ≤ x * ∑ n ∈ F, invTotient n := by calc _ = ∑ _n ∈ F, (1 : ℝ) := by simp[Erdos416Proof.invTotient_one, Erdos416Proof.weightedInvTotient_one] _ ≤ ∑ n ∈ F, x * invTotient n := by apply Finset.sum_le_sum intro n hn have hφ : (0 : ℝ) < n.totient := by exact_mod_cast Nat.totient_pos.mpr (hF n hn).1 have hφx : (n.totient : ℝ) ≤ x := (show (n.totient : ℝ) ≤ n by exact_mod_cast Nat.totient_le n).trans (hF n hn).2 rw [invTotient, ← div_eq_mul_inv] exact (one_le_div hφ).mpr hφx _ = _ := (Finset.mul_sum _ _ _).symm /- Original line 14118: Erdos416Proof.exists_cardFactors_totient_tail_bound -/ theorem exists_cardFactors_totient_tail_bound : ∃ K : ℝ, 0 < K ∧ ∀ (x z a : ℝ) (F : Finset ℕ), 2 ≤ x → 1 ≤ z → z ≤ 7 / 4 → (∀ n ∈ F, n ∈ Nat.factoredNumbers (Nat.primesLE ⌊x⌋₊)) → (∀ n ∈ F, a ≤ (ArithmeticFunction.cardFactors n : ℝ)) → (∑ n ∈ F, invTotient n) ≤ K * Real.log x ^ z / z ^ a := by obtain ⟨K, hK, hmoment⟩ := exists_cardFactors_totient_moment_bound refine ⟨K, hK, ?_⟩ intro x z a F hx hz1 hz hF ha have hz0 : 0 < z := by linarith have hweighted : z ^ a * (∑ n ∈ F, invTotient n) ≤ ∑ n ∈ F, z ^ ArithmeticFunction.cardFactors n / (n.totient : ℝ) := by rw [Finset.mul_sum] apply Finset.sum_le_sum intro n hn have hpow := Real.rpow_le_rpow_of_exponent_le hz1 (ha n hn) rw [Real.rpow_natCast] at hpow simpa only [invTotient, div_eq_mul_inv] using mul_le_mul_of_nonneg_right hpow (invTotient_nonneg n) apply (le_div_iff₀ (Real.rpow_pos_of_pos hz0 a)).mpr simpa only [mul_comm] using hweighted.trans (hmoment x z F hx hz0.le hz hF) /-- An elementary high-factor-count estimate sufficient for the normal-prime argument. It applies to all positive integers, with multiplicities counted. -/ /- Original line 14142: Erdos416Proof.exists_largeOmega_integer_bound -/ theorem exists_largeOmega_integer_bound : ∃ K : ℝ, 0 < K ∧ ∀ (x : ℝ) (F : Finset ℕ), Real.exp 1 ≤ x → (∀ n ∈ F, 0 < n ∧ (n : ℝ) ≤ x ∧ 12 * Real.log (Real.log x) ≤ (ArithmeticFunction.cardFactors n : ℝ)) → (F.card : ℝ) ≤ K * x * Real.log x ^ (-5 / 2 : ℝ) := by obtain ⟨K, hK, htail⟩ := exists_cardFactors_totient_tail_bound refine ⟨K, hK, ?_⟩ intro x F hx hF have hx2 : 2 ≤ x := by linarith [Real.add_one_le_exp (1 : ℝ)] have hx0 : 0 < x := by linarith have hlog1 : 1 ≤ Real.log x := by simpa only [Real.log_exp] using Real.log_le_log (Real.exp_pos 1) hx have hlog : 0 < Real.log x := by linarith have hLL : 0 ≤ Real.log (Real.log x) := Real.log_nonneg hlog1 have hlogthree : (1 / 3 : ℝ) ≤ Real.log (3 / 2) := by have h := Real.one_sub_inv_le_log_of_pos (show (0 : ℝ) < 3 / 2 by norm_num) norm_num at h linarith have hs := htail x (3 / 2) (12 * Real.log (Real.log x)) F hx2 (by norm_num) (by norm_num) (fun n hn => factored_primesLE_of_positive_le (hF n hn).1 (hF n hn).2.1) (fun n hn => (hF n hn).2.2) have hdecay : Real.log x ^ (3 / 2 : ℝ) / (3 / 2 : ℝ) ^ (12 * Real.log (Real.log x)) ≤ Real.log x ^ (-5 / 2 : ℝ) := by rw [Real.rpow_def_of_pos hlog, Real.rpow_def_of_pos (show (0 : ℝ) < 3 / 2 by norm_num), ← Real.exp_sub, Real.rpow_def_of_pos hlog] apply Real.exp_le_exp.mpr nlinarith [mul_le_mul_of_nonneg_right hlogthree hLL] calc _ ≤ x * ∑ n ∈ F, invTotient n := finite_card_le_totient_reciprocal F (fun n hn => ⟨(hF n hn).1, (hF n hn).2.1⟩) _ ≤ x * (K * Real.log x ^ (3 / 2 : ℝ) / (3 / 2 : ℝ) ^ (12 * Real.log (Real.log x))) := mul_le_mul_of_nonneg_left hs hx0.le _ = (K * x) * (Real.log x ^ (3 / 2 : ℝ) / (3 / 2 : ℝ) ^ (12 * Real.log (Real.log x))) := by ring _ ≤ _ := mul_le_mul_of_nonneg_left hdecay (mul_nonneg hK.le hx0.le) /- Original line 14177: Erdos416Proof.largeOmegaIntegers -/ noncomputable def largeOmegaIntegers (x : ℝ) : Finset ℕ := (Finset.Icc 1 ⌊x⌋₊).filter (fun n : ℕ => 12 * Real.log (Real.log x) ≤ (ArithmeticFunction.cardFactors n : ℝ)) /- Original line 14181: Erdos416Proof.largeOmegaIntegers_data -/ theorem largeOmegaIntegers_data {x : ℝ} (hx : 0 ≤ x) {n : ℕ} (hn : n ∈ largeOmegaIntegers x) : 0 < n ∧ (n : ℝ) ≤ x ∧ 12 * Real.log (Real.log x) ≤ (ArithmeticFunction.cardFactors n : ℝ) := by obtain ⟨hnI, hnΩ⟩ := Finset.mem_filter.mp hn obtain ⟨hn1, hnx⟩ := Finset.mem_Icc.mp hnI exact ⟨hn1, (Nat.le_floor_iff hx).mp hnx, hnΩ⟩ /- Original line 14187: Erdos416Proof.largeOmegaIntegers_negligible -/ theorem largeOmegaIntegers_negligible : (fun x : ℝ => ((largeOmegaIntegers x).card : ℝ)) =o[atTop] (fun x : ℝ => x / Real.log x ^ 2) := by obtain ⟨K, hK, hbound⟩ := exists_largeOmega_integer_bound have hlim : Tendsto (fun x : ℝ => K * Real.log x ^ (-1 / 2 : ℝ)) atTop (nhds 0) := by have h := (tendsto_rpow_neg_atTop (show (0 : ℝ) < 1 / 2 by norm_num)).comp Real.tendsto_log_atTop simpa only [Function.comp_apply, neg_div, mul_zero] using h.const_mul K have hpos : ∀ᶠ x : ℝ in atTop, 0 < x ∧ 0 < Real.log x := by filter_upwards [eventually_gt_atTop (1 : ℝ)] with x hx exact ⟨by linarith, Real.log_pos hx⟩ apply (isLittleO_iff_tendsto' ?_).mpr · refine squeeze_zero' ?_ ?_ hlim · filter_upwards [hpos] with x hx rcases hx with ⟨hx0, hlog⟩ exact div_nonneg (Nat.cast_nonneg _) (by positivity) · filter_upwards [hpos, eventually_ge_atTop (Real.exp 1)] with x hx hxexp rcases hx with ⟨hx0, hlog⟩ have h := hbound x (largeOmegaIntegers x) hxexp (fun n hn => largeOmegaIntegers_data hx0.le hn) have hg : 0 < x / Real.log x ^ 2 := by positivity apply (div_le_div_of_nonneg_right h hg.le).trans_eq have hpowers : Real.log x ^ (-5 / 2 : ℝ) * Real.log x ^ 2 = Real.log x ^ (-1 / 2 : ℝ) := by rw [← Real.rpow_natCast, ← Real.rpow_add hlog] norm_num calc _ = K * (Real.log x ^ (-5 / 2 : ℝ) * Real.log x ^ 2) := by field_simp [hx0.ne', hlog.ne'] _ = _ := by rw [hpowers] · filter_upwards [hpos] with x hx rcases hx with ⟨hx0, hlog⟩ intro hzero have h : 0 < x / Real.log x ^ 2 := by positivity exact (h.ne' hzero).elim /- Original line 14221: Erdos416Proof.exists_smallPrimeOmega_totient_moment_bound -/ theorem exists_smallPrimeOmega_totient_moment_bound : ∃ K : ℝ, 0 < K ∧ ∀ (x S : ℝ) (F : Finset ℕ), 2 ≤ x → 2 ≤ S → (∀ n ∈ F, n ∈ Nat.factoredNumbers (Nat.primesLE ⌊x⌋₊)) → (∑ n ∈ F, (3 / 2 : ℝ) ^ omegaInterval n 1 S / (n.totient : ℝ)) ≤ K * Real.log x * Real.exp ((1 / 2 : ℝ) * Real.log (Real.log S)) := by obtain ⟨B, hB⟩ := prime_reciprocal_mertens let K := Real.exp (36 + 2 * |B|) refine ⟨K, Real.exp_pos _, ?_⟩ intro x S F hx hS hF have hlog : 0 < Real.log x := Real.log_pos (by linarith) have hw : ∀ p : ℕ, p.Prime → 0 ≤ primeIntervalTilt 1 S (3 / 2) p ∧ primeIntervalTilt 1 S (3 / 2) p ≤ 7 / 4 := by intro p hp unfold primeIntervalTilt split_ifs <;> norm_num have hbound := finite_weightedInvTotient_exp_bound (primeIntervalTilt 1 S (3 / 2)) hw (Nat.primesLE ⌊x⌋₊) F hF have hsum : (∑ n ∈ F, weightedInvTotient (primeIntervalTilt 1 S (3 / 2)) n) = ∑ n ∈ F, (3 / 2 : ℝ) ^ omegaInterval n 1 S / (n.totient : ℝ) := by apply Finset.sum_congr rfl intro n hn have hn0 := (Nat.mem_factoredNumbers_iff_primeFactors_subset.mp (hF n hn)).1 rw [weightedInvTotient, primeWeightHom_intervalTilt 1 S (3 / 2) hn0] simp only [invTotient, div_eq_mul_inv] have hprimes : (Nat.primesLE ⌊x⌋₊).filter Nat.Prime = Nat.primesLE ⌊x⌋₊ := Finset.filter_eq_self.mpr (fun p hp => Nat.prime_of_mem_primesLE hp) rw [hsum, hprimes, primeIntervalTilt_sum] at hbound let P := (Nat.primesLE ⌊x⌋₊).filter (fun p : ℕ => 1 < (p : ℝ) ∧ (p : ℝ) ≤ S) have hsub : P ⊆ Nat.primesLE ⌊S⌋₊ := by intro p hp obtain ⟨hpprime, _, hpS⟩ := Finset.mem_filter.mp hp exact Nat.mem_primesLE.mpr ⟨Nat.le_floor hpS, Nat.prime_of_mem_primesLE hpprime⟩ have hprefix : (∑ p ∈ P, (1 : ℝ) / p) ≤ Real.log (Real.log S) + |B| := by have hsumle : (∑ p ∈ P, (1 : ℝ) / p) ≤ ∑ p ∈ Nat.primesLE ⌊S⌋₊, (1 : ℝ) / p := Finset.sum_le_sum_of_subset_of_nonneg hsub (fun _ _ _ => by positivity) have h := (abs_le.mp (hB S hS)).2 linarith [le_abs_self B] have hbase := (abs_le.mp (hB x hx)).2 have hexponent : (∑ p ∈ Nat.primesLE ⌊x⌋₊, (1 : ℝ) / p) + ((3 / 2 : ℝ) - 1) * (∑ p ∈ P, (1 : ℝ) / p) + 36 ≤ (36 + 2 * |B|) + Real.log (Real.log x) + (1 / 2 : ℝ) * Real.log (Real.log S) := by linarith [le_abs_self B, abs_nonneg B] calc _ ≤ Real.exp ((∑ p ∈ Nat.primesLE ⌊x⌋₊, (1 : ℝ) / p) + ((3 / 2 : ℝ) - 1) * (∑ p ∈ P, (1 : ℝ) / p) + 36) := hbound _ ≤ Real.exp ((36 + 2 * |B|) + Real.log (Real.log x) + (1 / 2 : ℝ) * Real.log (Real.log S)) := Real.exp_le_exp.mpr hexponent _ = _ := by rw [Real.exp_add, Real.exp_add, Real.exp_log hlog] /-- The small-prime tail after removing one prime from a shifted prime. The saving is exactly the exponent required by the normal-prime estimate. -/ /- Original line 14272: Erdos416Proof.exists_smallPrimeOmega_totient_tail_bound -/ theorem exists_smallPrimeOmega_totient_tail_bound : ∃ C : ℝ, 0 < C ∧ ∀ (x S : ℝ) (F : Finset ℕ), 2 ≤ x → Real.exp 1 ≤ S → (∀ n ∈ F, n ∈ Nat.factoredNumbers (Nat.primesLE ⌊x⌋₊)) → (∀ n ∈ F, 2 * Real.log (Real.log S) - 1 ≤ (omegaInterval n 1 S : ℝ)) → (∑ n ∈ F, invTotient n) ≤ C * Real.log x * Real.exp (-Real.log (Real.log S) / 6) := by obtain ⟨K, hK, hmoment⟩ := exists_smallPrimeOmega_totient_moment_bound refine ⟨(3 / 2 : ℝ) * K, by positivity, ?_⟩ intro x S F hx hS hF hdev have hS2 : 2 ≤ S := by linarith [Real.add_one_le_exp (1 : ℝ)] have hlog : 0 < Real.log x := Real.log_pos (by linarith) have hlogS : 1 ≤ Real.log S := by simpa only [Real.log_exp] using Real.log_le_log (Real.exp_pos 1) hS have hL : 0 ≤ Real.log (Real.log S) := Real.log_nonneg hlogS have hlogthree : (1 / 3 : ℝ) ≤ Real.log (3 / 2) := by have h := Real.one_sub_inv_le_log_of_pos (show (0 : ℝ) < 3 / 2 by norm_num) norm_num at h linarith have hweighted : (3 / 2 : ℝ) ^ (2 * Real.log (Real.log S) - 1) * (∑ n ∈ F, invTotient n) ≤ ∑ n ∈ F, (3 / 2 : ℝ) ^ omegaInterval n 1 S / (n.totient : ℝ) := by rw [Finset.mul_sum] apply Finset.sum_le_sum intro n hn have hpow := Real.rpow_le_rpow_of_exponent_le (show (1 : ℝ) ≤ 3 / 2 by norm_num) (hdev n hn) rw [Real.rpow_natCast] at hpow simpa only [invTotient, div_eq_mul_inv] using mul_le_mul_of_nonneg_right hpow (invTotient_nonneg n) have hexponent : (1 / 2 : ℝ) * Real.log (Real.log S) - Real.log (3 / 2) * (2 * Real.log (Real.log S) - 1) ≤ Real.log (3 / 2) - Real.log (Real.log S) / 6 := by nlinarith [mul_le_mul_of_nonneg_right hlogthree hL] calc _ ≤ K * Real.log x * Real.exp ((1 / 2 : ℝ) * Real.log (Real.log S)) / (3 / 2 : ℝ) ^ (2 * Real.log (Real.log S) - 1) := by apply (le_div_iff₀ (Real.rpow_pos_of_pos (by norm_num : (0 : ℝ) < 3 / 2) _)).mpr simpa only [mul_comm] using hweighted.trans (hmoment x S F hx hS2 hF) _ = K * Real.log x * Real.exp ((1 / 2 : ℝ) * Real.log (Real.log S) - Real.log (3 / 2) * (2 * Real.log (Real.log S) - 1)) := by rw [Real.rpow_def_of_pos (by norm_num : (0 : ℝ) < 3 / 2), mul_div_assoc, ← Real.exp_sub] _ ≤ K * Real.log x * Real.exp (Real.log (3 / 2) - Real.log (Real.log S) / 6) := mul_le_mul_of_nonneg_left (Real.exp_le_exp.mpr hexponent) (mul_nonneg hK.le hlog.le) _ = _ := by rw [sub_eq_add_neg, Real.exp_add, Real.exp_log (by norm_num : (0 : ℝ) < 3 / 2)]; ring /-- The elementary numerical margin needed when continuous interval endpoints are rounded to the double-exponential integer grid. -/ /- Original line 14315: Erdos416Proof.normal_grid_tail_parameters -/ theorem normal_grid_tail_parameters {L k : ℝ} (hL : 100 ≤ L) (hLk : L ≤ k + 1) : 0 < Real.sqrt ((k - 1) * L) - 4 ∧ Real.sqrt ((k - 1) * L) - 4 ≤ k + 1 ∧ L / 6 ≤ (Real.sqrt ((k - 1) * L) - 4) ^ 2 / (4 * (k + 1)) := by have hM : 0 < k + 1 := by linarith have hk : 0 ≤ k - 1 := by linarith have hL0 : 0 ≤ L := by linarith have hR0 := Real.sqrt_nonneg ((k - 1) * L) have hRsq := Real.sq_sqrt (mul_nonneg hk hL0) have hprod : (9800 : ℝ) ≤ (k - 1) * L := by have h := mul_le_mul (show (98 : ℝ) ≤ k - 1 by linarith) hL (by norm_num) hk norm_num at h exact h have hRlarge : (98 : ℝ) ≤ Real.sqrt ((k - 1) * L) := (sq_le_sq₀ (by norm_num) hR0).mp (by nlinarith) have hRle : Real.sqrt ((k - 1) * L) ≤ k + 1 := (sq_le_sq₀ hR0 hM.le).mp (by nlinarith [mul_le_mul_of_nonneg_left hLk hk]) refine ⟨by linarith, by linarith, ?_⟩ apply (le_div_iff₀ (by positivity : (0 : ℝ) < 4 * (k + 1))).mpr have h₁ := mul_nonneg (sub_nonneg.mpr hLk) (show (0 : ℝ) ≤ L - 24 by linarith) have h₂ := mul_nonneg hL0 (show (0 : ℝ) ≤ L - 30 by linarith) nlinarith end Erdos416Proof /- Actual shifted-prime cofactor fibres and fixed-interval exceptional counts. The finite interval grid and uniform normal-prime density theorem are proved in the following sections. -/ open Filter Asymptotics open scoped BigOperators Classical Topology namespace Erdos416Proof /- Original line 14353: Erdos416Proof.shiftedPrimeCofactor -/ def shiftedPrimeCofactor (p : ℕ) : ℕ := (p - 1) / largestPrimeFactor (p - 1) /- Original line 14355: Erdos416Proof.shiftedPrimeCofactor_mul -/ theorem shiftedPrimeCofactor_mul (p : ℕ) : shiftedPrimeCofactor p * largestPrimeFactor (p - 1) = p - 1 := Nat.div_mul_cancel (largestPrimeFactor_dvd (p - 1)) /- Original line 14359: Erdos416Proof.shiftedPrimeCofactor_data -/ theorem shiftedPrimeCofactor_data {p : ℕ} (hp : 3 ≤ p) : 0 < shiftedPrimeCofactor p ∧ (largestPrimeFactor (p - 1)).Prime ∧ shiftedPrimeCofactor p * largestPrimeFactor (p - 1) + 1 = p := by have hp1 : 1 < p - 1 := by omega have hq := largestPrimeFactor_isPrime (largestPrimeFactor_one_lt hp1) refine ⟨?_, hq, ?_⟩ · exact Nat.div_pos (Nat.le_of_dvd (by omega) (largestPrimeFactor_dvd (p - 1))) hq.pos · rw [shiftedPrimeCofactor_mul, Nat.sub_add_cancel (by omega)] /- Original line 14368: Erdos416Proof.shiftedPrimeCofactor_le -/ theorem shiftedPrimeCofactor_le (p : ℕ) : shiftedPrimeCofactor p ≤ p := (Nat.div_le_self _ _).trans (Nat.sub_le _ _) /-- The actual fibres of primes under their selected largest-prime cofactor. The proof counts the prime q in each fibre using the established two-form sieve. -/ /- Original line 14373: Erdos416Proof.exists_shiftedPrime_cofactor_count_bound -/ theorem exists_shiftedPrime_cofactor_count_bound : ∃ C : ℝ, 0 < C ∧ ∀ (Y a : ℝ) (F : Finset ℕ), 0 ≤ Y → 0 < a → (∀ p ∈ F, p.Prime ∧ 3 ≤ p ∧ (p : ℝ) ≤ Y ∧ a ≤ Real.log (largestPrimeFactor (p - 1))) → (F.card : ℝ) ≤ C * Y / a ^ 2 * ∑ b ∈ F.image shiftedPrimeCofactor, invTotient b := by obtain ⟨C, hC, hcount⟩ := exists_prime_cofactor_sieve_bound refine ⟨C, hC, ?_⟩ intro Y a F hY ha hF let B := F.image shiftedPrimeCofactor let Q := fun b => (F.filter (fun p => shiftedPrimeCofactor p = b)).image (fun p => largestPrimeFactor (p - 1)) have hB : ∀ b ∈ B, 0 < b := by intro b hb obtain ⟨p, hp, rfl⟩ := Finset.mem_image.mp hb exact (shiftedPrimeCofactor_data (hF p hp).2.1).1 have hQ : ∀ b ∈ B, ∀ q ∈ Q b, q.Prime ∧ (b * q + 1).Prime ∧ ((b * q + 1 : ℕ) : ℝ) ≤ Y ∧ a ≤ Real.log q := by intro b hb q hq obtain ⟨p, hp, rfl⟩ := Finset.mem_image.mp hq obtain ⟨hpF, hpb⟩ := Finset.mem_filter.mp hp have hd := shiftedPrimeCofactor_data (hF p hpF).2.1 have heq : b * largestPrimeFactor (p - 1) + 1 = p := by rw [← hpb]; exact hd.2.2 rw [heq] exact ⟨hd.2.1, (hF p hpF).1, (hF p hpF).2.2.1, (hF p hpF).2.2.2⟩ have hcard : F.card ≤ (B.sigma Q).card := by apply Finset.card_le_card_of_injOn (fun p => (⟨shiftedPrimeCofactor p, largestPrimeFactor (p - 1)⟩ : Σ _ : ℕ, ℕ)) · intro p hp exact Finset.mem_sigma.mpr ⟨Finset.mem_image.mpr ⟨p, hp, rfl⟩, Finset.mem_image.mpr ⟨p, Finset.mem_filter.mpr ⟨hp, rfl⟩, rfl⟩⟩ · intro p hp r hr heq have hb : shiftedPrimeCofactor p = shiftedPrimeCofactor r := congrArg Sigma.fst heq have hq : largestPrimeFactor (p - 1) = largestPrimeFactor (r - 1) := congrArg (fun z : Σ _ : ℕ, ℕ => z.2) heq calc p = shiftedPrimeCofactor p * largestPrimeFactor (p - 1) + 1 := (shiftedPrimeCofactor_data (hF p hp).2.1).2.2.symm _ = shiftedPrimeCofactor r * largestPrimeFactor (r - 1) + 1 := by rw [hb, hq] _ = r := (shiftedPrimeCofactor_data (hF r hr).2.1).2.2 have hsum : (F.card : ℝ) ≤ ∑ b ∈ B, ((Q b).card : ℝ) := by have h : (F.card : ℝ) ≤ (B.sigma Q).card := by exact_mod_cast hcard simpa only [Finset.card_sigma, Nat.cast_sum] using h calc _ ≤ ∑ b ∈ B, ((Q b).card : ℝ) := hsum _ ≤ ∑ b ∈ B, C * Y / ((b.totient : ℝ) * a ^ 2) := by apply Finset.sum_le_sum intro b hb exact hcount b Y a (Q b) (hB b hb) hY ha (hQ b hb) _ = _ := by rw [Finset.mul_sum] apply Finset.sum_congr rfl intro b hb simp only [invTotient, div_eq_mul_inv, mul_inv_rev] ring /- Original line 14428: Erdos416Proof.omegaInterval_prime -/ theorem omegaInterval_prime {q : ℕ} (hq : q.Prime) (u v : ℝ) : omegaInterval q u v = if u < (q : ℝ) ∧ (q : ℝ) ≤ v then 1 else 0 := by by_cases h : u < (q : ℝ) ∧ (q : ℝ) ≤ v <;> simp [Erdos416Proof.omegaInterval_one, omegaInterval, Nat.primeFactorsList_prime hq, h] /- Original line 14433: Erdos416Proof.shiftedPrimeCofactor_omega_bounds -/ theorem shiftedPrimeCofactor_omega_bounds {p : ℕ} (hp : 3 ≤ p) (u v : ℝ) : omegaInterval (shiftedPrimeCofactor p) u v ≤ omegaInterval (p - 1) u v ∧ omegaInterval (p - 1) u v ≤ omegaInterval (shiftedPrimeCofactor p) u v + 1 := by have hd := shiftedPrimeCofactor_data hp have hω := omegaInterval_mul hd.1.ne' hd.2.1.ne_zero u v rw [shiftedPrimeCofactor_mul] at hω rw [hω, omegaInterval_prime hd.2.1] split_ifs <;> omega /- Original line 14442: Erdos416Proof.shiftedPrimeCofactor_deviation_transfer -/ theorem shiftedPrimeCofactor_deviation_transfer {p : ℕ} (hp : 3 ≤ p) (u v μ H : ℝ) (hdev : H ≤ |(omegaInterval (p - 1) u v : ℝ) - μ|) : H - 1 ≤ |(omegaInterval (shiftedPrimeCofactor p) u v : ℝ) - μ| := by have hb := shiftedPrimeCofactor_omega_bounds hp u v have h₁ : (omegaInterval (shiftedPrimeCofactor p) u v : ℝ) ≤ omegaInterval (p - 1) u v := by exact_mod_cast hb.1 have h₂ : (omegaInterval (p - 1) u v : ℝ) ≤ omegaInterval (shiftedPrimeCofactor p) u v + 1 := by exact_mod_cast hb.2 have hdiff : |(omegaInterval (p - 1) u v : ℝ) - omegaInterval (shiftedPrimeCofactor p) u v| ≤ 1 := by rw [abs_of_nonneg (sub_nonneg.mpr h₁)] linarith have htriangle := abs_sub_le (omegaInterval (p - 1) u v : ℝ) (omegaInterval (shiftedPrimeCofactor p) u v : ℝ) μ linarith /- Original line 14457: Erdos416Proof.shiftedLargestPrime_log_lower_bound -/ theorem shiftedLargestPrime_log_lower_bound {p : ℕ} (hp : 17 ≤ p) {x T : ℝ} (hx : 0 < x) (hT : 0 < T) (hpx : Real.sqrt x ≤ (p : ℝ)) (hΩ : (ArithmeticFunction.cardFactors (p - 1) : ℝ) ≤ 12 * T) : Real.log x / (30 * T) ≤ Real.log (largestPrimeFactor (p - 1)) := by have hbound := shifted_largestPrimeFactor_log_bound hp (T := 3 * T) (by nlinarith : (ArithmeticFunction.cardFactors (p - 1) : ℝ) ≤ 4 * (3 * T)) have hlog := Real.log_le_log (Real.sqrt_pos.mpr hx) hpx rw [Real.log_sqrt hx.le] at hlog apply (div_le_iff₀ (by positivity : (0 : ℝ) < 30 * T)).mpr nlinarith /- Original line 14468: Erdos416Proof.exists_normalPrime_cofactor_reduction -/ theorem exists_normalPrime_cofactor_reduction : ∃ C : ℝ, 0 < C ∧ ∀ (x T : ℝ) (F : Finset ℕ), 1 < x → 0 < T → (∀ p ∈ F, p.Prime ∧ 17 ≤ p ∧ Real.sqrt x ≤ (p : ℝ) ∧ (p : ℝ) ≤ x ∧ (ArithmeticFunction.cardFactors (p - 1) : ℝ) ≤ 12 * T) → (F.card : ℝ) ≤ C * x * T ^ 2 / Real.log x ^ 2 * ∑ b ∈ F.image shiftedPrimeCofactor, invTotient b := by obtain ⟨C, hC, hcount⟩ := exists_shiftedPrime_cofactor_count_bound refine ⟨900 * C, by positivity, ?_⟩ intro x T F hx hT hF have hx0 : 0 < x := by linarith have hlog : 0 < Real.log x := Real.log_pos hx have h := hcount x (Real.log x / (30 * T)) F hx0.le (by positivity) (by intro p hp obtain ⟨hprime, hp17, hpsqrt, hpx, hΩ⟩ := hF p hp exact ⟨hprime, by omega, hpx, shiftedLargestPrime_log_lower_bound hp17 hx0 hT hpsqrt hΩ⟩) calc _ ≤ C * x / (Real.log x / (30 * T)) ^ 2 * ∑ b ∈ F.image shiftedPrimeCofactor, invTotient b := h _ = _ := by field_simp; ring /- Original line 14488: Erdos416Proof.shiftedPrimeCofactors_factored -/ theorem shiftedPrimeCofactors_factored {x : ℝ} {F : Finset ℕ} (hF : ∀ p ∈ F, 3 ≤ p ∧ (p : ℝ) ≤ x) : ∀ b ∈ F.image shiftedPrimeCofactor, b ∈ Nat.factoredNumbers (Nat.primesLE ⌊x⌋₊) := by intro b hb obtain ⟨p, hp, rfl⟩ := Finset.mem_image.mp hb apply factored_primesLE_of_positive_le (shiftedPrimeCofactor_data (hF p hp).1).1 exact (show (shiftedPrimeCofactor p : ℝ) ≤ p by exact_mod_cast shiftedPrimeCofactor_le p).trans (hF p hp).2 /-- The actual small-prime normality failure among primes with a large selected factor, after the two-form sieve is combined with the moment bound. -/ /- Original line 14500: Erdos416Proof.exists_smallPrime_normality_failure_bound -/ theorem exists_smallPrime_normality_failure_bound : ∃ C : ℝ, 0 < C ∧ ∀ (x S T : ℝ) (F : Finset ℕ), 2 ≤ x → Real.exp 1 ≤ S → 0 < T → (∀ p ∈ F, p.Prime ∧ 17 ≤ p ∧ Real.sqrt x ≤ (p : ℝ) ∧ (p : ℝ) ≤ x ∧ (ArithmeticFunction.cardFactors (p - 1) : ℝ) ≤ 12 * T) → (∀ p ∈ F, 2 * Real.log (Real.log S) < (omegaInterval (p - 1) 1 S : ℝ)) → (F.card : ℝ) ≤ C * x * T ^ 2 / Real.log x * Real.exp (-Real.log (Real.log S) / 6) := by obtain ⟨C₁, hC₁, hcount⟩ := exists_normalPrime_cofactor_reduction obtain ⟨C₂, hC₂, htail⟩ := exists_smallPrimeOmega_totient_tail_bound refine ⟨C₁ * C₂, mul_pos hC₁ hC₂, ?_⟩ intro x S T F hx hS hT hF hbad have hx1 : 1 < x := by linarith have hx0 : 0 < x := by linarith have hlog : 0 < Real.log x := Real.log_pos hx1 have hs := htail x S (F.image shiftedPrimeCofactor) hx hS (shiftedPrimeCofactors_factored (fun p hp => ⟨by have := (hF p hp).2.1; omega, (hF p hp).2.2.2.1⟩)) (by intro b hb obtain ⟨p, hp, rfl⟩ := Finset.mem_image.mp hb have hp3 : 3 ≤ p := by have := (hF p hp).2.1; omega have hω : (omegaInterval (p - 1) 1 S : ℝ) ≤ omegaInterval (shiftedPrimeCofactor p) 1 S + 1 := by exact_mod_cast (shiftedPrimeCofactor_omega_bounds hp3 1 S).2 linarith [hbad p hp]) have h := hcount x T F hx1 hT hF calc _ ≤ C₁ * x * T ^ 2 / Real.log x ^ 2 * ∑ b ∈ F.image shiftedPrimeCofactor, invTotient b := h _ ≤ C₁ * x * T ^ 2 / Real.log x ^ 2 * (C₂ * Real.log x * Real.exp (-Real.log (Real.log S) / 6)) := mul_le_mul_of_nonneg_left hs (by positivity) _ = _ := by field_simp /-- A fixed-interval failure bound for the actual primes. The moment support endpoint X may exceed the original counting endpoint x, as required at the top of the rounded grid. -/ /- Original line 14535: Erdos416Proof.exists_interval_normality_failure_bound -/ theorem exists_interval_normality_failure_bound : ∃ C : ℝ, 0 < C ∧ ∀ (x X u v T h M : ℝ) (F : Finset ℕ), 2 ≤ x → x ≤ X → 2 ≤ u → u ≤ v → v ≤ X → 0 < T → 0 < h → h ≤ M → Real.log (Real.log v) - Real.log (Real.log u) ≤ M → (∀ p ∈ F, p.Prime ∧ 17 ≤ p ∧ Real.sqrt x ≤ (p : ℝ) ∧ (p : ℝ) ≤ x ∧ (ArithmeticFunction.cardFactors (p - 1) : ℝ) ≤ 12 * T) → (∀ p ∈ F, h + 1 ≤ |(omegaInterval (p - 1) u v : ℝ) - (Real.log (Real.log v) - Real.log (Real.log u))|) → (F.card : ℝ) ≤ C * x * T ^ 2 / Real.log x ^ 2 * Real.log X * Real.exp (-h ^ 2 / (4 * M)) := by obtain ⟨C₁, hC₁, hcount⟩ := exists_normalPrime_cofactor_reduction obtain ⟨C₂, hC₂, htail⟩ := exists_omegaInterval_totient_deviation_bound refine ⟨C₁ * C₂, mul_pos hC₁ hC₂, ?_⟩ intro x X u v T h M F hx hxX hu huv hvX hT hh hhM hΔM hF hbad have hx1 : 1 < x := by linarith have hx0 : 0 < x := by linarith have hlog : 0 < Real.log x := Real.log_pos hx1 have hs := htail X u v h M (F.image shiftedPrimeCofactor) hu huv hvX hh hhM hΔM (shiftedPrimeCofactors_factored (fun p hp => ⟨by have := (hF p hp).2.1; omega, (hF p hp).2.2.2.1.trans hxX⟩)) (by intro b hb obtain ⟨p, hp, rfl⟩ := Finset.mem_image.mp hb have hp3 : 3 ≤ p := by have := (hF p hp).2.1; omega simpa only [add_sub_cancel_right] using shiftedPrimeCofactor_deviation_transfer hp3 u v (Real.log (Real.log v) - Real.log (Real.log u)) (h + 1) (hbad p hp)) have hcountF := hcount x T F hx1 hT hF calc _ ≤ C₁ * x * T ^ 2 / Real.log x ^ 2 * ∑ b ∈ F.image shiftedPrimeCofactor, invTotient b := hcountF _ ≤ C₁ * x * T ^ 2 / Real.log x ^ 2 * (C₂ * Real.log X * Real.exp (-h ^ 2 / (4 * M))) := mul_le_mul_of_nonneg_left hs (by positivity) _ = _ := by ring end Erdos416Proof /- Finite rounding of all abnormal real intervals. The next section sums the exceptional families and covers every parameter regime to establish the normal-prime density theorem. -/ open Filter Asymptotics open scoped BigOperators Classical Topology namespace Erdos416Proof /- Original line 14583: Erdos416Proof.omegaInterval_mono_bounds -/ theorem omegaInterval_mono_bounds (n : ℕ) {u u' v v' : ℝ} (hu : u' ≤ u) (hv : v ≤ v') : omegaInterval n u v ≤ omegaInterval n u' v' := by apply List.countP_mono_left intro p hp h simp only [decide_eq_true_eq] at h ⊢ exact ⟨hu.trans_lt h.1, h.2.trans hv⟩ /- Original line 14590: Erdos416Proof.normalityGridPoint -/ noncomputable def normalityGridPoint (j : ℕ) : ℝ := Real.exp (Real.exp (j : ℝ)) /- Original line 14592: Erdos416Proof.logLog_normalityGridPoint -/ theorem logLog_normalityGridPoint (j : ℕ) : logLog (normalityGridPoint j) = j := by simp [logLog, normalityGridPoint] /- Original line 14596: Erdos416Proof.normalityGridPoint_mono -/ theorem normalityGridPoint_mono : Monotone normalityGridPoint := by intro j k hjk apply Real.exp_le_exp.mpr apply Real.exp_le_exp.mpr exact_mod_cast hjk /- Original line 14602: Erdos416Proof.normalityGridPoint_le -/ theorem normalityGridPoint_le {j : ℕ} {x : ℝ} (hx : 1 < x) (hj : (j : ℝ) ≤ logLog x) : normalityGridPoint j ≤ x := by calc normalityGridPoint j ≤ Real.exp (Real.exp (logLog x)) := Real.exp_le_exp.mpr (Real.exp_le_exp.mpr hj) _ = x := by rw [logLog, Real.exp_log (Real.log_pos hx), Real.exp_log (by linarith)] /- Original line 14609: Erdos416Proof.le_normalityGridPoint -/ theorem le_normalityGridPoint {j : ℕ} {x : ℝ} (hx : 1 < x) (hj : logLog x ≤ (j : ℝ)) : x ≤ normalityGridPoint j := by calc x = Real.exp (Real.exp (logLog x)) := by rw [logLog, Real.exp_log (Real.log_pos hx), Real.exp_log (by linarith)] _ ≤ normalityGridPoint j := Real.exp_le_exp.mpr (Real.exp_le_exp.mpr hj) /-- Round an arbitrary abnormal interval before removing the largest prime factor. The retained margin is three; the cofactor step uses one more. -/ /- Original line 14618: Erdos416Proof.exists_normality_grid_interval -/ theorem exists_normality_grid_interval (n : ℕ) {L u v x : ℝ} (hL : 100 ≤ L) (hu : 1 < u) (huv : u < v) (hvx : v ≤ x) (hLu : L ≤ logLog u) (hbad : Real.sqrt (L * logLog v) ≤ |(omegaInterval n u v : ℝ) - (logLog v - logLog u)|) : ∃ j k : ℕ, L - 1 ≤ (j : ℝ) ∧ j < k ∧ k ≤ ⌊logLog x⌋₊ + 1 ∧ Real.sqrt (((k : ℝ) - 1) * L) - 3 ≤ |(omegaInterval n (normalityGridPoint j) (normalityGridPoint k) : ℝ) - ((k : ℝ) - j)| := by have hv : 1 < v := hu.trans huv have hA0 : 0 ≤ logLog u := by linarith have hAB : logLog u ≤ logLog v := logLog_mono hu huv.le have hB0 : 0 ≤ logLog v := hA0.trans hAB have hBX : logLog v ≤ logLog x := logLog_mono hv hvx have hL0 : 0 ≤ L := by linarith have hjle := Nat.floor_le hA0 have hjlt := Nat.lt_floor_add_one (logLog u) have hkle := Nat.floor_le hB0 have hklt := Nat.lt_floor_add_one (logLog v) have hfloorAB := Nat.floor_mono hAB have hfloorBX := Nat.floor_mono hBX have hlarge : L ≤ Real.sqrt (L * logLog v) := by apply (sq_le_sq₀ hL0 (Real.sqrt_nonneg _)).mp rw [Real.sq_sqrt (mul_nonneg hL0 hB0)] nlinarith by_cases hsign : 0 ≤ (omegaInterval n u v : ℝ) - (logLog v - logLog u) · rw [abs_of_nonneg hsign] at hbad let j := ⌊logLog u⌋₊ let k := ⌊logLog v⌋₊ + 1 have hj : normalityGridPoint j ≤ u := normalityGridPoint_le hu hjle have hk : v ≤ normalityGridPoint k := le_normalityGridPoint hv (by dsimp [Erdos416Proof.logLog_normalityGridPoint, Erdos416Proof.omegaInterval_one, k]; push_cast; exact hklt.le) have hcount : (omegaInterval n u v : ℝ) ≤ omegaInterval n (normalityGridPoint j) (normalityGridPoint k) := by exact_mod_cast omegaInterval_mono_bounds n hj hk have hkr : (k : ℝ) = (⌊logLog v⌋₊ : ℝ) + 1 := by simp [Erdos416Proof.logLog_normalityGridPoint, Erdos416Proof.omegaInterval_one, k] have hroot : Real.sqrt (((k : ℝ) - 1) * L) ≤ Real.sqrt (L * logLog v) := by apply Real.sqrt_le_sqrt rw [hkr] nlinarith refine ⟨j, k, ?_, ?_, ?_, ?_⟩ · dsimp [Erdos416Proof.logLog_normalityGridPoint, Erdos416Proof.omegaInterval_one, j]; linarith · dsimp [Erdos416Proof.logLog_normalityGridPoint, Erdos416Proof.omegaInterval_one, j, k]; omega · dsimp [Erdos416Proof.logLog_normalityGridPoint, Erdos416Proof.omegaInterval_one, k]; omega · have hjr : (j : ℝ) = (⌊logLog u⌋₊ : ℝ) := rfl have habs := le_abs_self ((omegaInterval n (normalityGridPoint j) (normalityGridPoint k) : ℝ) - ((k : ℝ) - j)) linarith · rw [abs_of_nonpos (le_of_not_ge hsign)] at hbad let j := ⌊logLog u⌋₊ + 1 let k := ⌊logLog v⌋₊ have hjr : (j : ℝ) = (⌊logLog u⌋₊ : ℝ) + 1 := by simp [Erdos416Proof.logLog_normalityGridPoint, Erdos416Proof.omegaInterval_one, j] have hkr : (k : ℝ) = (⌊logLog v⌋₊ : ℝ) := rfl have hjk : j < k := by by_contra hnot have hkj : k ≤ j := le_of_not_gt hnot have hkjR : (k : ℝ) ≤ j := by exact_mod_cast hkj have hcount0 : (0 : ℝ) ≤ omegaInterval n u v := Nat.cast_nonneg _ linarith have hj : u ≤ normalityGridPoint j := le_normalityGridPoint hu (by rw [hjr]; exact hjlt.le) have hk : normalityGridPoint k ≤ v := normalityGridPoint_le hv hkle have hcount : (omegaInterval n (normalityGridPoint j) (normalityGridPoint k) : ℝ) ≤ omegaInterval n u v := by exact_mod_cast omegaInterval_mono_bounds n hj hk have hroot : Real.sqrt (((k : ℝ) - 1) * L) ≤ Real.sqrt (L * logLog v) := by apply Real.sqrt_le_sqrt rw [hkr] nlinarith refine ⟨j, k, ?_, hjk, ?_, ?_⟩ · rw [hjr]; linarith · dsimp [Erdos416Proof.logLog_normalityGridPoint, Erdos416Proof.omegaInterval_one, k]; omega · have habs := neg_le_abs ((omegaInterval n (normalityGridPoint j) (normalityGridPoint k) : ℝ) - ((k : ℝ) - j)) linarith /- Original line 14694: Erdos416Proof.normalityGrid_support_bound -/ theorem normalityGrid_support_bound {x : ℝ} (hx : 1 < x) (hLL : 0 ≤ logLog x) : x ≤ normalityGridPoint (⌊logLog x⌋₊ + 1) ∧ Real.log (normalityGridPoint (⌊logLog x⌋₊ + 1)) ≤ Real.exp 1 * Real.log x := by constructor · apply le_normalityGridPoint hx push_cast exact (Nat.lt_floor_add_one (logLog x)).le · simp only [normalityGridPoint, Real.log_exp, Nat.cast_add, Nat.cast_one] calc Real.exp ((⌊logLog x⌋₊ : ℝ) + 1) ≤ Real.exp (logLog x + 1) := Real.exp_le_exp.mpr (by linarith [Nat.floor_le hLL]) _ = Real.exp 1 * Real.log x := by rw [Real.exp_add, logLog, Real.exp_log (Real.log_pos hx), mul_comm] /- Original line 14708: Erdos416Proof.normalityGridPoint_ge_two -/ theorem normalityGridPoint_ge_two (j : ℕ) : 2 ≤ normalityGridPoint j := by calc (2 : ℝ) ≤ Real.exp 1 := by linarith [Real.add_one_le_exp (1 : ℝ)] _ ≤ normalityGridPoint j := Real.exp_le_exp.mpr (Real.one_le_exp_iff.mpr (Nat.cast_nonneg j)) /- Original line 14714: Erdos416Proof.normalityGridPairs -/ noncomputable def normalityGridPairs (L T : ℝ) : Finset (ℕ × ℕ) := ((Finset.range (⌊T⌋₊ + 2)).product (Finset.range (⌊T⌋₊ + 2))).filter (fun jk : ℕ × ℕ => L - 1 ≤ (jk.1 : ℝ) ∧ jk.1 < jk.2) /- Original line 14718: Erdos416Proof.mem_normalityGridPairs -/ theorem mem_normalityGridPairs {L T : ℝ} {j k : ℕ} : (j, k) ∈ normalityGridPairs L T ↔ L - 1 ≤ (j : ℝ) ∧ j < k ∧ k ≤ ⌊T⌋₊ + 1 := by simp only [normalityGridPairs, Finset.mem_filter, Finset.product_eq_sprod, Finset.mem_product, Finset.mem_range] constructor · rintro ⟨⟨hj, hk⟩, hL, hjk⟩ exact ⟨hL, hjk, by omega⟩ · rintro ⟨hL, hjk, hk⟩ exact ⟨⟨by omega, by omega⟩, hL, hjk⟩ /- Original line 14729: Erdos416Proof.normalityGridPairs_card_bound -/ theorem normalityGridPairs_card_bound (L : ℝ) {T : ℝ} (hT : 0 ≤ T) : ((normalityGridPairs L T).card : ℝ) ≤ 4 * (1 + T) ^ 2 := by have hcard := Finset.card_filter_le ((Finset.range (⌊T⌋₊ + 2)).product (Finset.range (⌊T⌋₊ + 2))) (fun jk : ℕ × ℕ => L - 1 ≤ (jk.1 : ℝ) ∧ jk.1 < jk.2) change (normalityGridPairs L T).card ≤ _ at hcard simp only [Finset.product_eq_sprod, Finset.card_product, Finset.card_range] at hcard have hcardR : ((normalityGridPairs L T).card : ℝ) ≤ ((⌊T⌋₊ : ℝ) + 2) ^ 2 := by exact_mod_cast (show (normalityGridPairs L T).card ≤ (⌊T⌋₊ + 2) ^ 2 by simpa only [pow_two] using hcard) have hf0 : (0 : ℝ) ≤ (⌊T⌋₊ : ℝ) := Nat.cast_nonneg _ have hfle := Nat.floor_le hT have hsq : ((⌊T⌋₊ : ℝ) + 2) ^ 2 ≤ (T + 2) ^ 2 := by nlinarith nlinarith [sq_nonneg T] end Erdos416Proof /- Uniform normal-prime density for the actual exceptional prime set. The proved density theorem discharges the analytic hypothesis in the squarefree exceptional-preimage pruning applications. -/ open Filter Asymptotics open scoped BigOperators Classical Topology namespace Erdos416Proof /- Original line 14758: Erdos416Proof.IntervalNormalityFailure -/ def IntervalNormalityFailure (S : ℝ) (p : ℕ) : Prop := ∃ u v : ℝ, S ≤ u ∧ u < v ∧ v ≤ ((p - 1 : ℕ) : ℝ) ∧ Real.sqrt (logLog S * logLog v) ≤ |(omegaInterval (p - 1) u v : ℝ) - (logLog v - logLog u)| /- Original line 14763: Erdos416Proof.not_SNormal_iff_failure -/ theorem not_SNormal_iff_failure {S : ℝ} {p : ℕ} (hp : p.Prime) : ¬ SNormal S p ↔ 2 * logLog S < (omegaInterval (p - 1) 1 S : ℝ) ∨ IntervalNormalityFailure S p := by constructor · intro h by_cases hsmall : (omegaInterval (p - 1) 1 S : ℝ) ≤ 2 * logLog S · right by_contra hnone apply h refine ⟨hp, hsmall, ?_⟩ intro u v hSu huv hvp by_contra hbad exact hnone ⟨u, v, hSu, huv, hvp, le_of_not_gt hbad⟩ · exact Or.inl (lt_of_not_ge hsmall) · rintro (hsmall | ⟨u, v, hSu, huv, hvp, hbad⟩) hnormal · exact (not_lt_of_ge hnormal.2.1) hsmall · exact (not_le_of_gt (hnormal.2.2 u v hSu huv hvp)) hbad /-- The fixed-interval bounds summed over the actual finite grid, with a single constant uniform in both the support and normality parameters. -/ /- Original line 14783: Erdos416Proof.exists_allInterval_normality_failure_bound -/ theorem exists_allInterval_normality_failure_bound : ∃ C : ℝ, 0 < C ∧ ∀ (x S : ℝ) (F : Finset ℕ), 2 ≤ x → 0 < logLog x → Real.exp 1 ≤ S → 100 ≤ logLog S → (∀ p ∈ F, p.Prime ∧ 17 ≤ p ∧ Real.sqrt x ≤ (p : ℝ) ∧ (p : ℝ) ≤ x ∧ (ArithmeticFunction.cardFactors (p - 1) : ℝ) ≤ 12 * logLog x) → (∀ p ∈ F, IntervalNormalityFailure S p) → (F.card : ℝ) ≤ C * x / Real.log x * (1 + logLog x) ^ 4 * Real.exp (-logLog S / 6) := by obtain ⟨C, hC, hcount⟩ := exists_interval_normality_failure_bound refine ⟨4 * C * Real.exp 1, by positivity, ?_⟩ intro x S F hx hT hS hL hF hbad have hx1 : 1 < x := by linarith have hx0 : 0 < x := by linarith have hlog : 0 < Real.log x := Real.log_pos hx1 have hSone : 1 < S := by linarith [Real.add_one_le_exp (1 : ℝ)] let T := logLog x let L := logLog S let P := normalityGridPairs L T let X := normalityGridPoint (⌊T⌋₊ + 1) let G := fun jk : ℕ × ℕ => F.filter (fun p : ℕ => Real.sqrt (((jk.2 : ℝ) - 1) * L) - 3 ≤ |(omegaInterval (p - 1) (normalityGridPoint jk.1) (normalityGridPoint jk.2) : ℝ) - ((jk.2 : ℝ) - jk.1)|) have hcover : F ⊆ P.biUnion G := by intro p hp obtain ⟨u, v, hSu, huv, hvp, hdev⟩ := hbad p hp have hvx : v ≤ x := hvp.trans ((show ((p - 1 : ℕ) : ℝ) ≤ p by exact_mod_cast Nat.sub_le p 1).trans (hF p hp).2.2.2.1) obtain ⟨j, k, hj, hjk, hk, hgrid⟩ := exists_normality_grid_interval (p - 1) hL (hSone.trans_le hSu) huv hvx (logLog_mono hSone hSu) hdev refine Finset.mem_biUnion.mpr ⟨(j, k), ?_, ?_⟩ · exact mem_normalityGridPairs.mpr ⟨hj, hjk, hk⟩ · exact Finset.mem_filter.mpr ⟨hp, hgrid⟩ have hX := normalityGrid_support_bound hx1 hT.le have hper : ∀ jk ∈ P, ((G jk).card : ℝ) ≤ C * Real.exp 1 * x / Real.log x * T ^ 2 * Real.exp (-L / 6) := by rintro ⟨j, k⟩ hjkP obtain ⟨hjL, hjk, hkN⟩ := mem_normalityGridPairs.mp hjkP have hj0 : (0 : ℝ) ≤ j := Nat.cast_nonneg _ have hjkR : (j : ℝ) + 1 ≤ k := by exact_mod_cast hjk have hLk : L ≤ (k : ℝ) + 1 := by linarith obtain ⟨hh, hhM, hsave⟩ := normal_grid_tail_parameters hL hLk have hμ : Real.log (Real.log (normalityGridPoint k)) - Real.log (Real.log (normalityGridPoint j)) ≤ (k : ℝ) + 1 := by change logLog (normalityGridPoint k) - logLog (normalityGridPoint j) ≤ _ simp only [logLog_normalityGridPoint] linarith have hc := hcount x X (normalityGridPoint j) (normalityGridPoint k) T (Real.sqrt (((k : ℝ) - 1) * L) - 4) ((k : ℝ) + 1) (G (j, k)) hx hX.1 (normalityGridPoint_ge_two j) (normalityGridPoint_mono hjk.le) (normalityGridPoint_mono hkN) hT hh hhM hμ (fun p hp => hF p (Finset.mem_filter.mp hp).1) (by intro p hp have hd := (Finset.mem_filter.mp hp).2 change Real.sqrt (((k : ℝ) - 1) * L) - 4 + 1 ≤ |(omegaInterval (p - 1) (normalityGridPoint j) (normalityGridPoint k) : ℝ) - (logLog (normalityGridPoint k) - logLog (normalityGridPoint j))| simp only [logLog_normalityGridPoint] linarith) have he : Real.exp (-(Real.sqrt (((k : ℝ) - 1) * L) - 4) ^ 2 / (4 * ((k : ℝ) + 1))) ≤ Real.exp (-L / 6) := by apply Real.exp_le_exp.mpr change L / 6 ≤ (Real.sqrt (((k : ℝ) - 1) * L) - 4) ^ 2 / (4 * ((k : ℝ) + 1)) at hsave simpa only [neg_div] using neg_le_neg hsave have hcoef : 0 ≤ C * x * T ^ 2 / Real.log x ^ 2 := by positivity calc _ ≤ C * x * T ^ 2 / Real.log x ^ 2 * Real.log X * Real.exp (-(Real.sqrt (((k : ℝ) - 1) * L) - 4) ^ 2 / (4 * ((k : ℝ) + 1))) := hc _ ≤ C * x * T ^ 2 / Real.log x ^ 2 * (Real.exp 1 * Real.log x) * Real.exp (-L / 6) := mul_le_mul (mul_le_mul_of_nonneg_left hX.2 hcoef) he (Real.exp_pos _).le (by positivity) _ = _ := by field_simp have hcardN : F.card ≤ ∑ jk ∈ P, (G jk).card := (Finset.card_le_card hcover).trans Finset.card_biUnion_le have hcardR : (F.card : ℝ) ≤ ∑ jk ∈ P, ((G jk).card : ℝ) := by exact_mod_cast hcardN have hP := normalityGridPairs_card_bound L hT.le have hT0 : 0 ≤ T := hT.le have hTpow : T ^ 2 ≤ (1 + T) ^ 2 := by nlinarith calc _ ≤ ∑ jk ∈ P, ((G jk).card : ℝ) := hcardR _ ≤ ∑ _jk ∈ P, C * Real.exp 1 * x / Real.log x * T ^ 2 * Real.exp (-L / 6) := Finset.sum_le_sum hper _ = (P.card : ℝ) * (C * Real.exp 1 * x / Real.log x * T ^ 2 * Real.exp (-L / 6)) := by simp[Erdos416Proof.logLog_normalityGridPoint, Erdos416Proof.omegaInterval_one] _ ≤ (4 * (1 + T) ^ 2) * (C * Real.exp 1 * x / Real.log x * T ^ 2 * Real.exp (-L / 6)) := mul_le_mul_of_nonneg_right hP (by positivity) _ ≤ _ := by have h := mul_le_mul_of_nonneg_left hTpow (show 0 ≤ 4 * (1 + T) ^ 2 * (C * Real.exp 1 * x / Real.log x * Real.exp (-L / 6)) by positivity) convert! h using 1 <;> ring /- Original line 14875: Erdos416Proof.exists_retained_nonNormal_bound -/ theorem exists_retained_nonNormal_bound : ∃ C : ℝ, 0 < C ∧ ∀ (x S : ℝ) (F : Finset ℕ), 2 ≤ x → 0 < logLog x → Real.exp 1 ≤ S → 100 ≤ logLog S → (∀ p ∈ F, p.Prime ∧ 17 ≤ p ∧ Real.sqrt x ≤ (p : ℝ) ∧ (p : ℝ) ≤ x ∧ (ArithmeticFunction.cardFactors (p - 1) : ℝ) ≤ 12 * logLog x) → (∀ p ∈ F, ¬ SNormal S p) → (F.card : ℝ) ≤ C * x / Real.log x * (1 + logLog x) ^ 4 * Real.exp (-logLog S / 6) := by obtain ⟨C₁, hC₁, hsmall⟩ := exists_smallPrime_normality_failure_bound obtain ⟨C₂, hC₂, hinterval⟩ := exists_allInterval_normality_failure_bound refine ⟨C₁ + C₂, add_pos hC₁ hC₂, ?_⟩ intro x S F hx hT hS hL hF hbad let P := fun p : ℕ => 2 * logLog S < (omegaInterval (p - 1) 1 S : ℝ) have hs := hsmall x S (logLog x) (F.filter P) hx hS hT (fun p hp => hF p (Finset.mem_filter.mp hp).1) (fun p hp => (Finset.mem_filter.mp hp).2) change ((F.filter P).card : ℝ) ≤ C₁ * x * logLog x ^ 2 / Real.log x * Real.exp (-logLog S / 6) at hs have hi := hinterval x S (F.filter (fun p => ¬P p)) hx hT hS hL (fun p hp => hF p (Finset.mem_filter.mp hp).1) (by intro p hp obtain ⟨hpF, hpP⟩ := Finset.mem_filter.mp hp exact ((not_SNormal_iff_failure (hF p hpF).1).mp (hbad p hpF)).resolve_left hpP) have hpow : logLog x ^ 2 ≤ (1 + logLog x) ^ 4 := by have h₁ : logLog x ^ 2 ≤ (1 + logLog x) ^ 2 := by nlinarith have h₂ : 1 ≤ (1 + logLog x) ^ 2 := by nlinarith nlinarith [sq_nonneg ((1 + logLog x) ^ 2 - 1)] have hlog : 0 < Real.log x := Real.log_pos (by linarith) have hs' : ((F.filter P).card : ℝ) ≤ C₁ * x / Real.log x * (1 + logLog x) ^ 4 * Real.exp (-logLog S / 6) := by apply hs.trans convert! mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left hpow (show 0 ≤ C₁ * x / Real.log x by positivity)) (Real.exp_pos (-logLog S / 6)).le using 1 <;> ring have hcard : (F.card : ℝ) = ((F.filter P).card : ℝ) + ((F.filter (fun p => ¬P p)).card : ℝ) := by exact_mod_cast (Finset.card_filter_add_card_filter_not (s := F) P).symm rw [hcard] calc _ ≤ C₁ * x / Real.log x * (1 + logLog x) ^ 4 * Real.exp (-logLog S / 6) + C₂ * x / Real.log x * (1 + logLog x) ^ 4 * Real.exp (-logLog S / 6) := add_le_add hs' hi _ = _ := by ring /- Original line 14918: Erdos416Proof.finite_positive_card_le -/ theorem finite_positive_card_le {x : ℝ} (hx : 0 ≤ x) (F : Finset ℕ) (hF : ∀ n ∈ F, 0 < n ∧ (n : ℝ) ≤ x) : (F.card : ℝ) ≤ x := by have hsub : F ⊆ Finset.Icc 1 ⌊x⌋₊ := by intro n hn exact Finset.mem_Icc.mpr ⟨(hF n hn).1, Nat.le_floor (hF n hn).2⟩ have hcard : F.card ≤ ⌊x⌋₊ := by simpa using Finset.card_le_card hsub exact (show (F.card : ℝ) ≤ (⌊x⌋₊ : ℝ) by exact_mod_cast hcard).trans (Nat.floor_le hx) /- Original line 14927: Erdos416Proof.small_retention_failures_bound -/ theorem small_retention_failures_bound {x : ℝ} (hx : 3 ≤ x) (F : Finset ℕ) (hF : ∀ p ∈ F, 0 < p ∧ (p < 17 ∨ (p : ℝ) < Real.sqrt x)) : (F.card : ℝ) ≤ 144 * x / Real.log x ^ 2 := by have hx0 : 0 < x := by linarith have hlog : 0 < Real.log x := Real.log_pos (by linarith) have hsqrt0 := Real.sqrt_nonneg x have hsqrt := Real.sq_sqrt hx0.le have hsqrt1 : 1 ≤ Real.sqrt x := by nlinarith have hcard : (F.card : ℝ) ≤ 17 + Real.sqrt x := finite_positive_card_le (by positivity) F (by intro p hp refine ⟨(hF p hp).1, ?_⟩ rcases (hF p hp).2 with hsmall | hs · have hp17 : (p : ℝ) < 17 := by exact_mod_cast hsmall linarith · linarith) have hexp := Real.pow_div_factorial_le_exp (x := Real.log x / 2) (show 0 ≤ Real.log x / 2 by positivity) 2 norm_num at hexp rw [← Real.log_sqrt hx0.le, Real.exp_log (Real.sqrt_pos.mpr hx0)] at hexp have hlogbound : Real.log x ^ 2 ≤ 8 * Real.sqrt x := by rw [Real.log_sqrt hx0.le] at hexp nlinarith apply (le_div_iff₀ (sq_pos_of_pos hlog)).mpr have hsmall : (F.card : ℝ) ≤ 18 * Real.sqrt x := by linarith have hmul := mul_le_mul_of_nonneg_right hsmall (sq_nonneg (Real.log x)) nlinarith [mul_le_mul_of_nonneg_left hlogbound hsqrt0] /- Original line 14955: Erdos416Proof.logLog_pos_of_three_le -/ theorem logLog_pos_of_three_le {x : ℝ} (hx : 3 ≤ x) : 0 < logLog x := by apply Real.log_pos have h := Real.log_lt_log (Real.exp_pos 1) (Real.exp_one_lt_three.trans_le hx) simpa only [Real.log_exp] using h /- Original line 14960: Erdos416Proof.exists_shifted_largeOmega_bound -/ theorem exists_shifted_largeOmega_bound : ∃ C : ℝ, 0 < C ∧ ∀ (x : ℝ) (F : Finset ℕ), 3 ≤ x → (∀ p ∈ F, 2 ≤ p ∧ (p : ℝ) ≤ x ∧ 12 * logLog x ≤ (ArithmeticFunction.cardFactors (p - 1) : ℝ)) → (F.card : ℝ) ≤ C * x / Real.log x ^ 2 := by obtain ⟨C, hC, hcount⟩ := exists_largeOmega_integer_bound refine ⟨C, hC, ?_⟩ intro x F hx hF have hx0 : 0 < x := by linarith have hxe : Real.exp 1 ≤ x := Real.exp_one_lt_three.le.trans hx have hlog1 : 1 ≤ Real.log x := by simpa only [Real.log_exp] using Real.log_le_log (Real.exp_pos 1) hxe let G := F.image (fun p => p - 1) have hcard : G.card = F.card := Finset.card_image_of_injOn (by intro p hp q hq heq change p - 1 = q - 1 at heq have := (hF p hp).1 have := (hF q hq).1 omega) have hc := hcount x G hxe (by intro n hn obtain ⟨p, hp, rfl⟩ := Finset.mem_image.mp hn exact ⟨by have := (hF p hp).1; omega, (show ((p - 1 : ℕ) : ℝ) ≤ p by exact_mod_cast Nat.sub_le p 1).trans (hF p hp).2.1, (hF p hp).2.2⟩) rw [hcard] at hc have hpow : Real.log x ^ (-5 / 2 : ℝ) ≤ 1 / Real.log x ^ 2 := by calc _ ≤ Real.log x ^ (-(2 : ℝ)) := Real.rpow_le_rpow_of_exponent_le hlog1 (by norm_num) _ = _ := by rw [Real.rpow_neg (by linarith), Real.rpow_ofNat, one_div] calc _ ≤ C * x * Real.log x ^ (-5 / 2 : ℝ) := hc _ ≤ C * x * (1 / Real.log x ^ 2) := mul_le_mul_of_nonneg_left hpow (by positivity) _ = _ := by ring /- Original line 14996: Erdos416Proof.exists_middle_normalPrime_bound -/ theorem exists_middle_normalPrime_bound : ∃ C : ℝ, 0 < C ∧ ∀ S x : ℝ, Real.exp 1 ≤ S → 3 ≤ x → 100 ≤ logLog S → logLog S ≤ 6 * logLog x → ((nonNormalPrimes S x).card : ℝ) ≤ C * x / Real.log x * (1 + logLog x) ^ 5 * Real.exp (-logLog S / 6) := by obtain ⟨C₁, hC₁, hret⟩ := exists_retained_nonNormal_bound obtain ⟨C₂, hC₂, hlarge⟩ := exists_shifted_largeOmega_bound refine ⟨144 + C₂ + C₁, by positivity, ?_⟩ intro S x hS hx hL hLT have hx0 : 0 < x := by linarith have hlog : 0 < Real.log x := Real.log_pos (by linarith) have hT := logLog_pos_of_three_le hx let F := nonNormalPrimes S x let P := fun p : ℕ => p < 17 ∨ (p : ℝ) < Real.sqrt x let Q := fun p : ℕ => 12 * logLog x < (ArithmeticFunction.cardFactors (p - 1) : ℝ) let A := F.filter P let B := (F.filter (fun p => ¬P p)).filter Q let R := (F.filter (fun p => ¬P p)).filter (fun p => ¬Q p) have hdata : ∀ p ∈ F, p.Prime ∧ (p : ℝ) ≤ x ∧ ¬ SNormal S p := fun p hp => (mem_nonNormalPrimes hx0.le).mp hp have ha := small_retention_failures_bound hx A (by intro p hp obtain ⟨hpF, hpP⟩ := Finset.mem_filter.mp hp exact ⟨(hdata p hpF).1.pos, hpP⟩) have hb := hlarge x B hx (by intro p hp obtain ⟨hp', hpQ⟩ := Finset.mem_filter.mp hp obtain ⟨hpF, hpP⟩ := Finset.mem_filter.mp hp' exact ⟨(hdata p hpF).1.two_le, (hdata p hpF).2.1, hpQ.le⟩) have hr := hret x S R (by linarith) hT hS hL (by intro p hp obtain ⟨hp', hpQ⟩ := Finset.mem_filter.mp hp obtain ⟨hpF, hpP⟩ := Finset.mem_filter.mp hp' have hpnot : ¬p < 17 ∧ ¬(p : ℝ) < Real.sqrt x := not_or.mp hpP exact ⟨(hdata p hpF).1, Nat.le_of_not_gt hpnot.1, le_of_not_gt hpnot.2, (hdata p hpF).2.1, le_of_not_gt hpQ⟩) (by intro p hp exact (hdata p (Finset.mem_filter.mp (Finset.mem_filter.mp hp).1).1).2.2) have hcard : (F.card : ℝ) = (A.card : ℝ) + (B.card : ℝ) + (R.card : ℝ) := by have h₁ := Finset.card_filter_add_card_filter_not (s := F) P have h₂ := Finset.card_filter_add_card_filter_not (s := F.filter (fun p => ¬P p)) Q dsimp [Erdos416Proof.logLog_normalityGridPoint, A, B, R] exact_mod_cast (show F.card = (F.filter P).card + ((F.filter (fun p => ¬P p)).filter Q).card + ((F.filter (fun p => ¬P p)).filter (fun p => ¬Q p)).card by omega) have hsaving : 1 / Real.log x ≤ Real.exp (-logLog S / 6) := by calc _ = Real.exp (-logLog x) := by rw [Real.exp_neg, logLog, Real.exp_log hlog, one_div] _ ≤ _ := Real.exp_le_exp.mpr (by linarith) have hp1 : 1 ≤ (1 + logLog x) ^ 5 := one_le_pow₀ (by linarith) have hp45 : (1 + logLog x) ^ 4 ≤ (1 + logLog x) ^ 5 := by exact pow_le_pow_right₀ (by linarith) (by norm_num) have herror : x / Real.log x ^ 2 ≤ x / Real.log x * (1 + logLog x) ^ 5 * Real.exp (-logLog S / 6) := by have hfactor : 1 / Real.log x ≤ (1 + logLog x) ^ 5 * Real.exp (-logLog S / 6) := hsaving.trans (by nlinarith [Real.exp_pos (-logLog S / 6)]) convert! mul_le_mul_of_nonneg_left hfactor (show 0 ≤ x / Real.log x by positivity) using 1 <;> field_simp <;> ring have ha' : (A.card : ℝ) ≤ 144 * (x / Real.log x * (1 + logLog x) ^ 5 * Real.exp (-logLog S / 6)) := by apply ha.trans convert! mul_le_mul_of_nonneg_left herror (show (0 : ℝ) ≤ 144 by norm_num) using 1 <;> ring have hb' : (B.card : ℝ) ≤ C₂ * (x / Real.log x * (1 + logLog x) ^ 5 * Real.exp (-logLog S / 6)) := by apply hb.trans convert! mul_le_mul_of_nonneg_left herror hC₂.le using 1 <;> ring have hr' : (R.card : ℝ) ≤ C₁ * (x / Real.log x * (1 + logLog x) ^ 5 * Real.exp (-logLog S / 6)) := by apply hr.trans convert! mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left hp45 (show 0 ≤ C₁ * x / Real.log x by positivity)) (Real.exp_pos (-logLog S / 6)).le using 1 <;> ring change (F.card : ℝ) ≤ _ rw [hcard] calc _ ≤ (144 + C₂ + C₁) * (x / Real.log x * (1 + logLog x) ^ 5 * Real.exp (-logLog S / 6)) := by linarith _ = _ := by ring /- Original line 15075: Erdos416Proof.finite_prime_card_le_primeCountReal -/ theorem finite_prime_card_le_primeCountReal {x : ℝ} (hx : 0 ≤ x) (F : Finset ℕ) (hF : ∀ p ∈ F, p.Prime ∧ (p : ℝ) ≤ x) : (F.card : ℝ) ≤ primeCountReal x := by have hsub : F ⊆ Nat.primesLE ⌊x⌋₊ := by intro p hp exact Nat.mem_primesLE.mpr ⟨Nat.le_floor (hF p hp).2, (hF p hp).1⟩ have hcard : (F.card : ℝ) ≤ ((Nat.primesLE ⌊x⌋₊).card : ℝ) := by exact_mod_cast Finset.card_le_card hsub simpa only [Nat.primesLE_card_eq_primeCounting, primeCountReal] using hcard /- Original line 15084: Erdos416Proof.exists_bounded_normalityParameter_bound -/ theorem exists_bounded_normalityParameter_bound : ∃ C : ℝ, 0 < C ∧ ∀ S x : ℝ, Real.exp 1 ≤ S → 3 ≤ x → logLog S ≤ 100 → ((nonNormalPrimes S x).card : ℝ) ≤ C * x / Real.log x * (1 + logLog x) ^ 5 * Real.exp (-logLog S / 6) := by obtain ⟨C, hC, hprime⟩ := exists_primeCountReal_upper_bound refine ⟨C * Real.exp (100 / 6), by positivity, ?_⟩ intro S x hS hx hL have hx0 : 0 < x := by linarith have hlog : 0 < Real.log x := Real.log_pos (by linarith) have hT := logLog_pos_of_three_le hx have hp1 : 1 ≤ (1 + logLog x) ^ 5 := one_le_pow₀ (by linarith) have he : 1 ≤ Real.exp (100 / 6) * Real.exp (-logLog S / 6) := by rw [← Real.exp_add] exact Real.one_le_exp_iff.mpr (by linarith) have hfactor : 1 ≤ Real.exp (100 / 6) * (1 + logLog x) ^ 5 * Real.exp (-logLog S / 6) := by have h := mul_le_mul_of_nonneg_left hp1 (mul_nonneg (Real.exp_pos (100 / 6)).le (Real.exp_pos (-logLog S / 6)).le) nlinarith have hcard := finite_prime_card_le_primeCountReal hx0.le (nonNormalPrimes S x) (fun p hp => ⟨((mem_nonNormalPrimes hx0.le).mp hp).1, ((mem_nonNormalPrimes hx0.le).mp hp).2.1⟩) calc _ ≤ C * x / Real.log x := hcard.trans (hprime x (by linarith)) _ ≤ C * x / Real.log x * (Real.exp (100 / 6) * (1 + logLog x) ^ 5 * Real.exp (-logLog S / 6)) := le_mul_of_one_le_right (by positivity) hfactor _ = _ := by ring /- Original line 15113: Erdos416Proof.exists_large_normalityParameter_bound -/ theorem exists_large_normalityParameter_bound : ∃ C : ℝ, 0 < C ∧ ∀ S x : ℝ, Real.exp 1 ≤ S → 3 ≤ x → 6 * logLog x ≤ logLog S → ((nonNormalPrimes S x).card : ℝ) ≤ C * x / Real.log x * (1 + logLog x) ^ 5 * Real.exp (-logLog S / 6) := by obtain ⟨C, hC, htail⟩ := exists_cardFactors_totient_tail_bound refine ⟨C, hC, ?_⟩ intro S x hS hx hLT have hx0 : 0 < x := by linarith have hlog : 0 < Real.log x := Real.log_pos (by linarith) have hT := logLog_pos_of_three_le hx have hL0 : 0 ≤ logLog S := by linarith have hSone : 1 < S := by linarith [Real.add_one_le_exp (1 : ℝ)] have hxS : x ≤ S := by by_contra hnot have hLL := logLog_mono hSone (le_of_not_ge hnot) linarith let F := nonNormalPrimes S x let G := F.image (fun p => p - 1) have hdata : ∀ p ∈ F, p.Prime ∧ (p : ℝ) ≤ x ∧ ¬SNormal S p := fun p hp => (mem_nonNormalPrimes hx0.le).mp hp have hcard : G.card = F.card := Finset.card_image_of_injOn (by intro p hp q hq heq change p - 1 = q - 1 at heq have := (hdata p hp).1.two_le have := (hdata q hq).1.two_le omega) have hG : ∀ n ∈ G, 0 < n ∧ (n : ℝ) ≤ x ∧ 2 * logLog S ≤ (ArithmeticFunction.cardFactors n : ℝ) := by intro n hn obtain ⟨p, hp, rfl⟩ := Finset.mem_image.mp hn obtain ⟨hpprime, hpx, hpbad⟩ := hdata p hp refine ⟨by have := hpprime.two_le; omega, (show ((p - 1 : ℕ) : ℝ) ≤ p by exact_mod_cast Nat.sub_le p 1).trans hpx, ?_⟩ by_contra hnot apply hpbad exact SNormal_of_small_prime hpprime (hpx.trans hxS) (le_of_not_ge hnot) have hs := htail x (3 / 2) (2 * logLog S) G (by linarith) (by norm_num) (by norm_num) (fun n hn => factored_primesLE_of_positive_le (hG n hn).1 (hG n hn).2.1) (fun n hn => (hG n hn).2.2) have hlogthree : (1 / 3 : ℝ) ≤ Real.log (3 / 2) := by have h := Real.one_sub_inv_le_log_of_pos (show (0 : ℝ) < 3 / 2 by norm_num) norm_num at h linarith have hdecay : Real.log x ^ (3 / 2 : ℝ) / (3 / 2 : ℝ) ^ (2 * logLog S) ≤ 1 / Real.log x * Real.exp (-logLog S / 6) := by have hexp : 1 / Real.log x = Real.exp (-logLog x) := by rw [Real.exp_neg, logLog, Real.exp_log hlog, one_div] rw [Real.rpow_def_of_pos hlog, Real.rpow_def_of_pos (show (0 : ℝ) < 3 / 2 by norm_num), ← Real.exp_sub, hexp, ← Real.exp_add] apply Real.exp_le_exp.mpr change logLog x * (3 / 2) - Real.log (3 / 2) * (2 * logLog S) ≤ -logLog x + -logLog S / 6 nlinarith [mul_le_mul_of_nonneg_right hlogthree hL0] have hcount : (F.card : ℝ) ≤ C * x / Real.log x * Real.exp (-logLog S / 6) := by calc _ = (G.card : ℝ) := by rw [hcard] _ ≤ x * ∑ n ∈ G, invTotient n := finite_card_le_totient_reciprocal G (fun n hn => ⟨(hG n hn).1, (hG n hn).2.1⟩) _ ≤ x * (C * Real.log x ^ (3 / 2 : ℝ) / (3 / 2 : ℝ) ^ (2 * logLog S)) := mul_le_mul_of_nonneg_left hs hx0.le _ = C * x * (Real.log x ^ (3 / 2 : ℝ) / (3 / 2 : ℝ) ^ (2 * logLog S)) := by ring _ ≤ C * x * (1 / Real.log x * Real.exp (-logLog S / 6)) := mul_le_mul_of_nonneg_left hdecay (by positivity) _ = _ := by ring have hp1 : 1 ≤ (1 + logLog x) ^ 5 := one_le_pow₀ (by linarith) apply hcount.trans have h := mul_le_mul_of_nonneg_left hp1 (show 0 ≤ C * x / Real.log x * Real.exp (-logLog S / 6) by positivity) convert! h using 1 <;> ring /-- Ford's normal-prime density estimate, proved for the actual prime set and for every S>=e and x>=3. No analytic density input is assumed. -/ /- Original line 15187: Erdos416Proof.exists_normalPrimeDensityEstimate -/ theorem exists_normalPrimeDensityEstimate : ∃ C : ℝ, 0 < C ∧ NormalPrimeDensityEstimate C := by obtain ⟨C₁, hC₁, hbounded⟩ := exists_bounded_normalityParameter_bound obtain ⟨C₂, hC₂, hmiddle⟩ := exists_middle_normalPrime_bound obtain ⟨C₃, hC₃, hlarge⟩ := exists_large_normalityParameter_bound refine ⟨C₁ + C₂ + C₃, by positivity, ?_⟩ intro S x hS hx change ((nonNormalPrimes S x).card : ℝ) ≤ (C₁ + C₂ + C₃) * x / Real.log x * (1 + logLog x) ^ 5 * Real.exp (-logLog S / 6) have hx0 : 0 < x := by linarith have hlog : 0 < Real.log x := Real.log_pos (by linarith) have hT := logLog_pos_of_three_le hx have hmono {A B : ℝ} (hAB : A ≤ B) : A * x / Real.log x * (1 + logLog x) ^ 5 * Real.exp (-logLog S / 6) ≤ B * x / Real.log x * (1 + logLog x) ^ 5 * Real.exp (-logLog S / 6) := by gcongr by_cases hL : logLog S ≤ 100 · exact (hbounded S x hS hx hL).trans (hmono (by linarith)) by_cases hLT : logLog S ≤ 6 * logLog x · exact (hmiddle S x hS hx (le_of_not_ge hL) hLT).trans (hmono (by linarith)) · exact (hlarge S x hS hx (le_of_not_ge hLT)).trans (hmono (by linarith)) /- Original line 15209: Erdos416Proof.normal_prime_pruning -/ theorem normal_prime_pruning {A c : ℝ} (hA : 0 < A) (hc : 0 < c) : squarefreeNonNormalCount A c =o[atTop] (fun y : ℝ => y / (Real.log y * Real.log (Real.log y) ^ 2)) := by obtain ⟨C, hC, hdensity⟩ := exists_normalPrimeDensityEstimate exact normal_prime_pruning_of_density hA hc hC hdensity /- Original line 15215: Erdos416Proof.normal_prime_pruning_for_squarefree_preimages -/ theorem normal_prime_pruning_for_squarefree_preimages {A : ℝ} (hA : 0 < A) (F : ℝ → Finset ℕ) (hF : ∀ᶠ y : ℝ in atTop, ∀ n ∈ F y, Squarefree n ∧ (n.totient : ℝ) ≤ y ∧ (ArithmeticFunction.cardFactors n : ℝ) ≤ A * Real.log (Real.log (Real.log y)) + 1) : (fun y : ℝ => ((normalPrimeFailures (F y) (normalityScale (Real.log (Real.log y)))).card : ℝ)) =o[atTop] (fun y => y / (Real.log y * Real.log (Real.log y) ^ 2)) := by obtain ⟨C, hC, hdensity⟩ := exists_normalPrimeDensityEstimate exact normal_prime_pruning_for_squarefree_preimages_of_density hA hC hdensity F hF /- Original line 15224: Erdos416Proof.normal_prime_pruning_negligible_in_V -/ theorem normal_prime_pruning_negligible_in_V {A : ℝ} (hA : 0 < A) (F : ℝ → Finset ℕ) (hF : ∀ᶠ y : ℝ in atTop, ∀ n ∈ F y, Squarefree n ∧ (n.totient : ℝ) ≤ y ∧ (ArithmeticFunction.cardFactors n : ℝ) ≤ A * Real.log (Real.log (Real.log y)) + 1) : (fun y : ℝ => ((normalPrimeFailures (F y) (normalityScale (Real.log (Real.log y)))).card : ℝ)) =o[atTop] V := by obtain ⟨C, hC, hdensity⟩ := exists_normalPrimeDensityEstimate exact normal_prime_pruning_negligible_in_V_of_density hA hC hdensity F hF end Erdos416Proof /- The five-log factor-count exception, proved first for all integers. Its application to actual totient values gives both the manuscript's exceptional scale and a loss negligible relative to V. -/ open Filter Asymptotics open scoped BigOperators Classical Topology namespace Erdos416Proof /- Original line 15248: Erdos416Proof.log_seven_fourths_lower_bound -/ theorem log_seven_fourths_lower_bound : (5 / 9 : ℝ) ≤ Real.log (7 / 4) := by have h := Real.sum_range_le_log_div (x := (3 / 11 : ℝ)) (by norm_num) (by norm_num) 2 norm_num [Finset.sum_range_succ] at h linarith /- Original line 15253: Erdos416Proof.exists_fiveLogOmega_threshold_bound -/ theorem exists_fiveLogOmega_threshold_bound : ∃ K : ℝ, 0 < K ∧ ∀ (x : ℝ) (F : Finset ℕ), Real.exp 1 ≤ x → (∀ n ∈ F, 0 < n ∧ (n : ℝ) ≤ x ∧ 5 * logLog x - 5 * Real.log 2 ≤ (ArithmeticFunction.cardFactors n : ℝ)) → (F.card : ℝ) ≤ K * x * Real.log x ^ (-37 / 36 : ℝ) := by obtain ⟨C, hC, htail⟩ := exists_cardFactors_totient_tail_bound let E := Real.exp (5 * Real.log 2 * Real.log (7 / 4)) refine ⟨C * E, mul_pos hC (Real.exp_pos _), ?_⟩ intro x F hx hF have hx2 : 2 ≤ x := by linarith [Real.add_one_le_exp (1 : ℝ)] have hx0 : 0 < x := by linarith have hlog : 0 < Real.log x := Real.log_pos (by linarith) have hT : 0 ≤ logLog x := logLog_nonneg hx have hs := htail x (7 / 4) (5 * logLog x - 5 * Real.log 2) F hx2 (by norm_num) (by norm_num) (fun n hn => factored_primesLE_of_positive_le (hF n hn).1 (hF n hn).2.1) (fun n hn => (hF n hn).2.2) have hdecay : Real.log x ^ (7 / 4 : ℝ) / (7 / 4 : ℝ) ^ (5 * logLog x - 5 * Real.log 2) ≤ E * Real.log x ^ (-37 / 36 : ℝ) := by dsimp only [E] rw [Real.rpow_def_of_pos hlog, Real.rpow_def_of_pos (show (0 : ℝ) < 7 / 4 by norm_num), ← Real.exp_sub, Real.rpow_def_of_pos hlog, ← Real.exp_add] apply Real.exp_le_exp.mpr change logLog x * (7 / 4) - Real.log (7 / 4) * (5 * logLog x - 5 * Real.log 2) ≤ 5 * Real.log 2 * Real.log (7 / 4) + logLog x * (-37 / 36) nlinarith [mul_le_mul_of_nonneg_right log_seven_fourths_lower_bound hT] calc _ ≤ x * ∑ n ∈ F, invTotient n := finite_card_le_totient_reciprocal F (fun n hn => ⟨(hF n hn).1, (hF n hn).2.1⟩) _ ≤ x * (C * Real.log x ^ (7 / 4 : ℝ) / (7 / 4 : ℝ) ^ (5 * logLog x - 5 * Real.log 2)) := mul_le_mul_of_nonneg_left hs hx0.le _ = C * x * (Real.log x ^ (7 / 4 : ℝ) / (7 / 4 : ℝ) ^ (5 * logLog x - 5 * Real.log 2)) := by ring _ ≤ C * x * (E * Real.log x ^ (-37 / 36 : ℝ)) := mul_le_mul_of_nonneg_left hdecay (by positivity) _ = _ := by ring /- Original line 15294: Erdos416Proof.exists_variable_fiveLogOmega_count_bound -/ theorem exists_variable_fiveLogOmega_count_bound : ∃ K : ℝ, 0 < K ∧ ∀ (x : ℝ) (F : Finset ℕ), Real.exp 1 ≤ x → (∀ n ∈ F, 3 ≤ n ∧ (n : ℝ) ≤ x ∧ 5 * logLog (n : ℝ) ≤ (ArithmeticFunction.cardFactors n : ℝ)) → (F.card : ℝ) ≤ Real.sqrt x + K * x * Real.log x ^ (-37 / 36 : ℝ) := by obtain ⟨K, hK, hcount⟩ := exists_fiveLogOmega_threshold_bound refine ⟨K, hK, ?_⟩ intro x F hx hF have hx1 : 1 < x := by linarith [Real.add_one_le_exp (1 : ℝ)] have hx0 : 0 < x := by linarith have hlog : 0 < Real.log x := Real.log_pos hx1 have hsqrt1 : 1 < Real.sqrt x := by nlinarith [Real.sq_sqrt hx0.le, Real.sqrt_nonneg x] let P := fun n : ℕ => (n : ℝ) ≤ Real.sqrt x have hsmall : ((F.filter P).card : ℝ) ≤ Real.sqrt x := finite_positive_card_le (Real.sqrt_nonneg x) _ (by intro n hn obtain ⟨hnF, hnP⟩ := Finset.mem_filter.mp hn exact ⟨by have := (hF n hnF).1; omega, hnP⟩) have hlarge := hcount x (F.filter (fun n => ¬P n)) hx (by intro n hn obtain ⟨hnF, hnP⟩ := Finset.mem_filter.mp hn refine ⟨by have := (hF n hnF).1; omega, (hF n hnF).2.1, ?_⟩ have hLL := logLog_mono hsqrt1 (le_of_not_ge hnP) simp only [logLog, Real.log_sqrt hx0.le, Real.log_div hlog.ne' (show (2 : ℝ) ≠ 0 by norm_num)] at hLL change 5 * (Real.log (Real.log x)) - 5 * Real.log 2 ≤ _ have hΩ := (hF n hnF).2.2 change 5 * Real.log (Real.log (n : ℝ)) ≤ _ at hΩ linarith) have hcard : (F.card : ℝ) = ((F.filter P).card : ℝ) + ((F.filter (fun n => ¬P n)).card : ℝ) := by exact_mod_cast (Finset.card_filter_add_card_filter_not (s := F) P).symm rw [hcard] exact add_le_add hsmall hlarge /- Original line 15330: Erdos416Proof.fiveLogOmegaIntegers -/ noncomputable def fiveLogOmegaIntegers (x : ℝ) : Finset ℕ := (Finset.Icc 3 ⌊x⌋₊).filter (fun n : ℕ => 5 * logLog (n : ℝ) < (ArithmeticFunction.cardFactors n : ℝ)) /- Original line 15334: Erdos416Proof.fiveLogOmegaIntegers_data -/ theorem fiveLogOmegaIntegers_data {x : ℝ} (hx : 0 ≤ x) {n : ℕ} (hn : n ∈ fiveLogOmegaIntegers x) : 3 ≤ n ∧ (n : ℝ) ≤ x ∧ 5 * logLog (n : ℝ) < (ArithmeticFunction.cardFactors n : ℝ) := by obtain ⟨hnI, hnΩ⟩ := Finset.mem_filter.mp hn obtain ⟨hn3, hnx⟩ := Finset.mem_Icc.mp hnI exact ⟨hn3, (Nat.le_floor_iff hx).mp hnx, hnΩ⟩ /- Original line 15341: Erdos416Proof.fiveLogOmegaIntegers_negligible -/ theorem fiveLogOmegaIntegers_negligible : (fun x : ℝ => ((fiveLogOmegaIntegers x).card : ℝ)) =o[atTop] (fun x : ℝ => x / (Real.log x * logLog x ^ 2)) := by obtain ⟨K, hK, hcount⟩ := exists_variable_fiveLogOmega_count_bound let g := fun x : ℝ => x / (Real.log x * logLog x ^ 2) have hT := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop have hpos : ∀ᶠ x : ℝ in atTop, 0 < x ∧ 0 < Real.log x ∧ 0 < logLog x := by filter_upwards [eventually_ge_atTop (3 : ℝ)] with x hx exact ⟨by linarith, Real.log_pos (by linarith), logLog_pos_of_three_le hx⟩ have hsqrt : (fun x : ℝ => Real.sqrt x) =o[atTop] g := by apply IsBigO.trans_isLittleO (g := fun x : ℝ => Real.sqrt (1 * x * logLog x)) ?_ (sqrt_inverse_totient_scale_negligible (show (0 : ℝ) < 1 by norm_num)) apply IsBigO.of_norm_eventuallyLE filter_upwards [hpos, hT.eventually_ge_atTop 1] with x hx hLL rcases hx with ⟨hx0, hlog, hLL0⟩ simp only [Real.norm_eq_abs, abs_of_nonneg (Real.sqrt_nonneg _)] apply Real.sqrt_le_sqrt change x ≤ 1 * x * logLog x change 1 ≤ logLog x at hLL nlinarith have hpower : (fun x : ℝ => K * x * Real.log x ^ (-37 / 36 : ℝ)) =o[atTop] g := by have hlim : Tendsto (fun x : ℝ => K * (logLog x ^ 2 * Real.log x ^ (-1 / 36 : ℝ))) atTop (nhds 0) := by have h := (log_pow_mul_rpow_littleO 2 (show (-1 / 36 : ℝ) < 0 by norm_num)).tendsto_div_nhds_zero simp only [Real.rpow_zero, div_one] at h simpa only [Function.comp_apply, mul_zero, logLog] using (h.comp Real.tendsto_log_atTop).const_mul K apply (isLittleO_iff_tendsto' ?_).mpr · apply hlim.congr' filter_upwards [hpos] with x hx rcases hx with ⟨hx0, hlog, hLL⟩ have hpowers : Real.log x ^ (-37 / 36 : ℝ) * Real.log x = Real.log x ^ (-1 / 36 : ℝ) := by have h := Real.rpow_add hlog (-37 / 36) 1 norm_num at h simpa only [neg_div] using h.symm dsimp only [g] calc K * (logLog x ^ 2 * Real.log x ^ (-1 / 36 : ℝ)) = K * (Real.log x ^ (-37 / 36 : ℝ) * Real.log x) * logLog x ^ 2 := by rw [hpowers]; ring _ = _ := by field_simp [hx0.ne', hlog.ne', hLL.ne'] · filter_upwards [hpos] with x hx hzero rcases hx with ⟨hx0, hlog, hLL⟩ have hg : 0 < g x := by dsimp [Erdos416Proof.logLog_normalityGridPoint, g]; positivity exact (hg.ne' hzero).elim have hdom : (fun x : ℝ => ((fiveLogOmegaIntegers x).card : ℝ)) =O[atTop] (fun x => Real.sqrt x + K * x * Real.log x ^ (-37 / 36 : ℝ)) := by apply IsBigO.of_norm_eventuallyLE filter_upwards [eventually_ge_atTop (Real.exp 1)] with x hx have hx0 : 0 < x := (Real.exp_pos 1).trans_le hx have hlog : 0 < Real.log x := Real.log_pos (by linarith [Real.add_one_le_exp (1 : ℝ)]) have h := hcount x (fiveLogOmegaIntegers x) hx (by intro n hn obtain ⟨hn3, hnx, hnΩ⟩ := fiveLogOmegaIntegers_data hx0.le hn exact ⟨hn3, hnx, hnΩ.le⟩) have hnonneg : 0 ≤ Real.sqrt x + K * x * Real.log x ^ (-37 / 36 : ℝ) := by positivity have hF0 : (0 : ℝ) ≤ (fiveLogOmegaIntegers x).card := Nat.cast_nonneg _ simpa only [Real.norm_eq_abs, abs_of_nonneg hF0, abs_of_nonneg hnonneg] using h exact hdom.trans_isLittleO (hsqrt.add hpower) /- Original line 15401: Erdos416Proof.fiveLogOmegaTotients -/ noncomputable def fiveLogOmegaTotients (x : ℝ) : Finset ℕ := (totientsUpTo x).filter (fun n : ℕ => 3 ≤ n ∧ 5 * logLog (n : ℝ) < (ArithmeticFunction.cardFactors n : ℝ)) /- Original line 15405: Erdos416Proof.fiveLogOmegaTotients_subset -/ theorem fiveLogOmegaTotients_subset {x : ℝ} (hx : 0 ≤ x) : fiveLogOmegaTotients x ⊆ fiveLogOmegaIntegers x := by intro n hn obtain ⟨hnV, hn3, hnΩ⟩ := Finset.mem_filter.mp hn have hnData := (mem_totientsUpTo hx).mp hnV exact Finset.mem_filter.mpr ⟨Finset.mem_Icc.mpr ⟨hn3, Nat.le_floor hnData.2.1⟩, hnΩ⟩ /- Original line 15412: Erdos416Proof.fiveLogOmegaTotients_negligible -/ theorem fiveLogOmegaTotients_negligible : (fun x : ℝ => ((fiveLogOmegaTotients x).card : ℝ)) =o[atTop] (fun x : ℝ => x / (Real.log x * logLog x ^ 2)) := by apply IsBigO.trans_isLittleO (g := fun x : ℝ => ((fiveLogOmegaIntegers x).card : ℝ)) ?_ fiveLogOmegaIntegers_negligible apply IsBigO.of_norm_eventuallyLE filter_upwards [eventually_ge_atTop (0 : ℝ)] with x hx have h : ((fiveLogOmegaTotients x).card : ℝ) ≤ (fiveLogOmegaIntegers x).card := by exact_mod_cast Finset.card_le_card (fiveLogOmegaTotients_subset hx) have hF0 : (0 : ℝ) ≤ (fiveLogOmegaTotients x).card := Nat.cast_nonneg _ have hG0 : (0 : ℝ) ≤ (fiveLogOmegaIntegers x).card := Nat.cast_nonneg _ simpa only [Real.norm_eq_abs, abs_of_nonneg hF0, abs_of_nonneg hG0] using h /- Original line 15425: Erdos416Proof.fiveLogOmegaTotients_negligible_in_V -/ theorem fiveLogOmegaTotients_negligible_in_V : (fun x : ℝ => ((fiveLogOmegaTotients x).card : ℝ)) =o[atTop] V := fiveLogOmegaTotients_negligible.trans_isBigO square_pruning_scale_isBigO_V end Erdos416Proof /- Distinct totients with a non-normal prime in some positive preimage. The finite bound uses the actual counting envelope. The negligible-error conclusion retains an explicit growth hypothesis, discharged later in this file. -/ open Filter Asymptotics open scoped BigOperators Classical Topology namespace Erdos416Proof /- Original line 15443: Erdos416Proof.TotientCountingEnvelope -/ def TotientCountingEnvelope (A x : ℝ) : Prop := ∀ u : ℝ, 2 ≤ u → u ≤ x → V u ≤ A * u / Real.log u /- Original line 15446: Erdos416Proof.nonNormalTotients -/ noncomputable def nonNormalTotients (S x : ℝ) : Finset ℕ := (totientsUpTo x).filter (fun m : ℕ => ∃ n : ℕ, 0 < n ∧ n.totient = m ∧ ∃ p : ℕ, p.Prime ∧ p ∣ n ∧ ¬ SNormal S p) /- Original line 15450: Erdos416Proof.siftedTotientPairs -/ noncomputable def siftedTotientPairs (Q : Finset ℕ) (x : ℝ) : Finset (ℕ × ℕ) := (Q.product (totientsUpTo x)).filter (fun pt : ℕ × ℕ => ((pt.1 : ℝ) - 1) * (pt.2 : ℝ) ≤ x) /- Original line 15454: Erdos416Proof.mem_siftedTotientPairs -/ theorem mem_siftedTotientPairs {Q : Finset ℕ} {x : ℝ} {p t : ℕ} : (p, t) ∈ siftedTotientPairs Q x ↔ p ∈ Q ∧ t ∈ totientsUpTo x ∧ ((p : ℝ) - 1) * (t : ℝ) ≤ x := by simp only [siftedTotientPairs, Finset.mem_filter, Finset.product_eq_sprod, Finset.mem_product] tauto /- Original line 15461: Erdos416Proof.totient_remove_prime -/ theorem totient_remove_prime {n p : ℕ} (hn : 0 < n) (hp : p.Prime) (hpn : p ∣ n) : 0 < n / p ∧ (n.totient = (p - 1) * (n / p).totient ∨ n.totient = p * (n / p).totient) := by have hnp : p * (n / p) = n := Nat.mul_div_cancel' hpn refine ⟨Nat.div_pos (Nat.le_of_dvd hn hpn) hp.pos, ?_⟩ by_cases hdiv : p ∣ n / p · right exact (congrArg Nat.totient hnp).symm.trans (Nat.totient_mul_of_prime_of_dvd hp hdiv) · left exact (congrArg Nat.totient hnp).symm.trans (Nat.totient_mul_of_prime_of_not_dvd hp hdiv) /- Original line 15472: Erdos416Proof.nonNormalTotients_pair_cover -/ theorem nonNormalTotients_pair_cover {S x : ℝ} (hx : 1 ≤ x) : nonNormalTotients S x ⊆ (siftedTotientPairs (nonNormalPrimes S (2 * x)) x).image (fun pt => (pt.1 - 1) * pt.2) ∪ (siftedTotientPairs (nonNormalPrimes S (2 * x)) x).image (fun pt => pt.1 * pt.2) := by intro m hm obtain ⟨hmV, n, hn, hnm, p, hp, hpn, hpbad⟩ := Finset.mem_filter.mp hm have hx0 : 0 ≤ x := by linarith obtain ⟨hmpos, hmx, hmrep⟩ := (mem_totientsUpTo hx0).mp hmV obtain ⟨hnp, hform⟩ := totient_remove_prime hn hp hpn let t := (n / p).totient have ht : 0 < t := Nat.totient_pos.mpr hnp have hp1 : 0 < p - 1 := by have := hp.two_le; omega have hprod : (p - 1) * t ≤ m := by rcases hform with h | h · exact le_of_eq (by simpa only [t, hnm] using h.symm) · rw [← hnm, h] exact Nat.mul_le_mul_right _ (Nat.sub_le p 1) have htm : t ≤ m := (le_mul_of_one_le_left (Nat.zero_le t) hp1).trans hprod have hpm : p - 1 ≤ m := (le_mul_of_one_le_right (Nat.zero_le (p - 1)) ht).trans hprod have hpR : (p : ℝ) ≤ 2 * x := by have hpR : ((p - 1 : ℕ) : ℝ) ≤ m := by exact_mod_cast hpm rw [Nat.cast_sub hp.one_le, Nat.cast_one] at hpR linarith have hpair : (p, t) ∈ siftedTotientPairs (nonNormalPrimes S (2 * x)) x := by apply mem_siftedTotientPairs.mpr refine ⟨(mem_nonNormalPrimes (by positivity)).mpr ⟨hp, hpR, hpbad⟩, (mem_totientsUpTo hx0).mpr ⟨ht, ?_, n / p, hnp, rfl⟩, ?_⟩ · exact (show (t : ℝ) ≤ m by exact_mod_cast htm).trans hmx · have hprodR : (((p - 1) * t : ℕ) : ℝ) ≤ m := by exact_mod_cast hprod rw [Nat.cast_mul, Nat.cast_sub hp.one_le, Nat.cast_one] at hprodR exact hprodR.trans hmx rcases hform with h | h · exact Finset.mem_union_left _ (Finset.mem_image.mpr ⟨(p, t), hpair, by simpa [t, hnm] using h.symm⟩) · exact Finset.mem_union_right _ (Finset.mem_image.mpr ⟨(p, t), hpair, by simpa [t, hnm] using h.symm⟩) /- Original line 15507: Erdos416Proof.nonNormalTotients_card_le_pairs -/ theorem nonNormalTotients_card_le_pairs {S x : ℝ} (hx : 1 ≤ x) : (nonNormalTotients S x).card ≤ 2 * (siftedTotientPairs (nonNormalPrimes S (2 * x)) x).card := by have h := (Finset.card_le_card (nonNormalTotients_pair_cover (S := S) hx)).trans (Finset.card_union_le _ _) have h₁ := Finset.card_image_le (s := siftedTotientPairs (nonNormalPrimes S (2 * x)) x) (f := fun pt : ℕ × ℕ => (pt.1 - 1) * pt.2) have h₂ := Finset.card_image_le (s := siftedTotientPairs (nonNormalPrimes S (2 * x)) x) (f := fun pt : ℕ × ℕ => pt.1 * pt.2) omega /- Original line 15517: Erdos416Proof.siftedTotientPairs_card_le_sum -/ theorem siftedTotientPairs_card_le_sum (Q : Finset ℕ) {x : ℝ} (hx : 0 ≤ x) (hQ : ∀ p ∈ Q, 2 ≤ p) : ((siftedTotientPairs Q x).card : ℝ) ≤ ∑ p ∈ Q, V (x / ((p : ℝ) - 1)) := by let T := Q.sigma (fun p => totientsUpTo (x / ((p : ℝ) - 1))) have hcard : (siftedTotientPairs Q x).card ≤ T.card := by apply Finset.card_le_card_of_injOn (fun pt : ℕ × ℕ => (⟨pt.1, pt.2⟩ : Σ _ : ℕ, ℕ)) · rintro ⟨p, t⟩ hpt obtain ⟨hpQ, htV, hbound⟩ := mem_siftedTotientPairs.mp hpt have hpR : (1 : ℝ) < p := by exact_mod_cast (by have := hQ p hpQ; omega : 1 < p) obtain ⟨ht, htx, m, hm, hmt⟩ := (mem_totientsUpTo hx).mp htV refine Finset.mem_sigma.mpr ⟨hpQ, (mem_totientsUpTo (by positivity)).mpr ⟨ht, ?_, m, hm, hmt⟩⟩ exact (le_div_iff₀ (by linarith : 0 < (p : ℝ) - 1)).mpr (by nlinarith) · intro a ha b hb hab apply Prod.ext · exact congrArg Sigma.fst hab · exact congrArg (fun z : Σ _ : ℕ, ℕ => z.2) hab dsimp only [T] at hcard rw [Finset.card_sigma] at hcard unfold V exact_mod_cast hcard /- Original line 15539: Erdos416Proof.finiteCountBelow_totientsUpTo -/ theorem finiteCountBelow_totientsUpTo {x u : ℝ} (hu : 0 ≤ u) (hux : u ≤ x) : finiteCountBelow (totientsUpTo x) u = V u := by have hx : 0 ≤ x := hu.trans hux have hset : (totientsUpTo x).filter (fun n : ℕ => (n : ℝ) ≤ u) = totientsUpTo u := by ext n simp only [Finset.mem_filter, mem_totientsUpTo hx, mem_totientsUpTo hu] constructor · rintro ⟨⟨hn, hnx, hrep⟩, hnu⟩ exact ⟨hn, hnu, hrep⟩ · rintro ⟨hn, hnu, hrep⟩ exact ⟨⟨hn, hnu.trans hux, hrep⟩, hnu⟩ simp only [finiteCountBelow, hset, V] /- Original line 15552: Erdos416Proof.exists_totient_reciprocal_envelope_bound -/ theorem exists_totient_reciprocal_envelope_bound : ∃ K : ℝ, 0 < K ∧ ∀ z A : ℝ, Real.exp 1 ≤ z → 1 ≤ A → TotientCountingEnvelope A z → (∑ t ∈ totientsUpTo z, (1 : ℝ) / t) ≤ K * A * (1 + logLog z) := by obtain ⟨K, hK, hrecip⟩ := exists_finite_reciprocal_density_constant refine ⟨1 + K, by positivity, ?_⟩ intro z A hz hA henv have hz0 : 0 ≤ z := (Real.exp_pos 1).le.trans hz have hz1 : 1 ≤ z := by linarith [Real.add_one_le_exp (1 : ℝ)] have hLL := logLog_nonneg hz let Q := (totientsUpTo z).filter (fun t => 2 ≤ t) have hdensity : ∀ u : ℝ, 2 ≤ u → u ≤ z → finiteCountBelow Q u ≤ A * u / Real.log u := by intro u hu huz have hsub : Q.filter (fun t : ℕ => (t : ℝ) ≤ u) ⊆ (totientsUpTo z).filter (fun t : ℕ => (t : ℝ) ≤ u) := by intro t ht exact Finset.mem_filter.mpr ⟨(Finset.mem_filter.mp (Finset.mem_filter.mp ht).1).1, (Finset.mem_filter.mp ht).2⟩ have hcard : finiteCountBelow Q u ≤ finiteCountBelow (totientsUpTo z) u := by unfold finiteCountBelow exact_mod_cast Finset.card_le_card hsub rw [finiteCountBelow_totientsUpTo (by linarith) huz] at hcard exact hcard.trans (henv u hu huz) have h := hrecip Q z A hz (by linarith) (by intro t ht obtain ⟨htV, ht2⟩ := Finset.mem_filter.mp ht exact ⟨ht2, ((mem_totientsUpTo hz0).mp htV).2.1⟩) hdensity have h1 : (1 : ℕ) ∉ Q := by simp [Erdos416Proof.logLog_normalityGridPoint, Q] have hset : totientsUpTo z = insert 1 Q := by ext t constructor · intro ht by_cases ht1 : t = 1 · simp [Erdos416Proof.logLog_normalityGridPoint, ht1] · exact Finset.mem_insert_of_mem (Finset.mem_filter.mpr ⟨ht, by have := ((mem_totientsUpTo hz0).mp ht).1; omega⟩) · intro ht rcases Finset.mem_insert.mp ht with ht1 | htQ · subst t exact (mem_totientsUpTo hz0).mpr ⟨by norm_num, by simpa [Erdos416Proof.logLog_normalityGridPoint] using hz1, 1, by norm_num, Nat.totient_one⟩ · exact (Finset.mem_filter.mp htQ).1 rw [hset, Finset.sum_insert h1] norm_num only [Nat.cast_one, div_one] have hunit : 1 ≤ A * (1 + logLog z) := by nlinarith change (∑ t ∈ Q, (1 : ℝ) / t) ≤ K * A * (1 + logLog z) at h nlinarith /- Original line 15599: Erdos416Proof.small_prime_totient_endpoint -/ theorem small_prime_totient_endpoint {x : ℝ} {p : ℕ} (hx : 16 ≤ x) (hp : 2 ≤ p) (hps : (p : ℝ) ≤ Real.sqrt x) : 2 ≤ x / ((p : ℝ) - 1) ∧ x / ((p : ℝ) - 1) ≤ x ∧ Real.log x / 2 ≤ Real.log (x / ((p : ℝ) - 1)) := by have hx0 : 0 < x := by linarith have hpR : (2 : ℝ) ≤ p := by exact_mod_cast hp have hd : 0 < (p : ℝ) - 1 := by linarith have hs0 := Real.sqrt_nonneg x have hs4 : 4 ≤ Real.sqrt x := Real.le_sqrt_of_sq_le (by norm_num; exact hx) have hsize : Real.sqrt x ≤ x / ((p : ℝ) - 1) := by apply (le_div_iff₀ hd).mpr nlinarith [mul_le_mul_of_nonneg_left hps hs0, Real.sq_sqrt hx0.le] refine ⟨by linarith, div_le_self hx0.le (by linarith), ?_⟩ have h := Real.log_le_log (Real.sqrt_pos.mpr hx0) hsize simpa only [Real.log_sqrt hx0.le] using h /- Original line 15615: Erdos416Proof.siftedTotientPairs_small_bound -/ theorem siftedTotientPairs_small_bound (Q : Finset ℕ) {x A : ℝ} (hx : 16 ≤ x) (hA : 0 ≤ A) (henv : TotientCountingEnvelope A x) (hQ : ∀ p ∈ Q, 2 ≤ p ∧ (p : ℝ) ≤ Real.sqrt x) : ((siftedTotientPairs Q x).card : ℝ) ≤ 4 * A * x / Real.log x * ∑ p ∈ Q, (1 : ℝ) / p := by have hx0 : 0 < x := by linarith have hlog : 0 < Real.log x := Real.log_pos (by linarith) calc _ ≤ ∑ p ∈ Q, V (x / ((p : ℝ) - 1)) := siftedTotientPairs_card_le_sum Q hx0.le (fun p hp => (hQ p hp).1) _ ≤ ∑ p ∈ Q, 4 * A * x / Real.log x * ((1 : ℝ) / p) := by apply Finset.sum_le_sum intro p hp obtain ⟨hlo, hhi, hlogs⟩ := small_prime_totient_endpoint hx (hQ p hp).1 (hQ p hp).2 have hpR : (2 : ℝ) ≤ p := by exact_mod_cast (hQ p hp).1 have hd : 0 < (p : ℝ) - 1 := by linarith have hrecip : 1 / ((p : ℝ) - 1) ≤ 2 / p := (div_le_div_iff₀ hd (by linarith)).mpr (by linarith) calc _ ≤ A * (x / ((p : ℝ) - 1)) / Real.log (x / ((p : ℝ) - 1)) := henv _ hlo hhi _ ≤ A * (x / ((p : ℝ) - 1)) / (Real.log x / 2) := div_le_div_of_nonneg_left (by positivity) (by positivity) hlogs _ = 2 * A * x / Real.log x * (1 / ((p : ℝ) - 1)) := by field_simp _ ≤ 2 * A * x / Real.log x * (2 / p) := mul_le_mul_of_nonneg_left hrecip (by positivity) _ = _ := by ring _ = _ := (Finset.mul_sum _ _ _).symm /- Original line 15643: Erdos416Proof.siftedTotientPairs_large_card_le_sum -/ theorem siftedTotientPairs_large_card_le_sum (Q : Finset ℕ) {x : ℝ} (hx : 0 < x) (hQ : ∀ p ∈ Q, 2 ≤ p ∧ Real.sqrt x < (p : ℝ)) : ((siftedTotientPairs Q x).card : ℝ) ≤ ∑ t ∈ totientsUpTo (2 * Real.sqrt x), finiteCountBelow Q (x / t + 1) := by let T := (totientsUpTo (2 * Real.sqrt x)).sigma (fun t => Q.filter (fun p : ℕ => (p : ℝ) ≤ x / t + 1)) have hcard : (siftedTotientPairs Q x).card ≤ T.card := by apply Finset.card_le_card_of_injOn (fun pt : ℕ × ℕ => (⟨pt.2, pt.1⟩ : Σ _ : ℕ, ℕ)) · rintro ⟨p, t⟩ hpt obtain ⟨hpQ, htV, hbound⟩ := mem_siftedTotientPairs.mp hpt obtain ⟨ht, htx, m, hm, hmt⟩ := (mem_totientsUpTo hx.le).mp htV have htR : (0 : ℝ) < t := by exact_mod_cast ht have hpR : (2 : ℝ) ≤ p := by exact_mod_cast (hQ p hpQ).1 have hs0 : 0 < Real.sqrt x := Real.sqrt_pos.mpr hx have hsp : Real.sqrt x ≤ 2 * ((p : ℝ) - 1) := by have := (hQ p hpQ).2; linarith have hts : (t : ℝ) ≤ 2 * Real.sqrt x := by by_contra hnot have hmul := mul_pos hs0 (sub_pos.mpr (lt_of_not_ge hnot)) nlinarith [mul_le_mul_of_nonneg_right hsp htR.le, Real.sq_sqrt hx.le] have hpend : (p : ℝ) ≤ x / t + 1 := by have h := (le_div_iff₀ htR).mpr hbound linarith exact Finset.mem_sigma.mpr ⟨(mem_totientsUpTo (by positivity)).mpr ⟨ht, hts, m, hm, hmt⟩, Finset.mem_filter.mpr ⟨hpQ, hpend⟩⟩ · intro a ha b hb hab apply Prod.ext · exact congrArg (fun z : Σ _ : ℕ, ℕ => z.2) hab · exact congrArg Sigma.fst hab dsimp only [T] at hcard rw [Finset.card_sigma] at hcard unfold finiteCountBelow exact_mod_cast hcard /- Original line 15676: Erdos416Proof.large_prime_totient_endpoint -/ theorem large_prime_totient_endpoint {x : ℝ} {t : ℕ} (hx : 16 ≤ x) (ht : 0 < t) (hts : (t : ℝ) ≤ 2 * Real.sqrt x) : 2 ≤ x / t + 1 ∧ x / t + 1 ≤ 2 * x ∧ Real.log x / 4 ≤ Real.log (x / t + 1) ∧ x / t + 1 ≤ 2 * x / t := by have hx0 : 0 < x := by linarith have htR : (0 : ℝ) < t := by exact_mod_cast ht have ht1 : (1 : ℝ) ≤ t := by exact_mod_cast ht have hs0 := Real.sqrt_nonneg x have hs4 : 4 ≤ Real.sqrt x := Real.le_sqrt_of_sq_le (by norm_num; exact hx) have hdiv : Real.sqrt x / 2 ≤ x / t := by apply (le_div_iff₀ htR).mpr nlinarith [mul_le_mul_of_nonneg_left hts hs0, Real.sq_sqrt hx0.le] have hdivupper : x / t ≤ x := div_le_self hx0.le ht1 have hfourth : Real.sqrt (Real.sqrt x) ≤ Real.sqrt x / 2 := by apply (sq_le_sq₀ (Real.sqrt_nonneg _) (by positivity)).mp rw [Real.sq_sqrt hs0] nlinarith [mul_nonneg hs0 (show 0 ≤ Real.sqrt x - 4 by linarith)] refine ⟨by linarith, by linarith, ?_, by rw [mul_div_assoc]; linarith⟩ have h := Real.log_le_log (Real.sqrt_pos.mpr (Real.sqrt_pos.mpr hx0)) (show Real.sqrt (Real.sqrt x) ≤ x / t + 1 by linarith) rw [Real.log_sqrt hs0, Real.log_sqrt hx0.le] at h linarith /- Original line 15699: Erdos416Proof.siftedTotientPairs_large_bound -/ theorem siftedTotientPairs_large_bound (Q : Finset ℕ) {x D : ℝ} (hx : 16 ≤ x) (hD : 0 ≤ D) (hQ : ∀ p ∈ Q, 2 ≤ p ∧ Real.sqrt x < (p : ℝ)) (hdensity : ∀ u : ℝ, 2 ≤ u → u ≤ 2 * x → finiteCountBelow Q u ≤ D * u / Real.log u) : ((siftedTotientPairs Q x).card : ℝ) ≤ 8 * D * x / Real.log x * ∑ t ∈ totientsUpTo (2 * Real.sqrt x), (1 : ℝ) / t := by have hx0 : 0 < x := by linarith have hlog : 0 < Real.log x := Real.log_pos (by linarith) calc _ ≤ ∑ t ∈ totientsUpTo (2 * Real.sqrt x), finiteCountBelow Q (x / t + 1) := siftedTotientPairs_large_card_le_sum Q hx0 hQ _ ≤ ∑ t ∈ totientsUpTo (2 * Real.sqrt x), 8 * D * x / Real.log x * ((1 : ℝ) / t) := by apply Finset.sum_le_sum intro t ht obtain ⟨htpos, hts, hrep⟩ := (mem_totientsUpTo (by positivity)).mp ht obtain ⟨hy2, hymax, hylog, hyupper⟩ := large_prime_totient_endpoint hx htpos hts have htR : (0 : ℝ) < t := by exact_mod_cast htpos calc _ ≤ D * (x / t + 1) / Real.log (x / t + 1) := hdensity _ hy2 hymax _ ≤ D * (x / t + 1) / (Real.log x / 4) := div_le_div_of_nonneg_left (by positivity) (by positivity) hylog _ ≤ D * (2 * x / t) / (Real.log x / 4) := div_le_div_of_nonneg_right (mul_le_mul_of_nonneg_left hyupper hD) (by positivity) _ = _ := by field_simp <;> ring _ = _ := (Finset.mul_sum _ _ _).symm /- Original line 15724: Erdos416Proof.finiteCountBelow_mono_finset -/ theorem finiteCountBelow_mono_finset {Q R : Finset ℕ} (hQR : Q ⊆ R) (u : ℝ) : finiteCountBelow Q u ≤ finiteCountBelow R u := by unfold finiteCountBelow have hsub : Q.filter (fun p : ℕ => (p : ℝ) ≤ u) ⊆ R.filter (fun p : ℕ => (p : ℝ) ≤ u) := by intro p hp exact Finset.mem_filter.mpr ⟨hQR (Finset.mem_filter.mp hp).1, (Finset.mem_filter.mp hp).2⟩ exact_mod_cast Finset.card_le_card hsub /- Original line 15732: Erdos416Proof.exists_siftedTotientPairs_density_bound -/ theorem exists_siftedTotientPairs_density_bound : ∃ K : ℝ, 0 < K ∧ ∀ (Q : Finset ℕ) (x A D : ℝ), 16 ≤ x → 1 ≤ A → 0 ≤ D → TotientCountingEnvelope A x → (∀ p ∈ Q, 2 ≤ p ∧ (p : ℝ) ≤ 2 * x) → (∀ u : ℝ, 2 ≤ u → u ≤ 2 * x → finiteCountBelow Q u ≤ D * u / Real.log u) → ((siftedTotientPairs Q x).card : ℝ) ≤ K * A * D * x / Real.log x * (1 + logLog (2 * x)) := by obtain ⟨K₁, hK₁, hrecip⟩ := exists_finite_reciprocal_density_constant obtain ⟨K₂, hK₂, htotrecip⟩ := exists_totient_reciprocal_envelope_bound refine ⟨4 * K₁ + 8 * K₂, by positivity, ?_⟩ intro Q x A D hx hA hD henv hQ hdensity have hx0 : 0 < x := by linarith have hlog : 0 < Real.log x := Real.log_pos (by linarith) have hA0 : 0 ≤ A := by linarith have h2xe : Real.exp 1 ≤ 2 * x := by linarith [Real.exp_one_lt_three] let P := fun p : ℕ => (p : ℝ) ≤ Real.sqrt x let Q₁ := Q.filter P let Q₂ := Q.filter (fun p => ¬P p) have hd₁ : ∀ u : ℝ, 2 ≤ u → u ≤ 2 * x → finiteCountBelow Q₁ u ≤ D * u / Real.log u := by intro u hu hux exact (finiteCountBelow_mono_finset (Finset.filter_subset _ _) u).trans (hdensity u hu hux) have hd₂ : ∀ u : ℝ, 2 ≤ u → u ≤ 2 * x → finiteCountBelow Q₂ u ≤ D * u / Real.log u := by intro u hu hux exact (finiteCountBelow_mono_finset (Finset.filter_subset _ _) u).trans (hdensity u hu hux) have hs := siftedTotientPairs_small_bound Q₁ hx hA0 henv (by intro p hp obtain ⟨hpQ, hpP⟩ := Finset.mem_filter.mp hp exact ⟨(hQ p hpQ).1, hpP⟩) have hr₁ := hrecip Q₁ (2 * x) D h2xe hD (fun p hp => hQ p (Finset.mem_filter.mp hp).1) hd₁ have hs' : ((siftedTotientPairs Q₁ x).card : ℝ) ≤ 4 * K₁ * A * D * x / Real.log x * (1 + logLog (2 * x)) := by calc _ ≤ 4 * A * x / Real.log x * ∑ p ∈ Q₁, (1 : ℝ) / p := hs _ ≤ 4 * A * x / Real.log x * (K₁ * D * (1 + logLog (2 * x))) := mul_le_mul_of_nonneg_left hr₁ (by positivity) _ = _ := by ring have hs4 : 4 ≤ Real.sqrt x := Real.le_sqrt_of_sq_le (by norm_num; exact hx) have hs0 := Real.sqrt_nonneg x have hzx : 2 * Real.sqrt x ≤ x := by nlinarith [Real.sq_sqrt hx0.le, mul_nonneg hs0 (show 0 ≤ Real.sqrt x - 2 by linarith)] have hze : Real.exp 1 ≤ 2 * Real.sqrt x := by linarith [Real.exp_one_lt_three] have hLL : logLog (2 * Real.sqrt x) ≤ logLog (2 * x) := logLog_mono (by linarith) (by linarith) have hr₂ := htotrecip (2 * Real.sqrt x) A hze hA (fun u hu huz => henv u hu (huz.trans hzx)) have hr₂' : (∑ t ∈ totientsUpTo (2 * Real.sqrt x), (1 : ℝ) / t) ≤ K₂ * A * (1 + logLog (2 * x)) := hr₂.trans (mul_le_mul_of_nonneg_left (add_le_add_right hLL 1) (by positivity)) have hl := siftedTotientPairs_large_bound Q₂ hx hD (by intro p hp obtain ⟨hpQ, hpP⟩ := Finset.mem_filter.mp hp exact ⟨(hQ p hpQ).1, lt_of_not_ge hpP⟩) hd₂ have hl' : ((siftedTotientPairs Q₂ x).card : ℝ) ≤ 8 * K₂ * A * D * x / Real.log x * (1 + logLog (2 * x)) := by calc _ ≤ 8 * D * x / Real.log x * ∑ t ∈ totientsUpTo (2 * Real.sqrt x), (1 : ℝ) / t := hl _ ≤ 8 * D * x / Real.log x * (K₂ * A * (1 + logLog (2 * x))) := mul_le_mul_of_nonneg_left hr₂' (by positivity) _ = _ := by ring have hcover : siftedTotientPairs Q x ⊆ siftedTotientPairs Q₁ x ∪ siftedTotientPairs Q₂ x := by rintro ⟨p, t⟩ hpt obtain ⟨hpQ, ht, hbound⟩ := mem_siftedTotientPairs.mp hpt by_cases hpP : P p · exact Finset.mem_union_left _ (mem_siftedTotientPairs.mpr ⟨Finset.mem_filter.mpr ⟨hpQ, hpP⟩, ht, hbound⟩) · exact Finset.mem_union_right _ (mem_siftedTotientPairs.mpr ⟨Finset.mem_filter.mpr ⟨hpQ, hpP⟩, ht, hbound⟩) have hcard : ((siftedTotientPairs Q x).card : ℝ) ≤ (siftedTotientPairs Q₁ x).card + (siftedTotientPairs Q₂ x).card := by exact_mod_cast (Finset.card_le_card hcover).trans (Finset.card_union_le _ _) calc _ ≤ ((siftedTotientPairs Q₁ x).card : ℝ) + (siftedTotientPairs Q₂ x).card := hcard _ ≤ 4 * K₁ * A * D * x / Real.log x * (1 + logLog (2 * x)) + 8 * K₂ * A * D * x / Real.log x * (1 + logLog (2 * x)) := add_le_add hs' hl' _ = _ := by ring /- Original line 15807: Erdos416Proof.logLog_double_le -/ theorem logLog_double_le {x : ℝ} (hx : 2 ≤ x) : logLog (2 * x) ≤ 1 + logLog x := by have hx0 : 0 < x := by linarith have hlog : 0 < Real.log x := Real.log_pos (by linarith) have hlog2 : Real.log 2 ≤ Real.log x := Real.log_le_log (by norm_num) hx have hinner : Real.log (2 * x) ≤ 2 * Real.log x := by rw [Real.log_mul (by norm_num) hx0.ne'] linarith have h := Real.log_le_log (Real.log_pos (show 1 < 2 * x by linarith)) hinner rw [Real.log_mul (by norm_num) hlog.ne'] at h change logLog (2 * x) ≤ Real.log 2 + logLog x at h linarith [Real.log_le_sub_one_of_pos (show (0 : ℝ) < 2 by norm_num)] /- Original line 15819: Erdos416Proof.exists_nonNormalTotients_count_bound -/ theorem exists_nonNormalTotients_count_bound : ∃ K : ℝ, 0 < K ∧ ∀ S x A : ℝ, Real.exp 1 ≤ S → 16 ≤ x → 1 ≤ A → TotientCountingEnvelope A x → ((nonNormalTotients S x).card : ℝ) ≤ K * A * x / Real.log x * (1 + logLog x) ^ 6 * Real.exp (-logLog S / 6) := by obtain ⟨K, hK, hpair⟩ := exists_siftedTotientPairs_density_bound obtain ⟨C, hC, hdensity⟩ := exists_normalPrimeDensityEstimate refine ⟨128 * K * C, by positivity, ?_⟩ intro S x A hS hx hA henv have hx0 : 0 < x := by linarith have hlog : 0 < Real.log x := Real.log_pos (by linarith) have hT : 0 ≤ logLog x := (logLog_pos_of_three_le (by linarith)).le have hT2 : 0 ≤ logLog (2 * x) := (logLog_pos_of_three_le (by linarith)).le let D := C * (1 + logLog (2 * x)) ^ 5 * Real.exp (-logLog S / 6) have hD : 0 ≤ D := by dsimp [Erdos416Proof.logLog_normalityGridPoint, D]; positivity have hfixed := nonNormalPrimes_density_frozen hS (show 3 ≤ 2 * x by linarith) hC.le (fun u hu _ => hdensity S u hS hu) have h := hpair (nonNormalPrimes S (2 * x)) x A D hx hA hD henv (by intro p hp have hp' := (mem_nonNormalPrimes (by positivity)).mp hp exact ⟨hp'.1.two_le, hp'.2.1⟩) hfixed have hcard : ((nonNormalTotients S x).card : ℝ) ≤ 2 * (siftedTotientPairs (nonNormalPrimes S (2 * x)) x).card := by exact_mod_cast nonNormalTotients_card_le_pairs (S := S) (show 1 ≤ x by linarith) have hpoly : (1 + logLog (2 * x)) ^ 6 ≤ 64 * (1 + logLog x) ^ 6 := by have hLL := logLog_double_le (show 2 ≤ x by linarith) have h := pow_le_pow_left₀ (show 0 ≤ 1 + logLog (2 * x) by linarith) (show 1 + logLog (2 * x) ≤ 2 * (1 + logLog x) by linarith) 6 convert! h using 1 <;> ring calc _ ≤ 2 * (K * A * D * x / Real.log x * (1 + logLog (2 * x))) := hcard.trans (mul_le_mul_of_nonneg_left h (by norm_num)) _ = 2 * K * C * A * x / Real.log x * (1 + logLog (2 * x)) ^ 6 * Real.exp (-logLog S / 6) := by dsimp [Erdos416Proof.logLog_normalityGridPoint, D]; ring _ ≤ 2 * K * C * A * x / Real.log x * (64 * (1 + logLog x) ^ 6) * Real.exp (-logLog S / 6) := mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left hpoly (by positivity)) (Real.exp_pos _).le _ = _ := by ring /- Original line 15858: Erdos416Proof.totientUpperEnvelope -/ noncomputable def totientUpperEnvelope (x : ℝ) : ℝ := max 1 (sSup ((fun u : ℝ => V u * Real.log u / u) '' Set.Icc 2 x)) /- Original line 15861: Erdos416Proof.totientRatio_bddAbove -/ theorem totientRatio_bddAbove (x : ℝ) : BddAbove ((fun u : ℝ => V u * Real.log u / u) '' Set.Icc 2 x) := by refine ⟨V (max 2 x), ?_⟩ rintro a ⟨u, hu, rfl⟩ have hu0 : 0 < u := by linarith [hu.1] have hratio : Real.log u / u ≤ 1 := (div_le_iff₀ hu0).mpr (by simpa only [one_mul] using Real.log_le_self hu0.le) calc _ = V u * (Real.log u / u) := by ring _ ≤ V u := mul_le_of_le_one_right (V_nonneg _) hratio _ ≤ _ := V_mono (hu.2.trans (le_max_right _ _)) /- Original line 15873: Erdos416Proof.totientUpperEnvelope_ge_one -/ theorem totientUpperEnvelope_ge_one (x : ℝ) : 1 ≤ totientUpperEnvelope x := le_max_left _ _ /- Original line 15875: Erdos416Proof.totientUpperEnvelope_spec -/ theorem totientUpperEnvelope_spec (x : ℝ) : TotientCountingEnvelope (totientUpperEnvelope x) x := by intro u hu hux have hu0 : 0 < u := by linarith have hlog : 0 < Real.log u := Real.log_pos (by linarith) have hs := le_csSup (totientRatio_bddAbove x) (show V u * Real.log u / u ∈ ((fun v : ℝ => V v * Real.log v / v) '' Set.Icc 2 x) from ⟨u, ⟨hu, hux⟩, rfl⟩) have hA : V u * Real.log u / u ≤ totientUpperEnvelope x := hs.trans (le_max_right _ _) exact (le_div_iff₀ hlog).mpr ((div_le_iff₀ hu0).mp hA) /- Original line 15884: Erdos416Proof.totientUpperEnvelope_le -/ theorem totientUpperEnvelope_le {x A : ℝ} (hx : 2 ≤ x) (hA : 1 ≤ A) (henv : TotientCountingEnvelope A x) : totientUpperEnvelope x ≤ A := by unfold totientUpperEnvelope refine max_le hA ?_ refine csSup_le (s := ((fun u : ℝ => V u * Real.log u / u) '' Set.Icc 2 x)) ?_ ?_ · exact ⟨_, ⟨(2 : ℝ), ⟨le_rfl, hx⟩, rfl⟩⟩ · rintro a ⟨u, hu, rfl⟩ have hu0 : 0 < u := by linarith [hu.1] have hlog : 0 < Real.log u := Real.log_pos (by linarith [hu.1]) exact (div_le_iff₀ hu0).mpr ((le_div_iff₀ hlog).mp (henv u hu.1 hu.2)) /- Original line 15895: Erdos416Proof.exists_nonNormalTotients_envelope_bound -/ theorem exists_nonNormalTotients_envelope_bound : ∃ K : ℝ, 0 < K ∧ ∀ S x : ℝ, Real.exp 1 ≤ S → 16 ≤ x → ((nonNormalTotients S x).card : ℝ) ≤ K * totientUpperEnvelope x * x / Real.log x * (1 + logLog x) ^ 6 * Real.exp (-logLog S / 6) := by obtain ⟨K, hK, hbound⟩ := exists_nonNormalTotients_count_bound exact ⟨K, hK, fun S x hS hx => hbound S x (totientUpperEnvelope x) hS hx (totientUpperEnvelope_ge_one x) (totientUpperEnvelope_spec x)⟩ /-- The finite exceptional-totient bound gives the manuscript's negligible scale once the actual counting envelope has the indicated growth. This growth statement is an explicit hypothesis, not an admitted theorem. -/ /- Original line 15906: Erdos416Proof.nonNormalTotients_pruning_of_envelope_growth -/ theorem nonNormalTotients_pruning_of_envelope_growth {B : ℝ} (hgrowth : ∀ᶠ x : ℝ in atTop, totientUpperEnvelope x ≤ Real.exp (B * Real.log (logLog x) ^ 2)) : (fun x : ℝ => ((nonNormalTotients (normalityScale (logLog x)) x).card : ℝ)) =o[atTop] (fun x : ℝ => x / (Real.log x * logLog x ^ 2)) := by obtain ⟨K, hK, hbound⟩ := exists_nonNormalTotients_envelope_bound let g : ℝ → ℝ := fun x => x / (Real.log x * logLog x ^ 2) let E : ℝ → ℝ := fun x => 64 * K * x / Real.log x * logLog x ^ 6 * Real.exp (B * Real.log (logLog x) ^ 2 - Real.log (logLog x) ^ 10 / 6) have hT : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop have hpos : ∀ᶠ x : ℝ in atTop, 0 < x ∧ 0 < Real.log x ∧ 0 < logLog x := by filter_upwards [eventually_ge_atTop (3 : ℝ)] with x hx exact ⟨by linarith, Real.log_pos (by linarith), logLog_pos_of_three_le hx⟩ have hE : E =o[atTop] g := by apply (isLittleO_iff_tendsto' ?_).mpr · have hlim := ((normality_saving_dominates B 8).comp hT).const_mul (64 * K) simp only [mul_zero] at hlim apply hlim.congr' filter_upwards [hpos] with x hx rcases hx with ⟨hx0, hlog, hLL⟩ dsimp only [E, g, Function.comp_apply] field_simp [hx0.ne', hlog.ne', hLL.ne'] · filter_upwards [hpos] with x hx hzero rcases hx with ⟨hx0, hlog, hLL⟩ have hg : 0 < g x := by dsimp [Erdos416Proof.logLog_normalityGridPoint, g]; positivity exact (hg.ne' hzero).elim have hdom : (fun x : ℝ => ((nonNormalTotients (normalityScale (logLog x)) x).card : ℝ)) =O[atTop] E := by apply IsBigO.of_norm_eventuallyLE filter_upwards [hgrowth, hpos, eventually_ge_atTop (16 : ℝ), hT.eventually_ge_atTop 1] with x hgrowth hx hx16 hLL1 rcases hx with ⟨hx0, hlog, hLL⟩ have h := hbound (normalityScale (logLog x)) x (normalityScale_ge_exp_one _) hx16 have hs : logLog (normalityScale (logLog x)) = Real.log (logLog x) ^ 10 := logLog_normalityScale _ rw [hs] at h have hpoly : (1 + logLog x) ^ 6 ≤ 64 * logLog x ^ 6 := by have hp := pow_le_pow_left₀ (show 0 ≤ 1 + logLog x by linarith) (show 1 + logLog x ≤ 2 * logLog x by linarith) 6 convert! hp using 1 <;> ring have hcard : ((nonNormalTotients (normalityScale (logLog x)) x).card : ℝ) ≤ E x := by calc _ ≤ K * totientUpperEnvelope x * x / Real.log x * (1 + logLog x) ^ 6 * Real.exp (-Real.log (logLog x) ^ 10 / 6) := h _ ≤ K * Real.exp (B * Real.log (logLog x) ^ 2) * x / Real.log x * (64 * logLog x ^ 6) * Real.exp (-Real.log (logLog x) ^ 10 / 6) := by gcongr _ = E x := by dsimp only [E] simp only [neg_div, Real.exp_neg, Real.exp_sub] ring have hF0 : (0 : ℝ) ≤ (nonNormalTotients (normalityScale (logLog x)) x).card := Nat.cast_nonneg _ have hE0 : 0 ≤ E x := by dsimp [Erdos416Proof.logLog_normalityGridPoint, E]; positivity simpa only [Real.norm_eq_abs, abs_of_nonneg hF0, abs_of_nonneg hE0] using hcard exact hdom.trans_isLittleO hE /- Original line 15965: Erdos416Proof.nonNormalTotients_negligible_in_V_of_envelope_growth -/ theorem nonNormalTotients_negligible_in_V_of_envelope_growth {B : ℝ} (hgrowth : ∀ᶠ x : ℝ in atTop, totientUpperEnvelope x ≤ Real.exp (B * Real.log (logLog x) ^ 2)) : (fun x : ℝ => ((nonNormalTotients (normalityScale (logLog x)) x).card : ℝ)) =o[atTop] V := (nonNormalTotients_pruning_of_envelope_growth hgrowth).trans_isBigO square_pruning_scale_isBigO_V end Erdos416Proof /- An interval weight-three moment and an actual exceptional-totient count. Three sufficiently large normal prime divisors of a positive preimage give a negligible set of totients after the size and factor-count cutoffs. The counting-envelope recursion and growth theorem are proved later in this file. -/ open Filter Asymptotics open scoped BigOperators Classical Topology namespace Erdos416Proof /-- A larger interval weight is permitted when its ratio to each prime stays below the fixed convergence threshold. -/ /- Original line 15992: Erdos416Proof.weightedTotientEulerFactor_three_bound -/ theorem weightedTotientEulerFactor_three_bound {p : ℕ} (hp : p.Prime) {z : ℝ} (hz0 : 0 ≤ z) (hz : z ≤ 3) (ht : z / p ≤ 7 / 8) : weightedTotientEulerFactor p z ≤ Real.exp (z / p + 78 / (p : ℝ) ^ 2) := by have hp2 : (2 : ℝ) ≤ p := by exact_mod_cast hp.two_le have hp0 : (0 : ℝ) < p := by linarith have hp1 : 0 < (p : ℝ) - 1 := by linarith have ht0 : 0 ≤ z / p := div_nonneg hz0 hp0.le have hu : z / ((p : ℝ) * ((p : ℝ) - 1)) ≤ 6 / (p : ℝ) ^ 2 := by have hratio : (p : ℝ) / ((p : ℝ) - 1) ≤ 2 := (div_le_iff₀ hp1).mpr (by linarith) calc _ = (z * ((p : ℝ) / ((p : ℝ) - 1))) / (p : ℝ) ^ 2 := by field_simp _ ≤ _ := div_le_div_of_nonneg_right (by nlinarith [mul_le_mul hz hratio (div_nonneg hp0.le hp1.le) (by norm_num : (0 : ℝ) ≤ 3)]) (sq_nonneg _) have htsq : (z / p) ^ 2 ≤ 9 / (p : ℝ) ^ 2 := by rw [div_pow] apply div_le_div_of_nonneg_right _ (sq_nonneg _) nlinarith have hnum : 1 + z / ((p : ℝ) * ((p : ℝ) - 1)) ≤ Real.exp (z / ((p : ℝ) * ((p : ℝ) - 1))) := by simpa only [add_comm] using Real.add_one_le_exp (z / ((p : ℝ) * ((p : ℝ) - 1))) have hden : 0 ≤ (1 - z / p)⁻¹ := by apply inv_nonneg.mpr; linarith calc _ = (1 + z / ((p : ℝ) * ((p : ℝ) - 1))) * (1 - z / p)⁻¹ := rfl _ ≤ Real.exp (z / ((p : ℝ) * ((p : ℝ) - 1))) * Real.exp (z / p + 8 * (z / p) ^ 2) := mul_le_mul hnum (inv_one_sub_le_exp_quadratic ht0 ht) hden (Real.exp_pos _).le _ = Real.exp (z / ((p : ℝ) * ((p : ℝ) - 1)) + (z / p + 8 * (z / p) ^ 2)) := (Real.exp_add _ _).symm _ ≤ _ := by apply Real.exp_le_exp.mpr ring_nf at hu htsq ⊢ linarith /- Original line 16025: Erdos416Proof.finite_weightedInvTotient_three_bound -/ theorem finite_weightedInvTotient_three_bound (w : ℕ → ℝ) (hw : ∀ p : ℕ, p.Prime → 0 ≤ w p ∧ w p ≤ 3 ∧ w p / p ≤ 7 / 8) (s F : Finset ℕ) (hF : ∀ n ∈ F, n ∈ Nat.factoredNumbers s) : (∑ n ∈ F, weightedInvTotient w n) ≤ Real.exp ((∑ p ∈ s with p.Prime, w p / p) + 78) := by have hwlt : ∀ p : ℕ, p.Prime → 0 ≤ w p ∧ w p < p := by intro p hp have hp0 : (0 : ℝ) < p := by exact_mod_cast hp.pos refine ⟨(hw p hp).1, (div_lt_one hp0).mp ?_⟩ linarith [(hw p hp).2.2] have hsq : (∑ p ∈ s with p.Prime, (1 : ℝ) / (p : ℝ) ^ 2) ≤ 1 := by simpa [Erdos416Proof.weightedInvTotient_one] using finite_inverse_square_tail (s.filter Nat.Prime) (show 0 < 2 by norm_num) (fun p hp => (Finset.mem_filter.mp hp).2.two_le) calc _ ≤ ∏ p ∈ s with p.Prime, weightedTotientEulerFactor p (w p) := finite_weightedInvTotient_bound w hwlt s F hF _ ≤ ∏ p ∈ s with p.Prime, Real.exp (w p / p + 78 / (p : ℝ) ^ 2) := by apply Finset.prod_le_prod · intro p hp have hp' := (Finset.mem_filter.mp hp).2 exact (weightedTotientEulerFactor_pos hp' (hwlt p hp').1 (hwlt p hp').2).le · intro p hp have hp' := (Finset.mem_filter.mp hp).2 exact weightedTotientEulerFactor_three_bound hp' (hw p hp').1 (hw p hp').2.1 (hw p hp').2.2 _ = Real.exp ((∑ p ∈ s with p.Prime, w p / p) + 78 * ∑ p ∈ s with p.Prime, (1 : ℝ) / (p : ℝ) ^ 2) := by rw [← Real.exp_sum] congr 1 simp only [Finset.sum_add_distrib, Finset.mul_sum, mul_one_div] _ ≤ _ := Real.exp_le_exp.mpr (by linarith) /-- The weight three is used only at primes larger than u>=7. Small prime powers keep weight one, so the Euler product converges. -/ /- Original line 16059: Erdos416Proof.exists_omegaInterval_three_moment_bound -/ theorem exists_omegaInterval_three_moment_bound : ∃ K : ℝ, 0 < K ∧ ∀ (x u v : ℝ) (F : Finset ℕ), 7 ≤ u → u ≤ v → v ≤ x → (∀ n ∈ F, n ∈ Nat.factoredNumbers (Nat.primesLE ⌊x⌋₊)) → (∑ n ∈ F, (3 : ℝ) ^ omegaInterval n u v / (n.totient : ℝ)) ≤ K * Real.log x * Real.exp (2 * (logLog v - logLog u)) := by obtain ⟨B, hB⟩ := prime_reciprocal_mertens let K := Real.exp (78 + 5 * |B|) refine ⟨K, Real.exp_pos _, ?_⟩ intro x u v F hu huv hvx hF have hu2 : 2 ≤ u := by linarith have hx2 : 2 ≤ x := (hu2.trans huv).trans hvx have hlog : 0 < Real.log x := Real.log_pos (by linarith) have hw : ∀ p : ℕ, p.Prime → 0 ≤ primeIntervalTilt u v 3 p ∧ primeIntervalTilt u v 3 p ≤ 3 ∧ primeIntervalTilt u v 3 p / p ≤ 7 / 8 := by intro p hp have hp2 : (2 : ℝ) ≤ p := by exact_mod_cast hp.two_le have hp0 : (0 : ℝ) < p := by linarith unfold primeIntervalTilt split_ifs with hin · refine ⟨by norm_num, le_rfl, (div_le_iff₀ hp0).mpr ?_⟩ linarith [hin.1] · exact ⟨by norm_num, by norm_num, (div_le_iff₀ hp0).mpr (by linarith)⟩ have hbound := finite_weightedInvTotient_three_bound (primeIntervalTilt u v 3) hw (Nat.primesLE ⌊x⌋₊) F hF have hsum : (∑ n ∈ F, weightedInvTotient (primeIntervalTilt u v 3) n) = ∑ n ∈ F, (3 : ℝ) ^ omegaInterval n u v / (n.totient : ℝ) := by apply Finset.sum_congr rfl intro n hn have hn0 := (Nat.mem_factoredNumbers_iff_primeFactors_subset.mp (hF n hn)).1 simp only [weightedInvTotient, primeWeightHom_intervalTilt u v 3 hn0, invTotient, div_eq_mul_inv] have hprimes : (Nat.primesLE ⌊x⌋₊).filter Nat.Prime = Nat.primesLE ⌊x⌋₊ := Finset.filter_eq_self.mpr (fun p hp => Nat.prime_of_mem_primesLE hp) rw [hsum, hprimes, primeIntervalTilt_sum] at hbound let Δ := logLog v - logLog u let μ := ∑ p ∈ (Nat.primesLE ⌊x⌋₊).filter (fun p : ℕ => u < (p : ℝ) ∧ (p : ℝ) ≤ v), (1 : ℝ) / p have hI : |μ - Δ| ≤ 2 * |B| := prime_interval_reciprocal_error hB hu2 huv hvx have hbase := (abs_le.mp (hB x hx2)).2 have hexponent : (∑ p ∈ Nat.primesLE ⌊x⌋₊, (1 : ℝ) / p) + 2 * μ + 78 ≤ (78 + 5 * |B|) + logLog x + 2 * Δ := by change (∑ p ∈ Nat.primesLE ⌊x⌋₊, (1 : ℝ) / p) - logLog x ≤ B at hbase linarith [(abs_le.mp hI).2, le_abs_self B] calc _ ≤ Real.exp ((∑ p ∈ Nat.primesLE ⌊x⌋₊, (1 : ℝ) / p) + 2 * μ + 78) := by simpa only [show (3 : ℝ) - 1 = 2 by norm_num] using hbound _ ≤ Real.exp ((78 + 5 * |B|) + logLog x + 2 * Δ) := Real.exp_le_exp.mpr hexponent _ = _ := by rw [Real.exp_add, Real.exp_add]; simp only [logLog, Real.exp_log hlog]; rfl /- Original line 16107: Erdos416Proof.exists_omegaInterval_three_tail_bound -/ theorem exists_omegaInterval_three_tail_bound : ∃ K : ℝ, 0 < K ∧ ∀ (x u v a : ℝ) (F : Finset ℕ), 7 ≤ u → u ≤ v → v ≤ x → (∀ n ∈ F, n ∈ Nat.factoredNumbers (Nat.primesLE ⌊x⌋₊)) → (∀ n ∈ F, a ≤ (omegaInterval n u v : ℝ)) → (∑ n ∈ F, invTotient n) ≤ K * Real.log x * Real.exp (2 * (logLog v - logLog u)) / (3 : ℝ) ^ a := by obtain ⟨K, hK, hmoment⟩ := exists_omegaInterval_three_moment_bound refine ⟨K, hK, ?_⟩ intro x u v a F hu huv hvx hF ha have hweighted : (3 : ℝ) ^ a * (∑ n ∈ F, invTotient n) ≤ ∑ n ∈ F, (3 : ℝ) ^ omegaInterval n u v / (n.totient : ℝ) := by rw [Finset.mul_sum] apply Finset.sum_le_sum intro n hn have hpow := Real.rpow_le_rpow_of_exponent_le (by norm_num : (1 : ℝ) ≤ 3) (ha n hn) rw [Real.rpow_natCast] at hpow simpa only [invTotient, div_eq_mul_inv] using mul_le_mul_of_nonneg_right hpow (invTotient_nonneg n) apply (le_div_iff₀ (Real.rpow_pos_of_pos (by norm_num : (0 : ℝ) < 3) a)).mpr simpa only [mul_comm] using hweighted.trans (hmoment x u v F hu huv hvx hF) /-- Counting via a largest prime preserves the saving from the interval moment. Removing that prime costs at most one interval factor, even when the integer is not squarefree. -/ /- Original line 16132: Erdos416Proof.exists_interval_dense_integer_bound -/ theorem exists_interval_dense_integer_bound : ∃ K : ℝ, 0 < K ∧ ∀ (x u v H a : ℝ) (F : Finset ℕ), 4 ≤ x → 7 ≤ u → u ≤ v → v ≤ x → 0 < H → (∀ n ∈ F, Real.sqrt x ≤ (n : ℝ) ∧ (n : ℝ) ≤ x ∧ (ArithmeticFunction.cardFactors n : ℝ) ≤ H ∧ a ≤ (omegaInterval n u v : ℝ)) → (F.card : ℝ) ≤ K * H * x * Real.exp (2 * (logLog v - logLog u)) / (3 : ℝ) ^ (a - 1) := by obtain ⟨C, hC, hcount⟩ := prime_cofactor_count_bound obtain ⟨K, hK, htail⟩ := exists_omegaInterval_three_tail_bound refine ⟨2 * C * K, by positivity, ?_⟩ intro x u v H a F hx hu huv hvx hH hF have hx0 : 0 < x := by linarith have hlog : 0 < Real.log x := Real.log_pos (by linarith) have hsqrt2 : (2 : ℝ) ≤ Real.sqrt x := Real.le_sqrt_of_sq_le (by norm_num; exact hx) let bnd := Real.log x / (2 * H) have hbnd : 0 < bnd := by dsimp [Erdos416Proof.invTotient_one, Erdos416Proof.largestPrimeFactor_one, Erdos416Proof.logLog_normalityGridPoint, Erdos416Proof.omegaInterval_one, Erdos416Proof.weightedInvTotient_one, bnd]; positivity have hdata (n : ℕ) (hn : n ∈ F) : 0 < n ∧ (n : ℝ) ≤ x ∧ (largestPrimeFactor n).Prime ∧ largestPrimeFactor n ∣ n ∧ bnd ≤ Real.log (largestPrimeFactor n) := by obtain ⟨hnlarge, hnx, hnH, _⟩ := hF n hn have hn1 : 1 < n := by have hnR : (1 : ℝ) < n := by linarith exact_mod_cast hnR have hp := largestPrimeFactor_isPrime (largestPrimeFactor_one_lt hn1) have hn0 : 0 < n := by omega refine ⟨hn0, hnx, hp, largestPrimeFactor_dvd n, ?_⟩ have hln : Real.log x / 2 ≤ Real.log n := by have h := Real.log_le_log (Real.sqrt_pos.mpr hx0) hnlarge simpa only [Real.log_sqrt hx0.le] using h have hΩ := log_le_cardFactors_mul_log_largestPrimeFactor hn0 have hpLog : 0 ≤ Real.log (largestPrimeFactor n) := Real.log_nonneg (by exact_mod_cast hp.one_le) have hklog := mul_le_mul_of_nonneg_right hnH hpLog exact (div_le_iff₀ (by positivity : 0 < 2 * H)).mpr (by nlinarith) let B := cofactorSet F largestPrimeFactor have hB (b : ℕ) (hb : b ∈ B) : 0 < b ∧ (b : ℝ) ≤ x ∧ a - 1 ≤ (omegaInterval b u v : ℝ) := by obtain ⟨n, hn, rfl⟩ := Finset.mem_image.mp hb obtain ⟨hn0, hnx, hp, hpn, _⟩ := hdata n hn have hb0 : 0 < n / largestPrimeFactor n := Nat.div_pos (Nat.le_of_dvd hn0 hpn) hp.pos have hbn : (n / largestPrimeFactor n : ℕ) ≤ n := Nat.div_le_self _ _ have hbnR : (n / largestPrimeFactor n : ℕ) ≤ (n : ℝ) := by exact_mod_cast hbn refine ⟨hb0, hbnR.trans hnx, ?_⟩ have hω := omegaInterval_mul hb0.ne' hp.ne_zero u v rw [Nat.div_mul_cancel hpn, omegaInterval_prime hp] at hω have hloss : omegaInterval n u v ≤ omegaInterval (n / largestPrimeFactor n) u v + 1 := by rw [hω] split_ifs <;> omega have hlossR : (omegaInterval n u v : ℝ) ≤ omegaInterval (n / largestPrimeFactor n) u v + 1 := by exact_mod_cast hloss linarith [(hF n hn).2.2.2] have hrecip : (∑ b ∈ B, (1 : ℝ) / b) ≤ ∑ b ∈ B, invTotient b := Finset.sum_le_sum (fun b hb => reciprocal_le_invTotient (hB b hb).1) have htailB := htail x u v (a - 1) B hu huv hvx (fun b hb => factored_primesLE_of_positive_le (hB b hb).1 (hB b hb).2.1) (fun b hb => (hB b hb).2.2) calc _ ≤ C * x / bnd * ∑ b ∈ B, (1 : ℝ) / b := hcount F largestPrimeFactor x bnd hx0 hbnd hdata _ ≤ C * x / bnd * (K * Real.log x * Real.exp (2 * (logLog v - logLog u)) / (3 : ℝ) ^ (a - 1)) := mul_le_mul_of_nonneg_left (hrecip.trans htailB) (by positivity) _ = _ := by dsimp [Erdos416Proof.invTotient_one, Erdos416Proof.largestPrimeFactor_one, Erdos416Proof.logLog_normalityGridPoint, Erdos416Proof.omegaInterval_one, Erdos416Proof.weightedInvTotient_one, bnd]; field_simp [hlog.ne', hH.ne'] /- Original line 16195: Erdos416Proof.log_three_lower_bound -/ theorem log_three_lower_bound : (23 / 21 : ℝ) ≤ Real.log 3 := by have h := Real.sum_range_le_log_div (x := (1 / 2 : ℝ)) (by norm_num) (by norm_num) 3 norm_num [Finset.sum_range_succ] at h linarith /- Original line 16200: Erdos416Proof.sqrt_mul_log_isLittleO -/ theorem sqrt_mul_log_isLittleO (c : ℝ) : (fun T : ℝ => Real.sqrt (c * T * Real.log T)) =o[atTop] (fun T : ℝ => T) := by have h : (fun T : ℝ => c * T * Real.log T) =o[atTop] (fun T : ℝ => T ^ 2) := by have hbase := (Real.isLittleO_log_id_atTop.mul_isBigO (isBigO_refl (fun T : ℝ => T) atTop)).const_mul_left c simpa only [id, pow_two, mul_comm, mul_left_comm, mul_assoc] using hbase have hs := h.sqrt (Eventually.of_forall fun T => sq_nonneg T) refine hs.congr' (Eventually.of_forall fun _ => rfl) ?_ filter_upwards [eventually_ge_atTop (0 : ℝ)] with T hT exact Real.sqrt_sq hT /- Original line 16211: Erdos416Proof.threePrimeIntervalThreshold -/ noncomputable def threePrimeIntervalThreshold (T : ℝ) : ℝ := 3 * ((79 / 100 : ℝ) * T - 100 * Real.log T - Real.sqrt (79 * T * Real.log T)) /-- The numerical margin for three large normal primes. Polynomial and square-root normality losses are absorbed with a strict saving beyond 1/log(x). -/ /- Original line 16216: Erdos416Proof.threePrimeInterval_exponent_saving -/ theorem threePrimeInterval_exponent_saving : ∀ᶠ T : ℝ in atTop, 2 * ((79 / 100 : ℝ) * T - 100 * Real.log T) - (threePrimeIntervalThreshold T - 1) * Real.log 3 ≤ -(101 / 100 : ℝ) * T := by let E : ℝ → ℝ := fun T => (3 * Real.log 3 - 2) * 100 * Real.log T + 3 * Real.log 3 * Real.sqrt (79 * T * Real.log T) + Real.log 3 have hE : E =o[atTop] (fun T : ℝ => T) := ((Real.isLittleO_log_id_atTop.const_mul_left ((3 * Real.log 3 - 2) * 100)).add ((sqrt_mul_log_isLittleO 79).const_mul_left (3 * Real.log 3))).add (isLittleO_const_id_atTop (Real.log 3)) filter_upwards [hE.def (by norm_num : (0 : ℝ) < 1 / 200), eventually_ge_atTop (0 : ℝ)] with T herror hT simp only [Real.norm_eq_abs, abs_of_nonneg hT] at herror have hEbound : E T ≤ T / 200 := by linarith [le_abs_self (E T)] have hlog := mul_le_mul_of_nonneg_right log_three_lower_bound hT calc _ = -((79 / 100 : ℝ) * (3 * Real.log 3 - 2)) * T + E T := by dsimp [threePrimeIntervalThreshold, E] ring _ ≤ _ := by nlinarith /- Original line 16237: Erdos416Proof.omegaInterval_mono_dvd -/ theorem omegaInterval_mono_dvd {m n : ℕ} (hn : 0 < n) (hmn : m ∣ n) (u v : ℝ) : omegaInterval m u v ≤ omegaInterval n u v := by obtain ⟨k, rfl⟩ := hmn have hm : m ≠ 0 := by intro hm; simp [Erdos416Proof.omegaInterval_one, hm] at hn have hk : k ≠ 0 := by intro hk; simp [Erdos416Proof.omegaInterval_one, hk] at hn rw [omegaInterval_mul hm hk] omega /-- Any finite set of distinct normal prime divisors forces interval factors in the actual totient. No squarefree hypothesis on n is needed. -/ /- Original line 16247: Erdos416Proof.normal_prime_divisors_interval_lower -/ theorem normal_prime_divisors_interval_lower {n : ℕ} (hn : 0 < n) (P : Finset ℕ) {S Z : ℝ} (hS : Real.exp 1 ≤ S) (hSZ : S < Z) (hP : ∀ p ∈ P, SNormal S p ∧ p ∣ n ∧ Z ≤ (p - 1 : ℕ)) : (P.card : ℝ) * (logLog Z - logLog S - Real.sqrt (logLog S * logLog Z)) ≤ (omegaInterval n.totient S Z : ℝ) := by have hprime : ∀ p ∈ P, p.Prime := fun p hp => (hP p hp).1.1 have hprod : ∏ p ∈ P, p ∣ n := Finset.prod_primes_dvd n (fun p hp => (Nat.prime_iff.mp (hprime p hp))) (fun p hp => (hP p hp).2.1) have hφ := Nat.totient_dvd_of_dvd hprod rw [totient_prod_primes P hprime] at hφ have hω := omegaInterval_mono_dvd (Nat.totient_pos.mpr hn) hφ S Z rw [omegaInterval_prod P (fun p => p - 1) (fun p hp => by have := (hprime p hp).two_le; omega)] at hω have hsum : (∑ p ∈ P, (omegaInterval (p - 1) S Z : ℝ)) ≤ (omegaInterval n.totient S Z : ℝ) := by exact_mod_cast hω calc _ = ∑ _p ∈ P, (logLog Z - logLog S - Real.sqrt (logLog S * logLog Z)) := by simp only [Finset.sum_const, nsmul_eq_mul] _ ≤ ∑ p ∈ P, (omegaInterval (p - 1) S Z : ℝ) := Finset.sum_le_sum (fun p hp => ((hP p hp).1.interval_bounds hS le_rfl hSZ le_rfl (hP p hp).2.2).1) _ ≤ _ := hsum /- Original line 16269: Erdos416Proof.growthNormalityScale -/ noncomputable def growthNormalityScale (T : ℝ) : ℝ := Real.exp (Real.exp (100 * Real.log T)) /- Original line 16272: Erdos416Proof.growthIntervalEndpoint -/ noncomputable def growthIntervalEndpoint (T : ℝ) : ℝ := Real.exp (Real.exp ((79 / 100 : ℝ) * T)) /- Original line 16275: Erdos416Proof.growthLargePrimeCutoff -/ noncomputable def growthLargePrimeCutoff (T : ℝ) : ℝ := Real.exp (Real.exp ((4 / 5 : ℝ) * T)) /- Original line 16278: Erdos416Proof.logLog_growthNormalityScale -/ theorem logLog_growthNormalityScale (T : ℝ) : logLog (growthNormalityScale T) = 100 * Real.log T := by simp only [logLog, growthNormalityScale, Real.log_exp] /- Original line 16282: Erdos416Proof.logLog_growthIntervalEndpoint -/ theorem logLog_growthIntervalEndpoint (T : ℝ) : logLog (growthIntervalEndpoint T) = (79 / 100 : ℝ) * T := by simp only [logLog, growthIntervalEndpoint, Real.log_exp] /- Original line 16286: Erdos416Proof.growth_interval_below_cutoff -/ theorem growth_interval_below_cutoff {T : ℝ} (hT : 100 ≤ T) : growthIntervalEndpoint T + 1 ≤ growthLargePrimeCutoff T := by have hT0 : 0 ≤ T := by linarith have ha : 1 ≤ Real.exp ((79 / 100 : ℝ) * T) := Real.one_le_exp_iff.mpr (by positivity) have hb : 2 ≤ Real.exp ((1 / 100 : ℝ) * T) := by linarith [Real.add_one_le_exp ((1 / 100 : ℝ) * T)] have hc : Real.exp ((79 / 100 : ℝ) * T) + 1 ≤ Real.exp ((4 / 5 : ℝ) * T) := by rw [show (4 / 5 : ℝ) * T = (79 / 100 : ℝ) * T + (1 / 100 : ℝ) * T by ring, Real.exp_add] nlinarith [Real.exp_pos ((79 / 100 : ℝ) * T)] have hZ : 1 ≤ growthIntervalEndpoint T := Real.one_le_exp_iff.mpr (Real.exp_pos _).le calc _ ≤ growthIntervalEndpoint T * Real.exp 1 := by nlinarith [Real.add_one_le_exp (1 : ℝ)] _ = Real.exp (Real.exp ((79 / 100 : ℝ) * T) + 1) := by rw [Real.exp_add]; rfl _ ≤ _ := Real.exp_le_exp.mpr hc /- Original line 16304: Erdos416Proof.growth_interval_parameters -/ theorem growth_interval_parameters : ∀ᶠ x : ℝ in atTop, 4 ≤ x ∧ 7 ≤ growthNormalityScale (logLog x) ∧ growthNormalityScale (logLog x) < growthIntervalEndpoint (logLog x) ∧ growthIntervalEndpoint (logLog x) ≤ x ∧ growthIntervalEndpoint (logLog x) + 1 ≤ growthLargePrimeCutoff (logLog x) := by have hT : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop have hS : Tendsto growthNormalityScale atTop atTop := Real.tendsto_exp_atTop.comp (Real.tendsto_exp_atTop.comp (Real.tendsto_log_atTop.const_mul_atTop (by norm_num : (0 : ℝ) < 100))) have hsmall := Real.isLittleO_log_id_atTop.def (by norm_num : (0 : ℝ) < 1 / 200) filter_upwards [eventually_ge_atTop (4 : ℝ), hT.eventually_ge_atTop 100, (hS.comp hT).eventually_ge_atTop 7, hT.eventually hsmall] with x hx hT100 hS7 hsmall have hT0 : 0 < logLog x := by linarith have hlogT : 0 ≤ Real.log (logLog x) := Real.log_nonneg (by linarith) simp only [Real.norm_eq_abs, id, abs_of_nonneg hlogT, abs_of_pos hT0] at hsmall refine ⟨hx, hS7, ?_, ?_, growth_interval_below_cutoff hT100⟩ · apply Real.exp_lt_exp.mpr apply Real.exp_lt_exp.mpr nlinarith · calc _ ≤ Real.exp (Real.exp (logLog x)) := by apply Real.exp_le_exp.mpr apply Real.exp_le_exp.mpr linarith _ = x := by rw [logLog, Real.exp_log (Real.log_pos (by linarith)), Real.exp_log (by linarith)] /-- Actual distinct totients whose some positive preimage contains three distinct large normal primes, after the already controlled size and total-factor-count exceptions have been removed. -/ /- Original line 16335: Erdos416Proof.threeLargeNormalTotients -/ noncomputable def threeLargeNormalTotients (x : ℝ) : Finset ℕ := (totientsUpTo x).filter (fun m : ℕ => Real.sqrt x ≤ (m : ℝ) ∧ (ArithmeticFunction.cardFactors m : ℝ) ≤ 5 * logLog x ∧ ∃ n : ℕ, 0 < n ∧ n.totient = m ∧ ∃ P : Finset ℕ, P.card = 3 ∧ ∀ p ∈ P, SNormal (growthNormalityScale (logLog x)) p ∧ p ∣ n ∧ growthLargePrimeCutoff (logLog x) < (p : ℝ)) /- Original line 16342: Erdos416Proof.threeLargeNormalTotients_interval_lower -/ theorem threeLargeNormalTotients_interval_lower {x : ℝ} (hS : 7 ≤ growthNormalityScale (logLog x)) (hSZ : growthNormalityScale (logLog x) < growthIntervalEndpoint (logLog x)) (hZH : growthIntervalEndpoint (logLog x) + 1 ≤ growthLargePrimeCutoff (logLog x)) {m : ℕ} (hm : m ∈ threeLargeNormalTotients x) : threePrimeIntervalThreshold (logLog x) ≤ (omegaInterval m (growthNormalityScale (logLog x)) (growthIntervalEndpoint (logLog x)) : ℝ) := by obtain ⟨_, _, _, n, hn, hφ, P, hPcard, hP⟩ := Finset.mem_filter.mp hm have hSe : Real.exp 1 ≤ growthNormalityScale (logLog x) := by linarith [Real.exp_one_lt_three] have h := normal_prime_divisors_interval_lower hn P hSe hSZ (by intro p hp obtain ⟨hpnormal, hpn, hpH⟩ := hP p hp refine ⟨hpnormal, hpn, ?_⟩ rw [Nat.cast_sub hpnormal.1.one_le, Nat.cast_one] linarith) rw [hPcard, hφ, logLog_growthNormalityScale, logLog_growthIntervalEndpoint] at h have hsqrt : 100 * Real.log (logLog x) * ((79 / 100 : ℝ) * logLog x) = 79 * logLog x * Real.log (logLog x) := by ring rw [hsqrt] at h simpa only [Nat.cast_ofNat, threePrimeIntervalThreshold] using h /- Original line 16364: Erdos416Proof.exists_threeLargeNormalTotients_bound -/ theorem exists_threeLargeNormalTotients_bound : ∃ K : ℝ, 0 < K ∧ ∀ᶠ x : ℝ in atTop, ((threeLargeNormalTotients x).card : ℝ) ≤ K * x * logLog x * Real.log x ^ (-(101 / 100 : ℝ)) := by obtain ⟨K, hK, hcount⟩ := exists_interval_dense_integer_bound refine ⟨5 * K, by positivity, ?_⟩ have hT : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [growth_interval_parameters, hT.eventually_ge_atTop 1, hT.eventually threePrimeInterval_exponent_saving] with x hparams hT1 hsaving obtain ⟨hx4, hS7, hSZ, hZx, hZH⟩ := hparams have hx0 : 0 < x := by linarith have hlog : 0 < Real.log x := Real.log_pos (by linarith) have hT0 : 0 < logLog x := by linarith have hF : ∀ m ∈ threeLargeNormalTotients x, Real.sqrt x ≤ (m : ℝ) ∧ (m : ℝ) ≤ x ∧ (ArithmeticFunction.cardFactors m : ℝ) ≤ 5 * logLog x ∧ threePrimeIntervalThreshold (logLog x) ≤ (omegaInterval m (growthNormalityScale (logLog x)) (growthIntervalEndpoint (logLog x)) : ℝ) := by intro m hm obtain ⟨hmV, hlarge, hΩ, _⟩ := Finset.mem_filter.mp hm exact ⟨hlarge, ((mem_totientsUpTo hx0.le).mp hmV).2.1, hΩ, threeLargeNormalTotients_interval_lower hS7 hSZ hZH hm⟩ have h := hcount x (growthNormalityScale (logLog x)) (growthIntervalEndpoint (logLog x)) (5 * logLog x) (threePrimeIntervalThreshold (logLog x)) (threeLargeNormalTotients x) hx4 hS7 hSZ.le hZx (by positivity) hF rw [logLog_growthNormalityScale, logLog_growthIntervalEndpoint] at h have hdecay : Real.exp (2 * ((79 / 100 : ℝ) * logLog x - 100 * Real.log (logLog x))) / (3 : ℝ) ^ (threePrimeIntervalThreshold (logLog x) - 1) ≤ Real.log x ^ (-(101 / 100 : ℝ)) := by rw [Real.rpow_def_of_pos (by norm_num : (0 : ℝ) < 3), ← Real.exp_sub, Real.rpow_def_of_pos hlog] apply Real.exp_le_exp.mpr change _ ≤ logLog x * -(101 / 100 : ℝ) nlinarith [hsaving] calc _ ≤ (K * (5 * logLog x) * x) * (Real.exp (2 * ((79 / 100 : ℝ) * logLog x - 100 * Real.log (logLog x))) / (3 : ℝ) ^ (threePrimeIntervalThreshold (logLog x) - 1)) := by convert! h using 1 <;> ring _ ≤ (K * (5 * logLog x) * x) * Real.log x ^ (-(101 / 100 : ℝ)) := mul_le_mul_of_nonneg_left hdecay (by positivity) _ = _ := by ring /- Original line 16408: Erdos416Proof.threeLargeNormalTotients_negligible -/ theorem threeLargeNormalTotients_negligible : (fun x : ℝ => ((threeLargeNormalTotients x).card : ℝ)) =o[atTop] (fun x : ℝ => x / (Real.log x * logLog x ^ 2)) := by obtain ⟨K, hK, hbound⟩ := exists_threeLargeNormalTotients_bound let g : ℝ → ℝ := fun x => x / (Real.log x * logLog x ^ 2) let E : ℝ → ℝ := fun x => K * x * logLog x * Real.log x ^ (-(101 / 100 : ℝ)) have hpos : ∀ᶠ x : ℝ in atTop, 0 < x ∧ 0 < Real.log x ∧ 0 < logLog x := by filter_upwards [eventually_ge_atTop (3 : ℝ)] with x hx exact ⟨by linarith, Real.log_pos (by linarith), logLog_pos_of_three_le hx⟩ have hE : E =o[atTop] g := by have hlim : Tendsto (fun x : ℝ => K * (logLog x ^ 3 * Real.log x ^ (-1 / 100 : ℝ))) atTop (nhds 0) := by have h := (log_pow_mul_rpow_littleO 3 (show (-1 / 100 : ℝ) < 0 by norm_num)).tendsto_div_nhds_zero simp only [Real.rpow_zero, div_one] at h simpa only [Function.comp_apply, mul_zero, logLog] using (h.comp Real.tendsto_log_atTop).const_mul K apply (isLittleO_iff_tendsto' ?_).mpr · apply hlim.congr' filter_upwards [hpos] with x hx rcases hx with ⟨hx0, hlog, hLL⟩ have hpowers : Real.log x ^ (-(101 / 100 : ℝ)) * Real.log x = Real.log x ^ (-1 / 100 : ℝ) := by have h := Real.rpow_add hlog (-(101 / 100)) 1 norm_num at h simpa only [neg_div] using h.symm dsimp only [E, g] calc _ = K * (Real.log x ^ (-(101 / 100 : ℝ)) * Real.log x) * logLog x ^ 3 := by rw [hpowers]; ring _ = _ := by field_simp [hx0.ne', hlog.ne', hLL.ne'] · filter_upwards [hpos] with x hx hzero rcases hx with ⟨hx0, hlog, hLL⟩ have hg : 0 < g x := by dsimp [Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_normalityGridPoint, g]; positivity exact (hg.ne' hzero).elim have hdom : (fun x : ℝ => ((threeLargeNormalTotients x).card : ℝ)) =O[atTop] E := by apply IsBigO.of_norm_eventuallyLE filter_upwards [hbound, hpos] with x hbound hx rcases hx with ⟨hx0, hlog, hLL⟩ have hF0 : (0 : ℝ) ≤ (threeLargeNormalTotients x).card := Nat.cast_nonneg _ have hE0 : 0 ≤ E x := by dsimp [Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_normalityGridPoint, E]; positivity simpa only [Real.norm_eq_abs, abs_of_nonneg hF0, abs_of_nonneg hE0] using hbound exact hdom.trans_isLittleO hE /- Original line 16451: Erdos416Proof.threeLargeNormalTotients_negligible_in_V -/ theorem threeLargeNormalTotients_negligible_in_V : (fun x : ℝ => ((threeLargeNormalTotients x).card : ℝ)) =o[atTop] V := threeLargeNormalTotients_negligible.trans_isBigO square_pruning_scale_isBigO_V /- Original line 16455: Erdos416Proof.at_most_two_large_prime_divisors -/ theorem at_most_two_large_prime_divisors {x : ℝ} (hx : 9 ≤ x) {m n : ℕ} (hmV : m ∈ totientsUpTo x) (hlarge : Real.sqrt x ≤ (m : ℝ)) (hn : 0 < n) (hφ : n.totient = m) (hnormal : m ∉ nonNormalTotients (growthNormalityScale (logLog x)) x) (hΩ : m ∉ fiveLogOmegaTotients x) (hthree : m ∉ threeLargeNormalTotients x) : ((n.primeFactors).filter (fun p : ℕ => growthLargePrimeCutoff (logLog x) < (p : ℝ))).card ≤ 2 := by have hx0 : 0 ≤ x := by linarith have hmdata := (mem_totientsUpTo hx0).mp hmV have hm3 : 3 ≤ m := by have hs : (3 : ℝ) ≤ Real.sqrt x := Real.le_sqrt_of_sq_le (by norm_num; exact hx) have hm3R : (3 : ℝ) ≤ m := hs.trans hlarge exact_mod_cast hm3R have hΩm : (ArithmeticFunction.cardFactors m : ℝ) ≤ 5 * logLog (m : ℝ) := by by_contra h exact hΩ (Finset.mem_filter.mpr ⟨hmV, hm3, lt_of_not_ge h⟩) have hΩx : (ArithmeticFunction.cardFactors m : ℝ) ≤ 5 * logLog x := hΩm.trans (mul_le_mul_of_nonneg_left (logLog_mono (by exact_mod_cast (show 1 < m by omega)) hmdata.2.1) (by norm_num)) have hnorm : ∀ p ∈ n.primeFactors, SNormal (growthNormalityScale (logLog x)) p := by intro p hp by_contra hbad obtain ⟨hpprime, hpn, _⟩ := Nat.mem_primeFactors.mp hp exact hnormal (Finset.mem_filter.mpr ⟨hmV, n, hn, hφ, p, hpprime, hpn, hbad⟩) by_contra hcard obtain ⟨P, hPsub, hPcard⟩ := Finset.exists_subset_card_eq (show 3 ≤ ((n.primeFactors).filter (fun p : ℕ => growthLargePrimeCutoff (logLog x) < (p : ℝ))).card by omega) apply hthree refine Finset.mem_filter.mpr ⟨hmV, hlarge, hΩx, n, hn, hφ, P, hPcard, ?_⟩ intro p hp obtain ⟨hpf, hpH⟩ := Finset.mem_filter.mp (hPsub hp) exact ⟨hnorm p hpf, (Nat.mem_primeFactors.mp hpf).2.1, hpH⟩ /- Original line 16488: Erdos416Proof.growthNormality_coefficient_bound -/ theorem growthNormality_coefficient_bound {T : ℝ} (hT : 1 ≤ T) : (1 + T) ^ 6 * Real.exp (-(100 * Real.log T) / 6) ≤ 64 * T ^ (-10 : ℝ) := by have hT0 : 0 < T := by linarith have hlog : 0 ≤ Real.log T := Real.log_nonneg hT have hpoly : (1 + T) ^ 6 ≤ 64 * T ^ 6 := by have h := pow_le_pow_left₀ (show 0 ≤ 1 + T by linarith) (show 1 + T ≤ 2 * T by linarith) 6 convert! h using 1 <;> ring have hdecay : T ^ 6 * Real.exp (-(100 * Real.log T) / 6) ≤ T ^ (-10 : ℝ) := by rw [← Real.rpow_natCast T 6, Real.rpow_def_of_pos hT0, ← Real.exp_add, Real.rpow_def_of_pos hT0] apply Real.exp_le_exp.mpr norm_num nlinarith calc _ ≤ (64 * T ^ 6) * Real.exp (-(100 * Real.log T) / 6) := mul_le_mul_of_nonneg_right hpoly (Real.exp_pos _).le _ = 64 * (T ^ 6 * Real.exp (-(100 * Real.log T) / 6)) := by ring _ ≤ _ := mul_le_mul_of_nonneg_left hdecay (by norm_num) /- Original line 16508: Erdos416Proof.exists_growth_nonNormalTotients_bound -/ theorem exists_growth_nonNormalTotients_bound : ∃ K : ℝ, 0 < K ∧ ∀ᶠ x : ℝ in atTop, ((nonNormalTotients (growthNormalityScale (logLog x)) x).card : ℝ) ≤ K * totientUpperEnvelope x * x / Real.log x * logLog x ^ (-10 : ℝ) := by obtain ⟨K, hK, hbound⟩ := exists_nonNormalTotients_envelope_bound refine ⟨64 * K, by positivity, ?_⟩ have hT : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [growth_interval_parameters, eventually_ge_atTop (16 : ℝ), hT.eventually_ge_atTop 1] with x hparams hx16 hT1 have hx0 : 0 < x := by linarith have hlog : 0 < Real.log x := Real.log_pos (by linarith) have hA : 0 ≤ totientUpperEnvelope x := le_trans (by norm_num) (totientUpperEnvelope_ge_one x) have hSe : Real.exp 1 ≤ growthNormalityScale (logLog x) := by linarith [hparams.2.1, Real.exp_one_lt_three] have h := hbound (growthNormalityScale (logLog x)) x hSe hx16 rw [logLog_growthNormalityScale] at h calc _ ≤ (K * totientUpperEnvelope x * x / Real.log x) * ((1 + logLog x) ^ 6 * Real.exp (-(100 * Real.log (logLog x)) / 6)) := by convert! h using 1 <;> ring _ ≤ (K * totientUpperEnvelope x * x / Real.log x) * (64 * logLog x ^ (-10 : ℝ)) := mul_le_mul_of_nonneg_left (growthNormality_coefficient_bound hT1) (by positivity) _ = _ := by ring /- Original line 16533: Erdos416Proof.growth_normal_exception_absorbed -/ theorem growth_normal_exception_absorbed {ε : ℝ} (hε : 0 < ε) : ∀ᶠ x : ℝ in atTop, ((nonNormalTotients (growthNormalityScale (logLog x)) x).card : ℝ) ≤ ε * totientUpperEnvelope x * x / Real.log x := by obtain ⟨K, hK, hbound⟩ := exists_growth_nonNormalTotients_bound have hT : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop have hlim : Tendsto (fun x : ℝ => K * logLog x ^ (-10 : ℝ)) atTop (nhds 0) := by have h := ((tendsto_rpow_neg_atTop (by norm_num : (0 : ℝ) < 10)).comp hT).const_mul K simpa only [Function.comp_apply, mul_zero] using h filter_upwards [hbound, hlim.eventually (Iio_mem_nhds hε), eventually_ge_atTop (3 : ℝ)] with x hbound hsmall hx have hx0 : 0 < x := by linarith have hlog : 0 < Real.log x := Real.log_pos (by linarith) have hA : 0 ≤ totientUpperEnvelope x := le_trans (by norm_num) (totientUpperEnvelope_ge_one x) have hsmall' : K * logLog x ^ (-10 : ℝ) ≤ ε := le_of_lt hsmall calc _ ≤ (totientUpperEnvelope x * x / Real.log x) * (K * logLog x ^ (-10 : ℝ)) := by convert! hbound using 1 <;> ring _ ≤ (totientUpperEnvelope x * x / Real.log x) * ε := mul_le_mul_of_nonneg_left hsmall' (by positivity) _ = _ := by ring /- Original line 16556: Erdos416Proof.totientUpperEnvelope_mono -/ theorem totientUpperEnvelope_mono {x y : ℝ} (hx : 2 ≤ x) (hxy : x ≤ y) : totientUpperEnvelope x ≤ totientUpperEnvelope y := totientUpperEnvelope_le hx (totientUpperEnvelope_ge_one y) (fun u hu hux => totientUpperEnvelope_spec y u hu (hux.trans hxy)) end Erdos416Proof /- The retained totient count and the actual counting-envelope growth bound. The finite exceptional sets cover all totients. Taking the supremum and iterating the proved contraction give A(x)<=exp(B(log_3(x))^2). This supplies the unconditional non-normal-prime exceptional-totient estimate. -/ open Filter Asymptotics open scoped BigOperators Classical Topology namespace Erdos416Proof /- Original line 16576: Erdos416Proof.exists_shifted_large_prime_count_bound -/ theorem exists_shifted_large_prime_count_bound : ∃ C : ℝ, 0 < C ∧ ∀ (x a : ℝ) (b : ℕ) (F : Finset ℕ), 0 < x → 0 < a → 0 < b → (∀ p ∈ F, p.Prime ∧ a ≤ Real.log p ∧ ((p : ℝ) - 1) * b ≤ x) → (F.card : ℝ) ≤ C * x / a / b := by obtain ⟨C, hC, hprime⟩ := exists_primeCountReal_upper_bound refine ⟨2 * C, by positivity, ?_⟩ intro x a b F hx ha hb hF have hbR : (0 : ℝ) < b := by exact_mod_cast hb by_cases hne : F.Nonempty · obtain ⟨p, hp⟩ := hne have hupper : ∀ q ∈ F, (q : ℝ) ≤ 1 + x / b := by intro q hq have h := (le_div_iff₀ hbR).mpr (hF q hq).2.2 linarith have htwo : (2 : ℝ) ≤ 1 + x / b := (by exact_mod_cast (hF p hp).1.two_le : (2 : ℝ) ≤ p).trans (hupper p hp) have hlog : a ≤ Real.log (1 + x / b) := (hF p hp).2.1.trans (Real.log_le_log (by exact_mod_cast (hF p hp).1.pos) (hupper p hp)) have hnum : 1 + x / b ≤ 2 * (x / b) := by linarith calc _ ≤ primeCountReal (1 + x / b) := finite_prime_card_le_primeCountReal (by linarith) F (fun q hq => ⟨(hF q hq).1, hupper q hq⟩) _ ≤ C * (1 + x / b) / Real.log (1 + x / b) := hprime _ htwo _ ≤ C * (1 + x / b) / a := div_le_div_of_nonneg_left (by positivity) ha hlog _ ≤ C * (2 * (x / b)) / a := by gcongr _ = _ := by ring · have hF0 : F = ∅ := Finset.not_nonempty_iff_eq_empty.mp hne simp only [hF0, Finset.card_empty, Nat.cast_zero] positivity /- Original line 16607: Erdos416Proof.largePrimeCorePairs -/ noncomputable def largePrimeCorePairs (B : Finset ℕ) (x a : ℝ) : Finset (ℕ × ℕ) := (corePairs B 0 x).filter (fun bp : ℕ × ℕ => a ≤ Real.log bp.2) /- Original line 16610: Erdos416Proof.exists_largePrimeCorePairs_bound -/ theorem exists_largePrimeCorePairs_bound : ∃ C : ℝ, 0 < C ∧ ∀ (B : Finset ℕ) (x a : ℝ), 0 < x → 0 < a → (∀ b ∈ B, 0 < b) → ((largePrimeCorePairs B x a).card : ℝ) ≤ C * x / a * ∑ b ∈ B, (1 : ℝ) / b := by obtain ⟨C, hC, hcount⟩ := exists_shifted_large_prime_count_bound refine ⟨C, hC, ?_⟩ intro B x a hx ha hB let P := largePrimeCorePairs B x a have hmap : ∀ bp ∈ P, bp.1 ∈ B := by intro bp hbp exact ((mem_corePairs hx.le hB).mp (Finset.mem_filter.mp hbp).1).1 have hfibre : ∀ b ∈ B, (((P.filter (fun bp => bp.1 = b)).card : ℕ) : ℝ) ≤ C * x / a / b := by intro b hb let F := P.filter (fun bp => bp.1 = b) let Q := F.image Prod.snd have hcard : F.card ≤ Q.card := by apply Finset.card_le_card_of_injOn Prod.snd · intro bp hbp exact Finset.mem_image.mpr ⟨bp, hbp, rfl⟩ · intro bp hbp cp hcp heq apply Prod.ext · exact (Finset.mem_filter.mp hbp).2.trans (Finset.mem_filter.mp hcp).2.symm · exact heq have hQ : ∀ p ∈ Q, p.Prime ∧ a ≤ Real.log p ∧ ((p : ℝ) - 1) * b ≤ x := by intro p hp obtain ⟨bp, hbp, rfl⟩ := Finset.mem_image.mp hp obtain ⟨hbpP, hfst⟩ := Finset.mem_filter.mp hbp obtain ⟨hcore, hloga⟩ := Finset.mem_filter.mp hbpP obtain ⟨_, hpprime, _, hbound⟩ := (mem_corePairs hx.le hB).mp hcore refine ⟨hpprime, hloga, ?_⟩ have hval : (corePairValue bp : ℝ) = ((bp.2 : ℝ) - 1) * bp.1 := by simp only [corePairValue, Nat.cast_mul, Nat.cast_sub hpprime.one_le, Nat.cast_one] rwa [hval, hfst] at hbound have hcardR : (F.card : ℝ) ≤ Q.card := by exact_mod_cast hcard exact hcardR.trans (hcount x a b Q hx ha (hB b hb) hQ) calc _ = ∑ b ∈ B, (((P.filter (fun bp => bp.1 = b)).card : ℕ) : ℝ) := by rw [Finset.card_eq_sum_card_fiberwise hmap, Nat.cast_sum] _ ≤ ∑ b ∈ B, C * x / a / b := Finset.sum_le_sum hfibre _ = _ := by simp only [Finset.mul_sum]; apply Finset.sum_congr rfl; intro b hb; ring /- Original line 16651: Erdos416Proof.smallTailCores -/ noncomputable def smallTailCores (Q : Finset ℕ) (Y : ℝ) : Finset ℕ := totientsUpTo Y ∪ ((Q.product (totientsUpTo Y)).image (fun qt : ℕ × ℕ => (qt.1 - 1) * qt.2)) /- Original line 16654: Erdos416Proof.smallTailCores_pos -/ theorem smallTailCores_pos {Q : Finset ℕ} {Y : ℝ} (hY : 0 ≤ Y) (hQ : ∀ p ∈ Q, p.Prime) : ∀ b ∈ smallTailCores Q Y, 0 < b := by intro b hb rcases Finset.mem_union.mp hb with hb | hb · exact ((mem_totientsUpTo hY).mp hb).1 · obtain ⟨⟨p, t⟩, hpt, rfl⟩ := Finset.mem_image.mp hb obtain ⟨hp, ht⟩ := Finset.mem_product.mp hpt exact Nat.mul_pos (Nat.sub_pos_of_lt (hQ p hp).one_lt) ((mem_totientsUpTo hY).mp ht).1 /- Original line 16663: Erdos416Proof.smallTailCores_reciprocal_bound -/ theorem smallTailCores_reciprocal_bound (Q : Finset ℕ) (Y : ℝ) (hQ : ∀ p ∈ Q, p.Prime) : (∑ b ∈ smallTailCores Q Y, (1 : ℝ) / b) ≤ (1 + ∑ p ∈ Q, (1 : ℝ) / ((p : ℝ) - 1)) * ∑ t ∈ totientsUpTo Y, (1 : ℝ) / t := by let R := (Q.product (totientsUpTo Y)).image (fun qt : ℕ × ℕ => (qt.1 - 1) * qt.2) have himage : (∑ b ∈ R, (1 : ℝ) / b) ≤ ∑ qt ∈ Q.product (totientsUpTo Y), (1 : ℝ) / ((qt.1 - 1) * qt.2 : ℕ) := Finset.sum_image_le_of_nonneg (fun b _ => by positivity) have hprod : (∑ qt ∈ Q.product (totientsUpTo Y), (1 : ℝ) / ((qt.1 - 1) * qt.2 : ℕ)) = (∑ p ∈ Q, (1 : ℝ) / ((p : ℝ) - 1)) * ∑ t ∈ totientsUpTo Y, (1 : ℝ) / t := by rw [Finset.product_eq_sprod, Finset.sum_product, Finset.sum_mul] apply Finset.sum_congr rfl intro p hp rw [Finset.mul_sum] apply Finset.sum_congr rfl intro t ht simp only [Nat.cast_mul, Nat.cast_sub (hQ p hp).one_le, Nat.cast_one, one_div_mul_one_div] have hu := Finset.sum_union_inter (s₁ := totientsUpTo Y) (s₂ := R) (f := fun b : ℕ => (1 : ℝ) / b) have hi : (0 : ℝ) ≤ ∑ b ∈ totientsUpTo Y ∩ R, (1 : ℝ) / b := Finset.sum_nonneg (fun _ _ => by positivity) change (∑ b ∈ totientsUpTo Y ∪ R, (1 : ℝ) / b) ≤ _ rw [hprod] at himage nlinarith /- Original line 16686: Erdos416Proof.exists_smallTailCores_reciprocal_bound -/ theorem exists_smallTailCores_reciprocal_bound : ∃ K : ℝ, 0 < K ∧ ∀ x Y : ℝ, Real.exp (Real.exp 1) ≤ x → Real.exp 1 ≤ Y → Y ≤ x → (∑ b ∈ smallTailCores (Nat.primesLE ⌊2 * x⌋₊) Y, (1 : ℝ) / b) ≤ K * totientUpperEnvelope Y * logLog x ^ 2 := by obtain ⟨C, hC, hprime⟩ := shifted_prime_reciprocal_bound obtain ⟨K, hK, htail⟩ := exists_totient_reciprocal_envelope_bound refine ⟨2 * (1 + 2 * C) * K, by positivity, ?_⟩ intro x Y hx hY hYx have hx2 : 2 ≤ x := by linarith [Real.add_one_le_exp 1, Real.add_one_le_exp (Real.exp 1)] have hx0 : 0 < x := by linarith have hlog : Real.exp 1 ≤ Real.log x := by simpa only [Real.log_exp] using Real.log_le_log (Real.exp_pos (Real.exp 1)) hx have hT : 1 ≤ logLog x := by simpa only [Real.log_exp, logLog] using Real.log_le_log (Real.exp_pos 1) hlog have hA : 0 ≤ totientUpperEnvelope Y := le_trans (by norm_num) (totientUpperEnvelope_ge_one Y) have hLY : logLog Y ≤ logLog x := logLog_mono (by linarith [Real.add_one_le_exp (1 : ℝ)]) hYx have hrecip := hprime (2 * x) (hx.trans (by linarith)) have hrecip' : 1 + (∑ p ∈ Nat.primesLE ⌊2 * x⌋₊, (1 : ℝ) / ((p : ℝ) - 1)) ≤ (1 + 2 * C) * logLog x := by have hLL := logLog_double_le hx2 have hmul := mul_le_mul_of_nonneg_left hLL hC.le change (∑ p ∈ Nat.primesLE ⌊2 * x⌋₊, (1 : ℝ) / ((p : ℝ) - 1)) ≤ C * logLog (2 * x) at hrecip nlinarith have htot := htail Y (totientUpperEnvelope Y) hY (totientUpperEnvelope_ge_one Y) (totientUpperEnvelope_spec Y) have htot' : (∑ t ∈ totientsUpTo Y, (1 : ℝ) / t) ≤ 2 * K * totientUpperEnvelope Y * logLog x := by calc _ ≤ K * totientUpperEnvelope Y * (1 + logLog Y) := htot _ ≤ K * totientUpperEnvelope Y * (2 * logLog x) := mul_le_mul_of_nonneg_left (by linarith) (by positivity) _ = _ := by ring calc _ ≤ (1 + ∑ p ∈ Nat.primesLE ⌊2 * x⌋₊, (1 : ℝ) / ((p : ℝ) - 1)) * ∑ t ∈ totientsUpTo Y, (1 : ℝ) / t := smallTailCores_reciprocal_bound _ _ (fun _ hp => Nat.prime_of_mem_primesLE hp) _ ≤ ((1 + 2 * C) * logLog x) * (2 * K * totientUpperEnvelope Y * logLog x) := mul_le_mul hrecip' htot' (Finset.sum_nonneg fun _ _ => by positivity) (by positivity) _ = _ := by ring /- Original line 16728: Erdos416Proof.exists_smallTailPairs_bound -/ theorem exists_smallTailPairs_bound : ∃ K : ℝ, 0 < K ∧ ∀ x Y : ℝ, Real.exp (Real.exp 1) ≤ x → Real.exp 1 ≤ Y → Y ≤ x → ((largePrimeCorePairs (smallTailCores (Nat.primesLE ⌊2 * x⌋₊) Y) x (Real.log x / 6)).card : ℝ) ≤ K * x / Real.log x * logLog x ^ 2 * totientUpperEnvelope Y := by obtain ⟨C, hC, hcount⟩ := exists_largePrimeCorePairs_bound obtain ⟨K, hK, hrecip⟩ := exists_smallTailCores_reciprocal_bound refine ⟨6 * C * K, by positivity, ?_⟩ intro x Y hx hY hYx have hx2 : 2 ≤ x := by linarith [Real.add_one_le_exp 1, Real.add_one_le_exp (Real.exp 1)] have hx0 : 0 < x := by linarith have hlog : 0 < Real.log x := Real.log_pos (by linarith) have hY0 : 0 ≤ Y := (Real.exp_pos 1).le.trans hY have h := hcount (smallTailCores (Nat.primesLE ⌊2 * x⌋₊) Y) x (Real.log x / 6) hx0 (by positivity) (smallTailCores_pos hY0 (fun _ hp => Nat.prime_of_mem_primesLE hp)) calc _ ≤ C * x / (Real.log x / 6) * (K * totientUpperEnvelope Y * logLog x ^ 2) := h.trans (mul_le_mul_of_nonneg_left (hrecip x Y hx hY hYx) (by positivity)) _ = _ := by ring /- Original line 16749: Erdos416Proof.low_high_coprime -/ theorem low_high_coprime (n : ℕ) (H : ℝ) : (lowPrimePart n H).Coprime (highPrimePart n H) := by apply Nat.coprime_of_dvd intro p hp hpl hph have hl := (Nat.mem_primeFactorsList (primePart_pos n (fun p => (p : ℝ) ≤ H)).ne').mpr ⟨hp, hpl⟩ have hh := (Nat.mem_primeFactorsList (primePart_pos n (fun p => H < (p : ℝ))).ne').mpr ⟨hp, hph⟩ have hle := ((mem_primeFactorsList_primePart n p (fun p => (p : ℝ) ≤ H)).mp hl).2 have hlt := ((mem_primeFactorsList_primePart n p (fun p => H < (p : ℝ))).mp hh).2 exact (not_lt_of_ge hle) hlt /- Original line 16758: Erdos416Proof.highPrimePart_primeFactors -/ theorem highPrimePart_primeFactors (n : ℕ) (H : ℝ) : (highPrimePart n H).primeFactors = n.primeFactors.filter (fun p : ℕ => H < (p : ℝ)) := by ext p simp only [Nat.primeFactors, List.mem_toFinset, Finset.mem_filter, highPrimePart, mem_primeFactorsList_primePart] /- Original line 16764: Erdos416Proof.squarefree_two_prime_cases -/ theorem squarefree_two_prime_cases {a : ℕ} (ha : Squarefree a) (hc : a.primeFactors.card ≤ 2) : a = 1 ∨ a.Prime ∨ ∃ p q : ℕ, p.Prime ∧ q.Prime ∧ q ≤ p ∧ p ≠ q ∧ a = p * q := by have hcases : a.primeFactors.card = 0 ∨ a.primeFactors.card = 1 ∨ a.primeFactors.card = 2 := by omega rcases hcases with h0 | h1 | h2 · left rw [← Nat.prod_primeFactors_of_squarefree ha, Finset.card_eq_zero.mp h0] simp · obtain ⟨p, hP⟩ := Finset.card_eq_one.mp h1 have hp : p.Prime := (Nat.mem_primeFactors.mp (show p ∈ a.primeFactors by rw [hP]; simp)).1 have hap : a = p := by rw [← Nat.prod_primeFactors_of_squarefree ha, hP]; simp exact Or.inr (Or.inl (hap.symm ▸ hp)) · obtain ⟨p, q, hpq, hP⟩ := Finset.card_eq_two.mp h2 have hp : p.Prime := (Nat.mem_primeFactors.mp (show p ∈ a.primeFactors by rw [hP]; simp)).1 have hq : q.Prime := (Nat.mem_primeFactors.mp (show q ∈ a.primeFactors by rw [hP]; simp)).1 have hapq : a = p * q := by rw [← Nat.prod_primeFactors_of_squarefree ha, hP]; simp [hpq] right; right rcases le_total q p with hqp | hpq' · exact ⟨p, q, hp, hq, hqp, hpq, hapq⟩ · exact ⟨q, p, hq, hp, hpq', hpq.symm, hapq.trans (Nat.mul_comm _ _)⟩ /- Original line 16784: Erdos416Proof.growthTailEndpoint -/ noncomputable def growthTailEndpoint (T : ℝ) : ℝ := Real.exp (Real.exp ((9 / 10 : ℝ) * T)) /- Original line 16787: Erdos416Proof.logLog_growthTailEndpoint -/ theorem logLog_growthTailEndpoint (T : ℝ) : logLog (growthTailEndpoint T) = (9 / 10 : ℝ) * T := by simp only [logLog, growthTailEndpoint, Real.log_exp] /- Original line 16791: Erdos416Proof.growth_tail_parameters -/ theorem growth_tail_parameters : ∀ᶠ x : ℝ in atTop, Real.exp (Real.exp 1) ≤ x ∧ 1 ≤ logLog x ∧ Real.exp 1 ≤ growthTailEndpoint (logLog x) ∧ growthTailEndpoint (logLog x) ≤ x ∧ 6 * logLog x * Real.log (growthLargePrimeCutoff (logLog x)) ≤ Real.log (growthTailEndpoint (logLog x)) ∧ Real.log (growthTailEndpoint (logLog x)) ≤ Real.log x / 6 := by have hT : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop have h₁ : (fun T : ℝ => 6 * T * Real.exp ((4 / 5 : ℝ) * T)) =o[atTop] (fun T => Real.exp ((9 / 10 : ℝ) * T)) := by have h := (isLittleO_exp_mul_rpow_of_lt 1 (show (4 / 5 : ℝ) < 9 / 10 by norm_num)).const_mul_left 6 simpa only [Real.rpow_one, mul_comm, mul_left_comm, mul_assoc] using h have h₂ : (fun T : ℝ => Real.exp ((9 / 10 : ℝ) * T)) =o[atTop] (fun T => Real.exp T) := by simpa only [Real.rpow_zero, mul_one, one_mul] using isLittleO_exp_mul_rpow_of_lt 0 (show (9 / 10 : ℝ) < 1 by norm_num) filter_upwards [eventually_ge_atTop (Real.exp (Real.exp 1)), hT.eventually_ge_atTop 1, hT.eventually (h₁.def (by norm_num : (0 : ℝ) < 1)), hT.eventually (h₂.def (by norm_num : (0 : ℝ) < 1 / 6))] with x hx hT1 h₁ h₂ have hx2 : 2 ≤ x := by linarith [Real.add_one_le_exp 1, Real.add_one_le_exp (Real.exp 1)] have hT0 : 0 ≤ logLog x := by linarith have hlog : 0 < Real.log x := Real.log_pos (by linarith) simp only [Real.norm_eq_abs, abs_of_pos (Real.exp_pos _), abs_of_nonneg (show 0 ≤ 6 * logLog x * Real.exp ((4 / 5 : ℝ) * logLog x) by positivity), one_mul] at h₁ h₂ refine ⟨hx, hT1, ?_, ?_, ?_, ?_⟩ · exact Real.exp_le_exp.mpr (Real.one_le_exp_iff.mpr (by positivity)) · calc _ ≤ Real.exp (Real.exp (logLog x)) := by apply Real.exp_le_exp.mpr apply Real.exp_le_exp.mpr linarith _ = x := by rw [logLog, Real.exp_log hlog, Real.exp_log (by linarith)] · simpa only [growthLargePrimeCutoff, growthTailEndpoint, Real.log_exp] using h₁ · rw [growthTailEndpoint, Real.log_exp] have he : Real.exp (logLog x) = Real.log x := Real.exp_log hlog rw [he] at h₂ linarith /- Original line 16830: Erdos416Proof.lowPrimePart_le_growthTail -/ theorem lowPrimePart_le_growthTail {n : ℕ} {x : ℝ} (hT : 0 ≤ logLog x) (hΩ : (ArithmeticFunction.cardFactors n : ℝ) ≤ 6 * logLog x) (hcut : 6 * logLog x * Real.log (growthLargePrimeCutoff (logLog x)) ≤ Real.log (growthTailEndpoint (logLog x))) : (lowPrimePart n (growthLargePrimeCutoff (logLog x)) : ℝ) ≤ growthTailEndpoint (logLog x) := by have hH : 1 ≤ growthLargePrimeCutoff (logLog x) := Real.one_le_exp_iff.mpr (Real.exp_pos _).le have hHlog : 0 ≤ Real.log (growthLargePrimeCutoff (logLog x)) := Real.log_nonneg hH have hc : (omegaInterval n 1 (growthLargePrimeCutoff (logLog x)) : ℝ) ≤ ArithmeticFunction.cardFactors n := by exact_mod_cast omegaInterval_le_cardFactors n 1 (growthLargePrimeCutoff (logLog x)) have hω := hc.trans hΩ have hw0 : (0 : ℝ) < lowPrimePart n (growthLargePrimeCutoff (logLog x)) := by exact_mod_cast primePart_pos n (fun p => (p : ℝ) ≤ growthLargePrimeCutoff (logLog x)) apply (Real.log_le_log_iff hw0 (Real.exp_pos _)).mp exact ((lowPrimePart_log_bound n hH).trans (mul_le_mul_of_nonneg_right hω hHlog)).trans hcut /- Original line 16847: Erdos416Proof.growthRetainedTotients -/ noncomputable def growthRetainedTotients (x : ℝ) : Finset ℕ := (totientsUpTo x).filter (fun m : ℕ => Real.sqrt x ≤ (m : ℝ) ∧ (ArithmeticFunction.cardFactors m : ℝ) ≤ 5 * logLog x ∧ ∃ n : ℕ, 0 < n ∧ n.totient = m ∧ NoLargePrimeSquare n (growthLargePrimeCutoff (logLog x)) ∧ (n.primeFactors.filter (fun p : ℕ => growthLargePrimeCutoff (logLog x) < (p : ℝ))).card ≤ 2) /- Original line 16854: Erdos416Proof.growthRetainedTotients_pair_cover -/ theorem growthRetainedTotients_pair_cover : ∀ᶠ x : ℝ in atTop, ∀ m ∈ growthRetainedTotients x, ∃ bp ∈ largePrimeCorePairs (smallTailCores (Nat.primesLE ⌊2 * x⌋₊) (growthTailEndpoint (logLog x))) x (Real.log x / 6), corePairValue bp = m := by filter_upwards [growth_tail_parameters] with x hparams obtain ⟨hx, hT1, hY, hYx, hcut, hYlog⟩ := hparams have hx2 : 2 ≤ x := by linarith [Real.add_one_le_exp 1, Real.add_one_le_exp (Real.exp 1)] have hx0 : 0 < x := by linarith have hlog : 0 < Real.log x := Real.log_pos (by linarith) let H := growthLargePrimeCutoff (logLog x) let Y := growthTailEndpoint (logLog x) let B := smallTailCores (Nat.primesLE ⌊2 * x⌋₊) Y have hY0 : 0 < Y := Real.exp_pos _ have hB : ∀ b ∈ B, 0 < b := smallTailCores_pos hY0.le (fun _ hp => Nat.prime_of_mem_primesLE hp) intro m hm obtain ⟨hmV, hlarge, hΩm, n, hn, hφ, hsq, hcard⟩ := Finset.mem_filter.mp hm have hmdata := (mem_totientsUpTo hx0.le).mp hmV have hΩn : (ArithmeticFunction.cardFactors n : ℝ) ≤ 6 * logLog x := by have h : (ArithmeticFunction.cardFactors n : ℝ) ≤ ArithmeticFunction.cardFactors m + 1 := by exact_mod_cast (cardFactors_le_totient_add_one n).trans_eq (by rw [hφ]) linarith let w := lowPrimePart n H let a := highPrimePart n H have hw : 0 < w := primePart_pos _ _ have ha : 0 < a := primePart_pos _ _ have hwR : (0 : ℝ) < w := by exact_mod_cast hw have haR : (0 : ℝ) < a := by exact_mod_cast ha have hwn : w * a = n := low_mul_high hn.ne' H have hwY : (w : ℝ) ≤ Y := lowPrimePart_le_growthTail (by linarith) hΩn hcut have hwlog : Real.log w ≤ Real.log x / 6 := (Real.log_le_log hwR hwY).trans hYlog have hnlarge : Real.sqrt x ≤ (n : ℝ) := hlarge.trans (by exact_mod_cast (show m ≤ n from hφ ▸ Nat.totient_le n)) have hnlog : Real.log x / 2 ≤ Real.log n := by simpa only [Real.log_sqrt hx0.le] using Real.log_le_log (Real.sqrt_pos.mpr hx0) hnlarge have hlogprod : Real.log n = Real.log w + Real.log a := by rw [← hwn, Nat.cast_mul, Real.log_mul hwR.ne' haR.ne'] have hplog (p : ℕ) (hp : p.Prime) (hasq : a ≤ p ^ 2) : Real.log x / 6 ≤ Real.log p := by have hpa : (a : ℝ) ≤ (p : ℝ) ^ 2 := by exact_mod_cast hasq have hl := Real.log_le_log haR hpa rw [Real.log_pow] at hl norm_num at hl linarith have hwaφ : m = w.totient * a.totient := by calc m = n.totient := hφ.symm _ = (w * a).totient := congrArg Nat.totient hwn.symm _ = _ := Nat.totient_mul (low_high_coprime n H) have ht : w.totient ∈ totientsUpTo Y := (mem_totientsUpTo hY0.le).mpr ⟨Nat.totient_pos.mpr hw, (by exact_mod_cast Nat.totient_le w : (w.totient : ℝ) ≤ w).trans hwY, w, hw, rfl⟩ have hfinish (b p : ℕ) (hb : b ∈ B) (hp : p.Prime) (hval : corePairValue (b, p) = m) (hasq : a ≤ p ^ 2) : ∃ bp ∈ largePrimeCorePairs B x (Real.log x / 6), corePairValue bp = m := by refine ⟨(b, p), Finset.mem_filter.mpr ⟨?_, hplog p hp hasq⟩, hval⟩ apply (mem_corePairs hx0.le hB).mpr refine ⟨hb, hp, ?_, ?_⟩ · rw [hval] exact_mod_cast hmdata.1 · simpa only [hval] using hmdata.2.1 have haSF : Squarefree a := primePart_squarefree_of_no_large_square hn.ne' hsq (fun p => H < (p : ℝ)) (fun _ _ hp => hp) have haCard : a.primeFactors.card ≤ 2 := by change (highPrimePart n H).primeFactors.card ≤ 2 rw [highPrimePart_primeFactors] exact hcard rcases squarefree_two_prime_cases haSF haCard with ha1 | hp | ⟨p, q, hp, hq, hqp, hpq, hapq⟩ · have hlogzero : Real.log a = 0 := by rw [ha1]; norm_num linarith · have hb : w.totient ∈ B := Finset.mem_union_left _ ht refine hfinish w.totient a hb hp ?_ ?_ · change (a - 1) * w.totient = m rw [hwaφ, Nat.totient_prime hp] exact Nat.mul_comm _ _ · nlinarith [hp.one_le] · have hqd : q ∣ n := (show q ∣ a from ⟨p, by rw [hapq]; ring⟩).trans (primePart_dvd hn.ne' _) have hqφ := Nat.totient_dvd_of_dvd hqd rw [Nat.totient_prime hq, hφ] at hqφ have hqm : q - 1 ≤ m := Nat.le_of_dvd hmdata.1 hqφ have hqR : ((q - 1 : ℕ) : ℝ) ≤ m := by exact_mod_cast hqm rw [Nat.cast_sub hq.one_le, Nat.cast_one] at hqR have hqQ : q ∈ Nat.primesLE ⌊2 * x⌋₊ := Nat.mem_primesLE.mpr ⟨Nat.le_floor (show (q : ℝ) ≤ 2 * x by linarith [hmdata.2.1]), hq⟩ have hb : (q - 1) * w.totient ∈ B := Finset.mem_union_right _ (Finset.mem_image.mpr ⟨(q, w.totient), Finset.mem_product.mpr ⟨hqQ, ht⟩, rfl⟩) refine hfinish ((q - 1) * w.totient) p hb hp ?_ ?_ · have hcop : p.Coprime q := hp.coprime_iff_not_dvd.mpr (fun hd => hpq ((Nat.prime_dvd_prime_iff_eq hp hq).mp hd)) rw [hapq, Nat.totient_mul hcop, Nat.totient_prime hp, Nat.totient_prime hq] at hwaφ change (p - 1) * ((q - 1) * w.totient) = m rw [hwaφ] ring · rw [hapq, pow_two] exact Nat.mul_le_mul_left p hqp /- Original line 16950: Erdos416Proof.exists_growthRetainedTotients_bound -/ theorem exists_growthRetainedTotients_bound : ∃ K : ℝ, 0 < K ∧ ∀ᶠ x : ℝ in atTop, ((growthRetainedTotients x).card : ℝ) ≤ K * x / Real.log x * logLog x ^ 2 * totientUpperEnvelope (growthTailEndpoint (logLog x)) := by obtain ⟨K, hK, hcount⟩ := exists_smallTailPairs_bound refine ⟨K, hK, ?_⟩ filter_upwards [growth_tail_parameters, growthRetainedTotients_pair_cover] with x hparams hcover obtain ⟨hx, _, hY, hYx, _⟩ := hparams let P := largePrimeCorePairs (smallTailCores (Nat.primesLE ⌊2 * x⌋₊) (growthTailEndpoint (logLog x))) x (Real.log x / 6) have hsub : growthRetainedTotients x ⊆ P.image corePairValue := by intro m hm obtain ⟨bp, hbp, hval⟩ := hcover m hm exact Finset.mem_image.mpr ⟨bp, hbp, hval⟩ have hcard : ((growthRetainedTotients x).card : ℝ) ≤ P.card := by exact_mod_cast (Finset.card_le_card hsub).trans (Finset.card_image_le) exact hcard.trans (hcount x (growthTailEndpoint (logLog x)) hx hY hYx) /- Original line 16968: Erdos416Proof.largeSquareTotients -/ noncomputable def largeSquareTotients (x : ℝ) : Finset ℕ := (totientsUpTo x).filter (fun m : ℕ => ∃ n : ℕ, 0 < n ∧ n.totient = m ∧ ∃ q : ℕ, q.Prime ∧ Real.log x ^ 4 < (q : ℝ) ∧ (q ^ 2 ∣ n ∨ q ^ 2 ∣ n.totient)) /- Original line 16972: Erdos416Proof.largeSquareTotients_card_le -/ theorem largeSquareTotients_card_le {x z : ℝ} (hx : 0 ≤ x) (hsize : ∀ n : ℕ, 0 < n → (n.totient : ℝ) ≤ x → (n : ℝ) ≤ z) : (largeSquareTotients x).card ≤ (largePrimeSquareBad ⌊z⌋₊ (Real.log x ^ 4)).card := by let w : ℕ → ℕ := fun m => if h : m ∈ largeSquareTotients x then Classical.choose (Finset.mem_filter.mp h).2 else 1 have hw (m : ℕ) (hm : m ∈ largeSquareTotients x) : 0 < w m ∧ (w m).totient = m ∧ ∃ q : ℕ, q.Prime ∧ Real.log x ^ 4 < (q : ℝ) ∧ (q ^ 2 ∣ w m ∨ q ^ 2 ∣ (w m).totient) := by simpa only [w, dif_pos hm] using Classical.choose_spec (Finset.mem_filter.mp hm).2 apply Finset.card_le_card_of_injOn w · intro m hm obtain ⟨hw0, hwφ, hbad⟩ := hw m hm have hmV := (mem_totientsUpTo hx).mp (Finset.mem_filter.mp hm).1 have hwz := hsize (w m) hw0 (by simpa only [hwφ] using hmV.2.1) exact Finset.mem_filter.mpr ⟨Finset.mem_Icc.mpr ⟨hw0, Nat.le_floor hwz⟩, hbad⟩ · intro m hm r hr heq exact (hw m hm).2.1.symm.trans ((congrArg Nat.totient heq).trans (hw r hr).2.1) /- Original line 16990: Erdos416Proof.largeSquareTotients_negligible -/ theorem largeSquareTotients_negligible : (fun x : ℝ => ((largeSquareTotients x).card : ℝ)) =o[atTop] (fun x : ℝ => x / (Real.log x * logLog x ^ 2)) := by obtain ⟨c, hc, hsize⟩ := inverse_totient_bound_eventually have hdom : (fun x : ℝ => ((largeSquareTotients x).card : ℝ)) =O[atTop] largeSquareExceptionalCount c := by apply IsBigO.of_norm_eventuallyLE filter_upwards [hsize, eventually_ge_atTop (0 : ℝ)] with x hsize hx have hcard := largeSquareTotients_card_le hx hsize have hR : ((largeSquareTotients x).card : ℝ) ≤ largeSquareExceptionalCount c x := by unfold largeSquareExceptionalCount exact_mod_cast hcard simpa only [Real.norm_eq_abs, largeSquareExceptionalCount, Nat.abs_cast] using hR exact hdom.trans_isLittleO (large_prime_square_pruning hc) /- Original line 17005: Erdos416Proof.fourth_log_cutoff_le_growthLargePrimeCutoff -/ theorem fourth_log_cutoff_le_growthLargePrimeCutoff : ∀ᶠ x : ℝ in atTop, Real.log x ^ 4 ≤ growthLargePrimeCutoff (logLog x) := by have hT : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop have h : (fun T : ℝ => 4 * T) =o[atTop] (fun T => Real.exp ((4 / 5 : ℝ) * T)) := by simpa only [pow_one] using (isLittleO_pow_exp_pos_mul_atTop 1 (show (0 : ℝ) < 4 / 5 by norm_num)).const_mul_left 4 filter_upwards [hT.eventually (h.def (by norm_num : (0 : ℝ) < 1)), hT.eventually_ge_atTop 0, eventually_gt_atTop (1 : ℝ)] with x hsmall hT0 hx have hlog : 0 < Real.log x := Real.log_pos hx simp only [Real.norm_eq_abs, abs_of_nonneg (show 0 ≤ 4 * logLog x by positivity), abs_of_pos (Real.exp_pos _), one_mul] at hsmall have hpow : Real.log x ^ 4 = Real.exp (4 * logLog x) := by rw [show (4 : ℝ) = ((4 : ℕ) : ℝ) by norm_num, Real.exp_nat_mul] simp only [logLog, Real.exp_log hlog] rw [hpow] exact Real.exp_le_exp.mpr hsmall /- Original line 17023: Erdos416Proof.growth_totient_count_cover -/ theorem growth_totient_count_cover : ∀ᶠ x : ℝ in atTop, V x ≤ V (Real.sqrt x) + (fiveLogOmegaTotients x).card + (nonNormalTotients (growthNormalityScale (logLog x)) x).card + (threeLargeNormalTotients x).card + (largeSquareTotients x).card + (growthRetainedTotients x).card := by filter_upwards [eventually_ge_atTop (9 : ℝ), fourth_log_cutoff_le_growthLargePrimeCutoff] with x hx hcut have hx0 : 0 ≤ x := by linarith let A := totientsUpTo (Real.sqrt x) let B := fiveLogOmegaTotients x let C := nonNormalTotients (growthNormalityScale (logLog x)) x let D := threeLargeNormalTotients x let E := largeSquareTotients x let G := growthRetainedTotients x have hcover : totientsUpTo x ⊆ A ∪ B ∪ C ∪ D ∪ E ∪ G := by intro m hm simp only [Finset.mem_union] by_cases hA : m ∈ A · tauto by_cases hB : m ∈ B · tauto by_cases hC : m ∈ C · tauto by_cases hD : m ∈ D · tauto by_cases hE : m ∈ E · tauto right have hmdata := (mem_totientsUpTo hx0).mp hm have hlarge : Real.sqrt x ≤ (m : ℝ) := by have hnot : ¬(m : ℝ) ≤ Real.sqrt x := fun h => hA ((mem_totientsUpTo (Real.sqrt_nonneg x)).mpr ⟨hmdata.1, h, hmdata.2.2⟩) exact (lt_of_not_ge hnot).le have hm3 : 3 ≤ m := by have hs : (3 : ℝ) ≤ Real.sqrt x := Real.le_sqrt_of_sq_le (by norm_num; exact hx) exact_mod_cast hs.trans hlarge have hΩm : (ArithmeticFunction.cardFactors m : ℝ) ≤ 5 * logLog (m : ℝ) := by by_contra h exact hB (Finset.mem_filter.mpr ⟨hm, hm3, lt_of_not_ge h⟩) have hΩx : (ArithmeticFunction.cardFactors m : ℝ) ≤ 5 * logLog x := hΩm.trans (mul_le_mul_of_nonneg_left (logLog_mono (by exact_mod_cast (show 1 < m by omega)) hmdata.2.1) (by norm_num)) obtain ⟨n, hn, hφ⟩ := hmdata.2.2 have hsq : NoLargePrimeSquare n (Real.log x ^ 4) := by intro q hq hlargeq hqd exact hE (Finset.mem_filter.mpr ⟨hm, n, hn, hφ, q, hq, hlargeq, Or.inl hqd⟩) exact Finset.mem_filter.mpr ⟨hm, hlarge, hΩx, n, hn, hφ, hsq.mono hcut, at_most_two_large_prime_divisors hx hm hlarge hn hφ hC hB hD⟩ have hc := Finset.card_le_card hcover have h₁ := Finset.card_union_le A B have h₂ := Finset.card_union_le (A ∪ B) C have h₃ := Finset.card_union_le (A ∪ B ∪ C) D have h₄ := Finset.card_union_le (A ∪ B ∪ C ∪ D) E have h₅ := Finset.card_union_le (A ∪ B ∪ C ∪ D ∪ E) G have hcard : (totientsUpTo x).card ≤ A.card + B.card + C.card + D.card + E.card + G.card := by omega unfold V exact_mod_cast hcard /- Original line 17081: Erdos416Proof.V_sqrt_negligible -/ theorem V_sqrt_negligible : (fun x : ℝ => V (Real.sqrt x)) =o[atTop] (fun x : ℝ => x / (Real.log x * logLog x ^ 2)) := by have hT : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop have hdom : (fun x : ℝ => V (Real.sqrt x)) =O[atTop] (fun x : ℝ => Real.sqrt (1 * x * logLog x)) := by apply IsBigO.of_norm_eventuallyLE filter_upwards [eventually_ge_atTop (0 : ℝ), hT.eventually_ge_atTop 1] with x hx hT1 have hV : V (Real.sqrt x) ≤ Real.sqrt x := finite_positive_card_le (Real.sqrt_nonneg x) (totientsUpTo (Real.sqrt x)) (fun m hm => ⟨((mem_totientsUpTo (Real.sqrt_nonneg x)).mp hm).1, ((mem_totientsUpTo (Real.sqrt_nonneg x)).mp hm).2.1⟩) have hroot : Real.sqrt x ≤ Real.sqrt (1 * x * logLog x) := Real.sqrt_le_sqrt (by nlinarith) simpa only [Real.norm_eq_abs, abs_of_nonneg (V_nonneg _), abs_of_nonneg (Real.sqrt_nonneg _)] using hV.trans hroot exact hdom.trans_isLittleO (sqrt_inverse_totient_scale_negligible (by norm_num : (0 : ℝ) < 1)) /- Original line 17098: Erdos416Proof.pruning_error_le_baseScale -/ theorem pruning_error_le_baseScale {f : ℝ → ℝ} (hf : f =o[atTop] (fun x : ℝ => x / (Real.log x * logLog x ^ 2))) : ∀ᶠ x : ℝ in atTop, f x ≤ x / Real.log x := by have hT : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [hf.def (by norm_num : (0 : ℝ) < 1), eventually_gt_atTop (1 : ℝ), hT.eventually_ge_atTop 1] with x hsmall hx hT1 have hx0 : 0 < x := by linarith have hlog : 0 < Real.log x := Real.log_pos hx have hT0 : 0 < logLog x := by linarith have hT2 : 1 ≤ logLog x ^ 2 := by nlinarith simp only [Real.norm_eq_abs, one_mul, abs_of_pos (by positivity : 0 < x / (Real.log x * logLog x ^ 2))] at hsmall calc _ ≤ |f x| := le_abs_self _ _ ≤ x / (Real.log x * logLog x ^ 2) := hsmall _ = (x / Real.log x) / logLog x ^ 2 := by ring _ ≤ _ := div_le_self (by positivity) hT2 /- Original line 17117: Erdos416Proof.exists_totient_growth_step -/ theorem exists_totient_growth_step : ∃ K : ℝ, 0 < K ∧ ∀ᶠ x : ℝ in atTop, V x ≤ (1 / 4 : ℝ) * totientUpperEnvelope x * x / Real.log x + K * x / Real.log x * logLog x ^ 2 * totientUpperEnvelope (growthTailEndpoint (logLog x)) := by obtain ⟨K, hK, hretained⟩ := exists_growthRetainedTotients_bound refine ⟨K + 4, by linarith, ?_⟩ filter_upwards [growth_tail_parameters, growth_totient_count_cover, hretained, growth_normal_exception_absorbed (by norm_num : (0 : ℝ) < 1 / 4), pruning_error_le_baseScale V_sqrt_negligible, pruning_error_le_baseScale fiveLogOmegaTotients_negligible, pruning_error_le_baseScale threeLargeNormalTotients_negligible, pruning_error_le_baseScale largeSquareTotients_negligible] with x hparams hcover hret hnormal hsmall hΩ hthree hsquare obtain ⟨hx, hT1, _⟩ := hparams have hx2 : 2 ≤ x := by linarith [Real.add_one_le_exp 1, Real.add_one_le_exp (Real.exp 1)] have hx0 : 0 < x := by linarith have hlog : 0 < Real.log x := Real.log_pos (by linarith) have hT2 : 1 ≤ logLog x ^ 2 := by nlinarith have hA := totientUpperEnvelope_ge_one (growthTailEndpoint (logLog x)) have hbase : x / Real.log x ≤ x / Real.log x * logLog x ^ 2 * totientUpperEnvelope (growthTailEndpoint (logLog x)) := by calc _ ≤ x / Real.log x * logLog x ^ 2 := le_mul_of_one_le_right (by positivity) hT2 _ ≤ _ := le_mul_of_one_le_right (by positivity) hA calc _ ≤ (1 / 4 : ℝ) * totientUpperEnvelope x * x / Real.log x + K * x / Real.log x * logLog x ^ 2 * totientUpperEnvelope (growthTailEndpoint (logLog x)) + 4 * (x / Real.log x) := by linarith _ ≤ (1 / 4 : ℝ) * totientUpperEnvelope x * x / Real.log x + K * x / Real.log x * logLog x ^ 2 * totientUpperEnvelope (growthTailEndpoint (logLog x)) + 4 * (x / Real.log x * logLog x ^ 2 * totientUpperEnvelope (growthTailEndpoint (logLog x))) := by linarith _ = _ := by ring /- Original line 17151: Erdos416Proof.growthTailEndpoint_mono -/ theorem growthTailEndpoint_mono : Monotone growthTailEndpoint := by intro a b hab apply Real.exp_le_exp.mpr apply Real.exp_le_exp.mpr exact mul_le_mul_of_nonneg_left hab (by norm_num) /-- Take the supremum over every smaller counting endpoint and absorb the normality exception. The smaller envelope is the actual totient envelope. -/ /- Original line 17159: Erdos416Proof.exists_totientUpperEnvelope_recurrence -/ theorem exists_totientUpperEnvelope_recurrence : ∃ C : ℝ, 0 < C ∧ ∀ᶠ x : ℝ in atTop, totientUpperEnvelope x ≤ C * logLog x ^ 2 * totientUpperEnvelope (growthTailEndpoint (logLog x)) := by obtain ⟨K, hK, hstep⟩ := exists_totient_growth_step obtain ⟨x₀, hx₀⟩ := eventually_atTop.mp (hstep.and growth_tail_parameters) let N := max 2 x₀ let M := totientUpperEnvelope N let C := K + M have hM : 1 ≤ M := totientUpperEnvelope_ge_one N have hC : 0 < C := by dsimp [Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, C]; linarith refine ⟨2 * C, by positivity, ?_⟩ filter_upwards [eventually_ge_atTop N, growth_tail_parameters] with x hxN hparams obtain ⟨hx, hT1, hYe, _, _⟩ := hparams have hx2 : 2 ≤ x := (le_max_left _ _).trans hxN have hxA : 0 ≤ totientUpperEnvelope x := le_trans (by norm_num) (totientUpperEnvelope_ge_one x) have hT2 : 1 ≤ logLog x ^ 2 := by nlinarith let R := logLog x ^ 2 * totientUpperEnvelope (growthTailEndpoint (logLog x)) have hR1 : 1 ≤ R := hT2.trans (le_mul_of_one_le_right (sq_nonneg _) (totientUpperEnvelope_ge_one _)) have hR0 : 0 ≤ R := by linarith have hCR : 0 ≤ C * R := mul_nonneg hC.le hR0 have hCR1 : 1 ≤ C * R := by have hC1 : 1 ≤ C := by dsimp [Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, C]; linarith exact hC1.trans (le_mul_of_one_le_right hC.le hR1) have hupper (u : ℝ) (hu : 2 ≤ u) (hux : u ≤ x) : V u * Real.log u / u ≤ totientUpperEnvelope x / 4 + C * R := by have hu0 : 0 < u := by linarith have hulog : 0 < Real.log u := Real.log_pos (by linarith) by_cases huN : u ≤ N · have hr : V u * Real.log u / u ≤ M := (div_le_iff₀ hu0).mpr ((le_div_iff₀ hulog).mp (totientUpperEnvelope_spec N u hu huN)) have hMC : M ≤ C := by dsimp [Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, C]; linarith have hCCR : C ≤ C * R := le_mul_of_one_le_right hC.le hR1 linarith · have hNu : N ≤ u := (lt_of_not_ge huN).le obtain ⟨hstepu, hpu⟩ := hx₀ u ((le_max_right _ _).trans hNu) obtain ⟨_, hTu1, hYue, _, _⟩ := hpu have hr : V u * Real.log u / u ≤ totientUpperEnvelope u / 4 + K * logLog u ^ 2 * totientUpperEnvelope (growthTailEndpoint (logLog u)) := by have hmul := mul_le_mul_of_nonneg_right hstepu (div_nonneg hulog.le hu0.le) convert! hmul using 1 <;> field_simp [hu0.ne', hulog.ne'] <;> ring have hAu := totientUpperEnvelope_mono hu hux have hLL := logLog_mono (by linarith : 1 < u) hux have hAY := totientUpperEnvelope_mono (Real.exp_one_gt_two.le.trans hYue) (growthTailEndpoint_mono hLL) have hTu0 : 0 ≤ logLog u := by linarith have hAy0 : 0 ≤ totientUpperEnvelope (growthTailEndpoint (logLog u)) := le_trans (by norm_num) (totientUpperEnvelope_ge_one _) have hp : logLog u ^ 2 * totientUpperEnvelope (growthTailEndpoint (logLog u)) ≤ R := mul_le_mul (pow_le_pow_left₀ hTu0 hLL 2) hAY hAy0 (sq_nonneg _) have hprod := mul_le_mul_of_nonneg_left hp hK.le have hKC : K * R ≤ C * R := mul_le_mul_of_nonneg_right (by dsimp [Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, C]; linarith) hR0 nlinarith have henv : TotientCountingEnvelope (totientUpperEnvelope x / 4 + C * R) x := by intro u hu hux have hu0 : 0 < u := by linarith have hlog : 0 < Real.log u := Real.log_pos (by linarith) exact (le_div_iff₀ hlog).mpr ((div_le_iff₀ hu0).mp (hupper u hu hux)) have hA := totientUpperEnvelope_le hx2 (by linarith : 1 ≤ totientUpperEnvelope x / 4 + C * R) henv calc _ ≤ 2 * C * R := by nlinarith _ = _ := by dsimp [Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, R]; ring /-- Iterate a genuine contraction of the argument. The bounded initial range is retained in the constant; no boundedness of F at infinity is assumed. -/ /- Original line 17225: Erdos416Proof.log_square_bound_of_geometric_recurrence -/ theorem log_square_bound_of_geometric_recurrence (F : ℝ → ℝ) (hF : ∀ T : ℝ, 1 ≤ F T) (hmono : ∀ a b : ℝ, 1 ≤ a → a ≤ b → F a ≤ F b) {C : ℝ} (hC : 0 < C) (hstep : ∀ᶠ T : ℝ in atTop, F T ≤ C * T ^ 2 * F ((9 / 10 : ℝ) * T)) : ∃ B : ℝ, 0 < B ∧ ∀ᶠ T : ℝ in atTop, F T ≤ Real.exp (B * Real.log T ^ 2) := by obtain ⟨T₁, hT₁⟩ := eventually_atTop.mp hstep let T₀ := max 1 T₁ let q : ℝ := 10 / 9 have hT₀1 : 1 ≤ T₀ := le_max_left _ _ have hT₀ : 0 < T₀ := by linarith have hq1 : 1 ≤ q := by norm_num [q] have hq0 : 0 < q := by norm_num [q] have hlogq : 0 < Real.log q := Real.log_pos (by norm_num [q]) let K := 1 + |Real.log (F T₀)| + |Real.log C| + 2 * |Real.log T₀| + |Real.log q| have hK : 0 < K := by dsimp [K]; positivity have hKF : Real.log (F T₀) ≤ K := by dsimp [K] linarith [le_abs_self (Real.log (F T₀)), abs_nonneg (Real.log C), abs_nonneg (Real.log T₀), abs_nonneg (Real.log q)] have hKcost : Real.log C + 2 * Real.log T₀ ≤ K := by dsimp [K] linarith [le_abs_self (Real.log C), le_abs_self (Real.log T₀), abs_nonneg (Real.log (F T₀)), abs_nonneg (Real.log q)] have hKq : Real.log q ≤ K := by dsimp [K] linarith [le_abs_self (Real.log q), abs_nonneg (Real.log (F T₀)), abs_nonneg (Real.log C), abs_nonneg (Real.log T₀)] have hgrid_ge (n : ℕ) : T₀ ≤ T₀ * q ^ n := le_mul_of_one_le_right hT₀.le (one_le_pow₀ hq1) have hgridlog (n : ℕ) : Real.log (T₀ * q ^ n) = Real.log T₀ + (n : ℝ) * Real.log q := by rw [Real.log_mul hT₀.ne' (pow_ne_zero _ hq0.ne'), Real.log_pow] have hgrid : ∀ n : ℕ, F (T₀ * q ^ n) ≤ Real.exp (K * ((n : ℝ) + 1) ^ 2) := by intro n induction n with | zero => have hFpos : 0 < F T₀ := by linarith [hF T₀] simpa only [pow_zero, mul_one, Nat.cast_zero, zero_add, one_pow] using (Real.log_le_iff_le_exp hFpos).mp hKF | succ n ih => have hstepn := hT₁ (T₀ * q ^ (n + 1)) ((le_max_right _ _).trans (hgrid_ge _)) have hshrink : (9 / 10 : ℝ) * (T₀ * q ^ (n + 1)) = T₀ * q ^ n := by rw [pow_succ] dsimp only [q] ring rw [hshrink] at hstepn have hRpos : 0 < T₀ * q ^ (n + 1) := mul_pos hT₀ (pow_pos hq0 _) calc _ ≤ C * (T₀ * q ^ (n + 1)) ^ 2 * F (T₀ * q ^ n) := hstepn _ ≤ C * (T₀ * q ^ (n + 1)) ^ 2 * Real.exp (K * ((n : ℝ) + 1) ^ 2) := mul_le_mul_of_nonneg_left ih (by positivity) _ ≤ _ := by apply (Real.log_le_log_iff (by positivity) (Real.exp_pos _)).mp rw [Real.log_mul (by positivity) (Real.exp_ne_zero _), Real.log_mul hC.ne' (by positivity), Real.log_pow, hgridlog, Real.log_exp, Real.log_exp] push_cast have hqcost := mul_le_mul_of_nonneg_left hKq (show 0 ≤ 2 * ((n : ℝ) + 1) by positivity) nlinarith let D := 1 / Real.log q + 2 have hD : 0 < D := by dsimp [D]; positivity refine ⟨K * D ^ 2, by positivity, ?_⟩ filter_upwards [eventually_ge_atTop (Real.exp 1)] with T hTe have hTpos : 0 < T := (Real.exp_pos 1).trans_le hTe have hT1 : 1 ≤ T := by linarith [Real.add_one_le_exp (1 : ℝ)] have hlogT : 1 ≤ Real.log T := by simpa only [Real.log_exp] using Real.log_le_log (Real.exp_pos 1) hTe let n : ℕ := ⌈Real.log T / Real.log q⌉₊ have hTq : T ≤ q ^ n := by apply (Real.log_le_log_iff hTpos (pow_pos hq0 _)).mp rw [Real.log_pow] exact (div_le_iff₀ hlogq).mp (Nat.le_ceil (Real.log T / Real.log q)) have hTgrid : T ≤ T₀ * q ^ n := hTq.trans (le_mul_of_one_le_left (pow_nonneg hq0.le _) hT₀1) have hnlt : (n : ℝ) < Real.log T / Real.log q + 1 := Nat.ceil_lt_add_one (div_nonneg (by linarith) hlogq.le) have hnD : (n : ℝ) + 1 ≤ D * Real.log T := by have heq : D * Real.log T = Real.log T / Real.log q + 2 * Real.log T := by dsimp [D]; ring rw [heq] linarith calc _ ≤ F (T₀ * q ^ n) := hmono T _ hT1 hTgrid _ ≤ Real.exp (K * ((n : ℝ) + 1) ^ 2) := hgrid n _ ≤ _ := by apply Real.exp_le_exp.mpr calc _ ≤ K * (D * Real.log T) ^ 2 := mul_le_mul_of_nonneg_left (pow_le_pow_left₀ (by positivity) hnD 2) hK.le _ = _ := by ring /-- The actual counting envelope has the crude subexponential growth needed for exceptional-totient pruning. All inputs to the recurrence and its iteration are proved above. -/ /- Original line 17317: Erdos416Proof.exists_totientUpperEnvelope_growth -/ theorem exists_totientUpperEnvelope_growth : ∃ B : ℝ, 0 < B ∧ ∀ᶠ x : ℝ in atTop, totientUpperEnvelope x ≤ Real.exp (B * Real.log (logLog x) ^ 2) := by obtain ⟨C, hC, hrec⟩ := exists_totientUpperEnvelope_recurrence let F : ℝ → ℝ := fun T => totientUpperEnvelope (Real.exp (Real.exp T)) have hF : ∀ T : ℝ, 1 ≤ F T := fun T => totientUpperEnvelope_ge_one _ have hmono : ∀ a b : ℝ, 1 ≤ a → a ≤ b → F a ≤ F b := by intro a b ha hab have ha0 : 0 ≤ a := by linarith have he : Real.exp 1 ≤ Real.exp (Real.exp a) := Real.exp_le_exp.mpr (Real.one_le_exp_iff.mpr ha0) exact totientUpperEnvelope_mono (Real.exp_one_gt_two.le.trans he) (Real.exp_le_exp.mpr (Real.exp_le_exp.mpr hab)) have hX : Tendsto (fun T : ℝ => Real.exp (Real.exp T)) atTop atTop := Real.tendsto_exp_atTop.comp Real.tendsto_exp_atTop have hstep : ∀ᶠ T : ℝ in atTop, F T ≤ C * T ^ 2 * F ((9 / 10 : ℝ) * T) := by filter_upwards [hX.eventually hrec] with T hrec simpa only [F, logLog, Real.log_exp, growthTailEndpoint] using hrec obtain ⟨B, hB, hbound⟩ := log_square_bound_of_geometric_recurrence F hF hmono hC hstep refine ⟨B, hB, ?_⟩ have hT : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [hT.eventually hbound, eventually_gt_atTop (1 : ℝ)] with x hbound hx have heq : Real.exp (Real.exp (logLog x)) = x := by rw [logLog, Real.exp_log (Real.log_pos hx), Real.exp_log (by linarith)] simpa only [F, heq] using hbound /- Original line 17344: Erdos416Proof.nonNormalTotients_pruning -/ theorem nonNormalTotients_pruning : (fun x : ℝ => ((nonNormalTotients (normalityScale (logLog x)) x).card : ℝ)) =o[atTop] (fun x : ℝ => x / (Real.log x * logLog x ^ 2)) := by obtain ⟨B, _, hgrowth⟩ := exists_totientUpperEnvelope_growth exact nonNormalTotients_pruning_of_envelope_growth hgrowth /- Original line 17350: Erdos416Proof.nonNormalTotients_negligible_in_V -/ theorem nonNormalTotients_negligible_in_V : (fun x : ℝ => ((nonNormalTotients (normalityScale (logLog x)) x).card : ℝ)) =o[atTop] V := nonNormalTotients_pruning.trans_isBigO square_pruning_scale_isBigO_V end Erdos416Proof /- The actual three-form sieve for q, a*q+1, and b*q+1. The congruence counts and cubic logarithmic denominator are proved, with a uniform arithmetic factor for varying distinct coefficients. This supplies a required input to the multivariable sieve proved later in this file. -/ open Filter Asymptotics open scoped BigOperators Classical Topology namespace Erdos416Proof open Sieve SelbergSieve BoundingSieve /-- A restricted-support form of the proved Selberg denominator bound. This permits omitting the primes dividing a varying discriminant. -/ /- Original line 17373: Erdos416Proof.selbergBoundingSum_ge_supported_sum -/ theorem selbergBoundingSum_ge_supported_sum (s : SelbergSieve) (F : Finset ℕ) (hF : ∀ m ∈ F, 0 < m ∧ (m : ℝ) ≤ Real.sqrt s.level ∧ ∀ p, p.Prime → p ∣ m → p ∣ s.prodPrimes) (hnu : Sieve.CompletelyMultiplicative s.nu) (hnu_nonneg : ∀ n, 0 ≤ s.nu n) (hnu_lt : ∀ p, p.Prime → p ∣ s.prodPrimes → s.nu p < 1) : (∑ m ∈ F, s.nu m) ≤ s.selbergBoundingSum := by unfold selbergBoundingSum calc ∑ l ∈ s.prodPrimes.divisors, (if l ^ 2 ≤ s.level then selbergTerms _ l else 0) ≥ ∑ l ∈ s.prodPrimes.divisors.filter (fun (l:ℕ) => l^2 ≤ s.level), ∑ m ∈ (l^(Nat.floor s.level)).divisors.filter (l ∣ ·), s.nu m := ?_ _ ≥ ∑ m ∈ F, s.nu m := ?_ · rw [←Finset.sum_filter]; apply Finset.sum_le_sum; intro l hl rw [Finset.mem_filter, Nat.mem_divisors] at hl have hlsq : Squarefree l := Squarefree.squarefree_of_dvd hl.1.1 s.prodPrimes_squarefree trans (∏ p ∈ l.primeFactors, ∑ n ∈ Finset.Icc 1 (Nat.floor s.level), s.nu (p^n)) · rw [prod_factors_sum_pow_compMult (Nat.floor s.level) _ s.nu] · exact hnu · exact hlsq · rw [ne_eq, Nat.floor_eq_zero, not_lt] exact s.one_le_level rw [selbergTerms_apply _ l] apply prod_factors_one_div_compMult_ge _ _ hnu _ _ hlsq · intro p hpp hpl apply hnu_lt p hpp (Trans.trans hpl hl.1.1) · exact hnu_nonneg rw [←Finset.sum_biUnion] · apply Finset.sum_le_sum_of_subset_of_nonneg ?_ (fun _ _ _ => hnu_nonneg _) intro m hm obtain ⟨hmpos, hmbound, hmsupport⟩ := hF m hm have hprod_pos : 0 < (∏ p ∈ m.primeFactors, p) := by apply Finset.prod_pos; intro p hp; exact Nat.pos_of_mem_primeFactorsList <| List.mem_toFinset.mp hp have hprod_ne_zero : (∏ p ∈ m.primeFactors, p) ^ ⌊s.level⌋₊ ≠ 0 := by apply pow_ne_zero; apply ne_of_gt; apply hprod_pos rw [Finset.mem_biUnion]; simp_rw [Finset.mem_filter, Nat.mem_divisors] have hm_ne_zero : m ≠ 0 := hmpos.ne' use ∏ p ∈ m.primeFactors, p constructor; constructor; constructor · apply prod_primes_dvd_of_dvd <;> intro p hp · exact hmsupport p (Nat.prime_of_mem_primeFactors hp) (Nat.dvd_of_mem_primeFactors hp) exact Nat.prime_of_mem_primeFactors hp · exact prodPrimes_ne_zero · rw [←Real.sqrt_le_sqrt_iff (by linarith only [s.one_le_level]), Real.sqrt_sq] · trans (m:ℝ) · norm_cast; apply Nat.le_of_dvd hmpos exact Nat.prod_primeFactors_dvd m exact hmbound apply le_of_lt; norm_cast constructor; constructor · rw [←Nat.factorization_le_iff_dvd _ hprod_ne_zero, Nat.factorization_pow] · intro p have hy_mul_prod_nonneg : 0 ≤ ⌊s.level⌋₊ * (Nat.factorization (∏ p ∈ m.primeFactors, p)) p := by apply mul_nonneg · apply Nat.le_floor; norm_cast; linarith only [s.one_le_level] · norm_num trans (Nat.factorization m) p * 1 · rw [mul_one] rw [Finsupp.smul_apply, smul_eq_mul] by_cases hpp : p.Prime swap · rw [Nat.factorization_eq_zero_of_not_prime _ hpp, zero_mul]; exact hy_mul_prod_nonneg by_cases hpdvd : p ∣ m swap · rw [Nat.factorization_eq_zero_of_not_dvd hpdvd, zero_mul]; exact hy_mul_prod_nonneg apply mul_le_mul · trans m · apply le_of_lt <| Nat.factorization_lt _ _ apply hm_ne_zero apply Nat.le_floor refine le_trans hmbound ?_ apply sqrt_le_self _ s.one_le_level · rw [←Nat.Prime.pow_dvd_iff_le_factorization hpp <| ne_of_gt hprod_pos, pow_one] apply Finset.dvd_prod_of_mem rw [Nat.mem_primeFactors] exact ⟨hpp, hpdvd, hm_ne_zero⟩ · norm_num · norm_num exact hm_ne_zero · exact hprod_ne_zero · exact Nat.prod_primeFactors_dvd m · intro idx hi j hj hij t hti htj x hx simp only [Finset.bot_eq_empty, Finset.notMem_empty] specialize hti hx specialize htj hx simp_rw [Finset.mem_coe, Finset.mem_filter, Nat.mem_divisors] at * have h : ∀ idx j {n}, idx ∣ s.prodPrimes → idx ∣ x → x ∣ j ^ n → idx ∣ j := by intro idx j n hiP hix hij apply Nat.squarefree_dvd_pow idx j n (squarefree_of_dvd_prodPrimes hiP) exact Trans.trans hix hij have hidvdj : idx ∣ j := by apply h idx j hi.1.1 hti.2 htj.1.1 have hjdvdi : j ∣ idx := by apply h j idx hj.1.1 htj.2 hti.1.1 exact hij <| Nat.dvd_antisymm hidvdj hjdvdi /- Original line 17471: Erdos416Proof.omegaWeightNat -/ def omegaWeightNat (z : ℕ) : ArithmeticFunction ℕ := ⟨fun n => if n = 0 then 0 else z ^ ArithmeticFunction.cardFactors n, by simp⟩ /- Original line 17474: Erdos416Proof.omegaWeightNat_multiplicative -/ theorem omegaWeightNat_multiplicative (z : ℕ) : (omegaWeightNat z).IsMultiplicative := by refine ⟨by simp [omegaWeightNat], ?_⟩ intro m n _ by_cases hm : m = 0 · simp [hm] by_cases hn : n = 0 · simp [hn] simp [omegaWeightNat, hm, hn, ArithmeticFunction.cardFactors_mul hm hn, pow_add] /- Original line 17484: Erdos416Proof.sum_two_pow_range_le_three_pow -/ theorem sum_two_pow_range_le_three_pow (k : ℕ) : (∑ j ∈ Finset.range (k + 1), (2 : ℕ) ^ j) ≤ 3 ^ k := by induction k with | zero => simp | succ k ih => rw [Finset.sum_range_succ', pow_zero] simp only [pow_succ, ← Finset.sum_mul] have h1 : 1 ≤ (3 : ℕ) ^ k := Nat.one_le_pow k 3 (by omega) omega /- Original line 17494: Erdos416Proof.sum_two_pow_cardFactors_divisors_le_three_pow -/ theorem sum_two_pow_cardFactors_divisors_le_three_pow (n : ℕ) : (∑ d ∈ n.divisors, (2 : ℕ) ^ ArithmeticFunction.cardFactors d) ≤ 3 ^ ArithmeticFunction.cardFactors n := by by_cases hn : n = 0 · simp [hn] let f := ArithmeticFunction.zeta * omegaWeightNat 2 have hf : f.IsMultiplicative := ArithmeticFunction.isMultiplicative_zeta.mul (omegaWeightNat_multiplicative 2) have heq : f n = ∑ d ∈ n.divisors, (2 : ℕ) ^ ArithmeticFunction.cardFactors d := by rw [ArithmeticFunction.zeta_mul_apply] apply Finset.sum_congr rfl intro d hd simp [omegaWeightNat, ne_zero_of_dvd_ne_zero hn (Nat.dvd_of_mem_divisors hd)] have hp (p k : ℕ) (hprime : p.Prime) : f (p ^ k) ≤ 3 ^ k := by rw [ArithmeticFunction.zeta_mul_apply, Nat.sum_divisors_prime_pow hprime] simpa [omegaWeightNat, hprime.ne_zero, ArithmeticFunction.cardFactors_apply_prime_pow hprime] using sum_two_pow_range_le_three_pow k rw [← heq, hf.multiplicative_factorization f hn, ArithmeticFunction.cardFactors_eq_sum_factorization] simp only [Finsupp.prod, Finsupp.sum, Nat.support_factorization] rw [← Finset.prod_pow_eq_pow_sum] exact Finset.prod_le_prod (fun _ _ => Nat.zero_le _) fun p hp' => hp p _ (Nat.prime_of_mem_primeFactors hp') /- Original line 17519: Erdos416Proof.tripleDivisors -/ def tripleDivisors (n : ℕ) : Finset (Σ _ : ℕ, ℕ) := n.divisors.sigma (fun d => d.divisors) /- Original line 17522: Erdos416Proof.tripleDivisors_card_le -/ theorem tripleDivisors_card_le (n : ℕ) : (tripleDivisors n).card ≤ 3 ^ ArithmeticFunction.cardFactors n := by rw [tripleDivisors, Finset.card_sigma] exact (Finset.sum_le_sum fun d _ => card_divisors_le_two_pow_cardFactors d).trans (sum_two_pow_cardFactors_divisors_le_three_pow n) /- Original line 17528: Erdos416Proof.threeFormDensity -/ noncomputable def threeFormDensity : ArithmeticFunction ℝ := ⟨fun n => (3 : ℝ) ^ ArithmeticFunction.cardFactors n / n, by simp⟩ /- Original line 17531: Erdos416Proof.threeFormDensity_apply -/ theorem threeFormDensity_apply (n : ℕ) : threeFormDensity n = (3 : ℝ) ^ ArithmeticFunction.cardFactors n / n := rfl /- Original line 17534: Erdos416Proof.threeFormDensity_one -/ theorem threeFormDensity_one : threeFormDensity 1 = 1 := by simp [threeFormDensity_apply] /- Original line 17537: Erdos416Proof.threeFormDensity_mul -/ theorem threeFormDensity_mul (m n : ℕ) : threeFormDensity (m * n) = threeFormDensity m * threeFormDensity n := by by_cases hm : m = 0 · simp [Erdos416Proof.threeFormDensity_one, hm] by_cases hn : n = 0 · simp [Erdos416Proof.threeFormDensity_one, hn] simp only [threeFormDensity_apply, ArithmeticFunction.cardFactors_mul hm hn, pow_add, Nat.cast_mul] ring /- Original line 17547: Erdos416Proof.threeFormDensity_nonneg -/ theorem threeFormDensity_nonneg (n : ℕ) : 0 ≤ threeFormDensity n := by rw [threeFormDensity_apply] positivity /- Original line 17551: Erdos416Proof.threeFormDensity_pos -/ theorem threeFormDensity_pos {n : ℕ} (hn : 0 < n) : 0 < threeFormDensity n := by rw [threeFormDensity_apply] positivity /- Original line 17555: Erdos416Proof.threeFormDensity_prime -/ theorem threeFormDensity_prime {p : ℕ} (hp : p.Prime) : threeFormDensity p = 3 / (p : ℝ) := by simp [Erdos416Proof.threeFormDensity_one, threeFormDensity_apply, hp] /- Original line 17559: Erdos416Proof.threeFormDensity_prime_lt_one -/ theorem threeFormDensity_prime_lt_one {D p : ℕ} (hD : 6 ∣ D) (hp : p.Prime) (hpD : ¬p ∣ D) : threeFormDensity p < 1 := by have hp2 : p ≠ 2 := by intro heq exact hpD (heq ▸ dvd_trans (by norm_num : 2 ∣ 6) hD) have hp3 : p ≠ 3 := by intro heq exact hpD (heq ▸ dvd_trans (by norm_num : 3 ∣ 6) hD) have hpgt : 3 < p := by have := hp.two_le; omega rw [threeFormDensity_prime hp] exact (div_lt_one (by exact_mod_cast hp.pos)).mpr (by exact_mod_cast hpgt) /-- Cubic logarithmic mass from actual triples of integers coprime to D. -/ /- Original line 17572: Erdos416Proof.threeFormDensity_sum_lower_bound -/ theorem threeFormDensity_sum_lower_bound (N : ℕ) {D : ℕ} (hD : 0 < D) : ((D.totient : ℝ) / D) ^ 3 * (∑ n ∈ Finset.Icc 1 N, (n : ℝ)⁻¹) ^ 3 ≤ ∑ n ∈ (Finset.Icc 1 (N ^ 3)).filter (fun n => n.Coprime D), threeFormDensity n := by let B := (Finset.Icc 1 N).filter (fun n => n.Coprime D) let P := B.product (B.product B) let F := (Finset.Icc 1 (N ^ 3)).filter (fun n => n.Coprime D) let Q := F.sigma tripleDivisors let f : ℕ × (ℕ × ℕ) → (Σ _ : ℕ, Σ _ : ℕ, ℕ) := fun v => ⟨v.1 * (v.2.1 * v.2.2), ⟨v.2.1 * v.2.2, v.2.2⟩⟩ have hB (n : ℕ) (hn : n ∈ B) : 0 < n ∧ n ≤ N ∧ n.Coprime D := by obtain ⟨h, hcop⟩ := Finset.mem_filter.mp hn exact ⟨(Finset.mem_Icc.mp h).1, (Finset.mem_Icc.mp h).2, hcop⟩ have hP (v : ℕ × (ℕ × ℕ)) (hv : v ∈ P) : v.1 ∈ B ∧ v.2.1 ∈ B ∧ v.2.2 ∈ B := by simpa only [P, Finset.product_eq_sprod, Finset.mem_product] using hv have hsub : P.image f ⊆ Q := by intro v hv obtain ⟨w, hw, rfl⟩ := Finset.mem_image.mp hv obtain ⟨hw1, hw2, hw3⟩ := hP w hw obtain ⟨h1, hN1, hc1⟩ := hB _ hw1 obtain ⟨h2, hN2, hc2⟩ := hB _ hw2 obtain ⟨h3, hN3, hc3⟩ := hB _ hw3 have h23 : 0 < w.2.1 * w.2.2 := Nat.mul_pos h2 h3 apply Finset.mem_sigma.mpr refine ⟨Finset.mem_filter.mpr ⟨Finset.mem_Icc.mpr ⟨Nat.mul_pos h1 h23, ?_⟩, hc1.mul_left (hc2.mul_left hc3)⟩, ?_⟩ · simpa only [pow_succ, pow_zero, one_mul, mul_assoc] using Nat.mul_le_mul hN1 (Nat.mul_le_mul hN2 hN3) · apply Finset.mem_sigma.mpr exact ⟨Nat.mem_divisors.mpr ⟨dvd_mul_left _ _, (Nat.mul_pos h1 h23).ne'⟩, Nat.mem_divisors.mpr ⟨dvd_mul_left _ _, h23.ne'⟩⟩ have hinj : Set.InjOn f (P : Set (ℕ × (ℕ × ℕ))) := by intro v hv w hw heq have hn : v.1 * (v.2.1 * v.2.2) = w.1 * (w.2.1 * w.2.2) := congrArg Sigma.fst heq have hd : v.2.1 * v.2.2 = w.2.1 * w.2.2 := congrArg (fun t : Σ _ : ℕ, Σ _ : ℕ, ℕ => t.2.1) heq have he : v.2.2 = w.2.2 := congrArg (fun t : Σ _ : ℕ, Σ _ : ℕ, ℕ => t.2.2) heq have h2 : 0 < w.2.1 := (hB _ (hP w hw).2.1).1 have h3 : 0 < w.2.2 := (hB _ (hP w hw).2.2).1 have hv1 : v.1 = w.1 := by rw [hd] at hn exact Nat.eq_of_mul_eq_mul_right (Nat.mul_pos h2 h3) hn have hv2 : v.2.1 = w.2.1 := by rw [he] at hd exact Nat.eq_of_mul_eq_mul_right h3 hd exact Prod.ext hv1 (Prod.ext hv2 he) have hmass : (∑ n ∈ B, (n : ℝ)⁻¹) ^ 3 ≤ ∑ n ∈ F, threeFormDensity n := by calc _ = ∑ v ∈ P, ((v.1 * (v.2.1 * v.2.2) : ℕ) : ℝ)⁻¹ := by simp only [P, Finset.product_eq_sprod, Finset.sum_product, Nat.cast_mul, mul_inv_rev] simp_rw [← Finset.sum_mul, ← Finset.mul_sum] ring _ = ∑ v ∈ P.image f, (v.1 : ℝ)⁻¹ := (Finset.sum_image (f := fun v : Σ _ : ℕ, Σ _ : ℕ, ℕ => (v.1 : ℝ)⁻¹) hinj).symm _ ≤ ∑ v ∈ Q, (v.1 : ℝ)⁻¹ := Finset.sum_le_sum_of_subset_of_nonneg hsub (fun _ _ _ => by positivity) _ = ∑ n ∈ F, ((tripleDivisors n).card : ℝ) / n := by rw [Finset.sum_sigma] simp only [Finset.sum_const, nsmul_eq_mul, div_eq_mul_inv] _ ≤ ∑ n ∈ F, threeFormDensity n := by apply Finset.sum_le_sum intro n _ rw [threeFormDensity_apply] apply div_le_div_of_nonneg_right _ (Nat.cast_nonneg n) exact_mod_cast tripleDivisors_card_le n have hcop := reciprocal_coprime_sum_lower_bound N hD have hleft : ((D.totient : ℝ) / D) ^ 3 * (∑ n ∈ Finset.Icc 1 N, (n : ℝ)⁻¹) ^ 3 ≤ (∑ n ∈ B, (n : ℝ)⁻¹) ^ 3 := by rw [← mul_pow] exact pow_le_pow_left₀ (by positivity) hcop 3 exact hleft.trans hmass /-- The cubic logarithmic Selberg denominator, with a uniform arithmetic factor. Primes dividing D are omitted from the sifting product. -/ /- Original line 17648: Erdos416Proof.threeForm_selberg_boundingSum_lower -/ theorem threeForm_selberg_boundingSum_lower (s : SelbergSieve) {D : ℕ} (hD : 0 < D) (h6 : 6 ∣ D) (hcop : s.prodPrimes.Coprime D) (hnu : s.nu = threeFormDensity) (hP : ∀ p : ℕ, p.Prime → (p : ℝ) ≤ s.level → ¬p ∣ D → p ∣ s.prodPrimes) : ((D.totient : ℝ) / D) ^ 3 * Real.log s.level ^ 3 / 512 ≤ s.selbergBoundingSum := by let r := Real.sqrt (Real.sqrt (Real.sqrt s.level)) let N := ⌊r⌋₊ let F := (Finset.Icc 1 ⌊Real.sqrt s.level⌋₊).filter (fun n => n.Coprime D) have hy0 : 0 ≤ s.level := le_trans zero_le_one s.one_le_level have hroot1 : 1 ≤ r := by apply Real.le_sqrt_of_sq_le simp only [one_pow] apply Real.le_sqrt_of_sq_le simp only [one_pow] exact Real.le_sqrt_of_sq_le (by simpa only [one_pow] using s.one_le_level) have hN1 : (1 : ℝ) ≤ N := by have h : (1 : ℕ) ≤ N := Nat.le_floor (by simpa only [Nat.cast_one] using hroot1) exact_mod_cast h have hN : N ^ 3 ≤ ⌊Real.sqrt s.level⌋₊ := by apply Nat.le_floor push_cast have hfloor : (N : ℝ) ≤ r := Nat.floor_le (Real.sqrt_nonneg _) have hfour : r ^ 4 = Real.sqrt s.level := by calc r ^ 4 = (r ^ 2) ^ 2 := by ring _ = (Real.sqrt (Real.sqrt s.level)) ^ 2 := by rw [show r ^ 2 = Real.sqrt (Real.sqrt s.level) from Real.sq_sqrt (Real.sqrt_nonneg _)] _ = Real.sqrt s.level := Real.sq_sqrt (Real.sqrt_nonneg _) calc (N : ℝ) ^ 3 ≤ (N : ℝ) ^ 3 * N := le_mul_of_one_le_right (by positivity) hN1 _ = (N : ℝ) ^ 4 := by ring _ ≤ r ^ 4 := pow_le_pow_left₀ (by positivity) hfloor 4 _ = Real.sqrt s.level := hfour have hstart := selbergBoundingSum_ge_supported_sum s F (by intro m hm obtain ⟨hbound, hcopm⟩ := Finset.mem_filter.mp hm obtain ⟨hm1, hmL⟩ := Finset.mem_Icc.mp hbound have hmr : (m : ℝ) ≤ Real.sqrt s.level := (Nat.cast_le.mpr hmL).trans (Nat.floor_le (Real.sqrt_nonneg _)) refine ⟨hm1, hmr, ?_⟩ intro p hp hpm apply hP p hp · exact (Nat.cast_le.mpr (Nat.le_of_dvd hm1 hpm)).trans (hmr.trans (sqrt_le_self s.level s.one_le_level)) · intro hpD exact hp.not_dvd_one (hcopm ▸ Nat.dvd_gcd hpm hpD)) (by rw [hnu]; exact ⟨threeFormDensity_one, threeFormDensity_mul⟩) (by intro n; rw [hnu]; exact threeFormDensity_nonneg n) (by intro p hp hpP rw [hnu] apply threeFormDensity_prime_lt_one h6 hp intro hpD exact hp.not_dvd_one (hcop ▸ Nat.dvd_gcd hpP hpD)) rw [hnu] at hstart have hsum : (∑ n ∈ (Finset.Icc 1 (N ^ 3)).filter (fun n => n.Coprime D), threeFormDensity n) ≤ ∑ n ∈ F, threeFormDensity n := by apply Finset.sum_le_sum_of_subset_of_nonneg (Finset.filter_subset_filter _ (Finset.Icc_subset_Icc_right hN)) intro n _ _ exact threeFormDensity_nonneg n have hlog : Real.log s.level / 8 ≤ ∑ n ∈ Finset.Icc 1 N, (n : ℝ)⁻¹ := by have h := Aux.log_le_sum_inv r hroot1 have heq : Real.log r = Real.log s.level / 8 := by dsimp [Erdos416Proof.threeFormDensity_one, SelbergSieve.selbergBoundingSum, r] rw [Real.log_sqrt (Real.sqrt_nonneg _), Real.log_sqrt (Real.sqrt_nonneg _), Real.log_sqrt hy0] ring rwa [heq] at h calc _ = ((D.totient : ℝ) / D) ^ 3 * (Real.log s.level / 8) ^ 3 := by ring _ ≤ ((D.totient : ℝ) / D) ^ 3 * (∑ n ∈ Finset.Icc 1 N, (n : ℝ)⁻¹) ^ 3 := by gcongr exact div_nonneg (Real.log_nonneg s.one_le_level) (by norm_num) _ ≤ _ := (threeFormDensity_sum_lower_bound N hD).trans (hsum.trans hstart) /- Original line 17724: Erdos416Proof.threeForm_selberg_error_bound -/ theorem threeForm_selberg_error_bound (s : SelbergSieve) (hrem : ∀ d ∈ s.prodPrimes.divisors, (d : ℝ) ≤ s.level → |BoundingSieve.rem (s := s.toBoundingSieve) d| ≤ (3 : ℝ) ^ ArithmeticFunction.cardDistinctFactors d) : (∑ d ∈ s.prodPrimes.divisors, if (d : ℝ) ≤ s.level then (3 : ℝ) ^ ArithmeticFunction.cardDistinctFactors d * |BoundingSieve.rem (s := s.toBoundingSieve) d| else 0) ≤ s.level * (1 + Real.log s.level) ^ 9 := by calc _ ≤ ∑ d ∈ s.prodPrimes.divisors, if (d : ℝ) ≤ s.level then (9 : ℝ) ^ ArithmeticFunction.cardDistinctFactors d else 0 := by apply Finset.sum_le_sum intro d hd split_ifs with hdy · calc _ ≤ (3 : ℝ) ^ ArithmeticFunction.cardDistinctFactors d * (3 : ℝ) ^ ArithmeticFunction.cardDistinctFactors d := mul_le_mul_of_nonneg_left (hrem d hd hdy) (by positivity) _ = _ := by rw [← mul_pow]; norm_num · rfl _ ≤ _ := Aux.sum_pow_cardDistinctFactors_le_self_mul_log_pow s.level s.one_le_level s.prodPrimes_squarefree /- Original line 17746: Erdos416Proof.threeForm_selberg_bound -/ theorem threeForm_selberg_bound (s : SelbergSieve) {D : ℕ} (hD : 0 < D) (h6 : 6 ∣ D) (hcop : s.prodPrimes.Coprime D) (hnu : s.nu = threeFormDensity) (hP : ∀ p : ℕ, p.Prime → (p : ℝ) ≤ s.level → ¬p ∣ D → p ∣ s.prodPrimes) (hy : 1 < s.level) (hX : 0 ≤ s.totalMass) (hrem : ∀ d ∈ s.prodPrimes.divisors, (d : ℝ) ≤ s.level → |BoundingSieve.rem (s := s.toBoundingSieve) d| ≤ (3 : ℝ) ^ ArithmeticFunction.cardDistinctFactors d) : BoundingSieve.siftedSum (s := s.toBoundingSieve) ≤ 512 * ((D : ℝ) / D.totient) ^ 3 * s.totalMass / Real.log s.level ^ 3 + s.level * (1 + Real.log s.level) ^ 9 := by have hDR : (0 : ℝ) < D := by exact_mod_cast hD have hφR : (0 : ℝ) < D.totient := by exact_mod_cast Nat.totient_pos.mpr hD have hlog : 0 < Real.log s.level := Real.log_pos hy have hlow := threeForm_selberg_boundingSum_lower s hD h6 hcop hnu hP have hmain : s.totalMass / s.selbergBoundingSum ≤ 512 * ((D : ℝ) / D.totient) ^ 3 * s.totalMass / Real.log s.level ^ 3 := by calc _ ≤ s.totalMass / (((D.totient : ℝ) / D) ^ 3 * Real.log s.level ^ 3 / 512) := div_le_div_of_nonneg_left hX (by positivity) hlow _ = _ := by field_simp exact s.selberg_bound_simple.trans (add_le_add hmain (threeForm_selberg_error_bound s hrem)) /- Original line 17768: Erdos416Proof.threeFormPolynomial -/ def threeFormPolynomial (a b n : ℕ) : ℕ := n * (a * n + 1) * (b * n + 1) /- Original line 17770: Erdos416Proof.threeFormPolynomial_strictMono -/ theorem threeFormPolynomial_strictMono (a b : ℕ) : StrictMono (threeFormPolynomial a b) := by intro m n hmn change twoFormPolynomial a m * (b * m + 1) < twoFormPolynomial a n * (b * n + 1) exact (Nat.mul_lt_mul_of_pos_right (twoFormPolynomial_strictMono a hmn) (by omega)).trans_le (Nat.mul_le_mul_left _ (Nat.add_le_add_right (Nat.mul_le_mul_left b hmn.le) 1)) /- Original line 17776: Erdos416Proof.threeFormResidues -/ def threeFormResidues (a b d : ℕ) : Finset ℕ := (Finset.range d).filter (fun n => d ∣ threeFormPolynomial a b n) /- Original line 17779: Erdos416Proof.threeForm_divisibility_iff_zmod -/ theorem threeForm_divisibility_iff_zmod (a b d n : ℕ) : d ∣ threeFormPolynomial a b n ↔ (n : ZMod d) * ((a : ZMod d) * (n : ZMod d) + 1) * ((b : ZMod d) * (n : ZMod d) + 1) = 0 := by rw [← ZMod.natCast_eq_zero_iff] simp only [threeFormPolynomial, Nat.cast_mul, Nat.cast_add, Nat.cast_one] /- Original line 17786: Erdos416Proof.threeForm_prime_roots_card -/ theorem threeForm_prime_roots_card (a b p : ℕ) [Fact p.Prime] (ha : (a : ZMod p) ≠ 0) (hb : (b : ZMod p) ≠ 0) (hab : (a : ZMod p) ≠ b) : ((Finset.univ : Finset (ZMod p)).filter (fun t => t * ((a : ZMod p) * t + 1) * ((b : ZMod p) * t + 1) = 0)).card = 3 := by have linear (c t : ZMod p) (hc : c ≠ 0) : c * t + 1 = 0 ↔ t = -c⁻¹ := by constructor · intro h apply mul_left_cancel₀ hc calc c * t = -1 := eq_neg_of_add_eq_zero_left h _ = c * -c⁻¹ := by simp [hc] · rintro rfl simp [hc] have hset : (Finset.univ : Finset (ZMod p)).filter (fun t => t * ((a : ZMod p) * t + 1) * ((b : ZMod p) * t + 1) = 0) = {0, -(a : ZMod p)⁻¹, -(b : ZMod p)⁻¹} := by ext t simp only [Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_insert, Finset.mem_singleton, mul_eq_zero, linear _ _ ha, linear _ _ hb, or_assoc] have hab' : -(a : ZMod p)⁻¹ ≠ -(b : ZMod p)⁻¹ := by simpa using hab have hzero : (0 : ZMod p) ∉ ({-(a : ZMod p)⁻¹, -(b : ZMod p)⁻¹} : Finset (ZMod p)) := by simp [ha, hb] rw [hset, Finset.card_insert_of_notMem hzero, Finset.card_pair hab'] /- Original line 17810: Erdos416Proof.threeFormResidues_card_eq_zmod -/ theorem threeFormResidues_card_eq_zmod (a b d : ℕ) [NeZero d] : (threeFormResidues a b d).card = ((Finset.univ : Finset (ZMod d)).filter (fun t => t * ((a : ZMod d) * t + 1) * ((b : ZMod d) * t + 1) = 0)).card := by let Q := (Finset.univ : Finset (ZMod d)).filter (fun t => t * ((a : ZMod d) * t + 1) * ((b : ZMod d) * t + 1) = 0) have heq : Q.image ZMod.val = threeFormResidues a b d := by ext n constructor · intro hn obtain ⟨t, ht, rfl⟩ := Finset.mem_image.mp hn apply Finset.mem_filter.mpr refine ⟨Finset.mem_range.mpr (ZMod.val_lt t), ?_⟩ apply (threeForm_divisibility_iff_zmod a b d t.val).mpr simpa only [ZMod.natCast_zmod_val] using (Finset.mem_filter.mp ht).2 · intro hn obtain ⟨hnlt, hdiv⟩ := Finset.mem_filter.mp hn refine Finset.mem_image.mpr ⟨(n : ZMod d), ?_, ?_⟩ · exact Finset.mem_filter.mpr ⟨Finset.mem_univ _, (threeForm_divisibility_iff_zmod a b d n).mp hdiv⟩ · exact ZMod.val_natCast_of_lt (Finset.mem_range.mp hnlt) rw [← heq, Finset.card_image_of_injective _ (ZMod.val_injective d)] /- Original line 17833: Erdos416Proof.threeFormDiscriminant -/ def threeFormDiscriminant (a b : ℕ) : ℕ := 6 * a * b * (b - a) /- Original line 17835: Erdos416Proof.threeFormDiscriminant_pos -/ theorem threeFormDiscriminant_pos {a b : ℕ} (ha : 0 < a) (hab : a < b) : 0 < threeFormDiscriminant a b := Nat.mul_pos (Nat.mul_pos (Nat.mul_pos (by norm_num) ha) (ha.trans hab)) (Nat.sub_pos_of_lt hab) /- Original line 17839: Erdos416Proof.six_dvd_threeFormDiscriminant -/ theorem six_dvd_threeFormDiscriminant (a b : ℕ) : 6 ∣ threeFormDiscriminant a b := by unfold threeFormDiscriminant exact dvd_mul_of_dvd_left (dvd_mul_of_dvd_left (dvd_mul_right _ _) _) _ /- Original line 17843: Erdos416Proof.threeFormResidues_prime -/ theorem threeFormResidues_prime {a b p : ℕ} (hab : a < b) (hp : p.Prime) (hpD : ¬p ∣ threeFormDiscriminant a b) : (threeFormResidues a b p).card = 3 := by let : Fact p.Prime := ⟨hp⟩ have hd : ¬p ∣ 6 ∧ ¬p ∣ a ∧ ¬p ∣ b ∧ ¬p ∣ b - a := by simpa only [threeFormDiscriminant, hp.dvd_mul, not_or, and_assoc] using hpD have ha : (a : ZMod p) ≠ 0 := (ZMod.natCast_eq_zero_iff a p).not.mpr hd.2.1 have hb : (b : ZMod p) ≠ 0 := (ZMod.natCast_eq_zero_iff b p).not.mpr hd.2.2.1 have hab' : (a : ZMod p) ≠ b := by intro heq apply hd.2.2.2 apply (ZMod.natCast_eq_zero_iff (b-a) p).mp rw [Nat.cast_sub hab.le, ← heq, sub_self] rw [threeFormResidues_card_eq_zmod, threeForm_prime_roots_card a b p ha hb hab'] /- Original line 17857: Erdos416Proof.threeFormRootsCRT -/ noncomputable def threeFormRootsCRT (a b : ℕ) {m n : ℕ} (hcop : m.Coprime n) : {t : ZMod (m*n) // t * ((a : ZMod (m*n))*t+1) * ((b : ZMod (m*n))*t+1) = 0} ≃ {t : ZMod m // t*((a : ZMod m)*t+1)*((b : ZMod m)*t+1) = 0} × {t : ZMod n // t*((a : ZMod n)*t+1)*((b : ZMod n)*t+1) = 0} := by let e := ZMod.chineseRemainder hcop have hmap (t : ZMod (m*n)) : t*((a : ZMod (m*n))*t+1)*((b : ZMod (m*n))*t+1) = 0 ↔ (e t).1*((a : ZMod m)*(e t).1+1)*((b : ZMod m)*(e t).1+1) = 0 ∧ (e t).2*((a : ZMod n)*(e t).2+1)*((b : ZMod n)*(e t).2+1) = 0 := by constructor · intro ht have h := congrArg e ht simp only [map_mul, map_add, map_natCast, map_one, map_zero] at h exact ⟨congrArg (fun x : ZMod m × ZMod n => x.1) h, congrArg (fun x : ZMod m × ZMod n => x.2) h⟩ · rintro ⟨hm, hn⟩ apply e.injective simp only [map_mul, map_add, map_natCast, map_one, map_zero] exact Prod.ext hm hn refine { toFun := fun t => (⟨(e t.1).1, ((hmap t.1).mp t.2).1⟩, ⟨(e t.1).2, ((hmap t.1).mp t.2).2⟩) invFun := fun t => ⟨e.symm (t.1.1, t.2.1), ?_⟩ left_inv := fun t => Subtype.ext (e.symm_apply_apply t.1) right_inv := fun t => ?_ } · apply (hmap _).mpr rw [e.apply_symm_apply] exact ⟨t.1.2, t.2.2⟩ · exact Prod.ext (Subtype.ext (congrArg (fun x : ZMod m × ZMod n => x.1) (e.apply_symm_apply (t.1.1, t.2.1)))) (Subtype.ext (congrArg (fun x : ZMod m × ZMod n => x.2) (e.apply_symm_apply (t.1.1, t.2.1)))) /- Original line 17890: Erdos416Proof.threeFormResidues_mul -/ theorem threeFormResidues_mul (a b : ℕ) {m n : ℕ} (hm : 0 < m) (hn : 0 < n) (hcop : m.Coprime n) : (threeFormResidues a b (m*n)).card = (threeFormResidues a b m).card * (threeFormResidues a b n).card := by let : NeZero m := ⟨hm.ne'⟩ let : NeZero n := ⟨hn.ne'⟩ have hcard (d : ℕ) [NeZero d] : Nat.card {t : ZMod d // t*((a : ZMod d)*t+1)*((b : ZMod d)*t+1) = 0} = (threeFormResidues a b d).card := by rw [Nat.card_eq_fintype_card, Fintype.card_subtype, threeFormResidues_card_eq_zmod] calc _ = Nat.card {t : ZMod (m*n) // t*((a : ZMod (m*n))*t+1)*((b : ZMod (m*n))*t+1) = 0} := (hcard _).symm _ = Nat.card ({t : ZMod m // t*((a : ZMod m)*t+1)*((b : ZMod m)*t+1) = 0} × {t : ZMod n // t*((a : ZMod n)*t+1)*((b : ZMod n)*t+1) = 0}) := Nat.card_congr (threeFormRootsCRT a b hcop) _ = _ := by rw [Nat.card_prod, hcard m, hcard n] /- Original line 17908: Erdos416Proof.threeFormRootCount -/ def threeFormRootCount (a b : ℕ) : ArithmeticFunction ℕ := ⟨fun d => (threeFormResidues a b d).card, by simp [threeFormResidues]⟩ /- Original line 17911: Erdos416Proof.threeFormRootCount_apply -/ theorem threeFormRootCount_apply (a b d : ℕ) : threeFormRootCount a b d = (threeFormResidues a b d).card := rfl /- Original line 17914: Erdos416Proof.threeFormRootCount_one -/ theorem threeFormRootCount_one (a b : ℕ) : threeFormRootCount a b 1 = 1 := by simp [Erdos416Proof.threeFormRootCount_apply, threeFormRootCount_apply, threeFormResidues, Finset.range_one] /- Original line 17917: Erdos416Proof.threeFormRootCount_multiplicative -/ theorem threeFormRootCount_multiplicative (a b : ℕ) : (threeFormRootCount a b).IsMultiplicative := by refine ⟨threeFormRootCount_one a b, ?_⟩ intro m n hcop by_cases hm : m = 0 · simp [Erdos416Proof.threeFormRootCount_apply, Erdos416Proof.threeFormRootCount_one, hm] by_cases hn : n = 0 · simp [Erdos416Proof.threeFormRootCount_apply, Erdos416Proof.threeFormRootCount_one, hn] exact threeFormResidues_mul a b (Nat.pos_of_ne_zero hm) (Nat.pos_of_ne_zero hn) hcop /- Original line 17927: Erdos416Proof.threeFormRootCount_eq_density -/ theorem threeFormRootCount_eq_density {a b d : ℕ} (hab : a < b) (hd : Squarefree d) (hcop : d.Coprime (threeFormDiscriminant a b)) : (threeFormRootCount a b d : ℝ) = (d : ℝ) * threeFormDensity d := by have hmult : threeFormDensity.IsMultiplicative := ⟨threeFormDensity_one, fun {m n} _ => threeFormDensity_mul m n⟩ have hdc : (d : ℝ) = ∏ p ∈ d.primeFactors, (p : ℝ) := by rw [← Nat.cast_prod, Nat.prod_primeFactors_of_squarefree hd] rw [← (threeFormRootCount_multiplicative a b).prod_primeFactors hd, ← hmult.prod_primeFactors hd, Nat.cast_prod, hdc, ← Finset.prod_mul_distrib] apply Finset.prod_congr rfl intro p hp have hprime := Nat.prime_of_mem_primeFactors hp have hnD : ¬p ∣ threeFormDiscriminant a b := by intro hpD exact hprime.not_dvd_one (hcop ▸ Nat.dvd_gcd (Nat.dvd_of_mem_primeFactors hp) hpD) rw [threeFormRootCount_apply, threeFormResidues_prime hab hprime hnD, threeFormDensity_prime hprime] have hpR : (p : ℝ) ≠ 0 := by exact_mod_cast hprime.ne_zero field_simp norm_num /- Original line 17948: Erdos416Proof.threeFormRootCount_le_pow -/ theorem threeFormRootCount_le_pow {a b d : ℕ} (hab : a < b) (hd : Squarefree d) (hcop : d.Coprime (threeFormDiscriminant a b)) : threeFormRootCount a b d ≤ 3 ^ ArithmeticFunction.cardDistinctFactors d := by rw [← (threeFormRootCount_multiplicative a b).prod_primeFactors hd] have hcard : d.primeFactors.card = ArithmeticFunction.cardDistinctFactors d := by rw [ArithmeticFunction.cardDistinctFactors_apply, ← Nat.toFinset_factors, List.card_toFinset] calc _ ≤ ∏ _p ∈ d.primeFactors, (3 : ℕ) := by apply Finset.prod_le_prod (fun _ _ => Nat.zero_le _) intro p hp have hprime := Nat.prime_of_mem_primeFactors hp have hnD : ¬p ∣ threeFormDiscriminant a b := by intro hpD exact hprime.not_dvd_one (hcop ▸ Nat.dvd_gcd (Nat.dvd_of_mem_primeFactors hp) hpD) exact (threeFormResidues_prime hab hprime hnD).le _ = _ := by simp [Erdos416Proof.threeFormRootCount_apply, Erdos416Proof.threeFormRootCount_one, hcard] /- Original line 17965: Erdos416Proof.threeForm_divisibility_periodic -/ theorem threeForm_divisibility_periodic (a b d : ℕ) : Function.Periodic (fun n => d ∣ threeFormPolynomial a b n) d := by intro n apply propext dsimp only rw [threeForm_divisibility_iff_zmod, threeForm_divisibility_iff_zmod] simp[Erdos416Proof.threeFormRootCount_one] /- Original line 17973: Erdos416Proof.threeForm_congruence_error -/ theorem threeForm_congruence_error {a b : ℕ} (hab : a < b) (N : ℕ) {d : ℕ} (hd : Squarefree d) (hcop : d.Coprime (threeFormDiscriminant a b)) : |(((Finset.range N).filter (fun n => d ∣ threeFormPolynomial a b n)).card : ℝ) - threeFormDensity d * N| ≤ (3 : ℝ) ^ ArithmeticFunction.cardDistinctFactors d := by have herr := periodic_count_error (threeForm_divisibility_periodic a b d) (Nat.pos_of_ne_zero hd.ne_zero) N simp only [Nat.count_eq_card_filter_range] at herr change |(_ : ℝ) - (threeFormRootCount a b d : ℝ) / d * N| ≤ threeFormRootCount a b d at herr have hcoef : (threeFormRootCount a b d : ℝ) / d = threeFormDensity d := by rw [threeFormRootCount_eq_density hab hd hcop] have hdR : (d : ℝ) ≠ 0 := by exact_mod_cast hd.ne_zero field_simp rw [hcoef] at herr exact herr.trans (by exact_mod_cast threeFormRootCount_le_pow hab hd hcop) /- Original line 17987: Erdos416Proof.threeFormSieveProduct -/ noncomputable def threeFormSieveProduct (D : ℕ) (L : ℝ) : ℕ := primePart (primorial ⌊L⌋₊) (fun p => ¬p ∣ D) /- Original line 17990: Erdos416Proof.threeFormSieveProduct_squarefree -/ theorem threeFormSieveProduct_squarefree (D : ℕ) (L : ℝ) : Squarefree (threeFormSieveProduct D L) := Squarefree.squarefree_of_dvd (primePart_dvd (primorial_pos _).ne' _) (squarefree_primorial _) /- Original line 17995: Erdos416Proof.threeFormSieveProduct_coprime -/ theorem threeFormSieveProduct_coprime (D : ℕ) (L : ℝ) : (threeFormSieveProduct D L).Coprime D := primePart_coprime_complement _ _ /- Original line 17998: Erdos416Proof.prime_dvd_threeFormSieveProduct_iff -/ theorem prime_dvd_threeFormSieveProduct_iff (D : ℕ) (L : ℝ) {p : ℕ} (hp : p.Prime) : p ∣ threeFormSieveProduct D L ↔ p ≤ ⌊L⌋₊ ∧ ¬p ∣ D := by calc _ ↔ p ∈ (threeFormSieveProduct D L).primeFactorsList := by rw [threeFormSieveProduct, Nat.mem_primeFactorsList (primePart_pos _ _).ne'] simp only [hp, true_and] _ ↔ _ := by rw [threeFormSieveProduct, mem_primeFactorsList_primePart, Nat.mem_primeFactorsList (primorial_pos _).ne'] simp only [hp, true_and, hp.dvd_primorial_iff] /- Original line 18009: Erdos416Proof.threeFormSieve -/ noncomputable def threeFormSieve (a b N : ℕ) (L : ℝ) (hL : 1 ≤ L) : SelbergSieve where support := (Finset.range N).image (threeFormPolynomial a b) prodPrimes := threeFormSieveProduct (threeFormDiscriminant a b) L prodPrimes_squarefree := threeFormSieveProduct_squarefree _ _ weights := fun _ => 1 weights_nonneg := fun _ => zero_le_one totalMass := N nu := threeFormDensity nu_mult := ⟨threeFormDensity_one, fun {m n} _ => threeFormDensity_mul m n⟩ nu_pos_of_prime := fun _ hp _ => threeFormDensity_pos hp.pos nu_lt_one_of_prime := fun _ hp hpP => threeFormDensity_prime_lt_one (six_dvd_threeFormDiscriminant a b) hp ((prime_dvd_threeFormSieveProduct_iff _ _ hp).mp hpP).2 level := L one_le_level := hL /- Original line 18024: Erdos416Proof.threeFormSieve_multSum -/ theorem threeFormSieve_multSum (a b N d : ℕ) (L : ℝ) (hL : 1 ≤ L) : BoundingSieve.multSum (s := (threeFormSieve a b N L hL).toBoundingSieve) d = (((Finset.range N).filter (fun n => d ∣ threeFormPolynomial a b n)).card : ℝ) := by change (∑ n ∈ (Finset.range N).image (threeFormPolynomial a b), if d ∣ n then (1 : ℝ) else 0) = _ rw [Finset.sum_image (fun _ _ _ _ h => (threeFormPolynomial_strictMono a b).injective h)] exact Finset.sum_boole _ _ /- Original line 18031: Erdos416Proof.threeFormSieve_rem_bound -/ theorem threeFormSieve_rem_bound {a b : ℕ} (hab : a < b) (N : ℕ) (L : ℝ) (hL : 1 ≤ L) {d : ℕ} (hd : d ∣ threeFormSieveProduct (threeFormDiscriminant a b) L) : |BoundingSieve.rem (s := (threeFormSieve a b N L hL).toBoundingSieve) d| ≤ (3 : ℝ) ^ ArithmeticFunction.cardDistinctFactors d := by rw [BoundingSieve.rem, threeFormSieve_multSum] exact threeForm_congruence_error hab N (Squarefree.squarefree_of_dvd hd (threeFormSieveProduct_squarefree _ _)) (Nat.Coprime.of_dvd_left hd (threeFormSieveProduct_coprime _ _)) /- Original line 18040: Erdos416Proof.threeFormSieve_siftedSum -/ theorem threeFormSieve_siftedSum (a b N : ℕ) (L : ℝ) (hL : 1 ≤ L) : BoundingSieve.siftedSum (s := (threeFormSieve a b N L hL).toBoundingSieve) = (((Finset.range N).filter (fun n => (threeFormSieveProduct (threeFormDiscriminant a b) L).Coprime (threeFormPolynomial a b n))).card : ℝ) := by change (∑ n ∈ (Finset.range N).image (threeFormPolynomial a b), if (threeFormSieveProduct (threeFormDiscriminant a b) L).Coprime n then (1 : ℝ) else 0) = _ rw [Finset.sum_image (fun _ _ _ _ h => (threeFormPolynomial_strictMono a b).injective h)] exact Finset.sum_boole _ _ /- Original line 18049: Erdos416Proof.threeForm_sifted_count_bound -/ theorem threeForm_sifted_count_bound {a b : ℕ} (ha : 0 < a) (hab : a < b) (N : ℕ) {L : ℝ} (hL : 1 < L) : (((Finset.range N).filter (fun n => (threeFormSieveProduct (threeFormDiscriminant a b) L).Coprime (threeFormPolynomial a b n))).card : ℝ) ≤ 512 * ((threeFormDiscriminant a b : ℝ) / (threeFormDiscriminant a b).totient) ^ 3 * N / Real.log L ^ 3 + L * (1 + Real.log L) ^ 9 := by let s := threeFormSieve a b N L hL.le have hP : ∀ p : ℕ, p.Prime → (p : ℝ) ≤ s.level → ¬p ∣ threeFormDiscriminant a b → p ∣ s.prodPrimes := by intro p hp hpL hpD exact (prime_dvd_threeFormSieveProduct_iff _ _ hp).mpr ⟨Nat.le_floor hpL, hpD⟩ have hrem : ∀ d ∈ s.prodPrimes.divisors, (d : ℝ) ≤ s.level → |BoundingSieve.rem (s := s.toBoundingSieve) d| ≤ (3 : ℝ) ^ ArithmeticFunction.cardDistinctFactors d := by intro d hd _ exact threeFormSieve_rem_bound hab N L hL.le (Nat.dvd_of_mem_divisors hd) have h := threeForm_selberg_bound s (threeFormDiscriminant_pos ha hab) (six_dvd_threeFormDiscriminant a b) (threeFormSieveProduct_coprime (threeFormDiscriminant a b) L) rfl hP hL (by change (0 : ℝ) ≤ N; positivity) hrem rw [threeFormSieve_siftedSum] at h exact h /- Original line 18071: Erdos416Proof.threeFormPrimeTriples -/ def threeFormPrimeTriples (a b N : ℕ) : Finset ℕ := (Finset.range N).filter (fun n => n.Prime ∧ (a*n+1).Prime ∧ (b*n+1).Prime) /- Original line 18074: Erdos416Proof.prime_triple_coprime_sieveProduct -/ theorem prime_triple_coprime_sieveProduct {a b t : ℕ} (ha : 0 < a) (hab : a < b) (ht : t.Prime) (hat : (a*t+1).Prime) (hbt : (b*t+1).Prime) {L : ℝ} (hLt : ⌊L⌋₊ < t) : (threeFormSieveProduct (threeFormDiscriminant a b) L).Coprime (threeFormPolynomial a b t) := by apply Nat.coprime_of_dvd intro p hp hpP hpF have hpt : p < t := ((prime_dvd_threeFormSieveProduct_iff _ _ hp).mp hpP).1.trans_lt hLt have htpa : t < a*t+1 := by nlinarith have htpb : t < b*t+1 := by nlinarith rcases hp.dvd_mul.mp hpF with h | h · rcases hp.dvd_mul.mp h with h | h · have heq : p = t := (Nat.dvd_prime ht).mp h |>.resolve_left hp.ne_one omega · have heq : p = a*t+1 := (Nat.dvd_prime hat).mp h |>.resolve_left hp.ne_one omega · have heq : p = b*t+1 := (Nat.dvd_prime hbt).mp h |>.resolve_left hp.ne_one omega /- Original line 18091: Erdos416Proof.threeFormPrimeTriples_le_sifted -/ theorem threeFormPrimeTriples_le_sifted {a b : ℕ} (ha : 0 < a) (hab : a < b) (N : ℕ) {L : ℝ} (hL : 0 ≤ L) : ((threeFormPrimeTriples a b N).card : ℝ) ≤ (((Finset.range N).filter (fun n => (threeFormSieveProduct (threeFormDiscriminant a b) L).Coprime (threeFormPolynomial a b n))).card : ℝ) + (L+1) := by let A := (Finset.range N).filter (fun n => (threeFormSieveProduct (threeFormDiscriminant a b) L).Coprime (threeFormPolynomial a b n)) have hsub : threeFormPrimeTriples a b N ⊆ A ∪ Finset.range (⌊L⌋₊+1) := by intro t ht obtain ⟨htN, htprime, hat, hbt⟩ := Finset.mem_filter.mp ht by_cases htL : t ≤ ⌊L⌋₊ · exact Finset.mem_union_right _ (Finset.mem_range.mpr (by omega)) · exact Finset.mem_union_left _ (Finset.mem_filter.mpr ⟨htN, prime_triple_coprime_sieveProduct ha hab htprime hat hbt (by omega)⟩) have hcard : ((threeFormPrimeTriples a b N).card : ℝ) ≤ A.card + (⌊L⌋₊ : ℝ) + 1 := by have h := (Finset.card_le_card hsub).trans (Finset.card_union_le _ _) simpa only [Finset.card_range, Nat.cast_add, Nat.cast_one, add_assoc] using (Nat.cast_le (α := ℝ)).mpr h exact hcard.trans (by linarith [Nat.floor_le hL]) /- Original line 18111: Erdos416Proof.threeFormPrimeTriples_bound -/ theorem threeFormPrimeTriples_bound {a b : ℕ} (ha : 0 < a) (hab : a < b) (N : ℕ) {L : ℝ} (hL : 1 < L) : ((threeFormPrimeTriples a b N).card : ℝ) ≤ 512 * ((threeFormDiscriminant a b : ℝ) / (threeFormDiscriminant a b).totient) ^ 3 * N / Real.log L ^ 3 + L * (1 + Real.log L) ^ 9 + (L+1) := by exact (threeFormPrimeTriples_le_sifted ha hab N (by linarith)).trans (add_le_add (threeForm_sifted_count_bound ha hab N hL) le_rfl) /- Original line 18119: Erdos416Proof.threeForm_sieve_error_eventually -/ theorem threeForm_sieve_error_eventually : ∀ᶠ x : ℝ in atTop, x ^ (1 / 2 : ℝ) * (1 + Real.log (x ^ (1 / 2 : ℝ))) ^ 9 + (x ^ (1 / 2 : ℝ) + 1) ≤ x / Real.log x ^ 3 := by have hsmall : (fun x : ℝ => Real.log x ^ 12 * x ^ (1 / 2 : ℝ)) =o[atTop] (fun x : ℝ => x) := by simpa only [Real.rpow_one] using log_pow_mul_rpow_littleO 12 (show (1 / 2 : ℝ) < 1 by norm_num) filter_upwards [hsmall.def (show (0 : ℝ) < 1 / 3 by norm_num), Real.tendsto_log_atTop.eventually (eventually_ge_atTop (2 : ℝ)), eventually_gt_atTop (1 : ℝ)] with x hs hxlog hx have hx0 : 0 < x := by linarith have hlog0 : 0 < Real.log x := by linarith have hL0 := Real.rpow_pos_of_pos hx0 (1 / 2 : ℝ) have hL1 := (Real.one_lt_rpow hx (show (0 : ℝ) < 1 / 2 by norm_num)).le have hlogL : Real.log (x ^ (1 / 2 : ℝ)) = (1 / 2 : ℝ) * Real.log x := Real.log_rpow hx0 _ have hpoly : (1 + Real.log (x ^ (1 / 2 : ℝ))) ^ 9 ≤ Real.log x ^ 9 := by rw [hlogL] gcongr linarith have hpow : (1 : ℝ) ≤ Real.log x ^ 9 := one_le_pow₀ (by linarith) have herr : x ^ (1 / 2 : ℝ) * (1 + Real.log (x ^ (1 / 2 : ℝ))) ^ 9 + (x ^ (1 / 2 : ℝ) + 1) ≤ 3 * x ^ (1 / 2 : ℝ) * Real.log x ^ 9 := by have hmul := mul_le_mul_of_nonneg_left hpoly hL0.le have hone := mul_le_mul_of_nonneg_left hpow hL0.le nlinarith simp only [Real.norm_eq_abs, abs_of_nonneg hx0.le, abs_of_nonneg (mul_nonneg (pow_nonneg hlog0.le 12) hL0.le)] at hs apply (le_div_iff₀ (pow_pos hlog0 3)).mpr calc _ ≤ (3 * x ^ (1 / 2 : ℝ) * Real.log x ^ 9) * Real.log x ^ 3 := mul_le_mul_of_nonneg_right herr (pow_nonneg hlog0.le 3) _ = 3 * (Real.log x ^ 12 * x ^ (1 / 2 : ℝ)) := by ring _ ≤ x := by linarith /- Original line 18154: Erdos416Proof.threeFormPrimeTriples_eventually_bound -/ theorem threeFormPrimeTriples_eventually_bound : ∀ᶠ x : ℝ in atTop, ∀ a b : ℕ, 0 < a → a < b → ((threeFormPrimeTriples a b (⌊x⌋₊ + 1)).card : ℝ) ≤ 8193 * ((threeFormDiscriminant a b : ℝ) / (threeFormDiscriminant a b).totient) ^ 3 * x / Real.log x ^ 3 := by filter_upwards [threeForm_sieve_error_eventually, eventually_gt_atTop (2 : ℝ)] with x herr hx intro a b ha hab let D := threeFormDiscriminant a b have hD : 0 < D := threeFormDiscriminant_pos ha hab have hx0 : 0 < x := by linarith have hlog : 0 < Real.log x := Real.log_pos (by linarith) have hL := Real.one_lt_rpow (show 1 < x by linarith) (show (0 : ℝ) < 1 / 2 by norm_num) have hφ : (0 : ℝ) < D.totient := by exact_mod_cast Nat.totient_pos.mpr hD have hDφ : (1 : ℝ) ≤ (D : ℝ) / D.totient := by apply (le_div_iff₀ hφ).mpr simpa only [one_mul] using (show (D.totient : ℝ) ≤ D by exact_mod_cast Nat.totient_le D) have hρ : (1 : ℝ) ≤ ((D : ℝ) / D.totient) ^ 3 := one_le_pow₀ hDφ have hN : ((⌊x⌋₊ + 1 : ℕ) : ℝ) ≤ 2 * x := by push_cast linarith [Nat.floor_le hx0.le] have hmain : 512 * ((D : ℝ) / D.totient) ^ 3 * (⌊x⌋₊ + 1 : ℕ) / Real.log (x ^ (1 / 2 : ℝ)) ^ 3 ≤ 8192 * ((D : ℝ) / D.totient) ^ 3 * x / Real.log x ^ 3 := by calc _ ≤ 512 * ((D : ℝ) / D.totient) ^ 3 * (2 * x) / Real.log (x ^ (1 / 2 : ℝ)) ^ 3 := by gcongr exact pow_nonneg (Real.log_nonneg hL.le) 3 _ = _ := by rw [Real.log_rpow hx0]; field_simp; ring have hbound := threeFormPrimeTriples_bound ha hab (⌊x⌋₊ + 1) hL have hunit : x / Real.log x ^ 3 ≤ ((D : ℝ) / D.totient) ^ 3 * x / Real.log x ^ 3 := by gcongr simpa only [one_mul] using mul_le_mul_of_nonneg_right hρ hx0.le calc _ ≤ 8192 * ((D : ℝ) / D.totient) ^ 3 * x / Real.log x ^ 3 + x / Real.log x ^ 3 := by linarith [hmain, herr, hbound] _ ≤ 8192 * ((D : ℝ) / D.totient) ^ 3 * x / Real.log x ^ 3 + ((D : ℝ) / D.totient) ^ 3 * x / Real.log x ^ 3 := add_le_add le_rfl hunit _ = _ := by ring /-- One absolute constant, valid for all positive distinct ordered coefficients and all real endpoints at least two. No size bound on the coefficients is used. -/ /- Original line 18195: Erdos416Proof.exists_threeFormPrimeTriples_upper_bound -/ theorem exists_threeFormPrimeTriples_upper_bound : ∃ C : ℝ, 0 < C ∧ ∀ (a b : ℕ) (x : ℝ), 0 < a → a < b → 2 ≤ x → ((threeFormPrimeTriples a b (⌊x⌋₊ + 1)).card : ℝ) ≤ C * ((threeFormDiscriminant a b : ℝ) / (threeFormDiscriminant a b).totient) ^ 3 * x / Real.log x ^ 3 := by obtain ⟨X₀, hX₀⟩ := eventually_atTop.mp threeFormPrimeTriples_eventually_bound let X := max 2 X₀ let C := 8193 + 2 * Real.log X ^ 3 have hX : (2 : ℝ) ≤ X := le_max_left _ _ have hlogX0 : 0 ≤ Real.log X := Real.log_nonneg (by linarith) have hC8193 : (8193 : ℝ) ≤ C := by dsimp [C]; linarith [pow_nonneg hlogX0 3] have hC : 0 < C := lt_of_lt_of_le (by norm_num) hC8193 refine ⟨C, hC, ?_⟩ intro a b x ha hab hx let D := threeFormDiscriminant a b have hD : 0 < D := threeFormDiscriminant_pos ha hab have hx0 : 0 < x := by linarith have hlog : 0 < Real.log x := Real.log_pos (by linarith) have hφ : (0 : ℝ) < D.totient := by exact_mod_cast Nat.totient_pos.mpr hD have hDφ : (1 : ℝ) ≤ (D : ℝ) / D.totient := by apply (le_div_iff₀ hφ).mpr simpa only [one_mul] using (show (D.totient : ℝ) ≤ D by exact_mod_cast Nat.totient_le D) have hρ : (1 : ℝ) ≤ ((D : ℝ) / D.totient) ^ 3 := one_le_pow₀ hDφ by_cases hxX : X ≤ x · exact (hX₀ x ((le_max_right _ _).trans hxX) a b ha hab).trans (by gcongr) have hlogX : Real.log x ≤ Real.log X := Real.log_le_log hx0 (le_of_not_ge hxX) have hlogXcube : Real.log x ^ 3 ≤ Real.log X ^ 3 := by gcongr have hcoef : 2 * Real.log x ^ 3 ≤ C * ((D : ℝ) / D.totient) ^ 3 := by have hCα : C ≤ C * ((D : ℝ) / D.totient) ^ 3 := by simpa only [mul_one] using mul_le_mul_of_nonneg_left hρ hC.le dsimp [C] at hCα ⊢ linarith have hcard : ((threeFormPrimeTriples a b (⌊x⌋₊ + 1)).card : ℝ) ≤ (⌊x⌋₊ + 1 : ℕ) := by exact_mod_cast (Finset.card_filter_le (Finset.range (⌊x⌋₊ + 1)) (fun n => n.Prime ∧ (a*n+1).Prime ∧ (b*n+1).Prime)).trans_eq (Finset.card_range _) calc _ ≤ 2 * x := hcard.trans (by push_cast; linarith [Nat.floor_le hx0.le]) _ ≤ _ := by apply (le_div_iff₀ (pow_pos hlog 3)).mpr nlinarith [mul_le_mul_of_nonneg_right hcoef hx0.le] /- Original line 18236: Erdos416Proof.exists_threeFormPrimeSet_upper_bound -/ theorem exists_threeFormPrimeSet_upper_bound : ∃ C : ℝ, 0 < C ∧ ∀ (a b : ℕ) (x : ℝ) (F : Finset ℕ), 0 < a → a < b → 2 ≤ x → (∀ q ∈ F, q.Prime ∧ (a*q+1).Prime ∧ (b*q+1).Prime ∧ (q : ℝ) ≤ x) → (F.card : ℝ) ≤ C * ((threeFormDiscriminant a b : ℝ) / (threeFormDiscriminant a b).totient) ^ 3 * x / Real.log x ^ 3 := by obtain ⟨C, hC, hcount⟩ := exists_threeFormPrimeTriples_upper_bound refine ⟨C, hC, ?_⟩ intro a b x F ha hab hx hF have hsub : F ⊆ threeFormPrimeTriples a b (⌊x⌋₊+1) := by intro q hq obtain ⟨hqprime, haqprime, hbqprime, hqx⟩ := hF q hq exact Finset.mem_filter.mpr ⟨Finset.mem_range.mpr (Nat.lt_succ_of_le (Nat.le_floor hqx)), hqprime, haqprime, hbqprime⟩ exact (Nat.cast_le.mpr (Finset.card_le_card hsub)).trans (hcount a b x ha hab hx) /- Original line 18252: Erdos416Proof.exists_threeFormPrimeSet_upper_bound_unordered -/ theorem exists_threeFormPrimeSet_upper_bound_unordered : ∃ C : ℝ, 0 < C ∧ ∀ (a b : ℕ) (x : ℝ) (F : Finset ℕ), 0 < a → 0 < b → a ≠ b → 2 ≤ x → (∀ q ∈ F, q.Prime ∧ (a*q+1).Prime ∧ (b*q+1).Prime ∧ (q : ℝ) ≤ x) → (F.card : ℝ) ≤ C * ((threeFormDiscriminant (min a b) (max a b) : ℝ) / (threeFormDiscriminant (min a b) (max a b)).totient) ^ 3 * x / Real.log x ^ 3 := by obtain ⟨C, hC, hcount⟩ := exists_threeFormPrimeSet_upper_bound refine ⟨C, hC, ?_⟩ intro a b x F ha hb hab hx hF rcases lt_or_gt_of_ne hab with hlt | hgt · simpa only [min_eq_left hlt.le, max_eq_right hlt.le] using hcount a b x F ha hlt hx hF · have hF' : ∀ q ∈ F, q.Prime ∧ (b*q+1).Prime ∧ (a*q+1).Prime ∧ (q : ℝ) ≤ x := by intro q hq obtain ⟨hq, haq, hbq, hqx⟩ := hF q hq exact ⟨hq, hbq, haq, hqx⟩ simpa only [min_eq_right hgt.le, max_eq_left hgt.le] using hcount b a x F hb hgt hx hF' /-- The inverse-totient ratio estimate is uniform over every positive integer below the scale, including the bounded initial range. -/ /- Original line 18271: Erdos416Proof.totient_ratio_uniform_up_to -/ theorem totient_ratio_uniform_up_to : ∃ C : ℝ, 0 < C ∧ ∀ᶠ Y : ℝ in atTop, ∀ n : ℕ, 0 < n → (n : ℝ) ≤ Y → (n : ℝ) / n.totient ≤ C * logLog Y := by obtain ⟨C₀, hC₀, hlarge⟩ := totient_ratio_logLog_bound_eventually obtain ⟨N₀, hN₀⟩ := eventually_atTop.mp hlarge let N := max 3 N₀ let C := C₀ + (N : ℝ) + 1 have hC : 0 < C := by dsimp [Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, C]; positivity have hC₀C : C₀ ≤ C := by dsimp [Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, C]; linarith [Nat.cast_nonneg (α := ℝ) N] have hNC : (N : ℝ) ≤ C := by dsimp [Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, C]; linarith refine ⟨C, hC, ?_⟩ have hT : ∀ᶠ Y : ℝ in atTop, 1 ≤ logLog Y := (Real.tendsto_log_atTop.comp Real.tendsto_log_atTop).eventually (eventually_ge_atTop 1) filter_upwards [hT] with Y hY intro n hn hnY by_cases hNn : N ≤ n · have hn3 : 3 ≤ n := (le_max_left _ _).trans hNn have hbound := hN₀ n ((le_max_right _ _).trans hNn) have hmono := logLog_mono (x := (n : ℝ)) (y := Y) (by exact_mod_cast (show 1 < n by omega)) hnY change (n : ℝ) / n.totient ≤ C₀ * logLog (n : ℝ) at hbound exact hbound.trans ((mul_le_mul_of_nonneg_left hmono hC₀.le).trans (mul_le_mul_of_nonneg_right hC₀C (by linarith))) · have hφ : (0 : ℝ) < n.totient := by exact_mod_cast Nat.totient_pos.mpr hn have hφ1 : (1 : ℝ) ≤ n.totient := by exact_mod_cast Nat.totient_pos.mpr hn calc _ ≤ (n : ℝ) := (div_le_iff₀ hφ).mpr (le_mul_of_one_le_right (by positivity) hφ1) _ ≤ (N : ℝ) := by exact_mod_cast (Nat.le_of_lt (lt_of_not_ge hNn)) _ ≤ C := hNC _ ≤ C * logLog Y := le_mul_of_one_le_right hC.le hY /-- The form of the three-prime estimate used when all discriminants are bounded by one external scale Y. The endpoint x remains independent of Y. -/ /- Original line 18303: Erdos416Proof.exists_threeFormPrimeSet_bound_of_discriminant_le -/ theorem exists_threeFormPrimeSet_bound_of_discriminant_le : ∃ C : ℝ, 0 < C ∧ ∀ᶠ Y : ℝ in atTop, ∀ (a b : ℕ) (x : ℝ) (F : Finset ℕ), 0 < a → a < b → 2 ≤ x → (threeFormDiscriminant a b : ℝ) ≤ Y → (∀ q ∈ F, q.Prime ∧ (a*q+1).Prime ∧ (b*q+1).Prime ∧ (q : ℝ) ≤ x) → (F.card : ℝ) ≤ C * logLog Y ^ 3 * x / Real.log x ^ 3 := by obtain ⟨K, hK, hcount⟩ := exists_threeFormPrimeSet_upper_bound obtain ⟨R, hR, hratio⟩ := totient_ratio_uniform_up_to refine ⟨K * R ^ 3, by positivity, ?_⟩ filter_upwards [hratio] with Y hY intro a b x F ha hab hx hDY hF have hD := threeFormDiscriminant_pos ha hab have hρ := hY (threeFormDiscriminant a b) hD hDY have hx0 : 0 < x := by linarith have hlog : 0 < Real.log x := Real.log_pos (by linarith) calc _ ≤ K * ((threeFormDiscriminant a b : ℝ) / (threeFormDiscriminant a b).totient) ^ 3 * x / Real.log x ^ 3 := hcount a b x F ha hab hx hF _ ≤ K * (R * logLog Y) ^ 3 * x / Real.log x ^ 3 := by gcongr _ = _ := by ring end Erdos416Proof /- Reciprocal prime and rough-cofactor sums, followed by actual ordered factorization counts and squarefree interval allocation weights. These are inputs to the multivariable sieve proved later in this file. -/ open Filter Asymptotics MeasureTheory open scoped BigOperators Classical Topology namespace Erdos416Proof /-- Abel summation for an actual finite set with a variable lower endpoint. Members equal to u are retained; no endpoint count is discarded. -/ /- Original line 18342: Erdos416Proof.finite_reciprocal_abel_lower -/ theorem finite_reciprocal_abel_lower (Q : Finset ℕ) {u z : ℝ} (hu : 2 ≤ u) (huz : u ≤ z) (hQ : ∀ q ∈ Q, u ≤ (q : ℝ) ∧ (q : ℝ) ≤ z) : IntervalIntegrable (fun t : ℝ => finiteCountBelow Q t / t ^ 2) volume u z ∧ (∑ q ∈ Q, (1 : ℝ) / q) = finiteCountBelow Q z / z + ∫ t : ℝ in u..z, finiteCountBelow Q t / t ^ 2 := by have hz : 2 ≤ z := hu.trans huz obtain ⟨hI, hAbel⟩ := finite_reciprocal_abel Q hz (by intro q hq exact ⟨by exact_mod_cast hu.trans (hQ q hq).1, (hQ q hq).2⟩) have hIcc := (intervalIntegrable_iff_integrableOn_Icc_of_le hz).mp hI have hLeft : IntervalIntegrable (fun t : ℝ => finiteCountBelow Q t / t ^ 2) volume 2 u := (intervalIntegrable_iff_integrableOn_Icc_of_le hu).mpr (hIcc.mono_set (Set.Icc_subset_Icc_right huz)) have hRight : IntervalIntegrable (fun t : ℝ => finiteCountBelow Q t / t ^ 2) volume u z := (intervalIntegrable_iff_integrableOn_Icc_of_le huz).mpr (hIcc.mono_set (Set.Icc_subset_Icc_left hu)) have hzero : (∫ t : ℝ in (2 : ℝ)..u, finiteCountBelow Q t / t ^ 2) = 0 := by calc _ = ∫ _t : ℝ in (2 : ℝ)..u, (0 : ℝ) := by apply intervalIntegral.integral_congr_Ioo_of_le hu intro t ht have hempty : Q.filter (fun q : ℕ => (q : ℝ) ≤ t) = ∅ := by apply Finset.filter_eq_empty_iff.mpr intro q hq hqt exact (not_lt_of_ge ((hQ q hq).1.trans hqt)) ht.2 simp only [finiteCountBelow, hempty, Finset.card_empty, Nat.cast_zero, zero_div] _ = 0 := by simp have hsplit := intervalIntegral.integral_add_adjacent_intervals hLeft hRight rw [hzero, zero_add] at hsplit exact ⟨hRight, hAbel.trans (by rw [hsplit])⟩ /- Original line 18373: Erdos416Proof.integral_inv_div_log_cube -/ theorem integral_inv_div_log_cube {u z : ℝ} (hu : 1 < u) (huz : u ≤ z) : (∫ t : ℝ in u..z, t⁻¹ / Real.log t ^ 3) = (1 : ℝ) / (2 * Real.log u ^ 2) - 1 / (2 * Real.log z ^ 2) := by have hlog (t : ℝ) (ht : t ∈ Set.Icc u z) : 0 < Real.log t := Real.log_pos (hu.trans_le ht.1) have ht0 (t : ℝ) (ht : t ∈ Set.Icc u z) : t ≠ 0 := by linarith [ht.1] have hcont : ContinuousOn (fun t : ℝ => t⁻¹ / Real.log t ^ 3) (Set.Icc u z) := (continuousOn_id.inv₀ ht0).div ((continuousOn_id.log ht0).pow 3) (fun t ht => pow_ne_zero 3 (hlog t ht).ne') have hderiv : ∀ t ∈ Set.Icc u z, HasDerivAt (fun t : ℝ => -(1 / 2 : ℝ) * (Real.log t ^ 2)⁻¹) (t⁻¹ / Real.log t ^ 3) t := by intro t ht have h := (((Real.hasDerivAt_log (ht0 t ht)).pow 2).inv (pow_ne_zero 2 (hlog t ht).ne')).const_mul (-(1 / 2 : ℝ)) have htne := ht0 t ht have hlne := (hlog t ht).ne' convert h using 1 <;> first | rfl | (simp only [Pi.pow_apply]; field_simp; ring) have hInt : IntervalIntegrable (fun t : ℝ => t⁻¹ / Real.log t ^ 3) volume u z := (intervalIntegrable_iff_integrableOn_Icc_of_le huz).mpr hcont.integrableOn_Icc have h := intervalIntegral.integral_eq_sub_of_hasDerivAt (by intro t ht exact hderiv t (by simpa only [Set.uIcc_of_le huz] using ht)) hInt rw [h] ring /-- Density with a power of log, together with its elementary integral bound, controls the actual reciprocal sum above u. -/ /- Original line 18401: Erdos416Proof.finite_reciprocal_tail_of_log_power -/ theorem finite_reciprocal_tail_of_log_power (Q : Finset ℕ) {u z D : ℝ} {k : ℕ} (hu : Real.exp 1 ≤ u) (huz : u ≤ z) (hD : 0 ≤ D) (hk : 1 ≤ k) (hQ : ∀ q ∈ Q, u ≤ (q : ℝ) ∧ (q : ℝ) ≤ z) (hdensity : ∀ t : ℝ, u ≤ t → t ≤ z → finiteCountBelow Q t ≤ D * t / Real.log t ^ k) (hintegral : (∫ t : ℝ in u..z, t⁻¹ / Real.log t ^ k) ≤ 1 / Real.log u ^ (k-1)) : (∑ q ∈ Q, (1 : ℝ) / q) ≤ 2 * D / Real.log u ^ (k-1) := by have he2 : (2 : ℝ) ≤ Real.exp 1 := by linarith [Real.add_one_le_exp (1 : ℝ)] have hu2 : 2 ≤ u := he2.trans hu have hu1 : 1 < u := by linarith have hz0 : 0 < z := by linarith have hlu : 1 ≤ Real.log u := by simpa only [Real.log_exp] using Real.log_le_log (Real.exp_pos 1) hu have hlz : 0 < Real.log z := Real.log_pos (hu1.trans_le huz) have hlogmono : Real.log u ≤ Real.log z := Real.log_le_log (by linarith) huz obtain ⟨hI, hAbel⟩ := finite_reciprocal_abel_lower Q hu2 huz hQ have ht0 (t : ℝ) (ht : t ∈ Set.Icc u z) : t ≠ 0 := by linarith [ht.1] have hlog (t : ℝ) (ht : t ∈ Set.Icc u z) : 0 < Real.log t := Real.log_pos (hu1.trans_le ht.1) have hcont : ContinuousOn (fun t : ℝ => D * (t⁻¹ / Real.log t ^ k)) (Set.Icc u z) := continuousOn_const.mul ((continuousOn_id.inv₀ ht0).div ((continuousOn_id.log ht0).pow k) (fun t ht => pow_ne_zero k (hlog t ht).ne')) have hJ : IntervalIntegrable (fun t : ℝ => D * (t⁻¹ / Real.log t ^ k)) volume u z := (intervalIntegrable_iff_integrableOn_Icc_of_le huz).mpr hcont.integrableOn_Icc have hIntegral := intervalIntegral.integral_mono_on huz hI hJ (fun t ht => by calc finiteCountBelow Q t / t ^ 2 ≤ (D * t / Real.log t ^ k) / t ^ 2 := div_le_div_of_nonneg_right (hdensity t ht.1 ht.2) (sq_nonneg _) _ = D * (t⁻¹ / Real.log t ^ k) := by field_simp) rw [intervalIntegral.integral_const_mul] at hIntegral have hIntegralBound : (∫ t : ℝ in u..z, finiteCountBelow Q t / t ^ 2) ≤ D / Real.log u ^ (k-1) := hIntegral.trans (by simpa only [mul_one_div] using mul_le_mul_of_nonneg_left hintegral hD) have hpow : Real.log u ^ (k-1) ≤ Real.log u ^ k := by calc _ ≤ Real.log u ^ (k-1) * Real.log u := le_mul_of_one_le_right (by positivity) hlu _ = _ := by rw [← pow_succ, Nat.sub_add_cancel hk] have hend : finiteCountBelow Q z / z ≤ D / Real.log u ^ (k-1) := by calc _ ≤ (D * z / Real.log z ^ k) / z := div_le_div_of_nonneg_right (hdensity z huz le_rfl) hz0.le _ = D / Real.log z ^ k := by field_simp _ ≤ D / Real.log u ^ k := div_le_div_of_nonneg_left hD (by positivity) (pow_le_pow_left₀ (by linarith) hlogmono k) _ ≤ _ := div_le_div_of_nonneg_left hD (by positivity) hpow rw [hAbel] calc _ ≤ D / Real.log u ^ (k-1) + D / Real.log u ^ (k-1) := add_le_add hend hIntegralBound _ = _ := by ring /- Original line 18450: Erdos416Proof.finite_reciprocal_tail_log_sq -/ theorem finite_reciprocal_tail_log_sq (Q : Finset ℕ) {u z D : ℝ} (hu : Real.exp 1 ≤ u) (huz : u ≤ z) (hD : 0 ≤ D) (hQ : ∀ q ∈ Q, u ≤ (q : ℝ) ∧ (q : ℝ) ≤ z) (hdensity : ∀ t : ℝ, u ≤ t → t ≤ z → finiteCountBelow Q t ≤ D * t / Real.log t ^ 2) : (∑ q ∈ Q, (1 : ℝ) / q) ≤ 2 * D / Real.log u := by have hu1 : 1 < u := (Real.one_lt_exp_iff.mpr (by norm_num : (0 : ℝ) < 1)).trans_le hu have h := finite_reciprocal_tail_of_log_power Q hu huz hD (by norm_num : 1 ≤ (2 : ℕ)) hQ hdensity (by rw [integral_inv_div_log_sq hu1 (hu1.trans_le huz)] simp only [Nat.reduceSub, pow_one, one_div] exact sub_le_self _ (inv_nonneg.mpr (Real.log_pos (hu1.trans_le huz)).le)) simpa only [Nat.reduceSub, pow_one] using h /- Original line 18462: Erdos416Proof.finite_reciprocal_tail_log_cube -/ theorem finite_reciprocal_tail_log_cube (Q : Finset ℕ) {u z D : ℝ} (hu : Real.exp 1 ≤ u) (huz : u ≤ z) (hD : 0 ≤ D) (hQ : ∀ q ∈ Q, u ≤ (q : ℝ) ∧ (q : ℝ) ≤ z) (hdensity : ∀ t : ℝ, u ≤ t → t ≤ z → finiteCountBelow Q t ≤ D * t / Real.log t ^ 3) : (∑ q ∈ Q, (1 : ℝ) / q) ≤ 2 * D / Real.log u ^ 2 := by have hu1 : 1 < u := (Real.one_lt_exp_iff.mpr (by norm_num : (0 : ℝ) < 1)).trans_le hu have hlu : 0 < Real.log u := Real.log_pos hu1 have h := finite_reciprocal_tail_of_log_power Q hu huz hD (by norm_num : 1 ≤ (3 : ℕ)) hQ hdensity (by rw [integral_inv_div_log_cube hu1 huz] norm_num only have hfirst : (1 : ℝ) / (2 * Real.log u ^ 2) ≤ 1 / Real.log u ^ 2 := by apply div_le_div_of_nonneg_left (by norm_num) (by positivity) nlinarith [sq_nonneg (Real.log u)] exact (sub_le_self _ (by positivity)).trans hfirst) simpa only [Nat.reduceSub] using h /- Original line 18478: Erdos416Proof.exists_twoForm_reciprocal_tail_bound -/ theorem exists_twoForm_reciprocal_tail_bound : ∃ C : ℝ, 0 < C ∧ ∀ (b : ℕ) (u z : ℝ) (Q : Finset ℕ), 0 < b → Real.exp 1 ≤ u → u ≤ z → (∀ q ∈ Q, q.Prime ∧ (b*q+1).Prime ∧ u ≤ (q : ℝ) ∧ (q : ℝ) ≤ z) → (∑ q ∈ Q, (1 : ℝ) / q) ≤ C * ((b : ℝ) / b.totient) / Real.log u := by obtain ⟨K, hK, hcount⟩ := exists_twoFormPrimeSet_upper_bound refine ⟨2*K, by positivity, ?_⟩ intro b u z Q hb hu huz hQ have hu2 : 2 ≤ u := by linarith [Real.add_one_le_exp (1 : ℝ)] have h := finite_reciprocal_tail_log_sq Q hu huz (show 0 ≤ K*((b : ℝ)/b.totient) by positivity) (fun q hq => (hQ q hq).2.2) (by intro t hut _ exact hcount b t (Q.filter (fun q : ℕ => (q : ℝ) ≤ t)) hb (hu2.trans hut) (by intro q hq obtain ⟨hqQ, hqt⟩ := Finset.mem_filter.mp hq exact ⟨(hQ q hqQ).1, (hQ q hqQ).2.1, hqt⟩)) convert h using 1 <;> ring /- Original line 18496: Erdos416Proof.exists_threeForm_reciprocal_tail_bound -/ theorem exists_threeForm_reciprocal_tail_bound : ∃ C : ℝ, 0 < C ∧ ∀ (a b : ℕ) (u z : ℝ) (Q : Finset ℕ), 0 < a → a < b → Real.exp 1 ≤ u → u ≤ z → (∀ q ∈ Q, q.Prime ∧ (a*q+1).Prime ∧ (b*q+1).Prime ∧ u ≤ (q : ℝ) ∧ (q : ℝ) ≤ z) → (∑ q ∈ Q, (1 : ℝ) / q) ≤ C * ((threeFormDiscriminant a b : ℝ) / (threeFormDiscriminant a b).totient) ^ 3 / Real.log u ^ 2 := by obtain ⟨K, hK, hcount⟩ := exists_threeFormPrimeSet_upper_bound refine ⟨2*K, by positivity, ?_⟩ intro a b u z Q ha hab hu huz hQ have hu2 : 2 ≤ u := by linarith [Real.add_one_le_exp (1 : ℝ)] have h := finite_reciprocal_tail_log_cube Q hu huz (show 0 ≤ K*((threeFormDiscriminant a b : ℝ)/(threeFormDiscriminant a b).totient)^3 by positivity) (fun q hq => (hQ q hq).2.2.2) (by intro t hut _ exact hcount a b t (Q.filter (fun q : ℕ => (q : ℝ) ≤ t)) ha hab (hu2.trans hut) (by intro q hq obtain ⟨hqQ, hqt⟩ := Finset.mem_filter.mp hq exact ⟨(hQ q hqQ).1, (hQ q hqQ).2.1, (hQ q hqQ).2.2.1, hqt⟩)) convert h using 1 <;> ring /- Original line 18516: Erdos416Proof.logLog_six_mul_cube_eventually -/ theorem logLog_six_mul_cube_eventually : ∀ᶠ Y : ℝ in atTop, Y ≤ 6*Y^3 ∧ logLog (6*Y^3) ≤ 2*logLog Y := by filter_upwards [eventually_ge_atTop (2 : ℝ), Real.tendsto_log_atTop.eventually (eventually_ge_atTop (Real.log 6)), (Real.tendsto_log_atTop.comp Real.tendsto_log_atTop).eventually (eventually_ge_atTop (Real.log 4))] with Y hY hlog hLL change Real.log 4 ≤ Real.log (Real.log Y) at hLL have hY0 : 0 < Y := by linarith have hY3 : Y ≤ Y^3 := by have hs : (1 : ℝ) ≤ Y^2 := one_le_pow₀ (by linarith) nlinarith [mul_le_mul_of_nonneg_left hs hY0.le] refine ⟨by nlinarith [pow_nonneg hY0.le 3], ?_⟩ have hlog0 : 0 < Real.log Y := Real.log_pos (by linarith) have hlogbound : Real.log (6*Y^3) ≤ 4*Real.log Y := by rw [Real.log_mul (by norm_num : (6 : ℝ) ≠ 0) (pow_ne_zero 3 hY0.ne'), Real.log_pow] norm_num linarith have hlog6 : 0 < Real.log (6*Y^3) := Real.log_pos (by nlinarith) change Real.log (Real.log (6*Y^3)) ≤ 2*Real.log (Real.log Y) calc _ ≤ Real.log (4*Real.log Y) := Real.log_le_log hlog6 hlogbound _ = Real.log 4 + Real.log (Real.log Y) := Real.log_mul (by norm_num) hlog0.ne' _ ≤ _ := by linarith /- Original line 18541: Erdos416Proof.threeFormDiscriminant_le_cube -/ theorem threeFormDiscriminant_le_cube {a b : ℕ} {Y : ℝ} (ha : 0 < a) (hab : a < b) (hbY : (b : ℝ) ≤ Y) : (threeFormDiscriminant a b : ℝ) ≤ 6*Y^3 := by have haY : (a : ℝ) ≤ Y := (Nat.cast_le.mpr hab.le).trans hbY have hdiff : ((b-a : ℕ) : ℝ) ≤ Y := (Nat.cast_le.mpr (Nat.sub_le b a)).trans hbY have hY0 : 0 ≤ Y := (Nat.cast_nonneg b).trans hbY unfold threeFormDiscriminant push_cast calc 6 * (a : ℝ) * b * ((b-a : ℕ) : ℝ) ≤ 6 * Y * Y * Y := by gcongr _ = _ := by ring /- Original line 18553: Erdos416Proof.exists_threeFormPrimeSet_bound_of_coefficients_le -/ theorem exists_threeFormPrimeSet_bound_of_coefficients_le : ∃ C : ℝ, 0 < C ∧ ∀ᶠ Y : ℝ in atTop, ∀ (a b : ℕ) (x : ℝ) (Q : Finset ℕ), 0 < a → a < b → (b : ℝ) ≤ Y → 2 ≤ x → (∀ q ∈ Q, q.Prime ∧ (a*q+1).Prime ∧ (b*q+1).Prime ∧ (q : ℝ) ≤ x) → (Q.card : ℝ) ≤ C * logLog Y ^ 3 * x / Real.log x ^ 3 := by obtain ⟨K, hK, hbound⟩ := exists_threeFormPrimeSet_bound_of_discriminant_le obtain ⟨Y₀, hY₀⟩ := eventually_atTop.mp hbound refine ⟨8*K, by positivity, ?_⟩ filter_upwards [eventually_ge_atTop Y₀, logLog_six_mul_cube_eventually] with Y hY hlog intro a b x Q ha hab hbY hx hQ have hx0 : 0 < x := by linarith have hlogx : 0 < Real.log x := Real.log_pos (by linarith) have hD := threeFormDiscriminant_le_cube ha hab hbY have h := hY₀ (6*Y^3) (hY.trans hlog.1) a b x Q ha hab hx hD hQ have hYlarge : 3 ≤ 6*Y^3 := by have hb2 : 2 ≤ b := by omega have hY2 : (2 : ℝ) ≤ Y := (Nat.cast_le.mpr hb2).trans hbY have hs : (1 : ℝ) ≤ Y^2 := one_le_pow₀ (by linarith) nlinarith [mul_le_mul_of_nonneg_left hs (by linarith : 0 ≤ Y)] have hLL0 : 0 ≤ logLog (6*Y^3) := (logLog_pos_of_three_le hYlarge).le calc _ ≤ K * logLog (6*Y^3) ^ 3 * x / Real.log x ^ 3 := h _ ≤ K * (2*logLog Y) ^ 3 * x / Real.log x ^ 3 := by gcongr; exact hlog.2 _ = _ := by ring /- Original line 18578: Erdos416Proof.exists_twoFormPrimeSet_bound_of_coefficient_le -/ theorem exists_twoFormPrimeSet_bound_of_coefficient_le : ∃ C : ℝ, 0 < C ∧ ∀ᶠ Y : ℝ in atTop, ∀ (b : ℕ) (x : ℝ) (Q : Finset ℕ), 0 < b → (b : ℝ) ≤ Y → 2 ≤ x → (∀ q ∈ Q, q.Prime ∧ (b*q+1).Prime ∧ (q : ℝ) ≤ x) → (Q.card : ℝ) ≤ C * logLog Y * x / Real.log x ^ 2 := by obtain ⟨K, hK, hcount⟩ := exists_twoFormPrimeSet_upper_bound obtain ⟨R, hR, hratio⟩ := totient_ratio_uniform_up_to refine ⟨K*R, by positivity, ?_⟩ filter_upwards [hratio] with Y hY intro b x Q hb hbY hx hQ have hx0 : 0 < x := by linarith calc _ ≤ K*((b : ℝ)/b.totient)*x/Real.log x^2 := hcount b x Q hb hx hQ _ ≤ K*(R*logLog Y)*x/Real.log x^2 := by gcongr; exact hY b hb hbY _ = _ := by ring /- Original line 18594: Erdos416Proof.exists_threeForm_reciprocal_tail_bound_of_coefficients_le -/ theorem exists_threeForm_reciprocal_tail_bound_of_coefficients_le : ∃ C : ℝ, 0 < C ∧ ∀ᶠ Y : ℝ in atTop, ∀ (a b : ℕ) (u z : ℝ) (Q : Finset ℕ), 0 < a → a < b → (b : ℝ) ≤ Y → Real.exp 1 ≤ u → u ≤ z → (∀ q ∈ Q, q.Prime ∧ (a*q+1).Prime ∧ (b*q+1).Prime ∧ u ≤ (q : ℝ) ∧ (q : ℝ) ≤ z) → (∑ q ∈ Q, (1 : ℝ)/q) ≤ C * logLog Y^3 / Real.log u^2 := by obtain ⟨K, hK, hcount⟩ := exists_threeFormPrimeSet_bound_of_coefficients_le refine ⟨2*K, by positivity, ?_⟩ filter_upwards [hcount, eventually_ge_atTop (3 : ℝ)] with Y hY hY3 intro a b u z Q ha hab hbY hu huz hQ have hu2 : 2 ≤ u := by linarith [Real.add_one_le_exp (1 : ℝ)] have hLL : 0 ≤ logLog Y := (logLog_pos_of_three_le hY3).le have h := finite_reciprocal_tail_log_cube Q hu huz (show 0 ≤ K*logLog Y^3 by positivity) (fun q hq => (hQ q hq).2.2.2) (by intro t hut _ exact hY a b t (Q.filter (fun q : ℕ => (q : ℝ) ≤ t)) ha hab hbY (hu2.trans hut) (by intro q hq obtain ⟨hqQ, hqt⟩ := Finset.mem_filter.mp hq exact ⟨(hQ q hqQ).1, (hQ q hqQ).2.1, (hQ q hqQ).2.2.1, hqt⟩)) convert h using 1 <;> ring /- Original line 18614: Erdos416Proof.exists_twoForm_reciprocal_tail_bound_of_coefficient_le -/ theorem exists_twoForm_reciprocal_tail_bound_of_coefficient_le : ∃ C : ℝ, 0 < C ∧ ∀ᶠ Y : ℝ in atTop, ∀ (b : ℕ) (u z : ℝ) (Q : Finset ℕ), 0 < b → (b : ℝ) ≤ Y → Real.exp 1 ≤ u → u ≤ z → (∀ q ∈ Q, q.Prime ∧ (b*q+1).Prime ∧ u ≤ (q : ℝ) ∧ (q : ℝ) ≤ z) → (∑ q ∈ Q, (1 : ℝ)/q) ≤ C * logLog Y / Real.log u := by obtain ⟨K, hK, hcount⟩ := exists_twoFormPrimeSet_bound_of_coefficient_le refine ⟨2*K, by positivity, ?_⟩ filter_upwards [hcount, eventually_ge_atTop (3 : ℝ)] with Y hY hY3 intro b u z Q hb hbY hu huz hQ have hu2 : 2 ≤ u := by linarith [Real.add_one_le_exp (1 : ℝ)] have hLL : 0 ≤ logLog Y := (logLog_pos_of_three_le hY3).le have h := finite_reciprocal_tail_log_sq Q hu huz (show 0 ≤ K*logLog Y by positivity) (fun q hq => (hQ q hq).2.2) (by intro t hut _ exact hY b t (Q.filter (fun q : ℕ => (q : ℝ) ≤ t)) hb hbY (hu2.trans hut) (by intro q hq obtain ⟨hqQ, hqt⟩ := Finset.mem_filter.mp hq exact ⟨(hQ q hqQ).1, (hQ q hqQ).2.1, hqt⟩)) convert h using 1 <;> ring /-- Positivity is uniform even at endpoints containing no primes. -/ /- Original line 18635: Erdos416Proof.prime_euler_product_pos -/ theorem prime_euler_product_pos (x : ℝ) : 0 < ∏ p ∈ Nat.primesLE ⌊x⌋₊, (1 - (1 : ℝ) / p) := by apply Finset.prod_pos intro p hp have hp1 : (1 : ℝ) < p := by exact_mod_cast (Nat.prime_of_mem_primesLE hp).one_lt exact sub_pos.mpr ((div_lt_one (by linarith : (0 : ℝ) < p)).mpr hp1) /- Original line 18642: Erdos416Proof.prime_totient_product_eq_inv -/ theorem prime_totient_product_eq_inv (x : ℝ) : (∏ p ∈ Nat.primesLE ⌊x⌋₊, totientFactor p) = (∏ p ∈ Nat.primesLE ⌊x⌋₊, (1 - (1 : ℝ) / p))⁻¹ := by rw [← Finset.prod_inv_distrib] exact Finset.prod_congr rfl fun p hp => totientFactor_eq_inv (Nat.prime_of_mem_primesLE hp) /- Original line 18648: Erdos416Proof.exists_prime_euler_product_upper_bound -/ theorem exists_prime_euler_product_upper_bound : ∃ C : ℝ, 0 < C ∧ ∀ᶠ x : ℝ in atTop, (∏ p ∈ Nat.primesLE ⌊x⌋₊, (1 - (1 : ℝ) / p)) ≤ C / Real.log x := by obtain ⟨B, hB, hbound⟩ := prime_euler_product_asymptotic.isBigO.exists_pos refine ⟨B * Real.exp (-Real.eulerMascheroniConstant), by positivity, ?_⟩ filter_upwards [hbound.bound, eventually_gt_atTop (1 : ℝ)] with x h hx change ‖(∏ p ∈ Nat.primesLE ⌊x⌋₊, (1 - (1 : ℝ) / p))‖ ≤ B * ‖Real.exp (-Real.eulerMascheroniConstant) / Real.log x‖ at h rw [Real.norm_eq_abs, abs_of_pos (prime_euler_product_pos x), Real.norm_eq_abs, abs_of_pos (div_pos (Real.exp_pos _) (Real.log_pos hx))] at h simpa only [mul_div_assoc] using h /-- Splitting at the real endpoint retains the exact open lower interval. -/ /- Original line 18661: Erdos416Proof.prime_interval_totient_product -/ theorem prime_interval_totient_product {v Y : ℝ} (hv : 0 ≤ v) (hvY : v ≤ Y) : (∏ p ∈ (Nat.primesLE ⌊Y⌋₊).filter (fun p : ℕ => v < (p : ℝ)), totientFactor p) = (∏ p ∈ Nat.primesLE ⌊v⌋₊, (1 - (1 : ℝ) / p)) * ∏ p ∈ Nat.primesLE ⌊Y⌋₊, totientFactor p := by have hsmall : (Nat.primesLE ⌊Y⌋₊).filter (fun p : ℕ => (p : ℝ) ≤ v) = Nat.primesLE ⌊v⌋₊ := by ext p simp only [Finset.mem_filter, Nat.mem_primesLE] constructor · rintro ⟨⟨_, hp⟩, hpv⟩ exact ⟨Nat.le_floor hpv, hp⟩ · rintro ⟨hpv, hp⟩ have hpvR : (p : ℝ) ≤ v := (Nat.cast_le.mpr hpv).trans (Nat.floor_le hv) exact ⟨⟨Nat.le_floor (hpvR.trans hvY), hp⟩, hpvR⟩ have hsplit := Finset.prod_filter_mul_prod_filter_not (Nat.primesLE ⌊Y⌋₊) (fun p : ℕ => (p : ℝ) ≤ v) totientFactor rw [hsmall, prime_totient_product_eq_inv v] at hsplit simp only [not_le] at hsplit rw [← hsplit, ← mul_assoc, mul_inv_cancel₀ (prime_euler_product_pos v).ne', one_mul] /-- The finite reciprocal sum over any family supported on a fixed prime set is bounded by its convergent Euler product. Multiplicities are unrestricted. -/ /- Original line 18683: Erdos416Proof.finite_reciprocal_prime_support_bound -/ theorem finite_reciprocal_prime_support_bound (P F : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (hF : ∀ n ∈ F, n ∈ Nat.factoredNumbers P) : (∑ n ∈ F, (1 : ℝ) / n) ≤ ∏ p ∈ P, totientFactor p := by have hsum := hasSum_reciprocal_factored P rw [Finset.filter_eq_self.mpr hP] at hsum have heq : (∏ p ∈ P, (1 - (p : ℝ)⁻¹)⁻¹) = ∏ p ∈ P, totientFactor p := by apply Finset.prod_congr rfl intro p hp simpa only [one_div] using (totientFactor_eq_inv (hP p hp)).symm rw [heq] at hsum have h : HasSum ((Nat.factoredNumbers P).indicator (fun n : ℕ => (n : ℝ)⁻¹)) (∏ p ∈ P, totientFactor p) := (hasSum_subtype_iff_indicator (f := fun n : ℕ => (n : ℝ)⁻¹)).mp hsum have hs := sum_le_hasSum F (fun n _ => by by_cases hn : n ∈ Nat.factoredNumbers P · rw [Set.indicator_of_mem hn] positivity · rw [Set.indicator_of_notMem hn]) h calc _ = ∑ n ∈ F, (Nat.factoredNumbers P).indicator (fun k : ℕ => (k : ℝ)⁻¹) n := by apply Finset.sum_congr rfl intro n hn rw [Set.indicator_of_mem (hF n hn), one_div] _ ≤ _ := hs /-- Uniform rough reciprocal mass, for every upper endpoint Y>=v and every finite family of positive integers supported on primes in (v,Y]. -/ /- Original line 18710: Erdos416Proof.exists_rough_reciprocal_sum_bound -/ theorem exists_rough_reciprocal_sum_bound : ∃ C : ℝ, 0 < C ∧ ∀ᶠ v : ℝ in atTop, ∀ (Y : ℝ) (F : Finset ℕ), v ≤ Y → (∀ n ∈ F, 0 < n ∧ ∀ p ∈ n.primeFactorsList, v < (p : ℝ) ∧ (p : ℝ) ≤ Y) → (∑ n ∈ F, (1 : ℝ) / n) ≤ C * Real.log Y / Real.log v := by obtain ⟨A, hA, hupper⟩ := exists_prime_euler_product_upper_bound obtain ⟨B, hB, hinverse⟩ := inverse_prime_euler_product_bound obtain ⟨Y₀, hY₀⟩ := eventually_atTop.mp hinverse refine ⟨A*B, by positivity, ?_⟩ filter_upwards [hupper, eventually_ge_atTop Y₀, eventually_gt_atTop (1 : ℝ)] with v hv hvY₀ hv1 intro Y F hvY hF have hv0 : 0 ≤ v := by linarith have hlogv : 0 < Real.log v := Real.log_pos hv1 have hlogY : 0 < Real.log Y := Real.log_pos (hv1.trans_le hvY) let P := (Nat.primesLE ⌊Y⌋₊).filter (fun p : ℕ => v < (p : ℝ)) have hP : ∀ p ∈ P, p.Prime := fun p hp => Nat.prime_of_mem_primesLE (Finset.mem_filter.mp hp).1 have hsupport : ∀ n ∈ F, n ∈ Nat.factoredNumbers P := by intro n hn refine ⟨(hF n hn).1.ne', ?_⟩ intro p hp obtain ⟨hpv, hpY⟩ := (hF n hn).2 p hp exact Finset.mem_filter.mpr ⟨Nat.mem_primesLE.mpr ⟨Nat.le_floor hpY, Nat.prime_of_mem_primeFactorsList hp⟩, hpv⟩ calc _ ≤ ∏ p ∈ P, totientFactor p := finite_reciprocal_prime_support_bound P F hP hsupport _ = (∏ p ∈ Nat.primesLE ⌊v⌋₊, (1 - (1 : ℝ) / p)) * ∏ p ∈ Nat.primesLE ⌊Y⌋₊, totientFactor p := prime_interval_totient_product hv0 hvY _ ≤ (A / Real.log v) * (B * Real.log Y) := mul_le_mul hv (hY₀ Y (hvY₀.trans hvY)) (Finset.prod_nonneg (fun p hp => (totientFactor_pos (Nat.prime_of_mem_primesLE hp)).le)) (by positivity) _ = _ := by ring end Erdos416Proof open Filter Asymptotics MeasureTheory open scoped BigOperators Classical Topology namespace Erdos416Proof /- Original line 18756: Erdos416Proof.sum_nat_pow_range_le_succ_pow -/ theorem sum_nat_pow_range_le_succ_pow (a k : ℕ) : (∑ j ∈ Finset.range (k+1), a^j) ≤ (a+1)^k := by induction k with | zero => simp | succ k ih => rw [Finset.sum_range_succ', pow_zero] simp only [pow_succ, ← Finset.sum_mul] have hpow : 1 ≤ (a+1)^k := Nat.one_le_pow k (a+1) (by omega) nlinarith [Nat.mul_le_mul_right a ih] /- Original line 18766: Erdos416Proof.sum_nat_pow_cardFactors_divisors_le -/ theorem sum_nat_pow_cardFactors_divisors_le (a n : ℕ) : (∑ d ∈ n.divisors, a ^ ArithmeticFunction.cardFactors d) ≤ (a+1) ^ ArithmeticFunction.cardFactors n := by by_cases hn : n = 0 · simp [hn] let f := ArithmeticFunction.zeta * omegaWeightNat a have hf : f.IsMultiplicative := ArithmeticFunction.isMultiplicative_zeta.mul (omegaWeightNat_multiplicative a) have heq : f n = ∑ d ∈ n.divisors, a ^ ArithmeticFunction.cardFactors d := by rw [ArithmeticFunction.zeta_mul_apply] apply Finset.sum_congr rfl intro d hd simp [omegaWeightNat, ne_zero_of_dvd_ne_zero hn (Nat.dvd_of_mem_divisors hd)] have hp (p k : ℕ) (hprime : p.Prime) : f (p^k) ≤ (a+1)^k := by rw [ArithmeticFunction.zeta_mul_apply, Nat.sum_divisors_prime_pow hprime] simpa [omegaWeightNat, hprime.ne_zero, ArithmeticFunction.cardFactors_apply_prime_pow hprime] using sum_nat_pow_range_le_succ_pow a k rw [← heq, hf.multiplicative_factorization f hn, ArithmeticFunction.cardFactors_eq_sum_factorization] simp only [Finsupp.prod, Finsupp.sum, Nat.support_factorization] rw [← Finset.prod_pow_eq_pow_sum] exact Finset.prod_le_prod (fun _ _ => Nat.zero_le _) fun p hp' => hp p _ (Nat.prime_of_mem_primeFactors hp') /-- Actual ordered tuples with prescribed positive product, constructed by successively choosing the product of the remaining entries. -/ /- Original line 18792: Erdos416Proof.orderedFactorizations -/ def orderedFactorizations : (k n : ℕ) → Finset (Fin k → ℕ) | 0, n => if n = 1 then {Fin.elim0} else ∅ | k+1, n => n.divisors.biUnion fun d => (orderedFactorizations k d).image (fun f => Fin.cons (n/d) f) /- Original line 18797: Erdos416Proof.mem_orderedFactorizations -/ theorem mem_orderedFactorizations {k n : ℕ} (hn : 0 < n) (f : Fin k → ℕ) : f ∈ orderedFactorizations k n ↔ (∏ idx, f idx) = n := by induction k generalizing n with | zero => by_cases hn1 : n = 1 · subst n simp [orderedFactorizations, Subsingleton.elim f (Fin.elim0 : Fin 0 → ℕ)] · simp [orderedFactorizations, hn1, Ne.symm hn1] | succ k ih => simp only [orderedFactorizations, Finset.mem_biUnion, Finset.mem_image] constructor · rintro ⟨d, hd, t, ht, rfl⟩ have hd0 : 0 < d := Nat.pos_of_ne_zero (ne_zero_of_dvd_ne_zero hn.ne' (Nat.dvd_of_mem_divisors hd)) rw [Fin.prod_cons, (ih hd0 t).mp ht] exact Nat.div_mul_cancel (Nat.dvd_of_mem_divisors hd) · intro hprod let d : ℕ := ∏ idx : Fin k, f idx.succ have hmul : f 0 * d = n := (Fin.prod_univ_succ f).symm.trans hprod have hd0 : 0 < d := by by_contra hd have hdz : d = 0 := by omega simp only [hdz, mul_zero] at hmul omega have hdvd : d ∣ n := ⟨f 0, by simpa only [mul_comm] using hmul.symm⟩ have hfirst : n/d = f 0 := by rw [← hmul, Nat.mul_div_cancel _ hd0] refine ⟨d, Nat.mem_divisors.mpr ⟨hdvd, hn.ne'⟩, (fun idx => f idx.succ), (ih hd0 _).mpr rfl, ?_⟩ rw [hfirst] exact Fin.cons_self_tail f /- Original line 18828: Erdos416Proof.orderedFactorizations_card_le -/ theorem orderedFactorizations_card_le (k n : ℕ) : (orderedFactorizations k n).card ≤ k ^ ArithmeticFunction.cardFactors n := by induction k generalizing n with | zero => by_cases hn1 : n = 1 · simp [orderedFactorizations, hn1] · simp [orderedFactorizations, hn1] | succ k ih => rw [orderedFactorizations] apply Finset.card_biUnion_le.trans exact (Finset.sum_le_sum (fun d _ => Finset.card_image_le.trans (ih d))).trans (sum_nat_pow_cardFactors_divisors_le k n) /- Original line 18841: Erdos416Proof.finite_ordered_factorization_count -/ theorem finite_ordered_factorization_count {k n : ℕ} (hn : 0 < n) (F : Finset (Fin k → ℕ)) (hF : ∀ f ∈ F, (∏ idx, f idx) = n) : F.card ≤ k ^ ArithmeticFunction.cardFactors n := (Finset.card_le_card (fun f hf => (mem_orderedFactorizations hn f).mpr (hF f hf))).trans (orderedFactorizations_card_le k n) /- Original line 18847: Erdos416Proof.finite_dual_ordered_factorization_count -/ theorem finite_dual_ordered_factorization_count {idx j n : ℕ} (hn : 0 < n) (F : Finset ((Fin idx → ℕ) × (Fin j → ℕ))) (hF : ∀ f ∈ F, (∏ k, f.1 k) = n ∧ (∏ k, f.2 k) = n) : F.card ≤ idx ^ ArithmeticFunction.cardFactors n * j ^ ArithmeticFunction.cardFactors n := by have hsub : F ⊆ (orderedFactorizations idx n).product (orderedFactorizations j n) := by intro f hf exact Finset.mem_product.mpr ⟨(mem_orderedFactorizations hn f.1).mpr (hF f hf).1, (mem_orderedFactorizations hn f.2).mpr (hF f hf).2⟩ calc _ ≤ ((orderedFactorizations idx n).product (orderedFactorizations j n)).card := Finset.card_le_card hsub _ = (orderedFactorizations idx n).card * (orderedFactorizations j n).card := Finset.card_product _ _ _ ≤ _ := Nat.mul_le_mul (orderedFactorizations_card_le idx n) (orderedFactorizations_card_le j n) /- Original line 18862: Erdos416Proof.cardFactors_eq_primeFactors_card_of_squarefree -/ theorem cardFactors_eq_primeFactors_card_of_squarefree {n : ℕ} (hn : Squarefree n) : ArithmeticFunction.cardFactors n = n.primeFactors.card := by rw [← (ArithmeticFunction.cardDistinctFactors_eq_cardFactors_iff_squarefree hn.ne_zero).mpr hn, ArithmeticFunction.cardDistinctFactors_apply, ← Nat.toFinset_factors, List.card_toFinset] /- Original line 18867: Erdos416Proof.squarefree_omega_weight_product -/ theorem squarefree_omega_weight_product {n : ℕ} (hn : Squarefree n) (a : ℝ) : a ^ ArithmeticFunction.cardFactors n / (n : ℝ) = ∏ p ∈ n.primeFactors, a / (p : ℝ) := by have hdc : (n : ℝ) = ∏ p ∈ n.primeFactors, (p : ℝ) := by rw [← Nat.cast_prod, Nat.prod_primeFactors_of_squarefree hn] rw [cardFactors_eq_primeFactors_card_of_squarefree hn, hdc, Finset.prod_div_distrib, Finset.prod_const] /- Original line 18874: Erdos416Proof.squarefree_omega_weight_sum_le_product -/ theorem squarefree_omega_weight_sum_le_product (M P : Finset ℕ) {a : ℝ} (ha : 0 ≤ a) (hM : ∀ n ∈ M, Squarefree n ∧ n.primeFactors ⊆ P) : (∑ n ∈ M, a ^ ArithmeticFunction.cardFactors n / (n : ℝ)) ≤ ∏ p ∈ P, (1 + a / (p : ℝ)) := by have hinj : Set.InjOn Nat.primeFactors (M : Set ℕ) := by intro n hn m hm hnm calc n = ∏ p ∈ n.primeFactors, p := (Nat.prod_primeFactors_of_squarefree (hM n hn).1).symm _ = ∏ p ∈ m.primeFactors, p := congrArg (fun s : Finset ℕ => ∏ p ∈ s, p) hnm _ = m := Nat.prod_primeFactors_of_squarefree (hM m hm).1 have hsub : M.image Nat.primeFactors ⊆ P.powerset := by intro s hs obtain ⟨n, hn, rfl⟩ := Finset.mem_image.mp hs exact Finset.mem_powerset.mpr (hM n hn).2 calc _ = ∑ n ∈ M, ∏ p ∈ n.primeFactors, a / (p : ℝ) := Finset.sum_congr rfl fun n hn => squarefree_omega_weight_product (hM n hn).1 a _ = ∑ s ∈ M.image Nat.primeFactors, ∏ p ∈ s, a / (p : ℝ) := (Finset.sum_image (f := fun s : Finset ℕ => ∏ p ∈ s, a / (p : ℝ)) hinj).symm _ ≤ ∑ s ∈ P.powerset, ∏ p ∈ s, a / (p : ℝ) := by apply Finset.sum_le_sum_of_subset_of_nonneg hsub intro s _ _ exact Finset.prod_nonneg fun p _ => div_nonneg ha (Nat.cast_nonneg p) _ = _ := (Finset.prod_one_add P).symm /- Original line 18899: Erdos416Proof.finite_prime_weight_product_le_exp -/ theorem finite_prime_weight_product_le_exp (P : Finset ℕ) {a : ℝ} (ha : 0 ≤ a) : (∏ p ∈ P, (1 + a / (p : ℝ))) ≤ Real.exp (a * ∑ p ∈ P, (1 : ℝ) / p) := by calc _ ≤ ∏ p ∈ P, Real.exp (a / (p : ℝ)) := by apply Finset.prod_le_prod · intro p _ positivity · intro p _ simpa only [add_comm] using Real.add_one_le_exp (a / (p : ℝ)) _ = Real.exp (∑ p ∈ P, a / (p : ℝ)) := (Real.exp_sum _ _).symm _ = _ := by congr 1; rw [Finset.mul_sum]; apply Finset.sum_congr rfl; intro p _; ring /-- Two allocations cost at most a^(2 Omega(n)); one copy is bounded by the factor-count cutoff and the other is summed by the squarefree Euler product. -/ /- Original line 18913: Erdos416Proof.squarefree_dual_allocation_weight_sum -/ theorem squarefree_dual_allocation_weight_sum (M P : Finset ℕ) {a I H : ℝ} (ha : 1 ≤ a) (hM : ∀ n ∈ M, Squarefree n ∧ n.primeFactors ⊆ P ∧ (ArithmeticFunction.cardFactors n : ℝ) ≤ I) (hH : (∑ p ∈ P, (1 : ℝ) / p) ≤ H) : (∑ n ∈ M, a ^ (2 * ArithmeticFunction.cardFactors n) / (n : ℝ)) ≤ Real.exp (I * Real.log a + a * H) := by have ha0 : 0 < a := by linarith have hloga : 0 ≤ Real.log a := Real.log_nonneg ha have hpower (n : ℕ) (hn : n ∈ M) : a ^ ArithmeticFunction.cardFactors n ≤ Real.exp (I * Real.log a) := by apply (Real.log_le_log_iff (by positivity) (Real.exp_pos _)).mp rw [Real.log_pow, Real.log_exp] exact mul_le_mul_of_nonneg_right (hM n hn).2.2 hloga calc _ = ∑ n ∈ M, a ^ ArithmeticFunction.cardFactors n * (a ^ ArithmeticFunction.cardFactors n / (n : ℝ)) := by apply Finset.sum_congr rfl intro n _ rw [two_mul, pow_add] ring _ ≤ ∑ n ∈ M, Real.exp (I * Real.log a) * (a ^ ArithmeticFunction.cardFactors n / (n : ℝ)) := by apply Finset.sum_le_sum intro n hn exact mul_le_mul_of_nonneg_right (hpower n hn) (by positivity) _ = Real.exp (I * Real.log a) * ∑ n ∈ M, a ^ ArithmeticFunction.cardFactors n / (n : ℝ) := (Finset.mul_sum _ _ _).symm _ ≤ Real.exp (I * Real.log a) * ∏ p ∈ P, (1 + a / (p : ℝ)) := mul_le_mul_of_nonneg_left (squarefree_omega_weight_sum_le_product M P ha0.le (fun n hn => ⟨(hM n hn).1, (hM n hn).2.1⟩)) (Real.exp_pos _).le _ ≤ Real.exp (I * Real.log a) * Real.exp (a * H) := by apply mul_le_mul_of_nonneg_left _ (Real.exp_pos _).le exact (finite_prime_weight_product_le_exp P ha0.le).trans (Real.exp_le_exp.mpr (mul_le_mul_of_nonneg_left hH ha0.le)) _ = _ := (Real.exp_add _ _).symm /-- Reciprocal mass of actual pairs of ordered factorizations, grouped by their common squarefree product. -/ /- Original line 18951: Erdos416Proof.finite_dual_ordered_factorization_mass -/ theorem finite_dual_ordered_factorization_mass {idx j : ℕ} (hi : 1 ≤ idx) (hji : j ≤ idx) (M P : Finset ℕ) (F : ℕ → Finset ((Fin idx → ℕ) × (Fin j → ℕ))) {I H : ℝ} (hM : ∀ n ∈ M, Squarefree n ∧ n.primeFactors ⊆ P ∧ (ArithmeticFunction.cardFactors n : ℝ) ≤ I) (hF : ∀ n ∈ M, ∀ f ∈ F n, (∏ k, f.1 k) = n ∧ (∏ k, f.2 k) = n) (hH : (∑ p ∈ P, (1 : ℝ) / p) ≤ H) : (∑ n ∈ M, ((F n).card : ℝ) / (n : ℝ)) ≤ Real.exp (I * Real.log idx + (idx : ℝ) * H) := by have hcard (n : ℕ) (hn : n ∈ M) : ((F n).card : ℝ) ≤ (idx : ℝ) ^ (2 * ArithmeticFunction.cardFactors n) := by have h := finite_dual_ordered_factorization_count (Nat.pos_of_ne_zero (hM n hn).1.ne_zero) (F n) (hF n hn) have hjpow := Nat.pow_le_pow_left hji (ArithmeticFunction.cardFactors n) have hbound : (F n).card ≤ idx ^ (2 * ArithmeticFunction.cardFactors n) := by calc _ ≤ idx ^ ArithmeticFunction.cardFactors n * j ^ ArithmeticFunction.cardFactors n := h _ ≤ idx ^ ArithmeticFunction.cardFactors n * idx ^ ArithmeticFunction.cardFactors n := Nat.mul_le_mul_left _ hjpow _ = _ := by rw [two_mul, pow_add] exact_mod_cast hbound calc _ ≤ ∑ n ∈ M, (idx : ℝ) ^ (2 * ArithmeticFunction.cardFactors n) / (n : ℝ) := Finset.sum_le_sum fun n hn => div_le_div_of_nonneg_right (hcard n hn) (Nat.cast_nonneg n) _ ≤ _ := squarefree_dual_allocation_weight_sum M P (by exact_mod_cast hi) hM hH /- Original line 18975: Erdos416Proof.exists_squarefree_interval_dual_allocation_bound -/ theorem exists_squarefree_interval_dual_allocation_bound : ∃ B : ℝ, 0 ≤ B ∧ ∀ (u v a I : ℝ) (M : Finset ℕ), 2 ≤ u → u ≤ v → 1 ≤ a → a * (logLog v - logLog u + B) ≤ I → (∀ n ∈ M, Squarefree n ∧ (∀ p ∈ n.primeFactors, u < (p : ℝ) ∧ (p : ℝ) ≤ v) ∧ (ArithmeticFunction.cardFactors n : ℝ) ≤ I) → (∑ n ∈ M, a ^ (2 * ArithmeticFunction.cardFactors n) / (n : ℝ)) ≤ Real.exp ((1 + Real.log a) * I) := by obtain ⟨B, hB⟩ := prime_reciprocal_mertens refine ⟨2 * |B|, by positivity, ?_⟩ intro u v a I M hu huv ha hroom hM let P := (Nat.primesLE ⌊v⌋₊).filter (fun p : ℕ => u < (p : ℝ) ∧ (p : ℝ) ≤ v) have hH : (∑ p ∈ P, (1 : ℝ) / p) ≤ logLog v - logLog u + 2 * |B| := by have h := (abs_le.mp (prime_interval_reciprocal_error hB hu huv le_rfl)).2 change (∑ p ∈ P, (1 : ℝ) / p) - (logLog v - logLog u) ≤ 2 * |B| at h linarith have hMP : ∀ n ∈ M, Squarefree n ∧ n.primeFactors ⊆ P ∧ (ArithmeticFunction.cardFactors n : ℝ) ≤ I := by intro n hn refine ⟨(hM n hn).1, ?_, (hM n hn).2.2⟩ intro p hp have hinterval := (hM n hn).2.1 p hp exact Finset.mem_filter.mpr ⟨Nat.mem_primesLE.mpr ⟨Nat.le_floor hinterval.2, Nat.prime_of_mem_primeFactors hp⟩, hinterval⟩ exact (squarefree_dual_allocation_weight_sum M P ha hMP hH).trans (Real.exp_le_exp.mpr (by nlinarith)) end Erdos416Proof /- Actual sieve-state decomposition, finite iteration, terminal mass, and interval allocation bounds, followed by the initial rough-factor count. The compatible-fiber applications and middle selected-prime cases remain. -/ open Filter Asymptotics MeasureTheory open scoped BigOperators Classical Topology namespace Erdos416Proof /- Original line 19018: Erdos416Proof.primePart_finset_prod -/ theorem primePart_finset_prod {ι : Type*} (F : Finset ι) (f : ι → ℕ) (hf : ∀ idx ∈ F, f idx ≠ 0) (A : ℕ → Prop) : primePart (∏ idx ∈ F, f idx) A = ∏ idx ∈ F, primePart (f idx) A := by induction F using Finset.induction_on with | empty => simp [Erdos416Proof.twoFormDensity_one, primePart] | @insert idx F hi ih => rw [Finset.prod_insert hi, Finset.prod_insert hi, primePart_mul (hf idx (Finset.mem_insert_self _ _)) (Finset.prod_ne_zero_iff.mpr (fun j hj => hf j (Finset.mem_insert_of_mem hj))), ih (fun j hj => hf j (Finset.mem_insert_of_mem hj))] /- Original line 19029: Erdos416Proof.lowPrimePart_lowPrimePart -/ theorem lowPrimePart_lowPrimePart (n : ℕ) {u v : ℝ} (huv : u ≤ v) : lowPrimePart (lowPrimePart n v) u = lowPrimePart n u := by unfold lowPrimePart rw [primePart_primePart] congr 1 funext p exact propext ⟨And.right, fun hp => ⟨hp.trans huv, hp⟩⟩ /- Original line 19037: Erdos416Proof.lowPrimePart_highPrimePart -/ theorem lowPrimePart_highPrimePart (n : ℕ) (v : ℝ) : lowPrimePart (highPrimePart n v) v = 1 := by unfold lowPrimePart highPrimePart rw [primePart_primePart] have hpred : (fun p : ℕ => v < (p : ℝ) ∧ (p : ℝ) ≤ v) = (fun _ => False) := by funext p exact propext ⟨fun hp => (not_lt_of_ge hp.2) hp.1, False.elim⟩ rw [hpred] simp [Erdos416Proof.twoFormDensity_one, primePart] /- Original line 19047: Erdos416Proof.highPrimePart_lowPrimePart -/ theorem highPrimePart_lowPrimePart (n : ℕ) (v : ℝ) : highPrimePart (lowPrimePart n v) v = 1 := by unfold lowPrimePart highPrimePart rw [primePart_primePart] have hpred : (fun p : ℕ => (p : ℝ) ≤ v ∧ v < (p : ℝ)) = (fun _ => False) := by funext p exact propext ⟨fun hp => (not_lt_of_ge hp.1) hp.2, False.elim⟩ rw [hpred] simp [Erdos416Proof.twoFormDensity_one, primePart] /- Original line 19057: Erdos416Proof.highPrimePart_highPrimePart -/ theorem highPrimePart_highPrimePart (n : ℕ) (v : ℝ) : highPrimePart (highPrimePart n v) v = highPrimePart n v := by simp only [highPrimePart, primePart_primePart, and_self] /-- A state records both actual ordered factor lists. The fixed multiplier d is kept outside the left list. There are no redundant product coordinates. -/ /- Original line 19063: Erdos416Proof.CollisionState -/ abbrev CollisionState (m n : ℕ) := (Fin m → ℕ) × (Fin n → ℕ) namespace CollisionState variable {m n : ℕ} /- Original line 19069: Erdos416Proof.CollisionState.Positive -/ def Positive (s : CollisionState m n) : Prop := (∀ idx, 0 < s.1 idx) ∧ ∀ idx, 0 < s.2 idx /- Original line 19071: Erdos416Proof.CollisionState.leftValue -/ def leftValue (s : CollisionState m n) : ℕ := ∏ idx, s.1 idx /- Original line 19073: Erdos416Proof.CollisionState.rightValue -/ def rightValue (s : CollisionState m n) : ℕ := ∏ idx, s.2 idx /- Original line 19075: Erdos416Proof.CollisionState.Balanced -/ def Balanced (d : ℕ) (s : CollisionState m n) : Prop := d * leftValue s = rightValue s /- Original line 19077: Erdos416Proof.CollisionState.cut -/ noncomputable def cut (v : ℝ) (s : CollisionState m n) : CollisionState m n := (fun idx => lowPrimePart (s.1 idx) v, fun idx => lowPrimePart (s.2 idx) v) /- Original line 19080: Erdos416Proof.CollisionState.high -/ noncomputable def high (v : ℝ) (s : CollisionState m n) : CollisionState m n := (fun idx => highPrimePart (s.1 idx) v, fun idx => highPrimePart (s.2 idx) v) /- Original line 19083: Erdos416Proof.CollisionState.interval -/ noncomputable def interval (u v : ℝ) (s : CollisionState m n) : CollisionState m n := (fun idx => primePart (s.1 idx) (fun p => u < (p : ℝ) ∧ (p : ℝ) ≤ v), fun idx => primePart (s.2 idx) (fun p => u < (p : ℝ) ∧ (p : ℝ) ≤ v)) /- Original line 19087: Erdos416Proof.CollisionState.cut_positive -/ theorem cut_positive (v : ℝ) (s : CollisionState m n) : Positive (cut v s) := ⟨fun _ => primePart_pos _ _, fun _ => primePart_pos _ _⟩ /- Original line 19090: Erdos416Proof.CollisionState.high_positive -/ theorem high_positive (v : ℝ) (s : CollisionState m n) : Positive (high v s) := ⟨fun _ => primePart_pos _ _, fun _ => primePart_pos _ _⟩ /- Original line 19093: Erdos416Proof.CollisionState.leftValue_pos -/ theorem leftValue_pos {s : CollisionState m n} (hs : Positive s) : 0 < leftValue s := Finset.prod_pos fun idx _ => hs.1 idx /- Original line 19096: Erdos416Proof.CollisionState.rightValue_pos -/ theorem rightValue_pos {s : CollisionState m n} (hs : Positive s) : 0 < rightValue s := Finset.prod_pos fun idx _ => hs.2 idx /- Original line 19099: Erdos416Proof.CollisionState.leftValue_mul -/ theorem leftValue_mul (s t : CollisionState m n) : leftValue (s*t) = leftValue s * leftValue t := by simp [leftValue, Finset.prod_mul_distrib] /- Original line 19102: Erdos416Proof.CollisionState.rightValue_mul -/ theorem rightValue_mul (s t : CollisionState m n) : rightValue (s*t) = rightValue s * rightValue t := by simp [rightValue, Finset.prod_mul_distrib] /- Original line 19105: Erdos416Proof.CollisionState.cut_mul -/ theorem cut_mul {s t : CollisionState m n} (hs : Positive s) (ht : Positive t) (v : ℝ) : cut v (s*t) = cut v s * cut v t := by apply Prod.ext · funext idx exact primePart_mul (hs.1 idx).ne' (ht.1 idx).ne' _ · funext idx exact primePart_mul (hs.2 idx).ne' (ht.2 idx).ne' _ /- Original line 19113: Erdos416Proof.CollisionState.high_mul -/ theorem high_mul {s t : CollisionState m n} (hs : Positive s) (ht : Positive t) (v : ℝ) : high v (s*t) = high v s * high v t := by apply Prod.ext · funext idx exact primePart_mul (hs.1 idx).ne' (ht.1 idx).ne' _ · funext idx exact primePart_mul (hs.2 idx).ne' (ht.2 idx).ne' _ /- Original line 19121: Erdos416Proof.CollisionState.cut_mul_high -/ theorem cut_mul_high {s : CollisionState m n} (hs : Positive s) (v : ℝ) : cut v s * high v s = s := by apply Prod.ext · funext idx exact low_mul_high (hs.1 idx).ne' v · funext idx exact low_mul_high (hs.2 idx).ne' v /- Original line 19129: Erdos416Proof.CollisionState.cut_cut -/ theorem cut_cut (s : CollisionState m n) {u v : ℝ} (huv : u ≤ v) : cut u (cut v s) = cut u s := by apply Prod.ext · funext idx exact lowPrimePart_lowPrimePart _ huv · funext idx exact lowPrimePart_lowPrimePart _ huv /- Original line 19137: Erdos416Proof.CollisionState.cut_high -/ theorem cut_high (v : ℝ) (s : CollisionState m n) : cut v (high v s) = 1 := by apply Prod.ext · funext idx exact lowPrimePart_highPrimePart _ _ · funext idx exact lowPrimePart_highPrimePart _ _ /- Original line 19144: Erdos416Proof.CollisionState.high_cut -/ theorem high_cut (v : ℝ) (s : CollisionState m n) : high v (cut v s) = 1 := by apply Prod.ext · funext idx exact highPrimePart_lowPrimePart _ _ · funext idx exact highPrimePart_lowPrimePart _ _ /- Original line 19151: Erdos416Proof.CollisionState.high_high -/ theorem high_high (v : ℝ) (s : CollisionState m n) : high v (high v s) = high v s := by apply Prod.ext · funext idx exact highPrimePart_highPrimePart _ _ · funext idx exact highPrimePart_highPrimePart _ _ /- Original line 19158: Erdos416Proof.CollisionState.high_cut_interval -/ theorem high_cut_interval (u v : ℝ) (s : CollisionState m n) : high u (cut v s) = interval u v s := by apply Prod.ext <;> funext idx <;> simp only [high, cut, interval, lowPrimePart, highPrimePart, primePart_primePart, and_comm] /- Original line 19163: Erdos416Proof.CollisionState.cut_leftValue -/ theorem cut_leftValue (v : ℝ) {s : CollisionState m n} (hs : Positive s) : leftValue (cut v s) = lowPrimePart (leftValue s) v := (primePart_finset_prod Finset.univ s.1 (fun idx _ => (hs.1 idx).ne') _).symm /- Original line 19167: Erdos416Proof.CollisionState.cut_rightValue -/ theorem cut_rightValue (v : ℝ) {s : CollisionState m n} (hs : Positive s) : rightValue (cut v s) = lowPrimePart (rightValue s) v := (primePart_finset_prod Finset.univ s.2 (fun idx _ => (hs.2 idx).ne') _).symm /- Original line 19171: Erdos416Proof.CollisionState.high_leftValue -/ theorem high_leftValue (v : ℝ) {s : CollisionState m n} (hs : Positive s) : leftValue (high v s) = highPrimePart (leftValue s) v := (primePart_finset_prod Finset.univ s.1 (fun idx _ => (hs.1 idx).ne') _).symm /- Original line 19175: Erdos416Proof.CollisionState.high_rightValue -/ theorem high_rightValue (v : ℝ) {s : CollisionState m n} (hs : Positive s) : rightValue (high v s) = highPrimePart (rightValue s) v := (primePart_finset_prod Finset.univ s.2 (fun idx _ => (hs.2 idx).ne') _).symm /- Original line 19179: Erdos416Proof.CollisionState.cut_balanced -/ theorem cut_balanced {d : ℕ} {v : ℝ} {s : CollisionState m n} (hd : 0 < d) (hs : Positive s) (hbal : Balanced d s) (hsupport : ∀ p ∈ d.primeFactorsList, (p : ℝ) ≤ v) : Balanced d (cut v s) := by have heq := congrArg (fun t : ℕ => lowPrimePart t v) hbal change lowPrimePart (d * leftValue s) v = lowPrimePart (rightValue s) v at heq rw [lowPrimePart, primePart_mul hd.ne' (leftValue_pos hs).ne', primePart_eq_self hd.ne' _ hsupport] at heq change d * lowPrimePart (leftValue s) v = lowPrimePart (rightValue s) v at heq simpa only [Balanced, cut_leftValue v hs, cut_rightValue v hs] using heq /- Original line 19189: Erdos416Proof.CollisionState.high_balanced -/ theorem high_balanced {d : ℕ} {v : ℝ} {s : CollisionState m n} (hd : 0 < d) (hs : Positive s) (hbal : Balanced d s) (hsupport : ∀ p ∈ d.primeFactorsList, (p : ℝ) ≤ v) : Balanced 1 (high v s) := by have hcut := cut_balanced hd hs hbal hsupport have hleft : leftValue s = leftValue (cut v s) * leftValue (high v s) := by rw [← leftValue_mul, cut_mul_high hs] have hright : rightValue s = rightValue (cut v s) * rightValue (high v s) := by rw [← rightValue_mul, cut_mul_high hs] change d * leftValue s = rightValue s at hbal change d * leftValue (cut v s) = rightValue (cut v s) at hcut rw [hleft, hright, ← hcut, ← mul_assoc] at hbal have hprefix : 0 < d * leftValue (cut v s) := Nat.mul_pos hd (leftValue_pos (cut_positive _ _)) have hcancel := Nat.eq_of_mul_eq_mul_left hprefix hbal simpa only [Balanced, one_mul] using hcancel /- Original line 19204: Erdos416Proof.CollisionState.lowStates -/ noncomputable def lowStates (v : ℝ) (F : Finset (CollisionState m n)) := F.image (cut v) /- Original line 19206: Erdos416Proof.CollisionState.highStates -/ noncomputable def highStates (v : ℝ) (F : Finset (CollisionState m n)) := F.image (high v) /-- Only compatible recombinations of the actual low and high images occur. -/ /- Original line 19209: Erdos416Proof.CollisionState.compatibleSplits -/ noncomputable def compatibleSplits (v : ℝ) (F : Finset (CollisionState m n)) : Finset (CollisionState m n × CollisionState m n) := ((lowStates v F).product (highStates v F)).filter (fun st => st.1 * st.2 ∈ F) /- Original line 19213: Erdos416Proof.CollisionState.recover_split -/ theorem recover_split {v : ℝ} {F : Finset (CollisionState m n)} {s t : CollisionState m n} (hs : s ∈ lowStates v F) (ht : t ∈ highStates v F) : cut v (s*t) = s ∧ high v (s*t) = t := by obtain ⟨a, _, rfl⟩ := Finset.mem_image.mp hs obtain ⟨b, _, rfl⟩ := Finset.mem_image.mp ht rw [cut_mul (cut_positive _ _) (high_positive _ _), high_mul (cut_positive _ _) (high_positive _ _), cut_cut _ le_rfl, cut_high, high_cut, high_high, mul_one, one_mul] exact ⟨rfl, rfl⟩ /- Original line 19223: Erdos416Proof.CollisionState.mul_injOn_compatibleSplits -/ theorem mul_injOn_compatibleSplits (v : ℝ) (F : Finset (CollisionState m n)) : Set.InjOn (fun st : CollisionState m n × CollisionState m n => st.1 * st.2) (compatibleSplits v F : Set _) := by intro st hst ab hab heq obtain ⟨hst', _⟩ := Finset.mem_filter.mp hst obtain ⟨hab', _⟩ := Finset.mem_filter.mp hab obtain ⟨hs, ht⟩ := Finset.mem_product.mp hst' obtain ⟨ha, hb⟩ := Finset.mem_product.mp hab' have hstrec := recover_split hs ht have habrec := recover_split ha hb apply Prod.ext · exact hstrec.1.symm.trans ((congrArg (cut v) heq).trans habrec.1) · exact hstrec.2.symm.trans ((congrArg (high v) heq).trans habrec.2) /- Original line 19237: Erdos416Proof.CollisionState.image_mul_compatibleSplits -/ theorem image_mul_compatibleSplits (v : ℝ) (F : Finset (CollisionState m n)) (hF : ∀ s ∈ F, Positive s) : (compatibleSplits v F).image (fun st => st.1 * st.2) = F := by apply Finset.Subset.antisymm · intro s hs obtain ⟨st, hst, rfl⟩ := Finset.mem_image.mp hs exact (Finset.mem_filter.mp hst).2 · intro s hs apply Finset.mem_image.mpr refine ⟨(cut v s, high v s), Finset.mem_filter.mpr ⟨?_, ?_⟩, cut_mul_high (hF s hs) v⟩ · exact Finset.mem_product.mpr ⟨Finset.mem_image.mpr ⟨s, hs, rfl⟩, Finset.mem_image.mpr ⟨s, hs, rfl⟩⟩ · simpa only [cut_mul_high (hF s hs)] using hs /-- The exact sum over an actual family, with every recombination counted once. -/ /- Original line 19252: Erdos416Proof.CollisionState.sum_split -/ theorem sum_split (v : ℝ) (F : Finset (CollisionState m n)) (hF : ∀ s ∈ F, Positive s) (w : CollisionState m n → ℝ) : (∑ s ∈ F, w s) = ∑ s ∈ lowStates v F, ∑ t ∈ (highStates v F).filter (fun t => s*t ∈ F), w (s*t) := by calc _ = ∑ st ∈ compatibleSplits v F, w (st.1 * st.2) := by rw [← Finset.sum_image (mul_injOn_compatibleSplits v F), image_mul_compatibleSplits v F hF] _ = _ := by simp only [compatibleSplits, Finset.sum_filter, Finset.product_eq_sprod, Finset.sum_product] /- Original line 19262: Erdos416Proof.CollisionState.card_split -/ theorem card_split (v : ℝ) (F : Finset (CollisionState m n)) (hF : ∀ s ∈ F, Positive s) : (F.card : ℝ) = ∑ s ∈ lowStates v F, (((highStates v F).filter (fun t => s*t ∈ F)).card : ℝ) := by simpa only [Finset.sum_const, nsmul_eq_mul, Nat.cast_id, mul_one] using sum_split v F hF (fun _ => 1) /- Original line 19268: Erdos416Proof.CollisionState.reciprocalMass -/ noncomputable def reciprocalMass (d : ℕ) (F : Finset (CollisionState m n)) : ℝ := ∑ s ∈ F, (1 : ℝ) / ((d : ℝ) * leftValue s) /- Original line 19271: Erdos416Proof.CollisionState.reciprocalMass_split -/ theorem reciprocalMass_split (d : ℕ) (v : ℝ) (F : Finset (CollisionState m n)) (hF : ∀ s ∈ F, Positive s) : reciprocalMass d F = ∑ s ∈ lowStates v F, ((1 : ℝ) / ((d : ℝ) * leftValue s)) * ∑ t ∈ (highStates v F).filter (fun t => s*t ∈ F), (1 : ℝ) / leftValue t := by rw [reciprocalMass, sum_split v F hF] apply Finset.sum_congr rfl intro s _ rw [Finset.mul_sum] apply Finset.sum_congr rfl intro t _ rw [leftValue_mul, Nat.cast_mul] simp only [one_div, mul_inv_rev] ring /- Original line 19286: Erdos416Proof.CollisionState.card_le_reciprocalMass -/ theorem card_le_reciprocalMass (d : ℕ) (v : ℝ) (F : Finset (CollisionState m n)) (hF : ∀ s ∈ F, Positive s) {A : ℝ} (hcount : ∀ s ∈ lowStates v F, (((highStates v F).filter (fun t => s*t ∈ F)).card : ℝ) ≤ A / ((d : ℝ) * leftValue s)) : (F.card : ℝ) ≤ A * reciprocalMass d (lowStates v F) := by rw [card_split v F hF, reciprocalMass, Finset.mul_sum] apply Finset.sum_le_sum intro s hs simpa only [mul_one_div] using hcount s hs /- Original line 19297: Erdos416Proof.CollisionState.reciprocalMass_le_cut -/ theorem reciprocalMass_le_cut (d : ℕ) (v : ℝ) (F : Finset (CollisionState m n)) (hF : ∀ s ∈ F, Positive s) {B : ℝ} (hweight : ∀ s ∈ lowStates v F, (∑ t ∈ (highStates v F).filter (fun t => s*t ∈ F), (1 : ℝ) / leftValue t) ≤ B) : reciprocalMass d F ≤ B * reciprocalMass d (lowStates v F) := by rw [reciprocalMass_split d v F hF, reciprocalMass, Finset.mul_sum] apply Finset.sum_le_sum intro s hs simpa only [mul_comm] using mul_le_mul_of_nonneg_left (hweight s hs) (show 0 ≤ (1 : ℝ) / ((d : ℝ) * leftValue s) by positivity) /- Original line 19308: Erdos416Proof.CollisionState.card_leftValue_fiber_le -/ theorem card_leftValue_fiber_le {d a : ℕ} (hd : 0 < d) (ha : 0 < a) (F : Finset (CollisionState m n)) (hF : ∀ s ∈ F, Balanced d s) : (F.filter (fun s => leftValue s = a)).card ≤ m ^ ArithmeticFunction.cardFactors a * n ^ ArithmeticFunction.cardFactors (d*a) := by have hsub : F.filter (fun s => leftValue s = a) ⊆ (orderedFactorizations m a).product (orderedFactorizations n (d*a)) := by intro s hs obtain ⟨hsF, hsa⟩ := Finset.mem_filter.mp hs apply Finset.mem_product.mpr refine ⟨(mem_orderedFactorizations ha s.1).mpr hsa, (mem_orderedFactorizations (Nat.mul_pos hd ha) s.2).mpr ?_⟩ exact (hF s hsF).symm.trans (congrArg (fun t : ℕ => d*t) hsa) calc _ ≤ ((orderedFactorizations m a).product (orderedFactorizations n (d*a))).card := Finset.card_le_card hsub _ = (orderedFactorizations m a).card * (orderedFactorizations n (d*a)).card := Finset.card_product _ _ _ ≤ _ := Nat.mul_le_mul (orderedFactorizations_card_le _ _) (orderedFactorizations_card_le _ _) /- Original line 19327: Erdos416Proof.CollisionState.card_leftValue_fiber_le_of_right_le -/ theorem card_leftValue_fiber_le_of_right_le {d a : ℕ} (hd : 0 < d) (ha : 0 < a) (hnm : n ≤ m) (F : Finset (CollisionState m n)) (hF : ∀ s ∈ F, Balanced d s) : (F.filter (fun s => leftValue s = a)).card ≤ n ^ ArithmeticFunction.cardFactors d * m ^ (2 * ArithmeticFunction.cardFactors a) := by have h := card_leftValue_fiber_le hd ha F hF rw [ArithmeticFunction.cardFactors_mul hd.ne' ha.ne', pow_add] at h calc _ ≤ m ^ ArithmeticFunction.cardFactors a * (n ^ ArithmeticFunction.cardFactors d * n ^ ArithmeticFunction.cardFactors a) := h _ ≤ m ^ ArithmeticFunction.cardFactors a * (n ^ ArithmeticFunction.cardFactors d * m ^ ArithmeticFunction.cardFactors a) := by gcongr _ = _ := by rw [two_mul, pow_add]; ring /- Original line 19341: Erdos416Proof.CollisionState.reciprocalMass_fibers -/ theorem reciprocalMass_fibers (d : ℕ) (F : Finset (CollisionState m n)) : reciprocalMass d F = ∑ a ∈ F.image leftValue, ((F.filter (fun s => leftValue s = a)).card : ℝ) / ((d : ℝ) * a) := by rw [reciprocalMass, Finset.sum_comp (fun a : ℕ => (1 : ℝ) / ((d : ℝ)*a)) leftValue] simp only [nsmul_eq_mul, mul_one_div] /- Original line 19347: Erdos416Proof.CollisionState.reciprocalMass_le_supported_sum -/ theorem reciprocalMass_le_supported_sum {d : ℕ} (hd : 0 < d) (hm : 1 ≤ m) (hnm : n ≤ m) (F : Finset (CollisionState m n)) {I : ℝ} (hF : ∀ s ∈ F, Positive s ∧ Balanced d s ∧ (ArithmeticFunction.cardFactors (leftValue s) : ℝ) ≤ I) : reciprocalMass d F ≤ ((n : ℝ) ^ ArithmeticFunction.cardFactors d / d) * Real.exp (2*I*Real.log m) * ∑ a ∈ F.image leftValue, (1 : ℝ)/a := by have hmR : (1 : ℝ) ≤ m := by exact_mod_cast hm have hm0 : (0 : ℝ) < m := by linarith have hlogm : 0 ≤ Real.log m := Real.log_nonneg hmR rw [reciprocalMass_fibers, Finset.mul_sum] apply Finset.sum_le_sum intro a haF obtain ⟨s, hs, hsa⟩ := Finset.mem_image.mp haF have ha : 0 < a := hsa ▸ leftValue_pos (hF s hs).1 have hI : (ArithmeticFunction.cardFactors a : ℝ) ≤ I := hsa ▸ (hF s hs).2.2 have hpower : (m : ℝ) ^ (2 * ArithmeticFunction.cardFactors a) ≤ Real.exp (2*I*Real.log m) := by apply (Real.log_le_log_iff (by positivity) (Real.exp_pos _)).mp rw [Real.log_pow, Real.log_exp] push_cast nlinarith [mul_le_mul_of_nonneg_right hI hlogm] have hcard : ((F.filter (fun s => leftValue s = a)).card : ℝ) ≤ (n : ℝ) ^ ArithmeticFunction.cardFactors d * (m : ℝ) ^ (2 * ArithmeticFunction.cardFactors a) := by exact_mod_cast card_leftValue_fiber_le_of_right_le hd ha hnm F (fun s hs => (hF s hs).2.1) calc _ ≤ ((n : ℝ) ^ ArithmeticFunction.cardFactors d * Real.exp (2*I*Real.log m)) / ((d : ℝ)*a) := div_le_div_of_nonneg_right (hcard.trans (mul_le_mul_of_nonneg_left hpower (by positivity))) (by positivity) _ = _ := by simp only [div_eq_mul_inv, mul_inv_rev]; ring /- Original line 19375: Erdos416Proof.CollisionState.exists_terminal_state_mass_bound -/ theorem exists_terminal_state_mass_bound : ∃ C : ℝ, 0 < C ∧ ∀ᶠ v : ℝ in atTop, ∀ (m n d : ℕ) (I : ℝ) (F : Finset (CollisionState m n)), 1 ≤ m → n ≤ m → 0 < d → (∀ s ∈ F, Positive s ∧ Balanced d s ∧ (∀ p ∈ (leftValue s).primeFactorsList, (p : ℝ) ≤ v) ∧ (ArithmeticFunction.cardFactors (leftValue s) : ℝ) ≤ I) → reciprocalMass d F ≤ C * ((n : ℝ) ^ ArithmeticFunction.cardFactors d / d) * Real.exp (2*I*Real.log m) * Real.log v := by obtain ⟨C, hC, hprod⟩ := inverse_prime_euler_product_bound refine ⟨C, hC, ?_⟩ filter_upwards [hprod] with v hv intro m n d I F hm hnm hd hF let M := F.image leftValue have hsupport : ∀ a ∈ M, a ∈ Nat.factoredNumbers (Nat.primesLE ⌊v⌋₊) := by intro a ha obtain ⟨s, hs, rfl⟩ := Finset.mem_image.mp ha refine ⟨(leftValue_pos (hF s hs).1).ne', ?_⟩ intro p hp exact Nat.mem_primesLE.mpr ⟨Nat.le_floor ((hF s hs).2.2.1 p hp), Nat.prime_of_mem_primeFactorsList hp⟩ have hsum : (∑ a ∈ M, (1 : ℝ) / a) ≤ C * Real.log v := (finite_reciprocal_prime_support_bound _ M (fun p hp => Nat.prime_of_mem_primesLE hp) hsupport).trans hv calc _ ≤ ((n : ℝ) ^ ArithmeticFunction.cardFactors d / d) * Real.exp (2*I*Real.log m) * ∑ a ∈ M, (1 : ℝ)/a := reciprocalMass_le_supported_sum hd hm hnm F (fun s hs => ⟨(hF s hs).1, (hF s hs).2.1, (hF s hs).2.2.2⟩) _ ≤ ((n : ℝ) ^ ArithmeticFunction.cardFactors d / d) * Real.exp (2*I*Real.log m) * (C * Real.log v) := mul_le_mul_of_nonneg_left hsum (by positivity) _ = _ := by ring /-- Ford's terminal logarithmic factor, for the actual application l>=1. No squarefree condition is imposed on the terminal small-prime products. -/ /- Original line 19410: Erdos416Proof.CollisionState.exists_terminal_state_mass_log_bound -/ theorem exists_terminal_state_mass_log_bound : ∃ C : ℝ, 0 < C ∧ ∀ᶠ v : ℝ in atTop, ∀ (k l d : ℕ) (F : Finset (CollisionState (k+l) (k+1))), 1 ≤ k → 1 ≤ l → 0 < d → (∀ s ∈ F, Positive s ∧ Balanced d s ∧ (∀ p ∈ (leftValue s).primeFactorsList, (p : ℝ) ≤ v) ∧ (ArithmeticFunction.cardFactors (leftValue s) : ℝ) ≤ 10*(k+l : ℕ)*logLog v) → reciprocalMass d F ≤ C * (((k+1 : ℕ) : ℝ) ^ ArithmeticFunction.cardFactors d / d) * (Real.log v) ^ (20*(k+l : ℕ)*Real.log (k+l : ℕ)+1 : ℝ) := by obtain ⟨C, hC, hbound⟩ := exists_terminal_state_mass_bound refine ⟨C, hC, ?_⟩ filter_upwards [hbound, eventually_gt_atTop (1 : ℝ)] with v hv hv1 intro k l d F hk hl hd hF have hlogv : 0 < Real.log v := Real.log_pos hv1 have h := hv (k+l) (k+1) d (10*(k+l : ℕ)*logLog v) F (by omega) (by omega) hd hF have heq : Real.exp (2*(10*(k+l : ℕ)*logLog v)*Real.log (k+l : ℕ)) * Real.log v = (Real.log v) ^ (20*(k+l : ℕ)*Real.log (k+l : ℕ)+1 : ℝ) := by calc _ = Real.exp (2*(10*(k+l : ℕ)*logLog v)*Real.log (k+l : ℕ)) * Real.exp (Real.log (Real.log v)) := by rw [Real.exp_log hlogv] _ = Real.exp (Real.log (Real.log v) * (20*(k+l : ℕ)*Real.log (k+l : ℕ)+1)) := by rw [← Real.exp_add] congr 1 unfold logLog ring _ = _ := (Real.rpow_def_of_pos hlogv _).symm calc _ ≤ C * (((k+1 : ℕ) : ℝ) ^ ArithmeticFunction.cardFactors d / d) * Real.exp (2*(10*(k+l : ℕ)*logLog v)*Real.log (k+l : ℕ)) * Real.log v := h _ = _ := by rw [mul_assoc, heq] /- Original line 19442: Erdos416Proof.CollisionState.cut_leftValue_support -/ theorem cut_leftValue_support (v : ℝ) {s : CollisionState m n} (hs : Positive s) : ∀ p ∈ (leftValue (cut v s)).primeFactorsList, (p : ℝ) ≤ v := by intro p hp rw [cut_leftValue v hs] at hp exact ((mem_primeFactorsList_primePart _ _ _).mp hp).2 /- Original line 19448: Erdos416Proof.CollisionState.interval_leftValue -/ theorem interval_leftValue (u v : ℝ) {s : CollisionState m n} (hs : Positive s) : leftValue (interval u v s) = primePart (leftValue s) (fun p => u < (p : ℝ) ∧ (p : ℝ) ≤ v) := (primePart_finset_prod Finset.univ s.1 (fun idx _ => (hs.1 idx).ne') _).symm /- Original line 19453: Erdos416Proof.CollisionState.interval_leftValue_support -/ theorem interval_leftValue_support (u v : ℝ) {s : CollisionState m n} (hs : Positive s) : ∀ p ∈ (leftValue (interval u v s)).primeFactorsList, u < (p : ℝ) ∧ (p : ℝ) ≤ v := by intro p hp rw [interval_leftValue u v hs] at hp exact ((mem_primeFactorsList_primePart _ _ _).mp hp).2 /- Original line 19459: Erdos416Proof.CollisionState.interval_leftValue_cardFactors -/ theorem interval_leftValue_cardFactors (u v : ℝ) {s : CollisionState m n} (hs : Positive s) : ArithmeticFunction.cardFactors (leftValue (interval u v s)) = omegaInterval (leftValue s) u v := by rw [interval_leftValue u v hs, primePart_cardFactors] unfold omegaInterval apply List.countP_congr intro p _ simp[Erdos416Proof.omegaInterval_one, Erdos416Proof.twoFormDensity_one] /- Original line 19467: Erdos416Proof.CollisionState.interval_leftValue_squarefree -/ theorem interval_leftValue_squarefree {d : ℕ} {u v : ℝ} {s : CollisionState m n} (hs : Positive s) (hsq : NoLargePrimeSquare (d * leftValue s) u) : Squarefree (leftValue (interval u v s)) := by rw [interval_leftValue u v hs] apply primePart_squarefree_of_no_large_square (leftValue_pos hs).ne' (show NoLargePrimeSquare (leftValue s) u from fun p hp hup hdiv => hsq p hp hup (hdiv.trans (dvd_mul_left _ _))) intro p _ hp exact hp.1 /- Original line 19477: Erdos416Proof.CollisionState.interval_balanced -/ theorem interval_balanced {d : ℕ} {u v : ℝ} {s : CollisionState m n} (hd : 0 < d) (hs : Positive s) (hbal : Balanced d s) (huv : u ≤ v) (hsupport : ∀ p ∈ d.primeFactorsList, (p : ℝ) ≤ u) : Balanced 1 (interval u v s) := by have h := high_balanced hd (cut_positive v s) (cut_balanced hd hs hbal (fun p hp => (hsupport p hp).trans huv)) hsupport simpa only [high_cut_interval] using h /-- The actual left tuple consists of k shifted normal primes followed by l tail factors. Cutting it at v supplies the terminal factor-count bound. -/ /- Original line 19486: Erdos416Proof.CollisionState.terminal_cut_cardFactors_bound -/ theorem terminal_cut_cardFactors_bound {k l : ℕ} {S v : ℝ} (s : CollisionState (k+l) n) (hS : Real.exp 1 ≤ S) (hSv : S ≤ v) (hp : ∀ idx : Fin k, SNormal S (s.1 (Fin.castAdd l idx) + 1)) (hf : ∀ j : Fin l, (ArithmeticFunction.cardFactors (s.1 (Fin.natAdd k j)) : ℝ) ≤ 10*logLog v) : (ArithmeticFunction.cardFactors (leftValue (cut v s)) : ℝ) ≤ 10*(k+l : ℕ)*logLog v := by have hS1 : 1 < S := (Real.one_lt_exp_iff.mpr (by norm_num : (0 : ℝ) < 1)).trans_le hS have hvLL : 0 ≤ logLog v := (logLog_nonneg hS).trans (logLog_mono hS1 hSv) have hprefix (idx : Fin k) : (ArithmeticFunction.cardFactors (lowPrimePart (s.1 (Fin.castAdd l idx)) v) : ℝ) ≤ 3*logLog v := by have h := (hp idx).initial_interval_le_three_mul hS hSv le_rfl simpa only [lowPrimePart_cardFactors, Nat.add_sub_cancel] using h have htail (j : Fin l) : (ArithmeticFunction.cardFactors (lowPrimePart (s.1 (Fin.natAdd k j)) v) : ℝ) ≤ 10*logLog v := by rw [lowPrimePart_cardFactors] have hle : (omegaInterval (s.1 (Fin.natAdd k j)) 1 v : ℝ) ≤ ArithmeticFunction.cardFactors (s.1 (Fin.natAdd k j)) := by exact_mod_cast omegaInterval_le_cardFactors (s.1 (Fin.natAdd k j)) 1 v exact hle.trans (hf j) change (ArithmeticFunction.cardFactors (∏ idx, lowPrimePart (s.1 idx) v) : ℝ) ≤ _ rw [cardFactors_finset_prod Finset.univ (fun idx => lowPrimePart (s.1 idx) v) (fun idx _ => (primePart_pos (s.1 idx) _).ne'), Nat.cast_sum, Fin.sum_univ_add] calc _ ≤ (∑ _i : Fin k, 3*logLog v) + ∑ _j : Fin l, 10*logLog v := add_le_add (Finset.sum_le_sum (fun idx _ => hprefix idx)) (Finset.sum_le_sum (fun j _ => htail j)) _ = (k : ℝ)*(3*logLog v) + (l : ℝ)*(10*logLog v) := by simp[Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, Erdos416Proof.omegaInterval_one, Erdos416Proof.twoFormDensity_one] _ ≤ _ := by push_cast; nlinarith [Nat.cast_nonneg k (α := ℝ)] /- Original line 19514: Erdos416Proof.CollisionState.exists_terminal_cut_state_mass_log_bound -/ theorem exists_terminal_cut_state_mass_log_bound : ∃ C : ℝ, 0 < C ∧ ∀ᶠ v : ℝ in atTop, ∀ (S : ℝ) (k l d : ℕ) (F : Finset (CollisionState (k+l) (k+1))), Real.exp 1 ≤ S → S ≤ v → 1 ≤ k → 1 ≤ l → 0 < d → (∀ p ∈ d.primeFactorsList, (p : ℝ) ≤ v) → (∀ s ∈ F, Positive s ∧ Balanced d s ∧ (∀ idx : Fin k, SNormal S (s.1 (Fin.castAdd l idx) + 1)) ∧ (∀ j : Fin l, (ArithmeticFunction.cardFactors (s.1 (Fin.natAdd k j)) : ℝ) ≤ 10*logLog v)) → reciprocalMass d (lowStates v F) ≤ C * (((k+1 : ℕ) : ℝ) ^ ArithmeticFunction.cardFactors d / d) * (Real.log v) ^ (20*(k+l : ℕ)*Real.log (k+l : ℕ)+1 : ℝ) := by obtain ⟨C, hC, hbound⟩ := exists_terminal_state_mass_log_bound refine ⟨C, hC, ?_⟩ filter_upwards [hbound] with v hv intro S k l d F hS hSv hk hl hd hdv hF apply hv k l d (lowStates v F) hk hl hd intro s hs obtain ⟨a, ha, rfl⟩ := Finset.mem_image.mp hs exact ⟨cut_positive v a, cut_balanced hd (hF a ha).1 (hF a ha).2.1 hdv, cut_leftValue_support v (hF a ha).1, terminal_cut_cardFactors_bound a hS hSv (hF a ha).2.2.1 (hF a ha).2.2.2⟩ /- Original line 19536: Erdos416Proof.CollisionState.lowStates_lowStates -/ theorem lowStates_lowStates (F : Finset (CollisionState m n)) {u v : ℝ} (huv : u ≤ v) : lowStates u (lowStates v F) = lowStates u F := by simp only [lowStates, Finset.image_image, Function.comp_def, cut_cut _ huv] /-- Successive actual finite images; v(i) is the cutoff from level i to i+1. -/ /- Original line 19541: Erdos416Proof.CollisionState.levels -/ noncomputable def levels (v : ℕ → ℝ) (F : Finset (CollisionState m n)) : ℕ → Finset (CollisionState m n) | 0 => F | idx+1 => lowStates (v idx) (levels v F idx) /- Original line 19545: Erdos416Proof.CollisionState.levels_positive -/ theorem levels_positive (v : ℕ → ℝ) (F : Finset (CollisionState m n)) (hF : ∀ s ∈ F, Positive s) (idx : ℕ) : ∀ s ∈ levels v F idx, Positive s := by cases idx with | zero => exact hF | succ idx => intro s hs obtain ⟨a, _, rfl⟩ := Finset.mem_image.mp hs exact cut_positive _ _ /- Original line 19554: Erdos416Proof.CollisionState.levels_eq_cut -/ theorem levels_eq_cut (v : ℕ → ℝ) (hanti : Antitone v) (F : Finset (CollisionState m n)) (idx : ℕ) : levels v F (idx+1) = lowStates (v idx) F := by induction idx with | zero => rfl | succ idx ih => rw [levels, ih, lowStates_lowStates F (hanti (Nat.le_succ idx))] /-- The finite iteration follows from exact splits of the actual images. Only the analytic bound for each compatible high-part fiber is left as an input. -/ /- Original line 19563: Erdos416Proof.CollisionState.reciprocalMass_levels_bound -/ theorem reciprocalMass_levels_bound (d : ℕ) (v : ℕ → ℝ) (F : Finset (CollisionState m n)) (hF : ∀ s ∈ F, Positive s) (B : ℕ → ℝ) (k : ℕ) (hB : ∀ idx < k, 0 ≤ B idx) (hstep : ∀ idx < k, ∀ s ∈ lowStates (v idx) (levels v F idx), (∑ t ∈ (highStates (v idx) (levels v F idx)).filter (fun t => s*t ∈ levels v F idx), (1 : ℝ) / leftValue t) ≤ B idx) : reciprocalMass d F ≤ (∏ idx ∈ Finset.range k, B idx) * reciprocalMass d (levels v F k) := by revert hB hstep induction k with | zero => intro _ _; simp [levels] | succ k ih => intro hB hstep have hprev := ih (fun idx hi => hB idx (Nat.lt_succ_of_lt hi)) (fun idx hi => hstep idx (Nat.lt_succ_of_lt hi)) have hnext := reciprocalMass_le_cut d (v k) (levels v F k) (levels_positive v F hF k) (hstep k (Nat.lt_succ_self k)) calc _ ≤ (∏ idx ∈ Finset.range k, B idx) * reciprocalMass d (levels v F k) := hprev _ ≤ (∏ idx ∈ Finset.range k, B idx) * (B k * reciprocalMass d (levels v F (k+1))) := mul_le_mul_of_nonneg_left hnext (Finset.prod_nonneg fun idx hi => hB idx (Nat.lt_succ_of_lt (Finset.mem_range.mp hi))) _ = _ := by rw [Finset.prod_range_succ]; ring /- Original line 19586: Erdos416Proof.CollisionState.card_le_iterated_reciprocalMass -/ theorem card_le_iterated_reciprocalMass (d : ℕ) (u : ℝ) (v : ℕ → ℝ) (F : Finset (CollisionState m n)) (hF : ∀ s ∈ F, Positive s) {A : ℝ} (hA : 0 ≤ A) (B : ℕ → ℝ) (k : ℕ) (hfirst : ∀ s ∈ lowStates u F, (((highStates u F).filter (fun t => s*t ∈ F)).card : ℝ) ≤ A / ((d : ℝ) * leftValue s)) (hB : ∀ idx < k, 0 ≤ B idx) (hstep : ∀ idx < k, ∀ s ∈ lowStates (v idx) (levels v (lowStates u F) idx), (∑ t ∈ (highStates (v idx) (levels v (lowStates u F) idx)).filter (fun t => s*t ∈ levels v (lowStates u F) idx), (1 : ℝ) / leftValue t) ≤ B idx) : (F.card : ℝ) ≤ A * (∏ idx ∈ Finset.range k, B idx) * reciprocalMass d (levels v (lowStates u F) k) := by have hlow : ∀ s ∈ lowStates u F, Positive s := by intro s hs obtain ⟨a, _, rfl⟩ := Finset.mem_image.mp hs exact cut_positive _ _ have h := (card_le_reciprocalMass d u F hF hfirst).trans (mul_le_mul_of_nonneg_left (reciprocalMass_levels_bound d v (lowStates u F) hlow B k hB hstep) hA) simpa only [mul_assoc] using h /-- Remove trailing unit entries after a prime interval has been separated. -/ /- Original line 19607: Erdos416Proof.CollisionState.prefixState -/ def prefixState (idx r t : ℕ) (s : CollisionState (idx+r) (idx+t)) : CollisionState idx idx := (fun j => s.1 (Fin.castAdd r j), fun j => s.2 (Fin.castAdd t j)) /- Original line 19610: Erdos416Proof.CollisionState.UnitTails -/ def UnitTails {idx r t : ℕ} (s : CollisionState (idx+r) (idx+t)) : Prop := (∀ j : Fin r, s.1 (Fin.natAdd idx j) = 1) ∧ ∀ j : Fin t, s.2 (Fin.natAdd idx j) = 1 /- Original line 19613: Erdos416Proof.CollisionState.prefix_leftValue -/ theorem prefix_leftValue {idx r t : ℕ} {s : CollisionState (idx+r) (idx+t)} (hs : UnitTails s) : leftValue (prefixState idx r t s) = leftValue s := (Fin.prod_trunc s.1 hs.1).symm /- Original line 19616: Erdos416Proof.CollisionState.prefix_rightValue -/ theorem prefix_rightValue {idx r t : ℕ} {s : CollisionState (idx+r) (idx+t)} (hs : UnitTails s) : rightValue (prefixState idx r t s) = rightValue s := (Fin.prod_trunc s.2 hs.2).symm /- Original line 19619: Erdos416Proof.CollisionState.prefix_injOn -/ theorem prefix_injOn {idx r t : ℕ} (F : Finset (CollisionState (idx+r) (idx+t))) (hF : ∀ s ∈ F, UnitTails s) : Set.InjOn (prefixState idx r t) (F : Set _) := by intro s hs a ha heq apply Prod.ext · funext j refine Fin.addCases ?_ ?_ j · intro q exact congrFun (congrArg Prod.fst heq) q · intro q rw [(hF s hs).1 q, (hF a ha).1 q] · funext j refine Fin.addCases ?_ ?_ j · intro q exact congrFun (congrArg Prod.snd heq) q · intro q rw [(hF s hs).2 q, (hF a ha).2 q] /- Original line 19636: Erdos416Proof.CollisionState.reciprocalMass_prefix -/ theorem reciprocalMass_prefix (d : ℕ) {idx r t : ℕ} (F : Finset (CollisionState (idx+r) (idx+t))) (hF : ∀ s ∈ F, UnitTails s) : reciprocalMass d F = reciprocalMass d (F.image (prefixState idx r t)) := by rw [reciprocalMass, reciprocalMass, Finset.sum_image (prefix_injOn F hF)] apply Finset.sum_congr rfl intro s hs rw [prefix_leftValue (hF s hs)] /- Original line 19644: Erdos416Proof.CollisionState.reciprocalMass_squarefree_bound -/ theorem reciprocalMass_squarefree_bound (hi : 1 ≤ m) (hnm : n ≤ m) (F : Finset (CollisionState m n)) (P : Finset ℕ) {I H : ℝ} (hF : ∀ s ∈ F, Balanced 1 s ∧ Squarefree (leftValue s) ∧ (leftValue s).primeFactors ⊆ P ∧ (ArithmeticFunction.cardFactors (leftValue s) : ℝ) ≤ I) (hH : (∑ p ∈ P, (1 : ℝ)/p) ≤ H) : reciprocalMass 1 F ≤ Real.exp (I * Real.log m + (m : ℝ)*H) := by rw [reciprocalMass_fibers] simp only [Nat.cast_one, one_mul] apply finite_dual_ordered_factorization_mass hi hnm (F.image leftValue) P (fun a => F.filter (fun s => leftValue s = a)) · intro a ha obtain ⟨s, hs, rfl⟩ := Finset.mem_image.mp ha exact (hF s hs).2 · intro a _ s hs obtain ⟨hsF, hsa⟩ := Finset.mem_filter.mp hs have hbal := (hF s hsF).1 change 1 * leftValue s = rightValue s at hbal rw [one_mul] at hbal exact ⟨hsa, hbal.symm.trans hsa⟩ · exact hH /- Original line 19665: Erdos416Proof.CollisionState.reciprocalMass_unitTail_bound -/ theorem reciprocalMass_unitTail_bound {idx r t : ℕ} (hi : 1 ≤ idx) (F : Finset (CollisionState (idx+r) (idx+t))) (P : Finset ℕ) {I H : ℝ} (htail : ∀ s ∈ F, UnitTails s) (hF : ∀ s ∈ F, Balanced 1 s ∧ Squarefree (leftValue s) ∧ (leftValue s).primeFactors ⊆ P ∧ (ArithmeticFunction.cardFactors (leftValue s) : ℝ) ≤ I) (hH : (∑ p ∈ P, (1 : ℝ)/p) ≤ H) : reciprocalMass 1 F ≤ Real.exp (I * Real.log idx + (idx : ℝ)*H) := by rw [reciprocalMass_prefix 1 F htail] apply reciprocalMass_squarefree_bound hi le_rfl (F.image (prefixState idx r t)) P _ hH intro s hs obtain ⟨a, ha, rfl⟩ := Finset.mem_image.mp hs simpa only [Balanced, prefix_leftValue (htail a ha), prefix_rightValue (htail a ha)] using hF a ha /- Original line 19678: Erdos416Proof.CollisionState.interval_unitTails -/ theorem interval_unitTails {idx r t : ℕ} {u v : ℝ} (s : CollisionState (idx+r) (idx+t)) (hl : ∀ j : Fin r, ∀ p ∈ (s.1 (Fin.natAdd idx j)).primeFactorsList, (p : ℝ) ≤ u) (hr : ∀ j : Fin t, ∀ p ∈ (s.2 (Fin.natAdd idx j)).primeFactorsList, (p : ℝ) ≤ u) : UnitTails (interval u v s) := by have hpart (a : ℕ) (ha : ∀ p ∈ a.primeFactorsList, (p : ℝ) ≤ u) : primePart a (fun p => u < (p : ℝ) ∧ (p : ℝ) ≤ v) = 1 := by unfold primePart rw [List.filter_eq_nil_iff.mpr (by intro p hp simp only [decide_eq_true_eq] exact fun h => (not_lt_of_ge (ha p hp)) h.1)] rfl exact ⟨fun j => hpart _ (hl j), fun j => hpart _ (hr j)⟩ /- Original line 19692: Erdos416Proof.CollisionState.interval_cardFactors_bound -/ theorem interval_cardFactors_bound {idx r : ℕ} {S u v T : ℝ} (s : CollisionState (idx+r) n) (hs : Positive s) (hS : Real.exp 1 ≤ S) (hSu : S ≤ u) (huv : u < v) (hvT : logLog v ≤ T) (hp : ∀ j : Fin idx, SNormal S (s.1 (Fin.castAdd r j)+1)) (htail : ∀ j : Fin r, ∀ p ∈ (s.1 (Fin.natAdd idx j)).primeFactorsList, (p : ℝ) ≤ u) : (ArithmeticFunction.cardFactors (leftValue (interval u v s)) : ℝ) ≤ (idx : ℝ) * (logLog v - logLog u + Real.sqrt (logLog S * T)) := by rw [interval_leftValue_cardFactors u v hs, leftValue, omegaInterval_prod _ _ (fun j _ => (hs.1 j).ne'), Nat.cast_sum, Fin.sum_univ_add] have hzero : (∑ j : Fin r, (omegaInterval (s.1 (Fin.natAdd idx j)) u v : ℝ)) = 0 := by apply Finset.sum_eq_zero intro j _ rw [omegaInterval_eq_zero_of_support (htail j), Nat.cast_zero] rw [hzero, add_zero] calc _ ≤ ∑ _j : Fin idx, (logLog v - logLog u + Real.sqrt (logLog S * T)) := by apply Finset.sum_le_sum intro j _ simpa only [Nat.add_sub_cancel] using (hp j).interval_upper hS hSu huv hvT _ = _ := by simp [Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, Erdos416Proof.omegaInterval_one, mul_add] /- Original line 19713: Erdos416Proof.CollisionState.normality_interval_error_ge_eventually -/ theorem normality_interval_error_ge_eventually (B : ℝ) : ∀ᶠ Y : ℝ in atTop, ∀ S : ℝ, Real.exp (Real.exp 1) ≤ S → B ≤ Real.sqrt (logLog S * logLog Y) := by have hLL : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [hLL.eventually_ge_atTop (B^2)] with Y hY intro S hS have hS1 : 1 < Real.exp (Real.exp 1) := Real.one_lt_exp_iff.mpr (Real.exp_pos 1) have hLS : 1 ≤ logLog S := by simpa only [logLog, Real.log_exp] using logLog_mono hS1 hS have hLY : 0 ≤ logLog Y := (sq_nonneg B).trans hY have hmul : B^2 ≤ logLog S * logLog Y := hY.trans (le_mul_of_one_le_left hLY hLS) calc B ≤ |B| := le_abs_self B _ = Real.sqrt (B^2) := (Real.sqrt_sq_eq_abs B).symm _ ≤ _ := Real.sqrt_le_sqrt hmul /-- Actual interval-state mass from normal shifted factors and smooth tails. The fixed Mertens error is absorbed by the proved normality error, uniformly in S and the tuple length. The selected-prime savings remain separate. -/ /- Original line 19733: Erdos416Proof.CollisionState.interval_state_mass_eventually -/ theorem interval_state_mass_eventually : ∀ᶠ Y : ℝ in atTop, ∀ (S u v : ℝ) (idx r t d : ℕ) (F : Finset (CollisionState (idx+r) (idx+t))), Real.exp (Real.exp 1) ≤ S → S ≤ u → u < v → v ≤ Y → 1 ≤ idx → 0 < d → (∀ p ∈ d.primeFactorsList, (p : ℝ) ≤ u) → (∀ s ∈ F, Positive s ∧ Balanced d s ∧ NoLargePrimeSquare (d * leftValue s) u ∧ (∀ j : Fin idx, SNormal S (s.1 (Fin.castAdd r j)+1)) ∧ (∀ j : Fin r, ∀ p ∈ (s.1 (Fin.natAdd idx j)).primeFactorsList, (p : ℝ) ≤ u) ∧ (∀ j : Fin t, ∀ p ∈ (s.2 (Fin.natAdd idx j)).primeFactorsList, (p : ℝ) ≤ u)) → reciprocalMass 1 (F.image (interval u v)) ≤ Real.exp ((1+Real.log idx) * ((idx : ℝ) * (logLog v - logLog u + Real.sqrt (logLog S * logLog Y)))) := by obtain ⟨B, hB⟩ := prime_reciprocal_mertens filter_upwards [normality_interval_error_ge_eventually (2*|B|)] with Y hY intro S u v idx r t d F hS hSu huv hvY hi hd hdU hF have hSe : Real.exp 1 ≤ S := (Real.exp_le_exp.mpr (by linarith [Real.add_one_le_exp (1 : ℝ)])).trans hS have hu2 : 2 ≤ u := by linarith [Real.add_one_le_exp (1 : ℝ)] have hv1 : 1 < v := by linarith have hvT : logLog v ≤ logLog Y := logLog_mono hv1 hvY let P := (Nat.primesLE ⌊v⌋₊).filter (fun p : ℕ => u < (p : ℝ) ∧ (p : ℝ) ≤ v) let I := (idx : ℝ) * (logLog v - logLog u + Real.sqrt (logLog S * logLog Y)) let H := logLog v - logLog u + 2*|B| have hH : (∑ p ∈ P, (1 : ℝ)/p) ≤ H := by have h := (abs_le.mp (prime_interval_reciprocal_error hB hu2 huv.le le_rfl)).2 change (∑ p ∈ P, (1 : ℝ)/p) - (logLog v - logLog u) ≤ 2*|B| at h dsimp [Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, H] linarith have htUnit : ∀ s ∈ F.image (interval u v), UnitTails s := by intro s hs obtain ⟨a, ha, rfl⟩ := Finset.mem_image.mp hs exact interval_unitTails a (hF a ha).2.2.2.2.1 (hF a ha).2.2.2.2.2 have hImage : ∀ s ∈ F.image (interval u v), Balanced 1 s ∧ Squarefree (leftValue s) ∧ (leftValue s).primeFactors ⊆ P ∧ (ArithmeticFunction.cardFactors (leftValue s) : ℝ) ≤ I := by intro s hs obtain ⟨a, ha, rfl⟩ := Finset.mem_image.mp hs obtain ⟨hpos, hbal, hsq, hnormal, hleft, hright⟩ := hF a ha refine ⟨interval_balanced hd hpos hbal huv.le hdU, interval_leftValue_squarefree hpos hsq, ?_, interval_cardFactors_bound a hpos hSe hSu huv hvT hnormal hleft⟩ intro p hp have hpList : p ∈ (leftValue (interval u v a)).primeFactorsList := by simpa only [Nat.primeFactors, List.mem_toFinset] using hp have hpRange := interval_leftValue_support u v hpos p hpList exact Finset.mem_filter.mpr ⟨Nat.mem_primesLE.mpr ⟨Nat.le_floor hpRange.2, Nat.prime_of_mem_primeFactors hp⟩, hpRange⟩ have hmass := reciprocalMass_unitTail_bound hi (F.image (interval u v)) P htUnit hImage hH have hroom : (idx : ℝ)*H ≤ I := by dsimp [Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, H, I] exact mul_le_mul_of_nonneg_left (add_le_add le_rfl (hY S hS)) (Nat.cast_nonneg idx) exact hmass.trans (Real.exp_le_exp.mpr (by change I * Real.log idx + (idx : ℝ)*H ≤ (1+Real.log idx)*I nlinarith)) end CollisionState end Erdos416Proof open Filter Asymptotics MeasureTheory open scoped BigOperators Classical Topology namespace Erdos416Proof /- Original line 19803: Erdos416Proof.exists_threeFormPrimeSet_bound_log_lower -/ theorem exists_threeFormPrimeSet_bound_log_lower : ∃ C : ℝ, 0 < C ∧ ∀ᶠ Y : ℝ in atTop, ∀ (a b : ℕ) (X L : ℝ) (Q : Finset ℕ), 0 < a → a < b → (b : ℝ) ≤ Y → 0 ≤ X → 0 < L → (∀ q ∈ Q, q.Prime ∧ (a*q+1).Prime ∧ (b*q+1).Prime ∧ (q : ℝ) ≤ X ∧ L ≤ Real.log q) → (Q.card : ℝ) ≤ C * logLog Y^3 * X / L^3 := by obtain ⟨C, hC, hcount⟩ := exists_threeFormPrimeSet_bound_of_coefficients_le refine ⟨C, hC, ?_⟩ filter_upwards [hcount, eventually_ge_atTop (3 : ℝ)] with Y hY hY3 intro a b X L Q ha hab hbY hX hL hQ have hLL : 0 ≤ logLog Y := (logLog_pos_of_three_le hY3).le by_cases hempty : Q = ∅ · simp only [hempty, Finset.card_empty, Nat.cast_zero] positivity obtain ⟨q, hq⟩ := Finset.nonempty_iff_ne_empty.mpr hempty have hX2 : 2 ≤ X := (by exact_mod_cast (hQ q hq).1.two_le : (2 : ℝ) ≤ q).trans (hQ q hq).2.2.2.1 have hLX : L ≤ Real.log X := (hQ q hq).2.2.2.2.trans (Real.log_le_log (by exact_mod_cast (hQ q hq).1.pos) (hQ q hq).2.2.2.1) calc _ ≤ C * logLog Y^3 * X / Real.log X^3 := hY a b X Q ha hab hbY hX2 (fun q hq => ⟨(hQ q hq).1, (hQ q hq).2.1, (hQ q hq).2.2.1, (hQ q hq).2.2.2.1⟩) _ ≤ _ := div_le_div_of_nonneg_left (by positivity) (by positivity) (pow_le_pow_left₀ hL.le hLX 3) /-- Counting actual integers by a chosen prime divisor, while requiring both shifted multiples to be prime. The cofactor family is constructed from F. -/ /- Original line 19830: Erdos416Proof.exists_threeForm_selected_prime_cofactor_bound -/ theorem exists_threeForm_selected_prime_cofactor_bound : ∃ C : ℝ, 0 < C ∧ ∀ᶠ Y : ℝ in atTop, ∀ (a b : ℕ) (F : Finset ℕ) (p : ℕ → ℕ) (X L : ℝ), 0 < a → a < b → 0 < X → 0 < L → (∀ t ∈ F, 0 < t ∧ (t : ℝ) ≤ X ∧ (p t).Prime ∧ p t ∣ t ∧ L ≤ Real.log (p t) ∧ (a*t+1).Prime ∧ (b*t+1).Prime ∧ ((b*t : ℕ) : ℝ) ≤ Y) → (F.card : ℝ) ≤ C * logLog Y^3 * X / L^3 * ∑ c ∈ cofactorSet F p, (1 : ℝ) / c := by obtain ⟨C, hC, hcount⟩ := exists_threeFormPrimeSet_bound_log_lower refine ⟨C, hC, ?_⟩ filter_upwards [hcount] with Y hY intro a b F p X L ha hab hX hL hF let B := cofactorSet F p let Q (c : ℕ) := (Nat.primesLE ⌊X / c⌋₊).filter (fun q => (a*c*q+1).Prime ∧ (b*c*q+1).Prime ∧ L ≤ Real.log q) have hcofactor (t : ℕ) (ht : t ∈ F) : 0 < t / p t := Nat.div_pos (Nat.le_of_dvd (hF t ht).1 (hF t ht).2.2.2.1) (hF t ht).2.2.1.pos have hqbound (t : ℕ) (ht : t ∈ F) : (p t : ℝ) ≤ X / (t / p t : ℕ) := by have hcR : (0 : ℝ) < (t / p t : ℕ) := by exact_mod_cast hcofactor t ht apply (le_div_iff₀ hcR).mpr have hmul : (p t : ℝ) * (t / p t : ℕ) = t := by exact_mod_cast Nat.mul_div_cancel' (hF t ht).2.2.2.1 exact hmul.trans_le (hF t ht).2.1 have hQmem (t : ℕ) (ht : t ∈ F) : p t ∈ Q (t / p t) := by have hprod := Nat.div_mul_cancel (hF t ht).2.2.2.1 refine Finset.mem_filter.mpr ⟨Nat.mem_primesLE.mpr ⟨Nat.le_floor (hqbound t ht), (hF t ht).2.2.1⟩, ?_⟩ simpa only [mul_assoc, hprod] using ⟨(hF t ht).2.2.2.2.2.1, (hF t ht).2.2.2.2.2.2.1, (hF t ht).2.2.2.2.1⟩ have hcard : F.card ≤ (B.sigma Q).card := by apply Finset.card_le_card_of_injOn (fun t => (⟨t / p t, p t⟩ : Σ _ : ℕ, ℕ)) · intro t ht exact Finset.mem_sigma.mpr ⟨Finset.mem_image.mpr ⟨t, ht, rfl⟩, hQmem t ht⟩ · intro t ht z hz heq have hc : t / p t = z / p z := congrArg Sigma.fst heq have hp : p t = p z := congrArg (fun s : Σ _ : ℕ, ℕ => s.2) heq calc t = (t / p t) * p t := (Nat.div_mul_cancel (hF t ht).2.2.2.1).symm _ = (z / p z) * p z := by rw [hc, hp] _ = z := Nat.div_mul_cancel (hF z hz).2.2.2.1 have hsum : (F.card : ℝ) ≤ ∑ c ∈ B, ((Q c).card : ℝ) := by exact_mod_cast (by simpa only [Finset.card_sigma] using hcard) calc _ ≤ ∑ c ∈ B, ((Q c).card : ℝ) := hsum _ ≤ ∑ c ∈ B, (C * logLog Y^3 * X / L^3) * ((1 : ℝ)/c) := by apply Finset.sum_le_sum intro c hc obtain ⟨t, ht, rfl⟩ := Finset.mem_image.mp hc have hcpos := hcofactor t ht have hbc : ((b*(t / p t) : ℕ) : ℝ) ≤ Y := (Nat.cast_le.mpr (Nat.mul_le_mul_left b (Nat.div_le_self t (p t)))).trans (hF t ht).2.2.2.2.2.2.2 have h := hY (a*(t / p t)) (b*(t / p t)) (X / (t / p t : ℕ)) L (Q (t / p t)) (Nat.mul_pos ha hcpos) (Nat.mul_lt_mul_of_pos_right hab hcpos) hbc (by positivity) hL (by intro q hq obtain ⟨hqp, hpa, hpb, hqL⟩ := Finset.mem_filter.mp hq exact ⟨Nat.prime_of_mem_primesLE hqp, hpa, hpb, (Nat.cast_le.mpr (Nat.mem_primesLE.mp hqp).1).trans (Nat.floor_le (by positivity)), hqL⟩) calc _ ≤ C * logLog Y^3 * (X / (t / p t : ℕ)) / L^3 := h _ = _ := by ring _ = _ := (Finset.mul_sum _ _ _).symm /- Original line 19893: Erdos416Proof.largestPrimeFactor_log_lower_of_large -/ theorem largestPrimeFactor_log_lower_of_large {Y : ℝ} {t : ℕ} (hY : 4 ≤ Y) (ht : Real.sqrt Y ≤ (t : ℝ)) (hOmega : (ArithmeticFunction.cardFactors t : ℝ) ≤ 3*logLog Y) : (largestPrimeFactor t).Prime ∧ Real.log Y / (6*logLog Y) ≤ Real.log (largestPrimeFactor t) := by have hY0 : 0 < Y := by linarith have hsqrt2 : (2 : ℝ) ≤ Real.sqrt Y := Real.le_sqrt_of_sq_le (by norm_num; exact hY) have ht1 : 1 < t := by exact_mod_cast (show (1 : ℝ) < t by linarith) have hp := largestPrimeFactor_isPrime (largestPrimeFactor_one_lt ht1) have hLL : 0 < logLog Y := logLog_pos_of_three_le (by linarith) have hln : Real.log Y / 2 ≤ Real.log t := by simpa only [Real.log_sqrt hY0.le] using Real.log_le_log (Real.sqrt_pos.mpr hY0) ht have hlogQ : 0 ≤ Real.log (largestPrimeFactor t) := Real.log_nonneg (by exact_mod_cast hp.one_le) have hsum := log_le_cardFactors_mul_log_largestPrimeFactor (by omega : 0 < t) have hmul := mul_le_mul_of_nonneg_right hOmega hlogQ refine ⟨hp, (div_le_iff₀ (by positivity : 0 < 6*logLog Y)).mpr ?_⟩ nlinarith /-- The actual large rough factors in the initial sieve step. The constant is uniform in both coefficients and in the smaller counting endpoint X. -/ /- Original line 19913: Erdos416Proof.exists_initial_rough_shifted_pair_count -/ theorem exists_initial_rough_shifted_pair_count : ∃ C : ℝ, 0 < C ∧ ∀ᶠ v : ℝ in atTop, ∀ (Y X : ℝ) (a b : ℕ) (F : Finset ℕ), v ≤ Y → 0 < X → 0 < a → a < b → (∀ t ∈ F, Real.sqrt Y ≤ (t : ℝ) ∧ (t : ℝ) ≤ X ∧ (a*t+1).Prime ∧ (b*t+1).Prime ∧ ((b*t : ℕ) : ℝ) ≤ Y ∧ (∀ p ∈ t.primeFactorsList, v < (p : ℝ)) ∧ (ArithmeticFunction.cardFactors t : ℝ) ≤ 3*logLog Y) → (F.card : ℝ) ≤ C * X * logLog Y^6 / (Real.log Y^2 * Real.log v) := by obtain ⟨K, hK, hcount⟩ := exists_threeForm_selected_prime_cofactor_bound obtain ⟨R, hR, hrough⟩ := exists_rough_reciprocal_sum_bound obtain ⟨Y₀, hY₀⟩ := eventually_atTop.mp hcount refine ⟨216*K*R, by positivity, ?_⟩ filter_upwards [hrough, eventually_ge_atTop Y₀, eventually_ge_atTop (4 : ℝ)] with v hv hvY₀ hv4 intro Y X a b F hvY hX ha hab hF have hY4 : 4 ≤ Y := hv4.trans hvY have hlogY : 0 < Real.log Y := Real.log_pos (by linarith) have hlogv : 0 < Real.log v := Real.log_pos (by linarith) have hLL : 0 < logLog Y := logLog_pos_of_three_le (by linarith) let L := Real.log Y / (6*logLog Y) have hL : 0 < L := by dsimp [Erdos416Proof.largestPrimeFactor_one, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, L]; positivity have htpos (t : ℕ) (ht : t ∈ F) : 0 < t := by have h2 : (2 : ℝ) ≤ Real.sqrt Y := Real.le_sqrt_of_sq_le (by norm_num; exact hY4) exact_mod_cast (show (0 : ℝ) < t by linarith [(hF t ht).1]) have hprime (t : ℕ) (ht : t ∈ F) := largestPrimeFactor_log_lower_of_large hY4 (hF t ht).1 (hF t ht).2.2.2.2.2.2 have hselected := hY₀ Y (hvY₀.trans hvY) a b F largestPrimeFactor X L ha hab hX hL (by intro t ht exact ⟨htpos t ht, (hF t ht).2.1, (hprime t ht).1, largestPrimeFactor_dvd t, (hprime t ht).2, (hF t ht).2.2.1, (hF t ht).2.2.2.1, (hF t ht).2.2.2.2.1⟩) have hcofactors : ∀ c ∈ cofactorSet F largestPrimeFactor, 0 < c ∧ ∀ p ∈ c.primeFactorsList, v < (p : ℝ) ∧ (p : ℝ) ≤ Y := by intro c hc obtain ⟨t, ht, rfl⟩ := Finset.mem_image.mp hc have ht0 := htpos t ht have hdiv := largestPrimeFactor_dvd t refine ⟨Nat.div_pos (Nat.le_of_dvd ht0 hdiv) (hprime t ht).1.pos, ?_⟩ intro p hp have hpt : p ∈ t.primeFactorsList := (Nat.mem_primeFactorsList ht0.ne').mpr ⟨Nat.prime_of_mem_primeFactorsList hp, (Nat.dvd_of_mem_primeFactorsList hp).trans (Nat.div_dvd_of_dvd hdiv)⟩ have htY : (t : ℝ) ≤ Y := (Nat.cast_le.mpr (Nat.le_mul_of_pos_left t (by omega : 0 < b))).trans (hF t ht).2.2.2.2.1 exact ⟨(hF t ht).2.2.2.2.2.1 p hpt, (Nat.cast_le.mpr (Nat.le_of_mem_primeFactorsList hpt)).trans htY⟩ have hsum := hv Y (cofactorSet F largestPrimeFactor) hvY hcofactors calc _ ≤ K * logLog Y^3 * X / L^3 * ∑ c ∈ cofactorSet F largestPrimeFactor, (1 : ℝ)/c := hselected _ ≤ (K * logLog Y^3 * X / L^3) * (R * Real.log Y / Real.log v) := mul_le_mul_of_nonneg_left hsum (by positivity) _ = _ := by dsimp [Erdos416Proof.largestPrimeFactor_one, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, L]; field_simp; ring /- Original line 19964: Erdos416Proof.primePart_cardFactors_le -/ theorem primePart_cardFactors_le (n : ℕ) (A : ℕ → Prop) : ArithmeticFunction.cardFactors (primePart n A) ≤ ArithmeticFunction.cardFactors n := by rw [primePart_cardFactors, ArithmeticFunction.cardFactors_apply] exact List.countP_le_length /- Original line 19969: Erdos416Proof.SNormal.highPrimePart_cardFactors_le -/ theorem SNormal.highPrimePart_cardFactors_le {S v Y : ℝ} {p : ℕ} (hp : SNormal S p) (hS : Real.exp 1 ≤ S) (hSY : S ≤ Y) (hpY : ((p-1 : ℕ) : ℝ) ≤ Y) : (ArithmeticFunction.cardFactors (highPrimePart (p-1) v) : ℝ) ≤ 3*logLog Y := by have hp0 : 0 < p-1 := by have h := hp.1.two_le; omega have hself : lowPrimePart (p-1) Y = p-1 := primePart_eq_self hp0.ne' _ (by intro q hq exact (Nat.cast_le.mpr (Nat.le_of_mem_primeFactorsList hq)).trans hpY) have h := hp.initial_interval_le_three_mul hS hSY le_rfl rw [← lowPrimePart_cardFactors, hself] at h have hpart : (ArithmeticFunction.cardFactors (highPrimePart (p-1) v) : ℝ) ≤ ArithmeticFunction.cardFactors (p-1) := by exact_mod_cast primePart_cardFactors_le (p-1) (fun q => v < (q : ℝ)) exact hpart.trans h /- Original line 19983: Erdos416Proof.exists_initial_rough_shifted_pair_count_unordered -/ theorem exists_initial_rough_shifted_pair_count_unordered : ∃ C : ℝ, 0 < C ∧ ∀ᶠ v : ℝ in atTop, ∀ (Y X : ℝ) (a b : ℕ) (F : Finset ℕ), v ≤ Y → 0 < X → 0 < a → 0 < b → a ≠ b → (∀ t ∈ F, Real.sqrt Y ≤ (t : ℝ) ∧ (t : ℝ) ≤ X ∧ (a*t+1).Prime ∧ (b*t+1).Prime ∧ ((a*t : ℕ) : ℝ) ≤ Y ∧ ((b*t : ℕ) : ℝ) ≤ Y ∧ (∀ p ∈ t.primeFactorsList, v < (p : ℝ)) ∧ (ArithmeticFunction.cardFactors t : ℝ) ≤ 3*logLog Y) → (F.card : ℝ) ≤ C * X * logLog Y^6 / (Real.log Y^2 * Real.log v) := by obtain ⟨C, hC, hbound⟩ := exists_initial_rough_shifted_pair_count refine ⟨C, hC, ?_⟩ filter_upwards [hbound] with v hv intro Y X a b F hvY hX ha hb hne hF rcases lt_or_gt_of_ne hne with hab | hba · apply hv Y X a b F hvY hX ha hab intro t ht obtain ⟨htY, htX, hpa, hpb, _, hbY, hrough, hOmega⟩ := hF t ht exact ⟨htY, htX, hpa, hpb, hbY, hrough, hOmega⟩ · apply hv Y X b a F hvY hX hb hba intro t ht obtain ⟨htY, htX, hpa, hpb, haY, _, hrough, hOmega⟩ := hF t ht exact ⟨htY, htX, hpb, hpa, haY, hrough, hOmega⟩ /- Original line 20007: Erdos416Proof.dvd_highPrimePart_of_support -/ theorem dvd_highPrimePart_of_support {D n : ℕ} {v : ℝ} (hn : n ≠ 0) (hDn : D ∣ n) (hD : ∀ p ∈ D.primeFactorsList, v < (p : ℝ)) : D ∣ highPrimePart n v := by have hD0 : D ≠ 0 := ne_zero_of_dvd_ne_zero hn hDn have hself := primePart_eq_self hD0 (fun p => v < (p : ℝ)) hD have h := primePart_dvd_of_dvd hn hDn (fun p => v < (p : ℝ)) rwa [hself] at h /- Original line 20014: Erdos416Proof.normal_highPrimePart_large_eventually -/ theorem normal_highPrimePart_large_eventually : ∀ᶠ Y : ℝ in atTop, ∀ (p : ℕ) (S v : ℝ), SNormal S p → Real.exp 1 ≤ S → S ≤ v → v ≤ Y ^ (1 / (10 * logLog Y)) → Y ^ (9 / 10 : ℝ) < p → Real.sqrt Y ≤ (highPrimePart (p-1) v : ℝ) := by filter_upwards [large_rough_divisor_eventually] with Y hY intro p S v hp hS hSv hcut htop obtain ⟨D, hD, hdiv, hsize, hrough⟩ := hY p S v hp hS hSv hcut htop have hp0 : p-1 ≠ 0 := by have h := hp.1.two_le; omega have hhigh : D ∣ highPrimePart (p-1) v := dvd_highPrimePart_of_support hp0 hdiv (by intro q hq exact hrough q (Nat.prime_of_mem_primeFactorsList hq) (Nat.dvd_of_mem_primeFactorsList hq)) have hle : (D : ℝ) ≤ highPrimePart (p-1) v := by exact_mod_cast Nat.le_of_dvd (primePart_pos (p-1) _) hhigh simpa only [Real.sqrt_eq_rpow] using hsize.trans hle end Erdos416Proof /- The initial rough-factor sieve applied to actual compatible state fibers. Every integer-sieve hypothesis and the sum over original solutions are proved. -/ open Filter Asymptotics MeasureTheory open scoped BigOperators Classical Topology namespace Erdos416Proof.CollisionState /- Original line 20045: Erdos416Proof.CollisionState.left_entry_le -/ theorem left_entry_le {m n : ℕ} {s : CollisionState m n} (hs : Positive s) (j : Fin m) : s.1 j ≤ leftValue s := Nat.le_of_dvd (leftValue_pos hs) (Finset.dvd_prod_of_mem s.1 (Finset.mem_univ j)) /- Original line 20049: Erdos416Proof.CollisionState.right_entry_le -/ theorem right_entry_le {m n : ℕ} {s : CollisionState m n} (hs : Positive s) (j : Fin n) : s.2 j ≤ rightValue s := Nat.le_of_dvd (rightValue_pos hs) (Finset.dvd_prod_of_mem s.2 (Finset.mem_univ j)) /- Original line 20053: Erdos416Proof.CollisionState.high_unitTails -/ theorem high_unitTails {idx r t : ℕ} {v : ℝ} (s : CollisionState (idx+r) (idx+t)) (hl : ∀ j : Fin r, ∀ p ∈ (s.1 (Fin.natAdd idx j)).primeFactorsList, (p : ℝ) ≤ v) (hr : ∀ j : Fin t, ∀ p ∈ (s.2 (Fin.natAdd idx j)).primeFactorsList, (p : ℝ) ≤ v) : UnitTails (high v s) := by have hpart (a : ℕ) (ha : ∀ p ∈ a.primeFactorsList, (p : ℝ) ≤ v) : highPrimePart a v = 1 := by unfold highPrimePart primePart rw [List.filter_eq_nil_iff.mpr (by intro p hp simp only [decide_eq_true_eq] exact not_lt_of_ge (ha p hp))] rfl exact ⟨fun j => hpart _ (hl j), fun j => hpart _ (hr j)⟩ /- Original line 20067: Erdos416Proof.CollisionState.leftValue_eq_head -/ theorem leftValue_eq_head {r t : ℕ} {s : CollisionState (1+r) (1+t)} (hs : UnitTails (idx := 1) s) : leftValue s = s.1 0 := by rw [← prefix_leftValue hs] simp only [leftValue, prefixState, Fin.prod_univ_one] congr 1 /- Original line 20073: Erdos416Proof.CollisionState.rightValue_eq_head -/ theorem rightValue_eq_head {r t : ℕ} {s : CollisionState (1+r) (1+t)} (hs : UnitTails (idx := 1) s) : rightValue s = s.2 0 := by rw [← prefix_rightValue hs] simp only [rightValue, prefixState, Fin.prod_univ_one] congr 1 /- Original line 20079: Erdos416Proof.CollisionState.right_head_eq_leftValue -/ theorem right_head_eq_leftValue {r t : ℕ} {s : CollisionState (1+r) (1+t)} (hs : UnitTails (idx := 1) s) (hbal : Balanced 1 s) : s.2 0 = leftValue s := by rw [← rightValue_eq_head hs] simpa only [Balanced, one_mul] using hbal.symm /- Original line 20084: Erdos416Proof.CollisionState.leftValue_injOn_unitTails -/ theorem leftValue_injOn_unitTails {r t : ℕ} (F : Finset (CollisionState (1+r) (1+t))) (htail : ∀ s ∈ F, UnitTails (idx := 1) s) (hbal : ∀ s ∈ F, Balanced 1 s) : Set.InjOn (fun s : CollisionState (1+r) (1+t) => leftValue s) (F : Set _) := by intro s hs a ha heq apply prefix_injOn (idx := 1) F htail hs ha apply Prod.ext · funext j have hj : j = 0 := Subsingleton.elim _ _ subst j change s.1 0 = a.1 0 rw [← leftValue_eq_head (htail s hs), ← leftValue_eq_head (htail a ha)] exact heq · funext j have hj : j = 0 := Subsingleton.elim _ _ subst j change s.2 0 = a.2 0 rw [right_head_eq_leftValue (htail s hs) (hbal s hs), right_head_eq_leftValue (htail a ha) (hbal a ha)] exact heq /-- Conditions on an original ordered solution at the first prime cutoff. The first entries are the two shifted primes; the other entries have only prime factors at most v. The external size multiplier R is separate from d. -/ /- Original line 20107: Erdos416Proof.CollisionState.InitialConditions -/ structure InitialConditions {r t : ℕ} (S v Y R : ℝ) (d : ℕ) (s : CollisionState (1+r) (1+t)) : Prop where positive : Positive s balanced : Balanced d s size : R * (d : ℝ) * leftValue s ≤ Y left_normal : SNormal S (s.1 0 + 1) right_prime : (s.2 0 + 1).Prime heads_ne : s.1 0 ≠ s.2 0 top : Y ^ (9 / 10 : ℝ) < (s.1 0 + 1 : ℕ) left_tail : ∀ j : Fin r, ∀ p ∈ (s.1 (Fin.natAdd 1 j)).primeFactorsList, (p : ℝ) ≤ v right_tail : ∀ j : Fin t, ∀ p ∈ (s.2 (Fin.natAdd 1 j)).primeFactorsList, (p : ℝ) ≤ v /- Original line 20119: Erdos416Proof.CollisionState.InitialConditions.left_head_le -/ theorem InitialConditions.left_head_le {r t d : ℕ} {S v Y R : ℝ} {s : CollisionState (1+r) (1+t)} (hs : InitialConditions S v Y R d s) (hd : 0 < d) (hR : 1 ≤ R) : (s.1 0 : ℝ) ≤ Y := by have hd1 : (1 : ℝ) ≤ d := by exact_mod_cast hd have hprod : (1 : ℝ) ≤ R * d := hR.trans (le_mul_of_one_le_right (by linarith : 0 ≤ R) hd1) exact (Nat.cast_le.mpr (left_entry_le hs.positive 0)).trans ((le_mul_of_one_le_left (Nat.cast_nonneg _) hprod).trans hs.size) /- Original line 20128: Erdos416Proof.CollisionState.InitialConditions.right_head_le -/ theorem InitialConditions.right_head_le {r t d : ℕ} {S v Y R : ℝ} {s : CollisionState (1+r) (1+t)} (hs : InitialConditions S v Y R d s) (hR : 1 ≤ R) : (s.2 0 : ℝ) ≤ Y := by have hbal : ((rightValue s : ℕ) : ℝ) = (d : ℝ) * leftValue s := by exact_mod_cast hs.balanced.symm calc _ ≤ (rightValue s : ℝ) := Nat.cast_le.mpr (right_entry_le hs.positive 0) _ = (d : ℝ) * leftValue s := hbal _ ≤ R * ((d : ℝ) * leftValue s) := le_mul_of_one_le_left (by positivity) hR _ ≤ Y := by simpa only [mul_assoc] using hs.size /-- The initial integer sieve applies to every actual compatible high fiber. The hypotheses concern the original solutions, not an auxiliary superset. -/ /- Original line 20142: Erdos416Proof.CollisionState.exists_initial_state_fiber_bound -/ theorem exists_initial_state_fiber_bound : ∃ C : ℝ, 0 < C ∧ ∀ᶠ v : ℝ in atTop, ∀ (Y R S : ℝ) (r t d : ℕ) (F : Finset (CollisionState (1+r) (1+t))), v ≤ Y → 1 ≤ R → Real.exp 1 ≤ S → S ≤ v → v ≤ Y ^ (1 / (10 * logLog Y)) → 0 < d → (∀ p ∈ d.primeFactorsList, (p : ℝ) ≤ v) → (∀ s ∈ F, InitialConditions S v Y R d s) → ∀ sigma ∈ lowStates v F, (((highStates v F).filter (fun tau => sigma*tau ∈ F)).card : ℝ) ≤ (C * Y * logLog Y^6 / (R * Real.log Y^2 * Real.log v)) / ((d : ℝ) * leftValue sigma) := by obtain ⟨C, hC, hcount⟩ := exists_initial_rough_shifted_pair_count_unordered obtain ⟨Y₀, hY₀⟩ := eventually_atTop.mp normal_highPrimePart_large_eventually refine ⟨C, hC, ?_⟩ filter_upwards [hcount, eventually_ge_atTop (max (4 : ℝ) Y₀)] with v hv hv₀ intro Y R S r t d F hvY hR hS hSv hcut hd hdv hF sigma hsigma have hv4 : (4 : ℝ) ≤ v := (le_max_left _ _).trans hv₀ have hYY₀ : Y₀ ≤ Y := ((le_max_right _ _).trans hv₀).trans hvY have hYpos : 0 < Y := by linarith have hRpos : 0 < R := by linarith have hdpos : (0 : ℝ) < d := Nat.cast_pos.mpr hd have hlogY : 0 < Real.log Y := Real.log_pos (by linarith) have hlogv : 0 < Real.log v := Real.log_pos (by linarith) have hsigmaPos : Positive sigma := by obtain ⟨s, _, rfl⟩ := Finset.mem_image.mp hsigma exact cut_positive _ _ have hsigmaVal : (0 : ℝ) < leftValue sigma := Nat.cast_pos.mpr (leftValue_pos hsigmaPos) let G := (highStates v F).filter (fun tau => sigma*tau ∈ F) have hproperties (tau : CollisionState (1+r) (1+t)) (htau : tau ∈ G) : Positive tau ∧ UnitTails (idx := 1) tau ∧ Balanced 1 tau ∧ leftValue tau = highPrimePart ((sigma*tau).1 0) v := by obtain ⟨hhigh, horig⟩ := Finset.mem_filter.mp htau have hcond := hF _ horig have hrec := (recover_split hsigma hhigh).2 have htail : UnitTails (idx := 1) tau := by rw [← hrec] exact high_unitTails _ hcond.left_tail hcond.right_tail refine ⟨?_, htail, ?_, ?_⟩ · rw [← hrec] exact high_positive _ _ · rw [← hrec] exact high_balanced hd hcond.positive hcond.balanced hdv · calc leftValue tau = tau.1 0 := leftValue_eq_head htail _ = _ := congrArg (fun s : CollisionState (1+r) (1+t) => s.1 0) hrec.symm change (G.card : ℝ) ≤ _ by_cases hGempty : G = ∅ · rw [hGempty, Finset.card_empty, Nat.cast_zero] positivity have hGnonempty : G.Nonempty := Finset.nonempty_iff_ne_empty.mpr hGempty let a := sigma.1 0 let b := sigma.2 0 have ha : 0 < a := hsigmaPos.1 0 have hb : 0 < b := hsigmaPos.2 0 have hleft (tau : CollisionState (1+r) (1+t)) (htau : tau ∈ G) : (sigma*tau).1 0 = a * leftValue tau := by change a * tau.1 0 = a * leftValue tau rw [leftValue_eq_head (hproperties tau htau).2.1] have hright (tau : CollisionState (1+r) (1+t)) (htau : tau ∈ G) : (sigma*tau).2 0 = b * leftValue tau := by change b * tau.2 0 = b * leftValue tau rw [right_head_eq_leftValue (hproperties tau htau).2.1 (hproperties tau htau).2.2.1] have hab : a ≠ b := by intro hab obtain ⟨tau, htau⟩ := hGnonempty apply (hF _ (Finset.mem_filter.mp htau).2).heads_ne rw [hleft tau htau, hright tau htau, hab] let X := Y / (R * (d : ℝ) * leftValue sigma) have hdenpos : 0 < R * (d : ℝ) * leftValue sigma := by positivity have hX : 0 < X := div_pos hYpos hdenpos have himage : ∀ z ∈ G.image leftValue, Real.sqrt Y ≤ (z : ℝ) ∧ (z : ℝ) ≤ X ∧ (a*z+1).Prime ∧ (b*z+1).Prime ∧ ((a*z : ℕ) : ℝ) ≤ Y ∧ ((b*z : ℕ) : ℝ) ≤ Y ∧ (∀ p ∈ z.primeFactorsList, v < (p : ℝ)) ∧ (ArithmeticFunction.cardFactors z : ℝ) ≤ 3*logLog Y := by intro z hz obtain ⟨tau, htau, rfl⟩ := Finset.mem_image.mp hz have hcond := hF _ (Finset.mem_filter.mp htau).2 have hhigh := (hproperties tau htau).2.2.2 have hlarge := hY₀ Y hYY₀ ((sigma*tau).1 0 + 1) S v hcond.left_normal hS hSv hcut hcond.top have hOmega := hcond.left_normal.highPrimePart_cardFactors_le (v := v) hS (hSv.trans hvY) (by simpa only [Nat.add_sub_cancel] using hcond.left_head_le hd hR) refine ⟨?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_⟩ · simpa only [Nat.add_sub_cancel, ← hhigh] using hlarge · have hsize : (R * (d : ℝ) * leftValue sigma) * leftValue tau ≤ Y := by simpa only [leftValue_mul, Nat.cast_mul, mul_assoc] using hcond.size apply (le_div_iff₀ hdenpos).mpr rw [mul_comm] exact hsize · rw [← hleft tau htau] exact hcond.left_normal.1 · rw [← hright tau htau] exact hcond.right_prime · rw [← hleft tau htau] exact hcond.left_head_le hd hR · rw [← hright tau htau] exact hcond.right_head_le hR · intro p hp rw [hhigh] at hp exact (mem_primeFactorsList_primePart _ p (fun q => v < (q : ℝ))).mp hp |>.2 · simpa only [Nat.add_sub_cancel, ← hhigh] using hOmega have hbound := hv Y X a b (G.image leftValue) hvY hX ha hb hab himage have hinj := leftValue_injOn_unitTails G (fun tau htau => (hproperties tau htau).2.1) (fun tau htau => (hproperties tau htau).2.2.1) rw [Finset.card_image_of_injOn hinj] at hbound calc _ ≤ C * X * logLog Y^6 / (Real.log Y^2 * Real.log v) := hbound _ = _ := by dsimp [Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, Erdos416Proof.omegaInterval_one, Erdos416Proof.twoFormDensity_one, X]; field_simp /-- Summing the initial bounds over the actual low states gives the first step of the collision count with its full d and R dependence. -/ /- Original line 20255: Erdos416Proof.CollisionState.exists_initial_state_card_bound -/ theorem exists_initial_state_card_bound : ∃ C : ℝ, 0 < C ∧ ∀ᶠ v : ℝ in atTop, ∀ (Y R S : ℝ) (r t d : ℕ) (F : Finset (CollisionState (1+r) (1+t))), v ≤ Y → 1 ≤ R → Real.exp 1 ≤ S → S ≤ v → v ≤ Y ^ (1 / (10 * logLog Y)) → 0 < d → (∀ p ∈ d.primeFactorsList, (p : ℝ) ≤ v) → (∀ s ∈ F, InitialConditions S v Y R d s) → (F.card : ℝ) ≤ (C * Y * logLog Y^6 / (R * Real.log Y^2 * Real.log v)) * reciprocalMass d (lowStates v F) := by obtain ⟨C, hC, hbound⟩ := exists_initial_state_fiber_bound refine ⟨C, hC, ?_⟩ filter_upwards [hbound] with v hv intro Y R S r t d F hvY hR hS hSv hcut hd hdv hF exact card_le_reciprocalMass d v F (fun s hs => (hF s hs).positive) (hv Y R S r t d F hvY hR hS hSv hcut hd hdv hF) end Erdos416Proof.CollisionState /- Prime removal, exact weighted reconstruction, and the shared-largest-prime case for actual middle compatible fibers. The different-prime cases remain. -/ open Filter Asymptotics MeasureTheory open scoped BigOperators Classical Topology namespace Erdos416Proof.CollisionState variable {m n : ℕ} /-- Remove one copy of q from a specified entry on each side. -/ /- Original line 20287: Erdos416Proof.CollisionState.removePrimeAt -/ def removePrimeAt (s : CollisionState m n) (idx : Fin m) (j : Fin n) (q : ℕ) : CollisionState m n := (Function.update s.1 idx (s.1 idx / q), Function.update s.2 j (s.2 j / q)) /-- Recorded positions and the removed prime reconstruct both factor lists. -/ /- Original line 20292: Erdos416Proof.CollisionState.restorePrimeAt -/ def restorePrimeAt (s : CollisionState m n) (idx : Fin m) (j : Fin n) (q : ℕ) : CollisionState m n := (Function.update s.1 idx (s.1 idx * q), Function.update s.2 j (s.2 j * q)) /- Original line 20296: Erdos416Proof.CollisionState.factorList_prod_update_mul -/ theorem factorList_prod_update_mul (f : Fin m → ℕ) (idx : Fin m) (q : ℕ) : (∏ k, Function.update f idx (f idx * q) k) = (∏ k, f k) * q := by rw [Finset.prod_update_of_mem (Finset.mem_univ idx), Finset.prod_eq_mul_prod_sdiff_singleton_of_mem (Finset.mem_univ idx)] ring /- Original line 20302: Erdos416Proof.CollisionState.restorePrimeAt_leftValue -/ theorem restorePrimeAt_leftValue (s : CollisionState m n) (idx : Fin m) (j : Fin n) (q : ℕ) : leftValue (restorePrimeAt s idx j q) = leftValue s * q := factorList_prod_update_mul s.1 idx q /- Original line 20306: Erdos416Proof.CollisionState.restorePrimeAt_rightValue -/ theorem restorePrimeAt_rightValue (s : CollisionState m n) (idx : Fin m) (j : Fin n) (q : ℕ) : rightValue (restorePrimeAt s idx j q) = rightValue s * q := factorList_prod_update_mul s.2 j q /- Original line 20310: Erdos416Proof.CollisionState.restore_removePrimeAt -/ theorem restore_removePrimeAt (s : CollisionState m n) (idx : Fin m) (j : Fin n) (q : ℕ) (hl : q ∣ s.1 idx) (hr : q ∣ s.2 j) : restorePrimeAt (removePrimeAt s idx j q) idx j q = s := by apply Prod.ext · funext k by_cases hk : k = idx · subst k simp [restorePrimeAt, removePrimeAt, Nat.div_mul_cancel hl] · simp [restorePrimeAt, removePrimeAt, hk] · funext k by_cases hk : k = j · subst k simp [restorePrimeAt, removePrimeAt, Nat.div_mul_cancel hr] · simp [restorePrimeAt, removePrimeAt, hk] /- Original line 20325: Erdos416Proof.CollisionState.removePrimeAt_leftValue_mul -/ theorem removePrimeAt_leftValue_mul (s : CollisionState m n) (idx : Fin m) (j : Fin n) (q : ℕ) (hl : q ∣ s.1 idx) (hr : q ∣ s.2 j) : leftValue (removePrimeAt s idx j q) * q = leftValue s := by rw [← restorePrimeAt_leftValue, restore_removePrimeAt s idx j q hl hr] /- Original line 20330: Erdos416Proof.CollisionState.removePrimeAt_rightValue_mul -/ theorem removePrimeAt_rightValue_mul (s : CollisionState m n) (idx : Fin m) (j : Fin n) (q : ℕ) (hl : q ∣ s.1 idx) (hr : q ∣ s.2 j) : rightValue (removePrimeAt s idx j q) * q = rightValue s := by rw [← restorePrimeAt_rightValue, restore_removePrimeAt s idx j q hl hr] /- Original line 20335: Erdos416Proof.CollisionState.removePrimeAt_positive -/ theorem removePrimeAt_positive {s : CollisionState m n} (hs : Positive s) (idx : Fin m) (j : Fin n) {q : ℕ} (hq : 0 < q) (hl : q ∣ s.1 idx) (hr : q ∣ s.2 j) : Positive (removePrimeAt s idx j q) := by constructor · intro k by_cases hk : k = idx · subst k simpa [removePrimeAt] using Nat.div_pos (Nat.le_of_dvd (hs.1 idx) hl) hq · simpa [removePrimeAt, hk] using hs.1 k · intro k by_cases hk : k = j · subst k simpa [removePrimeAt] using Nat.div_pos (Nat.le_of_dvd (hs.2 j) hr) hq · simpa [removePrimeAt, hk] using hs.2 k /- Original line 20352: Erdos416Proof.CollisionState.removePrimeAt_balanced -/ theorem removePrimeAt_balanced {s : CollisionState m n} {d q : ℕ} (hbal : Balanced d s) (idx : Fin m) (j : Fin n) (hq : 0 < q) (hl : q ∣ s.1 idx) (hr : q ∣ s.2 j) : Balanced d (removePrimeAt s idx j q) := by apply Nat.eq_of_mul_eq_mul_left hq calc _ = d * (leftValue (removePrimeAt s idx j q) * q) := by ring _ = d * leftValue s := by rw [removePrimeAt_leftValue_mul s idx j q hl hr] _ = rightValue s := hbal _ = _ := by rw [mul_comm, removePrimeAt_rightValue_mul s idx j q hl hr] /- Original line 20362: Erdos416Proof.CollisionState.removePrimeAt_leftValue_dvd -/ theorem removePrimeAt_leftValue_dvd (s : CollisionState m n) (idx : Fin m) (j : Fin n) (q : ℕ) (hl : q ∣ s.1 idx) (hr : q ∣ s.2 j) : leftValue (removePrimeAt s idx j q) ∣ leftValue s := ⟨q, (removePrimeAt_leftValue_mul s idx j q hl hr).symm⟩ /- Original line 20366: Erdos416Proof.CollisionState.removePrimeAt_squarefree -/ theorem removePrimeAt_squarefree {s : CollisionState m n} (hsq : Squarefree (leftValue s)) (idx : Fin m) (j : Fin n) (q : ℕ) (hl : q ∣ s.1 idx) (hr : q ∣ s.2 j) : Squarefree (leftValue (removePrimeAt s idx j q)) := hsq.squarefree_of_dvd (removePrimeAt_leftValue_dvd s idx j q hl hr) /- Original line 20371: Erdos416Proof.CollisionState.removePrimeAt_cardFactors_le -/ theorem removePrimeAt_cardFactors_le {s : CollisionState m n} (hs : Positive s) (idx : Fin m) (j : Fin n) (q : ℕ) (hl : q ∣ s.1 idx) (hr : q ∣ s.2 j) : ArithmeticFunction.cardFactors (leftValue (removePrimeAt s idx j q)) ≤ ArithmeticFunction.cardFactors (leftValue s) := by simp only [ArithmeticFunction.cardFactors_apply] exact (Nat.primeFactorsList_sublist_of_dvd (removePrimeAt_leftValue_dvd s idx j q hl hr) (leftValue_pos hs).ne').length_le /- Original line 20379: Erdos416Proof.CollisionState.removePrimeAt_primeFactors_subset -/ theorem removePrimeAt_primeFactors_subset {s : CollisionState m n} (hs : Positive s) (idx : Fin m) (j : Fin n) (q : ℕ) (hl : q ∣ s.1 idx) (hr : q ∣ s.2 j) : (leftValue (removePrimeAt s idx j q)).primeFactors ⊆ (leftValue s).primeFactors := by intro p hp simp only [Nat.primeFactors, List.mem_toFinset] at hp ⊢ exact Nat.primeFactorsList_subset_of_dvd (removePrimeAt_leftValue_dvd s idx j q hl hr) (leftValue_pos hs).ne' hp /-- This reconstruction works for varying selected primes and recorded positions, as required when the two factorizations allocate primes differently. -/ /- Original line 20389: Erdos416Proof.CollisionState.removePrimeAt_record_injOn -/ theorem removePrimeAt_record_injOn (F : Finset (CollisionState m n)) (idx : CollisionState m n → Fin m) (j : CollisionState m n → Fin n) (q : CollisionState m n → ℕ) (hF : ∀ s ∈ F, q s ∣ s.1 (idx s) ∧ q s ∣ s.2 (j s)) : Set.InjOn (fun s => (removePrimeAt s (idx s) (j s) (q s), idx s, j s, q s)) (F : Set _) := by intro s hs a ha heq have hrec := congrArg (fun z : CollisionState m n × Fin m × Fin n × ℕ => restorePrimeAt z.1 z.2.1 z.2.2.1 z.2.2.2) heq simpa only [restore_removePrimeAt s _ _ _ (hF s hs).1 (hF s hs).2, restore_removePrimeAt a _ _ _ (hF a ha).1 (hF a ha).2] using hrec /- Original line 20400: Erdos416Proof.CollisionState.removePrimeAt_pair_injOn -/ theorem removePrimeAt_pair_injOn (F : Finset (CollisionState m n)) (idx : Fin m) (j : Fin n) (q : CollisionState m n → ℕ) (hF : ∀ s ∈ F, q s ∣ s.1 idx ∧ q s ∣ s.2 j) : Set.InjOn (fun s => (removePrimeAt s idx j (q s), q s)) (F : Set _) := by intro s hs a ha heq have hrec := congrArg (fun z : CollisionState m n × ℕ => restorePrimeAt z.1 idx j z.2) heq simpa only [restore_removePrimeAt s _ _ _ (hF s hs).1 (hF s hs).2, restore_removePrimeAt a _ _ _ (hF a ha).1 (hF a ha).2] using hrec /- Original line 20409: Erdos416Proof.CollisionState.removePrimeAt_fiber_prime_injOn -/ theorem removePrimeAt_fiber_prime_injOn (F : Finset (CollisionState m n)) (idx : Fin m) (j : Fin n) (q : CollisionState m n → ℕ) (hF : ∀ s ∈ F, q s ∣ s.1 idx ∧ q s ∣ s.2 j) (a : CollisionState m n) : Set.InjOn q (↑(F.filter (fun s => removePrimeAt s idx j (q s) = a)) : Set _) := by intro s hs b hb heq obtain ⟨hsF, hsR⟩ := Finset.mem_filter.mp hs obtain ⟨hbF, hbR⟩ := Finset.mem_filter.mp hb exact removePrimeAt_pair_injOn F idx j q hF hsF hbF (Prod.ext (hsR.trans hbR.symm) heq) /-- Exact grouping by the remaining ordered state and the removed prime. The reconstruction proof supplies the injectivity within every fiber. -/ /- Original line 20420: Erdos416Proof.CollisionState.reciprocalMass_removePrimeAt -/ theorem reciprocalMass_removePrimeAt (d : ℕ) (F : Finset (CollisionState m n)) (idx : Fin m) (j : Fin n) (q : CollisionState m n → ℕ) (hF : ∀ s ∈ F, q s ∣ s.1 idx ∧ q s ∣ s.2 j) : reciprocalMass d F = ∑ a ∈ F.image (fun s => removePrimeAt s idx j (q s)), ((1 : ℝ) / ((d : ℝ) * leftValue a)) * ∑ p ∈ (F.filter (fun s => removePrimeAt s idx j (q s) = a)).image q, (1 : ℝ)/p := by let f := fun s => removePrimeAt s idx j (q s) have hsplit := Finset.sum_fiberwise_of_maps_to (s := F) (t := F.image f) (g := f) (fun s hs => Finset.mem_image.mpr ⟨s, hs, rfl⟩) (fun s => (1 : ℝ) / ((d : ℝ) * leftValue s)) calc _ = ∑ a ∈ F.image f, ∑ s ∈ F.filter (fun s => f s = a), (1 : ℝ) / ((d : ℝ) * leftValue s) := hsplit.symm _ = _ := by apply Finset.sum_congr rfl intro a ha rw [Finset.mul_sum, Finset.sum_image (removePrimeAt_fiber_prime_injOn F idx j q hF a)] apply Finset.sum_congr rfl intro s hs obtain ⟨hsF, hsR⟩ := Finset.mem_filter.mp hs have hvalue := removePrimeAt_leftValue_mul s idx j (q s) (hF s hsF).1 (hF s hsF).2 change leftValue (f s) * q s = leftValue s at hvalue rw [hsR] at hvalue rw [← hvalue, Nat.cast_mul] simp [div_eq_mul_inv, mul_comm, mul_left_comm] /- Original line 20446: Erdos416Proof.CollisionState.exists_threeForm_reciprocal_tail_unordered -/ theorem exists_threeForm_reciprocal_tail_unordered : ∃ C : ℝ, 0 < C ∧ ∀ᶠ Y : ℝ in atTop, ∀ (a b : ℕ) (u z : ℝ) (Q : Finset ℕ), 0 < a → 0 < b → a ≠ b → (a : ℝ) ≤ Y → (b : ℝ) ≤ Y → Real.exp 1 ≤ u → u ≤ z → (∀ q ∈ Q, q.Prime ∧ (a*q+1).Prime ∧ (b*q+1).Prime ∧ u ≤ (q : ℝ) ∧ (q : ℝ) ≤ z) → (∑ q ∈ Q, (1 : ℝ)/q) ≤ C * logLog Y^3 / Real.log u^2 := by obtain ⟨C, hC, hbound⟩ := exists_threeForm_reciprocal_tail_bound_of_coefficients_le refine ⟨C, hC, ?_⟩ filter_upwards [hbound] with Y hY intro a b u z Q ha hb hab haY hbY hu huz hQ rcases lt_or_gt_of_ne hab with hab | hba · exact hY a b u z Q ha hab hbY hu huz hQ · apply hY b a u z Q hb hba haY hu huz intro q hq obtain ⟨hqP, haP, hbP, huq, hqz⟩ := hQ q hq exact ⟨hqP, hbP, haP, huq, hqz⟩ /-- The original distinguished entries and their common selected prime. The two coefficients are fixed before the prime is summed. -/ /- Original line 20465: Erdos416Proof.CollisionState.SharedPrimeConditions -/ structure SharedPrimeConditions (a b : ℕ) (idx : Fin m) (j : Fin n) (q : ℕ) (Y u z : ℝ) (s : CollisionState m n) : Prop where positive : Positive s selected_prime : q.Prime left_dvd : q ∣ s.1 idx right_dvd : q ∣ s.2 j left_shift_prime : (a * s.1 idx + 1).Prime right_shift_prime : (b * s.2 j + 1).Prime shifts_ne : a * s.1 idx ≠ b * s.2 j left_size : ((a * s.1 idx : ℕ) : ℝ) ≤ Y right_size : ((b * s.2 j : ℕ) : ℝ) ≤ Y lower : u ≤ (q : ℝ) upper : (q : ℝ) ≤ z /-- Three-form reciprocal saving for the actual shared-prime state family. No squarefreeness is needed until the remaining allocation mass is bounded. -/ /- Original line 20481: Erdos416Proof.CollisionState.exists_sharedPrime_state_mass_bound -/ theorem exists_sharedPrime_state_mass_bound : ∃ C : ℝ, 0 < C ∧ ∀ᶠ Y : ℝ in atTop, ∀ (m n : ℕ) (idx : Fin m) (j : Fin n) (a b : ℕ) (u z : ℝ) (F : Finset (CollisionState m n)) (q : CollisionState m n → ℕ), 0 < a → 0 < b → Real.exp 1 ≤ u → u ≤ z → (∀ s ∈ F, SharedPrimeConditions a b idx j (q s) Y u z s) → reciprocalMass 1 F ≤ (C * logLog Y^3 / Real.log u^2) * reciprocalMass 1 (F.image (fun s => removePrimeAt s idx j (q s))) := by obtain ⟨C, hC, hbound⟩ := exists_threeForm_reciprocal_tail_unordered refine ⟨C, hC, ?_⟩ filter_upwards [hbound] with Y hY intro m n idx j a b u z F q ha hb hu huz hF have hdivs (s : CollisionState m n) (hs : s ∈ F) : q s ∣ s.1 idx ∧ q s ∣ s.2 j := ⟨(hF s hs).left_dvd, (hF s hs).right_dvd⟩ let f := fun s => removePrimeAt s idx j (q s) have hfiber (tau : CollisionState m n) (htau : tau ∈ F.image f) : (∑ p ∈ (F.filter (fun s => f s = tau)).image q, (1 : ℝ)/p) ≤ C * logLog Y^3 / Real.log u^2 := by let A := a * tau.1 idx let B := b * tau.2 j have hcoeff (s : CollisionState m n) (hs : s ∈ F.filter (fun s => f s = tau)) : A * q s = a * s.1 idx ∧ B * q s = b * s.2 j := by obtain ⟨hsF, hsR⟩ := Finset.mem_filter.mp hs have hrec := restore_removePrimeAt s idx j (q s) (hdivs s hsF).1 (hdivs s hsF).2 change restorePrimeAt (f s) idx j (q s) = s at hrec rw [hsR] at hrec have hl : tau.1 idx * q s = s.1 idx := by simpa [Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, restorePrimeAt] using congrArg (fun w : CollisionState m n => w.1 idx) hrec have hr : tau.2 j * q s = s.2 j := by simpa [Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, restorePrimeAt] using congrArg (fun w : CollisionState m n => w.2 j) hrec constructor · dsimp [Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, A] rw [mul_assoc, hl] · dsimp [Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, B] rw [mul_assoc, hr] obtain ⟨s, hs, hsR⟩ := Finset.mem_image.mp htau have hsFiber : s ∈ F.filter (fun s => f s = tau) := Finset.mem_filter.mpr ⟨hs, hsR⟩ have hcond := hF s hs have htauPos : Positive tau := by rw [← hsR] exact removePrimeAt_positive hcond.positive idx j hcond.selected_prime.pos hcond.left_dvd hcond.right_dvd have hA : 0 < A := Nat.mul_pos ha (htauPos.1 idx) have hB : 0 < B := Nat.mul_pos hb (htauPos.2 j) have hAB : A ≠ B := by intro heq apply hcond.shifts_ne rw [← (hcoeff s hsFiber).1, ← (hcoeff s hsFiber).2, heq] have hAY : (A : ℝ) ≤ Y := by have hle : (A : ℝ) ≤ (A * q s : ℕ) := Nat.cast_le.mpr (Nat.le_mul_of_pos_right A hcond.selected_prime.pos) rw [(hcoeff s hsFiber).1] at hle exact hle.trans hcond.left_size have hBY : (B : ℝ) ≤ Y := by have hle : (B : ℝ) ≤ (B * q s : ℕ) := Nat.cast_le.mpr (Nat.le_mul_of_pos_right B hcond.selected_prime.pos) rw [(hcoeff s hsFiber).2] at hle exact hle.trans hcond.right_size apply hY A B u z _ hA hB hAB hAY hBY hu huz intro p hp obtain ⟨w, hw, rfl⟩ := Finset.mem_image.mp hp have hwcond := hF w (Finset.mem_filter.mp hw).1 refine ⟨hwcond.selected_prime, ?_, ?_, hwcond.lower, hwcond.upper⟩ · rw [(hcoeff w hw).1] exact hwcond.left_shift_prime · rw [(hcoeff w hw).2] exact hwcond.right_shift_prime rw [reciprocalMass_removePrimeAt 1 F idx j q hdivs] calc _ ≤ ∑ tau ∈ F.image f, ((1 : ℝ) / ((1 : ℕ) * leftValue tau)) * (C * logLog Y^3 / Real.log u^2) := by apply Finset.sum_le_sum intro tau htau exact mul_le_mul_of_nonneg_left (hfiber tau htau) (by positivity) _ = _ := by rw [reciprocalMass, Finset.mul_sum] apply Finset.sum_congr rfl intro tau htau ring /-- The remaining shared-prime factorizations satisfy the proved squarefree allocation estimate, with the original factor-count and support bounds. -/ /- Original line 20562: Erdos416Proof.CollisionState.exists_sharedPrime_state_allocation_bound -/ theorem exists_sharedPrime_state_allocation_bound : ∃ C : ℝ, 0 < C ∧ ∀ᶠ Y : ℝ in atTop, ∀ (m n : ℕ) (idx : Fin m) (j : Fin n) (a b : ℕ) (u z I H : ℝ) (F : Finset (CollisionState m n)) (q : CollisionState m n → ℕ) (P : Finset ℕ), 1 ≤ m → n ≤ m → 0 < a → 0 < b → Real.exp 1 ≤ u → u ≤ z → (∀ s ∈ F, SharedPrimeConditions a b idx j (q s) Y u z s ∧ Balanced 1 s ∧ Squarefree (leftValue s) ∧ (leftValue s).primeFactors ⊆ P ∧ (ArithmeticFunction.cardFactors (leftValue s) : ℝ) ≤ I) → (∑ p ∈ P, (1 : ℝ)/p) ≤ H → reciprocalMass 1 F ≤ (C * logLog Y^3 / Real.log u^2) * Real.exp (I * Real.log m + (m : ℝ)*H) := by obtain ⟨C, hC, hbound⟩ := exists_sharedPrime_state_mass_bound refine ⟨C, hC, ?_⟩ filter_upwards [hbound, eventually_ge_atTop (3 : ℝ)] with Y hY hY3 intro m n idx j a b u z I H F q P hm hnm ha hb hu huz hF hH have hLL : 0 ≤ logLog Y := (logLog_pos_of_three_le hY3).le have hmass := hY m n idx j a b u z F q ha hb hu huz (fun s hs => (hF s hs).1) have halloc := reciprocalMass_squarefree_bound hm hnm (F.image (fun s => removePrimeAt s idx j (q s))) P (I := I) (H := H) (by intro tau htau obtain ⟨s, hs, rfl⟩ := Finset.mem_image.mp htau obtain ⟨hcond, hbal, hsq, hsupport, hOmega⟩ := hF s hs refine ⟨removePrimeAt_balanced hbal idx j hcond.selected_prime.pos hcond.left_dvd hcond.right_dvd, removePrimeAt_squarefree hsq idx j (q s) hcond.left_dvd hcond.right_dvd, (removePrimeAt_primeFactors_subset hcond.positive idx j (q s) hcond.left_dvd hcond.right_dvd).trans hsupport, ?_⟩ have hle : (ArithmeticFunction.cardFactors (leftValue (removePrimeAt s idx j (q s))) : ℝ) ≤ ArithmeticFunction.cardFactors (leftValue s) := by exact_mod_cast removePrimeAt_cardFactors_le hcond.positive idx j (q s) hcond.left_dvd hcond.right_dvd exact hle.trans hOmega) hH exact hmass.trans (mul_le_mul_of_nonneg_left halloc (by positivity)) /- Original line 20594: Erdos416Proof.CollisionState.removePrimeAt_unitTails -/ theorem removePrimeAt_unitTails {idx r t : ℕ} {s : CollisionState (idx+r) (idx+t)} (hs : UnitTails s) (a b : Fin idx) (q : ℕ) : UnitTails (removePrimeAt s (Fin.castAdd r a) (Fin.castAdd t b) q) := by have hne {k : ℕ} (x : Fin k) (a : Fin idx) : Fin.natAdd idx x ≠ Fin.castAdd k a := by intro heq have hval := congrArg Fin.val heq change idx + x.val = a.val at hval omega constructor · intro j simpa [removePrimeAt, hne j a] using hs.1 j · intro j simpa [removePrimeAt, hne j b] using hs.2 j /- Original line 20608: Erdos416Proof.CollisionState.primePart_largestPrimeFactor_eq -/ theorem primePart_largestPrimeFactor_eq {N : ℕ} (hN : 1 < largestPrimeFactor N) (A : ℕ → Prop) (hA : A (largestPrimeFactor N)) : largestPrimeFactor (primePart N A) = largestPrimeFactor N := by apply Nat.le_antisymm · have hle := primePart_largestPrimeFactor_le N A (show (1 : ℝ) ≤ largestPrimeFactor N by exact_mod_cast one_le_largestPrimeFactor N) (fun p hp _ => Nat.cast_le.mpr (primeFactorsList_le_largestPrimeFactor hp)) exact_mod_cast hle · apply prime_le_largestPrimeFactor (primePart_pos N A) (largestPrimeFactor_isPrime hN) apply Nat.dvd_of_mem_primeFactorsList apply (mem_primeFactorsList_primePart N (largestPrimeFactor N) A).mpr refine ⟨?_, hA⟩ simpa only [Nat.primeFactors, List.mem_toFinset] using largestPrimeFactor_mem_primeFactors hN /- Original line 20622: Erdos416Proof.CollisionState.lowPrimePart_eq_self_of_largest_le -/ theorem lowPrimePart_eq_self_of_largest_le {N : ℕ} {v : ℝ} (hN : 0 < N) (hv : (largestPrimeFactor N : ℝ) ≤ v) : lowPrimePart N v = N := by apply primePart_eq_self hN.ne' intro p hp exact (Nat.cast_le.mpr (primeFactorsList_le_largestPrimeFactor hp)).trans hv /-- The actual intermediate compatible fiber, formed from two consecutive cuts of the original solution family. -/ /- Original line 20630: Erdos416Proof.CollisionState.compatibleIntervalFiber -/ noncomputable def compatibleIntervalFiber (u v : ℝ) (sigma : CollisionState m n) (F : Finset (CollisionState m n)) : Finset (CollisionState m n) := (highStates u (lowStates v F)).filter (fun tau => sigma*tau ∈ lowStates v F) /- Original line 20634: Erdos416Proof.CollisionState.compatibleIntervalFiber_witness -/ theorem compatibleIntervalFiber_witness {u v : ℝ} {sigma tau : CollisionState m n} {F : Finset (CollisionState m n)} (hsigma : sigma ∈ lowStates u (lowStates v F)) (htau : tau ∈ compatibleIntervalFiber u v sigma F) : ∃ s ∈ F, cut v s = sigma*tau ∧ interval u v s = tau := by obtain ⟨htHigh, htCompat⟩ := Finset.mem_filter.mp htau obtain ⟨s, hs, hsEq⟩ := Finset.mem_image.mp htCompat refine ⟨s, hs, hsEq, ?_⟩ rw [← high_cut_interval, hsEq] exact (recover_split hsigma htHigh).2 /- Original line 20644: Erdos416Proof.CollisionState.sharedPrimeIntervalFiber -/ noncomputable def sharedPrimeIntervalFiber (u v : ℝ) (idx : Fin m) (j : Fin n) (sigma : CollisionState m n) (F : Finset (CollisionState m n)) : Finset (CollisionState m n) := (compatibleIntervalFiber u v sigma F).filter (fun tau => largestPrimeFactor (tau.1 idx) = largestPrimeFactor (tau.2 j)) /-- Original-solution hypotheses for one middle interval. The distinguished shifted primes have largest factors in [W,v]; the other active left factors supply normality, and all inactive factors are supported below u. -/ /- Original line 20652: Erdos416Proof.CollisionState.MiddleOriginalConditions -/ structure MiddleOriginalConditions {idx r t : ℕ} (S u v W Y : ℝ) (d : ℕ) (j : Fin idx) (s : CollisionState (idx+r) (idx+t)) : Prop where positive : Positive s balanced : Balanced d s square_exclusion : NoLargePrimeSquare (d * leftValue s) u left_normal : ∀ a : Fin idx, SNormal S (s.1 (Fin.castAdd r a)+1) left_tail : ∀ a : Fin r, ∀ p ∈ (s.1 (Fin.natAdd idx a)).primeFactorsList, (p : ℝ) ≤ u right_tail : ∀ a : Fin t, ∀ p ∈ (s.2 (Fin.natAdd idx a)).primeFactorsList, (p : ℝ) ≤ u right_prime : (s.2 (Fin.castAdd t j)+1).Prime distinguished_ne : s.1 (Fin.castAdd r j) ≠ s.2 (Fin.castAdd t j) left_size : (s.1 (Fin.castAdd r j) : ℝ) ≤ Y right_size : (s.2 (Fin.castAdd t j) : ℝ) ≤ Y left_largest : W ≤ (largestPrimeFactor (s.1 (Fin.castAdd r j)) : ℝ) ∧ (largestPrimeFactor (s.1 (Fin.castAdd r j)) : ℝ) ≤ v right_largest : W ≤ (largestPrimeFactor (s.2 (Fin.castAdd t j)) : ℝ) ∧ (largestPrimeFactor (s.2 (Fin.castAdd t j)) : ℝ) ≤ v /- Original line 20669: Erdos416Proof.CollisionState.sharedPrimeInterval_conditions -/ theorem sharedPrimeInterval_conditions {idx r t d : ℕ} {S u v W Y : ℝ} (j : Fin idx) {F : Finset (CollisionState (idx+r) (idx+t))} {sigma tau : CollisionState (idx+r) (idx+t)} (hu : 1 ≤ u) (huW : u < W) (hF : ∀ s ∈ F, MiddleOriginalConditions S u v W Y d j s) (hsigma : sigma ∈ lowStates u (lowStates v F)) (htau : tau ∈ sharedPrimeIntervalFiber u v (Fin.castAdd r j) (Fin.castAdd t j) sigma F) : SharedPrimeConditions (sigma.1 (Fin.castAdd r j)) (sigma.2 (Fin.castAdd t j)) (Fin.castAdd r j) (Fin.castAdd t j) (largestPrimeFactor (tau.1 (Fin.castAdd r j))) Y W v tau := by obtain ⟨htCompat, htSame⟩ := Finset.mem_filter.mp htau obtain ⟨s, hs, hsCut, hsInt⟩ := compatibleIntervalFiber_witness hsigma htCompat have hcond := hF s hs have hleft : sigma.1 (Fin.castAdd r j) * tau.1 (Fin.castAdd r j) = s.1 (Fin.castAdd r j) := by have h := congrArg (fun w : CollisionState (idx+r) (idx+t) => w.1 (Fin.castAdd r j)) hsCut change lowPrimePart (s.1 (Fin.castAdd r j)) v = sigma.1 (Fin.castAdd r j) * tau.1 (Fin.castAdd r j) at h rw [lowPrimePart_eq_self_of_largest_le (hcond.positive.1 _) hcond.left_largest.2] at h exact h.symm have hright : sigma.2 (Fin.castAdd t j) * tau.2 (Fin.castAdd t j) = s.2 (Fin.castAdd t j) := by have h := congrArg (fun w : CollisionState (idx+r) (idx+t) => w.2 (Fin.castAdd t j)) hsCut change lowPrimePart (s.2 (Fin.castAdd t j)) v = sigma.2 (Fin.castAdd t j) * tau.2 (Fin.castAdd t j) at h rw [lowPrimePart_eq_self_of_largest_le (hcond.positive.2 _) hcond.right_largest.2] at h exact h.symm have hlarge : 1 < largestPrimeFactor (s.1 (Fin.castAdd r j)) := by have hreal : (1 : ℝ) < largestPrimeFactor (s.1 (Fin.castAdd r j)) := (hu.trans_lt huW).trans_le hcond.left_largest.1 exact_mod_cast hreal have hselected : largestPrimeFactor (tau.1 (Fin.castAdd r j)) = largestPrimeFactor (s.1 (Fin.castAdd r j)) := by rw [← hsInt] exact primePart_largestPrimeFactor_eq hlarge _ ⟨huW.trans_le hcond.left_largest.1, hcond.left_largest.2⟩ refine ⟨?_, ?_, largestPrimeFactor_dvd _, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_⟩ · rw [← hsInt] exact ⟨fun _ => primePart_pos _ _, fun _ => primePart_pos _ _⟩ · rw [hselected] exact largestPrimeFactor_isPrime hlarge · rw [htSame] exact largestPrimeFactor_dvd _ · rw [hleft] exact (hcond.left_normal j).1 · rw [hright] exact hcond.right_prime · rw [hleft, hright] exact hcond.distinguished_ne · rw [hleft] exact hcond.left_size · rw [hright] exact hcond.right_size · rw [hselected] exact hcond.left_largest.1 · rw [hselected] exact hcond.left_largest.2 /-- The complete shared-largest-prime case for an actual middle compatible fiber. Normality, support, coefficient bounds, squarefreeness, and the active allocation dimension are all derived from the original solutions. -/ /- Original line 20727: Erdos416Proof.CollisionState.exists_sharedPrime_interval_fiber_bound -/ theorem exists_sharedPrime_interval_fiber_bound : ∃ C : ℝ, 0 < C ∧ ∀ᶠ Y : ℝ in atTop, ∀ (S u v W : ℝ) (idx r t d : ℕ) (j : Fin idx) (F : Finset (CollisionState (idx+r) (idx+t))) (sigma : CollisionState (idx+r) (idx+t)), Real.exp (Real.exp 1) ≤ S → S ≤ u → u < W → W ≤ v → v ≤ Y → 1 ≤ idx → 0 < d → (∀ p ∈ d.primeFactorsList, (p : ℝ) ≤ u) → (∀ s ∈ F, MiddleOriginalConditions S u v W Y d j s) → sigma ∈ lowStates u (lowStates v F) → reciprocalMass 1 (sharedPrimeIntervalFiber u v (Fin.castAdd r j) (Fin.castAdd t j) sigma F) ≤ (C * logLog Y^3 / Real.log W^2) * Real.exp ((1 + Real.log idx) * ((idx : ℝ) * (logLog v - logLog u + Real.sqrt (logLog S * logLog Y)))) := by obtain ⟨C, hC, hbound⟩ := exists_sharedPrime_state_mass_bound obtain ⟨B, hB⟩ := prime_reciprocal_mertens refine ⟨C, hC, ?_⟩ filter_upwards [hbound, normality_interval_error_ge_eventually (2*|B|), eventually_ge_atTop (3 : ℝ)] with Y hY hError hY3 intro S u v W idx r t d j F sigma hS hSu huW hWv hvY hi hd hdU hF hsigma have hSe : Real.exp 1 ≤ S := (Real.exp_le_exp.mpr (by linarith [Real.add_one_le_exp (1 : ℝ)])).trans hS have hu2 : 2 ≤ u := by linarith [Real.add_one_le_exp (1 : ℝ)] have huv : u < v := huW.trans_le hWv have hW : Real.exp 1 ≤ W := (hSe.trans hSu).trans huW.le have hvLL : logLog v ≤ logLog Y := logLog_mono (by linarith) hvY have hLL : 0 ≤ logLog Y := (logLog_pos_of_three_le hY3).le have hsigmaPos : Positive sigma := by obtain ⟨s, _, rfl⟩ := Finset.mem_image.mp hsigma exact cut_positive _ _ let G := sharedPrimeIntervalFiber u v (Fin.castAdd r j) (Fin.castAdd t j) sigma F let q := fun tau : CollisionState (idx+r) (idx+t) => largestPrimeFactor (tau.1 (Fin.castAdd r j)) let f := fun tau => removePrimeAt tau (Fin.castAdd r j) (Fin.castAdd t j) (q tau) let I := (idx : ℝ) * (logLog v - logLog u + Real.sqrt (logLog S * logLog Y)) let H := logLog v - logLog u + 2*|B| let P := (Nat.primesLE ⌊v⌋₊).filter (fun p : ℕ => u < (p : ℝ) ∧ (p : ℝ) ≤ v) have hG (tau : CollisionState (idx+r) (idx+t)) (htau : tau ∈ G) : SharedPrimeConditions (sigma.1 (Fin.castAdd r j)) (sigma.2 (Fin.castAdd t j)) (Fin.castAdd r j) (Fin.castAdd t j) (q tau) Y W v tau := sharedPrimeInterval_conditions j (by linarith) huW hF hsigma htau have hmass := hY (idx+r) (idx+t) (Fin.castAdd r j) (Fin.castAdd t j) (sigma.1 (Fin.castAdd r j)) (sigma.2 (Fin.castAdd t j)) W v G q (hsigmaPos.1 _) (hsigmaPos.2 _) hW hWv hG have hH : (∑ p ∈ P, (1 : ℝ)/p) ≤ H := by have h := (abs_le.mp (prime_interval_reciprocal_error hB hu2 huv.le le_rfl)).2 change (∑ p ∈ P, (1 : ℝ)/p) - (logLog v - logLog u) ≤ 2*|B| at h dsimp [Erdos416Proof.largestPrimeFactor_one, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, H] linarith have hdata (tau : CollisionState (idx+r) (idx+t)) (htau : tau ∈ G) : UnitTails tau ∧ Balanced 1 tau ∧ Squarefree (leftValue tau) ∧ (leftValue tau).primeFactors ⊆ P ∧ (ArithmeticFunction.cardFactors (leftValue tau) : ℝ) ≤ I := by obtain ⟨htCompat, _⟩ := Finset.mem_filter.mp htau obtain ⟨s, hs, _, hsInt⟩ := compatibleIntervalFiber_witness hsigma htCompat have hcond := hF s hs rw [← hsInt] refine ⟨interval_unitTails s hcond.left_tail hcond.right_tail, interval_balanced hd hcond.positive hcond.balanced huv.le hdU, interval_leftValue_squarefree hcond.positive hcond.square_exclusion, ?_, interval_cardFactors_bound s hcond.positive hSe hSu huv hvLL hcond.left_normal hcond.left_tail⟩ intro p hp have hpList : p ∈ (leftValue (interval u v s)).primeFactorsList := by simpa only [Nat.primeFactors, List.mem_toFinset] using hp have hpRange := interval_leftValue_support u v hcond.positive p hpList exact Finset.mem_filter.mpr ⟨Nat.mem_primesLE.mpr ⟨Nat.le_floor hpRange.2, Nat.prime_of_mem_primeFactors hp⟩, hpRange⟩ have htail : ∀ tau ∈ G.image f, UnitTails tau := by intro tau htau obtain ⟨s, hs, rfl⟩ := Finset.mem_image.mp htau exact removePrimeAt_unitTails (hdata s hs).1 j j (q s) have hremaining : ∀ tau ∈ G.image f, Balanced 1 tau ∧ Squarefree (leftValue tau) ∧ (leftValue tau).primeFactors ⊆ P ∧ (ArithmeticFunction.cardFactors (leftValue tau) : ℝ) ≤ I := by intro tau htau obtain ⟨s, hs, rfl⟩ := Finset.mem_image.mp htau have hcond := hG s hs obtain ⟨_, hbal, hsq, hsupport, hOmega⟩ := hdata s hs refine ⟨removePrimeAt_balanced hbal _ _ hcond.selected_prime.pos hcond.left_dvd hcond.right_dvd, removePrimeAt_squarefree hsq _ _ (q s) hcond.left_dvd hcond.right_dvd, (removePrimeAt_primeFactors_subset hcond.positive _ _ (q s) hcond.left_dvd hcond.right_dvd).trans hsupport, ?_⟩ have hle : (ArithmeticFunction.cardFactors (leftValue (f s)) : ℝ) ≤ ArithmeticFunction.cardFactors (leftValue s) := by exact_mod_cast removePrimeAt_cardFactors_le hcond.positive _ _ (q s) hcond.left_dvd hcond.right_dvd exact hle.trans hOmega have halloc := reciprocalMass_unitTail_bound hi (G.image f) P htail hremaining hH have hroom : (idx : ℝ) * H ≤ I := by dsimp [Erdos416Proof.largestPrimeFactor_one, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, H, I] exact mul_le_mul_of_nonneg_left (add_le_add le_rfl (hError S hS)) (Nat.cast_nonneg idx) have hexp : Real.exp (I * Real.log idx + (idx : ℝ)*H) ≤ Real.exp ((1 + Real.log idx)*I) := by apply Real.exp_le_exp.mpr nlinarith exact hmass.trans (mul_le_mul_of_nonneg_left (halloc.trans hexp) (by positivity)) end Erdos416Proof.CollisionState /- The four prime-pair incidences, two-prime reconstruction, and the actual different-prime and complete middle compatible-fiber estimates. -/ open Filter Asymptotics MeasureTheory open scoped BigOperators Classical Topology namespace Erdos416Proof /- Original line 20830: Erdos416Proof.exists_primeSet_reciprocal_bound -/ theorem exists_primeSet_reciprocal_bound : ∃ C : ℝ, 0 < C ∧ ∀ᶠ Y : ℝ in atTop, ∀ P : Finset ℕ, (∀ p ∈ P, p.Prime ∧ (p : ℝ) ≤ Y) → (∑ p ∈ P, (1 : ℝ)/p) ≤ C * logLog Y := by obtain ⟨B, hB⟩ := prime_reciprocal_mertens have hLL : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop refine ⟨1+|B|, by positivity, ?_⟩ filter_upwards [eventually_ge_atTop (2 : ℝ), hLL.eventually_ge_atTop 1] with Y hY hLY intro P hP have hsub : P ⊆ Nat.primesLE ⌊Y⌋₊ := by intro p hp exact Nat.mem_primesLE.mpr ⟨Nat.le_floor (hP p hp).2, (hP p hp).1⟩ have hsum := Finset.sum_le_sum_of_subset_of_nonneg (f := fun p : ℕ => (1 : ℝ)/p) hsub (by intros; positivity) have hmain := (abs_le.mp (hB Y hY)).2 change (∑ p ∈ Nat.primesLE ⌊Y⌋₊, (1 : ℝ)/p) - logLog Y ≤ B at hmain have hBmul : |B| ≤ |B| * logLog Y := le_mul_of_one_le_right (abs_nonneg B) hLY nlinarith [le_abs_self B] namespace PrimePair /- Original line 20850: Erdos416Proof.PrimePair.secondFiber -/ noncomputable def secondFiber (F : Finset (ℕ × ℕ)) (p : ℕ) : Finset ℕ := (F.filter (fun x => x.1 = p)).image Prod.snd /- Original line 20853: Erdos416Proof.PrimePair.mem_secondFiber -/ theorem mem_secondFiber {F : Finset (ℕ × ℕ)} {p q : ℕ} : q ∈ secondFiber F p ↔ (p,q) ∈ F := by constructor · intro hq obtain ⟨⟨a,b⟩, hab, hb⟩ := Finset.mem_image.mp hq obtain ⟨hF, ha⟩ := Finset.mem_filter.mp hab dsimp at ha hb subst a subst b exact hF · intro hq exact Finset.mem_image.mpr ⟨(p,q), Finset.mem_filter.mpr ⟨hq, rfl⟩, rfl⟩ /- Original line 20866: Erdos416Proof.PrimePair.snd_injOn_fiber -/ theorem snd_injOn_fiber (F : Finset (ℕ × ℕ)) (p : ℕ) : Set.InjOn Prod.snd (↑(F.filter (fun x => x.1 = p)) : Set (ℕ × ℕ)) := by intro x hx y hy heq exact Prod.ext ((Finset.mem_filter.mp hx).2.trans (Finset.mem_filter.mp hy).2.symm) heq /- Original line 20871: Erdos416Proof.PrimePair.reciprocalMass -/ noncomputable def reciprocalMass (F : Finset (ℕ × ℕ)) : ℝ := ∑ x ∈ F, (1 : ℝ) / ((x.1 : ℝ) * x.2) /- Original line 20874: Erdos416Proof.PrimePair.reciprocalMass_fst -/ theorem reciprocalMass_fst (F : Finset (ℕ × ℕ)) : reciprocalMass F = ∑ p ∈ F.image Prod.fst, (1 : ℝ)/p * ∑ q ∈ secondFiber F p, (1 : ℝ)/q := by have hsplit := Finset.sum_fiberwise_of_maps_to (s := F) (t := F.image Prod.fst) (g := Prod.fst) (fun x hx => Finset.mem_image.mpr ⟨x, hx, rfl⟩) (fun x : ℕ × ℕ => (1 : ℝ)/((x.1 : ℝ)*x.2)) calc _ = ∑ p ∈ F.image Prod.fst, ∑ x ∈ F.filter (fun x => x.1 = p), (1 : ℝ)/((x.1 : ℝ)*x.2) := hsplit.symm _ = _ := by apply Finset.sum_congr rfl intro p hp rw [secondFiber, Finset.mul_sum, Finset.sum_image (snd_injOn_fiber F p)] apply Finset.sum_congr rfl intro x hx rw [(Finset.mem_filter.mp hx).2] simp [div_eq_mul_inv, mul_comm] /- Original line 20893: Erdos416Proof.PrimePair.reciprocalMass_swap -/ theorem reciprocalMass_swap (F : Finset (ℕ × ℕ)) : reciprocalMass (F.image Prod.swap) = reciprocalMass F := by rw [reciprocalMass, reciprocalMass, Finset.sum_image (by intro x _ y _ heq simpa using congrArg Prod.swap heq)] apply Finset.sum_congr rfl intro x hx change (1 : ℝ)/((x.2 : ℝ)*x.1) = 1/((x.1 : ℝ)*x.2) rw [mul_comm] /-- The flags record whether the other selected prime occurs in each distinguished factor. Size and distinctness refer to the original shifts. -/ /- Original line 20905: Erdos416Proof.PrimePair.Conditions -/ structure Conditions (a b : ℕ) (eL eR : Bool) (Y u z : ℝ) (x : ℕ × ℕ) : Prop where left_prime : x.1.Prime right_prime : x.2.Prime left_shift : (a*x.1*(if eL then x.2 else 1)+1).Prime right_shift : (b*x.2*(if eR then x.1 else 1)+1).Prime shifts_ne : a*x.1*(if eL then x.2 else 1) ≠ b*x.2*(if eR then x.1 else 1) left_size : ((a*x.1*(if eL then x.2 else 1) : ℕ) : ℝ) ≤ Y right_size : ((b*x.2*(if eR then x.1 else 1) : ℕ) : ℝ) ≤ Y left_lower : u ≤ (x.1 : ℝ) left_upper : (x.1 : ℝ) ≤ z right_lower : u ≤ (x.2 : ℝ) right_upper : (x.2 : ℝ) ≤ z /- Original line 20918: Erdos416Proof.PrimePair.Conditions.swap -/ theorem Conditions.swap {a b : ℕ} {eL eR : Bool} {Y u z : ℝ} {x : ℕ × ℕ} (h : Conditions a b eL eR Y u z x) : Conditions b a eR eL Y u z x.swap := ⟨h.right_prime, h.left_prime, h.right_shift, h.left_shift, h.shifts_ne.symm, h.right_size, h.left_size, h.right_lower, h.right_upper, h.left_lower, h.left_upper⟩ /-- If the left shift does not contain the right selected prime, the outer prime has its own two-form condition. The right coefficient may depend on it. -/ /- Original line 20925: Erdos416Proof.PrimePair.exists_reciprocal_bound_no_left_cross -/ theorem exists_reciprocal_bound_no_left_cross : ∃ C : ℝ, 0 < C ∧ ∀ᶠ Y : ℝ in atTop, ∀ (a b : ℕ) (eR : Bool) (u z : ℝ) (F : Finset (ℕ × ℕ)), 0 < a → 0 < b → Real.exp 1 ≤ u → u ≤ z → (∀ x ∈ F, Conditions a b false eR Y u z x) → reciprocalMass F ≤ C * logLog Y^2 / Real.log u^2 := by obtain ⟨K, hK, hbound⟩ := exists_twoForm_reciprocal_tail_bound_of_coefficient_le refine ⟨K*K, mul_pos hK hK, ?_⟩ filter_upwards [hbound, eventually_ge_atTop (3 : ℝ)] with Y hY hY3 intro a b eR u z F ha hb hu huz hF have hLL : 0 ≤ logLog Y := (logLog_pos_of_three_le hY3).le have hlogu : 0 < Real.log u := Real.log_pos ((Real.one_lt_exp_iff.mpr (by norm_num : (0 : ℝ) < 1)).trans_le hu) by_cases hEmpty : F = ∅ · simp only [hEmpty, reciprocalMass, Finset.sum_empty] positivity obtain ⟨x, hx⟩ := Finset.nonempty_iff_ne_empty.mpr hEmpty have haY : (a : ℝ) ≤ Y := by have hle : (a : ℝ) ≤ (a*x.1 : ℕ) := Nat.cast_le.mpr (Nat.le_mul_of_pos_right a (hF x hx).left_prime.pos) exact hle.trans (by simpa [Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint] using (hF x hx).left_size) have houter : (∑ p ∈ F.image Prod.fst, (1 : ℝ)/p) ≤ K * logLog Y / Real.log u := by apply hY a u z _ ha haY hu huz intro p hp obtain ⟨x, hx, rfl⟩ := Finset.mem_image.mp hp exact ⟨(hF x hx).left_prime, by simpa [Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint] using (hF x hx).left_shift, (hF x hx).left_lower, (hF x hx).left_upper⟩ have hinner (p : ℕ) (hp : p ∈ F.image Prod.fst) : (∑ q ∈ secondFiber F p, (1 : ℝ)/q) ≤ K * logLog Y / Real.log u := by obtain ⟨⟨p₀,q₀⟩, hrep, hpEq⟩ := Finset.mem_image.mp hp dsimp [Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint] at hpEq subst p₀ have hcond := hF (p,q₀) hrep let c := b * (if eR then p else 1) have hpp : 0 < p := hcond.left_prime.pos have hc : 0 < c := by cases eR <;> dsimp [Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, c] <;> positivity have hcoef (q : ℕ) : c*q = b*q*(if eR then p else 1) := by dsimp [Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, c]; ring have hcY : (c : ℝ) ≤ Y := by have hle : (c : ℝ) ≤ (c*q₀ : ℕ) := Nat.cast_le.mpr (Nat.le_mul_of_pos_right c hcond.right_prime.pos) rw [hcoef] at hle exact hle.trans hcond.right_size apply hY c u z _ hc hcY hu huz intro q hq have h := hF (p,q) (mem_secondFiber.mp hq) refine ⟨h.right_prime, ?_, h.right_lower, h.right_upper⟩ rw [hcoef] exact h.right_shift calc _ = ∑ p ∈ F.image Prod.fst, (1 : ℝ)/p * ∑ q ∈ secondFiber F p, (1 : ℝ)/q := reciprocalMass_fst F _ ≤ ∑ p ∈ F.image Prod.fst, (1 : ℝ)/p * (K * logLog Y / Real.log u) := by apply Finset.sum_le_sum intro p hp exact mul_le_mul_of_nonneg_left (hinner p hp) (by positivity) _ = (∑ p ∈ F.image Prod.fst, (1 : ℝ)/p) * (K * logLog Y / Real.log u) := (Finset.sum_mul _ _ _).symm _ ≤ (K * logLog Y / Real.log u) * (K * logLog Y / Real.log u) := mul_le_mul_of_nonneg_right houter (by positivity) _ = _ := by field_simp /-- When both shifts contain both primes, a three-form inner sieve replaces an invalid independence assumption. The outer sum only uses primality. -/ /- Original line 20988: Erdos416Proof.PrimePair.exists_reciprocal_bound_both_cross -/ theorem exists_reciprocal_bound_both_cross : ∃ C : ℝ, 0 < C ∧ ∀ᶠ Y : ℝ in atTop, ∀ (a b : ℕ) (u z : ℝ) (F : Finset (ℕ × ℕ)), 0 < a → 0 < b → Real.exp 1 ≤ u → u ≤ z → z ≤ Y → (∀ x ∈ F, Conditions a b true true Y u z x) → reciprocalMass F ≤ C * logLog Y^4 / Real.log u^2 := by obtain ⟨K, hK, hbound⟩ := CollisionState.exists_threeForm_reciprocal_tail_unordered obtain ⟨R, hR, hprimes⟩ := exists_primeSet_reciprocal_bound refine ⟨R*K, mul_pos hR hK, ?_⟩ filter_upwards [hbound, hprimes, eventually_ge_atTop (3 : ℝ)] with Y hY hPrimeY hY3 intro a b u z F ha hb hu huz hzY hF have hLL : 0 ≤ logLog Y := (logLog_pos_of_three_le hY3).le have houter : (∑ p ∈ F.image Prod.fst, (1 : ℝ)/p) ≤ R * logLog Y := by apply hPrimeY intro p hp obtain ⟨x, hx, rfl⟩ := Finset.mem_image.mp hp exact ⟨(hF x hx).left_prime, (hF x hx).left_upper.trans hzY⟩ have hinner (p : ℕ) (hp : p ∈ F.image Prod.fst) : (∑ q ∈ secondFiber F p, (1 : ℝ)/q) ≤ K * logLog Y^3 / Real.log u^2 := by obtain ⟨⟨p₀,q₀⟩, hrep, hpEq⟩ := Finset.mem_image.mp hp dsimp [Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint] at hpEq subst p₀ have hcond := hF (p,q₀) hrep let A := a*p let B := b*p have hA : 0 < A := Nat.mul_pos ha hcond.left_prime.pos have hB : 0 < B := Nat.mul_pos hb hcond.left_prime.pos have hleft (q : ℕ) : A*q = a*p*(if true then q else 1) := rfl have hright (q : ℕ) : B*q = b*q*(if true then p else 1) := by dsimp [Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, B]; ring have hAB : A ≠ B := by intro heq apply hcond.shifts_ne rw [← hleft q₀, ← hright q₀, heq] have hAY : (A : ℝ) ≤ Y := by have hle : (A : ℝ) ≤ (A*q₀ : ℕ) := Nat.cast_le.mpr (Nat.le_mul_of_pos_right A hcond.right_prime.pos) rw [hleft] at hle exact hle.trans hcond.left_size have hBY : (B : ℝ) ≤ Y := by have hle : (B : ℝ) ≤ (B*q₀ : ℕ) := Nat.cast_le.mpr (Nat.le_mul_of_pos_right B hcond.right_prime.pos) rw [hright] at hle exact hle.trans hcond.right_size apply hY A B u z _ hA hB hAB hAY hBY hu huz intro q hq have h := hF (p,q) (mem_secondFiber.mp hq) refine ⟨h.right_prime, ?_, ?_, h.right_lower, h.right_upper⟩ · rw [hleft] exact h.left_shift · rw [hright] exact h.right_shift calc _ = ∑ p ∈ F.image Prod.fst, (1 : ℝ)/p * ∑ q ∈ secondFiber F p, (1 : ℝ)/q := reciprocalMass_fst F _ ≤ ∑ p ∈ F.image Prod.fst, (1 : ℝ)/p * (K * logLog Y^3 / Real.log u^2) := by apply Finset.sum_le_sum intro p hp exact mul_le_mul_of_nonneg_left (hinner p hp) (by positivity) _ = (∑ p ∈ F.image Prod.fst, (1 : ℝ)/p) * (K * logLog Y^3 / Real.log u^2) := (Finset.sum_mul _ _ _).symm _ ≤ (R * logLog Y) * (K * logLog Y^3 / Real.log u^2) := mul_le_mul_of_nonneg_right houter (by positivity) _ = _ := by ring /-- One uniform reciprocal estimate for all four possible cross incidences of the selected prime pair. Every sum is over an actual finite pair set. -/ /- Original line 21054: Erdos416Proof.PrimePair.exists_reciprocal_bound -/ theorem exists_reciprocal_bound : ∃ C : ℝ, 0 < C ∧ ∀ᶠ Y : ℝ in atTop, ∀ (a b : ℕ) (eL eR : Bool) (u z : ℝ) (F : Finset (ℕ × ℕ)), 0 < a → 0 < b → Real.exp 1 ≤ u → u ≤ z → z ≤ Y → (∀ x ∈ F, Conditions a b eL eR Y u z x) → reciprocalMass F ≤ C * logLog Y^4 / Real.log u^2 := by obtain ⟨K, hK, hnoCross⟩ := exists_reciprocal_bound_no_left_cross obtain ⟨R, hR, hboth⟩ := exists_reciprocal_bound_both_cross have hLL : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop refine ⟨K+R, add_pos hK hR, ?_⟩ filter_upwards [hnoCross, hboth, hLL.eventually_ge_atTop 1] with Y hNoY hBothY hLY intro a b eL eR u z F ha hb hu huz hzY hF have hpow : logLog Y^2 ≤ logLog Y^4 := by have hsq : 1 ≤ logLog Y^2 := by nlinarith [sq_nonneg (logLog Y-1)] calc _ ≤ logLog Y^2 * logLog Y^2 := le_mul_of_one_le_right (sq_nonneg _) hsq _ = _ := by ring have hraise : K * logLog Y^2 / Real.log u^2 ≤ (K+R) * logLog Y^4 / Real.log u^2 := div_le_div_of_nonneg_right (mul_le_mul (le_add_of_nonneg_right hR.le) hpow (sq_nonneg _) (by positivity)) (sq_nonneg _) cases eL with | false => exact (hNoY a b eR u z F ha hb hu huz hF).trans hraise | true => cases eR with | false => have hswap := hNoY b a true u z (F.image Prod.swap) hb ha hu huz (by intro x hx obtain ⟨y, hy, rfl⟩ := Finset.mem_image.mp hx exact (hF y hy).swap) rw [reciprocalMass_swap] at hswap exact hswap.trans hraise | true => apply (hBothY a b u z F ha hb hu huz hzY hF).trans apply div_le_div_of_nonneg_right _ (sq_nonneg _) exact mul_le_mul_of_nonneg_right (le_add_of_nonneg_left hK.le) (by positivity) end PrimePair namespace CollisionState variable {m n : ℕ} /- Original line 21096: Erdos416Proof.CollisionState.dvd_div_of_coprime -/ theorem dvd_div_of_coprime {N p q : ℕ} (hp : p ∣ N) (hq : q ∣ N) (hcop : q.Coprime p) : q ∣ N / p := hcop.dvd_of_dvd_mul_right (by rw [Nat.div_mul_cancel hp]; exact hq) /- Original line 21100: Erdos416Proof.CollisionState.dvd_left_removePrimeAt -/ theorem dvd_left_removePrimeAt {s : CollisionState m n} (idx k : Fin m) (l : Fin n) {p q : ℕ} (hp : p ∣ s.1 idx) (hq : q ∣ s.1 k) (hcop : q.Coprime p) : q ∣ (removePrimeAt s idx l p).1 k := by by_cases hki : k = idx · subst k simpa [removePrimeAt] using dvd_div_of_coprime hp hq hcop · simpa [removePrimeAt, hki] using hq /- Original line 21108: Erdos416Proof.CollisionState.dvd_right_removePrimeAt -/ theorem dvd_right_removePrimeAt {s : CollisionState m n} (idx : Fin m) (l j : Fin n) {p q : ℕ} (hp : p ∣ s.2 l) (hq : q ∣ s.2 j) (hcop : q.Coprime p) : q ∣ (removePrimeAt s idx l p).2 j := by by_cases hjl : j = l · subst j simpa [removePrimeAt] using dvd_div_of_coprime hp hq hcop · simpa [removePrimeAt, hjl] using hq /-- p occurs at the distinguished left position i and at right position l; q occurs at left position k and at the distinguished right position j. -/ /- Original line 21118: Erdos416Proof.CollisionState.removeTwoPrimesAt -/ def removeTwoPrimesAt (s : CollisionState m n) (idx : Fin m) (j : Fin n) (k : Fin m) (l : Fin n) (p q : ℕ) : CollisionState m n := removePrimeAt (removePrimeAt s idx l p) k j q /- Original line 21122: Erdos416Proof.CollisionState.restoreTwoPrimesAt -/ def restoreTwoPrimesAt (s : CollisionState m n) (idx : Fin m) (j : Fin n) (k : Fin m) (l : Fin n) (p q : ℕ) : CollisionState m n := restorePrimeAt (restorePrimeAt s k j q) idx l p /- Original line 21126: Erdos416Proof.CollisionState.restore_removeTwoPrimesAt -/ theorem restore_removeTwoPrimesAt (s : CollisionState m n) (idx : Fin m) (j : Fin n) (k : Fin m) (l : Fin n) (p q : ℕ) (hcop : q.Coprime p) (hpl : p ∣ s.1 idx) (hpr : p ∣ s.2 l) (hql : q ∣ s.1 k) (hqr : q ∣ s.2 j) : restoreTwoPrimesAt (removeTwoPrimesAt s idx j k l p q) idx j k l p q = s := by unfold restoreTwoPrimesAt removeTwoPrimesAt rw [restore_removePrimeAt _ k j q (dvd_left_removePrimeAt idx k l hpl hql hcop) (dvd_right_removePrimeAt idx l j hpr hqr hcop), restore_removePrimeAt s idx l p hpl hpr] /- Original line 21134: Erdos416Proof.CollisionState.restoreTwoPrimesAt_leftValue -/ theorem restoreTwoPrimesAt_leftValue (s : CollisionState m n) (idx : Fin m) (j : Fin n) (k : Fin m) (l : Fin n) (p q : ℕ) : leftValue (restoreTwoPrimesAt s idx j k l p q) = leftValue s * p * q := by rw [restoreTwoPrimesAt, restorePrimeAt_leftValue, restorePrimeAt_leftValue] ring /- Original line 21140: Erdos416Proof.CollisionState.removeTwoPrimesAt_leftValue_mul -/ theorem removeTwoPrimesAt_leftValue_mul (s : CollisionState m n) (idx : Fin m) (j : Fin n) (k : Fin m) (l : Fin n) (p q : ℕ) (hcop : q.Coprime p) (hpl : p ∣ s.1 idx) (hpr : p ∣ s.2 l) (hql : q ∣ s.1 k) (hqr : q ∣ s.2 j) : leftValue (removeTwoPrimesAt s idx j k l p q) * p * q = leftValue s := by rw [← restoreTwoPrimesAt_leftValue, restore_removeTwoPrimesAt s idx j k l p q hcop hpl hpr hql hqr] /- Original line 21147: Erdos416Proof.CollisionState.restoreTwoPrimesAt_left_entry -/ theorem restoreTwoPrimesAt_left_entry (s : CollisionState m n) (idx : Fin m) (j : Fin n) (k : Fin m) (l : Fin n) (p q : ℕ) : (restoreTwoPrimesAt s idx j k l p q).1 idx = s.1 idx * p * (if k = idx then q else 1) := by by_cases hki : k = idx · subst k simp [restoreTwoPrimesAt, restorePrimeAt] ring · simp [restoreTwoPrimesAt, restorePrimeAt, Ne.symm hki, hki] /- Original line 21156: Erdos416Proof.CollisionState.restoreTwoPrimesAt_right_entry -/ theorem restoreTwoPrimesAt_right_entry (s : CollisionState m n) (idx : Fin m) (j : Fin n) (k : Fin m) (l : Fin n) (p q : ℕ) : (restoreTwoPrimesAt s idx j k l p q).2 j = s.2 j * q * (if l = j then p else 1) := by by_cases hlj : l = j · subst l simp [restoreTwoPrimesAt, restorePrimeAt] · simp [restoreTwoPrimesAt, restorePrimeAt, Ne.symm hlj, hlj] /- Original line 21164: Erdos416Proof.CollisionState.removeTwoPrimesAt_positive -/ theorem removeTwoPrimesAt_positive {s : CollisionState m n} (hs : Positive s) (idx : Fin m) (j : Fin n) (k : Fin m) (l : Fin n) {p q : ℕ} (hp : 0 < p) (hq : 0 < q) (hcop : q.Coprime p) (hpl : p ∣ s.1 idx) (hpr : p ∣ s.2 l) (hql : q ∣ s.1 k) (hqr : q ∣ s.2 j) : Positive (removeTwoPrimesAt s idx j k l p q) := removePrimeAt_positive (removePrimeAt_positive hs idx l hp hpl hpr) k j hq (dvd_left_removePrimeAt idx k l hpl hql hcop) (dvd_right_removePrimeAt idx l j hpr hqr hcop) /- Original line 21172: Erdos416Proof.CollisionState.removeTwoPrimesAt_balanced -/ theorem removeTwoPrimesAt_balanced {s : CollisionState m n} {d p q : ℕ} (hs : Balanced d s) (idx : Fin m) (j : Fin n) (k : Fin m) (l : Fin n) (hp : 0 < p) (hq : 0 < q) (hcop : q.Coprime p) (hpl : p ∣ s.1 idx) (hpr : p ∣ s.2 l) (hql : q ∣ s.1 k) (hqr : q ∣ s.2 j) : Balanced d (removeTwoPrimesAt s idx j k l p q) := removePrimeAt_balanced (removePrimeAt_balanced hs idx l hp hpl hpr) k j hq (dvd_left_removePrimeAt idx k l hpl hql hcop) (dvd_right_removePrimeAt idx l j hpr hqr hcop) /- Original line 21180: Erdos416Proof.CollisionState.removeTwoPrimesAt_leftValue_dvd -/ theorem removeTwoPrimesAt_leftValue_dvd (s : CollisionState m n) (idx : Fin m) (j : Fin n) (k : Fin m) (l : Fin n) (p q : ℕ) (hcop : q.Coprime p) (hpl : p ∣ s.1 idx) (hpr : p ∣ s.2 l) (hql : q ∣ s.1 k) (hqr : q ∣ s.2 j) : leftValue (removeTwoPrimesAt s idx j k l p q) ∣ leftValue s := by refine ⟨p*q, ?_⟩ rw [← mul_assoc, removeTwoPrimesAt_leftValue_mul s idx j k l p q hcop hpl hpr hql hqr] /- Original line 21187: Erdos416Proof.CollisionState.removeTwoPrimesAt_squarefree -/ theorem removeTwoPrimesAt_squarefree {s : CollisionState m n} (hsq : Squarefree (leftValue s)) (idx : Fin m) (j : Fin n) (k : Fin m) (l : Fin n) (p q : ℕ) (hcop : q.Coprime p) (hpl : p ∣ s.1 idx) (hpr : p ∣ s.2 l) (hql : q ∣ s.1 k) (hqr : q ∣ s.2 j) : Squarefree (leftValue (removeTwoPrimesAt s idx j k l p q)) := hsq.squarefree_of_dvd (removeTwoPrimesAt_leftValue_dvd s idx j k l p q hcop hpl hpr hql hqr) /- Original line 21193: Erdos416Proof.CollisionState.removeTwoPrimesAt_cardFactors_le -/ theorem removeTwoPrimesAt_cardFactors_le {s : CollisionState m n} (hs : Positive s) (idx : Fin m) (j : Fin n) (k : Fin m) (l : Fin n) (p q : ℕ) (hcop : q.Coprime p) (hpl : p ∣ s.1 idx) (hpr : p ∣ s.2 l) (hql : q ∣ s.1 k) (hqr : q ∣ s.2 j) : ArithmeticFunction.cardFactors (leftValue (removeTwoPrimesAt s idx j k l p q)) ≤ ArithmeticFunction.cardFactors (leftValue s) := by simp only [ArithmeticFunction.cardFactors_apply] exact (Nat.primeFactorsList_sublist_of_dvd (removeTwoPrimesAt_leftValue_dvd s idx j k l p q hcop hpl hpr hql hqr) (leftValue_pos hs).ne').length_le /- Original line 21202: Erdos416Proof.CollisionState.removeTwoPrimesAt_primeFactors_subset -/ theorem removeTwoPrimesAt_primeFactors_subset {s : CollisionState m n} (hs : Positive s) (idx : Fin m) (j : Fin n) (k : Fin m) (l : Fin n) (p q : ℕ) (hcop : q.Coprime p) (hpl : p ∣ s.1 idx) (hpr : p ∣ s.2 l) (hql : q ∣ s.1 k) (hqr : q ∣ s.2 j) : (leftValue (removeTwoPrimesAt s idx j k l p q)).primeFactors ⊆ (leftValue s).primeFactors := by intro a ha simp only [Nat.primeFactors, List.mem_toFinset] at ha ⊢ exact Nat.primeFactorsList_subset_of_dvd (removeTwoPrimesAt_leftValue_dvd s idx j k l p q hcop hpl hpr hql hqr) (leftValue_pos hs).ne' ha /- Original line 21211: Erdos416Proof.CollisionState.removeTwoPrimesAt_unitTails -/ theorem removeTwoPrimesAt_unitTails {idx r t : ℕ} {s : CollisionState (idx+r) (idx+t)} (hs : UnitTails s) (a b k l : Fin idx) (p q : ℕ) : UnitTails (removeTwoPrimesAt s (Fin.castAdd r a) (Fin.castAdd t b) (Fin.castAdd r k) (Fin.castAdd t l) p q) := removePrimeAt_unitTails (removePrimeAt_unitTails hs a l p) k b q /- Original line 21217: Erdos416Proof.CollisionState.removeTwoPrimesAt_pair_injOn -/ theorem removeTwoPrimesAt_pair_injOn (F : Finset (CollisionState m n)) (idx : Fin m) (j : Fin n) (k : Fin m) (l : Fin n) (p q : CollisionState m n → ℕ) (hF : ∀ s ∈ F, (q s).Coprime (p s) ∧ p s ∣ s.1 idx ∧ p s ∣ s.2 l ∧ q s ∣ s.1 k ∧ q s ∣ s.2 j) : Set.InjOn (fun s => (removeTwoPrimesAt s idx j k l (p s) (q s), p s, q s)) (F : Set _) := by intro s hs a ha heq have hrec := congrArg (fun z : CollisionState m n × ℕ × ℕ => restoreTwoPrimesAt z.1 idx j k l z.2.1 z.2.2) heq have hsF := hF s hs have haF := hF a ha simpa only [restore_removeTwoPrimesAt s _ _ _ _ _ _ hsF.1 hsF.2.1 hsF.2.2.1 hsF.2.2.2.1 hsF.2.2.2.2, restore_removeTwoPrimesAt a _ _ _ _ _ _ haF.1 haF.2.1 haF.2.2.1 haF.2.2.2.1 haF.2.2.2.2] using hrec /- Original line 21230: Erdos416Proof.CollisionState.removeTwoPrimesAt_fiber_pair_injOn -/ theorem removeTwoPrimesAt_fiber_pair_injOn (F : Finset (CollisionState m n)) (idx : Fin m) (j : Fin n) (k : Fin m) (l : Fin n) (p q : CollisionState m n → ℕ) (hF : ∀ s ∈ F, (q s).Coprime (p s) ∧ p s ∣ s.1 idx ∧ p s ∣ s.2 l ∧ q s ∣ s.1 k ∧ q s ∣ s.2 j) (a : CollisionState m n) : Set.InjOn (fun s => (p s, q s)) (↑(F.filter (fun s => removeTwoPrimesAt s idx j k l (p s) (q s) = a)) : Set _) := by intro s hs b hb heq obtain ⟨hsF, hsR⟩ := Finset.mem_filter.mp hs obtain ⟨hbF, hbR⟩ := Finset.mem_filter.mp hb exact removeTwoPrimesAt_pair_injOn F idx j k l p q hF hsF hbF (Prod.ext (hsR.trans hbR.symm) heq) /- Original line 21242: Erdos416Proof.CollisionState.reciprocalMass_removeTwoPrimesAt -/ theorem reciprocalMass_removeTwoPrimesAt (d : ℕ) (F : Finset (CollisionState m n)) (idx : Fin m) (j : Fin n) (k : Fin m) (l : Fin n) (p q : CollisionState m n → ℕ) (hF : ∀ s ∈ F, (q s).Coprime (p s) ∧ p s ∣ s.1 idx ∧ p s ∣ s.2 l ∧ q s ∣ s.1 k ∧ q s ∣ s.2 j) : reciprocalMass d F = ∑ a ∈ F.image (fun s => removeTwoPrimesAt s idx j k l (p s) (q s)), ((1 : ℝ) / ((d : ℝ) * leftValue a)) * PrimePair.reciprocalMass ((F.filter (fun s => removeTwoPrimesAt s idx j k l (p s) (q s) = a)).image (fun s => (p s, q s))) := by let f := fun s => removeTwoPrimesAt s idx j k l (p s) (q s) have hsplit := Finset.sum_fiberwise_of_maps_to (s := F) (t := F.image f) (g := f) (fun s hs => Finset.mem_image.mpr ⟨s, hs, rfl⟩) (fun s => (1 : ℝ) / ((d : ℝ) * leftValue s)) calc _ = ∑ a ∈ F.image f, ∑ s ∈ F.filter (fun s => f s = a), (1 : ℝ) / ((d : ℝ) * leftValue s) := hsplit.symm _ = _ := by apply Finset.sum_congr rfl intro a ha rw [PrimePair.reciprocalMass, Finset.mul_sum, Finset.sum_image (removeTwoPrimesAt_fiber_pair_injOn F idx j k l p q hF a)] apply Finset.sum_congr rfl intro s hs obtain ⟨hsF, hsR⟩ := Finset.mem_filter.mp hs have hdivs := hF s hsF have hvalue := removeTwoPrimesAt_leftValue_mul s idx j k l (p s) (q s) hdivs.1 hdivs.2.1 hdivs.2.2.1 hdivs.2.2.2.1 hdivs.2.2.2.2 change leftValue (f s) * p s * q s = leftValue s at hvalue rw [hsR] at hvalue rw [← hvalue, Nat.cast_mul, Nat.cast_mul] simp [div_eq_mul_inv, mul_assoc, mul_comm, mul_left_comm] /-- Original distinguished shifted primes and recorded cross positions. The prime-pair incidence flags are derived from these positions. -/ /- Original line 21275: Erdos416Proof.CollisionState.DifferentPrimeConditions -/ structure DifferentPrimeConditions (a b : ℕ) (idx : Fin m) (j : Fin n) (k : Fin m) (l : Fin n) (p q : ℕ) (Y u z : ℝ) (s : CollisionState m n) : Prop where positive : Positive s left_prime : p.Prime right_prime : q.Prime primes_ne : p ≠ q left_own_dvd : p ∣ s.1 idx right_cross_dvd : p ∣ s.2 l left_cross_dvd : q ∣ s.1 k right_own_dvd : q ∣ s.2 j left_shift : (a*s.1 idx+1).Prime right_shift : (b*s.2 j+1).Prime shifts_ne : a*s.1 idx ≠ b*s.2 j left_size : ((a*s.1 idx : ℕ) : ℝ) ≤ Y right_size : ((b*s.2 j : ℕ) : ℝ) ≤ Y left_lower : u ≤ (p : ℝ) left_upper : (p : ℝ) ≤ z right_lower : u ≤ (q : ℝ) right_upper : (q : ℝ) ≤ z /- Original line 21295: Erdos416Proof.CollisionState.DifferentPrimeConditions.coprime -/ theorem DifferentPrimeConditions.coprime {a b p q : ℕ} {idx k : Fin m} {j l : Fin n} {Y u z : ℝ} {s : CollisionState m n} (h : DifferentPrimeConditions a b idx j k l p q Y u z s) : q.Coprime p := (Nat.coprime_primes h.right_prime h.left_prime).mpr h.primes_ne.symm /-- For fixed recorded positions, the remaining-state coefficients are fixed before applying the four-case prime-pair estimate. -/ /- Original line 21301: Erdos416Proof.CollisionState.exists_differentPrime_state_mass_bound -/ theorem exists_differentPrime_state_mass_bound : ∃ C : ℝ, 0 < C ∧ ∀ᶠ Y : ℝ in atTop, ∀ (m n : ℕ) (idx : Fin m) (j : Fin n) (k : Fin m) (l : Fin n) (a b : ℕ) (u z : ℝ) (F : Finset (CollisionState m n)) (p q : CollisionState m n → ℕ), 0 < a → 0 < b → Real.exp 1 ≤ u → u ≤ z → z ≤ Y → (∀ s ∈ F, DifferentPrimeConditions a b idx j k l (p s) (q s) Y u z s) → reciprocalMass 1 F ≤ (C * logLog Y^4 / Real.log u^2) * reciprocalMass 1 (F.image (fun s => removeTwoPrimesAt s idx j k l (p s) (q s))) := by obtain ⟨C, hC, hbound⟩ := PrimePair.exists_reciprocal_bound refine ⟨C, hC, ?_⟩ filter_upwards [hbound] with Y hY intro m n idx j k l a b u z F p q ha hb hu huz hzY hF have hdivs (s : CollisionState m n) (hs : s ∈ F) : (q s).Coprime (p s) ∧ p s ∣ s.1 idx ∧ p s ∣ s.2 l ∧ q s ∣ s.1 k ∧ q s ∣ s.2 j := ⟨(hF s hs).coprime, (hF s hs).left_own_dvd, (hF s hs).right_cross_dvd, (hF s hs).left_cross_dvd, (hF s hs).right_own_dvd⟩ let f := fun s => removeTwoPrimesAt s idx j k l (p s) (q s) have hfiber (tau : CollisionState m n) (htau : tau ∈ F.image f) : PrimePair.reciprocalMass ((F.filter (fun s => f s = tau)).image (fun s => (p s, q s))) ≤ C * logLog Y^4 / Real.log u^2 := by let A := a * tau.1 idx let B := b * tau.2 j obtain ⟨s, hs, hsR⟩ := Finset.mem_image.mp htau have hcond := hF s hs have htauPos : Positive tau := by rw [← hsR] exact removeTwoPrimesAt_positive hcond.positive idx j k l hcond.left_prime.pos hcond.right_prime.pos hcond.coprime hcond.left_own_dvd hcond.right_cross_dvd hcond.left_cross_dvd hcond.right_own_dvd apply hY A B (decide (k=idx)) (decide (l=j)) u z _ (Nat.mul_pos ha (htauPos.1 idx)) (Nat.mul_pos hb (htauPos.2 j)) hu huz hzY intro x hx obtain ⟨w, hw, rfl⟩ := Finset.mem_image.mp hx obtain ⟨hwF, hwR⟩ := Finset.mem_filter.mp hw have hwcond := hF w hwF have hrec := restore_removeTwoPrimesAt w idx j k l (p w) (q w) hwcond.coprime hwcond.left_own_dvd hwcond.right_cross_dvd hwcond.left_cross_dvd hwcond.right_own_dvd change restoreTwoPrimesAt (f w) idx j k l (p w) (q w) = w at hrec rw [hwR] at hrec have hl : tau.1 idx * p w * (if k=idx then q w else 1) = w.1 idx := by simpa only [restoreTwoPrimesAt_left_entry] using congrArg (fun s : CollisionState m n => s.1 idx) hrec have hr : tau.2 j * q w * (if l=j then p w else 1) = w.2 j := by simpa only [restoreTwoPrimesAt_right_entry] using congrArg (fun s : CollisionState m n => s.2 j) hrec have hleft : A*p w*(if decide (k=idx) then q w else 1) = a*w.1 idx := by simpa [Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, A, mul_assoc] using congrArg (fun N : ℕ => a*N) hl have hright : B*q w*(if decide (l=j) then p w else 1) = b*w.2 j := by simpa [Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, B, mul_assoc] using congrArg (fun N : ℕ => b*N) hr refine ⟨hwcond.left_prime, hwcond.right_prime, ?_, ?_, ?_, ?_, ?_, hwcond.left_lower, hwcond.left_upper, hwcond.right_lower, hwcond.right_upper⟩ · rw [hleft] exact hwcond.left_shift · rw [hright] exact hwcond.right_shift · rw [hleft, hright] exact hwcond.shifts_ne · rw [hleft] exact hwcond.left_size · rw [hright] exact hwcond.right_size rw [reciprocalMass_removeTwoPrimesAt 1 F idx j k l p q hdivs] calc _ ≤ ∑ tau ∈ F.image f, ((1 : ℝ) / ((1 : ℕ) * leftValue tau)) * (C * logLog Y^4 / Real.log u^2) := by apply Finset.sum_le_sum intro tau htau exact mul_le_mul_of_nonneg_left (hfiber tau htau) (by positivity) _ = _ := by rw [reciprocalMass, Finset.mul_sum] apply Finset.sum_congr rfl intro tau htau ring /-- Fixed cross positions among the active entries retain the active allocation dimension after both selected primes have been removed. -/ /- Original line 21376: Erdos416Proof.CollisionState.exists_differentPrime_unitTail_allocation_bound -/ theorem exists_differentPrime_unitTail_allocation_bound : ∃ C : ℝ, 0 < C ∧ ∀ᶠ Y : ℝ in atTop, ∀ (idx r t : ℕ) (j k l : Fin idx) (a b : ℕ) (u z I H : ℝ) (F : Finset (CollisionState (idx+r) (idx+t))) (p q : CollisionState (idx+r) (idx+t) → ℕ) (P : Finset ℕ), 1 ≤ idx → 0 < a → 0 < b → Real.exp 1 ≤ u → u ≤ z → z ≤ Y → (∀ s ∈ F, DifferentPrimeConditions a b (Fin.castAdd r j) (Fin.castAdd t j) (Fin.castAdd r k) (Fin.castAdd t l) (p s) (q s) Y u z s ∧ UnitTails s ∧ Balanced 1 s ∧ Squarefree (leftValue s) ∧ (leftValue s).primeFactors ⊆ P ∧ (ArithmeticFunction.cardFactors (leftValue s) : ℝ) ≤ I) → (∑ p ∈ P, (1 : ℝ)/p) ≤ H → reciprocalMass 1 F ≤ (C * logLog Y^4 / Real.log u^2) * Real.exp (I * Real.log idx + (idx : ℝ)*H) := by obtain ⟨C, hC, hbound⟩ := exists_differentPrime_state_mass_bound refine ⟨C, hC, ?_⟩ filter_upwards [hbound] with Y hY intro idx r t j k l a b u z I H F p q P hi ha hb hu huz hzY hF hH let f := fun s => removeTwoPrimesAt s (Fin.castAdd r j) (Fin.castAdd t j) (Fin.castAdd r k) (Fin.castAdd t l) (p s) (q s) have hmass := hY (idx+r) (idx+t) (Fin.castAdd r j) (Fin.castAdd t j) (Fin.castAdd r k) (Fin.castAdd t l) a b u z F p q ha hb hu huz hzY (fun s hs => (hF s hs).1) have htail : ∀ tau ∈ F.image f, UnitTails tau := by intro tau htau obtain ⟨s, hs, rfl⟩ := Finset.mem_image.mp htau exact removeTwoPrimesAt_unitTails (hF s hs).2.1 j j k l (p s) (q s) have hremaining : ∀ tau ∈ F.image f, Balanced 1 tau ∧ Squarefree (leftValue tau) ∧ (leftValue tau).primeFactors ⊆ P ∧ (ArithmeticFunction.cardFactors (leftValue tau) : ℝ) ≤ I := by intro tau htau obtain ⟨s, hs, rfl⟩ := Finset.mem_image.mp htau obtain ⟨hcond, _, hbal, hsq, hsupport, hOmega⟩ := hF s hs refine ⟨removeTwoPrimesAt_balanced hbal _ _ _ _ hcond.left_prime.pos hcond.right_prime.pos hcond.coprime hcond.left_own_dvd hcond.right_cross_dvd hcond.left_cross_dvd hcond.right_own_dvd, removeTwoPrimesAt_squarefree hsq _ _ _ _ _ _ hcond.coprime hcond.left_own_dvd hcond.right_cross_dvd hcond.left_cross_dvd hcond.right_own_dvd, (removeTwoPrimesAt_primeFactors_subset hcond.positive _ _ _ _ _ _ hcond.coprime hcond.left_own_dvd hcond.right_cross_dvd hcond.left_cross_dvd hcond.right_own_dvd).trans hsupport, ?_⟩ have hle : (ArithmeticFunction.cardFactors (leftValue (f s)) : ℝ) ≤ ArithmeticFunction.cardFactors (leftValue s) := by exact_mod_cast removeTwoPrimesAt_cardFactors_le hcond.positive _ _ _ _ _ _ hcond.coprime hcond.left_own_dvd hcond.right_cross_dvd hcond.left_cross_dvd hcond.right_own_dvd exact hle.trans hOmega have halloc := reciprocalMass_unitTail_bound hi (F.image f) P htail hremaining hH exact hmass.trans (mul_le_mul_of_nonneg_left halloc (by positivity)) /- Original line 21421: Erdos416Proof.CollisionState.differentPrimeIntervalFiber -/ noncomputable def differentPrimeIntervalFiber (u v : ℝ) (idx : Fin m) (j : Fin n) (sigma : CollisionState m n) (F : Finset (CollisionState m n)) : Finset (CollisionState m n) := (compatibleIntervalFiber u v sigma F).filter (fun tau => largestPrimeFactor (tau.1 idx) ≠ largestPrimeFactor (tau.2 j)) /- Original line 21426: Erdos416Proof.CollisionState.compatibleInterval_prime_data -/ theorem compatibleInterval_prime_data {idx r t d : ℕ} {S u v W Y : ℝ} (j : Fin idx) {F : Finset (CollisionState (idx+r) (idx+t))} {sigma tau : CollisionState (idx+r) (idx+t)} (hu : 1 ≤ u) (huW : u < W) (hF : ∀ s ∈ F, MiddleOriginalConditions S u v W Y d j s) (hsigma : sigma ∈ lowStates u (lowStates v F)) (htau : tau ∈ compatibleIntervalFiber u v sigma F) : Positive tau ∧ (largestPrimeFactor (tau.1 (Fin.castAdd r j))).Prime ∧ (largestPrimeFactor (tau.2 (Fin.castAdd t j))).Prime ∧ (sigma.1 (Fin.castAdd r j)*tau.1 (Fin.castAdd r j)+1).Prime ∧ (sigma.2 (Fin.castAdd t j)*tau.2 (Fin.castAdd t j)+1).Prime ∧ sigma.1 (Fin.castAdd r j)*tau.1 (Fin.castAdd r j) ≠ sigma.2 (Fin.castAdd t j)*tau.2 (Fin.castAdd t j) ∧ ((sigma.1 (Fin.castAdd r j)*tau.1 (Fin.castAdd r j) : ℕ) : ℝ) ≤ Y ∧ ((sigma.2 (Fin.castAdd t j)*tau.2 (Fin.castAdd t j) : ℕ) : ℝ) ≤ Y ∧ W ≤ (largestPrimeFactor (tau.1 (Fin.castAdd r j)) : ℝ) ∧ (largestPrimeFactor (tau.1 (Fin.castAdd r j)) : ℝ) ≤ v ∧ W ≤ (largestPrimeFactor (tau.2 (Fin.castAdd t j)) : ℝ) ∧ (largestPrimeFactor (tau.2 (Fin.castAdd t j)) : ℝ) ≤ v := by obtain ⟨s, hs, hsCut, hsInt⟩ := compatibleIntervalFiber_witness hsigma htau have hcond := hF s hs have hleft : sigma.1 (Fin.castAdd r j)*tau.1 (Fin.castAdd r j) = s.1 (Fin.castAdd r j) := by have h := congrArg (fun w : CollisionState (idx+r) (idx+t) => w.1 (Fin.castAdd r j)) hsCut change lowPrimePart (s.1 (Fin.castAdd r j)) v = sigma.1 (Fin.castAdd r j)*tau.1 (Fin.castAdd r j) at h rw [lowPrimePart_eq_self_of_largest_le (hcond.positive.1 _) hcond.left_largest.2] at h exact h.symm have hright : sigma.2 (Fin.castAdd t j)*tau.2 (Fin.castAdd t j) = s.2 (Fin.castAdd t j) := by have h := congrArg (fun w : CollisionState (idx+r) (idx+t) => w.2 (Fin.castAdd t j)) hsCut change lowPrimePart (s.2 (Fin.castAdd t j)) v = sigma.2 (Fin.castAdd t j)*tau.2 (Fin.castAdd t j) at h rw [lowPrimePart_eq_self_of_largest_le (hcond.positive.2 _) hcond.right_largest.2] at h exact h.symm have hselected (N : ℕ) (hl : W ≤ (largestPrimeFactor N : ℝ)) (hr : (largestPrimeFactor N : ℝ) ≤ v) : (largestPrimeFactor (primePart N (fun p => u < (p : ℝ) ∧ (p : ℝ) ≤ v))).Prime ∧ W ≤ (largestPrimeFactor (primePart N (fun p => u < (p : ℝ) ∧ (p : ℝ) ≤ v)) : ℝ) ∧ (largestPrimeFactor (primePart N (fun p => u < (p : ℝ) ∧ (p : ℝ) ≤ v)) : ℝ) ≤ v := by have hlarge : 1 < largestPrimeFactor N := by have hreal : (1 : ℝ) < largestPrimeFactor N := (hu.trans_lt huW).trans_le hl exact_mod_cast hreal rw [primePart_largestPrimeFactor_eq hlarge _ ⟨huW.trans_le hl, hr⟩] exact ⟨largestPrimeFactor_isPrime hlarge, hl, hr⟩ have hp : (largestPrimeFactor (tau.1 (Fin.castAdd r j))).Prime ∧ W ≤ (largestPrimeFactor (tau.1 (Fin.castAdd r j)) : ℝ) ∧ (largestPrimeFactor (tau.1 (Fin.castAdd r j)) : ℝ) ≤ v := by rw [← hsInt] exact hselected _ hcond.left_largest.1 hcond.left_largest.2 have hq : (largestPrimeFactor (tau.2 (Fin.castAdd t j))).Prime ∧ W ≤ (largestPrimeFactor (tau.2 (Fin.castAdd t j)) : ℝ) ∧ (largestPrimeFactor (tau.2 (Fin.castAdd t j)) : ℝ) ≤ v := by rw [← hsInt] exact hselected _ hcond.right_largest.1 hcond.right_largest.2 refine ⟨?_, hp.1, hq.1, ?_, ?_, ?_, ?_, ?_, hp.2.1, hp.2.2, hq.2.1, hq.2.2⟩ · rw [← hsInt] exact ⟨fun _ => primePart_pos _ _, fun _ => primePart_pos _ _⟩ · rw [hleft] exact (hcond.left_normal j).1 · rw [hright] exact hcond.right_prime · rw [hleft, hright] exact hcond.distinguished_ne · rw [hleft] exact hcond.left_size · rw [hright] exact hcond.right_size /- Original line 21490: Erdos416Proof.CollisionState.exists_active_cross_positions -/ theorem exists_active_cross_positions {idx r t : ℕ} {s : CollisionState (idx+r) (idx+t)} (j : Fin idx) (htail : UnitTails s) (hbal : Balanced 1 s) {p q : ℕ} (hp : p.Prime) (hq : q.Prime) (hpl : p ∣ s.1 (Fin.castAdd r j)) (hqr : q ∣ s.2 (Fin.castAdd t j)) : ∃ kl : Fin idx × Fin idx, q ∣ s.1 (Fin.castAdd r kl.1) ∧ p ∣ s.2 (Fin.castAdd t kl.2) := by have hbal' : leftValue s = rightValue s := by simpa only [Balanced, one_mul] using hbal have hqprod : q ∣ ∏ a : Fin idx, s.1 (Fin.castAdd r a) := by change q ∣ leftValue (prefixState idx r t s) rw [prefix_leftValue htail, hbal'] exact hqr.trans (Finset.dvd_prod_of_mem s.2 (Finset.mem_univ _)) have hpprod : p ∣ ∏ a : Fin idx, s.2 (Fin.castAdd t a) := by change p ∣ rightValue (prefixState idx r t s) rw [prefix_rightValue htail, ← hbal'] exact hpl.trans (Finset.dvd_prod_of_mem s.1 (Finset.mem_univ _)) obtain ⟨k, _, hk⟩ := (Nat.prime_iff.mp hq).exists_mem_finset_dvd hqprod obtain ⟨l, _, hl⟩ := (Nat.prime_iff.mp hp).exists_mem_finset_dvd hpprod exact ⟨(k,l), hk, hl⟩ /-- The actual different-largest-prime compatible fiber, summed over its recorded active cross positions. The i^2 factor is the exact number of possible position pairs, not an independence assumption about the primes. -/ /- Original line 21511: Erdos416Proof.CollisionState.exists_differentPrime_interval_fiber_bound -/ theorem exists_differentPrime_interval_fiber_bound : ∃ C : ℝ, 0 < C ∧ ∀ᶠ Y : ℝ in atTop, ∀ (S u v W : ℝ) (idx r t d : ℕ) (j : Fin idx) (F : Finset (CollisionState (idx+r) (idx+t))) (sigma : CollisionState (idx+r) (idx+t)), Real.exp (Real.exp 1) ≤ S → S ≤ u → u < W → W ≤ v → v ≤ Y → 1 ≤ idx → 0 < d → (∀ p ∈ d.primeFactorsList, (p : ℝ) ≤ u) → (∀ s ∈ F, MiddleOriginalConditions S u v W Y d j s) → sigma ∈ lowStates u (lowStates v F) → reciprocalMass 1 (differentPrimeIntervalFiber u v (Fin.castAdd r j) (Fin.castAdd t j) sigma F) ≤ (C * (idx : ℝ)^2 * logLog Y^4 / Real.log W^2) * Real.exp ((1 + Real.log idx) * ((idx : ℝ) * (logLog v - logLog u + Real.sqrt (logLog S * logLog Y)))) := by obtain ⟨C, hC, hbound⟩ := exists_differentPrime_unitTail_allocation_bound obtain ⟨B, hB⟩ := prime_reciprocal_mertens refine ⟨C, hC, ?_⟩ filter_upwards [hbound, normality_interval_error_ge_eventually (2*|B|)] with Y hY hError intro S u v W idx r t d j F sigma hS hSu huW hWv hvY hi hd hdU hF hsigma have hSe : Real.exp 1 ≤ S := (Real.exp_le_exp.mpr (by linarith [Real.add_one_le_exp (1 : ℝ)])).trans hS have hu2 : 2 ≤ u := by linarith [Real.add_one_le_exp (1 : ℝ)] have huv : u < v := huW.trans_le hWv have hW : Real.exp 1 ≤ W := (hSe.trans hSu).trans huW.le have hvLL : logLog v ≤ logLog Y := logLog_mono (by linarith) hvY have hsigmaPos : Positive sigma := by obtain ⟨s, _, rfl⟩ := Finset.mem_image.mp hsigma exact cut_positive _ _ let G := differentPrimeIntervalFiber u v (Fin.castAdd r j) (Fin.castAdd t j) sigma F let p := fun tau : CollisionState (idx+r) (idx+t) => largestPrimeFactor (tau.1 (Fin.castAdd r j)) let q := fun tau : CollisionState (idx+r) (idx+t) => largestPrimeFactor (tau.2 (Fin.castAdd t j)) let I := (idx : ℝ) * (logLog v - logLog u + Real.sqrt (logLog S * logLog Y)) let H := logLog v - logLog u + 2*|B| let P := (Nat.primesLE ⌊v⌋₊).filter (fun p : ℕ => u < (p : ℝ) ∧ (p : ℝ) ≤ v) have hH : (∑ p ∈ P, (1 : ℝ)/p) ≤ H := by have h := (abs_le.mp (prime_interval_reciprocal_error hB hu2 huv.le le_rfl)).2 change (∑ p ∈ P, (1 : ℝ)/p) - (logLog v - logLog u) ≤ 2*|B| at h dsimp [Erdos416Proof.largestPrimeFactor_one, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, H] linarith have hdata (tau : CollisionState (idx+r) (idx+t)) (htau : tau ∈ G) : UnitTails tau ∧ Balanced 1 tau ∧ Squarefree (leftValue tau) ∧ (leftValue tau).primeFactors ⊆ P ∧ (ArithmeticFunction.cardFactors (leftValue tau) : ℝ) ≤ I := by obtain ⟨htCompat, _⟩ := Finset.mem_filter.mp htau obtain ⟨s, hs, _, hsInt⟩ := compatibleIntervalFiber_witness hsigma htCompat have hcond := hF s hs rw [← hsInt] refine ⟨interval_unitTails s hcond.left_tail hcond.right_tail, interval_balanced hd hcond.positive hcond.balanced huv.le hdU, interval_leftValue_squarefree hcond.positive hcond.square_exclusion, ?_, interval_cardFactors_bound s hcond.positive hSe hSu huv hvLL hcond.left_normal hcond.left_tail⟩ intro a ha have haList : a ∈ (leftValue (interval u v s)).primeFactorsList := by simpa only [Nat.primeFactors, List.mem_toFinset] using ha have haRange := interval_leftValue_support u v hcond.positive a haList exact Finset.mem_filter.mpr ⟨Nat.mem_primesLE.mpr ⟨Nat.le_floor haRange.2, Nat.prime_of_mem_primeFactors ha⟩, haRange⟩ have hpositions (tau : CollisionState (idx+r) (idx+t)) (htau : tau ∈ G) : ∃ kl : Fin idx × Fin idx, q tau ∣ tau.1 (Fin.castAdd r kl.1) ∧ p tau ∣ tau.2 (Fin.castAdd t kl.2) := by have hprimeData := compatibleInterval_prime_data j (by linarith) huW hF hsigma (Finset.mem_filter.mp htau).1 exact exists_active_cross_positions j (hdata tau htau).1 (hdata tau htau).2.1 hprimeData.2.1 hprimeData.2.2.1 (largestPrimeFactor_dvd _) (largestPrimeFactor_dvd _) let positions := fun tau : CollisionState (idx+r) (idx+t) => if h : tau ∈ G then Classical.choose (hpositions tau h) else (j,j) have hpos (tau : CollisionState (idx+r) (idx+t)) (htau : tau ∈ G) : q tau ∣ tau.1 (Fin.castAdd r (positions tau).1) ∧ p tau ∣ tau.2 (Fin.castAdd t (positions tau).2) := by dsimp [Erdos416Proof.largestPrimeFactor_one, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, positions] rw [dif_pos htau] exact Classical.choose_spec (hpositions tau htau) have hroom : (idx : ℝ)*H ≤ I := by dsimp [Erdos416Proof.largestPrimeFactor_one, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, H, I] exact mul_le_mul_of_nonneg_left (add_le_add le_rfl (hError S hS)) (Nat.cast_nonneg idx) have hexp : Real.exp (I * Real.log idx + (idx : ℝ)*H) ≤ Real.exp ((1 + Real.log idx)*I) := by apply Real.exp_le_exp.mpr nlinarith have hEach (kl : Fin idx × Fin idx) : reciprocalMass 1 (G.filter (fun tau => positions tau = kl)) ≤ (C * logLog Y^4 / Real.log W^2) * Real.exp ((1 + Real.log idx)*I) := by have hlocal := hY idx r t j kl.1 kl.2 (sigma.1 (Fin.castAdd r j)) (sigma.2 (Fin.castAdd t j)) W v I H (G.filter (fun tau => positions tau = kl)) p q P hi (hsigmaPos.1 _) (hsigmaPos.2 _) hW hWv hvY (by intro tau htau obtain ⟨htG, htPos⟩ := Finset.mem_filter.mp htau obtain ⟨htCompat, htNe⟩ := Finset.mem_filter.mp htG obtain ⟨htPositive, hpPrime, hqPrime, hpShift, hqShift, hShiftNe, hpY, hqY, hpW, hpv, hqW, hqv⟩ := compatibleInterval_prime_data j (by linarith) huW hF hsigma htCompat have hcross := hpos tau htG rw [htPos] at hcross exact ⟨⟨htPositive, hpPrime, hqPrime, htNe, largestPrimeFactor_dvd _, hcross.2, hcross.1, largestPrimeFactor_dvd _, hpShift, hqShift, hShiftNe, hpY, hqY, hpW, hpv, hqW, hqv⟩, hdata tau htG⟩) hH exact hlocal.trans (mul_le_mul_of_nonneg_left hexp (by positivity)) have hsplit := Finset.sum_fiberwise G positions (fun tau => (1 : ℝ)/((1 : ℝ)*leftValue tau)) have hsplit' : (∑ kl : Fin idx × Fin idx, reciprocalMass 1 (G.filter (fun tau => positions tau = kl))) = reciprocalMass 1 G := by simpa only [reciprocalMass, Nat.cast_one] using hsplit calc _ = ∑ kl : Fin idx × Fin idx, reciprocalMass 1 (G.filter (fun tau => positions tau = kl)) := hsplit'.symm _ ≤ ∑ _kl : Fin idx × Fin idx, (C * logLog Y^4 / Real.log W^2) * Real.exp ((1 + Real.log idx)*I) := Finset.sum_le_sum (fun kl _ => hEach kl) _ = _ := by simp [Erdos416Proof.largestPrimeFactor_one, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, Fintype.card_prod, Nat.cast_mul, pow_two]; ring /- Original line 21610: Erdos416Proof.CollisionState.reciprocalMass_compatibleInterval_split -/ theorem reciprocalMass_compatibleInterval_split (u v : ℝ) (idx : Fin m) (j : Fin n) (sigma : CollisionState m n) (F : Finset (CollisionState m n)) : reciprocalMass 1 (compatibleIntervalFiber u v sigma F) = reciprocalMass 1 (sharedPrimeIntervalFiber u v idx j sigma F) + reciprocalMass 1 (differentPrimeIntervalFiber u v idx j sigma F) := by simpa only [reciprocalMass, sharedPrimeIntervalFiber, differentPrimeIntervalFiber, Nat.cast_one] using (Finset.sum_filter_add_sum_filter_not (compatibleIntervalFiber u v sigma F) (fun tau => largestPrimeFactor (tau.1 idx) = largestPrimeFactor (tau.2 j)) (fun tau => (1 : ℝ)/((1 : ℝ)*leftValue tau))).symm /-- The complete middle compatible-fiber estimate. The required dimension bound is explicit and is not inferred from the normality hypotheses. -/ /- Original line 21622: Erdos416Proof.CollisionState.exists_middle_interval_fiber_bound -/ theorem exists_middle_interval_fiber_bound : ∃ C : ℝ, 0 < C ∧ ∀ᶠ Y : ℝ in atTop, ∀ (S u v W : ℝ) (idx r t d : ℕ) (j : Fin idx) (F : Finset (CollisionState (idx+r) (idx+t))) (sigma : CollisionState (idx+r) (idx+t)), Real.exp (Real.exp 1) ≤ S → S ≤ u → u < W → W ≤ v → v ≤ Y → 1 ≤ idx → (idx : ℝ) ≤ logLog Y → 0 < d → (∀ p ∈ d.primeFactorsList, (p : ℝ) ≤ u) → (∀ s ∈ F, MiddleOriginalConditions S u v W Y d j s) → sigma ∈ lowStates u (lowStates v F) → reciprocalMass 1 (compatibleIntervalFiber u v sigma F) ≤ (C * logLog Y^6 / Real.log W^2) * Real.exp ((1 + Real.log idx) * ((idx : ℝ) * (logLog v - logLog u + Real.sqrt (logLog S * logLog Y)))) := by obtain ⟨A, hA, hShared⟩ := exists_sharedPrime_interval_fiber_bound obtain ⟨B, hB, hDifferent⟩ := exists_differentPrime_interval_fiber_bound have hLL : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop refine ⟨A+B, add_pos hA hB, ?_⟩ filter_upwards [hShared, hDifferent, hLL.eventually_ge_atTop 1] with Y hSieve1 hSieve2 hLY intro S u v W idx r t d j F sigma hS hSu huW hWv hvY hi hiY hd hdU hF hsigma have hshared := hSieve1 S u v W idx r t d j F sigma hS hSu huW hWv hvY hi hd hdU hF hsigma have hdifferent := hSieve2 S u v W idx r t d j F sigma hS hSu huW hWv hvY hi hd hdU hF hsigma let E := Real.exp ((1 + Real.log idx) * ((idx : ℝ) * (logLog v - logLog u + Real.sqrt (logLog S * logLog Y)))) have hE : 0 ≤ E := (Real.exp_pos _).le have hfirst : A * logLog Y^3 / Real.log W^2 ≤ A * logLog Y^6 / Real.log W^2 := div_le_div_of_nonneg_right (mul_le_mul_of_nonneg_left (pow_le_pow_right₀ hLY (by omega : 3 ≤ 6)) hA.le) (sq_nonneg _) have hi2 : (idx : ℝ)^2 ≤ logLog Y^2 := pow_le_pow_left₀ (Nat.cast_nonneg idx) hiY 2 have hsecond : B * (idx : ℝ)^2 * logLog Y^4 / Real.log W^2 ≤ B * logLog Y^6 / Real.log W^2 := by apply div_le_div_of_nonneg_right _ (sq_nonneg _) calc _ ≤ B * logLog Y^2 * logLog Y^4 := mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left hi2 hB.le) (by positivity) _ = _ := by ring calc _ = reciprocalMass 1 (sharedPrimeIntervalFiber u v (Fin.castAdd r j) (Fin.castAdd t j) sigma F) + reciprocalMass 1 (differentPrimeIntervalFiber u v (Fin.castAdd r j) (Fin.castAdd t j) sigma F) := reciprocalMass_compatibleInterval_split _ _ _ _ _ _ _ ≤ (A * logLog Y^3 / Real.log W^2) * E + (B * (idx : ℝ)^2 * logLog Y^4 / Real.log W^2) * E := add_le_add hshared hdifferent _ ≤ (A * logLog Y^6 / Real.log W^2) * E + (B * logLog Y^6 / Real.log W^2) * E := add_le_add (mul_le_mul_of_nonneg_right hfirst hE) (mul_le_mul_of_nonneg_right hsecond hE) _ = _ := by ring end CollisionState end Erdos416Proof /- Uniform initial, middle and terminal applications to one original family, the derived dimension bound, and the complete raw finite-stage iteration. -/ open Filter Asymptotics MeasureTheory open scoped BigOperators Classical Topology namespace Erdos416Proof.CollisionState variable {m n : ℕ} /-- One original solution family, before any cutoff is applied. Prefix and tail hypotheses refer to the actual natural positions in the ordered lists. -/ /- Original line 21684: Erdos416Proof.CollisionState.SieveOriginalConditions -/ structure SieveOriginalConditions (k d : ℕ) (S Y R : ℝ) (v W : ℕ → ℝ) (s : CollisionState m n) : Prop where positive : Positive s balanced : Balanced d s size : R * (d : ℝ) * leftValue s ≤ Y square_exclusion : NoLargePrimeSquare (d * leftValue s) (v k) normal_left : ∀ a : Fin m, a.val < k → SNormal S (s.1 a+1) normal_right : ∀ a : Fin n, a.val < k → SNormal S (s.2 a+1) distinct : ∀ (a : Fin m) (b : Fin n), a.val < k → b.val = a.val → s.1 a ≠ s.2 b largest_left : ∀ a : Fin m, a.val < k → W a.val ≤ (largestPrimeFactor (s.1 a) : ℝ) ∧ (largestPrimeFactor (s.1 a) : ℝ) ≤ v a.val largest_right : ∀ a : Fin n, a.val < k → W a.val ≤ (largestPrimeFactor (s.2 a) : ℝ) ∧ (largestPrimeFactor (s.2 a) : ℝ) ≤ v a.val tail_left : ∀ a : Fin m, k ≤ a.val → ∀ p ∈ (s.1 a).primeFactorsList, (p : ℝ) ≤ v k tail_right : ∀ a : Fin n, k ≤ a.val → ∀ p ∈ (s.2 a).primeFactorsList, (p : ℝ) ≤ v k tail_factors : ∀ a : Fin m, k ≤ a.val → (ArithmeticFunction.cardFactors (s.1 a) : ℝ) ≤ 10*logLog (v k) top : ∀ a : Fin m, a.val = 0 → Y ^ (9/10 : ℝ) < (s.1 a+1 : ℕ) /- Original line 21702: Erdos416Proof.CollisionState.SieveOriginalConditions.left_support_after -/ theorem SieveOriginalConditions.left_support_after {k d idx : ℕ} {S Y R : ℝ} {v W : ℕ → ℝ} {s : CollisionState m n} (hs : SieveOriginalConditions k d S Y R v W s) (hanti : Antitone v) (hi : idx ≤ k) (a : Fin m) (hia : idx ≤ a.val) : ∀ p ∈ (s.1 a).primeFactorsList, (p : ℝ) ≤ v idx := by intro p hp by_cases hak : a.val < k · exact ((Nat.cast_le.mpr (primeFactorsList_le_largestPrimeFactor hp)).trans (hs.largest_left a hak).2).trans (hanti hia) · exact (hs.tail_left a (le_of_not_gt hak) p hp).trans (hanti hi) /- Original line 21712: Erdos416Proof.CollisionState.SieveOriginalConditions.right_support_after -/ theorem SieveOriginalConditions.right_support_after {k d idx : ℕ} {S Y R : ℝ} {v W : ℕ → ℝ} {s : CollisionState m n} (hs : SieveOriginalConditions k d S Y R v W s) (hanti : Antitone v) (hi : idx ≤ k) (a : Fin n) (hia : idx ≤ a.val) : ∀ p ∈ (s.2 a).primeFactorsList, (p : ℝ) ≤ v idx := by intro p hp by_cases hak : a.val < k · exact ((Nat.cast_le.mpr (primeFactorsList_le_largestPrimeFactor hp)).trans (hs.largest_right a hak).2).trans (hanti hia) · exact (hs.tail_right a (le_of_not_gt hak) p hp).trans (hanti hi) /- Original line 21722: Erdos416Proof.CollisionState.SieveOriginalConditions.left_entry_le -/ theorem SieveOriginalConditions.left_entry_le {k d : ℕ} {S Y R : ℝ} {v W : ℕ → ℝ} {s : CollisionState m n} (hs : SieveOriginalConditions k d S Y R v W s) (hd : 0 < d) (hR : 1 ≤ R) (a : Fin m) : (s.1 a : ℝ) ≤ Y := by have hd1 : (1 : ℝ) ≤ d := by exact_mod_cast hd have hprod : (1 : ℝ) ≤ R*d := hR.trans (le_mul_of_one_le_right (by linarith : 0 ≤ R) hd1) exact (Nat.cast_le.mpr (CollisionState.left_entry_le hs.positive a)).trans ((le_mul_of_one_le_left (Nat.cast_nonneg _) hprod).trans hs.size) /- Original line 21730: Erdos416Proof.CollisionState.SieveOriginalConditions.right_entry_le -/ theorem SieveOriginalConditions.right_entry_le {k d : ℕ} {S Y R : ℝ} {v W : ℕ → ℝ} {s : CollisionState m n} (hs : SieveOriginalConditions k d S Y R v W s) (hR : 1 ≤ R) (a : Fin n) : (s.2 a : ℝ) ≤ Y := by have hbal : (rightValue s : ℝ) = (d : ℝ)*leftValue s := by exact_mod_cast hs.balanced.symm calc _ ≤ (rightValue s : ℝ) := Nat.cast_le.mpr (CollisionState.right_entry_le hs.positive a) _ = (d : ℝ)*leftValue s := hbal _ ≤ R*((d : ℝ)*leftValue s) := le_mul_of_one_le_left (by positivity) hR _ ≤ Y := by simpa only [mul_assoc] using hs.size /- Original line 21740: Erdos416Proof.CollisionState.SieveOriginalConditions.initial -/ theorem SieveOriginalConditions.initial {r t k d : ℕ} {S Y R : ℝ} {v W : ℕ → ℝ} {s : CollisionState (1+r) (1+t)} (hs : SieveOriginalConditions k d S Y R v W s) (hk : 1 ≤ k) (hanti : Antitone v) : InitialConditions S (v 1) Y R d s := by refine ⟨hs.positive, hs.balanced, hs.size, hs.normal_left 0 (by dsimp[Erdos416Proof.omegaInterval_one] ; omega), (hs.normal_right 0 (by dsimp[Erdos416Proof.omegaInterval_one] ; omega)).1, hs.distinct 0 0 (by dsimp[Erdos416Proof.omegaInterval_one] ; omega) rfl, hs.top 0 rfl, ?_, ?_⟩ · intro a exact hs.left_support_after hanti hk (Fin.natAdd 1 a) (by dsimp[Erdos416Proof.omegaInterval_one] ; omega) · intro a exact hs.right_support_after hanti hk (Fin.natAdd 1 a) (by dsimp[Erdos416Proof.omegaInterval_one] ; omega) /-- The initial bound on the original family, with arbitrary fixed list lengths. Prefix and tail conditions are derived from its single record. -/ /- Original line 21753: Erdos416Proof.CollisionState.exists_initial_sieve_fiber_bound -/ theorem exists_initial_sieve_fiber_bound : ∃ C : ℝ, 0 < C ∧ ∃ Z : ℝ, ∀ (k m n d : ℕ) (S Y R : ℝ) (v W : ℕ → ℝ) (F : Finset (CollisionState m n)), Z ≤ v 1 → 1 ≤ k → k ≤ m → k ≤ n → Antitone v → v 0 = Y → 1 ≤ R → Real.exp 1 ≤ S → S ≤ v k → v 1 ≤ Y ^ (1/(10*logLog Y)) → 0 < d → (∀ p ∈ d.primeFactorsList, (p : ℝ) ≤ v k) → (∀ s ∈ F, SieveOriginalConditions k d S Y R v W s) → ∀ sigma ∈ lowStates (v 1) F, (((highStates (v 1) F).filter (fun tau => sigma*tau ∈ F)).card : ℝ) ≤ (C*Y*logLog Y^6/(R*Real.log Y^2*Real.log (v 1))) / ((d : ℝ)*leftValue sigma) := by obtain ⟨C, hC, hbound⟩ := exists_initial_state_fiber_bound obtain ⟨Z, hZ⟩ := eventually_atTop.mp hbound refine ⟨C, hC, Z, ?_⟩ intro k m n d S Y R v W F hvZ hk hkm hkn hanti hv0 hR hS hSv hcut hd hdv hF obtain ⟨r, rfl⟩ := Nat.exists_eq_add_of_le (hk.trans hkm) obtain ⟨t, rfl⟩ := Nat.exists_eq_add_of_le (hk.trans hkn) have hvY : v 1 ≤ Y := by simpa only [hv0] using hanti (show 0 ≤ 1 by omega) exact hZ (v 1) hvZ Y R S r t d F hvY hR hS (hSv.trans (hanti hk)) hcut hd (fun p hp => (hdv p hp).trans (hanti hk)) (fun s hs => (hF s hs).initial hk hanti) /-- Every middle-stage hypothesis is obtained from the original solution record, including all inactive factors and the distinguished entries. -/ /- Original line 21775: Erdos416Proof.CollisionState.exists_middle_sieve_fiber_bound -/ theorem exists_middle_sieve_fiber_bound : ∃ C : ℝ, 0 < C ∧ ∀ᶠ Y : ℝ in atTop, ∀ (k m n d idx : ℕ) (S R : ℝ) (v W : ℕ → ℝ) (F : Finset (CollisionState m n)) (sigma : CollisionState m n), k ≤ m → k ≤ n → 1 ≤ idx → idx ≤ k → (idx : ℝ) ≤ logLog Y → Real.exp (Real.exp 1) ≤ S → S ≤ v k → Antitone v → v 0 = Y → (∀ j < k, v (j+1) < W j ∧ W j ≤ v j) → 1 ≤ R → 0 < d → (∀ p ∈ d.primeFactorsList, (p : ℝ) ≤ v k) → (∀ s ∈ F, SieveOriginalConditions k d S Y R v W s) → sigma ∈ lowStates (v idx) (lowStates (v (idx-1)) F) → reciprocalMass 1 (compatibleIntervalFiber (v idx) (v (idx-1)) sigma F) ≤ (C*logLog Y^6/Real.log (W (idx-1))^2) * Real.exp ((1+Real.log idx)*((idx : ℝ)* (logLog (v (idx-1))-logLog (v idx)+Real.sqrt (logLog S*logLog Y)))) := by obtain ⟨C, hC, hbound⟩ := exists_middle_interval_fiber_bound refine ⟨C, hC, ?_⟩ filter_upwards [hbound] with Y hY intro k m n d idx S R v W F sigma hkm hkn hi hik hiY hS hSv hanti hv0 hW hR hd hdv hF hsigma obtain ⟨r, rfl⟩ := Nat.exists_eq_add_of_le (hik.trans hkm) obtain ⟨t, rfl⟩ := Nat.exists_eq_add_of_le (hik.trans hkn) let j : Fin idx := ⟨idx-1, by omega⟩ have hjk : idx-1 < k := by omega have huW : v idx < W (idx-1) := by simpa only [Nat.sub_add_cancel hi] using (hW (idx-1) hjk).1 have hvY : v (idx-1) ≤ Y := by simpa only [hv0] using hanti (Nat.zero_le (idx-1)) apply hY S (v idx) (v (idx-1)) (W (idx-1)) idx r t d j F sigma hS (hSv.trans (hanti hik)) huW (hW (idx-1) hjk).2 hvY hi hiY hd (fun p hp => (hdv p hp).trans (hanti hik)) _ hsigma intro s hs have hcond := hF s hs refine ⟨hcond.positive, hcond.balanced, hcond.square_exclusion.mono (hanti hik), ?_, ?_, ?_, ?_, ?_, hcond.left_entry_le hd hR _, hcond.right_entry_le hR _, ?_, ?_⟩ · intro a exact hcond.normal_left (Fin.castAdd r a) (by dsimp[Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, Erdos416Proof.omegaInterval_one] ; omega) · intro a exact hcond.left_support_after hanti hik (Fin.natAdd idx a) (by dsimp[Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, Erdos416Proof.omegaInterval_one] ; omega) · intro a exact hcond.right_support_after hanti hik (Fin.natAdd idx a) (by dsimp[Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, Erdos416Proof.omegaInterval_one] ; omega) · exact (hcond.normal_right (Fin.castAdd t j) (by dsimp [Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, Erdos416Proof.omegaInterval_one, j]; omega)).1 · exact hcond.distinct (Fin.castAdd r j) (Fin.castAdd t j) (by dsimp [Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, Erdos416Proof.omegaInterval_one, j]; omega) rfl · exact hcond.largest_left (Fin.castAdd r j) (by dsimp [Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, Erdos416Proof.omegaInterval_one, j]; omega) · exact hcond.largest_right (Fin.castAdd t j) (by dsimp [Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, Erdos416Proof.omegaInterval_one, j]; omega) /- Original line 21816: Erdos416Proof.CollisionState.SieveOriginalConditions.terminal_factors -/ theorem SieveOriginalConditions.terminal_factors {k d : ℕ} {S Y R : ℝ} {v W : ℕ → ℝ} {s : CollisionState m n} (hs : SieveOriginalConditions k d S Y R v W s) (hkm : k ≤ m) (hS : Real.exp 1 ≤ S) (hSv : S ≤ v k) : (ArithmeticFunction.cardFactors (leftValue (cut (v k) s)) : ℝ) ≤ 10*(m : ℝ)*logLog (v k) := by obtain ⟨l, rfl⟩ := Nat.exists_eq_add_of_le hkm exact terminal_cut_cardFactors_bound s hS hSv (fun a => hs.normal_left (Fin.castAdd l a) a.isLt) (fun a => hs.tail_factors (Fin.natAdd k a) (by dsimp[Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint] ; omega)) /-- The terminal mass for the same original family and arbitrary fixed list lengths. The factor-count hypothesis is derived from that family. -/ /- Original line 21828: Erdos416Proof.CollisionState.exists_terminal_sieve_mass_bound -/ theorem exists_terminal_sieve_mass_bound : ∃ C : ℝ, 0 < C ∧ ∃ Z : ℝ, ∀ (k m n d : ℕ) (S Y R : ℝ) (v W : ℕ → ℝ) (F : Finset (CollisionState m n)), Z ≤ v k → 1 ≤ m → k ≤ m → n ≤ m → Real.exp 1 ≤ S → S ≤ v k → 0 < d → (∀ p ∈ d.primeFactorsList, (p : ℝ) ≤ v k) → (∀ s ∈ F, SieveOriginalConditions k d S Y R v W s) → reciprocalMass d (lowStates (v k) F) ≤ C * ((n : ℝ)^ArithmeticFunction.cardFactors d / d) * (Real.log (v k)) ^ (20*(m : ℝ)*Real.log m+1 : ℝ) := by obtain ⟨C, hC, hbound⟩ := exists_terminal_state_mass_bound obtain ⟨Z, hZ⟩ := eventually_atTop.mp (hbound.and (eventually_gt_atTop (1 : ℝ))) refine ⟨C, hC, Z, ?_⟩ intro k m n d S Y R v W F hvZ hm hkm hnm hS hSv hd hdv hF have hlogv : 0 < Real.log (v k) := Real.log_pos (hZ (v k) hvZ).2 have h := (hZ (v k) hvZ).1 m n d (10*(m : ℝ)*logLog (v k)) (lowStates (v k) F) hm hnm hd (by intro s hs obtain ⟨a, ha, rfl⟩ := Finset.mem_image.mp hs exact ⟨cut_positive (v k) a, cut_balanced hd (hF a ha).positive (hF a ha).balanced hdv, cut_leftValue_support (v k) (hF a ha).positive, (hF a ha).terminal_factors hkm hS hSv⟩) have heq : Real.exp (2*(10*(m : ℝ)*logLog (v k))*Real.log m) * Real.log (v k) = (Real.log (v k)) ^ (20*(m : ℝ)*Real.log m+1 : ℝ) := by calc _ = Real.exp (2*(10*(m : ℝ)*logLog (v k))*Real.log m) * Real.exp (Real.log (Real.log (v k))) := by rw [Real.exp_log hlogv] _ = Real.exp (Real.log (Real.log (v k)) * (20*(m : ℝ)*Real.log m+1)) := by rw [← Real.exp_add] congr 1 unfold logLog ring _ = _ := (Real.rpow_def_of_pos hlogv _).symm calc _ ≤ C * ((n : ℝ)^ArithmeticFunction.cardFactors d / d) * Real.exp (2*(10*(m : ℝ)*logLog (v k))*Real.log m) * Real.log (v k) := h _ = _ := by rw [mul_assoc, heq] /-- Successive cuts after the initial cut are actual images of the same original family, including the empty middle iteration. -/ /- Original line 21868: Erdos416Proof.CollisionState.levels_after_initial_eq_cut -/ theorem levels_after_initial_eq_cut (v : ℕ → ℝ) (hanti : Antitone v) (F : Finset (CollisionState m n)) (idx : ℕ) : levels (fun j => v (j+2)) (lowStates (v 1) F) idx = lowStates (v (idx+1)) F := by induction idx with | zero => rfl | succ idx ih => rw [levels, ih, lowStates_lowStates F (hanti (show idx+1 ≤ idx+2 by omega))] /-- Unit gaps in successive double logarithms already force the active dimension below logLog(Y). The published separation is stronger. -/ /- Original line 21878: Erdos416Proof.CollisionState.sieve_dimension_le_of_gaps -/ theorem sieve_dimension_le_of_gaps {k : ℕ} {v : ℕ → ℝ} {T : ℝ} (hk : 1 ≤ k) (hlast : 1 ≤ logLog (v k)) (hfirst : logLog (v 1) ≤ T) (hgap : ∀ j, 1 ≤ j → j < k → 1 ≤ logLog (v j)-logLog (v (j+1))) : (k : ℝ) ≤ T := by have htel : ∀ j : ℕ, j < k → logLog (v (j+1))+(j : ℝ) ≤ logLog (v 1) := by intro j induction j with | zero => intro _; simp[Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint] | succ j ih => intro hj have hp := ih (by omega) have hg := hgap (j+1) (by omega) (by omega) push_cast linarith have h := htel (k-1) (by omega) rw [Nat.sub_add_cancel hk, Nat.cast_sub hk, Nat.cast_one] at h linarith /-- The complete finite-stage sieve bound on one original family. All initial, middle and terminal estimates are proved inputs, with one common threshold independent of the dimensions and cutoffs. This is the raw product form, before telescoping its logarithmic exponent. -/ /- Original line 21900: Erdos416Proof.CollisionState.exists_multivariable_sieve_raw_bound -/ theorem exists_multivariable_sieve_raw_bound : ∃ C0 C1 C2 Z : ℝ, 0 < C0 ∧ 0 < C1 ∧ 0 < C2 ∧ ∀ (k m n d : ℕ) (S Y R : ℝ) (v W : ℕ → ℝ) (F : Finset (CollisionState m n)), Z ≤ v k → 1 ≤ k → k ≤ m → k ≤ n → n ≤ m → Real.exp (Real.exp 1) ≤ S → S ≤ v k → Antitone v → v 0 = Y → (∀ j < k, v (j+1) < W j ∧ W j ≤ v j) → (∀ j, 1 ≤ j → j < k → 1 ≤ logLog (v j)-logLog (v (j+1))) → 1 ≤ R → v 1 ≤ Y ^ (1/(10*logLog Y)) → 0 < d → (∀ p ∈ d.primeFactorsList, (p : ℝ) ≤ v k) → (∀ s ∈ F, SieveOriginalConditions k d S Y R v W s) → (F.card : ℝ) ≤ (C0*Y*logLog Y^6/(R*Real.log Y^2*Real.log (v 1))) * (∏ j ∈ Finset.range (k-1), (C1*logLog Y^6/Real.log (W (j+1))^2) * Real.exp ((1+Real.log (j+2 : ℕ))*((j+2 : ℕ) : ℝ)* (logLog (v (j+1))-logLog (v (j+2))+Real.sqrt (logLog S*logLog Y)))) * (C2 * ((n : ℝ)^ArithmeticFunction.cardFactors d / d) * (Real.log (v k)) ^ (20*(m : ℝ)*Real.log m+1 : ℝ)) := by obtain ⟨C0, hC0, Z0, h0⟩ := exists_initial_sieve_fiber_bound obtain ⟨C1, hC1, h1⟩ := exists_middle_sieve_fiber_bound obtain ⟨Z1, h1⟩ := eventually_atTop.mp h1 obtain ⟨C2, hC2, Z2, h2⟩ := exists_terminal_sieve_mass_bound refine ⟨C0, C1, C2, max Z0 (max Z1 (max Z2 (Real.exp (Real.exp 1)))), hC0, hC1, hC2, ?_⟩ intro k m n d S Y R v W F hvZ hk hkm hkn hnm hS hSv hanti hv0 hW hgap hR hcut hd hdv hF have hvZ0 := (max_le_iff.mp hvZ).1 have hvZ1 := (max_le_iff.mp (max_le_iff.mp hvZ).2).1 have hvZ2 := (max_le_iff.mp (max_le_iff.mp (max_le_iff.mp hvZ).2).2).1 have hvbase := (max_le_iff.mp (max_le_iff.mp (max_le_iff.mp hvZ).2).2).2 have hbase1 : 1 < Real.exp (Real.exp 1) := Real.one_lt_exp_iff.mpr (Real.exp_pos 1) have hvk1 : 1 < v k := hbase1.trans_le hvbase have hvkY : v k ≤ Y := by simpa only [hv0] using hanti (Nat.zero_le k) have hv11 : 1 < v 1 := hvk1.trans_le (hanti hk) have hv1Y : v 1 ≤ Y := by simpa only [hv0] using hanti (show 0 ≤ 1 by omega) have hLLvk : 1 ≤ logLog (v k) := by simpa only [logLog, Real.log_exp] using logLog_mono hbase1 hvbase have hdim : (k : ℝ) ≤ logLog Y := sieve_dimension_le_of_gaps hk hLLvk (logLog_mono hv11 hv1Y) hgap have heS : Real.exp 1 ≤ S := (Real.exp_le_exp.mpr (Real.one_le_exp (by norm_num : (0 : ℝ) ≤ 1))).trans hS have hR0 : 0 < R := by linarith have hY1 : 1 < Y := hvk1.trans_le hvkY have hY0 : 0 < Y := by linarith have hlogY : 0 < Real.log Y := Real.log_pos hY1 have hlogv1 : 0 < Real.log (v 1) := Real.log_pos hv11 let A := C0*Y*logLog Y^6/(R*Real.log Y^2*Real.log (v 1)) let B : ℕ → ℝ := fun j => (C1*logLog Y^6/Real.log (W (j+1))^2) * Real.exp ((1+Real.log (j+2 : ℕ))*((j+2 : ℕ) : ℝ)* (logLog (v (j+1))-logLog (v (j+2))+Real.sqrt (logLog S*logLog Y))) have hA : 0 ≤ A := by dsimp [Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, A]; positivity have hB (j : ℕ) : 0 ≤ B j := by dsimp [Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, B]; positivity have hfirst := h0 k m n d S Y R v W F (hvZ0.trans (hanti hk)) hk hkm hkn hanti hv0 hR heS hSv hcut hd hdv hF have hstep : ∀ j < k-1, ∀ sigma ∈ lowStates (v (j+2)) (levels (fun j => v (j+2)) (lowStates (v 1) F) j), (∑ tau ∈ (highStates (v (j+2)) (levels (fun j => v (j+2)) (lowStates (v 1) F) j)).filter (fun tau => sigma*tau ∈ levels (fun j => v (j+2)) (lowStates (v 1) F) j), (1 : ℝ)/leftValue tau) ≤ B j := by intro j hj sigma hsigma rw [levels_after_initial_eq_cut v hanti F j] at hsigma ⊢ have hik : j+2 ≤ k := by omega have hpred : j+2-1 = j+1 := by omega have h := h1 Y (hvZ1.trans hvkY) k m n d (j+2) S R v W F sigma hkm hkn (by omega) hik ((Nat.cast_le.mpr hik).trans hdim) hS hSv hanti hv0 hW hR hd hdv hF (by simpa only [hpred] using hsigma) simpa only [B, compatibleIntervalFiber, reciprocalMass, Nat.cast_one, one_mul, hpred, mul_assoc] using h have hiter := card_le_iterated_reciprocalMass d (v 1) (fun j => v (j+2)) F (fun s hs => (hF s hs).positive) hA B (k-1) hfirst (fun j _ => hB j) hstep rw [levels_after_initial_eq_cut v hanti F (k-1), Nat.sub_add_cancel hk] at hiter have hterminal := h2 k m n d S Y R v W F hvZ2 (hk.trans hkm) hkm hnm heS hSv hd hdv hF exact hiter.trans (mul_le_mul_of_nonneg_left hterminal (mul_nonneg hA (Finset.prod_nonneg (fun j _ => hB j)))) end Erdos416Proof.CollisionState /- The exact exponent telescope, normalized separation and uniform constants; the complete sieve at the manuscript's actual normality scale. -/ open Filter Asymptotics MeasureTheory open scoped BigOperators Classical Topology namespace Erdos416Proof.CollisionState /- Original line 21990: Erdos416Proof.CollisionState.sieveWeight -/ noncomputable def sieveWeight (idx : ℕ) : ℝ := (idx : ℝ)*(1+Real.log idx) /- Original line 21992: Erdos416Proof.CollisionState.sieveWeight_one -/ theorem sieveWeight_one : sieveWeight 1 = 1 := by simp [sieveWeight] /- Original line 21994: Erdos416Proof.CollisionState.sieveWeight_succ -/ theorem sieveWeight_succ (idx : ℕ) : sieveWeight (idx+1) = sieveWeight idx + fordWeight idx + 2 := by unfold sieveWeight fordWeight push_cast ring /- Original line 22000: Erdos416Proof.CollisionState.sieveWeight_nonneg -/ theorem sieveWeight_nonneg {idx : ℕ} (hi : 1 ≤ idx) : 0 ≤ sieveWeight idx := by have hi1 : (1 : ℝ) ≤ idx := by exact_mod_cast hi exact mul_nonneg (Nat.cast_nonneg _) (by linarith [Real.log_nonneg hi1]) /-- Exact telescoping, including the negative last-coordinate term. -/ /- Original line 22005: Erdos416Proof.CollisionState.sieve_exponent_telescope_range -/ theorem sieve_exponent_telescope_range (r : ℕ) (δ : ℝ) (ν μ : ℕ → ℝ) : -2-ν 1 + (∑ j ∈ Finset.range r, (sieveWeight (j+2)*(ν (j+1)-ν (j+2)+δ)-2*μ (j+1))) = -2+(∑ j ∈ Finset.range r, fordWeight (j+1)*ν (j+1)) + δ*(∑ j ∈ Finset.range r, sieveWeight (j+2)) + 2*(∑ j ∈ Finset.range r, (ν (j+1)-μ (j+1))) - sieveWeight (r+1)*ν (r+1) := by induction r with | zero => simp [sieveWeight_one] | succ r ih => simp only [Finset.sum_range_succ] rw [show r+1+1 = r+2 by omega, sieveWeight_succ (r+1)] linear_combination ih /- Original line 22018: Erdos416Proof.CollisionState.sieve_sqrt_scale -/ theorem sieve_sqrt_scale {A T : ℝ} (hA : 0 ≤ A) (hT : 0 < T) : Real.sqrt (A*T) = Real.sqrt (A/T)*T := by have hsq := Real.sq_sqrt (div_nonneg hA hT.le) have heq : Real.sqrt (A/T)^2*T = A := (div_eq_iff hT.ne').mp hsq.symm |>.symm have hsq' : (Real.sqrt (A/T)*T)^2 = A*T := by calc _ = (Real.sqrt (A/T)^2*T)*T := by ring _ = _ := by rw [heq] nlinarith [Real.sq_sqrt (mul_nonneg hA hT.le), Real.sqrt_nonneg (A*T), mul_nonneg (Real.sqrt_nonneg (A/T)) hT.le] /-- The normalized published separation supplies the unit gap required by the checked finite-stage iteration. -/ /- Original line 22031: Erdos416Proof.CollisionState.sieve_unit_gap_of_normalized -/ theorem sieve_unit_gap_of_normalized {A T b a : ℝ} (hA : 1 ≤ A) (hT : 1 ≤ T) (hgap : 2*Real.sqrt (A/T) ≤ b/T-a/T) : 1 ≤ b-a := by have hT0 : 0 < T := by linarith have hA0 : 0 ≤ A := by linarith have hAT : 1 ≤ A*T := by nlinarith have hs : 1 ≤ Real.sqrt (A*T) := by nlinarith [Real.sq_sqrt (show 0 ≤ A*T by positivity), Real.sqrt_nonneg (A*T)] have h := (mul_le_mul_of_nonneg_right hgap hT0.le) rw [sub_mul, div_mul_cancel₀ _ hT0.ne', div_mul_cancel₀ _ hT0.ne', mul_assoc, ← sieve_sqrt_scale hA0 hT0] at h linarith /- Original line 22043: Erdos416Proof.CollisionState.sieve_sum_Icc_eq_range -/ theorem sieve_sum_Icc_eq_range (a b : ℕ) (f : ℕ → ℝ) : (∑ idx ∈ Finset.Icc a b, f idx) = ∑ j ∈ Finset.range (b+1-a), f (j+a) := by have h : Finset.Icc a b = Finset.Ico a (b+1) := by ext j simp only [Finset.mem_Icc, Finset.mem_Ico] omega rw [h, Finset.sum_Ico_eq_sum_range] simp only [Nat.add_comm a] /- Original line 22052: Erdos416Proof.CollisionState.sieveWeight_expanded -/ theorem sieveWeight_expanded (idx : ℕ) : sieveWeight idx = (idx : ℝ)*Real.log idx+idx := by unfold sieveWeight; ring /- Original line 22055: Erdos416Proof.CollisionState.sieve_exponent_telescope -/ theorem sieve_exponent_telescope {k : ℕ} (hk : 1 ≤ k) (δ : ℝ) (ν μ : ℕ → ℝ) : -2-ν 1 + (∑ j ∈ Finset.range (k-1), (sieveWeight (j+2)*(ν (j+1)-ν (j+2)+δ)-2*μ (j+1))) = -2+(∑ idx ∈ Finset.Icc 1 (k-1), fordWeight idx*ν idx) + fordSieveError k δ ν μ - sieveWeight k*ν k := by have h1 (f : ℕ → ℝ) : (∑ idx ∈ Finset.Icc 1 (k-1), f idx) = ∑ j ∈ Finset.range (k-1), f (j+1) := by rw [sieve_sum_Icc_eq_range] congr 1 have h2 (f : ℕ → ℝ) : (∑ idx ∈ Finset.Icc 2 k, f idx) = ∑ j ∈ Finset.range (k-1), f (j+2) := by rw [sieve_sum_Icc_eq_range] congr 1 unfold fordSieveError rw [h1, h2, h1] simp_rw [← sieveWeight_expanded] simpa only [Nat.sub_add_cancel hk, add_assoc] using sieve_exponent_telescope_range (k-1) δ ν μ /- Original line 22074: Erdos416Proof.CollisionState.sieve_exponent_le -/ theorem sieve_exponent_le {k : ℕ} (hk : 1 ≤ k) (δ : ℝ) (ν μ : ℕ → ℝ) (hνk : 0 ≤ ν k) : -2-ν 1 + (∑ j ∈ Finset.range (k-1), (sieveWeight (j+2)*(ν (j+1)-ν (j+2)+δ)-2*μ (j+1))) ≤ -2+(∑ idx ∈ Finset.Icc 1 (k-1), fordWeight idx*ν idx) + fordSieveError k δ ν μ := by rw [sieve_exponent_telescope hk] exact sub_le_self _ (mul_nonneg (sieveWeight_nonneg hk) hνk) /- Original line 22082: Erdos416Proof.CollisionState.sieve_initial_factor_eq -/ theorem sieve_initial_factor_eq (C Y R u : ℝ) (hY : 1 < Y) (hT : 0 < logLog Y) (hu : 1 < u) : C*Y*logLog Y^6/(R*Real.log Y^2*Real.log u) = (C*Y*logLog Y^6/R)*(Real.log Y)^(-2-logLog u/logLog Y) := by have hlogY : 0 < Real.log Y := Real.log_pos hY have harg : Real.log (Real.log Y)*(-2-logLog u/logLog Y) = -(2*Real.log (Real.log Y)+logLog u) := by change logLog Y*(-2-logLog u/logLog Y) = -(2*logLog Y+logLog u) field_simp ring have hpow : (Real.log Y)^(-2-logLog u/logLog Y) = 1/(Real.log Y^2*Real.log u) := by rw [Real.rpow_def_of_pos hlogY, harg, Real.exp_neg, Real.exp_add, two_mul, Real.exp_add] simp only [logLog, Real.exp_log hlogY, Real.exp_log (Real.log_pos hu)] ring rw [hpow] simp only [div_eq_mul_inv, mul_inv_rev] ring /- Original line 22101: Erdos416Proof.CollisionState.sieve_middle_factor_eq -/ theorem sieve_middle_factor_eq (C S Y u v W w : ℝ) (hY : 1 < Y) (hT : 0 < logLog Y) (hS : 0 ≤ logLog S) (hW : 1 < W) : (C*logLog Y^6/Real.log W^2)* Real.exp (w*(logLog v-logLog u+Real.sqrt (logLog S*logLog Y))) = (C*logLog Y^6)*(Real.log Y)^ (w*(logLog v/logLog Y-logLog u/logLog Y+Real.sqrt (logLog S/logLog Y))- 2*(logLog W/logLog Y)) := by have hlogY : 0 < Real.log Y := Real.log_pos hY have harg : Real.log (Real.log Y)* (w*(logLog v/logLog Y-logLog u/logLog Y+Real.sqrt (logLog S/logLog Y))- 2*(logLog W/logLog Y)) = w*(logLog v-logLog u+Real.sqrt (logLog S*logLog Y))-2*logLog W := by rw [sieve_sqrt_scale hS hT] change logLog Y*(w*(logLog v/logLog Y-logLog u/logLog Y+ Real.sqrt (logLog S/logLog Y))-2*(logLog W/logLog Y)) = _ field_simp have hpow : (Real.log Y)^ (w*(logLog v/logLog Y-logLog u/logLog Y+Real.sqrt (logLog S/logLog Y))- 2*(logLog W/logLog Y)) = Real.exp (w*(logLog v-logLog u+Real.sqrt (logLog S*logLog Y)))/Real.log W^2 := by rw [Real.rpow_def_of_pos hlogY, harg, Real.exp_sub, two_mul, Real.exp_add] simp only [logLog, Real.exp_log (Real.log_pos hW)] ring rw [hpow] ring /-- Three fixed analytic constants are absorbed uniformly in every dimension, while retaining exactly the power T^(6k). -/ /- Original line 22129: Erdos416Proof.CollisionState.exists_sieve_constant_absorption -/ theorem exists_sieve_constant_absorption (C0 C1 C2 : ℝ) (_hC0 : 0 < C0) (hC1 : 0 < C1) (hC2 : 0 < C2) : ∃ c : ℝ, 1 ≤ c ∧ ∀ (k : ℕ) (T : ℝ), 1 ≤ k → 0 ≤ T → (C0*T^6)*(C1*T^6)^(k-1)*C2 ≤ (c*T)^(6*k) := by let c := max 1 (max C0 (max C1 C2)) have hc1 : 1 ≤ c := le_max_left _ _ have hc0 : 0 ≤ c := by linarith have h0 : C0 ≤ c := (le_max_left C0 _).trans (le_max_right 1 _) have h1 : C1 ≤ c := (le_max_left C1 C2).trans ((le_max_right C0 _).trans (le_max_right 1 _)) have h2 : C2 ≤ c := (le_max_right C1 C2).trans ((le_max_right C0 _).trans (le_max_right 1 _)) refine ⟨c, hc1, ?_⟩ intro k T hk hT have hconst : C0*C1^(k-1)*C2 ≤ c^(6*k) := by calc _ ≤ c*c^(k-1)*c := mul_le_mul (mul_le_mul h0 (pow_le_pow_left₀ hC1.le h1 (k-1)) (by positivity) hc0) h2 hC2.le (by positivity) _ = c^(k+1) := by rw [mul_comm c (c^(k-1)), ← pow_succ, Nat.sub_add_cancel hk, ← pow_succ] _ ≤ c^(6*k) := pow_le_pow_right₀ hc1 (by omega) calc _ = (C0*C1^(k-1)*C2)*T^(6*k) := by rw [mul_pow, ← pow_mul, show 6*k = 6+6*(k-1) by omega, pow_add] ring _ ≤ c^(6*k)*T^(6*k) := mul_le_mul_of_nonneg_right hconst (by positivity) _ = _ := (mul_pow c T (6*k)).symm /- Original line 22157: Erdos416Proof.CollisionState.sieve_product_factors_eq -/ theorem sieve_product_factors_eq (C0 C1 C2 Y R T x N P a : ℝ) (r : ℕ) (E : ℕ → ℝ) (hx : 0 < x) : ((C0*Y*T^6/R)*x^a)*(∏ j ∈ Finset.range r, (C1*T^6)*x^(E j))*(C2*N*P) = ((C0*T^6)*(C1*T^6)^r*C2)*(Y/R*N*P)*x^(a+∑ j ∈ Finset.range r, E j) := by have hp : (∏ j ∈ Finset.range r, (C1*T^6)*x^(E j)) = (C1*T^6)^r*x^(∑ j ∈ Finset.range r, E j) := by rw [Finset.prod_mul_distrib, ← Real.rpow_sum_of_pos hx] simp rw [hp, Real.rpow_add hx] ring /-- The multivariable sieve with the manuscript's telescoped exponent and one absolute constant. The normalized separation discharges every unit gap in the raw iteration; no analytic stage bound is left as a hypothesis. -/ /- Original line 22171: Erdos416Proof.CollisionState.exists_multivariable_sieve_bound -/ theorem exists_multivariable_sieve_bound : ∃ c Z : ℝ, 0 < c ∧ ∀ (k m n d : ℕ) (S Y R : ℝ) (v W : ℕ → ℝ) (F : Finset (CollisionState m n)), Z ≤ v k → 1 ≤ k → k ≤ m → k ≤ n → n ≤ m → Real.exp (Real.exp 1) ≤ S → S ≤ v k → Antitone v → v 0 = Y → (∀ j < k, v (j+1) < W j ∧ W j ≤ v j) → (∀ idx, 2 ≤ idx → idx ≤ k → 2*Real.sqrt (logLog S/logLog Y) ≤ logLog (v (idx-1))/logLog Y-logLog (v idx)/logLog Y) → 1 ≤ R → v 1 ≤ Y ^ (1/(10*logLog Y)) → 0 < d → (∀ p ∈ d.primeFactorsList, (p : ℝ) ≤ v k) → (∀ s ∈ F, SieveOriginalConditions k d S Y R v W s) → (F.card : ℝ) ≤ (Y/((d : ℝ)*R))*(c*logLog Y)^(6*k)*(n : ℝ)^ArithmeticFunction.cardFactors d * (Real.log (v k)) ^ (20*(m : ℝ)*Real.log m+1 : ℝ) * (Real.log Y)^(-2+(∑ idx ∈ Finset.Icc 1 (k-1), fordWeight idx*(logLog (v idx)/logLog Y)) + fordSieveError k (Real.sqrt (logLog S/logLog Y)) (fun idx => logLog (v idx)/logLog Y) (fun idx => logLog (W idx)/logLog Y)) := by obtain ⟨C0, C1, C2, Z, hC0, hC1, hC2, hraw⟩ := exists_multivariable_sieve_raw_bound obtain ⟨c, hc1, hconst⟩ := exists_sieve_constant_absorption C0 C1 C2 hC0 hC1 hC2 refine ⟨c, Z, by linarith, ?_⟩ intro k m n d S Y R v W F hvZ hk hkm hkn hnm hS hSv hanti hv0 hW hgap hR hcut hd hdv hF have hbase1 : 1 < Real.exp (Real.exp 1) := Real.one_lt_exp_iff.mpr (Real.exp_pos 1) have hS1 : 1 < S := hbase1.trans_le hS have hvk1 : 1 < v k := hS1.trans_le hSv have hvkY : v k ≤ Y := by simpa only [hv0] using hanti (Nat.zero_le k) have hSY : S ≤ Y := hSv.trans hvkY have hY1 : 1 < Y := hS1.trans_le hSY have hY0 : 0 ≤ Y := by linarith have hlogY : 0 < Real.log Y := Real.log_pos hY1 have hLLS : 1 ≤ logLog S := by simpa only [logLog, Real.log_exp] using logLog_mono hbase1 hS have hT : 1 ≤ logLog Y := hLLS.trans (logLog_mono hS1 hSY) have hT0 : 0 < logLog Y := by linarith have hlogY1 : 1 ≤ Real.log Y := by have h := Real.log_le_log (Real.exp_pos (Real.exp 1)) (hS.trans hSY) rw [Real.log_exp] at h exact (Real.one_le_exp (by norm_num : (0 : ℝ) ≤ 1)).trans h have hv11 : 1 < v 1 := hvk1.trans_le (hanti hk) have hR0 : 0 ≤ R := by linarith have hunit : ∀ j, 1 ≤ j → j < k → 1 ≤ logLog (v j)-logLog (v (j+1)) := by intro j hj1 hjk apply sieve_unit_gap_of_normalized hLLS hT have heq : j+1-1 = j := by omega simpa only [heq] using hgap (j+1) (by omega) (by omega) have h := hraw k m n d S Y R v W F hvZ hk hkm hkn hnm hS hSv hanti hv0 hW hunit hR hcut hd hdv hF let ν : ℕ → ℝ := fun idx => logLog (v idx)/logLog Y let μ : ℕ → ℝ := fun idx => logLog (W idx)/logLog Y let δ := Real.sqrt (logLog S/logLog Y) let E : ℕ → ℝ := fun j => sieveWeight (j+2)*(ν (j+1)-ν (j+2)+δ)-2*μ (j+1) let N := (n : ℝ)^ArithmeticFunction.cardFactors d/d let P := (Real.log (v k))^(20*(m : ℝ)*Real.log m+1 : ℝ) let M := Y/R*N*P have hN : 0 ≤ N := by dsimp [Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, N]; positivity have hP : 0 ≤ P := Real.rpow_nonneg (Real.log_pos hvk1).le _ have hM : 0 ≤ M := mul_nonneg (mul_nonneg (div_nonneg hY0 hR0) hN) hP have hprod : (∏ j ∈ Finset.range (k-1), (C1*logLog Y^6/Real.log (W (j+1))^2)* Real.exp ((1+Real.log (j+2 : ℕ))*((j+2 : ℕ) : ℝ)* (logLog (v (j+1))-logLog (v (j+2))+Real.sqrt (logLog S*logLog Y)))) = ∏ j ∈ Finset.range (k-1), (C1*logLog Y^6)*(Real.log Y)^(E j) := by apply Finset.prod_congr rfl intro j hj have hjk : j+2 ≤ k := by have := Finset.mem_range.mp hj; omega have hW1 : 1 < W (j+1) := (hvk1.trans_le (hanti hjk)).trans (hW (j+1) (by omega)).1 have hw : (1+Real.log (j+2 : ℕ))*((j+2 : ℕ) : ℝ) = sieveWeight (j+2) := by unfold sieveWeight ring rw [hw] exact sieve_middle_factor_eq C1 S Y (v (j+2)) (v (j+1)) (W (j+1)) (sieveWeight (j+2)) hY1 hT0 (by linarith) hW1 rw [sieve_initial_factor_eq C0 Y R (v 1) hY1 hT0 hv11, hprod, sieve_product_factors_eq C0 C1 C2 Y R (logLog Y) (Real.log Y) N P (-2-ν 1) (k-1) E hlogY] at h have hνk : 0 ≤ ν k := div_nonneg (le_trans (by norm_num : (0 : ℝ) ≤ 1) (hLLS.trans (logLog_mono hS1 hSv))) hT0.le have hexp := Real.rpow_le_rpow_of_exponent_le hlogY1 (sieve_exponent_le hk δ ν μ hνk) have hcoeff := mul_le_mul_of_nonneg_right (hconst k (logLog Y) hk hT0.le) hM calc _ ≤ ((C0*logLog Y^6)*(C1*logLog Y^6)^(k-1)*C2)*M* (Real.log Y)^(-2-ν 1+∑ j ∈ Finset.range (k-1), E j) := h _ ≤ (c*logLog Y)^(6*k)*M* (Real.log Y)^(-2+(∑ idx ∈ Finset.Icc 1 (k-1), fordWeight idx*ν idx)+ fordSieveError k δ ν μ) := mul_le_mul hcoeff hexp (Real.rpow_nonneg hlogY.le _) (mul_nonneg (by positivity) hM) _ = _ := by dsimp [Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, M, N, P, ν, μ, δ] simp only [div_eq_mul_inv, mul_inv_rev] ring /- Original line 22263: Erdos416Proof.CollisionState.normalityScale_atTop -/ theorem normalityScale_atTop : Tendsto normalityScale atTop atTop := Real.tendsto_exp_atTop.comp (Real.tendsto_exp_atTop.comp ((tendsto_pow_atTop (by norm_num : (10 : ℕ) ≠ 0)).comp Real.tendsto_log_atTop)) /- Original line 22267: Erdos416Proof.CollisionState.sieve_normality_delta -/ theorem sieve_normality_delta {T : ℝ} (hT : 1 ≤ T) : Real.sqrt (logLog (normalityScale T)/T) = normalityDelta T/2 := by have hT0 : 0 < T := by linarith have hS : 0 ≤ logLog (normalityScale T) := logLog_nonneg (normalityScale_ge_exp_one T) apply mul_right_cancel₀ hT0.ne' rw [← sieve_sqrt_scale hS hT0] change Real.sqrt (Real.log (Real.log (normalityScale T))*T) = _ rw [normality_error_exact hT] nlinarith [normalityDelta_mul_self hT0] /-- The sieve at the manuscript's actual normality scale and list lengths. Its lower analytic threshold is now discharged by that scale tending to infinity, leaving a single eventual threshold in Y. -/ /- Original line 22280: Erdos416Proof.CollisionState.exists_multivariable_sieve_normal_bound -/ theorem exists_multivariable_sieve_normal_bound : ∃ c : ℝ, 0 < c ∧ ∀ᶠ Y : ℝ in atTop, ∀ (k l d : ℕ) (R : ℝ) (v W : ℕ → ℝ) (F : Finset (CollisionState (k+l) (k+1))), 1 ≤ k → 1 ≤ l → normalityScale (logLog Y) ≤ v k → Antitone v → v 0 = Y → (∀ j < k, v (j+1) < W j ∧ W j ≤ v j) → (∀ idx, 2 ≤ idx → idx ≤ k → normalityDelta (logLog Y) ≤ logLog (v (idx-1))/logLog Y-logLog (v idx)/logLog Y) → 1 ≤ R → v 1 ≤ Y ^ (1/(10*logLog Y)) → 0 < d → (∀ p ∈ d.primeFactorsList, (p : ℝ) ≤ v k) → (∀ s ∈ F, SieveOriginalConditions k d (normalityScale (logLog Y)) Y R v W s) → (F.card : ℝ) ≤ (Y/((d : ℝ)*R))*(c*logLog Y)^(6*k)*(k+1 : ℝ)^ArithmeticFunction.cardFactors d * (Real.log (v k)) ^ (20*(k+l : ℕ)*Real.log (k+l : ℕ)+1 : ℝ) * (Real.log Y)^(-2+(∑ idx ∈ Finset.Icc 1 (k-1), fordWeight idx*(logLog (v idx)/logLog Y)) + fordSieveError k (normalityDelta (logLog Y)/2) (fun idx => logLog (v idx)/logLog Y) (fun idx => logLog (W idx)/logLog Y)) := by obtain ⟨c, Z, hc, hbound⟩ := exists_multivariable_sieve_bound have hLL : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop have hscale := normalityScale_atTop.comp hLL refine ⟨c, hc, ?_⟩ filter_upwards [hscale.eventually_ge_atTop Z, hscale.eventually_ge_atTop (Real.exp (Real.exp 1)), hLL.eventually_ge_atTop 1] with Y hZ hS hT intro k l d R v W F hk hl hSv hanti hv0 hW hgap hR hcut hd hdv hF have hdelta := sieve_normality_delta hT have hsep : ∀ idx, 2 ≤ idx → idx ≤ k → 2*Real.sqrt (logLog (normalityScale (logLog Y))/logLog Y) ≤ logLog (v (idx-1))/logLog Y-logLog (v idx)/logLog Y := by intro idx hi hik rw [hdelta] linarith [hgap idx hi hik] have h := hbound k (k+l) (k+1) d (normalityScale (logLog Y)) Y R v W F (hZ.trans hSv) hk (by omega) (by omega) (by omega) hS hSv hanti hv0 hW hsep hR hcut hd hdv hF simpa only [hdelta, Nat.cast_add, Nat.cast_one] using h end Erdos416Proof.CollisionState /- Cancellation into actual sieve states, direct integer reconstruction, the finite class bound and the complete auxiliary-preimage residual. -/ open Filter Asymptotics MeasureTheory open scoped BigOperators Classical Topology namespace Erdos416Proof.CollisionClass open CollisionState variable {a l : ℕ} /- Original line 22334: Erdos416Proof.CollisionClass.remaining -/ noncomputable def remaining (C : Finset (Fin a)) : Finset (Fin a) := Finset.univ \ C /- Original line 22336: Erdos416Proof.CollisionClass.index -/ noncomputable def index (C : Finset (Fin a)) (idx : Fin (remaining C).card) : Fin a := ((remaining C).orderIsoOfFin rfl idx).val /- Original line 22339: Erdos416Proof.CollisionClass.index_mem -/ theorem index_mem (C : Finset (Fin a)) (idx : Fin (remaining C).card) : index C idx ∈ remaining C := ((remaining C).orderIsoOfFin rfl idx).property /- Original line 22342: Erdos416Proof.CollisionClass.index_strictMono -/ theorem index_strictMono (C : Finset (Fin a)) : StrictMono (index C) := (remaining C).orderIsoOfFin rfl |>.strictMono /- Original line 22345: Erdos416Proof.CollisionClass.index_surjective -/ theorem index_surjective (C : Finset (Fin a)) {j : Fin a} (hj : j ∈ remaining C) : ∃ idx, index C idx = j := by refine ⟨(remaining C).orderIsoOfFin rfl |>.symm ⟨j, hj⟩, ?_⟩ exact congrArg Subtype.val ((remaining C).orderIsoOfFin rfl |>.apply_symm_apply ⟨j, hj⟩) /- Original line 22350: Erdos416Proof.CollisionClass.prod_index -/ theorem prod_index (C : Finset (Fin a)) (f : Fin a → ℕ) : (∏ idx : Fin (remaining C).card, f (index C idx)) = ∏ j ∈ remaining C, f j := prod_ordered_enumeration (remaining C) f /- Original line 22354: Erdos416Proof.CollisionClass.index_first -/ theorem index_first (C : Finset (Fin a)) (hzero : ∀ j : Fin a, j.val = 0 → j ∉ C) (idx : Fin (remaining C).card) (hi : idx.val = 0) : (index C idx).val = 0 := by have ha : 0 < a := by have := (index C idx).isLt; omega let z : Fin a := ⟨0, ha⟩ have hz : z ∈ remaining C := by simp [remaining, hzero z rfl] obtain ⟨j, hj⟩ := index_surjective C hz have hij : idx ≤ j := by change idx.val ≤ j.val; omega have h := (index_strictMono C).monotone hij rw [hj] at h change (index C idx).val ≤ 0 at h omega /- Original line 22367: Erdos416Proof.CollisionClass.remaining_card_pos -/ theorem remaining_card_pos (C : Finset (Fin a)) (ha : 1 ≤ a) (hzero : ∀ j : Fin a, j.val = 0 → j ∉ C) : 1 ≤ (remaining C).card := by let z : Fin a := ⟨0, by omega⟩ have hz : z ∈ remaining C := by simp [remaining, hzero z rfl] exact Finset.card_pos.mpr ⟨z, hz⟩ /-- The actual surviving ordinary primes, followed by the unchanged tail. -/ /- Original line 22374: Erdos416Proof.CollisionClass.leftPrimes -/ noncomputable def leftPrimes (C : Finset (Fin a)) (p : Fin a → ℕ) (t : Fin l → ℕ) : Fin ((remaining C).card+l) → ℕ := Fin.append (fun idx => p (index C idx)) t /-- Cancel paired common primes and retain the complete right residual. -/ /- Original line 22378: Erdos416Proof.CollisionClass.state -/ noncomputable def state (C : Finset (Fin a)) (p q : Fin a → ℕ) (t : Fin l → ℕ) (e : ℕ) : CollisionState ((remaining C).card+l) ((remaining C).card+1) := (fun idx => leftPrimes C p t idx-1, Fin.append (fun idx => q (index C idx)-1) (fun _ : Fin 1 => e)) /- Original line 22382: Erdos416Proof.CollisionClass.leftPrimes_prime -/ theorem leftPrimes_prime (C : Finset (Fin a)) (p : Fin a → ℕ) (t : Fin l → ℕ) (hp : ∀ idx, (p idx).Prime) (ht : ∀ idx, (t idx).Prime) : ∀ idx, (leftPrimes C p t idx).Prime := by intro idx refine Fin.addCases ?_ ?_ idx · intro j simpa only [leftPrimes, Fin.append_left] using hp (index C j) · intro j simpa only [leftPrimes, Fin.append_right] using ht j /- Original line 22391: Erdos416Proof.CollisionClass.state_positive -/ theorem state_positive (C : Finset (Fin a)) (p q : Fin a → ℕ) (t : Fin l → ℕ) (e : ℕ) (hp : ∀ idx, (p idx).Prime) (hq : ∀ idx, (q idx).Prime) (ht : ∀ idx, (t idx).Prime) (he : 0 < e) : Positive (state C p q t e) := by constructor · intro idx have h := (leftPrimes_prime C p t hp ht idx).one_lt change 0 < leftPrimes C p t idx-1 omega · intro idx refine Fin.addCases ?_ ?_ idx · intro j simp only [state, Fin.append_left] have h := (hq (index C j)).one_lt omega · intro j simpa only [state, Fin.append_right] using he /- Original line 22408: Erdos416Proof.CollisionClass.state_leftValue -/ theorem state_leftValue (C : Finset (Fin a)) (p q : Fin a → ℕ) (t : Fin l → ℕ) (e : ℕ) : leftValue (state C p q t e) = (∏ j ∈ remaining C, (p j-1))*(∏ idx, (t idx-1)) := by change (∏ idx, (leftPrimes C p t idx-1)) = _ rw [Fin.prod_univ_add] simp only [leftPrimes, Fin.append_left, Fin.append_right] rw [prod_index C (fun idx => p idx-1)] /- Original line 22416: Erdos416Proof.CollisionClass.state_rightValue -/ theorem state_rightValue (C : Finset (Fin a)) (p q : Fin a → ℕ) (t : Fin l → ℕ) (e : ℕ) : rightValue (state C p q t e) = (∏ j ∈ remaining C, (q j-1))*e := by change (∏ idx, (Fin.append (fun j => q (index C j)-1) (fun _ : Fin 1 => e)) idx) = _ rw [Fin.prod_univ_add] simp only [Fin.append_left, Fin.append_right, Fin.prod_univ_one] rw [prod_index C (fun idx => q idx-1)] /- Original line 22423: Erdos416Proof.CollisionClass.prod_leftPrimes -/ theorem prod_leftPrimes (C : Finset (Fin a)) (p : Fin a → ℕ) (t : Fin l → ℕ) : (∏ idx, leftPrimes C p t idx) = (∏ j ∈ remaining C, p j)*(∏ idx, t idx) := by rw [Fin.prod_univ_add] simp only [leftPrimes, Fin.append_left, Fin.append_right, prod_index] /- Original line 22428: Erdos416Proof.CollisionClass.prod_reconstruct -/ theorem prod_reconstruct (C : Finset (Fin a)) (p : Fin a → ℕ) (t : Fin l → ℕ) : (∏ idx, p idx)*(∏ j, t j) = (∏ idx ∈ C, p idx)*(∏ j, leftPrimes C p t j) := by have hs := Finset.prod_sdiff (s₁ := C) (s₂ := Finset.univ) (f := p) (Finset.subset_univ C) rw [prod_leftPrimes] change _ = (∏ idx ∈ C, p idx)*((∏ idx ∈ Finset.univ \ C, p idx)*(∏ j, t j)) rw [← hs] ring /-- Fixing the canceled ordinary prime product recovers the counted integer directly from the left entries of its actual sieve state. -/ /- Original line 22438: Erdos416Proof.CollisionClass.integer_reconstruct -/ theorem integer_reconstruct (C : Finset (Fin a)) (p q : Fin a → ℕ) (t : Fin l → ℕ) (e : ℕ) (hp : ∀ idx, (p idx).Prime) (ht : ∀ idx, (t idx).Prime) : (∏ idx, p idx)*(∏ j, t j) = (∏ idx ∈ C, p idx)*(∏ j, ((state C p q t e).1 j+1)) := by rw [prod_reconstruct C p t] congr 1 apply Finset.prod_congr rfl intro idx _ change leftPrimes C p t idx = leftPrimes C p t idx-1+1 exact (Nat.sub_add_cancel (leftPrimes_prime C p t hp ht idx).one_le).symm /- Original line 22449: Erdos416Proof.CollisionClass.state_shifted_factor -/ theorem state_shifted_factor (C : Finset (Fin a)) (p q : Fin a → ℕ) (t : Fin l → ℕ) (e : ℕ) (hp : ∀ idx, (p idx).Prime) (hinj : Function.Injective p) : (∏ idx, (p idx-1))*(∏ j, (t j-1)) = (∏ idx ∈ C, p idx).totient*leftValue (state C p q t e) := by have hphi := totient_prod_injective_primes C p (fun idx _ => hp idx) hinj.injOn rw [hphi, state_leftValue] have hs := Finset.prod_sdiff (s₁ := C) (s₂ := Finset.univ) (f := fun idx => p idx-1) (Finset.subset_univ C) change _ = (∏ idx ∈ C, (p idx-1))*((∏ idx ∈ Finset.univ \ C, (p idx-1))*(∏ j, (t j-1))) rw [← hs] ring /- Original line 22461: Erdos416Proof.CollisionClass.state_balanced -/ theorem state_balanced (C : Finset (Fin a)) (p q : Fin a → ℕ) (t : Fin l → ℕ) (e d : ℕ) (hp : ∀ idx, (p idx).Prime) (hinj : Function.Injective p) (hC : C = commonIndices Finset.univ p q) (hbal : d*((∏ idx, (p idx-1))*(∏ j, (t j-1))) = (∏ idx, (q idx-1))*e) : CollisionState.Balanced d (state C p q t e) := by let : DecidableEq (Fin a) := fun idx j => Classical.propDecidable (idx = j) have hbal' : (d*(∏ j, (t j-1)))*(∏ idx, (p idx-1)) = e*(∏ idx, (q idx-1)) := by nlinarith only [hbal] have h := (cancel_common_shifted_primes Finset.univ p q (fun idx _ => hp idx) hinj.injOn hbal').1 rw [← hC] at h have hrem : Finset.univ \ C = remaining C := by ext idx simp only [remaining, Finset.mem_sdiff] rw [hrem] at h unfold CollisionState.Balanced rw [state_leftValue, state_rightValue] nlinarith only [h] /- Original line 22479: Erdos416Proof.CollisionClass.state_image_card -/ theorem state_image_card (A : Finset ℕ) (C : Finset (Fin a)) (M : ℕ) (p q : ℕ → Fin a → ℕ) (t : ℕ → Fin l → ℕ) (e : ℕ → ℕ) (hF : ∀ n ∈ A, (∀ idx, (p n idx).Prime) ∧ (∀ j, (t n j).Prime) ∧ (∏ idx ∈ C, p n idx) = M ∧ (∏ idx, p n idx)*(∏ j, t n j) = n) : (A.image (fun n => state C (p n) (q n) (t n) (e n))).card = A.card := by apply Finset.card_image_iff.mpr intro n hn m hm heq change state C (p n) (q n) (t n) (e n) = state C (p m) (q m) (t m) (e m) at heq have hnrec := integer_reconstruct C (p n) (q n) (t n) (e n) (hF n hn).1 (hF n hn).2.1 have hmrec := integer_reconstruct C (p m) (q m) (t m) (e m) (hF m hm).1 (hF m hm).2.1 rw [(hF n hn).2.2.1, (hF n hn).2.2.2, heq] at hnrec rw [(hF m hm).2.2.1, (hF m hm).2.2.2] at hmrec exact hnrec.trans hmrec.symm /- Original line 22493: Erdos416Proof.CollisionClass.state_left_prefix -/ theorem state_left_prefix (C : Finset (Fin a)) (p q : Fin a → ℕ) (t : Fin l → ℕ) (e : ℕ) (idx : Fin (remaining C).card) : (state C p q t e).1 (Fin.castAdd l idx) = p (index C idx)-1 := by simp only [state, leftPrimes, Fin.append_left] /- Original line 22498: Erdos416Proof.CollisionClass.state_right_prefix -/ theorem state_right_prefix (C : Finset (Fin a)) (p q : Fin a → ℕ) (t : Fin l → ℕ) (e : ℕ) (idx : Fin (remaining C).card) : (state C p q t e).2 (Fin.castAdd 1 idx) = q (index C idx)-1 := by simp only [state, Fin.append_left] /- Original line 22503: Erdos416Proof.CollisionClass.state_left_tail -/ theorem state_left_tail (C : Finset (Fin a)) (p q : Fin a → ℕ) (t : Fin l → ℕ) (e : ℕ) (idx : Fin l) : (state C p q t e).1 (Fin.natAdd (remaining C).card idx) = t idx-1 := by simp only [state, leftPrimes, Fin.append_right] /- Original line 22507: Erdos416Proof.CollisionClass.state_right_tail -/ theorem state_right_tail (C : Finset (Fin a)) (p q : Fin a → ℕ) (t : Fin l → ℕ) (e : ℕ) (idx : Fin 1) : (state C p q t e).2 (Fin.natAdd (remaining C).card idx) = e := by simp only [state, Fin.append_right] /- Original line 22511: Erdos416Proof.CollisionClass.state_size -/ theorem state_size (C : Finset (Fin a)) (p q : Fin a → ℕ) (t : Fin l → ℕ) (e d M : ℕ) {Y : ℝ} (hp : ∀ idx, (p idx).Prime) (hinj : Function.Injective p) (hM : (∏ idx ∈ C, p idx) = M) (hY : ((d*((∏ idx, (p idx-1))*(∏ j, (t j-1))) : ℕ) : ℝ) ≤ Y) : (M.totient : ℝ)*(d : ℝ)*leftValue (state C p q t e) ≤ Y := by have hfactor : d*((∏ idx, (p idx-1))*(∏ j, (t j-1))) = M.totient*(d*leftValue (state C p q t e)) := by rw [state_shifted_factor C p q t e hp hinj, hM] ring rw [hfactor, Nat.cast_mul, Nat.cast_mul] at hY simpa only [mul_assoc] using hY /- Original line 22523: Erdos416Proof.CollisionClass.state_square_exclusion -/ theorem state_square_exclusion (C : Finset (Fin a)) (p q : Fin a → ℕ) (t : Fin l → ℕ) (e d : ℕ) {u : ℝ} (hp : ∀ idx, (p idx).Prime) (hinj : Function.Injective p) (hsq : NoLargePrimeSquare (d*((∏ idx, (p idx-1))*(∏ j, (t j-1)))) u) : NoLargePrimeSquare (d*leftValue (state C p q t e)) u := by have hdiv : d*leftValue (state C p q t e) ∣ d*((∏ idx, (p idx-1))*(∏ j, (t j-1))) := by rw [state_shifted_factor C p q t e hp hinj] refine ⟨(∏ idx ∈ C, p idx).totient, ?_⟩ ring exact fun z hz hzu hzd => hsq z hz hzu (hzd.trans hdiv) /- Original line 22533: Erdos416Proof.CollisionClass.state_paired_ne -/ theorem state_paired_ne (C : Finset (Fin a)) (p q : Fin a → ℕ) (t : Fin l → ℕ) (e : ℕ) (hp : ∀ idx, (p idx).Prime) (hq : ∀ idx, (q idx).Prime) (hC : C = commonIndices Finset.univ p q) (idx : Fin (remaining C).card) : (state C p q t e).1 (Fin.castAdd l idx) ≠ (state C p q t e).2 (Fin.castAdd 1 idx) := by let : DecidableEq (Fin a) := fun idx j => Classical.propDecidable (idx = j) rw [state_left_prefix, state_right_prefix] have hi : index C idx ∈ Finset.univ \ commonIndices Finset.univ p q := by rw [← hC] simpa only [remaining, Finset.mem_sdiff] using index_mem C idx have hne := remaining_paired_primes_ne hi have hp1 := (hp (index C idx)).one_lt have hq1 := (hq (index C idx)).one_lt omega /- Original line 22547: Erdos416Proof.CollisionClass.normal_tail_cardFactors -/ theorem normal_tail_cardFactors {p : ℕ} {S u : ℝ} (hS : Real.exp 1 ≤ S) (hSu : S ≤ u) (hp : SNormal S p) (hsupport : ∀ z ∈ (p-1).primeFactorsList, (z : ℝ) ≤ u) : (ArithmeticFunction.cardFactors (p-1) : ℝ) ≤ 10*logLog u := by have hp0 : 0 < p-1 := by have := hp.1.one_lt; omega have hlow : lowPrimePart (p-1) u = p-1 := primePart_eq_self hp0.ne' _ hsupport have hsmall := hp.initial_interval_le_three_mul hS hSu le_rfl have hcard : (ArithmeticFunction.cardFactors (lowPrimePart (p-1) u) : ℝ) ≤ 3*logLog u := by simpa only [lowPrimePart_cardFactors] using hsmall rw [hlow] at hcard have hS1 : 1 < S := (Real.one_lt_exp_iff.mpr (by norm_num : (0 : ℝ) < 1)).trans_le hS have hLLu : 0 ≤ logLog u := (logLog_nonneg hS).trans (logLog_mono hS1 hSu) linarith /-- Conditions on the original prime lists and their full right residual, before cancellation. The integer being counted and the common ordinary prime product are explicit. -/ /- Original line 22563: Erdos416Proof.CollisionClass.Conditions -/ structure Conditions (C : Finset (Fin a)) (d M n : ℕ) (S Y : ℝ) (v W : ℕ → ℝ) (p q : Fin a → ℕ) (t : Fin l → ℕ) (e : ℕ) : Prop where normal_left : ∀ idx, SNormal S (p idx) normal_right : ∀ idx, SNormal S (q idx) normal_tail : ∀ idx, SNormal S (t idx) left_injective : Function.Injective p residual_pos : 0 < e common : C = commonIndices Finset.univ p q common_product : (∏ idx ∈ C, p idx) = M integer : (∏ idx, p idx)*(∏ j, t j) = n equation : d*((∏ idx, (p idx-1))*(∏ j, (t j-1))) = (∏ idx, (q idx-1))*e size : ((d*((∏ idx, (p idx-1))*(∏ j, (t j-1))) : ℕ) : ℝ) ≤ Y square_exclusion : NoLargePrimeSquare (d*((∏ idx, (p idx-1))*(∏ j, (t j-1)))) (v (remaining C).card) largest_left : ∀ idx : Fin (remaining C).card, W idx.val ≤ (largestPrimeFactor (p (index C idx)-1) : ℝ) ∧ (largestPrimeFactor (p (index C idx)-1) : ℝ) ≤ v idx.val largest_right : ∀ idx : Fin (remaining C).card, W idx.val ≤ (largestPrimeFactor (q (index C idx)-1) : ℝ) ∧ (largestPrimeFactor (q (index C idx)-1) : ℝ) ≤ v idx.val tail_support : ∀ idx : Fin l, ∀ z ∈ (t idx-1).primeFactorsList, (z : ℝ) ≤ v (remaining C).card residual_support : ∀ z ∈ e.primeFactorsList, (z : ℝ) ≤ v (remaining C).card top : ∀ idx : Fin a, idx.val = 0 → Y^(9/10 : ℝ) < (p idx : ℝ) /- Original line 22586: Erdos416Proof.CollisionClass.Conditions.common_pos -/ theorem Conditions.common_pos {C : Finset (Fin a)} {d M n : ℕ} {S Y : ℝ} {v W : ℕ → ℝ} {p q : Fin a → ℕ} {t : Fin l → ℕ} {e : ℕ} (hs : Conditions C d M n S Y v W p q t e) : 0 < M := by rw [← hs.common_product] exact Finset.prod_pos (fun idx _ => (hs.normal_left idx).1.pos) /-- Every hypothesis of the sieve on the canceled image is derived from the original prime records. In particular the tail factor count is proved, and cancellation preserves the original first coordinate. -/ /- Original line 22595: Erdos416Proof.CollisionClass.Conditions.state_conditions -/ theorem Conditions.state_conditions {C : Finset (Fin a)} {d M n : ℕ} {S Y : ℝ} {v W : ℕ → ℝ} {p q : Fin a → ℕ} {t : Fin l → ℕ} {e : ℕ} (hs : Conditions C d M n S Y v W p q t e) (hk : 1 ≤ (remaining C).card) (hzero : ∀ j : Fin a, j.val = 0 → j ∉ C) (hS : Real.exp 1 ≤ S) (hSv : S ≤ v (remaining C).card) : SieveOriginalConditions (remaining C).card d S Y M.totient v W (state C p q t e) := by have hp : ∀ idx, (p idx).Prime := fun idx => (hs.normal_left idx).1 have hq : ∀ idx, (q idx).Prime := fun idx => (hs.normal_right idx).1 have ht : ∀ idx, (t idx).Prime := fun idx => (hs.normal_tail idx).1 refine ⟨state_positive C p q t e hp hq ht hs.residual_pos, state_balanced C p q t e d hp hs.left_injective hs.common hs.equation, state_size C p q t e d M hp hs.left_injective hs.common_product hs.size, state_square_exclusion C p q t e d hp hs.left_injective hs.square_exclusion, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_⟩ · intro j hj let idx : Fin (remaining C).card := ⟨j.val, hj⟩ have heq : j = Fin.castAdd l idx := by apply Fin.ext; rfl rw [heq, state_left_prefix, Nat.sub_add_cancel (hp (index C idx)).one_le] exact hs.normal_left (index C idx) · intro j hj let idx : Fin (remaining C).card := ⟨j.val, hj⟩ have heq : j = Fin.castAdd 1 idx := by apply Fin.ext; rfl rw [heq, state_right_prefix, Nat.sub_add_cancel (hq (index C idx)).one_le] exact hs.normal_right (index C idx) · intro j r hj hr let idx : Fin (remaining C).card := ⟨j.val, hj⟩ have hjeq : j = Fin.castAdd l idx := by apply Fin.ext; rfl have hreq : r = Fin.castAdd 1 idx := by apply Fin.ext; exact hr rw [hjeq, hreq] exact state_paired_ne C p q t e hp hq hs.common idx · intro j hj let idx : Fin (remaining C).card := ⟨j.val, hj⟩ have heq : j = Fin.castAdd l idx := by apply Fin.ext; rfl rw [heq, state_left_prefix] exact hs.largest_left idx · intro j hj let idx : Fin (remaining C).card := ⟨j.val, hj⟩ have heq : j = Fin.castAdd 1 idx := by apply Fin.ext; rfl rw [heq, state_right_prefix] exact hs.largest_right idx · intro j refine Fin.addCases ?_ ?_ j · intro idx hi have := idx.isLt change (remaining C).card ≤ idx.val at hi omega · intro idx _ z hz exact hs.tail_support idx z (by simpa only [state_left_tail] using hz) · intro j refine Fin.addCases ?_ ?_ j · intro idx hi have := idx.isLt change (remaining C).card ≤ idx.val at hi omega · intro idx _ z hz exact hs.residual_support z (by simpa only [state_right_tail] using hz) · intro j refine Fin.addCases ?_ ?_ j · intro idx hi have := idx.isLt change (remaining C).card ≤ idx.val at hi omega · intro idx _ rw [state_left_tail] exact normal_tail_cardFactors hS hSv (hs.normal_tail idx) (hs.tail_support idx) · intro j hj let idx : Fin (remaining C).card := ⟨j.val, by omega⟩ have heq : j = Fin.castAdd l idx := by apply Fin.ext; rfl rw [heq, state_left_prefix, Nat.sub_add_cancel (hp (index C idx)).one_le] exact hs.top (index C idx) (index_first C hzero idx hj) /- Original line 22666: Erdos416Proof.CollisionClass.remaining_card_le -/ theorem remaining_card_le (C : Finset (Fin a)) : (remaining C).card ≤ a := by have h := Finset.card_le_card (Finset.subset_univ (remaining C)) simpa only [Finset.card_univ, Fintype.card_fin] using h /- Original line 22670: Erdos416Proof.CollisionClass.index_val_ge -/ theorem index_val_ge (C : Finset (Fin a)) (idx : Fin (remaining C).card) : idx.val ≤ (index C idx).val := increasing_index_val_le (index C) (index_strictMono C) idx /-- A fixed collision class is counted through its explicitly constructed image. The map is proved injective in the original integers and every original-solution hypothesis of the sieve is supplied from Conditions. -/ /- Original line 22676: Erdos416Proof.CollisionClass.exists_collision_class_sieve_bound -/ theorem exists_collision_class_sieve_bound : ∃ c : ℝ, 0 < c ∧ ∀ᶠ Y : ℝ in atTop, ∀ (a l d M : ℕ) (C : Finset (Fin a)) (A : Finset ℕ) (p q : ℕ → Fin a → ℕ) (t : ℕ → Fin l → ℕ) (e : ℕ → ℕ) (v W : ℕ → ℝ), let k := (remaining C).card 1 ≤ a → 1 ≤ l → (∀ j : Fin a, j.val = 0 → j ∉ C) → normalityScale (logLog Y) ≤ v k → Antitone v → v 0 = Y → (∀ j < k, v (j+1) < W j ∧ W j ≤ v j) → (∀ idx, 2 ≤ idx → idx ≤ k → normalityDelta (logLog Y) ≤ logLog (v (idx-1))/logLog Y-logLog (v idx)/logLog Y) → v 1 ≤ Y ^ (1/(10*logLog Y)) → 0 < d → (∀ z ∈ d.primeFactorsList, (z : ℝ) ≤ v k) → (∀ n ∈ A, Conditions C d M n (normalityScale (logLog Y)) Y v W (p n) (q n) (t n) (e n)) → (A.card : ℝ) ≤ (Y/((d : ℝ)*M.totient))*(c*logLog Y)^(6*k)*(k+1 : ℝ)^ArithmeticFunction.cardFactors d * (Real.log (v k)) ^ (20*(k+l : ℕ)*Real.log (k+l : ℕ)+1 : ℝ) * (Real.log Y)^(-2+(∑ idx ∈ Finset.Icc 1 (k-1), fordWeight idx*(logLog (v idx)/logLog Y)) + fordSieveError k (normalityDelta (logLog Y)/2) (fun idx => logLog (v idx)/logLog Y) (fun idx => logLog (W idx)/logLog Y)) := by obtain ⟨c, hc, hbound⟩ := exists_multivariable_sieve_normal_bound refine ⟨c, hc, ?_⟩ filter_upwards [hbound, eventually_ge_atTop (Real.exp (Real.exp 1))] with Y hY hbase intro a l d M C A p q t e v W dsimp only intro ha hl hzero hSv hanti hv0 hW hgap hcut hd hdv hA let k := (remaining C).card have hk : 1 ≤ k := remaining_card_pos C ha hzero have hS : Real.exp 1 ≤ normalityScale (logLog Y) := normalityScale_ge_exp_one _ have hbase1 : 1 < Real.exp (Real.exp 1) := Real.one_lt_exp_iff.mpr (Real.exp_pos 1) have hY1 : 1 < Y := hbase1.trans_le hbase have hY0 : 0 ≤ Y := by linarith have hT : 1 ≤ logLog Y := by simpa only [logLog, Real.log_exp] using logLog_mono hbase1 hbase have hT0 : 0 ≤ logLog Y := by linarith have hlogY : 0 ≤ Real.log Y := (Real.log_pos hY1).le have hlogv : 0 ≤ Real.log (v k) := Real.log_nonneg ((Real.one_le_exp (by norm_num : (0 : ℝ) ≤ 1)).trans (hS.trans hSv)) by_cases hnonempty : A.Nonempty · obtain ⟨n, hn⟩ := hnonempty have hM : 0 < M := (hA n hn).common_pos have hR : (1 : ℝ) ≤ M.totient := by exact_mod_cast Nat.totient_pos.mpr hM let F : Finset (CollisionState (k+l) (k+1)) := A.image (fun n => state C (p n) (q n) (t n) (e n)) have hF : ∀ s ∈ F, SieveOriginalConditions k d (normalityScale (logLog Y)) Y M.totient v W s := by intro s hs obtain ⟨n, hn, rfl⟩ := Finset.mem_image.mp hs exact (hA n hn).state_conditions hk hzero hS hSv have hcard : F.card = A.card := state_image_card A C M p q t e (by intro n hn have hs := hA n hn exact ⟨fun idx => (hs.normal_left idx).1, fun j => (hs.normal_tail j).1, hs.common_product, hs.integer⟩) have h := hY k l d M.totient v W F hk hl hSv hanti hv0 hW hgap hR hcut hd hdv hF rw [hcard] at h exact h · rw [Finset.not_nonempty_iff_eq_empty.mp hnonempty] simp only [Finset.card_empty, Nat.cast_zero] positivity /- Original line 22736: Erdos416Proof.CollisionClass.prod_prefix_tail -/ theorem prod_prefix_tail {k m : ℕ} (f : Fin m → ℕ) (hkm : k ≤ m) : (∏ idx : Fin k, f (Fin.castLE hkm idx))* (∏ j ∈ Finset.univ.filter (fun j : Fin m => k ≤ j.val), f j) = ∏ j, f j := by have hp : (∏ idx : Fin k, f (Fin.castLE hkm idx)) = ∏ j ∈ Finset.univ.filter (fun j : Fin m => j.val < k), f j := by refine Finset.prod_bij (fun idx (_ : idx ∈ Finset.univ) => Fin.castLE hkm idx) ?_ ?_ ?_ ?_ · intro idx _ exact Finset.mem_filter.mpr ⟨Finset.mem_univ _, idx.isLt⟩ · intro idx _ j _ hij apply Fin.ext exact congrArg (fun x : Fin m => x.val) hij · intro j hj refine ⟨⟨j.val, (Finset.mem_filter.mp hj).2⟩, Finset.mem_univ _, ?_⟩ apply Fin.ext rfl · intro idx _ rfl have h := Finset.prod_filter_mul_prod_filter_not Finset.univ (fun j : Fin m => j.val < k) f rw [← hp] at h simpa only [not_lt] using h /-- The first matched shifted factors are selected from the actual normal preimage list, whose length may depend on its original integer. -/ /- Original line 22759: Erdos416Proof.CollisionClass.prefixPrimes -/ noncomputable def prefixPrimes {N : ℕ} {S : ℝ} (Q : NormalPreimageList N S) (ha : a ≤ (largeShiftPrimes N S).card) : Fin a → ℕ := fun idx => Q.primes (Fin.castLE ha idx) /-- The complete remaining totient factor, including the small prime-power part of N and all normal shifted factors beyond the selected prefix. -/ /- Original line 22764: Erdos416Proof.CollisionClass.normalResidual -/ noncomputable def normalResidual {N : ℕ} {S : ℝ} (Q : NormalPreimageList N S) (a : ℕ) : ℕ := smallShiftPart N S * ∏ j ∈ Finset.univ.filter (fun j : Fin (largeShiftPrimes N S).card => a ≤ j.val), (Q.primes j-1) /- Original line 22768: Erdos416Proof.CollisionClass.prefixPrimes_normal -/ theorem prefixPrimes_normal {N : ℕ} {S : ℝ} (Q : NormalPreimageList N S) (ha : a ≤ (largeShiftPrimes N S).card) (idx : Fin a) : SNormal S (prefixPrimes Q ha idx) := Q.normal (Fin.castLE ha idx) /- Original line 22772: Erdos416Proof.CollisionClass.normalResidual_pos -/ theorem normalResidual_pos {N : ℕ} {S : ℝ} (Q : NormalPreimageList N S) (a : ℕ) : 0 < normalResidual Q a := by apply Nat.mul_pos Q.residual_pos apply Finset.prod_pos intro j _ have h := (Q.normal j).1.one_lt omega /- Original line 22780: Erdos416Proof.CollisionClass.prefixPrimes_equation -/ theorem prefixPrimes_equation {N : ℕ} {S : ℝ} (Q : NormalPreimageList N S) (ha : a ≤ (largeShiftPrimes N S).card) : N.totient = (∏ idx : Fin a, (prefixPrimes Q ha idx-1))*normalResidual Q a := by rw [Q.phi_eq] simp only [prefixPrimes, normalResidual] rw [← prod_prefix_tail (fun j => Q.primes j-1) ha] ring /- Original line 22788: Erdos416Proof.CollisionClass.normalResidual_support -/ theorem normalResidual_support {N : ℕ} {S u : ℝ} (Q : NormalPreimageList N S) (a : ℕ) (hS : 1 ≤ S) (hSu : S ≤ u) (htail : ∀ j : Fin (largeShiftPrimes N S).card, a ≤ j.val → (largestPrimeFactor (Q.primes j-1) : ℝ) ≤ u) : ∀ z ∈ (normalResidual Q a).primeFactorsList, (z : ℝ) ≤ u := by let F := Finset.univ.filter (fun j : Fin (largeShiftPrimes N S).card => a ≤ j.val) have hp : ∀ j ∈ F, 0 < Q.primes j-1 := by intro j _ have := (Q.normal j).1.one_lt omega have hprod := largestPrimeFactor_prod_le F (fun j => Q.primes j-1) (hS.trans hSu) hp (fun j hj => htail j (Finset.mem_filter.mp hj).2) have hres : (largestPrimeFactor (normalResidual Q a) : ℝ) ≤ u := by rw [normalResidual, largestPrimeFactor_mul Q.residual_pos (Finset.prod_pos hp), Nat.cast_max] exact max_le (Q.residual_smooth.trans hSu) hprod intro z hz exact (Nat.cast_le.mpr (primeFactorsList_le_largestPrimeFactor hz)).trans hres /- Original line 22806: Erdos416Proof.CollisionClass.prefixPrimes_ne_of_largest_ne -/ theorem prefixPrimes_ne_of_largest_ne {N p : ℕ} {S : ℝ} (Q : NormalPreimageList N S) (ha : a ≤ (largeShiftPrimes N S).card) (hN : 0 < N) (hp : p.Prime) (hsize : N ≤ p^2) (hneq : largestPrimeFactor N ≠ p) (idx : Fin a) : p ≠ prefixPrimes Q ha idx := by have hdiv : prefixPrimes Q ha idx ∣ N := by change Q.primes (Fin.castLE ha idx) ∣ N apply ((Q.normal (Fin.castLE ha idx)).1.dvd_iff_one_le_factorization hN.ne').mpr rw [Q.occurs_once] intro heq rw [← heq] at hdiv exact top_prime_not_dvd_of_square_bound hN hp hsize hneq hdiv /- Original line 22817: Erdos416Proof.CollisionClass.common_zero_absent -/ theorem common_zero_absent {N : ℕ} {S : ℝ} (Q : NormalPreimageList N S) (ha : a ≤ (largeShiftPrimes N S).card) (C : Finset (Fin a)) (p : Fin a → ℕ) (hN : 0 < N) (hp : ∀ idx, (p idx).Prime) (hC : C = commonIndices Finset.univ p (prefixPrimes Q ha)) (hsize : ∀ idx : Fin a, idx.val = 0 → N ≤ (p idx)^2) (hneq : ∀ idx : Fin a, idx.val = 0 → largestPrimeFactor N ≠ p idx) : ∀ idx : Fin a, idx.val = 0 → idx ∉ C := by intro idx hi hmem rw [hC] at hmem exact prefixPrimes_ne_of_largest_ne Q ha hN (hp idx) (hsize idx hi) (hneq idx hi) idx (mem_commonIndices.mp hmem).2 /-- Construct the class record from an actual auxiliary preimage. Its right prefix, residual, exact equation, positivity and residual support are supplied by the normal preimage list rather than assumed separately. -/ /- Original line 22832: Erdos416Proof.CollisionClass.conditions_of_normalPreimage -/ theorem conditions_of_normalPreimage {N : ℕ} {S Y : ℝ} (Q : NormalPreimageList N S) (ha : a ≤ (largeShiftPrimes N S).card) (C : Finset (Fin a)) (d M n : ℕ) (v W : ℕ → ℝ) (p : Fin a → ℕ) (t : Fin l → ℕ) (hS : 1 ≤ S) (hSu : S ≤ v (remaining C).card) (hp : ∀ idx, SNormal S (p idx)) (ht : ∀ j, SNormal S (t j)) (hinj : Function.Injective p) (hC : C = commonIndices Finset.univ p (prefixPrimes Q ha)) (hM : (∏ idx ∈ C, p idx) = M) (hn : (∏ idx, p idx)*(∏ j, t j) = n) (hphi : N.totient = d*((∏ idx, (p idx-1))*(∏ j, (t j-1)))) (hsize : (N.totient : ℝ) ≤ Y) (hsquare : NoLargePrimeSquare N.totient (v (remaining C).card)) (hlargest : ∀ idx : Fin (remaining C).card, W idx.val ≤ (largestPrimeFactor (p (index C idx)-1) : ℝ) ∧ (largestPrimeFactor (p (index C idx)-1) : ℝ) ≤ v idx.val) (hqlargest : ∀ idx : Fin (remaining C).card, W idx.val ≤ (largestPrimeFactor (prefixPrimes Q ha (index C idx)-1) : ℝ) ∧ (largestPrimeFactor (prefixPrimes Q ha (index C idx)-1) : ℝ) ≤ v idx.val) (htail : ∀ idx : Fin l, ∀ z ∈ (t idx-1).primeFactorsList, (z : ℝ) ≤ v (remaining C).card) (hqtail : ∀ j : Fin (largeShiftPrimes N S).card, a ≤ j.val → (largestPrimeFactor (Q.primes j-1) : ℝ) ≤ v (remaining C).card) (htop : ∀ idx : Fin a, idx.val = 0 → Y^(9/10 : ℝ) < (p idx : ℝ)) : Conditions C d M n S Y v W p (prefixPrimes Q ha) t (normalResidual Q a) := by refine ⟨hp, prefixPrimes_normal Q ha, ht, hinj, normalResidual_pos Q a, hC, hM, hn, hphi.symm.trans (prefixPrimes_equation Q ha), ?_, ?_, hlargest, hqlargest, htail, normalResidual_support Q a hS hSu hqtail, htop⟩ · simpa only [hphi] using hsize · simpa only [hphi] using hsquare end Erdos416Proof.CollisionClass /- Actual rounded boxes from normal prime coordinates, high-prefix ordering and tail separation, and the uniform finite label count. -/ open Filter Finset open scoped Topology BigOperators namespace Erdos416Proof.CollisionBox /-- The actual upper grid point, with mesh `ε`. -/ /- Original line 22876: Erdos416Proof.CollisionBox.roundUp -/ noncomputable def roundUp (ε w : ℝ) : ℝ := ε * (⌈w / ε⌉₊ : ℝ) /- Original line 22878: Erdos416Proof.CollisionBox.roundUp_bounds -/ theorem roundUp_bounds {ε w : ℝ} (hε : 0 < ε) (hw : 0 ≤ w) : w ≤ roundUp ε w ∧ roundUp ε w < w + ε := by have hc := Nat.le_ceil (w / ε) have hd := Nat.ceil_lt_add_one (div_nonneg hw hε.le) have hlo := mul_le_mul_of_nonneg_left hc hε.le have hhi := mul_lt_mul_of_pos_left hd hε have heq : ε * (w / ε) = w := by field_simp constructor · simpa only [roundUp, heq] using hlo · change ε * (⌈w / ε⌉₊ : ℝ) < w + ε nlinarith /- Original line 22890: Erdos416Proof.CollisionBox.roundUp_mono -/ theorem roundUp_mono {ε : ℝ} (hε : 0 < ε) : Monotone (roundUp ε) := by intro w z hwz have hc := Nat.ceil_mono (div_le_div_of_nonneg_right hwz hε.le) exact mul_le_mul_of_nonneg_left (by exact_mod_cast hc) hε.le /-- The top coordinate is fixed at one; the others use the actual grid. -/ /- Original line 22896: Erdos416Proof.CollisionBox.rounded -/ noncomputable def rounded {L : ℕ} (ε : ℝ) (w : Fin (L + 1) → ℝ) (idx : Fin (L + 1)) : ℝ := if idx.val = 0 then 1 else roundUp ε (w idx) /- Original line 22899: Erdos416Proof.CollisionBox.rounded_zero -/ theorem rounded_zero {L : ℕ} (ε : ℝ) (w : Fin (L + 1) → ℝ) : rounded ε w 0 = 1 := by simp [rounded] /- Original line 22902: Erdos416Proof.CollisionBox.rounded_of_pos -/ theorem rounded_of_pos {L : ℕ} (ε : ℝ) (w : Fin (L + 1) → ℝ) (idx : Fin (L + 1)) (hi : 0 < idx.val) : rounded ε w idx = roundUp ε (w idx) := by simp only [rounded, ne_of_gt hi, ↓reduceIte] /- Original line 22906: Erdos416Proof.CollisionBox.tailCoordinate -/ noncomputable def tailCoordinate {L : ℕ} (ε h b : ℝ) (w : Fin (L + 1) → ℝ) (J : Fin (L + 1)) : ℝ := min b (rounded ε w J - 2 * h) /- Original line 22910: Erdos416Proof.CollisionBox.exists_last_high -/ theorem exists_last_high {L : ℕ} (w : Fin (L + 1) → ℝ) {b : ℝ} (hhead : b < w 0) (hlast : w (Fin.last L) ≤ b) : ∃ J : Fin (L + 1), J.val < L ∧ b < w J ∧ ∀ j, J < j → w j ≤ b := by classical let H := Finset.univ.filter (fun idx => b < w idx) have hH : H.Nonempty := ⟨0, by simp [H, hhead]⟩ obtain ⟨J, hJ, hmax⟩ := H.exists_max_image (fun idx => idx) hH have hhigh : b < w J := (Finset.mem_filter.mp hJ).2 have hJL : J.val < L := by by_contra hn have heq : J = Fin.last L := Fin.ext (by change J.val = L; omega) rw [heq] at hhigh exact (not_lt_of_ge hlast) hhigh refine ⟨J, hJL, hhigh, ?_⟩ intro j hj by_contra hn have hjH : j ∈ H := by simp [H, lt_of_not_ge hn] exact (not_le_of_gt hj) (hmax j hjH) /-- Quantitative coordinate conditions before choosing the high prefix. The approximation is needed only where the ordinary coordinate is at least `b`. No ordering of the shifted coordinates is assumed. -/ /- Original line 22933: Erdos416Proof.CollisionBox.Data -/ structure Data {L : ℕ} (x w : Fin (L + 1) → ℝ) (b e e₀ ε h g θ : ℝ) : Prop where threshold_pos : 0 < b mesh_pos : 0 < ε gap_pos : 0 < h contraction_nonneg : 0 ≤ g ordinary_order : Antitone x shifted_le : ∀ idx, w idx ≤ x idx approximation : ∀ idx, b ≤ x idx → x idx - e ≤ w idx contraction : ∀ idx j, 0 < idx.val → idx < j → g * x idx ≤ x idx - x j lower_upper : ∀ idx, 0 < idx.val → x idx ≤ θ head_high : b < w 0 head_le : w 0 ≤ 1 head_approximation : 1 - e₀ ≤ w 0 last_low : w (Fin.last L) ≤ b lower_gap : 10 * h + ε + e ≤ g * b head_gap : 10 * h + ε + e₀ ≤ 1 - θ tail_margin : 4 * h ≤ b variable {L : ℕ} {x w : Fin (L + 1) → ℝ} {b e e₀ ε h g θ : ℝ} /- Original line 22954: Erdos416Proof.CollisionBox.Data.shifted_gap -/ theorem Data.shifted_gap (d : Data x w b e e₀ ε h g θ) {idx j : Fin (L + 1)} (hi : 0 < idx.val) (hij : idx < j) (hxi : b ≤ x idx) : 10 * h + ε ≤ w idx - w j := by have hc := d.contraction idx j hi hij have he := d.approximation idx hxi have hw := d.shifted_le j have hm := mul_le_mul_of_nonneg_left hxi d.contraction_nonneg have hg := d.lower_gap linarith /- Original line 22964: Erdos416Proof.CollisionBox.Data.head_shifted_gap -/ theorem Data.head_shifted_gap (d : Data x w b e e₀ ε h g θ) {j : Fin (L + 1)} (hj : 0 < j.val) : 10 * h + ε ≤ w 0 - w j := by have hu := d.lower_upper j hj have hw := d.shifted_le j have ha := d.head_approximation have hg := d.head_gap linarith /- Original line 22972: Erdos416Proof.CollisionBox.Data.high_before -/ theorem Data.high_before (d : Data x w b e e₀ ε h g θ) {idx J : Fin (L + 1)} (hJ : b < w J) (hi : idx ≤ J) : b < w idx := by by_cases hiJ : idx = J · simpa only [hiJ] using hJ by_cases hi0 : idx.val = 0 · have heq : idx = 0 := Fin.ext hi0 simpa only [heq] using d.head_high have hxi : b ≤ x idx := hJ.le.trans ((d.shifted_le J).trans (d.ordinary_order hi)) have hgap := d.shifted_gap (Nat.pos_of_ne_zero hi0) (lt_of_le_of_ne hi hiJ) hxi have hh := d.gap_pos have hε := d.mesh_pos linarith /-- Every high original position precedes all later shifted factors by a quantified gap, including factors outside the selected prefix. -/ /- Original line 22987: Erdos416Proof.CollisionBox.Data.gap_after_high -/ theorem Data.gap_after_high (d : Data x w b e e₀ ε h g θ) {idx j : Fin (L + 1)} (hi : b < w idx) (hij : idx < j) : 10 * h + ε ≤ w idx - w j := by by_cases hi0 : idx.val = 0 · have heq : idx = 0 := Fin.ext hi0 rw [heq] at hij ⊢ exact d.head_shifted_gap (show 0 < j.val from hij) · exact d.shifted_gap (Nat.pos_of_ne_zero hi0) hij (hi.le.trans (d.shifted_le idx)) /- Original line 22996: Erdos416Proof.CollisionBox.Data.rounded_bounds -/ theorem Data.rounded_bounds (d : Data x w b e e₀ ε h g θ) {idx : Fin (L + 1)} (hi : b < w idx) : w idx ≤ rounded ε w idx ∧ (0 < idx.val → rounded ε w idx < w idx + ε) := by by_cases hi0 : idx.val = 0 · have heq : idx = 0 := Fin.ext hi0 subst idx exact ⟨by simpa [Erdos416Proof.CollisionBox.rounded_zero] using d.head_le, by intro hn; omega⟩ · rw [rounded_of_pos ε w idx (Nat.pos_of_ne_zero hi0)] have hb := roundUp_bounds d.mesh_pos (d.threshold_pos.le.trans hi.le) exact ⟨hb.1, fun _ => hb.2⟩ /- Original line 23007: Erdos416Proof.CollisionBox.Data.rounded_gap -/ theorem Data.rounded_gap (d : Data x w b e e₀ ε h g θ) {idx j : Fin (L + 1)} (hi : b < w idx) (hj : b < w j) (hij : idx < j) : 10 * h ≤ rounded ε w idx - rounded ε w j := by have hgap := d.gap_after_high hi hij have hlo := (d.rounded_bounds hi).1 have hhi := (d.rounded_bounds hj).2 (show 0 < j.val by omega) linarith /- Original line 23015: Erdos416Proof.CollisionBox.Data.tail_bounds -/ theorem Data.tail_bounds (d : Data x w b e e₀ ε h g θ) {J : Fin (L + 1)} (hJ : b < w J) (hlast : ∀ j, J < j → w j ≤ b) : b / 2 ≤ tailCoordinate ε h b w J ∧ tailCoordinate ε h b w J ≤ b ∧ 2 * h ≤ rounded ε w J - tailCoordinate ε h b w J ∧ ∀ j, J < j → w j ≤ tailCoordinate ε h b w J := by have hround := (d.rounded_bounds hJ).1 have hmargin := d.tail_margin have hb := d.threshold_pos have hh := d.gap_pos have hε := d.mesh_pos refine ⟨le_min (by linarith) (by linarith), min_le_left _ _, ?_, ?_⟩ · have hmin : tailCoordinate ε h b w J ≤ rounded ε w J - 2 * h := min_le_right _ _ linarith · intro j hj have hg := d.gap_after_high hJ hj exact le_min (hlast j hj) (by linarith) /-- Construct the actual rounded prefix and its tail cutoff. The highest threshold crossing is proved to be the end of an initial segment. -/ /- Original line 23036: Erdos416Proof.CollisionBox.Data.exists_prefix -/ theorem Data.exists_prefix (d : Data x w b e e₀ ε h g θ) : ∃ J : Fin (L + 1), J.val < L ∧ (∀ idx, idx ≤ J ↔ b < w idx) ∧ (∀ idx j, idx ≤ J → idx < j → 10 * h + ε ≤ w idx - w j) ∧ (∀ idx j, idx < j → j ≤ J → 10 * h ≤ rounded ε w idx - rounded ε w j) ∧ b / 2 ≤ tailCoordinate ε h b w J ∧ tailCoordinate ε h b w J ≤ b ∧ 2 * h ≤ rounded ε w J - tailCoordinate ε h b w J ∧ ∀ j, J < j → w j ≤ tailCoordinate ε h b w J := by obtain ⟨J, hJL, hJ, hlast⟩ := exists_last_high w d.head_high d.last_low have hprefix : ∀ idx, idx ≤ J ↔ b < w idx := by intro idx constructor · exact d.high_before hJ · intro hi by_contra hn exact (not_lt_of_ge (hlast idx (lt_of_not_ge hn))) hi refine ⟨J, hJL, hprefix, ?_, ?_, d.tail_bounds hJ hlast⟩ · intro idx j hi hij exact d.gap_after_high ((hprefix idx).mp hi) hij · intro idx j hij hj exact d.rounded_gap ((hprefix idx).mp (hij.le.trans hj)) ((hprefix j).mp hj) hij /-- The actual integer code of the rounded vector. -/ /- Original line 23059: Erdos416Proof.CollisionBox.code -/ noncomputable def code {L : ℕ} (ε : ℝ) (w : Fin (L + 1) → ℝ) (idx : Fin (L + 1)) : ℕ := if idx.val = 0 then 0 else ⌈w idx / ε⌉₊ /-- A finite family of actual rounded vectors is bounded by the grid size. Coordinates below zero cause no difficulty because the natural ceiling is zero. -/ /- Original line 23064: Erdos416Proof.CollisionBox.rounded_image_card -/ theorem rounded_image_card {α : Type*} [DecidableEq α] (A : Finset α) (w : α → Fin (L + 1) → ℝ) (hε : 0 < ε) (hw : ∀ a ∈ A, ∀ idx, 0 < idx.val → w a idx ≤ 1) : (A.image (fun a => rounded ε (w a))).card ≤ (⌈1 / ε⌉₊ + 1) ^ (L + 1) := by classical let decode := fun c : Fin (L + 1) → ℕ => fun idx : Fin (L + 1) => if idx.val = 0 then (1 : ℝ) else ε * (c idx : ℝ) have hdecode : ∀ a, decode (code ε (w a)) = rounded ε (w a) := by intro a funext idx simp only [decode, code, rounded, roundUp] split_ifs <;> rfl have himage : A.image (fun a => rounded ε (w a)) = (A.image (fun a => code ε (w a))).image decode := by rw [Finset.image_image] exact Finset.image_congr fun a _ => (hdecode a).symm have hsub : A.image (fun a => code ε (w a)) ⊆ Fintype.piFinset (fun _ : Fin (L + 1) => Finset.range (⌈1 / ε⌉₊ + 1)) := by intro c hc obtain ⟨a, ha, rfl⟩ := Finset.mem_image.mp hc apply Fintype.mem_piFinset.mpr intro idx apply Finset.mem_range.mpr by_cases hi0 : idx.val = 0 · simp [Erdos416Proof.CollisionBox.rounded_zero, code, hi0] · have hceil := Nat.ceil_mono (div_le_div_of_nonneg_right (hw a ha idx (Nat.pos_of_ne_zero hi0)) hε.le) simpa only [code, hi0, ↓reduceIte] using Nat.lt_succ_of_le hceil rw [himage] exact (Finset.card_image_le).trans ((Finset.card_le_card hsub).trans_eq (by simp[Erdos416Proof.CollisionBox.rounded_zero] )) /-- Adding the actual last high index costs only the finite number of indices. -/ /- Original line 23096: Erdos416Proof.CollisionBox.prefix_label_image_card -/ theorem prefix_label_image_card {α : Type*} [DecidableEq α] (A : Finset α) (w : α → Fin (L + 1) → ℝ) (J : α → Fin (L + 1)) (hε : 0 < ε) (hw : ∀ a ∈ A, ∀ idx, 0 < idx.val → w a idx ≤ 1) : (A.image (fun a => (J a, rounded ε (w a)))).card ≤ (L + 1) * (⌈1 / ε⌉₊ + 1) ^ (L + 1) := by classical have hsub : A.image (fun a => (J a, rounded ε (w a))) ⊆ Finset.univ ×ˢ (A.image (fun a => rounded ε (w a))) := by intro z hz obtain ⟨a, ha, rfl⟩ := Finset.mem_image.mp hz exact Finset.mem_product.mpr ⟨Finset.mem_univ _, Finset.mem_image.mpr ⟨a, ha, rfl⟩⟩ calc _ ≤ (Finset.univ ×ˢ (A.image (fun a => rounded ε (w a)))).card := Finset.card_le_card hsub _ = (L + 1) * (A.image (fun a => rounded ε (w a))).card := by simp[Erdos416Proof.CollisionBox.rounded_zero] _ ≤ _ := Nat.mul_le_mul_left _ (rounded_image_card A w hε hw) /- Original line 23113: Erdos416Proof.CollisionBox.coordinateError -/ noncomputable def coordinateError (c T : ℝ) : ℝ := Real.log (c * T) / T /- Original line 23115: Erdos416Proof.CollisionBox.coordinateError_littleO -/ theorem coordinateError_littleO {c a : ℝ} (hc : 0 < c) (ha : -1 < a) : coordinateError c =o[atTop] (fun T : ℝ => T ^ a) := by have h := ((log_pow_mul_rpow_littleO 0 ha).const_mul_left (Real.log c)).add (log_pow_mul_rpow_littleO 1 ha) refine h.congr' ?_ (Eventually.of_forall fun _ => rfl) filter_upwards [eventually_gt_atTop (0 : ℝ)] with T hT simp only [coordinateError, pow_zero, one_mul, pow_one, Real.rpow_neg_one, Real.log_mul hc.ne' hT.ne'] ring /- Original line 23125: Erdos416Proof.CollisionBox.coordinateLoss_littleO -/ theorem coordinateLoss_littleO {c a : ℝ} (hc : 0 < c) (ha : (-2 / 5 : ℝ) < a) : (fun T : ℝ => 10 * T ^ (-2 / 5 : ℝ) + 1 / T + coordinateError c T) =o[atTop] (fun T : ℝ => T ^ a) := by have h₁ := (log_pow_mul_rpow_littleO 0 ha).const_mul_left (10 : ℝ) have h₂ := log_pow_mul_rpow_littleO 0 (show (-1 : ℝ) < a by linarith) simpa only [pow_zero, one_mul, Real.rpow_neg_one, one_div] using (h₁.add h₂).add (coordinateError_littleO hc (show -1 < a by linarith)) /-- All numerical gap conditions are uniform in the original prime tuple. The contraction coefficient and the bound on the second coordinate are fixed. -/ /- Original line 23135: Erdos416Proof.CollisionBox.coordinate_scales_eventually -/ theorem coordinate_scales_eventually {g θ : ℝ} (hg : 0 < g) (hθ : θ < 1) : ∀ᶠ T : ℝ in atTop, 0 < T ^ (-1 / 3 : ℝ) ∧ 0 < 1 / T ∧ 0 < T ^ (-2 / 5 : ℝ) ∧ 10 * T ^ (-2 / 5 : ℝ) + 1 / T + coordinateError 5 T ≤ g * T ^ (-1 / 3 : ℝ) ∧ 10 * T ^ (-2 / 5 : ℝ) + 1 / T + coordinateError 6 T ≤ 1 - θ ∧ 4 * T ^ (-2 / 5 : ℝ) ≤ T ^ (-1 / 3 : ℝ) := by have hlower := (coordinateLoss_littleO (by norm_num : (0 : ℝ) < 5) (by norm_num : (-2 / 5 : ℝ) < -1 / 3)).def hg have hhead := (coordinateLoss_littleO (by norm_num : (0 : ℝ) < 6) (by norm_num : (-2 / 5 : ℝ) < 0)).def (sub_pos.mpr hθ) have htail := ((log_pow_mul_rpow_littleO 0 (by norm_num : (-2 / 5 : ℝ) < -1 / 3)).const_mul_left (4 : ℝ)).def (by norm_num : (0 : ℝ) < 1) filter_upwards [hlower, hhead, htail, eventually_gt_atTop (0 : ℝ)] with T hlower hhead htail hT have hb := Real.rpow_pos_of_pos hT (-1 / 3 : ℝ) have hh := Real.rpow_pos_of_pos hT (-2 / 5 : ℝ) simp only [Real.norm_eq_abs, abs_of_pos hb] at hlower simp only [Real.rpow_zero, Real.norm_eq_abs, abs_one, mul_one] at hhead simp only [pow_zero, one_mul, Real.norm_eq_abs, abs_of_pos hb] at htail refine ⟨hb, one_div_pos.mpr hT, hh, ?_, ?_, ?_⟩ · exact (le_abs_self _).trans hlower · exact (le_abs_self _).trans hhead · exact (le_abs_self _).trans htail /-- Exact real cutoffs associated to a normalized double-logarithm coordinate. -/ /- Original line 23162: Erdos416Proof.CollisionBox.cutoff -/ noncomputable def cutoff (Y ν : ℝ) : ℝ := Real.exp ((Real.log Y) ^ ν) /- Original line 23164: Erdos416Proof.CollisionBox.logLog_cutoff -/ theorem logLog_cutoff {Y : ℝ} (hY : 1 < Y) (ν : ℝ) : logLog (cutoff Y ν) = ν * logLog Y := by simp only [cutoff, logLog, Real.log_exp, Real.log_rpow (Real.log_pos hY)] /- Original line 23168: Erdos416Proof.CollisionBox.normalized_cutoff -/ theorem normalized_cutoff {Y : ℝ} (hY : 1 < Y) (hT : logLog Y ≠ 0) (ν : ℝ) : logLog (cutoff Y ν) / logLog Y = ν := by rw [logLog_cutoff hY, mul_div_cancel_right₀ _ hT] /- Original line 23172: Erdos416Proof.CollisionBox.cutoff_one -/ theorem cutoff_one {Y : ℝ} (hY : 1 < Y) : cutoff Y 1 = Y := by simp only [cutoff, Real.rpow_one, Real.exp_log (by linarith : 0 < Y)] /- Original line 23175: Erdos416Proof.CollisionBox.cutoff_strictMono -/ theorem cutoff_strictMono {Y : ℝ} (hY : Real.exp 1 < Y) : StrictMono (cutoff Y) := by have hlog : 1 < Real.log Y := by have := Real.log_lt_log (Real.exp_pos 1) hY simpa only [Real.log_exp] using this intro a b hab exact Real.exp_lt_exp.mpr (Real.rpow_lt_rpow_of_exponent_lt hlog hab) /-- Adjacent geometric gaps imply the quantitative contraction used above. -/ /- Original line 23183: Erdos416Proof.CollisionBox.contraction_of_adjacent -/ theorem contraction_of_adjacent {x : Fin (L + 1) → ℝ} {κ : ℝ} (hκ : 0 < κ) (hanti : Antitone x) (hstep : ∀ idx : Fin (L + 1), 0 < idx.val → ∀ hi : idx.val + 1 < L + 1, κ * x ⟨idx.val + 1, hi⟩ ≤ x idx) : ∀ idx j, 0 < idx.val → idx < j → (1 - 1 / κ) * x idx ≤ x idx - x j := by intro idx j hi hij have hn : idx.val + 1 < L + 1 := by omega have hnext : (⟨idx.val + 1, hn⟩ : Fin (L + 1)) ≤ j := hij have hx := hanti hnext have hs := hstep idx hi hn have hdiv : x j ≤ x idx / κ := by apply (le_div_iff₀ hκ).mpr nlinarith calc (1 - 1 / κ) * x idx = x idx - x idx / κ := by ring _ ≤ x idx - x j := sub_le_sub_left hdiv _ /- Original line 23200: Erdos416Proof.CollisionBox.primeCoordinate -/ noncomputable def primeCoordinate (T : ℝ) (p : ℕ) : ℝ := logLog p / T /- Original line 23202: Erdos416Proof.CollisionBox.shiftedCoordinate -/ noncomputable def shiftedCoordinate (T : ℝ) (p : ℕ) : ℝ := logLog (largestPrimeFactor (p - 1)) / T /- Original line 23205: Erdos416Proof.CollisionBox.shiftedCoordinate_le -/ theorem shiftedCoordinate_le {T : ℝ} (hT : 0 < T) {p : ℕ} (hp : 17 ≤ p) : shiftedCoordinate T p ≤ primeCoordinate T p := by apply div_le_div_of_nonneg_right _ hT.le apply logLog_mono (by exact_mod_cast largestPrimeFactor_one_lt (show 1 < p - 1 by omega)) exact_mod_cast (largestPrimeFactor_le (by omega : 0 < p - 1)).trans (Nat.sub_le p 1) /-- At the actual scale, normality supplies all coordinate approximations. The remaining hypotheses concern the original prime tuple: ordinary ordering, adjacent geometric gaps, size, a large top prime and a fixed final prime bound. -/ /- Original line 23214: Erdos416Proof.CollisionBox.prime_data_eventually -/ theorem prime_data_eventually (c P κ θ : ℝ) (hκ : 1 < κ) (hθ : θ < 1) : ∀ᶠ T : ℝ in atTop, ∀ L : ℕ, ∀ p : Fin (L + 1) → ℕ, (∀ idx, SNormal (normalityScale T) (p idx)) → (∀ idx, 17 ≤ p idx) → (∀ idx, (p idx : ℝ) ≤ c * Real.exp (Real.exp T) * T) → Antitone p → (∀ idx : Fin (L + 1), 0 < idx.val → ∀ hi : idx.val + 1 < L + 1, κ * logLog (p ⟨idx.val + 1, hi⟩) ≤ logLog (p idx)) → (∀ idx, 0 < idx.val → (p idx : ℝ) ≤ cutoff (Real.exp (Real.exp T)) θ) → (p (Fin.last L) : ℝ) ≤ P → (Real.exp (Real.exp T)) ^ (9 / 10 : ℝ) < (p 0 : ℝ) → ((p 0 - 1 : ℕ) : ℝ) ≤ Real.exp (Real.exp T) → Data (fun idx => primeCoordinate T (p idx)) (fun idx => shiftedCoordinate T (p idx)) (T ^ (-1 / 3 : ℝ)) (coordinateError 5 T) (coordinateError 6 T) (1 / T) (T ^ (-2 / 5 : ℝ)) (1 - 1 / κ) θ := by have hκpos : 0 < κ := by linarith have hg : 0 < 1 - 1 / κ := by have hinv : 1 / κ < (1 : ℝ) := (div_lt_iff₀ hκpos).mpr (by linarith) linarith have hb := (log_pow_mul_rpow_littleO 0 (by norm_num : (-1 / 3 : ℝ) < 0)).def (by norm_num : (0 : ℝ) < 1 / 4) have he := (coordinateError_littleO (by norm_num : (0 : ℝ) < 6) (by norm_num : (-1 : ℝ) < 0)).def (by norm_num : (0 : ℝ) < 1 / 4) have hp := ((log_pow_mul_rpow_littleO 0 (by norm_num : (-1 : ℝ) < -1 / 3)).const_mul_left (logLog P)).def (by norm_num : (0 : ℝ) < 1) filter_upwards [coordinate_scales_eventually hg hθ, normality_largestPrimeFactor_eventually c, hb, he, hp, eventually_gt_atTop (0 : ℝ)] with T hs hnormal hb he hp hT intro L p hpn hp17 hpsize horder hstep hlower hlast htop hsize have hY : 1 < Real.exp (Real.exp T) := Real.one_lt_exp_iff.mpr (Real.exp_pos T) have hLLY : logLog (Real.exp (Real.exp T)) = T := by simp only [logLog, Real.log_exp] have hgap : ∀ idx, logLog (p idx) - logLog (largestPrimeFactor (p idx - 1)) ≤ Real.log (5 * T) := fun idx => (hnormal (p idx) (hpn idx) (hp17 idx) (hpsize idx)).2.2 have hLP : ∀ idx, 1 < (largestPrimeFactor (p idx - 1) : ℝ) := by intro idx exact_mod_cast largestPrimeFactor_one_lt (show 1 < p idx - 1 by have := hp17 idx; omega) have hLPle : ∀ idx, (largestPrimeFactor (p idx - 1) : ℝ) ≤ (p idx - 1 : ℕ) := by intro idx exact_mod_cast largestPrimeFactor_le (show 0 < p idx - 1 by have := hp17 idx; omega) have hxanti : Antitone (fun idx => primeCoordinate T (p idx)) := by intro idx j hij apply div_le_div_of_nonneg_right _ hT.le apply logLog_mono (by have := hp17 j; norm_cast; omega) exact_mod_cast horder hij have hxstep : ∀ idx : Fin (L + 1), 0 < idx.val → ∀ hi : idx.val + 1 < L + 1, κ * primeCoordinate T (p ⟨idx.val + 1, hi⟩) ≤ primeCoordinate T (p idx) := by intro idx hi hn simpa only [primeCoordinate, mul_div_assoc] using div_le_div_of_nonneg_right (hstep idx hi hn) hT.le have hheadApprox : 1 - coordinateError 6 T ≤ shiftedCoordinate T (p 0) := by have hpow : logLog ((Real.exp (Real.exp T)) ^ (9 / 10 : ℝ)) = Real.log (9 / 10 : ℝ) + T := by simp only [logLog, Real.log_rpow (Real.exp_pos _), Real.log_exp, Real.log_mul (by norm_num : (9 / 10 : ℝ) ≠ 0) (Real.exp_ne_zero T)] have hbig := logLog_mono (Real.one_lt_rpow hY (by norm_num : (0 : ℝ) < 9 / 10)) htop.le rw [hpow] at hbig have hlog := Real.log_le_log (by positivity : (0 : ℝ) < 5 * T) (show 5 * T ≤ (9 / 10 : ℝ) * (6 * T) by nlinarith) rw [Real.log_mul (by norm_num : (9 / 10 : ℝ) ≠ 0) (by positivity : 6 * T ≠ 0)] at hlog have hg0 := hgap 0 change 1 - Real.log (6 * T) / T ≤ logLog (largestPrimeFactor (p 0 - 1)) / T apply (le_div_iff₀ hT).mpr have hid : (1 - Real.log (6 * T) / T) * T = T - Real.log (6 * T) := by field_simp rw [hid] linarith simp only [pow_zero, one_mul, Real.rpow_zero, Real.norm_eq_abs, abs_one, mul_one] at hb he simp only [pow_zero, one_mul, Real.rpow_neg_one, Real.norm_eq_abs, abs_of_pos hs.1] at hp rw [← div_eq_mul_inv] at hp have hhead : T ^ (-1 / 3 : ℝ) < shiftedCoordinate T (p 0) := by have hb' := (le_abs_self _).trans hb have he' := (le_abs_self _).trans he linarith have htail : shiftedCoordinate T (p (Fin.last L)) ≤ T ^ (-1 / 3 : ℝ) := by have hnat : ((p (Fin.last L) - 1 : ℕ) : ℝ) ≤ p (Fin.last L) := by exact_mod_cast Nat.sub_le (p (Fin.last L)) 1 have hLL := logLog_mono (hLP (Fin.last L)) ((hLPle (Fin.last L)).trans (hnat.trans hlast)) exact (div_le_div_of_nonneg_right hLL hT.le).trans ((le_abs_self _).trans hp) refine ⟨hs.1, hs.2.1, hs.2.2.1, hg.le, hxanti, (fun idx => shiftedCoordinate_le hT (hp17 idx)), ?_, contraction_of_adjacent hκpos hxanti hxstep, ?_, hhead, ?_, hheadApprox, htail, hs.2.2.2.1, hs.2.2.2.2.1, hs.2.2.2.2.2⟩ · intro idx _ have hi := div_le_div_of_nonneg_right (hgap idx) hT.le rw [sub_div] at hi dsimp only [primeCoordinate, coordinateError, shiftedCoordinate] linarith · intro idx hi have hpone : (1 : ℝ) < p idx := by have := hp17 idx; norm_cast; omega have hLL := logLog_mono hpone (hlower idx hi) rw [logLog_cutoff hY, hLLY] at hLL exact (div_le_div_of_nonneg_right hLL hT.le).trans_eq (mul_div_cancel_right₀ θ hT.ne') · have hLL := logLog_mono (hLP 0) ((hLPle 0).trans hsize) rw [hLLY] at hLL exact (div_le_div_of_nonneg_right hLL hT.le).trans_eq (div_self hT.ne') /- Original line 23313: Erdos416Proof.CollisionBox.largest_lt_of_shiftedCoordinate_lt -/ theorem largest_lt_of_shiftedCoordinate_lt {T : ℝ} (hT : 0 < T) {p q : ℕ} (hq : 17 ≤ q) (hcoord : shiftedCoordinate T p < shiftedCoordinate T q) : largestPrimeFactor (p - 1) < largestPrimeFactor (q - 1) := by by_contra hn have hle : largestPrimeFactor (q - 1) ≤ largestPrimeFactor (p - 1) := le_of_not_gt hn have hLL : logLog (largestPrimeFactor (q - 1)) ≤ logLog (largestPrimeFactor (p - 1)) := logLog_mono (by exact_mod_cast largestPrimeFactor_one_lt (show 1 < q - 1 by omega)) (by exact_mod_cast hle) exact (not_lt_of_ge (div_le_div_of_nonneg_right hLL hT.le)) hcoord /-- The ordering required by the matching theorem is derived at each high position. No ordering hypothesis on the whole shifted-factor list is added. -/ /- Original line 23325: Erdos416Proof.CollisionBox.Data.rankedAt_shifted -/ theorem Data.rankedAt_shifted {T : ℝ} (hT : 0 < T) {p : Fin (L + 1) → ℕ} (hp : ∀ idx, 17 ≤ p idx) (d : Data x (fun idx => shiftedCoordinate T (p idx)) b e e₀ ε h g θ) {idx : Fin (L + 1)} (hi : b < shiftedCoordinate T (p idx)) : RankedAt (fun j => largestPrimeFactor (p j - 1)) idx := by have hh := d.gap_pos have hε := d.mesh_pos constructor · intro j hji rcases lt_or_eq_of_le hji with hji | rfl · have hg := d.gap_after_high (d.high_before hi hji.le) hji exact (largest_lt_of_shiftedCoordinate_lt hT (hp j) (by linarith)).le · exact le_rfl · intro j hij rcases lt_or_eq_of_le hij with hij | rfl · have hg := d.gap_after_high hi hij exact (largest_lt_of_shiftedCoordinate_lt hT (hp idx) (by linarith)).le · exact le_rfl /-- The actual number of index-and-grid labels has logarithm `O((log T)^2)` throughout the allowed dimension range. -/ /- Original line 23346: Erdos416Proof.CollisionBox.grid_card_bound -/ theorem grid_card_bound {A T : ℝ} (hT : Real.exp 1 ≤ T) (hL : (L : ℝ) ≤ A * Real.log T) : (((L + 1) * (⌈T⌉₊ + 1) ^ (L + 1) : ℕ) : ℝ) ≤ Real.exp (3 * (A + 1) * Real.log T ^ 2) := by have hT2 : (2 : ℝ) ≤ T := by linarith [Real.add_one_le_exp (1 : ℝ)] have hTpos : 0 < T := by linarith have hlog : 1 ≤ Real.log T := by have := Real.log_le_log (Real.exp_pos 1) hT simpa only [Real.log_exp] using this have hB : (0 : ℝ) < (⌈T⌉₊ + 1 : ℕ) := by positivity have hB2 : ((⌈T⌉₊ + 1 : ℕ) : ℝ) ≤ T * T := by have hc := Nat.ceil_lt_add_one hTpos.le push_cast nlinarith have hlogB : Real.log ((⌈T⌉₊ + 1 : ℕ) : ℝ) ≤ 2 * Real.log T := by have := Real.log_le_log hB hB2 rw [Real.log_mul hTpos.ne' hTpos.ne'] at this linarith have hL' : ((L + 1 : ℕ) : ℝ) ≤ (A + 1) * Real.log T := by push_cast nlinarith have hdim : (0 : ℝ) ≤ (L + 1 : ℕ) := by positivity have hexp : ((L + 1 : ℕ) : ℝ) + ((L + 1 : ℕ) : ℝ) * Real.log ((⌈T⌉₊ + 1 : ℕ) : ℝ) ≤ 3 * (A + 1) * Real.log T ^ 2 := by have h₁ := mul_le_mul_of_nonneg_left hlogB hdim have h₂ := mul_le_mul_of_nonneg_right hL' (show 0 ≤ 3 * Real.log T by linarith) have h₃ := mul_le_mul_of_nonneg_left hlog hdim nlinarith calc _ = ((L + 1 : ℕ) : ℝ) * ((⌈T⌉₊ + 1 : ℕ) : ℝ) ^ (L + 1) := by push_cast; rfl _ ≤ Real.exp ((L + 1 : ℕ) : ℝ) * Real.exp (((L + 1 : ℕ) : ℝ) * Real.log ((⌈T⌉₊ + 1 : ℕ) : ℝ)) := by rw [Real.exp_nat_mul, Real.exp_log hB] apply mul_le_mul_of_nonneg_right _ (by positivity) linarith [Real.add_one_le_exp (((L + 1 : ℕ) : ℝ))] _ = Real.exp (((L + 1 : ℕ) : ℝ) + ((L + 1 : ℕ) : ℝ) * Real.log ((⌈T⌉₊ + 1 : ℕ) : ℝ)) := by rw [Real.exp_add] _ ≤ _ := Real.exp_le_exp.mpr hexp /- Original line 23385: Erdos416Proof.CollisionBox.prefix_label_image_card_scale -/ theorem prefix_label_image_card_scale {α : Type*} [DecidableEq α] (F : Finset α) (w : α → Fin (L + 1) → ℝ) (J : α → Fin (L + 1)) {A T : ℝ} (hT : Real.exp 1 ≤ T) (hL : (L : ℝ) ≤ A * Real.log T) (hw : ∀ a ∈ F, ∀ idx, 0 < idx.val → w a idx ≤ 1) : ((F.image (fun a => (J a, rounded (1 / T) (w a)))).card : ℝ) ≤ Real.exp (3 * (A + 1) * Real.log T ^ 2) := by have hTpos : 0 < T := (Real.exp_pos 1).trans_le hT have hc := prefix_label_image_card F w J (one_div_pos.mpr hTpos) hw simp only [one_div_one_div] at hc exact (show ((F.image (fun a => (J a, rounded (1 / T) (w a)))).card : ℝ) ≤ (((L + 1) * (⌈T⌉₊ + 1) ^ (L + 1) : ℕ) : ℝ) by exact_mod_cast hc).trans (grid_card_bound hT hL) end Erdos416Proof.CollisionBox /- Actual surviving-index sieve cutoffs, their uniform numerical margins, and all cutoff hypotheses at the original real endpoint. -/ open Filter Finset open scoped Topology BigOperators namespace Erdos416Proof.CollisionCutoff variable {k L : ℕ} /-- The actual upper coordinates, extended constantly after the tail. -/ /- Original line 23417: Erdos416Proof.CollisionCutoff.nu -/ noncomputable def nu (L : ℕ) (δ : ℝ) (z : Fin k → ℝ) (zstar : ℝ) (idx : ℕ) : ℝ := if idx = 0 then 1 else if hi : idx < k then z ⟨idx, hi⟩ + (2 * L + 1) * δ else zstar + (2 * L + 3) * δ /- Original line 23421: Erdos416Proof.CollisionCutoff.mu -/ noncomputable def mu (L : ℕ) (δ ε : ℝ) (z : Fin k → ℝ) (zstar : ℝ) (idx : ℕ) : ℝ := nu L δ z zstar idx - (4 * L + 2) * δ - ε /- Original line 23424: Erdos416Proof.CollisionCutoff.upper -/ noncomputable def upper (Y : ℝ) (L : ℕ) (δ : ℝ) (z : Fin k → ℝ) (zstar : ℝ) (idx : ℕ) : ℝ := CollisionBox.cutoff Y (nu L δ z zstar idx) /- Original line 23427: Erdos416Proof.CollisionCutoff.lower -/ noncomputable def lower (Y : ℝ) (L : ℕ) (δ ε : ℝ) (z : Fin k → ℝ) (zstar : ℝ) (idx : ℕ) : ℝ := CollisionBox.cutoff Y (mu L δ ε z zstar idx) /- Original line 23430: Erdos416Proof.CollisionCutoff.nu_zero -/ theorem nu_zero (L : ℕ) (δ : ℝ) (z : Fin k → ℝ) (zstar : ℝ) : nu L δ z zstar 0 = 1 := by simp [nu] /- Original line 23433: Erdos416Proof.CollisionCutoff.nu_internal -/ theorem nu_internal (L : ℕ) (δ : ℝ) (z : Fin k → ℝ) (zstar : ℝ) {idx : ℕ} (hi : 0 < idx) (hik : idx < k) : nu L δ z zstar idx = z ⟨idx, hik⟩ + (2 * L + 1) * δ := by rw [nu, if_neg (ne_of_gt hi), dif_pos hik] /- Original line 23438: Erdos416Proof.CollisionCutoff.nu_tail -/ theorem nu_tail (L : ℕ) (δ : ℝ) (z : Fin k → ℝ) (zstar : ℝ) (hk : 1 ≤ k) {idx : ℕ} (hi : k ≤ idx) : nu L δ z zstar idx = zstar + (2 * L + 3) * δ := by rw [nu, if_neg (show idx ≠ 0 by omega), dif_neg (not_lt.mpr hi)] /-- The coordinates obtained by retaining the actual uncanceled indices. -/ /- Original line 23444: Erdos416Proof.CollisionCutoff.Selected -/ structure Selected (z : Fin k → ℝ) (zstar ε h b θ : ℝ) : Prop where head : ∀ idx, idx.val = 0 → z idx = 1 internal_upper : ∀ idx, 0 < idx.val → z idx ≤ θ + ε separation : ∀ idx j, idx < j → 10 * h ≤ z idx - z j tail_gap : ∀ idx, 2 * h ≤ z idx - zstar tail_lower : b / 2 ≤ zstar tail_upper : zstar ≤ b /- Original line 23452: Erdos416Proof.CollisionCutoff.selectedIndex -/ noncomputable def selectedIndex (J : Fin (L + 1)) (C : Finset (Fin (J.val + 1))) (idx : Fin (CollisionClass.remaining C).card) : Fin (L + 1) := Fin.castLE (by have := J.isLt; omega) (CollisionClass.index C idx) /- Original line 23456: Erdos416Proof.CollisionCutoff.selectedIndex_le -/ theorem selectedIndex_le (J : Fin (L + 1)) (C : Finset (Fin (J.val + 1))) (idx : Fin (CollisionClass.remaining C).card) : selectedIndex J C idx ≤ J := by have hj := (CollisionClass.index C idx).isLt change (CollisionClass.index C idx).val ≤ J.val omega /- Original line 23462: Erdos416Proof.CollisionCutoff.selectedIndex_strictMono -/ theorem selectedIndex_strictMono (J : Fin (L + 1)) (C : Finset (Fin (J.val + 1))) : StrictMono (selectedIndex J C) := by intro idx j hij exact CollisionClass.index_strictMono C hij /- Original line 23467: Erdos416Proof.CollisionCutoff.selectedIndex_val_ge -/ theorem selectedIndex_val_ge (J : Fin (L + 1)) (C : Finset (Fin (J.val + 1))) (idx : Fin (CollisionClass.remaining C).card) : idx.val ≤ (selectedIndex J C idx).val := CollisionClass.index_val_ge C idx /- Original line 23471: Erdos416Proof.CollisionCutoff.selectedIndex_first -/ theorem selectedIndex_first (J : Fin (L + 1)) (C : Finset (Fin (J.val + 1))) (hzero : ∀ j : Fin (J.val + 1), j.val = 0 → j ∉ C) (idx : Fin (CollisionClass.remaining C).card) (hi : idx.val = 0) : selectedIndex J C idx = 0 := Fin.ext (CollisionClass.index_first C hzero idx hi) /- Original line 23477: Erdos416Proof.CollisionCutoff.selectedZeta -/ noncomputable def selectedZeta (J : Fin (L + 1)) (C : Finset (Fin (J.val + 1))) (ε : ℝ) (w : Fin (L + 1) → ℝ) (idx : Fin (CollisionClass.remaining C).card) : ℝ := CollisionBox.rounded ε w (selectedIndex J C idx) /- Original line 23481: Erdos416Proof.CollisionCutoff.selected_of_boxes -/ theorem selected_of_boxes {x w : Fin (L + 1) → ℝ} {b e e₀ ε h g θ : ℝ} (d : CollisionBox.Data x w b e e₀ ε h g θ) (J : Fin (L + 1)) (hJ : b < w J) (hlast : ∀ j, J < j → w j ≤ b) (C : Finset (Fin (J.val + 1))) (hzero : ∀ j : Fin (J.val + 1), j.val = 0 → j ∉ C) : Selected (selectedZeta J C ε w) (CollisionBox.tailCoordinate ε h b w J) ε h b θ := by have hhigh : ∀ idx, b < w (selectedIndex J C idx) := fun idx => d.high_before hJ (selectedIndex_le J C idx) have htail := d.tail_bounds hJ hlast refine ⟨?_, ?_, ?_, ?_, htail.1, htail.2.1⟩ · intro idx hi simp only [selectedZeta, selectedIndex_first J C hzero idx hi, CollisionBox.rounded_zero] · intro idx hi have hpos : 0 < (selectedIndex J C idx).val := lt_of_lt_of_le hi (selectedIndex_val_ge J C idx) have hr := (d.rounded_bounds (hhigh idx)).2 hpos have hx := d.lower_upper (selectedIndex J C idx) hpos have hw := d.shifted_le (selectedIndex J C idx) change CollisionBox.rounded ε w (selectedIndex J C idx) ≤ θ + ε linarith · intro idx j hij exact d.rounded_gap (hhigh idx) (hhigh j) (selectedIndex_strictMono J C hij) · intro idx have hle : CollisionBox.rounded ε w J ≤ selectedZeta J C ε w idx := by rcases lt_or_eq_of_le (selectedIndex_le J C idx) with hi | hi · have hg := d.rounded_gap (hhigh idx) hJ hi have hh := d.gap_pos change CollisionBox.rounded ε w J ≤ CollisionBox.rounded ε w (selectedIndex J C idx) linarith · simp only [selectedZeta, hi, le_refl] have hg := htail.2.2.1 linarith /-- Numerical margins at a fixed scale. An eventual theorem below supplies these uniformly over every permitted dimension. -/ /- Original line 23515: Erdos416Proof.CollisionCutoff.Margins -/ structure Margins (L : ℕ) (δ ε h b θ T : ℝ) : Prop where scale_pos : 0 < T delta_nonneg : 0 ≤ δ mesh_pos : 0 < ε gap_pos : 0 < h budget : (4 * L + 4) * δ + ε ≤ h first_internal : θ + 2 * ε + (6 * L + 3) * δ < 1 first_tail : b + ε + (6 * L + 5) * δ < 1 short_internal : θ + ε + (2 * L + 1) * δ + CollisionBox.coordinateError 10 T ≤ 1 short_tail : b + (2 * L + 3) * δ + CollisionBox.coordinateError 10 T ≤ 1 normality : Real.log T ^ 10 ≤ b * T / 2 variable {δ ε h b θ T zstar : ℝ} {z : Fin k → ℝ} /- Original line 23529: Erdos416Proof.CollisionCutoff.Margins.width_nonneg -/ theorem Margins.width_nonneg (m : Margins L δ ε h b θ T) : 0 ≤ (4 * L + 2) * δ + ε := by have hL : (0 : ℝ) ≤ L := Nat.cast_nonneg L have hd := m.delta_nonneg have he := m.mesh_pos positivity /- Original line 23535: Erdos416Proof.CollisionCutoff.nu_step_gap -/ theorem nu_step_gap (s : Selected z zstar ε h b θ) (m : Margins L δ ε h b θ T) (hk : 1 ≤ k) {idx : ℕ} (hi : idx < k) : (4 * L + 2) * δ + ε < nu L δ z zstar idx - nu L δ z zstar (idx + 1) := by have hL : (0 : ℝ) ≤ L := Nat.cast_nonneg L have hd := m.delta_nonneg have hh := m.gap_pos have hb := m.budget by_cases hi0 : idx = 0 · subst idx rw [nu_zero] by_cases hnext : 1 < k · rw [show 0 + 1 = 1 by omega, nu_internal L δ z zstar (by omega) hnext] have hs := s.internal_upper ⟨1, hnext⟩ (by norm_num) have hm := m.first_internal nlinarith · rw [nu_tail L δ z zstar hk (by omega)] have hs := s.tail_upper have hm := m.first_tail nlinarith · have hip : 0 < idx := Nat.pos_of_ne_zero hi0 rw [nu_internal L δ z zstar hip hi] by_cases hnext : idx + 1 < k · rw [nu_internal L δ z zstar (by omega) hnext] have hs := s.separation ⟨idx, hi⟩ ⟨idx + 1, hnext⟩ (by exact Nat.lt_succ_self idx) nlinarith · rw [nu_tail L δ z zstar hk (by omega)] have hs := s.tail_gap ⟨idx, hi⟩ nlinarith /- Original line 23564: Erdos416Proof.CollisionCutoff.nu_antitone -/ theorem nu_antitone (s : Selected z zstar ε h b θ) (m : Margins L δ ε h b θ T) (hk : 1 ≤ k) : Antitone (nu L δ z zstar) := by apply antitone_nat_of_succ_le intro idx by_cases hi : idx < k · have hg := nu_step_gap s m hk hi have hw := m.width_nonneg linarith · rw [nu_tail L δ z zstar hk (le_of_not_gt hi), nu_tail L δ z zstar hk (by omega)] /- Original line 23574: Erdos416Proof.CollisionCutoff.nu_gap -/ theorem nu_gap (s : Selected z zstar ε h b θ) (m : Margins L δ ε h b θ T) (hk : 1 ≤ k) {idx : ℕ} (hi : 1 ≤ idx) (hik : idx ≤ k) : δ ≤ nu L δ z zstar (idx - 1) - nu L δ z zstar idx := by have hg := nu_step_gap s m hk (show idx - 1 < k by omega) rw [Nat.sub_add_cancel hi] at hg have hL : (0 : ℝ) ≤ L := Nat.cast_nonneg L have hd := m.delta_nonneg have he := m.mesh_pos nlinarith /- Original line 23584: Erdos416Proof.CollisionCutoff.mu_le_nu -/ theorem mu_le_nu (m : Margins L δ ε h b θ T) (idx : ℕ) : mu L δ ε z zstar idx ≤ nu L δ z zstar idx := by have hw := m.width_nonneg dsimp only [mu] linarith /- Original line 23590: Erdos416Proof.CollisionCutoff.nu_next_lt_mu -/ theorem nu_next_lt_mu (s : Selected z zstar ε h b θ) (m : Margins L δ ε h b θ T) (hk : 1 ≤ k) {idx : ℕ} (hi : idx < k) : nu L δ z zstar (idx + 1) < mu L δ ε z zstar idx := by have hg := nu_step_gap s m hk hi dsimp only [mu] linarith /- Original line 23597: Erdos416Proof.CollisionCutoff.nu_one_short -/ theorem nu_one_short (s : Selected z zstar ε h b θ) (m : Margins L δ ε h b θ T) (hk : 1 ≤ k) : nu L δ z zstar 1 + CollisionBox.coordinateError 10 T ≤ 1 := by by_cases h1 : 1 < k · rw [nu_internal L δ z zstar (by omega) h1] have hs := s.internal_upper ⟨1, h1⟩ (by norm_num) have hm := m.short_internal linarith · rw [nu_tail L δ z zstar hk (by omega)] have hs := s.tail_upper have hm := m.short_tail linarith /- Original line 23609: Erdos416Proof.CollisionCutoff.margins_eventually -/ theorem margins_eventually (A θ : ℝ) (hθ : θ < 1) : ∀ᶠ T : ℝ in atTop, ∀ L : ℕ, (L : ℝ) ≤ A * Real.log T → Margins L (normalityDelta T) (1 / T) (T ^ (-2 / 5 : ℝ)) (T ^ (-1 / 3 : ℝ)) θ T := by have hdim := dimension_delta_small (A + 1) (by norm_num : (0 : ℝ) < 1 / 8) have heps := (log_pow_mul_rpow_littleO 0 (by norm_num : (-1 : ℝ) < -2 / 5)).def (by norm_num : (0 : ℝ) < 1 / 2) have hsmall := log_pow_mul_rpow_littleO 0 (by norm_num : (-2 / 5 : ℝ) < 0) have hquarter := hsmall.def (by norm_num : (0 : ℝ) < 1 / 4) have htheta := hsmall.def (show 0 < (1 - θ) / 4 by linarith) have hb := (log_pow_mul_rpow_littleO 0 (by norm_num : (-1 / 3 : ℝ) < 0)).def (by norm_num : (0 : ℝ) < 1 / 4) have herr := CollisionBox.coordinateError_littleO (by norm_num : (0 : ℝ) < 10) (by norm_num : (-1 : ℝ) < 0) have herrq := herr.def (by norm_num : (0 : ℝ) < 1 / 4) have herrθ := herr.def (show 0 < (1 - θ) / 4 by linarith) have hnormal := (log_pow_mul_rpow_littleO 10 (by norm_num : (0 : ℝ) < 2 / 3)).def (by norm_num : (0 : ℝ) < 1 / 2) filter_upwards [hdim, heps, hquarter, htheta, hb, herrq, herrθ, hnormal, eventually_ge_atTop (Real.exp 1)] with T hdim heps hquarter htheta hb herrq herrθ hnormal hTe have hT1 : 1 ≤ T := by linarith [Real.add_one_le_exp (1 : ℝ)] have hT : 0 < T := by linarith have hlog : 1 ≤ Real.log T := by have hl := Real.log_le_log (Real.exp_pos 1) hTe simpa only [Real.log_exp] using hl have hh : 0 < T ^ (-2 / 5 : ℝ) := Real.rpow_pos_of_pos hT _ have hbpos : 0 < T ^ (-1 / 3 : ℝ) := Real.rpow_pos_of_pos hT _ have heps' : 1 / T ≤ (1 / 2 : ℝ) * T ^ (-2 / 5 : ℝ) := by simpa only [pow_zero, one_mul, Real.rpow_neg_one, Real.norm_eq_abs, abs_of_pos (inv_pos.mpr hT), abs_of_pos hh, one_div] using heps simp only [pow_zero, one_mul, Real.rpow_zero, Real.norm_eq_abs, abs_of_pos hh, abs_one, mul_one] at hquarter htheta simp only [pow_zero, one_mul, Real.rpow_zero, Real.norm_eq_abs, abs_of_pos hbpos, abs_one, mul_one] at hb simp only [Real.rpow_zero, Real.norm_eq_abs, abs_one, mul_one] at herrq herrθ have herrq' := (le_abs_self _).trans herrq have herrθ' := (le_abs_self _).trans herrθ have hnorm : Real.log T ^ 10 ≤ (1 / 2 : ℝ) * T ^ (2 / 3 : ℝ) := by simpa only [Real.rpow_zero, mul_one, Real.norm_eq_abs, abs_of_nonneg (pow_nonneg (Real.log_nonneg hT1) 10), abs_of_pos (Real.rpow_pos_of_pos hT (2 / 3 : ℝ))] using hnormal have hprod : T ^ (-1 / 3 : ℝ) * T = T ^ (2 / 3 : ℝ) := by calc _ = T ^ (-1 / 3 : ℝ) * T ^ (1 : ℝ) := by rw [Real.rpow_one] _ = T ^ ((-1 / 3 : ℝ) + 1) := (Real.rpow_add hT _ _).symm _ = _ := by norm_num intro L hL have hLplus : ((L + 1 : ℕ) : ℝ) ≤ (A + 1) * Real.log T := by push_cast nlinarith have hδ := hdim (L + 1) hLplus simp only [Nat.cast_add, Nat.cast_one] at hδ have hd := normalityDelta_nonneg hT1 have hL0 : (0 : ℝ) ≤ L := Nat.cast_nonneg L refine ⟨hT, hd, one_div_pos.mpr hT, hh, ?_, ?_, ?_, ?_, ?_, ?_⟩ · nlinarith · nlinarith · nlinarith · nlinarith · nlinarith · rw [hprod] linarith /- Original line 23672: Erdos416Proof.CollisionCutoff.cutoff_exp_exp -/ theorem cutoff_exp_exp {Y : ℝ} (hY : 1 < Y) (a : ℝ) : CollisionBox.cutoff Y a = Real.exp (Real.exp (a * logLog Y)) := by rw [CollisionBox.cutoff, Real.rpow_def_of_pos (Real.log_pos hY)] simp only [logLog, mul_comm] /- Original line 23677: Erdos416Proof.CollisionCutoff.cutoff_short -/ theorem cutoff_short {Y a : ℝ} (hY : 1 < Y) (hT : 0 < logLog Y) (ha : a + CollisionBox.coordinateError 10 (logLog Y) ≤ 1) : CollisionBox.cutoff Y a ≤ Y ^ (1 / (10 * logLog Y)) := by change a + Real.log (10 * logLog Y) / logLog Y ≤ 1 at ha have hm := mul_le_mul_of_nonneg_right ha hT.le rw [add_mul, div_mul_cancel₀ _ hT.ne', one_mul] at hm have he : a * logLog Y ≤ logLog Y - Real.log (10 * logLog Y) := by linarith rw [cutoff_exp_exp hY, Real.rpow_def_of_pos (by linarith : 0 < Y)] apply Real.exp_le_exp.mpr calc Real.exp (a * logLog Y) ≤ Real.exp (logLog Y - Real.log (10 * logLog Y)) := Real.exp_le_exp.mpr he _ = Real.exp (logLog Y) / (10 * logLog Y) := by rw [Real.exp_sub, Real.exp_log (by positivity : 0 < 10 * logLog Y)] _ = Real.log Y * (1 / (10 * logLog Y)) := by rw [show Real.exp (logLog Y) = Real.log Y from Real.exp_log (Real.log_pos hY)] ring /-- The exact cutoff interface required by the checked collision-class sieve. -/ /- Original line 23696: Erdos416Proof.CollisionCutoff.SieveCutoffs -/ structure SieveCutoffs (k : ℕ) (Y δ : ℝ) (v W : ℕ → ℝ) : Prop where antitone : Antitone v zero : v 0 = Y interleaving : ∀ idx, idx < k → v (idx + 1) < W idx ∧ W idx ≤ v idx gaps : ∀ idx, 2 ≤ idx → idx ≤ k → δ ≤ logLog (v (idx - 1)) / logLog Y - logLog (v idx) / logLog Y normality : normalityScale (logLog Y) ≤ v k initial : v 1 ≤ Y ^ (1 / (10 * logLog Y)) /- Original line 23704: Erdos416Proof.CollisionCutoff.cutoff_conditions -/ theorem cutoff_conditions {Y : ℝ} (hY : Real.exp 1 < Y) (s : Selected z zstar ε h b θ) (m : Margins L δ ε h b θ (logLog Y)) (hk : 1 ≤ k) : SieveCutoffs k Y δ (upper Y L δ z zstar) (lower Y L δ ε z zstar) := by have hYone : 1 < Y := (Real.one_lt_exp_iff.mpr (by norm_num : (0 : ℝ) < 1)).trans hY have hmono := CollisionBox.cutoff_strictMono hY have hT := m.scale_pos have hcoordinates : ∀ idx, logLog (upper Y L δ z zstar idx) / logLog Y = nu L δ z zstar idx := fun idx => CollisionBox.normalized_cutoff hYone hT.ne' _ refine ⟨?_, ?_, ?_, ?_, ?_, ?_⟩ · intro idx j hij exact hmono.monotone (nu_antitone s m hk hij) · exact (congrArg (CollisionBox.cutoff Y) (nu_zero L δ z zstar)).trans (CollisionBox.cutoff_one hYone) · intro idx hi exact ⟨hmono (nu_next_lt_mu s m hk hi), hmono.monotone (mu_le_nu m idx)⟩ · intro idx hi hik rw [hcoordinates, hcoordinates] exact nu_gap s m hk (by omega) hik · change normalityScale (logLog Y) ≤ CollisionBox.cutoff Y (nu L δ z zstar k) rw [cutoff_exp_exp hYone, normalityScale] apply Real.exp_le_exp.mpr apply Real.exp_le_exp.mpr have hn : b / 2 ≤ nu L δ z zstar k := by rw [nu_tail L δ z zstar hk le_rfl] have hs := s.tail_lower have hd := m.delta_nonneg have hL : (0 : ℝ) ≤ L := Nat.cast_nonneg L nlinarith have hnT := mul_le_mul_of_nonneg_right hn hT.le have hm := m.normality nlinarith · exact cutoff_short hYone hT (nu_one_short s m hk) /-- The actual high prefix and every surviving-index cutoff family. -/ /- Original line 23738: Erdos416Proof.CollisionCutoff.BoxSieveCutoffs -/ noncomputable def BoxSieveCutoffs (Y : ℝ) (L : ℕ) (w : Fin (L + 1) → ℝ) : Prop := let T := logLog Y let ε := 1 / T let h := T ^ (-2 / 5 : ℝ) let b := T ^ (-1 / 3 : ℝ) let δ := normalityDelta T ∃ J : Fin (L + 1), J.val < L ∧ (∀ idx, idx ≤ J ↔ b < w idx) ∧ ∀ C : Finset (Fin (J.val + 1)), (∀ j : Fin (J.val + 1), j.val = 0 → j ∉ C) → let k := (CollisionClass.remaining C).card let z := selectedZeta J C ε w let zstar := CollisionBox.tailCoordinate ε h b w J 1 ≤ k ∧ SieveCutoffs k Y δ (upper Y L δ z zstar) (lower Y L δ ε z zstar) /- Original line 23751: Erdos416Proof.CollisionCutoff.boxes_cutoffs_eventually -/ theorem boxes_cutoffs_eventually (A θ : ℝ) (hθ : θ < 1) : ∀ᶠ Y : ℝ in atTop, ∀ L : ℕ, ∀ x w : Fin (L + 1) → ℝ, ∀ e e₀ g : ℝ, (L : ℝ) ≤ A * Real.log (logLog Y) → CollisionBox.Data x w ((logLog Y) ^ (-1 / 3 : ℝ)) e e₀ (1 / logLog Y) ((logLog Y) ^ (-2 / 5 : ℝ)) g θ → BoxSieveCutoffs Y L w := by have hT : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [hT.eventually (margins_eventually A θ hθ), eventually_gt_atTop (Real.exp 1)] with Y hm hY intro L x w e e₀ g hL hd have m := hm L hL obtain ⟨J, hJL, hprefix, _, _, _, hupp, _, htail⟩ := hd.exists_prefix have hJ := (hprefix J).mp le_rfl have hlast : ∀ j, J < j → w j ≤ (logLog Y) ^ (-1 / 3 : ℝ) := fun j hj => (htail j hj).trans hupp refine ⟨J, hJL, hprefix, ?_⟩ intro C hzero have hk := CollisionClass.remaining_card_pos C (by omega) hzero exact ⟨hk, cutoff_conditions hY (selected_of_boxes hd J hJ hlast C hzero) m hk⟩ /-- All sieve-cutoff hypotheses at the actual real endpoint, derived from the original normal prime tuple. The common set is arbitrary except that its first index must survive, as supplied by the checked collision map. -/ /- Original line 23773: Erdos416Proof.CollisionCutoff.prime_cutoffs_eventually -/ theorem prime_cutoffs_eventually (A c P κ θ : ℝ) (hκ : 1 < κ) (hθ : θ < 1) : ∀ᶠ Y : ℝ in atTop, ∀ L : ℕ, ∀ p : Fin (L + 1) → ℕ, (L : ℝ) ≤ A * Real.log (logLog Y) → (∀ idx, SNormal (normalityScale (logLog Y)) (p idx)) → (∀ idx, 17 ≤ p idx) → (∀ idx, (p idx : ℝ) ≤ c * Y * logLog Y) → Antitone p → (∀ idx : Fin (L + 1), 0 < idx.val → ∀ hi : idx.val + 1 < L + 1, κ * logLog (p ⟨idx.val + 1, hi⟩) ≤ logLog (p idx)) → (∀ idx, 0 < idx.val → (p idx : ℝ) ≤ CollisionBox.cutoff Y θ) → (p (Fin.last L) : ℝ) ≤ P → Y ^ (9 / 10 : ℝ) < (p 0 : ℝ) → ((p 0 - 1 : ℕ) : ℝ) ≤ Y → BoxSieveCutoffs Y L (fun idx => CollisionBox.shiftedCoordinate (logLog Y) (p idx)) := by have hT : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [boxes_cutoffs_eventually A θ hθ, hT.eventually (CollisionBox.prime_data_eventually c P κ θ hκ hθ), eventually_gt_atTop (Real.exp 1)] with Y hboxes hpdata hY intro L p hL hpn hp17 hpsize horder hstep hlower hlast htop hshift have hYone : 1 < Y := (Real.one_lt_exp_iff.mpr (by norm_num : (0 : ℝ) < 1)).trans hY have hYpos : 0 < Y := by linarith have hYY : Real.exp (Real.exp (logLog Y)) = Y := by simp only [logLog, Real.exp_log (Real.log_pos hYone), Real.exp_log hYpos] have hd := hpdata L p hpn hp17 (by simpa only [hYY] using hpsize) horder hstep (by simpa only [hYY] using hlower) hlast (by simpa only [hYY] using htop) (by simpa only [hYY] using hshift) exact hboxes L (fun idx => CollisionBox.primeCoordinate (logLog Y) (p idx)) (fun idx => CollisionBox.shiftedCoordinate (logLog Y) (p idx)) (CollisionBox.coordinateError 5 (logLog Y)) (CollisionBox.coordinateError 6 (logLog Y)) (1 - 1 / κ) hL hd end Erdos416Proof.CollisionCutoff /- Actual normal-preimage matching, all paired cutoff intervals, and complete residual support, with sizes from the totient equation. -/ open Filter Finset open scoped Topology BigOperators namespace Erdos416Proof.CollisionMatching /- Original line 23820: Erdos416Proof.CollisionMatching.exp_exp_logLog -/ theorem exp_exp_logLog {r : ℝ} (hr : 1 < r) : Real.exp (Real.exp (logLog r)) = r := by simp only [logLog, Real.exp_log (Real.log_pos hr), Real.exp_log (by linarith : 0 < r)] /- Original line 23823: Erdos416Proof.CollisionMatching.le_cutoff_iff -/ theorem le_cutoff_iff {Y r a : ℝ} (hY : 1 < Y) (hT : 0 < logLog Y) (hr : 1 < r) : r ≤ CollisionBox.cutoff Y a ↔ logLog r / logLog Y ≤ a := by calc _ ↔ Real.exp (Real.exp (logLog r)) ≤ Real.exp (Real.exp (a * logLog Y)) := by rw [exp_exp_logLog hr, CollisionCutoff.cutoff_exp_exp hY] _ ↔ logLog r ≤ a * logLog Y := by rw [Real.exp_le_exp, Real.exp_le_exp] _ ↔ _ := (div_le_iff₀ hT).symm /- Original line 23831: Erdos416Proof.CollisionMatching.cutoff_le_iff -/ theorem cutoff_le_iff {Y r a : ℝ} (hY : 1 < Y) (hT : 0 < logLog Y) (hr : 1 < r) : CollisionBox.cutoff Y a ≤ r ↔ a ≤ logLog r / logLog Y := by calc _ ↔ Real.exp (Real.exp (a * logLog Y)) ≤ Real.exp (Real.exp (logLog r)) := by rw [exp_exp_logLog hr, CollisionCutoff.cutoff_exp_exp hY] _ ↔ a * logLog Y ≤ logLog r := by rw [Real.exp_le_exp, Real.exp_le_exp] _ ↔ _ := (le_div_iff₀ hT).symm /- Original line 23839: Erdos416Proof.CollisionMatching.normalityDelta_pos -/ theorem normalityDelta_pos {T : ℝ} (hT : 1 < T) : 0 < normalityDelta T := by have hTp : 0 < T := by linarith have hlog := Real.log_pos hT dsimp only [normalityDelta] positivity /- Original line 23845: Erdos416Proof.CollisionMatching.logLog_nat_le -/ theorem logLog_nat_le {Y : ℝ} {n : ℕ} (hn : 0 < n) (hT : 0 ≤ logLog Y) (hsize : (n : ℝ) ≤ Y) : logLog n ≤ logLog Y := by by_cases hn1 : n = 1 · simpa only [hn1, Nat.cast_one, logLog, Real.log_one, Real.log_zero] using hT · exact logLog_mono (by exact_mod_cast (show 1 < n by omega)) hsize /- Original line 23851: Erdos416Proof.CollisionMatching.shifted_largest_one_lt -/ theorem shifted_largest_one_lt {p : ℕ} (hp : 17 ≤ p) : 1 < (largestPrimeFactor (p - 1) : ℝ) := by exact_mod_cast largestPrimeFactor_one_lt (show 1 < p - 1 by omega) variable {L : ℕ} variable {Y T ε h b θ e e₀ g : ℝ} {p : Fin (L + 1) → ℕ} {x : Fin (L + 1) → ℝ} /-- The strict matching gap follows from the already-proved box margins. -/ /- Original line 23860: Erdos416Proof.CollisionMatching.high_matching_gap -/ theorem high_matching_gap (hT1 : 1 ≤ T) (m : CollisionCutoff.Margins L (normalityDelta T) ε h b θ T) (htail : 4 * h ≤ b) (idx : Fin (L + 1)) (hp : 17 ≤ p idx) (hi : b < CollisionBox.shiftedCoordinate T (p idx)) : normalityScale T < (largestPrimeFactor (p idx - 1) : ℝ) ∧ (2 * idx.val + 1 : ℝ) * Real.sqrt (logLog (normalityScale T) * T) < logLog (largestPrimeFactor (p idx - 1)) - logLog (normalityScale T) := by have hT := m.scale_pos have hδ := m.delta_nonneg have hε := m.mesh_pos have hbudget := m.budget have hile : (idx.val : ℝ) ≤ L := by exact_mod_cast (show idx.val ≤ L by omega) have hmul := mul_le_mul_of_nonneg_right hile hδ have hcoef : (2 * idx.val + 1 : ℝ) * normalityDelta T ≤ h / 2 := by nlinarith have hE : Real.sqrt (logLog (normalityScale T) * T) ≤ normalityDelta T * T := normality_error_le_delta hT1 have hbound : (2 * idx.val + 1 : ℝ) * Real.sqrt (logLog (normalityScale T) * T) ≤ h * T / 2 := by calc _ ≤ (2 * idx.val + 1 : ℝ) * (normalityDelta T * T) := mul_le_mul_of_nonneg_left hE (by positivity) _ = ((2 * idx.val + 1 : ℝ) * normalityDelta T) * T := by ring _ ≤ (h / 2) * T := mul_le_mul_of_nonneg_right hcoef hT.le _ = _ := by ring have hnormal : logLog (normalityScale T) ≤ b * T / 2 := by simpa only [logLog, logLog_normalityScale] using m.normality have hhigh : b * T < logLog (largestPrimeFactor (p idx - 1)) := (lt_div_iff₀ hT).mp hi have htailT := mul_le_mul_of_nonneg_right htail hT.le have hhT : 0 < h * T := mul_pos m.gap_pos hT have hgap : (2 * idx.val + 1 : ℝ) * Real.sqrt (logLog (normalityScale T) * T) < logLog (largestPrimeFactor (p idx - 1)) - logLog (normalityScale T) := by nlinarith refine ⟨?_, hgap⟩ by_contra hn have hLL := logLog_mono (shifted_largest_one_lt hp) (le_of_not_gt hn) have hnonneg : 0 ≤ (2 * idx.val + 1 : ℝ) * Real.sqrt (logLog (normalityScale T) * T) := by positivity linarith /-- Matching at an actual high left position, including existence of the right index and the normalized error. -/ /- Original line 23898: Erdos416Proof.CollisionMatching.match_high -/ theorem match_high {N d : ℕ} (hT1 : 1 ≤ logLog Y) (Q : NormalPreimageList N (normalityScale (logLog Y))) (hN : 0 < N) (B : CollisionBox.Data x (fun idx => CollisionBox.shiftedCoordinate (logLog Y) (p idx)) b e e₀ ε h g θ) (m : CollisionCutoff.Margins L (normalityDelta (logLog Y)) ε h b θ (logLog Y)) (hp : ∀ idx, SNormal (normalityScale (logLog Y)) (p idx)) (hp17 : ∀ idx, 17 ≤ p idx) (hd : 0 < d) (hdS : (largestPrimeFactor d : ℝ) ≤ normalityScale (logLog Y)) (hphi : N.totient = d * ∏ idx, (p idx - 1)) (hsize : (N.totient : ℝ) ≤ Y) (hPL : ∀ idx, (largestPrimeFactor (p idx - 1) : ℝ) ≤ Y) (idx : Fin (L + 1)) (hi : b < CollisionBox.shiftedCoordinate (logLog Y) (p idx)) : ∃ j : Fin (largeShiftPrimes N (normalityScale (logLog Y))).card, j.val = idx.val ∧ |CollisionBox.shiftedCoordinate (logLog Y) (p idx) - CollisionBox.shiftedCoordinate (logLog Y) (Q.primes j)| ≤ (2 * idx.val + 1 : ℝ) * normalityDelta (logLog Y) := by have hT := m.scale_pos have hgap := high_matching_gap hT1 m B.tail_margin idx (hp17 idx) hi have horder := B.rankedAt_shifted hT hp17 hi have hphiT := logLog_nat_le (Nat.totient_pos.mpr hN) hT.le hsize have hPT := logLog_mono (shifted_largest_one_lt (hp17 idx)) (hPL idx) obtain ⟨j, hj, hmatch⟩ := Q.matching hN (normalityScale_ge_exp_one (logLog Y)) p hp hd.ne' hdS hphi hphiT idx horder hgap.1 hPT hgap.2 refine ⟨j, hj, ?_⟩ have hE := normality_error_le_delta hT1 have hbnd := hmatch.trans (mul_le_mul_of_nonneg_left hE (by positivity : (0 : ℝ) ≤ 2 * idx.val + 1)) have hdiv := div_le_div_of_nonneg_right hbnd hT.le have hrhs : ((2 * idx.val + 1 : ℝ) * (normalityDelta (logLog Y) * logLog Y)) / logLog Y = (2 * idx.val + 1 : ℝ) * normalityDelta (logLog Y) := by field_simp rw [hrhs] at hdiv change |logLog (largestPrimeFactor (p idx - 1)) / logLog Y - logLog (largestPrimeFactor (Q.primes j - 1)) / logLog Y| ≤ _ rw [← sub_div, abs_div, abs_of_pos hT] exact hdiv /- Original line 23930: Erdos416Proof.CollisionMatching.prefixIndex -/ def prefixIndex (J : Fin (L + 1)) (idx : Fin (J.val + 1)) : Fin (L + 1) := Fin.castLE (by have := J.isLt; omega) idx /- Original line 23933: Erdos416Proof.CollisionMatching.prefixIndex_val -/ theorem prefixIndex_val (J : Fin (L + 1)) (idx : Fin (J.val + 1)) : (prefixIndex J idx).val = idx.val := rfl /- Original line 23936: Erdos416Proof.CollisionMatching.prefixIndex_le -/ theorem prefixIndex_le (J : Fin (L + 1)) (idx : Fin (J.val + 1)) : prefixIndex J idx ≤ J := by change idx.val ≤ J.val omega /-- The canonical right prefix has the required length and matches every left prefix position. The length is derived by matching at the actual J. -/ /- Original line 23942: Erdos416Proof.CollisionMatching.prefix_exists -/ theorem prefix_exists {N d : ℕ} (hT1 : 1 ≤ logLog Y) (Q : NormalPreimageList N (normalityScale (logLog Y))) (hN : 0 < N) (B : CollisionBox.Data x (fun idx => CollisionBox.shiftedCoordinate (logLog Y) (p idx)) b e e₀ ε h g θ) (m : CollisionCutoff.Margins L (normalityDelta (logLog Y)) ε h b θ (logLog Y)) (hp : ∀ idx, SNormal (normalityScale (logLog Y)) (p idx)) (hp17 : ∀ idx, 17 ≤ p idx) (hd : 0 < d) (hdS : (largestPrimeFactor d : ℝ) ≤ normalityScale (logLog Y)) (hphi : N.totient = d * ∏ idx, (p idx - 1)) (hsize : (N.totient : ℝ) ≤ Y) (hPL : ∀ idx, (largestPrimeFactor (p idx - 1) : ℝ) ≤ Y) (J : Fin (L + 1)) (hJ : b < CollisionBox.shiftedCoordinate (logLog Y) (p J)) : ∃ ha : J.val + 1 ≤ (largeShiftPrimes N (normalityScale (logLog Y))).card, ∀ idx : Fin (J.val + 1), |CollisionBox.shiftedCoordinate (logLog Y) (p (prefixIndex J idx)) - CollisionBox.shiftedCoordinate (logLog Y) (CollisionClass.prefixPrimes Q ha idx)| ≤ (2 * idx.val + 1 : ℝ) * normalityDelta (logLog Y) := by obtain ⟨j, hj, _⟩ := match_high hT1 Q hN B m hp hp17 hd hdS hphi hsize hPL J hJ have ha : J.val + 1 ≤ (largeShiftPrimes N (normalityScale (logLog Y))).card := by have := j.isLt omega refine ⟨ha, ?_⟩ intro idx have hi := B.high_before hJ (prefixIndex_le J idx) obtain ⟨j, hj, hmatch⟩ := match_high hT1 Q hN B m hp hp17 hd hdS hphi hsize hPL (prefixIndex J idx) hi have heq : j = Fin.castLE ha idx := Fin.ext hj simpa only [heq, CollisionClass.prefixPrimes, prefixIndex_val] using hmatch /- Original line 23968: Erdos416Proof.CollisionMatching.tailCutoff -/ noncomputable def tailCutoff (Y : ℝ) (L : ℕ) (zstar : ℝ) : ℝ := CollisionBox.cutoff Y (zstar + (2 * L + 3) * normalityDelta (logLog Y)) /- Original line 23971: Erdos416Proof.CollisionMatching.tailCutoff_eq_upper -/ theorem tailCutoff_eq_upper {k : ℕ} (Y : ℝ) (L : ℕ) (zstar : ℝ) (z : Fin k → ℝ) (hk : 1 ≤ k) : tailCutoff Y L zstar = CollisionCutoff.upper Y L (normalityDelta (logLog Y)) z zstar k := by rw [CollisionCutoff.upper, CollisionCutoff.nu_tail L _ z zstar hk le_rfl] rfl /- Original line 23977: Erdos416Proof.CollisionMatching.tail_cutoff_properties -/ theorem tail_cutoff_properties {zstar : ℝ} (hY : Real.exp 1 < Y) (hT1 : 1 < logLog Y) (m : CollisionCutoff.Margins L (normalityDelta (logLog Y)) ε h b θ (logLog Y)) (hzlo : b / 2 ≤ zstar) (hzhi : zstar ≤ b) : normalityScale (logLog Y) ≤ CollisionBox.cutoff Y zstar ∧ CollisionBox.cutoff Y zstar < tailCutoff Y L zstar ∧ logLog (tailCutoff Y L zstar) ≤ logLog Y := by have hYone : 1 < Y := (Real.one_lt_exp_iff.mpr (by norm_num : (0 : ℝ) < 1)).trans hY have hT := m.scale_pos have hδ := normalityDelta_pos hT1 have hL : (0 : ℝ) ≤ L := Nat.cast_nonneg L refine ⟨?_, ?_, ?_⟩ · rw [normalityScale, CollisionCutoff.cutoff_exp_exp hYone] apply Real.exp_le_exp.mpr apply Real.exp_le_exp.mpr have hn := m.normality have hm := mul_le_mul_of_nonneg_right hzlo hT.le nlinarith · apply CollisionBox.cutoff_strictMono hY have hpos : 0 < (2 * L + 3 : ℝ) * normalityDelta (logLog Y) := by positivity linarith · rw [tailCutoff, CollisionBox.logLog_cutoff hYone] have hn : zstar + (2 * L + 3 : ℝ) * normalityDelta (logLog Y) ≤ 1 := by have hm := m.first_tail have he := m.mesh_pos nlinarith simpa only [one_mul] using mul_le_mul_of_nonneg_right hn hT.le /- Original line 24003: Erdos416Proof.CollisionMatching.tail_matching_gap -/ theorem tail_matching_gap (hY : 1 < Y) (hT1 : 1 < logLog Y) (J : Fin (L + 1)) (hJL : J.val < L) (zstar : ℝ) : (2 * (J.val + 1 : ℕ) + 1 : ℝ) * Real.sqrt (logLog (normalityScale (logLog Y)) * logLog Y) < logLog (tailCutoff Y L zstar) - logLog (CollisionBox.cutoff Y zstar) := by have hT : 0 < logLog Y := by linarith have hδ := normalityDelta_pos hT1 have hE := normality_error_le_delta hT1.le have hcoef : (2 * (J.val + 1 : ℕ) + 1 : ℝ) < 2 * L + 3 := by have hJLr : (J.val : ℝ) < L := by exact_mod_cast hJL push_cast linarith calc _ ≤ (2 * (J.val + 1 : ℕ) + 1 : ℝ) * (normalityDelta (logLog Y) * logLog Y) := mul_le_mul_of_nonneg_left hE (by positivity) _ < (2 * L + 3 : ℝ) * (normalityDelta (logLog Y) * logLog Y) := mul_lt_mul_of_pos_right hcoef (mul_pos hδ hT) _ = _ := by rw [tailCutoff, CollisionBox.logLog_cutoff hY, CollisionBox.logLog_cutoff hY] ring /-- Every actual right-tail shifted factor lies below the same terminal cutoff, by interval balance and the normal preimage's proved ordering. -/ /- Original line 24025: Erdos416Proof.CollisionMatching.right_tail_bound -/ theorem right_tail_bound {N d : ℕ} (hY : Real.exp 1 < Y) (hT1 : 1 < logLog Y) (Q : NormalPreimageList N (normalityScale (logLog Y))) (B : CollisionBox.Data x (fun idx => CollisionBox.shiftedCoordinate (logLog Y) (p idx)) b e e₀ ε h g θ) (m : CollisionCutoff.Margins L (normalityDelta (logLog Y)) ε h b θ (logLog Y)) (hp : ∀ idx, SNormal (normalityScale (logLog Y)) (p idx)) (hp17 : ∀ idx, 17 ≤ p idx) (hd : 0 < d) (hdS : (largestPrimeFactor d : ℝ) ≤ normalityScale (logLog Y)) (hphi : N.totient = d * ∏ idx, (p idx - 1)) (J : Fin (L + 1)) (hJL : J.val < L) (hJ : b < CollisionBox.shiftedCoordinate (logLog Y) (p J)) (hlast : ∀ idx, J < idx → CollisionBox.shiftedCoordinate (logLog Y) (p idx) ≤ b) : ∀ j : Fin (largeShiftPrimes N (normalityScale (logLog Y))).card, J.val + 1 ≤ j.val → (largestPrimeFactor (Q.primes j - 1) : ℝ) < tailCutoff Y L (CollisionBox.tailCoordinate ε h b (fun idx => CollisionBox.shiftedCoordinate (logLog Y) (p idx)) J) := by let zstar := CollisionBox.tailCoordinate ε h b (fun idx => CollisionBox.shiftedCoordinate (logLog Y) (p idx)) J have htail := B.tail_bounds hJ hlast have hcuts := tail_cutoff_properties hY hT1 m htail.1 htail.2.1 have hYone : 1 < Y := (Real.one_lt_exp_iff.mpr (by norm_num : (0 : ℝ) < 1)).trans hY intro j hj let idx : Fin (L + 1) := ⟨J.val + 1, by omega⟩ let j₀ : Fin (largeShiftPrimes N (normalityScale (logLog Y))).card := ⟨J.val + 1, by omega⟩ have htailP : ∀ r : Fin (L + 1), idx ≤ r → (largestPrimeFactor (p r - 1) : ℝ) ≤ CollisionBox.cutoff Y zstar := by intro r hr apply (le_cutoff_iff hYone m.scale_pos (shifted_largest_one_lt (hp17 r))).mpr have hJr : J < r := by change J.val < r.val; change J.val + 1 ≤ r.val at hr; omega exact htail.2.2.2 r hJr have hg := tail_matching_gap hYone hT1 J hJL zstar have hfirst := matching_tail_cutoff p Q.primes hp Q.normal (normalityScale_ge_exp_one (logLog Y)) idx j₀ rfl (rankedAt_of_antitone Q.sorted.antitone j₀) htailP hcuts.1 hcuts.2.1 hcuts.2.2 hg (fun a _ ha _ => Q.interval_balance p (fun r => (hp r).1) hd.ne' hdS hphi ha) have hle : (largestPrimeFactor (Q.primes j - 1) : ℝ) ≤ largestPrimeFactor (Q.primes j₀ - 1) := by exact_mod_cast Q.sorted.antitone (show j₀ ≤ j from hj) exact hle.trans_lt hfirst /- Original line 24060: Erdos416Proof.CollisionMatching.residual_support -/ theorem residual_support {N d : ℕ} (hY : Real.exp 1 < Y) (hT1 : 1 < logLog Y) (Q : NormalPreimageList N (normalityScale (logLog Y))) (B : CollisionBox.Data x (fun idx => CollisionBox.shiftedCoordinate (logLog Y) (p idx)) b e e₀ ε h g θ) (m : CollisionCutoff.Margins L (normalityDelta (logLog Y)) ε h b θ (logLog Y)) (hp : ∀ idx, SNormal (normalityScale (logLog Y)) (p idx)) (hp17 : ∀ idx, 17 ≤ p idx) (hd : 0 < d) (hdS : (largestPrimeFactor d : ℝ) ≤ normalityScale (logLog Y)) (hphi : N.totient = d * ∏ idx, (p idx - 1)) (J : Fin (L + 1)) (hJL : J.val < L) (hJ : b < CollisionBox.shiftedCoordinate (logLog Y) (p J)) (hlast : ∀ idx, J < idx → CollisionBox.shiftedCoordinate (logLog Y) (p idx) ≤ b) : ∀ z ∈ (CollisionClass.normalResidual Q (J.val + 1)).primeFactorsList, (z : ℝ) ≤ tailCutoff Y L (CollisionBox.tailCoordinate ε h b (fun idx => CollisionBox.shiftedCoordinate (logLog Y) (p idx)) J) := by have htail := B.tail_bounds hJ hlast have hcuts := tail_cutoff_properties hY hT1 m htail.1 htail.2.1 have hS : 1 ≤ normalityScale (logLog Y) := (Real.one_lt_exp_iff.mpr (by norm_num : (0 : ℝ) < 1)).le.trans (normalityScale_ge_exp_one (logLog Y)) exact CollisionClass.normalResidual_support Q (J.val + 1) hS (hcuts.1.trans hcuts.2.1.le) (fun j hj => (right_tail_bound hY hT1 Q B m hp hp17 hd hdS hphi J hJL hJ hlast j hj).le) /- Original line 24079: Erdos416Proof.CollisionMatching.head_error_eventually -/ theorem head_error_eventually : ∀ᶠ T : ℝ in atTop, CollisionBox.coordinateError 6 T ≤ normalityDelta T := by have he := (CollisionBox.coordinateError_littleO (by norm_num : (0 : ℝ) < 6) (by norm_num : (-1 : ℝ) < -1 / 2)).def (by norm_num : (0 : ℝ) < 1) filter_upwards [he, eventually_ge_atTop (Real.exp 1)] with T he hTe have hT : 0 < T := (Real.exp_pos 1).trans_le hTe have hlog : 1 ≤ Real.log T := by have hl := Real.log_le_log (Real.exp_pos 1) hTe simpa only [Real.log_exp] using hl have hpow : (1 : ℝ) ≤ Real.log T ^ 5 := one_le_pow₀ hlog have hr : T ^ (-1 / 2 : ℝ) = (Real.sqrt T)⁻¹ := by rw [show (-1 / 2 : ℝ) = -(1 / 2) by ring, Real.rpow_neg hT.le, ← Real.sqrt_eq_rpow] simp only [Real.norm_eq_abs, one_mul, abs_of_pos (Real.rpow_pos_of_pos hT (-1 / 2 : ℝ))] at he refine ((le_abs_self _).trans he).trans ?_ rw [hr, normalityDelta, ← one_div] exact div_le_div_of_nonneg_right (by linarith) (Real.sqrt_nonneg T) /- Original line 24096: Erdos416Proof.CollisionMatching.selectedIndex_eq_prefixIndex -/ theorem selectedIndex_eq_prefixIndex (J : Fin (L + 1)) (C : Finset (Fin (J.val + 1))) (idx : Fin (CollisionClass.remaining C).card) : CollisionCutoff.selectedIndex J C idx = prefixIndex J (CollisionClass.index C idx) := rfl /-- The actual matched coordinates fit both intervals, including the top coordinate whose approximation error is separate from the grid mesh. -/ /- Original line 24102: Erdos416Proof.CollisionMatching.paired_coordinate_bounds -/ theorem paired_coordinate_bounds {δ : ℝ} {w : Fin (L + 1) → ℝ} (B : CollisionBox.Data x w b e e₀ ε h g θ) (m : CollisionCutoff.Margins L δ ε h b θ T) (he₀ : e₀ ≤ δ) (J : Fin (L + 1)) (hJ : b < w J) (q : Fin (J.val + 1) → ℝ) (hmatch : ∀ j, |w (prefixIndex J j) - q j| ≤ (2 * j.val + 1 : ℝ) * δ) (hq : ∀ j, q j ≤ 1) (C : Finset (Fin (J.val + 1))) (hzero : ∀ j : Fin (J.val + 1), j.val = 0 → j ∉ C) : let z := CollisionCutoff.selectedZeta J C ε w let zstar := CollisionBox.tailCoordinate ε h b w J ∀ idx : Fin (CollisionClass.remaining C).card, (CollisionCutoff.mu L δ ε z zstar idx.val ≤ w (CollisionCutoff.selectedIndex J C idx) ∧ w (CollisionCutoff.selectedIndex J C idx) ≤ CollisionCutoff.nu L δ z zstar idx.val) ∧ (CollisionCutoff.mu L δ ε z zstar idx.val ≤ q (CollisionClass.index C idx) ∧ q (CollisionClass.index C idx) ≤ CollisionCutoff.nu L δ z zstar idx.val) := by intro z zstar idx have hδ := m.delta_nonneg have hε := m.mesh_pos have hL : (0 : ℝ) ≤ L := Nat.cast_nonneg L have hm := hmatch (CollisionClass.index C idx) rw [← selectedIndex_eq_prefixIndex J C idx] at hm by_cases hi0 : idx.val = 0 · have hfirst := CollisionCutoff.selectedIndex_first J C hzero idx hi0 have hj0 := CollisionClass.index_first C hzero idx hi0 rw [hfirst, hj0] at hm norm_num only [Nat.cast_zero, mul_zero, zero_add, one_mul] at hm have habs := abs_le.mp hm have hw := B.head_approximation have hwupper := B.head_le have hqupper := hq (CollisionClass.index C idx) rw [CollisionCutoff.mu, hi0, CollisionCutoff.nu_zero, hfirst] constructor <;> constructor <;> nlinarith · have hip : 0 < idx.val := Nat.pos_of_ne_zero hi0 have hsel := CollisionCutoff.selectedIndex_le J C idx have hhigh := B.high_before hJ hsel have hpos : 0 < (CollisionCutoff.selectedIndex J C idx).val := lt_of_lt_of_le hip (CollisionCutoff.selectedIndex_val_ge J C idx) have hrlo : w (CollisionCutoff.selectedIndex J C idx) ≤ z idx := (B.rounded_bounds hhigh).1 have hrhi : z idx ≤ w (CollisionCutoff.selectedIndex J C idx) + ε := ((B.rounded_bounds hhigh).2 hpos).le have hjL : ((CollisionClass.index C idx).val : ℝ) ≤ L := by have hj := (CollisionClass.index C idx).isLt have hJL := J.isLt exact_mod_cast (show (CollisionClass.index C idx).val ≤ L by omega) have hcoef : (2 * (CollisionClass.index C idx).val + 1 : ℝ) * δ ≤ (2 * L + 1 : ℝ) * δ := by have hc := mul_le_mul_of_nonneg_right hjL hδ nlinarith have habs := abs_le.mp (hm.trans hcoef) have hnu : CollisionCutoff.nu L δ z zstar idx.val = z idx + (2 * L + 1 : ℝ) * δ := CollisionCutoff.nu_internal L δ z zstar hip idx.isLt rw [CollisionCutoff.mu, hnu] constructor <;> constructor <;> nlinarith /- Original line 24154: Erdos416Proof.CollisionMatching.paired_intervals -/ theorem paired_intervals {N : ℕ} (hY : Real.exp 1 < Y) (Q : NormalPreimageList N (normalityScale (logLog Y))) (hN : 0 < N) (B : CollisionBox.Data x (fun idx => CollisionBox.shiftedCoordinate (logLog Y) (p idx)) b e e₀ ε h g θ) (m : CollisionCutoff.Margins L (normalityDelta (logLog Y)) ε h b θ (logLog Y)) (he₀ : e₀ ≤ normalityDelta (logLog Y)) (hp17 : ∀ idx, 17 ≤ p idx) (hsize : (N.totient : ℝ) ≤ Y) (J : Fin (L + 1)) (hJ : b < CollisionBox.shiftedCoordinate (logLog Y) (p J)) (ha : J.val + 1 ≤ (largeShiftPrimes N (normalityScale (logLog Y))).card) (hmatch : ∀ j : Fin (J.val + 1), |CollisionBox.shiftedCoordinate (logLog Y) (p (prefixIndex J j)) - CollisionBox.shiftedCoordinate (logLog Y) (CollisionClass.prefixPrimes Q ha j)| ≤ (2 * j.val + 1 : ℝ) * normalityDelta (logLog Y)) (C : Finset (Fin (J.val + 1))) (hzero : ∀ j : Fin (J.val + 1), j.val = 0 → j ∉ C) : let w := fun idx => CollisionBox.shiftedCoordinate (logLog Y) (p idx) let z := CollisionCutoff.selectedZeta J C ε w let zstar := CollisionBox.tailCoordinate ε h b w J ∀ idx : Fin (CollisionClass.remaining C).card, (CollisionCutoff.lower Y L (normalityDelta (logLog Y)) ε z zstar idx.val ≤ (largestPrimeFactor (p (CollisionCutoff.selectedIndex J C idx) - 1) : ℝ) ∧ (largestPrimeFactor (p (CollisionCutoff.selectedIndex J C idx) - 1) : ℝ) ≤ CollisionCutoff.upper Y L (normalityDelta (logLog Y)) z zstar idx.val) ∧ (CollisionCutoff.lower Y L (normalityDelta (logLog Y)) ε z zstar idx.val ≤ (largestPrimeFactor (CollisionClass.prefixPrimes Q ha (CollisionClass.index C idx) - 1) : ℝ) ∧ (largestPrimeFactor (CollisionClass.prefixPrimes Q ha (CollisionClass.index C idx) - 1) : ℝ) ≤ CollisionCutoff.upper Y L (normalityDelta (logLog Y)) z zstar idx.val) := by intro w z zstar have hYone : 1 < Y := (Real.one_lt_exp_iff.mpr (by norm_num : (0 : ℝ) < 1)).trans hY have hSone : 1 ≤ normalityScale (logLog Y) := (Real.one_lt_exp_iff.mpr (by norm_num : (0 : ℝ) < 1)).le.trans (normalityScale_ge_exp_one (logLog Y)) have hQone : ∀ j : Fin (J.val + 1), 1 < (largestPrimeFactor (CollisionClass.prefixPrimes Q ha j - 1) : ℝ) := fun j => hSone.trans_lt (Q.large (Fin.castLE ha j)) have hqupper : ∀ j : Fin (J.val + 1), CollisionBox.shiftedCoordinate (logLog Y) (CollisionClass.prefixPrimes Q ha j) ≤ 1 := by intro j have hLP : (largestPrimeFactor (CollisionClass.prefixPrimes Q ha j - 1) : ℝ) ≤ Y := (Nat.cast_le.mpr (Q.shifted_le_totient hN (Fin.castLE ha j))).trans hsize have hLL := logLog_mono (hQone j) hLP exact (div_le_div_of_nonneg_right hLL m.scale_pos.le).trans_eq (div_self m.scale_pos.ne') have hcoords := paired_coordinate_bounds B m he₀ J hJ (fun j => CollisionBox.shiftedCoordinate (logLog Y) (CollisionClass.prefixPrimes Q ha j)) hmatch hqupper C hzero intro idx have hc := hcoords idx have hleft := shifted_largest_one_lt (hp17 (CollisionCutoff.selectedIndex J C idx)) have hright := hQone (CollisionClass.index C idx) exact ⟨⟨(cutoff_le_iff hYone m.scale_pos hleft).mpr hc.1.1, (le_cutoff_iff hYone m.scale_pos hleft).mpr hc.1.2⟩, ⟨(cutoff_le_iff hYone m.scale_pos hright).mpr hc.2.1, (le_cutoff_iff hYone m.scale_pos hright).mpr hc.2.2⟩⟩ /- Original line 24205: Erdos416Proof.CollisionMatching.shifted_factor_le_totient -/ theorem shifted_factor_le_totient {N d : ℕ} (hN : 0 < N) (hphi : N.totient = d * ∏ idx, (p idx - 1)) (idx : Fin (L + 1)) : p idx - 1 ≤ N.totient := by have hprod : p idx - 1 ∣ ∏ j, (p j - 1) := Finset.dvd_prod_of_mem (fun j => p j - 1) (Finset.mem_univ idx) have hdvd : p idx - 1 ∣ N.totient := by rw [hphi]; exact dvd_mul_of_dvd_right hprod d exact Nat.le_of_dvd (Nat.totient_pos.mpr hN) hdvd /- Original line 24211: Erdos416Proof.CollisionMatching.PairedIntervals -/ def PairedIntervals {k : ℕ} (P Q : Fin k → ℕ) (v W : ℕ → ℝ) : Prop := ∀ idx, (W idx.val ≤ (largestPrimeFactor (P idx - 1) : ℝ) ∧ (largestPrimeFactor (P idx - 1) : ℝ) ≤ v idx.val) ∧ (W idx.val ≤ (largestPrimeFactor (Q idx - 1) : ℝ) ∧ (largestPrimeFactor (Q idx - 1) : ℝ) ≤ v idx.val) /-- The actual matched prefix, full residual support and all surviving paired-factor intervals. Every field below is proved, not an analytic input. -/ /- Original line 24219: Erdos416Proof.CollisionMatching.MatchedPreimage -/ structure MatchedPreimage {N : ℕ} (Y : ℝ) (p : Fin (L + 1) → ℕ) (Q : NormalPreimageList N (normalityScale (logLog Y))) (ε h b : ℝ) (J : Fin (L + 1)) (ha : J.val + 1 ≤ (largeShiftPrimes N (normalityScale (logLog Y))).card) : Prop where prefix_error : ∀ idx : Fin (J.val + 1), |CollisionBox.shiftedCoordinate (logLog Y) (p (prefixIndex J idx)) - CollisionBox.shiftedCoordinate (logLog Y) (CollisionClass.prefixPrimes Q ha idx)| ≤ (2 * idx.val + 1 : ℝ) * normalityDelta (logLog Y) left_tail : ∀ idx, J < idx → ∀ z ∈ (p idx - 1).primeFactorsList, (z : ℝ) ≤ tailCutoff Y L (CollisionBox.tailCoordinate ε h b (fun idx => CollisionBox.shiftedCoordinate (logLog Y) (p idx)) J) right_tail : ∀ j : Fin (largeShiftPrimes N (normalityScale (logLog Y))).card, J.val + 1 ≤ j.val → (largestPrimeFactor (Q.primes j - 1) : ℝ) < tailCutoff Y L (CollisionBox.tailCoordinate ε h b (fun idx => CollisionBox.shiftedCoordinate (logLog Y) (p idx)) J) residual : ∀ z ∈ (CollisionClass.normalResidual Q (J.val + 1)).primeFactorsList, (z : ℝ) ≤ tailCutoff Y L (CollisionBox.tailCoordinate ε h b (fun idx => CollisionBox.shiftedCoordinate (logLog Y) (p idx)) J) paired : ∀ C : Finset (Fin (J.val + 1)), (∀ j : Fin (J.val + 1), j.val = 0 → j ∉ C) → let k := (CollisionClass.remaining C).card let w := fun idx => CollisionBox.shiftedCoordinate (logLog Y) (p idx) let z := CollisionCutoff.selectedZeta J C ε w let zstar := CollisionBox.tailCoordinate ε h b w J let v := CollisionCutoff.upper Y L (normalityDelta (logLog Y)) z zstar let W := CollisionCutoff.lower Y L (normalityDelta (logLog Y)) ε z zstar 1 ≤ k ∧ CollisionCutoff.SieveCutoffs k Y (normalityDelta (logLog Y)) v W ∧ PairedIntervals (fun idx => p (CollisionCutoff.selectedIndex J C idx)) (fun idx => CollisionClass.prefixPrimes Q ha (CollisionClass.index C idx)) v W /- Original line 24244: Erdos416Proof.CollisionMatching.matched_of_boxes -/ theorem matched_of_boxes {N d : ℕ} (hY : Real.exp 1 < Y) (hT1 : 1 < logLog Y) (Q : NormalPreimageList N (normalityScale (logLog Y))) (hN : 0 < N) (B : CollisionBox.Data x (fun idx => CollisionBox.shiftedCoordinate (logLog Y) (p idx)) b e e₀ ε h g θ) (m : CollisionCutoff.Margins L (normalityDelta (logLog Y)) ε h b θ (logLog Y)) (he₀ : e₀ ≤ normalityDelta (logLog Y)) (hp : ∀ idx, SNormal (normalityScale (logLog Y)) (p idx)) (hp17 : ∀ idx, 17 ≤ p idx) (hd : 0 < d) (hdS : (largestPrimeFactor d : ℝ) ≤ normalityScale (logLog Y)) (hphi : N.totient = d * ∏ idx, (p idx - 1)) (hsize : (N.totient : ℝ) ≤ Y) (J : Fin (L + 1)) (hJL : J.val < L) (hJ : b < CollisionBox.shiftedCoordinate (logLog Y) (p J)) (hlast : ∀ idx, J < idx → CollisionBox.shiftedCoordinate (logLog Y) (p idx) ≤ b) : ∃ ha : J.val + 1 ≤ (largeShiftPrimes N (normalityScale (logLog Y))).card, MatchedPreimage Y p Q ε h b J ha := by have hYone : 1 < Y := (Real.one_lt_exp_iff.mpr (by norm_num : (0 : ℝ) < 1)).trans hY have hPL : ∀ idx, (largestPrimeFactor (p idx - 1) : ℝ) ≤ Y := by intro idx have hp0 : 0 < p idx - 1 := by have := hp17 idx; omega exact (Nat.cast_le.mpr ((largestPrimeFactor_le hp0).trans (shifted_factor_le_totient hN hphi idx))).trans hsize obtain ⟨ha, hmatches⟩ := prefix_exists hT1.le Q hN B m hp hp17 hd hdS hphi hsize hPL J hJ refine ⟨ha, hmatches, ?_, right_tail_bound hY hT1 Q B m hp hp17 hd hdS hphi J hJL hJ hlast, residual_support hY hT1 Q B m hp hp17 hd hdS hphi J hJL hJ hlast, ?_⟩ · intro idx hi z hz have ht := B.tail_bounds hJ hlast have hcuts := tail_cutoff_properties hY hT1 m ht.1 ht.2.1 have hLP := (le_cutoff_iff hYone m.scale_pos (shifted_largest_one_lt (hp17 idx))).mpr (ht.2.2.2 idx hi) have hzP : (z : ℝ) ≤ largestPrimeFactor (p idx - 1) := Nat.cast_le.mpr (primeFactorsList_le_largestPrimeFactor hz) exact hzP.trans (hLP.trans hcuts.2.1.le) · intro C hzero have hk := CollisionClass.remaining_card_pos C (by omega) hzero exact ⟨hk, CollisionCutoff.cutoff_conditions hY (CollisionCutoff.selected_of_boxes B J hJ hlast C hzero) m hk, paired_intervals hY Q hN B m he₀ hp17 hsize J hJ ha hmatches C hzero⟩ /-- Uniform application to the actual equation and original prime tuple. The totient equation supplies the prime-size envelope and the top shifted factor bound, so neither is assumed in this final matching wrapper. -/ /- Original line 24280: Erdos416Proof.CollisionMatching.matched_preimage_eventually -/ theorem matched_preimage_eventually (A P κ θ : ℝ) (hκ : 1 < κ) (hθ : θ < 1) : ∀ᶠ Y : ℝ in atTop, ∀ (L : ℕ) (p : Fin (L + 1) → ℕ) (N d : ℕ) (Q : NormalPreimageList N (normalityScale (logLog Y))), (L : ℝ) ≤ A * Real.log (logLog Y) → (∀ idx, SNormal (normalityScale (logLog Y)) (p idx)) → (∀ idx, 17 ≤ p idx) → Antitone p → (∀ idx : Fin (L + 1), 0 < idx.val → ∀ hi : idx.val + 1 < L + 1, κ * logLog (p ⟨idx.val + 1, hi⟩) ≤ logLog (p idx)) → (∀ idx, 0 < idx.val → (p idx : ℝ) ≤ CollisionBox.cutoff Y θ) → (p (Fin.last L) : ℝ) ≤ P → Y ^ (9 / 10 : ℝ) < (p 0 : ℝ) → 0 < N → 0 < d → (largestPrimeFactor d : ℝ) ≤ normalityScale (logLog Y) → N.totient = d * ∏ idx, (p idx - 1) → (N.totient : ℝ) ≤ Y → ∃ J : Fin (L + 1), J.val < L ∧ (∀ idx, idx ≤ J ↔ (logLog Y) ^ (-1 / 3 : ℝ) < CollisionBox.shiftedCoordinate (logLog Y) (p idx)) ∧ ∃ ha : J.val + 1 ≤ (largeShiftPrimes N (normalityScale (logLog Y))).card, MatchedPreimage Y p Q (1 / logLog Y) ((logLog Y) ^ (-2 / 5 : ℝ)) ((logLog Y) ^ (-1 / 3 : ℝ)) J ha := by have hT : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [hT.eventually (CollisionBox.prime_data_eventually 1 P κ θ hκ hθ), hT.eventually (CollisionCutoff.margins_eventually A θ hθ), hT.eventually head_error_eventually, hT.eventually_ge_atTop 2, eventually_gt_atTop (Real.exp 1)] with Y hpdata hmargin he₀ hT2 hY intro L p N d Q hL hp hp17 horder hstep hlower hlast htop hN hd hdS hphi hsize have hYone : 1 < Y := (Real.one_lt_exp_iff.mpr (by norm_num : (0 : ℝ) < 1)).trans hY have hYpos : 0 < Y := by linarith have hshift : ∀ idx, ((p idx - 1 : ℕ) : ℝ) ≤ Y := fun idx => (Nat.cast_le.mpr (shifted_factor_le_totient hN hphi idx)).trans hsize have hpsize : ∀ idx, (p idx : ℝ) ≤ Y * logLog Y := by intro idx have hi := hshift idx rw [Nat.cast_sub (show 1 ≤ p idx by have := hp17 idx; omega), Nat.cast_one] at hi have hm := mul_le_mul_of_nonneg_left hT2 hYpos.le nlinarith have hYY : Real.exp (Real.exp (logLog Y)) = Y := exp_exp_logLog hYone have B := hpdata L p hp hp17 (by simpa only [one_mul, hYY] using hpsize) horder hstep (by simpa only [hYY] using hlower) hlast (by simpa only [hYY] using htop) (by simpa only [hYY] using hshift 0) have m := hmargin L hL obtain ⟨J, hJL, hprefix, _, _, _, hupp, _, htail⟩ := B.exists_prefix have hJ := (hprefix J).mp le_rfl have hlast' : ∀ idx, J < idx → CollisionBox.shiftedCoordinate (logLog Y) (p idx) ≤ (logLog Y) ^ (-1 / 3 : ℝ) := fun idx hi => (htail idx hi).trans hupp exact ⟨J, hJL, hprefix, matched_of_boxes hY (by linarith) Q hN B m he₀ hp hp17 hd hdS hphi hsize J hJL hJ hlast'⟩ end Erdos416Proof.CollisionMatching /- Complete original collision records, ordinary-prime product splits, and uniform leading-prime survival from the proved inverse-totient bound. -/ open Filter Finset open scoped Topology BigOperators namespace Erdos416Proof.CollisionRecord variable {L : ℕ} /-- The ordinary-prime tail immediately after the matched prefix. -/ /- Original line 24342: Erdos416Proof.CollisionRecord.tailIndex -/ def tailIndex (J : Fin (L + 1)) (idx : Fin (L - J.val)) : Fin (L + 1) := ⟨J.val + 1 + idx.val, by have := idx.isLt; have := J.isLt; omega⟩ /- Original line 24345: Erdos416Proof.CollisionRecord.tailIndex_val -/ theorem tailIndex_val (J : Fin (L + 1)) (idx : Fin (L - J.val)) : (tailIndex J idx).val = J.val + 1 + idx.val := rfl /- Original line 24348: Erdos416Proof.CollisionRecord.tailIndex_gt -/ theorem tailIndex_gt (J : Fin (L + 1)) (idx : Fin (L - J.val)) : J < tailIndex J idx := by change J.val < J.val + 1 + idx.val omega /- Original line 24352: Erdos416Proof.CollisionRecord.leftPrimes -/ abbrev leftPrimes (J : Fin (L + 1)) (p : Fin (L + 1) → ℕ) : Fin (J.val + 1) → ℕ := fun idx => p (CollisionMatching.prefixIndex J idx) /- Original line 24355: Erdos416Proof.CollisionRecord.tailPrimes -/ abbrev tailPrimes (J : Fin (L + 1)) (p : Fin (L + 1) → ℕ) : Fin (L - J.val) → ℕ := fun idx => p (tailIndex J idx) /- Original line 24358: Erdos416Proof.CollisionRecord.prod_split -/ theorem prod_split {M : Type*} [CommMonoid M] (J : Fin (L + 1)) (f : Fin (L + 1) → M) : (∏ idx, f (CollisionMatching.prefixIndex J idx)) * (∏ idx, f (tailIndex J idx)) = ∏ idx, f idx := by have hlen : (J.val + 1) + (L - J.val) = L + 1 := by have := J.isLt; omega have hprod := Fin.prod_congr' f hlen rw [Fin.prod_univ_add] at hprod exact hprod /- Original line 24365: Erdos416Proof.CollisionRecord.leftPrimes_injective -/ theorem leftPrimes_injective (J : Fin (L + 1)) {p : Fin (L + 1) → ℕ} (hp : Function.Injective p) : Function.Injective (leftPrimes J p) := by intro idx j hij have heq := congrArg (fun k : Fin (L + 1) => k.val) (hp hij) exact Fin.ext heq /- Original line 24371: Erdos416Proof.CollisionRecord.leftPrimes_zero -/ theorem leftPrimes_zero (J : Fin (L + 1)) (p : Fin (L + 1) → ℕ) (idx : Fin (J.val + 1)) (hi : idx.val = 0) : leftPrimes J p idx = p 0 := by exact congrArg p (Fin.ext hi) /-- Every positive preimage is smaller than the square of a prime above the original tuple's leading-prime threshold, uniformly in the preimage. -/ /- Original line 24377: Erdos416Proof.CollisionRecord.preimage_le_top_square_eventually -/ theorem preimage_le_top_square_eventually : ∀ᶠ Y : ℝ in atTop, ∀ N p : ℕ, 0 < N → (N.totient : ℝ) ≤ Y → Y ^ (9 / 10 : ℝ) < (p : ℝ) → N ≤ p ^ 2 := by obtain ⟨D, hD, hpreimage⟩ := inverse_totient_bound_eventually have hsmall := (log_pow_mul_rpow_littleO 1 (show (1 : ℝ) < 9 / 5 by norm_num)).const_mul_left D filter_upwards [hpreimage, hsmall.bound (by norm_num : (0 : ℝ) < 1), eventually_gt_atTop (1 : ℝ)] with Y hpre hbound hY have hYpos : 0 < Y := by linarith simp only [pow_one, Real.rpow_one, one_mul, Real.norm_eq_abs] at hbound rw [abs_of_nonneg (mul_nonneg hD.le (mul_nonneg (Real.log_pos hY).le hYpos.le)), abs_of_nonneg (Real.rpow_nonneg hYpos.le _)] at hbound intro N p hN hsize htop have hreal : (N : ℝ) ≤ (p : ℝ) ^ 2 := by calc (N : ℝ) ≤ D * Y * Real.log (Real.log Y) := hpre N hN hsize _ ≤ D * Y * Real.log Y := mul_le_mul_of_nonneg_left (Real.log_le_self (Real.log_pos hY).le) (by positivity) _ ≤ Y ^ (9 / 5 : ℝ) := by nlinarith [hbound] _ = (Y ^ (9 / 10 : ℝ)) ^ 2 := by rw [← Real.rpow_natCast, ← Real.rpow_mul hYpos.le] congr 1 norm_num _ ≤ (p : ℝ) ^ 2 := pow_le_pow_left₀ (Real.rpow_nonneg hYpos.le _) htop.le 2 exact_mod_cast hreal /- Original line 24402: Erdos416Proof.CollisionRecord.common -/ noncomputable def common {N : ℕ} {Y : ℝ} (J : Fin (L + 1)) (p : Fin (L + 1) → ℕ) (Q : NormalPreimageList N (normalityScale (logLog Y))) (ha : J.val + 1 ≤ (largeShiftPrimes N (normalityScale (logLog Y))).card) : Finset (Fin (J.val + 1)) := commonIndices Finset.univ (leftPrimes J p) (CollisionClass.prefixPrimes Q ha) /- Original line 24407: Erdos416Proof.CollisionRecord.commonProduct -/ noncomputable def commonProduct (J : Fin (L + 1)) (p : Fin (L + 1) → ℕ) (C : Finset (Fin (J.val + 1))) : ℕ := ∏ idx ∈ C, leftPrimes J p idx /- Original line 24410: Erdos416Proof.CollisionRecord.upper -/ noncomputable def upper (Y : ℝ) (p : Fin (L + 1) → ℕ) (ε h b : ℝ) (J : Fin (L + 1)) (C : Finset (Fin (J.val + 1))) : ℕ → ℝ := let w := fun idx => CollisionBox.shiftedCoordinate (logLog Y) (p idx) CollisionCutoff.upper Y L (normalityDelta (logLog Y)) (CollisionCutoff.selectedZeta J C ε w) (CollisionBox.tailCoordinate ε h b w J) /- Original line 24416: Erdos416Proof.CollisionRecord.lower -/ noncomputable def lower (Y : ℝ) (p : Fin (L + 1) → ℕ) (ε h b : ℝ) (J : Fin (L + 1)) (C : Finset (Fin (J.val + 1))) : ℕ → ℝ := let w := fun idx => CollisionBox.shiftedCoordinate (logLog Y) (p idx) CollisionCutoff.lower Y L (normalityDelta (logLog Y)) ε (CollisionCutoff.selectedZeta J C ε w) (CollisionBox.tailCoordinate ε h b w J) /-- All records needed to apply the proved finite collision-class sieve. The shared product and the ordinary integer are actual products of the given tuple; the right side is the chosen preimage's full residual. -/ /- Original line 24425: Erdos416Proof.CollisionRecord.Complete -/ structure Complete {N : ℕ} (Y : ℝ) (p : Fin (L + 1) → ℕ) (d : ℕ) (Q : NormalPreimageList N (normalityScale (logLog Y))) (ε h b : ℝ) (J : Fin (L + 1)) (ha : J.val + 1 ≤ (largeShiftPrimes N (normalityScale (logLog Y))).card) : Prop where tail_pos : 1 ≤ L - J.val zero_survives : ∀ idx : Fin (J.val + 1), idx.val = 0 → idx ∉ common J p Q ha cutoffs : CollisionCutoff.SieveCutoffs (CollisionClass.remaining (common J p Q ha)).card Y (normalityDelta (logLog Y)) (upper Y p ε h b J (common J p Q ha)) (lower Y p ε h b J (common J p Q ha)) conditions : CollisionClass.Conditions (common J p Q ha) d (commonProduct J p (common J p Q ha)) (∏ idx, p idx) (normalityScale (logLog Y)) Y (upper Y p ε h b J (common J p Q ha)) (lower Y p ε h b J (common J p Q ha)) (leftPrimes J p) (CollisionClass.prefixPrimes Q ha) (tailPrimes J p) (CollisionClass.normalResidual Q (J.val + 1)) /-- Instantiate every original-equation condition of the class sieve, using the actual matching theorem and the leading-prime size argument. -/ /- Original line 24441: Erdos416Proof.CollisionRecord.complete_of_matched -/ theorem complete_of_matched {N d : ℕ} {Y ε h b : ℝ} {p : Fin (L + 1) → ℕ} (Q : NormalPreimageList N (normalityScale (logLog Y))) (J : Fin (L + 1)) (ha : J.val + 1 ≤ (largeShiftPrimes N (normalityScale (logLog Y))).card) (hm : CollisionMatching.MatchedPreimage Y p Q ε h b J ha) (hJL : J.val < L) (hN : 0 < N) (hp : ∀ idx, SNormal (normalityScale (logLog Y)) (p idx)) (hinj : Function.Injective p) (hphi : N.totient = d * ∏ idx, (p idx - 1)) (hsize : (N.totient : ℝ) ≤ Y) (hsquare : NoLargePrimeSquare N.totient (normalityScale (logLog Y))) (htop : Y ^ (9 / 10 : ℝ) < (p 0 : ℝ)) (hsizetop : N ≤ (p 0) ^ 2) (hneq : largestPrimeFactor N ≠ p 0) : Complete Y p d Q ε h b J ha := by let C := common J p Q ha have hzero : ∀ idx : Fin (J.val + 1), idx.val = 0 → idx ∉ C := by apply CollisionClass.common_zero_absent Q ha C (leftPrimes J p) hN (fun idx => (hp (CollisionMatching.prefixIndex J idx)).1) rfl · intro idx hi simpa only [leftPrimes_zero J p idx hi] using hsizetop · intro idx hi simpa only [leftPrimes_zero J p idx hi] using hneq obtain ⟨hk, hv, hpaired⟩ := hm.paired C hzero have hS : 1 ≤ normalityScale (logLog Y) := (Real.one_le_exp (by norm_num : (0 : ℝ) ≤ 1)).trans (normalityScale_ge_exp_one _) have htailEq : CollisionMatching.tailCutoff Y L (CollisionBox.tailCoordinate ε h b (fun idx => CollisionBox.shiftedCoordinate (logLog Y) (p idx)) J) = upper Y p ε h b J C (CollisionClass.remaining C).card := CollisionMatching.tailCutoff_eq_upper Y L _ _ hk refine ⟨by omega, hzero, hv, ?_⟩ apply CollisionClass.conditions_of_normalPreimage Q ha C d (commonProduct J p C) (∏ idx, p idx) (upper Y p ε h b J C) (lower Y p ε h b J C) (leftPrimes J p) (tailPrimes J p) hS hv.normality (fun idx => hp (CollisionMatching.prefixIndex J idx)) (fun idx => hp (tailIndex J idx)) (leftPrimes_injective J hinj) rfl rfl (prod_split J p) · simpa only [leftPrimes, tailPrimes, prod_split J (fun idx => p idx - 1)] using hphi · exact hsize · exact hsquare.mono hv.normality · intro idx simpa only [CollisionMatching.selectedIndex_eq_prefixIndex, leftPrimes, upper, lower] using (hpaired idx).1 · intro idx exact (hpaired idx).2 · intro idx z hz exact htailEq ▸ hm.left_tail (tailIndex J idx) (tailIndex_gt J idx) z hz · intro j hj exact htailEq ▸ (hm.right_tail j hj).le · intro idx hi simpa only [leftPrimes_zero J p idx hi] using htop /-- Actual complete records for every retained original tuple and every admissible collision witness, uniformly in the dimension and prime data. The right normal-preimage list and every sieve record are constructed. -/ /- Original line 24488: Erdos416Proof.CollisionRecord.complete_records_eventually -/ theorem complete_records_eventually (A P κ θ : ℝ) (hκ : 1 < κ) (hθ : θ < 1) : ∀ᶠ Y : ℝ in atTop, ∀ (L : ℕ) (p : Fin (L + 1) → ℕ) (N d : ℕ), (L : ℝ) ≤ A * Real.log (logLog Y) → (∀ idx, SNormal (normalityScale (logLog Y)) (p idx)) → (∀ idx, 17 ≤ p idx) → StrictAnti p → (∀ idx : Fin (L + 1), 0 < idx.val → ∀ hi : idx.val + 1 < L + 1, κ * logLog (p ⟨idx.val + 1, hi⟩) ≤ logLog (p idx)) → (∀ idx, 0 < idx.val → (p idx : ℝ) ≤ CollisionBox.cutoff Y θ) → (p (Fin.last L) : ℝ) ≤ P → Y ^ (9 / 10 : ℝ) < (p 0 : ℝ) → 0 < N → 0 < d → (largestPrimeFactor d : ℝ) ≤ normalityScale (logLog Y) → N.totient = d * ∏ idx, (p idx - 1) → (N.totient : ℝ) ≤ Y → largestPrimeFactor N ≠ p 0 → (∀ q ∈ N.primeFactors, SNormal (normalityScale (logLog Y)) q) → NoLargePrimeSquare N (Real.log Y ^ 4) → NoLargePrimeSquare N.totient (Real.log Y ^ 4) → ∃ Q : NormalPreimageList N (normalityScale (logLog Y)), ∃ J : Fin (L + 1), J.val < L ∧ (∀ idx, idx ≤ J ↔ (logLog Y) ^ (-1 / 3 : ℝ) < CollisionBox.shiftedCoordinate (logLog Y) (p idx)) ∧ ∃ ha : J.val + 1 ≤ (largeShiftPrimes N (normalityScale (logLog Y))).card, CollisionMatching.MatchedPreimage Y p Q (1 / logLog Y) ((logLog Y) ^ (-2 / 5 : ℝ)) ((logLog Y) ^ (-1 / 3 : ℝ)) J ha ∧ Complete Y p d Q (1 / logLog Y) ((logLog Y) ^ (-2 / 5 : ℝ)) ((logLog Y) ^ (-1 / 3 : ℝ)) J ha := by filter_upwards [CollisionMatching.matched_preimage_eventually A P κ θ hκ hθ, preimage_le_top_square_eventually, fourth_log_cutoff_lt_normalityScale] with Y hmatch htopsize hcutoff intro L p N d hL hp hp17 horder hstep hlower hlast htop hN hd hdS hphi hsize hneq hnormal hsquareN hsquarePhi have hS : 1 ≤ normalityScale (logLog Y) := (Real.one_le_exp (by norm_num : (0 : ℝ) ≤ 1)).trans (normalityScale_ge_exp_one _) have hcut : Real.log Y ^ 4 ≤ normalityScale (logLog Y) := hcutoff.le have hsqPhi := hsquarePhi.mono hcut obtain ⟨Q⟩ := exists_NormalPreimageList hN hS hnormal (hsquareN.mono hcut) hsqPhi obtain ⟨J, hJL, hprefix, ha, hm⟩ := hmatch L p N d Q hL hp hp17 horder.antitone hstep hlower hlast htop hN hd hdS hphi hsize exact ⟨Q, J, hJL, hprefix, ha, hm, complete_of_matched Q J ha hm hJL hN hp horder.injective hphi hsize hsqPhi htop (htopsize N (p 0) hN hsize htop) hneq⟩ end Erdos416Proof.CollisionRecord /- Direct strict-facet application to the actual selected cutoffs, retaining half the original saving uniformly in the tuple length. -/ open Filter Finset open scoped Topology BigOperators namespace Erdos416Proof.CollisionFacet variable {L : ℕ} /-- The original coordinate vector, with zeros outside its finite range. -/ /- Original line 24539: Erdos416Proof.CollisionFacet.extend -/ noncomputable def extend (x : Fin (L + 1) → ℝ) (idx : ℕ) : ℝ := if hi : idx < L + 1 then x ⟨idx, hi⟩ else 0 /- Original line 24542: Erdos416Proof.CollisionFacet.extend_apply -/ theorem extend_apply (x : Fin (L + 1) → ℝ) (idx : Fin (L + 1)) : extend x idx.val = x idx := by simp only [extend, dif_pos idx.isLt] /- Original line 24545: Erdos416Proof.CollisionFacet.extend_nonneg -/ theorem extend_nonneg {x : Fin (L + 1) → ℝ} (hx : ∀ idx, 0 ≤ x idx) (idx : ℕ) : 0 ≤ extend x idx := by unfold extend split_ifs with hi · exact hx _ · exact le_rfl /-- Rounding a shifted coordinate is controlled directly by the original ordinary coordinate, including when the shifted coordinate is negative. -/ /- Original line 24554: Erdos416Proof.CollisionFacet.rounded_le_ordinary -/ theorem rounded_le_ordinary {x w : Fin (L + 1) → ℝ} {ε : ℝ} (hε : 0 < ε) (hx : ∀ idx, 0 ≤ x idx) (hwx : ∀ idx, w idx ≤ x idx) (idx : Fin (L + 1)) (hi : 0 < idx.val) : CollisionBox.rounded ε w idx ≤ x idx + ε := by rw [CollisionBox.rounded_of_pos ε w idx hi] exact (CollisionBox.roundUp_mono hε (hwx idx)).trans (CollisionBox.roundUp_bounds hε (hx idx)).2.le /-- Removing common positions only moves the i-th retained coordinate to the right in the ordinary ordered tuple. No ordering assumption on the full shifted-factor tuple is needed. -/ /- Original line 24563: Erdos416Proof.CollisionFacet.selected_nu_le -/ theorem selected_nu_le {x w : Fin (L + 1) → ℝ} {δ ε zstar : ℝ} (J : Fin (L + 1)) (C : Finset (Fin (J.val + 1))) (hε : 0 < ε) (hx : ∀ idx, 0 ≤ x idx) (hanti : Antitone x) (hwx : ∀ idx, w idx ≤ x idx) (idx : ℕ) (hi : 1 ≤ idx) (hik : idx < (CollisionClass.remaining C).card) : CollisionCutoff.nu L δ (CollisionCutoff.selectedZeta J C ε w) zstar idx ≤ extend x idx + ((2 * L + 1 : ℝ) * δ + ε) := by let j := CollisionCutoff.selectedIndex J C ⟨idx, hik⟩ have hij : idx ≤ j.val := CollisionCutoff.selectedIndex_val_ge J C ⟨idx, hik⟩ have hiL : idx < L + 1 := lt_of_le_of_lt hij j.isLt have hjpos : 0 < j.val := by omega have hround := rounded_le_ordinary hε hx hwx j hjpos have horder : x j ≤ x ⟨idx, hiL⟩ := hanti hij rw [CollisionCutoff.nu_internal L δ _ zstar (by omega) hik] simp only [extend, dif_pos hiL] change CollisionBox.rounded ε w j + (2 * L + 1 : ℝ) * δ ≤ _ linarith /-- The total extra mesh error is uniformly smaller than half the original strict facet saving, even while the number of primes grows with the scale. -/ /- Original line 24582: Erdos416Proof.CollisionFacet.mesh_error_eventually -/ theorem mesh_error_eventually {A : ℝ} (hA : 0 ≤ A) : ∀ᶠ T : ℝ in atTop, ∀ L : ℕ, (L : ℝ) ≤ A * Real.log T → (1 / T) * L * Real.log ((L : ℝ) + 1) ≤ (1 / 2 : ℝ) * T ^ (-1 / 8 : ℝ) := by have hsmall := (log_pow_mul_rpow_littleO 2 (show (-1 : ℝ) < -1 / 8 by norm_num)).const_mul_left (A + 1) filter_upwards [dimension_log_bounds_eventually A, hsmall.bound (by norm_num : (0 : ℝ) < 1 / 2), eventually_gt_atTop (1 : ℝ)] with T hdim hbound hT have hTpos : 0 < T := by linarith have hlog : 0 ≤ Real.log T := (Real.log_pos hT).le simp only [Real.norm_eq_abs] at hbound rw [abs_of_nonneg (by positivity : 0 ≤ (A + 1) * (Real.log T ^ 2 * T ^ (-1 : ℝ))), abs_of_nonneg (Real.rpow_nonneg hTpos.le _)] at hbound intro L hL have hdimL := hdim L hL have hLL : (L : ℝ) ≤ (A + 1) * Real.log T := by linarith [hdimL.1] calc (1 / T) * L * Real.log ((L : ℝ) + 1) ≤ (1 / T) * ((A + 1) * Real.log T) * Real.log T := by apply mul_le_mul · exact mul_le_mul_of_nonneg_left hLL (by positivity) · exact hdimL.2 · exact Real.log_nonneg (by linarith [Nat.cast_nonneg (α := ℝ) L] : (1 : ℝ) ≤ (L : ℝ) + 1) · positivity _ = (A + 1) * (Real.log T ^ 2 * T ^ (-1 : ℝ)) := by rw [Real.rpow_neg_one]; ring _ ≤ _ := hbound /-- Apply the checked sieve exponent directly to the original facet. The one-sided mesh cost is explicit, so a separate rounded-facet construction and a second ordering proof are unnecessary. -/ /- Original line 24611: Erdos416Proof.CollisionFacet.selected_exponent_le -/ theorem selected_exponent_le {x w : Fin (L + 1) → ℝ} {δ ε zstar σ : ℝ} (J : Fin (L + 1)) (C : Finset (Fin (J.val + 1))) (hk : 1 ≤ (CollisionClass.remaining C).card) (hδ : 0 ≤ δ) (hε : 0 < ε) (hx : ∀ idx, 0 ≤ x idx) (hanti : Antitone x) (hwx : ∀ idx, w idx ≤ x idx) (hfacet : (∑ idx ∈ Finset.Icc 1 L, fordWeight idx * extend x idx) ≤ 1 - σ) : let k := (CollisionClass.remaining C).card; let z := CollisionCutoff.selectedZeta J C ε w; let ν := CollisionCutoff.nu L δ z zstar; let μ := CollisionCutoff.mu L δ ε z zstar; -2 + (∑ idx ∈ Finset.Icc 1 (k - 1), fordWeight idx * ν idx) + fordSieveError k (δ / 2) ν μ ≤ -1 - σ + (((2 * L + 1 : ℝ) * δ + ε) * L * Real.log ((L : ℝ) + 1)) + δ * ((L : ℝ) + 1) ^ 2 * (Real.log ((L : ℝ) + 1) + 1) + 2 * L * ((4 * L + 2 : ℝ) * δ + ε) := by dsimp only have hkL : (CollisionClass.remaining C).card ≤ L + 1 := (CollisionClass.remaining_card_le C).trans (by have := J.isLt; omega) have hwidth : ∀ idx ∈ Finset.Icc 1 ((CollisionClass.remaining C).card - 1), CollisionCutoff.nu L δ (CollisionCutoff.selectedZeta J C ε w) zstar idx - CollisionCutoff.mu L δ ε (CollisionCutoff.selectedZeta J C ε w) zstar idx ≤ (4 * L + 2 : ℝ) * δ + ε := by intro idx _ unfold CollisionCutoff.mu linarith have hν : ∀ idx ∈ Finset.Icc 1 ((CollisionClass.remaining C).card - 1), CollisionCutoff.nu L δ (CollisionCutoff.selectedZeta J C ε w) zstar idx ≤ extend x idx + ((2 * L + 1 : ℝ) * δ + ε) := by intro idx hi have hi' := Finset.mem_Icc.mp hi exact selected_nu_le J C hε hx hanti hwx idx hi'.1 (by omega) have h := ford_sieve_exponent_le hkL (extend x) (CollisionCutoff.nu L δ (CollisionCutoff.selectedZeta J C ε w) zstar) (CollisionCutoff.mu L δ ε (CollisionCutoff.selectedZeta J C ε w) zstar) (show 0 ≤ δ / 2 by positivity) (by positivity) (by positivity) (fun idx _ => extend_nonneg hx idx) hν hwidth hfacet have hc : 0 ≤ ((L : ℝ) + 1) ^ 2 * (Real.log ((L : ℝ) + 1) + 1) := by have hlog := Real.log_nonneg (by linarith [Nat.cast_nonneg (α := ℝ) L] : (1 : ℝ) ≤ (L : ℝ) + 1) positivity nlinarith [mul_nonneg hδ hc] /-- The actual mesh and normality scales retain half the strict saving, with exactly the loss term already handled by the prefactor absorption. -/ /- Original line 24652: Erdos416Proof.CollisionFacet.selected_exponent_eventually -/ theorem selected_exponent_eventually {A : ℝ} (hA : 0 ≤ A) : ∀ᶠ T : ℝ in atTop, ∀ (L : ℕ) (x w : Fin (L + 1) → ℝ) (J : Fin (L + 1)) (C : Finset (Fin (J.val + 1))) (zstar : ℝ), (L : ℝ) ≤ A * Real.log T → 1 ≤ (CollisionClass.remaining C).card → (∀ idx, 0 ≤ x idx) → Antitone x → (∀ idx, w idx ≤ x idx) → (∑ idx ∈ Finset.Icc 1 L, fordWeight idx * extend x idx) ≤ 1 - T ^ (-1 / 8 : ℝ) → let k := (CollisionClass.remaining C).card; let z := CollisionCutoff.selectedZeta J C (1 / T) w; let ν := CollisionCutoff.nu L (normalityDelta T) z zstar; let μ := CollisionCutoff.mu L (normalityDelta T) (1 / T) z zstar; -2 + (∑ idx ∈ Finset.Icc 1 (k - 1), fordWeight idx * ν idx) + fordSieveError k (normalityDelta T / 2) ν μ ≤ -1 - (1 / 2 : ℝ) * T ^ (-1 / 8 : ℝ) + normalitySieveLoss T L / T := by filter_upwards [mesh_error_eventually hA, eventually_gt_atTop (1 : ℝ)] with T hmesh hT intro L x w J C zstar hL hk hx hanti hwx hfacet have hTpos : 0 < T := by linarith have h := selected_exponent_le (zstar := zstar) J C hk (normalityDelta_nonneg hT.le) (by positivity : 0 < 1 / T) hx hanti hwx hfacet have herror := hmesh L hL dsimp only at h ⊢ have hloss : normalitySieveLoss T L / T = ((2 * L + 1 : ℝ) * normalityDelta T) * L * Real.log ((L : ℝ) + 1) + normalityDelta T * ((L : ℝ) + 1) ^ 2 * (Real.log ((L : ℝ) + 1) + 1) + 2 * L * ((4 * L + 2 : ℝ) * normalityDelta T + 1 / T) := by unfold normalitySieveLoss exact mul_div_cancel_right₀ _ hTpos.ne' rw [hloss] nlinarith /-- The exponent in the actual class sieve, at its real cutoffs. -/ /- Original line 24682: Erdos416Proof.CollisionFacet.actualExponent -/ noncomputable def actualExponent (Y : ℝ) (k : ℕ) (v W : ℕ → ℝ) : ℝ := -2 + (∑ idx ∈ Finset.Icc 1 (k - 1), fordWeight idx * (logLog (v idx) / logLog Y)) + fordSieveError k (normalityDelta (logLog Y) / 2) (fun idx => logLog (v idx) / logLog Y) (fun idx => logLog (W idx) / logLog Y) /-- Uniform strict-facet application to the original prime tuple and the actual surviving cutoffs. All coordinate inequalities follow from ordinary prime ordering and p_i>=17; no shifted-coordinate ordering is assumed. -/ /- Original line 24690: Erdos416Proof.CollisionFacet.cutoff_exponent_eventually -/ theorem cutoff_exponent_eventually {A : ℝ} (hA : 0 ≤ A) : ∀ᶠ Y : ℝ in atTop, ∀ (L : ℕ) (p : Fin (L + 1) → ℕ) (J : Fin (L + 1)) (C : Finset (Fin (J.val + 1))) (h b : ℝ), (L : ℝ) ≤ A * Real.log (logLog Y) → 1 ≤ (CollisionClass.remaining C).card → (∀ idx, 17 ≤ p idx) → Antitone p → (∑ idx ∈ Finset.Icc 1 L, fordWeight idx * extend (fun j => CollisionBox.primeCoordinate (logLog Y) (p j)) idx) ≤ 1 - (logLog Y) ^ (-1 / 8 : ℝ) → actualExponent Y (CollisionClass.remaining C).card (CollisionRecord.upper Y p (1 / logLog Y) h b J C) (CollisionRecord.lower Y p (1 / logLog Y) h b J C) ≤ -1 - (1 / 2 : ℝ) * (logLog Y) ^ (-1 / 8 : ℝ) + normalitySieveLoss (logLog Y) L / logLog Y := by have hT : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [hT.eventually (selected_exponent_eventually hA), hT.eventually_gt_atTop 1, eventually_gt_atTop (1 : ℝ)] with Y hselected hT1 hY intro L p J C h b hL hk hp17 horder hfacet have hTpos : 0 < logLog Y := by linarith have hx : ∀ idx, 0 ≤ CollisionBox.primeCoordinate (logLog Y) (p idx) := by intro idx apply div_nonneg _ hTpos.le apply logLog_nonneg have hpi : (17 : ℝ) ≤ p idx := by exact_mod_cast hp17 idx linarith [Real.exp_one_lt_three] have hanti : Antitone (fun idx => CollisionBox.primeCoordinate (logLog Y) (p idx)) := by intro idx j hij apply div_le_div_of_nonneg_right _ hTpos.le apply logLog_mono (by have := hp17 j; norm_cast; omega) exact_mod_cast horder hij have hs := hselected L (fun idx => CollisionBox.primeCoordinate (logLog Y) (p idx)) (fun idx => CollisionBox.shiftedCoordinate (logLog Y) (p idx)) J C (CollisionBox.tailCoordinate (1 / logLog Y) h b (fun idx => CollisionBox.shiftedCoordinate (logLog Y) (p idx)) J) hL hk hx hanti (fun idx => CollisionBox.shiftedCoordinate_le hTpos (hp17 idx)) hfacet simpa only [actualExponent, CollisionRecord.upper, CollisionRecord.lower, CollisionCutoff.upper, CollisionCutoff.lower, CollisionBox.normalized_cutoff hY hTpos.ne'] using hs end Erdos416Proof.CollisionFacet /- Exponential saving for each actual finite collision class, including a fixed reserve for the later sum over classes. -/ open Filter Finset open scoped Topology BigOperators namespace Erdos416Proof.CollisionSaving /-- Convert the checked logarithmic loss absorption into a bound for the actual positive sieve factor, with a reserve for the later class sum. -/ /- Original line 24743: Erdos416Proof.CollisionSaving.prefactor_saving_eventually -/ theorem prefactor_saving_eventually {A c : ℝ} (hA : 0 ≤ A) (hc : 0 < c) (D : ℕ) (K : ℝ) : ∀ᶠ T : ℝ in atTop, ∀ (k l L : ℕ) (ζ E : ℝ), 1 ≤ k + l → k + l ≤ L + 1 → (L : ℝ) ≤ A * Real.log T → ζ ≤ T ^ (-1 / 3 : ℝ) → E ≤ -1 - (1 / 2 : ℝ) * T ^ (-1 / 8 : ℝ) + normalitySieveLoss T L / T → fordSievePrefactor T (ζ + (2 * L + 3 : ℝ) * normalityDelta T) c k l D * (Real.exp T) ^ E ≤ (1 / Real.exp T) * Real.exp (-(1 / 4 : ℝ) * T ^ (7 / 8 : ℝ) - K * sieveErrorEnvelope T) := by filter_upwards [ford_sieve_losses_absorbed hA hc D K, eventually_gt_atTop (0 : ℝ)] with T habs hT intro k l L ζ E hkl hklL hL hζ hE have hsave := habs k l L ζ hkl hklL hL hζ have hET := mul_le_mul_of_nonneg_right hE hT.le have hpowers : T ^ (-1 / 8 : ℝ) * T = T ^ (7 / 8 : ℝ) := by calc _ = T ^ (-1 / 8 : ℝ) * T ^ (1 : ℝ) := by rw [Real.rpow_one] _ = T ^ ((-1 / 8 : ℝ) + 1) := (Real.rpow_add hT _ _).symm _ = _ := by congr 1; norm_num rw [add_mul, sub_mul, div_mul_cancel₀ _ hT.ne'] at hET rw [mul_assoc, hpowers] at hET have hlog : fordLogPrefactor T (ζ + (2 * L + 3 : ℝ) * normalityDelta T) c k l D + E * T ≤ -T - (1 / 4 : ℝ) * T ^ (7 / 8 : ℝ) - K * sieveErrorEnvelope T := by nlinarith have hpref : 0 < fordSievePrefactor T (ζ + (2 * L + 3 : ℝ) * normalityDelta T) c k l D := by unfold fordSievePrefactor positivity have hexp := Real.exp_le_exp.mpr hlog rw [Real.exp_add, ← log_fordSievePrefactor hT hc, Real.exp_log hpref] at hexp have hpower : (Real.exp T) ^ E = Real.exp (E * T) := by rw [Real.rpow_def_of_pos (Real.exp_pos T), Real.log_exp, mul_comm] rw [← hpower] at hexp convert hexp using 1 rw [show -T - (1 / 4 : ℝ) * T ^ (7 / 8 : ℝ) - K * sieveErrorEnvelope T = -T + (-(1 / 4 : ℝ) * T ^ (7 / 8 : ℝ) - K * sieveErrorEnvelope T) by ring, Real.exp_add, Real.exp_neg, one_div] variable {L : ℕ} /- Original line 24777: Erdos416Proof.CollisionSaving.log_upper_tail -/ theorem log_upper_tail {Y ε h b : ℝ} (hY : 1 < Y) (p : Fin (L + 1) → ℕ) (J : Fin (L + 1)) (C : Finset (Fin (J.val + 1))) (hk : 1 ≤ (CollisionClass.remaining C).card) : Real.log (CollisionRecord.upper Y p ε h b J C (CollisionClass.remaining C).card) = Real.exp ((CollisionBox.tailCoordinate ε h b (fun idx => CollisionBox.shiftedCoordinate (logLog Y) (p idx)) J + (2 * L + 3 : ℝ) * normalityDelta (logLog Y)) * logLog Y) := by unfold CollisionRecord.upper CollisionCutoff.upper rw [CollisionCutoff.nu_tail L _ _ _ hk le_rfl, CollisionCutoff.cutoff_exp_exp hY, Real.log_exp] /-- A complete class has an exponentially small count. The reserve K can absorb the later number of boxes and reciprocal shared-product sum. All analytic inputs are proved; the original class records and cutoff record are the objects constructed by CollisionRecord.Complete. -/ /- Original line 24789: Erdos416Proof.CollisionSaving.class_saving_eventually -/ theorem class_saving_eventually {A : ℝ} (hA : 0 ≤ A) (d : ℕ) (hd : 0 < d) (K : ℝ) : ∀ᶠ Y : ℝ in atTop, ∀ (L : ℕ) (J : Fin (L + 1)) (C : Finset (Fin (J.val + 1))) (M : ℕ) (F : Finset ℕ) (pstar : Fin (L + 1) → ℕ) (p q : ℕ → Fin (J.val + 1) → ℕ) (t : ℕ → Fin (L - J.val) → ℕ) (e : ℕ → ℕ), let T := logLog Y; let k := (CollisionClass.remaining C).card; let v := CollisionRecord.upper Y pstar (1 / T) (T ^ (-2 / 5 : ℝ)) (T ^ (-1 / 3 : ℝ)) J C; let W := CollisionRecord.lower Y pstar (1 / T) (T ^ (-2 / 5 : ℝ)) (T ^ (-1 / 3 : ℝ)) J C; (L : ℝ) ≤ A * Real.log T → J.val < L → (∀ idx : Fin (J.val + 1), idx.val = 0 → idx ∉ C) → CollisionCutoff.SieveCutoffs k Y (normalityDelta T) v W → (largestPrimeFactor d : ℝ) ≤ normalityScale T → (∀ idx, 17 ≤ pstar idx) → Antitone pstar → (∑ idx ∈ Finset.Icc 1 L, fordWeight idx * CollisionFacet.extend (fun j => CollisionBox.primeCoordinate T (pstar j)) idx) ≤ 1 - T ^ (-1 / 8 : ℝ) → (∀ n ∈ F, CollisionClass.Conditions C d M n (normalityScale T) Y v W (p n) (q n) (t n) (e n)) → (F.card : ℝ) ≤ Y / ((d : ℝ) * M.totient * Real.log Y) * Real.exp (-(1 / 4 : ℝ) * T ^ (7 / 8 : ℝ) - K * sieveErrorEnvelope T) := by obtain ⟨c, hc, hclass⟩ := CollisionClass.exists_collision_class_sieve_bound have hT : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [hclass, CollisionFacet.cutoff_exponent_eventually hA, hT.eventually (prefactor_saving_eventually hA hc (ArithmeticFunction.cardFactors d) K), eventually_gt_atTop (1 : ℝ)] with Y hcount hexponent hsave hY intro L J C M F pstar p q t e dsimp only intro hL hJL hzero hcuts hdS hp17 horder hfacet hF let T := logLog Y let k := (CollisionClass.remaining C).card let ζ := CollisionBox.tailCoordinate (1 / T) (T ^ (-2 / 5 : ℝ)) (T ^ (-1 / 3 : ℝ)) (fun idx => CollisionBox.shiftedCoordinate T (pstar idx)) J let v := CollisionRecord.upper Y pstar (1 / T) (T ^ (-2 / 5 : ℝ)) (T ^ (-1 / 3 : ℝ)) J C let W := CollisionRecord.lower Y pstar (1 / T) (T ^ (-2 / 5 : ℝ)) (T ^ (-1 / 3 : ℝ)) J C have hk : 1 ≤ k := CollisionClass.remaining_card_pos C (by omega) hzero have hkL : k ≤ J.val + 1 := CollisionClass.remaining_card_le C have hζ : ζ ≤ T ^ (-1 / 3 : ℝ) := min_le_left _ _ have hE := hexponent L pstar J C (T ^ (-2 / 5 : ℝ)) (T ^ (-1 / 3 : ℝ)) hL hk hp17 horder hfacet have hfactors := hsave k (L - J.val) L ζ (CollisionFacet.actualExponent Y k v W) (by omega) (by omega) hL hζ hE have hexpT : Real.exp T = Real.log Y := Real.exp_log (Real.log_pos hY) rw [hexpT] at hfactors have hlogtail : Real.log (v k) = Real.exp ((ζ + (2 * L + 3 : ℝ) * normalityDelta T) * T) := log_upper_tail hY pstar J C hk dsimp only [T, k] at hlogtail have hdv : ∀ z ∈ d.primeFactorsList, (z : ℝ) ≤ v k := by intro z hz exact (Nat.cast_le.mpr (primeFactorsList_le_largestPrimeFactor hz)).trans (hdS.trans hcuts.normality) have hraw := hcount (J.val + 1) (L - J.val) d M C F p q t e v W (by omega) (by omega) hzero hcuts.normality hcuts.antitone hcuts.zero hcuts.interleaving hcuts.gaps hcuts.initial hd hdv hF calc (F.card : ℝ) ≤ (Y / ((d : ℝ) * M.totient)) * (fordSievePrefactor T (ζ + (2 * L + 3 : ℝ) * normalityDelta T) c k (L - J.val) (ArithmeticFunction.cardFactors d) * (Real.log Y) ^ CollisionFacet.actualExponent Y k v W) := by convert hraw using 1 simp only [fordSievePrefactor, CollisionFacet.actualExponent, T, k, hlogtail] ring _ ≤ (Y / ((d : ℝ) * M.totient)) * ((1 / Real.log Y) * Real.exp (-(1 / 4 : ℝ) * T ^ (7 / 8 : ℝ) - K * sieveErrorEnvelope T)) := mul_le_mul_of_nonneg_left hfactors (div_nonneg (by linarith) (mul_nonneg (Nat.cast_nonneg d) (Nat.cast_nonneg M.totient))) _ = _ := by ring end Erdos416Proof.CollisionSaving /- Actual collision-class partition, uniform weighted label sum, and the required count for the manuscript's retained original pairs. -/ open Filter Finset open scoped Topology BigOperators namespace Erdos416Proof.CollisionSum variable {L : ℕ} /- Original line 24868: Erdos416Proof.CollisionSum.upper -/ noncomputable abbrev upper (Y : ℝ) (p : Fin (L + 1) → ℕ) (J : Fin (L + 1)) (C : Finset (Fin (J.val + 1))) : ℕ → ℝ := CollisionRecord.upper Y p (1 / logLog Y) ((logLog Y) ^ (-2 / 5 : ℝ)) ((logLog Y) ^ (-1 / 3 : ℝ)) J C /- Original line 24872: Erdos416Proof.CollisionSum.lower -/ noncomputable abbrev lower (Y : ℝ) (p : Fin (L + 1) → ℕ) (J : Fin (L + 1)) (C : Finset (Fin (J.val + 1))) : ℕ → ℝ := CollisionRecord.lower Y p (1 / logLog Y) ((logLog Y) ^ (-2 / 5 : ℝ)) ((logLog Y) ^ (-1 / 3 : ℝ)) J C /- Original line 24876: Erdos416Proof.CollisionSum.box -/ noncomputable def box (Y : ℝ) (p : Fin (L + 1) → ℕ) : Fin (L + 1) → ℝ := CollisionBox.rounded (1 / logLog Y) (fun idx => CollisionBox.shiftedCoordinate (logLog Y) (p idx)) /- Original line 24879: Erdos416Proof.CollisionSum.prefixEmbedding -/ def prefixEmbedding (J : Fin (L + 1)) : Fin (J.val + 1) ↪ Fin (L + 1) where toFun := CollisionMatching.prefixIndex J inj' := by intro idx j hij exact Fin.ext (congrArg (fun k : Fin (L + 1) => k.val) hij) /- Original line 24885: Erdos416Proof.CollisionSum.commonCode -/ noncomputable def commonCode (J : Fin (L + 1)) (C : Finset (Fin (J.val + 1))) : Finset (Fin (L + 1)) := C.map (prefixEmbedding J) /- Original line 24888: Erdos416Proof.CollisionSum.commonCode_injective -/ theorem commonCode_injective (J : Fin (L + 1)) : Function.Injective (commonCode J) := Finset.map_injective (prefixEmbedding J) /- Original line 24891: Erdos416Proof.CollisionSum.cutoffs_eq_of_box_eq -/ theorem cutoffs_eq_of_box_eq {Y : ℝ} {p q : Fin (L + 1) → ℕ} (J : Fin (L + 1)) (C : Finset (Fin (J.val + 1))) (heq : box Y p = box Y q) : upper Y p J C = upper Y q J C ∧ lower Y p J C = lower Y q J C := by have hselected : CollisionCutoff.selectedZeta J C (1 / logLog Y) (fun idx => CollisionBox.shiftedCoordinate (logLog Y) (p idx)) = CollisionCutoff.selectedZeta J C (1 / logLog Y) (fun idx => CollisionBox.shiftedCoordinate (logLog Y) (q idx)) := by funext idx exact congrFun heq (CollisionCutoff.selectedIndex J C idx) have htail : CollisionBox.tailCoordinate (1 / logLog Y) ((logLog Y) ^ (-2 / 5 : ℝ)) ((logLog Y) ^ (-1 / 3 : ℝ)) (fun idx => CollisionBox.shiftedCoordinate (logLog Y) (p idx)) J = CollisionBox.tailCoordinate (1 / logLog Y) ((logLog Y) ^ (-2 / 5 : ℝ)) ((logLog Y) ^ (-1 / 3 : ℝ)) (fun idx => CollisionBox.shiftedCoordinate (logLog Y) (q idx)) J := by unfold CollisionBox.tailCoordinate rw [show CollisionBox.rounded (1 / logLog Y) (fun idx => CollisionBox.shiftedCoordinate (logLog Y) (p idx)) J = CollisionBox.rounded (1 / logLog Y) (fun idx => CollisionBox.shiftedCoordinate (logLog Y) (q idx)) J from congrFun heq J] constructor <;> simp only [upper, lower, CollisionRecord.upper, CollisionRecord.lower, hselected, htail] /-- One actual integer with its fully checked finite collision record. The class partition will select only one record per original integer. -/ /- Original line 24913: Erdos416Proof.CollisionSum.Record -/ structure Record (Y : ℝ) (L d : ℕ) where integer : ℕ primes : Fin (L + 1) → ℕ J : Fin (L + 1) common : Finset (Fin (J.val + 1)) right : Fin (J.val + 1) → ℕ residual : ℕ prefix_lt : J.val < L zero_survives : ∀ idx : Fin (J.val + 1), idx.val = 0 → idx ∉ common cutoffs : CollisionCutoff.SieveCutoffs (CollisionClass.remaining common).card Y (normalityDelta (logLog Y)) (upper Y primes J common) (lower Y primes J common) conditions : CollisionClass.Conditions common d (CollisionRecord.commonProduct J primes common) integer (normalityScale (logLog Y)) Y (upper Y primes J common) (lower Y primes J common) (CollisionRecord.leftPrimes J primes) right (CollisionRecord.tailPrimes J primes) residual prime_min : ∀ idx, 17 ≤ primes idx order : Antitone primes facet : (∑ idx ∈ Finset.Icc 1 L, fordWeight idx * CollisionFacet.extend (fun j => CollisionBox.primeCoordinate (logLog Y) (primes j)) idx) ≤ 1 - (logLog Y) ^ (-1 / 8 : ℝ) variable {Y : ℝ} {d : ℕ} /- Original line 24935: Erdos416Proof.CollisionSum.record_of_complete -/ noncomputable def record_of_complete {N : ℕ} {p : Fin (L + 1) → ℕ} {Q : NormalPreimageList N (normalityScale (logLog Y))} {J : Fin (L + 1)} {ha : J.val + 1 ≤ (largeShiftPrimes N (normalityScale (logLog Y))).card} (h : CollisionRecord.Complete Y p d Q (1 / logLog Y) ((logLog Y) ^ (-2 / 5 : ℝ)) ((logLog Y) ^ (-1 / 3 : ℝ)) J ha) (hp17 : ∀ idx, 17 ≤ p idx) (horder : Antitone p) (hfacet : (∑ idx ∈ Finset.Icc 1 L, fordWeight idx * CollisionFacet.extend (fun j => CollisionBox.primeCoordinate (logLog Y) (p j)) idx) ≤ 1 - (logLog Y) ^ (-1 / 8 : ℝ)) : Record Y L d where integer := ∏ idx, p idx primes := p J := J common := CollisionRecord.common J p Q ha right := CollisionClass.prefixPrimes Q ha residual := CollisionClass.normalResidual Q (J.val + 1) prefix_lt := by have := h.tail_pos; omega zero_survives := h.zero_survives cutoffs := h.cutoffs conditions := h.conditions prime_min := hp17 order := horder facet := hfacet /- Original line 24958: Erdos416Proof.CollisionSum.Label -/ abbrev Label (L : ℕ) := (Fin (L + 1) × (Fin (L + 1) → ℝ)) × Finset (Fin (L + 1)) × ℕ /- Original line 24961: Erdos416Proof.CollisionSum.Record.label -/ noncomputable def Record.label (r : Record Y L d) : Label L := ((r.J, box Y r.primes), commonCode r.J r.common, CollisionRecord.commonProduct r.J r.primes r.common) /-- Equal actual labels transport the original Conditions to the cutoffs of a representative, despite the variable length of the matched prefix. -/ /- Original line 24966: Erdos416Proof.CollisionSum.Record.conditions_of_label_eq -/ theorem Record.conditions_of_label_eq (r s : Record Y L d) (heq : r.label = s.label) : ∃ (p q : Fin (s.J.val + 1) → ℕ) (t : Fin (L - s.J.val) → ℕ) (e : ℕ), CollisionClass.Conditions s.common d (CollisionRecord.commonProduct s.J s.primes s.common) r.integer (normalityScale (logLog Y)) Y (upper Y s.primes s.J s.common) (lower Y s.primes s.J s.common) p q t e := by rcases r with ⟨n, p, J, C, q, e, hJ, hzero, hcuts, hconditions, hp17, horder, hfacet⟩ rcases s with ⟨nstar, pstar, Jstar, Cstar, qstar, estar, hJstar, hzerostar, hcutsstar, hconditionsstar, hp17star, horderstar, hfacetstar⟩ change ((J, box Y p), commonCode J C, CollisionRecord.commonProduct J p C) = ((Jstar, box Y pstar), commonCode Jstar Cstar, CollisionRecord.commonProduct Jstar pstar Cstar) at heq have hJJ : J = Jstar := congrArg (fun l : Label L => l.1.1) heq subst Jstar have hCC : C = Cstar := commonCode_injective J (congrArg (fun l : Label L => l.2.1) heq) subst Cstar have hb : box Y p = box Y pstar := congrArg (fun l : Label L => l.1.2) heq have hM : CollisionRecord.commonProduct J p C = CollisionRecord.commonProduct J pstar C := congrArg (fun l : Label L => l.2.2) heq have hcut := cutoffs_eq_of_box_eq J C hb refine ⟨CollisionRecord.leftPrimes J p, q, CollisionRecord.tailPrimes J p, e, ?_⟩ simpa only [hM, hcut.1, hcut.2] using hconditions /- Original line 24986: Erdos416Proof.CollisionSum.Record.shifted_le -/ theorem Record.shifted_le (r : Record Y L d) (hd : 0 < d) (idx : Fin (L + 1)) : ((r.primes idx - 1 : ℕ) : ℝ) ≤ Y := by have hsize : ((d * ∏ j, (r.primes j - 1) : ℕ) : ℝ) ≤ Y := by simpa only [CollisionRecord.leftPrimes, CollisionRecord.tailPrimes, CollisionRecord.prod_split r.J (fun j => r.primes j - 1)] using r.conditions.size have hprodpos : 0 < d * ∏ j, (r.primes j - 1) := by apply mul_pos hd apply Finset.prod_pos intro j _ have := r.prime_min j omega have hdiv : r.primes idx - 1 ∣ d * ∏ j, (r.primes j - 1) := dvd_mul_of_dvd_right (Finset.dvd_prod_of_mem (fun j => r.primes j - 1) (Finset.mem_univ idx)) d exact (Nat.cast_le.mpr (Nat.le_of_dvd hprodpos hdiv)).trans hsize /- Original line 25001: Erdos416Proof.CollisionSum.Record.prime_size -/ theorem Record.prime_size (r : Record Y L d) (hd : 0 < d) (hY : 1 ≤ Y) (hT : 2 ≤ logLog Y) (idx : Fin (L + 1)) : (r.primes idx : ℝ) ≤ Y * logLog Y := by have h := r.shifted_le hd idx rw [Nat.cast_sub (by have := r.prime_min idx; omega), Nat.cast_one] at h nlinarith [mul_le_mul_of_nonneg_left hT (by linarith : 0 ≤ Y)] /- Original line 25007: Erdos416Proof.CollisionSum.Record.shifted_coordinate_le_one -/ theorem Record.shifted_coordinate_le_one (r : Record Y L d) (hd : 0 < d) (hT : 0 < logLog Y) (idx : Fin (L + 1)) : CollisionBox.shiftedCoordinate (logLog Y) (r.primes idx) ≤ 1 := by apply (div_le_one hT).mpr apply logLog_mono (CollisionMatching.shifted_largest_one_lt (r.prime_min idx)) exact (Nat.cast_le.mpr (largestPrimeFactor_le (by have := r.prime_min idx; omega))).trans (r.shifted_le hd idx) /- Original line 25013: Erdos416Proof.CollisionSum.Record.common_product_properties -/ theorem Record.common_product_properties (r : Record Y L d) : Squarefree (CollisionRecord.commonProduct r.J r.primes r.common) ∧ (CollisionRecord.commonProduct r.J r.primes r.common).primeFactors = r.common.image (CollisionRecord.leftPrimes r.J r.primes) ∧ (CollisionRecord.commonProduct r.J r.primes r.common).primeFactors.card ≤ L + 1 := by classical have hp : ∀ q ∈ r.common.image (CollisionRecord.leftPrimes r.J r.primes), q.Prime := by intro q hq obtain ⟨idx, _, rfl⟩ := Finset.mem_image.mp hq exact (r.conditions.normal_left idx).1 have hinj := r.conditions.left_injective.injOn (s := (r.common : Set (Fin (r.J.val + 1)))) have hprod : (∏ q ∈ r.common.image (CollisionRecord.leftPrimes r.J r.primes), q) = CollisionRecord.commonProduct r.J r.primes r.common := Finset.prod_image hinj have hfactors : (CollisionRecord.commonProduct r.J r.primes r.common).primeFactors = r.common.image (CollisionRecord.leftPrimes r.J r.primes) := by rw [← hprod] exact Nat.primeFactors_prod hp refine ⟨hprod ▸ Sieve.prodDistinctPrimes_squarefree _ hp, hfactors, ?_⟩ rw [hfactors] have hcard : r.common.card ≤ r.J.val + 1 := by simpa only [Finset.card_univ, Fintype.card_fin] using Finset.card_le_card (Finset.subset_univ r.common) exact Finset.card_image_le.trans (hcard.trans (by have := r.J.isLt; omega)) /- Original line 25036: Erdos416Proof.CollisionSum.Record.common_product_support -/ theorem Record.common_product_support (r : Record Y L d) (hd : 0 < d) (hY : 1 ≤ Y) (hT : 2 ≤ logLog Y) : (CollisionRecord.commonProduct r.J r.primes r.common).primeFactors ⊆ Nat.primesLE ⌊Y * logLog Y⌋₊ := by rw [r.common_product_properties.2.1] intro q hq obtain ⟨idx, _, rfl⟩ := Finset.mem_image.mp hq apply Nat.mem_primesLE.mpr exact ⟨Nat.le_floor (r.prime_size hd hY hT (CollisionMatching.prefixIndex r.J idx)), (r.conditions.normal_left idx).1⟩ /-- Bound the actual label image inside the product of its box image, all finite common-index codes, and its actual shared-product image. -/ /- Original line 25047: Erdos416Proof.CollisionSum.label_weight_sum_le -/ theorem label_weight_sum_le (F : Finset (Record Y L d)) : (∑ l ∈ F.image Record.label, invTotient l.2.2) ≤ ((F.image (fun r => (r.J, box Y r.primes))).card : ℝ) * (2 : ℝ) ^ (L + 1) * ∑ M ∈ F.image (fun r => CollisionRecord.commonProduct r.J r.primes r.common), invTotient M := by classical let B := F.image (fun r => (r.J, box Y r.primes)) let M := F.image (fun r => CollisionRecord.commonProduct r.J r.primes r.common) let C : Finset (Finset (Fin (L + 1))) := Finset.univ have hsub : F.image Record.label ⊆ B.product (C.product M) := by intro l hl obtain ⟨r, hr, rfl⟩ := Finset.mem_image.mp hl exact Finset.mem_product.mpr ⟨Finset.mem_image.mpr ⟨r, hr, rfl⟩, Finset.mem_product.mpr ⟨Finset.mem_univ _, Finset.mem_image.mpr ⟨r, hr, rfl⟩⟩⟩ calc _ ≤ ∑ l ∈ B.product (C.product M), invTotient l.2.2 := Finset.sum_le_sum_of_subset_of_nonneg hsub (by intro l _ _; unfold invTotient; positivity) _ = ∑ _b ∈ B, ∑ _c ∈ C, ∑ m ∈ M, invTotient m := by simp only [Finset.product_eq_sprod, Finset.sum_product] _ = _ := by simp only [Finset.sum_const, C, Finset.card_univ, Fintype.card_finset, Fintype.card_fin, nsmul_eq_mul, Nat.cast_pow, Nat.cast_ofNat] ring /- Original line 25070: Erdos416Proof.CollisionSum.common_code_count_le -/ theorem common_code_count_le {A T : ℝ} (hA : 0 ≤ A) (hT : Real.exp 1 ≤ T) (hL : (L : ℝ) + 1 ≤ (A + 1) * Real.log T) : (2 : ℝ) ^ (L + 1) ≤ Real.exp ((A + 1) * Real.log T ^ 2) := by have hU : 1 ≤ Real.log T := by simpa only [Real.log_exp] using Real.log_le_log (Real.exp_pos 1) hT have hlog2 : Real.log 2 ≤ 1 := by have := Real.log_le_sub_one_of_pos (by norm_num : (0 : ℝ) < 2) linarith have hlog20 : 0 ≤ Real.log 2 := Real.log_nonneg (by norm_num) calc (2 : ℝ) ^ (L + 1) = Real.exp (((L + 1 : ℕ) : ℝ) * Real.log 2) := by rw [Real.exp_nat_mul, Real.exp_log (by norm_num : (0 : ℝ) < 2)] _ ≤ _ := by apply Real.exp_le_exp.mpr have hmul := mul_le_mul_of_nonneg_right hL hlog20 have hprod := mul_le_mul_of_nonneg_left hlog2 (show 0 ≤ (A + 1) * Real.log T by positivity) push_cast nlinarith [mul_nonneg (show 0 ≤ A + 1 by linarith) (sq_nonneg (Real.log T - 1))] /-- The complete weighted number of labels is controlled uniformly for the actual common products occurring in an arbitrary retained family. -/ /- Original line 25091: Erdos416Proof.CollisionSum.label_weight_sum_eventually -/ theorem label_weight_sum_eventually {A : ℝ} (hA : 0 ≤ A) (d : ℕ) (hd : 0 < d) : ∀ᶠ Y : ℝ in atTop, ∀ (L : ℕ) (F : Finset (Record Y L d)), (L : ℝ) ≤ A * Real.log (logLog Y) → (∑ l ∈ F.image Record.label, invTotient l.2.2) ≤ Real.exp ((6 * A + 7) * Real.log (logLog Y) ^ 2) := by classical have hT : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [hT.eventually (common_product_sum_inverse_totient_scale (A + 1) (c := 1) (by norm_num)), hT.eventually (dimension_log_bounds_eventually A), hT.eventually_ge_atTop (Real.exp 1), hT.eventually_ge_atTop 2, eventually_gt_atTop (1 : ℝ)] with Y hcommon hdim hTe hT2 hY intro L F hL have hTp : 0 < logLog Y := by linarith have hdimL := (hdim L hL).1 have hboxes := CollisionBox.prefix_label_image_card_scale F (fun r idx => CollisionBox.shiftedCoordinate (logLog Y) (r.primes idx)) (fun r => r.J) hTe hL (fun r _ idx _ => r.shifted_coordinate_le_one hd hTp idx) have hcodes := common_code_count_le hA hTe hdimL let M := F.image (fun r => CollisionRecord.commonProduct r.J r.primes r.common) have hM := hcommon M (L + 1) (by simpa only [Nat.cast_add, Nat.cast_one] using hdimL) (by intro m hm obtain ⟨r, _, rfl⟩ := Finset.mem_image.mp hm have hp := r.common_product_properties refine ⟨hp.1, ?_, hp.2.2⟩ simpa only [one_mul, CollisionMatching.exp_exp_logLog hY] using r.common_product_support hd hY.le hT2) have hbound := label_weight_sum_le F calc _ ≤ ((F.image (fun r => (r.J, box Y r.primes))).card : ℝ) * (2 : ℝ) ^ (L + 1) * ∑ m ∈ M, invTotient m := hbound _ ≤ Real.exp (3 * (A + 1) * Real.log (logLog Y) ^ 2) * Real.exp ((A + 1) * Real.log (logLog Y) ^ 2) * Real.exp ((2 * (A + 1) + 1) * Real.log (logLog Y) ^ 2) := by apply mul_le_mul · exact mul_le_mul hboxes hcodes (by positivity) (by positivity) · exact hM · apply Finset.sum_nonneg intro m _ unfold invTotient positivity · positivity _ = _ := by rw [← Real.exp_add, ← Real.exp_add]; congr 1; ring /-- Sum the actual disjoint label fibers. Each fiber is sent injectively to its original integer values, receives the checked class bound, and is then included in the proved weighted label sum. -/ /- Original line 25135: Erdos416Proof.CollisionSum.records_count_eventually -/ theorem records_count_eventually {A : ℝ} (hA : 0 ≤ A) (d : ℕ) (hd : 0 < d) : ∀ᶠ Y : ℝ in atTop, ∀ (L : ℕ) (F : Finset (Record Y L d)), (L : ℝ) ≤ A * Real.log (logLog Y) → Set.InjOn Record.integer (F : Set (Record Y L d)) → (largestPrimeFactor d : ℝ) ≤ normalityScale (logLog Y) → (F.card : ℝ) ≤ Y / ((d : ℝ) * Real.log Y) * Real.exp (-(1 / 4 : ℝ) * (logLog Y) ^ (7 / 8 : ℝ)) := by classical have hT : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [CollisionSaving.class_saving_eventually hA d hd (6 * A + 7), label_weight_sum_eventually hA d hd, eventually_gt_atTop (1 : ℝ), hT.eventually_gt_atTop 0] with Y hclass hlabels hY hTpos intro L F hL hinj hdS let T := logLog Y let β := Y / ((d : ℝ) * Real.log Y) * Real.exp (-(1 / 4 : ℝ) * T ^ (7 / 8 : ℝ) - (6 * A + 7) * sieveErrorEnvelope T) have hYpos : 0 < Y := by linarith have hTp : 0 < T := hTpos have hlogY : 0 < Real.log Y := Real.log_pos hY have hβ : 0 ≤ β := by unfold β; positivity have hfiber : ∀ l ∈ F.image Record.label, ((F.filter (fun r => r.label = l)).card : ℝ) ≤ β * invTotient l.2.2 := by intro l hl obtain ⟨s, hs, rfl⟩ := Finset.mem_image.mp hl let G := F.filter (fun r => r.label = s.label) let U := G.image Record.integer have hU : ∀ n ∈ U, ∃ (p q : Fin (s.J.val + 1) → ℕ) (t : Fin (L - s.J.val) → ℕ) (e : ℕ), CollisionClass.Conditions s.common d (CollisionRecord.commonProduct s.J s.primes s.common) n (normalityScale (logLog Y)) Y (upper Y s.primes s.J s.common) (lower Y s.primes s.J s.common) p q t e := by intro n hn obtain ⟨r, hr, rfl⟩ := Finset.mem_image.mp hn exact r.conditions_of_label_eq s (Finset.mem_filter.mp hr).2 choose! p q t e hconditions using hU have hcount := hclass L s.J s.common (CollisionRecord.commonProduct s.J s.primes s.common) U s.primes p q t e hL s.prefix_lt s.zero_survives s.cutoffs hdS s.prime_min s.order s.facet hconditions have hcard : U.card = G.card := Finset.card_image_of_injOn (hinj.mono (show (G : Set (Record Y L d)) ⊆ F from fun r hr => (Finset.mem_filter.mp hr).1)) rw [hcard] at hcount calc ((F.filter (fun r => r.label = s.label)).card : ℝ) ≤ Y / ((d : ℝ) * (CollisionRecord.commonProduct s.J s.primes s.common).totient * Real.log Y) * Real.exp (-(1 / 4 : ℝ) * T ^ (7 / 8 : ℝ) - (6 * A + 7) * sieveErrorEnvelope T) := hcount _ = β * invTotient s.label.2.2 := by simp only [β, Record.label, invTotient]; ring have hsum : (F.card : ℝ) = ∑ l ∈ F.image Record.label, ((F.filter (fun r => r.label = l)).card : ℝ) := by exact_mod_cast Finset.card_eq_sum_card_image Record.label F have henv : Real.log T ^ 2 ≤ sieveErrorEnvelope T := by unfold sieveErrorEnvelope have h₁ : 0 ≤ Real.log T ^ 2 * T ^ (2 / 3 : ℝ) := by exact mul_nonneg (sq_nonneg _) (Real.rpow_nonneg hTp.le _) have h₂ : 0 ≤ Real.log T ^ 8 * T ^ (1 / 2 : ℝ) := by positivity linarith calc (F.card : ℝ) = ∑ l ∈ F.image Record.label, ((F.filter (fun r => r.label = l)).card : ℝ) := hsum _ ≤ ∑ l ∈ F.image Record.label, β * invTotient l.2.2 := Finset.sum_le_sum hfiber _ = β * ∑ l ∈ F.image Record.label, invTotient l.2.2 := (Finset.mul_sum _ _ _).symm _ ≤ β * Real.exp ((6 * A + 7) * Real.log T ^ 2) := mul_le_mul_of_nonneg_left (hlabels L F hL) hβ _ = Y / ((d : ℝ) * Real.log Y) * Real.exp (-(1 / 4 : ℝ) * T ^ (7 / 8 : ℝ) - (6 * A + 7) * sieveErrorEnvelope T + (6 * A + 7) * Real.log T ^ 2) := by rw [Real.exp_add]; unfold β; ring _ ≤ _ := by apply mul_le_mul_of_nonneg_left _ (by positivity) apply Real.exp_le_exp.mpr have hcost := mul_le_mul_of_nonneg_left henv (show 0 ≤ 6 * A + 7 by linarith) linarith /-- Select one proved record per actual integer. This construction supplies the injection required by the finite record-family bound. -/ /- Original line 25203: Erdos416Proof.CollisionSum.retained_count_eventually -/ theorem retained_count_eventually {A : ℝ} (hA : 0 ≤ A) (d : ℕ) (hd : 0 < d) : ∀ᶠ Y : ℝ in atTop, ∀ (L : ℕ) (F : Finset ℕ), (L : ℝ) ≤ A * Real.log (logLog Y) → (largestPrimeFactor d : ℝ) ≤ normalityScale (logLog Y) → (∀ n ∈ F, ∃ r : Record Y L d, r.integer = n) → (F.card : ℝ) ≤ Y / ((d : ℝ) * Real.log Y) * Real.exp (-(1 / 4 : ℝ) * (logLog Y) ^ (7 / 8 : ℝ)) := by classical filter_upwards [records_count_eventually hA d hd] with Y hbound intro L F hL hdS hrecords let f : F → Record Y L d := fun n => Classical.choose (hrecords n n.property) have hf : ∀ n : F, (f n).integer = n := fun n => Classical.choose_spec (hrecords n n.property) have hinj : Function.Injective f := by intro n m hnm apply Subtype.ext simpa only [hf] using congrArg Record.integer hnm let G := F.attach.image f have hGin : Set.InjOn Record.integer (G : Set (Record Y L d)) := by intro r hr s hs hrs obtain ⟨n, _, rfl⟩ := Finset.mem_image.mp hr obtain ⟨m, _, rfl⟩ := Finset.mem_image.mp hs have hnm : n = m := Subtype.ext (by simpa only [hf] using hrs) exact congrArg f hnm have hcard : G.card = F.card := by rw [Finset.card_image_of_injective _ hinj, Finset.card_attach] simpa only [hcard] using hbound L G hL hGin hdS /-- The manuscript's actual retained tuple and auxiliary collision witness. These are the structural and pruning conditions before the class partition. -/ /- Original line 25231: Erdos416Proof.CollisionSum.RetainedPair -/ structure RetainedPair (Y P κ θ : ℝ) (d n : ℕ) (p : Fin (L + 1) → ℕ) (N : ℕ) : Prop where integer : (∏ idx, p idx) = n normal_left : ∀ idx, SNormal (normalityScale (logLog Y)) (p idx) prime_min : ∀ idx, 17 ≤ p idx order : StrictAnti p gaps : ∀ idx : Fin (L + 1), 0 < idx.val → ∀ hi : idx.val + 1 < L + 1, κ * logLog (p ⟨idx.val + 1, hi⟩) ≤ logLog (p idx) lower_upper : ∀ idx, 0 < idx.val → (p idx : ℝ) ≤ CollisionBox.cutoff Y θ last_upper : (p (Fin.last L) : ℝ) ≤ P top : Y ^ (9 / 10 : ℝ) < (p 0 : ℝ) witness_pos : 0 < N equation : N.totient = d * ∏ idx, (p idx - 1) size : (N.totient : ℝ) ≤ Y largest_ne : largestPrimeFactor N ≠ p 0 normal_right : ∀ q ∈ N.primeFactors, SNormal (normalityScale (logLog Y)) q square_witness : NoLargePrimeSquare N (Real.log Y ^ 4) square_totient : NoLargePrimeSquare N.totient (Real.log Y ^ 4) facet : (∑ idx ∈ Finset.Icc 1 L, fordWeight idx * CollisionFacet.extend (fun j => CollisionBox.primeCoordinate (logLog Y) (p j)) idx) ≤ 1 - (logLog Y) ^ (-1 / 8 : ℝ) /-- Construct every actual class record and sum it, starting directly with the retained original tuples and witnesses. Neither class membership nor the existence of a common set or a matched right prefix is assumed. -/ /- Original line 25255: Erdos416Proof.CollisionSum.retained_pairs_count_eventually -/ theorem retained_pairs_count_eventually {A : ℝ} (hA : 0 ≤ A) (P κ θ : ℝ) (hκ : 1 < κ) (hθ : θ < 1) (d : ℕ) (hd : 0 < d) : ∀ᶠ Y : ℝ in atTop, ∀ (L : ℕ) (F : Finset ℕ), (L : ℝ) ≤ A * Real.log (logLog Y) → (largestPrimeFactor d : ℝ) ≤ normalityScale (logLog Y) → (∀ n ∈ F, ∃ (p : Fin (L + 1) → ℕ) (N : ℕ), RetainedPair Y P κ θ d n p N) → (F.card : ℝ) ≤ Y / ((d : ℝ) * Real.log Y) * Real.exp (-(1 / 4 : ℝ) * (logLog Y) ^ (7 / 8 : ℝ)) := by filter_upwards [CollisionRecord.complete_records_eventually A P κ θ hκ hθ, retained_count_eventually hA d hd] with Y hcomplete hcount intro L F hL hdS hF apply hcount L F hL hdS intro n hn obtain ⟨p, N, h⟩ := hF n hn obtain ⟨Q, J, _, _, ha, _, hc⟩ := hcomplete L p N d hL h.normal_left h.prime_min h.order h.gaps h.lower_upper h.last_upper h.top h.witness_pos hd hdS h.equation h.size h.largest_ne h.normal_right h.square_witness h.square_totient exact ⟨record_of_complete hc h.prime_min h.order.antitone h.facet, h.integer⟩ /- Original line 25273: Erdos416Proof.CollisionSum.exponential_saving_le_inv_sq_eventually -/ theorem exponential_saving_le_inv_sq_eventually : ∀ᶠ T : ℝ in atTop, Real.exp (-(1 / 4 : ℝ) * T ^ (7 / 8 : ℝ)) ≤ 1 / T ^ 2 := by have hsmall := (log_pow_mul_rpow_littleO 1 (show (0 : ℝ) < 7 / 8 by norm_num)).const_mul_left (8 : ℝ) filter_upwards [hsmall.bound (by norm_num : (0 : ℝ) < 1), eventually_gt_atTop (1 : ℝ)] with T hbound hT have hTpos : 0 < T := by linarith have hlog : 0 ≤ Real.log T := (Real.log_pos hT).le simp only [Real.norm_eq_abs, pow_one, Real.rpow_zero, mul_one, one_mul] at hbound rw [abs_of_nonneg (by positivity : 0 ≤ 8 * Real.log T), abs_of_nonneg (Real.rpow_nonneg hTpos.le _)] at hbound calc Real.exp (-(1 / 4 : ℝ) * T ^ (7 / 8 : ℝ)) ≤ Real.exp (-Real.log (T ^ 2)) := by apply Real.exp_le_exp.mpr rw [Real.log_pow] norm_num linarith _ = _ := by rw [Real.exp_neg, Real.exp_log (by positivity), one_div] /-- The retained part of fixed-tail rigidity has the required pruning scale, uniformly in the finite family and the varying tuple length. -/ /- Original line 25292: Erdos416Proof.CollisionSum.retained_pairs_pruning_scale_eventually -/ theorem retained_pairs_pruning_scale_eventually {A : ℝ} (hA : 0 ≤ A) (P κ θ : ℝ) (hκ : 1 < κ) (hθ : θ < 1) (d : ℕ) (hd : 0 < d) : ∀ᶠ Y : ℝ in atTop, ∀ (L : ℕ) (F : Finset ℕ), (L : ℝ) ≤ A * Real.log (logLog Y) → (largestPrimeFactor d : ℝ) ≤ normalityScale (logLog Y) → (∀ n ∈ F, ∃ (p : Fin (L + 1) → ℕ) (N : ℕ), RetainedPair Y P κ θ d n p N) → (F.card : ℝ) ≤ Y / (Real.log Y * (logLog Y) ^ 2) := by have hT : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [retained_pairs_count_eventually hA P κ θ hκ hθ d hd, hT.eventually exponential_saving_le_inv_sq_eventually, eventually_gt_atTop (1 : ℝ), hT.eventually_gt_atTop 0] with Y hcount hsave hY hTp intro L F hL hdS hF have hYpos : 0 < Y := by linarith have hlog : 0 < Real.log Y := Real.log_pos hY have hd1 : (1 : ℝ) ≤ d := by exact_mod_cast hd have hbase : Y / ((d : ℝ) * Real.log Y) ≤ Y / Real.log Y := div_le_div_of_nonneg_left hYpos.le hlog (by nlinarith) calc (F.card : ℝ) ≤ Y / ((d : ℝ) * Real.log Y) * Real.exp (-(1 / 4 : ℝ) * (logLog Y) ^ (7 / 8 : ℝ)) := hcount L F hL hdS hF _ ≤ (Y / Real.log Y) * (1 / (logLog Y) ^ 2) := mul_le_mul hbase hsave (by positivity) (by positivity) _ = _ := by ring end Erdos416Proof.CollisionSum /- Full fixed-tail rigidity: actual injective witnesses, all exceptional deletions and the uniform bound on the original collision family. -/ open Filter Finset Asymptotics open scoped Topology BigOperators Classical namespace Erdos416Proof.Rigidity variable {L r n m : ℕ} {Y P κ θ : ℝ} {p q : Fin (L + 1) → ℕ} /-- The original fixed-tail tuple, before any normality or square exclusions. The collision witness is deliberately not included in this record. -/ /- Original line 25334: Erdos416Proof.Rigidity.Tuple -/ structure Tuple (Y P κ θ : ℝ) (r n : ℕ) (p : Fin (L + 1) → ℕ) : Prop where integer : (∏ idx, p idx) = n prime : ∀ idx, (p idx).Prime order : StrictAnti p last_lower : max 17 (largestPrimeFactor r) < p (Fin.last L) last_upper : (p (Fin.last L) : ℝ) ≤ P gaps : ∀ idx : Fin (L + 1), 0 < idx.val → ∀ hi : idx.val + 1 < L + 1, κ * logLog (p ⟨idx.val + 1, hi⟩) ≤ logLog (p idx) lower_upper : ∀ idx, 0 < idx.val → (p idx : ℝ) ≤ CollisionBox.cutoff Y θ top : Y ^ (9 / 10 : ℝ) < (p 0 : ℝ) size : ((r.totient * n.totient : ℕ) : ℝ) ≤ Y facet : (∑ idx ∈ Finset.Icc 1 L, fordWeight idx * CollisionFacet.extend (fun j => CollisionBox.primeCoordinate (logLog Y) (p j)) idx) ≤ 1 - (logLog Y) ^ (-1 / 8 : ℝ) /- Original line 25349: Erdos416Proof.Rigidity.Tuple.positive -/ theorem Tuple.positive (h : Tuple Y P κ θ r n p) : 0 < n := by rw [← h.integer] exact Finset.prod_pos (fun idx _ => (h.prime idx).pos) /- Original line 25353: Erdos416Proof.Rigidity.Tuple.prime_min -/ theorem Tuple.prime_min (h : Tuple Y P κ θ r n p) (idx : Fin (L + 1)) : 17 ≤ p idx := ((le_max_left _ _).trans h.last_lower.le).trans (h.order.antitone (Fin.le_last idx)) /- Original line 25356: Erdos416Proof.Rigidity.Tuple.tail_lt -/ theorem Tuple.tail_lt (h : Tuple Y P κ θ r n p) (idx : Fin (L + 1)) : largestPrimeFactor r < p idx := ((le_max_right _ _).trans_lt h.last_lower).trans_le (h.order.antitone (Fin.le_last idx)) /- Original line 25360: Erdos416Proof.Rigidity.Tuple.totient -/ theorem Tuple.totient (h : Tuple Y P κ θ r n p) : n.totient = ∏ idx, (p idx - 1) := by rw [← h.integer] exact totient_prod_injective_primes Finset.univ p (fun idx _ => h.prime idx) h.order.injective.injOn /- Original line 25365: Erdos416Proof.Rigidity.Tuple.prime_factors -/ theorem Tuple.prime_factors (h : Tuple Y P κ θ r n p) : n.primeFactors = Finset.univ.image p := by have hp : ∀ v ∈ Finset.univ.image p, v.Prime := by intro v hv obtain ⟨idx, _, rfl⟩ := Finset.mem_image.mp hv exact h.prime idx have hprod : (∏ v ∈ Finset.univ.image p, v) = n := (Finset.prod_image h.order.injective.injOn).trans h.integer rw [← hprod] exact Nat.primeFactors_prod hp /- Original line 25376: Erdos416Proof.Rigidity.Tuple.squarefree -/ theorem Tuple.squarefree (h : Tuple Y P κ θ r n p) : Squarefree n := by have hp : ∀ v ∈ Finset.univ.image p, v.Prime := by intro v hv obtain ⟨idx, _, rfl⟩ := Finset.mem_image.mp hv exact h.prime idx have hprod : (∏ v ∈ Finset.univ.image p, v) = n := (Finset.prod_image h.order.injective.injOn).trans h.integer exact hprod ▸ Sieve.prodDistinctPrimes_squarefree _ hp /- Original line 25385: Erdos416Proof.Rigidity.Tuple.factor_count -/ theorem Tuple.factor_count (h : Tuple Y P κ θ r n p) : ArithmeticFunction.cardFactors n = L + 1 := by rw [cardFactors_eq_primeFactors_card_of_squarefree h.squarefree, h.prime_factors, Finset.card_image_of_injective _ h.order.injective] simp /- Original line 25391: Erdos416Proof.Rigidity.Tuple.largest -/ theorem Tuple.largest (h : Tuple Y P κ θ r n p) : largestPrimeFactor n = p 0 := by apply le_antisymm · rw [largestPrimeFactor, h.prime_factors] refine max_le (h.prime 0).one_le (Finset.sup_le ?_) intro v hv obtain ⟨idx, _, rfl⟩ := Finset.mem_image.mp hv exact h.order.antitone (Fin.zero_le idx) · apply prime_le_largestPrimeFactor h.positive (h.prime 0) rw [← h.integer] exact Finset.dvd_prod_of_mem p (Finset.mem_univ 0) /- Original line 25402: Erdos416Proof.Rigidity.Tuple.coprime -/ theorem Tuple.coprime (h : Tuple Y P κ θ r n p) (hr : 0 < r) : n.Coprime r := by rw [← h.integer] exact Nat.coprime_prod_left_iff.mpr (fun idx _ => coprime_of_largestPrimeFactor_lt hr (h.prime idx) (h.tail_lt idx)) /- Original line 25407: Erdos416Proof.Rigidity.Tuple.canonical_totient -/ theorem Tuple.canonical_totient (h : Tuple Y P κ θ r n p) (hr : 0 < r) : (r * n).totient = r.totient * n.totient := Nat.totient_mul (h.coprime hr).symm /- Original line 25410: Erdos416Proof.Rigidity.Tuple.canonical_largest -/ theorem Tuple.canonical_largest (h : Tuple Y P κ θ r n p) (hr : 0 < r) : largestPrimeFactor (r * n) = p 0 := by rw [largestPrimeFactor_mul hr h.positive, h.largest, max_eq_right (h.tail_lt 0).le] /- Original line 25414: Erdos416Proof.Rigidity.Tuple.totient_size -/ theorem Tuple.totient_size (h : Tuple Y P κ θ r n p) (hr : 0 < r) : (n.totient : ℝ) ≤ Y := by have hd : 1 ≤ r.totient := Nat.totient_pos.mpr hr have hle : n.totient ≤ r.totient * n.totient := by nlinarith exact (Nat.cast_le.mpr hle).trans h.size /-- Equal totients and equal leading primes force equal original integers, provided the family distinguishes its lower tuples by their shifted products. -/ /- Original line 25422: Erdos416Proof.Rigidity.Tuple.eq_of_totient_eq_top_eq -/ theorem Tuple.eq_of_totient_eq_top_eq (hn : Tuple Y P κ θ r n p) (hm : Tuple Y P κ θ r m q) (hφ : n.totient = m.totient) (h0 : p 0 = q 0) (hlower : (∏ idx : Fin L, (p idx.succ - 1)) = (∏ idx : Fin L, (q idx.succ - 1)) → ∀ idx : Fin L, p idx.succ = q idx.succ) : n = m := by rw [hn.totient, hm.totient, Fin.prod_univ_succ, Fin.prod_univ_succ, ← h0] at hφ have hlow := hlower (Nat.eq_of_mul_eq_mul_left (Nat.sub_pos_of_lt (hn.prime 0).one_lt) hφ) have hpq : p = q := funext (fun idx => Fin.cases h0 hlow idx) rw [← hn.integer, ← hm.integer, hpq] /-- An assignment is made on the original family and retained unchanged when later exceptional sets are deleted. -/ /- Original line 25433: Erdos416Proof.Rigidity.Assignment -/ structure Assignment (F : Finset ℕ) (r : ℕ) (p : ℕ → Fin (L + 1) → ℕ) (w : ℕ → ℕ) : Prop where injective : Set.InjOn w (F : Set ℕ) positive : ∀ n ∈ F, 0 < w n equation : ∀ n ∈ F, (w n).totient = r.totient * n.totient largest_ne : ∀ n ∈ F, largestPrimeFactor (w n) ≠ p n 0 peer : ∀ n ∈ F, (∃ m ∈ F, m.totient = n.totient ∧ m ≠ n) → ∃ m ∈ F, w n = r * m /-- The checked fibre-permutation theorem applied to the actual original integers. Both the canonical totient equation and leading-prime mismatch are proved from the tuples, with no multiplicity hypothesis on totients. -/ /- Original line 25444: Erdos416Proof.Rigidity.exists_assignment -/ theorem exists_assignment (F : Finset ℕ) (p : ℕ → Fin (L + 1) → ℕ) (hr : 0 < r) (hF : ∀ n ∈ F, Tuple Y P κ θ r n (p n)) (hlower : ∀ n ∈ F, ∀ m ∈ F, (∏ idx : Fin L, (p n idx.succ - 1)) = (∏ idx : Fin L, (p m idx.succ - 1)) → ∀ idx : Fin L, p n idx.succ = p m idx.succ) (hwitness : ∀ n ∈ F, ∃ N : ℕ, 0 < N ∧ N.totient = r.totient * n.totient ∧ largestPrimeFactor N ≠ p n 0) : ∃ w : ℕ → ℕ, Assignment F r p w := by classical let f : F → ℕ := fun n => r.totient * n.val.totient let canonical : F → ℕ := fun n => r * n.val let relation : F → ℕ → Prop := fun n N => 0 < N ∧ largestPrimeFactor N ≠ p n.val 0 have hcan : Function.Injective canonical := by intro a b hab exact Subtype.ext (Nat.eq_of_mul_eq_mul_left hr hab) have hval (a : F) : (canonical a).totient = f a := (hF a a.property).canonical_totient hr have hpeer (a b : F) (hab : f b = f a) (hba : b ≠ a) : relation a (canonical b) := by refine ⟨Nat.mul_pos hr (hF b b.property).positive, ?_⟩ change largestPrimeFactor (r * b.val) ≠ p a.val 0 rw [(hF b b.property).canonical_largest hr] intro htop apply hba apply Subtype.ext apply (hF b b.property).eq_of_totient_eq_top_eq (hF a a.property) (Nat.eq_of_mul_eq_mul_left (Nat.totient_pos.mpr hr) hab) htop exact hlower b b.property a a.property have hwit (a : F) : ∃ N : ℕ, N.totient = f a ∧ relation a N := by obtain ⟨N, hN, hφ, htop⟩ := hwitness a a.property exact ⟨N, hφ, hN, htop⟩ obtain ⟨w, hw, hwval, hwpeer⟩ := exists_injective_witness f Nat.totient canonical hcan hval relation hpeer hwit let w' : ℕ → ℕ := fun n => if hn : n ∈ F then w ⟨n, hn⟩ else 0 have hw' (n : ℕ) (hn : n ∈ F) : w' n = w ⟨n, hn⟩ := dif_pos hn refine ⟨w', ?_⟩ constructor · intro n hn m hm heq rw [hw' n hn, hw' m hm] at heq exact congrArg Subtype.val (hw heq) · intro n hn rw [hw' n hn] exact (hwval ⟨n, hn⟩).2.1 · intro n hn rw [hw' n hn] exact (hwval ⟨n, hn⟩).1 · intro n hn rw [hw' n hn] exact (hwval ⟨n, hn⟩).2.2 · intro n hn ⟨m, hm, hφ, hmn⟩ have hpeer' : HasPeer f ⟨n, hn⟩ := ⟨⟨m, hm⟩, congrArg (fun z : ℕ => r.totient * z) hφ, fun heq => hmn (congrArg Subtype.val heq)⟩ obtain ⟨b, hb⟩ := hwpeer ⟨n, hn⟩ hpeer' exact ⟨b, b.property, (hw' n hn).trans hb⟩ /-- Each fixed prime factor of the tail is normal beyond one common scale. -/ /- Original line 25500: Erdos416Proof.Rigidity.fixed_tail_normal_eventually -/ theorem fixed_tail_normal_eventually (r : ℕ) : ∀ᶠ Y : ℝ in atTop, ∀ q ∈ r.primeFactors, SNormal (normalityScale (logLog Y)) q := by have hscale : Tendsto (fun Y : ℝ => normalityScale (logLog Y)) atTop atTop := CollisionState.normalityScale_atTop.comp (Real.tendsto_log_atTop.comp Real.tendsto_log_atTop) apply (Finset.eventually_all r.primeFactors).mpr intro q hq exact hscale.eventually (eventually_fixed_prime_normal (Nat.prime_of_mem_primeFactors hq)) /- Original line 25508: Erdos416Proof.Rigidity.normal_outside_failures -/ theorem normal_outside_failures {F : Finset ℕ} {S : ℝ} {n : ℕ} (hn : n ∈ F) (hgood : n ∉ normalPrimeFailures F S) : ∀ q : ℕ, q.Prime → q ∣ n → SNormal S q := by intro q hp hqn by_contra hbad exact hgood (Finset.mem_filter.mpr ⟨hn, q, hp, hqn, hbad⟩) /- Original line 25515: Erdos416Proof.Rigidity.Tuple.normal_primes -/ theorem Tuple.normal_primes {F : Finset ℕ} {S : ℝ} (h : Tuple Y P κ θ r n p) (hn : n ∈ F) (hgood : n ∉ normalPrimeFailures F S) : ∀ idx, SNormal S (p idx) := by intro idx apply normal_outside_failures hn hgood (p idx) (h.prime idx) rw [← h.integer] exact Finset.dvd_prod_of_mem p (Finset.mem_univ idx) /- Original line 25522: Erdos416Proof.Rigidity.witnessNormalFailures -/ noncomputable def witnessNormalFailures (F : Finset ℕ) (w : ℕ → ℕ) (S : ℝ) : Finset ℕ := F.filter (fun n => ∃ q : ℕ, q.Prime ∧ q ∣ w n ∧ ¬ SNormal S q) /-- A witness in a nonsingleton fibre is normal because it is r times an original survivor. The assignment is the same one used for every exclusion. -/ /- Original line 25527: Erdos416Proof.Rigidity.Assignment.normal_of_peer -/ theorem Assignment.normal_of_peer {F : Finset ℕ} {p : ℕ → Fin (L + 1) → ℕ} {w : ℕ → ℕ} {S : ℝ} (h : Assignment F r p w) (hr : 0 < r) (hrnormal : ∀ q ∈ r.primeFactors, SNormal S q) (hFnormal : ∀ m ∈ F, ∀ q : ℕ, q.Prime → q ∣ m → SNormal S q) (hn : n ∈ F) (hpeer : ∃ m ∈ F, m.totient = n.totient ∧ m ≠ n) : ∀ q : ℕ, q.Prime → q ∣ w n → SNormal S q := by obtain ⟨m, hm, hwm⟩ := h.peer n hn hpeer intro q hq hdiv rw [hwm] at hdiv rcases hq.dvd_mul.mp hdiv with hqr | hqm · exact hrnormal q (hq.mem_primeFactors hqr hr.ne') · exact hFnormal m hm q hq hqm /-- Abnormal assigned witnesses can only come from singleton fibres, so their totient values give an injection into the actual exceptional values. -/ /- Original line 25542: Erdos416Proof.Rigidity.Assignment.normal_failures_card_le -/ theorem Assignment.normal_failures_card_le {F : Finset ℕ} {p : ℕ → Fin (L + 1) → ℕ} {w : ℕ → ℕ} {S : ℝ} (h : Assignment F r p w) (hr : 0 < r) (hY : 0 ≤ Y) (hsize : ∀ n ∈ F, ((w n).totient : ℝ) ≤ Y) (hrnormal : ∀ q ∈ r.primeFactors, SNormal S q) (hFnormal : ∀ m ∈ F, ∀ q : ℕ, q.Prime → q ∣ m → SNormal S q) : (witnessNormalFailures F w S).card ≤ (nonNormalTotients S Y).card := by classical apply Finset.card_le_card_of_injOn (fun n => (w n).totient) · intro n hn obtain ⟨hnF, hbad⟩ := Finset.mem_filter.mp hn apply Finset.mem_filter.mpr exact ⟨(mem_totientsUpTo hY).mpr ⟨Nat.totient_pos.mpr (h.positive n hnF), hsize n hnF, w n, h.positive n hnF, rfl⟩, w n, h.positive n hnF, rfl, hbad⟩ · intro n hn m hm heq obtain ⟨hnF, q, hq, hqn, hqbad⟩ := Finset.mem_filter.mp hn have hmF := (Finset.mem_filter.mp hm).1 by_contra hne have hφ : m.totient = n.totient := Nat.eq_of_mul_eq_mul_left (Nat.totient_pos.mpr hr) (by rw [← h.equation m hmF, ← h.equation n hnF] exact heq.symm) exact hqbad (h.normal_of_peer hr hrnormal hFnormal hnF ⟨m, hmF, hφ, Ne.symm hne⟩ q hq hqn) /- Original line 25567: Erdos416Proof.Rigidity.squarefree_normal_failures_card_le -/ theorem squarefree_normal_failures_card_le {F : Finset ℕ} {p : ℕ → Fin (L + 1) → ℕ} {A c : ℝ} (hr : 0 < r) (hL : (L : ℝ) ≤ A * Real.log (logLog Y)) (hF : ∀ n ∈ F, Tuple Y P κ θ r n (p n)) (hsize : ∀ n : ℕ, 0 < n → (n.totient : ℝ) ≤ Y → (n : ℝ) ≤ c * Y * logLog Y) : ((normalPrimeFailures F (normalityScale (logLog Y))).card : ℝ) ≤ squarefreeNonNormalCount A c Y := by classical apply Nat.cast_le.mpr apply Finset.card_le_card intro n hn obtain ⟨hnF, hbad⟩ := Finset.mem_filter.mp hn have ht := hF n hnF have hnk : ArithmeticFunction.cardFactors n ≤ ⌊A * Real.log (logLog Y)⌋₊ + 1 := by rw [ht.factor_count] exact Nat.add_le_add_right (Nat.le_floor hL) 1 exact Finset.mem_filter.mpr ⟨Finset.mem_Icc.mpr ⟨ht.positive, Nat.le_floor (hsize n ht.positive (ht.totient_size hr))⟩, ht.squarefree, hnk, hbad⟩ /- Original line 25585: Erdos416Proof.Rigidity.not_square_failure -/ theorem not_square_failure {F : Finset ℕ} {w : ℕ → ℕ} {H : ℝ} (hn : n ∈ F) (hgood : n ∉ largeSquareFailures F w H) : NoLargePrimeSquare (w n) H ∧ NoLargePrimeSquare (w n).totient H := by constructor · intro q hq hH hdiv exact hgood (Finset.mem_filter.mpr ⟨hn, q, hq, hH, Or.inl hdiv⟩) · intro q hq hH hdiv exact hgood (Finset.mem_filter.mpr ⟨hn, q, hq, hH, Or.inr hdiv⟩) /-- The finite part of full fixed-tail rigidity, before asymptotic bounds are substituted. The three counts are global exceptional containers, and there is no separate preliminary square exclusion on phi(n). -/ /- Original line 25597: Erdos416Proof.Rigidity.original_count_le_exceptions -/ theorem original_count_le_exceptions {A c B : ℝ} (hr : 0 < r) (hY : 0 ≤ Y) (hsize : ∀ n : ℕ, 0 < n → (n.totient : ℝ) ≤ Y → (n : ℝ) ≤ c * Y * logLog Y) (hrnormal : ∀ q ∈ r.primeFactors, SNormal (normalityScale (logLog Y)) q) (hretained : ∀ (F : Finset ℕ), (∀ n ∈ F, ∃ (p : Fin (L + 1) → ℕ) (N : ℕ), CollisionSum.RetainedPair Y P κ θ r.totient n p N) → (F.card : ℝ) ≤ B) (F : Finset ℕ) (p : ℕ → Fin (L + 1) → ℕ) (hL : (L : ℝ) ≤ A * Real.log (logLog Y)) (hF : ∀ n ∈ F, Tuple Y P κ θ r n (p n)) (hlower : ∀ n ∈ F, ∀ m ∈ F, (∏ idx : Fin L, (p n idx.succ - 1)) = (∏ idx : Fin L, (p m idx.succ - 1)) → ∀ idx : Fin L, p n idx.succ = p m idx.succ) (hwitness : ∀ n ∈ F, ∃ N : ℕ, 0 < N ∧ N.totient = r.totient * n.totient ∧ largestPrimeFactor N ≠ p n 0) : (F.card : ℝ) ≤ squarefreeNonNormalCount A c Y + largeSquareExceptionalCount c Y + (nonNormalTotients (normalityScale (logLog Y)) Y).card + B := by classical let S := normalityScale (logLog Y) let E₀ := normalPrimeFailures F S let F₁ := F \ E₀ have hF₁ : F₁ ⊆ F := Finset.sdiff_subset have hnF₁ (n : ℕ) (hn : n ∈ F₁) : ∀ q : ℕ, q.Prime → q ∣ n → SNormal S q := normal_outside_failures (Finset.mem_sdiff.mp hn).1 (Finset.mem_sdiff.mp hn).2 obtain ⟨w, hw⟩ := exists_assignment F₁ p hr (fun n hn => hF n (hF₁ hn)) (fun n hn m hm => hlower n (hF₁ hn) m (hF₁ hm)) (fun n hn => hwitness n (hF₁ hn)) let E₁ := largeSquareFailures F₁ w (Real.log Y ^ 4) let E₂ := witnessNormalFailures F₁ w S let G := F₁ \ (E₁ ∪ E₂) have hφw (n : ℕ) (hn : n ∈ F₁) : ((w n).totient : ℝ) ≤ Y := by rw [hw.equation n hn] exact (hF n (hF₁ hn)).size have hzero : (E₀.card : ℝ) ≤ squarefreeNonNormalCount A c Y := squarefree_normal_failures_card_le hr hL hF hsize have hone : (E₁.card : ℝ) ≤ largeSquareExceptionalCount c Y := by change ((largeSquareFailures F₁ w (Real.log Y ^ 4)).card : ℝ) ≤ (largePrimeSquareBad ⌊c * Y * logLog Y⌋₊ (Real.log Y ^ 4)).card exact Nat.cast_le.mpr (largeSquareFailures_card_le F₁ w (c * Y * logLog Y) (Real.log Y ^ 4) hw.injective (fun n hn => ⟨hw.positive n hn, hsize (w n) (hw.positive n hn) (hφw n hn)⟩)) have htwo : (E₂.card : ℝ) ≤ (nonNormalTotients S Y).card := by exact_mod_cast hw.normal_failures_card_le hr hY hφw hrnormal hnF₁ have hG : (G.card : ℝ) ≤ B := by apply hretained G intro n hn obtain ⟨hnF₁, hnex⟩ := Finset.mem_sdiff.mp hn have hnF := hF₁ hnF₁ have ht := hF n hnF have hnE₁ : n ∉ E₁ := fun h => hnex (Finset.mem_union_left _ h) have hnE₂ : n ∉ E₂ := fun h => hnex (Finset.mem_union_right _ h) have hsquare := not_square_failure hnF₁ hnE₁ refine ⟨p n, w n, { integer := ht.integer normal_left := ht.normal_primes hnF (Finset.mem_sdiff.mp hnF₁).2 prime_min := ht.prime_min order := ht.order gaps := ht.gaps lower_upper := ht.lower_upper last_upper := ht.last_upper top := ht.top witness_pos := hw.positive n hnF₁ equation := (hw.equation n hnF₁).trans (congrArg (fun z : ℕ => r.totient * z) ht.totient) size := hφw n hnF₁ largest_ne := hw.largest_ne n hnF₁ normal_right := ?_ square_witness := hsquare.1 square_totient := hsquare.2 facet := ht.facet }⟩ intro q hq by_contra hbad exact hnE₂ (Finset.mem_filter.mpr ⟨hnF₁, q, Nat.prime_of_mem_primeFactors hq, Nat.dvd_of_mem_primeFactors hq, hbad⟩) have hcover : F ⊆ ((E₀ ∪ E₁) ∪ E₂) ∪ G := by intro n hn by_cases h₀ : n ∈ E₀ · exact Finset.mem_union_left _ (Finset.mem_union_left _ (Finset.mem_union_left _ h₀)) by_cases h₁ : n ∈ E₁ · exact Finset.mem_union_left _ (Finset.mem_union_left _ (Finset.mem_union_right _ h₁)) by_cases h₂ : n ∈ E₂ · exact Finset.mem_union_left _ (Finset.mem_union_right _ h₂) exact Finset.mem_union_right _ (Finset.mem_sdiff.mpr ⟨Finset.mem_sdiff.mpr ⟨hn, h₀⟩, fun h => (Finset.mem_union.mp h).elim h₁ h₂⟩) have hcard : F.card ≤ E₀.card + E₁.card + E₂.card + G.card := by calc F.card ≤ (((E₀ ∪ E₁) ∪ E₂) ∪ G).card := Finset.card_le_card hcover _ ≤ ((E₀ ∪ E₁) ∪ E₂).card + G.card := Finset.card_union_le _ _ _ ≤ (E₀ ∪ E₁).card + E₂.card + G.card := by gcongr; exact Finset.card_union_le _ _ _ ≤ E₀.card + E₁.card + E₂.card + G.card := by gcongr; exact Finset.card_union_le _ _ have hcardR : (F.card : ℝ) ≤ E₀.card + E₁.card + E₂.card + G.card := by exact_mod_cast hcard exact hcardR.trans (add_le_add (add_le_add (add_le_add hzero hone) htwo) hG) /-- The complete bound for any witnessed original family. Every threshold is chosen before the tuple length, the finite family and its prime records. -/ /- Original line 25688: Erdos416Proof.Rigidity.witnessed_family_count_eventually -/ theorem witnessed_family_count_eventually {A : ℝ} (hA : 0 < A) (P κ θ : ℝ) (hκ : 1 < κ) (hθ : θ < 1) (r : ℕ) (hr : 0 < r) : ∀ᶠ Y : ℝ in atTop, ∀ (L : ℕ) (F : Finset ℕ) (p : ℕ → Fin (L + 1) → ℕ), (L : ℝ) ≤ A * Real.log (logLog Y) → (∀ n ∈ F, Tuple Y P κ θ r n (p n)) → (∀ n ∈ F, ∀ m ∈ F, (∏ idx : Fin L, (p n idx.succ - 1)) = (∏ idx : Fin L, (p m idx.succ - 1)) → ∀ idx : Fin L, p n idx.succ = p m idx.succ) → (∀ n ∈ F, ∃ N : ℕ, 0 < N ∧ N.totient = r.totient * n.totient ∧ largestPrimeFactor N ≠ p n 0) → (F.card : ℝ) ≤ 4 * (Y / (Real.log Y * (logLog Y) ^ 2)) := by obtain ⟨c, hc, hsize⟩ := inverse_totient_bound_eventually have hT : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop have hS := CollisionState.normalityScale_atTop.comp hT filter_upwards [hsize, fixed_tail_normal_eventually r, hS.eventually_ge_atTop (largestPrimeFactor r.totient : ℝ), CollisionSum.retained_pairs_pruning_scale_eventually hA.le P κ θ hκ hθ r.totient (Nat.totient_pos.mpr hr), (normal_prime_pruning hA hc).bound (by norm_num : (0 : ℝ) < 1), (large_prime_square_pruning hc).bound (by norm_num : (0 : ℝ) < 1), nonNormalTotients_pruning.bound (by norm_num : (0 : ℝ) < 1), eventually_gt_atTop (1 : ℝ), hT.eventually_gt_atTop 0] with Y hsize hrnormal hdS hretained hzero hone htwo hY hTpos intro L F p hL hF hlower hwitness have hYpos : 0 < Y := by linarith have hlog : 0 < Real.log Y := Real.log_pos hY have hbase : 0 ≤ Y / (Real.log Y * (logLog Y) ^ 2) := by positivity have hzero' : squarefreeNonNormalCount A c Y ≤ Y / (Real.log Y * (logLog Y) ^ 2) := by change ‖squarefreeNonNormalCount A c Y‖ ≤ 1 * ‖Y / (Real.log Y * (logLog Y) ^ 2)‖ at hzero simpa only [one_mul, Real.norm_eq_abs, abs_of_nonneg hbase, abs_of_nonneg (show 0 ≤ squarefreeNonNormalCount A c Y from Nat.cast_nonneg _)] using hzero have hone' : largeSquareExceptionalCount c Y ≤ Y / (Real.log Y * (logLog Y) ^ 2) := by change ‖largeSquareExceptionalCount c Y‖ ≤ 1 * ‖Y / (Real.log Y * (logLog Y) ^ 2)‖ at hone simpa only [one_mul, Real.norm_eq_abs, abs_of_nonneg hbase, abs_of_nonneg (show 0 ≤ largeSquareExceptionalCount c Y from Nat.cast_nonneg _)] using hone have htwo' : ((nonNormalTotients (normalityScale (logLog Y)) Y).card : ℝ) ≤ Y / (Real.log Y * (logLog Y) ^ 2) := by simpa only [one_mul, Real.norm_eq_abs, abs_of_nonneg hbase, abs_of_nonneg (Nat.cast_nonneg _ : (0 : ℝ) ≤ (nonNormalTotients (normalityScale (logLog Y)) Y).card)] using htwo have hcount := original_count_le_exceptions hr hYpos.le hsize hrnormal (fun G hG => hretained L G hL hdS hG) F p hL hF hlower hwitness linarith /-- The actual members of a structural family admitting a preimage with a different largest prime. This counts original integers, not totient values. -/ /- Original line 25734: Erdos416Proof.Rigidity.collisions -/ noncomputable def collisions (F : Finset ℕ) (r : ℕ) (p : ℕ → Fin (L + 1) → ℕ) : Finset ℕ := F.filter (fun n => ∃ N : ℕ, 0 < N ∧ N.totient = r.totient * n.totient ∧ largestPrimeFactor N ≠ p n 0) /-- Full fixed-tail rigidity at the manuscript's scale, including witness assignment, every exceptional deletion and the retained-family sieve sum. -/ /- Original line 25740: Erdos416Proof.Rigidity.fixed_tail_rigidity -/ theorem fixed_tail_rigidity {A : ℝ} (hA : 0 < A) (P κ θ : ℝ) (hκ : 1 < κ) (hθ : θ < 1) (r : ℕ) (hr : 0 < r) : ∀ᶠ Y : ℝ in atTop, ∀ (L : ℕ) (F : Finset ℕ) (p : ℕ → Fin (L + 1) → ℕ), (L : ℝ) ≤ A * Real.log (logLog Y) → (∀ n ∈ F, Tuple Y P κ θ r n (p n)) → (∀ n ∈ F, ∀ m ∈ F, (∏ idx : Fin L, (p n idx.succ - 1)) = (∏ idx : Fin L, (p m idx.succ - 1)) → ∀ idx : Fin L, p n idx.succ = p m idx.succ) → ((collisions F r p).card : ℝ) ≤ 4 * (Y / (Real.log Y * (logLog Y) ^ 2)) := by filter_upwards [witnessed_family_count_eventually hA P κ θ hκ hθ r hr] with Y hcount intro L F p hL hF hlower apply hcount L (collisions F r p) p hL · intro n hn exact hF n (Finset.mem_filter.mp hn).1 · intro n hn m hm exact hlower n (Finset.mem_filter.mp hn).1 m (Finset.mem_filter.mp hm).1 · intro n hn exact (Finset.mem_filter.mp hn).2 end Erdos416Proof.Rigidity /- Actual Ford polytopes, diagonal volume comparison, the outer shell, and uniform bounds for the manuscript's expanded parameters. -/ open Filter Finset MeasureTheory open scoped Topology BigOperators Classical Pointwise namespace Erdos416Proof.FordGeometry variable {L : ℕ} /-- Coordinate j represents Ford's x_(j+1). The final row has coefficient one, as in I_(L-1); all earlier rows use the shifted Ford coefficients. -/ /- Original line 25778: Erdos416Proof.FordGeometry.tailWeight -/ noncomputable def tailWeight (idx j : Fin L) : ℝ := if idx.val < j.val then if idx.val + 2 < L then fordWeight (j.val - idx.val) else 1 else 0 /- Original line 25783: Erdos416Proof.FordGeometry.tailForm -/ noncomputable def tailForm (idx : Fin L) : (Fin L → ℝ) →ₗ[ℝ] ℝ := weightedForm (tailWeight idx) /- Original line 25786: Erdos416Proof.FordGeometry.outerForm -/ noncomputable def outerForm (L : ℕ) : (Fin L → ℝ) →ₗ[ℝ] ℝ := weightedForm (fun idx => fordWeight (idx.val + 1)) /-- The ordered Ford polytope S_L(xi). For L>=1, parameters beyond L-1 are unused. For L>=2 these are precisely the inequalities on page 11 of Ford v2. -/ /- Original line 25791: Erdos416Proof.FordGeometry.polytope -/ noncomputable def polytope (L : ℕ) (ξ : ℕ → ℝ) : Set (Fin L → ℝ) := {x | (∀ idx, 0 ≤ x idx) ∧ (∀ idx, x idx ≤ 1) ∧ Antitone x ∧ outerForm L x ≤ ξ 0 ∧ ∀ idx : Fin L, idx.val + 1 < L → tailForm idx x ≤ ξ (idx.val + 1) * x idx} /- Original line 25796: Erdos416Proof.FordGeometry.T -/ noncomputable def T (L : ℕ) : ℝ := volume.real (polytope L (fun _ => 1)) /- Original line 25798: Erdos416Proof.FordGeometry.tailWeight_nonneg -/ theorem tailWeight_nonneg (idx j : Fin L) : 0 ≤ tailWeight idx j := by unfold tailWeight split_ifs with hij hi · exact (fordWeight_bounds (by omega)).1 all_goals norm_num /- Original line 25804: Erdos416Proof.FordGeometry.tailWeight_zero -/ theorem tailWeight_zero {idx j : Fin L} (hij : j ≤ idx) : tailWeight idx j = 0 := by simp [tailWeight, show ¬ idx.val < j.val by exact not_lt_of_ge hij] /- Original line 25807: Erdos416Proof.FordGeometry.tailForm_eq_sum -/ theorem tailForm_eq_sum (idx : Fin L) (x : Fin L → ℝ) (hi : idx.val + 2 < L) : tailForm idx x = ∑ j : Fin L, if idx.val < j.val then fordWeight (j.val - idx.val) * x j else 0 := by simp [tailForm, weightedForm_apply, tailWeight, hi, ite_mul] /- Original line 25811: Erdos416Proof.FordGeometry.tailForm_last -/ theorem tailForm_last (idx j : Fin L) (hi : idx.val + 2 = L) (hj : j.val = idx.val + 1) (x : Fin L → ℝ) : tailForm idx x = x j := by change (∑ k : Fin L, tailWeight idx k * x k) = x j rw [Finset.sum_eq_single j] · simp [tailWeight, show idx.val < j.val by omega, show ¬ idx.val + 2 < L by omega] · intro k _ hkj have hki : k ≤ idx := by have hk := k.isLt have hne : k.val ≠ j.val := fun h => hkj (Fin.ext h) change k.val ≤ idx.val omega simp [tailWeight_zero hki] · simp /-- The defining inequalities written without the coefficient-matrix abbreviation. This includes the distinct last-row inequality of Ford. -/ /- Original line 25827: Erdos416Proof.FordGeometry.mem_polytope_iff -/ theorem mem_polytope_iff (hL : 2 ≤ L) (ξ : ℕ → ℝ) (x : Fin L → ℝ) : x ∈ polytope L ξ ↔ Antitone x ∧ 0 ≤ x ⟨L - 1, by omega⟩ ∧ x ⟨0, by omega⟩ ≤ 1 ∧ outerForm L x ≤ ξ 0 ∧ (∀ idx : Fin L, idx.val + 2 < L → (∑ j : Fin L, if idx.val < j.val then fordWeight (j.val - idx.val) * x j else 0) ≤ ξ (idx.val + 1) * x idx) ∧ x ⟨L - 1, by omega⟩ ≤ ξ (L - 1) * x ⟨L - 2, by omega⟩ := by constructor · intro hx refine ⟨hx.2.2.1, hx.1 _, hx.2.1 _, hx.2.2.2.1, ?_, ?_⟩ · intro idx hi rw [← tailForm_eq_sum idx x hi] exact hx.2.2.2.2 idx (by omega) · have h := hx.2.2.2.2 ⟨L - 2, by omega⟩ (by simp only; omega) rw [tailForm_last ⟨L - 2, by omega⟩ ⟨L - 1, by omega⟩ (by simp only; omega) (by simp only; omega) x] at h simpa only [show L - 2 + 1 = L - 1 by omega] using h · rintro ⟨hanti, hnonneg, htop, houter, hrows, hlast⟩ refine ⟨?_, ?_, hanti, houter, ?_⟩ · intro idx exact hnonneg.trans (hanti (show idx ≤ ⟨L - 1, by omega⟩ by have := idx.isLt; exact Nat.le_sub_one_of_lt this)) · intro idx exact (hanti (show (⟨0, by omega⟩ : Fin L) ≤ idx from Nat.zero_le _)).trans htop · intro idx hi by_cases hi' : idx.val + 2 < L · rw [tailForm_eq_sum idx x hi'] exact hrows idx hi' · have hlastrow : idx.val + 2 = L := by omega have hiEq : idx = ⟨L - 2, by omega⟩ := Fin.ext (by change idx.val = L - 2; omega) rw [tailForm_last idx ⟨L - 1, by omega⟩ hlastrow (by simp only; omega) x] simpa only [hiEq, show L - 2 + 1 = L - 1 by omega] using hlast /- Original line 25860: Erdos416Proof.FordGeometry.polytope_zero -/ theorem polytope_zero {ξ : ℕ → ℝ} (hξ : 0 ≤ ξ 0) : (0 : Fin L → ℝ) ∈ polytope L ξ := by simp [polytope, outerForm, tailForm, weightedForm_apply, Antitone, hξ] /- Original line 25863: Erdos416Proof.FordGeometry.polytope_mono -/ theorem polytope_mono {ξ η : ℕ → ℝ} (hξη : ∀ idx, ξ idx ≤ η idx) : polytope L ξ ⊆ polytope L η := by intro x hx exact ⟨hx.1, hx.2.1, hx.2.2.1, hx.2.2.2.1.trans (hξη 0), fun idx hi => (hx.2.2.2.2 idx hi).trans (mul_le_mul_of_nonneg_right (hξη _) (hx.1 idx))⟩ /- Original line 25869: Erdos416Proof.FordGeometry.polytope_isClosed -/ theorem polytope_isClosed (L : ℕ) (ξ : ℕ → ℝ) : IsClosed (polytope L ξ) := by simp only [polytope, Antitone, Set.ofPred_and, Set.ofPred_forall] refine (isClosed_iInter fun idx => isClosed_le continuous_const (continuous_apply idx)).inter ?_ refine (isClosed_iInter fun idx => isClosed_le (continuous_apply idx) continuous_const).inter ?_ refine (isClosed_iInter fun idx => isClosed_iInter fun j => isClosed_iInter fun _ => isClosed_le (continuous_apply j) (continuous_apply idx)).inter ?_ refine (isClosed_le (outerForm L).continuous_of_finiteDimensional continuous_const).inter ?_ exact isClosed_iInter fun idx => isClosed_iInter fun _ => isClosed_le (tailForm idx).continuous_of_finiteDimensional ((continuous_apply idx).const_mul _) /- Original line 25879: Erdos416Proof.FordGeometry.polytope_isCompact -/ theorem polytope_isCompact (L : ℕ) (ξ : ℕ → ℝ) : IsCompact (polytope L ξ) := by apply (isCompact_Icc : IsCompact (Set.Icc (0 : Fin L → ℝ) 1)).of_isClosed_subset (polytope_isClosed L ξ) intro x hx exact ⟨hx.1, hx.2.1⟩ /- Original line 25885: Erdos416Proof.FordGeometry.polytope_convex -/ theorem polytope_convex (L : ℕ) (ξ : ℕ → ℝ) : Convex ℝ (polytope L ξ) := by intro x hx y hy a b ha hb hab refine ⟨?_, ?_, ?_, ?_, ?_⟩ · intro idx exact add_nonneg (mul_nonneg ha (hx.1 idx)) (mul_nonneg hb (hy.1 idx)) · intro idx change a * x idx + b * y idx ≤ 1 nlinarith [mul_le_mul_of_nonneg_left (hx.2.1 idx) ha, mul_le_mul_of_nonneg_left (hy.2.1 idx) hb] · intro idx j hij exact add_le_add (mul_le_mul_of_nonneg_left (hx.2.2.1 hij) ha) (mul_le_mul_of_nonneg_left (hy.2.2.1 hij) hb) · simp only [map_add, map_smul, smul_eq_mul] calc _ ≤ a * ξ 0 + b * ξ 0 := add_le_add (mul_le_mul_of_nonneg_left hx.2.2.2.1 ha) (mul_le_mul_of_nonneg_left hy.2.2.2.1 hb) _ = (a + b) * ξ 0 := by ring _ = ξ 0 := by rw [hab, one_mul] · intro idx hi simp only [map_add, map_smul, smul_eq_mul, Pi.add_apply, Pi.smul_apply] nlinarith [mul_le_mul_of_nonneg_left (hx.2.2.2.2 idx hi) ha, mul_le_mul_of_nonneg_left (hy.2.2.2.2 idx hi) hb] /- Original line 25908: Erdos416Proof.FordGeometry.scaleProduct -/ noncomputable def scaleProduct (ξ : ℕ → ℝ) (k : ℕ) : ℝ := ∏ j ∈ Finset.range k, ξ j /- Original line 25910: Erdos416Proof.FordGeometry.prefix_zero -/ theorem prefix_zero (ξ : ℕ → ℝ) : scaleProduct ξ 0 = 1 := by simp [scaleProduct] /- Original line 25911: Erdos416Proof.FordGeometry.prefix_one -/ theorem prefix_one (ξ : ℕ → ℝ) : scaleProduct ξ 1 = ξ 0 := by simp [Erdos416Proof.FordGeometry.prefix_zero, scaleProduct] /- Original line 25912: Erdos416Proof.FordGeometry.prefix_succ -/ theorem prefix_succ (ξ : ℕ → ℝ) (k : ℕ) : scaleProduct ξ (k + 1) = scaleProduct ξ k * ξ k := Finset.prod_range_succ _ _ /- Original line 25915: Erdos416Proof.FordGeometry.prefix_pos -/ theorem prefix_pos {ξ : ℕ → ℝ} (hξ : ∀ j, 0 < ξ j) (k : ℕ) : 0 < scaleProduct ξ k := Finset.prod_pos (fun j _ => hξ j) /- Original line 25918: Erdos416Proof.FordGeometry.prefix_ge_one -/ theorem prefix_ge_one {ξ : ℕ → ℝ} (hξ : ∀ j, 1 ≤ ξ j) (k : ℕ) : 1 ≤ scaleProduct ξ k := Finset.one_le_prod (fun j _ => hξ j) /- Original line 25921: Erdos416Proof.FordGeometry.prefix_monotone -/ theorem prefix_monotone {ξ : ℕ → ℝ} (hξ : ∀ j, 1 ≤ ξ j) : Monotone (scaleProduct ξ) := by apply monotone_nat_of_le_succ intro k rw [prefix_succ] exact le_mul_of_one_le_right (by linarith [prefix_ge_one hξ k]) (hξ k) /- Original line 25927: Erdos416Proof.FordGeometry.prefix_antitone -/ theorem prefix_antitone {ξ : ℕ → ℝ} (hξ : ∀ j, 0 < ξ j ∧ ξ j ≤ 1) : Antitone (scaleProduct ξ) := by apply antitone_nat_of_succ_le intro k rw [prefix_succ] exact mul_le_of_le_one_right (prefix_pos (fun j => (hξ j).1) k).le (hξ k).2 /- Original line 25933: Erdos416Proof.FordGeometry.normalized -/ noncomputable def normalized (ξ : ℕ → ℝ) (x : Fin L → ℝ) : Fin L → ℝ := fun idx => x idx / scaleProduct ξ (idx.val + 1) /- Original line 25936: Erdos416Proof.FordGeometry.diagonal -/ noncomputable def diagonal (L : ℕ) (ξ : ℕ → ℝ) : (Fin L → ℝ) →ₗ[ℝ] (Fin L → ℝ) := Matrix.toLin' (Matrix.diagonal (fun idx : Fin L => scaleProduct ξ (idx.val + 1))) /- Original line 25939: Erdos416Proof.FordGeometry.diagonal_apply -/ theorem diagonal_apply (ξ : ℕ → ℝ) (x : Fin L → ℝ) (idx : Fin L) : diagonal L ξ x idx = scaleProduct ξ (idx.val + 1) * x idx := by simp [Erdos416Proof.FordGeometry.prefix_one, Erdos416Proof.FordGeometry.prefix_zero, diagonal, Matrix.toLin'_apply, Matrix.mulVec_diagonal] /- Original line 25943: Erdos416Proof.FordGeometry.diagonal_normalized -/ theorem diagonal_normalized {ξ : ℕ → ℝ} (hξ : ∀ j, 0 < ξ j) (x : Fin L → ℝ) : diagonal L ξ (normalized ξ x) = x := by ext idx simp only [diagonal_apply, normalized] field_simp [(prefix_pos hξ (idx.val + 1)).ne'] /-- Ford's Lemma 3.2 in the direction used for upper volume bounds. -/ /- Original line 25950: Erdos416Proof.FordGeometry.normalized_mem -/ theorem normalized_mem {ξ : ℕ → ℝ} (hξ : ∀ j, 1 ≤ ξ j) {x : Fin L → ℝ} (hx : x ∈ polytope L ξ) : normalized ξ x ∈ polytope L (fun _ => 1) := by have hp : ∀ j, 0 < ξ j := fun j => lt_of_lt_of_le zero_lt_one (hξ j) have hd := prefix_pos hp have hmono := prefix_monotone hξ refine ⟨?_, ?_, ?_, ?_, ?_⟩ · intro idx exact div_nonneg (hx.1 idx) (hd _).le · intro idx exact (div_le_one (hd _)).mpr ((hx.2.1 idx).trans (prefix_ge_one hξ _)) · intro idx j hij change x j / scaleProduct ξ (j.val + 1) ≤ x idx / scaleProduct ξ (idx.val + 1) exact (div_le_div_of_nonneg_left (hx.1 j) (hd _) (hmono (by exact Nat.add_le_add_right hij 1))).trans (div_le_div_of_nonneg_right (hx.2.2.1 hij) (hd _).le) · have houter : outerForm L (normalized ξ x) ≤ outerForm L x / ξ 0 := by change (∑ idx : Fin L, fordWeight (idx.val + 1) * (x idx / scaleProduct ξ (idx.val + 1))) ≤ (∑ idx : Fin L, fordWeight (idx.val + 1) * x idx) / ξ 0 rw [Finset.sum_div] apply Finset.sum_le_sum intro idx _ have hi : ξ 0 ≤ scaleProduct ξ (idx.val + 1) := by simpa only [prefix_one] using hmono (show 1 ≤ idx.val + 1 by omega) calc _ ≤ fordWeight (idx.val + 1) * (x idx / ξ 0) := mul_le_mul_of_nonneg_left (div_le_div_of_nonneg_left (hx.1 idx) (hp 0) hi) (fordWeight_bounds (by omega)).1 _ = _ := by ring exact houter.trans ((div_le_one (hp 0)).mpr hx.2.2.2.1) · intro idx hi have hrow : tailForm idx (normalized ξ x) ≤ tailForm idx x / scaleProduct ξ (idx.val + 2) := by change (∑ j : Fin L, tailWeight idx j * (x j / scaleProduct ξ (j.val + 1))) ≤ (∑ j : Fin L, tailWeight idx j * x j) / scaleProduct ξ (idx.val + 2) rw [Finset.sum_div] apply Finset.sum_le_sum intro j _ by_cases hij : idx < j · calc _ ≤ tailWeight idx j * (x j / scaleProduct ξ (idx.val + 2)) := mul_le_mul_of_nonneg_left (div_le_div_of_nonneg_left (hx.1 j) (hd _) (hmono (by change idx.val < j.val at hij; omega))) (tailWeight_nonneg idx j) _ = _ := by ring · simp [Erdos416Proof.FordGeometry.diagonal_apply, Erdos416Proof.FordGeometry.prefix_one, Erdos416Proof.FordGeometry.prefix_zero, tailWeight_zero (le_of_not_gt hij)] calc tailForm idx (normalized ξ x) ≤ tailForm idx x / scaleProduct ξ (idx.val + 2) := hrow _ ≤ (ξ (idx.val + 1) * x idx) / scaleProduct ξ (idx.val + 2) := div_le_div_of_nonneg_right (hx.2.2.2.2 idx hi) (hd _).le _ = 1 * normalized ξ x idx := by rw [show idx.val + 2 = (idx.val + 1) + 1 by omega, prefix_succ] simp only [normalized, one_mul] field_simp [(hp (idx.val + 1)).ne', (hd (idx.val + 1)).ne'] /-- Ford's Lemma 3.2 in the contraction direction. -/ /- Original line 26002: Erdos416Proof.FordGeometry.diagonal_mem -/ theorem diagonal_mem {ξ : ℕ → ℝ} (hξ : ∀ j, 0 < ξ j ∧ ξ j ≤ 1) {x : Fin L → ℝ} (hx : x ∈ polytope L (fun _ => 1)) : diagonal L ξ x ∈ polytope L ξ := by have hp : ∀ j, 0 < ξ j := fun j => (hξ j).1 have hd := prefix_pos hp have hanti := prefix_antitone hξ refine ⟨?_, ?_, ?_, ?_, ?_⟩ · intro idx rw [diagonal_apply] exact mul_nonneg (hd _).le (hx.1 idx) · intro idx rw [diagonal_apply] have hdi : scaleProduct ξ (idx.val + 1) ≤ 1 := by simpa only [prefix_zero] using hanti (show 0 ≤ idx.val + 1 by omega) exact (mul_le_mul_of_nonneg_left (hx.2.1 idx) (hd _).le).trans (by simpa [Erdos416Proof.FordGeometry.diagonal_apply, Erdos416Proof.FordGeometry.prefix_one, Erdos416Proof.FordGeometry.prefix_zero] using hdi) · intro idx j hij simp only [diagonal_apply] exact mul_le_mul (hanti (Nat.add_le_add_right hij 1)) (hx.2.2.1 hij) (hx.1 j) (hd _).le · have houter : outerForm L (diagonal L ξ x) ≤ ξ 0 * outerForm L x := by simp only [outerForm, weightedForm_apply, diagonal_apply, Finset.mul_sum] apply Finset.sum_le_sum intro idx _ have hi : scaleProduct ξ (idx.val + 1) ≤ ξ 0 := by simpa only [prefix_one] using hanti (show 1 ≤ idx.val + 1 by omega) calc _ ≤ fordWeight (idx.val + 1) * (ξ 0 * x idx) := mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_right hi (hx.1 idx)) (fordWeight_bounds (by omega)).1 _ = _ := by ring exact houter.trans (by simpa [Erdos416Proof.FordGeometry.diagonal_apply, Erdos416Proof.FordGeometry.prefix_one, Erdos416Proof.FordGeometry.prefix_zero] using mul_le_mul_of_nonneg_left hx.2.2.2.1 (hp 0).le) · intro idx hi have hrow : tailForm idx (diagonal L ξ x) ≤ scaleProduct ξ (idx.val + 2) * tailForm idx x := by simp only [tailForm, weightedForm_apply, diagonal_apply, Finset.mul_sum] apply Finset.sum_le_sum intro j _ by_cases hij : idx < j · calc _ ≤ tailWeight idx j * (scaleProduct ξ (idx.val + 2) * x j) := mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_right (hanti (by change idx.val < j.val at hij; omega)) (hx.1 j)) (tailWeight_nonneg idx j) _ = _ := by ring · simp [Erdos416Proof.FordGeometry.diagonal_apply, Erdos416Proof.FordGeometry.prefix_one, Erdos416Proof.FordGeometry.prefix_zero, tailWeight_zero (le_of_not_gt hij)] calc tailForm idx (diagonal L ξ x) ≤ scaleProduct ξ (idx.val + 2) * tailForm idx x := hrow _ ≤ scaleProduct ξ (idx.val + 2) * x idx := mul_le_mul_of_nonneg_left (by simpa [Erdos416Proof.FordGeometry.diagonal_apply, Erdos416Proof.FordGeometry.prefix_one, Erdos416Proof.FordGeometry.prefix_zero] using hx.2.2.2.2 idx hi) (hd _).le _ = ξ (idx.val + 1) * diagonal L ξ x idx := by rw [diagonal_apply, show idx.val + 2 = (idx.val + 1) + 1 by omega, prefix_succ] ring /-- The exact accumulated volume distortion in Ford's Corollary 3.3. -/ /- Original line 26052: Erdos416Proof.FordGeometry.H -/ noncomputable def H (L : ℕ) (ξ : ℕ → ℝ) : ℝ := ∏ j ∈ Finset.range L, ξ j ^ (L - j) /- Original line 26055: Erdos416Proof.FordGeometry.H_nonneg -/ theorem H_nonneg {ξ : ℕ → ℝ} (hξ : ∀ j, 0 ≤ ξ j) : 0 ≤ H L ξ := Finset.prod_nonneg (fun j _ => pow_nonneg (hξ j) _) /- Original line 26058: Erdos416Proof.FordGeometry.scaleProduct_product -/ theorem scaleProduct_product (ξ : ℕ → ℝ) (L : ℕ) : (∏ idx ∈ Finset.range L, scaleProduct ξ (idx + 1)) = H L ξ := by induction L with | zero => simp [Erdos416Proof.FordGeometry.diagonal_apply, Erdos416Proof.FordGeometry.prefix_one, Erdos416Proof.FordGeometry.prefix_zero, H] | succ L ih => rw [Finset.prod_range_succ, ih] unfold H rw [Finset.prod_range_succ] have hinner : (∏ j ∈ Finset.range L, ξ j ^ (L + 1 - j)) = (∏ j ∈ Finset.range L, ξ j ^ (L - j)) * scaleProduct ξ L := by rw [scaleProduct, ← Finset.prod_mul_distrib] apply Finset.prod_congr rfl intro j hj have hjL := Finset.mem_range.mp hj rw [show L + 1 - j = (L - j) + 1 by omega, pow_succ] rw [hinner, prefix_succ] simp only [Nat.add_sub_cancel_left, pow_one] ring /- Original line 26077: Erdos416Proof.FordGeometry.diagonal_det -/ theorem diagonal_det (L : ℕ) (ξ : ℕ → ℝ) : LinearMap.det (diagonal L ξ) = H L ξ := by rw [diagonal, LinearMap.det_toLin', Matrix.det_diagonal] exact (Fin.prod_univ_eq_prod_range (fun idx => scaleProduct ξ (idx + 1)) L).trans (scaleProduct_product ξ L) /- Original line 26082: Erdos416Proof.FordGeometry.diagonal_volume -/ theorem diagonal_volume (ξ : ℕ → ℝ) (E : Set (Fin L → ℝ)) : volume.real (diagonal L ξ '' E) = |H L ξ| * volume.real E := by simp only [measureReal_def, Measure.addHaar_image_linearMap, diagonal_det, ENNReal.toReal_mul, ENNReal.toReal_ofReal (abs_nonneg (H L ξ))] /-- Both bounds in Ford's Corollary 3.3 for parameters at least one. -/ /- Original line 26088: Erdos416Proof.FordGeometry.volume_comparison_ge_one -/ theorem volume_comparison_ge_one {ξ : ℕ → ℝ} (hξ : ∀ j, 1 ≤ ξ j) : T L ≤ volume.real (polytope L ξ) ∧ volume.real (polytope L ξ) ≤ H L ξ * T L := by have hp : ∀ j, 0 < ξ j := fun j => lt_of_lt_of_le zero_lt_one (hξ j) constructor · exact measureReal_mono (polytope_mono hξ) (polytope_isCompact L ξ).measure_lt_top.ne · have hsub : polytope L ξ ⊆ diagonal L ξ '' polytope L (fun _ => 1) := by intro x hx exact ⟨normalized ξ x, normalized_mem hξ hx, diagonal_normalized hp x⟩ have hfin : volume (diagonal L ξ '' polytope L (fun _ => 1)) ≠ ⊤ := ((polytope_isCompact L (fun _ => 1)).image (diagonal L ξ).continuous_of_finiteDimensional).measure_lt_top.ne have h := measureReal_mono hsub hfin simpa only [diagonal_volume, abs_of_nonneg (H_nonneg (fun j => (hp j).le)), T] using h /-- Both bounds in Ford's Corollary 3.3 for positive parameters at most one. -/ /- Original line 26103: Erdos416Proof.FordGeometry.volume_comparison_le_one -/ theorem volume_comparison_le_one {ξ : ℕ → ℝ} (hξ : ∀ j, 0 < ξ j ∧ ξ j ≤ 1) : H L ξ * T L ≤ volume.real (polytope L ξ) ∧ volume.real (polytope L ξ) ≤ T L := by constructor · have hsub : diagonal L ξ '' polytope L (fun _ => 1) ⊆ polytope L ξ := by rintro x ⟨y, hy, rfl⟩ exact diagonal_mem hξ hy have h := measureReal_mono (μ := volume) hsub (polytope_isCompact L ξ).measure_lt_top.ne simpa only [diagonal_volume, abs_of_nonneg (H_nonneg (fun j => (hξ j).1.le)), T] using h · exact measureReal_mono (polytope_mono (fun j => (hξ j).2)) (polytope_isCompact L (fun _ => 1)).measure_lt_top.ne /- Original line 26114: Erdos416Proof.FordGeometry.sum_succ_eq_Icc -/ theorem sum_succ_eq_Icc (f : ℕ → ℝ) (L : ℕ) : (∑ idx : Fin L, f (idx.val + 1)) = ∑ idx ∈ Finset.Icc 1 L, f idx := by induction L with | zero => simp | succ L ih => rw [Fin.sum_univ_castSucc, Finset.sum_Icc_succ_top (by omega)] simpa only [Fin.val_castSucc, Fin.val_last] using congrArg (fun z => z + f (L + 1)) ih /- Original line 26122: Erdos416Proof.FordGeometry.outer_weight_sum -/ theorem outer_weight_sum (L : ℕ) : (∑ idx : Fin L, fordWeight (idx.val + 1)) = ((L : ℝ) + 1) * Real.log ((L : ℝ) + 1) - L := by rw [sum_succ_eq_Icc] exact sum_fordWeight L /-- The actual lower-coordinate outer facet is exactly the one used in the original tuple record of the proved collision theorem. -/ /- Original line 26129: Erdos416Proof.FordGeometry.outerForm_eq_extended_sum -/ theorem outerForm_eq_extended_sum (x : Fin (L + 1) → ℝ) : outerForm L (fun idx : Fin L => x idx.succ) = ∑ j ∈ Finset.Icc 1 L, fordWeight j * CollisionFacet.extend x j := by calc _ = ∑ idx : Fin L, fordWeight (idx.val + 1) * CollisionFacet.extend x (idx.val + 1) := by simp only [outerForm, weightedForm_apply] apply Finset.sum_congr rfl intro idx _ simp only [CollisionFacet.extend, dif_pos (Nat.add_lt_add_right idx.isLt 1)] rfl _ = _ := sum_succ_eq_Icc (fun j => fordWeight j * CollisionFacet.extend x j) L /-- The already checked geometric shell theorem applied to the actual Ford polytope. A later volume comparison must control the final thickened volume. -/ /- Original line 26143: Erdos416Proof.FordGeometry.outer_shell_bound -/ theorem outer_shell_bound (hL : 1 ≤ L) {ξ : ℕ → ℝ} (hξ : 1 ≤ ξ 0) {δ τ : ℝ} (hδ : 0 ≤ δ) (hτ : 0 ≤ τ) : volume.real ((polytope L ξ ∩ {x | 1 - δ < outerForm L x}) + errorCube L τ) ≤ 2 * L * (δ + ξ 0 - 1 + (((L : ℝ) + 1) * Real.log ((L : ℝ) + 1) - L) * τ) * volume.real (polytope L ξ + errorCube L τ) := by have h := thickened_outer_shell_cube hL (polytope L ξ) (polytope_isCompact L ξ) (polytope_convex L ξ) (polytope_zero (by linarith)) (fun idx : Fin L => fordWeight (idx.val + 1)) (fun idx => (fordWeight_bounds (by omega)).1) hξ hδ hτ (fun x hx => hx.2.2.2.1) simpa only [outer_weight_sum, outerForm] using h /- Original line 26155: Erdos416Proof.FordGeometry.H_pos -/ theorem H_pos {ξ : ℕ → ℝ} (hξ : ∀ j, 0 < ξ j) : 0 < H L ξ := Finset.prod_pos (fun j _ => pow_pos (hξ j) _) /- Original line 26158: Erdos416Proof.FordGeometry.log_H -/ theorem log_H {ξ : ℕ → ℝ} (hξ : ∀ j, 0 < ξ j) : Real.log (H L ξ) = ∑ j ∈ Finset.range L, ((L - j : ℕ) : ℝ) * Real.log (ξ j) := by rw [H, Real.log_prod (fun j _ => pow_ne_zero _ (hξ j).ne')] simp only [Real.log_pow] /- Original line 26163: Erdos416Proof.FordGeometry.geometric_weight_sum_le -/ theorem geometric_weight_sum_le {q : ℝ} (hq0 : 0 ≤ q) (hq1 : q < 1) (L : ℕ) : (∑ j ∈ Finset.range L, ((L - j : ℕ) : ℝ) * q ^ (L - j)) ≤ q / (1 - q) ^ 2 := by have hqnorm : ‖q‖ < 1 := by simpa only [Real.norm_eq_abs, abs_of_nonneg hq0] using hq1 have hs := hasSum_coe_mul_geometric_of_norm_lt_one hqnorm calc _ = ∑ k ∈ Finset.Icc 1 L, (k : ℝ) * q ^ k := by refine Finset.sum_bij (fun j _ => L - j) ?_ ?_ ?_ ?_ · intro j hj have hjL := Finset.mem_range.mp hj exact Finset.mem_Icc.mpr ⟨by omega, by omega⟩ · intro j hj k hk heq have hjL := Finset.mem_range.mp hj have hkL := Finset.mem_range.mp hk omega · intro k hk obtain ⟨hk1, hkL⟩ := Finset.mem_Icc.mp hk exact ⟨L - k, Finset.mem_range.mpr (by omega), by omega⟩ · intro j hj rfl _ ≤ ∑' k : ℕ, (k : ℝ) * q ^ k := hs.summable.sum_le_tsum _ (fun k _ => mul_nonneg (Nat.cast_nonneg _) (pow_nonneg hq0 _)) _ = _ := hs.tsum_eq /-- Summable perturbations give one bound on the volume distortion for every dimension. No asymptotic for the fundamental volume is used here. -/ /- Original line 26188: Erdos416Proof.FordGeometry.H_le_exp_geometric -/ theorem H_le_exp_geometric {ξ : ℕ → ℝ} (hξ : ∀ j, 0 < ξ j) {a q : ℝ} (ha : 0 ≤ a) (hq0 : 0 ≤ q) (hq1 : q < 1) (hbound : ∀ j < L, ξ j ≤ 1 + a * q ^ (L - j)) : H L ξ ≤ Real.exp (a * (q / (1 - q) ^ 2)) := by have hlog : Real.log (H L ξ) ≤ a * (q / (1 - q) ^ 2) := by calc _ = ∑ j ∈ Finset.range L, ((L - j : ℕ) : ℝ) * Real.log (ξ j) := log_H hξ _ ≤ ∑ j ∈ Finset.range L, ((L - j : ℕ) : ℝ) * (a * q ^ (L - j)) := by apply Finset.sum_le_sum intro j hj apply mul_le_mul_of_nonneg_left _ (Nat.cast_nonneg _) have h := Real.log_le_sub_one_of_pos (hξ j) have hb := hbound j (Finset.mem_range.mp hj) linarith _ = a * ∑ j ∈ Finset.range L, ((L - j : ℕ) : ℝ) * q ^ (L - j) := by rw [Finset.mul_sum] apply Finset.sum_congr rfl intro j hj ring _ ≤ _ := mul_le_mul_of_nonneg_left (geometric_weight_sum_le hq0 hq1 L) ha calc H L ξ = Real.exp (Real.log (H L ξ)) := (Real.exp_log (H_pos hξ)).symm _ ≤ _ := Real.exp_le_exp.mpr hlog /-- The perturbation appearing in the structural-record construction. -/ /- Original line 26213: Erdos416Proof.FordGeometry.expandedParameter -/ noncomputable def expandedParameter (N j : ℕ) : ℝ := 1 + (1 / 10000 : ℝ) * Real.exp (-(((N : ℝ) - j) / 40)) /- Original line 26216: Erdos416Proof.FordGeometry.expandedParameter_ge_one -/ theorem expandedParameter_ge_one (N j : ℕ) : 1 ≤ expandedParameter N j := by unfold expandedParameter linarith [Real.exp_pos (-(((N : ℝ) - j) / 40))] /- Original line 26220: Erdos416Proof.FordGeometry.perturbationConstant -/ noncomputable def perturbationConstant : ℝ := (1 / 10000 : ℝ) * (Real.exp (-1 / 40) / (1 - Real.exp (-1 / 40)) ^ 2) /- Original line 26223: Erdos416Proof.FordGeometry.expanded_H_bound -/ theorem expanded_H_bound (L M : ℕ) : H L (expandedParameter (L + M)) ≤ Real.exp (perturbationConstant * Real.exp (-((M : ℝ) / 40))) := by let q : ℝ := Real.exp (-1 / 40) have hq0 : 0 < q := Real.exp_pos _ have hq1 : q < 1 := Real.exp_lt_one_iff.mpr (by norm_num) have hparam (j : ℕ) (hj : j < L) : expandedParameter (L + M) j = 1 + ((1 / 10000 : ℝ) * Real.exp (-((M : ℝ) / 40))) * q ^ (L - j) := by unfold expandedParameter have hq : q ^ (L - j) = Real.exp (-(((L - j : ℕ) : ℝ) / 40)) := by dsimp only [q] rw [← Real.exp_nat_mul] congr 1 ring rw [hq] have he : Real.exp (-((((L + M : ℕ) : ℝ) - j) / 40)) = Real.exp (-((M : ℝ) / 40)) * Real.exp (-(((L - j : ℕ) : ℝ) / 40)) := by rw [← Real.exp_add, Nat.cast_add, Nat.cast_sub hj.le] congr 1 ring rw [he] ring have h := H_le_exp_geometric (fun j => lt_of_lt_of_le zero_lt_one (expandedParameter_ge_one (L + M) j)) (by positivity : 0 ≤ (1 / 10000 : ℝ) * Real.exp (-((M : ℝ) / 40))) hq0.le hq1 (fun j hj => (hparam j hj).le) convert h using 1 congr 1 unfold perturbationConstant q ring /-- M is fixed first, and one choice works for every later dimension L. -/ /- Original line 26256: Erdos416Proof.FordGeometry.expanded_H_eventually -/ theorem expanded_H_eventually : ∀ᶠ M : ℕ in atTop, ∀ L : ℕ, H L (expandedParameter (L + M)) ≤ 2 := by have hM : Tendsto (fun M : ℕ => (M : ℝ) / 40) atTop atTop := tendsto_natCast_atTop_atTop.atTop_div_const (by norm_num : (0 : ℝ) < 40) have hz := Real.tendsto_exp_neg_atTop_nhds_zero.comp hM have hlim : Tendsto (fun M : ℕ => Real.exp (perturbationConstant * Real.exp (-((M : ℝ) / 40)))) atTop (nhds 1) := by have he := (Real.continuous_exp.tendsto (perturbationConstant * 0)).comp (hz.const_mul perturbationConstant) simpa only [Function.comp_def, mul_zero, Real.exp_zero] using! he filter_upwards [hlim.eventually (gt_mem_nhds (by norm_num : (1 : ℝ) < 2))] with M hM intro L exact (expanded_H_bound L M).trans hM.le /- Original line 26269: Erdos416Proof.FordGeometry.expanded_volume_eventually -/ theorem expanded_volume_eventually : ∀ᶠ M : ℕ in atTop, ∀ L : ℕ, volume.real (polytope L (expandedParameter (L + M))) ≤ 2 * T L := by filter_upwards [expanded_H_eventually] with M hM intro L exact (volume_comparison_ge_one (expandedParameter_ge_one (L + M))).2.trans (mul_le_mul_of_nonneg_right (hM L) (measureReal_nonneg : 0 ≤ T L)) /-- The outer-facet perturbation, including its dimension factor, tends to zero for every fixed M. This is one of the shell-loss terms in the cores. -/ /- Original line 26279: Erdos416Proof.FordGeometry.expanded_outer_decay -/ theorem expanded_outer_decay (M : ℕ) : Tendsto (fun L : ℕ => (L : ℝ) * (expandedParameter (L + M) 0 - 1)) atTop (nhds 0) := by have hL : Tendsto (fun L : ℕ => (L : ℝ) / 40) atTop atTop := tendsto_natCast_atTop_atTop.atTop_div_const (by norm_num : (0 : ℝ) < 40) have hs := (Real.tendsto_pow_mul_exp_neg_atTop_nhds_zero 1).comp hL have h := hs.const_mul ((40 / 10000 : ℝ) * Real.exp (-((M : ℝ) / 40))) convert h using 1 · funext L dsimp only [Function.comp_def, expandedParameter] rw [Nat.cast_add] simp only [Nat.cast_zero, sub_zero, add_sub_cancel_left, pow_one] rw [show -(((L : ℝ) + M) / 40) = -((L : ℝ) / 40) + -((M : ℝ) / 40) by ring, Real.exp_add] ring · simp end Erdos416Proof.FordGeometry /- Ford's power series, its simple root, and the renewal generating function. The quantitative renewal estimate and subsequent volume estimates remain. -/ open Filter Finset open scoped Topology BigOperators namespace Erdos416Proof.FordAnalysis /-- Ford's power series has zero constant coefficient, unlike `fordWeight 0`. -/ /- Original line 26311: Erdos416Proof.FordAnalysis.coeff -/ noncomputable def coeff (n : ℕ) : ℝ := if n = 0 then 0 else fordWeight n /- Original line 26313: Erdos416Proof.FordAnalysis.coeff_zero -/ theorem coeff_zero : coeff 0 = 0 := by simp [coeff] /- Original line 26315: Erdos416Proof.FordAnalysis.coeff_eq -/ theorem coeff_eq {n : ℕ} (hn : 1 ≤ n) : coeff n = fordWeight n := by simp [Erdos416Proof.FordAnalysis.coeff_zero, coeff, show n ≠ 0 by omega] /- Original line 26318: Erdos416Proof.FordAnalysis.coeff_bounds -/ theorem coeff_bounds (n : ℕ) : 0 ≤ coeff n ∧ coeff n ≤ n := by rcases Nat.eq_zero_or_pos n with rfl | hn · simp[Erdos416Proof.FordAnalysis.coeff_zero] rw [coeff_eq hn] refine ⟨(fordWeight_bounds hn).1, (fordWeight_bounds hn).2.trans ?_⟩ have h := Real.log_le_sub_one_of_pos (show 0 < (n : ℝ) + 1 by positivity) linarith /- Original line 26326: Erdos416Proof.FordAnalysis.coeff_ge_log -/ theorem coeff_ge_log {n : ℕ} (hn : 1 ≤ n) : Real.log n ≤ coeff n := by have hn0 : (0 : ℝ) < n := by exact_mod_cast hn have hnp : (0 : ℝ) < (n : ℝ) + 1 := by positivity have h := Real.one_sub_inv_le_log_of_pos (div_pos hnp hn0) rw [Real.log_div hnp.ne' hn0.ne', inv_div] at h have hm := mul_le_mul_of_nonneg_left h hnp.le have hid : ((n : ℝ) + 1) * (1 - (n : ℝ) / ((n : ℝ) + 1)) = 1 := by field_simp ring rw [hid] at hm rw [coeff_eq hn, fordWeight] nlinarith /- Original line 26339: Erdos416Proof.FordAnalysis.half_lt_log_two -/ theorem half_lt_log_two : (1 / 2 : ℝ) < Real.log 2 := by have h := Real.log_lt_sub_one_of_pos (show (0 : ℝ) < (2 : ℝ)⁻¹ by norm_num) (by norm_num : (2 : ℝ)⁻¹ ≠ 1) rw [Real.log_inv] at h norm_num at h linarith /- Original line 26346: Erdos416Proof.FordAnalysis.coeff_one_pos -/ theorem coeff_one_pos : 0 < coeff 1 := by have h := half_lt_log_two norm_num [coeff, fordWeight] at * linarith /- Original line 26351: Erdos416Proof.FordAnalysis.coeff_ge_half -/ theorem coeff_ge_half {n : ℕ} (hn : 2 ≤ n) : (1 / 2 : ℝ) ≤ coeff n := by exact half_lt_log_two.le.trans ((Real.log_le_log (by norm_num) (show (2 : ℝ) ≤ n by exact_mod_cast hn)).trans (coeff_ge_log (by omega))) /- Original line 26355: Erdos416Proof.FordAnalysis.F -/ noncomputable def F (z : ℝ) : ℝ := ∑' n : ℕ, coeff n * z ^ n /- Original line 26357: Erdos416Proof.FordAnalysis.summable_F -/ theorem summable_F {z : ℝ} (hz : |z| < 1) : Summable (fun n : ℕ => coeff n * z ^ n) := by apply Summable.of_norm_bounded (hasSum_coe_mul_geometric_of_norm_lt_one (r := |z|) (by simpa [Erdos416Proof.FordAnalysis.coeff_zero] using hz)).summable intro n rw [norm_mul, Real.norm_eq_abs, abs_of_nonneg (coeff_bounds n).1, norm_pow, Real.norm_eq_abs] exact mul_le_mul_of_nonneg_right (coeff_bounds n).2 (pow_nonneg (abs_nonneg z) n) /- Original line 26366: Erdos416Proof.FordAnalysis.F_nonneg -/ theorem F_nonneg {z : ℝ} (hz : 0 ≤ z) : 0 ≤ F z := tsum_nonneg fun n => mul_nonneg (coeff_bounds n).1 (pow_nonneg hz n) /- Original line 26369: Erdos416Proof.FordAnalysis.F_zero -/ theorem F_zero : F 0 = 0 := by calc F 0 = ∑' _n : ℕ, (0 : ℝ) := tsum_congr fun n => by cases n <;> simp[Erdos416Proof.FordAnalysis.coeff_zero] _ = 0 := tsum_zero /- Original line 26374: Erdos416Proof.FordAnalysis.F_continuousOn_Icc -/ theorem F_continuousOn_Icc {r : ℝ} (hr0 : 0 ≤ r) (hr1 : r < 1) : ContinuousOn F (Set.Icc (-r) r) := by apply continuousOn_tsum (fun n => (continuous_const.mul (continuous_id.pow n)).continuousOn) (hasSum_coe_mul_geometric_of_norm_lt_one (r := r) (by simpa [Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.coeff_zero, Real.norm_eq_abs, abs_of_nonneg hr0] using hr1)).summable intro n x hx have hxabs : |x| ≤ r := abs_le.mpr hx change ‖coeff n * x ^ n‖ ≤ (n : ℝ) * r ^ n rw [norm_mul, Real.norm_eq_abs, abs_of_nonneg (coeff_bounds n).1, norm_pow, Real.norm_eq_abs] exact mul_le_mul (coeff_bounds n).2 (pow_le_pow_left₀ (abs_nonneg x) hxabs n) (pow_nonneg (abs_nonneg x) n) (Nat.cast_nonneg n) /- Original line 26387: Erdos416Proof.FordAnalysis.F_strictMonoOn -/ theorem F_strictMonoOn : StrictMonoOn F (Set.Ico 0 1) := by intro x hx y hy hxy refine Summable.tsum_lt_tsum ?_ (show coeff 1 * x ^ 1 < coeff 1 * y ^ 1 from ?_) ?_ ?_ · intro n exact mul_le_mul_of_nonneg_left (pow_le_pow_left₀ hx.1 hxy.le n) (coeff_bounds n).1 · simpa only [pow_one] using mul_lt_mul_of_pos_left hxy coeff_one_pos · exact summable_F (by simpa only [abs_of_nonneg hx.1] using hx.2) · exact summable_F (by simpa only [abs_of_nonneg hy.1] using hy.2) /- Original line 26396: Erdos416Proof.FordAnalysis.one_lt_F_three_quarters -/ theorem one_lt_F_three_quarters : 1 < F (3 / 4) := by have hs : (∑ n ∈ Finset.Icc 2 9, coeff n * (3 / 4 : ℝ) ^ n) ≤ F (3 / 4) := by apply Summable.sum_le_tsum · intro n _ exact mul_nonneg (coeff_bounds n).1 (by positivity) · exact summable_F (by norm_num) have hl : (∑ n ∈ Finset.Icc 2 9, (1 / 2 : ℝ) * (3 / 4 : ℝ) ^ n) ≤ ∑ n ∈ Finset.Icc 2 9, coeff n * (3 / 4 : ℝ) ^ n := by apply Finset.sum_le_sum intro n hn exact mul_le_mul_of_nonneg_right (coeff_ge_half (Finset.mem_Icc.mp hn).1) (by positivity) have hnum : (1 : ℝ) < ∑ n ∈ Finset.Icc 2 9, (1 / 2 : ℝ) * (3 / 4 : ℝ) ^ n := by rw [show Finset.Icc 2 9 = {2, 3, 4, 5, 6, 7, 8, 9} by decide] norm_num exact hnum.trans_le (hl.trans hs) /- Original line 26413: Erdos416Proof.FordAnalysis.exists_rho -/ theorem exists_rho : ∃ r : ℝ, 0 < r ∧ r < 3 / 4 ∧ F r = 1 := by have hc : ContinuousOn F (Set.Icc 0 (3 / 4)) := (F_continuousOn_Icc (by norm_num : (0 : ℝ) ≤ 3 / 4) (by norm_num)).mono (by intro x hx; exact ⟨by linarith [hx.1], hx.2⟩) obtain ⟨r, hr, heq⟩ := intermediate_value_Icc (by norm_num : (0 : ℝ) ≤ 3 / 4) hc (show (1 : ℝ) ∈ Set.Icc (F 0) (F (3 / 4)) from ⟨by simp[Erdos416Proof.FordAnalysis.F_zero] , one_lt_F_three_quarters.le⟩) refine ⟨r, ?_, ?_, heq⟩ · rcases hr.1.eq_or_lt with h | h · subst r simp [Erdos416Proof.FordAnalysis.F_zero] at heq · exact h · rcases hr.2.eq_or_lt with h | h · rw [h] at heq linarith [one_lt_F_three_quarters] · exact h /- Original line 26430: Erdos416Proof.FordAnalysis.rho -/ noncomputable def rho : ℝ := Classical.choose exists_rho /- Original line 26432: Erdos416Proof.FordAnalysis.rho_pos -/ theorem rho_pos : 0 < rho := (Classical.choose_spec exists_rho).1 /- Original line 26433: Erdos416Proof.FordAnalysis.rho_lt_three_quarters -/ theorem rho_lt_three_quarters : rho < 3 / 4 := (Classical.choose_spec exists_rho).2.1 /- Original line 26434: Erdos416Proof.FordAnalysis.rho_lt_one -/ theorem rho_lt_one : rho < 1 := rho_lt_three_quarters.trans (by norm_num) /- Original line 26435: Erdos416Proof.FordAnalysis.F_rho -/ theorem F_rho : F rho = 1 := (Classical.choose_spec exists_rho).2.2 /- Original line 26437: Erdos416Proof.FordAnalysis.rho_unique -/ theorem rho_unique {r : ℝ} (hr0 : 0 ≤ r) (hr1 : r < 1) (hF : F r = 1) : r = rho := F_strictMonoOn.injOn ⟨hr0, hr1⟩ ⟨rho_pos.le, rho_lt_one⟩ (hF.trans F_rho.symm) /- Original line 26441: Erdos416Proof.FordAnalysis.F_lt_one -/ theorem F_lt_one {r : ℝ} (hr0 : 0 ≤ r) (hr : r < rho) : F r < 1 := by rw [← F_rho] exact F_strictMonoOn ⟨hr0, hr.trans rho_lt_one⟩ ⟨rho_pos.le, rho_lt_one⟩ hr /- Original line 26445: Erdos416Proof.FordAnalysis.C -/ noncomputable def C : ℝ := (2 * |Real.log rho|)⁻¹ /- Original line 26447: Erdos416Proof.FordAnalysis.C_pos -/ theorem C_pos : 0 < C := by unfold C have hlog : Real.log rho < 0 := Real.log_neg rho_pos rho_lt_one exact inv_pos.mpr (mul_pos (by norm_num) (abs_pos.mpr (ne_of_lt hlog))) /- Original line 26452: Erdos416Proof.FordAnalysis.summable_derivative_majorant -/ theorem summable_derivative_majorant {r : ℝ} (hr0 : 0 ≤ r) (hr1 : r < 1) : Summable (fun n : ℕ => (n : ℝ) ^ 2 * r ^ (n - 1)) := by have hr : ‖r‖ < 1 := by simpa [Real.norm_eq_abs, abs_of_nonneg hr0] using hr1 have hs := ((summable_pow_mul_geometric_of_norm_lt_one 2 hr).add ((hasSum_coe_mul_geometric_of_norm_lt_one hr).summable.mul_left 2)).add (hasSum_geometric_of_lt_one hr0 hr1).summable apply (summable_nat_add_iff (f := fun n : ℕ => (n : ℝ) ^ 2 * r ^ (n - 1)) 1).mp exact hs.congr fun n => by simp only [Nat.add_sub_cancel, Nat.cast_add, Nat.cast_one] ring /- Original line 26463: Erdos416Proof.FordAnalysis.derivative_term_bound -/ theorem derivative_term_bound {r z : ℝ} (hz : |z| ≤ r) (n : ℕ) : ‖coeff n * ((n : ℝ) * z ^ (n - 1))‖ ≤ (n : ℝ) ^ 2 * r ^ (n - 1) := by rw [norm_mul, Real.norm_eq_abs, abs_of_nonneg (coeff_bounds n).1, norm_mul, Real.norm_eq_abs, abs_of_nonneg (Nat.cast_nonneg n), norm_pow, Real.norm_eq_abs] have hp := pow_le_pow_left₀ (abs_nonneg z) hz (n - 1) calc coeff n * ((n : ℝ) * |z| ^ (n - 1)) ≤ (n : ℝ) * ((n : ℝ) * r ^ (n - 1)) := mul_le_mul (coeff_bounds n).2 (mul_le_mul_of_nonneg_left hp (Nat.cast_nonneg n)) (mul_nonneg (Nat.cast_nonneg n) (pow_nonneg (abs_nonneg z) _)) (Nat.cast_nonneg n) _ = (n : ℝ) ^ 2 * r ^ (n - 1) := by ring /- Original line 26478: Erdos416Proof.FordAnalysis.derivativeSeries -/ noncomputable def derivativeSeries (z : ℝ) : ℝ := ∑' n : ℕ, coeff n * ((n : ℝ) * z ^ (n - 1)) /- Original line 26481: Erdos416Proof.FordAnalysis.summable_derivativeSeries -/ theorem summable_derivativeSeries {z : ℝ} (hz : |z| < 1) : Summable (fun n : ℕ => coeff n * ((n : ℝ) * z ^ (n - 1))) := Summable.of_norm_bounded (summable_derivative_majorant (abs_nonneg z) hz) (derivative_term_bound le_rfl) /- Original line 26486: Erdos416Proof.FordAnalysis.hasDerivAt_F -/ theorem hasDerivAt_F {z : ℝ} (hz : |z| < 1) : HasDerivAt F (derivativeSeries z) z := by let r : ℝ := (|z| + 1) / 2 have hr0 : 0 < r := by dsimp [Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.coeff_zero, r]; positivity have hr1 : r < 1 := by dsimp [Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.coeff_zero, r]; linarith have hzr : |z| < r := by dsimp [Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.coeff_zero, r]; linarith unfold F derivativeSeries apply hasDerivAt_tsum_of_isPreconnected (summable_derivative_majorant hr0.le hr1) isOpen_Ioo isPreconnected_Ioo (g := fun n x => coeff n * x ^ n) (g' := fun n x => coeff n * ((n : ℝ) * x ^ (n - 1))) (t := Set.Ioo (-r) r) (y₀ := 0) · intro n y _ simpa only [id_eq, mul_one, Pi.pow_apply] using! ((hasDerivAt_id y).pow n).const_mul (coeff n) · intro n y hy exact derivative_term_bound (abs_le.mpr ⟨hy.1.le, hy.2.le⟩) n · exact ⟨neg_neg_of_pos hr0, hr0⟩ · exact summable_F (by norm_num) · exact abs_lt.mp hzr /- Original line 26506: Erdos416Proof.FordAnalysis.deriv_F -/ theorem deriv_F {z : ℝ} (hz : |z| < 1) : deriv F z = derivativeSeries z := (hasDerivAt_F hz).deriv /- Original line 26509: Erdos416Proof.FordAnalysis.derivativeSeries_pos -/ theorem derivativeSeries_pos {z : ℝ} (hz0 : 0 ≤ z) (hz1 : z < 1) : 0 < derivativeSeries z := by have hs : (∑ n ∈ ({1} : Finset ℕ), coeff n * ((n : ℝ) * z ^ (n - 1))) ≤ derivativeSeries z := Summable.sum_le_tsum _ (fun n _ => mul_nonneg (coeff_bounds n).1 (mul_nonneg (Nat.cast_nonneg n) (pow_nonneg hz0 _))) (summable_derivativeSeries (by simpa [Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.coeff_zero, abs_of_nonneg hz0] using hz1)) have h : coeff 1 ≤ derivativeSeries z := by simpa [Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.coeff_zero] using hs exact coeff_one_pos.trans_le h /- Original line 26519: Erdos416Proof.FordAnalysis.deriv_F_rho_pos -/ theorem deriv_F_rho_pos : 0 < deriv F rho := by rw [deriv_F (by simpa [Erdos416Proof.FordAnalysis.F_zero, abs_of_pos rho_pos] using rho_lt_one)] exact derivativeSeries_pos rho_pos.le rho_lt_one /- Original line 26523: Erdos416Proof.FordAnalysis.lambda -/ noncomputable def lambda : ℝ := 1 / (rho * deriv F rho) /- Original line 26525: Erdos416Proof.FordAnalysis.lambda_pos -/ theorem lambda_pos : 0 < lambda := one_div_pos.mpr (mul_pos rho_pos deriv_F_rho_pos) /-- The renewal sequence in Ford's equation (3.3). -/ /- Original line 26528: Erdos416Proof.FordAnalysis.g -/ noncomputable def g : ℕ → ℝ | 0 => 1 | n + 1 => ∑ idx ∈ Finset.range (n + 1), coeff (idx + 1) * g (n - idx) termination_by n => n decreasing_by omega /- Original line 26534: Erdos416Proof.FordAnalysis.g_zero -/ theorem g_zero : g 0 = 1 := by rw [g] /- Original line 26536: Erdos416Proof.FordAnalysis.g_succ -/ theorem g_succ (n : ℕ) : g (n + 1) = ∑ idx ∈ Finset.range (n + 1), coeff (idx + 1) * g (n - idx) := by rw [g] /- Original line 26540: Erdos416Proof.FordAnalysis.g_pos -/ theorem g_pos (n : ℕ) : 0 < g n := by induction n using Nat.strong_induction_on with | h n ih => cases n with | zero => simp[Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.g_zero] | succ n => rw [g_succ] have hterm : 0 < coeff (0 + 1) * g (n - 0) := by simpa [Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.g_zero] using mul_pos coeff_one_pos (ih n (by omega)) apply hterm.trans_le apply Finset.single_le_sum (f := fun idx => coeff (idx + 1) * g (n - idx)) (a := 0) · intro idx hi exact mul_nonneg (coeff_bounds (idx + 1)).1 (ih (n - idx) (by omega)).le · simp[Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.g_zero] /- Original line 26555: Erdos416Proof.FordAnalysis.g_scaled_le_one -/ theorem g_scaled_le_one (n : ℕ) : g n * rho ^ n ≤ 1 := by induction n using Nat.strong_induction_on with | h n ih => cases n with | zero => simp[Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.g_zero] | succ n => rw [g_succ, Finset.sum_mul] calc (∑ idx ∈ range (n + 1), coeff (idx + 1) * g (n - idx) * rho ^ (n + 1)) = ∑ idx ∈ range (n + 1), (coeff (idx + 1) * rho ^ (idx + 1)) * (g (n - idx) * rho ^ (n - idx)) := by apply Finset.sum_congr rfl intro idx hi have he : n + 1 = (idx + 1) + (n - idx) := by have := Finset.mem_range.mp hi omega rw [he, pow_add] ring _ ≤ ∑ idx ∈ range (n + 1), coeff (idx + 1) * rho ^ (idx + 1) := by apply Finset.sum_le_sum intro idx _ exact mul_le_of_le_one_right (mul_nonneg (coeff_bounds (idx + 1)).1 (pow_nonneg rho_pos.le _)) (ih (n - idx) (by omega)) _ ≤ 1 := by have hs : (∑ idx ∈ range (n + 2), coeff idx * rho ^ idx) ≤ F rho := Summable.sum_le_tsum _ (fun idx _ => mul_nonneg (coeff_bounds idx).1 (pow_nonneg rho_pos.le _)) (summable_F (by simpa [Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.g_zero, abs_of_pos rho_pos] using rho_lt_one)) simpa only [Finset.sum_range_succ', coeff_zero, zero_mul, add_zero, F_rho] using hs /- Original line 26586: Erdos416Proof.FordAnalysis.g_le_inv_pow -/ theorem g_le_inv_pow (n : ℕ) : g n ≤ 1 / rho ^ n := (le_div_iff₀ (pow_pos rho_pos n)).mpr (g_scaled_le_one n) /- Original line 26589: Erdos416Proof.FordAnalysis.summable_g -/ theorem summable_g {z : ℝ} (hz : |z| < rho) : Summable (fun n : ℕ => g n * z ^ n) := by apply Summable.of_norm_bounded (hasSum_geometric_of_lt_one (show 0 ≤ |z| / rho from div_nonneg (abs_nonneg z) rho_pos.le) ((div_lt_one rho_pos).mpr hz)).summable intro n rw [norm_mul, Real.norm_eq_abs, abs_of_pos (g_pos n), norm_pow, Real.norm_eq_abs, div_pow] calc g n * |z| ^ n ≤ (1 / rho ^ n) * |z| ^ n := mul_le_mul_of_nonneg_right (g_le_inv_pow n) (pow_nonneg (abs_nonneg z) n) _ = |z| ^ n / rho ^ n := by ring /- Original line 26601: Erdos416Proof.FordAnalysis.g_convolution -/ theorem g_convolution (n : ℕ) : (∑ idx ∈ range (n + 1), coeff idx * g (n - idx)) = g n - if n = 0 then 1 else 0 := by cases n with | zero => simp[Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.g_zero] | succ n => rw [Finset.sum_range_succ'] simp only [coeff_zero, zero_mul, add_zero, Nat.succ_ne_zero, ↓reduceIte, sub_zero, Nat.add_sub_add_right] exact (g_succ n).symm /- Original line 26611: Erdos416Proof.FordAnalysis.g_weighted_convolution -/ theorem g_weighted_convolution (n : ℕ) (z : ℝ) : (∑ idx ∈ range (n + 1), (coeff idx * z ^ idx) * (g (n - idx) * z ^ (n - idx))) = g n * z ^ n - if n = 0 then 1 else 0 := by calc (∑ idx ∈ range (n + 1), (coeff idx * z ^ idx) * (g (n - idx) * z ^ (n - idx))) = (∑ idx ∈ range (n + 1), coeff idx * g (n - idx)) * z ^ n := by rw [Finset.sum_mul] apply Finset.sum_congr rfl intro idx hi have he : idx + (n - idx) = n := Nat.add_sub_of_le (by have := Finset.mem_range.mp hi omega) calc (coeff idx * z ^ idx) * (g (n - idx) * z ^ (n - idx)) = (coeff idx * g (n - idx)) * z ^ (idx + (n - idx)) := by rw [pow_add]; ring _ = _ := by rw [he] _ = _ := by rw [g_convolution]; split_ifs with hn <;> simp [Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.g_zero, hn] /- Original line 26629: Erdos416Proof.FordAnalysis.G -/ noncomputable def G (z : ℝ) : ℝ := ∑' n : ℕ, g n * z ^ n /- Original line 26631: Erdos416Proof.FordAnalysis.F_mul_G -/ theorem F_mul_G {z : ℝ} (hz : |z| < rho) : F z * G z = G z - 1 := by have hs := summable_g hz calc F z * G z = ∑' n : ℕ, ∑ idx ∈ range (n + 1), (coeff idx * z ^ idx) * (g (n - idx) * z ^ (n - idx)) := tsum_mul_tsum_eq_tsum_sum_range_of_summable_norm (summable_F (hz.trans rho_lt_one)).norm hs.norm _ = ∑' n : ℕ, (g n * z ^ n - if n = 0 then 1 else 0) := tsum_congr fun n => g_weighted_convolution n z _ = G z - 1 := by rw [hs.tsum_sub (hasSum_ite_eq 0 (1 : ℝ)).summable] simp [Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.g_zero, G] /- Original line 26644: Erdos416Proof.FordAnalysis.G_eq_reciprocal -/ theorem G_eq_reciprocal {z : ℝ} (hz : |z| < rho) : G z = 1 / (1 - F z) := by have hm : G z * (1 - F z) = 1 := by nlinarith [F_mul_G hz] have hn : 1 - F z ≠ 0 := by intro he rw [he, mul_zero] at hm norm_num at hm exact (eq_div_iff hn).mpr hm /-- The complex power series needed for the coefficient estimate. -/ /- Original line 26653: Erdos416Proof.FordAnalysis.FComplex -/ noncomputable def FComplex (z : ℂ) : ℂ := ∑' n : ℕ, (coeff n : ℂ) * z ^ n /- Original line 26655: Erdos416Proof.FordAnalysis.FComplex_term_bound -/ theorem FComplex_term_bound {r : ℝ} {z : ℂ} (hz : ‖z‖ ≤ r) (n : ℕ) : ‖(coeff n : ℂ) * z ^ n‖ ≤ (n : ℝ) * r ^ n := by rw [norm_mul, Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg (coeff_bounds n).1, norm_pow] exact mul_le_mul (coeff_bounds n).2 (pow_le_pow_left₀ (norm_nonneg z) hz n) (pow_nonneg (norm_nonneg z) n) (Nat.cast_nonneg n) /- Original line 26662: Erdos416Proof.FordAnalysis.summable_FComplex -/ theorem summable_FComplex {z : ℂ} (hz : ‖z‖ < 1) : Summable (fun n : ℕ => (coeff n : ℂ) * z ^ n) := Summable.of_norm_bounded (hasSum_coe_mul_geometric_of_norm_lt_one (r := ‖z‖) (by simpa [Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.coeff_zero] using hz)).summable (FComplex_term_bound le_rfl) /- Original line 26668: Erdos416Proof.FordAnalysis.FComplex_ofReal -/ theorem FComplex_ofReal (z : ℝ) : FComplex (z : ℂ) = (F z : ℂ) := by simp only [FComplex, F, Complex.ofReal_tsum, Complex.ofReal_mul, Complex.ofReal_pow] /- Original line 26671: Erdos416Proof.FordAnalysis.FComplex_differentiableOn_ball -/ theorem FComplex_differentiableOn_ball {r : ℝ} (hr0 : 0 ≤ r) (hr1 : r < 1) : DifferentiableOn ℂ FComplex (Metric.ball 0 r) := by apply Complex.differentiableOn_tsum_of_summable_norm (hasSum_coe_mul_geometric_of_norm_lt_one (r := r) (by simpa [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.coeff_zero, Real.norm_eq_abs, abs_of_nonneg hr0] using hr1)).summable · intro n fun_prop · exact Metric.isOpen_ball · intro n z hz have hzn : ‖z‖ < r := by simpa only [Metric.mem_ball, dist_zero_right] using hz exact FComplex_term_bound hzn.le n /- Original line 26683: Erdos416Proof.FordAnalysis.FComplex_analyticAt -/ theorem FComplex_analyticAt {z : ℂ} (hz : ‖z‖ < 1) : AnalyticAt ℂ FComplex z := by let r : ℝ := (‖z‖ + 1) / 2 have hr0 : 0 ≤ r := by dsimp [Erdos416Proof.FordAnalysis.FComplex_ofReal, r]; positivity have hr1 : r < 1 := by dsimp [Erdos416Proof.FordAnalysis.FComplex_ofReal, r]; linarith have hzr : z ∈ Metric.ball 0 r := by simp only [Metric.mem_ball, dist_zero_right] dsimp [Erdos416Proof.FordAnalysis.FComplex_ofReal, r] linarith exact (FComplex_differentiableOn_ball hr0 hr1).analyticAt (Metric.isOpen_ball.mem_nhds hzr) /- Original line 26693: Erdos416Proof.FordAnalysis.deriv_FComplex_ofReal -/ theorem deriv_FComplex_ofReal {z : ℝ} (hz : |z| < 1) : deriv FComplex (z : ℂ) = ((deriv F z : ℝ) : ℂ) := by have hc := (FComplex_analyticAt (z := (z : ℂ)) (by simpa only [Complex.norm_real, Real.norm_eq_abs] using hz)).differentiableAt.hasDerivAt have hc' : HasDerivAt (fun y : ℝ => (F y : ℂ)) (deriv FComplex (z : ℂ)) z := by simpa only [FComplex_ofReal] using! hc.comp_ofReal rw [deriv_F hz] exact hc'.unique (hasDerivAt_F hz).ofReal_comp /- Original line 26702: Erdos416Proof.FordAnalysis.deriv_FComplex_rho_ne_zero -/ theorem deriv_FComplex_rho_ne_zero : deriv FComplex (rho : ℂ) ≠ 0 := by rw [deriv_FComplex_ofReal (by simpa [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, abs_of_pos rho_pos] using rho_lt_one)] exact_mod_cast ne_of_gt deriv_F_rho_pos /- Original line 26706: Erdos416Proof.FordAnalysis.FComplex_root_unique -/ theorem FComplex_root_unique {z : ℂ} (hz : ‖z‖ ≤ rho) (hF : FComplex z = 1) : z = (rho : ℂ) := by have hsR := (summable_F (z := rho) (by simpa [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.coeff_zero, abs_of_pos rho_pos] using rho_lt_one)).hasSum have hsC := (summable_FComplex (hz.trans_lt rho_lt_one)).hasSum have hsre : HasSum (fun n : ℕ => coeff n * (z ^ n).re) (FComplex z).re := by simpa only [FComplex, Complex.mul_re, Complex.ofReal_re, Complex.ofReal_im, zero_mul, sub_zero] using! Complex.hasSum_re hsC have hd : HasSum (fun n : ℕ => coeff n * (rho ^ n - (z ^ n).re)) 0 := by have ht : HasSum (fun n : ℕ => coeff n * (rho ^ n - (z ^ n).re)) (F rho - (FComplex z).re) := (hsR.sub hsre).congr_fun fun n => by ring simpa only [F_rho, hF, Complex.one_re, sub_self] using ht have hnon : ∀ n : ℕ, 0 ≤ coeff n * (rho ^ n - (z ^ n).re) := by intro n apply mul_nonneg (coeff_bounds n).1 apply sub_nonneg.mpr calc (z ^ n).re ≤ ‖z ^ n‖ := Complex.re_le_norm _ _ ≤ rho ^ n := by rw [norm_pow]; exact pow_le_pow_left₀ (norm_nonneg z) hz n have hsingle : coeff 1 * (rho - z.re) ≤ 0 := by calc coeff 1 * (rho - z.re) = ∑ n ∈ ({1} : Finset ℕ), coeff n * (rho ^ n - (z ^ n).re) := by simp[Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.coeff_zero] _ ≤ ∑' n : ℕ, coeff n * (rho ^ n - (z ^ n).re) := Summable.sum_le_tsum _ (fun n _ => hnon n) hd.summable _ = 0 := hd.tsum_eq have hre : z.re = rho := le_antisymm ((Complex.re_le_norm z).trans hz) (by nlinarith [coeff_one_pos]) have him : z.im = 0 := by have hsq := pow_le_pow_left₀ (norm_nonneg z) hz 2 have hid := Complex.sq_norm_sub_sq_re z rw [hre] at hid nlinarith [sq_nonneg z.im] exact Complex.ext hre (by simpa [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.coeff_zero] using him) /- Original line 26741: Erdos416Proof.FordAnalysis.GComplex -/ noncomputable def GComplex (z : ℂ) : ℂ := ∑' n : ℕ, (g n : ℂ) * z ^ n /- Original line 26743: Erdos416Proof.FordAnalysis.summable_GComplex -/ theorem summable_GComplex {z : ℂ} (hz : ‖z‖ < rho) : Summable (fun n : ℕ => (g n : ℂ) * z ^ n) := by apply Summable.of_norm_bounded (hasSum_geometric_of_lt_one (show 0 ≤ ‖z‖ / rho from div_nonneg (norm_nonneg z) rho_pos.le) ((div_lt_one rho_pos).mpr hz)).summable intro n rw [norm_mul, Complex.norm_real, Real.norm_eq_abs, abs_of_pos (g_pos n), norm_pow, div_pow] calc g n * ‖z‖ ^ n ≤ (1 / rho ^ n) * ‖z‖ ^ n := mul_le_mul_of_nonneg_right (g_le_inv_pow n) (pow_nonneg (norm_nonneg z) n) _ = ‖z‖ ^ n / rho ^ n := by ring /- Original line 26755: Erdos416Proof.FordAnalysis.GComplex_ofReal -/ theorem GComplex_ofReal (z : ℝ) : GComplex (z : ℂ) = (G z : ℂ) := by simp only [GComplex, G, Complex.ofReal_tsum, Complex.ofReal_mul, Complex.ofReal_pow] /- Original line 26758: Erdos416Proof.FordAnalysis.g_complex_convolution -/ theorem g_complex_convolution (n : ℕ) (z : ℂ) : (∑ idx ∈ range (n + 1), ((coeff idx : ℂ) * z ^ idx) * ((g (n - idx) : ℂ) * z ^ (n - idx))) = (g n : ℂ) * z ^ n - if n = 0 then 1 else 0 := by have hconv : (∑ idx ∈ range (n + 1), (coeff idx : ℂ) * (g (n - idx) : ℂ)) = (g n : ℂ) - if n = 0 then 1 else 0 := by have h := congrArg (fun x : ℝ => (x : ℂ)) (g_convolution n) push_cast at h by_cases hn : n = 0 · simp [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.g_zero, hn] · simpa [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.g_zero, hn] using h calc (∑ idx ∈ range (n + 1), ((coeff idx : ℂ) * z ^ idx) * ((g (n - idx) : ℂ) * z ^ (n - idx))) = (∑ idx ∈ range (n + 1), (coeff idx : ℂ) * (g (n - idx) : ℂ)) * z ^ n := by rw [Finset.sum_mul] apply Finset.sum_congr rfl intro idx hi have he : idx + (n - idx) = n := Nat.add_sub_of_le (by have := Finset.mem_range.mp hi omega) calc ((coeff idx : ℂ) * z ^ idx) * ((g (n - idx) : ℂ) * z ^ (n - idx)) = ((coeff idx : ℂ) * (g (n - idx) : ℂ)) * z ^ (idx + (n - idx)) := by rw [pow_add]; ring _ = _ := by rw [he] _ = _ := by rw [hconv]; split_ifs with hn <;> simp [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.g_zero, hn] /- Original line 26783: Erdos416Proof.FordAnalysis.FComplex_mul_GComplex -/ theorem FComplex_mul_GComplex {z : ℂ} (hz : ‖z‖ < rho) : FComplex z * GComplex z = GComplex z - 1 := by have hs := summable_GComplex hz calc FComplex z * GComplex z = ∑' n : ℕ, ∑ idx ∈ range (n + 1), ((coeff idx : ℂ) * z ^ idx) * ((g (n - idx) : ℂ) * z ^ (n - idx)) := tsum_mul_tsum_eq_tsum_sum_range_of_summable_norm (summable_FComplex (hz.trans rho_lt_one)).norm hs.norm _ = ∑' n : ℕ, ((g n : ℂ) * z ^ n - if n = 0 then 1 else 0) := tsum_congr fun n => g_complex_convolution n z _ = GComplex z - 1 := by rw [hs.tsum_sub (hasSum_ite_eq 0 (1 : ℂ)).summable] simp [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.g_zero, GComplex] /- Original line 26797: Erdos416Proof.FordAnalysis.GComplex_eq_reciprocal -/ theorem GComplex_eq_reciprocal {z : ℂ} (hz : ‖z‖ < rho) : GComplex z = 1 / (1 - FComplex z) := by have hm : GComplex z * (1 - FComplex z) = 1 := by linear_combination -FComplex_mul_GComplex hz have hn : 1 - FComplex z ≠ 0 := by intro he rw [he, mul_zero] at hm norm_num at hm exact (eq_div_iff hn).mpr hm end Erdos416Proof.FordAnalysis /- Quantitative renewal estimates and normalized coefficient products. The actual simplex volume and ordered-volume comparison remain. -/ open Filter Finset Metric open scoped Topology BigOperators NNReal ENNReal namespace Erdos416Proof.FordAnalysis /- Original line 26822: Erdos416Proof.FordAnalysis.renewalFactor -/ noncomputable def renewalFactor (z : ℂ) : ℂ := (rho : ℂ) * dslope FComplex (rho : ℂ) z /- Original line 26825: Erdos416Proof.FordAnalysis.rho_complex_ne_zero -/ theorem rho_complex_ne_zero : (rho : ℂ) ≠ 0 := by exact_mod_cast ne_of_gt rho_pos /- Original line 26827: Erdos416Proof.FordAnalysis.renewalFactor_identity -/ theorem renewalFactor_identity (z : ℂ) : (1 - z / (rho : ℂ)) * renewalFactor z = 1 - FComplex z := by have h := sub_smul_dslope FComplex (rho : ℂ) z rw [smul_eq_mul, FComplex_ofReal, F_rho, Complex.ofReal_one] at h calc (1 - z / (rho : ℂ)) * renewalFactor z = -((z - (rho : ℂ)) * dslope FComplex (rho : ℂ) z) := by unfold renewalFactor rw [← mul_assoc, sub_mul, one_mul, div_mul_cancel₀ z rho_complex_ne_zero] ring_nf _ = 1 - FComplex z := by rw [h]; ring_nf /- Original line 26839: Erdos416Proof.FordAnalysis.renewalFactor_rho -/ theorem renewalFactor_rho : renewalFactor (rho : ℂ) = ((rho * deriv F rho : ℝ) : ℂ) := by rw [renewalFactor, dslope_same, deriv_FComplex_ofReal (by simpa [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, abs_of_pos rho_pos] using rho_lt_one)] push_cast rfl /- Original line 26846: Erdos416Proof.FordAnalysis.inv_renewalFactor_rho -/ theorem inv_renewalFactor_rho : (renewalFactor (rho : ℂ))⁻¹ = (lambda : ℂ) := by rw [renewalFactor_rho] simp [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, lambda, one_div] /- Original line 26850: Erdos416Proof.FordAnalysis.renewalFactor_rho_ne_zero -/ theorem renewalFactor_rho_ne_zero : renewalFactor (rho : ℂ) ≠ 0 := by rw [renewalFactor, dslope_same] exact mul_ne_zero rho_complex_ne_zero deriv_FComplex_rho_ne_zero /- Original line 26854: Erdos416Proof.FordAnalysis.renewalFactor_ne_zero_closed -/ theorem renewalFactor_ne_zero_closed {z : ℂ} (hz : ‖z‖ ≤ rho) : renewalFactor z ≠ 0 := by by_cases he : z = (rho : ℂ) · simpa [Erdos416Proof.FordAnalysis.FComplex_ofReal, he] using renewalFactor_rho_ne_zero · intro hzero have hid := renewalFactor_identity z rw [hzero, mul_zero] at hid exact he (FComplex_root_unique hz (sub_eq_zero.mp hid.symm).symm) /- Original line 26862: Erdos416Proof.FordAnalysis.renewalFactor_differentiableOn -/ theorem renewalFactor_differentiableOn : DifferentiableOn ℂ renewalFactor (ball 0 1) := by have hF : DifferentiableOn ℂ FComplex (ball 0 1) := by intro z hz exact (FComplex_analyticAt (by simpa only [mem_ball, dist_zero_right] using hz)).differentiableAt.differentiableWithinAt have hmem : (rho : ℂ) ∈ ball 0 1 := by simpa [Erdos416Proof.FordAnalysis.FComplex_ofReal, mem_ball, dist_zero_right, Complex.norm_real, abs_of_pos rho_pos] using rho_lt_one exact ((Complex.differentiableOn_dslope (isOpen_ball.mem_nhds hmem)).mpr hF).const_mul _ /- Original line 26871: Erdos416Proof.FordAnalysis.renewalFactor_analyticAt -/ theorem renewalFactor_analyticAt {z : ℂ} (hz : ‖z‖ < 1) : AnalyticAt ℂ renewalFactor z := renewalFactor_differentiableOn.analyticAt (isOpen_ball.mem_nhds (by simpa only [mem_ball, dist_zero_right] using hz)) /- Original line 26876: Erdos416Proof.FordAnalysis.exists_renewal_radius -/ theorem exists_renewal_radius : ∃ R : ℝ, rho < R ∧ R < 1 ∧ ∀ z : ℂ, ‖z‖ ≤ R → renewalFactor z ≠ 0 := by let U : Set ℂ := {z | ‖z‖ < 1 ∧ renewalFactor z ≠ 0} have hU : IsOpen U := by apply isOpen_iff_mem_nhds.mpr intro z hz exact inter_mem ((isOpen_lt continuous_norm continuous_const).mem_nhds hz.1) ((renewalFactor_analyticAt hz.1).continuousAt.eventually_ne hz.2) have hsub : closedBall (0 : ℂ) rho ⊆ U := by intro z hz have hzn : ‖z‖ ≤ rho := by simpa only [mem_closedBall, dist_zero_right] using hz exact ⟨hzn.trans_lt rho_lt_one, renewalFactor_ne_zero_closed hzn⟩ obtain ⟨δ, hδ, hδsub⟩ := (isCompact_closedBall (0 : ℂ) rho).exists_cthickening_subset_open hU hsub rw [cthickening_closedBall hδ.le rho_pos.le] at hδsub have hR0 : 0 < δ + rho := add_pos hδ rho_pos refine ⟨δ + rho, by linarith, ?_, ?_⟩ · have hp : ((δ + rho : ℝ) : ℂ) ∈ closedBall 0 (δ + rho) := by simp only [mem_closedBall, dist_zero_right, Complex.norm_real, Real.norm_eq_abs, abs_of_pos hR0, le_refl] have hh := (hδsub hp).1 simpa only [Complex.norm_real, Real.norm_eq_abs, abs_of_pos hR0] using hh · intro z hz exact (hδsub (by simpa only [mem_closedBall, dist_zero_right] using hz)).2 /-- Analytic continuation of the renewal generating function after its pole is removed. -/ /- Original line 26901: Erdos416Proof.FordAnalysis.renewalError -/ noncomputable def renewalError (z : ℂ) : ℂ := -(rho : ℂ) * dslope (fun w => (renewalFactor w)⁻¹) (rho : ℂ) z /- Original line 26904: Erdos416Proof.FordAnalysis.renewalError_differentiableOn -/ theorem renewalError_differentiableOn {R : ℝ} (hρ : rho < R) (hR : R < 1) (hn : ∀ z : ℂ, ‖z‖ ≤ R → renewalFactor z ≠ 0) : DifferentiableOn ℂ renewalError (closedBall 0 R) := by have hD : DifferentiableOn ℂ (fun w => (renewalFactor w)⁻¹) (closedBall 0 R) := by intro z hz have hzn : ‖z‖ ≤ R := by simpa only [mem_closedBall, dist_zero_right] using hz exact ((renewalFactor_analyticAt (hzn.trans_lt hR)).differentiableAt.inv (hn z hzn)).differentiableWithinAt have hmem : closedBall (0 : ℂ) R ∈ nhds (rho : ℂ) := by apply Filter.mem_of_superset (isOpen_ball.mem_nhds ?_) ball_subset_closedBall simpa [mem_ball, dist_zero_right, Complex.norm_real, abs_of_pos rho_pos] using hρ exact ((Complex.differentiableOn_dslope hmem).mpr hD).const_mul _ /- Original line 26917: Erdos416Proof.FordAnalysis.renewalError_eq -/ theorem renewalError_eq {z : ℂ} (hz : ‖z‖ < rho) : renewalError z = GComplex z - (lambda : ℂ) / (1 - z / (rho : ℂ)) := by have hzr : z ≠ (rho : ℂ) := by intro he rw [he, Complex.norm_real, Real.norm_eq_abs, abs_of_pos rho_pos] at hz exact lt_irrefl _ hz have hsub : z - (rho : ℂ) ≠ 0 := sub_ne_zero.mpr hzr have hf : renewalFactor z ≠ 0 := renewalFactor_ne_zero_closed hz.le rw [renewalError, dslope_of_ne _ hzr, slope_def_field, inv_renewalFactor_rho, GComplex_eq_reciprocal hz, ← renewalFactor_identity z] have hden : 1 - z / (rho : ℂ) = -(z - (rho : ℂ)) / (rho : ℂ) := by rw [neg_sub, sub_div, div_self rho_complex_ne_zero] rw [hden] field_simp [rho_complex_ne_zero, hsub, hf] ring_nf /- Original line 26933: Erdos416Proof.FordAnalysis.renewalErrorCoeff -/ noncomputable def renewalErrorCoeff (n : ℕ) : ℝ := g n - lambda / rho ^ n /- Original line 26935: Erdos416Proof.FordAnalysis.renewalError_hasSum -/ theorem renewalError_hasSum {z : ℂ} (hz : ‖z‖ < rho) : HasSum (fun n : ℕ => (renewalErrorCoeff n : ℂ) * z ^ n) (renewalError z) := by have hgeom : HasSum (fun n : ℕ => (z / (rho : ℂ)) ^ n) (1 - z / (rho : ℂ))⁻¹ := hasSum_geometric_of_norm_lt_one (by rw [norm_div, Complex.norm_real, Real.norm_eq_abs, abs_of_pos rho_pos] exact (div_lt_one rho_pos).mpr hz) have hs := (summable_GComplex hz).hasSum.sub (hgeom.mul_left (lambda : ℂ)) change HasSum _ (GComplex z - (lambda : ℂ) / (1 - z / (rho : ℂ))) at hs rw [← renewalError_eq hz] at hs exact hs.congr_fun fun n => by dsimp [Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.g_zero, renewalErrorCoeff] push_cast rw [div_pow] ring_nf /- Original line 26950: Erdos416Proof.FordAnalysis.renewalErrorSeries -/ noncomputable def renewalErrorSeries : FormalMultilinearSeries ℂ ℂ ℂ := fun n => ContinuousMultilinearMap.mkPiRing ℂ (Fin n) (renewalErrorCoeff n : ℂ) /- Original line 26953: Erdos416Proof.FordAnalysis.renewalErrorSeries_coeff -/ theorem renewalErrorSeries_coeff (n : ℕ) : renewalErrorSeries.coeff n = (renewalErrorCoeff n : ℂ) := by simp [renewalErrorSeries, FormalMultilinearSeries.coeff] /- Original line 26957: Erdos416Proof.FordAnalysis.renewalError_hasFPowerSeriesAt -/ theorem renewalError_hasFPowerSeriesAt : HasFPowerSeriesAt renewalError renewalErrorSeries 0 := by apply hasFPowerSeriesAt_iff.mpr filter_upwards [ball_mem_nhds (0 : ℂ) rho_pos] with z hz have hzn : ‖z‖ < rho := by simpa only [mem_ball, dist_zero_right] using hz simpa only [zero_add, renewalErrorSeries_coeff, smul_eq_mul, mul_comm] using renewalError_hasSum hzn /- Original line 26965: Erdos416Proof.FordAnalysis.exists_renewal_error_bound -/ theorem exists_renewal_error_bound : ∃ R K : ℝ, rho < R ∧ R < 1 ∧ 0 < K ∧ ∀ n : ℕ, |renewalErrorCoeff n| ≤ K / R ^ n := by obtain ⟨R, hρR, hR1, hn⟩ := exists_renewal_radius have hR0 : 0 < R := rho_pos.trans hρR let Rn : ℝ≥0 := ⟨R, hR0.le⟩ have hc := (renewalError_differentiableOn hρR hR1 hn).hasFPowerSeriesOnBall (R := Rn) (by exact hR0) have he := renewalError_hasFPowerSeriesAt.eq_formalMultilinearSeries hc.hasFPowerSeriesAt have hrad : (Rn : ℝ≥0∞) ≤ renewalErrorSeries.radius := by rw [he]; exact hc.r_le let S : ℝ := (rho + R) / 2 have hρS : rho < S := by dsimp [Erdos416Proof.FordAnalysis.renewalErrorSeries_coeff, S]; linarith have hSR : S < R := by dsimp [Erdos416Proof.FordAnalysis.renewalErrorSeries_coeff, S]; linarith have hS0 : 0 < S := rho_pos.trans hρS let Sn : ℝ≥0 := ⟨S, hS0.le⟩ have hSl : (Sn : ℝ≥0∞) < renewalErrorSeries.radius := (show (Sn : ℝ≥0∞) < Rn by exact_mod_cast hSR).trans_le hrad obtain ⟨K, hK, hbound⟩ := renewalErrorSeries.norm_le_div_pow_of_pos_of_lt_radius (r := Sn) (by exact hS0) hSl refine ⟨S, K, hρS, hSR.trans hR1, hK, fun n => ?_⟩ simpa only [FormalMultilinearSeries.norm_apply_eq_norm_coef, renewalErrorSeries_coeff, Complex.norm_real, Real.norm_eq_abs, Sn] using! hbound n /- Original line 26988: Erdos416Proof.FordAnalysis.exists_renewal_relative_error_bound -/ theorem exists_renewal_relative_error_bound : ∃ K q : ℝ, 0 < K ∧ 0 < q ∧ q < 1 ∧ ∀ n : ℕ, |g n * rho ^ n - lambda| ≤ K * q ^ n := by obtain ⟨R, K, hρR, _, hK, hbound⟩ := exists_renewal_error_bound have hR0 : 0 < R := rho_pos.trans hρR refine ⟨K, rho / R, hK, div_pos rho_pos hR0, (div_lt_one hR0).mpr hρR, fun n => ?_⟩ have he : g n * rho ^ n - lambda = renewalErrorCoeff n * rho ^ n := by dsimp only [renewalErrorCoeff] rw [sub_mul, div_mul_cancel₀ _ (pow_ne_zero _ (ne_of_gt rho_pos))] calc |g n * rho ^ n - lambda| = |renewalErrorCoeff n| * rho ^ n := by rw [he, abs_mul, abs_of_pos (pow_pos rho_pos n)] _ ≤ (K / R ^ n) * rho ^ n := mul_le_mul_of_nonneg_right (hbound n) (pow_nonneg rho_pos.le n) _ = K * (rho / R) ^ n := by rw [div_pow]; ring_nf /- Original line 27004: Erdos416Proof.FordAnalysis.summable_g_scaled_error -/ theorem summable_g_scaled_error : Summable (fun n : ℕ => g n * rho ^ n - lambda) := by obtain ⟨K, q, _, hq0, hq1, hb⟩ := exists_renewal_relative_error_bound exact Summable.of_norm_bounded ((hasSum_geometric_of_lt_one hq0.le hq1).summable.mul_left K) (fun n => by simpa only [Real.norm_eq_abs] using hb n) /- Original line 27009: Erdos416Proof.FordAnalysis.g_scaled_tendsto -/ theorem g_scaled_tendsto : Tendsto (fun n : ℕ => g n * rho ^ n) atTop (nhds lambda) := by simpa only [sub_add_cancel, zero_add] using summable_g_scaled_error.tendsto_atTop_zero.add_const lambda /- Original line 27012: Erdos416Proof.FordAnalysis.normalizedG -/ noncomputable def normalizedG (n : ℕ) : ℝ := g n * rho ^ n / lambda /- Original line 27014: Erdos416Proof.FordAnalysis.normalizedG_pos -/ theorem normalizedG_pos (n : ℕ) : 0 < normalizedG n := div_pos (mul_pos (g_pos n) (pow_pos rho_pos n)) lambda_pos /- Original line 27017: Erdos416Proof.FordAnalysis.summable_normalizedG_sub_one -/ theorem summable_normalizedG_sub_one : Summable (fun n : ℕ => normalizedG n - 1) := by have h := summable_g_scaled_error.div_const lambda simpa only [sub_div, div_self (ne_of_gt lambda_pos), normalizedG] using h /- Original line 27021: Erdos416Proof.FordAnalysis.normalizedG_tendsto -/ theorem normalizedG_tendsto : Tendsto normalizedG atTop (nhds 1) := by simpa only [normalizedG, div_self (ne_of_gt lambda_pos)] using! g_scaled_tendsto.div_const lambda /- Original line 27024: Erdos416Proof.FordAnalysis.summable_log_normalizedG -/ theorem summable_log_normalizedG : Summable (fun n : ℕ => Real.log (normalizedG n)) := by exact (Real.summable_log_one_add_of_summable summable_normalizedG_sub_one).congr fun n => by congr 1; ring_nf /- Original line 27028: Erdos416Proof.FordAnalysis.renewalProductConstant -/ noncomputable def renewalProductConstant : ℝ := Real.exp (∑' n : ℕ, Real.log (normalizedG n)) /- Original line 27031: Erdos416Proof.FordAnalysis.renewalProductConstant_pos -/ theorem renewalProductConstant_pos : 0 < renewalProductConstant := Real.exp_pos _ /- Original line 27033: Erdos416Proof.FordAnalysis.hasProd_normalizedG -/ theorem hasProd_normalizedG : HasProd normalizedG renewalProductConstant := Real.hasProd_of_hasSum_log normalizedG_pos summable_log_normalizedG.hasSum /- Original line 27036: Erdos416Proof.FordAnalysis.normalizedG_prod_tendsto -/ theorem normalizedG_prod_tendsto : Tendsto (fun N : ℕ => ∏ n ∈ range N, normalizedG n) atTop (nhds renewalProductConstant) := hasProd_normalizedG.tendsto_prod_nat /- Original line 27040: Erdos416Proof.FordAnalysis.normalizedG_prod_eq -/ theorem normalizedG_prod_eq (N : ℕ) : (∏ n ∈ range N, normalizedG n) = (∏ n ∈ range N, g n) * rho ^ (N * (N - 1) / 2) / lambda ^ N := by simp only [normalizedG, Finset.prod_div_distrib, Finset.prod_mul_distrib, Finset.prod_const, Finset.card_range] rw [Finset.prod_pow_eq_pow_sum, Finset.sum_range_id] /- Original line 27047: Erdos416Proof.FordAnalysis.normalizedG_prod_uniform_bounds -/ theorem normalizedG_prod_uniform_bounds : ∃ a b : ℝ, 0 < a ∧ 0 < b ∧ ∀ N : ℕ, a ≤ ∏ n ∈ range N, normalizedG n ∧ (∏ n ∈ range N, normalizedG n) ≤ b := by let u : ℕ → ℝ := fun N => ∏ n ∈ range N, normalizedG n have hu : ∀ N, 0 < u N := fun N => Finset.prod_pos (fun n _ => normalizedG_pos n) have hlim : Tendsto u atTop (nhds renewalProductConstant) := normalizedG_prod_tendsto obtain ⟨b, hb0, hb⟩ := (Metric.isBounded_range_of_tendsto u hlim).exists_pos_norm_le have hilim : Tendsto (fun N => (u N)⁻¹) atTop (nhds renewalProductConstant⁻¹) := hlim.inv₀ (ne_of_gt renewalProductConstant_pos) obtain ⟨d, hd0, hd⟩ := (Metric.isBounded_range_of_tendsto (fun N => (u N)⁻¹) hilim).exists_pos_norm_le refine ⟨1 / d, b, one_div_pos.mpr hd0, hb0, fun N => ⟨?_, ?_⟩⟩ · have hid : 1 / u N ≤ d := by rw [one_div] have hnorm := hd ((u N)⁻¹) ⟨N, rfl⟩ exact (le_abs_self ((u N)⁻¹)).trans (by simpa only [Real.norm_eq_abs] using hnorm) have hm := (div_le_iff₀ (hu N)).mp hid apply (div_le_iff₀ hd0).mpr nlinarith · exact (le_abs_self (u N)).trans (by simpa only [Real.norm_eq_abs] using hb (u N) ⟨N, rfl⟩) /- Original line 27068: Erdos416Proof.FordAnalysis.coeff_one_lt_one -/ theorem coeff_one_lt_one : coeff 1 < 1 := by have h := Real.log_lt_sub_one_of_pos (by norm_num : (0 : ℝ) < 2) (by norm_num : (2 : ℝ) ≠ 1) norm_num [coeff, fordWeight] at * linarith /-- The modified final coefficient in Ford's equation (3.6). -/ /- Original line 27075: Erdos416Proof.FordAnalysis.gStar -/ noncomputable def gStar : ℕ → ℝ | 0 => 1 | n + 1 => g (n + 1) + (1 - coeff 1) * g n /- Original line 27079: Erdos416Proof.FordAnalysis.gStar_zero -/ theorem gStar_zero : gStar 0 = 1 := rfl /- Original line 27081: Erdos416Proof.FordAnalysis.gStar_succ -/ theorem gStar_succ (n : ℕ) : gStar (n + 1) = g (n + 1) + (1 - coeff 1) * g n := rfl /- Original line 27083: Erdos416Proof.FordAnalysis.gStar_pos -/ theorem gStar_pos (n : ℕ) : 0 < gStar n := by cases n with | zero => simp[Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.gStar_zero, Erdos416Proof.FordAnalysis.g_zero] | succ n => rw [gStar_succ] exact add_pos (g_pos _) (mul_pos (sub_pos.mpr coeff_one_lt_one) (g_pos n)) /- Original line 27090: Erdos416Proof.FordAnalysis.renewalLastFactor -/ noncomputable def renewalLastFactor : ℝ := 1 + (1 - coeff 1) * rho /- Original line 27092: Erdos416Proof.FordAnalysis.renewalLastFactor_pos -/ theorem renewalLastFactor_pos : 0 < renewalLastFactor := by have hp := mul_pos (sub_pos.mpr coeff_one_lt_one) rho_pos unfold renewalLastFactor linarith /- Original line 27097: Erdos416Proof.FordAnalysis.gStar_scaled_tendsto -/ theorem gStar_scaled_tendsto : Tendsto (fun n : ℕ => gStar n * rho ^ n) atTop (nhds (lambda * renewalLastFactor)) := by apply (tendsto_add_atTop_iff_nat 1).mp have hshift := g_scaled_tendsto.comp (tendsto_add_atTop_nat 1) have hside := g_scaled_tendsto.const_mul ((1 - coeff 1) * rho) convert! hshift.add hside using 1 · funext n simp only [Function.comp_def, gStar_succ, pow_succ] ring_nf · unfold renewalLastFactor ring_nf /- Original line 27109: Erdos416Proof.FordAnalysis.gStar_ratio_tendsto -/ theorem gStar_ratio_tendsto : Tendsto (fun n : ℕ => gStar n / g n) atTop (nhds renewalLastFactor) := by have h := gStar_scaled_tendsto.div g_scaled_tendsto (ne_of_gt lambda_pos) convert! h using 1 · funext n change gStar n / g n = (gStar n * rho ^ n) / (g n * rho ^ n) rw [mul_div_mul_right _ _ (ne_of_gt (pow_pos rho_pos n))] · rw [mul_div_cancel_left₀ _ (ne_of_gt lambda_pos)] /-- The coefficient product in the simplex volume formula, without the factorial. -/ /- Original line 27119: Erdos416Proof.FordAnalysis.renewalDenominator -/ noncomputable def renewalDenominator (L : ℕ) : ℝ := (∏ n ∈ range L, g n) * gStar L /- Original line 27121: Erdos416Proof.FordAnalysis.renewalDenominator_pos -/ theorem renewalDenominator_pos (L : ℕ) : 0 < renewalDenominator L := mul_pos (Finset.prod_pos (fun n _ => g_pos n)) (gStar_pos L) /- Original line 27124: Erdos416Proof.FordAnalysis.renewalDenominator_normalized_eq -/ theorem renewalDenominator_normalized_eq (L : ℕ) : renewalDenominator L * rho ^ (L * (L + 1) / 2) / lambda ^ (L + 1) = (∏ n ∈ range (L + 1), normalizedG n) * (gStar L / g L) := by rw [normalizedG_prod_eq, Finset.prod_range_succ, Nat.add_sub_cancel] rw [Nat.mul_comm (L + 1) L] unfold renewalDenominator field_simp [ne_of_gt (g_pos L), ne_of_gt lambda_pos] /- Original line 27132: Erdos416Proof.FordAnalysis.renewalDenominator_normalized_tendsto -/ theorem renewalDenominator_normalized_tendsto : Tendsto (fun L : ℕ => renewalDenominator L * rho ^ (L * (L + 1) / 2) / lambda ^ (L + 1)) atTop (nhds (renewalProductConstant * renewalLastFactor)) := by have hp := normalizedG_prod_tendsto.comp (tendsto_add_atTop_nat 1) have h := hp.mul gStar_ratio_tendsto simpa only [Function.comp_def, renewalDenominator_normalized_eq] using! h end Erdos416Proof.FordAnalysis /- Exact simplex volumes, the actual Ford slack transformation, and the unordered-volume asymptotic. The ordered lower comparison remains. -/ open Filter Finset MeasureTheory open scoped Topology BigOperators Classical ENNReal namespace Erdos416Proof.SimplexVolume /-- The actual nonnegative simplex of total coordinate mass at most t. -/ /- Original line 27155: Erdos416Proof.SimplexVolume.positiveSimplex -/ def positiveSimplex (n : ℕ) (t : ℝ) : Set (Fin n → ℝ) := {x | (∀ idx, 0 ≤ x idx) ∧ ∑ idx, x idx ≤ t} /- Original line 27158: Erdos416Proof.SimplexVolume.positiveSimplex_isClosed -/ theorem positiveSimplex_isClosed (n : ℕ) (t : ℝ) : IsClosed (positiveSimplex n t) := by unfold positiveSimplex simp only [Set.ofPred_and, Set.ofPred_forall] exact (isClosed_iInter fun idx => isClosed_le continuous_const (continuous_apply idx)).inter (isClosed_le (continuous_finsetSum _ fun idx _ => continuous_apply idx) continuous_const) /- Original line 27165: Erdos416Proof.SimplexVolume.positiveSimplex_measurable -/ theorem positiveSimplex_measurable (n : ℕ) (t : ℝ) : MeasurableSet (positiveSimplex n t) := (positiveSimplex_isClosed n t).measurableSet /- Original line 27168: Erdos416Proof.SimplexVolume.positiveSimplex_isCompact -/ theorem positiveSimplex_isCompact (n : ℕ) (t : ℝ) : IsCompact (positiveSimplex n t) := by apply (isCompact_Icc : IsCompact (Set.Icc (0 : Fin n → ℝ) (fun _ => t))).of_isClosed_subset (positiveSimplex_isClosed n t) intro x hx refine ⟨hx.1, fun idx => ?_⟩ exact (Finset.single_le_sum (fun j _ => hx.1 j) (Finset.mem_univ idx)).trans hx.2 /- Original line 27176: Erdos416Proof.SimplexVolume.positiveSimplex_eq_empty -/ theorem positiveSimplex_eq_empty {n : ℕ} {t : ℝ} (ht : t < 0) : positiveSimplex n t = ∅ := by apply Set.eq_empty_iff_forall_notMem.mpr intro x hx have h := Finset.sum_nonneg (fun idx (_ : idx ∈ Finset.univ) => hx.1 idx) linarith [hx.2] /- Original line 27183: Erdos416Proof.SimplexVolume.cons_mem_positiveSimplex -/ theorem cons_mem_positiveSimplex {n : ℕ} (t s : ℝ) (x : Fin n → ℝ) : Fin.cons s x ∈ positiveSimplex (n + 1) t ↔ 0 ≤ s ∧ x ∈ positiveSimplex n (t - s) := by simp only [positiveSimplex, Set.mem_ofPred_eq, Fin.forall_fin_succ, Fin.cons_zero, Fin.cons_succ, Fin.sum_univ_succ] constructor · rintro ⟨⟨hs, hx⟩, hsum⟩ exact ⟨hs, hx, by linarith⟩ · rintro ⟨hs, hx, hsum⟩ exact ⟨⟨hs, hx⟩, by linarith⟩ /- Original line 27194: Erdos416Proof.SimplexVolume.volume_positiveSimplex -/ theorem volume_positiveSimplex (n : ℕ) {t : ℝ} (ht : 0 ≤ t) : volume (positiveSimplex n t) = ENNReal.ofReal (t ^ n / n.factorial) := by induction n generalizing t with | zero => simp [positiveSimplex, ht, volume_pi] | succ n ih => let e : (ℝ × (Fin n → ℝ)) ≃ᵐ (Fin (n + 1) → ℝ) := (MeasurableEquiv.piFinSuccAbove (fun _ => ℝ) 0).symm have he : MeasurePreserving e := (volume_preserving_piFinSuccAbove (fun _ : Fin (n + 1) => ℝ) 0).symm _ have he_apply (s : ℝ) (x : Fin n → ℝ) : e (s, x) = Fin.cons s x := by simp [e, MeasurableEquiv.piFinSuccAbove_symm_apply, Fin.insertNthEquiv, Fin.insertNth_zero'] have hm : MeasurableSet (e ⁻¹' positiveSimplex (n + 1) t) := e.measurable (positiveSimplex_measurable _ _) have hslice (s : ℝ) : volume (Prod.mk s ⁻¹' (e ⁻¹' positiveSimplex (n + 1) t)) = (Set.Icc 0 t).indicator (fun s : ℝ => ENNReal.ofReal ((t - s)^n / n.factorial)) s := by by_cases hs : s ∈ Set.Icc 0 t · rw [Set.indicator_of_mem hs] have hset : Prod.mk s ⁻¹' (e ⁻¹' positiveSimplex (n + 1) t) = positiveSimplex n (t - s) := by ext x simp only [Set.mem_preimage, he_apply, cons_mem_positiveSimplex, hs.1, true_and] rw [hset, ih (sub_nonneg.mpr hs.2)] · rw [Set.indicator_of_notMem hs] have hset : Prod.mk s ⁻¹' (e ⁻¹' positiveSimplex (n + 1) t) = ∅ := by apply Set.eq_empty_iff_forall_notMem.mpr intro x hx have hx' := (cons_mem_positiveSimplex t s x).mp (by simpa only [Set.mem_preimage, he_apply] using hx) apply hs refine ⟨hx'.1, ?_⟩ have hsum := Finset.sum_nonneg (fun idx (_ : idx ∈ Finset.univ) => hx'.2.1 idx) have hbound := hx'.2.2 linarith rw [hset, measure_empty] have hc : Continuous (fun s : ℝ => (t - s)^n / (n.factorial : ℝ)) := by fun_prop have hi : IntegrableOn (fun s : ℝ => (t - s)^n / (n.factorial : ℝ)) (Set.Icc 0 t) := hc.integrableOn_Icc have hn : 0 ≤ᵐ[volume.restrict (Set.Icc 0 t)] (fun s : ℝ => (t - s)^n / (n.factorial : ℝ)) := by filter_upwards [ae_restrict_mem measurableSet_Icc] with s hs exact div_nonneg (pow_nonneg (sub_nonneg.mpr hs.2) _) (by positivity) have hint : (∫ s in Set.Icc 0 t, (t - s)^n / (n.factorial : ℝ)) = t^(n+1) / ((n+1).factorial : ℝ) := by rw [integral_Icc_eq_integral_Ioc, ← intervalIntegral.integral_of_le ht, intervalIntegral.integral_div, intervalIntegral.integral_comp_sub_left (fun x : ℝ => x^n) t] simp only [sub_self, sub_zero, integral_pow, zero_pow (by omega : n + 1 ≠ 0), sub_zero, Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one] rw [div_div] calc volume (positiveSimplex (n + 1) t) = volume (e ⁻¹' positiveSimplex (n + 1) t) := (he.measure_preimage (positiveSimplex_measurable _ _).nullMeasurableSet).symm _ = ∫⁻ s : ℝ, volume (Prod.mk s ⁻¹' (e ⁻¹' positiveSimplex (n + 1) t)) := by rw [Measure.volume_eq_prod, Measure.prod_apply hm] _ = ∫⁻ s in Set.Icc 0 t, ENNReal.ofReal ((t - s)^n / n.factorial) := by simp_rw [hslice] exact lintegral_indicator measurableSet_Icc _ _ = ENNReal.ofReal (∫ s in Set.Icc 0 t, (t - s)^n / (n.factorial : ℝ)) := (ofReal_integral_eq_lintegral_ofReal hi hn).symm _ = _ := by rw [hint] /- Original line 27259: Erdos416Proof.SimplexVolume.realVolume_positiveSimplex -/ theorem realVolume_positiveSimplex (n : ℕ) {t : ℝ} (ht : 0 ≤ t) : volume.real (positiveSimplex n t) = t^n / (n.factorial : ℝ) := by rw [measureReal_def, volume_positiveSimplex n ht, ENNReal.toReal_ofReal] exact div_nonneg (pow_nonneg ht _) (by positivity) /-- Positive weighted coordinate inequalities, before any asserted volume formula. -/ /- Original line 27265: Erdos416Proof.SimplexVolume.weightedSimplex -/ def weightedSimplex (n : ℕ) (b : Fin n → ℝ) (t : ℝ) : Set (Fin n → ℝ) := {x | (∀ idx, 0 ≤ x idx) ∧ ∑ idx, b idx * x idx ≤ t} /- Original line 27268: Erdos416Proof.SimplexVolume.rescale -/ noncomputable def rescale (n : ℕ) (b : Fin n → ℝ) : (Fin n → ℝ) →ₗ[ℝ] (Fin n → ℝ) := Matrix.toLin' (Matrix.diagonal (fun idx => (b idx)⁻¹)) /- Original line 27272: Erdos416Proof.SimplexVolume.rescale_apply -/ theorem rescale_apply {n : ℕ} (b : Fin n → ℝ) (x : Fin n → ℝ) (idx : Fin n) : rescale n b x idx = (b idx)⁻¹ * x idx := by simp [rescale, Matrix.toLin'_apply, Matrix.mulVec_diagonal] /- Original line 27276: Erdos416Proof.SimplexVolume.rescale_det -/ theorem rescale_det {n : ℕ} (b : Fin n → ℝ) : LinearMap.det (rescale n b) = (∏ idx, b idx)⁻¹ := by rw [rescale, LinearMap.det_toLin', Matrix.det_diagonal, Finset.prod_inv_distrib] /- Original line 27280: Erdos416Proof.SimplexVolume.rescale_image -/ theorem rescale_image {n : ℕ} {b : Fin n → ℝ} (hb : ∀ idx, 0 < b idx) (t : ℝ) : rescale n b '' positiveSimplex n t = weightedSimplex n b t := by ext y constructor · rintro ⟨x, hx, rfl⟩ refine ⟨?_, ?_⟩ · intro idx rw [rescale_apply] exact mul_nonneg (inv_pos.mpr (hb idx)).le (hx.1 idx) · simpa only [rescale_apply, ← mul_assoc, mul_inv_cancel₀ (hb _).ne', one_mul] using hx.2 · intro hy refine ⟨fun idx => b idx * y idx, ⟨fun idx => mul_nonneg (hb idx).le (hy.1 idx), hy.2⟩, ?_⟩ ext idx simp [Erdos416Proof.SimplexVolume.rescale_apply, rescale_apply, (hb idx).ne'] /- Original line 27295: Erdos416Proof.SimplexVolume.realVolume_weightedSimplex -/ theorem realVolume_weightedSimplex {n : ℕ} {b : Fin n → ℝ} (hb : ∀ idx, 0 < b idx) {t : ℝ} (ht : 0 ≤ t) : volume.real (weightedSimplex n b t) = t^n / ((n.factorial : ℝ) * ∏ idx, b idx) := by have hp : 0 < ∏ idx, b idx := Finset.prod_pos (fun idx _ => hb idx) rw [← rescale_image hb t, measureReal_def, Measure.addHaar_image_linearMap, rescale_det, ENNReal.toReal_mul, ENNReal.toReal_ofReal (abs_nonneg _), abs_of_pos (inv_pos.mpr hp), ← measureReal_def, realVolume_positiveSimplex n ht] ring /- Original line 27304: Erdos416Proof.SimplexVolume.weightedSimplex_isCompact -/ theorem weightedSimplex_isCompact {n : ℕ} {b : Fin n → ℝ} (hb : ∀ idx, 0 < b idx) (t : ℝ) : IsCompact (weightedSimplex n b t) := by rw [← rescale_image hb t] exact (positiveSimplex_isCompact n t).image (rescale n b).continuous_of_finiteDimensional end Erdos416Proof.SimplexVolume namespace Erdos416Proof.FordGeometry open FordAnalysis SimplexVolume variable {L : ℕ} /-- The unordered region: the terminal row expresses nonnegativity of the last coordinate. All other rows are Ford's original tail inequalities. -/ /- Original line 27320: Erdos416Proof.FordGeometry.unorderedSimplex -/ noncomputable def unorderedSimplex (L : ℕ) : Set (Fin L → ℝ) := {x | outerForm L x ≤ 1 ∧ ∀ idx, tailForm idx x ≤ x idx} /- Original line 27323: Erdos416Proof.FordGeometry.TStar -/ noncomputable def TStar (L : ℕ) : ℝ := volume.real (unorderedSimplex L) /- Original line 27325: Erdos416Proof.FordGeometry.slackMatrix -/ noncomputable def slackMatrix (L : ℕ) : Matrix (Fin L) (Fin L) ℝ := fun idx j => (if idx = j then 1 else 0) - tailWeight idx j /- Original line 27328: Erdos416Proof.FordGeometry.slackMap -/ noncomputable def slackMap (L : ℕ) : (Fin L → ℝ) →ₗ[ℝ] (Fin L → ℝ) := Matrix.toLin' (slackMatrix L) /- Original line 27331: Erdos416Proof.FordGeometry.slackMap_apply -/ theorem slackMap_apply (x : Fin L → ℝ) (idx : Fin L) : slackMap L x idx = x idx - tailForm idx x := by simp [slackMap, slackMatrix, Matrix.toLin'_apply, sub_mul, ite_mul, tailForm, weightedForm_apply, Matrix.mulVec, dotProduct, Finset.sum_sub_distrib] /- Original line 27336: Erdos416Proof.FordGeometry.slackMatrix_upper -/ theorem slackMatrix_upper (L : ℕ) : (slackMatrix L).IsUpperTriangular := by intro idx j hij have hij' : j < idx := hij simp [Erdos416Proof.FordGeometry.slackMap_apply, slackMatrix, tailWeight_zero hij'.le, ne_of_gt hij'] /- Original line 27341: Erdos416Proof.FordGeometry.slackMap_det -/ theorem slackMap_det (L : ℕ) : LinearMap.det (slackMap L) = 1 := by rw [slackMap, LinearMap.det_toLin', Matrix.det_of_isUpperTriangular (slackMatrix_upper L)] simp [Erdos416Proof.FordGeometry.slackMap_apply, slackMatrix, tailWeight_zero (le_refl _)] /- Original line 27345: Erdos416Proof.FordGeometry.slackEquiv -/ noncomputable def slackEquiv (L : ℕ) : (Fin L → ℝ) ≃ₗ[ℝ] (Fin L → ℝ) := LinearMap.equivOfIsUnitDet (by rw [slackMap_det L]; exact isUnit_one) /- Original line 27348: Erdos416Proof.FordGeometry.slackEquiv_apply -/ theorem slackEquiv_apply (x : Fin L → ℝ) : slackEquiv L x = slackMap L x := LinearMap.equivOfIsUnitDet_apply _ _ /- Original line 27351: Erdos416Proof.FordGeometry.tailForm_terminal -/ theorem tailForm_terminal (idx : Fin L) (hi : idx.val + 1 = L) (x : Fin L → ℝ) : tailForm idx x = 0 := by change (∑ j, tailWeight idx j * x j) = 0 apply Finset.sum_eq_zero intro j _ have hji : j ≤ idx := by have := j.isLt; change j.val ≤ idx.val; omega rw [tailWeight_zero hji, zero_mul] /- Original line 27359: Erdos416Proof.FordGeometry.mem_unorderedSimplex_iff -/ theorem mem_unorderedSimplex_iff (hL : 0 < L) (x : Fin L → ℝ) : x ∈ unorderedSimplex L ↔ outerForm L x ≤ 1 ∧ 0 ≤ x ⟨L - 1, by omega⟩ ∧ ∀ idx : Fin L, idx.val + 1 < L → tailForm idx x ≤ x idx := by constructor · rintro ⟨ho, hx⟩ refine ⟨ho, ?_, fun idx _ => hx idx⟩ have h := hx ⟨L - 1, by omega⟩ rwa [tailForm_terminal _ (by simp only; omega)] at h · rintro ⟨ho, hl, hx⟩ refine ⟨ho, fun idx => ?_⟩ by_cases hi : idx.val + 1 < L · exact hx idx hi · have hil : idx.val + 1 = L := by have := idx.isLt; omega rw [tailForm_terminal idx hil] have hie : idx = ⟨L - 1, by omega⟩ := Fin.ext (by simp only; omega) simpa only [hie] using hl /- Original line 27377: Erdos416Proof.FordGeometry.nonneg_of_nonneg_slack -/ theorem nonneg_of_nonneg_slack (x : Fin L → ℝ) (hx : ∀ idx, 0 ≤ slackMap L x idx) : ∀ idx, 0 ≤ x idx := by have haux : ∀ k : ℕ, ∀ idx : Fin L, L - idx.val = k → 0 ≤ x idx := by intro k induction k using Nat.strong_induction_on with | h k ih => intro idx hi have ht : 0 ≤ tailForm idx x := by change 0 ≤ ∑ j, tailWeight idx j * x j apply Finset.sum_nonneg intro j _ by_cases hij : idx < j · have hj : 0 ≤ x j := ih (L - j.val) (by have := idx.isLt; have := j.isLt; change idx.val < j.val at hij; omega) j rfl exact mul_nonneg (tailWeight_nonneg idx j) hj · rw [tailWeight_zero (le_of_not_gt hij), zero_mul] have hs := hx idx rw [slackMap_apply] at hs linarith exact fun idx => haux _ idx rfl /- Original line 27398: Erdos416Proof.FordGeometry.unorderedSimplex_nonneg -/ theorem unorderedSimplex_nonneg {x : Fin L → ℝ} (hx : x ∈ unorderedSimplex L) : ∀ idx, 0 ≤ x idx := nonneg_of_nonneg_slack x (fun idx => by rw [slackMap_apply]; exact sub_nonneg.mpr (hx.2 idx)) /- Original line 27402: Erdos416Proof.FordGeometry.polytope_subset_unorderedSimplex -/ theorem polytope_subset_unorderedSimplex (L : ℕ) : polytope L (fun _ => 1) ⊆ unorderedSimplex L := by intro x hx refine ⟨hx.2.2.2.1, fun idx => ?_⟩ by_cases hi : idx.val + 1 < L · simpa only [one_mul] using hx.2.2.2.2 idx hi · rw [tailForm_terminal idx (by have := idx.isLt; omega)] exact hx.1 idx /-- The coefficients after the triangular slack substitution. -/ /- Original line 27412: Erdos416Proof.FordGeometry.simplexWeight -/ noncomputable def simplexWeight (L : ℕ) (idx : Fin L) : ℝ := if idx.val + 1 < L then g (idx.val + 1) else gStar (idx.val + 1) /- Original line 27415: Erdos416Proof.FordGeometry.simplexWeight_pos -/ theorem simplexWeight_pos (idx : Fin L) : 0 < simplexWeight L idx := by unfold simplexWeight split_ifs · exact g_pos _ · exact gStar_pos _ /- Original line 27421: Erdos416Proof.FordGeometry.g_succ_tail_sum -/ theorem g_succ_tail_sum (n : ℕ) : g (n + 1) = coeff (n + 1) + ∑ idx ∈ range n, g (idx + 1) * coeff (n - idx) := by have href := Finset.sum_range_reflect (fun idx => coeff (idx + 1) * g (n - idx)) (n + 1) have hsum : (∑ idx ∈ range (n + 1), coeff (n - idx + 1) * g idx) = g (n + 1) := by rw [g_succ, ← href] apply Finset.sum_congr rfl intro idx hi have hi' := Finset.mem_range.mp hi simp only [Nat.add_sub_cancel, Nat.sub_sub_self (by omega : idx ≤ n)] rw [Finset.sum_range_succ'] at hsum simp only [Nat.sub_zero, g_zero, mul_one] at hsum rw [← hsum, add_comm] congr 1 apply Finset.sum_congr rfl intro idx hi have hi' := Finset.mem_range.mp hi rw [show n - (idx + 1) + 1 = n - idx by omega, mul_comm] /- Original line 27439: Erdos416Proof.FordGeometry.sum_fin_lt -/ theorem sum_fin_lt {n : ℕ} (hn : n ≤ L) (f : ℕ → ℝ) : (∑ idx : Fin L, if idx.val < n then f idx.val else 0) = ∑ idx ∈ range n, f idx := by rw [Fin.sum_univ_eq_sum_range (fun idx : ℕ => if idx < n then f idx else 0) L] calc (∑ idx ∈ range L, if idx < n then f idx else 0) = ∑ idx ∈ range n, if idx < n then f idx else 0 := by symm apply Finset.sum_subset (Finset.range_mono hn) intro idx _ hi simp only [Finset.mem_range, not_lt] at hi simp [not_lt_of_ge hi] _ = _ := Finset.sum_congr rfl (fun idx hi => if_pos (Finset.mem_range.mp hi)) /- Original line 27452: Erdos416Proof.FordGeometry.simplexWeight_tail_column -/ theorem simplexWeight_tail_column (hL : 2 ≤ L) (j : Fin L) : simplexWeight L j - ∑ idx : Fin L, simplexWeight L idx * tailWeight idx j = coeff (j.val + 1) := by have hjL := j.isLt by_cases hj : j.val + 1 < L · have hterm (idx : Fin L) : simplexWeight L idx * tailWeight idx j = if idx.val < j.val then g (idx.val + 1) * coeff (j.val - idx.val) else 0 := by by_cases hij : idx.val < j.val · simp [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.gStar_zero, Erdos416Proof.FordAnalysis.g_zero, Erdos416Proof.FordGeometry.slackMap_apply, simplexWeight, tailWeight, hij, show idx.val + 1 < L by omega, show idx.val + 2 < L by omega, coeff, show j.val - idx.val ≠ 0 by omega] · simp [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.gStar_zero, Erdos416Proof.FordAnalysis.g_zero, Erdos416Proof.FordGeometry.slackMap_apply, tailWeight, hij] simp_rw [hterm] rw [sum_fin_lt (Nat.le_of_lt hjL) (fun idx => g (idx + 1) * coeff (j.val - idx)), simplexWeight, if_pos hj, g_succ_tail_sum] ring · have hjlast : j.val + 1 = L := by omega let k : Fin L := ⟨j.val - 1, by omega⟩ have hk : k.val + 1 = j.val := by dsimp [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.gStar_zero, Erdos416Proof.FordAnalysis.g_zero, Erdos416Proof.FordGeometry.slackMap_apply, k]; omega have hterm (idx : Fin L) : simplexWeight L idx * tailWeight idx j = (if idx.val < j.val then g (idx.val + 1) * coeff (j.val - idx.val) else 0) + if idx = k then (1 - coeff 1) * g j.val else 0 := by by_cases hik : idx = k · subst idx have hkj : k.val < j.val := by omega have hki2 : ¬ k.val + 2 < L := by omega simp only [simplexWeight, hjL, ↓reduceIte, tailWeight, hkj, hki2, mul_one, hk, show j.val - k.val = 1 by omega] ring · have hne : idx.val ≠ k.val := fun h => hik (Fin.ext h) by_cases hij : idx.val < j.val · simp [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.gStar_zero, Erdos416Proof.FordAnalysis.g_zero, Erdos416Proof.FordGeometry.slackMap_apply, simplexWeight, tailWeight, hij, hik, show idx.val + 1 < L by omega, show idx.val + 2 < L by omega, coeff, show j.val - idx.val ≠ 0 by omega] · simp [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.gStar_zero, Erdos416Proof.FordAnalysis.g_zero, Erdos416Proof.FordGeometry.slackMap_apply, tailWeight, hij, hik] simp_rw [hterm] rw [Finset.sum_add_distrib, sum_fin_lt (Nat.le_of_lt hjL) (fun idx => g (idx + 1) * coeff (j.val - idx))] simp only [Finset.sum_ite_eq', Finset.mem_univ, ↓reduceIte] rw [simplexWeight, if_neg hj, gStar_succ, g_succ_tail_sum] ring /- Original line 27492: Erdos416Proof.FordGeometry.weighted_slack_eq_outer -/ theorem weighted_slack_eq_outer (hL : 2 ≤ L) (x : Fin L → ℝ) : (∑ idx : Fin L, simplexWeight L idx * slackMap L x idx) = outerForm L x := by calc _ = ∑ j : Fin L, (simplexWeight L j - ∑ idx : Fin L, simplexWeight L idx * tailWeight idx j) * x j := by simp only [slackMap_apply, tailForm, weightedForm_apply, mul_sub, sub_mul, Finset.sum_sub_distrib, Finset.mul_sum, Finset.sum_mul] congr 1 rw [Finset.sum_comm] simp only [mul_assoc] _ = _ := by simp only [simplexWeight_tail_column hL, outerForm, weightedForm_apply] apply Finset.sum_congr rfl intro idx _ simp [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordGeometry.slackEquiv_apply, Erdos416Proof.FordGeometry.slackMap_apply, coeff] /- Original line 27508: Erdos416Proof.FordGeometry.simplexWeight_product -/ theorem simplexWeight_product (L : ℕ) : (∏ idx : Fin L, simplexWeight L idx) = renewalDenominator L := by cases L with | zero => simp [Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.gStar_zero, Erdos416Proof.FordAnalysis.g_zero, renewalDenominator] | succ n => rw [Fin.prod_univ_castSucc] have hi (idx : Fin n) : simplexWeight (n + 1) idx.castSucc = g (idx.val + 1) := by simp [Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.gStar_zero, Erdos416Proof.FordAnalysis.g_zero, simplexWeight, show idx.val + 1 < n + 1 by have := idx.isLt; omega] simp_rw [hi] simp only [simplexWeight, Fin.val_last, lt_self_iff_false, ↓reduceIte] rw [Fin.prod_univ_eq_prod_range (fun idx => g (idx + 1)) n] unfold renewalDenominator rw [Finset.prod_range_succ'] simp only [g_zero, mul_one] /- Original line 27523: Erdos416Proof.FordGeometry.slack_mem_weightedSimplex_iff -/ theorem slack_mem_weightedSimplex_iff (hL : 2 ≤ L) (x : Fin L → ℝ) : slackMap L x ∈ weightedSimplex L (simplexWeight L) 1 ↔ x ∈ unorderedSimplex L := by change ((∀ idx, 0 ≤ slackMap L x idx) ∧ (∑ idx, simplexWeight L idx * slackMap L x idx) ≤ 1) ↔ (outerForm L x ≤ 1 ∧ ∀ idx, tailForm idx x ≤ x idx) rw [weighted_slack_eq_outer hL] simp only [slackMap_apply, sub_nonneg] exact and_comm /- Original line 27532: Erdos416Proof.FordGeometry.slack_image_unorderedSimplex -/ theorem slack_image_unorderedSimplex (hL : 2 ≤ L) : slackMap L '' unorderedSimplex L = weightedSimplex L (simplexWeight L) 1 := by ext y constructor · rintro ⟨x, hx, rfl⟩ exact (slack_mem_weightedSimplex_iff hL x).mpr hx · intro hy obtain ⟨x, hx⟩ := (slackEquiv L).surjective y rw [slackEquiv_apply] at hx exact ⟨x, (slack_mem_weightedSimplex_iff hL x).mp (hx.symm ▸ hy), hx⟩ /-- The actual volume formula for Ford's unordered simplex, with the modified final coefficient retained. -/ /- Original line 27545: Erdos416Proof.FordGeometry.TStar_eq -/ theorem TStar_eq (hL : 2 ≤ L) : TStar L = 1 / ((L.factorial : ℝ) * renewalDenominator L) := by have hv : volume.real (slackMap L '' unorderedSimplex L) = TStar L := by simp only [measureReal_def, Measure.addHaar_image_linearMap, slackMap_det, abs_one, ENNReal.ofReal_one, one_mul, TStar] rw [slack_image_unorderedSimplex hL, realVolume_weightedSimplex (fun idx => simplexWeight_pos idx) zero_le_one, one_pow, simplexWeight_product] at hv exact hv.symm /- Original line 27555: Erdos416Proof.FordGeometry.TStar_pos -/ theorem TStar_pos (hL : 2 ≤ L) : 0 < TStar L := by rw [TStar_eq hL] exact one_div_pos.mpr (mul_pos (by positivity) (renewalDenominator_pos L)) /- Original line 27559: Erdos416Proof.FordGeometry.unorderedSimplex_isClosed -/ theorem unorderedSimplex_isClosed (L : ℕ) : IsClosed (unorderedSimplex L) := by simp only [unorderedSimplex, Set.ofPred_and, Set.ofPred_forall] exact (isClosed_le (outerForm L).continuous_of_finiteDimensional continuous_const).inter (isClosed_iInter fun idx => isClosed_le (tailForm idx).continuous_of_finiteDimensional (continuous_apply idx)) /- Original line 27565: Erdos416Proof.FordGeometry.unorderedSimplex_isCompact -/ theorem unorderedSimplex_isCompact (hL : 2 ≤ L) : IsCompact (unorderedSimplex L) := by have hi : (slackEquiv L).symm '' weightedSimplex L (simplexWeight L) 1 = unorderedSimplex L := by rw [← slack_image_unorderedSimplex hL, Set.image_image] simp only [← slackEquiv_apply, LinearEquiv.symm_apply_apply, Set.image_id'] rw [← hi] exact (weightedSimplex_isCompact (fun idx => simplexWeight_pos idx) 1).image (slackEquiv L).symm.continuous_of_finiteDimensional /- Original line 27575: Erdos416Proof.FordGeometry.T_le_TStar -/ theorem T_le_TStar (hL : 2 ≤ L) : T L ≤ TStar L := measureReal_mono (polytope_subset_unorderedSimplex L) (unorderedSimplex_isCompact hL).measure_lt_top.ne /-- Quantitative normalization of the actual geometric volume. -/ /- Original line 27580: Erdos416Proof.FordGeometry.TStar_normalized_tendsto -/ theorem TStar_normalized_tendsto : Tendsto (fun L : ℕ => TStar L * (L.factorial : ℝ) * lambda^(L+1) / rho^(L*(L+1)/2)) atTop (nhds ((renewalProductConstant * renewalLastFactor)⁻¹)) := by have h := renewalDenominator_normalized_tendsto.inv₀ (mul_pos renewalProductConstant_pos renewalLastFactor_pos).ne' apply h.congr' filter_upwards [eventually_ge_atTop 2] with L hL rw [TStar_eq hL] have hf : (L.factorial : ℝ) ≠ 0 := by exact_mod_cast Nat.factorial_ne_zero L field_simp [(renewalDenominator_pos L).ne', rho_pos.ne', lambda_pos.ne', hf] /- Original line 27591: Erdos416Proof.FordGeometry.TStar_eventual_bounds -/ theorem TStar_eventual_bounds : ∃ a b : ℝ, 0 < a ∧ 0 < b ∧ ∀ᶠ L : ℕ in atTop, a * rho^(L*(L+1)/2) / ((L.factorial : ℝ) * lambda^(L+1)) ≤ TStar L ∧ TStar L ≤ b * rho^(L*(L+1)/2) / ((L.factorial : ℝ) * lambda^(L+1)) := by let c : ℝ := (renewalProductConstant * renewalLastFactor)⁻¹ have hc : 0 < c := inv_pos.mpr (mul_pos renewalProductConstant_pos renewalLastFactor_pos) refine ⟨c/2, 2*c, half_pos hc, mul_pos (by norm_num) hc, ?_⟩ have hlo := TStar_normalized_tendsto.eventually_const_lt (half_lt_self hc) have hhi := TStar_normalized_tendsto.eventually_lt_const (show c < 2*c by linarith) filter_upwards [hlo, hhi] with L hl hu have hf : 0 < (L.factorial : ℝ) := by positivity have hp : 0 < rho^(L*(L+1)/2) := pow_pos rho_pos _ have hd : 0 < (L.factorial : ℝ) * lambda^(L+1) := mul_pos hf (pow_pos lambda_pos _) constructor · apply (div_le_iff₀ hd).mpr have h := (lt_div_iff₀ hp).mp hl nlinarith · apply (le_div_iff₀ hd).mpr have h := (div_lt_iff₀ hp).mp hu nlinarith end Erdos416Proof.FordGeometry /- Coefficient shape and certified numerical parameters for Ford's ordered-volume comparison and the uniform renewal error proved below. -/ open Filter Finset MeasureTheory open scoped Topology BigOperators Classical namespace Erdos416Proof.FordAnalysis /- Original line 27627: Erdos416Proof.FordAnalysis.coeff_eq_log_integral -/ theorem coeff_eq_log_integral {n : ℕ} (hn : 1 ≤ n) : coeff n = ∫ t in (0 : ℝ)..1, Real.log ((n : ℝ) + t) := by rw [intervalIntegral.integral_comp_add_left Real.log, integral_log, coeff_eq hn, fordWeight] simp only [add_zero] ring /- Original line 27633: Erdos416Proof.FordAnalysis.coeff_log_integrable -/ theorem coeff_log_integrable {n : ℕ} (hn : 1 ≤ n) : IntervalIntegrable (fun t : ℝ => Real.log ((n : ℝ) + t)) volume 0 1 := by apply ContinuousOn.intervalIntegrable apply ContinuousOn.log (continuous_const.add continuous_id).continuousOn intro t ht have ht0 : 0 ≤ t := by simpa using ht.1 have hn0 : (0 : ℝ) < n := by exact_mod_cast hn exact ne_of_gt (add_pos_of_pos_of_nonneg hn0 ht0) /- Original line 27642: Erdos416Proof.FordAnalysis.coeff_le_succ -/ theorem coeff_le_succ {n : ℕ} (hn : 1 ≤ n) : coeff n ≤ coeff (n + 1) := by rw [coeff_eq_log_integral hn, coeff_eq_log_integral (by omega : 1 ≤ n + 1)] apply intervalIntegral.integral_mono_on (by norm_num) (coeff_log_integrable hn) (coeff_log_integrable (by omega : 1 ≤ n + 1)) intro t ht apply Real.log_le_log · have hn0 : (0 : ℝ) < n := by exact_mod_cast hn linarith [ht.1] · push_cast linarith /- Original line 27653: Erdos416Proof.FordAnalysis.coeff_monotone -/ theorem coeff_monotone : Monotone coeff := by apply monotone_nat_of_le_succ intro n rcases Nat.eq_zero_or_pos n with rfl | hn · simpa [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.coeff_zero] using coeff_one_pos.le · exact coeff_le_succ hn /- Original line 27660: Erdos416Proof.FordAnalysis.log_second_difference_nonpos -/ theorem log_second_difference_nonpos {x : ℝ} (hx : 0 < x) : Real.log (x + 2) - 2 * Real.log (x + 1) + Real.log x ≤ 0 := by have h := Real.log_le_log (mul_pos hx (by linarith : 0 < x + 2)) (show x * (x + 2) ≤ (x + 1)^2 by nlinarith) rw [Real.log_mul hx.ne' (by linarith : x + 2 ≠ 0), Real.log_pow] at h norm_num at h linarith /- Original line 27668: Erdos416Proof.FordAnalysis.coeff_second_difference_nonpos -/ theorem coeff_second_difference_nonpos {n : ℕ} (hn : 1 ≤ n) : coeff (n + 2) - 2 * coeff (n + 1) + coeff n ≤ 0 := by have hi0 := coeff_log_integrable hn have hi1 := coeff_log_integrable (by omega : 1 ≤ n + 1) have hi2 := coeff_log_integrable (by omega : 1 ≤ n + 2) rw [coeff_eq_log_integral (by omega : 1 ≤ n + 2), coeff_eq_log_integral (by omega : 1 ≤ n + 1), coeff_eq_log_integral hn, ← intervalIntegral.integral_const_mul, ← intervalIntegral.integral_sub hi2 (hi1.const_mul 2), ← intervalIntegral.integral_add (hi2.sub (hi1.const_mul 2)) hi0] apply le_trans (b := ∫ _t in (0 : ℝ)..1, (0 : ℝ)) ?_ (by simp[Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.coeff_zero] ) apply intervalIntegral.integral_mono_on (by norm_num) ((hi2.sub (hi1.const_mul 2)).add hi0) intervalIntegrable_const intro t ht have hn0 : (0 : ℝ) < n := by exact_mod_cast hn have h := log_second_difference_nonpos (show 0 < (n : ℝ) + t by linarith [ht.1]) convert h using 1 push_cast ring_nf /-- A finite logarithm certificate after scaling its argument by a power of two. -/ /- Original line 27688: Erdos416Proof.FordAnalysis.scaled_log_bounds -/ theorem scaled_log_bounds {x z : ℝ} (hx : 0 < x) (hz0 : 0 ≤ z) (hz1 : z < 1) (k N : ℕ) (he : (1 + z) / (1 - z) = x / (2 : ℝ)^k) : 2 * (∑ idx ∈ range N, z^(2*idx+1)/(2*idx+1)) ≤ Real.log x - k * Real.log 2 ∧ Real.log x - k * Real.log 2 ≤ 2 * ((∑ idx ∈ range N, z^(2*idx+1)/(2*idx+1)) + z^(2*N+1)/(1-z^2)) := by have hlo := Real.sum_range_le_log_div hz0 hz1 N have hhi := Real.log_div_le_sum_range_add hz0 hz1 N rw [he, Real.log_div hx.ne' (by positivity : (2 : ℝ)^k ≠ 0), Real.log_pow] at hlo hhi constructor <;> linarith /- Original line 27698: Erdos416Proof.FordAnalysis.log_two_decimal_bounds -/ theorem log_two_decimal_bounds : (6931471805 / 10000000000 : ℝ) ≤ Real.log 2 ∧ Real.log 2 ≤ 6931471806 / 10000000000 := by have h := scaled_log_bounds (by norm_num : (0 : ℝ) < 2) (by norm_num : (0 : ℝ) ≤ 1/3) (by norm_num : (1/3 : ℝ) < 1) 0 12 (by norm_num) norm_num [Finset.sum_range_succ] at h constructor <;> linarith [h.1, h.2] /- Original line 27706: Erdos416Proof.FordAnalysis.lambda_le_one -/ theorem lambda_le_one : lambda ≤ 1 := by have hs := (summable_derivativeSeries (z := rho) (by simpa [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.coeff_zero, abs_of_pos rho_pos] using rho_lt_one)).mul_left rho have he (n : ℕ) : rho * (coeff n * ((n : ℝ) * rho^(n-1))) = (n : ℝ) * (coeff n * rho^n) := by cases n with | zero => simp[Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.coeff_zero] | succ n => simp only [Nat.add_sub_cancel, pow_succ]; ring have hb : F rho ≤ rho * derivativeSeries rho := by rw [derivativeSeries, ← tsum_mul_left] apply Summable.tsum_le_tsum _ (summable_F (by simpa [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.coeff_zero, abs_of_pos rho_pos] using rho_lt_one)) hs intro n rw [he] rcases Nat.eq_zero_or_pos n with rfl | hn · simp[Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.coeff_zero] · exact le_mul_of_one_le_left (mul_nonneg (coeff_bounds n).1 (pow_pos rho_pos n).le) (by exact_mod_cast hn) rw [F_rho, ← deriv_F (by simpa [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.coeff_zero, abs_of_pos rho_pos] using rho_lt_one)] at hb exact (div_le_one (mul_pos rho_pos deriv_F_rho_pos)).mpr hb end Erdos416Proof.FordAnalysis namespace Erdos416Proof.FordAnalysis /- Original line 27732: Erdos416Proof.FordAnalysis.rationalLogBounds -/ def rationalLogBounds (n : ℕ) : ℚ × ℚ := ([ (0, 0), (0, 0), ((69314717 / 100000000), (433217 / 625000)), ((109861227 / 100000000), (10986123 / 10000000)), ((27725887 / 20000000), (69314719 / 50000000)), ((16094379 / 10000000), (160943793 / 100000000)), ((35835189 / 20000000), (44793987 / 25000000)), ((194591013 / 100000000), (24323877 / 12500000)), ((207944153 / 100000000), (51986039 / 25000000)), ((27465307 / 12500000), (219722459 / 100000000)), ((57564627 / 25000000), (230258511 / 100000000)), ((119894763 / 50000000), (239789529 / 100000000)), ((248490663 / 100000000), (124245333 / 50000000)), ((128247467 / 50000000), (256494937 / 100000000)), ((263905731 / 100000000), (131952867 / 50000000)), ((270805019 / 100000000), (135402511 / 50000000)), ((277258871 / 100000000), (138629437 / 50000000)), ((283321333 / 100000000), (35415167 / 12500000)), ((144518587 / 50000000), (289037177 / 100000000)), ((36805487 / 12500000), (294443899 / 100000000)), ((149786613 / 50000000), (299573229 / 100000000)), ((152226121 / 50000000), (60890449 / 20000000)), ((77276061 / 25000000), (309104247 / 100000000)), ((15677471 / 5000000), (313549423 / 100000000)), ((158902691 / 50000000), (63561077 / 20000000)), ((321887581 / 100000000), (10058987 / 3125000)), ((81452413 / 25000000), (65161931 / 20000000)), ((65916737 / 20000000), (41197961 / 12500000)), ((6664409 / 2000000), (333220453 / 100000000)), ((336729581 / 100000000), (21045599 / 6250000)), ((340119737 / 100000000), (17005987 / 5000000)), ((343398719 / 100000000), (171699361 / 50000000)), ((346573589 / 100000000), (43321699 / 12500000)), ((69930151 / 20000000), (174825379 / 50000000)) ] : List (ℚ × ℚ)).getD n (0, 0) /- Original line 27771: Erdos416Proof.FordAnalysis.log_table_bounds -/ private theorem log_table_bounds_case_1 : ((rationalLogBounds (1 : ℕ)).1 : ℝ) ≤ Real.log (1 : ℕ) ∧ Real.log (1 : ℕ) ≤ ((rationalLogBounds (1 : ℕ)).2 : ℝ) := by norm_num [rationalLogBounds] private theorem log_table_bounds_case_2 : ((rationalLogBounds (2 : ℕ)).1 : ℝ) ≤ Real.log (2 : ℕ) ∧ Real.log (2 : ℕ) ≤ ((rationalLogBounds (2 : ℕ)).2 : ℝ) := by have h := scaled_log_bounds (by norm_num : (0 : ℝ) < 2) (by norm_num : (0 : ℝ) ≤ (1 / 3)) (by norm_num : ((1 / 3) : ℝ) < 1) 0 12 (by norm_num) norm_num [Finset.sum_range_succ] at h norm_num [rationalLogBounds] constructor <;> linarith [h.1, h.2, log_two_decimal_bounds.1, log_two_decimal_bounds.2] private theorem log_table_bounds_case_3 : ((rationalLogBounds (3 : ℕ)).1 : ℝ) ≤ Real.log (3 : ℕ) ∧ Real.log (3 : ℕ) ≤ ((rationalLogBounds (3 : ℕ)).2 : ℝ) := by have h := scaled_log_bounds (by norm_num : (0 : ℝ) < 3) (by norm_num : (0 : ℝ) ≤ (1 / 5)) (by norm_num : ((1 / 5) : ℝ) < 1) 1 12 (by norm_num) norm_num [Finset.sum_range_succ] at h norm_num [rationalLogBounds] constructor <;> linarith [h.1, h.2, log_two_decimal_bounds.1, log_two_decimal_bounds.2] private theorem log_table_bounds_case_4 : ((rationalLogBounds (4 : ℕ)).1 : ℝ) ≤ Real.log (4 : ℕ) ∧ Real.log (4 : ℕ) ≤ ((rationalLogBounds (4 : ℕ)).2 : ℝ) := by have h := scaled_log_bounds (by norm_num : (0 : ℝ) < 4) (by norm_num : (0 : ℝ) ≤ (1 / 3)) (by norm_num : ((1 / 3) : ℝ) < 1) 1 12 (by norm_num) norm_num [Finset.sum_range_succ] at h norm_num [rationalLogBounds] constructor <;> linarith [h.1, h.2, log_two_decimal_bounds.1, log_two_decimal_bounds.2] private theorem log_table_bounds_case_5 : ((rationalLogBounds (5 : ℕ)).1 : ℝ) ≤ Real.log (5 : ℕ) ∧ Real.log (5 : ℕ) ≤ ((rationalLogBounds (5 : ℕ)).2 : ℝ) := by have h := scaled_log_bounds (by norm_num : (0 : ℝ) < 5) (by norm_num : (0 : ℝ) ≤ (1 / 9)) (by norm_num : ((1 / 9) : ℝ) < 1) 2 12 (by norm_num) norm_num [Finset.sum_range_succ] at h norm_num [rationalLogBounds] constructor <;> linarith [h.1, h.2, log_two_decimal_bounds.1, log_two_decimal_bounds.2] private theorem log_table_bounds_case_6 : ((rationalLogBounds (6 : ℕ)).1 : ℝ) ≤ Real.log (6 : ℕ) ∧ Real.log (6 : ℕ) ≤ ((rationalLogBounds (6 : ℕ)).2 : ℝ) := by have h := scaled_log_bounds (by norm_num : (0 : ℝ) < 6) (by norm_num : (0 : ℝ) ≤ (1 / 5)) (by norm_num : ((1 / 5) : ℝ) < 1) 2 12 (by norm_num) norm_num [Finset.sum_range_succ] at h norm_num [rationalLogBounds] constructor <;> linarith [h.1, h.2, log_two_decimal_bounds.1, log_two_decimal_bounds.2] private theorem log_table_bounds_case_7 : ((rationalLogBounds (7 : ℕ)).1 : ℝ) ≤ Real.log (7 : ℕ) ∧ Real.log (7 : ℕ) ≤ ((rationalLogBounds (7 : ℕ)).2 : ℝ) := by have h := scaled_log_bounds (by norm_num : (0 : ℝ) < 7) (by norm_num : (0 : ℝ) ≤ (3 / 11)) (by norm_num : ((3 / 11) : ℝ) < 1) 2 12 (by norm_num) norm_num [Finset.sum_range_succ] at h norm_num [rationalLogBounds] constructor <;> linarith [h.1, h.2, log_two_decimal_bounds.1, log_two_decimal_bounds.2] private theorem log_table_bounds_case_8 : ((rationalLogBounds (8 : ℕ)).1 : ℝ) ≤ Real.log (8 : ℕ) ∧ Real.log (8 : ℕ) ≤ ((rationalLogBounds (8 : ℕ)).2 : ℝ) := by have h := scaled_log_bounds (by norm_num : (0 : ℝ) < 8) (by norm_num : (0 : ℝ) ≤ (1 / 3)) (by norm_num : ((1 / 3) : ℝ) < 1) 2 12 (by norm_num) norm_num [Finset.sum_range_succ] at h norm_num [rationalLogBounds] constructor <;> linarith [h.1, h.2, log_two_decimal_bounds.1, log_two_decimal_bounds.2] private theorem log_table_bounds_case_9 : ((rationalLogBounds (9 : ℕ)).1 : ℝ) ≤ Real.log (9 : ℕ) ∧ Real.log (9 : ℕ) ≤ ((rationalLogBounds (9 : ℕ)).2 : ℝ) := by have h := scaled_log_bounds (by norm_num : (0 : ℝ) < 9) (by norm_num : (0 : ℝ) ≤ (1 / 17)) (by norm_num : ((1 / 17) : ℝ) < 1) 3 12 (by norm_num) norm_num [Finset.sum_range_succ] at h norm_num [rationalLogBounds] constructor <;> linarith [h.1, h.2, log_two_decimal_bounds.1, log_two_decimal_bounds.2] private theorem log_table_bounds_case_10 : ((rationalLogBounds (10 : ℕ)).1 : ℝ) ≤ Real.log (10 : ℕ) ∧ Real.log (10 : ℕ) ≤ ((rationalLogBounds (10 : ℕ)).2 : ℝ) := by have h := scaled_log_bounds (by norm_num : (0 : ℝ) < 10) (by norm_num : (0 : ℝ) ≤ (1 / 9)) (by norm_num : ((1 / 9) : ℝ) < 1) 3 12 (by norm_num) norm_num [Finset.sum_range_succ] at h norm_num [rationalLogBounds] constructor <;> linarith [h.1, h.2, log_two_decimal_bounds.1, log_two_decimal_bounds.2] private theorem log_table_bounds_case_11 : ((rationalLogBounds (11 : ℕ)).1 : ℝ) ≤ Real.log (11 : ℕ) ∧ Real.log (11 : ℕ) ≤ ((rationalLogBounds (11 : ℕ)).2 : ℝ) := by have h := scaled_log_bounds (by norm_num : (0 : ℝ) < 11) (by norm_num : (0 : ℝ) ≤ (3 / 19)) (by norm_num : ((3 / 19) : ℝ) < 1) 3 12 (by norm_num) norm_num [Finset.sum_range_succ] at h norm_num [rationalLogBounds] constructor <;> linarith [h.1, h.2, log_two_decimal_bounds.1, log_two_decimal_bounds.2] private theorem log_table_bounds_case_12 : ((rationalLogBounds (12 : ℕ)).1 : ℝ) ≤ Real.log (12 : ℕ) ∧ Real.log (12 : ℕ) ≤ ((rationalLogBounds (12 : ℕ)).2 : ℝ) := by have h := scaled_log_bounds (by norm_num : (0 : ℝ) < 12) (by norm_num : (0 : ℝ) ≤ (1 / 5)) (by norm_num : ((1 / 5) : ℝ) < 1) 3 12 (by norm_num) norm_num [Finset.sum_range_succ] at h norm_num [rationalLogBounds] constructor <;> linarith [h.1, h.2, log_two_decimal_bounds.1, log_two_decimal_bounds.2] private theorem log_table_bounds_case_13 : ((rationalLogBounds (13 : ℕ)).1 : ℝ) ≤ Real.log (13 : ℕ) ∧ Real.log (13 : ℕ) ≤ ((rationalLogBounds (13 : ℕ)).2 : ℝ) := by have h := scaled_log_bounds (by norm_num : (0 : ℝ) < 13) (by norm_num : (0 : ℝ) ≤ (5 / 21)) (by norm_num : ((5 / 21) : ℝ) < 1) 3 12 (by norm_num) norm_num [Finset.sum_range_succ] at h norm_num [rationalLogBounds] constructor <;> linarith [h.1, h.2, log_two_decimal_bounds.1, log_two_decimal_bounds.2] private theorem log_table_bounds_case_14 : ((rationalLogBounds (14 : ℕ)).1 : ℝ) ≤ Real.log (14 : ℕ) ∧ Real.log (14 : ℕ) ≤ ((rationalLogBounds (14 : ℕ)).2 : ℝ) := by have h := scaled_log_bounds (by norm_num : (0 : ℝ) < 14) (by norm_num : (0 : ℝ) ≤ (3 / 11)) (by norm_num : ((3 / 11) : ℝ) < 1) 3 12 (by norm_num) norm_num [Finset.sum_range_succ] at h norm_num [rationalLogBounds] constructor <;> linarith [h.1, h.2, log_two_decimal_bounds.1, log_two_decimal_bounds.2] private theorem log_table_bounds_case_15 : ((rationalLogBounds (15 : ℕ)).1 : ℝ) ≤ Real.log (15 : ℕ) ∧ Real.log (15 : ℕ) ≤ ((rationalLogBounds (15 : ℕ)).2 : ℝ) := by have h := scaled_log_bounds (by norm_num : (0 : ℝ) < 15) (by norm_num : (0 : ℝ) ≤ (7 / 23)) (by norm_num : ((7 / 23) : ℝ) < 1) 3 12 (by norm_num) norm_num [Finset.sum_range_succ] at h norm_num [rationalLogBounds] constructor <;> linarith [h.1, h.2, log_two_decimal_bounds.1, log_two_decimal_bounds.2] private theorem log_table_bounds_case_16 : ((rationalLogBounds (16 : ℕ)).1 : ℝ) ≤ Real.log (16 : ℕ) ∧ Real.log (16 : ℕ) ≤ ((rationalLogBounds (16 : ℕ)).2 : ℝ) := by have h := scaled_log_bounds (by norm_num : (0 : ℝ) < 16) (by norm_num : (0 : ℝ) ≤ (1 / 3)) (by norm_num : ((1 / 3) : ℝ) < 1) 3 12 (by norm_num) norm_num [Finset.sum_range_succ] at h norm_num [rationalLogBounds] constructor <;> linarith [h.1, h.2, log_two_decimal_bounds.1, log_two_decimal_bounds.2] private theorem log_table_bounds_case_17 : ((rationalLogBounds (17 : ℕ)).1 : ℝ) ≤ Real.log (17 : ℕ) ∧ Real.log (17 : ℕ) ≤ ((rationalLogBounds (17 : ℕ)).2 : ℝ) := by have h := scaled_log_bounds (by norm_num : (0 : ℝ) < 17) (by norm_num : (0 : ℝ) ≤ (1 / 33)) (by norm_num : ((1 / 33) : ℝ) < 1) 4 12 (by norm_num) norm_num [Finset.sum_range_succ] at h norm_num [rationalLogBounds] constructor <;> linarith [h.1, h.2, log_two_decimal_bounds.1, log_two_decimal_bounds.2] private theorem log_table_bounds_case_18 : ((rationalLogBounds (18 : ℕ)).1 : ℝ) ≤ Real.log (18 : ℕ) ∧ Real.log (18 : ℕ) ≤ ((rationalLogBounds (18 : ℕ)).2 : ℝ) := by have h := scaled_log_bounds (by norm_num : (0 : ℝ) < 18) (by norm_num : (0 : ℝ) ≤ (1 / 17)) (by norm_num : ((1 / 17) : ℝ) < 1) 4 12 (by norm_num) norm_num [Finset.sum_range_succ] at h norm_num [rationalLogBounds] constructor <;> linarith [h.1, h.2, log_two_decimal_bounds.1, log_two_decimal_bounds.2] private theorem log_table_bounds_case_19 : ((rationalLogBounds (19 : ℕ)).1 : ℝ) ≤ Real.log (19 : ℕ) ∧ Real.log (19 : ℕ) ≤ ((rationalLogBounds (19 : ℕ)).2 : ℝ) := by have h := scaled_log_bounds (by norm_num : (0 : ℝ) < 19) (by norm_num : (0 : ℝ) ≤ (3 / 35)) (by norm_num : ((3 / 35) : ℝ) < 1) 4 12 (by norm_num) norm_num [Finset.sum_range_succ] at h norm_num [rationalLogBounds] constructor <;> linarith [h.1, h.2, log_two_decimal_bounds.1, log_two_decimal_bounds.2] private theorem log_table_bounds_case_20 : ((rationalLogBounds (20 : ℕ)).1 : ℝ) ≤ Real.log (20 : ℕ) ∧ Real.log (20 : ℕ) ≤ ((rationalLogBounds (20 : ℕ)).2 : ℝ) := by have h := scaled_log_bounds (by norm_num : (0 : ℝ) < 20) (by norm_num : (0 : ℝ) ≤ (1 / 9)) (by norm_num : ((1 / 9) : ℝ) < 1) 4 12 (by norm_num) norm_num [Finset.sum_range_succ] at h norm_num [rationalLogBounds] constructor <;> linarith [h.1, h.2, log_two_decimal_bounds.1, log_two_decimal_bounds.2] private theorem log_table_bounds_case_21 : ((rationalLogBounds (21 : ℕ)).1 : ℝ) ≤ Real.log (21 : ℕ) ∧ Real.log (21 : ℕ) ≤ ((rationalLogBounds (21 : ℕ)).2 : ℝ) := by have h := scaled_log_bounds (by norm_num : (0 : ℝ) < 21) (by norm_num : (0 : ℝ) ≤ (5 / 37)) (by norm_num : ((5 / 37) : ℝ) < 1) 4 12 (by norm_num) norm_num [Finset.sum_range_succ] at h norm_num [rationalLogBounds] constructor <;> linarith [h.1, h.2, log_two_decimal_bounds.1, log_two_decimal_bounds.2] private theorem log_table_bounds_case_22 : ((rationalLogBounds (22 : ℕ)).1 : ℝ) ≤ Real.log (22 : ℕ) ∧ Real.log (22 : ℕ) ≤ ((rationalLogBounds (22 : ℕ)).2 : ℝ) := by have h := scaled_log_bounds (by norm_num : (0 : ℝ) < 22) (by norm_num : (0 : ℝ) ≤ (3 / 19)) (by norm_num : ((3 / 19) : ℝ) < 1) 4 12 (by norm_num) norm_num [Finset.sum_range_succ] at h norm_num [rationalLogBounds] constructor <;> linarith [h.1, h.2, log_two_decimal_bounds.1, log_two_decimal_bounds.2] private theorem log_table_bounds_case_23 : ((rationalLogBounds (23 : ℕ)).1 : ℝ) ≤ Real.log (23 : ℕ) ∧ Real.log (23 : ℕ) ≤ ((rationalLogBounds (23 : ℕ)).2 : ℝ) := by have h := scaled_log_bounds (by norm_num : (0 : ℝ) < 23) (by norm_num : (0 : ℝ) ≤ (7 / 39)) (by norm_num : ((7 / 39) : ℝ) < 1) 4 12 (by norm_num) norm_num [Finset.sum_range_succ] at h norm_num [rationalLogBounds] constructor <;> linarith [h.1, h.2, log_two_decimal_bounds.1, log_two_decimal_bounds.2] private theorem log_table_bounds_case_24 : ((rationalLogBounds (24 : ℕ)).1 : ℝ) ≤ Real.log (24 : ℕ) ∧ Real.log (24 : ℕ) ≤ ((rationalLogBounds (24 : ℕ)).2 : ℝ) := by have h := scaled_log_bounds (by norm_num : (0 : ℝ) < 24) (by norm_num : (0 : ℝ) ≤ (1 / 5)) (by norm_num : ((1 / 5) : ℝ) < 1) 4 12 (by norm_num) norm_num [Finset.sum_range_succ] at h norm_num [rationalLogBounds] constructor <;> linarith [h.1, h.2, log_two_decimal_bounds.1, log_two_decimal_bounds.2] private theorem log_table_bounds_case_25 : ((rationalLogBounds (25 : ℕ)).1 : ℝ) ≤ Real.log (25 : ℕ) ∧ Real.log (25 : ℕ) ≤ ((rationalLogBounds (25 : ℕ)).2 : ℝ) := by have h := scaled_log_bounds (by norm_num : (0 : ℝ) < 25) (by norm_num : (0 : ℝ) ≤ (9 / 41)) (by norm_num : ((9 / 41) : ℝ) < 1) 4 12 (by norm_num) norm_num [Finset.sum_range_succ] at h norm_num [rationalLogBounds] constructor <;> linarith [h.1, h.2, log_two_decimal_bounds.1, log_two_decimal_bounds.2] private theorem log_table_bounds_case_26 : ((rationalLogBounds (26 : ℕ)).1 : ℝ) ≤ Real.log (26 : ℕ) ∧ Real.log (26 : ℕ) ≤ ((rationalLogBounds (26 : ℕ)).2 : ℝ) := by have h := scaled_log_bounds (by norm_num : (0 : ℝ) < 26) (by norm_num : (0 : ℝ) ≤ (5 / 21)) (by norm_num : ((5 / 21) : ℝ) < 1) 4 12 (by norm_num) norm_num [Finset.sum_range_succ] at h norm_num [rationalLogBounds] constructor <;> linarith [h.1, h.2, log_two_decimal_bounds.1, log_two_decimal_bounds.2] private theorem log_table_bounds_case_27 : ((rationalLogBounds (27 : ℕ)).1 : ℝ) ≤ Real.log (27 : ℕ) ∧ Real.log (27 : ℕ) ≤ ((rationalLogBounds (27 : ℕ)).2 : ℝ) := by have h := scaled_log_bounds (by norm_num : (0 : ℝ) < 27) (by norm_num : (0 : ℝ) ≤ (11 / 43)) (by norm_num : ((11 / 43) : ℝ) < 1) 4 12 (by norm_num) norm_num [Finset.sum_range_succ] at h norm_num [rationalLogBounds] constructor <;> linarith [h.1, h.2, log_two_decimal_bounds.1, log_two_decimal_bounds.2] private theorem log_table_bounds_case_28 : ((rationalLogBounds (28 : ℕ)).1 : ℝ) ≤ Real.log (28 : ℕ) ∧ Real.log (28 : ℕ) ≤ ((rationalLogBounds (28 : ℕ)).2 : ℝ) := by have h := scaled_log_bounds (by norm_num : (0 : ℝ) < 28) (by norm_num : (0 : ℝ) ≤ (3 / 11)) (by norm_num : ((3 / 11) : ℝ) < 1) 4 12 (by norm_num) norm_num [Finset.sum_range_succ] at h norm_num [rationalLogBounds] constructor <;> linarith [h.1, h.2, log_two_decimal_bounds.1, log_two_decimal_bounds.2] private theorem log_table_bounds_case_29 : ((rationalLogBounds (29 : ℕ)).1 : ℝ) ≤ Real.log (29 : ℕ) ∧ Real.log (29 : ℕ) ≤ ((rationalLogBounds (29 : ℕ)).2 : ℝ) := by have h := scaled_log_bounds (by norm_num : (0 : ℝ) < 29) (by norm_num : (0 : ℝ) ≤ (13 / 45)) (by norm_num : ((13 / 45) : ℝ) < 1) 4 12 (by norm_num) norm_num [Finset.sum_range_succ] at h norm_num [rationalLogBounds] constructor <;> linarith [h.1, h.2, log_two_decimal_bounds.1, log_two_decimal_bounds.2] private theorem log_table_bounds_case_30 : ((rationalLogBounds (30 : ℕ)).1 : ℝ) ≤ Real.log (30 : ℕ) ∧ Real.log (30 : ℕ) ≤ ((rationalLogBounds (30 : ℕ)).2 : ℝ) := by have h := scaled_log_bounds (by norm_num : (0 : ℝ) < 30) (by norm_num : (0 : ℝ) ≤ (7 / 23)) (by norm_num : ((7 / 23) : ℝ) < 1) 4 12 (by norm_num) norm_num [Finset.sum_range_succ] at h norm_num [rationalLogBounds] constructor <;> linarith [h.1, h.2, log_two_decimal_bounds.1, log_two_decimal_bounds.2] private theorem log_table_bounds_case_31 : ((rationalLogBounds (31 : ℕ)).1 : ℝ) ≤ Real.log (31 : ℕ) ∧ Real.log (31 : ℕ) ≤ ((rationalLogBounds (31 : ℕ)).2 : ℝ) := by have h := scaled_log_bounds (by norm_num : (0 : ℝ) < 31) (by norm_num : (0 : ℝ) ≤ (15 / 47)) (by norm_num : ((15 / 47) : ℝ) < 1) 4 12 (by norm_num) norm_num [Finset.sum_range_succ] at h norm_num [rationalLogBounds] constructor <;> linarith [h.1, h.2, log_two_decimal_bounds.1, log_two_decimal_bounds.2] private theorem log_table_bounds_case_32 : ((rationalLogBounds (32 : ℕ)).1 : ℝ) ≤ Real.log (32 : ℕ) ∧ Real.log (32 : ℕ) ≤ ((rationalLogBounds (32 : ℕ)).2 : ℝ) := by have h := scaled_log_bounds (by norm_num : (0 : ℝ) < 32) (by norm_num : (0 : ℝ) ≤ (1 / 3)) (by norm_num : ((1 / 3) : ℝ) < 1) 4 12 (by norm_num) norm_num [Finset.sum_range_succ] at h norm_num [rationalLogBounds] constructor <;> linarith [h.1, h.2, log_two_decimal_bounds.1, log_two_decimal_bounds.2] private theorem log_table_bounds_case_33 : ((rationalLogBounds (33 : ℕ)).1 : ℝ) ≤ Real.log (33 : ℕ) ∧ Real.log (33 : ℕ) ≤ ((rationalLogBounds (33 : ℕ)).2 : ℝ) := by have h := scaled_log_bounds (by norm_num : (0 : ℝ) < 33) (by norm_num : (0 : ℝ) ≤ (1 / 65)) (by norm_num : ((1 / 65) : ℝ) < 1) 5 12 (by norm_num) norm_num [Finset.sum_range_succ] at h norm_num [rationalLogBounds] constructor <;> linarith [h.1, h.2, log_two_decimal_bounds.1, log_two_decimal_bounds.2] theorem log_table_bounds {n : ℕ} (hn0 : 1 ≤ n) (hn1 : n ≤ 33) : ((rationalLogBounds n).1 : ℝ) ≤ Real.log n ∧ Real.log n ≤ ((rationalLogBounds n).2 : ℝ) := by interval_cases n · exact log_table_bounds_case_1 · exact log_table_bounds_case_2 · exact log_table_bounds_case_3 · exact log_table_bounds_case_4 · exact log_table_bounds_case_5 · exact log_table_bounds_case_6 · exact log_table_bounds_case_7 · exact log_table_bounds_case_8 · exact log_table_bounds_case_9 · exact log_table_bounds_case_10 · exact log_table_bounds_case_11 · exact log_table_bounds_case_12 · exact log_table_bounds_case_13 · exact log_table_bounds_case_14 · exact log_table_bounds_case_15 · exact log_table_bounds_case_16 · exact log_table_bounds_case_17 · exact log_table_bounds_case_18 · exact log_table_bounds_case_19 · exact log_table_bounds_case_20 · exact log_table_bounds_case_21 · exact log_table_bounds_case_22 · exact log_table_bounds_case_23 · exact log_table_bounds_case_24 · exact log_table_bounds_case_25 · exact log_table_bounds_case_26 · exact log_table_bounds_case_27 · exact log_table_bounds_case_28 · exact log_table_bounds_case_29 · exact log_table_bounds_case_30 · exact log_table_bounds_case_31 · exact log_table_bounds_case_32 · exact log_table_bounds_case_33 /- Original line 28001: Erdos416Proof.FordAnalysis.rationalCoeffLower -/ def rationalCoeffLower (n : ℕ) : ℚ := if n = 0 then 0 else (n + 1) * (rationalLogBounds (n + 1)).1 - n * (rationalLogBounds n).2 - 1 /- Original line 28005: Erdos416Proof.FordAnalysis.rationalCoeffUpper -/ def rationalCoeffUpper (n : ℕ) : ℚ := if n = 0 then 0 else (n + 1) * (rationalLogBounds (n + 1)).2 - n * (rationalLogBounds n).1 - 1 /- Original line 28009: Erdos416Proof.FordAnalysis.coeff_table_bounds -/ theorem coeff_table_bounds {n : ℕ} (hn : n ≤ 32) : (rationalCoeffLower n : ℝ) ≤ coeff n ∧ coeff n ≤ (rationalCoeffUpper n : ℝ) := by rcases Nat.eq_zero_or_pos n with rfl | hn0 · simp [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.coeff_zero, rationalCoeffLower, rationalCoeffUpper] have hc := log_table_bounds hn0 (by omega : n ≤ 33) have hd := log_table_bounds (by omega : 1 ≤ n + 1) (by omega : n + 1 ≤ 33) simp only [Nat.cast_add, Nat.cast_one] at hd simp only [rationalCoeffLower, rationalCoeffUpper, if_neg (ne_of_gt hn0)] push_cast rw [coeff_eq hn0, fordWeight] have hnR : (0 : ℝ) ≤ n := Nat.cast_nonneg n have hn1R : (0 : ℝ) ≤ n + 1 := by positivity constructor <;> nlinarith [mul_le_mul_of_nonneg_left hc.1 hnR, mul_le_mul_of_nonneg_left hc.2 hnR, mul_le_mul_of_nonneg_left hd.1 hn1R, mul_le_mul_of_nonneg_left hd.2 hn1R] /- Original line 28025: Erdos416Proof.FordAnalysis.F_prefix_le -/ theorem F_prefix_le (N : ℕ) {z : ℝ} (hz0 : 0 ≤ z) (hz1 : z < 1) : (∑ n ∈ range N, coeff n * z^n) ≤ F z := Summable.sum_le_tsum _ (fun n _ => mul_nonneg (coeff_bounds n).1 (pow_nonneg hz0 n)) (summable_F (z := z) (by simpa [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.coeff_zero, abs_of_nonneg hz0] using hz1)) /- Original line 28030: Erdos416Proof.FordAnalysis.F_le_prefix_add_tail -/ theorem F_le_prefix_add_tail (N : ℕ) {z : ℝ} (hz0 : 0 ≤ z) (hz1 : z < 1) : F z ≤ (∑ n ∈ range N, coeff n * z^n) + z / (1-z)^2 - ∑ n ∈ range N, (n : ℝ) * z^n := by have hsF := summable_F (z := z) (by simpa [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.coeff_zero, abs_of_nonneg hz0] using hz1) have hsM := hasSum_coe_mul_geometric_of_norm_lt_one (r := z) (by simpa [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.coeff_zero, Real.norm_eq_abs, abs_of_nonneg hz0] using hz1) have hF := hsF.sum_add_tsum_nat_add N have hM := hsM.summable.sum_add_tsum_nat_add N change (∑ n ∈ range N, coeff n * z^n) + (∑' n : ℕ, coeff (n+N) * z^(n+N)) = F z at hF rw [hsM.tsum_eq] at hM have htail : (∑' n : ℕ, coeff (n+N) * z^(n+N)) ≤ ∑' n : ℕ, ((n+N : ℕ) : ℝ) * z^(n+N) := by apply Summable.tsum_le_tsum _ ((summable_nat_add_iff N).mpr hsF) ((summable_nat_add_iff N).mpr hsM.summable) intro n exact mul_le_mul_of_nonneg_right (coeff_bounds (n+N)).2 (pow_nonneg hz0 _) linarith /- Original line 28050: Erdos416Proof.FordAnalysis.F_lower_endpoint_lt_one -/ theorem F_lower_endpoint_lt_one : F (217/400) < 1 := by have hb := F_le_prefix_add_tail 33 (by norm_num : (0 : ℝ) ≤ 217/400) (by norm_num) have hc : (∑ n ∈ range 33, coeff n * (217/400 : ℝ)^n) ≤ ∑ n ∈ range 33, (rationalCoeffUpper n : ℝ) * (217/400 : ℝ)^n := by apply Finset.sum_le_sum intro n hn apply mul_le_mul_of_nonneg_right (coeff_table_bounds (by have := Finset.mem_range.mp hn; omega)).2 positivity have hnum : (∑ n ∈ range 33, (rationalCoeffUpper n : ℝ) * (217/400 : ℝ)^n) + (217/400 : ℝ)/(1-217/400)^2 - ∑ n ∈ range 33, (n : ℝ)*(217/400 : ℝ)^n < 1 := by norm_num [Finset.sum_range_succ, rationalCoeffUpper, rationalLogBounds] linarith /- Original line 28064: Erdos416Proof.FordAnalysis.one_lt_F_upper_endpoint -/ theorem one_lt_F_upper_endpoint : 1 < F (2713/5000) := by have hb := F_prefix_le 33 (by norm_num : (0 : ℝ) ≤ 2713/5000) (by norm_num) have hc : (∑ n ∈ range 33, (rationalCoeffLower n : ℝ) * (2713/5000 : ℝ)^n) ≤ ∑ n ∈ range 33, coeff n * (2713/5000 : ℝ)^n := by apply Finset.sum_le_sum intro n hn apply mul_le_mul_of_nonneg_right (coeff_table_bounds (by have := Finset.mem_range.mp hn; omega)).1 positivity have hnum : (1 : ℝ) < ∑ n ∈ range 33, (rationalCoeffLower n : ℝ) * (2713/5000 : ℝ)^n := by norm_num [Finset.sum_range_succ, rationalCoeffLower, rationalLogBounds] exact hnum.trans_le (hc.trans hb) /- Original line 28076: Erdos416Proof.FordAnalysis.rho_numeric_bounds -/ theorem rho_numeric_bounds : (217/400 : ℝ) < rho ∧ rho < 2713/5000 := by constructor · by_contra h have hm := F_strictMonoOn.monotoneOn ⟨rho_pos.le, rho_lt_one⟩ ⟨(by norm_num : (0 : ℝ) ≤ 217/400), (by norm_num : (217/400 : ℝ) < 1)⟩ (le_of_not_gt h) rw [F_rho] at hm exact not_lt_of_ge hm F_lower_endpoint_lt_one · by_contra h have hm := F_strictMonoOn.monotoneOn ⟨(by norm_num : (0 : ℝ) ≤ 2713/5000), (by norm_num : (2713/5000 : ℝ) < 1)⟩ ⟨rho_pos.le, rho_lt_one⟩ (le_of_not_gt h) rw [F_rho] at hm exact not_lt_of_ge hm one_lt_F_upper_endpoint /- Original line 28090: Erdos416Proof.FordAnalysis.coeff_one_numeric_lower -/ theorem coeff_one_numeric_lower : (38629/100000 : ℝ) < coeff 1 := by norm_num [coeff, fordWeight] linarith [log_two_decimal_bounds.1] /- Original line 28094: Erdos416Proof.FordAnalysis.renewalKappa -/ noncomputable def renewalKappa : ℝ := 2 + coeff 1 - 1/rho /- Original line 28096: Erdos416Proof.FordAnalysis.half_lt_renewalKappa -/ theorem half_lt_renewalKappa : (1/2 : ℝ) < renewalKappa := by have hi : (1 : ℝ)/rho < 50/27 := (div_lt_iff₀ rho_pos).mpr (by nlinarith [rho_numeric_bounds.1]) unfold renewalKappa linarith [coeff_one_numeric_lower] /- Original line 28101: Erdos416Proof.FordAnalysis.g_ratio_tendsto -/ theorem g_ratio_tendsto : Tendsto (fun n : ℕ => g (n + 1) / g n) atTop (nhds rho⁻¹) := by have h := ((g_scaled_tendsto.comp (tendsto_add_atTop_nat 1)).div g_scaled_tendsto lambda_pos.ne').div_const rho convert h using 1 · funext n change g (n + 1) / g n = (g (n + 1) * rho^(n+1) / (g n * rho^n)) / rho rw [pow_succ] field_simp [(g_pos n).ne', rho_pos.ne'] · simp [Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.g_zero, lambda_pos.ne', one_div] /- Original line 28112: Erdos416Proof.FordAnalysis.orderB -/ noncomputable def orderB (idx : ℕ) : ℝ := g (idx + 1) / (1 - coeff 1) /- Original line 28114: Erdos416Proof.FordAnalysis.orderA -/ noncomputable def orderA (idx : ℕ) : ℝ := g idx + orderB idx /- Original line 28116: Erdos416Proof.FordAnalysis.orderA_ratio_eq -/ theorem orderA_ratio_eq (idx : ℕ) : orderA idx / g idx = 1 + (g (idx + 1) / g idx) / (1 - coeff 1) := by unfold orderA orderB field_simp [(g_pos idx).ne', (sub_pos.mpr coeff_one_lt_one).ne'] /- Original line 28121: Erdos416Proof.FordAnalysis.orderA_ratio_tendsto -/ theorem orderA_ratio_tendsto : Tendsto (fun idx : ℕ => orderA idx / g idx) atTop (nhds (1 + rho⁻¹ / (1 - coeff 1))) := by simpa only [orderA_ratio_eq] using (tendsto_const_nhds.add (g_ratio_tendsto.div_const (1 - coeff 1))) /- Original line 28127: Erdos416Proof.FordAnalysis.orderA_ratio_limit_gt_four -/ theorem orderA_ratio_limit_gt_four : (4 : ℝ) < 1 + rho⁻¹ / (1 - coeff 1) := by have hd : 0 < 1 - coeff 1 := sub_pos.mpr coeff_one_lt_one have hp : rho * (1 - coeff 1) < 1/3 := calc rho * (1 - coeff 1) < (2713/5000 : ℝ) * (1 - coeff 1) := mul_lt_mul_of_pos_right rho_numeric_bounds.2 hd _ ≤ (2713/5000 : ℝ) * (1 - 38629/100000) := mul_le_mul_of_nonneg_left (by linarith [coeff_one_numeric_lower]) (by norm_num) _ < 1/3 := by norm_num have h3 : (3 : ℝ) < rho⁻¹ / (1 - coeff 1) := by rw [inv_eq_one_div, div_div, lt_div_iff₀ (mul_pos rho_pos hd)] nlinarith linarith /- Original line 28140: Erdos416Proof.FordAnalysis.orderA_eventually_gt_four_mul -/ theorem orderA_eventually_gt_four_mul : ∀ᶠ idx : ℕ in atTop, 4 * g idx < orderA idx := by filter_upwards [orderA_ratio_tendsto.eventually_const_lt orderA_ratio_limit_gt_four] with idx hi exact (lt_div_iff₀ (g_pos idx)).mp hi /-- The unnormalized all-index inequality printed on Ford page 15 fails at i=1; the volume ratio actually requires A_i>4*g_i. -/ /- Original line 28146: Erdos416Proof.FordAnalysis.orderA_one_lt_four -/ theorem orderA_one_lt_four : orderA 1 < 4 := by have h1 : coeff 1 < (2/5 : ℝ) := by have h := (coeff_table_bounds (by norm_num [Erdos416Proof.FordAnalysis.g_zero, Erdos416Proof.FordAnalysis.gStar_zero] : 1 ≤ 32)).2 norm_num [Erdos416Proof.FordAnalysis.g_zero, Erdos416Proof.FordAnalysis.gStar_zero, rationalCoeffUpper, rationalLogBounds] at h linarith have h2 : coeff 2 < 1 := by have h := (coeff_table_bounds (by norm_num [Erdos416Proof.FordAnalysis.g_zero, Erdos416Proof.FordAnalysis.gStar_zero] : 2 ≤ 32)).2 norm_num [Erdos416Proof.FordAnalysis.g_zero, Erdos416Proof.FordAnalysis.gStar_zero, rationalCoeffUpper, rationalLogBounds] at h linarith have hg1 : g 1 = coeff 1 := by rw [g_succ 0]; simp[Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.g_zero] have hg2 : g 2 = coeff 1 ^ 2 + coeff 2 := by rw [g_succ 1] norm_num [Erdos416Proof.FordAnalysis.g_zero, Erdos416Proof.FordAnalysis.gStar_zero, Finset.sum_range_succ, hg1] ring rw [orderA, orderB, hg1, hg2] have hb : (coeff 1 ^ 2 + coeff 2) / (1 - coeff 1) < 4 - coeff 1 := (div_lt_iff₀ (sub_pos.mpr coeff_one_lt_one)).mpr (by nlinarith) nlinarith /- Original line 28165: Erdos416Proof.FordAnalysis.derivative_mass_hasSum -/ theorem derivative_mass_hasSum {z : ℝ} (hz : |z| < 1) : HasSum (fun n : ℕ => (n : ℝ) * (coeff n * z^n)) (z * deriv F z) := by have h := (summable_derivativeSeries hz).hasSum.mul_left z change HasSum (fun n : ℕ => z * (coeff n * ((n : ℝ) * z^(n-1)))) (z * derivativeSeries z) at h rw [← deriv_F hz] at h exact h.congr_fun fun n => by cases n with | zero => simp[Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.coeff_zero] | succ n => simp only [Nat.add_sub_cancel, pow_succ]; ring /- Original line 28176: Erdos416Proof.FordAnalysis.derivative_mass_mono -/ theorem derivative_mass_mono {x y : ℝ} (hx0 : 0 ≤ x) (hxy : x ≤ y) (hy1 : y < 1) : x * deriv F x ≤ y * deriv F y := by have hx := derivative_mass_hasSum (z := x) (by simpa [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.coeff_zero, abs_of_nonneg hx0] using hxy.trans_lt hy1) have hy := derivative_mass_hasSum (z := y) (by simpa [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.coeff_zero, abs_of_nonneg (hx0.trans hxy)] using hy1) rw [← hx.tsum_eq, ← hy.tsum_eq] apply Summable.tsum_le_tsum _ hx.summable hy.summable intro n exact mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_left (pow_le_pow_left₀ hx0 hxy n) (coeff_bounds n).1) (Nat.cast_nonneg n) /- Original line 28186: Erdos416Proof.FordAnalysis.quadratic_majorant_hasSum -/ theorem quadratic_majorant_hasSum {z : ℝ} (hz : |z| < 1) : HasSum (fun n : ℕ => ((n : ℝ)+1)*((n : ℝ)+2)*z^n) (2/(1-z)^3) := by have h := (hasSum_choose_mul_geometric_of_norm_lt_one 2 (r := z) (by simpa [Real.norm_eq_abs] using hz)).mul_left 2 convert! h using 1 · funext n rw [Nat.cast_choose_two] push_cast ring · ring /- Original line 28197: Erdos416Proof.FordAnalysis.derivative_mass_prefix_le -/ theorem derivative_mass_prefix_le (N : ℕ) {z : ℝ} (hz0 : 0 ≤ z) (hz1 : z < 1) : (∑ n ∈ range N, (n : ℝ) * (coeff n * z^n)) ≤ z * deriv F z := by have hs := derivative_mass_hasSum (z := z) (by simpa [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.coeff_zero, abs_of_nonneg hz0] using hz1) rw [← hs.tsum_eq] exact Summable.sum_le_tsum _ (fun n _ => mul_nonneg (Nat.cast_nonneg n) (mul_nonneg (coeff_bounds n).1 (pow_nonneg hz0 _))) hs.summable /- Original line 28205: Erdos416Proof.FordAnalysis.derivative_mass_le_prefix_add_tail -/ theorem derivative_mass_le_prefix_add_tail (N : ℕ) {z : ℝ} (hz0 : 0 ≤ z) (hz1 : z < 1) : z * deriv F z ≤ (∑ n ∈ range N, (n : ℝ) * (coeff n * z^n)) + 2/(1-z)^3 - ∑ n ∈ range N, ((n : ℝ)+1)*((n : ℝ)+2)*z^n := by have hsD := derivative_mass_hasSum (z := z) (by simpa [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.coeff_zero, abs_of_nonneg hz0] using hz1) have hsM := quadratic_majorant_hasSum (z := z) (by simpa [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.coeff_zero, abs_of_nonneg hz0] using hz1) have hD := hsD.summable.sum_add_tsum_nat_add N have hM := hsM.summable.sum_add_tsum_nat_add N rw [hsD.tsum_eq] at hD rw [hsM.tsum_eq] at hM have ht : (∑' n : ℕ, ((n+N : ℕ) : ℝ) * (coeff (n+N) * z^(n+N))) ≤ ∑' n : ℕ, (((n+N : ℕ) : ℝ)+1)*(((n+N : ℕ) : ℝ)+2)*z^(n+N) := by apply Summable.tsum_le_tsum _ ((summable_nat_add_iff N).mpr hsD.summable) ((summable_nat_add_iff N).mpr hsM.summable) intro n rw [← mul_assoc] apply mul_le_mul_of_nonneg_right _ (pow_nonneg hz0 _) have hnR : (0 : ℝ) ≤ ((n+N : ℕ) : ℝ) := Nat.cast_nonneg _ have h := mul_le_mul_of_nonneg_left (coeff_bounds (n+N)).2 hnR nlinarith linarith /- Original line 28227: Erdos416Proof.FordAnalysis.lambda_numeric_bounds -/ theorem lambda_numeric_bounds : (161/500 : ℝ) < lambda ∧ lambda < 1/3 := by have hu := derivative_mass_le_prefix_add_tail 33 (by norm_num : (0 : ℝ) ≤ 2713/5000) (by norm_num) have huc : (∑ n ∈ range 33, (n : ℝ) * (coeff n * (2713/5000 : ℝ)^n)) ≤ ∑ n ∈ range 33, (n : ℝ) * ((rationalCoeffUpper n : ℝ) * (2713/5000 : ℝ)^n) := by apply Finset.sum_le_sum intro n hn exact mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_right (coeff_table_bounds (by have := Finset.mem_range.mp hn; omega)).2 (by positivity)) (Nat.cast_nonneg n) have hun : (∑ n ∈ range 33, (n : ℝ) * ((rationalCoeffUpper n : ℝ) * (2713/5000 : ℝ)^n)) + 2/(1-(2713/5000 : ℝ))^3 - (∑ n ∈ range 33, ((n : ℝ)+1)*((n : ℝ)+2)*(2713/5000 : ℝ)^n) < 500/161 := by norm_num [Finset.sum_range_succ, rationalCoeffUpper, rationalLogBounds] have hl := derivative_mass_prefix_le 33 (by norm_num : (0 : ℝ) ≤ 217/400) (by norm_num) have hlc : (∑ n ∈ range 33, (n : ℝ) * ((rationalCoeffLower n : ℝ) * (217/400 : ℝ)^n)) ≤ ∑ n ∈ range 33, (n : ℝ) * (coeff n * (217/400 : ℝ)^n) := by apply Finset.sum_le_sum intro n hn exact mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_right (coeff_table_bounds (by have := Finset.mem_range.mp hn; omega)).1 (by positivity)) (Nat.cast_nonneg n) have hln : (3 : ℝ) < ∑ n ∈ range 33, (n : ℝ) * ((rationalCoeffLower n : ℝ) * (217/400 : ℝ)^n) := by norm_num [Finset.sum_range_succ, rationalCoeffLower, rationalLogBounds] have hmU := derivative_mass_mono rho_pos.le rho_numeric_bounds.2.le (by norm_num) have hmL := derivative_mass_mono (by norm_num : (0 : ℝ) ≤ 217/400) rho_numeric_bounds.1.le rho_lt_one constructor · rw [lambda] apply (lt_div_iff₀ (mul_pos rho_pos deriv_F_rho_pos)).mpr nlinarith · rw [lambda] apply (div_lt_iff₀ (mul_pos rho_pos deriv_F_rho_pos)).mpr nlinarith /- Original line 28261: Erdos416Proof.FordAnalysis.renewalKappa_numeric_lower -/ theorem renewalKappa_numeric_lower : (20/37 : ℝ) < renewalKappa := by have hi : (1 : ℝ)/rho < 400/217 := (div_lt_iff₀ rho_pos).mpr (by nlinarith [rho_numeric_bounds.1]) unfold renewalKappa linarith [coeff_one_numeric_lower] /- Original line 28266: Erdos416Proof.FordAnalysis.two_div_renewalKappa_lt -/ theorem two_div_renewalKappa_lt : (2 : ℝ)/renewalKappa < 37/10 := by apply (div_lt_iff₀ (by linarith [half_lt_renewalKappa] : 0 < renewalKappa)).mpr nlinarith [renewalKappa_numeric_lower] /- Original line 28270: Erdos416Proof.FordAnalysis.renewal_boundary_constant_lt_five -/ theorem renewal_boundary_constant_lt_five : ((37/10 : ℝ) + lambda)/(rho⁻¹ - 1) < 5 := by have hi : (5000/2713 : ℝ) < rho⁻¹ := by rw [inv_eq_one_div] apply (lt_div_iff₀ rho_pos).mpr nlinarith [rho_numeric_bounds.2] apply (div_lt_iff₀ (by linarith : 0 < rho⁻¹ - 1)).mpr nlinarith [lambda_numeric_bounds.2] /- Original line 28279: Erdos416Proof.FordAnalysis.renewal_bulk_gain_gt -/ theorem renewal_bulk_gain_gt : (11/25 : ℝ) < lambda * (1-rho)/(rho*(1-coeff 1)) := by have hd : 0 < 1 - coeff 1 := sub_pos.mpr coeff_one_lt_one have hu : rho * (1-coeff 1) < (2713/5000 : ℝ) * (1-38629/100000) := calc _ < (2713/5000 : ℝ) * (1-coeff 1) := mul_lt_mul_of_pos_right rho_numeric_bounds.2 hd _ ≤ _ := mul_le_mul_of_nonneg_left (by linarith [coeff_one_numeric_lower]) (by norm_num) have hl : (161/500 : ℝ) * (1-2713/5000) < lambda * (1-rho) := calc _ < lambda * (1-2713/5000) := mul_lt_mul_of_pos_right lambda_numeric_bounds.1 (by norm_num) _ ≤ _ := mul_le_mul_of_nonneg_left (by linarith [rho_numeric_bounds.2]) lambda_pos.le apply (lt_div_iff₀ (mul_pos rho_pos hd)).mpr nlinarith end Erdos416Proof.FordAnalysis /- Uniform absolute renewal error for the actual Ford recurrence, from coefficient concavity, unit-disk factor control and Cauchy's estimate. -/ open Filter Finset MeasureTheory Metric open scoped Topology BigOperators Classical NNReal ENNReal namespace Erdos416Proof.FordAnalysis /- Original line 28306: Erdos416Proof.FordAnalysis.succ_weighted_geometric_hasSum -/ theorem succ_weighted_geometric_hasSum : HasSum (fun k : ℕ => ((k : ℝ)+1)*rho^(k+1)) (rho/(1-rho)^2) := by have hg := hasSum_geometric_of_lt_one rho_pos.le rho_lt_one have hw := hasSum_coe_mul_geometric_of_norm_lt_one (r := rho) (by simpa [Real.norm_eq_abs, abs_of_pos rho_pos] using rho_lt_one) have h := (hw.add hg).mul_left rho convert! h using 1 · funext k rw [pow_succ] ring · field_simp [(sub_pos.mpr rho_lt_one).ne'] ring /- Original line 28319: Erdos416Proof.FordAnalysis.factorCoeff_term_le -/ theorem factorCoeff_term_le (n k : ℕ) : rho^(k+1)*coeff (n+k+1) ≤ ((n : ℝ)+1)*(((k : ℝ)+1)*rho^(k+1)) := by have hc : coeff (n+k+1) ≤ ((n : ℝ)+1)*((k : ℝ)+1) := by have h := (coeff_bounds (n+k+1)).2 push_cast at h nlinarith [mul_nonneg (Nat.cast_nonneg n : (0:ℝ) ≤ n) (Nat.cast_nonneg k : (0:ℝ) ≤ k)] calc _ ≤ rho^(k+1)*(((n : ℝ)+1)*((k : ℝ)+1)) := mul_le_mul_of_nonneg_left hc (pow_pos rho_pos _).le _ = _ := by ring /- Original line 28330: Erdos416Proof.FordAnalysis.summable_factorCoeff -/ theorem summable_factorCoeff (n : ℕ) : Summable (fun k : ℕ => rho^(k+1)*coeff (n+k+1)) := by apply Summable.of_norm_bounded (succ_weighted_geometric_hasSum.summable.mul_left ((n : ℝ)+1)) intro k rw [Real.norm_eq_abs, abs_of_nonneg (mul_nonneg (pow_pos rho_pos _).le (coeff_bounds _).1)] exact factorCoeff_term_le n k /-- The actual coefficients of the analytic factor after removal of the root rho. -/ /- Original line 28338: Erdos416Proof.FordAnalysis.factorCoeff -/ noncomputable def factorCoeff (n : ℕ) : ℝ := ∑' k : ℕ, rho^(k+1)*coeff (n+k+1) /- Original line 28340: Erdos416Proof.FordAnalysis.factorCoeff_nonneg -/ theorem factorCoeff_nonneg (n : ℕ) : 0 ≤ factorCoeff n := tsum_nonneg fun _k => mul_nonneg (pow_pos rho_pos _).le (coeff_bounds _).1 /- Original line 28343: Erdos416Proof.FordAnalysis.factorCoeff_upper -/ theorem factorCoeff_upper (n : ℕ) : factorCoeff n ≤ ((n : ℝ)+1)*(rho/(1-rho)^2) := by have hs := succ_weighted_geometric_hasSum.mul_left ((n : ℝ)+1) rw [← hs.tsum_eq] exact Summable.tsum_le_tsum (factorCoeff_term_le n) (summable_factorCoeff n) hs.summable /- Original line 28349: Erdos416Proof.FordAnalysis.factorCoeff_zero -/ theorem factorCoeff_zero : factorCoeff 0 = 1 := by have h := (summable_F (z := rho) (by simpa [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.coeff_zero, abs_of_pos rho_pos] using rho_lt_one)).sum_add_tsum_nat_add 1 change (∑ n ∈ range 1, coeff n*rho^n) + (∑' n : ℕ, coeff (n+1)*rho^(n+1)) = F rho at h rw [F_rho] at h simpa [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.coeff_zero, factorCoeff, mul_comm] using h /- Original line 28355: Erdos416Proof.FordAnalysis.factorCoeff_monotone -/ theorem factorCoeff_monotone : Monotone factorCoeff := by intro n m hnm apply Summable.tsum_le_tsum _ (summable_factorCoeff n) (summable_factorCoeff m) intro k exact mul_le_mul_of_nonneg_left (coeff_monotone (by omega : n+k+1 ≤ m+k+1)) (pow_pos rho_pos _).le /- Original line 28362: Erdos416Proof.FordAnalysis.factorCoeff_second_difference -/ theorem factorCoeff_second_difference (n : ℕ) : factorCoeff (n+2)-2*factorCoeff (n+1)+factorCoeff n ≤ 0 := by have h := ((summable_factorCoeff (n+2)).hasSum.sub ((summable_factorCoeff (n+1)).hasSum.mul_left 2)).add (summable_factorCoeff n).hasSum change HasSum _ (factorCoeff (n+2)-2*factorCoeff (n+1)+factorCoeff n) at h rw [← h.tsum_eq] apply tsum_nonpos intro k have hc := coeff_second_difference_nonpos (by omega : 1 ≤ n+k+1) have hc' : coeff (n+2+k+1)-2*coeff (n+1+k+1)+coeff (n+k+1) ≤ 0 := by simpa only [Nat.add_assoc, Nat.add_comm, Nat.add_left_comm] using hc have hp := mul_nonpos_of_nonneg_of_nonpos (pow_pos rho_pos (k+1)).le hc' nlinarith /- Original line 28376: Erdos416Proof.FordAnalysis.factorCoeff_rec -/ theorem factorCoeff_rec (n : ℕ) : factorCoeff n = rho*coeff (n+1)+rho*factorCoeff (n+1) := by have h := (summable_factorCoeff n).sum_add_tsum_nat_add 1 change (∑ k ∈ range 1, rho^(k+1)*coeff (n+k+1)) + (∑' k : ℕ, rho^((k+1)+1)*coeff (n+(k+1)+1)) = factorCoeff n at h have he : (∑' k : ℕ, rho^((k+1)+1)*coeff (n+(k+1)+1)) = rho*factorCoeff (n+1) := by rw [factorCoeff, ← tsum_mul_left] apply tsum_congr intro k rw [show n+(k+1)+1 = (n+1)+k+1 by omega, pow_succ] ring simpa only [Finset.sum_range_one, Nat.zero_add, Nat.add_zero, pow_one, he] using h.symm /- Original line 28389: Erdos416Proof.FordAnalysis.factorCoeff_one -/ theorem factorCoeff_one : factorCoeff 1 = 1/rho-coeff 1 := by have h := factorCoeff_rec 0 rw [factorCoeff_zero] at h norm_num at h field_simp [rho_pos.ne'] nlinarith /-- Coefficients after multiplication of the analytic factor by (1-z)^2. -/ /- Original line 28397: Erdos416Proof.FordAnalysis.factorDiff -/ noncomputable def factorDiff : ℕ → ℝ | 0 => 1 | 1 => -renewalKappa | n+2 => factorCoeff (n+2)-2*factorCoeff (n+1)+factorCoeff n /- Original line 28402: Erdos416Proof.FordAnalysis.factorDiff_succ_nonpos -/ theorem factorDiff_succ_nonpos (n : ℕ) : factorDiff (n+1) ≤ 0 := by cases n with | zero => simp only [factorDiff]; linarith [half_lt_renewalKappa] | succ n => exact factorCoeff_second_difference n /- Original line 28407: Erdos416Proof.FordAnalysis.factorDiff_telescope -/ theorem factorDiff_telescope (N : ℕ) : 1-(∑ idx ∈ range (N+1), -factorDiff (idx+1)) = factorCoeff (N+1)-factorCoeff N := by induction N with | zero => simp [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.coeff_zero, factorDiff, factorCoeff_zero, factorCoeff_one, renewalKappa]; ring | succ N ih => rw [Finset.sum_range_succ] change 1-((∑ idx ∈ range (N+1), -factorDiff (idx+1)) + -(factorCoeff (N+2)-2*factorCoeff (N+1)+factorCoeff N)) = factorCoeff (N+2)-factorCoeff (N+1) linarith /- Original line 28418: Erdos416Proof.FordAnalysis.factorDiff_partial_mass_le -/ theorem factorDiff_partial_mass_le (N : ℕ) : (∑ idx ∈ range N, -factorDiff (idx+1)) ≤ 1 := by cases N with | zero => simp | succ N => have h := factorDiff_telescope N have hm := factorCoeff_monotone (Nat.le_succ N) linarith /- Original line 28427: Erdos416Proof.FordAnalysis.summable_factorDiff_mass -/ theorem summable_factorDiff_mass : Summable (fun idx : ℕ => -factorDiff (idx+1)) := summable_of_sum_range_le (fun idx => neg_nonneg.mpr (factorDiff_succ_nonpos idx)) factorDiff_partial_mass_le /- Original line 28430: Erdos416Proof.FordAnalysis.factorDiff_mass_le -/ theorem factorDiff_mass_le : (∑' idx : ℕ, -factorDiff (idx+1)) ≤ 1 := Real.tsum_le_of_sum_range_le (fun idx => neg_nonneg.mpr (factorDiff_succ_nonpos idx)) factorDiff_partial_mass_le /- Original line 28433: Erdos416Proof.FordAnalysis.summable_factorDiff_tail -/ theorem summable_factorDiff_tail : Summable (fun idx : ℕ => -factorDiff (idx+2)) := by simpa only [Nat.add_assoc] using (summable_nat_add_iff 1).mpr summable_factorDiff_mass /- Original line 28436: Erdos416Proof.FordAnalysis.factorDiff_tail_mass_le -/ theorem factorDiff_tail_mass_le : (∑' idx : ℕ, -factorDiff (idx+2)) ≤ 1-renewalKappa := by have h := summable_factorDiff_mass.sum_add_tsum_nat_add 1 simp only [Finset.sum_range_one, Nat.zero_add, show factorDiff 1 = -renewalKappa from rfl, neg_neg] at h have he : (∑' idx : ℕ, -factorDiff (idx+1+1)) = ∑' idx : ℕ, -factorDiff (idx+2) := by apply tsum_congr intro idx rw [show idx+1+1=idx+2 by omega] rw [he] at h linarith [factorDiff_mass_le] /-- The power series whose coefficients are the actual positive factor coefficients. -/ /- Original line 28448: Erdos416Proof.FordAnalysis.factorComplex -/ noncomputable def factorComplex (z : ℂ) : ℂ := ∑' n : ℕ, (factorCoeff n : ℂ)*z^n /- Original line 28450: Erdos416Proof.FordAnalysis.summable_factorComplex -/ theorem summable_factorComplex {z : ℂ} (hz : ‖z‖ < 1) : Summable (fun n : ℕ => (factorCoeff n : ℂ)*z^n) := by have hg := hasSum_geometric_of_lt_one (norm_nonneg z) hz have hw := hasSum_coe_mul_geometric_of_norm_lt_one (r := ‖z‖) (by simpa using hz) apply Summable.of_norm_bounded ((hw.add hg).summable.mul_left (rho/(1-rho)^2)) intro n rw [norm_mul, Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg (factorCoeff_nonneg n), norm_pow] have h := mul_le_mul_of_nonneg_right (factorCoeff_upper n) (pow_nonneg (norm_nonneg z) n) nlinarith /- Original line 28460: Erdos416Proof.FordAnalysis.factorComplex_tail_one -/ theorem factorComplex_tail_one {z : ℂ} (hz : ‖z‖ < 1) : HasSum (fun n : ℕ => (factorCoeff (n+1) : ℂ)*z^(n+1)) (factorComplex z-1) := by simpa only [Finset.sum_range_one, factorCoeff_zero, Complex.ofReal_one, pow_zero, mul_one] using! (hasSum_nat_add_iff' 1).mpr (summable_factorComplex hz).hasSum /- Original line 28465: Erdos416Proof.FordAnalysis.factorComplex_tail_two -/ theorem factorComplex_tail_two {z : ℂ} (hz : ‖z‖ < 1) : HasSum (fun n : ℕ => (factorCoeff (n+2) : ℂ)*z^(n+2)) (factorComplex z-1-(factorCoeff 1 : ℂ)*z) := by convert! (hasSum_nat_add_iff' 2).mpr (summable_factorComplex hz).hasSum using 1 simp only [Finset.sum_range_succ, Finset.sum_range_zero, zero_add, factorCoeff_zero, Complex.ofReal_one, pow_zero, pow_one, mul_one] change factorComplex z-1-(factorCoeff 1 : ℂ)*z = factorComplex z-(1+(factorCoeff 1 : ℂ)*z) ring /- Original line 28475: Erdos416Proof.FordAnalysis.factorComplex_identity -/ theorem factorComplex_identity {z : ℂ} (hz : ‖z‖ < 1) : (1-z/(rho : ℂ))*factorComplex z = 1-FComplex z := by have hF : HasSum (fun n : ℕ => (coeff (n+1) : ℂ)*z^(n+1)) (FComplex z) := by simpa only [Finset.sum_range_one, coeff_zero, Complex.ofReal_zero, zero_mul, sub_zero] using! (hasSum_nat_add_iff' 1).mpr (summable_FComplex hz).hasSum have hs := (hF.add (factorComplex_tail_one hz)).mul_left (rho : ℂ) have hs' : HasSum (fun n : ℕ => z*((factorCoeff n : ℂ)*z^n)) ((rho : ℂ)*(FComplex z+(factorComplex z-1))) := by apply hs.congr_fun intro n have hr : (factorCoeff n : ℂ) = (rho : ℂ)*(coeff (n+1) : ℂ)+(rho : ℂ)*(factorCoeff (n+1) : ℂ) := by exact_mod_cast factorCoeff_rec n rw [hr, pow_succ] ring have he := ((summable_factorComplex hz).hasSum.mul_left z).unique hs' change z*factorComplex z = (rho : ℂ)*(FComplex z+(factorComplex z-1)) at he have hc : (1-z/(rho : ℂ))*(rho : ℂ) = (rho : ℂ)-z := by rw [sub_mul, one_mul, div_mul_cancel₀ _ rho_complex_ne_zero] apply mul_right_cancel₀ rho_complex_ne_zero rw [mul_right_comm, hc] linear_combination -he /- Original line 28498: Erdos416Proof.FordAnalysis.factorComplex_eq_renewalFactor -/ theorem factorComplex_eq_renewalFactor {z : ℂ} (hz : ‖z‖ < 1) (hne : z ≠ (rho : ℂ)) : factorComplex z = renewalFactor z := by have hd : 1-z/(rho : ℂ) ≠ 0 := by intro h have he : z/(rho : ℂ) = 1 := (sub_eq_zero.mp h).symm exact hne ((div_eq_one_iff_eq rho_complex_ne_zero).mp he) apply mul_left_cancel₀ hd rw [factorComplex_identity hz, renewalFactor_identity] /-- The nonnegative second-difference mass, evaluated as a complex series. -/ /- Original line 28508: Erdos416Proof.FordAnalysis.factorTailComplex -/ noncomputable def factorTailComplex (z : ℂ) : ℂ := ∑' n : ℕ, ((-factorDiff (n+2) : ℝ) : ℂ)*z^(n+2) /- Original line 28511: Erdos416Proof.FordAnalysis.factorTailComplex_term_bound -/ theorem factorTailComplex_term_bound {z : ℂ} (hz : ‖z‖ ≤ 1) (n : ℕ) : ‖((-factorDiff (n+2) : ℝ) : ℂ)*z^(n+2)‖ ≤ -factorDiff (n+2) := by have hn : 0 ≤ -factorDiff (n+2) := neg_nonneg.mpr (factorDiff_succ_nonpos (n+1)) rw [norm_mul, Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg hn, norm_pow] exact mul_le_of_le_one_right hn (pow_le_one₀ (norm_nonneg z) hz) /- Original line 28517: Erdos416Proof.FordAnalysis.summable_factorTailComplex -/ theorem summable_factorTailComplex {z : ℂ} (hz : ‖z‖ ≤ 1) : Summable (fun n : ℕ => ((-factorDiff (n+2) : ℝ) : ℂ)*z^(n+2)) := Summable.of_norm_bounded summable_factorDiff_tail (factorTailComplex_term_bound hz) /- Original line 28521: Erdos416Proof.FordAnalysis.factorTailComplex_norm_le -/ theorem factorTailComplex_norm_le {z : ℂ} (hz : ‖z‖ ≤ 1) : ‖factorTailComplex z‖ ≤ 1-renewalKappa := by exact (tsum_of_norm_bounded summable_factorDiff_tail.hasSum (factorTailComplex_term_bound hz)).trans factorDiff_tail_mass_le /- Original line 28526: Erdos416Proof.FordAnalysis.factorComplex_second_identity -/ theorem factorComplex_second_identity {z : ℂ} (hz : ‖z‖ < 1) : (1-z)^2*factorComplex z = 1-(renewalKappa : ℂ)*z-factorTailComplex z := by have hs := ((factorComplex_tail_two hz).sub ((factorComplex_tail_one hz).mul_left (2*z))).add ((summable_factorComplex hz).hasSum.mul_left (z^2)) have hs' : HasSum (fun n : ℕ => ((-factorDiff (n+2) : ℝ) : ℂ)*z^(n+2)) (-((factorComplex z-1-(factorCoeff 1 : ℂ)*z)- (2*z)*(factorComplex z-1)+z^2*factorComplex z)) := by apply hs.neg.congr_fun intro n simp only [factorDiff, Complex.ofReal_neg, Complex.ofReal_add, Complex.ofReal_sub, Complex.ofReal_mul, Complex.ofReal_ofNat] rw [show n+2=(n+1)+1 by omega, pow_succ, pow_succ] ring have he : factorTailComplex z = -((factorComplex z-1-(factorCoeff 1 : ℂ)*z)- (2*z)*(factorComplex z-1)+z^2*factorComplex z) := hs'.tsum_eq rw [he] have hc : (factorCoeff 1 : ℂ) = 2-(renewalKappa : ℂ) := by rw [factorCoeff_one] simp only [renewalKappa, Complex.ofReal_sub, Complex.ofReal_add, Complex.ofReal_div, Complex.ofReal_one, Complex.ofReal_ofNat] ring rw [hc] ring /- Original line 28553: Erdos416Proof.FordAnalysis.factorComplex_second_real_bound -/ theorem factorComplex_second_real_bound {z : ℂ} (hz : ‖z‖ < 1) : renewalKappa*(1-z.re) ≤ ((1-z)^2*factorComplex z).re := by rw [factorComplex_second_identity hz] have ht := (Complex.re_le_norm (factorTailComplex z)).trans (factorTailComplex_norm_le hz.le) simp only [Complex.sub_re, Complex.one_re, Complex.mul_re, Complex.ofReal_re, Complex.ofReal_im, zero_mul, sub_zero] nlinarith /- Original line 28561: Erdos416Proof.FordAnalysis.factorComplex_ne_zero -/ theorem factorComplex_ne_zero {z : ℂ} (hz : ‖z‖ < 1) : factorComplex z ≠ 0 := by have hp : 0 < renewalKappa*(1-z.re) := mul_pos (by linarith [half_lt_renewalKappa]) (sub_pos.mpr ((Complex.re_le_norm z).trans_lt hz)) intro h have hb := factorComplex_second_real_bound hz rw [h, mul_zero, Complex.zero_re] at hb linarith /- Original line 28569: Erdos416Proof.FordAnalysis.one_sub_norm_sq_le -/ theorem one_sub_norm_sq_le {z : ℂ} (hz : ‖z‖ ≤ 1) : ‖1-z‖^2 ≤ 2*(1-z.re) := by have hsq : ‖z‖^2 ≤ 1 := by nlinarith [norm_nonneg z] rw [Complex.sq_norm, Complex.normSq_apply] at hsq ⊢ simp only [Complex.sub_re, Complex.one_re, Complex.sub_im, Complex.one_im] nlinarith /- Original line 28576: Erdos416Proof.FordAnalysis.factorComplex_inv_norm_le -/ theorem factorComplex_inv_norm_le {z : ℂ} (hz : ‖z‖ < 1) : ‖(factorComplex z)⁻¹‖ ≤ 2/renewalKappa := by have hk : 0 < renewalKappa := by linarith [half_lt_renewalKappa] have ha : 0 < 1-z.re := sub_pos.mpr ((Complex.re_le_norm z).trans_lt hz) have h1 := (factorComplex_second_real_bound hz).trans (Complex.re_le_norm ((1-z)^2*factorComplex z)) rw [norm_mul, norm_pow] at h1 have h2 := mul_le_mul_of_nonneg_right (one_sub_norm_sq_le hz.le) (norm_nonneg (factorComplex z)) have hh : renewalKappa ≤ 2*‖factorComplex z‖ := by nlinarith rw [norm_inv, inv_eq_one_div] exact (div_le_div_iff₀ (norm_pos_iff.mpr (factorComplex_ne_zero hz)) hk).mpr (by simpa using hh) /- Original line 28588: Erdos416Proof.FordAnalysis.renewalFactor_ne_zero_unit -/ theorem renewalFactor_ne_zero_unit {z : ℂ} (hz : ‖z‖ < 1) : renewalFactor z ≠ 0 := by by_cases he : z = (rho : ℂ) · simpa only [he] using renewalFactor_rho_ne_zero · rw [← factorComplex_eq_renewalFactor hz he] exact factorComplex_ne_zero hz /- Original line 28594: Erdos416Proof.FordAnalysis.renewalFactor_inv_norm_lt -/ theorem renewalFactor_inv_norm_lt {z : ℂ} (hz : ‖z‖ < 1) : ‖(renewalFactor z)⁻¹‖ < 37/10 := by by_cases he : z = (rho : ℂ) · rw [he, inv_renewalFactor_rho, Complex.norm_real, Real.norm_eq_abs, abs_of_pos lambda_pos] linarith [lambda_numeric_bounds.2] · rw [← factorComplex_eq_renewalFactor hz he] exact (factorComplex_inv_norm_le hz).trans_lt two_div_renewalKappa_lt /- Original line 28602: Erdos416Proof.FordAnalysis.renewalError_quotient -/ theorem renewalError_quotient {z : ℂ} (hz : z ≠ (rho : ℂ)) : renewalError z = ((renewalFactor z)⁻¹-(lambda : ℂ))/(1-z/(rho : ℂ)) := by have hsub : z-(rho : ℂ) ≠ 0 := sub_ne_zero.mpr hz rw [renewalError, dslope_of_ne _ hz, slope_def_field, inv_renewalFactor_rho] have hden : 1-z/(rho : ℂ) = -(z-(rho : ℂ))/(rho : ℂ) := by rw [neg_sub, sub_div, div_self rho_complex_ne_zero] rw [hden] field_simp [rho_complex_ne_zero, hsub] /- Original line 28612: Erdos416Proof.FordAnalysis.renewalError_circle_bound -/ theorem renewalError_circle_bound {R : ℝ} (hρR : rho < R) (hR : R < 1) {z : ℂ} (hz : ‖z‖ = R) : ‖renewalError z‖ ≤ (37/10+lambda)/(R/rho-1) := by have hzne : z ≠ (rho : ℂ) := by intro he rw [he, Complex.norm_real, Real.norm_eq_abs, abs_of_pos rho_pos] at hz linarith have hd : 0 < R/rho-1 := sub_pos.mpr ((one_lt_div rho_pos).mpr hρR) have hden : R/rho-1 ≤ ‖1-z/(rho : ℂ)‖ := by have h := norm_sub_norm_le (z/(rho : ℂ)) 1 simpa only [norm_div, Complex.norm_real, Real.norm_eq_abs, abs_of_pos rho_pos, hz, norm_one, norm_sub_rev] using h have hnum : ‖(renewalFactor z)⁻¹-(lambda : ℂ)‖ ≤ 37/10+lambda := by calc _ ≤ ‖(renewalFactor z)⁻¹‖+‖(lambda : ℂ)‖ := norm_sub_le _ _ _ ≤ _ := by rw [Complex.norm_real, Real.norm_eq_abs, abs_of_pos lambda_pos] exact add_le_add (renewalFactor_inv_norm_lt (hz.trans_lt hR)).le le_rfl rw [renewalError_quotient hzne, norm_div] exact (div_le_div_of_nonneg_right hnum (norm_nonneg _)).trans (div_le_div_of_nonneg_left (by linarith [lambda_pos]) hd hden) /- Original line 28634: Erdos416Proof.FordAnalysis.renewalError_cauchy_bound -/ theorem renewalError_cauchy_bound {R : ℝ} (hρR : rho < R) (hR : R < 1) (n : ℕ) : |renewalErrorCoeff n| ≤ ((37/10+lambda)/(R/rho-1))/R^n := by have hR0 : 0 < R := rho_pos.trans hρR have hd := renewalError_differentiableOn hρR hR (fun z hz => renewalFactor_ne_zero_unit (hz.trans_lt hR)) let Rn : ℝ≥0 := ⟨R, hR0.le⟩ have hc := hd.hasFPowerSeriesOnBall (R := Rn) (by exact hR0) have he := renewalError_hasFPowerSeriesAt.eq_formalMultilinearSeries hc.hasFPowerSeriesAt let M : ℝ := (37/10+lambda)/(R/rho-1) have hf : Continuous (fun θ : ℝ => renewalError (circleMap 0 R θ)) := hd.continuousOn.comp_continuous (continuous_circleMap 0 R) (circleMap_mem_closedBall 0 hR0.le) have hint : (∫ θ : ℝ in 0..2*Real.pi, ‖renewalError (circleMap 0 R θ)‖) ≤ 2*Real.pi*M := by calc _ ≤ ∫ θ : ℝ in 0..2*Real.pi, M := by apply intervalIntegral.integral_mono_on Real.two_pi_pos.le (hf.norm.intervalIntegrable _ _) intervalIntegrable_const intro θ _ exact renewalError_circle_bound hρR hR (by simp [Erdos416Proof.FordAnalysis.renewalErrorSeries_coeff, hR0.le, abs_of_nonneg]) _ = _ := by simp[Erdos416Proof.FordAnalysis.renewalErrorSeries_coeff] have hav : (2*Real.pi)⁻¹*(∫ θ : ℝ in 0..2*Real.pi, ‖renewalError (circleMap 0 R θ)‖) ≤ M := by calc _ ≤ (2*Real.pi)⁻¹*(2*Real.pi*M) := mul_le_mul_of_nonneg_left hint (inv_nonneg.mpr Real.two_pi_pos.le) _ = M := by rw [inv_mul_cancel_left₀ Real.two_pi_pos.ne'] calc |renewalErrorCoeff n| = ‖renewalErrorSeries n‖ := by rw [FormalMultilinearSeries.norm_apply_eq_norm_coef, renewalErrorSeries_coeff, Complex.norm_real, Real.norm_eq_abs] _ = ‖cauchyPowerSeries renewalError 0 R n‖ := by rw [he]; rfl _ ≤ ((2*Real.pi)⁻¹*(∫ θ : ℝ in 0..2*Real.pi, ‖renewalError (circleMap 0 R θ)‖))*|R|⁻¹^n := norm_cauchyPowerSeries_le _ _ _ _ _ ≤ M*|R|⁻¹^n := mul_le_mul_of_nonneg_right hav (pow_nonneg (inv_nonneg.mpr (abs_nonneg R)) _) _ = ((37/10+lambda)/(R/rho-1))/R^n := by rw [abs_of_pos hR0, inv_pow]; rfl /-- The radii stay strictly inside the analytic disk and tend to its boundary. -/ /- Original line 28669: Erdos416Proof.FordAnalysis.renewalRadius -/ noncomputable def renewalRadius (m : ℕ) : ℝ := 1-(1-rho)/((m : ℝ)+2) /- Original line 28671: Erdos416Proof.FordAnalysis.renewalRadius_bounds -/ theorem renewalRadius_bounds (m : ℕ) : rho < renewalRadius m ∧ renewalRadius m < 1 := by have hmp : 0 < (m : ℝ)+2 := by positivity have hm1 : 1 < (m : ℝ)+2 := by linarith [(Nat.cast_nonneg m : (0 : ℝ) ≤ m)] have hp : 0 < 1-rho := sub_pos.mpr rho_lt_one have hq := div_lt_self hp hm1 have hq0 := div_pos hp hmp dsimp only [renewalRadius] constructor <;> linarith /- Original line 28680: Erdos416Proof.FordAnalysis.renewalRadius_tendsto -/ theorem renewalRadius_tendsto : Tendsto renewalRadius atTop (nhds 1) := by have ht : Tendsto (fun m : ℕ => (m : ℝ)+2) atTop atTop := tendsto_atTop_add_const_right _ _ tendsto_natCast_atTop_atTop have hd : Tendsto (fun m : ℕ => (1-rho)/((m : ℝ)+2)) atTop (nhds 0) := tendsto_const_nhds.div_atTop ht change Tendsto (fun m : ℕ => 1-(1-rho)/((m : ℝ)+2)) atTop (nhds 1) simpa only [sub_zero] using tendsto_const_nhds.sub hd /- Original line 28688: Erdos416Proof.FordAnalysis.renewalError_uniform_bound -/ theorem renewalError_uniform_bound (n : ℕ) : |renewalErrorCoeff n| ≤ (37/10+lambda)/(rho⁻¹-1) := by have hd : (1 : ℝ)/rho-1 ≠ 0 := by apply ne_of_gt have h := (one_lt_div rho_pos).mpr rho_lt_one linarith have ht : Tendsto (fun m : ℕ => ((37/10+lambda)/(renewalRadius m/rho-1))/(renewalRadius m)^n) atTop (nhds ((37/10+lambda)/(rho⁻¹-1))) := by have hnum : Tendsto (fun _ : ℕ => (37/10 : ℝ)+lambda) atTop (nhds ((37/10 : ℝ)+lambda)) := tendsto_const_nhds have h := (hnum.div ((renewalRadius_tendsto.div_const rho).sub_const 1) hd).div (renewalRadius_tendsto.pow n) (by simp[Erdos416Proof.FordAnalysis.renewalErrorSeries_coeff] ) simpa only [one_pow, div_one, one_div, Pi.div_apply] using! h exact ge_of_tendsto ht (Filter.Eventually.of_forall fun m => renewalError_cauchy_bound (renewalRadius_bounds m).1 (renewalRadius_bounds m).2 n) /-- Ford's uniform absolute renewal error bound, proved from the actual recurrence. -/ /- Original line 28706: Erdos416Proof.FordAnalysis.renewalError_abs_lt_five -/ theorem renewalError_abs_lt_five (n : ℕ) : |g n-lambda/rho^n| < 5 := (renewalError_uniform_bound n).trans_lt renewal_boundary_constant_lt_five end Erdos416Proof.FordAnalysis /- Uniform numerical comparisons for the ordered volume, using actual finite recurrence certificates and the absolute renewal estimate. -/ open Filter Finset open scoped Topology BigOperators Classical namespace Erdos416Proof.FordAnalysis /- Original line 28723: Erdos416Proof.FordAnalysis.rationalGLower -/ def rationalGLower (n : ℕ) : ℚ := (([100000000, 38629434, 105876572, 200968678, 372394809, 687278009, 1267188173, 2335752657, 4304988692, 7934190900, 14622706141, 26949497105, 49667542944, 91536500408, 168700266297, 310911766792, 573005138547, 1056038762872, 1946261518651, 3586926923933, 6610645378370] : List ℚ).getD n 0)/100000000 /- Original line 28726: Erdos416Proof.FordAnalysis.rationalGUpper -/ def rationalGUpper (n : ℕ) : ℚ := (([100000000, 38629440, 105876593, 200968726, 372394918, 687278249, 1267188687, 2335753737, 4304990925, 7934195465, 14622715382, 26949515660, 49667579951, 91536573791, 168700411085, 310912051224, 573005695171, 1056039848470, 1946263629507, 3586931017150, 6610653296122] : List ℚ).getD n 0)/100000000 /- Original line 28730: Erdos416Proof.FordAnalysis.rationalG_nonneg -/ theorem rationalG_nonneg {n : ℕ} (hn : n ≤ 20) : 0 ≤ (rationalGLower n : ℝ) ∧ 0 ≤ (rationalGUpper n : ℝ) := by interval_cases n <;> norm_num [rationalGLower, rationalGUpper] /- Original line 28735: Erdos416Proof.FordAnalysis.rationalG_recurrence_certificate -/ private theorem rationalG_recurrence_case_0 : (rationalGLower ((0 : ℕ)+1) : ℝ) ≤ ∑ idx ∈ range ((0 : ℕ)+1), (rationalCoeffLower (idx+1) : ℝ)*(rationalGLower ((0 : ℕ)-idx) : ℝ) ∧ (∑ idx ∈ range ((0 : ℕ)+1), (rationalCoeffUpper (idx+1) : ℝ)*(rationalGUpper ((0 : ℕ)-idx) : ℝ)) ≤ (rationalGUpper ((0 : ℕ)+1) : ℝ) := by norm_num [rationalGLower, rationalGUpper, rationalCoeffLower, rationalCoeffUpper, rationalLogBounds, Finset.sum_range_succ] private theorem rationalG_recurrence_case_1 : (rationalGLower ((1 : ℕ)+1) : ℝ) ≤ ∑ idx ∈ range ((1 : ℕ)+1), (rationalCoeffLower (idx+1) : ℝ)*(rationalGLower ((1 : ℕ)-idx) : ℝ) ∧ (∑ idx ∈ range ((1 : ℕ)+1), (rationalCoeffUpper (idx+1) : ℝ)*(rationalGUpper ((1 : ℕ)-idx) : ℝ)) ≤ (rationalGUpper ((1 : ℕ)+1) : ℝ) := by norm_num [rationalGLower, rationalGUpper, rationalCoeffLower, rationalCoeffUpper, rationalLogBounds, Finset.sum_range_succ] private theorem rationalG_recurrence_case_2 : (rationalGLower ((2 : ℕ)+1) : ℝ) ≤ ∑ idx ∈ range ((2 : ℕ)+1), (rationalCoeffLower (idx+1) : ℝ)*(rationalGLower ((2 : ℕ)-idx) : ℝ) ∧ (∑ idx ∈ range ((2 : ℕ)+1), (rationalCoeffUpper (idx+1) : ℝ)*(rationalGUpper ((2 : ℕ)-idx) : ℝ)) ≤ (rationalGUpper ((2 : ℕ)+1) : ℝ) := by norm_num [rationalGLower, rationalGUpper, rationalCoeffLower, rationalCoeffUpper, rationalLogBounds, Finset.sum_range_succ] private theorem rationalG_recurrence_case_3 : (rationalGLower ((3 : ℕ)+1) : ℝ) ≤ ∑ idx ∈ range ((3 : ℕ)+1), (rationalCoeffLower (idx+1) : ℝ)*(rationalGLower ((3 : ℕ)-idx) : ℝ) ∧ (∑ idx ∈ range ((3 : ℕ)+1), (rationalCoeffUpper (idx+1) : ℝ)*(rationalGUpper ((3 : ℕ)-idx) : ℝ)) ≤ (rationalGUpper ((3 : ℕ)+1) : ℝ) := by norm_num [rationalGLower, rationalGUpper, rationalCoeffLower, rationalCoeffUpper, rationalLogBounds, Finset.sum_range_succ] private theorem rationalG_recurrence_case_4 : (rationalGLower ((4 : ℕ)+1) : ℝ) ≤ ∑ idx ∈ range ((4 : ℕ)+1), (rationalCoeffLower (idx+1) : ℝ)*(rationalGLower ((4 : ℕ)-idx) : ℝ) ∧ (∑ idx ∈ range ((4 : ℕ)+1), (rationalCoeffUpper (idx+1) : ℝ)*(rationalGUpper ((4 : ℕ)-idx) : ℝ)) ≤ (rationalGUpper ((4 : ℕ)+1) : ℝ) := by norm_num [rationalGLower, rationalGUpper, rationalCoeffLower, rationalCoeffUpper, rationalLogBounds, Finset.sum_range_succ] private theorem rationalG_recurrence_case_5 : (rationalGLower ((5 : ℕ)+1) : ℝ) ≤ ∑ idx ∈ range ((5 : ℕ)+1), (rationalCoeffLower (idx+1) : ℝ)*(rationalGLower ((5 : ℕ)-idx) : ℝ) ∧ (∑ idx ∈ range ((5 : ℕ)+1), (rationalCoeffUpper (idx+1) : ℝ)*(rationalGUpper ((5 : ℕ)-idx) : ℝ)) ≤ (rationalGUpper ((5 : ℕ)+1) : ℝ) := by norm_num [rationalGLower, rationalGUpper, rationalCoeffLower, rationalCoeffUpper, rationalLogBounds, Finset.sum_range_succ] private theorem rationalG_recurrence_case_6 : (rationalGLower ((6 : ℕ)+1) : ℝ) ≤ ∑ idx ∈ range ((6 : ℕ)+1), (rationalCoeffLower (idx+1) : ℝ)*(rationalGLower ((6 : ℕ)-idx) : ℝ) ∧ (∑ idx ∈ range ((6 : ℕ)+1), (rationalCoeffUpper (idx+1) : ℝ)*(rationalGUpper ((6 : ℕ)-idx) : ℝ)) ≤ (rationalGUpper ((6 : ℕ)+1) : ℝ) := by norm_num [rationalGLower, rationalGUpper, rationalCoeffLower, rationalCoeffUpper, rationalLogBounds, Finset.sum_range_succ] private theorem rationalG_recurrence_case_7 : (rationalGLower ((7 : ℕ)+1) : ℝ) ≤ ∑ idx ∈ range ((7 : ℕ)+1), (rationalCoeffLower (idx+1) : ℝ)*(rationalGLower ((7 : ℕ)-idx) : ℝ) ∧ (∑ idx ∈ range ((7 : ℕ)+1), (rationalCoeffUpper (idx+1) : ℝ)*(rationalGUpper ((7 : ℕ)-idx) : ℝ)) ≤ (rationalGUpper ((7 : ℕ)+1) : ℝ) := by norm_num [rationalGLower, rationalGUpper, rationalCoeffLower, rationalCoeffUpper, rationalLogBounds, Finset.sum_range_succ] private theorem rationalG_recurrence_case_8 : (rationalGLower ((8 : ℕ)+1) : ℝ) ≤ ∑ idx ∈ range ((8 : ℕ)+1), (rationalCoeffLower (idx+1) : ℝ)*(rationalGLower ((8 : ℕ)-idx) : ℝ) ∧ (∑ idx ∈ range ((8 : ℕ)+1), (rationalCoeffUpper (idx+1) : ℝ)*(rationalGUpper ((8 : ℕ)-idx) : ℝ)) ≤ (rationalGUpper ((8 : ℕ)+1) : ℝ) := by norm_num [rationalGLower, rationalGUpper, rationalCoeffLower, rationalCoeffUpper, rationalLogBounds, Finset.sum_range_succ] private theorem rationalG_recurrence_case_9 : (rationalGLower ((9 : ℕ)+1) : ℝ) ≤ ∑ idx ∈ range ((9 : ℕ)+1), (rationalCoeffLower (idx+1) : ℝ)*(rationalGLower ((9 : ℕ)-idx) : ℝ) ∧ (∑ idx ∈ range ((9 : ℕ)+1), (rationalCoeffUpper (idx+1) : ℝ)*(rationalGUpper ((9 : ℕ)-idx) : ℝ)) ≤ (rationalGUpper ((9 : ℕ)+1) : ℝ) := by norm_num [rationalGLower, rationalGUpper, rationalCoeffLower, rationalCoeffUpper, rationalLogBounds, Finset.sum_range_succ] private theorem rationalG_recurrence_case_10 : (rationalGLower ((10 : ℕ)+1) : ℝ) ≤ ∑ idx ∈ range ((10 : ℕ)+1), (rationalCoeffLower (idx+1) : ℝ)*(rationalGLower ((10 : ℕ)-idx) : ℝ) ∧ (∑ idx ∈ range ((10 : ℕ)+1), (rationalCoeffUpper (idx+1) : ℝ)*(rationalGUpper ((10 : ℕ)-idx) : ℝ)) ≤ (rationalGUpper ((10 : ℕ)+1) : ℝ) := by norm_num [rationalGLower, rationalGUpper, rationalCoeffLower, rationalCoeffUpper, rationalLogBounds, Finset.sum_range_succ] private theorem rationalG_recurrence_case_11 : (rationalGLower ((11 : ℕ)+1) : ℝ) ≤ ∑ idx ∈ range ((11 : ℕ)+1), (rationalCoeffLower (idx+1) : ℝ)*(rationalGLower ((11 : ℕ)-idx) : ℝ) ∧ (∑ idx ∈ range ((11 : ℕ)+1), (rationalCoeffUpper (idx+1) : ℝ)*(rationalGUpper ((11 : ℕ)-idx) : ℝ)) ≤ (rationalGUpper ((11 : ℕ)+1) : ℝ) := by norm_num [rationalGLower, rationalGUpper, rationalCoeffLower, rationalCoeffUpper, rationalLogBounds, Finset.sum_range_succ] private theorem rationalG_recurrence_case_12 : (rationalGLower ((12 : ℕ)+1) : ℝ) ≤ ∑ idx ∈ range ((12 : ℕ)+1), (rationalCoeffLower (idx+1) : ℝ)*(rationalGLower ((12 : ℕ)-idx) : ℝ) ∧ (∑ idx ∈ range ((12 : ℕ)+1), (rationalCoeffUpper (idx+1) : ℝ)*(rationalGUpper ((12 : ℕ)-idx) : ℝ)) ≤ (rationalGUpper ((12 : ℕ)+1) : ℝ) := by norm_num [rationalGLower, rationalGUpper, rationalCoeffLower, rationalCoeffUpper, rationalLogBounds, Finset.sum_range_succ] private theorem rationalG_recurrence_case_13 : (rationalGLower ((13 : ℕ)+1) : ℝ) ≤ ∑ idx ∈ range ((13 : ℕ)+1), (rationalCoeffLower (idx+1) : ℝ)*(rationalGLower ((13 : ℕ)-idx) : ℝ) ∧ (∑ idx ∈ range ((13 : ℕ)+1), (rationalCoeffUpper (idx+1) : ℝ)*(rationalGUpper ((13 : ℕ)-idx) : ℝ)) ≤ (rationalGUpper ((13 : ℕ)+1) : ℝ) := by norm_num [rationalGLower, rationalGUpper, rationalCoeffLower, rationalCoeffUpper, rationalLogBounds, Finset.sum_range_succ] private theorem rationalG_recurrence_case_14 : (rationalGLower ((14 : ℕ)+1) : ℝ) ≤ ∑ idx ∈ range ((14 : ℕ)+1), (rationalCoeffLower (idx+1) : ℝ)*(rationalGLower ((14 : ℕ)-idx) : ℝ) ∧ (∑ idx ∈ range ((14 : ℕ)+1), (rationalCoeffUpper (idx+1) : ℝ)*(rationalGUpper ((14 : ℕ)-idx) : ℝ)) ≤ (rationalGUpper ((14 : ℕ)+1) : ℝ) := by norm_num [rationalGLower, rationalGUpper, rationalCoeffLower, rationalCoeffUpper, rationalLogBounds, Finset.sum_range_succ] private theorem rationalG_recurrence_case_15 : (rationalGLower ((15 : ℕ)+1) : ℝ) ≤ ∑ idx ∈ range ((15 : ℕ)+1), (rationalCoeffLower (idx+1) : ℝ)*(rationalGLower ((15 : ℕ)-idx) : ℝ) ∧ (∑ idx ∈ range ((15 : ℕ)+1), (rationalCoeffUpper (idx+1) : ℝ)*(rationalGUpper ((15 : ℕ)-idx) : ℝ)) ≤ (rationalGUpper ((15 : ℕ)+1) : ℝ) := by norm_num [rationalGLower, rationalGUpper, rationalCoeffLower, rationalCoeffUpper, rationalLogBounds, Finset.sum_range_succ] private theorem rationalG_recurrence_case_16 : (rationalGLower ((16 : ℕ)+1) : ℝ) ≤ ∑ idx ∈ range ((16 : ℕ)+1), (rationalCoeffLower (idx+1) : ℝ)*(rationalGLower ((16 : ℕ)-idx) : ℝ) ∧ (∑ idx ∈ range ((16 : ℕ)+1), (rationalCoeffUpper (idx+1) : ℝ)*(rationalGUpper ((16 : ℕ)-idx) : ℝ)) ≤ (rationalGUpper ((16 : ℕ)+1) : ℝ) := by norm_num [rationalGLower, rationalGUpper, rationalCoeffLower, rationalCoeffUpper, rationalLogBounds, Finset.sum_range_succ] private theorem rationalG_recurrence_case_17 : (rationalGLower ((17 : ℕ)+1) : ℝ) ≤ ∑ idx ∈ range ((17 : ℕ)+1), (rationalCoeffLower (idx+1) : ℝ)*(rationalGLower ((17 : ℕ)-idx) : ℝ) ∧ (∑ idx ∈ range ((17 : ℕ)+1), (rationalCoeffUpper (idx+1) : ℝ)*(rationalGUpper ((17 : ℕ)-idx) : ℝ)) ≤ (rationalGUpper ((17 : ℕ)+1) : ℝ) := by norm_num [rationalGLower, rationalGUpper, rationalCoeffLower, rationalCoeffUpper, rationalLogBounds, Finset.sum_range_succ] private theorem rationalG_recurrence_case_18 : (rationalGLower ((18 : ℕ)+1) : ℝ) ≤ ∑ idx ∈ range ((18 : ℕ)+1), (rationalCoeffLower (idx+1) : ℝ)*(rationalGLower ((18 : ℕ)-idx) : ℝ) ∧ (∑ idx ∈ range ((18 : ℕ)+1), (rationalCoeffUpper (idx+1) : ℝ)*(rationalGUpper ((18 : ℕ)-idx) : ℝ)) ≤ (rationalGUpper ((18 : ℕ)+1) : ℝ) := by norm_num [rationalGLower, rationalGUpper, rationalCoeffLower, rationalCoeffUpper, rationalLogBounds, Finset.sum_range_succ] private theorem rationalG_recurrence_case_19 : (rationalGLower ((19 : ℕ)+1) : ℝ) ≤ ∑ idx ∈ range ((19 : ℕ)+1), (rationalCoeffLower (idx+1) : ℝ)*(rationalGLower ((19 : ℕ)-idx) : ℝ) ∧ (∑ idx ∈ range ((19 : ℕ)+1), (rationalCoeffUpper (idx+1) : ℝ)*(rationalGUpper ((19 : ℕ)-idx) : ℝ)) ≤ (rationalGUpper ((19 : ℕ)+1) : ℝ) := by norm_num [rationalGLower, rationalGUpper, rationalCoeffLower, rationalCoeffUpper, rationalLogBounds, Finset.sum_range_succ] theorem rationalG_recurrence_certificate {n : ℕ} (hn : n < 20) : (rationalGLower (n+1) : ℝ) ≤ ∑ idx ∈ range (n+1), (rationalCoeffLower (idx+1) : ℝ)*(rationalGLower (n-idx) : ℝ) ∧ (∑ idx ∈ range (n+1), (rationalCoeffUpper (idx+1) : ℝ)*(rationalGUpper (n-idx) : ℝ)) ≤ (rationalGUpper (n+1) : ℝ) := by interval_cases n · exact rationalG_recurrence_case_0 · exact rationalG_recurrence_case_1 · exact rationalG_recurrence_case_2 · exact rationalG_recurrence_case_3 · exact rationalG_recurrence_case_4 · exact rationalG_recurrence_case_5 · exact rationalG_recurrence_case_6 · exact rationalG_recurrence_case_7 · exact rationalG_recurrence_case_8 · exact rationalG_recurrence_case_9 · exact rationalG_recurrence_case_10 · exact rationalG_recurrence_case_11 · exact rationalG_recurrence_case_12 · exact rationalG_recurrence_case_13 · exact rationalG_recurrence_case_14 · exact rationalG_recurrence_case_15 · exact rationalG_recurrence_case_16 · exact rationalG_recurrence_case_17 · exact rationalG_recurrence_case_18 · exact rationalG_recurrence_case_19 /- Original line 28744: Erdos416Proof.FordAnalysis.g_table_bounds -/ theorem g_table_bounds {n : ℕ} (hn : n ≤ 20) : (rationalGLower n : ℝ) ≤ g n ∧ g n ≤ (rationalGUpper n : ℝ) := by induction n using Nat.strong_induction_on with | h n ih => cases n with | zero => norm_num [Erdos416Proof.FordAnalysis.g_zero, Erdos416Proof.FordAnalysis.gStar_zero, rationalGLower, rationalGUpper] | succ n => have hcert := rationalG_recurrence_certificate (by omega : n < 20) rw [g_succ] constructor · apply hcert.1.trans apply Finset.sum_le_sum intro idx hi have hi' := Finset.mem_range.mp hi exact mul_le_mul (coeff_table_bounds (by omega : idx+1 ≤ 32)).1 (ih (n-idx) (by omega) (by omega)).1 (rationalG_nonneg (by omega : n-idx ≤ 20)).1 (coeff_bounds _).1 · apply le_trans _ hcert.2 apply Finset.sum_le_sum intro idx hi have hi' := Finset.mem_range.mp hi exact mul_le_mul (coeff_table_bounds (by omega : idx+1 ≤ 32)).2 (ih (n-idx) (by omega) (by omega)).2 (g_pos _).le ((coeff_bounds _).1.trans (coeff_table_bounds (by omega : idx+1 ≤ 32)).2) /- Original line 28770: Erdos416Proof.FordAnalysis.g_prefix_numeric_certificate -/ theorem g_prefix_numeric_certificate {n : ℕ} (hn0 : 1 ≤ n) (hn1 : n < 20) : (rationalGUpper n : ℝ)*(2713/5000 : ℝ)^n < 17/50 ∧ (2 ≤ n → (31/100 : ℝ) < (rationalGLower n : ℝ)*(217/400 : ℝ)^n ∧ 0 < (rationalGLower n : ℝ)-(rationalGUpper (n-1) : ℝ) ∧ (147/1000 : ℝ) < ((rationalGLower n : ℝ)-(rationalGUpper (n-1) : ℝ))*(217/400 : ℝ)^n) := by interval_cases n <;> norm_num [rationalGLower, rationalGUpper] /- Original line 28777: Erdos416Proof.FordAnalysis.g_scaled_error_bounds -/ theorem g_scaled_error_bounds (n : ℕ) : lambda-5*rho^n ≤ g n*rho^n ∧ g n*rho^n ≤ lambda+5*rho^n := by have h := mul_le_mul_of_nonneg_right (renewalError_abs_lt_five n).le (pow_pos rho_pos n).le have he : (g n-lambda/rho^n)*rho^n = g n*rho^n-lambda := by rw [sub_mul, div_mul_cancel₀ _ (pow_pos rho_pos n).ne'] have ha : |g n*rho^n-lambda| = |g n-lambda/rho^n| * rho^n := by rw [← he, abs_mul, abs_of_pos (pow_pos rho_pos n)] rw [← ha] at h have ha := abs_le.mp h constructor <;> linarith /- Original line 28788: Erdos416Proof.FordAnalysis.renewalStep_scaled_lower -/ theorem renewalStep_scaled_lower (n : ℕ) : lambda*(1-rho)-10*rho^(n+1) ≤ (g (n+1)-g n)*rho^(n+1) := by have h1 := (abs_le.mp (renewalError_abs_lt_five (n+1)).le).1 have h0 := (abs_le.mp (renewalError_abs_lt_five n).le).2 have hdiff : lambda/rho^(n+1)-lambda/rho^n-10 ≤ g (n+1)-g n := by linarith have h := mul_le_mul_of_nonneg_right hdiff (pow_pos rho_pos (n+1)).le have he : (lambda/rho^(n+1)-lambda/rho^n-10)*rho^(n+1) = lambda*(1-rho)-10*rho^(n+1) := by rw [sub_mul, sub_mul, div_mul_cancel₀ _ (pow_pos rho_pos (n+1)).ne', pow_succ, ← mul_assoc, div_mul_cancel₀ _ (pow_pos rho_pos n).ne'] ring rwa [he] at h /- Original line 28801: Erdos416Proof.FordAnalysis.rho_power_twenty_bound -/ theorem rho_power_twenty_bound {n : ℕ} (hn : 20 ≤ n) : rho^n ≤ (2713/5000 : ℝ)^20 := (pow_le_pow_of_le_one rho_pos.le rho_lt_one.le hn).trans (pow_le_pow_left₀ rho_pos.le rho_numeric_bounds.2.le 20) /- Original line 28806: Erdos416Proof.FordAnalysis.g_scaled_uniform_upper -/ theorem g_scaled_uniform_upper {n : ℕ} (hn : 1 ≤ n) : g n*rho^n < 17/50 := by by_cases hlarge : 20 ≤ n · have hg := (g_scaled_error_bounds n).2 have hp := rho_power_twenty_bound hlarge have hnum : (1/3 : ℝ)+5*(2713/5000 : ℝ)^20 < 17/50 := by norm_num linarith [lambda_numeric_bounds.2] · have hcert := (g_prefix_numeric_certificate hn (by omega)).1 apply lt_of_le_of_lt _ hcert exact mul_le_mul (g_table_bounds (by omega : n ≤ 20)).2 (pow_le_pow_left₀ rho_pos.le rho_numeric_bounds.2.le n) (pow_pos rho_pos n).le (rationalG_nonneg (by omega : n ≤ 20)).2 /- Original line 28818: Erdos416Proof.FordAnalysis.g_scaled_uniform_lower -/ theorem g_scaled_uniform_lower {n : ℕ} (hn : 2 ≤ n) : (31/100 : ℝ) < g n*rho^n := by by_cases hlarge : 20 ≤ n · have hg := (g_scaled_error_bounds n).1 have hp := rho_power_twenty_bound hlarge have hnum : (31/100 : ℝ) < 161/500-5*(2713/5000 : ℝ)^20 := by norm_num linarith [lambda_numeric_bounds.1] · have hcert := ((g_prefix_numeric_certificate (by omega : 1 ≤ n) (by omega)).2 hn).1 apply lt_of_lt_of_le hcert exact mul_le_mul (g_table_bounds (by omega : n ≤ 20)).1 (pow_le_pow_left₀ (by norm_num : (0 : ℝ) ≤ 217/400) rho_numeric_bounds.1.le n) (by positivity) (g_pos n).le /- Original line 28830: Erdos416Proof.FordAnalysis.renewalStep -/ noncomputable def renewalStep (n : ℕ) : ℝ := g n-g (n-1) /- Original line 28832: Erdos416Proof.FordAnalysis.renewalStep_uniform_lower -/ theorem renewalStep_uniform_lower {n : ℕ} (hn : 2 ≤ n) : (147/1000 : ℝ) < renewalStep n*rho^n := by by_cases hlarge : 20 ≤ n · have hg := renewalStep_scaled_lower (n-1) rw [Nat.sub_add_cancel (by omega : 1 ≤ n)] at hg have hp := rho_power_twenty_bound hlarge have hl : (161/500 : ℝ)*(1-2713/5000) < lambda*(1-rho) := by calc _ < lambda*(1-2713/5000) := mul_lt_mul_of_pos_right lambda_numeric_bounds.1 (by norm_num) _ ≤ _ := mul_le_mul_of_nonneg_left (by linarith [rho_numeric_bounds.2]) lambda_pos.le have hnum : (147/1000 : ℝ) < (161/500)*(1-2713/5000)-10*(2713/5000 : ℝ)^20 := by norm_num dsimp only [renewalStep] linarith · have hc := (g_prefix_numeric_certificate (by omega : 1 ≤ n) (by omega)).2 hn have hg : (rationalGLower n : ℝ)-(rationalGUpper (n-1) : ℝ) ≤ renewalStep n := sub_le_sub (g_table_bounds (by omega : n ≤ 20)).1 (g_table_bounds (by omega : n-1 ≤ 20)).2 apply hc.2.2.trans_le exact mul_le_mul hg (pow_le_pow_left₀ (by norm_num : (0 : ℝ) ≤ 217/400) rho_numeric_bounds.1.le n) (by positivity) (hc.2.1.le.trans hg) /- Original line 28855: Erdos416Proof.FordAnalysis.order_denominator_pos -/ theorem order_denominator_pos : 0 < rho*(1-coeff 1) := mul_pos rho_pos (sub_pos.mpr coeff_one_lt_one) /- Original line 28858: Erdos416Proof.FordAnalysis.order_denominator_lt_third -/ theorem order_denominator_lt_third : rho*(1-coeff 1) < (1/3 : ℝ) := by calc _ < (2713/5000 : ℝ)*(1-coeff 1) := mul_lt_mul_of_pos_right rho_numeric_bounds.2 (sub_pos.mpr coeff_one_lt_one) _ ≤ (2713/5000 : ℝ)*(1-38629/100000) := mul_le_mul_of_nonneg_left (by linarith [coeff_one_numeric_lower]) (by norm_num) _ < _ := by norm_num /- Original line 28866: Erdos416Proof.FordAnalysis.orderB_pos -/ theorem orderB_pos (idx : ℕ) : 0 < orderB idx := div_pos (g_pos _) (sub_pos.mpr coeff_one_lt_one) /- Original line 28869: Erdos416Proof.FordAnalysis.orderB_scaled_identity -/ theorem orderB_scaled_identity (idx : ℕ) : (orderB idx*rho^idx)*(rho*(1-coeff 1)) = g (idx+1)*rho^(idx+1) := by unfold orderB calc _ = (g (idx+1)/(1-coeff 1)*(1-coeff 1))*rho^(idx+1) := by rw [pow_succ]; ring _ = _ := by rw [div_mul_cancel₀ _ (sub_pos.mpr coeff_one_lt_one).ne'] /- Original line 28876: Erdos416Proof.FordAnalysis.orderB_scaled_lower -/ theorem orderB_scaled_lower {idx : ℕ} (hi : 1 ≤ idx) : (93/100 : ℝ) < orderB idx*rho^idx := by have h := g_scaled_uniform_lower (by omega : 2 ≤ idx+1) rw [← orderB_scaled_identity] at h have hu := mul_le_mul_of_nonneg_left order_denominator_lt_third.le (mul_pos (orderB_pos idx) (pow_pos rho_pos idx)).le linarith /-- A weaker all-index prefactor estimate sufficient for the geometric sum. -/ /- Original line 28884: Erdos416Proof.FordAnalysis.orderA_uniform_lower -/ theorem orderA_uniform_lower {idx : ℕ} (hi : 1 ≤ idx) : (7/2 : ℝ)*g idx < orderA idx := by have hb := orderB_scaled_lower hi have hg := g_scaled_uniform_upper hi have hs : ((7/2 : ℝ)*g idx)*rho^idx < (g idx+orderB idx)*rho^idx := by nlinarith exact (mul_lt_mul_iff_of_pos_right (pow_pos rho_pos idx)).mp hs /- Original line 28890: Erdos416Proof.FordAnalysis.order_bulk_gain -/ theorem order_bulk_gain {idx k : ℕ} (hi : 1 ≤ idx) (hk : 2 ≤ k) : (7/5 : ℝ)*g (idx+k) < g (idx+k)+orderB idx*renewalStep k := by have hb := orderB_scaled_lower hi have hh := renewalStep_uniform_lower hk have hg := g_scaled_uniform_upper (by omega : 1 ≤ idx+k) have hp : (93/100 : ℝ)*(147/1000) < (orderB idx*rho^idx)*(renewalStep k*rho^k) := by calc _ < (orderB idx*rho^idx)*(147/1000) := mul_lt_mul_of_pos_right hb (by norm_num) _ ≤ _ := mul_le_mul_of_nonneg_left hh.le (mul_pos (orderB_pos idx) (pow_pos rho_pos idx)).le have he : (orderB idx*renewalStep k)*rho^(idx+k) = (orderB idx*rho^idx)*(renewalStep k*rho^k) := by rw [pow_add]; ring have hs : ((7/5 : ℝ)*g (idx+k))*rho^(idx+k) < (g (idx+k)+orderB idx*renewalStep k)*rho^(idx+k) := by rw [← he] at hp nlinarith exact (mul_lt_mul_iff_of_pos_right (pow_pos rho_pos (idx+k))).mp hs /- Original line 28907: Erdos416Proof.FordAnalysis.renewalStep_pos -/ theorem renewalStep_pos {n : ℕ} (hn : 2 ≤ n) : 0 < renewalStep n := by have h := renewalStep_uniform_lower hn have hp := pow_pos rho_pos n nlinarith /- Original line 28912: Erdos416Proof.FordAnalysis.renewalStepStar -/ noncomputable def renewalStepStar (n : ℕ) : ℝ := renewalStep n+(1-coeff 1)*renewalStep (n-1) /- Original line 28915: Erdos416Proof.FordAnalysis.renewalStepStar_two_lower -/ theorem renewalStepStar_two_lower : (7/25 : ℝ) < renewalStepStar 2 := by have hc := coeff_table_bounds (by norm_num : 1 ≤ 32) norm_num [rationalCoeffLower, rationalCoeffUpper, rationalLogBounds] at hc have hg := (g_table_bounds (by norm_num : 2 ≤ 20)).1 norm_num [rationalGLower] at hg have hg1 : g 1 = coeff 1 := by simpa [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.g_zero] using g_succ 0 simp only [renewalStepStar, renewalStep, Nat.reduceSub, g_zero, hg1] nlinarith [sq_nonneg (coeff 1-3862944/10000000)] /- Original line 28924: Erdos416Proof.FordAnalysis.renewalStepStar_uniform_lower -/ theorem renewalStepStar_uniform_lower {n : ℕ} (hn : 2 ≤ n) : (2/25 : ℝ) < renewalStepStar n*rho^n := by by_cases he : n = 2 · subst n calc (2/25 : ℝ) < (7/25 : ℝ)*(217/400 : ℝ)^2 := by norm_num _ < renewalStepStar 2*(217/400 : ℝ)^2 := mul_lt_mul_of_pos_right renewalStepStar_two_lower (by norm_num) _ ≤ _ := mul_le_mul_of_nonneg_left (pow_le_pow_left₀ (by norm_num : (0 : ℝ) ≤ 217/400) rho_numeric_bounds.1.le 2) (by linarith [renewalStepStar_two_lower]) · have hh := renewalStep_uniform_lower hn have hp : 0 ≤ ((1-coeff 1)*renewalStep (n-1))*rho^n := mul_nonneg (mul_nonneg (sub_pos.mpr coeff_one_lt_one).le (renewalStep_pos (by omega : 2 ≤ n-1)).le) (pow_pos rho_pos n).le dsimp only [renewalStepStar] nlinarith /- Original line 28942: Erdos416Proof.FordAnalysis.renewalStepStar_pos -/ theorem renewalStepStar_pos {n : ℕ} (hn : 2 ≤ n) : 0 < renewalStepStar n := by have h := renewalStepStar_uniform_lower hn have hp := pow_pos rho_pos n nlinarith /- Original line 28947: Erdos416Proof.FordAnalysis.renewalStepStar_eq -/ theorem renewalStepStar_eq {n : ℕ} (hn : 2 ≤ n) : renewalStepStar n = gStar n-gStar (n-1) := by obtain ⟨m, rfl⟩ : ∃ m : ℕ, n=m+2 := ⟨n-2, by omega⟩ simp only [renewalStepStar, renewalStep, show m+2-1=m+1 by omega, Nat.add_sub_cancel, gStar_succ] ring /- Original line 28954: Erdos416Proof.FordAnalysis.gStar_scaled_uniform_upper -/ theorem gStar_scaled_uniform_upper {n : ℕ} (hn : 2 ≤ n) : gStar n*rho^n < (1/2 : ℝ) := by have h0 := g_scaled_uniform_upper (by omega : 1 ≤ n) have h1 := g_scaled_uniform_upper (by omega : 1 ≤ n-1) have hpos : 0 ≤ g (n-1)*rho^(n-1) := (mul_pos (g_pos _) (pow_pos rho_pos _)).le have hprod : (rho*(1-coeff 1))*(g (n-1)*rho^(n-1)) ≤ (1/3 : ℝ)*(17/50) := mul_le_mul order_denominator_lt_third.le h1.le hpos (by norm_num) have he : gStar n*rho^n = g n*rho^n+(rho*(1-coeff 1))*(g (n-1)*rho^(n-1)) := by conv_lhs => rw [show n=(n-1)+1 by omega, gStar_succ] rw [Nat.sub_add_cancel (by omega : 1 ≤ n)] rw [show rho^n=rho^(n-1)*rho by rw [← pow_succ, Nat.sub_add_cancel (by omega : 1 ≤ n)]] ring rw [he] linarith /- Original line 28968: Erdos416Proof.FordAnalysis.order_final_gain -/ theorem order_final_gain {idx k : ℕ} (hi : 1 ≤ idx) (hk : 2 ≤ k) : (11/10 : ℝ)*gStar (idx+k) < gStar (idx+k)+orderB idx*renewalStepStar k := by have hb := orderB_scaled_lower hi have hh := renewalStepStar_uniform_lower hk have hg := gStar_scaled_uniform_upper (by omega : 2 ≤ idx+k) have hp : (93/100 : ℝ)*(2/25) < (orderB idx*rho^idx)*(renewalStepStar k*rho^k) := by calc _ < (orderB idx*rho^idx)*(2/25) := mul_lt_mul_of_pos_right hb (by norm_num) _ ≤ _ := mul_le_mul_of_nonneg_left hh.le (mul_pos (orderB_pos idx) (pow_pos rho_pos idx)).le have he : (orderB idx*renewalStepStar k)*rho^(idx+k) = (orderB idx*rho^idx)*(renewalStepStar k*rho^k) := by rw [pow_add]; ring have hs : ((11/10 : ℝ)*gStar (idx+k))*rho^(idx+k) < (gStar (idx+k)+orderB idx*renewalStepStar k)*rho^(idx+k) := by rw [← he] at hp nlinarith exact (mul_lt_mul_iff_of_pos_right (pow_pos rho_pos (idx+k))).mp hs /- Original line 28985: Erdos416Proof.FordAnalysis.top_multiplier_lower -/ theorem top_multiplier_lower : (3/5 : ℝ) < coeff 1/(1-coeff 1) := by apply (lt_div_iff₀ (sub_pos.mpr coeff_one_lt_one)).mpr linarith [coeff_one_numeric_lower] /- Original line 28989: Erdos416Proof.FordAnalysis.top_bulk_gain -/ theorem top_bulk_gain {n : ℕ} (hn : 2 ≤ n) : (5/4 : ℝ)*g n < g n+(coeff 1/(1-coeff 1))*renewalStep n := by have hh := renewalStep_uniform_lower hn have hg := g_scaled_uniform_upper (by omega : 1 ≤ n) have hp : (3/5 : ℝ)*(147/1000) < (coeff 1/(1-coeff 1))*(renewalStep n*rho^n) := by calc _ < (coeff 1/(1-coeff 1))*(147/1000) := mul_lt_mul_of_pos_right top_multiplier_lower (by norm_num) _ ≤ _ := mul_le_mul_of_nonneg_left hh.le (by linarith [top_multiplier_lower]) have hs : ((5/4 : ℝ)*g n)*rho^n < (g n+(coeff 1/(1-coeff 1))*renewalStep n)*rho^n := by nlinarith exact (mul_lt_mul_iff_of_pos_right (pow_pos rho_pos n)).mp hs /- Original line 29002: Erdos416Proof.FordAnalysis.top_final_gain -/ theorem top_final_gain {n : ℕ} (hn : 2 ≤ n) : gStar n < gStar n+(coeff 1/(1-coeff 1))*renewalStepStar n := by have h := mul_pos (by linarith [top_multiplier_lower] : 0 < coeff 1/(1-coeff 1)) (renewalStepStar_pos hn) linarith /- Original line 29008: Erdos416Proof.FordAnalysis.order_exclusion_majorant_hasSum -/ theorem order_exclusion_majorant_hasSum : HasSum (fun m : ℕ => (20/77 : ℝ)*(5/7 : ℝ)^m) (10/11) := by convert! (hasSum_geometric_of_lt_one (by norm_num : (0 : ℝ) ≤ 5/7) (by norm_num)).mul_left (20/77) using 1 norm_num /- Original line 29013: Erdos416Proof.FordAnalysis.order_exclusion_majorant_partial -/ theorem order_exclusion_majorant_partial (N : ℕ) : (∑ m ∈ range N, (20/77 : ℝ)*(5/7 : ℝ)^m) ≤ 10/11 := by rw [← order_exclusion_majorant_hasSum.tsum_eq] exact order_exclusion_majorant_hasSum.summable.sum_le_tsum _ (fun _ _ => by positivity) end Erdos416Proof.FordAnalysis /- The actual volume of a positive weighted simplex cut by one homogeneous coordinate inequality, via a verified change of variables. -/ open Finset MeasureTheory open scoped BigOperators Classical namespace Erdos416Proof.SimplexVolume variable {n : ℕ} /-- A positive weighted simplex cut by one homogeneous linear inequality. -/ /- Original line 29034: Erdos416Proof.SimplexVolume.cutSimplex -/ def cutSimplex (b c : Fin n → ℝ) (d : ℝ) (p : Fin n) (t : ℝ) : Set (Fin n → ℝ) := {x | x ∈ weightedSimplex n b t ∧ ∑ j, c j*x j ≤ d*x p} /- Original line 29037: Erdos416Proof.SimplexVolume.cutMap -/ noncomputable def cutMap (c : Fin n → ℝ) (d : ℝ) (p : Fin n) : (Fin n → ℝ) →ₗ[ℝ] (Fin n → ℝ) := Matrix.toLin' ((1 : Matrix (Fin n) (Fin n) ℝ).updateRow p (fun j => (if p=j then d else 0)-c j)) /- Original line 29042: Erdos416Proof.SimplexVolume.cutMap_apply_self -/ theorem cutMap_apply_self (c : Fin n → ℝ) (d : ℝ) (p : Fin n) (x : Fin n → ℝ) : cutMap c d p x p = d*x p-∑ j, c j*x j := by simp [cutMap, Matrix.toLin'_apply, Matrix.mulVec, dotProduct, sub_mul, ite_mul, Finset.sum_sub_distrib] /- Original line 29047: Erdos416Proof.SimplexVolume.cutMap_apply_ne -/ theorem cutMap_apply_ne (c : Fin n → ℝ) (d : ℝ) {p j : Fin n} (hj : j ≠ p) (x : Fin n → ℝ) : cutMap c d p x j = x j := by simp [cutMap, Matrix.toLin'_apply, Matrix.updateRow_mulVec, hj] /- Original line 29051: Erdos416Proof.SimplexVolume.cutMap_det -/ theorem cutMap_det {c : Fin n → ℝ} {p : Fin n} (hc : c p = 0) (d : ℝ) : LinearMap.det (cutMap c d p) = d := by rw [cutMap, LinearMap.det_toLin', ← Matrix.cramer_transpose_apply, Matrix.transpose_one, Matrix.cramer_one] simp [hc] /- Original line 29057: Erdos416Proof.SimplexVolume.cutWeight -/ noncomputable def cutWeight (b c : Fin n → ℝ) (d : ℝ) (p : Fin n) (j : Fin n) : ℝ := if j=p then b p/d else b j+(b p/d)*c j /- Original line 29060: Erdos416Proof.SimplexVolume.cutWeight_pos -/ theorem cutWeight_pos {b c : Fin n → ℝ} (hb : ∀ j, 0 < b j) (hc : ∀ j, 0 ≤ c j) {d : ℝ} (hd : 0 < d) (p : Fin n) (j : Fin n) : 0 < cutWeight b c d p j := by unfold cutWeight split_ifs · exact div_pos (hb p) hd · exact add_pos_of_pos_of_nonneg (hb j) (mul_nonneg (div_pos (hb p) hd).le (hc j)) /- Original line 29067: Erdos416Proof.SimplexVolume.cut_weighted_identity -/ theorem cut_weighted_identity {b c : Fin n → ℝ} {p : Fin n} (hc : c p=0) {d : ℝ} (hd : d ≠ 0) (x : Fin n → ℝ) : (∑ j, cutWeight b c d p j*cutMap c d p x j) = ∑ j, b j*x j := by have hcut : (∑ j, cutWeight b c d p j*cutMap c d p x j) = (∑ j ∈ univ.erase p, (b j+(b p/d)*c j)*x j) + (b p/d)*(d*x p-∑ j, c j*x j) := by rw [← Finset.sum_erase_add _ _ (Finset.mem_univ p)] congr 1 · apply Finset.sum_congr rfl intro j hj have hne := (Finset.mem_erase.mp hj).1 rw [cutWeight, if_neg hne, cutMap_apply_ne _ _ hne] · rw [cutWeight, if_pos rfl, cutMap_apply_self] have hcs : (∑ j, c j*x j) = ∑ j ∈ univ.erase p, c j*x j := by rw [← Finset.sum_erase_add _ _ (Finset.mem_univ p), hc, zero_mul, add_zero] have hbs : (∑ j, b j*x j) = (∑ j ∈ univ.erase p, b j*x j)+b p*x p := (Finset.sum_erase_add _ _ (Finset.mem_univ p)).symm rw [hcut, hcs, hbs] simp only [add_mul, Finset.sum_add_distrib, mul_assoc, ← Finset.mul_sum] rw [mul_sub, ← mul_assoc, div_mul_cancel₀ _ hd] ring /- Original line 29089: Erdos416Proof.SimplexVolume.cutMap_image -/ theorem cutMap_image {b c : Fin n → ℝ} (hc : ∀ j, 0 ≤ c j) {p : Fin n} (hcp : c p=0) {d : ℝ} (hd : 0 < d) (t : ℝ) : cutMap c d p '' cutSimplex b c d p t = weightedSimplex n (cutWeight b c d p) t := by ext y constructor · rintro ⟨x, hx, rfl⟩ refine ⟨?_, ?_⟩ · intro j by_cases he : j=p · subst j rw [cutMap_apply_self] exact sub_nonneg.mpr hx.2 · rw [cutMap_apply_ne _ _ he] exact hx.1.1 j · rw [cut_weighted_identity hcp hd.ne'] exact hx.1.2 · intro hy let e : (Fin n → ℝ) ≃ₗ[ℝ] (Fin n → ℝ) := LinearMap.equivOfIsUnitDet (by rw [cutMap_det hcp]; exact isUnit_iff_ne_zero.mpr hd.ne') let x := e.symm y have he : cutMap c d p x = y := by calc cutMap c d p x = e x := (LinearMap.equivOfIsUnitDet_apply _ _).symm _ = y := e.apply_symm_apply y have hn : ∀ j, j ≠ p → 0 ≤ x j := by intro j hj have h := congrFun he j rw [cutMap_apply_ne _ _ hj] at h rw [h] exact hy.1 j have hcp' : 0 ≤ ∑ j, c j*x j := by apply Finset.sum_nonneg intro j _ by_cases hj : j=p · subst j simp only [hcp, zero_mul, le_refl] · exact mul_nonneg (hc j) (hn j hj) have hp : ∑ j, c j*x j ≤ d*x p := by have h := hy.1 p rw [← he, cutMap_apply_self] at h linarith refine ⟨x, ⟨⟨?_, ?_⟩, hp⟩, he⟩ · intro j by_cases hj : j=p · subst j have h := hcp'.trans hp exact nonneg_of_mul_nonneg_right h hd · exact hn j hj · rw [← cut_weighted_identity hcp hd.ne', he] exact hy.2 /- Original line 29140: Erdos416Proof.SimplexVolume.realVolume_cutSimplex -/ theorem realVolume_cutSimplex {b c : Fin n → ℝ} (hb : ∀ j, 0 < b j) (hc : ∀ j, 0 ≤ c j) {p : Fin n} (hcp : c p=0) {d : ℝ} (hd : 0 < d) {t : ℝ} (ht : 0 ≤ t) : volume.real (cutSimplex b c d p t) = t^n/(d*((n.factorial : ℝ)*(∏ j, cutWeight b c d p j))) := by have hm := congrArg (fun s : Set (Fin n → ℝ) => volume.real s) (cutMap_image (b := b) hc hcp hd t) rw [measureReal_def, Measure.addHaar_image_linearMap, cutMap_det hcp, ENNReal.toReal_mul, ENNReal.toReal_ofReal (abs_nonneg _), abs_of_pos hd, ← measureReal_def, realVolume_weightedSimplex (cutWeight_pos hb hc hd p) ht] at hm calc volume.real (cutSimplex b c d p t) = (t^n/((n.factorial : ℝ)*∏ j, cutWeight b c d p j))/d := by apply (eq_div_iff hd.ne').mpr linarith [hm] _ = _ := by rw [div_div, mul_comm d] end Erdos416Proof.SimplexVolume /- The actual inverse slack coordinates, volumes of order violations, finite geometric cover and eventual lower bound T_L >= TStar_L/22. -/ open Filter Finset MeasureTheory open scoped Topology BigOperators Classical namespace Erdos416Proof.FordGeometry open FordAnalysis SimplexVolume variable {L : ℕ} /- Original line 29171: Erdos416Proof.FordGeometry.g_reverse_prefix -/ theorem g_reverse_prefix {n : ℕ} (hn : 1 ≤ n) : (∑ k ∈ range n, g k*coeff (n-k)) = g n := by obtain ⟨m, rfl⟩ : ∃ m : ℕ, n=m+1 := ⟨n-1, by omega⟩ rw [Finset.sum_range_succ', g_succ_tail_sum] simp only [Nat.sub_zero, g_zero, one_mul, Nat.add_sub_add_right] ring /- Original line 29178: Erdos416Proof.FordGeometry.sum_fin_Ico -/ theorem sum_fin_Ico {a b : ℕ} (hb : b ≤ L) (f : ℕ → ℝ) : (∑ j : Fin L, if a ≤ j.val ∧ j.val < b then f j.val else 0) = ∑ j ∈ Ico a b, f j := by have ht (j : Fin L) : (if a ≤ j.val ∧ j.val < b then f j.val else 0) = if j.val < b then (if a ≤ j.val then f j.val else 0) else 0 := by split_ifs <;> simp_all simp_rw [ht] rw [sum_fin_lt hb (fun j => if a ≤ j then f j else 0), ← Finset.sum_filter] have he : (range b).filter (fun j => a ≤ j) = Ico a b := by ext j simp [and_comm] rw [he] /- Original line 29191: Erdos416Proof.FordGeometry.shifted_g_convolution -/ theorem shifted_g_convolution {idx j : Fin L} (hij : idx.val < j.val) : (∑ k : Fin L, if idx.val ≤ k.val ∧ k.val < j.val then g (k.val-idx.val)*coeff (j.val-k.val) else 0) = g (j.val-idx.val) := by rw [sum_fin_Ico (a := idx.val) j.isLt.le (fun k => g (k-idx.val)*coeff (j.val-k)), Finset.sum_Ico_eq_sum_range] convert! g_reverse_prefix (by omega : 1 ≤ j.val-idx.val) using 1 apply Finset.sum_congr rfl intro k _ rw [Nat.add_sub_cancel_left, Nat.sub_add_eq] /-- The actual inverse-slack coefficients; the final column retains gStar. -/ /- Original line 29201: Erdos416Proof.FordGeometry.inverseSlackWeight -/ noncomputable def inverseSlackWeight (idx j : Fin L) : ℝ := if idx.val ≤ j.val then if j.val+1 < L then g (j.val-idx.val) else gStar (j.val-idx.val) else 0 /- Original line 29206: Erdos416Proof.FordGeometry.inverseSlackWeight_self -/ theorem inverseSlackWeight_self (idx : Fin L) : inverseSlackWeight idx idx = 1 := by simp [Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.gStar_zero, Erdos416Proof.FordAnalysis.g_zero, inverseSlackWeight] /- Original line 29209: Erdos416Proof.FordGeometry.inverseSlackWeight_zero -/ theorem inverseSlackWeight_zero {idx j : Fin L} (hij : j.val < idx.val) : inverseSlackWeight idx j = 0 := by simp [Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.gStar_zero, Erdos416Proof.FordAnalysis.g_zero, inverseSlackWeight, not_le.mpr hij] /- Original line 29213: Erdos416Proof.FordGeometry.inverseSlackWeight_column -/ theorem inverseSlackWeight_column (idx j : Fin L) : inverseSlackWeight idx j-(∑ k : Fin L, inverseSlackWeight idx k*tailWeight k j) = if idx=j then 1 else 0 := by have hiL := idx.isLt have hjL := j.isLt by_cases hij : idx.val < j.val · have hne : idx ≠ j := by intro he; subst j; omega rw [if_neg hne] have hb := shifted_g_convolution hij by_cases hj : j.val+1 < L · have ht (k : Fin L) : inverseSlackWeight idx k*tailWeight k j = if idx.val ≤ k.val ∧ k.val < j.val then g (k.val-idx.val)*coeff (j.val-k.val) else 0 := by by_cases hik : idx.val ≤ k.val · by_cases hkj : k.val < j.val · simp [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.gStar_zero, Erdos416Proof.FordAnalysis.g_zero, Erdos416Proof.FordGeometry.slackMap_apply, inverseSlackWeight, hik, show k.val+1 < L by omega, tailWeight, hkj, show k.val+2 < L by omega, coeff, show j.val-k.val ≠ 0 by omega] · simp [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.gStar_zero, Erdos416Proof.FordAnalysis.g_zero, Erdos416Proof.FordGeometry.slackMap_apply, tailWeight, hkj] · simp [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.gStar_zero, Erdos416Proof.FordAnalysis.g_zero, Erdos416Proof.FordGeometry.slackMap_apply, inverseSlackWeight, hik] simp_rw [ht] rw [hb, inverseSlackWeight, if_pos hij.le, if_pos hj, sub_self] · have hjlast : j.val+1=L := by omega let p : Fin L := ⟨j.val-1, by omega⟩ have hp : p.val+1=j.val := by dsimp [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.gStar_zero, Erdos416Proof.FordAnalysis.g_zero, Erdos416Proof.FordGeometry.slackMap_apply, p]; omega have hip : idx.val ≤ p.val := by dsimp [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.gStar_zero, Erdos416Proof.FordAnalysis.g_zero, Erdos416Proof.FordGeometry.slackMap_apply, p]; omega have hpd : p.val-idx.val=j.val-idx.val-1 := by dsimp [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.gStar_zero, Erdos416Proof.FordAnalysis.g_zero, Erdos416Proof.FordGeometry.slackMap_apply, p]; omega have ht (k : Fin L) : inverseSlackWeight idx k*tailWeight k j = (if idx.val ≤ k.val ∧ k.val < j.val then g (k.val-idx.val)*coeff (j.val-k.val) else 0) + if k=p then (1-coeff 1)*g (j.val-idx.val-1) else 0 := by by_cases hkp : k=p · subst k simp only [inverseSlackWeight, hip, show p.val+1 < L by omega, ↓reduceIte, tailWeight, show p.val < j.val by omega, show ¬ p.val+2 < L by omega, mul_one, show j.val-p.val=1 by omega, hpd, and_self] ring · by_cases hik : idx.val ≤ k.val · by_cases hkj : k.val < j.val · have hkn : k.val ≠ p.val := fun h => hkp (Fin.ext h) simp [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.gStar_zero, Erdos416Proof.FordAnalysis.g_zero, Erdos416Proof.FordGeometry.slackMap_apply, inverseSlackWeight, hik, show k.val+1 < L by omega, tailWeight, hkj, show k.val+2 < L by omega, coeff, show j.val-k.val ≠ 0 by omega, hkp] · simp [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.gStar_zero, Erdos416Proof.FordAnalysis.g_zero, Erdos416Proof.FordGeometry.slackMap_apply, tailWeight, hkj, hkp] · simp [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.gStar_zero, Erdos416Proof.FordAnalysis.g_zero, Erdos416Proof.FordGeometry.slackMap_apply, inverseSlackWeight, hik, hkp] simp_rw [ht] rw [Finset.sum_add_distrib, hb] simp only [Finset.sum_ite_eq', Finset.mem_univ, ↓reduceIte] rw [inverseSlackWeight, if_pos hij.le, if_neg hj] have hg := gStar_succ (j.val-idx.val-1) rw [show j.val-idx.val-1+1=j.val-idx.val by omega] at hg rw [hg] ring · have hs : (∑ k : Fin L, inverseSlackWeight idx k*tailWeight k j) = 0 := by apply Finset.sum_eq_zero intro k _ by_cases hkj : k.val < j.val · rw [inverseSlackWeight_zero (by omega : k.val < idx.val), zero_mul] · simp [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.gStar_zero, Erdos416Proof.FordAnalysis.g_zero, Erdos416Proof.FordGeometry.slackMap_apply, tailWeight, hkj] rw [hs, sub_zero] by_cases he : idx=j · subst j simp only [inverseSlackWeight_self, ↓reduceIte] · have hv : idx.val ≠ j.val := fun h => he (Fin.ext h) rw [inverseSlackWeight_zero (by omega), if_neg he] /- Original line 29279: Erdos416Proof.FordGeometry.inverse_slack_coordinates -/ theorem inverse_slack_coordinates (idx : Fin L) (x : Fin L → ℝ) : (∑ j : Fin L, inverseSlackWeight idx j*slackMap L x j) = x idx := by calc _ = ∑ k : Fin L, (inverseSlackWeight idx k-∑ j : Fin L, inverseSlackWeight idx j*tailWeight j k)*x k := by simp only [slackMap_apply, tailForm, weightedForm_apply, mul_sub, sub_mul, Finset.sum_sub_distrib, Finset.mul_sum, Finset.sum_mul] congr 1 rw [Finset.sum_comm] simp only [mul_assoc] _ = ∑ k : Fin L, (if idx=k then (1 : ℝ) else 0)*x k := by simp only [inverseSlackWeight_column] _ = x idx := by simp [Erdos416Proof.FordGeometry.slackEquiv_apply, Erdos416Proof.FordGeometry.slackMap_apply, ite_mul] /- Original line 29294: Erdos416Proof.FordGeometry.previousIndex -/ def previousIndex (p : Fin L) : Fin L := ⟨p.val-1, lt_of_le_of_lt (Nat.sub_le _ _) p.isLt⟩ /-- Coefficients of the actual adjacent-order cut in slack coordinates. -/ /- Original line 29298: Erdos416Proof.FordGeometry.adjacentCutCoeff -/ noncomputable def adjacentCutCoeff (p j : Fin L) : ℝ := if j.val+1=p.val then 1 else if p.val < j.val then if j.val+1 < L then renewalStep (j.val-p.val+1) else renewalStepStar (j.val-p.val+1) else 0 /- Original line 29305: Erdos416Proof.FordGeometry.adjacentCutCoeff_self -/ theorem adjacentCutCoeff_self (p : Fin L) : adjacentCutCoeff p p = 0 := by simp [adjacentCutCoeff] /- Original line 29308: Erdos416Proof.FordGeometry.adjacentCutCoeff_nonneg -/ theorem adjacentCutCoeff_nonneg (p j : Fin L) : 0 ≤ adjacentCutCoeff p j := by unfold adjacentCutCoeff split_ifs with hprev hj hlast · norm_num · exact (renewalStep_pos (by omega : 2 ≤ j.val-p.val+1)).le · exact (renewalStepStar_pos (by omega : 2 ≤ j.val-p.val+1)).le · norm_num /- Original line 29316: Erdos416Proof.FordGeometry.adjacentCutCoeff_identity -/ theorem adjacentCutCoeff_identity {p : Fin L} (hp0 : 1 ≤ p.val) (hp1 : p.val+1 < L) (j : Fin L) : adjacentCutCoeff p j = inverseSlackWeight (previousIndex p) j-inverseSlackWeight p j+ if j=p then 1-coeff 1 else 0 := by have hpL := p.isLt have hjL := j.isLt have hg1 : g 1=coeff 1 := by simpa [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.gStar_zero, Erdos416Proof.FordAnalysis.g_zero] using g_succ 0 by_cases he : j=p · subst j simp only [adjacentCutCoeff_self, inverseSlackWeight_self, ↓reduceIte] simp only [inverseSlackWeight, previousIndex, show p.val-1 ≤ p.val by omega, hp1, ↓reduceIte, show p.val-(p.val-1)=1 by omega, hg1] ring · rw [if_neg he] have hne : j.val ≠ p.val := fun h => he (Fin.ext h) by_cases hprev : j.val+1=p.val · have hq : j.val=p.val-1 := by omega rw [adjacentCutCoeff, if_pos hprev] simp [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.gStar_zero, Erdos416Proof.FordAnalysis.g_zero, inverseSlackWeight, previousIndex, hq, show p.val-1+1 < L by omega, show ¬ p.val ≤ p.val-1 by omega] · by_cases hj : p.val < j.val · have hqj : p.val-1 ≤ j.val := by omega have hd : j.val-(p.val-1)=j.val-p.val+1 := by omega by_cases hlast : j.val+1 < L · simp [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.gStar_zero, Erdos416Proof.FordAnalysis.g_zero, adjacentCutCoeff, hprev, hj, hlast, inverseSlackWeight, previousIndex, hqj, hj.le, hd, renewalStep] · rw [adjacentCutCoeff, if_neg hprev, if_pos hj, if_neg hlast, renewalStepStar_eq (by omega : 2 ≤ j.val-p.val+1)] simp [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.gStar_zero, Erdos416Proof.FordAnalysis.g_zero, inverseSlackWeight, previousIndex, hqj, hj.le, hlast, hd] · have hqj : j.val < p.val-1 := by omega simp [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.gStar_zero, Erdos416Proof.FordAnalysis.g_zero, adjacentCutCoeff, hprev, hj, inverseSlackWeight, previousIndex, not_le.mpr hqj, show ¬ p.val ≤ j.val by omega] /- Original line 29350: Erdos416Proof.FordGeometry.adjacent_cut_form -/ theorem adjacent_cut_form {p : Fin L} (hp0 : 1 ≤ p.val) (hp1 : p.val+1 < L) (x : Fin L → ℝ) : (∑ j, adjacentCutCoeff p j*slackMap L x j) = x (previousIndex p)-x p+(1-coeff 1)*slackMap L x p := by calc _ = (∑ j, inverseSlackWeight (previousIndex p) j*slackMap L x j)- (∑ j, inverseSlackWeight p j*slackMap L x j)+(1-coeff 1)*slackMap L x p := by simp_rw [adjacentCutCoeff_identity hp0 hp1] simp [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordGeometry.slackEquiv_apply, Erdos416Proof.FordGeometry.slackMap_apply, add_mul, sub_mul, Finset.sum_add_distrib, Finset.sum_sub_distrib, ite_mul] _ = _ := by rw [inverse_slack_coordinates, inverse_slack_coordinates] /-- An actual adjacent-order violation, before asserting its volume. -/ /- Original line 29362: Erdos416Proof.FordGeometry.adjacentViolation -/ def adjacentViolation (p : Fin L) : Set (Fin L → ℝ) := {x | x ∈ unorderedSimplex L ∧ x (previousIndex p) ≤ x p} /- Original line 29365: Erdos416Proof.FordGeometry.adjacent_cut_mem_iff -/ theorem adjacent_cut_mem_iff (hL : 2 ≤ L) {p : Fin L} (hp0 : 1 ≤ p.val) (hp1 : p.val+1 < L) (x : Fin L → ℝ) : slackMap L x ∈ cutSimplex (simplexWeight L) (adjacentCutCoeff p) (1-coeff 1) p 1 ↔ x ∈ adjacentViolation p := by change (slackMap L x ∈ weightedSimplex L (simplexWeight L) 1 ∧ (∑ j, adjacentCutCoeff p j*slackMap L x j) ≤ (1-coeff 1)*slackMap L x p) ↔ (x ∈ unorderedSimplex L ∧ x (previousIndex p) ≤ x p) rw [slack_mem_weightedSimplex_iff hL, adjacent_cut_form hp0 hp1] constructor <;> rintro ⟨hx, h⟩ <;> exact ⟨hx, by linarith⟩ /- Original line 29375: Erdos416Proof.FordGeometry.adjacent_cut_image -/ theorem adjacent_cut_image (hL : 2 ≤ L) {p : Fin L} (hp0 : 1 ≤ p.val) (hp1 : p.val+1 < L) : slackMap L '' adjacentViolation p = cutSimplex (simplexWeight L) (adjacentCutCoeff p) (1-coeff 1) p 1 := by ext y constructor · rintro ⟨x, hx, rfl⟩ exact (adjacent_cut_mem_iff hL hp0 hp1 x).mpr hx · intro hy obtain ⟨x, hx⟩ := (slackEquiv L).surjective y have he : slackMap L x=y := by simpa only [slackEquiv_apply] using hx refine ⟨x, (adjacent_cut_mem_iff hL hp0 hp1 x).mp ?_, he⟩ rwa [he] /- Original line 29389: Erdos416Proof.FordGeometry.slack_volume_image -/ theorem slack_volume_image (s : Set (Fin L → ℝ)) : volume.real (slackMap L '' s) = volume.real s := by rw [measureReal_def, Measure.addHaar_image_linearMap, slackMap_det, abs_one, ENNReal.ofReal_one, one_mul] rfl /- Original line 29395: Erdos416Proof.FordGeometry.adjacent_violation_volume -/ theorem adjacent_violation_volume (hL : 2 ≤ L) {p : Fin L} (hp0 : 1 ≤ p.val) (hp1 : p.val+1 < L) : volume.real (adjacentViolation p) = 1/((1-coeff 1)*((L.factorial : ℝ)* ∏ j, cutWeight (simplexWeight L) (adjacentCutCoeff p) (1-coeff 1) p j)) := by calc _ = volume.real (slackMap L '' adjacentViolation p) := (slack_volume_image _).symm _ = volume.real (cutSimplex (simplexWeight L) (adjacentCutCoeff p) (1-coeff 1) p 1) := by rw [adjacent_cut_image hL hp0 hp1] _ = _ := by rw [realVolume_cutSimplex (fun j => simplexWeight_pos j) (adjacentCutCoeff_nonneg p) (adjacentCutCoeff_self p) (sub_pos.mpr coeff_one_lt_one) (by norm_num)] simp only [one_pow] /- Original line 29410: Erdos416Proof.FordGeometry.prod_fin_Ico -/ theorem prod_fin_Ico {a b : ℕ} (hb : b ≤ L) (r : ℝ) : (∏ j : Fin L, if a ≤ j.val ∧ j.val < b then r else 1) = r^(b-a) := by rw [Fin.prod_univ_eq_prod_range (fun j => if a ≤ j ∧ j < b then r else 1) L, ← Finset.prod_filter] have he : (range L).filter (fun j => a ≤ j ∧ j < b) = Ico a b := by ext j simp only [Finset.mem_filter, Finset.mem_range, Finset.mem_Ico] omega rw [he] simp /- Original line 29421: Erdos416Proof.FordGeometry.adjacentWeight -/ noncomputable def adjacentWeight (p j : Fin L) : ℝ := cutWeight (simplexWeight L) (adjacentCutCoeff p) (1-coeff 1) p j /- Original line 29424: Erdos416Proof.FordGeometry.adjacentWeight_pos -/ theorem adjacentWeight_pos (p j : Fin L) : 0 < adjacentWeight p j := cutWeight_pos (fun k => simplexWeight_pos k) (adjacentCutCoeff_nonneg p) (sub_pos.mpr coeff_one_lt_one) p j /- Original line 29428: Erdos416Proof.FordGeometry.adjacentRatioBound -/ noncomputable def adjacentRatioBound (p j : Fin L) : ℝ := (if j=p then 1-coeff 1 else 1)*(if j.val+1=p.val then (2/7 : ℝ) else 1)* (if j.val+1=L then (10/11 : ℝ) else 1)* (if p.val < j.val ∧ j.val+1 < L then (5/7 : ℝ) else 1) /- Original line 29433: Erdos416Proof.FordGeometry.adjacent_weight_ratio_bound -/ theorem adjacent_weight_ratio_bound {p : Fin L} (hp0 : 1 ≤ p.val) (hp1 : p.val+1 < L) (j : Fin L) : simplexWeight L j/adjacentWeight p j ≤ adjacentRatioBound p j := by have hpL := p.isLt have hjL := j.isLt have hd := sub_pos.mpr coeff_one_lt_one by_cases he : j=p · subst j have hb := (simplexWeight_pos p).ne' have hcancel : simplexWeight L p/(simplexWeight L p/(1-coeff 1))=1-coeff 1 := by field_simp simp [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.gStar_zero, Erdos416Proof.FordAnalysis.g_zero, adjacentWeight, cutWeight, adjacentRatioBound, show p.val+1 ≠ L by omega, hcancel] · have hne : j.val ≠ p.val := fun h => he (Fin.ext h) by_cases hprev : j.val+1=p.val · have hnew : adjacentWeight p j=orderA p.val := by simp [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.gStar_zero, Erdos416Proof.FordAnalysis.g_zero, adjacentWeight, cutWeight, he, adjacentCutCoeff, hprev, simplexWeight, hp1, orderA, orderB] have hb : simplexWeight L j=g p.val := by simp [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.gStar_zero, Erdos416Proof.FordAnalysis.g_zero, simplexWeight, hprev, hpL] have hbound : adjacentRatioBound p j=(2/7 : ℝ) := by simp [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.gStar_zero, Erdos416Proof.FordAnalysis.g_zero, adjacentRatioBound, he, hprev, show p.val ≠ L by omega, show ¬ p.val < j.val by omega] rw [hbound] apply (div_le_iff₀ (adjacentWeight_pos p j)).mpr rw [hnew, hb] nlinarith [orderA_uniform_lower hp0] · by_cases hj : p.val < j.val · have hk : 2 ≤ j.val-p.val+1 := by omega have hsum : p.val+(j.val-p.val+1)=j.val+1 := by omega by_cases hlast : j.val+1 < L · have hg := order_bulk_gain hp0 hk rw [hsum] at hg have hgain : (7/5 : ℝ)*simplexWeight L j < adjacentWeight p j := by simpa only [simplexWeight, hlast, hp1, ↓reduceIte, adjacentWeight, cutWeight, if_neg he, adjacentCutCoeff, if_neg hprev, if_pos hj, orderB] using hg have hbound : adjacentRatioBound p j=(5/7 : ℝ) := by simp [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.gStar_zero, Erdos416Proof.FordAnalysis.g_zero, adjacentRatioBound, he, hprev, hj, hlast, show j.val+1 ≠ L by omega] rw [hbound] apply (div_le_iff₀ (adjacentWeight_pos p j)).mpr nlinarith · have hjlast : j.val+1=L := by omega have hg := order_final_gain hp0 hk rw [hsum] at hg have hgain : (11/10 : ℝ)*simplexWeight L j < adjacentWeight p j := by simpa only [simplexWeight, hlast, hp1, ↓reduceIte, adjacentWeight, cutWeight, if_neg he, adjacentCutCoeff, if_neg hprev, if_pos hj, orderB] using hg have hbound : adjacentRatioBound p j=(10/11 : ℝ) := by simp [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.gStar_zero, Erdos416Proof.FordAnalysis.g_zero, adjacentRatioBound, he, hj, hjlast, show L ≠ p.val by omega] rw [hbound] apply (div_le_iff₀ (adjacentWeight_pos p j)).mpr nlinarith · have hnew : adjacentWeight p j=simplexWeight L j := by simp [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.gStar_zero, Erdos416Proof.FordAnalysis.g_zero, adjacentWeight, cutWeight, he, adjacentCutCoeff, hprev, hj] have hbound : adjacentRatioBound p j=1 := by simp [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.gStar_zero, Erdos416Proof.FordAnalysis.g_zero, adjacentRatioBound, he, hprev, hj, show j.val+1 ≠ L by omega] rw [hnew, hbound, div_self (simplexWeight_pos j).ne'] /- Original line 29489: Erdos416Proof.FordGeometry.adjacentRatioBound_product -/ theorem adjacentRatioBound_product {p : Fin L} (hp0 : 1 ≤ p.val) (hp1 : p.val+1 < L) : (∏ j, adjacentRatioBound p j) = (1-coeff 1)*((20/77 : ℝ)*(5/7 : ℝ)^(L-p.val-2)) := by let last : Fin L := ⟨L-1, by have := p.isLt; omega⟩ have hprev (j : Fin L) : (j.val+1=p.val) ↔ j=previousIndex p := by constructor · intro h apply Fin.ext dsimp only [previousIndex] omega · intro h subst j dsimp only [previousIndex] omega have hlast (j : Fin L) : (j.val+1=L) ↔ j=last := by constructor · intro h apply Fin.ext dsimp only [last] omega · intro h subst j dsimp only [last] omega have htail (j : Fin L) : (p.val < j.val ∧ j.val+1 < L) ↔ (p.val+1 ≤ j.val ∧ j.val < L-1) := by omega simp only [adjacentRatioBound, Finset.prod_mul_distrib] simp_rw [hprev, hlast, htail] simp only [Finset.prod_ite_eq', Finset.mem_univ, ↓reduceIte] rw [prod_fin_Ico (Nat.sub_le L 1) (5/7 : ℝ)] rw [show L-1-(p.val+1)=L-p.val-2 by omega] ring /- Original line 29522: Erdos416Proof.FordGeometry.adjacent_violation_ratio -/ theorem adjacent_violation_ratio (hL : 2 ≤ L) {p : Fin L} (hp0 : 1 ≤ p.val) (hp1 : p.val+1 < L) : volume.real (adjacentViolation p)/TStar L = (∏ j, simplexWeight L j/adjacentWeight p j)/(1-coeff 1) := by have hd := (sub_pos.mpr coeff_one_lt_one).ne' have hf : (L.factorial : ℝ) ≠ 0 := by positivity have hb : (∏ j : Fin L, simplexWeight L j) ≠ 0 := (Finset.prod_pos (fun j _ => simplexWeight_pos j)).ne' have hn : (∏ j : Fin L, adjacentWeight p j) ≠ 0 := (Finset.prod_pos (fun j _ => adjacentWeight_pos p j)).ne' rw [adjacent_violation_volume hL hp0 hp1, TStar_eq hL, ← simplexWeight_product, Finset.prod_div_distrib] change (1/((1-coeff 1)*((L.factorial : ℝ)*∏ j, adjacentWeight p j)))/ (1/((L.factorial : ℝ)*∏ j, simplexWeight L j)) = ((∏ j, simplexWeight L j)/(∏ j, adjacentWeight p j))/(1-coeff 1) field_simp [hd, hf, hb, hn] /- Original line 29539: Erdos416Proof.FordGeometry.adjacent_violation_ratio_bound -/ theorem adjacent_violation_ratio_bound (hL : 2 ≤ L) {p : Fin L} (hp0 : 1 ≤ p.val) (hp1 : p.val+1 < L) : volume.real (adjacentViolation p)/TStar L ≤ (20/77 : ℝ)*(5/7 : ℝ)^(L-p.val-2) := by have hp : (∏ j, simplexWeight L j/adjacentWeight p j) ≤ ∏ j, adjacentRatioBound p j := Finset.prod_le_prod (fun j _ => (div_pos (simplexWeight_pos j) (adjacentWeight_pos p j)).le) (fun j _ => adjacent_weight_ratio_bound hp0 hp1 j) rw [adjacentRatioBound_product hp0 hp1] at hp rw [adjacent_violation_ratio hL hp0 hp1] calc _ ≤ ((1-coeff 1)*((20/77 : ℝ)*(5/7 : ℝ)^(L-p.val-2)))/(1-coeff 1) := div_le_div_of_nonneg_right hp (sub_pos.mpr coeff_one_lt_one).le _ = _ := by rw [mul_div_cancel_left₀ _ (sub_pos.mpr coeff_one_lt_one).ne'] /- Original line 29554: Erdos416Proof.FordGeometry.adjacent_violation_bound -/ theorem adjacent_violation_bound (hL : 2 ≤ L) {p : Fin L} (hp0 : 1 ≤ p.val) (hp1 : p.val+1 < L) : volume.real (adjacentViolation p) ≤ ((20/77 : ℝ)*(5/7 : ℝ)^(L-p.val-2))*TStar L := (div_le_iff₀ (TStar_pos hL)).mp (adjacent_violation_ratio_bound hL hp0 hp1) /-- The coefficient vector of the homogeneous cut containing the top violation. -/ /- Original line 29562: Erdos416Proof.FordGeometry.topCutCoeff -/ noncomputable def topCutCoeff (p j : Fin L) : ℝ := if j=p then 0 else if j.val+1 < L then renewalStep (j.val+1) else renewalStepStar (j.val+1) /- Original line 29566: Erdos416Proof.FordGeometry.topCutCoeff_self -/ theorem topCutCoeff_self (p : Fin L) : topCutCoeff p p=0 := by simp [topCutCoeff] /- Original line 29568: Erdos416Proof.FordGeometry.topCutCoeff_nonneg -/ theorem topCutCoeff_nonneg {p : Fin L} (hp : p.val=0) (j : Fin L) : 0 ≤ topCutCoeff p j := by by_cases he : j=p · subst j; simp [topCutCoeff] · have hj : 2 ≤ j.val+1 := by have hne : j.val ≠ p.val := fun h => he (Fin.ext h) omega unfold topCutCoeff rw [if_neg he] split_ifs · exact (renewalStep_pos hj).le · exact (renewalStepStar_pos hj).le /- Original line 29581: Erdos416Proof.FordGeometry.topCutCoeff_identity -/ theorem topCutCoeff_identity (hL : 2 ≤ L) {p : Fin L} (hp : p.val=0) (j : Fin L) : topCutCoeff p j = simplexWeight L j-inverseSlackWeight p j+ (if j=p then 1-coeff 1 else 0) := by have hg1 : g 1=coeff 1 := by simpa [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.gStar_zero, Erdos416Proof.FordAnalysis.g_zero] using g_succ_tail_sum 0 by_cases he : j=p · subst j simp [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.gStar_zero, Erdos416Proof.FordAnalysis.g_zero, topCutCoeff, simplexWeight, hp, show 1 < L by omega, inverseSlackWeight, hg1] · have hj : 2 ≤ j.val+1 := by have hne : j.val ≠ p.val := fun h => he (Fin.ext h) omega unfold topCutCoeff rw [if_neg he] by_cases hjL : j.val+1 < L · simp [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.gStar_zero, Erdos416Proof.FordAnalysis.g_zero, hjL, simplexWeight, inverseSlackWeight, hp, he, renewalStep] · simp [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.gStar_zero, Erdos416Proof.FordAnalysis.g_zero, hjL, simplexWeight, inverseSlackWeight, hp, he, renewalStepStar_eq hj] /- Original line 29598: Erdos416Proof.FordGeometry.top_cut_form -/ theorem top_cut_form (hL : 2 ≤ L) {p : Fin L} (hp : p.val=0) (x : Fin L → ℝ) : (∑ j, topCutCoeff p j*slackMap L x j) = outerForm L x-x p+(1-coeff 1)*slackMap L x p := by calc _ = (∑ j, simplexWeight L j*slackMap L x j)- (∑ j, inverseSlackWeight p j*slackMap L x j)+(1-coeff 1)*slackMap L x p := by simp_rw [topCutCoeff_identity hL hp] simp [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordGeometry.slackEquiv_apply, Erdos416Proof.FordGeometry.slackMap_apply, add_mul, sub_mul, Finset.sum_add_distrib, Finset.sum_sub_distrib, ite_mul] _ = _ := by rw [weighted_slack_eq_outer hL, inverse_slack_coordinates] /-- The actual top-coordinate violation. Applications take p.val=0. -/ /- Original line 29609: Erdos416Proof.FordGeometry.topViolation -/ def topViolation (p : Fin L) : Set (Fin L → ℝ) := {x | x ∈ unorderedSimplex L ∧ 1 ≤ x p} /- Original line 29612: Erdos416Proof.FordGeometry.top_violation_image_subset -/ theorem top_violation_image_subset (hL : 2 ≤ L) {p : Fin L} (hp : p.val=0) : slackMap L '' topViolation p ⊆ cutSimplex (simplexWeight L) (topCutCoeff p) (1-coeff 1) p 1 := by rintro y ⟨x, hx, rfl⟩ refine ⟨(slack_mem_weightedSimplex_iff hL x).mpr hx.1, ?_⟩ rw [top_cut_form hL hp] have ho := hx.1.1 have ht := hx.2 linarith /- Original line 29622: Erdos416Proof.FordGeometry.topWeight -/ noncomputable def topWeight (p j : Fin L) : ℝ := cutWeight (simplexWeight L) (topCutCoeff p) (1-coeff 1) p j /- Original line 29625: Erdos416Proof.FordGeometry.topWeight_pos -/ theorem topWeight_pos {p : Fin L} (hp : p.val=0) (j : Fin L) : 0 < topWeight p j := cutWeight_pos (fun k => simplexWeight_pos k) (topCutCoeff_nonneg hp) (sub_pos.mpr coeff_one_lt_one) p j /- Original line 29629: Erdos416Proof.FordGeometry.topRatioBound -/ noncomputable def topRatioBound (p j : Fin L) : ℝ := (if j=p then 1-coeff 1 else 1)* (if 0 < j.val ∧ j.val+1 < L then (4/5 : ℝ) else 1) /- Original line 29633: Erdos416Proof.FordGeometry.top_weight_ratio_bound -/ theorem top_weight_ratio_bound (hL : 2 ≤ L) {p : Fin L} (hp : p.val=0) (j : Fin L) : simplexWeight L j/topWeight p j ≤ topRatioBound p j := by have hp1 : p.val+1 < L := by omega have hd := sub_pos.mpr coeff_one_lt_one have hg1 : g 1=coeff 1 := by simpa [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.gStar_zero, Erdos416Proof.FordAnalysis.g_zero] using g_succ_tail_sum 0 have hb0 : simplexWeight L p=coeff 1 := by rw [simplexWeight, if_pos hp1, hp] exact hg1 by_cases he : j=p · subst j have hb := (simplexWeight_pos p).ne' have hcancel : simplexWeight L p/(simplexWeight L p/(1-coeff 1))=1-coeff 1 := by field_simp simp [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.gStar_zero, Erdos416Proof.FordAnalysis.g_zero, topWeight, cutWeight, topRatioBound, hp, hcancel] · have hj : 0 < j.val := by have hne : j.val ≠ p.val := fun h => he (Fin.ext h) omega have hj2 : 2 ≤ j.val+1 := by omega by_cases hlast : j.val+1 < L · have hbj : simplexWeight L j=g (j.val+1) := by simp [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.gStar_zero, Erdos416Proof.FordAnalysis.g_zero, simplexWeight, hlast] have hgain : (5/4 : ℝ)*simplexWeight L j < topWeight p j := by simpa only [topWeight, cutWeight, if_neg he, hb0, topCutCoeff, if_pos hlast, hbj] using top_bulk_gain hj2 have hbound : topRatioBound p j=(4/5 : ℝ) := by simp [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.gStar_zero, Erdos416Proof.FordAnalysis.g_zero, topRatioBound, he, hj, hlast] rw [hbound] apply (div_le_iff₀ (topWeight_pos hp j)).mpr nlinarith · have hbj : simplexWeight L j=gStar (j.val+1) := by simp [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.gStar_zero, Erdos416Proof.FordAnalysis.g_zero, simplexWeight, hlast] have hgain : simplexWeight L j < topWeight p j := by simpa only [topWeight, cutWeight, if_neg he, hb0, topCutCoeff, if_neg hlast, hbj] using top_final_gain hj2 have hbound : topRatioBound p j=1 := by simp [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.gStar_zero, Erdos416Proof.FordAnalysis.g_zero, topRatioBound, he, hlast] rw [hbound] apply (div_le_iff₀ (topWeight_pos hp j)).mpr simpa only [one_mul] using hgain.le /- Original line 29670: Erdos416Proof.FordGeometry.topRatioBound_product -/ theorem topRatioBound_product (hL : 2 ≤ L) {p : Fin L} : (∏ j, topRatioBound p j) = (1-coeff 1)*(4/5 : ℝ)^(L-2) := by have htail (j : Fin L) : (0 < j.val ∧ j.val+1 < L) ↔ (1 ≤ j.val ∧ j.val < L-1) := by omega simp only [topRatioBound, Finset.prod_mul_distrib] simp_rw [htail] simp only [Finset.prod_ite_eq', Finset.mem_univ, ↓reduceIte] rw [prod_fin_Ico (Nat.sub_le L 1) (4/5 : ℝ)] rw [show L-1-1=L-2 by omega] /- Original line 29680: Erdos416Proof.FordGeometry.top_cut_volume_ratio -/ theorem top_cut_volume_ratio (hL : 2 ≤ L) {p : Fin L} (hp : p.val=0) : volume.real (cutSimplex (simplexWeight L) (topCutCoeff p) (1-coeff 1) p 1)/TStar L = (∏ j, simplexWeight L j/topWeight p j)/(1-coeff 1) := by have hd := (sub_pos.mpr coeff_one_lt_one).ne' have hf : (L.factorial : ℝ) ≠ 0 := by positivity have hb : (∏ j : Fin L, simplexWeight L j) ≠ 0 := (Finset.prod_pos (fun j _ => simplexWeight_pos j)).ne' have hn : (∏ j : Fin L, topWeight p j) ≠ 0 := (Finset.prod_pos (fun j _ => topWeight_pos hp j)).ne' rw [realVolume_cutSimplex (fun j => simplexWeight_pos j) (topCutCoeff_nonneg hp) (topCutCoeff_self p) (sub_pos.mpr coeff_one_lt_one) (by norm_num), TStar_eq hL, ← simplexWeight_product, Finset.prod_div_distrib] simp only [one_pow] change (1/((1-coeff 1)*((L.factorial : ℝ)*∏ j, topWeight p j)))/ (1/((L.factorial : ℝ)*∏ j, simplexWeight L j)) = ((∏ j, simplexWeight L j)/(∏ j, topWeight p j))/(1-coeff 1) field_simp [hd, hf, hb, hn] /- Original line 29698: Erdos416Proof.FordGeometry.top_cut_ratio_bound -/ theorem top_cut_ratio_bound (hL : 2 ≤ L) {p : Fin L} (hp : p.val=0) : volume.real (cutSimplex (simplexWeight L) (topCutCoeff p) (1-coeff 1) p 1)/TStar L ≤ (4/5 : ℝ)^(L-2) := by have hprod : (∏ j, simplexWeight L j/topWeight p j) ≤ ∏ j, topRatioBound p j := Finset.prod_le_prod (fun j _ => (div_pos (simplexWeight_pos j) (topWeight_pos hp j)).le) (fun j _ => top_weight_ratio_bound hL hp j) rw [topRatioBound_product hL] at hprod rw [top_cut_volume_ratio hL hp] calc _ ≤ ((1-coeff 1)*(4/5 : ℝ)^(L-2))/(1-coeff 1) := div_le_div_of_nonneg_right hprod (sub_pos.mpr coeff_one_lt_one).le _ = _ := by rw [mul_div_cancel_left₀ _ (sub_pos.mpr coeff_one_lt_one).ne'] /- Original line 29712: Erdos416Proof.FordGeometry.top_violation_bound -/ theorem top_violation_bound (hL : 2 ≤ L) {p : Fin L} (hp : p.val=0) : volume.real (topViolation p) ≤ (4/5 : ℝ)^(L-2)*TStar L := by have hfinite : volume (cutSimplex (simplexWeight L) (topCutCoeff p) (1-coeff 1) p 1) ≠ ⊤ := measure_ne_top_of_subset (fun _ hx => hx.1) (weightedSimplex_isCompact (fun j : Fin L => simplexWeight_pos j) 1).measure_lt_top.ne calc _ = volume.real (slackMap L '' topViolation p) := (slack_volume_image _).symm _ ≤ volume.real (cutSimplex (simplexWeight L) (topCutCoeff p) (1-coeff 1) p 1) := measureReal_mono (top_violation_image_subset hL hp) hfinite _ ≤ _ := (div_le_iff₀ (TStar_pos hL)).mp (top_cut_ratio_bound hL hp) /-- The finite list of order constraints not already imposed by the unordered simplex. -/ /- Original line 29725: Erdos416Proof.FordGeometry.adjacentIndices -/ def adjacentIndices (L : ℕ) : Finset (Fin L) := univ.filter (fun p => 1 ≤ p.val ∧ p.val+1 < L) /- Original line 29728: Erdos416Proof.FordGeometry.mem_adjacentIndices -/ theorem mem_adjacentIndices {p : Fin L} : p ∈ adjacentIndices L ↔ 1 ≤ p.val ∧ p.val+1 < L := by simp [adjacentIndices] /- Original line 29731: Erdos416Proof.FordGeometry.antitone_of_previous -/ theorem antitone_of_previous (x : Fin L → ℝ) (hx : ∀ p : Fin L, 1 ≤ p.val → x p ≤ x (previousIndex p)) : Antitone x := by cases L with | zero => intro idx; exact Fin.elim0 idx | succ n => apply Fin.antitone_iff_succ_le.mpr intro idx have he : previousIndex idx.succ=idx.castSucc := by ext; simp [previousIndex] simpa only [he] using hx idx.succ (by simp) /- Original line 29741: Erdos416Proof.FordGeometry.unordered_simplex_cover -/ theorem unordered_simplex_cover (hL : 2 ≤ L) {p : Fin L} (hp : p.val=0) : unorderedSimplex L = polytope L (fun _ => 1) ∪ topViolation p ∪ ⋃ q ∈ adjacentIndices L, adjacentViolation q := by apply Set.Subset.antisymm · intro x hx by_cases ht : 1 ≤ x p · exact Or.inl (Or.inr ⟨hx, ht⟩) by_cases ha : ∃ q ∈ adjacentIndices L, x (previousIndex q) ≤ x q · obtain ⟨q, hq, hv⟩ := ha exact Or.inr (Set.mem_iUnion₂.mpr ⟨q, hq, hx, hv⟩) have hstep (q : Fin L) (hq0 : 1 ≤ q.val) : x q ≤ x (previousIndex q) := by by_cases hq1 : q.val+1 < L · have hn : ¬x (previousIndex q) ≤ x q := fun hv => ha ⟨q, mem_adjacentIndices.mpr ⟨hq0, hq1⟩, hv⟩ exact (lt_of_not_ge hn).le · have hqL := q.isLt have hprev : (previousIndex q).val+2=L := by dsimp [Erdos416Proof.FordGeometry.slackMap_apply, previousIndex]; omega have hnext : q.val=(previousIndex q).val+1 := by dsimp [Erdos416Proof.FordGeometry.slackMap_apply, previousIndex]; omega have h := hx.2 (previousIndex q) rwa [tailForm_last (previousIndex q) q hprev hnext x] at h have hanti := antitone_of_previous x hstep refine Or.inl (Or.inl ⟨unorderedSimplex_nonneg hx, ?_, hanti, hx.1, ?_⟩) · intro idx exact (hanti (show p ≤ idx by change p.val ≤ idx.val; omega)).trans (lt_of_not_ge ht).le · intro idx _ simpa only [one_mul] using hx.2 idx · rintro x ((hx | hx) | hx) · exact polytope_subset_unorderedSimplex L hx · exact hx.1 · obtain ⟨q, _, hq⟩ := Set.mem_iUnion₂.mp hx exact hq.1 /- Original line 29773: Erdos416Proof.FordGeometry.adjacent_majorant_sum -/ theorem adjacent_majorant_sum (hL : 2 ≤ L) : (∑ p ∈ adjacentIndices L, (20/77 : ℝ)*(5/7 : ℝ)^(L-p.val-2)) ≤ 10/11 := by have hcond (p : Fin L) : (1 ≤ p.val ∧ p.val+1 < L) ↔ (1 ≤ p.val ∧ p.val < L-1) := by omega rw [adjacentIndices, Finset.sum_filter] simp_rw [hcond] rw [sum_fin_Ico (Nat.sub_le L 1) (fun j => (20/77 : ℝ)*(5/7 : ℝ)^(L-j-2)), sum_Ico_eq_sum_range] rw [show L-1-1=L-2 by omega] have he : (∑ k ∈ range (L-2), (20/77 : ℝ)*(5/7 : ℝ)^(L-(1+k)-2)) = ∑ k ∈ range (L-2), (20/77 : ℝ)*(5/7 : ℝ)^k := by calc _ = ∑ k ∈ range (L-2), (20/77 : ℝ)*(5/7 : ℝ)^((L-2)-1-k) := by apply Finset.sum_congr rfl intro k _ rw [show L-(1+k)-2=(L-2)-1-k by omega] _ = _ := Finset.sum_range_reflect (fun k => (20/77 : ℝ)*(5/7 : ℝ)^k) (L-2) rw [he] exact order_exclusion_majorant_partial (L-2) /- Original line 29793: Erdos416Proof.FordGeometry.adjacent_violation_sum_bound -/ theorem adjacent_violation_sum_bound (hL : 2 ≤ L) : (∑ p ∈ adjacentIndices L, volume.real (adjacentViolation p)) ≤ (10/11 : ℝ)*TStar L := by calc _ ≤ ∑ p ∈ adjacentIndices L, ((20/77 : ℝ)*(5/7 : ℝ)^(L-p.val-2))*TStar L := by apply Finset.sum_le_sum intro p hp have hi := mem_adjacentIndices.mp hp exact adjacent_violation_bound hL hi.1 hi.2 _ = (∑ p ∈ adjacentIndices L, (20/77 : ℝ)*(5/7 : ℝ)^(L-p.val-2))*TStar L := (Finset.sum_mul ..).symm _ ≤ _ := mul_le_mul_of_nonneg_right (adjacent_majorant_sum hL) (TStar_pos hL).le /- Original line 29806: Erdos416Proof.FordGeometry.TStar_le_T_add_excluded -/ theorem TStar_le_T_add_excluded (hL : 2 ≤ L) : TStar L ≤ T L+((10/11 : ℝ)+(4/5 : ℝ)^(L-2))*TStar L := by let p : Fin L := ⟨0, by omega⟩ have hp : p.val=0 := rfl have hcover : TStar L ≤ (T L+volume.real (topViolation p))+ ∑ q ∈ adjacentIndices L, volume.real (adjacentViolation q) := by change volume.real (unorderedSimplex L) ≤ _ rw [unordered_simplex_cover hL hp] calc _ ≤ volume.real (polytope L (fun _ => 1) ∪ topViolation p)+ volume.real (⋃ q ∈ adjacentIndices L, adjacentViolation q) := measureReal_union_le _ _ _ ≤ _ := add_le_add (measureReal_union_le _ _) (measureReal_biUnion_finset_le (adjacentIndices L) adjacentViolation) have htop := top_violation_bound hL hp have hadj := adjacent_violation_sum_bound hL nlinarith /- Original line 29823: Erdos416Proof.FordGeometry.T_eventually_ge_TStar_div -/ theorem T_eventually_ge_TStar_div : ∀ᶠ L : ℕ in atTop, TStar L/22 ≤ T L := by have hpow : Tendsto (fun L : ℕ => (4/5 : ℝ)^(L-2)) atTop (nhds 0) := (tendsto_pow_atTop_nhds_zero_of_lt_one (by norm_num : (0 : ℝ) ≤ 4/5) (by norm_num)).comp (tendsto_sub_atTop_nat 2) filter_upwards [eventually_ge_atTop 2, hpow.eventually_lt_const (by norm_num : (0 : ℝ) < 1/22)] with L hL hp have h := TStar_le_T_add_excluded hL have hs : ((10/11 : ℝ)+(4/5 : ℝ)^(L-2))*TStar L ≤ (21/22 : ℝ)*TStar L := mul_le_mul_of_nonneg_right (by linarith) (TStar_pos hL).le linarith /-- The actual ordered Ford volume has the same scale as the unordered one. -/ /- Original line 29835: Erdos416Proof.FordGeometry.T_eventual_bounds -/ theorem T_eventual_bounds : ∃ a b : ℝ, 0 < a ∧ 0 < b ∧ ∀ᶠ L : ℕ in atTop, a*rho^(L*(L+1)/2)/((L.factorial : ℝ)*lambda^(L+1)) ≤ T L ∧ T L ≤ b*rho^(L*(L+1)/2)/((L.factorial : ℝ)*lambda^(L+1)) := by obtain ⟨a, b, ha, hb, hbounds⟩ := TStar_eventual_bounds refine ⟨a/22, b, by positivity, hb, ?_⟩ filter_upwards [hbounds, T_eventually_ge_TStar_div, eventually_ge_atTop 2] with L h hlow hL constructor · calc _ = (a*rho^(L*(L+1)/2)/((L.factorial : ℝ)*lambda^(L+1)))/22 := by ring _ ≤ TStar L/22 := div_le_div_of_nonneg_right h.1 (by norm_num) _ ≤ T L := hlow · exact (T_le_TStar hL).trans h.2 end Erdos416Proof.FordGeometry /- An actual affine-simplex enclosure and dimension-uniform bounds for thickened Ford polytopes and their outer-facet shells. -/ open Filter Finset MeasureTheory open scoped Topology BigOperators Classical Pointwise namespace Erdos416Proof.FordGeometry open FordAnalysis SimplexVolume variable {L : ℕ} /- Original line 29865: Erdos416Proof.FordGeometry.simplexWeight_scaled_le_one -/ theorem simplexWeight_scaled_le_one (hL : 2 ≤ L) (j : Fin L) : simplexWeight L j*rho^(j.val+1) ≤ 1 := by by_cases hj : j.val+1 < L · rw [simplexWeight, if_pos hj] have h := g_scaled_uniform_upper (by omega : 1 ≤ j.val+1) linarith · rw [simplexWeight, if_neg hj] have hlast : j.val+1=L := by have := j.isLt; omega rw [hlast] have h := gStar_scaled_uniform_upper hL linarith /- Original line 29877: Erdos416Proof.FordGeometry.simplexWeight_scaled_sum_bound -/ theorem simplexWeight_scaled_sum_bound (hL : 2 ≤ L) : (∑ j : Fin L, simplexWeight L j)*rho^L ≤ 4 := by calc _ = ∑ j : Fin L, (simplexWeight L j*rho^(j.val+1))*rho^(L-j.val-1) := by rw [Finset.sum_mul] apply Finset.sum_congr rfl intro j _ rw [mul_assoc, ← pow_add, show j.val+1+(L-j.val-1)=L by have := j.isLt; omega] _ ≤ ∑ j : Fin L, rho^(L-j.val-1) := by apply Finset.sum_le_sum intro j _ simpa only [one_mul] using mul_le_mul_of_nonneg_right (simplexWeight_scaled_le_one hL j) (pow_pos rho_pos _).le _ = ∑ j ∈ range L, rho^(L-1-j) := by rw [Fin.sum_univ_eq_sum_range (fun j => rho^(L-j-1)) L] apply Finset.sum_congr rfl intro j _ rw [show L-j-1=L-1-j by omega] _ = ∑ j ∈ range L, rho^j := Finset.sum_range_reflect (fun j => rho^j) L _ ≤ (1-rho)⁻¹ := by have hs := hasSum_geometric_of_lt_one rho_pos.le rho_lt_one rw [← hs.tsum_eq] exact hs.summable.sum_le_tsum _ (fun _ _ => (pow_pos rho_pos _).le) _ ≤ 4 := by rw [← one_div] apply (div_le_iff₀ (sub_pos.mpr rho_lt_one)).mpr linarith [rho_lt_three_quarters] /-- Coordinate allowance for the slack image of a cube of radius one. -/ /- Original line 29907: Erdos416Proof.FordGeometry.slackRowRadius -/ noncomputable def slackRowRadius (idx : Fin L) : ℝ := 1+∑ j, tailWeight idx j /- Original line 29909: Erdos416Proof.FordGeometry.slackShift -/ noncomputable def slackShift (L : ℕ) (τ : ℝ) (idx : Fin L) : ℝ := τ*slackRowRadius idx /-- The actual slack map followed by the translation enclosing the thickened simplex. -/ /- Original line 29912: Erdos416Proof.FordGeometry.thickSlack -/ noncomputable def thickSlack (L : ℕ) (τ : ℝ) (x : Fin L → ℝ) : Fin L → ℝ := slackMap L x+slackShift L τ /- Original line 29915: Erdos416Proof.FordGeometry.slackRowRadius_nonneg -/ theorem slackRowRadius_nonneg (idx : Fin L) : 0 ≤ slackRowRadius idx := add_nonneg (by norm_num) (Finset.sum_nonneg (fun j _ => tailWeight_nonneg idx j)) /- Original line 29918: Erdos416Proof.FordGeometry.slackRowRadius_weight_sum -/ theorem slackRowRadius_weight_sum (hL : 2 ≤ L) : (∑ idx : Fin L, simplexWeight L idx*slackRowRadius idx) = 2*(∑ idx : Fin L, simplexWeight L idx)-(∑ j : Fin L, fordWeight (j.val+1)) := by have hc (j : Fin L) : (∑ idx : Fin L, simplexWeight L idx*tailWeight idx j) = simplexWeight L j-fordWeight (j.val+1) := by have h := simplexWeight_tail_column hL j simp only [coeff, Nat.add_eq_zero_iff, Nat.one_ne_zero, and_false, ↓reduceIte] at h linarith calc _ = (∑ idx : Fin L, simplexWeight L idx)+ ∑ idx : Fin L, ∑ j : Fin L, simplexWeight L idx*tailWeight idx j := by simp [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordGeometry.slackMap_apply, slackRowRadius, mul_add, Finset.mul_sum, Finset.sum_add_distrib] _ = (∑ idx : Fin L, simplexWeight L idx)+ ∑ j : Fin L, ∑ idx : Fin L, simplexWeight L idx*tailWeight idx j := by rw [Finset.sum_comm] _ = _ := by simp_rw [hc]; rw [Finset.sum_sub_distrib]; ring /- Original line 29934: Erdos416Proof.FordGeometry.thickSlack_nonneg -/ theorem thickSlack_nonneg {τ : ℝ} {x e : Fin L → ℝ} (hx : x ∈ unorderedSimplex L) (he : e ∈ errorCube L τ) (idx : Fin L) : 0 ≤ thickSlack L τ (x+e) idx := by have htail : tailForm idx e ≤ (∑ j, tailWeight idx j)*τ := (le_abs_self _).trans (weightedForm_errorCube_bound (tailWeight idx) (tailWeight_nonneg idx) he) have hxi := hx.2 idx have hei := he.1 idx simp only [thickSlack, map_add, Pi.add_apply, slackMap_apply, slackShift, slackRowRadius] nlinarith /- Original line 29944: Erdos416Proof.FordGeometry.thickSlack_image_subset -/ theorem thickSlack_image_subset (hL : 2 ≤ L) (τ : ℝ) : thickSlack L τ '' (unorderedSimplex L+errorCube L τ) ⊆ weightedSimplex L (simplexWeight L) (1+2*τ*∑ j, simplexWeight L j) := by rintro y ⟨z, hz, rfl⟩ obtain ⟨x, hx, e, he, rfl⟩ := Set.mem_add.mp hz refine ⟨fun idx => thickSlack_nonneg hx he idx, ?_⟩ have hshift : (∑ idx, simplexWeight L idx*slackShift L τ idx) = τ*∑ idx : Fin L, simplexWeight L idx*slackRowRadius idx := by simp [Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordGeometry.slackEquiv_apply, Erdos416Proof.FordGeometry.slackMap_apply, slackShift, Finset.mul_sum, mul_left_comm] have hw : (∑ idx, simplexWeight L idx*thickSlack L τ (x+e) idx) = outerForm L (x+e)+τ*∑ idx : Fin L, simplexWeight L idx*slackRowRadius idx := by simp only [thickSlack, Pi.add_apply, mul_add, Finset.sum_add_distrib, weighted_slack_eq_outer hL, hshift] rw [hw, slackRowRadius_weight_sum hL, map_add] have ho : outerForm L e ≤ (∑ j : Fin L, fordWeight (j.val+1))*τ := (le_abs_self _).trans (weightedForm_errorCube_bound (fun j : Fin L => fordWeight (j.val+1)) (fun j => (fordWeight_bounds (by omega)).1) he) have hx1 := hx.1 nlinarith /- Original line 29964: Erdos416Proof.FordGeometry.thickSlack_volume_image -/ theorem thickSlack_volume_image (τ : ℝ) (s : Set (Fin L → ℝ)) : volume.real (thickSlack L τ '' s) = volume.real s := by have he : thickSlack L τ '' s = (fun y => y+slackShift L τ) '' (slackMap L '' s) := by rw [Set.image_image]; rfl rw [he, measureReal_def, Set.image_add_right, measure_preimage_add_right, ← measureReal_def, slack_volume_image] /- Original line 29971: Erdos416Proof.FordGeometry.thickened_unordered_volume -/ theorem thickened_unordered_volume (hL : 2 ≤ L) {τ : ℝ} (hτ : 0 ≤ τ) : volume.real (unorderedSimplex L+errorCube L τ) ≤ (1+2*τ*∑ j : Fin L, simplexWeight L j)^L*TStar L := by have hs : 0 ≤ ∑ j : Fin L, simplexWeight L j := Finset.sum_nonneg (fun j _ => (simplexWeight_pos j).le) have ht : 0 ≤ 1+2*τ*∑ j : Fin L, simplexWeight L j := by positivity calc _ = volume.real (thickSlack L τ '' (unorderedSimplex L+errorCube L τ)) := (thickSlack_volume_image _ _).symm _ ≤ volume.real (weightedSimplex L (simplexWeight L) (1+2*τ*∑ j, simplexWeight L j)) := measureReal_mono (thickSlack_image_subset hL τ) (weightedSimplex_isCompact (fun j => simplexWeight_pos j) _).measure_lt_top.ne _ = _ := by rw [realVolume_weightedSimplex (fun j => simplexWeight_pos j) ht, TStar_eq hL, ← simplexWeight_product] ring /- Original line 29990: Erdos416Proof.FordGeometry.thickening_power_bound -/ theorem thickening_power_bound (hL : 2 ≤ L) {τ : ℝ} (hτ : 0 ≤ τ) (hsmall : τ ≤ 10*rho^L/(L : ℝ)) : (1+2*τ*∑ j : Fin L, simplexWeight L j)^L ≤ Real.exp 80 := by have hLpos : (0 : ℝ) < L := by exact_mod_cast (show 0 < L by omega) have hs : 0 ≤ ∑ j : Fin L, simplexWeight L j := Finset.sum_nonneg (fun j _ => (simplexWeight_pos j).le) have hτL := (le_div_iff₀ hLpos).mp hsmall have hprod := mul_le_mul_of_nonneg_right hτL hs have hsum := simplexWeight_scaled_sum_bound hL have hexp : (L : ℝ)*(2*τ*∑ j : Fin L, simplexWeight L j) ≤ 80 := by nlinarith calc _ ≤ (Real.exp (2*τ*∑ j : Fin L, simplexWeight L j))^L := pow_le_pow_left₀ (by positivity) (by linarith [Real.add_one_le_exp (2*τ*∑ j : Fin L, simplexWeight L j)]) L _ = Real.exp ((L : ℝ)*(2*τ*∑ j : Fin L, simplexWeight L j)) := by rw [Real.exp_nat_mul] _ ≤ _ := Real.exp_le_exp.mpr hexp /- Original line 30007: Erdos416Proof.FordGeometry.thickened_unordered_uniform_bound -/ theorem thickened_unordered_uniform_bound (hL : 2 ≤ L) {τ : ℝ} (hτ : 0 ≤ τ) (hsmall : τ ≤ 10*rho^L/(L : ℝ)) : volume.real (unorderedSimplex L+errorCube L τ) ≤ Real.exp 80*TStar L := (thickened_unordered_volume hL hτ).trans (mul_le_mul_of_nonneg_right (thickening_power_bound hL hτ hsmall) (TStar_pos hL).le) /- Original line 30013: Erdos416Proof.FordGeometry.normalized_mem_errorCube -/ theorem normalized_mem_errorCube {ξ : ℕ → ℝ} (hξ : ∀ j, 1 ≤ ξ j) {τ : ℝ} (hτ : 0 ≤ τ) {e : Fin L → ℝ} (he : e ∈ errorCube L τ) : normalized ξ e ∈ errorCube L τ := by have hp (idx : Fin L) : 0 < scaleProduct ξ (idx.val+1) := lt_of_lt_of_le zero_lt_one (prefix_ge_one hξ _) have ht (idx : Fin L) : τ ≤ τ*scaleProduct ξ (idx.val+1) := by nlinarith [prefix_ge_one hξ (idx.val+1)] constructor · intro idx change -τ ≤ e idx/scaleProduct ξ (idx.val+1) apply (le_div_iff₀ (hp idx)).mpr nlinarith [he.1 idx, ht idx] · intro idx change e idx/scaleProduct ξ (idx.val+1) ≤ τ apply (div_le_iff₀ (hp idx)).mpr exact (he.2 idx).trans (ht idx) /- Original line 30030: Erdos416Proof.FordGeometry.thickened_polytope_subset_diagonal -/ theorem thickened_polytope_subset_diagonal {ξ : ℕ → ℝ} (hξ : ∀ j, 1 ≤ ξ j) {τ : ℝ} (hτ : 0 ≤ τ) : polytope L ξ+errorCube L τ ⊆ diagonal L ξ '' (unorderedSimplex L+errorCube L τ) := by intro z hz obtain ⟨x, hx, e, he, rfl⟩ := Set.mem_add.mp hz refine ⟨normalized ξ x+normalized ξ e, Set.mem_add.mpr ⟨normalized ξ x, polytope_subset_unorderedSimplex L (normalized_mem hξ hx), normalized ξ e, normalized_mem_errorCube hξ hτ he, rfl⟩, ?_⟩ rw [map_add, diagonal_normalized (fun j => lt_of_lt_of_le zero_lt_one (hξ j)), diagonal_normalized (fun j => lt_of_lt_of_le zero_lt_one (hξ j))] /- Original line 30041: Erdos416Proof.FordGeometry.thickened_polytope_uniform_bound -/ theorem thickened_polytope_uniform_bound (hL : 2 ≤ L) {ξ : ℕ → ℝ} (hξ : ∀ j, 1 ≤ ξ j) {τ : ℝ} (hτ : 0 ≤ τ) (hsmall : τ ≤ 10*rho^L/(L : ℝ)) : volume.real (polytope L ξ+errorCube L τ) ≤ H L ξ*Real.exp 80*TStar L := by have hc : IsCompact (unorderedSimplex L+errorCube L τ) := (unorderedSimplex_isCompact hL).add isCompact_Icc have hH : 0 ≤ H L ξ := H_nonneg (fun j => le_trans zero_le_one (hξ j)) calc _ ≤ volume.real (diagonal L ξ '' (unorderedSimplex L+errorCube L τ)) := measureReal_mono (thickened_polytope_subset_diagonal hξ hτ) (hc.image (diagonal L ξ).continuous_of_finiteDimensional).measure_lt_top.ne _ = H L ξ*volume.real (unorderedSimplex L+errorCube L τ) := by rw [diagonal_volume, abs_of_nonneg hH] _ ≤ H L ξ*(Real.exp 80*TStar L) := mul_le_mul_of_nonneg_left (thickened_unordered_uniform_bound hL hτ hsmall) hH _ = _ := by ring /-- The uniform alpha=0 thickening estimate needed by the outer-facet argument. -/ /- Original line 30058: Erdos416Proof.FordGeometry.thickened_polytope_eventual_bound -/ theorem thickened_polytope_eventual_bound : ∀ᶠ L : ℕ in atTop, ∀ (ξ : ℕ → ℝ) (τ : ℝ), (∀ j, 1 ≤ ξ j) → H L ξ ≤ 2 → 0 ≤ τ → τ ≤ 10*rho^L/(L : ℝ) → volume.real (polytope L ξ+errorCube L τ) ≤ (44*Real.exp 80)*T L := by filter_upwards [T_eventually_ge_TStar_div, eventually_ge_atTop 2] with L hTL hL intro ξ τ hξ hH hτ hsmall have hT : TStar L ≤ 22*T L := by linarith calc _ ≤ H L ξ*Real.exp 80*TStar L := thickened_polytope_uniform_bound hL hξ hτ hsmall _ = H L ξ*(Real.exp 80*TStar L) := by ring _ ≤ 2*(Real.exp 80*TStar L) := mul_le_mul_of_nonneg_right hH (mul_nonneg (Real.exp_pos _).le (TStar_pos hL).le) _ ≤ 2*(Real.exp 80*(22*T L)) := mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_left hT (Real.exp_pos _).le) (by norm_num) _ = _ := by ring /- Original line 30074: Erdos416Proof.FordGeometry.exists_thickened_polytope_bound -/ theorem exists_thickened_polytope_bound : ∃ C : ℝ, 0 < C ∧ ∀ᶠ L : ℕ in atTop, ∀ (ξ : ℕ → ℝ) (τ : ℝ), (∀ j, 1 ≤ ξ j) → H L ξ ≤ 2 → 0 ≤ τ → τ ≤ 10*rho^L/(L : ℝ) → volume.real (polytope L ξ+errorCube L τ) ≤ C*T L := ⟨44*Real.exp 80, by positivity, thickened_polytope_eventual_bound⟩ /- Original line 30080: Erdos416Proof.FordGeometry.exists_uniform_outer_shell_bound -/ theorem exists_uniform_outer_shell_bound : ∃ C : ℝ, 0 < C ∧ ∀ᶠ L : ℕ in atTop, ∀ (ξ : ℕ → ℝ) (δ τ : ℝ), (∀ j, 1 ≤ ξ j) → H L ξ ≤ 2 → 0 ≤ δ → 0 ≤ τ → τ ≤ 10*rho^L/(L : ℝ) → volume.real ((polytope L ξ ∩ {x | 1-δ < outerForm L x})+errorCube L τ) ≤ C*L*(δ+ξ 0-1+(((L : ℝ)+1)*Real.log ((L : ℝ)+1)-L)*τ)*T L := by obtain ⟨K, hK, hbound⟩ := exists_thickened_polytope_bound refine ⟨2*K, by positivity, ?_⟩ filter_upwards [hbound, eventually_ge_atTop 2] with L hvol hL intro ξ δ τ hξ hH hδ hτ hsmall have hs : 0 ≤ ((L : ℝ)+1)*Real.log ((L : ℝ)+1)-L := by rw [← outer_weight_sum L] exact Finset.sum_nonneg (fun idx _ => (fordWeight_bounds (by omega)).1) have herr : 0 ≤ δ+ξ 0-1+(((L : ℝ)+1)*Real.log ((L : ℝ)+1)-L)*τ := add_nonneg (by linarith [hξ 0]) (mul_nonneg hs hτ) calc _ ≤ 2*L*(δ+ξ 0-1+(((L : ℝ)+1)*Real.log ((L : ℝ)+1)-L)*τ)* volume.real (polytope L ξ+errorCube L τ) := outer_shell_bound (by omega) (hξ 0) hδ hτ _ ≤ 2*L*(δ+ξ 0-1+(((L : ℝ)+1)*Real.log ((L : ℝ)+1)-L)*τ)*(K*T L) := mul_le_mul_of_nonneg_left (hvol ξ τ hξ hH hτ hsmall) (by positivity) _ = _ := by ring end Erdos416Proof.FordGeometry /- The actual Ford dimension, its growth and admissible mesh, and the vanishing geometric strict-facet loss at that scale. -/ open Filter Finset MeasureTheory open scoped Topology BigOperators Classical Pointwise namespace Erdos416Proof.FordScale open FordAnalysis FordGeometry /-- Ford's principal dimension, with t=log_2(y) in the arithmetic application. -/ /- Original line 30119: Erdos416Proof.FordScale.optimalDimension -/ noncomputable def optimalDimension (t : ℝ) : ℕ := ⌊2*C*(Real.log t-Real.log (Real.log t))⌋₊ /-- The actual dimension after fixing the tail parameter M. -/ /- Original line 30123: Erdos416Proof.FordScale.coreDimension -/ noncomputable def coreDimension (M : ℕ) (t : ℝ) : ℕ := optimalDimension t-M /- Original line 30125: Erdos416Proof.FordScale.two_C_mul_log_rho -/ theorem two_C_mul_log_rho : (2*C)*Real.log rho = -1 := by have hlog := Real.log_neg rho_pos rho_lt_one unfold C rw [abs_of_neg hlog] field_simp [hlog.ne] /- Original line 30131: Erdos416Proof.FordScale.two_C_lt_four -/ theorem two_C_lt_four : 2*C < 4 := by have hlog : Real.log rho < -(1/4 : ℝ) := by linarith [Real.log_le_sub_one_of_pos rho_pos, rho_lt_three_quarters] have h := mul_lt_mul_of_pos_left hlog (mul_pos (by norm_num : (0 : ℝ) < 2) C_pos) rw [two_C_mul_log_rho] at h linarith /- Original line 30138: Erdos416Proof.FordScale.optimalDimension_real_le -/ theorem optimalDimension_real_le {t : ℝ} (ht : 1 < t) : (optimalDimension t : ℝ) ≤ 2*C*(Real.log t-Real.log (Real.log t)) := by have hu := Real.log_pos ht have hdiff : 0 ≤ Real.log t-Real.log (Real.log t) := by linarith [Real.log_le_sub_one_of_pos hu] exact Nat.floor_le (mul_nonneg (mul_pos (by norm_num) C_pos).le hdiff) /- Original line 30145: Erdos416Proof.FordScale.coreDimension_real_le -/ theorem coreDimension_real_le (M : ℕ) {t : ℝ} (ht : 1 < t) : (coreDimension M t : ℝ) ≤ 2*C*(Real.log t-Real.log (Real.log t)) := (Nat.cast_le.mpr (Nat.sub_le (optimalDimension t) M)).trans (optimalDimension_real_le ht) /- Original line 30149: Erdos416Proof.FordScale.coreDimension_le_log -/ theorem coreDimension_le_log (M : ℕ) {t : ℝ} (ht : Real.exp 1 ≤ t) : (coreDimension M t : ℝ) ≤ 2*C*Real.log t := by have ht1 : 1 < t := (Real.one_lt_exp_iff.mpr (by norm_num : (0 : ℝ) < 1)).trans_le ht have hu : 1 ≤ Real.log t := by calc _ = Real.log (Real.exp 1) := (Real.log_exp 1).symm _ ≤ _ := Real.log_le_log (Real.exp_pos _) ht have huu := Real.log_nonneg hu exact (coreDimension_real_le M ht1).trans (mul_le_mul_of_nonneg_left (by linarith) (mul_pos (by norm_num) C_pos).le) /- Original line 30160: Erdos416Proof.FordScale.coreDimension_rho_lower -/ theorem coreDimension_rho_lower (M : ℕ) {t : ℝ} (ht : 1 < t) : Real.log t/t ≤ rho^(coreDimension M t) := by have hlog := Real.log_neg rho_pos rho_lt_one have hm := mul_le_mul_of_nonpos_right (coreDimension_real_le M ht) hlog.le have he : (2*C*(Real.log t-Real.log (Real.log t)))*Real.log rho = Real.log (Real.log t)-Real.log t := by calc _ = ((2*C)*Real.log rho)*(Real.log t-Real.log (Real.log t)) := by ring _ = _ := by rw [two_C_mul_log_rho]; ring rw [he] at hm calc _ = Real.exp (Real.log (Real.log t)-Real.log t) := by rw [Real.exp_sub, Real.exp_log (Real.log_pos ht), Real.exp_log (by linarith)] _ ≤ Real.exp ((coreDimension M t : ℝ)*Real.log rho) := Real.exp_le_exp.mpr hm _ = _ := by rw [Real.exp_nat_mul, Real.exp_log rho_pos] /- Original line 30176: Erdos416Proof.FordScale.coreDimension_mesh_bound -/ theorem coreDimension_mesh_bound (M : ℕ) {t : ℝ} (ht : Real.exp 1 ≤ t) (hL : 1 ≤ coreDimension M t) : 1/t ≤ 10*rho^(coreDimension M t)/(coreDimension M t : ℝ) := by have ht1 : 1 < t := (Real.one_lt_exp_iff.mpr (by norm_num : (0 : ℝ) < 1)).trans_le ht have htpos : 0 < t := by linarith have hLpos : (0 : ℝ) < coreDimension M t := by exact_mod_cast (show 0 < coreDimension M t by omega) have hdim : (coreDimension M t : ℝ) ≤ 4*Real.log t := (coreDimension_le_log M ht).trans (mul_le_mul_of_nonneg_right two_C_lt_four.le (Real.log_pos ht1).le) have hdiv := div_le_div_of_nonneg_right hdim htpos.le have hrho := coreDimension_rho_lower M ht1 have hlogdiv : 0 ≤ Real.log t/t := (div_pos (Real.log_pos ht1) htpos).le apply (le_div_iff₀ hLpos).mpr calc _ = (coreDimension M t : ℝ)/t := by ring _ ≤ 4*Real.log t/t := hdiv _ ≤ 10*rho^(coreDimension M t) := by rw [mul_div_assoc]; nlinarith /- Original line 30193: Erdos416Proof.FordScale.log_argument_tendsto -/ theorem log_argument_tendsto : Tendsto (fun u : ℝ => u-Real.log u) atTop atTop := by have hlo : ∀ᶠ u : ℝ in atTop, u/2 ≤ u-Real.log u := by filter_upwards [Real.isLittleO_log_id_atTop.def (by norm_num : (0 : ℝ) < 1/2), eventually_ge_atTop (1 : ℝ)] with u hu hu1 simp only [Real.norm_eq_abs, id_eq, abs_of_nonneg (by linarith : 0 ≤ u)] at hu have hl := le_abs_self (Real.log u) linarith exact tendsto_atTop_mono' atTop hlo (tendsto_id.atTop_div_const (by norm_num : (0 : ℝ) < 2)) /- Original line 30203: Erdos416Proof.FordScale.optimalDimension_tendsto -/ theorem optimalDimension_tendsto : Tendsto optimalDimension atTop atTop := by have h := (log_argument_tendsto.comp Real.tendsto_log_atTop).const_mul_atTop (mul_pos (by norm_num : (0 : ℝ) < 2) C_pos) exact tendsto_nat_floor_atTop.comp h /- Original line 30208: Erdos416Proof.FordScale.coreDimension_tendsto -/ theorem coreDimension_tendsto (M : ℕ) : Tendsto (coreDimension M) atTop atTop := (tendsto_sub_atTop_nat M).comp optimalDimension_tendsto /- Original line 30211: Erdos416Proof.FordScale.coreDimension_eventual_mesh -/ theorem coreDimension_eventual_mesh (M : ℕ) : ∀ᶠ t : ℝ in atTop, 2 ≤ coreDimension M t ∧ 1/t ≤ 10*rho^(coreDimension M t)/(coreDimension M t : ℝ) := by filter_upwards [(coreDimension_tendsto M).eventually (eventually_ge_atTop 2), eventually_ge_atTop (Real.exp 1)] with t hL ht exact ⟨hL, coreDimension_mesh_bound M ht (by omega)⟩ /- Original line 30218: Erdos416Proof.FordScale.coreDimension_add_tail -/ theorem coreDimension_add_tail (M : ℕ) : ∀ᶠ t : ℝ in atTop, coreDimension M t+M=optimalDimension t := by filter_upwards [optimalDimension_tendsto.eventually (eventually_ge_atTop M)] with t ht exact Nat.sub_add_cancel ht /- Original line 30223: Erdos416Proof.FordScale.thickened_volume_at_core_scale -/ theorem thickened_volume_at_core_scale : ∀ᶠ M : ℕ in atTop, ∀ᶠ t : ℝ in atTop, volume.real (polytope (coreDimension M t) (expandedParameter (optimalDimension t))+ errorCube (coreDimension M t) (1/t)) ≤ (44*Real.exp 80)*T (coreDimension M t) := by filter_upwards [expanded_H_eventually] with M hM have hbound := (coreDimension_tendsto M).eventually thickened_polytope_eventual_bound filter_upwards [hbound, coreDimension_eventual_mesh M, coreDimension_add_tail M, eventually_ge_atTop (Real.exp 1)] with t hb hmesh hadd ht have hH : H (coreDimension M t) (expandedParameter (optimalDimension t)) ≤ 2 := by rw [← hadd] exact hM (coreDimension M t) exact hb (expandedParameter (optimalDimension t)) (1/t) (expandedParameter_ge_one _) hH (one_div_nonneg.mpr ((Real.exp_pos _).le.trans ht)) hmesh.2 /-- The actual shell error factor at the manuscript's dimension and mesh. -/ /- Original line 30238: Erdos416Proof.FordScale.coreShellFraction -/ noncomputable def coreShellFraction (M : ℕ) (t : ℝ) : ℝ := (coreDimension M t : ℝ)*(t^(-1/8 : ℝ)+expandedParameter (optimalDimension t) 0-1+ (((coreDimension M t : ℝ)+1)*Real.log ((coreDimension M t : ℝ)+1)-coreDimension M t)/t) /- Original line 30242: Erdos416Proof.FordScale.outer_shell_at_core_scale -/ theorem outer_shell_at_core_scale : ∃ K : ℝ, 0 < K ∧ ∀ᶠ M : ℕ in atTop, ∀ᶠ t : ℝ in atTop, volume.real ((polytope (coreDimension M t) (expandedParameter (optimalDimension t)) ∩ {x | 1-t^(-1/8 : ℝ) < outerForm (coreDimension M t) x})+ errorCube (coreDimension M t) (1/t)) ≤ K*coreShellFraction M t*T (coreDimension M t) := by obtain ⟨K, hK, hbound⟩ := exists_uniform_outer_shell_bound refine ⟨K, hK, ?_⟩ filter_upwards [expanded_H_eventually] with M hM filter_upwards [(coreDimension_tendsto M).eventually hbound, coreDimension_eventual_mesh M, coreDimension_add_tail M, eventually_ge_atTop (Real.exp 1)] with t hb hmesh hadd ht have htpos : 0 < t := lt_of_lt_of_le (Real.exp_pos _) ht have hH : H (coreDimension M t) (expandedParameter (optimalDimension t)) ≤ 2 := by rw [← hadd] exact hM (coreDimension M t) have h := hb (expandedParameter (optimalDimension t)) (t^(-1/8 : ℝ)) (1/t) (expandedParameter_ge_one _) hH (Real.rpow_nonneg htpos.le _) (one_div_nonneg.mpr htpos.le) hmesh.2 convert h using 1 unfold coreShellFraction ring /- Original line 30265: Erdos416Proof.FordScale.coreDimension_le_four_log -/ theorem coreDimension_le_four_log (M : ℕ) {t : ℝ} (ht : Real.exp 1 ≤ t) : (coreDimension M t : ℝ) ≤ 4*Real.log t := by have ht1 : 1 < t := (Real.one_lt_exp_iff.mpr (by norm_num : (0 : ℝ) < 1)).trans_le ht exact (coreDimension_le_log M ht).trans (mul_le_mul_of_nonneg_right two_C_lt_four.le (Real.log_pos ht1).le) /- Original line 30271: Erdos416Proof.FordScale.core_dimension_width_tendsto -/ theorem core_dimension_width_tendsto (M : ℕ) : Tendsto (fun t : ℝ => (coreDimension M t : ℝ)*t^(-1/8 : ℝ)) atTop (nhds 0) := by have hratio := (isLittleO_log_rpow_atTop (by norm_num : (0 : ℝ) < 1/8)).tendsto_div_nhds_zero have hlim : Tendsto (fun t : ℝ => 4*Real.log t*t^(-1/8 : ℝ)) atTop (nhds 0) := by have h := hratio.const_mul 4 simp only [mul_zero] at h apply h.congr' filter_upwards [eventually_ge_atTop (0 : ℝ)] with t ht rw [show (-1/8 : ℝ)=-(1/8) by ring, Real.rpow_neg ht] ring refine squeeze_zero' ?_ ?_ hlim · filter_upwards [eventually_ge_atTop (0 : ℝ)] with t ht exact mul_nonneg (Nat.cast_nonneg _) (Real.rpow_nonneg ht _) · filter_upwards [eventually_ge_atTop (Real.exp 1)] with t ht exact mul_le_mul_of_nonneg_right (coreDimension_le_four_log M ht) (Real.rpow_nonneg ((Real.exp_pos _).le.trans ht) _) /- Original line 30288: Erdos416Proof.FordScale.outer_mass_nonneg -/ theorem outer_mass_nonneg (L : ℕ) : 0 ≤ ((L : ℝ)+1)*Real.log ((L : ℝ)+1)-L := by rw [← outer_weight_sum L] exact Finset.sum_nonneg (fun idx _ => (fordWeight_bounds (by omega)).1) /- Original line 30293: Erdos416Proof.FordScale.outer_mass_le_sq -/ theorem outer_mass_le_sq (L : ℕ) : ((L : ℝ)+1)*Real.log ((L : ℝ)+1)-L ≤ (L : ℝ)^2 := by have hlog := Real.log_le_sub_one_of_pos (by positivity : (0 : ℝ) < (L : ℝ)+1) have h := mul_le_mul_of_nonneg_left hlog (by positivity : (0 : ℝ) ≤ (L : ℝ)+1) nlinarith /- Original line 30299: Erdos416Proof.FordScale.core_dimension_mesh_error_tendsto -/ theorem core_dimension_mesh_error_tendsto (M : ℕ) : Tendsto (fun t : ℝ => (coreDimension M t : ℝ)* (((coreDimension M t : ℝ)+1)*Real.log ((coreDimension M t : ℝ)+1)-coreDimension M t)/t) atTop (nhds 0) := by have hlim : Tendsto (fun t : ℝ => 64*Real.log t^3/t) atTop (nhds 0) := by have h := (Real.tendsto_pow_log_div_mul_add_atTop 1 0 3 one_ne_zero).const_mul 64 simpa only [one_mul, add_zero, mul_zero, ← mul_div_assoc] using h refine squeeze_zero' ?_ ?_ hlim · filter_upwards [eventually_ge_atTop (0 : ℝ)] with t ht exact div_nonneg (mul_nonneg (Nat.cast_nonneg _) (outer_mass_nonneg _)) ht · filter_upwards [eventually_ge_atTop (Real.exp 1)] with t ht have ht0 : 0 ≤ t := (Real.exp_pos _).le.trans ht have hL0 : (0 : ℝ) ≤ coreDimension M t := Nat.cast_nonneg _ calc _ ≤ (coreDimension M t : ℝ)*(coreDimension M t : ℝ)^2/t := div_le_div_of_nonneg_right (mul_le_mul_of_nonneg_left (outer_mass_le_sq _) hL0) ht0 _ = (coreDimension M t : ℝ)^3/t := by ring _ ≤ (4*Real.log t)^3/t := div_le_div_of_nonneg_right (pow_le_pow_left₀ hL0 (coreDimension_le_four_log M ht) 3) ht0 _ = _ := by ring /- Original line 30320: Erdos416Proof.FordScale.core_dimension_outer_perturbation_tendsto -/ theorem core_dimension_outer_perturbation_tendsto (M : ℕ) : Tendsto (fun t : ℝ => (coreDimension M t : ℝ)* (expandedParameter (optimalDimension t) 0-1)) atTop (nhds 0) := by apply ((expanded_outer_decay M).comp (coreDimension_tendsto M)).congr' filter_upwards [coreDimension_add_tail M] with t ht simp only [Function.comp_def, ht] /- Original line 30327: Erdos416Proof.FordScale.coreShellFraction_tendsto_zero -/ theorem coreShellFraction_tendsto_zero (M : ℕ) : Tendsto (coreShellFraction M) atTop (nhds 0) := by have h := ((core_dimension_width_tendsto M).add (core_dimension_outer_perturbation_tendsto M)).add (core_dimension_mesh_error_tendsto M) convert! h using 1 · funext t unfold coreShellFraction ring · norm_num /-- The strict-facet shell is negligible at the actual dimension, width and mesh. -/ /- Original line 30338: Erdos416Proof.FordScale.outer_shell_at_core_scale_negligible -/ theorem outer_shell_at_core_scale_negligible : ∀ᶠ M : ℕ in atTop, (fun t : ℝ => volume.real ((polytope (coreDimension M t) (expandedParameter (optimalDimension t)) ∩ {x | 1-t^(-1/8 : ℝ) < outerForm (coreDimension M t) x})+ errorCube (coreDimension M t) (1/t))) =o[atTop] (fun t : ℝ => T (coreDimension M t)) := by obtain ⟨K, hK, hbound⟩ := outer_shell_at_core_scale filter_upwards [hbound] with M hM apply Asymptotics.IsLittleO.of_bound intro ε hε have he := (coreShellFraction_tendsto_zero M).eventually_lt_const (div_pos hε hK) filter_upwards [hM, he] with t hvol herr have hcoef : K*coreShellFraction M t ≤ ε := by have h := (lt_div_iff₀ hK).mp herr nlinarith simp only [Real.norm_eq_abs, T, abs_of_nonneg measureReal_nonneg] exact hvol.trans (mul_le_mul_of_nonneg_right hcoef (measureReal_nonneg : 0 ≤ T (coreDimension M t))) end Erdos416Proof.FordScale /- Actual reciprocal-totient sums in prime bins: prime-power removal, uniform multiplicity bounds and the dimension-independent product estimate. The tuple-to-volume interpretation and totient structural inputs remain. -/ open Filter Finset MeasureTheory open scoped Topology BigOperators Classical namespace Erdos416Proof.FordReciprocal /-- The proved quantitative reciprocal-prime estimate, retaining its constant term. -/ /- Original line 30370: Erdos416Proof.FordReciprocal.exists_prime_reciprocal_log_error -/ theorem exists_prime_reciprocal_log_error : ∃ B K : ℝ, 0 < K ∧ ∀ x : ℝ, 2 ≤ x → |(∑ p ∈ Nat.primesLE ⌊x⌋₊, (1 : ℝ)/p)-logLog x-B| ≤ K/Real.log x := by refine ⟨Mertens.M, Real.log 4+6+Mertens.E₁, ?_, ?_⟩ · have hlog : 0 ≤ Real.log (4 : ℝ) := Real.log_nonneg (by norm_num) linarith [Mertens.E₁.nonneg] · intro x hx simpa only [primesLE_eq_Ioc_filter, logLog, Mertens.E₂p] using Mertens.E₂p.abs_le hx /-- The full weight of occurrences of a fixed prime in a reciprocal-totient sum. -/ /- Original line 30380: Erdos416Proof.FordReciprocal.primeOccurrenceWeight -/ noncomputable def primeOccurrenceWeight (p : ℕ) : ℝ := (p : ℝ)^2/((p : ℝ)-1)^3 /- Original line 30382: Erdos416Proof.FordReciprocal.hasSum_prime_occurrence -/ theorem hasSum_prime_occurrence {p : ℕ} (hp : p.Prime) : HasSum (fun k : ℕ => (k : ℝ)*invTotient (p^k)) (primeOccurrenceWeight p) := by have hp1 : 1 < (p : ℝ) := by exact_mod_cast hp.one_lt have hp0 : 0 < (p : ℝ) := by linarith have hd : (p : ℝ)-1 ≠ 0 := by linarith have hr : ‖(p : ℝ)⁻¹‖ < 1 := by rw [Real.norm_eq_abs, abs_of_pos (inv_pos.mpr hp0)] exact (inv_lt_one₀ hp0).mpr hp1 have h := (hasSum_coe_mul_geometric_of_norm_lt_one hr).mul_left ((p : ℝ)/((p : ℝ)-1)) convert! h using 1 · funext k cases k with | zero => simp[Erdos416Proof.invTotient_one, Erdos416Proof.weightedInvTotient_one] | succ k => rw [invTotient_prime_pow_succ hp] simp only [Nat.cast_add, Nat.cast_one, pow_succ] field_simp [hp0.ne', hd] · unfold primeOccurrenceWeight field_simp [hp0.ne', hd] /- Original line 30402: Erdos416Proof.FordReciprocal.prime_occurrence_partial -/ theorem prime_occurrence_partial {p : ℕ} (hp : p.Prime) (j : ℕ) : (∑ k ∈ Icc 1 j, (k : ℝ)*invTotient (p^k)) ≤ primeOccurrenceWeight p := by rw [← (hasSum_prime_occurrence hp).tsum_eq] exact (hasSum_prime_occurrence hp).summable.sum_le_tsum _ (fun k _ => mul_nonneg (Nat.cast_nonneg k) (invTotient_nonneg _)) /-- The actual integers supported on P with exactly j prime factors, with multiplicity. -/ /- Original line 30410: Erdos416Proof.FordReciprocal.binNumbers -/ noncomputable def binNumbers (P : Finset ℕ) (j : ℕ) : Finset ℕ := (Icc 1 ((P.sup id)^j)).filter (fun n => n.primeFactors ⊆ P ∧ ArithmeticFunction.cardFactors n = j) /- Original line 30414: Erdos416Proof.FordReciprocal.binMass -/ noncomputable def binMass (P : Finset ℕ) (j : ℕ) : ℝ := ∑ n ∈ binNumbers P j, invTotient n /- Original line 30417: Erdos416Proof.FordReciprocal.le_support_pow -/ theorem le_support_pow {P : Finset ℕ} {n : ℕ} (hn : n ≠ 0) (hs : n.primeFactors ⊆ P) : n ≤ (P.sup id)^(ArithmeticFunction.cardFactors n) := by simpa only [Nat.prod_primeFactorsList hn, ArithmeticFunction.cardFactors_apply] using List.prod_le_pow_card n.primeFactorsList (P.sup id) (fun p hp => Finset.le_sup (f := id) (hs (Nat.mem_primeFactors_iff_mem_primeFactorsList.mpr hp))) /- Original line 30424: Erdos416Proof.FordReciprocal.mem_binNumbers -/ theorem mem_binNumbers {P : Finset ℕ} {j n : ℕ} : n ∈ binNumbers P j ↔ n ≠ 0 ∧ n.primeFactors ⊆ P ∧ ArithmeticFunction.cardFactors n = j := by simp only [binNumbers, mem_filter, mem_Icc] constructor · rintro ⟨⟨hn, _⟩, hs, hj⟩ exact ⟨by omega, hs, hj⟩ · rintro ⟨hn, hs, hj⟩ refine ⟨⟨by omega, ?_⟩, hs, hj⟩ simpa only [hj] using le_support_pow hn hs /- Original line 30435: Erdos416Proof.FordReciprocal.binNumbers_zero -/ theorem binNumbers_zero (P : Finset ℕ) : binNumbers P 0 = {1} := by ext n simp only [mem_binNumbers, mem_singleton] constructor · rintro ⟨hn, _, hj⟩ exact (ArithmeticFunction.cardFactors_eq_zero_iff_eq_zero_or_one.mp hj).resolve_left hn · rintro rfl simp /- Original line 30444: Erdos416Proof.FordReciprocal.binNumbers_one -/ theorem binNumbers_one {P : Finset ℕ} (hP : ∀ p ∈ P, p.Prime) : binNumbers P 1 = P := by ext n rw [mem_binNumbers] constructor · rintro ⟨_, hs, hj⟩ have hp := ArithmeticFunction.cardFactors_eq_one_iff_prime.mp hj exact hs (by simp [Erdos416Proof.FordReciprocal.binNumbers_zero, hp.primeFactors]) · intro hn have hp := hP n hn exact ⟨hp.ne_zero, by simpa only [hp.primeFactors, singleton_subset_iff] using hn, ArithmeticFunction.cardFactors_apply_prime hp⟩ /- Original line 30457: Erdos416Proof.FordReciprocal.binMass_zero -/ theorem binMass_zero (P : Finset ℕ) : binMass P 0 = 1 := by simp [Erdos416Proof.FordReciprocal.binNumbers_zero, Erdos416Proof.invTotient_one, Erdos416Proof.weightedInvTotient_one, binMass] /- Original line 30460: Erdos416Proof.FordReciprocal.binMass_one -/ theorem binMass_one {P : Finset ℕ} (hP : ∀ p ∈ P, p.Prime) : binMass P 1 = ∑ p ∈ P, ((p : ℝ)-1)⁻¹ := by rw [binMass, binNumbers_one hP] apply sum_congr rfl intro p hp simp [Erdos416Proof.FordReciprocal.binMass_zero, Erdos416Proof.FordReciprocal.binNumbers_zero, Erdos416Proof.invTotient_one, Erdos416Proof.weightedInvTotient_one, invTotient, Nat.totient_prime (hP p hp), Nat.cast_sub (hP p hp).one_le] /- Original line 30467: Erdos416Proof.FordReciprocal.binMass_nonneg -/ theorem binMass_nonneg (P : Finset ℕ) (j : ℕ) : 0 ≤ binMass P j := sum_nonneg fun n _ => invTotient_nonneg n /- Original line 30470: Erdos416Proof.FordReciprocal.factorization_sum_of_support -/ theorem factorization_sum_of_support {P : Finset ℕ} {n : ℕ} (hs : n.primeFactors ⊆ P) : (∑ p ∈ P, n.factorization p) = ArithmeticFunction.cardFactors n := by rw [ArithmeticFunction.cardFactors_eq_sum_factorization, Finsupp.sum, Nat.support_factorization] symm exact sum_subset hs (fun p _ hp => by apply Finsupp.notMem_support_iff.mp simpa only [Nat.support_factorization] using hp) /- Original line 30480: Erdos416Proof.FordReciprocal.factorization_le_bin_degree -/ theorem factorization_le_bin_degree {P : Finset ℕ} {j n p : ℕ} (hn : n ∈ binNumbers P j) (hp : p ∈ P) : n.factorization p ≤ j := by obtain ⟨_, hs, hj⟩ := mem_binNumbers.mp hn rw [← hj, ← factorization_sum_of_support hs] exact single_le_sum (fun _ _ => Nat.zero_le _) hp /- Original line 30486: Erdos416Proof.FordReciprocal.ordCompl_mem_binNumbers -/ theorem ordCompl_mem_binNumbers {P : Finset ℕ} {j n p : ℕ} (hn : n ∈ binNumbers P j) (hp : p.Prime) : ordCompl[p] n ∈ binNumbers P (j-n.factorization p) := by obtain ⟨hn0, hs, hj⟩ := mem_binNumbers.mp hn have hm0 := (Nat.ordCompl_pos p hn0).ne' have hprod := Nat.ordProj_mul_ordCompl_eq_self n p refine mem_binNumbers.mpr ⟨hm0, ?_, ?_⟩ · intro q hq obtain ⟨hqp, hqd, _⟩ := Nat.mem_primeFactors.mp hq exact hs (Nat.mem_primeFactors.mpr ⟨hqp, hqd.trans (Nat.ordCompl_dvd n p), hn0⟩) · have hc := ArithmeticFunction.cardFactors_mul (pow_ne_zero (n.factorization p) hp.ne_zero) hm0 rw [hprod, ArithmeticFunction.cardFactors_apply_prime_pow hp, hj] at hc omega /- Original line 30501: Erdos416Proof.FordReciprocal.invTotient_ordCompl -/ theorem invTotient_ordCompl {n p : ℕ} (hn : n ≠ 0) (hp : p.Prime) : invTotient n = invTotient (p^(n.factorization p))*invTotient (ordCompl[p] n) := by have hcop := (Nat.coprime_ordCompl hp hn).pow_left (n.factorization p) simpa only [Nat.ordProj_mul_ordCompl_eq_self] using invTotient_mul hcop /- Original line 30506: Erdos416Proof.FordReciprocal.bin_fiber_mass -/ theorem bin_fiber_mass {P : Finset ℕ} {j p k : ℕ} (hp : p.Prime) : (∑ n ∈ (binNumbers P j).filter (fun n => n.factorization p = k), invTotient n) ≤ invTotient (p^k)*binMass P (j-k) := by let F := (binNumbers P j).filter (fun n => n.factorization p = k) have hmap : ∀ n ∈ F, ordCompl[p] n ∈ binNumbers P (j-k) := by intro n hn obtain ⟨hn, hk⟩ := mem_filter.mp hn simpa only [hk] using ordCompl_mem_binNumbers hn hp have hinj : Set.InjOn (fun n => ordCompl[p] n) (F : Set ℕ) := by intro a ha b hb heq obtain ⟨_, hka⟩ := mem_filter.mp ha obtain ⟨_, hkb⟩ := mem_filter.mp hb have hpa := Nat.ordProj_mul_ordCompl_eq_self a p have hpb := Nat.ordProj_mul_ordCompl_eq_self b p rw [hka] at hpa rw [hkb] at hpb simp only [hka, hkb] at heq rw [← hpa, ← hpb, heq] calc _ = invTotient (p^k)*(∑ n ∈ F, invTotient (ordCompl[p] n)) := by rw [mul_sum] apply sum_congr rfl intro n hn obtain ⟨hn, hk⟩ := mem_filter.mp hn rw [invTotient_ordCompl (mem_binNumbers.mp hn).1 hp, hk] _ = invTotient (p^k)*(∑ m ∈ F.image (fun n => ordCompl[p] n), invTotient m) := by rw [sum_image hinj] _ ≤ invTotient (p^k)*binMass P (j-k) := by apply mul_le_mul_of_nonneg_left _ (invTotient_nonneg _) apply sum_le_sum_of_subset_of_nonneg · intro m hm obtain ⟨n, hn, rfl⟩ := mem_image.mp hm exact hmap n hn · exact fun m _ _ => invTotient_nonneg m /-- Marking every prime occurrence gives an upper recurrence for the actual integer sums. -/ /- Original line 30542: Erdos416Proof.FordReciprocal.binMass_recurrence -/ theorem binMass_recurrence {P : Finset ℕ} (hP : ∀ p ∈ P, p.Prime) (j : ℕ) : (j : ℝ)*binMass P j ≤ ∑ p ∈ P, ∑ k ∈ Icc 1 j, (k : ℝ)*invTotient (p^k)*binMass P (j-k) := by have hpoint : ∀ n ∈ binNumbers P j, (j : ℝ)*invTotient n = ∑ p ∈ P, (n.factorization p : ℝ)*invTotient n := by intro n hn obtain ⟨_, hs, hj⟩ := mem_binNumbers.mp hn rw [← sum_mul, ← Nat.cast_sum, factorization_sum_of_support hs, hj] calc _ = ∑ n ∈ binNumbers P j, ∑ p ∈ P, (n.factorization p : ℝ)*invTotient n := by rw [binMass, mul_sum] exact sum_congr rfl hpoint _ = ∑ p ∈ P, ∑ n ∈ binNumbers P j, (n.factorization p : ℝ)*invTotient n := sum_comm _ ≤ _ := by apply sum_le_sum intro p hp have hmap : ∀ n ∈ binNumbers P j, n.factorization p ∈ Icc 0 j := fun n hn => mem_Icc.mpr ⟨Nat.zero_le _, factorization_le_bin_degree hn hp⟩ have hsplit := sum_fiberwise_of_maps_to hmap (fun n => (n.factorization p : ℝ)*invTotient n) calc _ = ∑ k ∈ Icc 0 j, ∑ n ∈ (binNumbers P j).filter (fun n => n.factorization p = k), (n.factorization p : ℝ)*invTotient n := hsplit.symm _ = ∑ k ∈ Icc 0 j, (k : ℝ)*(∑ n ∈ (binNumbers P j).filter (fun n => n.factorization p = k), invTotient n) := by apply sum_congr rfl intro k _ rw [mul_sum] apply sum_congr rfl intro n hn rw [(mem_filter.mp hn).2] _ ≤ ∑ k ∈ Icc 0 j, (k : ℝ)*invTotient (p^k)*binMass P (j-k) := by apply sum_le_sum intro k _ rw [mul_assoc] exact mul_le_mul_of_nonneg_left (bin_fiber_mass (hP p hp)) (Nat.cast_nonneg k) _ = ∑ k ∈ Icc 1 j, (k : ℝ)*invTotient (p^k)*binMass P (j-k) := by symm apply sum_subset (Icc_subset_Icc (by omega) le_rfl) intro k hk hk' have hk0 : k = 0 := by simp only [mem_Icc] at hk hk' omega simp [Erdos416Proof.FordReciprocal.binMass_zero, Erdos416Proof.FordReciprocal.binNumbers_zero, Erdos416Proof.invTotient_one, Erdos416Proof.weightedInvTotient_one, hk0] /-- A small total occurrence weight bounds every multiplicity by the same constant. -/ /- Original line 30590: Erdos416Proof.FordReciprocal.binMass_uniform_of_occurrence_le_two -/ theorem binMass_uniform_of_occurrence_le_two {P : Finset ℕ} (hP : ∀ p ∈ P, p.Prime) (hD : (∑ p ∈ P, primeOccurrenceWeight p) ≤ 2) (j : ℕ) : binMass P j ≤ max 1 (∑ p ∈ P, ((p : ℝ)-1)⁻¹) := by let B : ℝ := max 1 (∑ p ∈ P, ((p : ℝ)-1)⁻¹) have hB : 0 ≤ B := zero_le_one.trans (le_max_left _ _) change binMass P j ≤ B induction j using Nat.strong_induction_on with | h j ih => by_cases hj0 : j = 0 · subst j exact (binMass_zero P).le.trans (le_max_left _ _) by_cases hj1 : j = 1 · subst j exact (binMass_one hP).le.trans (le_max_right _ _) have hj2 : 2 ≤ j := by omega have hsum : (∑ p ∈ P, ∑ k ∈ Icc 1 j, (k : ℝ)*invTotient (p^k)*binMass P (j-k)) ≤ (∑ p ∈ P, primeOccurrenceWeight p)*B := by calc _ ≤ ∑ p ∈ P, ∑ k ∈ Icc 1 j, (k : ℝ)*invTotient (p^k)*B := by apply sum_le_sum intro p _ apply sum_le_sum intro k hk have hk0 : 0 < k := (mem_Icc.mp hk).1 exact mul_le_mul_of_nonneg_left (ih (j-k) (Nat.sub_lt (by omega) hk0)) (mul_nonneg (Nat.cast_nonneg k) (invTotient_nonneg _)) _ = (∑ p ∈ P, ∑ k ∈ Icc 1 j, (k : ℝ)*invTotient (p^k))*B := by simp_rw [← sum_mul] _ ≤ _ := mul_le_mul_of_nonneg_right (sum_le_sum fun p hp => prime_occurrence_partial (hP p hp) j) hB have hjR : (2 : ℝ) ≤ j := by exact_mod_cast hj2 have hfinal : (j : ℝ)*binMass P j ≤ (j : ℝ)*B := calc _ ≤ _ := (binMass_recurrence hP j).trans hsum _ ≤ 2*B := mul_le_mul_of_nonneg_right hD hB _ ≤ _ := mul_le_mul_of_nonneg_right hjR hB have hjpos : (0 : ℝ) < j := by linarith exact (mul_le_mul_iff_of_pos_left hjpos).mp hfinal /-- The omitted cofactor coprimality condition only enlarges the actual bin sum. -/ /- Original line 30630: Erdos416Proof.FordReciprocal.finite_binMass_le -/ theorem finite_binMass_le {P F : Finset ℕ} {j : ℕ} (hF : ∀ n ∈ F, n ≠ 0 ∧ n.primeFactors ⊆ P ∧ ArithmeticFunction.cardFactors n = j) : (∑ n ∈ F, invTotient n) ≤ binMass P j := by apply sum_le_sum_of_subset_of_nonneg · exact fun n hn => mem_binNumbers.mpr (hF n hn) · exact fun n _ _ => invTotient_nonneg n /-- The prime-power occurrence weight differs from 1/p by a summable error. -/ /- Original line 30638: Erdos416Proof.FordReciprocal.prime_occurrence_le_reciprocal -/ theorem prime_occurrence_le_reciprocal {p : ℕ} (hp : p.Prime) : primeOccurrenceWeight p ≤ (1 : ℝ)/p+18/(p : ℝ)^2 := by have hp2 : (2 : ℝ) ≤ p := by exact_mod_cast hp.two_le have hp0 : (0 : ℝ) < p := by linarith have hd : (0 : ℝ) < (p : ℝ)-1 := by linarith have hpoly : (0 : ℝ) ≤ 15*((p : ℝ)-2)^3+39*((p : ℝ)-2)^2+29*((p : ℝ)-2)+4 := by positivity unfold primeOccurrenceWeight apply (div_le_iff₀ (pow_pos hd 3)).mpr field_simp [hp0.ne'] nlinarith /- Original line 30651: Erdos416Proof.FordReciprocal.shifted_reciprocal_le_occurrence -/ theorem shifted_reciprocal_le_occurrence {p : ℕ} (hp : p.Prime) : ((p : ℝ)-1)⁻¹ ≤ primeOccurrenceWeight p := by have hp2 : (2 : ℝ) ≤ p := by exact_mod_cast hp.two_le have hd : (0 : ℝ) < (p : ℝ)-1 := by linarith unfold primeOccurrenceWeight rw [← one_div] apply (div_le_div_iff₀ hd (pow_pos hd 3)).mpr nlinarith /-- A real lower cutoff, including integers exactly at that cutoff. -/ /- Original line 30661: Erdos416Proof.FordReciprocal.finite_inverse_square_tail_real -/ theorem finite_inverse_square_tail_real {Q : Finset ℕ} {u : ℝ} (hu : 2 ≤ u) (hQ : ∀ q ∈ Q, u ≤ (q : ℝ)) : (∑ q ∈ Q, (1 : ℝ)/(q : ℝ)^2) ≤ 4/u := by have hfloor : 0 < ⌊u⌋₊ := Nat.floor_pos.mpr (by linarith) apply (finite_inverse_square_tail Q hfloor (fun q hq => ?_)).trans · have hF : (0 : ℝ) < ⌊u⌋₊ := by exact_mod_cast hfloor apply (div_le_div_iff₀ hF (by linarith : 0 < u)).mpr have := Nat.lt_floor_add_one u linarith · exact_mod_cast (Nat.floor_le (by linarith : 0 ≤ u)).trans (hQ q hq) /-- Quantitative Mertens on a closed prime interval, retaining its lower endpoint. -/ /- Original line 30673: Erdos416Proof.FordReciprocal.prime_interval_reciprocal_upper -/ theorem prime_interval_reciprocal_upper {B K : ℝ} (hE : ∀ x : ℝ, 2 ≤ x → |(∑ p ∈ Nat.primesLE ⌊x⌋₊, (1 : ℝ)/p)-logLog x-B| ≤ K/Real.log x) {u v : ℝ} (hu : 2 ≤ u) (huv : u ≤ v) (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime ∧ u ≤ (p : ℝ) ∧ (p : ℝ) ≤ v) : (∑ p ∈ P, (1 : ℝ)/p) ≤ logLog v-logLog u+K/Real.log v+K/Real.log u+1/u := by let Q := (Nat.primesLE ⌊v⌋₊).filter (fun p : ℕ => u < (p : ℝ) ∧ (p : ℝ) ≤ v) have hsub : P ⊆ Q ∪ {⌈u⌉₊} := by intro p hp obtain ⟨hpp, hup, hpv⟩ := hP p hp by_cases hlt : u < (p : ℝ) · exact mem_union_left _ (mem_filter.mpr ⟨Nat.mem_primesLE.mpr ⟨Nat.le_floor hpv, hpp⟩, hlt, hpv⟩) · have heq : u = (p : ℝ) := le_antisymm hup (le_of_not_gt hlt) exact mem_union_right _ (by simp [Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, heq]) have hceil : (1 : ℝ)/(⌈u⌉₊ : ℝ) ≤ 1/u := by exact one_div_le_one_div_of_le (by linarith) (Nat.le_ceil u) have hsum : (∑ p ∈ P, (1 : ℝ)/p) ≤ (∑ p ∈ Q, (1 : ℝ)/p)+1/u := by calc _ ≤ ∑ p ∈ Q ∪ {⌈u⌉₊}, (1 : ℝ)/p := sum_le_sum_of_subset_of_nonneg hsub (fun _ _ _ => by positivity) _ ≤ (∑ p ∈ Q, (1 : ℝ)/p)+(∑ p ∈ {⌈u⌉₊}, (1 : ℝ)/p) := le_trans (le_add_of_nonneg_right (sum_nonneg (s := Q ∩ {⌈u⌉₊}) (fun _ _ => by positivity))) sum_union_inter.le _ ≤ _ := by simpa only [sum_singleton] using add_le_add_right hceil _ have hdiff : (∑ p ∈ Q, (1 : ℝ)/p) = (∑ p ∈ Nat.primesLE ⌊v⌋₊, (1 : ℝ)/p) - (∑ p ∈ Nat.primesLE ⌊u⌋₊, (1 : ℝ)/p) := by rw [show Q = _ from primesLE_filter_interval (by linarith) huv le_rfl, sum_sdiff_eq_sub (Nat.primesLE_mono (Nat.floor_mono huv))] rw [hdiff] at hsum have hvE := (abs_le.mp (hE v (hu.trans huv))).2 have huE := (abs_le.mp (hE u hu)).1 linarith /-- Prime bins for the clipped double-logarithm coordinates; the low bin includes 2. -/ /- Original line 30710: Erdos416Proof.FordReciprocal.primeBin -/ noncomputable def primeBin (m : ℕ) : Finset ℕ := (Nat.primesLE ⌊Real.exp (Real.exp ((m : ℝ)+1))⌋₊).filter (fun p => (m = 0 ∨ Real.exp (Real.exp (m : ℝ)) ≤ (p : ℝ)) ∧ (p : ℝ) < Real.exp (Real.exp ((m : ℝ)+1))) /- Original line 30715: Erdos416Proof.FordReciprocal.mem_primeBin -/ theorem mem_primeBin {m p : ℕ} : p ∈ primeBin m ↔ p.Prime ∧ (m = 0 ∨ Real.exp (Real.exp (m : ℝ)) ≤ (p : ℝ)) ∧ (p : ℝ) < Real.exp (Real.exp ((m : ℝ)+1)) := by simp only [primeBin, mem_filter, Nat.mem_primesLE] constructor · rintro ⟨⟨_, hp⟩, hlow, hhigh⟩ exact ⟨hp, hlow, hhigh⟩ · rintro ⟨hp, hlow, hhigh⟩ exact ⟨⟨Nat.le_floor hhigh.le, hp⟩, hlow, hhigh⟩ /- Original line 30726: Erdos416Proof.FordReciprocal.prime_of_mem_primeBin -/ theorem prime_of_mem_primeBin {m p : ℕ} (hp : p ∈ primeBin m) : p.Prime := (mem_primeBin.mp hp).1 /-- One error constant works for every positive bin, including both endpoint cases. -/ /- Original line 30730: Erdos416Proof.FordReciprocal.exists_primeBin_occurrence_bound -/ theorem exists_primeBin_occurrence_bound : ∃ K : ℝ, 0 < K ∧ ∀ m : ℕ, 1 ≤ m → (∑ p ∈ primeBin m, primeOccurrenceWeight p) ≤ 1+K*Real.exp (-(m : ℝ)) := by obtain ⟨B, K, hK, hE⟩ := exists_prime_reciprocal_log_error refine ⟨2*K+73, by linarith, ?_⟩ intro m hm let u := Real.exp (Real.exp (m : ℝ)) let v := Real.exp (Real.exp ((m : ℝ)+1)) have hexp : 1 ≤ Real.exp (m : ℝ) := Real.one_le_exp (Nat.cast_nonneg m) have hu : 2 ≤ u := by have he2 : (2 : ℝ) ≤ Real.exp 1 := by linarith [Real.add_one_le_exp (1 : ℝ)] exact he2.trans (Real.exp_le_exp.mpr hexp) have huv : u ≤ v := by exact Real.exp_le_exp.mpr (Real.exp_le_exp.mpr (by linarith)) have hP : ∀ p ∈ primeBin m, p.Prime ∧ u ≤ (p : ℝ) ∧ (p : ℝ) ≤ v := by intro p hp obtain ⟨hpp, hlow, hhigh⟩ := mem_primeBin.mp hp exact ⟨hpp, hlow.resolve_left (by omega), hhigh.le⟩ have hrec := prime_interval_reciprocal_upper hE hu huv (primeBin m) hP have htail := finite_inverse_square_tail_real hu (fun p hp => (hP p hp).2.1) have hKdiv : K/Real.exp ((m : ℝ)+1) ≤ K/Real.exp (m : ℝ) := div_le_div_of_nonneg_left hK.le (Real.exp_pos _) (Real.exp_le_exp.mpr (by linarith)) have hinv : (1 : ℝ)/u ≤ Real.exp (-(m : ℝ)) := by rw [Real.exp_neg, ← one_div] apply one_div_le_one_div_of_le (Real.exp_pos _) apply Real.exp_le_exp.mpr linarith [Real.add_one_le_exp (m : ℝ)] have hKscale : K/Real.exp (m : ℝ) = K*Real.exp (-(m : ℝ)) := by rw [Real.exp_neg, div_eq_mul_inv] simp only [u, v, logLog, Real.log_exp] at hrec rw [hKscale] at hKdiv hrec calc _ ≤ ∑ p ∈ primeBin m, ((1 : ℝ)/p+18/(p : ℝ)^2) := sum_le_sum fun p hp => prime_occurrence_le_reciprocal (hP p hp).1 _ = (∑ p ∈ primeBin m, (1 : ℝ)/p)+18*(∑ p ∈ primeBin m, (1 : ℝ)/(p : ℝ)^2) := by rw [sum_add_distrib, mul_sum] congr 1 apply sum_congr rfl intro p _ ring _ ≤ 1+(2*K+73)*Real.exp (-(m : ℝ)) := by have hrec' : (∑ p ∈ primeBin m, (1 : ℝ)/p) ≤ 1+2*K*Real.exp (-(m : ℝ))+1/u := by linarith have htail' : (∑ p ∈ primeBin m, (1 : ℝ)/(p : ℝ)^2) ≤ 4*(1/u) := by simpa only [div_eq_mul_inv, one_mul] using htail nlinarith /-- For all sufficiently high bins, the bound is uniform in the number of factors. -/ /- Original line 30778: Erdos416Proof.FordReciprocal.exists_eventual_primeBin_mass_bound -/ theorem exists_eventual_primeBin_mass_bound : ∃ K : ℝ, 0 < K ∧ ∀ᶠ m : ℕ in atTop, ∀ j : ℕ, binMass (primeBin m) j ≤ 1+K*Real.exp (-(m : ℝ)) := by obtain ⟨K, hK, hbound⟩ := exists_primeBin_occurrence_bound refine ⟨K, hK, ?_⟩ have hlim : Tendsto (fun m : ℕ => K*Real.exp (-(m : ℝ))) atTop (nhds 0) := by simpa only [mul_zero, Function.comp_apply] using! (Real.tendsto_exp_neg_atTop_nhds_zero.comp tendsto_natCast_atTop_atTop).const_mul K filter_upwards [eventually_ge_atTop 1, hlim.eventually (gt_mem_nhds (by norm_num : (0 : ℝ) < 1))] with m hm hsmall have hD := hbound m hm have hD2 : (∑ p ∈ primeBin m, primeOccurrenceWeight p) ≤ 2 := by linarith have hs : (∑ p ∈ primeBin m, ((p : ℝ)-1)⁻¹) ≤ 1+K*Real.exp (-(m : ℝ)) := (sum_le_sum fun p hp => shifted_reciprocal_le_occurrence (prime_of_mem_primeBin hp)).trans hD intro j exact (binMass_uniform_of_occurrence_le_two (fun _ hp => prime_of_mem_primeBin hp) hD2 j).trans (max_le (le_add_of_nonneg_right (mul_nonneg hK.le (Real.exp_nonneg _))) hs) /-- The complete convergent reciprocal-totient mass on a fixed finite prime support. -/ /- Original line 30797: Erdos416Proof.FordReciprocal.supportedMass -/ noncomputable def supportedMass (P : Finset ℕ) : ℝ := ∏ p ∈ P with p.Prime, (1+(p : ℝ)/((p : ℝ)-1)^2) /- Original line 30800: Erdos416Proof.FordReciprocal.one_le_supportedMass -/ theorem one_le_supportedMass (P : Finset ℕ) : 1 ≤ supportedMass P := by apply one_le_prod intro p _ exact le_add_of_nonneg_right (by positivity) /- Original line 30805: Erdos416Proof.FordReciprocal.finite_supported_mass_bound -/ theorem finite_supported_mass_bound (P F : Finset ℕ) (hF : ∀ n ∈ F, n ≠ 0 ∧ n.primeFactors ⊆ P) : (∑ n ∈ F, invTotient n) ≤ supportedMass P := by have hs0 : HasSum (fun n : Nat.factoredNumbers P => invTotient n) (supportedMass P) := by rw [supportedMass, ← tsum_invTotient_factored P] exact (summable_invTotient_factored P).hasSum have hs := (hasSum_subtype_iff_indicator (f := invTotient)).mp hs0 have hbound := sum_le_hasSum F (fun n _ => by by_cases hn : n ∈ Nat.factoredNumbers P · rw [Set.indicator_of_mem hn] exact invTotient_nonneg n · simp only [Set.indicator_of_notMem hn, le_refl]) hs simpa only [sum_congr rfl (fun n hn => Set.indicator_of_mem (Nat.mem_factoredNumbers_iff_primeFactors_subset.mpr (hF n hn)) invTotient)] using hbound /- Original line 30820: Erdos416Proof.FordReciprocal.binMass_le_supportedMass -/ theorem binMass_le_supportedMass (P : Finset ℕ) (j : ℕ) : binMass P j ≤ supportedMass P := finite_supported_mass_bound P (binNumbers P j) (fun _n hn => ⟨(mem_binNumbers.mp hn).1, (mem_binNumbers.mp hn).2.1⟩) /-- Any finite collection of bins has one bound, independent of all multiplicities. -/ /- Original line 30826: Erdos416Proof.FordReciprocal.exists_primeBin_product_bound -/ theorem exists_primeBin_product_bound : ∃ C : ℝ, 0 < C ∧ ∀ (I : Finset ℕ) (j : ℕ → ℕ), (∏ m ∈ I, binMass (primeBin m) (j m)) ≤ C := by obtain ⟨K, hK, hbound⟩ := exists_eventual_primeBin_mass_bound obtain ⟨N, hN⟩ := Filter.eventually_atTop.mp hbound let E : ℝ := ∏ m ∈ range N, supportedMass (primeBin m) let A : ℝ := Real.exp (K*(∑' m : ℕ, Real.exp (-(m : ℝ)))) have hE : 1 ≤ E := one_le_prod fun _ _ => one_le_supportedMass _ have hA : 0 < A := Real.exp_pos _ refine ⟨E*A, mul_pos (zero_lt_one.trans_le hE) hA, ?_⟩ intro I j have hlow : (∏ m ∈ I.filter (fun m => m < N), binMass (primeBin m) (j m)) ≤ E := by calc _ ≤ ∏ m ∈ I.filter (fun m => m < N), supportedMass (primeBin m) := prod_le_prod (fun _ _ => binMass_nonneg _ _) (fun _ _ => binMass_le_supportedMass _ _) _ ≤ E := prod_le_prod_of_subset_of_one_le (fun m hm => mem_range.mpr (mem_filter.mp hm).2) (fun _ _ => zero_le_one.trans (one_le_supportedMass _)) (fun _ _ _ => one_le_supportedMass _) have hhigh : (∏ m ∈ I.filter (fun m => ¬m < N), binMass (primeBin m) (j m)) ≤ A := by calc _ ≤ ∏ m ∈ I.filter (fun m => ¬m < N), (1+K*Real.exp (-(m : ℝ))) := prod_le_prod (fun _ _ => binMass_nonneg _ _) (fun m hm => hN m (le_of_not_gt (mem_filter.mp hm).2) (j m)) _ ≤ Real.exp (∑ m ∈ I.filter (fun m => ¬m < N), K*Real.exp (-(m : ℝ))) := Real.prod_one_add_le_exp_sum _ (fun _ => mul_nonneg hK.le (Real.exp_nonneg _)) _ ≤ A := by apply Real.exp_le_exp.mpr rw [← mul_sum] exact mul_le_mul_of_nonneg_left (Real.summable_exp_neg_nat.sum_le_tsum _ (fun _ _ => Real.exp_nonneg _)) hK.le rw [← prod_filter_mul_prod_filter_not I (fun m => m < N) (fun m => binMass (primeBin m) (j m))] exact mul_le_mul hlow hhigh (prod_nonneg fun _ _ => binMass_nonneg _ _) (zero_le_one.trans hE) /-- The padded low-bin factor is also bounded without any dependence on the dimension. -/ /- Original line 30862: Erdos416Proof.FordReciprocal.exists_primeBin_product_bound_with_low_support -/ theorem exists_primeBin_product_bound_with_low_support : ∃ C : ℝ, 0 < C ∧ ∀ (I F : Finset ℕ) (j : ℕ → ℕ), (∀ n ∈ F, n ≠ 0 ∧ n.primeFactors ⊆ primeBin 0) → (∑ n ∈ F, invTotient n)*(∏ m ∈ I, binMass (primeBin m) (j m)) ≤ C := by obtain ⟨C, hC, hbound⟩ := exists_primeBin_product_bound refine ⟨supportedMass (primeBin 0)*C, mul_pos (zero_lt_one.trans_le (one_le_supportedMass _)) hC, ?_⟩ intro I F j hF exact mul_le_mul (finite_supported_mass_bound _ _ hF) (hbound I j) (prod_nonneg fun _ _ => binMass_nonneg _ _) (zero_le_one.trans (one_le_supportedMass _)) end Erdos416Proof.FordReciprocal /- The actual reciprocal integer sums, coordinate-box decomposition and volume bound, and the negligible reciprocal outer-shell mass at the prescribed core scale. Comparison with V and the totient structural inputs remain. -/ open Filter Finset MeasureTheory open scoped Topology BigOperators Classical open scoped Pointwise namespace Erdos416Proof.FordReciprocal /- Original line 30889: Erdos416Proof.FordReciprocal.invTotient_prod_coprime -/ theorem invTotient_prod_coprime {ι : Type*} (I : Finset ι) (f : ι → ℕ) (hc : ∀ idx ∈ I, ∀ j ∈ I, idx ≠ j → (f idx).Coprime (f j)) : invTotient (∏ idx ∈ I, f idx) = ∏ idx ∈ I, invTotient (f idx) := by induction I using Finset.induction_on with | empty => simp[Erdos416Proof.FordReciprocal.binMass_zero, Erdos416Proof.invTotient_one, Erdos416Proof.weightedInvTotient_one] | @insert idx I hi ih => have hcop : (f idx).Coprime (∏ j ∈ I, f j) := by apply Nat.coprime_prod_right_iff.mpr intro j hj exact hc idx (mem_insert_self _ _) j (mem_insert_of_mem hj) (by intro heq exact hi (heq ▸ hj)) rw [prod_insert hi, invTotient_mul hcop, prod_insert hi] congr 1 exact ih (fun j hj k hk hjk => hc j (mem_insert_of_mem hj) k (mem_insert_of_mem hk) hjk) /-- Reconstructing the integer makes the actual factor-vector map injective. -/ /- Original line 30906: Erdos416Proof.FordReciprocal.finite_factor_image_mass -/ theorem finite_factor_image_mass {ι : Type*} [Fintype ι] (F : Finset ℕ) (a : ℕ → ι → ℕ) (hprod : ∀ n ∈ F, (∏ idx, a n idx) = n) (hcop : ∀ n ∈ F, ∀ idx j, idx ≠ j → (a n idx).Coprime (a n j)) : (∑ n ∈ F, invTotient n) ≤ ∏ idx, ∑ k ∈ F.image (fun n => a n idx), invTotient k := by have hinj : Set.InjOn a (F : Set ℕ) := by intro n hn m hm heq rw [← hprod n hn, ← hprod m hm, heq] have hweight : ∀ n ∈ F, invTotient n = ∏ idx, invTotient (a n idx) := by intro n hn simpa only [hprod n hn] using invTotient_prod_coprime univ (a n) (fun idx _ j _ hij => hcop n hn idx j hij) calc _ = ∑ n ∈ F, ∏ idx, invTotient (a n idx) := sum_congr rfl hweight _ = ∑ b ∈ F.image a, ∏ idx, invTotient (b idx) := by rw [sum_image hinj] _ ≤ ∑ b ∈ Fintype.piFinset (fun idx => F.image (fun n => a n idx)), ∏ idx, invTotient (b idx) := by apply sum_le_sum_of_subset_of_nonneg · intro b hb obtain ⟨n, hn, rfl⟩ := mem_image.mp hb exact Fintype.mem_piFinset.mpr (fun idx => mem_image.mpr ⟨n, hn, rfl⟩) · exact fun b _ _ => prod_nonneg fun idx _ => invTotient_nonneg (b idx) _ = _ := (prod_univ_sum (fun idx => F.image (fun n => a n idx)) (fun _ k => invTotient k)).symm /- Original line 30928: Erdos416Proof.FordReciprocal.coprime_of_disjoint_prime_support -/ theorem coprime_of_disjoint_prime_support {a b : ℕ} {P Q : Finset ℕ} (ha : a ≠ 0) (hb : b ≠ 0) (haP : a.primeFactors ⊆ P) (hbQ : b.primeFactors ⊆ Q) (hPQ : Disjoint P Q) : a.Coprime b := (Nat.disjoint_primeFactors ha hb).mp (hPQ.mono haP hbQ) /-- Disjoint prime supports supply the actual reciprocal-totient product identity. -/ /- Original line 30934: Erdos416Proof.FordReciprocal.finite_factor_image_mass_of_disjoint_support -/ theorem finite_factor_image_mass_of_disjoint_support {ι : Type*} [Fintype ι] (P : ι → Finset ℕ) (hP : ∀ idx j, idx ≠ j → Disjoint (P idx) (P j)) (F : Finset ℕ) (a : ℕ → ι → ℕ) (hprod : ∀ n ∈ F, (∏ idx, a n idx) = n) (hs : ∀ n ∈ F, ∀ idx, a n idx ≠ 0 ∧ (a n idx).primeFactors ⊆ P idx) : (∑ n ∈ F, invTotient n) ≤ ∏ idx, ∑ k ∈ F.image (fun n => a n idx), invTotient k := by apply finite_factor_image_mass F a hprod intro n hn idx j hij exact coprime_of_disjoint_prime_support (hs n hn idx).1 (hs n hn j).1 (hs n hn idx).2 (hs n hn j).2 (hP idx j hij) /-- The label of a prime-list entry in the unscaled double-logarithm grid. -/ /- Original line 30947: Erdos416Proof.FordReciprocal.primeLabel -/ noncomputable def primeLabel (p : ℕ) : ℕ := ⌊max 0 (logLog p)⌋₊ /- Original line 30949: Erdos416Proof.FordReciprocal.primeLabel_one -/ theorem primeLabel_one : primeLabel 1 = 0 := by simp [Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, primeLabel, logLog] /- Original line 30952: Erdos416Proof.FordReciprocal.primeLabel_eq_iff_mem_primeBin -/ theorem primeLabel_eq_iff_mem_primeBin {p m : ℕ} (hp : p.Prime) : primeLabel p = m ↔ p ∈ primeBin m := by have hp1 : (1 : ℝ) < p := by exact_mod_cast hp.one_lt have hp0 : (0 : ℝ) < p := by linarith have hlp : 0 < Real.log (p : ℝ) := Real.log_pos hp1 have hlow : (m : ℝ) ≤ logLog p ↔ Real.exp (Real.exp (m : ℝ)) ≤ (p : ℝ) := by rw [logLog, Real.le_log_iff_exp_le hlp, Real.le_log_iff_exp_le hp0] have hhigh : logLog p < (m : ℝ)+1 ↔ (p : ℝ) < Real.exp (Real.exp ((m : ℝ)+1)) := by rw [logLog, Real.log_lt_iff_lt_exp hlp, Real.log_lt_iff_lt_exp hp0] rw [primeLabel, Nat.floor_eq_iff (le_max_left _ _), mem_primeBin] simp only [hp, true_and] constructor · rintro ⟨hlo, hhi⟩ refine ⟨?_, hhigh.mp ((le_max_right _ _).trans_lt hhi)⟩ rcases le_max_iff.mp hlo with hm | hm · left have : (m : ℝ) = 0 := le_antisymm hm (Nat.cast_nonneg m) exact_mod_cast this · exact Or.inr (hlow.mp hm) · rintro ⟨hlo, hhi⟩ refine ⟨?_, max_lt (by positivity) (hhigh.mpr hhi)⟩ rcases hlo with hm | hm · subst m simpa only [Nat.cast_zero] using le_max_left (0 : ℝ) (logLog p) · exact (hlow.mpr hm).trans (le_max_right _ _) /- Original line 30979: Erdos416Proof.FordReciprocal.primeBin_disjoint -/ theorem primeBin_disjoint {m k : ℕ} (hmk : m ≠ k) : Disjoint (primeBin m) (primeBin k) := by apply disjoint_left.mpr intro p hpm hpk have hp := prime_of_mem_primeBin hpm exact hmk ((primeLabel_eq_iff_mem_primeBin hp).mpr hpm |>.symm.trans ((primeLabel_eq_iff_mem_primeBin hp).mpr hpk)) /- Original line 30987: Erdos416Proof.FordReciprocal.groupIndices -/ noncomputable def groupIndices {L : ℕ} (m : Fin L → ℕ) (k : ℕ) : Finset (Fin L) := univ.filter (fun idx => m idx = k) /- Original line 30990: Erdos416Proof.FordReciprocal.groupProduct -/ noncomputable def groupProduct {L : ℕ} (q m : Fin L → ℕ) (k : ℕ) : ℕ := ∏ idx ∈ groupIndices m k, q idx /- Original line 30993: Erdos416Proof.FordReciprocal.groupLabels -/ noncomputable def groupLabels {L : ℕ} (m : Fin L → ℕ) : Finset ℕ := insert 0 (univ.image m) /- Original line 30996: Erdos416Proof.FordReciprocal.prod_groupProduct -/ theorem prod_groupProduct {L : ℕ} (q m : Fin L → ℕ) : (∏ k ∈ groupLabels m, groupProduct q m k) = ∏ idx, q idx := by exact prod_fiberwise_of_maps_to (fun idx _ => mem_insert_of_mem (mem_image.mpr ⟨idx, mem_univ _, rfl⟩)) q /- Original line 31001: Erdos416Proof.FordReciprocal.groupProduct_ne_zero -/ theorem groupProduct_ne_zero {L : ℕ} {q : Fin L → ℕ} (hq : ∀ idx, (q idx).Prime ∨ q idx = 1) (m : Fin L → ℕ) (k : ℕ) : groupProduct q m k ≠ 0 := by apply prod_ne_zero_iff.mpr intro idx _ rcases hq idx with hp | h1 · exact hp.ne_zero · simp [h1] /- Original line 31010: Erdos416Proof.FordReciprocal.groupProduct_support -/ theorem groupProduct_support {L : ℕ} {q m : Fin L → ℕ} (hq : ∀ idx, (q idx).Prime ∨ q idx = 1) (hm : ∀ idx, primeLabel (q idx) = m idx) (k : ℕ) : (groupProduct q m k).primeFactors ⊆ primeBin k := by intro p hp obtain ⟨hpp, hpdvd, _⟩ := Nat.mem_primeFactors.mp hp obtain ⟨idx, hi, hdvd⟩ := Prime.exists_mem_finset_dvd hpp.prime hpdvd have hik : m idx = k := (mem_filter.mp hi).2 rcases hq idx with hqi | hqi · have heq : p = q idx := (Nat.prime_dvd_prime_iff_eq hpp hqi).mp hdvd subst p exact (primeLabel_eq_iff_mem_primeBin hqi).mp ((hm idx).trans hik) · rw [hqi] at hdvd exact (hpp.ne_one (Nat.dvd_one.mp hdvd)).elim /- Original line 31024: Erdos416Proof.FordReciprocal.groupProduct_degree -/ theorem groupProduct_degree {L : ℕ} {q m : Fin L → ℕ} (hq : ∀ idx, (q idx).Prime ∨ q idx = 1) (hm : ∀ idx, primeLabel (q idx) = m idx) {k : ℕ} (hk : k ≠ 0) : ArithmeticFunction.cardFactors (groupProduct q m k) = (groupIndices m k).card := by have hprime : ∀ idx ∈ groupIndices m k, (q idx).Prime := by intro idx hi rcases hq idx with hp | h1 · exact hp · have hlabel := (hm idx).trans (mem_filter.mp hi).2 rw [h1, primeLabel_one] at hlabel exact (hk hlabel.symm).elim rw [groupProduct, cardFactors_finset_prod _ _ (fun idx hi => (hprime idx hi).ne_zero)] calc _ = ∑ _i ∈ groupIndices m k, (1 : ℕ) := sum_congr rfl fun idx hi => ArithmeticFunction.cardFactors_apply_prime (hprime idx hi) _ = _ := by simp[Erdos416Proof.FordReciprocal.primeLabel_one] /-- The actual reciprocal sum in any fixed coordinate-label fiber has one absolute bound. -/ /- Original line 31042: Erdos416Proof.FordReciprocal.exists_fixed_label_mass_bound -/ theorem exists_fixed_label_mass_bound : ∃ C : ℝ, 0 < C ∧ ∀ (L : ℕ) (F : Finset ℕ) (q : ℕ → Fin L → ℕ) (m : Fin L → ℕ), (∀ n ∈ F, (∏ idx, q n idx) = n) → (∀ n ∈ F, ∀ idx, (q n idx).Prime ∨ q n idx = 1) → (∀ n ∈ F, ∀ idx, primeLabel (q n idx) = m idx) → (∑ n ∈ F, invTotient n) ≤ C := by obtain ⟨C, hC, hbound⟩ := exists_primeBin_product_bound_with_low_support refine ⟨C, hC, ?_⟩ intro L F q m hprod hq hm let I := groupLabels m let a : ℕ → I → ℕ := fun n k => groupProduct (q n) m k.1 let G : ℕ → Finset ℕ := fun k => F.image (fun n => groupProduct (q n) m k) have hs : ∀ n ∈ F, ∀ k : I, a n k ≠ 0 ∧ (a n k).primeFactors ⊆ primeBin k.1 := by intro n hn k exact ⟨groupProduct_ne_zero (hq n hn) m k.1, groupProduct_support (hq n hn) (hm n hn) k.1⟩ have hrec : ∀ n ∈ F, (∏ k : I, a n k) = n := by intro n hn dsimp only [a] rw [prod_coe_sort, prod_groupProduct, hprod n hn] have hmass := finite_factor_image_mass_of_disjoint_support (fun k : I => primeBin k.1) (fun idx j hij => primeBin_disjoint (fun heq => hij (Subtype.ext heq))) F a hrec hs have hmass' : (∑ n ∈ F, invTotient n) ≤ ∏ k ∈ I, ∑ r ∈ G k, invTotient r := by rw [← prod_coe_sort I (fun k => ∑ r ∈ G k, invTotient r)] exact hmass have hGlow : ∀ n ∈ G 0, n ≠ 0 ∧ n.primeFactors ⊆ primeBin 0 := by intro n hn obtain ⟨r, hr, rfl⟩ := mem_image.mp hn exact ⟨groupProduct_ne_zero (hq r hr) m 0, groupProduct_support (hq r hr) (hm r hr) 0⟩ have hGmass : ∀ k ∈ I.erase 0, (∑ r ∈ G k, invTotient r) ≤ binMass (primeBin k) (groupIndices m k).card := by intro k hk apply finite_binMass_le intro n hn obtain ⟨r, hr, rfl⟩ := mem_image.mp hn exact ⟨groupProduct_ne_zero (hq r hr) m k, groupProduct_support (hq r hr) (hm r hr) k, groupProduct_degree (hq r hr) (hm r hr) (mem_erase.mp hk).1⟩ calc _ ≤ _ := hmass' _ = (∑ r ∈ G 0, invTotient r)*(∏ k ∈ I.erase 0, ∑ r ∈ G k, invTotient r) := (mul_prod_erase I (fun k => ∑ r ∈ G k, invTotient r) (mem_insert_self _ _)).symm _ ≤ (∑ r ∈ G 0, invTotient r)* (∏ k ∈ I.erase 0, binMass (primeBin k) (groupIndices m k).card) := by exact mul_le_mul_of_nonneg_left (prod_le_prod (fun k _ => sum_nonneg fun r _ => invTotient_nonneg r) hGmass) (sum_nonneg fun r _ => invTotient_nonneg r) _ ≤ C := hbound (I.erase 0) (G 0) (fun k => (groupIndices m k).card) hGlow /-- Actual half-open boxes at the reciprocal double-logarithm mesh. -/ /- Original line 31091: Erdos416Proof.FordReciprocal.meshBox -/ def meshBox {L : ℕ} (t : ℝ) (m : Fin L → ℕ) : Set (Fin L → ℝ) := Set.pi Set.univ (fun idx => Set.Ico ((m idx : ℝ)/t) (((m idx : ℝ)+1)/t)) /- Original line 31094: Erdos416Proof.FordReciprocal.tuplePoint -/ noncomputable def tuplePoint {L : ℕ} (t : ℝ) (q : Fin L → ℕ) : Fin L → ℝ := fun idx => max 0 (logLog (q idx))/t /- Original line 31097: Erdos416Proof.FordReciprocal.meshBox_measurable -/ theorem meshBox_measurable {L : ℕ} (t : ℝ) (m : Fin L → ℕ) : MeasurableSet (meshBox t m) := MeasurableSet.univ_pi (fun _ => measurableSet_Ico) /- Original line 31101: Erdos416Proof.FordReciprocal.meshBox_measure_ne_top -/ theorem meshBox_measure_ne_top {L : ℕ} (t : ℝ) (m : Fin L → ℕ) : volume (meshBox t m) ≠ ⊤ := by apply measure_ne_top_of_subset (s := Set.Icc (fun idx => (m idx : ℝ)/t) (fun idx => ((m idx : ℝ)+1)/t)) · intro x hx exact ⟨fun idx => (hx idx (Set.mem_univ _)).1, fun idx => (hx idx (Set.mem_univ _)).2.le⟩ · exact isCompact_Icc.measure_lt_top.ne /- Original line 31110: Erdos416Proof.FordReciprocal.meshBox_volume -/ theorem meshBox_volume {L : ℕ} {t : ℝ} (ht : 0 < t) (m : Fin L → ℕ) : volume.real (meshBox t m) = (1/t)^L := by have hle : (fun idx => (m idx : ℝ)/t) ≤ (fun idx => ((m idx : ℝ)+1)/t) := by intro idx exact div_le_div_of_nonneg_right (by linarith) ht.le change (volume (Set.pi Set.univ (fun idx => Set.Ico ((m idx : ℝ)/t) (((m idx : ℝ)+1)/t)))).toReal = _ rw [Real.volume_pi_Ico_toReal hle] simp only [add_div, add_sub_cancel_left, prod_const, card_univ, Fintype.card_fin] /- Original line 31120: Erdos416Proof.FordReciprocal.meshBox_disjoint -/ theorem meshBox_disjoint {L : ℕ} {t : ℝ} (ht : 0 < t) {m k : Fin L → ℕ} (hmk : m ≠ k) : Disjoint (meshBox t m) (meshBox t k) := by apply Set.disjoint_left.mpr intro x hx hy apply hmk funext idx have hm := hx idx (Set.mem_univ _) have hk := hy idx (Set.mem_univ _) have hml := (div_le_iff₀ ht).mp hm.1 have hmh := (lt_div_iff₀ ht).mp hm.2 have hkl := (div_le_iff₀ ht).mp hk.1 have hkh := (lt_div_iff₀ ht).mp hk.2 have hmle : m idx ≤ k idx := Nat.lt_succ_iff.mp (by exact_mod_cast hml.trans_lt hkh) have hkle : k idx ≤ m idx := Nat.lt_succ_iff.mp (by exact_mod_cast hkl.trans_lt hmh) exact le_antisymm hmle hkle /- Original line 31136: Erdos416Proof.FordReciprocal.tuplePoint_mem_meshBox -/ theorem tuplePoint_mem_meshBox {L : ℕ} {t : ℝ} (ht : 0 < t) (q : Fin L → ℕ) : tuplePoint t q ∈ meshBox t (fun idx => primeLabel (q idx)) := by intro idx _ exact ⟨div_le_div_of_nonneg_right (Nat.floor_le (le_max_left 0 (logLog (q idx)))) ht.le, div_lt_div_of_pos_right (Nat.lt_floor_add_one (max 0 (logLog (q idx)))) ht⟩ /- Original line 31142: Erdos416Proof.FordReciprocal.meshBox_subset_thickening -/ theorem meshBox_subset_thickening {L : ℕ} {t : ℝ} {m : Fin L → ℕ} {E : Set (Fin L → ℝ)} {z : Fin L → ℝ} (hzE : z ∈ E) (hzm : z ∈ meshBox t m) : meshBox t m ⊆ E+errorCube L (1/t) := by intro x hx have herr : x-z ∈ errorCube L (1/t) := by constructor · intro idx have hz := hzm idx (Set.mem_univ _) have hxi := hx idx (Set.mem_univ _) have hwidth : (((m idx : ℝ)+1)/t)-(m idx : ℝ)/t = 1/t := by ring change -(1/t) ≤ x idx-z idx linarith [hz.1, hz.2, hxi.1, hxi.2] · intro idx have hz := hzm idx (Set.mem_univ _) have hxi := hx idx (Set.mem_univ _) have hwidth : (((m idx : ℝ)+1)/t)-(m idx : ℝ)/t = 1/t := by ring change x idx-z idx ≤ 1/t linarith [hz.1, hz.2, hxi.1, hxi.2] exact Set.mem_add.mpr ⟨z, hzE, x-z, herr, by abel⟩ /- Original line 31162: Erdos416Proof.FordReciprocal.unit_thickening_measure_ne_top -/ theorem unit_thickening_measure_ne_top {L : ℕ} {E : Set (Fin L → ℝ)} (hE : E ⊆ Set.Icc (fun _ => 0) (fun _ => 1)) (τ : ℝ) : volume (E+errorCube L τ) ≠ ⊤ := by apply measure_ne_top_of_subset (s := Set.Icc (fun _ => -τ) (fun _ => 1+τ)) · rintro x ⟨z, hz, e, he, rfl⟩ constructor · intro idx change -τ ≤ z idx+e idx linarith [(hE hz).1 idx, he.1 idx] · intro idx change z idx+e idx ≤ 1+τ linarith [(hE hz).2 idx, he.2 idx] · exact isCompact_Icc.measure_lt_top.ne /- Original line 31176: Erdos416Proof.FordReciprocal.meshBoxes_volume -/ theorem meshBoxes_volume {L : ℕ} {t : ℝ} (ht : 0 < t) (I : Finset (Fin L → ℕ)) : volume.real (⋃ m : I, meshBox t m.1) = (I.card : ℝ)*(1/t)^L := by rw [measureReal_iUnion_fintype (fun m k hmk => meshBox_disjoint ht (fun heq => hmk (Subtype.ext heq))) (fun m => meshBox_measurable t m.1) (fun m => meshBox_measure_ne_top t m.1)] simp only [meshBox_volume ht, sum_const, card_univ, Fintype.card_coe, nsmul_eq_mul] /- Original line 31183: Erdos416Proof.FordReciprocal.meshBox_count_bound -/ theorem meshBox_count_bound {L : ℕ} {t : ℝ} (ht : 0 < t) {E : Set (Fin L → ℝ)} (hE : E ⊆ Set.Icc (fun _ => 0) (fun _ => 1)) (I : Finset (Fin L → ℕ)) (hI : ∀ m ∈ I, ∃ z ∈ E, z ∈ meshBox t m) : (I.card : ℝ) ≤ t^L*volume.real (E+errorCube L (1/t)) := by have hsub : (⋃ m : I, meshBox t m.1) ⊆ E+errorCube L (1/t) := by intro x hx obtain ⟨m, hm⟩ := Set.mem_iUnion.mp hx obtain ⟨z, hzE, hzm⟩ := hI m.1 m.2 exact meshBox_subset_thickening hzE hzm hm have hvol := measureReal_mono hsub (unit_thickening_measure_ne_top hE (1/t)) rw [meshBoxes_volume ht I] at hvol have hinv : t^L*(1/t)^L = 1 := by rw [← mul_pow, mul_one_div_cancel ht.ne', one_pow] calc (I.card : ℝ) = (I.card : ℝ)*(t^L*(1/t)^L) := by rw [hinv, mul_one] _ = t^L*((I.card : ℝ)*(1/t)^L) := by ring _ ≤ _ := mul_le_mul_of_nonneg_left hvol (pow_nonneg ht.le L) /-- The full uniform upper reciprocal-to-volume bound for actual finite prime-list families. -/ /- Original line 31202: Erdos416Proof.FordReciprocal.exists_finite_prime_tuple_volume_bound -/ theorem exists_finite_prime_tuple_volume_bound : ∃ C : ℝ, 0 < C ∧ ∀ (L : ℕ) (t : ℝ) (E : Set (Fin L → ℝ)) (F : Finset ℕ) (q : ℕ → Fin L → ℕ), 0 < t → E ⊆ Set.Icc (fun _ => 0) (fun _ => 1) → (∀ n ∈ F, (∏ idx, q n idx) = n) → (∀ n ∈ F, ∀ idx, (q n idx).Prime ∨ q n idx = 1) → (∀ n ∈ F, tuplePoint t (q n) ∈ E) → (∑ n ∈ F, invTotient n) ≤ C*t^L*volume.real (E+errorCube L (1/t)) := by obtain ⟨C, hC, hbound⟩ := exists_fixed_label_mass_bound refine ⟨C, hC, ?_⟩ intro L t E F q ht hE hprod hq hpoint let labels : ℕ → Fin L → ℕ := fun n idx => primeLabel (q n idx) let I := F.image labels have hcard := meshBox_count_bound ht hE I (by intro m hm obtain ⟨n, hn, rfl⟩ := mem_image.mp hm exact ⟨tuplePoint t (q n), hpoint n hn, tuplePoint_mem_meshBox ht (q n)⟩) have hsplit := sum_fiberwise_of_maps_to (s := F) (t := I) (g := labels) (fun n hn => mem_image.mpr ⟨n, hn, rfl⟩) invTotient calc _ = ∑ m ∈ I, ∑ n ∈ F.filter (fun n => labels n = m), invTotient n := hsplit.symm _ ≤ ∑ _m ∈ I, C := by apply sum_le_sum intro m _ exact hbound L (F.filter (fun n => labels n = m)) q m (fun n hn => hprod n (mem_filter.mp hn).1) (fun n hn => hq n (mem_filter.mp hn).1) (fun n hn idx => congrFun (mem_filter.mp hn).2 idx) _ = C*(I.card : ℝ) := by simp [Erdos416Proof.FordReciprocal.binMass_zero, Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.invTotient_one, Erdos416Proof.weightedInvTotient_one, mul_comm] _ ≤ C*(t^L*volume.real (E+errorCube L (1/t))) := mul_le_mul_of_nonneg_left hcard hC.le _ = _ := by ring /- Original line 31234: Erdos416Proof.FordReciprocal.tuple_entry_ne_zero -/ theorem tuple_entry_ne_zero {L : ℕ} {q : Fin L → ℕ} (hq : ∀ idx, (q idx).Prime ∨ q idx = 1) (idx : Fin L) : q idx ≠ 0 := by rcases hq idx with hp | h1 · exact hp.ne_zero · simp [h1] /- Original line 31240: Erdos416Proof.FordReciprocal.tuple_degree_le -/ theorem tuple_degree_le {L : ℕ} {q : Fin L → ℕ} (hq : ∀ idx, (q idx).Prime ∨ q idx = 1) : ArithmeticFunction.cardFactors (∏ idx, q idx) ≤ L := by rw [cardFactors_finset_prod _ _ (fun idx _ => tuple_entry_ne_zero hq idx)] calc _ ≤ ∑ _i : Fin L, (1 : ℕ) := by apply sum_le_sum intro idx _ rcases hq idx with hp | h1 · simp [hp] · simp [h1] _ = L := by simp /- Original line 31253: Erdos416Proof.FordReciprocal.tuple_entry_bound -/ theorem tuple_entry_bound {L : ℕ} {t : ℝ} (ht : 0 < t) {q : Fin L → ℕ} (hq : ∀ idx, (q idx).Prime ∨ q idx = 1) (hpoint : tuplePoint t q ∈ Set.Icc (fun _ => 0) (fun _ => 1)) (idx : Fin L) : (q idx : ℝ) ≤ Real.exp (Real.exp t) := by rcases hq idx with hp | h1 · have hp1 : (1 : ℝ) < q idx := by exact_mod_cast hp.one_lt have hp0 : (0 : ℝ) < q idx := by linarith have hlog0 := Real.log_pos hp1 have hi := (div_le_iff₀ ht).mp (hpoint.2 idx) have hlog : logLog (q idx) ≤ t := by have hmax := le_max_right (0 : ℝ) (logLog (q idx)) linarith exact (Real.log_le_iff_le_exp hp0).mp ((Real.log_le_iff_le_exp hlog0).mp hlog) · simpa only [h1, Nat.cast_one] using Real.one_le_exp (Real.exp_nonneg t) /- Original line 31268: Erdos416Proof.FordReciprocal.tuple_product_bound -/ theorem tuple_product_bound {L : ℕ} {t : ℝ} (ht : 0 < t) {q : Fin L → ℕ} (hq : ∀ idx, (q idx).Prime ∨ q idx = 1) (hpoint : tuplePoint t q ∈ Set.Icc (fun _ => 0) (fun _ => 1)) : (∏ idx, q idx) ≤ ⌊Real.exp (Real.exp t)⌋₊^L := by have h := prod_le_prod (s := (univ : Finset (Fin L))) (fun idx _ => Nat.zero_le (q idx)) (fun idx _ => Nat.le_floor (tuple_entry_bound ht hq hpoint idx)) simpa only [prod_const, card_univ, Fintype.card_fin] using h /-- Actual positive integers with a decreasing prime list padded by units and lying in E. -/ /- Original line 31278: Erdos416Proof.FordReciprocal.tupleIntegers -/ noncomputable def tupleIntegers (L : ℕ) (t : ℝ) (E : Set (Fin L → ℝ)) : Finset ℕ := (Icc 1 (⌊Real.exp (Real.exp t)⌋₊^L)).filter (fun n => ∃ q : Fin L → ℕ, (∏ idx, q idx) = n ∧ (∀ idx, (q idx).Prime ∨ q idx = 1) ∧ Antitone q ∧ tuplePoint t q ∈ E) /- Original line 31283: Erdos416Proof.FordReciprocal.mem_tupleIntegers -/ theorem mem_tupleIntegers {L : ℕ} {t : ℝ} (ht : 0 < t) {E : Set (Fin L → ℝ)} (hE : E ⊆ Set.Icc (fun _ => 0) (fun _ => 1)) {n : ℕ} : n ∈ tupleIntegers L t E ↔ ∃ q : Fin L → ℕ, (∏ idx, q idx) = n ∧ (∀ idx, (q idx).Prime ∨ q idx = 1) ∧ Antitone q ∧ tuplePoint t q ∈ E := by constructor · exact fun hn => (mem_filter.mp hn).2 · rintro ⟨q, hprod, hq, hanti, hpoint⟩ have hn0 : n ≠ 0 := by rw [← hprod] exact prod_ne_zero_iff.mpr (fun idx _ => tuple_entry_ne_zero hq idx) have hnle : n ≤ ⌊Real.exp (Real.exp t)⌋₊^L := by rw [← hprod] exact tuple_product_bound ht hq (hE hpoint) exact mem_filter.mpr ⟨mem_Icc.mpr ⟨by omega, hnle⟩, q, hprod, hq, hanti, hpoint⟩ /- Original line 31299: Erdos416Proof.FordReciprocal.tupleIntegers_positive_and_degree -/ theorem tupleIntegers_positive_and_degree {L : ℕ} {t : ℝ} (ht : 0 < t) {E : Set (Fin L → ℝ)} (hE : E ⊆ Set.Icc (fun _ => 0) (fun _ => 1)) {n : ℕ} (hn : n ∈ tupleIntegers L t E) : 0 < n ∧ ArithmeticFunction.cardFactors n ≤ L := by obtain ⟨q, hprod, hq, _, _⟩ := (mem_tupleIntegers ht hE).mp hn constructor · exact (mem_Icc.mp (mem_filter.mp hn).1).1 · rw [← hprod] exact tuple_degree_le hq /- Original line 31309: Erdos416Proof.FordReciprocal.tupleReciprocalMass -/ noncomputable def tupleReciprocalMass (L : ℕ) (t : ℝ) (E : Set (Fin L → ℝ)) : ℝ := ∑ n ∈ tupleIntegers L t E, invTotient n /-- Ford's upper reciprocal-volume estimate for the actual finite integer family. -/ /- Original line 31313: Erdos416Proof.FordReciprocal.exists_tupleReciprocalMass_volume_bound -/ theorem exists_tupleReciprocalMass_volume_bound : ∃ C : ℝ, 0 < C ∧ ∀ (L : ℕ) (t : ℝ) (E : Set (Fin L → ℝ)), 0 < t → E ⊆ Set.Icc (fun _ => 0) (fun _ => 1) → tupleReciprocalMass L t E ≤ C*t^L*volume.real (E+errorCube L (1/t)) := by obtain ⟨C, hC, hbound⟩ := exists_finite_prime_tuple_volume_bound refine ⟨C, hC, ?_⟩ intro L t E ht hE let F := tupleIntegers L t E have hw : ∀ n ∈ F, ∃ q : Fin L → ℕ, (∏ idx, q idx) = n ∧ (∀ idx, (q idx).Prime ∨ q idx = 1) ∧ Antitone q ∧ tuplePoint t q ∈ E := fun _ hn => (mem_tupleIntegers ht hE).mp hn let q : ℕ → Fin L → ℕ := fun n => if hn : n ∈ F then (hw n hn).choose else fun _ => 1 have hq : ∀ n ∈ F, (∏ idx, q n idx) = n ∧ (∀ idx, (q n idx).Prime ∨ q n idx = 1) ∧ Antitone (q n) ∧ tuplePoint t (q n) ∈ E := by intro n hn simpa only [q, dif_pos hn] using (hw n hn).choose_spec exact hbound L t E F q ht hE (fun n hn => (hq n hn).1) (fun n hn => (hq n hn).2.1) (fun n hn => (hq n hn).2.2.2) open FordGeometry FordScale /- Original line 31334: Erdos416Proof.FordReciprocal.tupleReciprocalMass_nonneg -/ theorem tupleReciprocalMass_nonneg (L : ℕ) (t : ℝ) (E : Set (Fin L → ℝ)) : 0 ≤ tupleReciprocalMass L t E := sum_nonneg fun n _ => invTotient_nonneg n /- Original line 31338: Erdos416Proof.FordReciprocal.coreTupleMass -/ noncomputable def coreTupleMass (M : ℕ) (t : ℝ) : ℝ := tupleReciprocalMass (coreDimension M t) t (polytope (coreDimension M t) (expandedParameter (optimalDimension t))) /- Original line 31342: Erdos416Proof.FordReciprocal.coreOuterShell -/ noncomputable def coreOuterShell (M : ℕ) (t : ℝ) : Set (Fin (coreDimension M t) → ℝ) := polytope (coreDimension M t) (expandedParameter (optimalDimension t)) ∩ {x | 1-t^(-1/8 : ℝ) < outerForm (coreDimension M t) x} /- Original line 31346: Erdos416Proof.FordReciprocal.coreOuterShellMass -/ noncomputable def coreOuterShellMass (M : ℕ) (t : ℝ) : ℝ := tupleReciprocalMass (coreDimension M t) t (coreOuterShell M t) /- Original line 31349: Erdos416Proof.FordReciprocal.exists_core_tuple_mass_bound -/ theorem exists_core_tuple_mass_bound : ∃ K : ℝ, 0 < K ∧ ∀ᶠ M : ℕ in atTop, ∀ᶠ t : ℝ in atTop, coreTupleMass M t ≤ K*t^(coreDimension M t)*T (coreDimension M t) := by obtain ⟨C, hC, hbound⟩ := exists_tupleReciprocalMass_volume_bound refine ⟨C*(44*Real.exp 80), by positivity, ?_⟩ filter_upwards [thickened_volume_at_core_scale] with M hM filter_upwards [hM, eventually_gt_atTop (0 : ℝ)] with t hvol ht have hrec := hbound (coreDimension M t) t (polytope (coreDimension M t) (expandedParameter (optimalDimension t))) ht (fun x hx => ⟨hx.1, hx.2.1⟩) calc _ ≤ _ := hrec _ ≤ C*t^(coreDimension M t)*((44*Real.exp 80)*T (coreDimension M t)) := mul_le_mul_of_nonneg_left hvol (mul_nonneg hC.le (pow_nonneg ht.le _)) _ = _ := by ring /- Original line 31365: Erdos416Proof.FordReciprocal.exists_core_outer_shell_mass_bound -/ theorem exists_core_outer_shell_mass_bound : ∃ K : ℝ, 0 < K ∧ ∀ᶠ M : ℕ in atTop, ∀ᶠ t : ℝ in atTop, coreOuterShellMass M t ≤ K*coreShellFraction M t*(t^(coreDimension M t)*T (coreDimension M t)) := by obtain ⟨C, hC, hbound⟩ := exists_tupleReciprocalMass_volume_bound obtain ⟨K, hK, hvol⟩ := outer_shell_at_core_scale refine ⟨C*K, mul_pos hC hK, ?_⟩ filter_upwards [hvol] with M hM filter_upwards [hM, eventually_gt_atTop (0 : ℝ)] with t hvol ht have hrec := hbound (coreDimension M t) t (coreOuterShell M t) ht (fun x hx => ⟨hx.1.1, hx.1.2.1⟩) calc _ ≤ _ := hrec _ ≤ C*t^(coreDimension M t)*(K*coreShellFraction M t*T (coreDimension M t)) := mul_le_mul_of_nonneg_left hvol (mul_nonneg hC.le (pow_nonneg ht.le _)) _ = _ := by ring /-- At the manuscript's actual scale, the shell's reciprocal integer mass is negligible. -/ /- Original line 31383: Erdos416Proof.FordReciprocal.core_outer_shell_mass_negligible -/ theorem core_outer_shell_mass_negligible : ∀ᶠ M : ℕ in atTop, (fun t : ℝ => coreOuterShellMass M t) =o[atTop] (fun t : ℝ => t^(coreDimension M t)*T (coreDimension M t)) := by obtain ⟨K, hK, hbound⟩ := exists_core_outer_shell_mass_bound filter_upwards [hbound] with M hM apply Asymptotics.IsLittleO.of_bound intro ε hε have he := (coreShellFraction_tendsto_zero M).eventually_lt_const (div_pos hε hK) filter_upwards [hM, he, eventually_gt_atTop (0 : ℝ)] with t hmass herr ht have hcoef : K*coreShellFraction M t ≤ ε := by have h := (lt_div_iff₀ hK).mp herr nlinarith have hmass0 : 0 ≤ coreOuterShellMass M t := tupleReciprocalMass_nonneg _ _ _ have hdenom0 : 0 ≤ t^(coreDimension M t)*T (coreDimension M t) := mul_nonneg (pow_nonneg ht.le _) measureReal_nonneg simp only [Real.norm_eq_abs, abs_of_nonneg hmass0, abs_of_nonneg hdenom0] exact hmass.trans (mul_le_mul_of_nonneg_right hcoef hdenom0) end Erdos416Proof.FordReciprocal /- The lower reciprocal-volume estimate for actual integers, including all prime-bin endpoints, uniform positive mass, unique sorted tuples and the eroded-box cover. The totient order, structural and core-coverage inputs remain. -/ open Filter Finset MeasureTheory open scoped Topology BigOperators Classical namespace Erdos416Proof.FordReciprocal /-- The lower endpoint of every exponential prime bin is at least two. -/ /- Original line 31417: Erdos416Proof.FordReciprocal.primeBin_lower_two_le -/ theorem primeBin_lower_two_le (m : ℕ) : 2 ≤ Real.exp (Real.exp (m : ℝ)) := by have he : (2 : ℝ) ≤ Real.exp 1 := by linarith [Real.add_one_le_exp (1 : ℝ)] exact he.trans (Real.exp_le_exp.mpr (Real.one_le_exp (Nat.cast_nonneg m))) /-- Quantitative Mertens from below, retaining the possible upper endpoint prime. -/ /- Original line 31422: Erdos416Proof.FordReciprocal.primeBin_reciprocal_lower -/ theorem primeBin_reciprocal_lower {B K : ℝ} (hE : ∀ x : ℝ, 2 ≤ x → |(∑ p ∈ Nat.primesLE ⌊x⌋₊, (1 : ℝ)/p)-logLog x-B| ≤ K/Real.log x) (m : ℕ) : 1-K/Real.exp ((m : ℝ)+1)-K/Real.exp (m : ℝ)- 1/Real.exp (Real.exp ((m : ℝ)+1)) ≤ ∑ p ∈ primeBin m, (1 : ℝ)/p := by let u := Real.exp (Real.exp (m : ℝ)) let v := Real.exp (Real.exp ((m : ℝ)+1)) let Q := (Nat.primesLE ⌊v⌋₊).filter (fun p : ℕ => u < (p : ℝ) ∧ (p : ℝ) ≤ v) have hu : 2 ≤ u := primeBin_lower_two_le m have huv : u ≤ v := Real.exp_le_exp.mpr (Real.exp_le_exp.mpr (by linarith)) have hsub : Q ⊆ primeBin m ∪ {⌈v⌉₊} := by intro p hp obtain ⟨hpp, hup, hpv⟩ := mem_filter.mp hp have hprime := Nat.prime_of_mem_primesLE hpp by_cases hlt : (p : ℝ) < v · exact mem_union_left _ (mem_primeBin.mpr ⟨hprime, Or.inr hup.le, hlt⟩) · have heq : v = (p : ℝ) := le_antisymm (le_of_not_gt hlt) hpv exact mem_union_right _ (by simp [Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, heq]) have hceil : (1 : ℝ)/(⌈v⌉₊ : ℝ) ≤ 1/v := one_div_le_one_div_of_le (Real.exp_pos _) (Nat.le_ceil v) have hsum : (∑ p ∈ Q, (1 : ℝ)/p) ≤ (∑ p ∈ primeBin m, (1 : ℝ)/p)+1/v := by calc _ ≤ ∑ p ∈ primeBin m ∪ {⌈v⌉₊}, (1 : ℝ)/p := sum_le_sum_of_subset_of_nonneg hsub (fun _ _ _ => by positivity) _ ≤ (∑ p ∈ primeBin m, (1 : ℝ)/p)+(∑ p ∈ {⌈v⌉₊}, (1 : ℝ)/p) := le_trans (le_add_of_nonneg_right (sum_nonneg (s := primeBin m ∩ {⌈v⌉₊}) (fun _ _ => by positivity))) sum_union_inter.le _ ≤ _ := by simpa only [sum_singleton] using add_le_add_right hceil _ have hdiff : (∑ p ∈ Q, (1 : ℝ)/p) = (∑ p ∈ Nat.primesLE ⌊v⌋₊, (1 : ℝ)/p)- (∑ p ∈ Nat.primesLE ⌊u⌋₊, (1 : ℝ)/p) := by rw [show Q = _ from primesLE_filter_interval (by linarith) huv le_rfl, sum_sdiff_eq_sub (Nat.primesLE_mono (Nat.floor_mono huv))] rw [hdiff] at hsum have hlow := (abs_le.mp (hE v (hu.trans huv))).1 have hhigh := (abs_le.mp (hE u hu)).2 simp only [u, v, logLog, Real.log_exp] at hlow hhigh hsum linarith /- Original line 31461: Erdos416Proof.FordReciprocal.exists_primeBin_first_mass_lower_error -/ theorem exists_primeBin_first_mass_lower_error : ∃ K : ℝ, 0 < K ∧ ∀ m : ℕ, 1-K*Real.exp (-(m : ℝ)) ≤ ∑ p ∈ primeBin m, ((p : ℝ)-1)⁻¹ := by obtain ⟨B, K, hK, hE⟩ := exists_prime_reciprocal_log_error refine ⟨2*K+1, by linarith, ?_⟩ intro m have hrec := primeBin_reciprocal_lower hE m have hKdiv : K/Real.exp ((m : ℝ)+1) ≤ K/Real.exp (m : ℝ) := div_le_div_of_nonneg_left hK.le (Real.exp_pos _) (Real.exp_le_exp.mpr (by linarith)) have hinv : (1 : ℝ)/Real.exp (Real.exp ((m : ℝ)+1)) ≤ Real.exp (-(m : ℝ)) := by rw [Real.exp_neg, ← one_div] apply one_div_le_one_div_of_le (Real.exp_pos _) apply Real.exp_le_exp.mpr linarith [Real.add_one_le_exp ((m : ℝ)+1)] have hscale : K/Real.exp (m : ℝ) = K*Real.exp (-(m : ℝ)) := by rw [Real.exp_neg, div_eq_mul_inv] rw [hscale] at hKdiv hrec have hsmall : 1-(2*K+1)*Real.exp (-(m : ℝ)) ≤ ∑ p ∈ primeBin m, (1 : ℝ)/p := by linarith apply hsmall.trans apply sum_le_sum intro p hp have hp2 : (2 : ℝ) ≤ p := by exact_mod_cast (prime_of_mem_primeBin hp).two_le rw [← one_div] exact one_div_le_one_div_of_le (by linarith) (by linarith) /-- Every bin contains an actual prime, including the finitely many early bins. -/ /- Original line 31488: Erdos416Proof.FordReciprocal.primeBin_nonempty -/ theorem primeBin_nonempty (m : ℕ) : (primeBin m).Nonempty := by let u := Real.exp (Real.exp (m : ℝ)) have hu : 2 ≤ u := primeBin_lower_two_le m have he : (2 : ℝ) < Real.exp 1 := by linarith [Real.add_one_lt_exp (by norm_num : (1 : ℝ) ≠ 0)] have ha : 1 ≤ Real.exp (m : ℝ) := Real.one_le_exp (Nat.cast_nonneg m) have harg : Real.exp (m : ℝ)+1 < Real.exp ((m : ℝ)+1) := by rw [Real.exp_add] nlinarith [mul_nonneg (sub_nonneg.mpr ha) (sub_nonneg.mpr he.le)] have huv : 2*u < Real.exp (Real.exp ((m : ℝ)+1)) := by calc _ < Real.exp 1*u := mul_lt_mul_of_pos_right he (Real.exp_pos _) _ = Real.exp (Real.exp (m : ℝ)+1) := by rw [Real.exp_add]; ring _ < _ := Real.exp_lt_exp.mpr harg have hfloor : 1 ≤ ⌊u⌋₊ := (Nat.le_floor_iff (by linarith : 0 ≤ u)).mpr (by norm_num linarith) obtain ⟨p, hp, hpl, hpu⟩ := Nat.exists_prime_lt_and_le_two_mul ⌊u⌋₊ (by omega) refine ⟨p, mem_primeBin.mpr ⟨hp, Or.inr (Nat.lt_of_floor_lt hpl).le, ?_⟩⟩ have hpu' : (p : ℝ) ≤ 2*(⌊u⌋₊ : ℝ) := by exact_mod_cast hpu exact (hpu'.trans (mul_le_mul_of_nonneg_left (Nat.floor_le (by linarith)) (by norm_num))).trans_lt huv /- Original line 31511: Erdos416Proof.FordReciprocal.primeBin_first_mass_pos -/ theorem primeBin_first_mass_pos (m : ℕ) : 0 < ∑ p ∈ primeBin m, ((p : ℝ)-1)⁻¹ := by apply sum_pos · intro p hp have hp2 : (2 : ℝ) ≤ p := by exact_mod_cast (prime_of_mem_primeBin hp).two_le exact inv_pos.mpr (by linarith) · exact primeBin_nonempty m /-- A positive lower bound suitable for multiplying summably small errors. -/ /- Original line 31520: Erdos416Proof.FordReciprocal.exp_neg_two_le_one_sub -/ theorem exp_neg_two_le_one_sub {a : ℝ} (ha : 0 ≤ a) (ha' : a ≤ 1/2) : Real.exp (-2*a) ≤ 1-a := by have hpos : 0 < 1-a := by linarith apply (Real.le_log_iff_exp_le hpos).mp have hinv : (1-a)⁻¹ ≤ 1+2*a := (inv_le_iff_one_le_mul₀ hpos).mpr (by nlinarith) have hlog := Real.log_le_sub_one_of_pos (inv_pos.mpr hpos) rw [Real.log_inv] at hlog linarith /-- One positive lower bound for the product of first masses in any finite set of bins. -/ /- Original line 31531: Erdos416Proof.FordReciprocal.exists_primeBin_first_mass_product_lower -/ theorem exists_primeBin_first_mass_product_lower : ∃ c : ℝ, 0 < c ∧ ∀ I : Finset ℕ, c ≤ ∏ m ∈ I, ∑ p ∈ primeBin m, ((p : ℝ)-1)⁻¹ := by obtain ⟨K, hK, hbound⟩ := exists_primeBin_first_mass_lower_error have hlim : Tendsto (fun m : ℕ => K*Real.exp (-(m : ℝ))) atTop (nhds 0) := by simpa only [mul_zero, Function.comp_apply] using! (Real.tendsto_exp_neg_atTop_nhds_zero.comp tendsto_natCast_atTop_atTop).const_mul K obtain ⟨N, hN⟩ := eventually_atTop.mp (hlim.eventually_lt_const (by norm_num : (0 : ℝ) < 1/2)) let s (m : ℕ) := ∑ p ∈ primeBin m, ((p : ℝ)-1)⁻¹ let E : ℝ := ∏ m ∈ range N, min 1 (s m) let A : ℝ := Real.exp (-2*K*(∑' m : ℕ, Real.exp (-(m : ℝ)))) have hs (m : ℕ) : 0 < s m := primeBin_first_mass_pos m have hE : 0 < E := prod_pos fun m _ => lt_min zero_lt_one (hs m) have hA : 0 < A := Real.exp_pos _ refine ⟨E*A, mul_pos hE hA, ?_⟩ intro I have hlow : E ≤ ∏ m ∈ I.filter (fun m => m < N), s m := by calc _ ≤ ∏ m ∈ I.filter (fun m => m < N), min 1 (s m) := prod_le_prod_of_subset_of_le_one (fun m hm => mem_range.mpr (mem_filter.mp hm).2) (fun m _ => (lt_min zero_lt_one (hs m)).le) (fun _ _ _ => min_le_left _ _) _ ≤ _ := prod_le_prod (fun m _ => (lt_min zero_lt_one (hs m)).le) (fun _ _ => min_le_right _ _) have hhigh : A ≤ ∏ m ∈ I.filter (fun m => ¬m < N), s m := by calc _ ≤ Real.exp (∑ m ∈ I.filter (fun m => ¬m < N), -2*K*Real.exp (-(m : ℝ))) := by apply Real.exp_le_exp.mpr rw [← mul_sum] exact mul_le_mul_of_nonpos_left (Real.summable_exp_neg_nat.sum_le_tsum _ (fun _ _ => Real.exp_nonneg _)) (by linarith) _ = ∏ m ∈ I.filter (fun m => ¬m < N), Real.exp (-2*K*Real.exp (-(m : ℝ))) := Real.exp_sum _ _ _ ≤ _ := by apply prod_le_prod (fun _ _ => Real.exp_nonneg _) intro m hm have hsmall := (hN m (le_of_not_gt (mem_filter.mp hm).2)).le have hexp := exp_neg_two_le_one_sub (mul_nonneg hK.le (Real.exp_nonneg _)) hsmall have hexp' : Real.exp (-2*K*Real.exp (-(m : ℝ))) ≤ 1-K*Real.exp (-(m : ℝ)) := by simpa only [mul_assoc] using hexp exact hexp'.trans (hbound m) change E*A ≤ ∏ m ∈ I, s m rw [← prod_filter_mul_prod_filter_not I (fun m => m < N) s] exact mul_le_mul hlow hhigh hA.le (prod_nonneg fun m _ => (hs m).le) /-- An ordered prime list is determined by its actual product. -/ /- Original line 31579: Erdos416Proof.FordReciprocal.antitone_prime_tuple_eq_of_prod_eq -/ theorem antitone_prime_tuple_eq_of_prod_eq {L : ℕ} {q r : Fin L → ℕ} (hq : ∀ idx, (q idx).Prime) (hr : ∀ idx, (r idx).Prime) (hqanti : Antitone q) (hranti : Antitone r) (heq : (∏ idx, q idx) = ∏ idx, r idx) : q = r := by have hq' := Nat.primeFactorsList_unique (show (List.ofFn q).prod = ∏ idx, r idx by simpa only [List.prod_ofFn] using heq) (List.forall_mem_ofFn_iff.mpr hq) have hr' := Nat.primeFactorsList_unique (show (List.ofFn r).prod = ∏ idx, r idx by rw [List.prod_ofFn]) (List.forall_mem_ofFn_iff.mpr hr) exact List.ofFn_injective (List.Perm.eq_of_sortedGE hqanti.sortedGE_ofFn hranti.sortedGE_ofFn (hq'.trans hr'.symm)) /- Original line 31591: Erdos416Proof.FordReciprocal.boxPrimeTuples -/ noncomputable def boxPrimeTuples {L : ℕ} (m : Fin L → ℕ) : Finset (Fin L → ℕ) := Fintype.piFinset (fun idx => primeBin (m idx)) /- Original line 31594: Erdos416Proof.FordReciprocal.mem_boxPrimeTuples -/ theorem mem_boxPrimeTuples {L : ℕ} {m q : Fin L → ℕ} : q ∈ boxPrimeTuples m ↔ ∀ idx, q idx ∈ primeBin (m idx) := Fintype.mem_piFinset /- Original line 31597: Erdos416Proof.FordReciprocal.boxPrimeTuples_prime -/ theorem boxPrimeTuples_prime {L : ℕ} {m q : Fin L → ℕ} (hq : q ∈ boxPrimeTuples m) (idx : Fin L) : (q idx).Prime := prime_of_mem_primeBin (mem_boxPrimeTuples.mp hq idx) /- Original line 31600: Erdos416Proof.FordReciprocal.boxPrimeTuples_strictAnti -/ theorem boxPrimeTuples_strictAnti {L : ℕ} {m q : Fin L → ℕ} (hm : StrictAnti m) (hq : q ∈ boxPrimeTuples m) : StrictAnti q := by intro idx j hij have hmi : m idx ≠ 0 := by have h := hm hij; omega have hpi := mem_primeBin.mp (mem_boxPrimeTuples.mp hq idx) have hpj := mem_primeBin.mp (mem_boxPrimeTuples.mp hq j) have hcast : (m j : ℝ)+1 ≤ m idx := by exact_mod_cast (Nat.succ_le_iff.mpr (hm hij)) have hlt : (q j : ℝ) < q idx := hpj.2.2.trans_le ((Real.exp_le_exp.mpr (Real.exp_le_exp.mpr hcast)).trans (hpi.2.1.resolve_left hmi)) exact_mod_cast hlt /- Original line 31611: Erdos416Proof.FordReciprocal.boxPrimeTuples_point -/ theorem boxPrimeTuples_point {L : ℕ} {t : ℝ} (ht : 0 < t) {m q : Fin L → ℕ} (hq : q ∈ boxPrimeTuples m) : tuplePoint t q ∈ meshBox t m := by have hm : (fun idx => primeLabel (q idx)) = m := funext fun idx => (primeLabel_eq_iff_mem_primeBin (boxPrimeTuples_prime hq idx)).mpr (mem_boxPrimeTuples.mp hq idx) simpa only [hm] using tuplePoint_mem_meshBox ht q /-- The actual integers obtained by choosing one prime from each prescribed bin. -/ /- Original line 31619: Erdos416Proof.FordReciprocal.boxIntegers -/ noncomputable def boxIntegers {L : ℕ} (m : Fin L → ℕ) : Finset ℕ := (boxPrimeTuples m).image (fun q => ∏ idx, q idx) /- Original line 31622: Erdos416Proof.FordReciprocal.boxPrimeTuples_prod_inj -/ theorem boxPrimeTuples_prod_inj {L : ℕ} {m : Fin L → ℕ} (hm : StrictAnti m) : Set.InjOn (fun q : Fin L → ℕ => ∏ idx, q idx) (boxPrimeTuples m) := by intro q hq r hr heq exact antitone_prime_tuple_eq_of_prod_eq (boxPrimeTuples_prime hq) (boxPrimeTuples_prime hr) (boxPrimeTuples_strictAnti hm hq).antitone (boxPrimeTuples_strictAnti hm hr).antitone heq /- Original line 31628: Erdos416Proof.FordReciprocal.boxIntegers_mass -/ theorem boxIntegers_mass {L : ℕ} {m : Fin L → ℕ} (hm : StrictAnti m) : (∑ n ∈ boxIntegers m, invTotient n) = ∏ idx, ∑ p ∈ primeBin (m idx), ((p : ℝ)-1)⁻¹ := by calc _ = ∑ q ∈ boxPrimeTuples m, invTotient (∏ idx, q idx) := by rw [boxIntegers, sum_image (boxPrimeTuples_prod_inj hm)] _ = ∑ q ∈ boxPrimeTuples m, ∏ idx, ((q idx : ℝ)-1)⁻¹ := by apply sum_congr rfl intro q hq rw [invTotient_prod_coprime univ q (fun idx _ j _ hij => (Nat.coprime_primes (boxPrimeTuples_prime hq idx) (boxPrimeTuples_prime hq j)).mpr ((boxPrimeTuples_strictAnti hm hq).injective.ne hij))] apply prod_congr rfl intro idx _ simp [Erdos416Proof.FordReciprocal.binMass_zero, Erdos416Proof.invTotient_one, Erdos416Proof.weightedInvTotient_one, invTotient, Nat.totient_prime (boxPrimeTuples_prime hq idx), Nat.cast_sub (boxPrimeTuples_prime hq idx).one_le] _ = _ := (prod_univ_sum (fun idx => primeBin (m idx)) (fun _ p => ((p : ℝ)-1)⁻¹)).symm /- Original line 31645: Erdos416Proof.FordReciprocal.boxIntegers_disjoint -/ theorem boxIntegers_disjoint {L : ℕ} {m k : Fin L → ℕ} (hm : StrictAnti m) (hk : StrictAnti k) (hmk : m ≠ k) : Disjoint (boxIntegers m) (boxIntegers k) := by apply disjoint_left.mpr intro n hn hn' obtain ⟨q, hq, hqn⟩ := mem_image.mp hn obtain ⟨r, hr, hrn⟩ := mem_image.mp hn' have heq := antitone_prime_tuple_eq_of_prod_eq (boxPrimeTuples_prime hq) (boxPrimeTuples_prime hr) (boxPrimeTuples_strictAnti hm hq).antitone (boxPrimeTuples_strictAnti hk hr).antitone (hqn.trans hrn.symm) subst r apply hmk funext idx exact ((primeLabel_eq_iff_mem_primeBin (boxPrimeTuples_prime hq idx)).mpr (mem_boxPrimeTuples.mp hq idx)).symm.trans ((primeLabel_eq_iff_mem_primeBin (boxPrimeTuples_prime hr idx)).mpr (mem_boxPrimeTuples.mp hr idx)) /- Original line 31662: Erdos416Proof.FordReciprocal.exists_boxIntegers_mass_lower -/ theorem exists_boxIntegers_mass_lower : ∃ c : ℝ, 0 < c ∧ ∀ (L : ℕ) (m : Fin L → ℕ), StrictAnti m → c ≤ ∑ n ∈ boxIntegers m, invTotient n := by obtain ⟨c, hc, hbound⟩ := exists_primeBin_first_mass_product_lower refine ⟨c, hc, ?_⟩ intro L m hm rw [boxIntegers_mass hm] have h := hbound (univ.image m) simpa only [prod_image hm.injective.injOn] using h /-- Points whose entire closed coordinate cube remains inside E. -/ /- Original line 31674: Erdos416Proof.FordReciprocal.cubeErosion -/ def cubeErosion {L : ℕ} (E : Set (Fin L → ℝ)) (τ : ℝ) : Set (Fin L → ℝ) := {x | ∀ e ∈ errorCube L τ, x+e ∈ E} /- Original line 31677: Erdos416Proof.FordReciprocal.cubeErosion_subset -/ theorem cubeErosion_subset {L : ℕ} {τ : ℝ} (hτ : 0 ≤ τ) (E : Set (Fin L → ℝ)) : cubeErosion E τ ⊆ E := by intro x hx simpa only [add_zero] using hx 0 ⟨fun _ => neg_nonpos.mpr hτ, fun _ => hτ⟩ /- Original line 31682: Erdos416Proof.FordReciprocal.meshBox_corner_mem -/ theorem meshBox_corner_mem {L : ℕ} {t : ℝ} (ht : 0 < t) (m : Fin L → ℕ) : (fun idx => (m idx : ℝ)/t) ∈ meshBox t m := by intro idx _ exact ⟨le_rfl, div_lt_div_of_pos_right (by linarith) ht⟩ /-- A box contained in an ordered region has strictly decreasing bin labels. -/ /- Original line 31688: Erdos416Proof.FordReciprocal.meshBox_strictAnti_labels -/ theorem meshBox_strictAnti_labels {L : ℕ} {t : ℝ} (ht : 0 < t) {E : Set (Fin L → ℝ)} (hE : ∀ x ∈ E, Antitone x) {m : Fin L → ℕ} (hm : meshBox t m ⊆ E) : StrictAnti m := by intro idx j hij let x (k : Fin L) : ℝ := ((m k : ℝ)+(if k = j then 1/2 else 0))/t have hx : x ∈ meshBox t m := by intro k _ have h0 : (0 : ℝ) ≤ if k = j then 1/2 else 0 := by split_ifs <;> norm_num have h1 : (if k = j then (1/2 : ℝ) else 0) < 1 := by split_ifs <;> norm_num exact ⟨div_le_div_of_nonneg_right (by linarith) ht.le, div_lt_div_of_pos_right (by linarith) ht⟩ have hji := hE x (hm hx) hij.le simp [x, hij.ne] at hji have hc := (div_le_div_iff_of_pos_right ht).mp hji have hlt : (m j : ℝ) < m idx := by linarith exact_mod_cast hlt /-- The finite family of mesh boxes wholly contained in E. -/ /- Original line 31706: Erdos416Proof.FordReciprocal.containedMeshBoxes -/ noncomputable def containedMeshBoxes (L : ℕ) (t : ℝ) (E : Set (Fin L → ℝ)) : Finset (Fin L → ℕ) := (Fintype.piFinset (fun _ : Fin L => range (⌊t⌋₊+1))).filter (fun m => meshBox t m ⊆ E) /- Original line 31710: Erdos416Proof.FordReciprocal.mem_containedMeshBoxes -/ theorem mem_containedMeshBoxes {L : ℕ} {t : ℝ} (ht : 0 < t) {E : Set (Fin L → ℝ)} (hE : E ⊆ Set.Icc (fun _ => 0) (fun _ => 1)) {m : Fin L → ℕ} : m ∈ containedMeshBoxes L t E ↔ meshBox t m ⊆ E := by constructor · exact fun hm => (mem_filter.mp hm).2 · intro hm refine mem_filter.mpr ⟨Fintype.mem_piFinset.mpr ?_, hm⟩ intro idx have hi := (hE (hm (meshBox_corner_mem ht m))).2 idx have hml : (m idx : ℝ) ≤ t := by simpa only [one_mul] using (div_le_iff₀ ht).mp hi exact mem_range.mpr (Nat.lt_succ_iff.mpr (Nat.le_floor hml)) /-- The union of the actual contained boxes covers the eroded region. -/ /- Original line 31723: Erdos416Proof.FordReciprocal.cubeErosion_subset_meshBoxes -/ theorem cubeErosion_subset_meshBoxes {L : ℕ} {t : ℝ} (ht : 0 < t) {E : Set (Fin L → ℝ)} (hE : E ⊆ Set.Icc (fun _ => 0) (fun _ => 1)) : cubeErosion E (1/t) ⊆ ⋃ m : containedMeshBoxes L t E, meshBox t m.1 := by intro x hx have hxE := cubeErosion_subset (by positivity : 0 ≤ 1/t) E hx let m (idx : Fin L) := ⌊t*x idx⌋₊ have hxm : x ∈ meshBox t m := by intro idx _ have hnonneg : 0 ≤ t*x idx := mul_nonneg ht.le ((hE hxE).1 idx) exact ⟨(div_le_iff₀ ht).mpr (by simpa only [mul_comm] using Nat.floor_le hnonneg), (lt_div_iff₀ ht).mpr (by simpa only [mul_comm] using Nat.lt_floor_add_one (t*x idx))⟩ have hsub : meshBox t m ⊆ E := by intro z hz obtain ⟨a, ha, e, he, rfl⟩ := Set.mem_add.mp (meshBox_subset_thickening (E := {x}) (by simp) hxm hz) have hax : a = x := ha subst a exact hx e he exact Set.mem_iUnion.mpr ⟨⟨m, (mem_containedMeshBoxes ht hE).mpr hsub⟩, hxm⟩ /- Original line 31743: Erdos416Proof.FordReciprocal.cubeErosion_volume_le_box_count -/ theorem cubeErosion_volume_le_box_count {L : ℕ} {t : ℝ} (ht : 0 < t) {E : Set (Fin L → ℝ)} (hE : E ⊆ Set.Icc (fun _ => 0) (fun _ => 1)) : t^L*volume.real (cubeErosion E (1/t)) ≤ (containedMeshBoxes L t E).card := by let I := containedMeshBoxes L t E have hfinite : volume (⋃ m : I, meshBox t m.1) ≠ ⊤ := by apply measure_ne_top_of_subset (s := Set.Icc (fun _ : Fin L => (0 : ℝ)) (fun _ => 1)) · intro x hx obtain ⟨m, hm⟩ := Set.mem_iUnion.mp hx exact hE ((mem_containedMeshBoxes ht hE).mp m.2 hm) · exact isCompact_Icc.measure_lt_top.ne have hvol := measureReal_mono (cubeErosion_subset_meshBoxes ht hE) hfinite rw [meshBoxes_volume ht I] at hvol have hinv : t^L*(1/t)^L = 1 := by rw [← mul_pow, mul_one_div_cancel ht.ne', one_pow] calc _ ≤ t^L*((I.card : ℝ)*(1/t)^L) := mul_le_mul_of_nonneg_left hvol (pow_nonneg ht.le L) _ = (I.card : ℝ)*(t^L*(1/t)^L) := by ring _ = _ := by rw [hinv, mul_one] /- Original line 31762: Erdos416Proof.FordReciprocal.boxIntegers_subset_tupleIntegers -/ theorem boxIntegers_subset_tupleIntegers {L : ℕ} {t : ℝ} (ht : 0 < t) {E : Set (Fin L → ℝ)} (hE : E ⊆ Set.Icc (fun _ => 0) (fun _ => 1)) (horder : ∀ x ∈ E, Antitone x) {m : Fin L → ℕ} (hm : meshBox t m ⊆ E) : boxIntegers m ⊆ tupleIntegers L t E := by intro n hn obtain ⟨q, hq, hprod⟩ := mem_image.mp hn exact (mem_tupleIntegers ht hE).mpr ⟨q, hprod, fun idx => Or.inl (boxPrimeTuples_prime hq idx), (boxPrimeTuples_strictAnti (meshBox_strictAnti_labels ht horder hm) hq).antitone, hm (boxPrimeTuples_point ht hq)⟩ /-- The lower reciprocal-volume estimate for the actual finite family of integers. -/ /- Original line 31773: Erdos416Proof.FordReciprocal.exists_tupleReciprocalMass_volume_lower -/ theorem exists_tupleReciprocalMass_volume_lower : ∃ c : ℝ, 0 < c ∧ ∀ (L : ℕ) (t : ℝ) (E : Set (Fin L → ℝ)), 0 < t → E ⊆ Set.Icc (fun _ => 0) (fun _ => 1) → (∀ x ∈ E, Antitone x) → c*t^L*volume.real (cubeErosion E (1/t)) ≤ tupleReciprocalMass L t E := by obtain ⟨c, hc, hbound⟩ := exists_boxIntegers_mass_lower refine ⟨c, hc, ?_⟩ intro L t E ht hE horder let I := containedMeshBoxes L t E have hsub (m : Fin L → ℕ) (hm : m ∈ I) : meshBox t m ⊆ E := (mem_containedMeshBoxes ht hE).mp hm have hanti (m : Fin L → ℕ) (hm : m ∈ I) : StrictAnti m := meshBox_strictAnti_labels ht horder (hsub m hm) have hdisjoint : Set.PairwiseDisjoint (↑I) boxIntegers := fun m hm k hk hmk => boxIntegers_disjoint (hanti m hm) (hanti k hk) hmk have hF : I.biUnion boxIntegers ⊆ tupleIntegers L t E := by intro n hn obtain ⟨m, hm, hnm⟩ := mem_biUnion.mp hn exact boxIntegers_subset_tupleIntegers ht hE horder (hsub m hm) hnm calc _ = c*(t^L*volume.real (cubeErosion E (1/t))) := by ring _ ≤ c*(I.card : ℝ) := mul_le_mul_of_nonneg_left (cubeErosion_volume_le_box_count ht hE) hc.le _ = ∑ _m ∈ I, c := by simp [Erdos416Proof.FordReciprocal.binMass_zero, Erdos416Proof.invTotient_one, Erdos416Proof.weightedInvTotient_one, mul_comm] _ ≤ ∑ m ∈ I, ∑ n ∈ boxIntegers m, invTotient n := sum_le_sum (fun m hm => hbound L m (hanti m hm)) _ = ∑ n ∈ I.biUnion boxIntegers, invTotient n := (sum_biUnion hdisjoint).symm _ ≤ _ := sum_le_sum_of_subset_of_nonneg hF (fun n _ _ => invTotient_nonneg n) end Erdos416Proof.FordReciprocal /- Exact coordinate-cap volumes, exponential tails and lower-slice losses for the actual Ford simplices, including the core-scale loss with its rho^M factor. The contracted inner-region inclusion and positive-alpha thickening remain. -/ open Finset MeasureTheory open scoped BigOperators Classical namespace Erdos416Proof.SimplexVolume variable {n : ℕ} /- Original line 31817: Erdos416Proof.SimplexVolume.coordinateShift -/ def coordinateShift (p : Fin n) (α : ℝ) : Fin n → ℝ := fun idx => if idx = p then α else 0 /- Original line 31819: Erdos416Proof.SimplexVolume.coordinateShift_weight_sum -/ theorem coordinateShift_weight_sum (b : Fin n → ℝ) (p : Fin n) (α : ℝ) (x : Fin n → ℝ) : (∑ idx, b idx*(x+coordinateShift p α) idx) = (∑ idx, b idx*x idx)+b p*α := by simp [Pi.add_apply, coordinateShift, mul_add, sum_add_distrib, mul_ite] /- Original line 31823: Erdos416Proof.SimplexVolume.simplexCap -/ def simplexCap (b : Fin n → ℝ) (p : Fin n) (α t : ℝ) : Set (Fin n → ℝ) := weightedSimplex n b t ∩ {x | α ≤ x p} /- Original line 31826: Erdos416Proof.SimplexVolume.simplexCap_translate -/ theorem simplexCap_translate (b : Fin n → ℝ) (p : Fin n) {α : ℝ} (hα : 0 ≤ α) (t : ℝ) : (fun x => x+coordinateShift p α) '' weightedSimplex n b (t-b p*α) = simplexCap b p α t := by ext y constructor · rintro ⟨x, hx, rfl⟩ refine ⟨⟨?_, ?_⟩, ?_⟩ · intro idx exact add_nonneg (hx.1 idx) (by dsimp [coordinateShift]; split_ifs <;> linarith) · rw [coordinateShift_weight_sum] linarith [hx.2] · change α ≤ x p+coordinateShift p α p simpa [coordinateShift] using hx.1 p · intro hy refine ⟨y-coordinateShift p α, ⟨?_, ?_⟩, sub_add_cancel _ _⟩ · intro idx change 0 ≤ y idx-coordinateShift p α idx by_cases hi : idx = p · subst idx simpa [coordinateShift] using (show α ≤ y p from hy.2) · simpa only [coordinateShift, if_neg hi, sub_zero] using hy.1.1 idx · have hsum := coordinateShift_weight_sum b p α (y-coordinateShift p α) rw [sub_add_cancel] at hsum linarith [hy.1.2] /- Original line 31851: Erdos416Proof.SimplexVolume.simplexCap_volume -/ theorem simplexCap_volume {b : Fin n → ℝ} (hb : ∀ idx, 0 < b idx) (p : Fin n) {α t : ℝ} (hα : 0 ≤ α) (ht : 0 ≤ t-b p*α) : volume.real (simplexCap b p α t) = (t-b p*α)^n / ((n.factorial : ℝ)*∏ idx, b idx) := by rw [← simplexCap_translate b p hα t, measureReal_def, Set.image_add_right, measure_preimage_add_right, ← measureReal_def, realVolume_weightedSimplex hb ht] /- Original line 31857: Erdos416Proof.SimplexVolume.simplexCap_empty_of_lt -/ theorem simplexCap_empty_of_lt {b : Fin n → ℝ} (hb : ∀ idx, 0 < b idx) (p : Fin n) {α t : ℝ} (ht : t < b p*α) : simplexCap b p α t = ∅ := by apply Set.eq_empty_iff_forall_notMem.mpr intro x hx have hsum : b p*x p ≤ ∑ idx, b idx*x idx := single_le_sum (fun idx _ => mul_nonneg (hb idx).le (hx.1.1 idx)) (mem_univ p) have hαx := mul_le_mul_of_nonneg_left hx.2 (hb p).le linarith [hx.1.2] /- Original line 31866: Erdos416Proof.SimplexVolume.simplexCap_exponential_bound -/ theorem simplexCap_exponential_bound {b : Fin n → ℝ} (hb : ∀ idx, 0 < b idx) (p : Fin n) {α : ℝ} (hα : 0 ≤ α) : volume.real (simplexCap b p α 1) ≤ Real.exp (-(n : ℝ)*(b p*α))*volume.real (weightedSimplex n b 1) := by by_cases hcut : b p*α ≤ 1 · have hpow : (1-b p*α)^n ≤ Real.exp (-(n : ℝ)*(b p*α)) := by calc _ ≤ (Real.exp (-(b p*α)))^n := pow_le_pow_left₀ (by linarith) (by linarith [Real.add_one_le_exp (-(b p*α))]) n _ = _ := by rw [← Real.exp_nat_mul]; congr 1; ring calc _ = (1-b p*α)^n / ((n.factorial : ℝ)*∏ idx, b idx) := simplexCap_volume hb p hα (by linarith) _ ≤ Real.exp (-(n : ℝ)*(b p*α)) / ((n.factorial : ℝ)*∏ idx, b idx) := div_le_div_of_nonneg_right hpow (mul_nonneg (Nat.cast_nonneg _) (prod_nonneg fun idx _ => (hb idx).le)) _ = _ := by rw [realVolume_weightedSimplex hb zero_le_one, one_pow]; ring · rw [simplexCap_empty_of_lt hb p (lt_of_not_ge hcut)] simp only [measureReal_empty] positivity /- Original line 31885: Erdos416Proof.SimplexVolume.simplexCap_volume_lower -/ theorem simplexCap_volume_lower {b : Fin n → ℝ} (hb : ∀ idx, 0 < b idx) (p : Fin n) {α : ℝ} (hα : 0 ≤ α) : (1-(n : ℝ)*(b p*α))*volume.real (weightedSimplex n b 1) ≤ volume.real (simplexCap b p α 1) := by by_cases hcut : b p*α ≤ 1 · have hpow : 1-(n : ℝ)*(b p*α) ≤ (1-b p*α)^n := by simpa only [neg_mul, add_neg_cancel_right, sub_eq_add_neg, mul_neg] using (one_add_mul_le_pow (a := -(b p*α)) (by linarith : -2 ≤ -(b p*α)) n) rw [simplexCap_volume hb p hα (by linarith), realVolume_weightedSimplex hb zero_le_one, one_pow] simpa only [mul_one_div] using div_le_div_of_nonneg_right hpow (mul_nonneg (Nat.cast_nonneg _) (prod_nonneg fun idx _ => (hb idx).le)) · have hn : (1 : ℝ) ≤ n := by exact_mod_cast (show 1 ≤ n by have := p.isLt; omega) have hneg : 1-(n : ℝ)*(b p*α) ≤ 0 := by have hprod := mul_le_mul_of_nonneg_right hn (mul_nonneg (hb p).le hα) nlinarith exact (mul_nonpos_of_nonpos_of_nonneg hneg measureReal_nonneg).trans measureReal_nonneg /-- The strict lower-coordinate slice is small, with the dimension factor explicit. -/ /- Original line 31903: Erdos416Proof.SimplexVolume.simplex_lower_slice_bound -/ theorem simplex_lower_slice_bound {b : Fin n → ℝ} (hb : ∀ idx, 0 < b idx) (p : Fin n) {α : ℝ} (hα : 0 ≤ α) : volume.real (weightedSimplex n b 1 ∩ {x | x p < α}) ≤ (n : ℝ)*(b p*α)*volume.real (weightedSimplex n b 1) := by have hmeas : MeasurableSet {x : Fin n → ℝ | α ≤ x p} := (isClosed_le continuous_const (continuous_apply p)).measurableSet have hfinite : volume (weightedSimplex n b 1) ≠ ⊤ := (weightedSimplex_isCompact hb 1).measure_lt_top.ne have heq : weightedSimplex n b 1 \ {x | α ≤ x p} = weightedSimplex n b 1 ∩ {x | x p < α} := by ext x; simp have hsplit := measureReal_sdiff_add_inter (μ := volume) hmeas hfinite rw [heq] at hsplit have hcap := simplexCap_volume_lower hb p hα change _ ≤ volume.real (weightedSimplex n b 1 ∩ {x | α ≤ x p}) at hcap nlinarith end Erdos416Proof.SimplexVolume namespace Erdos416Proof.FordGeometry open SimplexVolume variable {L : ℕ} /- Original line 31926: Erdos416Proof.FordGeometry.slack_terminal_eq -/ theorem slack_terminal_eq (p : Fin L) (hp : p.val+1 = L) (x : Fin L → ℝ) : slackMap L x p = x p := by rw [slackMap_apply, tailForm_terminal p hp, sub_zero] /- Original line 31930: Erdos416Proof.FordGeometry.slack_image_coordinate_cap -/ theorem slack_image_coordinate_cap (hL : 2 ≤ L) (p : Fin L) (hp : p.val+1 = L) (α : ℝ) : slackMap L '' (unorderedSimplex L ∩ {x | α ≤ x p}) = simplexCap (simplexWeight L) p α 1 := by ext y constructor · rintro ⟨x, hx, rfl⟩ exact ⟨(slack_mem_weightedSimplex_iff hL x).mpr hx.1, by simpa only [Set.mem_ofPred_eq, slack_terminal_eq p hp] using hx.2⟩ · intro hy obtain ⟨x, hx⟩ := (slackEquiv L).surjective y rw [slackEquiv_apply] at hx have hxU := (slack_mem_weightedSimplex_iff hL x).mp (hx.symm ▸ hy.1) have hxp : α ≤ x p := by rw [← slack_terminal_eq p hp x, hx]; exact hy.2 exact ⟨x, ⟨hxU, hxp⟩, hx⟩ /- Original line 31945: Erdos416Proof.FordGeometry.slack_image_lower_slice -/ theorem slack_image_lower_slice (hL : 2 ≤ L) (p : Fin L) (hp : p.val+1 = L) (α : ℝ) : slackMap L '' (unorderedSimplex L ∩ {x | x p < α}) = weightedSimplex L (simplexWeight L) 1 ∩ {x | x p < α} := by ext y constructor · rintro ⟨x, hx, rfl⟩ exact ⟨(slack_mem_weightedSimplex_iff hL x).mpr hx.1, by simpa only [Set.mem_ofPred_eq, slack_terminal_eq p hp] using hx.2⟩ · intro hy obtain ⟨x, hx⟩ := (slackEquiv L).surjective y rw [slackEquiv_apply] at hx have hxU := (slack_mem_weightedSimplex_iff hL x).mp (hx.symm ▸ hy.1) have hxp : x p < α := by rw [← slack_terminal_eq p hp x, hx]; exact hy.2 exact ⟨x, ⟨hxU, hxp⟩, hx⟩ /- Original line 31960: Erdos416Proof.FordGeometry.weightedSimplex_volume_eq_TStar -/ theorem weightedSimplex_volume_eq_TStar (hL : 2 ≤ L) : volume.real (weightedSimplex L (simplexWeight L) 1) = TStar L := by rw [← slack_image_unorderedSimplex hL, slack_volume_image] rfl /- Original line 31965: Erdos416Proof.FordGeometry.unordered_coordinate_cap_bound -/ theorem unordered_coordinate_cap_bound (hL : 2 ≤ L) (p : Fin L) (hp : p.val+1 = L) {α : ℝ} (hα : 0 ≤ α) : volume.real (unorderedSimplex L ∩ {x | α ≤ x p}) ≤ Real.exp (-(L : ℝ)*(simplexWeight L p*α))*TStar L := by have h := simplexCap_exponential_bound (fun idx => simplexWeight_pos idx) p hα rw [← slack_image_coordinate_cap hL p hp α, slack_volume_image, weightedSimplex_volume_eq_TStar hL] at h exact h /- Original line 31974: Erdos416Proof.FordGeometry.unordered_coordinate_slice_bound -/ theorem unordered_coordinate_slice_bound (hL : 2 ≤ L) (p : Fin L) (hp : p.val+1 = L) {α : ℝ} (hα : 0 ≤ α) : volume.real (unorderedSimplex L ∩ {x | x p < α}) ≤ (L : ℝ)*(simplexWeight L p*α)*TStar L := by have h := simplex_lower_slice_bound (fun idx => simplexWeight_pos idx) p hα rw [← slack_image_lower_slice hL p hp α, slack_volume_image, weightedSimplex_volume_eq_TStar hL] at h exact h /-- Removing a small last-coordinate slice preserves the actual ordered volume up to this loss. -/ /- Original line 31984: Erdos416Proof.FordGeometry.ordered_coordinate_cap_lower -/ theorem ordered_coordinate_cap_lower (hL : 2 ≤ L) (p : Fin L) (hp : p.val+1 = L) {α : ℝ} (hα : 0 ≤ α) : T L-(L : ℝ)*(simplexWeight L p*α)*TStar L ≤ volume.real (polytope L (fun _ => 1) ∩ {x | α ≤ x p}) := by have hsub : polytope L (fun _ => 1) ∩ {x | x p < α} ⊆ unorderedSimplex L ∩ {x | x p < α} := fun x hx => ⟨polytope_subset_unorderedSimplex L hx.1, hx.2⟩ have hfiniteU : volume (unorderedSimplex L ∩ {x | x p < α}) ≠ ⊤ := measure_ne_top_of_subset Set.inter_subset_left (unorderedSimplex_isCompact hL).measure_lt_top.ne have hsmall := (measureReal_mono hsub hfiniteU).trans (unordered_coordinate_slice_bound hL p hp hα) have hmeas : MeasurableSet {x : Fin L → ℝ | α ≤ x p} := (isClosed_le continuous_const (continuous_apply p)).measurableSet have heq : polytope L (fun _ => 1) \ {x | α ≤ x p} = polytope L (fun _ => 1) ∩ {x | x p < α} := by ext x; simp have hsplit := measureReal_inter_add_sdiff (μ := volume) hmeas (polytope_isCompact L (fun _ => 1)).measure_lt_top.ne rw [heq] at hsplit change _+_ = T L at hsplit linarith end Erdos416Proof.FordGeometry namespace Erdos416Proof.FordScale open Filter FordAnalysis FordGeometry open scoped Topology /-- Retaining the fixed tail parameter supplies the small factor lost by the coarse mesh bound. -/ /- Original line 32013: Erdos416Proof.FordScale.coreDimension_rho_lower_with_tail -/ theorem coreDimension_rho_lower_with_tail (M : ℕ) : ∀ᶠ t : ℝ in atTop, Real.log t/t ≤ rho^(coreDimension M t)*rho^M := by filter_upwards [coreDimension_add_tail M, eventually_gt_atTop (1 : ℝ)] with t hadd ht rw [← pow_add, hadd] simpa only [coreDimension, Nat.sub_zero] using coreDimension_rho_lower 0 ht /- Original line 32019: Erdos416Proof.FordScale.core_last_cutoff_loss_bound -/ theorem core_last_cutoff_loss_bound (M : ℕ) {A : ℝ} (hA : 0 ≤ A) : ∀ᶠ t : ℝ in atTop, ∀ p : Fin (coreDimension M t), p.val+1 = coreDimension M t → (coreDimension M t : ℝ)*(simplexWeight (coreDimension M t) p*(A/t)) ≤ 4*A*rho^M := by filter_upwards [coreDimension_rho_lower_with_tail M, eventually_ge_atTop (Real.exp 1), (coreDimension_tendsto M).eventually (eventually_ge_atTop 2)] with t hr ht hL intro p hp have htpos : 0 < t := (Real.exp_pos _).trans_le ht have hb := simplexWeight_pos p have hweight := simplexWeight_scaled_le_one hL p rw [hp] at hweight have hblog : simplexWeight (coreDimension M t) p*(Real.log t/t) ≤ rho^M := by calc _ ≤ simplexWeight (coreDimension M t) p*(rho^(coreDimension M t)*rho^M) := mul_le_mul_of_nonneg_left hr hb.le _ = (simplexWeight (coreDimension M t) p*rho^(coreDimension M t))*rho^M := by ring _ ≤ 1*rho^M := mul_le_mul_of_nonneg_right hweight (pow_nonneg rho_pos.le M) _ = _ := one_mul _ have hcoef : (coreDimension M t : ℝ)*simplexWeight (coreDimension M t) p/t ≤ 4*rho^M := by calc _ ≤ (4*Real.log t)*simplexWeight (coreDimension M t) p/t := div_le_div_of_nonneg_right (mul_le_mul_of_nonneg_right (coreDimension_le_four_log M ht) hb.le) htpos.le _ = 4*(simplexWeight (coreDimension M t) p*(Real.log t/t)) := by ring _ ≤ _ := mul_le_mul_of_nonneg_left hblog (by norm_num) calc _ = A*((coreDimension M t : ℝ)*simplexWeight (coreDimension M t) p/t) := by ring _ ≤ A*(4*rho^M) := mul_le_mul_of_nonneg_left hcoef hA _ = _ := by ring /-- The actual ordered polytope retains its volume up to a loss of 88 A rho^M. -/ /- Original line 32048: Erdos416Proof.FordScale.ordered_core_cap_lower -/ theorem ordered_core_cap_lower (M : ℕ) {A : ℝ} (hA : 0 ≤ A) : ∀ᶠ t : ℝ in atTop, ∀ p : Fin (coreDimension M t), p.val+1 = coreDimension M t → (1-88*A*rho^M)*T (coreDimension M t) ≤ volume.real (polytope (coreDimension M t) (fun _ => 1) ∩ {x | A/t ≤ x p}) := by filter_upwards [core_last_cutoff_loss_bound M hA, (coreDimension_tendsto M).eventually T_eventually_ge_TStar_div, (coreDimension_tendsto M).eventually (eventually_ge_atTop 2), eventually_gt_atTop (0 : ℝ)] with t hcut hT hL ht intro p hp have hraw := ordered_coordinate_cap_lower hL p hp (div_nonneg hA ht.le) have hT' : TStar (coreDimension M t) ≤ 22*T (coreDimension M t) := by linarith have hprod := mul_le_mul (hcut p hp) hT' (show 0 ≤ TStar (coreDimension M t) from measureReal_nonneg) (mul_nonneg (mul_nonneg (by norm_num) hA) (pow_nonneg rho_pos.le M)) nlinarith /- Original line 32063: Erdos416Proof.FordScale.ordered_core_cap_half -/ theorem ordered_core_cap_half {A : ℝ} (hA : 0 ≤ A) : ∀ᶠ M : ℕ in atTop, ∀ᶠ t : ℝ in atTop, ∀ p : Fin (coreDimension M t), p.val+1 = coreDimension M t → T (coreDimension M t)/2 ≤ volume.real (polytope (coreDimension M t) (fun _ => 1) ∩ {x | A/t ≤ x p}) := by have hlim : Tendsto (fun M : ℕ => 88*A*rho^M) atTop (nhds 0) := by simpa only [mul_zero] using (tendsto_pow_atTop_nhds_zero_of_lt_one rho_pos.le rho_lt_one).const_mul (88*A) filter_upwards [hlim.eventually_lt_const (by norm_num : (0 : ℝ) < 1/2)] with M hM filter_upwards [ordered_core_cap_lower M hA] with t ht intro p hp have h := ht p hp have hT : 0 ≤ T (coreDimension M t) := measureReal_nonneg nlinarith end Erdos416Proof.FordScale /- The actual contracted inner region, including inverse-rho coordinate growth, the corrected diagonal cutoff, a uniform positive determinant factor, every mesh margin and the core-scale reciprocal lower count for each fixed cutoff. Distinct-totient order, structural estimates and final coverage remain. -/ open Finset open MeasureTheory open scoped BigOperators Classical namespace Erdos416Proof.FordAnalysis /- Original line 32094: Erdos416Proof.FordAnalysis.g_le_gStar -/ theorem g_le_gStar (n : ℕ) : g n ≤ gStar n := by cases n with | zero => simp[Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.gStar_zero, Erdos416Proof.FordAnalysis.g_zero] | succ n => rw [gStar_succ] exact le_add_of_nonneg_right (mul_nonneg (sub_nonneg.mpr coeff_one_lt_one.le) (g_pos n).le) /- Original line 32101: Erdos416Proof.FordAnalysis.gStar_scaled_lower -/ theorem gStar_scaled_lower (n : ℕ) : (1/4 : ℝ) ≤ gStar n*rho^n := by rcases n with _ | n · norm_num[Erdos416Proof.FordAnalysis.g_zero, Erdos416Proof.FordAnalysis.gStar_zero] by_cases hn : n = 0 · subst n have hg1 : g 1 = coeff 1 := by simpa [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.gStar_zero, Erdos416Proof.FordAnalysis.g_zero] using FordGeometry.g_succ_tail_sum 0 have hgStar1 : gStar 1 = 1 := by rw [gStar_succ, hg1, g_zero]; ring rw [hgStar1, one_mul, pow_one] linarith [rho_numeric_bounds.1] · have h := (g_scaled_uniform_lower (by omega : 2 ≤ n+1)).le.trans (mul_le_mul_of_nonneg_right (g_le_gStar (n+1)) (pow_nonneg rho_pos.le (n+1))) linarith end Erdos416Proof.FordAnalysis namespace Erdos416Proof.FordGeometry open FordAnalysis variable {L : ℕ} /- Original line 32122: Erdos416Proof.FordGeometry.inverseSlackWeight_nonneg -/ theorem inverseSlackWeight_nonneg (idx j : Fin L) : 0 ≤ inverseSlackWeight idx j := by unfold inverseSlackWeight split_ifs · exact (g_pos _).le · exact (gStar_pos _).le · exact le_rfl /-- Every coordinate dominates the actual last-column contribution in the inverse slack map. -/ /- Original line 32130: Erdos416Proof.FordGeometry.unordered_coordinate_ge_terminal -/ theorem unordered_coordinate_ge_terminal {x : Fin L → ℝ} (hx : x ∈ unorderedSimplex L) (p : Fin L) (hp : p.val+1 = L) (idx : Fin L) : gStar (p.val-idx.val)*x p ≤ x idx := by have hs (j : Fin L) : 0 ≤ slackMap L x j := by rw [slackMap_apply] exact sub_nonneg.mpr (hx.2 j) have h := single_le_sum (s := (univ : Finset (Fin L))) (fun j _ => mul_nonneg (inverseSlackWeight_nonneg idx j) (hs j)) (mem_univ p) have hip : idx.val ≤ p.val := by have := idx.isLt; omega have hweight : inverseSlackWeight idx p = gStar (p.val-idx.val) := by simp [Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.gStar_zero, Erdos416Proof.FordAnalysis.g_zero, Erdos416Proof.FordGeometry.slackEquiv_apply, Erdos416Proof.FordGeometry.slackMap_apply, inverseSlackWeight, hip, hp] rw [inverse_slack_coordinates, hweight, slackMap_apply, tailForm_terminal p hp, sub_zero] at h exact h /-- The required growth is by the inverse power of rho as the distance from the last coordinate grows. -/ /- Original line 32145: Erdos416Proof.FordGeometry.unordered_terminal_growth -/ theorem unordered_terminal_growth {x : Fin L → ℝ} (hx : x ∈ unorderedSimplex L) (p : Fin L) (hp : p.val+1 = L) (idx : Fin L) : x p/(4*rho^(p.val-idx.val)) ≤ x idx := by have hx0 := unorderedSimplex_nonneg hx p have hscaled := mul_le_mul_of_nonneg_right (gStar_scaled_lower (p.val-idx.val)) hx0 have hcoord := mul_le_mul_of_nonneg_right (unordered_coordinate_ge_terminal hx p hp idx) (pow_nonneg rho_pos.le (p.val-idx.val)) apply (div_le_iff₀ (mul_pos (by norm_num : (0 : ℝ) < 4) (pow_pos rho_pos _))).mpr nlinarith /- Original line 32156: Erdos416Proof.FordGeometry.polytope_subset_unordered_of_le_one -/ theorem polytope_subset_unordered_of_le_one {ξ : ℕ → ℝ} (hξ : ∀ j, ξ j ≤ 1) : polytope L ξ ⊆ unorderedSimplex L := by intro x hx refine ⟨hx.2.2.2.1.trans (hξ 0), ?_⟩ intro idx by_cases hi : idx.val+1 < L · exact (hx.2.2.2.2 idx hi).trans (mul_le_of_le_one_left (hx.1 idx) (hξ (idx.val+1))) · rw [tailForm_terminal idx (by have := idx.isLt; omega)] exact hx.1 idx /-- A mesh perturbation preserves the inverse-rho coordinate lower bound when the last coordinate is large. -/ /- Original line 32167: Erdos416Proof.FordGeometry.perturbed_terminal_growth -/ theorem perturbed_terminal_growth {x e : Fin L → ℝ} (hx : x ∈ unorderedSimplex L) (p : Fin L) (hp : p.val+1 = L) {τ : ℝ} (he : e ∈ errorCube L τ) (hlarge : 8*τ ≤ x p) (idx : Fin L) : x p/(8*rho^(p.val-idx.val)) ≤ (x+e) idx := by have hraw := unordered_terminal_growth hx p hp idx have hρ : rho^(p.val-idx.val) ≤ 1 := pow_le_one₀ rho_pos.le rho_lt_one.le have hx0 := unorderedSimplex_nonneg hx idx have hmul := (div_le_iff₀ (mul_pos (by norm_num : (0 : ℝ) < 4) (pow_pos rho_pos (p.val-idx.val)))).mp hraw have htwo : 2*τ ≤ x idx := by have h := mul_le_mul_of_nonneg_left hρ (mul_nonneg (by norm_num : (0 : ℝ) ≤ 4) hx0) nlinarith have hhalf : x idx/2 ≤ (x+e) idx := by change x idx/2 ≤ x idx+e idx linarith [he.1 idx] calc _ = (x p/(4*rho^(p.val-idx.val)))/2 := by ring _ ≤ x idx/2 := div_le_div_of_nonneg_right hraw (by norm_num) _ ≤ _ := hhalf /- Original line 32188: Erdos416Proof.FordGeometry.H_le_scaleProduct -/ theorem H_le_scaleProduct {ξ : ℕ → ℝ} (hξ : ∀ j, 0 < ξ j ∧ ξ j ≤ 1) (L : ℕ) : H L ξ ≤ scaleProduct ξ L := by cases L with | zero => simp [Erdos416Proof.FordGeometry.diagonal_apply, Erdos416Proof.FordGeometry.prefix_one, Erdos416Proof.FordGeometry.prefix_zero, H] | succ n => rw [← scaleProduct_product] have hsub : ({n} : Finset ℕ) ⊆ range (n+1) := singleton_subset_iff.mpr (mem_range.mpr (Nat.lt_succ_self n)) have h := prod_le_prod_of_subset_of_le_one (f := fun j => scaleProduct ξ (j+1)) hsub (fun j _ => (prefix_pos (fun k => (hξ k).1) _).le) (fun j _ _ => by simpa only [prefix_zero] using prefix_antitone hξ (show 0 ≤ j+1 by omega)) simpa only [prod_singleton] using h /- Original line 32202: Erdos416Proof.FordGeometry.diagonal_adjacent_bound -/ theorem diagonal_adjacent_bound {ξ : ℕ → ℝ} (hξ : ∀ j, 0 < ξ j) {x : Fin L → ℝ} (hx : Antitone x) {idx j : Fin L} (hij : j.val = idx.val+1) : diagonal L ξ x j ≤ ξ (idx.val+1)*diagonal L ξ x idx := by have hxy : x j ≤ x idx := hx (by change idx.val ≤ j.val; omega) simp only [diagonal_apply, hij, prefix_succ] have h := mul_le_mul_of_nonneg_left hxy (mul_nonneg (prefix_pos hξ (idx.val+1)).le (hξ (idx.val+1)).le) simpa only [prefix_succ, mul_assoc, mul_left_comm] using h /-- The contracted polytope with all adjacent gaps and a terminal cutoff. -/ /- Original line 32211: Erdos416Proof.FordGeometry.separatedCap -/ def separatedCap (ξ : ℕ → ℝ) (p : Fin L) (α : ℝ) : Set (Fin L → ℝ) := {x | x ∈ polytope L ξ ∧ (∀ idx j : Fin L, j.val = idx.val+1 → x j ≤ ξ (idx.val+1)*x idx) ∧ α ≤ x p} /-- The terminal cutoff must be divided by the contraction product before taking the image. -/ /- Original line 32216: Erdos416Proof.FordGeometry.diagonal_cap_subset -/ theorem diagonal_cap_subset {ξ : ℕ → ℝ} (hξ : ∀ j, 0 < ξ j ∧ ξ j ≤ 1) (p : Fin L) (hp : p.val+1 = L) (α : ℝ) : diagonal L ξ '' (polytope L (fun _ => 1) ∩ {y | α/scaleProduct ξ L ≤ y p}) ⊆ separatedCap ξ p α := by rintro x ⟨y, hy, rfl⟩ refine ⟨diagonal_mem hξ hy.1, fun idx j hij => diagonal_adjacent_bound (fun k => (hξ k).1) hy.1.2.2.1 hij, ?_⟩ rw [diagonal_apply, hp] have h := (div_le_iff₀ (prefix_pos (fun j => (hξ j).1) L)).mp hy.2 simpa only [mul_comm] using h /- Original line 32227: Erdos416Proof.FordGeometry.separatedCap_volume_lower -/ theorem separatedCap_volume_lower {ξ : ℕ → ℝ} (hξ : ∀ j, 0 < ξ j ∧ ξ j ≤ 1) (p : Fin L) (hp : p.val+1 = L) (α : ℝ) : H L ξ*volume.real (polytope L (fun _ => 1) ∩ {y | α/scaleProduct ξ L ≤ y p}) ≤ volume.real (separatedCap ξ p α) := by have hfinite : volume (separatedCap ξ p α) ≠ ⊤ := measure_ne_top_of_subset (fun _ hx => hx.1) (polytope_isCompact L ξ).measure_lt_top.ne have h := measureReal_mono (diagonal_cap_subset hξ p hp α) hfinite simpa only [diagonal_volume, abs_of_nonneg (H_nonneg (fun j => (hξ j).1.le))] using h end Erdos416Proof.FordGeometry namespace Erdos416Proof.FordInner open Filter FordAnalysis FordGeometry FordReciprocal open scoped Topology /- Original line 32244: Erdos416Proof.FordInner.innerRadius -/ def innerRadius (d : ℕ) : ℝ := 4+((d : ℝ)+1)^2 /- Original line 32246: Erdos416Proof.FordInner.innerRadius_pos -/ theorem innerRadius_pos (d : ℕ) : 0 < innerRadius d := by unfold innerRadius; positivity /- Original line 32248: Erdos416Proof.FordInner.summable_inner_radius_mass -/ theorem summable_inner_radius_mass : Summable (fun d : ℕ => (d : ℝ)*innerRadius d*rho^d) := by have hr : ‖rho‖ < 1 := by simpa only [Real.norm_eq_abs, abs_of_pos rho_pos] using rho_lt_one have h1 := summable_pow_mul_geometric_of_norm_lt_one 1 hr have h2 := summable_pow_mul_geometric_of_norm_lt_one 2 hr have h3 := summable_pow_mul_geometric_of_norm_lt_one 3 hr apply (h3.add ((h2.mul_left 2).add (h1.mul_left 5))).congr intro d dsimp [innerRadius] ring /- Original line 32259: Erdos416Proof.FordInner.radiusMass -/ noncomputable def radiusMass : ℝ := ∑' d : ℕ, (d : ℝ)*innerRadius d*rho^d /- Original line 32261: Erdos416Proof.FordInner.radiusMass_nonneg -/ theorem radiusMass_nonneg : 0 ≤ radiusMass := tsum_nonneg fun d => mul_nonneg (mul_nonneg (Nat.cast_nonneg d) (innerRadius_pos d).le) (pow_nonneg rho_pos.le d) /- Original line 32265: Erdos416Proof.FordInner.innerEpsilon -/ noncomputable def innerEpsilon : ℝ := 1/(8*(radiusMass+1)) /- Original line 32267: Erdos416Proof.FordInner.innerEpsilon_pos -/ theorem innerEpsilon_pos : 0 < innerEpsilon := by have h := radiusMass_nonneg unfold innerEpsilon positivity /- Original line 32272: Erdos416Proof.FordInner.innerEpsilon_mass_le -/ theorem innerEpsilon_mass_le : innerEpsilon*radiusMass ≤ 1/8 := by have hden : 0 < 8*(radiusMass+1) := by have h := radiusMass_nonneg; positivity have heq : innerEpsilon*(8*(radiusMass+1)) = 1 := by unfold innerEpsilon exact div_mul_cancel₀ _ hden.ne' nlinarith [innerEpsilon_pos] /- Original line 32279: Erdos416Proof.FordInner.finite_inner_radius_loss -/ theorem finite_inner_radius_loss (I : Finset ℕ) : (∑ d ∈ I, (d : ℝ)*innerEpsilon*innerRadius d*rho^d) ≤ 1/8 := by have hsum := summable_inner_radius_mass.sum_le_tsum I (fun d _ => mul_nonneg (mul_nonneg (Nat.cast_nonneg d) (innerRadius_pos d).le) (pow_nonneg rho_pos.le d)) calc _ = innerEpsilon*(∑ d ∈ I, (d : ℝ)*innerRadius d*rho^d) := by rw [mul_sum]; congr 1; ext d; ring _ ≤ innerEpsilon*radiusMass := mul_le_mul_of_nonneg_left hsum innerEpsilon_pos.le _ ≤ _ := innerEpsilon_mass_le /- Original line 32288: Erdos416Proof.FordInner.baseLoss -/ noncomputable def baseLoss (M d : ℕ) : ℝ := 1/(10*((M+d : ℕ) : ℝ)^3) /- Original line 32290: Erdos416Proof.FordInner.baseLoss_nonneg -/ theorem baseLoss_nonneg (M d : ℕ) : 0 ≤ baseLoss M d := by unfold baseLoss; positivity /- Original line 32292: Erdos416Proof.FordInner.weighted_baseLoss_le -/ theorem weighted_baseLoss_le {M d : ℕ} (hMd : 0 < M+d) : (d : ℝ)*baseLoss M d ≤ (1/10)*(1/((M+d : ℕ) : ℝ)^2) := by have hs : (0 : ℝ) < (M+d : ℕ) := by exact_mod_cast hMd have hd : (d : ℝ)/((M+d : ℕ) : ℝ) ≤ 1 := (div_le_one hs).mpr (by exact_mod_cast Nat.le_add_left d M) calc _ = ((d : ℝ)/((M+d : ℕ) : ℝ))*(1/(10*((M+d : ℕ) : ℝ)^2)) := by unfold baseLoss field_simp _ ≤ 1*(1/(10*((M+d : ℕ) : ℝ)^2)) := mul_le_mul_of_nonneg_right hd (by positivity) _ = _ := by ring /- Original line 32303: Erdos416Proof.FordInner.finite_base_loss -/ theorem finite_base_loss {M : ℕ} (hM : 2 ≤ M) (L : ℕ) : (∑ d ∈ Icc 1 L, (d : ℝ)*baseLoss M d) ≤ 1/4 := by let Q := (Icc 1 L).image (fun d => M+d) have hMr : (2 : ℝ) ≤ M := by exact_mod_cast hM have hsum := finite_inverse_square_tail_real (Q := Q) (u := (M : ℝ)) hMr (by intro q hq obtain ⟨d, _, rfl⟩ := mem_image.mp hq exact_mod_cast Nat.le_add_right M d) have hinj : Set.InjOn (fun d => M+d) (Icc 1 L) := by intro a _ b _ hab exact Nat.add_left_cancel hab change (∑ q ∈ (Icc 1 L).image (fun d => M+d), (1 : ℝ)/(q : ℝ)^2) ≤ _ at hsum rw [sum_image hinj] at hsum calc _ ≤ ∑ d ∈ Icc 1 L, (1/10)*(1/((M+d : ℕ) : ℝ)^2) := sum_le_sum (fun d _ => weighted_baseLoss_le (by omega)) _ = (1/10)*(∑ d ∈ Icc 1 L, (1 : ℝ)/((M+d : ℕ) : ℝ)^2) := (mul_sum _ _ _).symm _ ≤ (1/10)*(4/(M : ℝ)) := mul_le_mul_of_nonneg_left hsum (by norm_num) _ = 4/(10*(M : ℝ)) := by ring _ ≤ _ := (div_le_iff₀ (by positivity : 0 < 10*(M : ℝ))).mpr (by linarith) /- Original line 32324: Erdos416Proof.FordInner.reverse_range_sum -/ theorem reverse_range_sum (L : ℕ) (f : ℕ → ℝ) : (∑ j ∈ range L, f (L-j)) = ∑ d ∈ Icc 1 L, f d := by refine sum_bij (fun j _ => L-j) ?_ ?_ ?_ (fun _ _ => rfl) · intro j hj have := mem_range.mp hj exact mem_Icc.mpr ⟨by omega, by omega⟩ · intro j hj k hk heq have := mem_range.mp hj have := mem_range.mp hk omega · intro d hd obtain ⟨hd1, hdL⟩ := mem_Icc.mp hd exact ⟨L-d, mem_range.mpr (by omega), by omega⟩ /- Original line 32339: Erdos416Proof.FordInner.extraLoss -/ noncomputable def extraLoss (d : ℕ) : ℝ := innerEpsilon*innerRadius d*rho^d /- Original line 32341: Erdos416Proof.FordInner.extraLoss_nonneg -/ theorem extraLoss_nonneg (d : ℕ) : 0 ≤ extraLoss d := mul_nonneg (mul_nonneg innerEpsilon_pos.le (innerRadius_pos d).le) (pow_nonneg rho_pos.le d) /- Original line 32344: Erdos416Proof.FordInner.lossSeq -/ noncomputable def lossSeq (L M j : ℕ) : ℝ := if j < L then baseLoss M (L-j)+extraLoss (L-j) else 0 /- Original line 32347: Erdos416Proof.FordInner.targetParameter -/ noncomputable def targetParameter (L M j : ℕ) : ℝ := 1-(if j < L then baseLoss M (L-j) else 0) /- Original line 32350: Erdos416Proof.FordInner.tightParameter -/ noncomputable def tightParameter (L M j : ℕ) : ℝ := 1-lossSeq L M j /- Original line 32352: Erdos416Proof.FordInner.lossSeq_nonneg -/ theorem lossSeq_nonneg (L M j : ℕ) : 0 ≤ lossSeq L M j := by unfold lossSeq split_ifs · exact add_nonneg (baseLoss_nonneg _ _) (extraLoss_nonneg _) · exact le_rfl /- Original line 32358: Erdos416Proof.FordInner.weighted_loss_sum_le -/ theorem weighted_loss_sum_le {M : ℕ} (hM : 2 ≤ M) (L : ℕ) : (∑ j ∈ range L, ((L-j : ℕ) : ℝ)*lossSeq L M j) ≤ 1/2 := by calc _ = ∑ d ∈ Icc 1 L, (d : ℝ)*(baseLoss M d+extraLoss d) := by rw [← reverse_range_sum] apply sum_congr rfl intro j hj simp only [lossSeq, if_pos (mem_range.mp hj)] _ = (∑ d ∈ Icc 1 L, (d : ℝ)*baseLoss M d)+ (∑ d ∈ Icc 1 L, (d : ℝ)*innerEpsilon*innerRadius d*rho^d) := by simp only [mul_add, sum_add_distrib, extraLoss, mul_assoc] _ ≤ 1/4+1/8 := add_le_add (finite_base_loss hM L) (finite_inner_radius_loss _) _ ≤ _ := by norm_num /- Original line 32372: Erdos416Proof.FordInner.lossSeq_le_half -/ theorem lossSeq_le_half {M : ℕ} (hM : 2 ≤ M) (L j : ℕ) : lossSeq L M j ≤ 1/2 := by by_cases hj : j < L · have hd : (1 : ℝ) ≤ (L-j : ℕ) := by exact_mod_cast (show 1 ≤ L-j by omega) have hterm := single_le_sum (s := range L) (fun k _ => mul_nonneg (Nat.cast_nonneg (L-k)) (lossSeq_nonneg L M k)) (mem_range.mpr hj) exact (le_mul_of_one_le_left (lossSeq_nonneg L M j) hd).trans (hterm.trans (weighted_loss_sum_le hM L)) · simp [lossSeq, hj] /- Original line 32380: Erdos416Proof.FordInner.tightParameter_bounds -/ theorem tightParameter_bounds {M : ℕ} (hM : 2 ≤ M) (L j : ℕ) : 0 < tightParameter L M j ∧ tightParameter L M j ≤ 1 := by have hlo := lossSeq_nonneg L M j have hhi := lossSeq_le_half hM L j unfold tightParameter constructor <;> linarith /- Original line 32387: Erdos416Proof.FordInner.target_tight_gap -/ theorem target_tight_gap {L M j : ℕ} (hj : j < L) : targetParameter L M j-tightParameter L M j = extraLoss (L-j) := by simp only [targetParameter, tightParameter, lossSeq, if_pos hj] ring /- Original line 32392: Erdos416Proof.FordInner.tight_le_target -/ theorem tight_le_target (L M j : ℕ) : tightParameter L M j ≤ targetParameter L M j := by by_cases hj : j < L · have h := target_tight_gap (M := M) hj linarith [extraLoss_nonneg (L-j)] · simp [targetParameter, tightParameter, lossSeq, hj] /- Original line 32398: Erdos416Proof.FordInner.targetParameter_bounds -/ theorem targetParameter_bounds {M : ℕ} (hM : 2 ≤ M) (L j : ℕ) : 0 < targetParameter L M j ∧ targetParameter L M j ≤ 1 := by refine ⟨(tightParameter_bounds hM L j).1.trans_le (tight_le_target L M j), ?_⟩ unfold targetParameter split_ifs · linarith [baseLoss_nonneg M (L-j)] · simp /-- The actual contracted parameters retain an absolute positive determinant factor. -/ /- Original line 32407: Erdos416Proof.FordInner.tightParameter_H_lower -/ theorem tightParameter_H_lower {M : ℕ} (hM : 2 ≤ M) (L : ℕ) : Real.exp (-1) ≤ H L (tightParameter L M) := by have hexp : (∏ j ∈ range L, Real.exp (-2*lossSeq L M j)^(L-j)) = Real.exp (-2*(∑ j ∈ range L, ((L-j : ℕ) : ℝ)*lossSeq L M j)) := by simp_rw [← Real.exp_nat_mul] rw [← Real.exp_sum] congr 1 rw [mul_sum] apply sum_congr rfl intro j _ ring calc _ ≤ Real.exp (-2*(∑ j ∈ range L, ((L-j : ℕ) : ℝ)*lossSeq L M j)) := Real.exp_le_exp.mpr (by linarith [weighted_loss_sum_le hM L]) _ = ∏ j ∈ range L, Real.exp (-2*lossSeq L M j)^(L-j) := hexp.symm _ ≤ H L (tightParameter L M) := prod_le_prod (fun j _ => pow_nonneg (Real.exp_nonneg _) _) (fun j _ => pow_le_pow_left₀ (Real.exp_nonneg _) (exp_neg_two_le_one_sub (lossSeq_nonneg L M j) (lossSeq_le_half hM L j)) _) /- Original line 32428: Erdos416Proof.FordInner.fordWeight_le_index -/ theorem fordWeight_le_index {j : ℕ} (hj : 1 ≤ j) : fordWeight j ≤ (j : ℝ) := by have hlog := Real.log_le_sub_one_of_pos (by positivity : (0 : ℝ) < (j : ℝ)+1) linarith [(fordWeight_bounds hj).2] /- Original line 32432: Erdos416Proof.FordInner.tail_weight_sum_le_square -/ theorem tail_weight_sum_le_square {L : ℕ} (idx : Fin L) : (∑ j : Fin L, tailWeight idx j) ≤ ((L-(idx.val+1) : ℕ) : ℝ)^2 := by have hsum : (∑ j : Fin L, tailWeight idx j) = ∑ j ∈ Ioi idx, tailWeight idx j := by symm apply sum_subset (subset_univ _) intro j _ hj exact tailWeight_zero (le_of_not_gt (by simpa only [mem_Ioi] using hj)) rw [hsum] calc _ ≤ ∑ _j ∈ Ioi idx, ((L-(idx.val+1) : ℕ) : ℝ) := by apply sum_le_sum intro j hj have hij' : idx < j := mem_Ioi.mp hj have hij : idx.val < j.val := hij' have hdiff : j.val-idx.val ≤ L-(idx.val+1) := by have := j.isLt; omega unfold tailWeight rw [if_pos hij] split_ifs · exact (fordWeight_le_index (by omega)).trans (by exact_mod_cast hdiff) · exact_mod_cast (show 1 ≤ L-(idx.val+1) by have := j.isLt; omega) _ = _ := by rw [sum_const, nsmul_eq_mul, Fin.card_Ioi] have heq : L-1-idx.val = L-(idx.val+1) := by omega rw [heq] ring /- Original line 32458: Erdos416Proof.FordInner.tail_row_radius_bound -/ theorem tail_row_radius_bound {L : ℕ} (idx : Fin L) : 1+(∑ j : Fin L, tailWeight idx j) ≤ innerRadius (L-(idx.val+1)) := by have h := tail_weight_sum_le_square idx have hd : (0 : ℝ) ≤ (L-(idx.val+1) : ℕ) := Nat.cast_nonneg _ unfold innerRadius nlinarith /- Original line 32465: Erdos416Proof.FordInner.outer_weight_radius_bound -/ theorem outer_weight_radius_bound (L : ℕ) : 1+(∑ j : Fin L, fordWeight (j.val+1)) ≤ innerRadius L := by have hsum : (∑ j : Fin L, fordWeight (j.val+1)) ≤ (L : ℝ)^2 := by calc _ ≤ ∑ _j : Fin L, (L : ℝ) := by apply sum_le_sum intro j _ exact (fordWeight_le_index (j := j.val+1) (by omega)).trans (Nat.cast_le.mpr (Nat.succ_le_iff.mpr j.isLt)) _ = _ := by simp [Erdos416Proof.FordAnalysis.coeff_zero, pow_two] unfold innerRadius nlinarith [(show (0 : ℝ) ≤ L from Nat.cast_nonneg L)] /- Original line 32478: Erdos416Proof.FordInner.innerRadius_ge_two -/ theorem innerRadius_ge_two (d : ℕ) : 2 ≤ innerRadius d := by unfold innerRadius nlinarith [sq_nonneg ((d : ℝ)+1)] /- Original line 32482: Erdos416Proof.FordInner.antitone_of_adjacent -/ theorem antitone_of_adjacent {L : ℕ} {x : Fin L → ℝ} (hx : ∀ idx j : Fin L, j.val = idx.val+1 → x j ≤ x idx) : Antitone x := by cases L with | zero => intro idx; exact Fin.elim0 idx | succ n => apply Fin.antitone_iff_succ_le.mpr intro idx exact hx idx.castSucc idx.succ rfl /-- The inner seed also stores the top-coordinate margin needed after perturbation. -/ /- Original line 32492: Erdos416Proof.FordInner.innerSeed -/ def innerSeed {L : ℕ} (ξ : ℕ → ℝ) (p : Fin L) (α : ℝ) : Set (Fin L → ℝ) := separatedCap ξ p α ∩ {x | ∀ idx : Fin L, idx.val = 0 → x idx ≤ ξ 0} /- Original line 32495: Erdos416Proof.FordInner.diagonal_innerSeed_subset -/ theorem diagonal_innerSeed_subset {L : ℕ} {ξ : ℕ → ℝ} (hξ : ∀ j, 0 < ξ j ∧ ξ j ≤ 1) (p : Fin L) (hp : p.val+1 = L) (α : ℝ) : diagonal L ξ '' (polytope L (fun _ => 1) ∩ {y | α/scaleProduct ξ L ≤ y p}) ⊆ innerSeed ξ p α := by rintro x ⟨y, hy, rfl⟩ refine ⟨diagonal_cap_subset hξ p hp α ⟨y, hy, rfl⟩, ?_⟩ intro idx hi rw [diagonal_apply, hi, zero_add, prefix_one] exact mul_le_of_le_one_right (hξ 0).1.le (hy.1.2.1 idx) /- Original line 32505: Erdos416Proof.FordInner.innerSeed_volume_lower -/ theorem innerSeed_volume_lower {L : ℕ} {ξ : ℕ → ℝ} (hξ : ∀ j, 0 < ξ j ∧ ξ j ≤ 1) (p : Fin L) (hp : p.val+1 = L) (α : ℝ) : H L ξ*volume.real (polytope L (fun _ => 1) ∩ {y | α/scaleProduct ξ L ≤ y p}) ≤ volume.real (innerSeed ξ p α) := by have hfinite : volume (innerSeed ξ p α) ≠ ⊤ := measure_ne_top_of_subset (fun _ hx => hx.1.1) (polytope_isCompact L ξ).measure_lt_top.ne have h := measureReal_mono (diagonal_innerSeed_subset hξ p hp α) hfinite simpa only [diagonal_volume, abs_of_nonneg (H_nonneg (fun j => (hξ j).1.le))] using h /- Original line 32514: Erdos416Proof.FordInner.perturbation_margin -/ theorem perturbation_margin {L M : ℕ} (hM : 2 ≤ M) {τ B : ℝ} (hτ : 0 ≤ τ) (hB : 8 ≤ B) (hεB : 8 ≤ innerEpsilon*B) (p : Fin L) (hp : p.val+1 = L) {x e : Fin L → ℝ} (hx : x ∈ separatedCap (tightParameter L M) p (B*τ)) (he : e ∈ errorCube L τ) (idx : Fin L) : τ*innerRadius (p.val-idx.val) ≤ extraLoss (p.val-idx.val)*(x+e) idx := by have hxU := polytope_subset_unordered_of_le_one (fun j => (tightParameter_bounds hM L j).2) hx.1 have hlarge : 8*τ ≤ x p := (mul_le_mul_of_nonneg_right hB hτ).trans hx.2.2 have hden : 0 < 8*rho^(p.val-idx.val) := mul_pos (by norm_num) (pow_pos rho_pos _) have hlow : B*τ/(8*rho^(p.val-idx.val)) ≤ (x+e) idx := (div_le_div_of_nonneg_right hx.2.2 hden.le).trans (perturbed_terminal_growth hxU p hp he hlarge idx) have hfactor : 1 ≤ innerEpsilon*B/8 := (le_div_iff₀ (by norm_num : (0 : ℝ) < 8)).mpr (by linarith) calc _ ≤ (innerEpsilon*B/8)*(τ*innerRadius (p.val-idx.val)) := le_mul_of_one_le_left (mul_nonneg hτ (innerRadius_pos _).le) hfactor _ = extraLoss (p.val-idx.val)*(B*τ/(8*rho^(p.val-idx.val))) := by unfold extraLoss field_simp [pow_ne_zero _ rho_pos.ne'] _ ≤ _ := mul_le_mul_of_nonneg_left hlow (extraLoss_nonneg _) /-- Every coordinate-cube perturbation of the tighter seed satisfies all target constraints. -/ /- Original line 32535: Erdos416Proof.FordInner.innerSeed_subset_erosion -/ theorem innerSeed_subset_erosion {L M : ℕ} (hL : 2 ≤ L) (hM : 2 ≤ M) (p : Fin L) (hp : p.val+1 = L) {τ A B : ℝ} (hτ : 0 ≤ τ) (hB : 8 ≤ B) (hεB : 8 ≤ innerEpsilon*B) (hAB : A+1 ≤ B) (houter : τ*innerRadius L ≤ extraLoss L) : innerSeed (tightParameter L M) p (B*τ) ⊆ cubeErosion (separatedCap (targetParameter L M) p (A*τ)) τ := by intro x hx e he have hxP := hx.1.1 have hxU := polytope_subset_unordered_of_le_one (fun j => (tightParameter_bounds hM L j).2) hxP have hlarge : 8*τ ≤ x p := (mul_le_mul_of_nonneg_right hB hτ).trans hx.1.2.2 have hy0 (idx : Fin L) : 0 ≤ (x+e) idx := (div_nonneg (unorderedSimplex_nonneg hxU p) (mul_nonneg (by norm_num : (0 : ℝ) ≤ 8) (pow_nonneg rho_pos.le _))).trans (perturbed_terminal_growth hxU p hp he hlarge idx) have hmargin (idx : Fin L) (hi : idx.val+1 < L) : τ*innerRadius (L-(idx.val+1)) ≤ (targetParameter L M (idx.val+1)-tightParameter L M (idx.val+1))*(x+e) idx := by rw [target_tight_gap hi] have hd : p.val-idx.val = L-(idx.val+1) := by omega simpa only [hd] using perturbation_margin hM hτ hB hεB p hp hx.1 he idx have hxe (idx : Fin L) : x idx ≤ (x+e) idx+τ := by change x idx ≤ x idx+e idx+τ linarith [he.1 idx] have hyGap : ∀ idx j : Fin L, j.val = idx.val+1 → (x+e) j ≤ targetParameter L M (idx.val+1)*(x+e) idx := by intro idx j hij have hi : idx.val+1 < L := by have := j.isLt; omega have hgap := hx.1.2.1 idx j hij have hxi := mul_le_mul_of_nonneg_left (hxe idx) (tightParameter_bounds hM L (idx.val+1)).1.le have hzτ := mul_le_mul_of_nonneg_right (tightParameter_bounds hM L (idx.val+1)).2 hτ have hRτ := mul_le_mul_of_nonneg_left (innerRadius_ge_two (L-(idx.val+1))) hτ have hm := hmargin idx hi simp only [Pi.add_apply] at hxi hm ⊢ nlinarith [he.2 j] have hyAnti : Antitone (x+e) := antitone_of_adjacent (fun idx j hij => (hyGap idx j hij).trans (mul_le_of_le_one_left (hy0 idx) (targetParameter_bounds hM L (idx.val+1)).2)) let p0 : Fin L := ⟨0, by omega⟩ have hgap0 : targetParameter L M 0-tightParameter L M 0 = extraLoss L := by simpa only [Nat.sub_zero] using target_tight_gap (L := L) (M := M) (j := 0) (by omega) have hτδ : τ ≤ extraLoss L := (le_mul_of_one_le_right hτ (by linarith [innerRadius_ge_two L])).trans houter have hyTop : (x+e) p0 ≤ targetParameter L M 0 := by have hxTop := hx.2 p0 rfl change x p0+e p0 ≤ _ linarith [he.2 p0] have hyUnit (idx : Fin L) : (x+e) idx ≤ 1 := (hyAnti (show p0 ≤ idx by change 0 ≤ idx.val; omega)).trans (hyTop.trans (targetParameter_bounds hM L 0).2) have hyOuter : outerForm L (x+e) ≤ targetParameter L M 0 := by have heOuter : outerForm L e ≤ (∑ j : Fin L, fordWeight (j.val+1))*τ := (le_abs_self _).trans (weightedForm_errorCube_bound (fun j : Fin L => fordWeight (j.val+1)) (fun j => (fordWeight_bounds (by omega)).1) he) have hR := mul_le_mul_of_nonneg_right (outer_weight_radius_bound L) hτ rw [map_add] nlinarith [hxP.2.2.2.1] have hyTail : ∀ idx : Fin L, idx.val+1 < L → tailForm idx (x+e) ≤ targetParameter L M (idx.val+1)*(x+e) idx := by intro idx hi have hrow := hxP.2.2.2.2 idx hi have hxi := mul_le_mul_of_nonneg_left (hxe idx) (tightParameter_bounds hM L (idx.val+1)).1.le have hzτ := mul_le_mul_of_nonneg_right (tightParameter_bounds hM L (idx.val+1)).2 hτ have heTail : tailForm idx e ≤ (∑ j : Fin L, tailWeight idx j)*τ := (le_abs_self _).trans (weightedForm_errorCube_bound (tailWeight idx) (tailWeight_nonneg idx) he) have hR := mul_le_mul_of_nonneg_right (tail_row_radius_bound idx) hτ have hm := hmargin idx hi rw [map_add] simp only [Pi.add_apply] at hxi hm ⊢ nlinarith refine ⟨⟨hy0, hyUnit, hyAnti, hyOuter, hyTail⟩, hyGap, ?_⟩ have hcut := mul_le_mul_of_nonneg_right hAB hτ change A*τ ≤ x p+e p nlinarith [hx.1.2.2, he.1 p] open FordScale /- Original line 32611: Erdos416Proof.FordInner.core_outer_margin -/ theorem core_outer_margin (M : ℕ) : ∀ᶠ t : ℝ in atTop, (1/t)*innerRadius (coreDimension M t) ≤ extraLoss (coreDimension M t) := by filter_upwards [Real.tendsto_log_atTop.eventually (eventually_ge_atTop (1/innerEpsilon)), eventually_gt_atTop (1 : ℝ)] with t hlog ht have ht0 : 0 < t := by linarith have he : 1 ≤ innerEpsilon*Real.log t := by simpa only [mul_comm] using (div_le_iff₀ innerEpsilon_pos).mp hlog have hmesh : 1/t ≤ innerEpsilon*rho^(coreDimension M t) := by calc _ ≤ (innerEpsilon*Real.log t)/t := div_le_div_of_nonneg_right he ht0.le _ = innerEpsilon*(Real.log t/t) := by ring _ ≤ _ := mul_le_mul_of_nonneg_left (coreDimension_rho_lower M ht) innerEpsilon_pos.le calc _ ≤ innerEpsilon*rho^(coreDimension M t)*innerRadius (coreDimension M t) := mul_le_mul_of_nonneg_right hmesh (innerRadius_pos _).le _ = _ := by unfold extraLoss; ring /- Original line 32628: Erdos416Proof.FordInner.seedThreshold -/ noncomputable def seedThreshold (A : ℝ) : ℝ := A+9+8/innerEpsilon /- Original line 32630: Erdos416Proof.FordInner.seedThreshold_bounds -/ theorem seedThreshold_bounds {A : ℝ} (hA : 0 ≤ A) : 8 ≤ seedThreshold A ∧ 8 ≤ innerEpsilon*seedThreshold A ∧ A+1 ≤ seedThreshold A := by have hd : 0 ≤ 8/innerEpsilon := div_nonneg (by norm_num) innerEpsilon_pos.le have heq : innerEpsilon*(8/innerEpsilon) = 8 := by field_simp [innerEpsilon_pos.ne'] have hprod := mul_nonneg innerEpsilon_pos.le hA dsimp [seedThreshold] constructor · linarith constructor · nlinarith [innerEpsilon_pos] · linarith /-- A fixed terminal cutoff retains an absolute fraction of the ordered volume after contraction. -/ /- Original line 32644: Erdos416Proof.FordInner.innerSeed_core_volume_lower -/ theorem innerSeed_core_volume_lower {B : ℝ} (hB : 0 ≤ B) : ∀ᶠ M : ℕ in atTop, ∀ᶠ t : ℝ in atTop, ∀ p : Fin (coreDimension M t), p.val+1 = coreDimension M t → (Real.exp (-1)/2)*T (coreDimension M t) ≤ volume.real (innerSeed (tightParameter (coreDimension M t) M) p (B/t)) := by filter_upwards [ordered_core_cap_half (div_nonneg hB (Real.exp_pos (-1)).le), eventually_ge_atTop (2 : ℕ)] with M hcap hM filter_upwards [hcap, eventually_gt_atTop (0 : ℝ)] with t hcap ht intro p hp let L := coreDimension M t have hξ := tightParameter_bounds hM L have hH := tightParameter_H_lower hM L have hQ := hH.trans (H_le_scaleProduct hξ L) have hcut : B/t/scaleProduct (tightParameter L M) L ≤ (B/Real.exp (-1))/t := by calc _ ≤ B/t/Real.exp (-1) := div_le_div_of_nonneg_left (div_nonneg hB ht.le) (Real.exp_pos _) hQ _ = _ := by ring have hsub : polytope L (fun _ => 1) ∩ {x | (B/Real.exp (-1))/t ≤ x p} ⊆ polytope L (fun _ => 1) ∩ {x | B/t/scaleProduct (tightParameter L M) L ≤ x p} := fun _ hx => ⟨hx.1, hcut.trans hx.2⟩ have hfinite : volume (polytope L (fun _ => 1) ∩ {x | B/t/scaleProduct (tightParameter L M) L ≤ x p}) ≠ ⊤ := measure_ne_top_of_subset Set.inter_subset_left (polytope_isCompact L (fun _ => 1)).measure_lt_top.ne have hv := (hcap p hp).trans (measureReal_mono hsub hfinite) calc _ = Real.exp (-1)*(T L/2) := by ring _ ≤ Real.exp (-1)*volume.real (polytope L (fun _ => 1) ∩ {x | B/t/scaleProduct (tightParameter L M) L ≤ x p}) := mul_le_mul_of_nonneg_left hv (Real.exp_pos _).le _ ≤ H L (tightParameter L M)*volume.real (polytope L (fun _ => 1) ∩ {x | B/t/scaleProduct (tightParameter L M) L ≤ x p}) := mul_le_mul_of_nonneg_right hH measureReal_nonneg _ ≤ _ := innerSeed_volume_lower hξ p hp (B/t) /-- The actual eroded target retains a dimension-independent positive volume fraction. -/ /- Original line 32679: Erdos416Proof.FordInner.core_erosion_volume_lower -/ theorem core_erosion_volume_lower {A : ℝ} (hA : 0 ≤ A) : ∀ᶠ M : ℕ in atTop, ∀ᶠ t : ℝ in atTop, ∀ p : Fin (coreDimension M t), p.val+1 = coreDimension M t → (Real.exp (-1)/2)*T (coreDimension M t) ≤ volume.real (cubeErosion (separatedCap (targetParameter (coreDimension M t) M) p (A/t)) (1/t)) := by have hB := seedThreshold_bounds hA filter_upwards [innerSeed_core_volume_lower (B := seedThreshold A) (by linarith [hB.1]), eventually_ge_atTop (2 : ℕ)] with M hv hM filter_upwards [hv, core_outer_margin M, (coreDimension_tendsto M).eventually (eventually_ge_atTop 2), eventually_gt_atTop (0 : ℝ)] with t hv houter hL ht intro p hp have hτ : 0 ≤ 1/t := one_div_nonneg.mpr ht.le have hsub : innerSeed (tightParameter (coreDimension M t) M) p (seedThreshold A/t) ⊆ cubeErosion (separatedCap (targetParameter (coreDimension M t) M) p (A/t)) (1/t) := by simpa only [mul_one_div] using innerSeed_subset_erosion hL hM p hp hτ hB.1 hB.2.1 hB.2.2 houter have hfinite : volume (cubeErosion (separatedCap (targetParameter (coreDimension M t) M) p (A/t)) (1/t)) ≠ ⊤ := by apply measure_ne_top_of_subset (s := polytope (coreDimension M t) (targetParameter (coreDimension M t) M)) · intro x hx exact (cubeErosion_subset hτ _ hx).1 · exact (polytope_isCompact _ _).measure_lt_top.ne exact (hv p hp).trans (measureReal_mono hsub hfinite) /-- The complete inner-region reciprocal count, with all geometric hypotheses supplied. -/ /- Original line 32706: Erdos416Proof.FordInner.exists_core_inner_reciprocal_lower -/ theorem exists_core_inner_reciprocal_lower : ∃ c : ℝ, 0 < c ∧ ∀ A : ℝ, 0 ≤ A → ∀ᶠ M : ℕ in atTop, ∀ᶠ t : ℝ in atTop, ∀ p : Fin (coreDimension M t), p.val+1 = coreDimension M t → c*t^(coreDimension M t)*T (coreDimension M t) ≤ tupleReciprocalMass (coreDimension M t) t (separatedCap (targetParameter (coreDimension M t) M) p (A/t)) := by obtain ⟨c, hc, hbound⟩ := exists_tupleReciprocalMass_volume_lower refine ⟨c*(Real.exp (-1)/2), mul_pos hc (div_pos (Real.exp_pos _) (by norm_num)), ?_⟩ intro A hA filter_upwards [core_erosion_volume_lower hA] with M hM filter_upwards [hM, eventually_gt_atTop (0 : ℝ)] with t hv ht intro p hp let L := coreDimension M t let E := separatedCap (targetParameter L M) p (A/t) have hE : E ⊆ Set.Icc (fun _ => 0) (fun _ => 1) := fun _ hx => ⟨hx.1.1, hx.1.2.1⟩ have hanti : ∀ x ∈ E, Antitone x := fun _ hx => hx.1.2.2.1 calc _ = (c*t^L)*((Real.exp (-1)/2)*T L) := by ring _ ≤ (c*t^L)*volume.real (cubeErosion E (1/t)) := mul_le_mul_of_nonneg_left (hv p hp) (mul_nonneg hc.le (pow_nonneg ht.le L)) _ ≤ _ := hbound L t E ht hE hanti /- Original line 32729: Erdos416Proof.FordInner.targetParameter_at_dimension -/ theorem targetParameter_at_dimension {L M N j : ℕ} (hadd : L+M = N) (hj : j < L) : targetParameter L M j = 1-1/(10*((N-j : ℕ) : ℝ)^3) := by have heq : M+(L-j) = N-j := by omega simp only [targetParameter, if_pos hj, baseLoss, heq] /- Original line 32734: Erdos416Proof.FordInner.targetParameter_at_core_dimension -/ theorem targetParameter_at_core_dimension (M : ℕ) : ∀ᶠ t : ℝ in atTop, ∀ j : ℕ, j < coreDimension M t → targetParameter (coreDimension M t) M j = 1-1/(10*((optimalDimension t-j : ℕ) : ℝ)^3) := by filter_upwards [coreDimension_add_tail M] with t ht exact fun j hj => targetParameter_at_dimension ht hj end Erdos416Proof.FordInner /- Actual large-prime products from the contracted inner region with its top cap. Uniform lower-product bounds, actual PNT choices, unique integer reconstruction, the full prime-factor records and the lower-order count are supplied. The explicit internal totient-collision loss remains to be bounded. -/ open MeasureTheory Filter open scoped Classical Topology namespace Erdos416Proof.FordInner open FordAnalysis FordGeometry FordReciprocal FordScale /-- Retain the top-coordinate margin as well as every row, gap and terminal cutoff. -/ /- Original line 32759: Erdos416Proof.FordInner.innerSeed_subset_seedErosion -/ theorem innerSeed_subset_seedErosion {L M : ℕ} (hL : 2 ≤ L) (hM : 2 ≤ M) (p : Fin L) (hp : p.val+1 = L) {τ A B : ℝ} (hτ : 0 ≤ τ) (hB : 8 ≤ B) (hεB : 8 ≤ innerEpsilon*B) (hAB : A+1 ≤ B) (houter : τ*innerRadius L ≤ extraLoss L) : innerSeed (tightParameter L M) p (B*τ) ⊆ cubeErosion (innerSeed (targetParameter L M) p (A*τ)) τ := by intro x hx e he refine ⟨innerSeed_subset_erosion hL hM p hp hτ hB hεB hAB houter hx e he, ?_⟩ intro idx hi have hxTop := hx.2 idx hi have hgap0 : targetParameter L M 0-tightParameter L M 0 = extraLoss L := by simpa only [Nat.sub_zero] using target_tight_gap (L := L) (M := M) (j := 0) (by omega) have hτδ : τ ≤ extraLoss L := (le_mul_of_one_le_right hτ (by linarith [innerRadius_ge_two L])).trans houter change x idx+e idx ≤ targetParameter L M 0 linarith [he.2 idx] /-- The eroded target with the extra top cutoff still has an absolute volume fraction. -/ /- Original line 32777: Erdos416Proof.FordInner.core_seed_erosion_volume_lower -/ theorem core_seed_erosion_volume_lower {A : ℝ} (hA : 0 ≤ A) : ∀ᶠ M : ℕ in atTop, ∀ᶠ t : ℝ in atTop, ∀ p : Fin (coreDimension M t), p.val+1 = coreDimension M t → (Real.exp (-1)/2)*T (coreDimension M t) ≤ volume.real (cubeErosion (innerSeed (targetParameter (coreDimension M t) M) p (A/t)) (1/t)) := by have hB := seedThreshold_bounds hA filter_upwards [innerSeed_core_volume_lower (B := seedThreshold A) (by linarith [hB.1]), eventually_ge_atTop (2 : ℕ)] with M hv hM filter_upwards [hv, core_outer_margin M, (coreDimension_tendsto M).eventually (eventually_ge_atTop 2), eventually_gt_atTop (0 : ℝ)] with t hv houter hL ht intro p hp have hτ : 0 ≤ 1/t := one_div_nonneg.mpr ht.le have hsub : innerSeed (tightParameter (coreDimension M t) M) p (seedThreshold A/t) ⊆ cubeErosion (innerSeed (targetParameter (coreDimension M t) M) p (A/t)) (1/t) := by simpa only [mul_one_div] using innerSeed_subset_seedErosion hL hM p hp hτ hB.1 hB.2.1 hB.2.2 houter have hfinite : volume (cubeErosion (innerSeed (targetParameter (coreDimension M t) M) p (A/t)) (1/t)) ≠ ⊤ := by apply measure_ne_top_of_subset (s := polytope (coreDimension M t) (targetParameter (coreDimension M t) M)) · intro x hx exact (cubeErosion_subset hτ _ hx).1.1 · exact (polytope_isCompact _ _).measure_lt_top.ne exact (hv p hp).trans (measureReal_mono hsub hfinite) /-- A complete lower count with the top-coordinate restriction needed for prime-product construction. -/ /- Original line 32804: Erdos416Proof.FordInner.exists_core_seed_reciprocal_lower -/ theorem exists_core_seed_reciprocal_lower : ∃ c : ℝ, 0 < c ∧ ∀ A : ℝ, 0 ≤ A → ∀ᶠ M : ℕ in atTop, ∀ᶠ t : ℝ in atTop, ∀ p : Fin (coreDimension M t), p.val+1 = coreDimension M t → c*t^(coreDimension M t)*T (coreDimension M t) ≤ tupleReciprocalMass (coreDimension M t) t (innerSeed (targetParameter (coreDimension M t) M) p (A/t)) := by obtain ⟨c, hc, hbound⟩ := exists_tupleReciprocalMass_volume_lower refine ⟨c*(Real.exp (-1)/2), mul_pos hc (div_pos (Real.exp_pos _) (by norm_num)), ?_⟩ intro A hA filter_upwards [core_seed_erosion_volume_lower hA] with M hM filter_upwards [hM, eventually_gt_atTop (0 : ℝ)] with t hv ht intro p hp let L := coreDimension M t let E := innerSeed (targetParameter L M) p (A/t) have hE : E ⊆ Set.Icc (fun _ => 0) (fun _ => 1) := fun _ hx => ⟨hx.1.1.1, hx.1.1.2.1⟩ have hanti : ∀ x ∈ E, Antitone x := fun _ hx => hx.1.1.2.2.1 calc _ = (c*t^L)*((Real.exp (-1)/2)*T L) := by ring _ ≤ (c*t^L)*volume.real (cubeErosion E (1/t)) := mul_le_mul_of_nonneg_left (hv p hp) (mul_nonneg hc.le (pow_nonneg ht.le L)) _ ≤ _ := hbound L t E ht hE hanti end Erdos416Proof.FordInner namespace Erdos416Proof.FordLower open Finset FordAnalysis FordGeometry FordReciprocal FordScale FordInner open scoped BigOperators /- Original line 32835: Erdos416Proof.FordLower.primeTuple_entry_log_le -/ theorem primeTuple_entry_log_le {L : ℕ} {t γ : ℝ} (ht : 0 < t) {q : Fin L → ℕ} (hq : ∀ idx, (q idx).Prime ∨ q idx = 1) {idx : Fin L} (hi : tuplePoint t q idx ≤ γ) : Real.log (q idx : ℝ) ≤ Real.exp (γ*t) := by rcases hq idx with hp | h1 · have hp1 : (1 : ℝ) < q idx := by exact_mod_cast hp.one_lt have hm := (div_le_iff₀ ht).mp hi have hlog : logLog (q idx) ≤ γ*t := (le_max_right _ _).trans hm exact (Real.log_le_iff_le_exp (Real.log_pos hp1)).mp hlog · simp only [h1, Nat.cast_one, Real.log_one] exact (Real.exp_pos _).le /- Original line 32846: Erdos416Proof.FordLower.primeTuple_log_product_le -/ theorem primeTuple_log_product_le {L : ℕ} {t γ : ℝ} (ht : 0 < t) {q : Fin L → ℕ} (hq : ∀ idx, (q idx).Prime ∨ q idx = 1) (hi : ∀ idx, tuplePoint t q idx ≤ γ) : Real.log ((∏ idx, q idx : ℕ) : ℝ) ≤ (L : ℝ)*Real.exp (γ*t) := by rw [Nat.cast_prod, Real.log_prod (fun idx _ => Nat.cast_ne_zero.mpr (tuple_entry_ne_zero hq idx))] calc _ ≤ ∑ _i : Fin L, Real.exp (γ*t) := sum_le_sum (fun idx _ => primeTuple_entry_log_le ht hq (hi idx)) _ = _ := by simp /- Original line 32854: Erdos416Proof.FordLower.innerSeed_log_product_le -/ theorem innerSeed_log_product_le {L M : ℕ} {t A : ℝ} (ht : 0 < t) {q : Fin L → ℕ} (hq : ∀ idx, (q idx).Prime ∨ q idx = 1) (p : Fin L) (hx : tuplePoint t q ∈ innerSeed (targetParameter L M) p (A/t)) : Real.log ((∏ idx, q idx : ℕ) : ℝ) ≤ (L : ℝ)*Real.exp (targetParameter L M 0*t) := by let p0 : Fin L := ⟨0, (Nat.zero_le p.val).trans_lt p.isLt⟩ apply primeTuple_log_product_le ht hq intro idx exact (hx.1.1.2.2.1 (show p0 ≤ idx by change 0 ≤ idx.val; omega)).trans (hx.2 p0 rfl) /- Original line 32863: Erdos416Proof.FordLower.polylog_eventually_le_id -/ theorem polylog_eventually_le_id (k : ℕ) (K : ℝ) : ∀ᶠ t : ℝ in atTop, K*Real.log t^k ≤ t := by have h := (Real.isLittleO_pow_log_id_atTop (n := k)).const_mul_left K filter_upwards [h.bound (by norm_num : (0 : ℝ) < 1), eventually_ge_atTop (0 : ℝ)] with t hb ht simp only [Real.norm_eq_abs, one_mul, id_eq] at hb rw [abs_of_nonneg ht] at hb exact (le_abs_self _).trans hb /- Original line 32871: Erdos416Proof.FordLower.topLoss -/ noncomputable def topLoss (t : ℝ) : ℝ := 1/(10*(optimalDimension t : ℝ)^3) /- Original line 32873: Erdos416Proof.FordLower.topLoss_nonneg -/ theorem topLoss_nonneg (t : ℝ) : 0 ≤ topLoss t := by unfold topLoss; positivity /- Original line 32875: Erdos416Proof.FordLower.topLoss_pos -/ theorem topLoss_pos {t : ℝ} (hN : 0 < optimalDimension t) : 0 < topLoss t := by have hNreal : (0 : ℝ) < optimalDimension t := by exact_mod_cast hN unfold topLoss positivity /- Original line 32880: Erdos416Proof.FordLower.core_target_zero_eq -/ theorem core_target_zero_eq (M : ℕ) : ∀ᶠ t : ℝ in atTop, targetParameter (coreDimension M t) M 0 = 1-topLoss t := by filter_upwards [targetParameter_at_core_dimension M, (coreDimension_tendsto M).eventually (eventually_ge_atTop 1)] with t he hL simpa only [Nat.sub_zero, topLoss] using he 0 (by omega) /- Original line 32886: Erdos416Proof.FordLower.topLoss_mul_ge_log -/ theorem topLoss_mul_ge_log : ∀ᶠ t : ℝ in atTop, Real.log t ≤ topLoss t*t := by filter_upwards [polylog_eventually_le_id 4 640, eventually_ge_atTop (Real.exp 1), optimalDimension_tendsto.eventually (eventually_ge_atTop 1)] with t ht ht1 hN have hlog : 0 ≤ Real.log t := Real.log_nonneg ((Real.one_le_exp (by norm_num)).trans ht1) have hdim : (optimalDimension t : ℝ) ≤ 4*Real.log t := by simpa only [coreDimension, Nat.sub_zero] using coreDimension_le_four_log 0 ht1 have hcube := pow_le_pow_left₀ (Nat.cast_nonneg (optimalDimension t)) hdim 3 have hbound : 10*(optimalDimension t : ℝ)^3*Real.log t ≤ 640*Real.log t^4 := by calc _ ≤ 10*(4*Real.log t)^3*Real.log t := mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left hcube (by norm_num)) hlog _ = _ := by ring have hNreal : (0 : ℝ) < optimalDimension t := by exact_mod_cast (show 0 < optimalDimension t by omega) have hden : 0 < 10*(optimalDimension t : ℝ)^3 := by positivity dsimp [topLoss] rw [div_mul_eq_mul_div, one_mul] exact (le_div_iff₀ hden).mpr (by nlinarith [hbound.trans ht]) /-- A common envelope for the logarithm of every lower product in the inner family. -/ /- Original line 32905: Erdos416Proof.FordLower.lowerLogBound -/ noncomputable def lowerLogBound (t : ℝ) : ℝ := (4*Real.log t/t)*Real.exp t /- Original line 32907: Erdos416Proof.FordLower.lowerLogBound_small -/ theorem lowerLogBound_small : Tendsto (fun t : ℝ => lowerLogBound t/Real.exp t) atTop (nhds 0) := by have h := Real.isLittleO_log_id_atTop.tendsto_div_nhds_zero.const_mul (4 : ℝ) simpa only [id_eq, mul_zero, lowerLogBound, mul_div_assoc, div_self (Real.exp_pos _).ne', mul_one] using h /- Original line 32913: Erdos416Proof.FordLower.core_lower_log_bound -/ theorem core_lower_log_bound (M : ℕ) : ∀ᶠ t : ℝ in atTop, ∀ (p : Fin (coreDimension M t)) (A : ℝ) (n : ℕ), n ∈ tupleIntegers (coreDimension M t) t (innerSeed (targetParameter (coreDimension M t) M) p (A/t)) → Real.log (n : ℝ) ≤ lowerLogBound t := by filter_upwards [core_target_zero_eq M, topLoss_mul_ge_log, eventually_ge_atTop (Real.exp 1)] with t hxi hδ ht have htpos : 0 < t := (Real.exp_pos _).trans_le ht have hdim := coreDimension_le_four_log M ht have hexp : Real.exp (targetParameter (coreDimension M t) M 0*t) ≤ Real.exp t/t := by calc _ ≤ Real.exp (t-Real.log t) := Real.exp_le_exp.mpr (by rw [hxi]; nlinarith) _ = _ := by rw [Real.exp_sub, Real.exp_log htpos] intro p A n hn have hE : innerSeed (targetParameter (coreDimension M t) M) p (A/t) ⊆ Set.Icc (fun _ => 0) (fun _ => 1) := fun _ hx => ⟨hx.1.1.1, hx.1.1.2.1⟩ obtain ⟨q, hprod, hq, _, hpoint⟩ := (mem_tupleIntegers htpos hE).mp hn calc _ ≤ (coreDimension M t : ℝ)*Real.exp (targetParameter (coreDimension M t) M 0*t) := by rw [← hprod] exact innerSeed_log_product_le htpos hq p hpoint _ ≤ (coreDimension M t : ℝ)*(Real.exp t/t) := mul_le_mul_of_nonneg_left hexp (Nat.cast_nonneg _) _ ≤ (4*Real.log t)*(Real.exp t/t) := mul_le_mul_of_nonneg_right hdim (div_nonneg (Real.exp_pos _).le htpos.le) _ = _ := by unfold lowerLogBound; ring /- Original line 32938: Erdos416Proof.FordLower.lowerCoreLogBound -/ noncomputable def lowerCoreLogBound (y : ℝ) : ℝ := lowerLogBound (logLog y) /- Original line 32940: Erdos416Proof.FordLower.lowerCoreLogBound_small -/ theorem lowerCoreLogBound_small : Tendsto (fun y : ℝ => lowerCoreLogBound y/Real.log y) atTop (nhds 0) := by have hloglog : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop apply (lowerLogBound_small.comp hloglog).congr' filter_upwards [eventually_gt_atTop (1 : ℝ)] with y hy simp only [Function.comp_apply, lowerCoreLogBound, logLog, Real.exp_log (Real.log_pos hy)] /- Original line 32948: Erdos416Proof.FordLower.targetParameter_lt_one -/ theorem targetParameter_lt_one {L M j : ℕ} (hj : j < L) : targetParameter L M j < 1 := by have hN : (0 : ℝ) < (M+(L-j) : ℕ) := by exact_mod_cast (show 0 < M+(L-j) by omega) have hδ : 0 < baseLoss M (L-j) := by unfold baseLoss; positivity simp only [targetParameter, if_pos hj] linarith /- Original line 32954: Erdos416Proof.FordLower.innerSeed_logLog_lower -/ theorem innerSeed_logLog_lower {L M : ℕ} {t A : ℝ} (ht : 0 < t) (hA : 0 < A) {q : Fin L → ℕ} (p : Fin L) (hp : p.val+1 = L) (hx : tuplePoint t q ∈ innerSeed (targetParameter L M) p (A/t)) (idx : Fin L) : A ≤ logLog (q idx) := by have hip : idx ≤ p := by change idx.val ≤ p.val; have := idx.isLt; omega have hAi : A/t ≤ tuplePoint t q idx := hx.1.2.2.trans (hx.1.1.2.2.1 hip) have hm : A ≤ max 0 (logLog (q idx)) := (div_le_div_iff_of_pos_right ht).mp hAi by_cases hlog : 0 ≤ logLog (q idx) · simpa only [max_eq_right hlog] using hm · have hbad : A ≤ 0 := by simpa only [max_eq_left (le_of_not_ge hlog)] using hm linarith /- Original line 32966: Erdos416Proof.FordLower.innerSeed_tuple_primes -/ theorem innerSeed_tuple_primes {L M : ℕ} {t A : ℝ} (ht : 0 < t) (hA : 0 < A) {q : Fin L → ℕ} (hq : ∀ idx, (q idx).Prime ∨ q idx = 1) (p : Fin L) (hp : p.val+1 = L) (hx : tuplePoint t q ∈ innerSeed (targetParameter L M) p (A/t)) (idx : Fin L) : (q idx).Prime := by rcases hq idx with hi | hi · exact hi · have hlog := innerSeed_logLog_lower ht hA p hp hx idx simp only [hi, Nat.cast_one, logLog, Real.log_one, Real.log_zero] at hlog linarith /- Original line 32976: Erdos416Proof.FordLower.innerSeed_tuplePoint_eq -/ theorem innerSeed_tuplePoint_eq {L M : ℕ} {t A : ℝ} (ht : 0 < t) (hA : 0 < A) {q : Fin L → ℕ} (p : Fin L) (hp : p.val+1 = L) (hx : tuplePoint t q ∈ innerSeed (targetParameter L M) p (A/t)) (idx : Fin L) : tuplePoint t q idx = logLog (q idx)/t := by have hlog : 0 ≤ logLog (q idx) := hA.le.trans (innerSeed_logLog_lower ht hA p hp hx idx) simp only [tuplePoint, max_eq_right hlog] /- Original line 32983: Erdos416Proof.FordLower.strictAnti_of_adjacent -/ theorem strictAnti_of_adjacent {L : ℕ} {x : Fin L → ℝ} (hx : ∀ idx j : Fin L, j.val = idx.val+1 → x j < x idx) : StrictAnti x := by cases L with | zero => intro idx; exact Fin.elim0 idx | succ k => apply Fin.strictAnti_iff_succ_lt.mpr intro idx exact hx idx.castSucc idx.succ rfl /- Original line 32992: Erdos416Proof.FordLower.innerSeed_tuple_strictAnti -/ theorem innerSeed_tuple_strictAnti {L M : ℕ} {t A : ℝ} (ht : 0 < t) (hA : 0 < A) {q : Fin L → ℕ} (hq : ∀ idx, (q idx).Prime ∨ q idx = 1) (p : Fin L) (hp : p.val+1 = L) (hx : tuplePoint t q ∈ innerSeed (targetParameter L M) p (A/t)) : StrictAnti q := by have hpos (idx : Fin L) : 0 < tuplePoint t q idx := by rw [innerSeed_tuplePoint_eq ht hA p hp hx idx] exact div_pos (hA.trans_le (innerSeed_logLog_lower ht hA p hp hx idx)) ht have hs : StrictAnti (tuplePoint t q) := strictAnti_of_adjacent (by intro idx j hij have hj : idx.val+1 < L := by have := j.isLt; omega have hgap := hx.1.2.1 idx j hij have hxi := targetParameter_lt_one (M := M) hj nlinarith [hpos idx]) intro idx j hij by_contra hnot have hqi : (1 : ℝ) < q idx := by exact_mod_cast (innerSeed_tuple_primes ht hA hq p hp hx idx).one_lt have hqij : q idx ≤ q j := by omega have hmono : tuplePoint t q idx ≤ tuplePoint t q j := div_le_div_of_nonneg_right (max_le_max le_rfl (logLog_mono hqi (Nat.cast_le.mpr hqij))) ht.le exact (not_lt_of_ge hmono) (hs hij) /- Original line 33012: Erdos416Proof.FordLower.innerSeed_adjacent_log_gap -/ theorem innerSeed_adjacent_log_gap {L M : ℕ} {t A : ℝ} (ht : 0 < t) (hA : 0 < A) {q : Fin L → ℕ} (p : Fin L) (hp : p.val+1 = L) (hx : tuplePoint t q ∈ innerSeed (targetParameter L M) p (A/t)) (idx j : Fin L) (hij : j.val = idx.val+1) : (1+baseLoss M (L-(idx.val+1)))*logLog (q j) ≤ logLog (q idx) := by have hj : idx.val+1 < L := by have := j.isLt; omega have hg := hx.1.2.1 idx j hij rw [innerSeed_tuplePoint_eq ht hA p hp hx idx, innerSeed_tuplePoint_eq ht hA p hp hx j] at hg have hg' : logLog (q j) ≤ (1-baseLoss M (L-(idx.val+1)))*logLog (q idx) := by apply (div_le_div_iff_of_pos_right ht).mp simpa only [targetParameter, if_pos hj, mul_div_assoc] using hg have hδ := baseLoss_nonneg M (L-(idx.val+1)) calc _ ≤ (1+baseLoss M (L-(idx.val+1)))*((1-baseLoss M (L-(idx.val+1)))*logLog (q idx)) := mul_le_mul_of_nonneg_left hg' (by linarith) _ = (1-baseLoss M (L-(idx.val+1))^2)*logLog (q idx) := by ring _ ≤ _ := mul_le_of_le_one_left (hA.le.trans (innerSeed_logLog_lower ht hA p hp hx idx)) (by linarith [sq_nonneg (baseLoss M (L-(idx.val+1)))]) /- Original line 33031: Erdos416Proof.FordLower.innerSeed_tuple_entry_lower -/ theorem innerSeed_tuple_entry_lower {L M : ℕ} {t A : ℝ} (ht : 0 < t) (hA : 0 < A) {q : Fin L → ℕ} (hq : ∀ idx, (q idx).Prime ∨ q idx = 1) (p : Fin L) (hp : p.val+1 = L) (hx : tuplePoint t q ∈ innerSeed (targetParameter L M) p (A/t)) (idx : Fin L) : Real.exp (Real.exp A) ≤ (q idx : ℝ) := by have hqi := innerSeed_tuple_primes ht hA hq p hp hx idx have hq1 : (1 : ℝ) < q idx := by exact_mod_cast hqi.one_lt have hlog := Real.exp_le_exp.mpr (innerSeed_logLog_lower ht hA p hp hx idx) simp only [logLog, Real.exp_log (Real.log_pos hq1)] at hlog have h := Real.exp_le_exp.mpr hlog simpa only [Real.exp_log (by linarith : (0 : ℝ) < q idx)] using h /- Original line 33042: Erdos416Proof.FordLower.core_lower_product_rpow_bound -/ theorem core_lower_product_rpow_bound (M : ℕ) {ε : ℝ} (hε : 0 < ε) : ∀ᶠ y : ℝ in atTop, ∀ (p : Fin (coreDimension M (logLog y))) (A : ℝ) (n : ℕ), n ∈ tupleIntegers (coreDimension M (logLog y)) (logLog y) (innerSeed (targetParameter (coreDimension M (logLog y)) M) p (A/logLog y)) → (n : ℝ) ≤ y^ε := by have hloglog : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [hloglog.eventually (core_lower_log_bound M), lowerCoreLogBound_small.eventually_lt_const hε, hloglog.eventually_gt_atTop 0, eventually_gt_atTop (1 : ℝ)] with y hb hsmall ht hy intro p A n hn have hE : innerSeed (targetParameter (coreDimension M (logLog y)) M) p (A/logLog y) ⊆ Set.Icc (fun _ => 0) (fun _ => 1) := fun _ hx => ⟨hx.1.1.1, hx.1.1.2.1⟩ have hnpos : (0 : ℝ) < n := by exact_mod_cast (tupleIntegers_positive_and_degree ht hE hn).1 have hlog : Real.log (n : ℝ) ≤ ε*Real.log y := (hb p A n hn).trans ((div_lt_iff₀ (Real.log_pos hy)).mp hsmall).le calc _ ≤ Real.exp (ε*Real.log y) := (Real.log_le_iff_le_exp hnpos).mp hlog _ = _ := by rw [Real.rpow_def_of_pos (by linarith : 0 < y)]; congr 1; ring /- Original line 33062: Erdos416Proof.FordLower.lowerPrimeChoices -/ noncomputable def lowerPrimeChoices (y : ℝ) (n : ℕ) : Finset ℕ := (corePairs {n.totient} (coreLowerFraction y*y) y).image Prod.snd /- Original line 33065: Erdos416Proof.FordLower.lowerPrimeChoices_pair_iff -/ theorem lowerPrimeChoices_pair_iff {y : ℝ} (hy : 0 ≤ y) {n p : ℕ} (hn : 0 < n) : p ∈ lowerPrimeChoices y n ↔ (n.totient, p) ∈ corePairs {n.totient} (coreLowerFraction y*y) y := by have hc : ∀ b ∈ ({n.totient} : Finset ℕ), 0 < b := by intro b hb simpa only [mem_singleton.mp hb] using Nat.totient_pos.mpr hn constructor · rintro hp obtain ⟨⟨b, q⟩, hbp, hq⟩ := mem_image.mp hp have hb : b = n.totient := mem_singleton.mp ((mem_corePairs hy hc).mp hbp).1 change q = p at hq subst b q exact hbp · intro hp exact mem_image.mpr ⟨(n.totient, p), hp, rfl⟩ /- Original line 33081: Erdos416Proof.FordLower.mem_lowerPrimeChoices -/ theorem mem_lowerPrimeChoices {y : ℝ} (hy : 0 ≤ y) {n p : ℕ} (hn : 0 < n) : p ∈ lowerPrimeChoices y n ↔ p.Prime ∧ 1+coreLowerFraction y*(y/(n.totient : ℝ)) < (p : ℝ) ∧ (p : ℝ) ≤ 1+y/(n.totient : ℝ) := by have hc : ∀ b ∈ ({n.totient} : Finset ℕ), 0 < b := by intro b hb simpa only [mem_singleton.mp hb] using Nat.totient_pos.mpr hn rw [lowerPrimeChoices_pair_iff hy hn, mem_corePairs hy hc] simp only [mem_singleton, true_and] constructor · rintro ⟨hp, hl, hu⟩ have h := (corePairValue_bounds_iff (Nat.totient_pos.mpr hn) hp (coreLowerFraction y*y) y).mp ⟨hl, hu⟩ exact ⟨hp, by simpa only [mul_div_assoc] using h.1, h.2⟩ · rintro ⟨hp, hl, hu⟩ have h := (corePairValue_bounds_iff (Nat.totient_pos.mpr hn) hp (coreLowerFraction y*y) y).mpr ⟨by simpa only [mul_div_assoc] using hl, hu⟩ exact ⟨hp, h.1, h.2⟩ /- Original line 33099: Erdos416Proof.FordLower.lowerPrimeChoices_card -/ theorem lowerPrimeChoices_card {y : ℝ} (hy : 0 ≤ y) (hs : coreLowerFraction y ≤ 1) {n : ℕ} (hn : 0 < n) : ((lowerPrimeChoices y n).card : ℝ) = primeCountReal (1+y/(n.totient : ℝ))- primeCountReal (1+coreLowerFraction y*(y/(n.totient : ℝ))) := by have hc : ∀ b ∈ ({n.totient} : Finset ℕ), 0 < b := by intro b hb simpa only [mem_singleton.mp hb] using Nat.totient_pos.mpr hn have hi : Set.InjOn (Prod.snd : ℕ × ℕ → ℕ) (↑(corePairs {n.totient} (coreLowerFraction y*y) y) : Set (ℕ × ℕ)) := by intro a ha b hb heq apply Prod.ext _ heq exact (mem_singleton.mp ((mem_corePairs hy hc).mp ha).1).trans (mem_singleton.mp ((mem_corePairs hy hc).mp hb).1).symm rw [lowerPrimeChoices, card_image_of_injOn hi, corePairs_card_prime_count hc (mul_nonneg (coreLowerFraction_nonneg y) hy) (by nlinarith [mul_le_mul_of_nonneg_right hs hy])] simp only [sum_singleton, mul_div_assoc] /-- PNT counts the actual prime choices uniformly for every lower integer in the common envelope. -/ /- Original line 33119: Erdos416Proof.FordLower.lowerPrimeChoices_count_uniform -/ theorem lowerPrimeChoices_count_uniform : ∀ᶠ y : ℝ in atTop, ∀ n : ℕ, 0 < n → Real.log (n : ℝ) ≤ lowerCoreLogBound y → (y/(2*Real.log y))*invTotient n ≤ ((lowerPrimeChoices y n).card : ℝ) := by filter_upwards [prime_counting_core_interval_uniform lowerCoreLogBound_small coreLowerFraction_tendsto (t := 1) (by norm_num) (ε := 1/2) (by norm_num), coreLowerFraction_tendsto.eventually_lt_const (by norm_num : (0 : ℝ) < 1), eventually_gt_atTop (1 : ℝ)] with y hu hs hy intro n hn hlog have hφ : (0 : ℝ) < n.totient := by exact_mod_cast Nat.totient_pos.mpr hn have hφ1 : (1 : ℝ) ≤ n.totient := by exact_mod_cast Nat.totient_pos.mpr hn have hφlog : Real.log (n.totient : ℝ) ≤ lowerCoreLogBound y := (Real.log_le_log hφ (Nat.cast_le.mpr (Nat.totient_le n))).trans hlog have h := hu (n.totient : ℝ) hφ1 hφlog have hw : 0 < y/((n.totient : ℝ)*Real.log y) := div_pos (by linarith) (mul_pos hφ (Real.log_pos hy)) have hlow : (1/2 : ℝ) ≤ (primeCountReal (1+y/(n.totient : ℝ))- primeCountReal (1+coreLowerFraction y*(y/(n.totient : ℝ)))) / (y/((n.totient : ℝ)*Real.log y)) := by simp only [one_mul] at h linarith [(abs_lt.mp h).1] have hm := (le_div_iff₀ hw).mp hlow rw [lowerPrimeChoices_card (by linarith) hs.le hn] calc _ = (1/2 : ℝ)*(y/((n.totient : ℝ)*Real.log y)) := by unfold invTotient; ring _ ≤ _ := hm /- Original line 33146: Erdos416Proof.FordLower.coreLowerFraction_lower_rpow -/ theorem coreLowerFraction_lower_rpow {η : ℝ} (hη : 0 < η) : ∀ᶠ y : ℝ in atTop, y^(-η) ≤ coreLowerFraction y := by have hloglog : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [(isLittleO_log_rpow_atTop hη).bound (by norm_num : (0 : ℝ) < 1), hloglog.eventually_ge_atTop 1, eventually_gt_atTop (1 : ℝ)] with y hb ht hy have hy0 : 0 < y := by linarith have hlog : 0 ≤ Real.log y := (Real.log_pos hy).le simp only [Real.norm_eq_abs, one_mul, abs_of_nonneg hlog, abs_of_nonneg (Real.rpow_nonneg hy0.le η)] at hb have ht0 : 0 < logLog y := by linarith have hsqrt : Real.sqrt (logLog y) ≤ logLog y := by have hs := Real.sq_sqrt ht0.le have hn := Real.sqrt_nonneg (logLog y) nlinarith have hs : Real.sqrt (logLog y) ≤ y^η := hsqrt.trans ((Real.log_le_self hlog).trans hb) calc _ = 1/(y^η) := by rw [Real.rpow_neg hy0.le, one_div] _ ≤ 1/Real.sqrt (logLog y) := div_le_div_of_nonneg_left (by norm_num) (Real.sqrt_pos.mpr ht0) hs _ = _ := rfl /- Original line 33167: Erdos416Proof.FordLower.lowerPrimeChoices_large_eventually -/ theorem lowerPrimeChoices_large_eventually : ∀ᶠ y : ℝ in atTop, ∀ n : ℕ, 0 < n → (n : ℝ) ≤ y^(1/40 : ℝ) → ∀ p ∈ lowerPrimeChoices y n, y^(19/20 : ℝ) < (p : ℝ) ∧ n < p := by filter_upwards [coreLowerFraction_lower_rpow (η := 1/40) (by norm_num), eventually_gt_atTop (1 : ℝ)] with y hs hy have hy0 : 0 < y := by linarith intro n hn hsize p hp have hφ : (0 : ℝ) < n.totient := by exact_mod_cast Nat.totient_pos.mpr hn have hφsize : (n.totient : ℝ) ≤ y^(1/40 : ℝ) := (Nat.cast_le.mpr (Nat.totient_le n)).trans hsize have hpow : y^(-1/40 : ℝ)*(y/y^(1/40 : ℝ)) = y^(19/20 : ℝ) := by calc _ = y^(-1/40 : ℝ)*(y^(1 : ℝ)/y^(1/40 : ℝ)) := by rw [Real.rpow_one] _ = y^(-1/40 : ℝ)*y^(1-1/40 : ℝ) := by rw [Real.rpow_sub hy0] _ = y^((-1/40)+(1-1/40) : ℝ) := (Real.rpow_add hy0 _ _).symm _ = _ := by congr 1; ring have hlow : y^(19/20 : ℝ) ≤ coreLowerFraction y*(y/(n.totient : ℝ)) := by rw [← hpow] have hs' : y^(-1/40 : ℝ) ≤ coreLowerFraction y := by simpa only [neg_div] using hs exact mul_le_mul hs' (div_le_div_of_nonneg_left hy0.le hφ hφsize) (div_nonneg hy0.le (Real.rpow_pos_of_pos hy0 _).le) (coreLowerFraction_nonneg y) have hchoice := (mem_lowerPrimeChoices hy0.le hn).mp hp have hlarge : y^(19/20 : ℝ) < (p : ℝ) := by linarith [hchoice.2.1] have hnp : (n : ℝ) < p := hsize.trans_lt ((Real.rpow_le_rpow_of_exponent_le hy.le (by norm_num : (1/40 : ℝ) ≤ 19/20)).trans_lt hlarge) exact ⟨hlarge, by exact_mod_cast hnp⟩ /- Original line 33193: Erdos416Proof.FordLower.primeProducts -/ noncomputable def primeProducts (F : Finset ℕ) (y : ℝ) : Finset ℕ := (F.sigma (lowerPrimeChoices y)).image (fun np => np.2*np.1) /- Original line 33196: Erdos416Proof.FordLower.mem_primeProducts -/ theorem mem_primeProducts {F : Finset ℕ} {y : ℝ} {N : ℕ} : N ∈ primeProducts F y ↔ ∃ n ∈ F, ∃ p ∈ lowerPrimeChoices y n, N = p*n := by constructor · intro hN obtain ⟨⟨n, p⟩, hn, hval⟩ := mem_image.mp hN obtain ⟨hnF, hp⟩ := mem_sigma.mp hn exact ⟨n, hnF, p, hp, hval.symm⟩ · rintro ⟨n, hn, p, hp, rfl⟩ exact mem_image.mpr ⟨⟨n, p⟩, mem_sigma.mpr ⟨hn, hp⟩, rfl⟩ /- Original line 33206: Erdos416Proof.FordLower.primeProducts_card -/ theorem primeProducts_card {F : Finset ℕ} {y : ℝ} (hy : 0 ≤ y) (hF : ∀ n ∈ F, 0 < n) (htop : ∀ n ∈ F, ∀ p ∈ lowerPrimeChoices y n, n < p) : (primeProducts F y).card = ∑ n ∈ F, (lowerPrimeChoices y n).card := by have hlargest {n p : ℕ} (hn : 0 < n) (hp : p.Prime) (hnp : n < p) : largestPrimeFactor (p*n) = p := by rw [largestPrimeFactor_mul hp.pos hn, largestPrimeFactor_prime hp, max_eq_left ((largestPrimeFactor_le hn).trans hnp.le)] have hinj : Set.InjOn (fun np : Σ _ : ℕ, ℕ => np.2*np.1) (F.sigma (lowerPrimeChoices y)) := by rintro ⟨n, p⟩ ha ⟨m, q⟩ hb heq obtain ⟨hn, hp⟩ := mem_sigma.mp ha obtain ⟨hm, hq⟩ := mem_sigma.mp hb have hpP := ((mem_lowerPrimeChoices hy (hF n hn)).mp hp).1 have hqP := ((mem_lowerPrimeChoices hy (hF m hm)).mp hq).1 change p*n = q*m at heq have hpq : p = q := by calc _ = largestPrimeFactor (p*n) := (hlargest (hF n hn) hpP (htop n hn p hp)).symm _ = largestPrimeFactor (q*m) := congrArg largestPrimeFactor heq _ = _ := hlargest (hF m hm) hqP (htop m hm q hq) subst q have hnm := Nat.eq_of_mul_eq_mul_left hpP.pos heq subst m rfl rw [primeProducts, card_image_of_injOn hinj, card_sigma] /- Original line 33232: Erdos416Proof.FordLower.primeProducts_totient_bounds -/ theorem primeProducts_totient_bounds {F : Finset ℕ} {y : ℝ} (hy : 0 ≤ y) (hF : ∀ n ∈ F, 0 < n) (htop : ∀ n ∈ F, ∀ p ∈ lowerPrimeChoices y n, n < p) {N : ℕ} (hN : N ∈ primeProducts F y) : 0 < N ∧ coreLowerFraction y*y < (N.totient : ℝ) ∧ (N.totient : ℝ) ≤ y := by obtain ⟨n, hn, p, hp, rfl⟩ := mem_primeProducts.mp hN have hn0 := hF n hn have hc := (mem_lowerPrimeChoices hy hn0).mp hp have hcop := coprime_of_largestPrimeFactor_lt hn0 hc.1 ((largestPrimeFactor_le hn0).trans_lt (htop n hn p hp)) have hφ : (p*n).totient = corePairValue (n.totient, p) := by rw [Nat.totient_mul hcop, Nat.totient_prime hc.1] rfl have hbounds := (corePairValue_bounds_iff (Nat.totient_pos.mpr hn0) hc.1 (coreLowerFraction y*y) y).mpr ⟨by simpa only [mul_div_assoc] using hc.2.1, hc.2.2⟩ exact ⟨Nat.mul_pos hc.1.pos hn0, by simpa only [hφ] using hbounds⟩ /- Original line 33248: Erdos416Proof.FordLower.primeProducts_count_lower_uniform -/ theorem primeProducts_count_lower_uniform : ∀ᶠ y : ℝ in atTop, ∀ F : Finset ℕ, (∀ n ∈ F, 0 < n) → (∀ n ∈ F, (n : ℝ) ≤ y^(1/40 : ℝ)) → (∀ n ∈ F, Real.log (n : ℝ) ≤ lowerCoreLogBound y) → (y/(2*Real.log y))*(∑ n ∈ F, invTotient n) ≤ ((primeProducts F y).card : ℝ) := by filter_upwards [lowerPrimeChoices_count_uniform, lowerPrimeChoices_large_eventually, eventually_ge_atTop (0 : ℝ)] with y hc hlarge hy intro F hF hs hlog have htop : ∀ n ∈ F, ∀ p ∈ lowerPrimeChoices y n, n < p := fun n hn p hp => (hlarge n (hF n hn) (hs n hn) p hp).2 rw [primeProducts_card hy hF htop, Nat.cast_sum, mul_sum] exact sum_le_sum fun n hn => hc n (hF n hn) (hlog n hn) /-- The actual large-prime products have the full lower-order main term before totient collisions are removed. -/ /- Original line 33262: Erdos416Proof.FordLower.exists_core_primeProducts_count_lower -/ theorem exists_core_primeProducts_count_lower : ∃ c : ℝ, 0 < c ∧ ∀ A : ℝ, 0 ≤ A → ∀ᶠ M : ℕ in atTop, ∀ᶠ y : ℝ in atTop, ∀ p : Fin (coreDimension M (logLog y)), p.val+1 = coreDimension M (logLog y) → c*(y/Real.log y)*(logLog y)^(coreDimension M (logLog y))*T (coreDimension M (logLog y)) ≤ ((primeProducts (tupleIntegers (coreDimension M (logLog y)) (logLog y) (innerSeed (targetParameter (coreDimension M (logLog y)) M) p (A/logLog y))) y).card : ℝ) := by obtain ⟨c, hc, hmass⟩ := exists_core_seed_reciprocal_lower refine ⟨c/2, div_pos hc (by norm_num), ?_⟩ intro A hA have hloglog : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [hmass A hA] with M hmass filter_upwards [hloglog.eventually hmass, hloglog.eventually (core_lower_log_bound M), core_lower_product_rpow_bound M (ε := 1/40) (by norm_num), primeProducts_count_lower_uniform, hloglog.eventually_gt_atTop 0, eventually_gt_atTop (1 : ℝ)] with y hm hb hs hcount ht hy intro p hp let L := coreDimension M (logLog y) let E := innerSeed (targetParameter L M) p (A/logLog y) let F := tupleIntegers L (logLog y) E have hE : E ⊆ Set.Icc (fun _ => 0) (fun _ => 1) := fun _ hx => ⟨hx.1.1.1, hx.1.1.2.1⟩ have hF : ∀ n ∈ F, 0 < n := fun n hn => (tupleIntegers_positive_and_degree ht hE hn).1 have hlog : ∀ n ∈ F, Real.log (n : ℝ) ≤ lowerCoreLogBound y := fun n hn => hb p A n hn have hsmall : ∀ n ∈ F, (n : ℝ) ≤ y^(1/40 : ℝ) := fun n hn => hs p A n hn have hmain := hm p hp have hfactor : 0 ≤ y/(2*Real.log y) := div_nonneg (by linarith) (mul_nonneg (by norm_num) (Real.log_pos hy).le) calc _ = (y/(2*Real.log y))*(c*(logLog y)^L*T L) := by ring _ ≤ (y/(2*Real.log y))*tupleReciprocalMass L (logLog y) E := mul_le_mul_of_nonneg_left hmain hfactor _ ≤ _ := hcount F hF hsmall hlog /- Original line 33294: Erdos416Proof.FordLower.core_primeProducts_totient_bounds -/ theorem core_primeProducts_totient_bounds (M : ℕ) : ∀ᶠ y : ℝ in atTop, ∀ (p : Fin (coreDimension M (logLog y))) (A : ℝ) (N : ℕ), N ∈ primeProducts (tupleIntegers (coreDimension M (logLog y)) (logLog y) (innerSeed (targetParameter (coreDimension M (logLog y)) M) p (A/logLog y))) y → 0 < N ∧ coreLowerFraction y*y < (N.totient : ℝ) ∧ (N.totient : ℝ) ≤ y := by have hloglog : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [core_lower_product_rpow_bound M (ε := 1/40) (by norm_num), lowerPrimeChoices_large_eventually, hloglog.eventually_gt_atTop 0, eventually_ge_atTop (0 : ℝ)] with y hs hlarge ht hy intro p A N hN let L := coreDimension M (logLog y) let E := innerSeed (targetParameter L M) p (A/logLog y) let F := tupleIntegers L (logLog y) E have hE : E ⊆ Set.Icc (fun _ => 0) (fun _ => 1) := fun _ hx => ⟨hx.1.1.1, hx.1.1.2.1⟩ have hF : ∀ n ∈ F, 0 < n := fun n hn => (tupleIntegers_positive_and_degree ht hE hn).1 exact primeProducts_totient_bounds hy hF (fun n hn q hq => (hlarge n (hF n hn) (hs p A n hn) q hq).2) hN /- Original line 33313: Erdos416Proof.FordLower.topLoss_sq_mul_ge_one -/ theorem topLoss_sq_mul_ge_one : ∀ᶠ t : ℝ in atTop, 1 ≤ topLoss t^2*t := by filter_upwards [polylog_eventually_le_id 6 409600, eventually_ge_atTop (Real.exp 1), optimalDimension_tendsto.eventually (eventually_ge_atTop 1)] with t ht ht1 hN have hdim : (optimalDimension t : ℝ) ≤ 4*Real.log t := by simpa only [coreDimension, Nat.sub_zero] using coreDimension_le_four_log 0 ht1 have hsix := pow_le_pow_left₀ (Nat.cast_nonneg (optimalDimension t)) hdim 6 have hbound : 100*(optimalDimension t : ℝ)^6 ≤ 409600*Real.log t^6 := by calc _ ≤ 100*(4*Real.log t)^6 := mul_le_mul_of_nonneg_left hsix (by norm_num) _ = _ := by ring have hNreal : (0 : ℝ) < optimalDimension t := by exact_mod_cast (show 0 < optimalDimension t by omega) have heq : topLoss t^2*t = t/(100*(optimalDimension t : ℝ)^6) := by unfold topLoss field_simp [hNreal.ne'] ring rw [heq] exact (le_div_iff₀ (by positivity : 0 < 100*(optimalDimension t : ℝ)^6)).mpr (by simpa only [one_mul] using hbound.trans ht) /- Original line 33332: Erdos416Proof.FordLower.large_prime_logLog_lower -/ theorem large_prime_logLog_lower {y : ℝ} (hy : 1 < y) {P : ℕ} (hP : y^(19/20 : ℝ) < (P : ℝ)) : logLog y-1 ≤ logLog P := by have hy0 : 0 < y := by linarith have hpow : 1 < y^(19/20 : ℝ) := by rw [Real.rpow_def_of_pos hy0] exact Real.one_lt_exp_iff.mpr (mul_pos (Real.log_pos hy) (by norm_num)) have hr : -1 ≤ Real.log (19/20 : ℝ) := by have h := Real.one_sub_inv_le_log_of_pos (by norm_num : (0 : ℝ) < 19/20) norm_num at h linarith have heq : logLog (y^(19/20 : ℝ)) = logLog y+Real.log (19/20 : ℝ) := by unfold logLog rw [Real.rpow_def_of_pos hy0, Real.log_exp, Real.log_mul (Real.log_pos hy).ne' (by norm_num)] exact (show logLog y-1 ≤ logLog y+Real.log (19/20 : ℝ) by linarith).trans (heq ▸ logLog_mono hpow hP.le) /- Original line 33349: Erdos416Proof.FordLower.core_top_log_gap -/ theorem core_top_log_gap (M : ℕ) : ∀ᶠ y : ℝ in atTop, ∀ (p : Fin (coreDimension M (logLog y))) (A : ℝ) (q : Fin (coreDimension M (logLog y)) → ℕ) (P : ℕ), tuplePoint (logLog y) q ∈ innerSeed (targetParameter (coreDimension M (logLog y)) M) p (A/logLog y) → y^(19/20 : ℝ) < (P : ℝ) → ∀ idx : Fin (coreDimension M (logLog y)), idx.val = 0 → (1+topLoss (logLog y))*logLog (q idx) ≤ logLog P := by have hloglog : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [hloglog.eventually topLoss_sq_mul_ge_one, hloglog.eventually (core_target_zero_eq M), hloglog.eventually_gt_atTop 0, eventually_gt_atTop (1 : ℝ)] with y hmargin hxi ht hy intro p A q P hx hP idx hi have hm : max 0 (logLog (q idx)) ≤ targetParameter (coreDimension M (logLog y)) M 0*logLog y := (div_le_iff₀ ht).mp (hx.2 idx hi) have hq : logLog (q idx) ≤ (1-topLoss (logLog y))*logLog y := by rw [← hxi] exact (le_max_right _ _).trans hm have hδ := topLoss_nonneg (logLog y) calc _ ≤ (1+topLoss (logLog y))*((1-topLoss (logLog y))*logLog y) := mul_le_mul_of_nonneg_left hq (by linarith) _ = logLog y-topLoss (logLog y)^2*logLog y := by ring _ ≤ logLog y-1 := by linarith _ ≤ _ := large_prime_logLog_lower hy hP /-- Data constructed from an actual counted integer; no totient injectivity is asserted. -/ /- Original line 33375: Erdos416Proof.FordLower.PrimeProductRecord -/ structure PrimeProductRecord (M : ℕ) (A y : ℝ) (p : Fin (coreDimension M (logLog y))) (N : ℕ) where leading : ℕ lower : Fin (coreDimension M (logLog y)) → ℕ terminal : p.val+1 = coreDimension M (logLog y) leading_prime : leading.Prime lower_prime : ∀ idx, (lower idx).Prime lower_order : StrictAnti lower point : tuplePoint (logLog y) lower ∈ innerSeed (targetParameter (coreDimension M (logLog y)) M) p (A/logLog y) integer : N = leading*(∏ idx, lower idx) leading_size : y^(19/20 : ℝ) < (leading : ℝ) lower_separated : ∀ idx, lower idx < leading lower_minimum : ∀ idx, Real.exp (Real.exp A) ≤ (lower idx : ℝ) lower_gaps : ∀ idx j, j.val = idx.val+1 → (1+baseLoss M (coreDimension M (logLog y)-(idx.val+1)))*logLog (lower j) ≤ logLog (lower idx) leading_gap : ∀ idx, idx.val = 0 → (1+topLoss (logLog y))*logLog (lower idx) ≤ logLog leading totient_range : coreLowerFraction y*y < (N.totient : ℝ) ∧ (N.totient : ℝ) ≤ y /- Original line 33393: Erdos416Proof.FordLower.core_primeProducts_record -/ theorem core_primeProducts_record (M : ℕ) : ∀ᶠ y : ℝ in atTop, ∀ (p : Fin (coreDimension M (logLog y))), p.val+1 = coreDimension M (logLog y) → ∀ A : ℝ, 0 < A → ∀ N : ℕ, N ∈ primeProducts (tupleIntegers (coreDimension M (logLog y)) (logLog y) (innerSeed (targetParameter (coreDimension M (logLog y)) M) p (A/logLog y))) y → Nonempty (PrimeProductRecord M A y p N) := by have hloglog : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [core_lower_product_rpow_bound M (ε := 1/40) (by norm_num), lowerPrimeChoices_large_eventually, core_top_log_gap M, core_primeProducts_totient_bounds M, hloglog.eventually_gt_atTop 0, eventually_ge_atTop (0 : ℝ)] with y hs hlarge hgap htot ht hy intro p hp A hA N hN have hbounds := (htot p A N hN).2 obtain ⟨n, hn, P, hP, hN⟩ := mem_primeProducts.mp hN let L := coreDimension M (logLog y) let E := innerSeed (targetParameter L M) p (A/logLog y) have hE : E ⊆ Set.Icc (fun _ => 0) (fun _ => 1) := fun _ hx => ⟨hx.1.1.1, hx.1.1.2.1⟩ have hn0 := (tupleIntegers_positive_and_degree ht hE hn).1 have hleading := hlarge n hn0 (hs p A n hn) P hP have hPP := ((mem_lowerPrimeChoices hy hn0).mp hP).1 obtain ⟨q, hprod, hq, _, hpoint⟩ := (mem_tupleIntegers ht hE).mp hn have hsep (idx : Fin L) : q idx < P := by have hdvd : q idx ∣ n := hprod ▸ dvd_prod_of_mem q (mem_univ idx) exact (Nat.le_of_dvd hn0 hdvd).trans_lt hleading.2 exact ⟨{ leading := P lower := q terminal := hp leading_prime := hPP lower_prime := innerSeed_tuple_primes ht hA hq p hp hpoint lower_order := innerSeed_tuple_strictAnti ht hA hq p hp hpoint point := hpoint integer := by rw [hprod]; exact hN leading_size := hleading.1 lower_separated := hsep lower_minimum := innerSeed_tuple_entry_lower ht hA hq p hp hpoint lower_gaps := innerSeed_adjacent_log_gap ht hA p hp hpoint leading_gap := hgap p A q P hpoint hleading.1 totient_range := hbounds }⟩ namespace PrimeProductRecord variable {M : ℕ} {A y : ℝ} {p : Fin (coreDimension M (logLog y))} {N : ℕ} variable (R : PrimeProductRecord M A y p N) include R /- Original line 33441: Erdos416Proof.FordLower.PrimeProductRecord.fullTuple -/ noncomputable def fullTuple : Fin (coreDimension M (logLog y)+1) → ℕ := Fin.cons R.leading R.lower /- Original line 33443: Erdos416Proof.FordLower.PrimeProductRecord.fullTuple_prime -/ theorem fullTuple_prime (idx : Fin (coreDimension M (logLog y)+1)) : (R.fullTuple idx).Prime := by refine Fin.cases ?_ ?_ idx · exact R.leading_prime · intro j exact R.lower_prime j /- Original line 33449: Erdos416Proof.FordLower.PrimeProductRecord.fullTuple_order -/ theorem fullTuple_order : StrictAnti R.fullTuple := by intro idx j hij cases idx using Fin.cases with | zero => cases j using Fin.cases with | zero => exact (lt_irrefl (0 : Fin (coreDimension M (logLog y)+1)) hij).elim | succ j => exact R.lower_separated j | succ idx => cases j using Fin.cases with | zero => have h : idx.val+1 < 0 := hij; omega | succ j => exact R.lower_order (Fin.succ_lt_succ_iff.mp hij) /- Original line 33461: Erdos416Proof.FordLower.PrimeProductRecord.fullTuple_product -/ theorem fullTuple_product : (∏ idx, R.fullTuple idx) = N := by simpa only [Fin.prod_univ_succ, fullTuple, Fin.cons_zero, Fin.cons_succ] using R.integer.symm /- Original line 33464: Erdos416Proof.FordLower.PrimeProductRecord.positive -/ theorem positive : 0 < N := by rw [← R.fullTuple_product] exact prod_pos fun idx _ => (R.fullTuple_prime idx).pos /- Original line 33468: Erdos416Proof.FordLower.PrimeProductRecord.totient_product -/ theorem totient_product : N.totient = ∏ idx, (R.fullTuple idx-1) := by calc _ = (∏ idx, R.fullTuple idx).totient := congrArg Nat.totient R.fullTuple_product.symm _ = _ := totient_prod_injective_primes univ R.fullTuple (fun idx _ => R.fullTuple_prime idx) R.fullTuple_order.injective.injOn /- Original line 33474: Erdos416Proof.FordLower.PrimeProductRecord.prime_factors -/ theorem prime_factors : N.primeFactors = univ.image R.fullTuple := by have hp : ∀ v ∈ univ.image R.fullTuple, v.Prime := by intro v hv obtain ⟨idx, _, rfl⟩ := mem_image.mp hv exact R.fullTuple_prime idx have hprod : (∏ v ∈ univ.image R.fullTuple, v) = N := (prod_image R.fullTuple_order.injective.injOn).trans R.fullTuple_product calc _ = (∏ v ∈ univ.image R.fullTuple, v).primeFactors := congrArg Nat.primeFactors hprod.symm _ = _ := Nat.primeFactors_prod hp /- Original line 33485: Erdos416Proof.FordLower.PrimeProductRecord.squarefree -/ theorem squarefree : Squarefree N := by have hp : ∀ v ∈ univ.image R.fullTuple, v.Prime := by intro v hv obtain ⟨idx, _, rfl⟩ := mem_image.mp hv exact R.fullTuple_prime idx have hprod : (∏ v ∈ univ.image R.fullTuple, v) = N := (prod_image R.fullTuple_order.injective.injOn).trans R.fullTuple_product exact hprod ▸ Sieve.prodDistinctPrimes_squarefree _ hp /- Original line 33494: Erdos416Proof.FordLower.PrimeProductRecord.factor_count -/ theorem factor_count : ArithmeticFunction.cardFactors N = coreDimension M (logLog y)+1 := by rw [cardFactors_eq_primeFactors_card_of_squarefree R.squarefree, R.prime_factors, card_image_of_injective _ R.fullTuple_order.injective] simp[Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint] /- Original line 33499: Erdos416Proof.FordLower.PrimeProductRecord.large_integer -/ theorem large_integer : y^(19/20 : ℝ) < (N : ℝ) := by have hp : 1 ≤ ∏ idx, R.lower idx := Nat.succ_le_of_lt (prod_pos (fun idx _ => (R.lower_prime idx).pos)) have hle : R.leading ≤ N := (le_mul_of_one_le_right (Nat.zero_le R.leading) hp).trans_eq R.integer.symm exact R.leading_size.trans_le (Nat.cast_le.mpr hle) end PrimeProductRecord /- Original line 33508: Erdos416Proof.FordLower.internalTotientCollisions -/ noncomputable def internalTotientCollisions (F : Finset ℕ) : Finset ℕ := collisionPoints F Nat.totient /- Original line 33511: Erdos416Proof.FordLower.card_le_V_add_internalCollisions -/ theorem card_le_V_add_internalCollisions {F : Finset ℕ} {y : ℝ} (hy : 0 ≤ y) (hF : ∀ n ∈ F, 0 < n ∧ (n.totient : ℝ) ≤ y) : (F.card : ℝ) ≤ V y+((internalTotientCollisions F).card : ℝ) := by classical have hmap : ∀ n ∈ F, n.totient ∈ totientsUpTo y := by intro n hn exact (mem_totientsUpTo hy).mpr ⟨Nat.totient_pos.mpr (hF n hn).1, (hF n hn).2, n, (hF n hn).1, rfl⟩ have h := card_le_of_injective_off_bad F (collisionPoints F Nat.totient) (totientsUpTo y) Nat.totient hmap (injective_off_collisionPoints F Nat.totient) have hreal : (F.card : ℝ) ≤ ((totientsUpTo y).card : ℝ)+((internalTotientCollisions F).card : ℝ) := by exact_mod_cast h exact hreal /-- The remaining lower-order obligation is now an explicit collision loss for the actual finite family. -/ /- Original line 33526: Erdos416Proof.FordLower.exists_core_mainTerm_le_V_add_collisions -/ theorem exists_core_mainTerm_le_V_add_collisions : ∃ c : ℝ, 0 < c ∧ ∀ A : ℝ, 0 ≤ A → ∀ᶠ M : ℕ in atTop, ∀ᶠ y : ℝ in atTop, ∀ p : Fin (coreDimension M (logLog y)), p.val+1 = coreDimension M (logLog y) → c*(y/Real.log y)*(logLog y)^(coreDimension M (logLog y))*T (coreDimension M (logLog y)) ≤ V y+((internalTotientCollisions (primeProducts (tupleIntegers (coreDimension M (logLog y)) (logLog y) (innerSeed (targetParameter (coreDimension M (logLog y)) M) p (A/logLog y))) y)).card : ℝ) := by obtain ⟨c, hc, hcount⟩ := exists_core_primeProducts_count_lower refine ⟨c, hc, ?_⟩ intro A hA filter_upwards [hcount A hA] with M hcount filter_upwards [hcount, core_primeProducts_totient_bounds M, eventually_ge_atTop (0 : ℝ)] with y hc hy0 hy intro p hp exact (hc p hp).trans (card_le_V_add_internalCollisions hy (fun n hn => ⟨(hy0 p A n hn).1, (hy0 p A n hn).2.2⟩)) end Erdos416Proof.FordLower /- Finite all-preimage prefix classes for the actual lower prime-product family. The maximality, cancellation and injective suffix witnesses are proved. The resulting class sum still needs an analytic bound. The simplified endpoint's finite missing-value/excess inequality follows. -/ open Filter Finset open scoped Classical Topology BigOperators namespace Erdos416Proof.FordLower open FordInner FordReciprocal FordScale /- Original line 33562: Erdos416Proof.FordLower.finite_positive_totient_preimages -/ theorem finite_positive_totient_preimages (v : ℕ) : Set.Finite {n : ℕ | 0 < n ∧ n.totient = v} := by obtain ⟨D, _, hbound⟩ := inverse_totient_bound_eventually obtain ⟨X, hX⟩ := eventually_atTop.mp hbound let Y : ℝ := max X (v : ℝ) have hpre := hX Y (le_max_left _ _) have hsub : {n : ℕ | 0 < n ∧ n.totient = v} ⊆ (↑(range (⌊D*Y*Real.log (Real.log Y)⌋₊+1)) : Set ℕ) := by intro n hn have hφ : (n.totient : ℝ) ≤ Y := by rw [hn.2]; exact le_max_right _ _ exact mem_range.mpr (Nat.lt_succ_iff.mpr (Nat.le_floor (hpre n hn.1 hφ))) exact (finite_toSet _).subset hsub /- Original line 33575: Erdos416Proof.FordLower.nontrivialPreimages -/ noncomputable def nontrivialPreimages (n : ℕ) : Finset ℕ := (finite_positive_totient_preimages n.totient).toFinset.filter (fun m => ¬n ∣ m) /- Original line 33578: Erdos416Proof.FordLower.mem_nontrivialPreimages -/ theorem mem_nontrivialPreimages {n m : ℕ} : m ∈ nontrivialPreimages n ↔ 0 < m ∧ m.totient = n.totient ∧ ¬n ∣ m := by simp only [nontrivialPreimages, Finset.mem_filter, Set.Finite.mem_toFinset, Set.mem_ofPred_eq, and_assoc] /- Original line 33583: Erdos416Proof.FordLower.externalTotientCollisions -/ noncomputable def externalTotientCollisions (F : Finset ℕ) : Finset ℕ := F.filter (fun n => (nontrivialPreimages n).Nonempty) /- Original line 33586: Erdos416Proof.FordLower.same_factor_count_eq_of_dvd -/ theorem same_factor_count_eq_of_dvd {n m : ℕ} (hn : Squarefree n) (hm : Squarefree m) (hcount : ArithmeticFunction.cardFactors n = ArithmeticFunction.cardFactors m) (hd : n ∣ m) : n = m := by have hcard : n.primeFactors.card = m.primeFactors.card := by rw [← cardFactors_eq_primeFactors_card_of_squarefree hn, ← cardFactors_eq_primeFactors_card_of_squarefree hm] exact hcount have heq : n.primeFactors = m.primeFactors := eq_of_subset_of_card_le (Nat.primeFactors_mono hd hm.ne_zero) hcard.ge calc _ = ∏ p ∈ n.primeFactors, p := (Nat.prod_primeFactors_of_squarefree hn).symm _ = ∏ p ∈ m.primeFactors, p := by rw [heq] _ = _ := Nat.prod_primeFactors_of_squarefree hm /- Original line 33600: Erdos416Proof.FordLower.internal_subset_external -/ theorem internal_subset_external {F : Finset ℕ} {k : ℕ} (hpos : ∀ n ∈ F, 0 < n) (hsq : ∀ n ∈ F, Squarefree n) (hcount : ∀ n ∈ F, ArithmeticFunction.cardFactors n = k) : internalTotientCollisions F ⊆ externalTotientCollisions F := by intro n hn simp only [internalTotientCollisions, collisionPoints, Finset.mem_filter] at hn obtain ⟨hnF, m, hmF, hne, hφ⟩ := hn refine Finset.mem_filter.mpr ⟨hnF, m, mem_nontrivialPreimages.mpr ⟨hpos m hmF, hφ, ?_⟩⟩ intro hd exact hne (same_factor_count_eq_of_dvd (hsq n hnF) (hsq m hmF) ((hcount n hnF).trans (hcount m hmF).symm) hd).symm /-- The actual internal collision loss is contained in Ford's larger all-preimage exceptional family. -/ /- Original line 33613: Erdos416Proof.FordLower.core_internal_subset_external -/ theorem core_internal_subset_external (M : ℕ) : ∀ᶠ y : ℝ in atTop, ∀ (p : Fin (coreDimension M (logLog y))), p.val+1 = coreDimension M (logLog y) → ∀ A : ℝ, 0 < A → internalTotientCollisions (primeProducts (tupleIntegers (coreDimension M (logLog y)) (logLog y) (innerSeed (targetParameter (coreDimension M (logLog y)) M) p (A/logLog y))) y) ⊆ externalTotientCollisions (primeProducts (tupleIntegers (coreDimension M (logLog y)) (logLog y) (innerSeed (targetParameter (coreDimension M (logLog y)) M) p (A/logLog y))) y) := by filter_upwards [core_primeProducts_record M] with y hr intro p hp A hA apply internal_subset_external (k := coreDimension M (logLog y)+1) · intro n hn obtain ⟨R⟩ := hr p hp A hA n hn exact R.positive · intro n hn obtain ⟨R⟩ := hr p hp A hA n hn exact R.squarefree · intro n hn obtain ⟨R⟩ := hr p hp A hA n hn exact R.factor_count end Erdos416Proof.FordLower namespace Erdos416Proof.FordLower variable {k n m j : ℕ} {p : Fin k → ℕ} /- Original line 33640: Erdos416Proof.FordLower.prefixProduct -/ def prefixProduct (p : Fin k → ℕ) (j : ℕ) : ℕ := ∏ idx ∈ univ.filter (fun idx : Fin k => idx.val < j), p idx /- Original line 33643: Erdos416Proof.FordLower.suffixProduct -/ def suffixProduct (p : Fin k → ℕ) (j : ℕ) : ℕ := ∏ idx ∈ univ.filter (fun idx : Fin k => j ≤ idx.val), p idx /- Original line 33646: Erdos416Proof.FordLower.prefixProduct_zero -/ theorem prefixProduct_zero (p : Fin k → ℕ) : prefixProduct p 0 = 1 := by simp [prefixProduct] /- Original line 33649: Erdos416Proof.FordLower.prefixProduct_length -/ theorem prefixProduct_length (p : Fin k → ℕ) : prefixProduct p k = ∏ idx, p idx := by simp [prefixProduct] /- Original line 33652: Erdos416Proof.FordLower.prefix_mul_suffix -/ theorem prefix_mul_suffix (p : Fin k → ℕ) (j : ℕ) : prefixProduct p j * suffixProduct p j = ∏ idx, p idx := by simpa only [prefixProduct, suffixProduct, not_lt] using prod_filter_mul_prod_filter_not univ (fun idx : Fin k => idx.val < j) p /- Original line 33657: Erdos416Proof.FordLower.prefixProduct_succ -/ theorem prefixProduct_succ (p : Fin k → ℕ) (hj : j < k) : prefixProduct p (j+1) = prefixProduct p j * p ⟨j, hj⟩ := by have hset : univ.filter (fun idx : Fin k => idx.val < j+1) = insert ⟨j, hj⟩ (univ.filter (fun idx : Fin k => idx.val < j)) := by ext idx simp only [mem_filter, mem_univ, true_and, mem_insert, Fin.ext_iff] omega unfold prefixProduct rw [hset, prod_insert (by simp)] exact mul_comm _ _ /- Original line 33668: Erdos416Proof.FordLower.prefixProduct_pos -/ theorem prefixProduct_pos (hp : ∀ idx, (p idx).Prime) (j : ℕ) : 0 < prefixProduct p j := prod_pos (fun idx _ => (hp idx).pos) /- Original line 33671: Erdos416Proof.FordLower.suffixProduct_pos -/ theorem suffixProduct_pos (hp : ∀ idx, (p idx).Prime) (j : ℕ) : 0 < suffixProduct p j := prod_pos (fun idx _ => (hp idx).pos) /- Original line 33674: Erdos416Proof.FordLower.suffixProduct_totient -/ theorem suffixProduct_totient (hp : ∀ idx, (p idx).Prime) (ho : StrictAnti p) (j : ℕ) : (suffixProduct p j).totient = ∏ idx ∈ univ.filter (fun idx : Fin k => j ≤ idx.val), (p idx-1) := totient_prod_injective_primes _ p (fun idx _ => hp idx) ho.injective.injOn /- Original line 33679: Erdos416Proof.FordLower.suffixProduct_squarefree -/ theorem suffixProduct_squarefree (hp : ∀ idx, (p idx).Prime) (ho : StrictAnti p) (j : ℕ) : Squarefree (suffixProduct p j) := by let s := univ.filter (fun idx : Fin k => j ≤ idx.val) have hpr : ∀ q ∈ s.image p, q.Prime := by intro q hq obtain ⟨idx, _, rfl⟩ := mem_image.mp hq exact hp idx have heq : (∏ q ∈ s.image p, q) = suffixProduct p j := prod_image ho.injective.injOn exact heq ▸ Sieve.prodDistinctPrimes_squarefree _ hpr /- Original line 33690: Erdos416Proof.FordLower.suffixProduct_factor_count -/ theorem suffixProduct_factor_count (hp : ∀ idx, (p idx).Prime) (hj : j < k) : ArithmeticFunction.cardFactors (suffixProduct p j) = k-j := by have hset : univ.filter (fun idx : Fin k => j ≤ idx.val) = Ici (⟨j, hj⟩ : Fin k) := by ext idx simp only [mem_filter, mem_univ, true_and, mem_Ici, Fin.le_def] rw [suffixProduct, cardFactors_finset_prod _ _ (fun idx _ => (hp idx).ne_zero)] calc _ = ∑ _i ∈ univ.filter (fun idx : Fin k => j ≤ idx.val), (1 : ℕ) := sum_congr rfl fun idx _ => ArithmeticFunction.cardFactors_apply_prime (hp idx) _ = k-j := by simp [hset] /- Original line 33701: Erdos416Proof.FordLower.largestPrimeFactor_suffixProduct -/ theorem largestPrimeFactor_suffixProduct (hp : ∀ idx, (p idx).Prime) (ho : StrictAnti p) (hj : j < k) : largestPrimeFactor (suffixProduct p j) = p ⟨j, hj⟩ := by have hpos := suffixProduct_pos hp j apply le_antisymm · unfold largestPrimeFactor apply max_le (hp ⟨j, hj⟩).one_le apply Finset.sup_le intro q hq have hqpr := Nat.prime_of_mem_primeFactors hq have hqd := Nat.dvd_of_mem_primeFactors hq obtain ⟨idx, hi, hqi⟩ := (Nat.prime_iff.mp hqpr).exists_mem_finset_dvd hqd have heq : q = p idx := (Nat.prime_dvd_prime_iff_eq hqpr (hp idx)).mp hqi rw [heq] exact ho.antitone (show (⟨j, hj⟩ : Fin k) ≤ idx from (mem_filter.mp hi).2) · apply prime_le_largestPrimeFactor hpos (hp ⟨j, hj⟩) exact dvd_prod_of_mem p (by simp[Erdos416Proof.largestPrimeFactor_one] ) /- Original line 33718: Erdos416Proof.FordLower.top_not_dvd_suffix_totient -/ theorem top_not_dvd_suffix_totient (hp : ∀ idx, (p idx).Prime) (ho : StrictAnti p) (hj : j < k) : ¬ p ⟨j, hj⟩ ∣ (suffixProduct p j).totient := by rw [suffixProduct_totient hp ho j] intro hd obtain ⟨idx, hi, hpi⟩ := (Nat.prime_iff.mp (hp ⟨j, hj⟩)).exists_mem_finset_dvd hd have hij : (⟨j, hj⟩ : Fin k) ≤ idx := (mem_filter.mp hi).2 have hle := ho.antitone hij have hsmall : p idx-1 < p ⟨j, hj⟩ := by have := (hp idx).pos; omega exact (not_lt_of_ge (Nat.le_of_dvd (Nat.sub_pos_of_lt (hp idx).one_lt) hpi)) hsmall /-- An equal-totient witness cannot repeat a prime absent from that totient. -/ /- Original line 33729: Erdos416Proof.FordLower.split_largest_prime_of_not_dvd_totient -/ theorem split_largest_prime_of_not_dvd_totient {q w : ℕ} (hq : q.Prime) (hw : 0 < w) (htop : largestPrimeFactor w = q) (hφ : ¬q ∣ w.totient) : ∃ a : ℕ, 0 < a ∧ w = q*a ∧ largestPrimeFactor a < q := by have hqw : q ∣ w := htop ▸ largestPrimeFactor_dvd w obtain ⟨a, ha⟩ := hqw have ha0 : 0 < a := by by_contra h have haz : a = 0 := by omega simp [Erdos416Proof.largestPrimeFactor_one, ha, haz] at hw have hqa : ¬q ∣ a := by intro hd apply hφ rw [ha, Nat.totient_mul_of_prime_of_dvd hq hd] exact dvd_mul_right q a.totient have hle : largestPrimeFactor a ≤ q := by have ht := htop rw [ha, largestPrimeFactor_mul hq.pos ha0, largestPrimeFactor_prime hq] at ht exact (le_max_right _ _).trans_eq ht have hne : largestPrimeFactor a ≠ q := by intro heq exact hqa (heq ▸ largestPrimeFactor_dvd a) exact ⟨a, ha0, ha, lt_of_le_of_ne hle hne⟩ /-- The indicated primes are precisely the distinct largest primes of the prefix, with every prime of the positive residual strictly smaller. -/ /- Original line 33755: Erdos416Proof.FordLower.PrefixAgreement -/ def PrefixAgreement (p : Fin k → ℕ) (j m : ℕ) : Prop := ∃ w : ℕ, 0 < w ∧ m = prefixProduct p j*w ∧ ∀ idx : Fin k, idx.val < j → largestPrimeFactor w < p idx /- Original line 33759: Erdos416Proof.FordLower.prefixAgreement_zero -/ theorem prefixAgreement_zero (p : Fin k → ℕ) (hm : 0 < m) : PrefixAgreement p 0 m := by refine ⟨m, hm, ?_, fun idx hi => (Nat.not_lt_zero _ hi).elim⟩ rw [prefixProduct_zero, one_mul] /- Original line 33763: Erdos416Proof.FordLower.prefixProduct_coprime_of_separated -/ theorem prefixProduct_coprime_of_separated (hp : ∀ idx, (p idx).Prime) {w : ℕ} (hw : 0 < w) (hsep : ∀ idx : Fin k, idx.val < j → largestPrimeFactor w < p idx) : (prefixProduct p j).Coprime w := by apply Nat.coprime_prod_left_iff.mpr intro idx hi exact coprime_of_largestPrimeFactor_lt hw (hp idx) (hsep idx (mem_filter.mp hi).2) /- Original line 33770: Erdos416Proof.FordLower.prefix_suffix_coprime -/ theorem prefix_suffix_coprime (hp : ∀ idx, (p idx).Prime) (ho : StrictAnti p) (hj : j < k) : (prefixProduct p j).Coprime (suffixProduct p j) := by apply prefixProduct_coprime_of_separated hp (suffixProduct_pos hp j) intro idx hi rw [largestPrimeFactor_suffixProduct hp ho hj] exact ho (show idx < (⟨j, hj⟩ : Fin k) from hi) /- Original line 33777: Erdos416Proof.FordLower.prefixDepths -/ noncomputable def prefixDepths (p : Fin k → ℕ) (n : ℕ) : Finset ℕ := (range (k+1)).filter (fun j => ∃ m ∈ nontrivialPreimages n, PrefixAgreement p j m) /- Original line 33780: Erdos416Proof.FordLower.mem_prefixDepths -/ theorem mem_prefixDepths : j ∈ prefixDepths p n ↔ j ≤ k ∧ ∃ m ∈ nontrivialPreimages n, PrefixAgreement p j m := by simp only [prefixDepths, mem_filter, mem_range, Nat.lt_succ_iff] /- Original line 33784: Erdos416Proof.FordLower.prefixDepth -/ noncomputable def prefixDepth (p : Fin k → ℕ) (n : ℕ) : ℕ := if h : (prefixDepths p n).Nonempty then (prefixDepths p n).max' h else 0 /- Original line 33787: Erdos416Proof.FordLower.zero_mem_prefixDepths -/ theorem zero_mem_prefixDepths (h : (nontrivialPreimages n).Nonempty) : 0 ∈ prefixDepths p n := by obtain ⟨m, hm⟩ := h exact mem_prefixDepths.mpr ⟨Nat.zero_le _, m, hm, prefixAgreement_zero p (mem_nontrivialPreimages.mp hm).1⟩ /- Original line 33793: Erdos416Proof.FordLower.prefixDepth_mem -/ theorem prefixDepth_mem (h : (nontrivialPreimages n).Nonempty) : prefixDepth p n ∈ prefixDepths p n := by have hd : (prefixDepths p n).Nonempty := ⟨0, zero_mem_prefixDepths h⟩ rw [prefixDepth, dif_pos hd] exact max'_mem _ hd /- Original line 33799: Erdos416Proof.FordLower.le_prefixDepth -/ theorem le_prefixDepth (h : j ∈ prefixDepths p n) : j ≤ prefixDepth p n := by have hd : (prefixDepths p n).Nonempty := ⟨j, h⟩ rw [prefixDepth, dif_pos hd] exact le_max' _ _ h /- Original line 33804: Erdos416Proof.FordLower.prefixDepth_lt -/ theorem prefixDepth_lt (hprod : (∏ idx, p idx) = n) (h : (nontrivialPreimages n).Nonempty) : prefixDepth p n < k := by obtain ⟨hle, m, hm, w, hw, heq, _⟩ := mem_prefixDepths.mp (prefixDepth_mem (p := p) h) by_contra hnlt have he : prefixDepth p n = k := by omega rw [he, prefixProduct_length, hprod] at heq exact (mem_nontrivialPreimages.mp hm).2.2 ⟨w, heq⟩ /- Original line 33812: Erdos416Proof.FordLower.no_prefixDepth_successor -/ theorem no_prefixDepth_successor (hprod : (∏ idx, p idx) = n) (h : (nontrivialPreimages n).Nonempty) : ¬∃ m ∈ nontrivialPreimages n, PrefixAgreement p (prefixDepth p n+1) m := by intro hw have hlt := prefixDepth_lt hprod h have hmem : prefixDepth p n+1 ∈ prefixDepths p n := mem_prefixDepths.mpr ⟨by omega, hw⟩ have hle := le_prefixDepth hmem omega /- Original line 33822: Erdos416Proof.FordLower.prefixCollisionClass -/ noncomputable def prefixCollisionClass (F : Finset ℕ) (p : ℕ → Fin k → ℕ) (j : ℕ) : Finset ℕ := (externalTotientCollisions F).filter (fun n => prefixDepth (p n) n = j) /- Original line 33826: Erdos416Proof.FordLower.mem_prefixCollisionClass -/ theorem mem_prefixCollisionClass {F : Finset ℕ} {p : ℕ → Fin k → ℕ} : n ∈ prefixCollisionClass F p j ↔ n ∈ F ∧ (nontrivialPreimages n).Nonempty ∧ prefixDepth (p n) n = j := by simp only [prefixCollisionClass, externalTotientCollisions, mem_filter, and_assoc] /- Original line 33831: Erdos416Proof.FordLower.card_external_eq_sum_prefixClasses -/ theorem card_external_eq_sum_prefixClasses (F : Finset ℕ) (p : ℕ → Fin k → ℕ) (hprod : ∀ n ∈ F, (∏ idx, p n idx) = n) : (externalTotientCollisions F).card = ∑ j ∈ range k, (prefixCollisionClass F p j).card := by apply card_eq_sum_card_fiberwise (f := fun n => prefixDepth (p n) n) intro n hn obtain ⟨hnF, hnw⟩ := mem_filter.mp hn exact mem_range.mpr (prefixDepth_lt (hprod n hnF) hnw) /-- Cancelling the maximal common prefix leaves a nontrivial totient witness. -/ /- Original line 33840: Erdos416Proof.FordLower.suffix_nontrivial_witness -/ theorem suffix_nontrivial_witness (hp : ∀ idx, (p idx).Prime) (ho : StrictAnti p) (hprod : (∏ idx, p idx) = n) (h : (nontrivialPreimages n).Nonempty) : (nontrivialPreimages (suffixProduct p (prefixDepth p n))).Nonempty := by obtain ⟨_, m, hm, w, hw, heq, hsep⟩ := mem_prefixDepths.mp (prefixDepth_mem (p := p) h) have hj := prefixDepth_lt hprod h have hfactor := (prefix_mul_suffix p (prefixDepth p n)).trans hprod have hcopw := prefixProduct_coprime_of_separated hp hw hsep have hcops := prefix_suffix_coprime hp ho hj have hφ : (prefixProduct p (prefixDepth p n)).totient*w.totient = (prefixProduct p (prefixDepth p n)).totient*(suffixProduct p (prefixDepth p n)).totient := by rw [← Nat.totient_mul hcopw, ← Nat.totient_mul hcops, ← heq, hfactor] exact (mem_nontrivialPreimages.mp hm).2.1 have hwφ := Nat.eq_of_mul_eq_mul_left (Nat.totient_pos.mpr (prefixProduct_pos hp _)) hφ refine ⟨w, mem_nontrivialPreimages.mpr ⟨hw, hwφ, ?_⟩⟩ intro hd apply (mem_nontrivialPreimages.mp hm).2.2 rw [← hfactor, heq] exact mul_dvd_mul_left _ hd /-- The all-preimage maximality condition also excludes a matching largest prime for every nontrivial suffix witness, including witnesses outside the family. -/ /- Original line 33863: Erdos416Proof.FordLower.suffix_witness_largest_ne -/ theorem suffix_witness_largest_ne (hp : ∀ idx, (p idx).Prime) (ho : StrictAnti p) (hprod : (∏ idx, p idx) = n) (h : (nontrivialPreimages n).Nonempty) {w : ℕ} (hw : w ∈ nontrivialPreimages (suffixProduct p (prefixDepth p n))) : largestPrimeFactor w ≠ largestPrimeFactor (suffixProduct p (prefixDepth p n)) := by intro heqtop let j := prefixDepth p n have hj : j < k := prefixDepth_lt hprod h have htop : largestPrimeFactor w = p ⟨j, hj⟩ := heqtop.trans (largestPrimeFactor_suffixProduct hp ho hj) obtain ⟨hw0, hwφ, hwn⟩ := mem_nontrivialPreimages.mp hw have hnot : ¬p ⟨j, hj⟩ ∣ w.totient := by rw [hwφ] exact top_not_dvd_suffix_totient hp ho hj obtain ⟨a, ha0, hwa, hatop⟩ := split_largest_prime_of_not_dvd_totient (hp ⟨j, hj⟩) hw0 htop hnot have hsep : ∀ idx : Fin k, idx.val < j → largestPrimeFactor w < p idx := by intro idx hi rw [htop] exact ho (show idx < (⟨j, hj⟩ : Fin k) from hi) have hcopw := prefixProduct_coprime_of_separated hp hw0 hsep have hcops := prefix_suffix_coprime hp ho hj have hfactor := (prefix_mul_suffix p j).trans hprod let m := prefixProduct p j*w have hm0 : 0 < m := Nat.mul_pos (prefixProduct_pos hp j) hw0 have hmφ : m.totient = n.totient := by calc _ = (prefixProduct p j).totient*w.totient := Nat.totient_mul hcopw _ = (prefixProduct p j).totient*(suffixProduct p j).totient := by rw [hwφ] _ = n.totient := (Nat.totient_mul hcops).symm.trans (congrArg Nat.totient hfactor) have hmn : ¬n ∣ m := by intro hd apply hwn have hd' : prefixProduct p j*suffixProduct p j ∣ prefixProduct p j*w := by simpa only [hfactor] using hd exact (mul_dvd_mul_iff_left (prefixProduct_pos hp j).ne').mp hd' apply no_prefixDepth_successor hprod h refine ⟨m, mem_nontrivialPreimages.mpr ⟨hm0, hmφ, hmn⟩, a, ha0, ?_, ?_⟩ · change prefixProduct p j*w = prefixProduct p (j+1)*a rw [prefixProduct_succ p hj, hwa, mul_assoc] · intro idx hi have hji : idx ≤ (⟨j, hj⟩ : Fin k) := by change idx.val ≤ j change idx.val < j+1 at hi omega exact hatop.trans_le (ho.antitone hji) /- Original line 33909: Erdos416Proof.FordLower.suffixCollisionFamily -/ noncomputable def suffixCollisionFamily (F : Finset ℕ) (p : ℕ → Fin k → ℕ) (j : ℕ) : Finset ℕ := (prefixCollisionClass F p j).image (fun n => suffixProduct (p n) j) /- Original line 33913: Erdos416Proof.FordLower.suffixCollisionFamily_properties -/ theorem suffixCollisionFamily_properties (F : Finset ℕ) (p : ℕ → Fin k → ℕ) (hp : ∀ n ∈ F, ∀ idx, (p n idx).Prime) (ho : ∀ n ∈ F, StrictAnti (p n)) (hprod : ∀ n ∈ F, (∏ idx, p n idx) = n) (j : ℕ) {s : ℕ} (hs : s ∈ suffixCollisionFamily F p j) : 0 < s ∧ Squarefree s ∧ ArithmeticFunction.cardFactors s = k-j ∧ (nontrivialPreimages s).Nonempty ∧ ∀ w ∈ nontrivialPreimages s, largestPrimeFactor w ≠ largestPrimeFactor s := by obtain ⟨n, hn, rfl⟩ := mem_image.mp hs obtain ⟨hnF, hnw, hdepth⟩ := mem_prefixCollisionClass.mp hn have hj : j < k := hdepth ▸ prefixDepth_lt (hprod n hnF) hnw refine ⟨suffixProduct_pos (hp n hnF) j, suffixProduct_squarefree (hp n hnF) (ho n hnF) j, suffixProduct_factor_count (hp n hnF) hj, ?_, ?_⟩ · simpa only [hdepth] using suffix_nontrivial_witness (hp n hnF) (ho n hnF) (hprod n hnF) hnw · intro w hw have hw' : w ∈ nontrivialPreimages (suffixProduct (p n) (prefixDepth (p n) n)) := by simpa only [hdepth] using hw simpa only [hdepth] using suffix_witness_largest_ne (hp n hnF) (ho n hnF) (hprod n hnF) hnw hw' /-- A single assignment on a suffix family, retained unchanged by later pruning. -/ /- Original line 33932: Erdos416Proof.FordLower.SuffixAssignment -/ structure SuffixAssignment (F : Finset ℕ) (w : ℕ → ℕ) : Prop where injective : Set.InjOn w (F : Set ℕ) positive : ∀ n ∈ F, 0 < w n equation : ∀ n ∈ F, (w n).totient = n.totient not_dvd : ∀ n ∈ F, ¬n ∣ w n largest_ne : ∀ n ∈ F, largestPrimeFactor (w n) ≠ largestPrimeFactor n peer : ∀ n ∈ F, (∃ m ∈ F, m.totient = n.totient ∧ m ≠ n) → ∃ m ∈ F, w n = m /- Original line 33941: Erdos416Proof.FordLower.exists_suffix_assignment -/ theorem exists_suffix_assignment (F : Finset ℕ) (k : ℕ) (hF : ∀ n ∈ F, 0 < n ∧ Squarefree n ∧ ArithmeticFunction.cardFactors n = k ∧ (nontrivialPreimages n).Nonempty ∧ ∀ w ∈ nontrivialPreimages n, largestPrimeFactor w ≠ largestPrimeFactor n) : ∃ w : ℕ → ℕ, SuffixAssignment F w := by classical let f : F → ℕ := fun n => n.val.totient let canonical : F → ℕ := Subtype.val let relation : F → ℕ → Prop := fun n N => 0 < N ∧ ¬n.val ∣ N ∧ largestPrimeFactor N ≠ largestPrimeFactor n.val have hpeer (a b : F) (hab : f b = f a) (hba : b ≠ a) : relation a (canonical b) := by have hnd : ¬a.val ∣ b.val := by intro hd apply hba exact Subtype.ext (same_factor_count_eq_of_dvd (hF a a.property).2.1 (hF b b.property).2.1 ((hF a a.property).2.2.1.trans (hF b b.property).2.2.1.symm) hd).symm have hmem : b.val ∈ nontrivialPreimages a.val := mem_nontrivialPreimages.mpr ⟨(hF b b.property).1, hab, hnd⟩ exact ⟨(hF b b.property).1, hnd, (hF a a.property).2.2.2.2 b hmem⟩ have hwit (a : F) : ∃ N : ℕ, N.totient = f a ∧ relation a N := by obtain ⟨N, hN⟩ := (hF a a.property).2.2.2.1 obtain ⟨hpos, hφ, hnd⟩ := mem_nontrivialPreimages.mp hN exact ⟨N, hφ, hpos, hnd, (hF a a.property).2.2.2.2 N hN⟩ obtain ⟨w, hw, hwval, hwpeer⟩ := exists_injective_witness f Nat.totient canonical Subtype.val_injective (fun _ => rfl) relation hpeer hwit let w' : ℕ → ℕ := fun n => if hn : n ∈ F then w ⟨n, hn⟩ else 0 have hw' (n : ℕ) (hn : n ∈ F) : w' n = w ⟨n, hn⟩ := dif_pos hn refine ⟨w', ?_⟩ constructor · intro n hn m hm heq rw [hw' n hn, hw' m hm] at heq exact congrArg Subtype.val (hw heq) · intro n hn rw [hw' n hn] exact (hwval ⟨n, hn⟩).2.1 · intro n hn rw [hw' n hn] exact (hwval ⟨n, hn⟩).1 · intro n hn rw [hw' n hn] exact (hwval ⟨n, hn⟩).2.2.1 · intro n hn rw [hw' n hn] exact (hwval ⟨n, hn⟩).2.2.2 · intro n hn ⟨m, hm, hφ, hmn⟩ have hpeer' : HasPeer f ⟨n, hn⟩ := ⟨⟨m, hm⟩, hφ, fun heq => hmn (congrArg Subtype.val heq)⟩ obtain ⟨b, hb⟩ := hwpeer ⟨n, hn⟩ hpeer' exact ⟨b, b.property, (hw' n hn).trans hb⟩ /- Original line 33991: Erdos416Proof.FordLower.suffixCollisionFamily_assignment -/ theorem suffixCollisionFamily_assignment (F : Finset ℕ) (p : ℕ → Fin k → ℕ) (hp : ∀ n ∈ F, ∀ idx, (p n idx).Prime) (ho : ∀ n ∈ F, StrictAnti (p n)) (hprod : ∀ n ∈ F, (∏ idx, p n idx) = n) (j : ℕ) : ∃ w : ℕ → ℕ, SuffixAssignment (suffixCollisionFamily F p j) w := exists_suffix_assignment _ (k-j) (fun _ hn => suffixCollisionFamily_properties F p hp ho hprod j hn) /- Original line 33997: Erdos416Proof.FordLower.card_internal_le_sum_prefixClasses -/ theorem card_internal_le_sum_prefixClasses (F : Finset ℕ) (p : ℕ → Fin k → ℕ) (hprod : ∀ n ∈ F, (∏ idx, p n idx) = n) (hpos : ∀ n ∈ F, 0 < n) (hsq : ∀ n ∈ F, Squarefree n) (hcount : ∀ n ∈ F, ArithmeticFunction.cardFactors n = k) : (internalTotientCollisions F).card ≤ ∑ j ∈ range k, (prefixCollisionClass F p j).card := by rw [← card_external_eq_sum_prefixClasses F p hprod] exact card_le_card (internal_subset_external hpos hsq hcount) open FordInner FordReciprocal FordScale FordGeometry /-- The prefix partition and injective suffix witnesses for the actual lower prime-product family. Its chosen tuples retain the complete geometric records. -/ /- Original line 34008: Erdos416Proof.FordLower.core_prefix_families -/ theorem core_prefix_families (M : ℕ) : ∀ᶠ y : ℝ in Filter.atTop, ∀ (a : Fin (coreDimension M (logLog y))), a.val+1 = coreDimension M (logLog y) → ∀ A : ℝ, 0 < A → let B := primeProducts (tupleIntegers (coreDimension M (logLog y)) (logLog y) (innerSeed (targetParameter (coreDimension M (logLog y)) M) a (A/logLog y))) y ∃ q : ℕ → Fin (coreDimension M (logLog y)+1) → ℕ, (∀ n ∈ B, ∃ R : PrimeProductRecord M A y a n, R.fullTuple = q n) ∧ (B.card : ℝ) ≤ V y + ∑ j ∈ range (coreDimension M (logLog y)+1), ((prefixCollisionClass B q j).card : ℝ) ∧ ∀ j : ℕ, ∃ w : ℕ → ℕ, SuffixAssignment (suffixCollisionFamily B q j) w := by classical filter_upwards [core_primeProducts_record M, Filter.eventually_ge_atTop (0 : ℝ)] with y hrec hy intro a ha A hA let B := primeProducts (tupleIntegers (coreDimension M (logLog y)) (logLog y) (innerSeed (targetParameter (coreDimension M (logLog y)) M) a (A/logLog y))) y have hR (n : ℕ) (hn : n ∈ B) : Nonempty (PrimeProductRecord M A y a n) := hrec a ha A hA n hn let q : ℕ → Fin (coreDimension M (logLog y)+1) → ℕ := fun n => if hn : n ∈ B then (Classical.choice (hR n hn)).fullTuple else fun _ => 2 have hq (n : ℕ) (hn : n ∈ B) : ∃ R : PrimeProductRecord M A y a n, R.fullTuple = q n := by refine ⟨Classical.choice (hR n hn), ?_⟩ simp only [q, dif_pos hn] have hp (n : ℕ) (hn : n ∈ B) : ∀ idx, (q n idx).Prime := by obtain ⟨R, hEq⟩ := hq n hn rw [← hEq] exact R.fullTuple_prime have ho (n : ℕ) (hn : n ∈ B) : StrictAnti (q n) := by obtain ⟨R, hEq⟩ := hq n hn rw [← hEq] exact R.fullTuple_order have hprod (n : ℕ) (hn : n ∈ B) : (∏ idx, q n idx) = n := by obtain ⟨R, hEq⟩ := hq n hn simpa only [hEq] using R.fullTuple_product have hpos (n : ℕ) (hn : n ∈ B) : 0 < n := (Classical.choice (hR n hn)).positive have hsq (n : ℕ) (hn : n ∈ B) : Squarefree n := (Classical.choice (hR n hn)).squarefree have hcount (n : ℕ) (hn : n ∈ B) : ArithmeticFunction.cardFactors n = coreDimension M (logLog y)+1 := (Classical.choice (hR n hn)).factor_count refine ⟨q, hq, ?_, fun j => suffixCollisionFamily_assignment B q hp ho hprod j⟩ have hV := card_le_V_add_internalCollisions hy (fun n hn => ⟨hpos n hn, (Classical.choice (hR n hn)).totient_range.2⟩) have hc := card_internal_le_sum_prefixClasses B q hprod hpos hsq hcount have hcR : ((internalTotientCollisions B).card : ℝ) ≤ ∑ j ∈ range (coreDimension M (logLog y)+1), ((prefixCollisionClass B q j).card : ℝ) := by exact_mod_cast hc linarith /-- The lower main term with its actual maximal-prefix exceptional classes. Each suffix family has a proved injective witness assignment. The class sum is still an error term whose analytic bound must be supplied. -/ /- Original line 34056: Erdos416Proof.FordLower.exists_core_mainTerm_le_V_add_prefixClasses -/ theorem exists_core_mainTerm_le_V_add_prefixClasses : ∃ c : ℝ, 0 < c ∧ ∀ A : ℝ, 0 < A → ∀ᶠ M : ℕ in Filter.atTop, ∀ᶠ y : ℝ in Filter.atTop, ∀ (a : Fin (coreDimension M (logLog y))), a.val+1 = coreDimension M (logLog y) → let B := primeProducts (tupleIntegers (coreDimension M (logLog y)) (logLog y) (innerSeed (targetParameter (coreDimension M (logLog y)) M) a (A/logLog y))) y ∃ q : ℕ → Fin (coreDimension M (logLog y)+1) → ℕ, (∀ n ∈ B, ∃ R : PrimeProductRecord M A y a n, R.fullTuple = q n) ∧ c*(y/Real.log y)*(logLog y)^(coreDimension M (logLog y))*T (coreDimension M (logLog y)) ≤ V y + ∑ j ∈ range (coreDimension M (logLog y)+1), ((prefixCollisionClass B q j).card : ℝ) ∧ ∀ j : ℕ, ∃ w : ℕ → ℕ, SuffixAssignment (suffixCollisionFamily B q j) w := by obtain ⟨c, hc, hcount⟩ := exists_core_primeProducts_count_lower refine ⟨c, hc, ?_⟩ intro A hA filter_upwards [hcount A hA.le] with M hcount filter_upwards [hcount, core_prefix_families M] with y hmain hfamily intro a ha obtain ⟨q, hq, hV, hw⟩ := hfamily a ha A hA exact ⟨q, hq, (hmain a ha).trans hV, hw⟩ end Erdos416Proof.FordLower open Finset open scoped Classical namespace Erdos416Proof.Simplified /- Original line 34087: Erdos416Proof.Simplified.image_full_preimage -/ theorem image_full_preimage {α β : Type*} (P : Finset α) (T₀ : Finset β) (f : α → β) : (P.filter (fun a => f a ∈ T₀)).image f = P.image f ∩ T₀ := by classical ext b simp only [Finset.mem_image, Finset.mem_filter, Finset.mem_inter] constructor · rintro ⟨a, ⟨ha, hfa⟩, rfl⟩ exact ⟨⟨a, ha, rfl⟩, hfa⟩ · rintro ⟨⟨a, ha, rfl⟩, hfa⟩ exact ⟨a, ⟨ha, hfa⟩, rfl⟩ /- Original line 34098: Erdos416Proof.Simplified.excess_representations_mono -/ theorem excess_representations_mono {α β : Type*} (f : α → β) {P₀ P : Finset α} (hP : P₀ ⊆ P) : (P₀.card : ℝ) - (P₀.image f).card ≤ (P.card : ℝ) - (P.image f).card := by classical have hI : P₀.image f ⊆ P.image f := image_subset_image hP have hsub : P.image f \ P₀.image f ⊆ (P \ P₀).image f := by intro b hb obtain ⟨hbP, hb₀⟩ := mem_sdiff.mp hb obtain ⟨a, ha, rfl⟩ := mem_image.mp hbP refine mem_image.mpr ⟨a, mem_sdiff.mpr ⟨ha, ?_⟩, rfl⟩ exact fun ha₀ => hb₀ (mem_image_of_mem f ha₀) have hcard := (card_le_card hsub).trans (card_image_le (f := f)) rw [card_sdiff_of_subset hI, card_sdiff_of_subset hP] at hcard have hIcard := card_le_card hI have hPcard := card_le_card hP have hnat : P₀.card + (P.image f).card ≤ P.card + (P₀.image f).card := by omega have hreal : (P₀.card : ℝ) + (P.image f).card ≤ P.card + (P₀.image f).card := by exact_mod_cast hnat linarith /- Original line 34118: Erdos416Proof.Simplified.finite_counting_error -/ theorem finite_counting_error {α β : Type*} (P : Finset α) (T T₀ : Finset β) (f : α → β) (hT : T₀ ⊆ T) (hmap : ∀ a ∈ P, f a ∈ T) : let P₀ := P.filter (fun a => f a ∈ T₀) |(T.card : ℝ) - 2 * T₀.card| ≤ |(P.card : ℝ) - 2 * P₀.card| + ((T.card : ℝ) - (P.image f).card) + ((P.card : ℝ) - (P.image f).card) := by classical let P₀ := P.filter (fun a => f a ∈ T₀) let I := P.image f let I₀ := P₀.image f have hP : P₀ ⊆ P := filter_subset _ _ have hI : I ⊆ T := image_subset_iff.mpr hmap have hI₀eq : I₀ = I ∩ T₀ := image_full_preimage P T₀ f have hI₀ : I₀ ⊆ T₀ := by rw [hI₀eq]; exact inter_subset_right have hmissing : T₀ \ I₀ ⊆ T \ I := by intro b hb obtain ⟨hb₀, hbn⟩ := mem_sdiff.mp hb refine mem_sdiff.mpr ⟨hT hb₀, ?_⟩ intro hbI apply hbn rw [hI₀eq] exact mem_inter.mpr ⟨hbI, hb₀⟩ have hmissingCard := card_le_card hmissing rw [card_sdiff_of_subset hI₀, card_sdiff_of_subset hI] at hmissingCard have hM : (T₀.card : ℝ) - I₀.card ≤ (T.card : ℝ) - I.card := by have hreal : ((T₀.card - I₀.card : ℕ) : ℝ) ≤ (T.card - I.card : ℕ) := by exact_mod_cast hmissingCard simpa only [Nat.cast_sub (card_le_card hI₀), Nat.cast_sub (card_le_card hI)] using hreal have hM₀ : 0 ≤ (T₀.card : ℝ) - I₀.card := by exact sub_nonneg.mpr (Nat.cast_le.mpr (card_le_card hI₀)) have hE : (P₀.card : ℝ) - I₀.card ≤ (P.card : ℝ) - I.card := excess_representations_mono f hP have hE₀ : 0 ≤ (P₀.card : ℝ) - I₀.card := by exact sub_nonneg.mpr (Nat.cast_le.mpr (card_image_le (f := f))) have hMa : |((T.card : ℝ) - I.card) - 2 * ((T₀.card : ℝ) - I₀.card)| ≤ (T.card : ℝ) - I.card := abs_le.mpr ⟨by linarith, by linarith⟩ have hEa : |((P.card : ℝ) - I.card) - 2 * ((P₀.card : ℝ) - I₀.card)| ≤ (P.card : ℝ) - I.card := abs_le.mpr ⟨by linarith, by linarith⟩ change |(T.card : ℝ) - 2 * T₀.card| ≤ |(P.card : ℝ) - 2 * P₀.card| + ((T.card : ℝ) - I.card) + ((P.card : ℝ) - I.card) calc _ = |((P.card : ℝ) - 2 * P₀.card) + (((T.card : ℝ) - I.card) - 2 * ((T₀.card : ℝ) - I₀.card)) - (((P.card : ℝ) - I.card) - 2 * ((P₀.card : ℝ) - I₀.card))| := by congr 1; ring _ ≤ |(P.card : ℝ) - 2 * P₀.card| + |((T.card : ℝ) - I.card) - 2 * ((T₀.card : ℝ) - I₀.card)| + |((P.card : ℝ) - I.card) - 2 * ((P₀.card : ℝ) - I₀.card)| := (abs_sub _ _).trans (add_le_add (abs_add_le _ _) le_rfl) _ ≤ _ := by linarith end Erdos416Proof.Simplified /- Suffix endpoint factor bounds and normal-prime / large-square pruning. These apply uniformly to the actual lower-order prefix classes. The remaining survivor count still requires the variable-gap sieve application. -/ open Filter Finset open scoped Classical Topology BigOperators namespace Erdos416Proof.FordLower open FordInner FordReciprocal FordScale FordAnalysis FordGeometry /- Original line 34185: Erdos416Proof.FordLower.targetParameter_le_one -/ theorem targetParameter_le_one (L M j : ℕ) : targetParameter L M j ≤ 1 := by unfold targetParameter split_ifs · linarith [baseLoss_nonneg M (L-j)] · norm_num /-- The terminal lower cutoff controls every earlier lower prime at its actual distance from the end; the original normalization parameter cancels out. -/ /- Original line 34193: Erdos416Proof.FordLower.innerSeed_logLog_terminal_growth -/ theorem innerSeed_logLog_terminal_growth {L M : ℕ} {t A : ℝ} (ht : 0 < t) (hA : 0 < A) {q : Fin L → ℕ} (a : Fin L) (ha : a.val+1 = L) (hx : tuplePoint t q ∈ innerSeed (targetParameter L M) a (A/t)) (idx : Fin L) : A/(4*rho^(a.val-idx.val)) ≤ logLog (q idx) := by have hxU := polytope_subset_unordered_of_le_one (targetParameter_le_one L M) hx.1.1 have hcoord := unordered_terminal_growth hxU a ha idx rw [innerSeed_tuplePoint_eq ht hA a ha hx a, innerSeed_tuplePoint_eq ht hA a ha hx idx] at hcoord have hρ : 0 < 4*rho^(a.val-idx.val) := mul_pos (by norm_num) (pow_pos rho_pos _) have hraw : logLog (q a)/(4*rho^(a.val-idx.val)) ≤ logLog (q idx) := by apply (div_le_div_iff_of_pos_right ht).mp simpa only [div_div, mul_comm] using hcoord exact (div_le_div_of_nonneg_right (innerSeed_logLog_lower ht hA a ha hx a) hρ.le).trans hraw /- Original line 34208: Erdos416Proof.FordLower.suffix_length_from_terminal_growth -/ theorem suffix_length_from_terminal_growth {d : ℕ} {t : ℝ} (h : 1/(4*rho^d) ≤ t) : (d : ℝ) ≤ 2*C*(Real.log t+Real.log 4) := by have hden : 0 < 4*rho^d := mul_pos (by norm_num) (pow_pos rho_pos _) have hinv : 0 < 1/(4*rho^d) := by positivity have hlog := Real.log_le_log hinv h rw [Real.log_div (by norm_num : (1 : ℝ) ≠ 0) hden.ne', Real.log_one, Real.log_mul (by norm_num : (4 : ℝ) ≠ 0) (pow_pos rho_pos d).ne', Real.log_pow] at hlog have hstep : -((d : ℝ)*Real.log rho) ≤ Real.log t+Real.log 4 := by linarith have hc : 0 ≤ 2*C := (mul_pos (by norm_num : (0 : ℝ) < 2) C_pos).le calc (d : ℝ) = (2*C)*(-((d : ℝ)*Real.log rho)) := by linear_combination (d : ℝ)*two_C_mul_log_rho _ ≤ _ := mul_le_mul_of_nonneg_left hstep hc /- Original line 34222: Erdos416Proof.FordLower.suffixIndex -/ def suffixIndex {k : ℕ} (j : ℕ) (idx : Fin (k-j)) : Fin k := ⟨j+idx.val, by have := idx.isLt; omega⟩ /- Original line 34225: Erdos416Proof.FordLower.suffixTuple -/ def suffixTuple {k : ℕ} (p : Fin k → ℕ) (j : ℕ) : Fin (k-j) → ℕ := fun idx => p (suffixIndex j idx) /- Original line 34228: Erdos416Proof.FordLower.suffixIndex_strictMono -/ theorem suffixIndex_strictMono {k : ℕ} (j : ℕ) : StrictMono (suffixIndex (k := k) j) := by intro idx l hil change j+idx.val < j+l.val exact Nat.add_lt_add_left hil j /- Original line 34233: Erdos416Proof.FordLower.suffixTuple_product -/ theorem suffixTuple_product {k : ℕ} (p : Fin k → ℕ) (j : ℕ) : (∏ idx, suffixTuple p j idx) = suffixProduct p j := by apply prod_bij (fun idx _ => suffixIndex j idx) · intro idx _ simp only [mem_filter, mem_univ, true_and] exact Nat.le_add_right _ _ · intro idx _ l _ hil exact (suffixIndex_strictMono j).injective hil · intro idx hi have hji : j ≤ idx.val := (mem_filter.mp hi).2 refine ⟨⟨idx.val-j, by have := idx.isLt; omega⟩, mem_univ _, ?_⟩ apply Fin.ext change j+(idx.val-j) = idx.val omega · intro idx _ rfl /- Original line 34250: Erdos416Proof.FordLower.suffixTuple_prime -/ theorem suffixTuple_prime {k : ℕ} {p : Fin k → ℕ} (hp : ∀ idx, (p idx).Prime) (j : ℕ) (idx : Fin (k-j)) : (suffixTuple p j idx).Prime := hp _ /- Original line 34253: Erdos416Proof.FordLower.suffixTuple_order -/ theorem suffixTuple_order {k : ℕ} {p : Fin k → ℕ} (ho : StrictAnti p) (j : ℕ) : StrictAnti (suffixTuple p j) := ho.comp_strictMono (suffixIndex_strictMono j) /- Original line 34256: Erdos416Proof.FordLower.suffixTuple_dvd -/ theorem suffixTuple_dvd {k : ℕ} (p : Fin k → ℕ) (j : ℕ) (idx : Fin (k-j)) : suffixTuple p j idx ∣ suffixProduct p j := by rw [← suffixTuple_product] exact dvd_prod_of_mem _ (mem_univ idx) /-- With two distinct prime divisors and the second odd, the totient of the integer already bounds the first prime. This supplies the suffix endpoint. -/ /- Original line 34263: Erdos416Proof.FordLower.prime_le_totient_of_other_odd_prime -/ theorem prime_le_totient_of_other_odd_prime {p q n : ℕ} (hn : 0 < n) (hp : p.Prime) (hq : q.Prime) (hq3 : 3 ≤ q) (hne : p ≠ q) (hpn : p ∣ n) (hqn : q ∣ n) : p ≤ n.totient := by have hcop : p.Coprime q := (hp.coprime_iff_not_dvd).mpr (by intro hd exact hne ((Nat.prime_dvd_prime_iff_eq hp hq).mp hd)) have hpq : p*q ∣ n := hcop.mul_dvd_of_dvd_of_dvd hpn hqn have hφ : (p*q).totient ∣ n.totient := Nat.totient_dvd_of_dvd hpq have hle := Nat.le_of_dvd (Nat.totient_pos.mpr hn) hφ rw [Nat.totient_mul hcop, Nat.totient_prime hp, Nat.totient_prime hq] at hle have hp2 := hp.two_le calc p ≤ (p-1)*2 := by omega _ ≤ (p-1)*(q-1) := Nat.mul_le_mul_left _ (by omega) _ ≤ _ := hle /-- A terminal-growth bound controls the number of remaining factors at the suffix's own totient endpoint, including suffixes which contain the top prime. -/ /- Original line 34281: Erdos416Proof.FordLower.suffix_card_bound -/ theorem suffix_card_bound {k : ℕ} {p : Fin k → ℕ} (hp : ∀ idx, (p idx).Prime) (ho : StrictAnti p) (hodd : ∀ idx, 3 ≤ p idx) (hgrowth : ∀ idx : Fin k, 0 < idx.val → 1/(4*rho^(k-(idx.val+1))) ≤ logLog (p idx)) (j : ℕ) {Z : ℝ} (hZ : 1 ≤ logLog Z) (hsize : ((suffixProduct p j).totient : ℝ) ≤ Z) : ((k-j : ℕ) : ℝ) ≤ 2*C*(Real.log (logLog Z)+Real.log 4)+2 := by have hlog : 0 ≤ Real.log (logLog Z) := Real.log_nonneg hZ have hconst : 0 ≤ 2*C*(Real.log (logLog Z)+Real.log 4) := mul_nonneg (mul_pos (by norm_num) C_pos).le (add_nonneg hlog (Real.log_nonneg (by norm_num))) by_cases hh : 2 ≤ k-j · let idx : Fin k := ⟨j+1, by omega⟩ let a : Fin k := ⟨j, by omega⟩ have hid : p idx ∣ suffixProduct p j := dvd_prod_of_mem _ (by simp only [mem_filter, mem_univ, true_and]; dsimp [Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, idx]; omega) have had : p a ∣ suffixProduct p j := dvd_prod_of_mem _ (by simp only [mem_filter, mem_univ, true_and]; exact le_rfl) have hne : p idx ≠ p a := by intro h have := congrArg Fin.val (ho.injective h) dsimp [Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, idx, a] at this omega have hptot := prime_le_totient_of_other_odd_prime (suffixProduct_pos hp j) (hp idx) (hp a) (hodd a) hne hid had have hpZ : (p idx : ℝ) ≤ Z := (Nat.cast_le.mpr hptot).trans hsize have hLL := logLog_mono (by exact_mod_cast (hp idx).one_lt) hpZ have h := (hgrowth idx (by dsimp [Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, idx]; omega)).trans hLL have hd := suffix_length_from_terminal_growth h have heq : k-(idx.val+1)+2 = k-j := by dsimp [Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, idx]; omega have hcast := congrArg (fun a : ℕ => (a : ℝ)) heq push_cast at hcast linarith · have hh' : ((k-j : ℕ) : ℝ) ≤ 1 := by exact_mod_cast (show k-j ≤ 1 by omega) linarith /- Original line 34317: Erdos416Proof.FordLower.suffix_factor_count_le_five_log_eventually -/ theorem suffix_factor_count_le_five_log_eventually : ∀ᶠ Z : ℝ in atTop, ∀ (k : ℕ) (p : Fin k → ℕ), (∀ idx, (p idx).Prime) → StrictAnti p → (∀ idx, 3 ≤ p idx) → (∀ idx : Fin k, 0 < idx.val → 1/(4*rho^(k-(idx.val+1))) ≤ logLog (p idx)) → ∀ j : ℕ, j < k → ((suffixProduct p j).totient : ℝ) ≤ Z → (ArithmeticFunction.cardFactors (suffixProduct p j) : ℝ) ≤ 5*Real.log (logLog Z) := by have hLL : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop have hLLL := Real.tendsto_log_atTop.comp hLL filter_upwards [hLL.eventually (eventually_ge_atTop (1 : ℝ)), hLLL.eventually (eventually_ge_atTop (2*C*Real.log 4+2))] with Z hZ hlarge intro k p hp ho hodd hg j hj hsize rw [suffixProduct_factor_count hp hj] have h := suffix_card_bound hp ho hodd hg j hZ hsize have hlog : 0 ≤ Real.log (logLog Z) := Real.log_nonneg hZ have hmul := mul_le_mul_of_nonneg_right two_C_lt_four.le hlog change 2*C*Real.log 4+2 ≤ Real.log (logLog Z) at hlarge nlinarith /- Original line 34335: Erdos416Proof.FordLower.record_fullTuple_odd -/ theorem record_fullTuple_odd {M : ℕ} {A y : ℝ} {a : Fin (coreDimension M (logLog y))} {N : ℕ} (R : PrimeProductRecord M A y a N) (hA : 1 ≤ A) (idx : Fin (coreDimension M (logLog y)+1)) : 3 ≤ R.fullTuple idx := by have hlower (l : Fin (coreDimension M (logLog y))) : 3 ≤ R.lower l := by have he₁ := Real.add_one_le_exp A have he₂ := Real.add_one_le_exp (Real.exp A) have hmin := R.lower_minimum l exact_mod_cast (show (3 : ℝ) ≤ R.lower l by linarith) cases idx using Fin.cases with | zero => exact (hlower a).trans (R.lower_separated a).le | succ idx => exact hlower idx /- Original line 34348: Erdos416Proof.FordLower.record_fullTuple_terminal_growth -/ theorem record_fullTuple_terminal_growth {M : ℕ} {A y : ℝ} {a : Fin (coreDimension M (logLog y))} {N : ℕ} (R : PrimeProductRecord M A y a N) (hA : 1 ≤ A) (ht : 0 < logLog y) (idx : Fin (coreDimension M (logLog y)+1)) (hi : 0 < idx.val) : 1/(4*rho^(coreDimension M (logLog y)+1-(idx.val+1))) ≤ logLog (R.fullTuple idx) := by cases idx using Fin.cases with | zero => simp [Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint] at hi | succ idx => have hA0 : 0 < A := lt_of_lt_of_le (by norm_num) hA have h := innerSeed_logLog_terminal_growth ht hA0 a R.terminal R.point idx have heq : a.val-idx.val = coreDimension M (logLog y)+1-(idx.succ.val+1) := by have := R.terminal simp only [Fin.val_succ] omega have hden : 0 ≤ 4*rho^(a.val-idx.val) := (mul_pos (by norm_num) (pow_pos rho_pos _)).le have hg := (div_le_div_of_nonneg_right hA hden).trans h simpa only [heq, PrimeProductRecord.fullTuple, Fin.cons_succ] using hg /-- The endpoint is quantified before the original family and every geometric parameter. Thus the estimate is uniform for the subsequent suffix count. -/ /- Original line 34368: Erdos416Proof.FordLower.record_suffix_factor_count_eventually -/ theorem record_suffix_factor_count_eventually : ∀ᶠ Z : ℝ in atTop, ∀ (M : ℕ) (A y : ℝ) (a : Fin (coreDimension M (logLog y))) (N : ℕ) (R : PrimeProductRecord M A y a N), 1 ≤ A → 0 < logLog y → ∀ j : ℕ, j < coreDimension M (logLog y)+1 → ((suffixProduct R.fullTuple j).totient : ℝ) ≤ Z → (ArithmeticFunction.cardFactors (suffixProduct R.fullTuple j) : ℝ) ≤ 5*Real.log (logLog Z) := by filter_upwards [suffix_factor_count_le_five_log_eventually] with Z hZ intro M A y a N R hA ht j hj hsize exact hZ _ R.fullTuple R.fullTuple_prime R.fullTuple_order (record_fullTuple_odd R hA) (record_fullTuple_terminal_growth R hA ht) j hj hsize /- Original line 34380: Erdos416Proof.FordLower.actual_suffix_family_data_eventually -/ theorem actual_suffix_family_data_eventually : ∀ᶠ Z : ℝ in atTop, ∀ (M : ℕ) (A y : ℝ) (a : Fin (coreDimension M (logLog y))) (F : Finset ℕ) (q : ℕ → Fin (coreDimension M (logLog y)+1) → ℕ), 1 ≤ A → 0 < logLog y → (∀ n ∈ F, ∃ R : PrimeProductRecord M A y a n, R.fullTuple = q n) → ∀ j s : ℕ, s ∈ suffixCollisionFamily F q j → (s.totient : ℝ) ≤ Z → 0 < s ∧ Squarefree s ∧ (ArithmeticFunction.cardFactors s : ℝ) ≤ 5*Real.log (logLog Z) := by filter_upwards [record_suffix_factor_count_eventually] with Z hZ intro M A y a F q hA ht hrecords j s hs hsize obtain ⟨n, hn, rfl⟩ := mem_image.mp hs obtain ⟨hnF, hnw, hdepth⟩ := mem_prefixCollisionClass.mp hn obtain ⟨R, hR⟩ := hrecords n hnF have hprod : (∏ idx, q n idx) = n := hR ▸ R.fullTuple_product have hj : j < coreDimension M (logLog y)+1 := hdepth ▸ prefixDepth_lt hprod hnw rw [← hR] at hsize ⊢ exact ⟨suffixProduct_pos R.fullTuple_prime j, suffixProduct_squarefree R.fullTuple_prime R.fullTuple_order j, hZ M A y a n R hA ht j hj hsize⟩ end Erdos416Proof.FordLower open Filter Finset Asymptotics open scoped Classical Topology BigOperators namespace Erdos416Proof.FordLower /- Original line 34410: Erdos416Proof.FordLower.SuffixAssignment.normal_of_peer -/ theorem SuffixAssignment.normal_of_peer {F : Finset ℕ} {w : ℕ → ℕ} {S : ℝ} (h : SuffixAssignment F w) (hF : ∀ n ∈ F, ∀ q : ℕ, q.Prime → q ∣ n → SNormal S q) {n : ℕ} (hn : n ∈ F) (hpeer : ∃ m ∈ F, m.totient = n.totient ∧ m ≠ n) : ∀ q : ℕ, q.Prime → q ∣ w n → SNormal S q := by obtain ⟨m, hm, hwm⟩ := h.peer n hn hpeer intro q hq hdiv rw [hwm] at hdiv exact hF m hm q hq hdiv /-- The abnormal-witness fibres are singletons once original primes have been cleaned. Their totients therefore inject into the actual exceptional set. -/ /- Original line 34422: Erdos416Proof.FordLower.SuffixAssignment.normal_failures_card_le -/ theorem SuffixAssignment.normal_failures_card_le {F : Finset ℕ} {w : ℕ → ℕ} {S Z : ℝ} (h : SuffixAssignment F w) (hZ : 0 ≤ Z) (hsize : ∀ n ∈ F, (n.totient : ℝ) ≤ Z) (hF : ∀ n ∈ F, ∀ q : ℕ, q.Prime → q ∣ n → SNormal S q) : (Rigidity.witnessNormalFailures F w S).card ≤ (nonNormalTotients S Z).card := by apply card_le_card_of_injOn (fun n => (w n).totient) · intro n hn obtain ⟨hnF, hbad⟩ := mem_filter.mp hn apply mem_filter.mpr refine ⟨(mem_totientsUpTo hZ).mpr ⟨Nat.totient_pos.mpr (h.positive n hnF), ?_, w n, h.positive n hnF, rfl⟩, w n, h.positive n hnF, rfl, hbad⟩ change ((w n).totient : ℝ) ≤ Z rw [h.equation n hnF] exact hsize n hnF · intro n hn m hm heq obtain ⟨hnF, q, hq, hqn, hqbad⟩ := mem_filter.mp hn have hmF := (mem_filter.mp hm).1 by_contra hne have hφ : m.totient = n.totient := by rw [← h.equation m hmF, ← h.equation n hnF] exact heq.symm exact hqbad (h.normal_of_peer hF hnF ⟨m, hmF, hφ, Ne.symm hne⟩ q hq hqn) /- Original line 34445: Erdos416Proof.FordLower.suffix_normal_failures_card_le -/ theorem suffix_normal_failures_card_le {F : Finset ℕ} {Z B c : ℝ} (hF : ∀ n ∈ F, 0 < n ∧ Squarefree n ∧ (n.totient : ℝ) ≤ Z ∧ (ArithmeticFunction.cardFactors n : ℝ) ≤ B*Real.log (logLog Z)) (hsize : ∀ n : ℕ, 0 < n → (n.totient : ℝ) ≤ Z → (n : ℝ) ≤ c*Z*logLog Z) : ((normalPrimeFailures F (normalityScale (logLog Z))).card : ℝ) ≤ squarefreeNonNormalCount B c Z := by apply Nat.cast_le.mpr apply card_le_card intro n hn obtain ⟨hnF, hbad⟩ := mem_filter.mp hn obtain ⟨hn0, hsq, hφ, hΩ⟩ := hF n hnF have hk : ArithmeticFunction.cardFactors n ≤ ⌊B*Real.log (logLog Z)⌋₊+1 := (Nat.le_floor hΩ).trans (Nat.le_succ _) exact mem_filter.mpr ⟨mem_Icc.mpr ⟨hn0, Nat.le_floor (hsize n hn0 hφ)⟩, hsq, hk, hbad⟩ /-- Arithmetic properties retained after normal-prime and large-square pruning. Geometric conditions remain available through membership in the original family. -/ /- Original line 34463: Erdos416Proof.FordLower.SuffixSurvivor -/ structure SuffixSurvivor (Z : ℝ) (n w : ℕ) : Prop where positive : 0 < n squarefree : Squarefree n size : (n.totient : ℝ) ≤ Z witness_pos : 0 < w equation : w.totient = n.totient not_dvd : ¬ n ∣ w largest_ne : largestPrimeFactor w ≠ largestPrimeFactor n normal_left : ∀ q : ℕ, q.Prime → q ∣ n → SNormal (normalityScale (logLog Z)) q normal_right : ∀ q : ℕ, q.Prime → q ∣ w → SNormal (normalityScale (logLog Z)) q square_witness : NoLargePrimeSquare w (Real.log Z^4) square_totient : NoLargePrimeSquare w.totient (Real.log Z^4) /-- Choose the assignment after cleaning original primes; keep that assignment unchanged when excluding bad witnesses. The bound counts original suffix integers. -/ /- Original line 34478: Erdos416Proof.FordLower.suffix_pruning_finite -/ theorem suffix_pruning_finite {Z B c : ℝ} (hZ : 0 ≤ Z) (hsize : ∀ n : ℕ, 0 < n → (n.totient : ℝ) ≤ Z → (n : ℝ) ≤ c*Z*logLog Z) (F : Finset ℕ) (hF : ∀ n ∈ F, 0 < n ∧ Squarefree n ∧ (n.totient : ℝ) ≤ Z ∧ (ArithmeticFunction.cardFactors n : ℝ) ≤ B*Real.log (logLog Z)) (hassign : ∀ G : Finset ℕ, G ⊆ F → ∃ w : ℕ → ℕ, SuffixAssignment G w) : ∃ (G : Finset ℕ) (w : ℕ → ℕ), G ⊆ F ∧ Set.InjOn w (G : Set ℕ) ∧ (∀ n ∈ G, SuffixSurvivor Z n (w n)) ∧ (F.card : ℝ) ≤ squarefreeNonNormalCount B c Z + largeSquareExceptionalCount c Z + (nonNormalTotients (normalityScale (logLog Z)) Z).card + G.card := by let S := normalityScale (logLog Z) let E₀ := normalPrimeFailures F S let F₁ := F \ E₀ have hF₁ : F₁ ⊆ F := sdiff_subset have hnF₁ (n : ℕ) (hn : n ∈ F₁) : ∀ q : ℕ, q.Prime → q ∣ n → SNormal S q := Rigidity.normal_outside_failures (mem_sdiff.mp hn).1 (mem_sdiff.mp hn).2 obtain ⟨w, hw⟩ := hassign F₁ hF₁ let E₁ := largeSquareFailures F₁ w (Real.log Z^4) let E₂ := Rigidity.witnessNormalFailures F₁ w S let G := F₁ \ (E₁ ∪ E₂) have hGF₁ : G ⊆ F₁ := sdiff_subset have hφw (n : ℕ) (hn : n ∈ F₁) : ((w n).totient : ℝ) ≤ Z := by rw [hw.equation n hn] exact (hF n (hF₁ hn)).2.2.1 have hzero : (E₀.card : ℝ) ≤ squarefreeNonNormalCount B c Z := suffix_normal_failures_card_le hF hsize have hone : (E₁.card : ℝ) ≤ largeSquareExceptionalCount c Z := by change ((largeSquareFailures F₁ w (Real.log Z^4)).card : ℝ) ≤ (largePrimeSquareBad ⌊c*Z*logLog Z⌋₊ (Real.log Z^4)).card exact Nat.cast_le.mpr (largeSquareFailures_card_le F₁ w (c*Z*logLog Z) (Real.log Z^4) hw.injective (fun n hn => ⟨hw.positive n hn, hsize (w n) (hw.positive n hn) (hφw n hn)⟩)) have htwo : (E₂.card : ℝ) ≤ (nonNormalTotients S Z).card := by exact_mod_cast hw.normal_failures_card_le hZ (fun n hn => (hF n (hF₁ hn)).2.2.1) hnF₁ refine ⟨G, w, hGF₁.trans hF₁, hw.injective.mono hGF₁, ?_, ?_⟩ · intro n hn obtain ⟨hnF₁', hnex⟩ := mem_sdiff.mp hn have hnF := hF₁ hnF₁' have hnE₁ : n ∉ E₁ := fun h => hnex (mem_union_left _ h) have hnE₂ : n ∉ E₂ := fun h => hnex (mem_union_right _ h) have hsquare := Rigidity.not_square_failure hnF₁' hnE₁ refine ⟨(hF n hnF).1, (hF n hnF).2.1, (hF n hnF).2.2.1, hw.positive n hnF₁', hw.equation n hnF₁', hw.not_dvd n hnF₁', hw.largest_ne n hnF₁', hnF₁ n hnF₁', ?_, hsquare.1, hsquare.2⟩ intro q hq hqn by_contra hbad exact hnE₂ (mem_filter.mpr ⟨hnF₁', q, hq, hqn, hbad⟩) · have hcover : F ⊆ ((E₀ ∪ E₁) ∪ E₂) ∪ G := by intro n hn by_cases h₀ : n ∈ E₀ · exact mem_union_left _ (mem_union_left _ (mem_union_left _ h₀)) by_cases h₁ : n ∈ E₁ · exact mem_union_left _ (mem_union_left _ (mem_union_right _ h₁)) by_cases h₂ : n ∈ E₂ · exact mem_union_left _ (mem_union_right _ h₂) exact mem_union_right _ (mem_sdiff.mpr ⟨mem_sdiff.mpr ⟨hn, h₀⟩, fun h => (mem_union.mp h).elim h₁ h₂⟩) have hcard : F.card ≤ E₀.card+E₁.card+E₂.card+G.card := by calc F.card ≤ (((E₀ ∪ E₁) ∪ E₂) ∪ G).card := card_le_card hcover _ ≤ ((E₀ ∪ E₁) ∪ E₂).card+G.card := card_union_le _ _ _ ≤ (E₀ ∪ E₁).card+E₂.card+G.card := by gcongr; exact card_union_le _ _ _ ≤ E₀.card+E₁.card+E₂.card+G.card := by gcongr; exact card_union_le _ _ have hcardR : (F.card : ℝ) ≤ E₀.card+E₁.card+E₂.card+G.card := by exact_mod_cast hcard exact hcardR.trans (add_le_add (add_le_add (add_le_add hzero hone) htwo) le_rfl) /-- Uniform suffix pruning at the suffix endpoint. The surviving family still needs the variable-gap sieve estimate; this theorem does not assume that count. -/ /- Original line 34545: Erdos416Proof.FordLower.suffix_pruning_eventually -/ theorem suffix_pruning_eventually {B : ℝ} (hB : 0 < B) : ∀ᶠ Z : ℝ in atTop, ∀ (F : Finset ℕ) (k : ℕ), (∀ n ∈ F, 0 < n ∧ Squarefree n ∧ ArithmeticFunction.cardFactors n = k ∧ (nontrivialPreimages n).Nonempty ∧ ∀ w ∈ nontrivialPreimages n, largestPrimeFactor w ≠ largestPrimeFactor n) → (∀ n ∈ F, (n.totient : ℝ) ≤ Z ∧ (ArithmeticFunction.cardFactors n : ℝ) ≤ B*Real.log (logLog Z)) → ∃ (G : Finset ℕ) (w : ℕ → ℕ), G ⊆ F ∧ Set.InjOn w (G : Set ℕ) ∧ (∀ n ∈ G, SuffixSurvivor Z n (w n)) ∧ (F.card : ℝ) ≤ 3*(Z/(Real.log Z*(logLog Z)^2))+G.card := by obtain ⟨c, hc, hsize⟩ := inverse_totient_bound_eventually have hT : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [hsize, (normal_prime_pruning hB hc).bound (by norm_num : (0 : ℝ) < 1), (large_prime_square_pruning hc).bound (by norm_num : (0 : ℝ) < 1), nonNormalTotients_pruning.bound (by norm_num : (0 : ℝ) < 1), eventually_gt_atTop (1 : ℝ), hT.eventually_gt_atTop 0] with Z hsize hzero hone htwo hZ hTpos intro F k hF hendpoint have hlog : 0 < Real.log Z := Real.log_pos hZ have hbase : 0 ≤ Z/(Real.log Z*(logLog Z)^2) := by positivity have hz : squarefreeNonNormalCount B c Z ≤ Z/(Real.log Z*(logLog Z)^2) := by change ‖squarefreeNonNormalCount B c Z‖ ≤ 1*‖Z/(Real.log Z*(logLog Z)^2)‖ at hzero simpa only [one_mul, Real.norm_eq_abs, abs_of_nonneg hbase, abs_of_nonneg (show 0 ≤ squarefreeNonNormalCount B c Z from Nat.cast_nonneg _)] using hzero have ho : largeSquareExceptionalCount c Z ≤ Z/(Real.log Z*(logLog Z)^2) := by change ‖largeSquareExceptionalCount c Z‖ ≤ 1*‖Z/(Real.log Z*(logLog Z)^2)‖ at hone simpa only [one_mul, Real.norm_eq_abs, abs_of_nonneg hbase, abs_of_nonneg (show 0 ≤ largeSquareExceptionalCount c Z from Nat.cast_nonneg _)] using hone have ht : ((nonNormalTotients (normalityScale (logLog Z)) Z).card : ℝ) ≤ Z/(Real.log Z*(logLog Z)^2) := by simpa only [one_mul, Real.norm_eq_abs, abs_of_nonneg hbase, abs_of_nonneg (Nat.cast_nonneg _ : (0 : ℝ) ≤ (nonNormalTotients (normalityScale (logLog Z)) Z).card)] using htwo obtain ⟨G, w, hGF, hinj, hG, hcount⟩ := suffix_pruning_finite (B := B) (by linarith) hsize F (fun n hn => ⟨(hF n hn).1, (hF n hn).2.1, (hendpoint n hn).1, (hendpoint n hn).2⟩) (fun H hHF => exists_suffix_assignment H k (fun n hn => hF n (hHF hn))) refine ⟨G, w, hGF, hinj, hG, ?_⟩ linarith end Erdos416Proof.FordLower namespace Erdos416Proof.FordLower open FordInner FordReciprocal FordScale FordAnalysis FordGeometry /- Original line 34591: Erdos416Proof.FordLower.suffixesUpTo -/ noncomputable def suffixesUpTo {k : ℕ} (F : Finset ℕ) (q : ℕ → Fin k → ℕ) (j : ℕ) (Z : ℝ) : Finset ℕ := (suffixCollisionFamily F q j).filter (fun s => (s.totient : ℝ) ≤ Z) /-- The geometric factor-count estimate and all three analytic exclusions now apply to the actual suffix family with a threshold independent of its origin. -/ /- Original line 34597: Erdos416Proof.FordLower.actual_suffix_pruning_eventually -/ theorem actual_suffix_pruning_eventually : ∀ᶠ Z : ℝ in atTop, ∀ (M : ℕ) (A y : ℝ) (a : Fin (coreDimension M (logLog y))) (F : Finset ℕ) (q : ℕ → Fin (coreDimension M (logLog y)+1) → ℕ), 1 ≤ A → 0 < logLog y → (∀ n ∈ F, ∃ R : PrimeProductRecord M A y a n, R.fullTuple = q n) → ∀ j : ℕ, ∃ (G : Finset ℕ) (w : ℕ → ℕ), G ⊆ suffixesUpTo F q j Z ∧ Set.InjOn w (G : Set ℕ) ∧ (∀ s ∈ G, SuffixSurvivor Z s (w s)) ∧ ((suffixesUpTo F q j Z).card : ℝ) ≤ 3*(Z/(Real.log Z*(logLog Z)^2))+G.card := by filter_upwards [actual_suffix_family_data_eventually, suffix_pruning_eventually (B := 5) (by norm_num)] with Z hdata hprune intro M A y a F q hA ht hrecords j have hp (n : ℕ) (hn : n ∈ F) (idx : Fin (coreDimension M (logLog y)+1)) : (q n idx).Prime := by obtain ⟨R, hR⟩ := hrecords n hn rw [← hR] exact R.fullTuple_prime idx have ho (n : ℕ) (hn : n ∈ F) : StrictAnti (q n) := by obtain ⟨R, hR⟩ := hrecords n hn rw [← hR] exact R.fullTuple_order have hprod (n : ℕ) (hn : n ∈ F) : (∏ idx, q n idx) = n := by obtain ⟨R, hR⟩ := hrecords n hn rw [← hR] exact R.fullTuple_product apply hprune (suffixesUpTo F q j Z) (coreDimension M (logLog y)+1-j) · intro s hs exact suffixCollisionFamily_properties F q hp ho hprod j (mem_filter.mp hs).1 · intro s hs obtain ⟨hsF, hsZ⟩ := mem_filter.mp hs exact ⟨hsZ, (hdata M A y a F q hA ht hrecords j s hsF hsZ).2.2⟩ end Erdos416Proof.FordLower /- The actual strict facet at every lower-order suffix endpoint, including the full tuple and the one-prime suffix, in the existing sieve convention. -/ open Filter Finset Asymptotics open scoped Classical Topology BigOperators namespace Erdos416Proof.FordLower open FordInner FordReciprocal FordScale FordAnalysis FordGeometry /-- The special last row of Ford's polytope is stronger than the row with the usual first Ford coefficient. This covers a suffix of just two primes. -/ /- Original line 34649: Erdos416Proof.FordLower.ford_tail_weight_le -/ theorem ford_tail_weight_le {L : ℕ} (idx j : Fin L) : (if idx.val < j.val then fordWeight (j.val-idx.val) else 0) ≤ tailWeight idx j := by by_cases hij : idx.val < j.val · by_cases hi : idx.val+2 < L · simp only [tailWeight, if_pos hij, if_pos hi, le_refl] · have hdiff : j.val-idx.val = 1 := by have := j.isLt; omega simp only [tailWeight, if_pos hij, if_neg hi, hdiff] have h := (fordWeight_bounds (by norm_num : 1 ≤ 1)).2 have hlog := Real.log_le_sub_one_of_pos (by norm_num : (0 : ℝ) < 2) norm_num only [Nat.cast_one, one_add_one_eq_two] at h linarith · simp only [tailWeight, if_neg hij, le_refl] /- Original line 34662: Erdos416Proof.FordLower.weighted_tail_le_tailForm -/ theorem weighted_tail_le_tailForm {L : ℕ} {x : Fin L → ℝ} (hx : ∀ j, 0 ≤ x j) (idx : Fin L) : (∑ j : Fin L, (if idx.val < j.val then fordWeight (j.val-idx.val) else 0)*x j) ≤ tailForm idx x := by change _ ≤ ∑ j : Fin L, tailWeight idx j*x j apply sum_le_sum intro j _ exact mul_le_mul_of_nonneg_right (ford_tail_weight_le idx j) (hx j) /-- The original normalized row gives an unnormalized logarithmic facet; the original endpoint cancels exactly. -/ /- Original line 34672: Erdos416Proof.FordLower.innerSeed_logLog_tail_bound -/ theorem innerSeed_logLog_tail_bound {L M : ℕ} {t A : ℝ} (ht : 0 < t) (hA : 0 < A) {q : Fin L → ℕ} (a : Fin L) (ha : a.val+1 = L) (hx : tuplePoint t q ∈ innerSeed (targetParameter L M) a (A/t)) (idx : Fin L) (hi : idx.val+1 < L) : (∑ j : Fin L, (if idx.val < j.val then fordWeight (j.val-idx.val) else 0)*logLog (q j)) ≤ targetParameter L M (idx.val+1)*logLog (q idx) := by have h := (weighted_tail_le_tailForm hx.1.1.1 idx).trans (hx.1.1.2.2.2.2 idx hi) simp only [innerSeed_tuplePoint_eq ht hA a ha hx, ← mul_div_assoc, ← sum_div] at h exact (div_le_div_iff_of_pos_right ht).mp h /- Original line 34683: Erdos416Proof.FordLower.innerSeed_normalized_tail_bound -/ theorem innerSeed_normalized_tail_bound {L M : ℕ} {t A Z : ℝ} (hM : 2 ≤ M) (ht : 0 < t) (hA : 0 < A) {q : Fin L → ℕ} (a : Fin L) (ha : a.val+1 = L) (hx : tuplePoint t q ∈ innerSeed (targetParameter L M) a (A/t)) (idx : Fin L) (hi : idx.val+1 < L) (hZ : 0 < logLog Z) (hqi : (1 : ℝ) < q idx) (hqZ : (q idx : ℝ) ≤ Z) : (∑ j : Fin L, (if idx.val < j.val then fordWeight (j.val-idx.val) else 0)* (logLog (q j)/logLog Z)) ≤ 1-baseLoss M (L-(idx.val+1)) := by have h := (innerSeed_logLog_tail_bound ht hA a ha hx idx hi).trans (mul_le_mul_of_nonneg_left (logLog_mono hqi hqZ) (targetParameter_bounds hM L (idx.val+1)).1.le) simp only [← mul_div_assoc, ← sum_div] calc _ ≤ (targetParameter L M (idx.val+1)*logLog Z)/logLog Z := div_le_div_of_nonneg_right h hZ.le _ = _ := by rw [mul_div_cancel_right₀ _ hZ.ne']; simp only [targetParameter, if_pos hi] /-- The variable margin at a suffix is eventually larger than the fixed power margin already supported by the checked sieve exponent. -/ /- Original line 34701: Erdos416Proof.FordLower.baseLoss_ge_two_rpow_eventually -/ theorem baseLoss_ge_two_rpow_eventually {K : ℝ} (hK : 0 < K) : ∀ᶠ T : ℝ in atTop, ∀ M d : ℕ, 0 < M+d → ((M+d : ℕ) : ℝ) ≤ K*Real.log T → 2*T^(-1/8 : ℝ) ≤ baseLoss M d := by let c : ℝ := 1/(20*K^3) have hc : 0 < c := by dsimp [c]; positivity filter_upwards [(isLittleO_log_rpow_rpow_atTop (3 : ℝ) (by norm_num : (0 : ℝ) < 1/8)).bound hc, eventually_gt_atTop (1 : ℝ)] with T hb hT have hT0 : 0 < T := by linarith have hlog : 0 ≤ Real.log T := (Real.log_pos hT).le have hpower : 0 < T^(1/8 : ℝ) := Real.rpow_pos_of_pos hT0 _ change ‖(Real.log T)^(3 : ℝ)‖ ≤ c*‖T^(1/8 : ℝ)‖ at hb rw [show (3 : ℝ) = (3 : ℕ) by norm_num, Real.rpow_natCast, Real.norm_eq_abs, abs_of_nonneg (pow_nonneg hlog 3), Real.norm_eq_abs, abs_of_pos hpower] at hb have hpoly : 20*(K*Real.log T)^3 ≤ T^(1/8 : ℝ) := by calc _ = (20*K^3)*(Real.log T)^3 := by ring _ ≤ (20*K^3)*(c*T^(1/8 : ℝ)) := mul_le_mul_of_nonneg_left hb (by positivity) _ = _ := by dsimp [c]; field_simp intro M d hMd hsum have hsum0 : 0 < ((M+d : ℕ) : ℝ) := by exact_mod_cast hMd have hcube := pow_le_pow_left₀ hsum0.le hsum 3 have hden : 0 < 10*((M+d : ℕ) : ℝ)^3 := by positivity have hdenle : 2*(10*((M+d : ℕ) : ℝ)^3) ≤ T^(1/8 : ℝ) := by nlinarith rw [baseLoss, show (-1/8 : ℝ) = -(1/8 : ℝ) by norm_num, Real.rpow_neg hT0.le, ← div_eq_mul_inv] exact (div_le_div_iff₀ hpower hden).mpr (by simpa only [one_mul] using hdenle) /- Original line 34728: Erdos416Proof.FordLower.record_proper_suffix_head_le_totient -/ theorem record_proper_suffix_head_le_totient {M : ℕ} {A y : ℝ} {a : Fin (coreDimension M (logLog y))} {N : ℕ} (R : PrimeProductRecord M A y a N) (hA : 1 ≤ A) (idx : Fin (coreDimension M (logLog y))) (hi : idx.val+1 < coreDimension M (logLog y)) : R.lower idx ≤ (suffixProduct R.fullTuple (idx.val+1)).totient := by have hia : idx < a := by change idx.val < a.val; have := R.terminal; omega have hdiv (l : Fin (coreDimension M (logLog y))) (hl : idx.val ≤ l.val) : R.lower l ∣ suffixProduct R.fullTuple (idx.val+1) := by change R.fullTuple l.succ ∣ ∏ j ∈ univ.filter (fun j => idx.val+1 ≤ j.val), R.fullTuple j apply dvd_prod_of_mem simp only [mem_filter, mem_univ, true_and, Fin.val_succ] omega exact prime_le_totient_of_other_odd_prime (suffixProduct_pos R.fullTuple_prime _) (R.lower_prime idx) (R.lower_prime a) (record_fullTuple_odd R hA a.succ) (R.lower_order hia).ne' (hdiv idx le_rfl) (hdiv a hia.le) /- Original line 34744: Erdos416Proof.FordLower.record_proper_suffix_normalized_facet -/ theorem record_proper_suffix_normalized_facet {M : ℕ} {A y Z : ℝ} {a : Fin (coreDimension M (logLog y))} {N : ℕ} (R : PrimeProductRecord M A y a N) (hM : 2 ≤ M) (hA : 1 ≤ A) (ht : 0 < logLog y) (idx : Fin (coreDimension M (logLog y))) (hi : idx.val+1 < coreDimension M (logLog y)) (hZ : 0 < logLog Z) (hsize : ((suffixProduct R.fullTuple (idx.val+1)).totient : ℝ) ≤ Z) : (∑ j : Fin (coreDimension M (logLog y)), (if idx.val < j.val then fordWeight (j.val-idx.val) else 0)*(logLog (R.lower j)/logLog Z)) ≤ 1-baseLoss M (coreDimension M (logLog y)-(idx.val+1)) := by apply innerSeed_normalized_tail_bound hM ht (lt_of_lt_of_le (by norm_num) hA) a R.terminal R.point idx hi hZ · exact_mod_cast (R.lower_prime idx).one_lt · exact (Nat.cast_le.mpr (record_proper_suffix_head_le_totient R hA idx hi)).trans hsize /-- The actual proper suffix retains twice the margin used by the existing strict-facet sieve estimate, uniformly in its original parameters. -/ /- Original line 34759: Erdos416Proof.FordLower.record_proper_suffix_facet_eventually -/ theorem record_proper_suffix_facet_eventually : ∀ᶠ Z : ℝ in atTop, ∀ (M : ℕ) (A y : ℝ) (a : Fin (coreDimension M (logLog y))) (N : ℕ) (R : PrimeProductRecord M A y a N), 2 ≤ M → 1 ≤ A → 0 < logLog y → (M : ℝ) ≤ 10*Real.log (logLog Z) → ∀ idx : Fin (coreDimension M (logLog y)), idx.val+1 < coreDimension M (logLog y) → ((suffixProduct R.fullTuple (idx.val+1)).totient : ℝ) ≤ Z → (∑ j : Fin (coreDimension M (logLog y)), (if idx.val < j.val then fordWeight (j.val-idx.val) else 0)*(logLog (R.lower j)/logLog Z)) ≤ 1-2*(logLog Z)^(-1/8 : ℝ) := by have hLL : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [record_suffix_factor_count_eventually, hLL.eventually (baseLoss_ge_two_rpow_eventually (K := 15) (by norm_num)), hLL.eventually_gt_atTop 0] with Z hcount hbase hZ intro M A y a N R hM hA ht hMsize idx hi hsize have hj : idx.val+1 < coreDimension M (logLog y)+1 := by omega have hΩ := hcount M A y a N R hA ht (idx.val+1) hj hsize rw [suffixProduct_factor_count R.fullTuple_prime hj] at hΩ have hdim : ((M+(coreDimension M (logLog y)-(idx.val+1)) : ℕ) : ℝ) ≤ (M : ℝ)+(coreDimension M (logLog y)+1-(idx.val+1) : ℕ) := by norm_cast omega have hsmall := hbase M (coreDimension M (logLog y)-(idx.val+1)) (by omega) (by linarith : ((M+(coreDimension M (logLog y)-(idx.val+1)) : ℕ) : ℝ) ≤ 15*Real.log (logLog Z)) exact (record_proper_suffix_normalized_facet R hM hA ht idx hi hZ hsize).trans (by linarith) end Erdos416Proof.FordLower namespace Erdos416Proof.FordLower open FordInner FordReciprocal FordScale FordAnalysis FordGeometry /- Original line 34791: Erdos416Proof.FordLower.innerSeed_logLog_outer_bound -/ theorem innerSeed_logLog_outer_bound {L M : ℕ} {t A : ℝ} (ht : 0 < t) (hA : 0 < A) {q : Fin L → ℕ} (a : Fin L) (ha : a.val+1 = L) (hx : tuplePoint t q ∈ innerSeed (targetParameter L M) a (A/t)) : (∑ j : Fin L, fordWeight (j.val+1)*logLog (q j)) ≤ targetParameter L M 0*t := by have h := hx.1.1.2.2.2.1 change (∑ j : Fin L, fordWeight (j.val+1)*tuplePoint t q j) ≤ _ at h simp only [innerSeed_tuplePoint_eq ht hA a ha hx, ← mul_div_assoc, ← sum_div] at h exact (div_le_iff₀ ht).mp h /-- The uncut tuple has its totient near its original endpoint. If that endpoint exceeds Z, their double logarithms still differ by at most one. -/ /- Original line 34803: Erdos416Proof.FordLower.record_endpoint_logLog_eventually -/ theorem record_endpoint_logLog_eventually : ∀ᶠ Z : ℝ in atTop, ∀ (M : ℕ) (A y : ℝ) (a : Fin (coreDimension M (logLog y))) (N : ℕ) (_R : PrimeProductRecord M A y a N), 1 < y → (N.totient : ℝ) ≤ Z → logLog y ≤ logLog Z+1 := by obtain ⟨y₀, hy₀⟩ := eventually_atTop.mp (coreLowerFraction_lower_rpow (η := 1/20) (by norm_num)) filter_upwards [eventually_ge_atTop y₀] with Z hZ intro M A y a N R hy hsize by_cases hyZ : y ≤ Z · have h := logLog_mono hy hyZ linarith · have hy0 : 0 < y := by linarith have hfrac := hy₀ y (hZ.trans (le_of_not_ge hyZ)) have hpow : y^(19/20 : ℝ) < (N.totient : ℝ) := by calc _ = y^(-1/20 : ℝ)*y := by rw [show (19/20 : ℝ) = (-1/20 : ℝ)+1 by norm_num, Real.rpow_add hy0, Real.rpow_one] _ ≤ coreLowerFraction y*y := by simpa only [neg_div] using mul_le_mul_of_nonneg_right hfrac hy0.le _ < _ := R.totient_range.1 have hN1 : (1 : ℝ) < N.totient := (Real.one_lt_rpow hy (by norm_num : (0 : ℝ) < 19/20)).trans hpow have h := (large_prime_logLog_lower hy hpow).trans (logLog_mono hN1 hsize) linarith /-- The full-tuple class also has the required margin at its own endpoint. The second half of the variable margin absorbs the endpoint change. -/ /- Original line 34829: Erdos416Proof.FordLower.record_full_suffix_facet_eventually -/ theorem record_full_suffix_facet_eventually : ∀ᶠ Z : ℝ in atTop, ∀ (M : ℕ) (A y : ℝ) (a : Fin (coreDimension M (logLog y))) (N : ℕ) (R : PrimeProductRecord M A y a N), 2 ≤ M → 1 ≤ A → 1 < y → 0 < logLog y → (M : ℝ) ≤ 10*Real.log (logLog Z) → (N.totient : ℝ) ≤ Z → (∑ j : Fin (coreDimension M (logLog y)), fordWeight (j.val+1)* (logLog (R.lower j)/logLog Z)) ≤ 1-(logLog Z)^(-1/8 : ℝ) := by have hLL : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [record_endpoint_logLog_eventually, record_suffix_factor_count_eventually, hLL.eventually (baseLoss_ge_two_rpow_eventually (K := 15) (by norm_num)), hLL.eventually_ge_atTop 1] with Z hendpoint hcount hbase hZ intro M A y a N R hM hA hy ht hMsize hsize let L := coreDimension M (logLog y) have hL : 0 < L := by have := a.isLt; dsimp [Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, L]; omega have hprod : suffixProduct R.fullTuple 0 = N := by simpa only [prefixProduct_zero, one_mul] using (prefix_mul_suffix R.fullTuple 0).trans R.fullTuple_product have hsize' : ((suffixProduct R.fullTuple 0).totient : ℝ) ≤ Z := hprod.symm ▸ hsize have hΩ := hcount M A y a N R hA ht 0 (by omega) hsize' rw [suffixProduct_factor_count R.fullTuple_prime (by omega), Nat.sub_zero] at hΩ have hdim : ((M+L : ℕ) : ℝ) ≤ 15*Real.log (logLog Z) := by change ((M+coreDimension M (logLog y) : ℕ) : ℝ) ≤ _ push_cast at hΩ ⊢ linarith have hmargin := hbase M L (by omega) hdim have hparam := targetParameter_bounds hM L 0 have hpe : targetParameter L M 0 = 1-baseLoss M L := by simp only [targetParameter, if_pos hL, Nat.sub_zero] have hraw := innerSeed_logLog_outer_bound ht (lt_of_lt_of_le (by norm_num) hA) a R.terminal R.point have hraw' := hraw.trans (mul_le_mul_of_nonneg_left (hendpoint M A y a N R hy hsize) hparam.1.le) have hZ0 : 0 < logLog Z := by linarith have hinv : 1/logLog Z ≤ (logLog Z)^(-1/8 : ℝ) := by have h := Real.rpow_le_rpow_of_exponent_le hZ (by norm_num : (-1 : ℝ) ≤ -1/8) simpa only [Real.rpow_neg_one, one_div] using h simp only [← mul_div_assoc, ← sum_div] calc _ ≤ (targetParameter L M 0*(logLog Z+1))/logLog Z := div_le_div_of_nonneg_right hraw' hZ0.le _ = targetParameter L M 0+targetParameter L M 0/logLog Z := by field_simp _ ≤ targetParameter L M 0+1/logLog Z := add_le_add le_rfl (div_le_div_of_nonneg_right hparam.2 hZ0.le) _ ≤ _ := by rw [hpe]; linarith end Erdos416Proof.FordLower open Filter Finset open scoped Classical Topology BigOperators namespace Erdos416Proof.FordLower open FordGeometry /-- An exact reindexing into the outer-form convention used by the sieve. -/ /- Original line 34882: Erdos416Proof.FordLower.suffix_outerForm_eq_tail -/ theorem suffix_outerForm_eq_tail {L : ℕ} (x : Fin L → ℝ) (idx : Fin L) : outerForm (L-(idx.val+1)) (fun j => x (suffixIndex (idx.val+1) j)) = ∑ j : Fin L, (if idx.val < j.val then fordWeight (j.val-idx.val) else 0)*x j := by have hright : (∑ j : Fin L, (if idx.val < j.val then fordWeight (j.val-idx.val) else 0)*x j) = ∑ j ∈ univ.filter (fun j : Fin L => idx.val < j.val), fordWeight (j.val-idx.val)*x j := by rw [sum_filter] apply sum_congr rfl intro j _ split_ifs <;> simp[Erdos416Proof.FordAnalysis.coeff_zero] rw [hright] change (∑ j : Fin (L-(idx.val+1)), fordWeight (j.val+1)*x (suffixIndex (idx.val+1) j)) = _ apply sum_bij (fun j _ => suffixIndex (idx.val+1) j) · intro j _ simp only [mem_filter, mem_univ, true_and] dsimp [Erdos416Proof.FordAnalysis.coeff_zero, suffixIndex] omega · intro j _ l _ heq exact (suffixIndex_strictMono (idx.val+1)).injective heq · intro j hj have hji := (mem_filter.mp hj).2 refine ⟨⟨j.val-(idx.val+1), by have := j.isLt; omega⟩, mem_univ _, ?_⟩ apply Fin.ext dsimp [Erdos416Proof.FordAnalysis.coeff_zero, suffixIndex] omega · intro j _ change fordWeight (j.val+1)*x (suffixIndex (idx.val+1) j) = fordWeight (idx.val+1+j.val-idx.val)*x (suffixIndex (idx.val+1) j) rw [show idx.val+1+j.val-idx.val = j.val+1 by omega] /- Original line 34911: Erdos416Proof.FordLower.properSuffixTuple -/ def properSuffixTuple {L : ℕ} (q : Fin L → ℕ) (idx : Fin L) : Fin (L-(idx.val+1)+1) → ℕ := Fin.cons (q idx) (suffixTuple q (idx.val+1)) /- Original line 34914: Erdos416Proof.FordLower.properSuffixTuple_prime -/ theorem properSuffixTuple_prime {L : ℕ} {q : Fin L → ℕ} (hq : ∀ idx, (q idx).Prime) (idx : Fin L) (j : Fin (L-(idx.val+1)+1)) : (properSuffixTuple q idx j).Prime := by cases j using Fin.cases with | zero => exact hq idx | succ j => exact suffixTuple_prime hq _ j /- Original line 34920: Erdos416Proof.FordLower.properSuffixTuple_order -/ theorem properSuffixTuple_order {L : ℕ} {q : Fin L → ℕ} (hq : StrictAnti q) (idx : Fin L) : StrictAnti (properSuffixTuple q idx) := by intro a b hab cases a using Fin.cases with | zero => cases b using Fin.cases with | zero => exact (lt_irrefl (0 : Fin (L-(idx.val+1)+1)) hab).elim | succ b => apply hq change idx.val < idx.val+1+b.val omega | succ a => cases b using Fin.cases with | zero => have h : a.val+1 < 0 := hab; omega | succ b => exact suffixTuple_order hq _ (Fin.succ_lt_succ_iff.mp hab) /- Original line 34936: Erdos416Proof.FordLower.properSuffixTuple_product -/ theorem properSuffixTuple_product {L : ℕ} {q : Fin L → ℕ} (hq : ∀ idx, (q idx).Prime) (idx : Fin L) : (∏ j, properSuffixTuple q idx j) = suffixProduct q idx.val := by simp only [Fin.prod_univ_succ, properSuffixTuple, Fin.cons_zero, Fin.cons_succ, suffixTuple_product] have h₀ := prefix_mul_suffix q idx.val have h₁ := prefix_mul_suffix q (idx.val+1) rw [prefixProduct_succ q idx.isLt] at h₁ apply Nat.eq_of_mul_eq_mul_left (prefixProduct_pos hq idx.val) rw [← mul_assoc] exact h₁.trans h₀.symm /- Original line 34947: Erdos416Proof.FordLower.suffixProduct_cons_succ -/ theorem suffixProduct_cons_succ {L : ℕ} (P : ℕ) (q : Fin L → ℕ) (j : ℕ) : suffixProduct (Fin.cons P q) (j+1) = suffixProduct q j := by simp [suffixProduct, prod_filter, Fin.prod_univ_succ] /- Original line 34951: Erdos416Proof.FordLower.properSuffixTuple_facet -/ theorem properSuffixTuple_facet {L : ℕ} (q : Fin L → ℕ) (idx : Fin L) (T : ℝ) : (∑ j ∈ Icc 1 (L-(idx.val+1)), fordWeight j * CollisionFacet.extend (fun k => CollisionBox.primeCoordinate T (properSuffixTuple q idx k)) j) = ∑ j : Fin L, (if idx.val < j.val then fordWeight (j.val-idx.val) else 0)*(logLog (q j)/T) := by rw [← outerForm_eq_extended_sum] change outerForm (L-(idx.val+1)) (fun j => logLog (q (suffixIndex (idx.val+1) j))/T) = _ exact suffix_outerForm_eq_tail (fun j => logLog (q j)/T) idx end Erdos416Proof.FordLower namespace Erdos416Proof.FordLower open FordInner FordReciprocal FordScale FordAnalysis FordGeometry /- Original line 34966: Erdos416Proof.FordLower.record_properSuffixTuple_integer -/ theorem record_properSuffixTuple_integer {M : ℕ} {A y : ℝ} {a : Fin (coreDimension M (logLog y))} {N : ℕ} (R : PrimeProductRecord M A y a N) (idx : Fin (coreDimension M (logLog y))) : (∏ j, properSuffixTuple R.lower idx j) = suffixProduct R.fullTuple (idx.val+1) := by rw [PrimeProductRecord.fullTuple, suffixProduct_cons_succ] exact properSuffixTuple_product R.lower_prime idx /- Original line 34973: Erdos416Proof.FordLower.record_properSuffixTuple_largest -/ theorem record_properSuffixTuple_largest {M : ℕ} {A y : ℝ} {a : Fin (coreDimension M (logLog y))} {N : ℕ} (R : PrimeProductRecord M A y a N) (idx : Fin (coreDimension M (logLog y))) : largestPrimeFactor (suffixProduct R.fullTuple (idx.val+1)) = properSuffixTuple R.lower idx 0 := by rw [PrimeProductRecord.fullTuple, suffixProduct_cons_succ, largestPrimeFactor_suffixProduct R.lower_prime R.lower_order idx.isLt] rfl /- Original line 34981: Erdos416Proof.FordLower.record_fullTuple_sieve_facet_eventually -/ theorem record_fullTuple_sieve_facet_eventually : ∀ᶠ Z : ℝ in atTop, ∀ (M : ℕ) (A y : ℝ) (a : Fin (coreDimension M (logLog y))) (N : ℕ) (R : PrimeProductRecord M A y a N), 2 ≤ M → 1 ≤ A → 1 < y → 0 < logLog y → (M : ℝ) ≤ 10*Real.log (logLog Z) → (N.totient : ℝ) ≤ Z → (∑ j ∈ Icc 1 (coreDimension M (logLog y)), fordWeight j * CollisionFacet.extend (fun k => CollisionBox.primeCoordinate (logLog Z) (R.fullTuple k)) j) ≤ 1-(logLog Z)^(-1/8 : ℝ) := by filter_upwards [record_full_suffix_facet_eventually] with Z hZ intro M A y a N R hM hA hy ht hMsize hsize rw [← outerForm_eq_extended_sum] change (∑ j, fordWeight (j.val+1)*(logLog (R.lower j)/logLog Z)) ≤ _ exact hZ M A y a N R hM hA hy ht hMsize hsize /-- Includes the one-prime suffix, whose lower-coordinate facet is empty. -/ /- Original line 34995: Erdos416Proof.FordLower.record_properSuffixTuple_sieve_facet_eventually -/ theorem record_properSuffixTuple_sieve_facet_eventually : ∀ᶠ Z : ℝ in atTop, ∀ (M : ℕ) (A y : ℝ) (a : Fin (coreDimension M (logLog y))) (N : ℕ) (R : PrimeProductRecord M A y a N), 2 ≤ M → 1 ≤ A → 0 < logLog y → (M : ℝ) ≤ 10*Real.log (logLog Z) → ∀ idx : Fin (coreDimension M (logLog y)), ((suffixProduct R.fullTuple (idx.val+1)).totient : ℝ) ≤ Z → (∑ j ∈ Icc 1 (coreDimension M (logLog y)-(idx.val+1)), fordWeight j * CollisionFacet.extend (fun k => CollisionBox.primeCoordinate (logLog Z) (properSuffixTuple R.lower idx k)) j) ≤ 1-(logLog Z)^(-1/8 : ℝ) := by have hLL : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [record_proper_suffix_facet_eventually, hLL.eventually_ge_atTop 1] with Z hfacet hZ intro M A y a N R hM hA ht hMsize idx hsize by_cases hi : idx.val+1 < coreDimension M (logLog y) · rw [properSuffixTuple_facet] have h := hfacet M A y a N R hM hA ht hMsize idx hi hsize have hpow := Real.rpow_nonneg (by linarith : 0 ≤ logLog Z) (-1/8 : ℝ) linarith · have heq : coreDimension M (logLog y)-(idx.val+1) = 0 := by omega have hpow := Real.rpow_le_one_of_one_le_of_nonpos hZ (by norm_num : (-1/8 : ℝ) ≤ 0) simpa only [heq, Icc_eq_empty_of_lt (by norm_num : 0 < (1 : ℕ)), sum_empty, sub_nonneg] using hpow end Erdos416Proof.FordLower /- Variable suffix gaps, numerical matching margins, and collision class counts allowing the entire left tuple to be in the matched prefix. -/ open Filter Finset Asymptotics open scoped Classical Topology BigOperators namespace Erdos416Proof.FordLower open FordInner FordReciprocal FordScale FordAnalysis FordGeometry /-- Keep an arbitrary positive power available for the box-separation budget; the facet's fixed eighth-power weakening would lose too much here. -/ /- Original line 35036: Erdos416Proof.FordLower.baseLoss_ge_power_eventually -/ theorem baseLoss_ge_power_eventually {K η : ℝ} (hK : 0 < K) (hη : 0 < η) : ∀ᶠ T : ℝ in atTop, ∀ M d : ℕ, 0 < M+d → ((M+d : ℕ) : ℝ) ≤ K*Real.log T → T^(-η) ≤ baseLoss M d := by let c : ℝ := 1/(10*K^3) have hc : 0 < c := by dsimp [c]; positivity filter_upwards [(isLittleO_log_rpow_rpow_atTop (3 : ℝ) hη).bound hc, eventually_gt_atTop (1 : ℝ)] with T hb hT have hT0 : 0 < T := by linarith have hlog : 0 ≤ Real.log T := (Real.log_pos hT).le have hpower : 0 < T^η := Real.rpow_pos_of_pos hT0 _ change ‖(Real.log T)^(3 : ℝ)‖ ≤ c*‖T^η‖ at hb rw [show (3 : ℝ) = (3 : ℕ) by norm_num, Real.rpow_natCast, Real.norm_eq_abs, abs_of_nonneg (pow_nonneg hlog 3), Real.norm_eq_abs, abs_of_pos hpower] at hb have hpoly : 10*(K*Real.log T)^3 ≤ T^η := by calc _ = (10*K^3)*(Real.log T)^3 := by ring _ ≤ (10*K^3)*(c*T^η) := mul_le_mul_of_nonneg_left hb (by positivity) _ = _ := by dsimp [c]; field_simp intro M d hMd hsum have hsum0 : 0 < ((M+d : ℕ) : ℝ) := by exact_mod_cast hMd have hcube := pow_le_pow_left₀ hsum0.le hsum 3 have hden : 0 < 10*((M+d : ℕ) : ℝ)^3 := by positivity have hdenle : 10*((M+d : ℕ) : ℝ)^3 ≤ T^η := by nlinarith rw [baseLoss, Real.rpow_neg hT0.le, ← one_div] exact div_le_div_of_nonneg_left (by norm_num) hden hdenle /- Original line 35062: Erdos416Proof.FordLower.baseLoss_antitone_right -/ theorem baseLoss_antitone_right {M : ℕ} (hM : 0 < M) : Antitone (baseLoss M) := by intro a b hab have ha : (0 : ℝ) < (M+a : ℕ) := by exact_mod_cast (show 0 < M+a by omega) have hab' : ((M+a : ℕ) : ℝ) ≤ (M+b : ℕ) := by exact_mod_cast Nat.add_le_add_left hab M unfold baseLoss exact div_le_div_of_nonneg_left (by norm_num) (by positivity) (mul_le_mul_of_nonneg_left (pow_le_pow_left₀ ha.le hab' 3) (by norm_num)) /- Original line 35070: Erdos416Proof.FordLower.record_dimension_add -/ theorem record_dimension_add {M : ℕ} {A y : ℝ} {a : Fin (coreDimension M (logLog y))} {N : ℕ} (_R : PrimeProductRecord M A y a N) : M+coreDimension M (logLog y) = optimalDimension (logLog y) := by have := a.isLt unfold coreDimension at * omega /- Original line 35077: Erdos416Proof.FordLower.record_topLoss_eq_baseLoss -/ theorem record_topLoss_eq_baseLoss {M : ℕ} {A y : ℝ} {a : Fin (coreDimension M (logLog y))} {N : ℕ} (R : PrimeProductRecord M A y a N) : topLoss (logLog y) = baseLoss M (coreDimension M (logLog y)) := by simp only [topLoss, baseLoss, record_dimension_add R] /-- The exact varying loss on each adjacent pair of the full tuple, including the leading pair, is retained before any endpoint weakening. -/ /- Original line 35084: Erdos416Proof.FordLower.record_fullTuple_adjacent_baseLoss -/ theorem record_fullTuple_adjacent_baseLoss {M : ℕ} {A y : ℝ} {a : Fin (coreDimension M (logLog y))} {N : ℕ} (R : PrimeProductRecord M A y a N) (idx j : Fin (coreDimension M (logLog y)+1)) (hij : j.val = idx.val+1) : (1+baseLoss M (coreDimension M (logLog y)+1-(idx.val+1)))*logLog (R.fullTuple j) ≤ logLog (R.fullTuple idx) := by cases idx using Fin.cases with | zero => cases j using Fin.cases with | zero => simp [Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint] at hij | succ j => have hj : j.val = 0 := by simp only [Fin.val_succ, Fin.val_zero] at hij omega have h := R.leading_gap j hj simpa only [record_topLoss_eq_baseLoss R, Fin.val_zero, zero_add, Nat.add_sub_cancel, PrimeProductRecord.fullTuple, Fin.cons_succ, Fin.cons_zero] using h | succ idx => cases j using Fin.cases with | zero => have h : 0 = idx.val+1+1 := hij; omega | succ j => have hj : j.val = idx.val+1 := by simpa only [Fin.val_succ, Nat.add_right_cancel_iff] using hij have heq : coreDimension M (logLog y)+1-(idx.succ.val+1) = coreDimension M (logLog y)-(idx.val+1) := by simp only [Fin.val_succ]; omega simpa only [heq, PrimeProductRecord.fullTuple, Fin.cons_succ] using R.lower_gaps idx j hj /- Original line 35109: Erdos416Proof.FordLower.record_fullTuple_logLog_nonneg -/ theorem record_fullTuple_logLog_nonneg {M : ℕ} {A y : ℝ} {a : Fin (coreDimension M (logLog y))} {N : ℕ} (R : PrimeProductRecord M A y a N) (hA : 1 ≤ A) (idx : Fin (coreDimension M (logLog y)+1)) : 0 ≤ logLog (R.fullTuple idx) := logLog_nonneg (Real.exp_one_lt_three.le.trans (Nat.cast_le.mpr (record_fullTuple_odd R hA idx))) /- Original line 35114: Erdos416Proof.FordLower.record_suffix_gap_eventually -/ theorem record_suffix_gap_eventually {η : ℝ} (hη : 0 < η) : ∀ᶠ Z : ℝ in atTop, ∀ (M : ℕ) (A y : ℝ) (a : Fin (coreDimension M (logLog y))) (N : ℕ) (R : PrimeProductRecord M A y a N), 2 ≤ M → 1 ≤ A → 0 < logLog y → (M : ℝ) ≤ 10*Real.log (logLog Z) → ∀ b : ℕ, b < coreDimension M (logLog y)+1 → ((suffixProduct R.fullTuple b).totient : ℝ) ≤ Z → ∀ idx j : Fin (coreDimension M (logLog y)+1), b ≤ idx.val → j.val = idx.val+1 → (1+(logLog Z)^(-η))*logLog (R.fullTuple j) ≤ logLog (R.fullTuple idx) := by have hLL : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [record_suffix_factor_count_eventually, hLL.eventually (baseLoss_ge_power_eventually (K := 15) (by norm_num) hη)] with Z hcount hbase intro M A y a N R hM hA ht hMsize b hb hsize idx j hbi hij have hΩ := hcount M A y a N R hA ht b hb hsize rw [suffixProduct_factor_count R.fullTuple_prime hb] at hΩ have hdim : ((M+(coreDimension M (logLog y)+1-(b+1)) : ℕ) : ℝ) ≤ (M : ℝ)+(coreDimension M (logLog y)+1-b : ℕ) := by norm_cast; omega have hδ := hbase M (coreDimension M (logLog y)+1-(b+1)) (by omega) (by linarith : ((M+(coreDimension M (logLog y)+1-(b+1)) : ℕ) : ℝ) ≤ 15*Real.log (logLog Z)) have hmono := baseLoss_antitone_right (M := M) (by omega) (show coreDimension M (logLog y)+1-(idx.val+1) ≤ coreDimension M (logLog y)+1-(b+1) by omega) have hcoef : 1+(logLog Z)^(-η) ≤ 1+baseLoss M (coreDimension M (logLog y)+1-(idx.val+1)) := by linarith exact (mul_le_mul_of_nonneg_right hcoef (record_fullTuple_logLog_nonneg R hA j)).trans (record_fullTuple_adjacent_baseLoss R idx j hij) end Erdos416Proof.FordLower namespace Erdos416Proof.FordLower open FordScale /-- Index in the original full tuple corresponding to a proper suffix. -/ /- Original line 35146: Erdos416Proof.FordLower.properSuffixIndex -/ def properSuffixIndex {L : ℕ} (idx : Fin L) (j : Fin (L-(idx.val+1)+1)) : Fin (L+1) := ⟨idx.val+1+j.val, by have := idx.isLt; have := j.isLt; omega⟩ /- Original line 35149: Erdos416Proof.FordLower.properSuffixTuple_eq_full -/ theorem properSuffixTuple_eq_full {L : ℕ} (P : ℕ) (q : Fin L → ℕ) (idx : Fin L) (j : Fin (L-(idx.val+1)+1)) : properSuffixTuple q idx j = (Fin.cons P q : Fin (L+1) → ℕ) (properSuffixIndex idx j) := by cases j using Fin.cases with | zero => have heq : properSuffixIndex idx 0 = idx.succ := Fin.ext (by simp [properSuffixIndex]) simp only [heq, Fin.cons_succ, properSuffixTuple, Fin.cons_zero] | succ j => have heq : properSuffixIndex idx j.succ = (suffixIndex (idx.val+1) j).succ := by apply Fin.ext simp only [properSuffixIndex, Fin.val_succ, suffixIndex] omega simp only [heq, properSuffixTuple, Fin.cons_succ, suffixTuple] /- Original line 35163: Erdos416Proof.FordLower.record_fullTuple_minimum -/ theorem record_fullTuple_minimum {M : ℕ} {A y : ℝ} {a : Fin (coreDimension M (logLog y))} {N : ℕ} (R : PrimeProductRecord M A y a N) (idx : Fin (coreDimension M (logLog y)+1)) : Real.exp (Real.exp A) ≤ (R.fullTuple idx : ℝ) := by cases idx using Fin.cases with | zero => exact (R.lower_minimum a).trans (Nat.cast_le.mpr (R.lower_separated a).le) | succ idx => exact R.lower_minimum idx /- Original line 35171: Erdos416Proof.FordLower.record_fullTuple_seventeen -/ theorem record_fullTuple_seventeen {M : ℕ} {A y : ℝ} {a : Fin (coreDimension M (logLog y))} {N : ℕ} (R : PrimeProductRecord M A y a N) (hA : 4 ≤ A) (idx : Fin (coreDimension M (logLog y)+1)) : 17 ≤ R.fullTuple idx := by have h4 : (4 : ℝ) ≤ Real.exp A := by have h := Real.add_one_le_exp A linarith have h16 : (16 : ℝ) < Real.exp (Real.exp A) := by calc (16 : ℝ) = 2^4 := by norm_num _ < (Real.exp 1)^4 := by gcongr; exact Real.exp_one_gt_two _ = Real.exp 4 := by rw [← Real.exp_nat_mul]; norm_num _ ≤ _ := Real.exp_le_exp.mpr h4 have hn : (16 : ℝ) < R.fullTuple idx := h16.trans_le (record_fullTuple_minimum R idx) have hn' : 16 < R.fullTuple idx := by exact_mod_cast hn omega /-- The varying adjacent gap in exactly the proper-suffix tuple convention used by the finite sieve and its facet. The threshold is uniform in records. -/ /- Original line 35190: Erdos416Proof.FordLower.record_properSuffixTuple_gap_eventually -/ theorem record_properSuffixTuple_gap_eventually {η : ℝ} (hη : 0 < η) : ∀ᶠ Z : ℝ in atTop, ∀ (M : ℕ) (A y : ℝ) (a : Fin (coreDimension M (logLog y))) (N : ℕ) (R : PrimeProductRecord M A y a N), 2 ≤ M → 1 ≤ A → 0 < logLog y → (M : ℝ) ≤ 10*Real.log (logLog Z) → ∀ idx : Fin (coreDimension M (logLog y)), ((suffixProduct R.fullTuple (idx.val+1)).totient : ℝ) ≤ Z → ∀ u v : Fin (coreDimension M (logLog y)-(idx.val+1)+1), v.val = u.val+1 → (1+(logLog Z)^(-η))*logLog (properSuffixTuple R.lower idx v) ≤ logLog (properSuffixTuple R.lower idx u) := by filter_upwards [record_suffix_gap_eventually hη] with Z hZ intro M A y a N R hM hA ht hMsize idx hsize u v huv have h := hZ M A y a N R hM hA ht hMsize (idx.val+1) (by have := idx.isLt; omega) hsize (properSuffixIndex idx u) (properSuffixIndex idx v) (by change idx.val+1 ≤ idx.val+1+u.val; omega) (by change idx.val+1+v.val = (idx.val+1+u.val)+1; omega) simpa only [properSuffixTuple_eq_full R.leading R.lower idx, PrimeProductRecord.fullTuple] using h end Erdos416Proof.FordLower open Filter Finset Asymptotics open scoped Classical Topology BigOperators namespace Erdos416Proof.FordLower /- Original line 35218: Erdos416Proof.FordLower.varying_contraction_lower -/ theorem varying_contraction_lower {T : ℝ} (hT : 1 ≤ T) : T^(-1/100 : ℝ)/2 ≤ 1-1/(1+T^(-1/100 : ℝ)) := by have hT0 : 0 < T := by linarith have hp0 : 0 < T^(-1/100 : ℝ) := Real.rpow_pos_of_pos hT0 _ have hp1 : T^(-1/100 : ℝ) ≤ 1 := Real.rpow_le_one_of_one_le_of_nonpos hT (by norm_num) have hinv : 1/(1+T^(-1/100 : ℝ)) ≤ 1-T^(-1/100 : ℝ)/2 := by apply (div_le_iff₀ (by positivity : 0 < 1+T^(-1/100 : ℝ))).mpr nlinarith [mul_nonneg hp0.le (sub_nonneg.mpr hp1)] linarith /-- The varying prime gaps remain larger than the mesh and coordinate errors. The power 1/100 leaves room above the -2/5 separation scale. -/ /- Original line 35231: Erdos416Proof.FordLower.varying_coordinate_scales_eventually -/ theorem varying_coordinate_scales_eventually : ∀ᶠ T : ℝ in atTop, 0 < T^(-1/3 : ℝ) ∧ 0 < 1/T ∧ 0 < T^(-2/5 : ℝ) ∧ 10*T^(-2/5 : ℝ)+1/T+CollisionBox.coordinateError 5 T ≤ (1-1/(1+T^(-1/100 : ℝ)))*T^(-1/3 : ℝ) ∧ 10*T^(-2/5 : ℝ)+1/T+CollisionBox.coordinateError 6 T ≤ T^(-1/100 : ℝ)/2 ∧ 4*T^(-2/5 : ℝ) ≤ T^(-1/3 : ℝ) := by have hlo := (CollisionBox.coordinateLoss_littleO (by norm_num : (0 : ℝ) < 5) (by norm_num : (-2/5 : ℝ) < -1/3-1/100)).bound (by norm_num : (0 : ℝ) < 1/2) have hhi := (CollisionBox.coordinateLoss_littleO (by norm_num : (0 : ℝ) < 6) (by norm_num : (-2/5 : ℝ) < -1/100)).bound (by norm_num : (0 : ℝ) < 1/2) filter_upwards [hlo, hhi, CollisionBox.coordinate_scales_eventually (g := 1) (θ := 0) (by norm_num) (by norm_num), eventually_ge_atTop (1 : ℝ)] with T hlo hhi hfixed hT have hT0 : 0 < T := by linarith have hp := Real.rpow_pos_of_pos hT0 (-1/100 : ℝ) have hb := Real.rpow_pos_of_pos hT0 (-1/3 : ℝ) have hpow := Real.rpow_pos_of_pos hT0 (-1/3-1/100 : ℝ) simp only [Real.norm_eq_abs, abs_of_pos hpow] at hlo simp only [Real.norm_eq_abs, abs_of_pos hp] at hhi have heq : (1/2 : ℝ)*T^(-1/3-1/100 : ℝ) = T^(-1/100 : ℝ)/2*T^(-1/3 : ℝ) := by rw [show (-1/3-1/100 : ℝ) = -1/100+(-1/3) by ring, Real.rpow_add hT0] ring refine ⟨hfixed.1, hfixed.2.1, hfixed.2.2.1, ?_, ?_, hfixed.2.2.2.2.2⟩ · exact ((le_abs_self _).trans hlo).trans (heq ▸ mul_le_mul_of_nonneg_right (varying_contraction_lower hT) hb.le) · have h := (le_abs_self _).trans hhi linarith /-- The existing cutoff margins also hold when the upper ordinary coordinate approaches one at the same varying-gap rate. -/ /- Original line 35261: Erdos416Proof.FordLower.varying_cutoff_margins_eventually -/ theorem varying_cutoff_margins_eventually (A : ℝ) : ∀ᶠ T : ℝ in atTop, ∀ L : ℕ, (L : ℝ) ≤ A*Real.log T → CollisionCutoff.Margins L (normalityDelta T) (1/T) (T^(-2/5 : ℝ)) (T^(-1/3 : ℝ)) (1-T^(-1/100 : ℝ)/2) T := by have herr := (CollisionBox.coordinateLoss_littleO (by norm_num : (0 : ℝ) < 10) (by norm_num : (-2/5 : ℝ) < -1/100)).bound (by norm_num : (0 : ℝ) < 1/2) filter_upwards [CollisionCutoff.margins_eventually A 0 (by norm_num), herr, eventually_ge_atTop (1 : ℝ)] with T hfixed herr hT have hT0 : 0 < T := by linarith have hδ := normalityDelta_nonneg hT have hp := Real.rpow_pos_of_pos hT0 (-1/100 : ℝ) have hh := Real.rpow_pos_of_pos hT0 (-2/5 : ℝ) have hε : 0 < 1/T := one_div_pos.mpr hT0 have he : 0 ≤ CollisionBox.coordinateError 10 T := by exact div_nonneg (Real.log_nonneg (by linarith : 1 ≤ 10*T)) hT0.le simp only [Real.norm_eq_abs, abs_of_pos hp] at herr have herr' : 10*T^(-2/5 : ℝ)+1/T+CollisionBox.coordinateError 10 T ≤ T^(-1/100 : ℝ)/2 := by linarith [(le_abs_self _).trans herr] intro L hL have m := hfixed L hL have hL0 : (0 : ℝ) ≤ L := Nat.cast_nonneg L have hbudget := m.budget refine ⟨m.scale_pos, m.delta_nonneg, m.mesh_pos, m.gap_pos, hbudget, ?_, m.first_tail, ?_, m.short_tail, m.normality⟩ · have hcoef : (6*L+3 : ℝ)*normalityDelta T ≤ 2*((4*L+4 : ℝ)*normalityDelta T) := by nlinarith [mul_nonneg hL0 hδ] linarith · have hcoef : (2*L+1 : ℝ)*normalityDelta T ≤ (4*L+4 : ℝ)*normalityDelta T := by nlinarith [mul_nonneg hL0 hδ] linarith end Erdos416Proof.FordLower open Filter Finset Asymptotics open scoped Classical Topology BigOperators namespace Erdos416Proof.CollisionState variable {m n : ℕ} /-- A unit in the internal factor list changes neither integer product. -/ /- Original line 35305: Erdos416Proof.CollisionState.padLeftUnit -/ def padLeftUnit (s : CollisionState m n) : CollisionState (m+1) n := (Fin.append s.1 (fun _ : Fin 1 => 1), s.2) /- Original line 35308: Erdos416Proof.CollisionState.padLeftUnit_left -/ theorem padLeftUnit_left (s : CollisionState m n) (idx : Fin m) : (padLeftUnit s).1 (Fin.castAdd 1 idx) = s.1 idx := by simp only [padLeftUnit, Fin.append_left] /- Original line 35311: Erdos416Proof.CollisionState.padLeftUnit_unit -/ theorem padLeftUnit_unit (s : CollisionState m n) (idx : Fin 1) : (padLeftUnit s).1 (Fin.natAdd m idx) = 1 := by simp only [padLeftUnit, Fin.append_right] /- Original line 35314: Erdos416Proof.CollisionState.padLeftUnit_right -/ theorem padLeftUnit_right (s : CollisionState m n) : (padLeftUnit s).2 = s.2 := rfl /- Original line 35316: Erdos416Proof.CollisionState.padLeftUnit_leftValue -/ theorem padLeftUnit_leftValue (s : CollisionState m n) : leftValue (padLeftUnit s) = leftValue s := by simp only [leftValue, Fin.prod_univ_add, padLeftUnit_left, padLeftUnit_unit, prod_const_one, mul_one] /- Original line 35321: Erdos416Proof.CollisionState.padLeftUnit_rightValue -/ theorem padLeftUnit_rightValue (s : CollisionState m n) : rightValue (padLeftUnit s) = rightValue s := rfl /- Original line 35324: Erdos416Proof.CollisionState.padLeftUnit_injective -/ theorem padLeftUnit_injective : Function.Injective (padLeftUnit (m := m) (n := n)) := by intro s t h apply Prod.ext · funext idx have heq := congrArg (fun a : CollisionState (m+1) n => a.1 (Fin.castAdd 1 idx)) h simpa only [padLeftUnit_left] using heq · have heq := congrArg (fun a : CollisionState (m+1) n => a.2) h simpa only [padLeftUnit_right] using heq /- Original line 35333: Erdos416Proof.CollisionState.SieveOriginalConditions.padLeftUnit -/ theorem SieveOriginalConditions.padLeftUnit {k d : ℕ} {S Y R : ℝ} {v W : ℕ → ℝ} {s : CollisionState m n} (hs : SieveOriginalConditions k d S Y R v W s) (hk : 1 ≤ k) (hkm : k ≤ m) (hlog : 0 ≤ logLog (v k)) : SieveOriginalConditions k d S Y R v W (CollisionState.padLeftUnit s) := by refine ⟨?_, ?_, ?_, ?_, ?_, hs.normal_right, ?_, ?_, hs.largest_right, ?_, hs.tail_right, ?_, ?_⟩ · constructor · intro idx refine Fin.addCases ?_ ?_ idx · intro j; simpa only [padLeftUnit_left] using hs.positive.1 j · intro j; simp only [padLeftUnit_unit]; norm_num · exact hs.positive.2 · simpa only [Balanced, padLeftUnit_leftValue, padLeftUnit_rightValue] using hs.balanced · simpa only [padLeftUnit_leftValue] using hs.size · simpa only [padLeftUnit_leftValue] using hs.square_exclusion · intro a refine Fin.addCases ?_ ?_ a · intro idx hi simpa only [padLeftUnit_left] using hs.normal_left idx hi · intro idx hi have h : m+idx.val < k := hi omega · intro a refine Fin.addCases ?_ ?_ a · intro idx b hi hbi simpa only [padLeftUnit_left, padLeftUnit_right] using hs.distinct idx b hi hbi · intro idx b hi _ have h : m+idx.val < k := hi omega · intro a refine Fin.addCases ?_ ?_ a · intro idx hi simpa only [padLeftUnit_left, Fin.val_castAdd] using hs.largest_left idx hi · intro idx hi have h : m+idx.val < k := hi omega · intro a refine Fin.addCases ?_ ?_ a · intro idx hi simpa only [padLeftUnit_left] using hs.tail_left idx hi · intro idx _ simp only [padLeftUnit_unit, Nat.primeFactorsList_one, List.not_mem_nil, false_implies, implies_true] · intro a refine Fin.addCases ?_ ?_ a · intro idx hi simpa only [padLeftUnit_left] using hs.tail_factors idx hi · intro idx _ simpa only [padLeftUnit_unit, ArithmeticFunction.cardFactors_one, Nat.cast_zero] using mul_nonneg (by norm_num : (0 : ℝ) ≤ 10) hlog · intro a refine Fin.addCases ?_ ?_ a · intro idx hi simpa only [padLeftUnit_left] using hs.top idx hi · intro idx hi have h : m+idx.val = 0 := hi omega /-- Allow the right residual to create one more coordinate than the left list. The padded image is injective and all original sieve hypotheses remain. -/ /- Original line 35393: Erdos416Proof.CollisionState.exists_multivariable_sieve_padded_bound -/ theorem exists_multivariable_sieve_padded_bound : ∃ c Z : ℝ, 0 < c ∧ ∀ (k m n d : ℕ) (S Y R : ℝ) (v W : ℕ → ℝ) (F : Finset (CollisionState m n)), Z ≤ v k → 1 ≤ k → k ≤ m → k ≤ n → n ≤ m+1 → Real.exp (Real.exp 1) ≤ S → S ≤ v k → Antitone v → v 0 = Y → (∀ j < k, v (j+1) < W j ∧ W j ≤ v j) → (∀ idx, 2 ≤ idx → idx ≤ k → 2*Real.sqrt (logLog S/logLog Y) ≤ logLog (v (idx-1))/logLog Y-logLog (v idx)/logLog Y) → 1 ≤ R → v 1 ≤ Y ^ (1/(10*logLog Y)) → 0 < d → (∀ p ∈ d.primeFactorsList, (p : ℝ) ≤ v k) → (∀ s ∈ F, SieveOriginalConditions k d S Y R v W s) → (F.card : ℝ) ≤ (Y/((d : ℝ)*R))*(c*logLog Y)^(6*k)*(n : ℝ)^ArithmeticFunction.cardFactors d * (Real.log (v k)) ^ (20*(m+1 : ℕ)*Real.log (m+1 : ℕ)+1 : ℝ) * (Real.log Y)^(-2+(∑ idx ∈ Icc 1 (k-1), fordWeight idx*(logLog (v idx)/logLog Y)) + fordSieveError k (Real.sqrt (logLog S/logLog Y)) (fun idx => logLog (v idx)/logLog Y) (fun idx => logLog (W idx)/logLog Y)) := by obtain ⟨c, Z, hc, hbound⟩ := exists_multivariable_sieve_bound refine ⟨c, Z, hc, ?_⟩ intro k m n d S Y R v W F hvZ hk hkm hkn hnm hS hSv hanti hv0 hW hgap hR hcut hd hdv hF have hlog : 0 ≤ logLog (v k) := by apply logLog_nonneg exact (Real.exp_le_exp.mpr (Real.one_le_exp (by norm_num : (0 : ℝ) ≤ 1))).trans (hS.trans hSv) let G := F.image CollisionState.padLeftUnit have hG : ∀ s ∈ G, SieveOriginalConditions k d S Y R v W s := by intro s hs obtain ⟨t, ht, rfl⟩ := mem_image.mp hs exact (hF t ht).padLeftUnit hk hkm hlog have hcard : G.card = F.card := card_image_of_injective F padLeftUnit_injective have h := hbound k (m+1) n d S Y R v W G hvZ hk (by omega) hkn hnm hS hSv hanti hv0 hW hgap hR hcut hd hdv hG rw [hcard] at h exact h /- Original line 35428: Erdos416Proof.CollisionState.exists_multivariable_sieve_normal_padded_bound -/ theorem exists_multivariable_sieve_normal_padded_bound : ∃ c : ℝ, 0 < c ∧ ∀ᶠ Y : ℝ in atTop, ∀ (k l d : ℕ) (R : ℝ) (v W : ℕ → ℝ) (F : Finset (CollisionState (k+l) (k+1))), 1 ≤ k → normalityScale (logLog Y) ≤ v k → Antitone v → v 0 = Y → (∀ j < k, v (j+1) < W j ∧ W j ≤ v j) → (∀ idx, 2 ≤ idx → idx ≤ k → normalityDelta (logLog Y) ≤ logLog (v (idx-1))/logLog Y-logLog (v idx)/logLog Y) → 1 ≤ R → v 1 ≤ Y ^ (1/(10*logLog Y)) → 0 < d → (∀ p ∈ d.primeFactorsList, (p : ℝ) ≤ v k) → (∀ s ∈ F, SieveOriginalConditions k d (normalityScale (logLog Y)) Y R v W s) → (F.card : ℝ) ≤ (Y/((d : ℝ)*R))*(c*logLog Y)^(6*k)*(k+1 : ℝ)^ArithmeticFunction.cardFactors d * (Real.log (v k)) ^ (20*(k+l+1 : ℕ)*Real.log (k+l+1 : ℕ)+1 : ℝ) * (Real.log Y)^(-2+(∑ idx ∈ Finset.Icc 1 (k-1), fordWeight idx*(logLog (v idx)/logLog Y)) + fordSieveError k (normalityDelta (logLog Y)/2) (fun idx => logLog (v idx)/logLog Y) (fun idx => logLog (W idx)/logLog Y)) := by obtain ⟨c, Z, hc, hbound⟩ := exists_multivariable_sieve_padded_bound have hLL : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop have hscale := normalityScale_atTop.comp hLL refine ⟨c, hc, ?_⟩ filter_upwards [hscale.eventually_ge_atTop Z, hscale.eventually_ge_atTop (Real.exp (Real.exp 1)), hLL.eventually_ge_atTop 1] with Y hZ hS hT intro k l d R v W F hk hSv hanti hv0 hW hgap hR hcut hd hdv hF have hdelta := sieve_normality_delta hT have hsep : ∀ idx, 2 ≤ idx → idx ≤ k → 2*Real.sqrt (logLog (normalityScale (logLog Y))/logLog Y) ≤ logLog (v (idx-1))/logLog Y-logLog (v idx)/logLog Y := by intro idx hi hik rw [hdelta] linarith [hgap idx hi hik] have h := hbound k (k+l) (k+1) d (normalityScale (logLog Y)) Y R v W F (hZ.trans hSv) hk (by omega) (by omega) (by omega) hS hSv hanti hv0 hW hsep hR hcut hd hdv hF simpa only [hdelta, Nat.cast_add, Nat.cast_one] using h end Erdos416Proof.CollisionState namespace Erdos416Proof.CollisionClass open CollisionState /- Original line 35470: Erdos416Proof.CollisionClass.exists_collision_class_sieve_bound_with_empty_tail -/ theorem exists_collision_class_sieve_bound_with_empty_tail : ∃ c : ℝ, 0 < c ∧ ∀ᶠ Y : ℝ in atTop, ∀ (a l d M : ℕ) (C : Finset (Fin a)) (A : Finset ℕ) (p q : ℕ → Fin a → ℕ) (t : ℕ → Fin l → ℕ) (e : ℕ → ℕ) (v W : ℕ → ℝ), let k := (remaining C).card 1 ≤ a → (∀ j : Fin a, j.val = 0 → j ∉ C) → normalityScale (logLog Y) ≤ v k → Antitone v → v 0 = Y → (∀ j < k, v (j+1) < W j ∧ W j ≤ v j) → (∀ idx, 2 ≤ idx → idx ≤ k → normalityDelta (logLog Y) ≤ logLog (v (idx-1))/logLog Y-logLog (v idx)/logLog Y) → v 1 ≤ Y ^ (1/(10*logLog Y)) → 0 < d → (∀ z ∈ d.primeFactorsList, (z : ℝ) ≤ v k) → (∀ n ∈ A, Conditions C d M n (normalityScale (logLog Y)) Y v W (p n) (q n) (t n) (e n)) → (A.card : ℝ) ≤ (Y/((d : ℝ)*M.totient))*(c*logLog Y)^(6*k)*(k+1 : ℝ)^ArithmeticFunction.cardFactors d * (Real.log (v k)) ^ (20*(k+l+1 : ℕ)*Real.log (k+l+1 : ℕ)+1 : ℝ) * (Real.log Y)^(-2+(∑ idx ∈ Finset.Icc 1 (k-1), fordWeight idx*(logLog (v idx)/logLog Y)) + fordSieveError k (normalityDelta (logLog Y)/2) (fun idx => logLog (v idx)/logLog Y) (fun idx => logLog (W idx)/logLog Y)) := by obtain ⟨c, hc, hbound⟩ := exists_multivariable_sieve_normal_padded_bound refine ⟨c, hc, ?_⟩ filter_upwards [hbound, eventually_ge_atTop (Real.exp (Real.exp 1))] with Y hY hbase intro a l d M C A p q t e v W dsimp only intro ha hzero hSv hanti hv0 hW hgap hcut hd hdv hA let k := (remaining C).card have hk : 1 ≤ k := remaining_card_pos C ha hzero have hS : Real.exp 1 ≤ normalityScale (logLog Y) := normalityScale_ge_exp_one _ have hbase1 : 1 < Real.exp (Real.exp 1) := Real.one_lt_exp_iff.mpr (Real.exp_pos 1) have hY1 : 1 < Y := hbase1.trans_le hbase have hY0 : 0 ≤ Y := by linarith have hT : 1 ≤ logLog Y := by simpa only [logLog, Real.log_exp] using logLog_mono hbase1 hbase have hT0 : 0 ≤ logLog Y := by linarith have hlogY : 0 ≤ Real.log Y := (Real.log_pos hY1).le have hlogv : 0 ≤ Real.log (v k) := Real.log_nonneg ((Real.one_le_exp (by norm_num : (0 : ℝ) ≤ 1)).trans (hS.trans hSv)) by_cases hnonempty : A.Nonempty · obtain ⟨n, hn⟩ := hnonempty have hM : 0 < M := (hA n hn).common_pos have hR : (1 : ℝ) ≤ M.totient := by exact_mod_cast Nat.totient_pos.mpr hM let F : Finset (CollisionState (k+l) (k+1)) := A.image (fun n => state C (p n) (q n) (t n) (e n)) have hF : ∀ s ∈ F, SieveOriginalConditions k d (normalityScale (logLog Y)) Y M.totient v W s := by intro s hs obtain ⟨n, hn, rfl⟩ := Finset.mem_image.mp hs exact (hA n hn).state_conditions hk hzero hS hSv have hcard : F.card = A.card := state_image_card A C M p q t e (by intro n hn have hs := hA n hn exact ⟨fun idx => (hs.normal_left idx).1, fun j => (hs.normal_tail j).1, hs.common_product, hs.integer⟩) have h := hY k l d M.totient v W F hk hSv hanti hv0 hW hgap hR hcut hd hdv hF rw [hcard] at h exact h · rw [Finset.not_nonempty_iff_eq_empty.mp hnonempty] simp only [Finset.card_empty, Nat.cast_zero] positivity end Erdos416Proof.CollisionClass namespace Erdos416Proof.CollisionSaving /- Original line 35535: Erdos416Proof.CollisionSaving.normalitySieveLoss_mono -/ theorem normalitySieveLoss_mono {T : ℝ} (hT : 1 ≤ T) : Monotone (normalitySieveLoss T) := by have hT0 : 0 < T := by linarith have hδ := normalityDelta_nonneg hT intro L M hLM have hLM' : (L : ℝ) ≤ M := by exact_mod_cast hLM have hL0 : (0 : ℝ) ≤ L := Nat.cast_nonneg L have hM0 : (0 : ℝ) ≤ M := Nat.cast_nonneg M have hlogL : 0 ≤ Real.log ((L : ℝ)+1) := Real.log_nonneg (by linarith) have hlogM : 0 ≤ Real.log ((M : ℝ)+1) := Real.log_nonneg (by linarith) unfold normalitySieveLoss gcongr /-- The extra unit coordinate costs one terminal dimension. Reuse the proved loss absorption with L+1 and the identical numerical tail cutoff. -/ /- Original line 35550: Erdos416Proof.CollisionSaving.prefactor_saving_with_empty_tail_eventually -/ theorem prefactor_saving_with_empty_tail_eventually {A c : ℝ} (hA : 0 ≤ A) (hc : 0 < c) (D : ℕ) (K : ℝ) : ∀ᶠ T : ℝ in atTop, ∀ (k l L : ℕ) (ζ E : ℝ), 1 ≤ k+l → k+l ≤ L+1 → (L : ℝ) ≤ A*Real.log T → ζ ≤ T^(-1/3 : ℝ) → E ≤ -1-(1/2 : ℝ)*T^(-1/8 : ℝ)+normalitySieveLoss T L/T → fordSievePrefactor T (ζ+(2*L+3 : ℝ)*normalityDelta T) c k (l+1) D * (Real.exp T)^E ≤ (1/Real.exp T)* Real.exp (-(1/4 : ℝ)*T^(7/8 : ℝ)-K*sieveErrorEnvelope T) := by filter_upwards [prefactor_saving_eventually (A := A+1) (by linarith) hc D K, eventually_ge_atTop (Real.exp 1)] with T hsave hT have hT1 : 1 ≤ T := (Real.one_le_exp (by norm_num : (0 : ℝ) ≤ 1)).trans hT have hT0 : 0 < T := (Real.exp_pos 1).trans_le hT have hlog : 1 ≤ Real.log T := by simpa only [Real.log_exp] using Real.log_le_log (Real.exp_pos 1) hT have hδ := normalityDelta_nonneg hT1 intro k l L ζ E hkl hklL hL hζ hE have hL' : ((L+1 : ℕ) : ℝ) ≤ (A+1)*Real.log T := by push_cast; nlinarith have hζ' : ζ-2*normalityDelta T ≤ T^(-1/3 : ℝ) := by linarith have hloss := div_le_div_of_nonneg_right (normalitySieveLoss_mono hT1 (Nat.le_succ L)) hT0.le have hE' : E ≤ -1-(1/2 : ℝ)*T^(-1/8 : ℝ)+normalitySieveLoss T (L+1)/T := by linarith have heq : ζ-2*normalityDelta T + (2*((L+1 : ℕ) : ℝ)+3)*normalityDelta T = ζ+(2*L+3 : ℝ)*normalityDelta T := by push_cast; ring have h := hsave k (l+1) (L+1) (ζ-2*normalityDelta T) E (by omega) (by omega) hL' hζ' hE' simpa only [heq] using h end Erdos416Proof.CollisionSaving namespace Erdos416Proof.CollisionSaving /- Original line 35581: Erdos416Proof.CollisionSaving.class_saving_with_empty_tail_eventually -/ theorem class_saving_with_empty_tail_eventually {A : ℝ} (hA : 0 ≤ A) (d : ℕ) (hd : 0 < d) (K : ℝ) : ∀ᶠ Y : ℝ in atTop, ∀ (L : ℕ) (J : Fin (L + 1)) (C : Finset (Fin (J.val + 1))) (M : ℕ) (F : Finset ℕ) (pstar : Fin (L + 1) → ℕ) (p q : ℕ → Fin (J.val + 1) → ℕ) (t : ℕ → Fin (L - J.val) → ℕ) (e : ℕ → ℕ), let T := logLog Y; let k := (CollisionClass.remaining C).card; let v := CollisionRecord.upper Y pstar (1 / T) (T ^ (-2 / 5 : ℝ)) (T ^ (-1 / 3 : ℝ)) J C; let W := CollisionRecord.lower Y pstar (1 / T) (T ^ (-2 / 5 : ℝ)) (T ^ (-1 / 3 : ℝ)) J C; (L : ℝ) ≤ A * Real.log T → (∀ idx : Fin (J.val + 1), idx.val = 0 → idx ∉ C) → CollisionCutoff.SieveCutoffs k Y (normalityDelta T) v W → (largestPrimeFactor d : ℝ) ≤ normalityScale T → (∀ idx, 17 ≤ pstar idx) → Antitone pstar → (∑ idx ∈ Finset.Icc 1 L, fordWeight idx * CollisionFacet.extend (fun j => CollisionBox.primeCoordinate T (pstar j)) idx) ≤ 1 - T ^ (-1 / 8 : ℝ) → (∀ n ∈ F, CollisionClass.Conditions C d M n (normalityScale T) Y v W (p n) (q n) (t n) (e n)) → (F.card : ℝ) ≤ Y / ((d : ℝ) * M.totient * Real.log Y) * Real.exp (-(1 / 4 : ℝ) * T ^ (7 / 8 : ℝ) - K * sieveErrorEnvelope T) := by obtain ⟨c, hc, hclass⟩ := CollisionClass.exists_collision_class_sieve_bound_with_empty_tail have hT : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [hclass, CollisionFacet.cutoff_exponent_eventually hA, hT.eventually (prefactor_saving_with_empty_tail_eventually hA hc (ArithmeticFunction.cardFactors d) K), eventually_gt_atTop (1 : ℝ)] with Y hcount hexponent hsave hY intro L J C M F pstar p q t e dsimp only intro hL hzero hcuts hdS hp17 horder hfacet hF let T := logLog Y let k := (CollisionClass.remaining C).card let ζ := CollisionBox.tailCoordinate (1 / T) (T ^ (-2 / 5 : ℝ)) (T ^ (-1 / 3 : ℝ)) (fun idx => CollisionBox.shiftedCoordinate T (pstar idx)) J let v := CollisionRecord.upper Y pstar (1 / T) (T ^ (-2 / 5 : ℝ)) (T ^ (-1 / 3 : ℝ)) J C let W := CollisionRecord.lower Y pstar (1 / T) (T ^ (-2 / 5 : ℝ)) (T ^ (-1 / 3 : ℝ)) J C have hk : 1 ≤ k := CollisionClass.remaining_card_pos C (by omega) hzero have hkL : k ≤ J.val + 1 := CollisionClass.remaining_card_le C have hζ : ζ ≤ T ^ (-1 / 3 : ℝ) := min_le_left _ _ have hE := hexponent L pstar J C (T ^ (-2 / 5 : ℝ)) (T ^ (-1 / 3 : ℝ)) hL hk hp17 horder hfacet have hfactors := hsave k (L - J.val) L ζ (CollisionFacet.actualExponent Y k v W) (by omega) (by omega) hL hζ hE have hexpT : Real.exp T = Real.log Y := Real.exp_log (Real.log_pos hY) rw [hexpT] at hfactors have hlogtail : Real.log (v k) = Real.exp ((ζ + (2 * L + 3 : ℝ) * normalityDelta T) * T) := log_upper_tail hY pstar J C hk dsimp only [T, k] at hlogtail have hdv : ∀ z ∈ d.primeFactorsList, (z : ℝ) ≤ v k := by intro z hz exact (Nat.cast_le.mpr (primeFactorsList_le_largestPrimeFactor hz)).trans (hdS.trans hcuts.normality) have hraw := hcount (J.val + 1) (L - J.val) d M C F p q t e v W (by omega) hzero hcuts.normality hcuts.antitone hcuts.zero hcuts.interleaving hcuts.gaps hcuts.initial hd hdv hF calc (F.card : ℝ) ≤ (Y / ((d : ℝ) * M.totient)) * (fordSievePrefactor T (ζ + (2 * L + 3 : ℝ) * normalityDelta T) c k (L - J.val+1) (ArithmeticFunction.cardFactors d) * (Real.log Y) ^ CollisionFacet.actualExponent Y k v W) := by convert hraw using 1 simp only [fordSievePrefactor, CollisionFacet.actualExponent, T, k, hlogtail, Nat.add_assoc] ring _ ≤ (Y / ((d : ℝ) * M.totient)) * ((1 / Real.log Y) * Real.exp (-(1 / 4 : ℝ) * T ^ (7 / 8 : ℝ) - K * sieveErrorEnvelope T)) := mul_le_mul_of_nonneg_left hfactors (div_nonneg (by linarith) (mul_nonneg (Nat.cast_nonneg d) (Nat.cast_nonneg M.totient))) _ = _ := by ring end Erdos416Proof.CollisionSaving namespace Erdos416Proof.CollisionRecord variable {L : ℕ} /- Original line 35651: Erdos416Proof.CollisionRecord.CompleteWithEmptyTail -/ structure CompleteWithEmptyTail {N : ℕ} (Y : ℝ) (p : Fin (L + 1) → ℕ) (d : ℕ) (Q : NormalPreimageList N (normalityScale (logLog Y))) (ε h b : ℝ) (J : Fin (L + 1)) (ha : J.val + 1 ≤ (largeShiftPrimes N (normalityScale (logLog Y))).card) : Prop where zero_survives : ∀ idx : Fin (J.val + 1), idx.val = 0 → idx ∉ common J p Q ha cutoffs : CollisionCutoff.SieveCutoffs (CollisionClass.remaining (common J p Q ha)).card Y (normalityDelta (logLog Y)) (upper Y p ε h b J (common J p Q ha)) (lower Y p ε h b J (common J p Q ha)) conditions : CollisionClass.Conditions (common J p Q ha) d (commonProduct J p (common J p Q ha)) (∏ idx, p idx) (normalityScale (logLog Y)) Y (upper Y p ε h b J (common J p Q ha)) (lower Y p ε h b J (common J p Q ha)) (leftPrimes J p) (CollisionClass.prefixPrimes Q ha) (tailPrimes J p) (CollisionClass.normalResidual Q (J.val + 1)) /-- Instantiate every original-equation condition of the class sieve, using the actual matching theorem and the leading-prime size argument. -/ /- Original line 35666: Erdos416Proof.CollisionRecord.complete_of_matched_with_empty_tail -/ theorem complete_of_matched_with_empty_tail {N d : ℕ} {Y ε h b : ℝ} {p : Fin (L + 1) → ℕ} (Q : NormalPreimageList N (normalityScale (logLog Y))) (J : Fin (L + 1)) (ha : J.val + 1 ≤ (largeShiftPrimes N (normalityScale (logLog Y))).card) (hm : CollisionMatching.MatchedPreimage Y p Q ε h b J ha) (hN : 0 < N) (hp : ∀ idx, SNormal (normalityScale (logLog Y)) (p idx)) (hinj : Function.Injective p) (hphi : N.totient = d * ∏ idx, (p idx - 1)) (hsize : (N.totient : ℝ) ≤ Y) (hsquare : NoLargePrimeSquare N.totient (normalityScale (logLog Y))) (htop : Y ^ (9 / 10 : ℝ) < (p 0 : ℝ)) (hsizetop : N ≤ (p 0) ^ 2) (hneq : largestPrimeFactor N ≠ p 0) : CompleteWithEmptyTail Y p d Q ε h b J ha := by let C := common J p Q ha have hzero : ∀ idx : Fin (J.val + 1), idx.val = 0 → idx ∉ C := by apply CollisionClass.common_zero_absent Q ha C (leftPrimes J p) hN (fun idx => (hp (CollisionMatching.prefixIndex J idx)).1) rfl · intro idx hi simpa only [leftPrimes_zero J p idx hi] using hsizetop · intro idx hi simpa only [leftPrimes_zero J p idx hi] using hneq obtain ⟨hk, hv, hpaired⟩ := hm.paired C hzero have hS : 1 ≤ normalityScale (logLog Y) := (Real.one_le_exp (by norm_num : (0 : ℝ) ≤ 1)).trans (normalityScale_ge_exp_one _) have htailEq : CollisionMatching.tailCutoff Y L (CollisionBox.tailCoordinate ε h b (fun idx => CollisionBox.shiftedCoordinate (logLog Y) (p idx)) J) = upper Y p ε h b J C (CollisionClass.remaining C).card := CollisionMatching.tailCutoff_eq_upper Y L _ _ hk refine ⟨hzero, hv, ?_⟩ apply CollisionClass.conditions_of_normalPreimage Q ha C d (commonProduct J p C) (∏ idx, p idx) (upper Y p ε h b J C) (lower Y p ε h b J C) (leftPrimes J p) (tailPrimes J p) hS hv.normality (fun idx => hp (CollisionMatching.prefixIndex J idx)) (fun idx => hp (tailIndex J idx)) (leftPrimes_injective J hinj) rfl rfl (prod_split J p) · simpa only [leftPrimes, tailPrimes, prod_split J (fun idx => p idx - 1)] using hphi · exact hsize · exact hsquare.mono hv.normality · intro idx simpa only [CollisionMatching.selectedIndex_eq_prefixIndex, leftPrimes, upper, lower] using (hpaired idx).1 · intro idx exact (hpaired idx).2 · intro idx z hz exact htailEq ▸ hm.left_tail (tailIndex J idx) (tailIndex_gt J idx) z hz · intro j hj exact htailEq ▸ (hm.right_tail j hj).le · intro idx hi simpa only [leftPrimes_zero J p idx hi] using htop end Erdos416Proof.CollisionRecord namespace Erdos416Proof.CollisionSum variable {L : ℕ} /- Original line 35717: Erdos416Proof.CollisionSum.RecordWithEmptyTail -/ structure RecordWithEmptyTail (Y : ℝ) (L d : ℕ) where integer : ℕ primes : Fin (L + 1) → ℕ J : Fin (L + 1) common : Finset (Fin (J.val + 1)) right : Fin (J.val + 1) → ℕ residual : ℕ zero_survives : ∀ idx : Fin (J.val + 1), idx.val = 0 → idx ∉ common cutoffs : CollisionCutoff.SieveCutoffs (CollisionClass.remaining common).card Y (normalityDelta (logLog Y)) (upper Y primes J common) (lower Y primes J common) conditions : CollisionClass.Conditions common d (CollisionRecord.commonProduct J primes common) integer (normalityScale (logLog Y)) Y (upper Y primes J common) (lower Y primes J common) (CollisionRecord.leftPrimes J primes) right (CollisionRecord.tailPrimes J primes) residual prime_min : ∀ idx, 17 ≤ primes idx order : Antitone primes facet : (∑ idx ∈ Finset.Icc 1 L, fordWeight idx * CollisionFacet.extend (fun j => CollisionBox.primeCoordinate (logLog Y) (primes j)) idx) ≤ 1 - (logLog Y) ^ (-1 / 8 : ℝ) variable {Y : ℝ} {d : ℕ} /- Original line 35738: Erdos416Proof.CollisionSum.record_of_complete_with_empty_tail -/ noncomputable def record_of_complete_with_empty_tail {N : ℕ} {p : Fin (L + 1) → ℕ} {Q : NormalPreimageList N (normalityScale (logLog Y))} {J : Fin (L + 1)} {ha : J.val + 1 ≤ (largeShiftPrimes N (normalityScale (logLog Y))).card} (h : CollisionRecord.CompleteWithEmptyTail Y p d Q (1 / logLog Y) ((logLog Y) ^ (-2 / 5 : ℝ)) ((logLog Y) ^ (-1 / 3 : ℝ)) J ha) (hp17 : ∀ idx, 17 ≤ p idx) (horder : Antitone p) (hfacet : (∑ idx ∈ Finset.Icc 1 L, fordWeight idx * CollisionFacet.extend (fun j => CollisionBox.primeCoordinate (logLog Y) (p j)) idx) ≤ 1 - (logLog Y) ^ (-1 / 8 : ℝ)) : RecordWithEmptyTail Y L d where integer := ∏ idx, p idx primes := p J := J common := CollisionRecord.common J p Q ha right := CollisionClass.prefixPrimes Q ha residual := CollisionClass.normalResidual Q (J.val + 1) zero_survives := h.zero_survives cutoffs := h.cutoffs conditions := h.conditions prime_min := hp17 order := horder facet := hfacet /- Original line 35760: Erdos416Proof.CollisionSum.RecordWithEmptyTail.label -/ noncomputable def RecordWithEmptyTail.label (r : RecordWithEmptyTail Y L d) : Label L := ((r.J, box Y r.primes), commonCode r.J r.common, CollisionRecord.commonProduct r.J r.primes r.common) /-- Equal actual labels transport the original Conditions to the cutoffs of a representative, despite the variable length of the matched prefix. -/ /- Original line 35765: Erdos416Proof.CollisionSum.RecordWithEmptyTail.conditions_of_label_eq -/ theorem RecordWithEmptyTail.conditions_of_label_eq (r s : RecordWithEmptyTail Y L d) (heq : r.label = s.label) : ∃ (p q : Fin (s.J.val + 1) → ℕ) (t : Fin (L - s.J.val) → ℕ) (e : ℕ), CollisionClass.Conditions s.common d (CollisionRecord.commonProduct s.J s.primes s.common) r.integer (normalityScale (logLog Y)) Y (upper Y s.primes s.J s.common) (lower Y s.primes s.J s.common) p q t e := by rcases r with ⟨n, p, J, C, q, e, hzero, hcuts, hconditions, hp17, horder, hfacet⟩ rcases s with ⟨nstar, pstar, Jstar, Cstar, qstar, estar, hzerostar, hcutsstar, hconditionsstar, hp17star, horderstar, hfacetstar⟩ change ((J, box Y p), commonCode J C, CollisionRecord.commonProduct J p C) = ((Jstar, box Y pstar), commonCode Jstar Cstar, CollisionRecord.commonProduct Jstar pstar Cstar) at heq have hJJ : J = Jstar := congrArg (fun l : Label L => l.1.1) heq subst Jstar have hCC : C = Cstar := commonCode_injective J (congrArg (fun l : Label L => l.2.1) heq) subst Cstar have hb : box Y p = box Y pstar := congrArg (fun l : Label L => l.1.2) heq have hM : CollisionRecord.commonProduct J p C = CollisionRecord.commonProduct J pstar C := congrArg (fun l : Label L => l.2.2) heq have hcut := cutoffs_eq_of_box_eq J C hb refine ⟨CollisionRecord.leftPrimes J p, q, CollisionRecord.tailPrimes J p, e, ?_⟩ simpa only [hM, hcut.1, hcut.2] using hconditions /- Original line 35785: Erdos416Proof.CollisionSum.RecordWithEmptyTail.shifted_le -/ theorem RecordWithEmptyTail.shifted_le (r : RecordWithEmptyTail Y L d) (hd : 0 < d) (idx : Fin (L + 1)) : ((r.primes idx - 1 : ℕ) : ℝ) ≤ Y := by have hsize : ((d * ∏ j, (r.primes j - 1) : ℕ) : ℝ) ≤ Y := by simpa only [CollisionRecord.leftPrimes, CollisionRecord.tailPrimes, CollisionRecord.prod_split r.J (fun j => r.primes j - 1)] using r.conditions.size have hprodpos : 0 < d * ∏ j, (r.primes j - 1) := by apply mul_pos hd apply Finset.prod_pos intro j _ have := r.prime_min j omega have hdiv : r.primes idx - 1 ∣ d * ∏ j, (r.primes j - 1) := dvd_mul_of_dvd_right (Finset.dvd_prod_of_mem (fun j => r.primes j - 1) (Finset.mem_univ idx)) d exact (Nat.cast_le.mpr (Nat.le_of_dvd hprodpos hdiv)).trans hsize /- Original line 35800: Erdos416Proof.CollisionSum.RecordWithEmptyTail.prime_size -/ theorem RecordWithEmptyTail.prime_size (r : RecordWithEmptyTail Y L d) (hd : 0 < d) (hY : 1 ≤ Y) (hT : 2 ≤ logLog Y) (idx : Fin (L + 1)) : (r.primes idx : ℝ) ≤ Y * logLog Y := by have h := r.shifted_le hd idx rw [Nat.cast_sub (by have := r.prime_min idx; omega), Nat.cast_one] at h nlinarith [mul_le_mul_of_nonneg_left hT (by linarith : 0 ≤ Y)] /- Original line 35806: Erdos416Proof.CollisionSum.RecordWithEmptyTail.shifted_coordinate_le_one -/ theorem RecordWithEmptyTail.shifted_coordinate_le_one (r : RecordWithEmptyTail Y L d) (hd : 0 < d) (hT : 0 < logLog Y) (idx : Fin (L + 1)) : CollisionBox.shiftedCoordinate (logLog Y) (r.primes idx) ≤ 1 := by apply (div_le_one hT).mpr apply logLog_mono (CollisionMatching.shifted_largest_one_lt (r.prime_min idx)) exact (Nat.cast_le.mpr (largestPrimeFactor_le (by have := r.prime_min idx; omega))).trans (r.shifted_le hd idx) /- Original line 35812: Erdos416Proof.CollisionSum.RecordWithEmptyTail.common_product_properties -/ theorem RecordWithEmptyTail.common_product_properties (r : RecordWithEmptyTail Y L d) : Squarefree (CollisionRecord.commonProduct r.J r.primes r.common) ∧ (CollisionRecord.commonProduct r.J r.primes r.common).primeFactors = r.common.image (CollisionRecord.leftPrimes r.J r.primes) ∧ (CollisionRecord.commonProduct r.J r.primes r.common).primeFactors.card ≤ L + 1 := by classical have hp : ∀ q ∈ r.common.image (CollisionRecord.leftPrimes r.J r.primes), q.Prime := by intro q hq obtain ⟨idx, _, rfl⟩ := Finset.mem_image.mp hq exact (r.conditions.normal_left idx).1 have hinj := r.conditions.left_injective.injOn (s := (r.common : Set (Fin (r.J.val + 1)))) have hprod : (∏ q ∈ r.common.image (CollisionRecord.leftPrimes r.J r.primes), q) = CollisionRecord.commonProduct r.J r.primes r.common := Finset.prod_image hinj have hfactors : (CollisionRecord.commonProduct r.J r.primes r.common).primeFactors = r.common.image (CollisionRecord.leftPrimes r.J r.primes) := by rw [← hprod] exact Nat.primeFactors_prod hp refine ⟨hprod ▸ Sieve.prodDistinctPrimes_squarefree _ hp, hfactors, ?_⟩ rw [hfactors] have hcard : r.common.card ≤ r.J.val + 1 := by simpa only [Finset.card_univ, Fintype.card_fin] using Finset.card_le_card (Finset.subset_univ r.common) exact Finset.card_image_le.trans (hcard.trans (by have := r.J.isLt; omega)) /- Original line 35835: Erdos416Proof.CollisionSum.RecordWithEmptyTail.common_product_support -/ theorem RecordWithEmptyTail.common_product_support (r : RecordWithEmptyTail Y L d) (hd : 0 < d) (hY : 1 ≤ Y) (hT : 2 ≤ logLog Y) : (CollisionRecord.commonProduct r.J r.primes r.common).primeFactors ⊆ Nat.primesLE ⌊Y * logLog Y⌋₊ := by rw [r.common_product_properties.2.1] intro q hq obtain ⟨idx, _, rfl⟩ := Finset.mem_image.mp hq apply Nat.mem_primesLE.mpr exact ⟨Nat.le_floor (r.prime_size hd hY hT (CollisionMatching.prefixIndex r.J idx)), (r.conditions.normal_left idx).1⟩ /-- Bound the actual label image inside the product of its box image, all finite common-index codes, and its actual shared-product image. -/ /- Original line 35846: Erdos416Proof.CollisionSum.label_weight_sum_le_with_empty_tail -/ theorem label_weight_sum_le_with_empty_tail (F : Finset (RecordWithEmptyTail Y L d)) : (∑ l ∈ F.image RecordWithEmptyTail.label, invTotient l.2.2) ≤ ((F.image (fun r => (r.J, box Y r.primes))).card : ℝ) * (2 : ℝ) ^ (L + 1) * ∑ M ∈ F.image (fun r => CollisionRecord.commonProduct r.J r.primes r.common), invTotient M := by classical let B := F.image (fun r => (r.J, box Y r.primes)) let M := F.image (fun r => CollisionRecord.commonProduct r.J r.primes r.common) let C : Finset (Finset (Fin (L + 1))) := Finset.univ have hsub : F.image RecordWithEmptyTail.label ⊆ B.product (C.product M) := by intro l hl obtain ⟨r, hr, rfl⟩ := Finset.mem_image.mp hl exact Finset.mem_product.mpr ⟨Finset.mem_image.mpr ⟨r, hr, rfl⟩, Finset.mem_product.mpr ⟨Finset.mem_univ _, Finset.mem_image.mpr ⟨r, hr, rfl⟩⟩⟩ calc _ ≤ ∑ l ∈ B.product (C.product M), invTotient l.2.2 := Finset.sum_le_sum_of_subset_of_nonneg hsub (by intro l _ _; unfold invTotient; positivity) _ = ∑ _b ∈ B, ∑ _c ∈ C, ∑ m ∈ M, invTotient m := by simp only [Finset.product_eq_sprod, Finset.sum_product] _ = _ := by simp only [Finset.sum_const, C, Finset.card_univ, Fintype.card_finset, Fintype.card_fin, nsmul_eq_mul, Nat.cast_pow, Nat.cast_ofNat] ring /-- The complete weighted number of labels is controlled uniformly for the actual common products occurring in an arbitrary retained family. -/ /- Original line 35871: Erdos416Proof.CollisionSum.label_weight_sum_with_empty_tail_eventually -/ theorem label_weight_sum_with_empty_tail_eventually {A : ℝ} (hA : 0 ≤ A) (d : ℕ) (hd : 0 < d) : ∀ᶠ Y : ℝ in atTop, ∀ (L : ℕ) (F : Finset (RecordWithEmptyTail Y L d)), (L : ℝ) ≤ A * Real.log (logLog Y) → (∑ l ∈ F.image RecordWithEmptyTail.label, invTotient l.2.2) ≤ Real.exp ((6 * A + 7) * Real.log (logLog Y) ^ 2) := by classical have hT : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [hT.eventually (common_product_sum_inverse_totient_scale (A + 1) (c := 1) (by norm_num)), hT.eventually (dimension_log_bounds_eventually A), hT.eventually_ge_atTop (Real.exp 1), hT.eventually_ge_atTop 2, eventually_gt_atTop (1 : ℝ)] with Y hcommon hdim hTe hT2 hY intro L F hL have hTp : 0 < logLog Y := by linarith have hdimL := (hdim L hL).1 have hboxes := CollisionBox.prefix_label_image_card_scale F (fun r idx => CollisionBox.shiftedCoordinate (logLog Y) (r.primes idx)) (fun r => r.J) hTe hL (fun r _ idx _ => r.shifted_coordinate_le_one hd hTp idx) have hcodes := common_code_count_le hA hTe hdimL let M := F.image (fun r => CollisionRecord.commonProduct r.J r.primes r.common) have hM := hcommon M (L + 1) (by simpa only [Nat.cast_add, Nat.cast_one] using hdimL) (by intro m hm obtain ⟨r, _, rfl⟩ := Finset.mem_image.mp hm have hp := r.common_product_properties refine ⟨hp.1, ?_, hp.2.2⟩ simpa only [one_mul, CollisionMatching.exp_exp_logLog hY] using r.common_product_support hd hY.le hT2) have hbound := label_weight_sum_le_with_empty_tail F calc _ ≤ ((F.image (fun r => (r.J, box Y r.primes))).card : ℝ) * (2 : ℝ) ^ (L + 1) * ∑ m ∈ M, invTotient m := hbound _ ≤ Real.exp (3 * (A + 1) * Real.log (logLog Y) ^ 2) * Real.exp ((A + 1) * Real.log (logLog Y) ^ 2) * Real.exp ((2 * (A + 1) + 1) * Real.log (logLog Y) ^ 2) := by apply mul_le_mul · exact mul_le_mul hboxes hcodes (by positivity) (by positivity) · exact hM · apply Finset.sum_nonneg intro m _ unfold invTotient positivity · positivity _ = _ := by rw [← Real.exp_add, ← Real.exp_add]; congr 1; ring /-- Sum the actual disjoint label fibers. Each fiber is sent injectively to its original integer values, receives the checked class bound, and is then included in the proved weighted label sum. -/ /- Original line 35915: Erdos416Proof.CollisionSum.records_count_with_empty_tail_eventually -/ theorem records_count_with_empty_tail_eventually {A : ℝ} (hA : 0 ≤ A) (d : ℕ) (hd : 0 < d) : ∀ᶠ Y : ℝ in atTop, ∀ (L : ℕ) (F : Finset (RecordWithEmptyTail Y L d)), (L : ℝ) ≤ A * Real.log (logLog Y) → Set.InjOn RecordWithEmptyTail.integer (F : Set (RecordWithEmptyTail Y L d)) → (largestPrimeFactor d : ℝ) ≤ normalityScale (logLog Y) → (F.card : ℝ) ≤ Y / ((d : ℝ) * Real.log Y) * Real.exp (-(1 / 4 : ℝ) * (logLog Y) ^ (7 / 8 : ℝ)) := by classical have hT : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [CollisionSaving.class_saving_with_empty_tail_eventually hA d hd (6 * A + 7), label_weight_sum_with_empty_tail_eventually hA d hd, eventually_gt_atTop (1 : ℝ), hT.eventually_gt_atTop 0] with Y hclass hlabels hY hTpos intro L F hL hinj hdS let T := logLog Y let β := Y / ((d : ℝ) * Real.log Y) * Real.exp (-(1 / 4 : ℝ) * T ^ (7 / 8 : ℝ) - (6 * A + 7) * sieveErrorEnvelope T) have hYpos : 0 < Y := by linarith have hTp : 0 < T := hTpos have hlogY : 0 < Real.log Y := Real.log_pos hY have hβ : 0 ≤ β := by unfold β; positivity have hfiber : ∀ l ∈ F.image RecordWithEmptyTail.label, ((F.filter (fun r => r.label = l)).card : ℝ) ≤ β * invTotient l.2.2 := by intro l hl obtain ⟨s, hs, rfl⟩ := Finset.mem_image.mp hl let G := F.filter (fun r => r.label = s.label) let U := G.image RecordWithEmptyTail.integer have hU : ∀ n ∈ U, ∃ (p q : Fin (s.J.val + 1) → ℕ) (t : Fin (L - s.J.val) → ℕ) (e : ℕ), CollisionClass.Conditions s.common d (CollisionRecord.commonProduct s.J s.primes s.common) n (normalityScale (logLog Y)) Y (upper Y s.primes s.J s.common) (lower Y s.primes s.J s.common) p q t e := by intro n hn obtain ⟨r, hr, rfl⟩ := Finset.mem_image.mp hn exact r.conditions_of_label_eq s (Finset.mem_filter.mp hr).2 choose! p q t e hconditions using hU have hcount := hclass L s.J s.common (CollisionRecord.commonProduct s.J s.primes s.common) U s.primes p q t e hL s.zero_survives s.cutoffs hdS s.prime_min s.order s.facet hconditions have hcard : U.card = G.card := Finset.card_image_of_injOn (hinj.mono (show (G : Set (RecordWithEmptyTail Y L d)) ⊆ F from fun r hr => (Finset.mem_filter.mp hr).1)) rw [hcard] at hcount calc ((F.filter (fun r => r.label = s.label)).card : ℝ) ≤ Y / ((d : ℝ) * (CollisionRecord.commonProduct s.J s.primes s.common).totient * Real.log Y) * Real.exp (-(1 / 4 : ℝ) * T ^ (7 / 8 : ℝ) - (6 * A + 7) * sieveErrorEnvelope T) := hcount _ = β * invTotient s.label.2.2 := by simp only [β, RecordWithEmptyTail.label, invTotient]; ring have hsum : (F.card : ℝ) = ∑ l ∈ F.image RecordWithEmptyTail.label, ((F.filter (fun r => r.label = l)).card : ℝ) := by exact_mod_cast Finset.card_eq_sum_card_image RecordWithEmptyTail.label F have henv : Real.log T ^ 2 ≤ sieveErrorEnvelope T := by unfold sieveErrorEnvelope have h₁ : 0 ≤ Real.log T ^ 2 * T ^ (2 / 3 : ℝ) := by exact mul_nonneg (sq_nonneg _) (Real.rpow_nonneg hTp.le _) have h₂ : 0 ≤ Real.log T ^ 8 * T ^ (1 / 2 : ℝ) := by positivity linarith calc (F.card : ℝ) = ∑ l ∈ F.image RecordWithEmptyTail.label, ((F.filter (fun r => r.label = l)).card : ℝ) := hsum _ ≤ ∑ l ∈ F.image RecordWithEmptyTail.label, β * invTotient l.2.2 := Finset.sum_le_sum hfiber _ = β * ∑ l ∈ F.image RecordWithEmptyTail.label, invTotient l.2.2 := (Finset.mul_sum _ _ _).symm _ ≤ β * Real.exp ((6 * A + 7) * Real.log T ^ 2) := mul_le_mul_of_nonneg_left (hlabels L F hL) hβ _ = Y / ((d : ℝ) * Real.log Y) * Real.exp (-(1 / 4 : ℝ) * T ^ (7 / 8 : ℝ) - (6 * A + 7) * sieveErrorEnvelope T + (6 * A + 7) * Real.log T ^ 2) := by rw [Real.exp_add]; unfold β; ring _ ≤ _ := by apply mul_le_mul_of_nonneg_left _ (by positivity) apply Real.exp_le_exp.mpr have hcost := mul_le_mul_of_nonneg_left henv (show 0 ≤ 6 * A + 7 by linarith) linarith /-- Select one proved record per actual integer. This construction supplies the injection required by the finite record-family bound. -/ /- Original line 35983: Erdos416Proof.CollisionSum.retained_count_with_empty_tail_eventually -/ theorem retained_count_with_empty_tail_eventually {A : ℝ} (hA : 0 ≤ A) (d : ℕ) (hd : 0 < d) : ∀ᶠ Y : ℝ in atTop, ∀ (L : ℕ) (F : Finset ℕ), (L : ℝ) ≤ A * Real.log (logLog Y) → (largestPrimeFactor d : ℝ) ≤ normalityScale (logLog Y) → (∀ n ∈ F, ∃ r : RecordWithEmptyTail Y L d, r.integer = n) → (F.card : ℝ) ≤ Y / ((d : ℝ) * Real.log Y) * Real.exp (-(1 / 4 : ℝ) * (logLog Y) ^ (7 / 8 : ℝ)) := by classical filter_upwards [records_count_with_empty_tail_eventually hA d hd] with Y hbound intro L F hL hdS hrecords let f : F → RecordWithEmptyTail Y L d := fun n => Classical.choose (hrecords n n.property) have hf : ∀ n : F, (f n).integer = n := fun n => Classical.choose_spec (hrecords n n.property) have hinj : Function.Injective f := by intro n m hnm apply Subtype.ext simpa only [hf] using congrArg RecordWithEmptyTail.integer hnm let G := F.attach.image f have hGin : Set.InjOn RecordWithEmptyTail.integer (G : Set (RecordWithEmptyTail Y L d)) := by intro r hr s hs hrs obtain ⟨n, _, rfl⟩ := Finset.mem_image.mp hr obtain ⟨m, _, rfl⟩ := Finset.mem_image.mp hs have hnm : n = m := Subtype.ext (by simpa only [hf] using hrs) exact congrArg f hnm have hcard : G.card = F.card := by rw [Finset.card_image_of_injective _ hinj, Finset.card_attach] simpa only [hcard] using hbound L G hL hGin hdS end Erdos416Proof.CollisionSum open Filter Finset open scoped Classical Topology BigOperators namespace Erdos416Proof /-- If every left position is used, the first extra right position still lies below the terminal cutoff. Interval mass uses the actual left length. -/ /- Original line 36023: Erdos416Proof.matching_tail_cutoff_exhausted -/ theorem matching_tail_cutoff_exhausted {m n : ℕ} (p : Fin m → ℕ) (q : Fin n → ℕ) {S T u v : ℝ} (hp : ∀ j, SNormal S (p j)) (hq : ∀ j, SNormal S (q j)) (hS : Real.exp 1 ≤ S) (j : Fin n) (hj : j.val = m) (horderQ : RankedAt (fun k => largestPrimeFactor (q k - 1)) j) (hSu : S ≤ u) (huv : u < v) (hvT : logLog v ≤ T) (hgap : (2*m+1 : ℝ)*Real.sqrt (logLog S*T) < logLog v-logLog u) (hbalance : ∀ a b : ℝ, S ≤ a → a < b → (∑ k, omegaInterval (p k - 1) a b) = ∑ k, omegaInterval (q k - 1) a b) : (largestPrimeFactor (q j - 1) : ℝ) < v := by by_contra hQ have hvQ : v ≤ (largestPrimeFactor (q j - 1) : ℝ) := le_of_not_gt hQ have hupper := SNormal.sum_interval_upper p hp hS hSu huv hvT have hlower := SNormal.sum_interval_lower_of_cutoff q hq hS j horderQ hvQ hSu huv hvT have hmass : (∑ k, (omegaInterval (p k - 1) u v : ℝ)) = ∑ k, (omegaInterval (q k - 1) u v : ℝ) := by exact_mod_cast hbalance u v hSu huv rw [hmass] at hupper rw [hj] at hlower nlinarith namespace CollisionMatching /-- The exact normality error is half of delta*T. This leaves a strict terminal gap even when J is the final left position. -/ /- Original line 36047: Erdos416Proof.CollisionMatching.tail_matching_gap_all -/ theorem tail_matching_gap_all {L : ℕ} {Y : ℝ} (hY : 1 < Y) (hT1 : 1 < logLog Y) (J : Fin (L+1)) (zstar : ℝ) : (2*(J.val+1 : ℕ)+1 : ℝ)*Real.sqrt (logLog (normalityScale (logLog Y))*logLog Y) < logLog (tailCutoff Y L zstar)-logLog (CollisionBox.cutoff Y zstar) := by have hT : 0 < logLog Y := by linarith have hδ := normalityDelta_pos hT1 have hexact : Real.sqrt (logLog (normalityScale (logLog Y))*logLog Y) = normalityDelta (logLog Y)*logLog Y/2 := by change Real.sqrt (Real.log (Real.log (normalityScale (logLog Y)))*logLog Y) = _ rw [normality_error_exact hT1.le, normalityDelta_mul_self hT] ring have hJL : (J.val : ℝ) ≤ L := by exact_mod_cast (show J.val ≤ L by omega) have hcoef : (2*(J.val+1 : ℕ)+1 : ℝ)/2 < 2*L+3 := by push_cast; linarith [Nat.cast_nonneg (α := ℝ) L] rw [hexact, tailCutoff, CollisionBox.logLog_cutoff hY, CollisionBox.logLog_cutoff hY] have h := mul_lt_mul_of_pos_right hcoef (mul_pos hδ hT) nlinarith /- Original line 36064: Erdos416Proof.CollisionMatching.exhausted_right_tail_bound -/ theorem exhausted_right_tail_bound {L N d : ℕ} {Y ε h b θ zstar : ℝ} {p : Fin (L+1) → ℕ} (hY : Real.exp 1 < Y) (hT1 : 1 < logLog Y) (Q : NormalPreimageList N (normalityScale (logLog Y))) (m : CollisionCutoff.Margins L (normalityDelta (logLog Y)) ε h b θ (logLog Y)) (hp : ∀ idx, SNormal (normalityScale (logLog Y)) (p idx)) (hd : 0 < d) (hdS : (largestPrimeFactor d : ℝ) ≤ normalityScale (logLog Y)) (hphi : N.totient = d*∏ idx, (p idx-1)) (hzlo : b/2 ≤ zstar) (hzhi : zstar ≤ b) : ∀ j : Fin (largeShiftPrimes N (normalityScale (logLog Y))).card, L+1 ≤ j.val → (largestPrimeFactor (Q.primes j-1) : ℝ) < tailCutoff Y L zstar := by have hcuts := tail_cutoff_properties hY hT1 m hzlo hzhi have hYone : 1 < Y := (Real.one_lt_exp_iff.mpr (by norm_num : (0 : ℝ) < 1)).trans hY intro j hj let j₀ : Fin (largeShiftPrimes N (normalityScale (logLog Y))).card := ⟨L+1, by have := j.isLt; omega⟩ have hg := tail_matching_gap_all hYone hT1 (Fin.last L) zstar have hfirst := matching_tail_cutoff_exhausted p Q.primes hp Q.normal (normalityScale_ge_exp_one (logLog Y)) j₀ rfl (rankedAt_of_antitone Q.sorted.antitone j₀) hcuts.1 hcuts.2.1 hcuts.2.2 hg (fun a _ ha _ => Q.interval_balance p (fun r => (hp r).1) hd.ne' hdS hphi ha) have hle : (largestPrimeFactor (Q.primes j-1) : ℝ) ≤ largestPrimeFactor (Q.primes j₀-1) := by exact_mod_cast Q.sorted.antitone (show j₀ ≤ j from hj) exact hle.trans_lt hfirst /- Original line 36086: Erdos416Proof.CollisionMatching.exhausted_residual_support -/ theorem exhausted_residual_support {L N d : ℕ} {Y ε h b θ zstar : ℝ} {p : Fin (L+1) → ℕ} (hY : Real.exp 1 < Y) (hT1 : 1 < logLog Y) (Q : NormalPreimageList N (normalityScale (logLog Y))) (m : CollisionCutoff.Margins L (normalityDelta (logLog Y)) ε h b θ (logLog Y)) (hp : ∀ idx, SNormal (normalityScale (logLog Y)) (p idx)) (hd : 0 < d) (hdS : (largestPrimeFactor d : ℝ) ≤ normalityScale (logLog Y)) (hphi : N.totient = d*∏ idx, (p idx-1)) (hzlo : b/2 ≤ zstar) (hzhi : zstar ≤ b) : ∀ z ∈ (CollisionClass.normalResidual Q (L+1)).primeFactorsList, (z : ℝ) ≤ tailCutoff Y L zstar := by have hcuts := tail_cutoff_properties hY hT1 m hzlo hzhi have hS : 1 ≤ normalityScale (logLog Y) := (Real.one_lt_exp_iff.mpr (by norm_num : (0 : ℝ) < 1)).le.trans (normalityScale_ge_exp_one _) exact CollisionClass.normalResidual_support Q (L+1) hS (hcuts.1.trans hcuts.2.1.le) (fun j hj => (exhausted_right_tail_bound hY hT1 Q m hp hd hdS hphi hzlo hzhi j hj).le) end CollisionMatching end Erdos416Proof /- Actual suffix-family counting, including unrestricted high prefixes, small leading primes, every matching record and all pruning losses. -/ open Filter Finset Asymptotics open scoped Classical Topology BigOperators namespace Erdos416Proof.CollisionBox /-- Choose the highest high position, allowing it to be the final one. -/ /- Original line 36119: Erdos416Proof.CollisionBox.exists_last_high_unrestricted -/ theorem exists_last_high_unrestricted {L : ℕ} (w : Fin (L+1) → ℝ) {b : ℝ} (hhead : b < w 0) : ∃ J : Fin (L+1), b < w J ∧ ∀ j, J < j → w j ≤ b := by let H := Finset.univ.filter (fun idx => b < w idx) have hH : H.Nonempty := ⟨0, by simp [H, hhead]⟩ obtain ⟨J, hJ, hmax⟩ := H.exists_max_image (fun idx => idx) hH refine ⟨J, (Finset.mem_filter.mp hJ).2, ?_⟩ intro j hj by_contra hn have hjH : j ∈ H := by simp [H, lt_of_not_ge hn] exact (not_le_of_gt hj) (hmax j hjH) /- Original line 36130: Erdos416Proof.CollisionBox.PrefixData -/ structure PrefixData {L : ℕ} (x w : Fin (L + 1) → ℝ) (b e e₀ ε h g θ : ℝ) : Prop where threshold_pos : 0 < b mesh_pos : 0 < ε gap_pos : 0 < h contraction_nonneg : 0 ≤ g ordinary_order : Antitone x shifted_le : ∀ idx, w idx ≤ x idx approximation : ∀ idx, b ≤ x idx → x idx - e ≤ w idx contraction : ∀ idx j, 0 < idx.val → idx < j → g * x idx ≤ x idx - x j lower_upper : ∀ idx, 0 < idx.val → x idx ≤ θ head_high : b < w 0 head_le : w 0 ≤ 1 head_approximation : 1 - e₀ ≤ w 0 lower_gap : 10 * h + ε + e ≤ g * b head_gap : 10 * h + ε + e₀ ≤ 1 - θ tail_margin : 4 * h ≤ b variable {L : ℕ} {x w : Fin (L + 1) → ℝ} {b e e₀ ε h g θ : ℝ} /- Original line 36150: Erdos416Proof.CollisionBox.PrefixData.shifted_gap -/ theorem PrefixData.shifted_gap (d : PrefixData x w b e e₀ ε h g θ) {idx j : Fin (L + 1)} (hi : 0 < idx.val) (hij : idx < j) (hxi : b ≤ x idx) : 10 * h + ε ≤ w idx - w j := by have hc := d.contraction idx j hi hij have he := d.approximation idx hxi have hw := d.shifted_le j have hm := mul_le_mul_of_nonneg_left hxi d.contraction_nonneg have hg := d.lower_gap linarith /- Original line 36160: Erdos416Proof.CollisionBox.PrefixData.head_shifted_gap -/ theorem PrefixData.head_shifted_gap (d : PrefixData x w b e e₀ ε h g θ) {j : Fin (L + 1)} (hj : 0 < j.val) : 10 * h + ε ≤ w 0 - w j := by have hu := d.lower_upper j hj have hw := d.shifted_le j have ha := d.head_approximation have hg := d.head_gap linarith /- Original line 36168: Erdos416Proof.CollisionBox.PrefixData.high_before -/ theorem PrefixData.high_before (d : PrefixData x w b e e₀ ε h g θ) {idx J : Fin (L + 1)} (hJ : b < w J) (hi : idx ≤ J) : b < w idx := by by_cases hiJ : idx = J · simpa only [hiJ] using hJ by_cases hi0 : idx.val = 0 · have heq : idx = 0 := Fin.ext hi0 simpa only [heq] using d.head_high have hxi : b ≤ x idx := hJ.le.trans ((d.shifted_le J).trans (d.ordinary_order hi)) have hgap := d.shifted_gap (Nat.pos_of_ne_zero hi0) (lt_of_le_of_ne hi hiJ) hxi have hh := d.gap_pos have hε := d.mesh_pos linarith /-- Every high original position precedes all later shifted factors by a quantified gap, including factors outside the selected prefix. -/ /- Original line 36183: Erdos416Proof.CollisionBox.PrefixData.gap_after_high -/ theorem PrefixData.gap_after_high (d : PrefixData x w b e e₀ ε h g θ) {idx j : Fin (L + 1)} (hi : b < w idx) (hij : idx < j) : 10 * h + ε ≤ w idx - w j := by by_cases hi0 : idx.val = 0 · have heq : idx = 0 := Fin.ext hi0 rw [heq] at hij ⊢ exact d.head_shifted_gap (show 0 < j.val from hij) · exact d.shifted_gap (Nat.pos_of_ne_zero hi0) hij (hi.le.trans (d.shifted_le idx)) /- Original line 36192: Erdos416Proof.CollisionBox.PrefixData.rounded_bounds -/ theorem PrefixData.rounded_bounds (d : PrefixData x w b e e₀ ε h g θ) {idx : Fin (L + 1)} (hi : b < w idx) : w idx ≤ rounded ε w idx ∧ (0 < idx.val → rounded ε w idx < w idx + ε) := by by_cases hi0 : idx.val = 0 · have heq : idx = 0 := Fin.ext hi0 subst idx exact ⟨by simpa [Erdos416Proof.CollisionBox.rounded_zero] using d.head_le, by intro hn; omega⟩ · rw [rounded_of_pos ε w idx (Nat.pos_of_ne_zero hi0)] have hb := roundUp_bounds d.mesh_pos (d.threshold_pos.le.trans hi.le) exact ⟨hb.1, fun _ => hb.2⟩ /- Original line 36203: Erdos416Proof.CollisionBox.PrefixData.rounded_gap -/ theorem PrefixData.rounded_gap (d : PrefixData x w b e e₀ ε h g θ) {idx j : Fin (L + 1)} (hi : b < w idx) (hj : b < w j) (hij : idx < j) : 10 * h ≤ rounded ε w idx - rounded ε w j := by have hgap := d.gap_after_high hi hij have hlo := (d.rounded_bounds hi).1 have hhi := (d.rounded_bounds hj).2 (show 0 < j.val by omega) linarith /- Original line 36211: Erdos416Proof.CollisionBox.PrefixData.tail_bounds -/ theorem PrefixData.tail_bounds (d : PrefixData x w b e e₀ ε h g θ) {J : Fin (L + 1)} (hJ : b < w J) (hlast : ∀ j, J < j → w j ≤ b) : b / 2 ≤ tailCoordinate ε h b w J ∧ tailCoordinate ε h b w J ≤ b ∧ 2 * h ≤ rounded ε w J - tailCoordinate ε h b w J ∧ ∀ j, J < j → w j ≤ tailCoordinate ε h b w J := by have hround := (d.rounded_bounds hJ).1 have hmargin := d.tail_margin have hb := d.threshold_pos have hh := d.gap_pos have hε := d.mesh_pos refine ⟨le_min (by linarith) (by linarith), min_le_left _ _, ?_, ?_⟩ · have hmin : tailCoordinate ε h b w J ≤ rounded ε w J - 2 * h := min_le_right _ _ linarith · intro j hj have hg := d.gap_after_high hJ hj exact le_min (hlast j hj) (by linarith) /-- Construct the actual rounded prefix and its tail cutoff. The highest threshold crossing is proved to be the end of an initial segment. -/ /- Original line 36232: Erdos416Proof.CollisionBox.PrefixData.exists_prefix -/ theorem PrefixData.exists_prefix (d : PrefixData x w b e e₀ ε h g θ) : ∃ J : Fin (L + 1), (∀ idx, idx ≤ J ↔ b < w idx) ∧ (∀ idx j, idx ≤ J → idx < j → 10 * h + ε ≤ w idx - w j) ∧ (∀ idx j, idx < j → j ≤ J → 10 * h ≤ rounded ε w idx - rounded ε w j) ∧ b / 2 ≤ tailCoordinate ε h b w J ∧ tailCoordinate ε h b w J ≤ b ∧ 2 * h ≤ rounded ε w J - tailCoordinate ε h b w J ∧ ∀ j, J < j → w j ≤ tailCoordinate ε h b w J := by obtain ⟨J, hJ, hlast⟩ := exists_last_high_unrestricted w d.head_high have hprefix : ∀ idx, idx ≤ J ↔ b < w idx := by intro idx constructor · exact d.high_before hJ · intro hi by_contra hn exact (not_lt_of_ge (hlast idx (lt_of_not_ge hn))) hi refine ⟨J, hprefix, ?_, ?_, d.tail_bounds hJ hlast⟩ · intro idx j hi hij exact d.gap_after_high ((hprefix idx).mp hi) hij · intro idx j hij hj exact d.rounded_gap ((hprefix idx).mp (hij.le.trans hj)) ((hprefix j).mp hj) hij /- Original line 36254: Erdos416Proof.CollisionBox.PrefixData.rankedAt_shifted -/ theorem PrefixData.rankedAt_shifted {T : ℝ} (hT : 0 < T) {p : Fin (L + 1) → ℕ} (hp : ∀ idx, 17 ≤ p idx) (d : PrefixData x (fun idx => shiftedCoordinate T (p idx)) b e e₀ ε h g θ) {idx : Fin (L + 1)} (hi : b < shiftedCoordinate T (p idx)) : RankedAt (fun j => largestPrimeFactor (p j - 1)) idx := by have hh := d.gap_pos have hε := d.mesh_pos constructor · intro j hji rcases lt_or_eq_of_le hji with hji | rfl · have hg := d.gap_after_high (d.high_before hi hji.le) hji exact (largest_lt_of_shiftedCoordinate_lt hT (hp j) (by linarith)).le · exact le_rfl · intro j hij rcases lt_or_eq_of_le hij with hij | rfl · have hg := d.gap_after_high hi hij exact (largest_lt_of_shiftedCoordinate_lt hT (hp idx) (by linarith)).le · exact le_rfl /-- Normality supplies the prime box data uniformly before the contraction and top-coordinate parameters are chosen. The last prime need not be low. -/ /- Original line 36276: Erdos416Proof.CollisionBox.prefix_prime_data_eventually -/ theorem prefix_prime_data_eventually (c : ℝ) : ∀ᶠ T : ℝ in atTop, ∀ κ θ : ℝ, 1 < κ → 10*T^(-2/5 : ℝ)+1/T+coordinateError 5 T ≤ (1-1/κ)*T^(-1/3 : ℝ) → 10*T^(-2/5 : ℝ)+1/T+coordinateError 6 T ≤ 1-θ → ∀ L : ℕ, ∀ p : Fin (L+1) → ℕ, (∀ idx, SNormal (normalityScale T) (p idx)) → (∀ idx, 17 ≤ p idx) → (∀ idx, (p idx : ℝ) ≤ c*Real.exp (Real.exp T)*T) → Antitone p → (∀ idx : Fin (L+1), 0 < idx.val → ∀ hi : idx.val+1 < L+1, κ*logLog (p ⟨idx.val+1, hi⟩) ≤ logLog (p idx)) → (∀ idx, 0 < idx.val → (p idx : ℝ) ≤ cutoff (Real.exp (Real.exp T)) θ) → (Real.exp (Real.exp T))^(9/10 : ℝ) < (p 0 : ℝ) → ((p 0-1 : ℕ) : ℝ) ≤ Real.exp (Real.exp T) → PrefixData (fun idx => primeCoordinate T (p idx)) (fun idx => shiftedCoordinate T (p idx)) (T^(-1/3 : ℝ)) (coordinateError 5 T) (coordinateError 6 T) (1/T) (T^(-2/5 : ℝ)) (1-1/κ) θ := by have hb := (log_pow_mul_rpow_littleO 0 (by norm_num : (-1 / 3 : ℝ) < 0)).def (by norm_num : (0 : ℝ) < 1 / 4) have he := (coordinateError_littleO (by norm_num : (0 : ℝ) < 6) (by norm_num : (-1 : ℝ) < 0)).def (by norm_num : (0 : ℝ) < 1 / 4) filter_upwards [coordinate_scales_eventually (g := 1) (θ := 0) (by norm_num) (by norm_num), normality_largestPrimeFactor_eventually c, hb, he, eventually_gt_atTop (0 : ℝ)] with T hs hnormal hb he hT intro κ θ hκ hlowergap hheadgap L p hpn hp17 hpsize horder hstep hlower htop hsize have hκpos : 0 < κ := by linarith have hg : 0 < 1-1/κ := by have hinv : 1/κ < (1 : ℝ) := (div_lt_iff₀ hκpos).mpr (by linarith) linarith have hY : 1 < Real.exp (Real.exp T) := Real.one_lt_exp_iff.mpr (Real.exp_pos T) have hLLY : logLog (Real.exp (Real.exp T)) = T := by simp only [logLog, Real.log_exp] have hgap : ∀ idx, logLog (p idx) - logLog (largestPrimeFactor (p idx - 1)) ≤ Real.log (5 * T) := fun idx => (hnormal (p idx) (hpn idx) (hp17 idx) (hpsize idx)).2.2 have hLP : ∀ idx, 1 < (largestPrimeFactor (p idx - 1) : ℝ) := by intro idx exact_mod_cast largestPrimeFactor_one_lt (show 1 < p idx - 1 by have := hp17 idx; omega) have hLPle : ∀ idx, (largestPrimeFactor (p idx - 1) : ℝ) ≤ (p idx - 1 : ℕ) := by intro idx exact_mod_cast largestPrimeFactor_le (show 0 < p idx - 1 by have := hp17 idx; omega) have hxanti : Antitone (fun idx => primeCoordinate T (p idx)) := by intro idx j hij apply div_le_div_of_nonneg_right _ hT.le apply logLog_mono (by have := hp17 j; norm_cast; omega) exact_mod_cast horder hij have hxstep : ∀ idx : Fin (L + 1), 0 < idx.val → ∀ hi : idx.val + 1 < L + 1, κ * primeCoordinate T (p ⟨idx.val + 1, hi⟩) ≤ primeCoordinate T (p idx) := by intro idx hi hn simpa only [primeCoordinate, mul_div_assoc] using div_le_div_of_nonneg_right (hstep idx hi hn) hT.le have hheadApprox : 1 - coordinateError 6 T ≤ shiftedCoordinate T (p 0) := by have hpow : logLog ((Real.exp (Real.exp T)) ^ (9 / 10 : ℝ)) = Real.log (9 / 10 : ℝ) + T := by simp only [logLog, Real.log_rpow (Real.exp_pos _), Real.log_exp, Real.log_mul (by norm_num : (9 / 10 : ℝ) ≠ 0) (Real.exp_ne_zero T)] have hbig := logLog_mono (Real.one_lt_rpow hY (by norm_num : (0 : ℝ) < 9 / 10)) htop.le rw [hpow] at hbig have hlog := Real.log_le_log (by positivity : (0 : ℝ) < 5 * T) (show 5 * T ≤ (9 / 10 : ℝ) * (6 * T) by nlinarith) rw [Real.log_mul (by norm_num : (9 / 10 : ℝ) ≠ 0) (by positivity : 6 * T ≠ 0)] at hlog have hg0 := hgap 0 change 1 - Real.log (6 * T) / T ≤ logLog (largestPrimeFactor (p 0 - 1)) / T apply (le_div_iff₀ hT).mpr have hid : (1 - Real.log (6 * T) / T) * T = T - Real.log (6 * T) := by field_simp rw [hid] linarith simp only [pow_zero, one_mul, Real.rpow_zero, Real.norm_eq_abs, abs_one, mul_one] at hb he have hhead : T ^ (-1 / 3 : ℝ) < shiftedCoordinate T (p 0) := by have hb' := (le_abs_self _).trans hb have he' := (le_abs_self _).trans he linarith refine ⟨hs.1, hs.2.1, hs.2.2.1, hg.le, hxanti, (fun idx => shiftedCoordinate_le hT (hp17 idx)), ?_, contraction_of_adjacent hκpos hxanti hxstep, ?_, hhead, ?_, hheadApprox, hlowergap, hheadgap, hs.2.2.2.2.2⟩ · intro idx _ have hi := div_le_div_of_nonneg_right (hgap idx) hT.le rw [sub_div] at hi dsimp only [primeCoordinate, coordinateError, shiftedCoordinate] linarith · intro idx hi have hpone : (1 : ℝ) < p idx := by have := hp17 idx; norm_cast; omega have hLL := logLog_mono hpone (hlower idx hi) rw [logLog_cutoff hY, hLLY] at hLL exact (div_le_div_of_nonneg_right hLL hT.le).trans_eq (mul_div_cancel_right₀ θ hT.ne') · have hLL := logLog_mono (hLP 0) ((hLPle 0).trans hsize) rw [hLLY] at hLL exact (div_le_div_of_nonneg_right hLL hT.le).trans_eq (div_self hT.ne') end Erdos416Proof.CollisionBox namespace Erdos416Proof.CollisionCutoff variable {L : ℕ} /- Original line 36371: Erdos416Proof.CollisionCutoff.selected_of_prefix_boxes -/ theorem selected_of_prefix_boxes {x w : Fin (L + 1) → ℝ} {b e e₀ ε h g θ : ℝ} (d : CollisionBox.PrefixData x w b e e₀ ε h g θ) (J : Fin (L + 1)) (hJ : b < w J) (hlast : ∀ j, J < j → w j ≤ b) (C : Finset (Fin (J.val + 1))) (hzero : ∀ j : Fin (J.val + 1), j.val = 0 → j ∉ C) : Selected (selectedZeta J C ε w) (CollisionBox.tailCoordinate ε h b w J) ε h b θ := by have hhigh : ∀ idx, b < w (selectedIndex J C idx) := fun idx => d.high_before hJ (selectedIndex_le J C idx) have htail := d.tail_bounds hJ hlast refine ⟨?_, ?_, ?_, ?_, htail.1, htail.2.1⟩ · intro idx hi simp only [selectedZeta, selectedIndex_first J C hzero idx hi, CollisionBox.rounded_zero] · intro idx hi have hpos : 0 < (selectedIndex J C idx).val := lt_of_lt_of_le hi (selectedIndex_val_ge J C idx) have hr := (d.rounded_bounds (hhigh idx)).2 hpos have hx := d.lower_upper (selectedIndex J C idx) hpos have hw := d.shifted_le (selectedIndex J C idx) change CollisionBox.rounded ε w (selectedIndex J C idx) ≤ θ + ε linarith · intro idx j hij exact d.rounded_gap (hhigh idx) (hhigh j) (selectedIndex_strictMono J C hij) · intro idx have hle : CollisionBox.rounded ε w J ≤ selectedZeta J C ε w idx := by rcases lt_or_eq_of_le (selectedIndex_le J C idx) with hi | hi · have hg := d.rounded_gap (hhigh idx) hJ hi have hh := d.gap_pos change CollisionBox.rounded ε w J ≤ CollisionBox.rounded ε w (selectedIndex J C idx) linarith · simp only [selectedZeta, hi, le_refl] have hg := htail.2.2.1 linarith end Erdos416Proof.CollisionCutoff namespace Erdos416Proof.CollisionMatching variable {L : ℕ} variable {Y T ε h b θ e e₀ g : ℝ} {p : Fin (L+1) → ℕ} {x : Fin (L+1) → ℝ} /- Original line 36412: Erdos416Proof.CollisionMatching.match_high_of_prefix_data -/ theorem match_high_of_prefix_data {N d : ℕ} (hT1 : 1 ≤ logLog Y) (Q : NormalPreimageList N (normalityScale (logLog Y))) (hN : 0 < N) (B : CollisionBox.PrefixData x (fun idx => CollisionBox.shiftedCoordinate (logLog Y) (p idx)) b e e₀ ε h g θ) (m : CollisionCutoff.Margins L (normalityDelta (logLog Y)) ε h b θ (logLog Y)) (hp : ∀ idx, SNormal (normalityScale (logLog Y)) (p idx)) (hp17 : ∀ idx, 17 ≤ p idx) (hd : 0 < d) (hdS : (largestPrimeFactor d : ℝ) ≤ normalityScale (logLog Y)) (hphi : N.totient = d * ∏ idx, (p idx - 1)) (hsize : (N.totient : ℝ) ≤ Y) (hPL : ∀ idx, (largestPrimeFactor (p idx - 1) : ℝ) ≤ Y) (idx : Fin (L + 1)) (hi : b < CollisionBox.shiftedCoordinate (logLog Y) (p idx)) : ∃ j : Fin (largeShiftPrimes N (normalityScale (logLog Y))).card, j.val = idx.val ∧ |CollisionBox.shiftedCoordinate (logLog Y) (p idx) - CollisionBox.shiftedCoordinate (logLog Y) (Q.primes j)| ≤ (2 * idx.val + 1 : ℝ) * normalityDelta (logLog Y) := by have hT := m.scale_pos have hgap := high_matching_gap hT1 m B.tail_margin idx (hp17 idx) hi have horder := B.rankedAt_shifted hT hp17 hi have hphiT := logLog_nat_le (Nat.totient_pos.mpr hN) hT.le hsize have hPT := logLog_mono (shifted_largest_one_lt (hp17 idx)) (hPL idx) obtain ⟨j, hj, hmatch⟩ := Q.matching hN (normalityScale_ge_exp_one (logLog Y)) p hp hd.ne' hdS hphi hphiT idx horder hgap.1 hPT hgap.2 refine ⟨j, hj, ?_⟩ have hE := normality_error_le_delta hT1 have hbnd := hmatch.trans (mul_le_mul_of_nonneg_left hE (by positivity : (0 : ℝ) ≤ 2 * idx.val + 1)) have hdiv := div_le_div_of_nonneg_right hbnd hT.le have hrhs : ((2 * idx.val + 1 : ℝ) * (normalityDelta (logLog Y) * logLog Y)) / logLog Y = (2 * idx.val + 1 : ℝ) * normalityDelta (logLog Y) := by field_simp rw [hrhs] at hdiv change |logLog (largestPrimeFactor (p idx - 1)) / logLog Y - logLog (largestPrimeFactor (Q.primes j - 1)) / logLog Y| ≤ _ rw [← sub_div, abs_div, abs_of_pos hT] exact hdiv /- Original line 36445: Erdos416Proof.CollisionMatching.prefix_exists_of_prefix_data -/ theorem prefix_exists_of_prefix_data {N d : ℕ} (hT1 : 1 ≤ logLog Y) (Q : NormalPreimageList N (normalityScale (logLog Y))) (hN : 0 < N) (B : CollisionBox.PrefixData x (fun idx => CollisionBox.shiftedCoordinate (logLog Y) (p idx)) b e e₀ ε h g θ) (m : CollisionCutoff.Margins L (normalityDelta (logLog Y)) ε h b θ (logLog Y)) (hp : ∀ idx, SNormal (normalityScale (logLog Y)) (p idx)) (hp17 : ∀ idx, 17 ≤ p idx) (hd : 0 < d) (hdS : (largestPrimeFactor d : ℝ) ≤ normalityScale (logLog Y)) (hphi : N.totient = d * ∏ idx, (p idx - 1)) (hsize : (N.totient : ℝ) ≤ Y) (hPL : ∀ idx, (largestPrimeFactor (p idx - 1) : ℝ) ≤ Y) (J : Fin (L + 1)) (hJ : b < CollisionBox.shiftedCoordinate (logLog Y) (p J)) : ∃ ha : J.val + 1 ≤ (largeShiftPrimes N (normalityScale (logLog Y))).card, ∀ idx : Fin (J.val + 1), |CollisionBox.shiftedCoordinate (logLog Y) (p (prefixIndex J idx)) - CollisionBox.shiftedCoordinate (logLog Y) (CollisionClass.prefixPrimes Q ha idx)| ≤ (2 * idx.val + 1 : ℝ) * normalityDelta (logLog Y) := by obtain ⟨j, hj, _⟩ := match_high_of_prefix_data hT1 Q hN B m hp hp17 hd hdS hphi hsize hPL J hJ have ha : J.val + 1 ≤ (largeShiftPrimes N (normalityScale (logLog Y))).card := by have := j.isLt omega refine ⟨ha, ?_⟩ intro idx have hi := B.high_before hJ (prefixIndex_le J idx) obtain ⟨j, hj, hmatch⟩ := match_high_of_prefix_data hT1 Q hN B m hp hp17 hd hdS hphi hsize hPL (prefixIndex J idx) hi have heq : j = Fin.castLE ha idx := Fin.ext hj simpa only [heq, CollisionClass.prefixPrimes, prefixIndex_val] using hmatch /- Original line 36472: Erdos416Proof.CollisionMatching.right_tail_bound_of_prefix_data -/ theorem right_tail_bound_of_prefix_data {N d : ℕ} (hY : Real.exp 1 < Y) (hT1 : 1 < logLog Y) (Q : NormalPreimageList N (normalityScale (logLog Y))) (B : CollisionBox.PrefixData x (fun idx => CollisionBox.shiftedCoordinate (logLog Y) (p idx)) b e e₀ ε h g θ) (m : CollisionCutoff.Margins L (normalityDelta (logLog Y)) ε h b θ (logLog Y)) (hp : ∀ idx, SNormal (normalityScale (logLog Y)) (p idx)) (hp17 : ∀ idx, 17 ≤ p idx) (hd : 0 < d) (hdS : (largestPrimeFactor d : ℝ) ≤ normalityScale (logLog Y)) (hphi : N.totient = d * ∏ idx, (p idx - 1)) (J : Fin (L + 1)) (hJ : b < CollisionBox.shiftedCoordinate (logLog Y) (p J)) (hlast : ∀ idx, J < idx → CollisionBox.shiftedCoordinate (logLog Y) (p idx) ≤ b) : ∀ j : Fin (largeShiftPrimes N (normalityScale (logLog Y))).card, J.val + 1 ≤ j.val → (largestPrimeFactor (Q.primes j - 1) : ℝ) < tailCutoff Y L (CollisionBox.tailCoordinate ε h b (fun idx => CollisionBox.shiftedCoordinate (logLog Y) (p idx)) J) := by by_cases hJL : J.val < L · let zstar := CollisionBox.tailCoordinate ε h b (fun idx => CollisionBox.shiftedCoordinate (logLog Y) (p idx)) J have htail := B.tail_bounds hJ hlast have hcuts := tail_cutoff_properties hY hT1 m htail.1 htail.2.1 have hYone : 1 < Y := (Real.one_lt_exp_iff.mpr (by norm_num : (0 : ℝ) < 1)).trans hY intro j hj let idx : Fin (L + 1) := ⟨J.val + 1, by omega⟩ let j₀ : Fin (largeShiftPrimes N (normalityScale (logLog Y))).card := ⟨J.val + 1, by omega⟩ have htailP : ∀ r : Fin (L + 1), idx ≤ r → (largestPrimeFactor (p r - 1) : ℝ) ≤ CollisionBox.cutoff Y zstar := by intro r hr apply (le_cutoff_iff hYone m.scale_pos (shifted_largest_one_lt (hp17 r))).mpr have hJr : J < r := by change J.val < r.val; change J.val + 1 ≤ r.val at hr; omega exact htail.2.2.2 r hJr have hg := tail_matching_gap hYone hT1 J hJL zstar have hfirst := matching_tail_cutoff p Q.primes hp Q.normal (normalityScale_ge_exp_one (logLog Y)) idx j₀ rfl (rankedAt_of_antitone Q.sorted.antitone j₀) htailP hcuts.1 hcuts.2.1 hcuts.2.2 hg (fun a _ ha _ => Q.interval_balance p (fun r => (hp r).1) hd.ne' hdS hphi ha) have hle : (largestPrimeFactor (Q.primes j - 1) : ℝ) ≤ largestPrimeFactor (Q.primes j₀ - 1) := by exact_mod_cast Q.sorted.antitone (show j₀ ≤ j from hj) exact hle.trans_lt hfirst · have htail := B.tail_bounds hJ hlast intro j hj apply exhausted_right_tail_bound hY hT1 Q m hp hd hdS hphi htail.1 htail.2.1 j have := J.isLt omega /- Original line 36516: Erdos416Proof.CollisionMatching.residual_support_of_prefix_data -/ theorem residual_support_of_prefix_data {N d : ℕ} (hY : Real.exp 1 < Y) (hT1 : 1 < logLog Y) (Q : NormalPreimageList N (normalityScale (logLog Y))) (B : CollisionBox.PrefixData x (fun idx => CollisionBox.shiftedCoordinate (logLog Y) (p idx)) b e e₀ ε h g θ) (m : CollisionCutoff.Margins L (normalityDelta (logLog Y)) ε h b θ (logLog Y)) (hp : ∀ idx, SNormal (normalityScale (logLog Y)) (p idx)) (hp17 : ∀ idx, 17 ≤ p idx) (hd : 0 < d) (hdS : (largestPrimeFactor d : ℝ) ≤ normalityScale (logLog Y)) (hphi : N.totient = d * ∏ idx, (p idx - 1)) (J : Fin (L + 1)) (hJ : b < CollisionBox.shiftedCoordinate (logLog Y) (p J)) (hlast : ∀ idx, J < idx → CollisionBox.shiftedCoordinate (logLog Y) (p idx) ≤ b) : ∀ z ∈ (CollisionClass.normalResidual Q (J.val + 1)).primeFactorsList, (z : ℝ) ≤ tailCutoff Y L (CollisionBox.tailCoordinate ε h b (fun idx => CollisionBox.shiftedCoordinate (logLog Y) (p idx)) J) := by have htail := B.tail_bounds hJ hlast have hcuts := tail_cutoff_properties hY hT1 m htail.1 htail.2.1 have hS : 1 ≤ normalityScale (logLog Y) := (Real.one_lt_exp_iff.mpr (by norm_num : (0 : ℝ) < 1)).le.trans (normalityScale_ge_exp_one (logLog Y)) exact CollisionClass.normalResidual_support Q (J.val + 1) hS (hcuts.1.trans hcuts.2.1.le) (fun j hj => (right_tail_bound_of_prefix_data hY hT1 Q B m hp hp17 hd hdS hphi J hJ hlast j hj).le) /- Original line 36536: Erdos416Proof.CollisionMatching.paired_coordinate_bounds_of_prefix_data -/ theorem paired_coordinate_bounds_of_prefix_data {δ : ℝ} {w : Fin (L + 1) → ℝ} (B : CollisionBox.PrefixData x w b e e₀ ε h g θ) (m : CollisionCutoff.Margins L δ ε h b θ T) (he₀ : e₀ ≤ δ) (J : Fin (L + 1)) (hJ : b < w J) (q : Fin (J.val + 1) → ℝ) (hmatch : ∀ j, |w (prefixIndex J j) - q j| ≤ (2 * j.val + 1 : ℝ) * δ) (hq : ∀ j, q j ≤ 1) (C : Finset (Fin (J.val + 1))) (hzero : ∀ j : Fin (J.val + 1), j.val = 0 → j ∉ C) : let z := CollisionCutoff.selectedZeta J C ε w let zstar := CollisionBox.tailCoordinate ε h b w J ∀ idx : Fin (CollisionClass.remaining C).card, (CollisionCutoff.mu L δ ε z zstar idx.val ≤ w (CollisionCutoff.selectedIndex J C idx) ∧ w (CollisionCutoff.selectedIndex J C idx) ≤ CollisionCutoff.nu L δ z zstar idx.val) ∧ (CollisionCutoff.mu L δ ε z zstar idx.val ≤ q (CollisionClass.index C idx) ∧ q (CollisionClass.index C idx) ≤ CollisionCutoff.nu L δ z zstar idx.val) := by intro z zstar idx have hδ := m.delta_nonneg have hε := m.mesh_pos have hL : (0 : ℝ) ≤ L := Nat.cast_nonneg L have hm := hmatch (CollisionClass.index C idx) rw [← selectedIndex_eq_prefixIndex J C idx] at hm by_cases hi0 : idx.val = 0 · have hfirst := CollisionCutoff.selectedIndex_first J C hzero idx hi0 have hj0 := CollisionClass.index_first C hzero idx hi0 rw [hfirst, hj0] at hm norm_num only [Nat.cast_zero, mul_zero, zero_add, one_mul] at hm have habs := abs_le.mp hm have hw := B.head_approximation have hwupper := B.head_le have hqupper := hq (CollisionClass.index C idx) rw [CollisionCutoff.mu, hi0, CollisionCutoff.nu_zero, hfirst] constructor <;> constructor <;> nlinarith · have hip : 0 < idx.val := Nat.pos_of_ne_zero hi0 have hsel := CollisionCutoff.selectedIndex_le J C idx have hhigh := B.high_before hJ hsel have hpos : 0 < (CollisionCutoff.selectedIndex J C idx).val := lt_of_lt_of_le hip (CollisionCutoff.selectedIndex_val_ge J C idx) have hrlo : w (CollisionCutoff.selectedIndex J C idx) ≤ z idx := (B.rounded_bounds hhigh).1 have hrhi : z idx ≤ w (CollisionCutoff.selectedIndex J C idx) + ε := ((B.rounded_bounds hhigh).2 hpos).le have hjL : ((CollisionClass.index C idx).val : ℝ) ≤ L := by have hj := (CollisionClass.index C idx).isLt have hJL := J.isLt exact_mod_cast (show (CollisionClass.index C idx).val ≤ L by omega) have hcoef : (2 * (CollisionClass.index C idx).val + 1 : ℝ) * δ ≤ (2 * L + 1 : ℝ) * δ := by have hc := mul_le_mul_of_nonneg_right hjL hδ nlinarith have habs := abs_le.mp (hm.trans hcoef) have hnu : CollisionCutoff.nu L δ z zstar idx.val = z idx + (2 * L + 1 : ℝ) * δ := CollisionCutoff.nu_internal L δ z zstar hip idx.isLt rw [CollisionCutoff.mu, hnu] constructor <;> constructor <;> nlinarith /- Original line 36589: Erdos416Proof.CollisionMatching.paired_intervals_of_prefix_data -/ theorem paired_intervals_of_prefix_data {N : ℕ} (hY : Real.exp 1 < Y) (Q : NormalPreimageList N (normalityScale (logLog Y))) (hN : 0 < N) (B : CollisionBox.PrefixData x (fun idx => CollisionBox.shiftedCoordinate (logLog Y) (p idx)) b e e₀ ε h g θ) (m : CollisionCutoff.Margins L (normalityDelta (logLog Y)) ε h b θ (logLog Y)) (he₀ : e₀ ≤ normalityDelta (logLog Y)) (hp17 : ∀ idx, 17 ≤ p idx) (hsize : (N.totient : ℝ) ≤ Y) (J : Fin (L + 1)) (hJ : b < CollisionBox.shiftedCoordinate (logLog Y) (p J)) (ha : J.val + 1 ≤ (largeShiftPrimes N (normalityScale (logLog Y))).card) (hmatch : ∀ j : Fin (J.val + 1), |CollisionBox.shiftedCoordinate (logLog Y) (p (prefixIndex J j)) - CollisionBox.shiftedCoordinate (logLog Y) (CollisionClass.prefixPrimes Q ha j)| ≤ (2 * j.val + 1 : ℝ) * normalityDelta (logLog Y)) (C : Finset (Fin (J.val + 1))) (hzero : ∀ j : Fin (J.val + 1), j.val = 0 → j ∉ C) : let w := fun idx => CollisionBox.shiftedCoordinate (logLog Y) (p idx) let z := CollisionCutoff.selectedZeta J C ε w let zstar := CollisionBox.tailCoordinate ε h b w J ∀ idx : Fin (CollisionClass.remaining C).card, (CollisionCutoff.lower Y L (normalityDelta (logLog Y)) ε z zstar idx.val ≤ (largestPrimeFactor (p (CollisionCutoff.selectedIndex J C idx) - 1) : ℝ) ∧ (largestPrimeFactor (p (CollisionCutoff.selectedIndex J C idx) - 1) : ℝ) ≤ CollisionCutoff.upper Y L (normalityDelta (logLog Y)) z zstar idx.val) ∧ (CollisionCutoff.lower Y L (normalityDelta (logLog Y)) ε z zstar idx.val ≤ (largestPrimeFactor (CollisionClass.prefixPrimes Q ha (CollisionClass.index C idx) - 1) : ℝ) ∧ (largestPrimeFactor (CollisionClass.prefixPrimes Q ha (CollisionClass.index C idx) - 1) : ℝ) ≤ CollisionCutoff.upper Y L (normalityDelta (logLog Y)) z zstar idx.val) := by intro w z zstar have hYone : 1 < Y := (Real.one_lt_exp_iff.mpr (by norm_num : (0 : ℝ) < 1)).trans hY have hSone : 1 ≤ normalityScale (logLog Y) := (Real.one_lt_exp_iff.mpr (by norm_num : (0 : ℝ) < 1)).le.trans (normalityScale_ge_exp_one (logLog Y)) have hQone : ∀ j : Fin (J.val + 1), 1 < (largestPrimeFactor (CollisionClass.prefixPrimes Q ha j - 1) : ℝ) := fun j => hSone.trans_lt (Q.large (Fin.castLE ha j)) have hqupper : ∀ j : Fin (J.val + 1), CollisionBox.shiftedCoordinate (logLog Y) (CollisionClass.prefixPrimes Q ha j) ≤ 1 := by intro j have hLP : (largestPrimeFactor (CollisionClass.prefixPrimes Q ha j - 1) : ℝ) ≤ Y := (Nat.cast_le.mpr (Q.shifted_le_totient hN (Fin.castLE ha j))).trans hsize have hLL := logLog_mono (hQone j) hLP exact (div_le_div_of_nonneg_right hLL m.scale_pos.le).trans_eq (div_self m.scale_pos.ne') have hcoords := paired_coordinate_bounds_of_prefix_data B m he₀ J hJ (fun j => CollisionBox.shiftedCoordinate (logLog Y) (CollisionClass.prefixPrimes Q ha j)) hmatch hqupper C hzero intro idx have hc := hcoords idx have hleft := shifted_largest_one_lt (hp17 (CollisionCutoff.selectedIndex J C idx)) have hright := hQone (CollisionClass.index C idx) exact ⟨⟨(cutoff_le_iff hYone m.scale_pos hleft).mpr hc.1.1, (le_cutoff_iff hYone m.scale_pos hleft).mpr hc.1.2⟩, ⟨(cutoff_le_iff hYone m.scale_pos hright).mpr hc.2.1, (le_cutoff_iff hYone m.scale_pos hright).mpr hc.2.2⟩⟩ /- Original line 36641: Erdos416Proof.CollisionMatching.matched_of_boxes_of_prefix_data -/ theorem matched_of_boxes_of_prefix_data {N d : ℕ} (hY : Real.exp 1 < Y) (hT1 : 1 < logLog Y) (Q : NormalPreimageList N (normalityScale (logLog Y))) (hN : 0 < N) (B : CollisionBox.PrefixData x (fun idx => CollisionBox.shiftedCoordinate (logLog Y) (p idx)) b e e₀ ε h g θ) (m : CollisionCutoff.Margins L (normalityDelta (logLog Y)) ε h b θ (logLog Y)) (he₀ : e₀ ≤ normalityDelta (logLog Y)) (hp : ∀ idx, SNormal (normalityScale (logLog Y)) (p idx)) (hp17 : ∀ idx, 17 ≤ p idx) (hd : 0 < d) (hdS : (largestPrimeFactor d : ℝ) ≤ normalityScale (logLog Y)) (hphi : N.totient = d * ∏ idx, (p idx - 1)) (hsize : (N.totient : ℝ) ≤ Y) (J : Fin (L + 1)) (hJ : b < CollisionBox.shiftedCoordinate (logLog Y) (p J)) (hlast : ∀ idx, J < idx → CollisionBox.shiftedCoordinate (logLog Y) (p idx) ≤ b) : ∃ ha : J.val + 1 ≤ (largeShiftPrimes N (normalityScale (logLog Y))).card, MatchedPreimage Y p Q ε h b J ha := by have hYone : 1 < Y := (Real.one_lt_exp_iff.mpr (by norm_num : (0 : ℝ) < 1)).trans hY have hPL : ∀ idx, (largestPrimeFactor (p idx - 1) : ℝ) ≤ Y := by intro idx have hp0 : 0 < p idx - 1 := by have := hp17 idx; omega exact (Nat.cast_le.mpr ((largestPrimeFactor_le hp0).trans (shifted_factor_le_totient hN hphi idx))).trans hsize obtain ⟨ha, hmatches⟩ := prefix_exists_of_prefix_data hT1.le Q hN B m hp hp17 hd hdS hphi hsize hPL J hJ refine ⟨ha, hmatches, ?_, right_tail_bound_of_prefix_data hY hT1 Q B m hp hp17 hd hdS hphi J hJ hlast, residual_support_of_prefix_data hY hT1 Q B m hp hp17 hd hdS hphi J hJ hlast, ?_⟩ · intro idx hi z hz have ht := B.tail_bounds hJ hlast have hcuts := tail_cutoff_properties hY hT1 m ht.1 ht.2.1 have hLP := (le_cutoff_iff hYone m.scale_pos (shifted_largest_one_lt (hp17 idx))).mpr (ht.2.2.2 idx hi) have hzP : (z : ℝ) ≤ largestPrimeFactor (p idx - 1) := Nat.cast_le.mpr (primeFactorsList_le_largestPrimeFactor hz) exact hzP.trans (hLP.trans hcuts.2.1.le) · intro C hzero have hk := CollisionClass.remaining_card_pos C (by omega) hzero exact ⟨hk, CollisionCutoff.cutoff_conditions hY (CollisionCutoff.selected_of_prefix_boxes B J hJ hlast C hzero) m hk, paired_intervals_of_prefix_data hY Q hN B m he₀ hp17 hsize J hJ ha hmatches C hzero⟩ /- Original line 36675: Erdos416Proof.CollisionMatching.matched_varying_preimage_eventually -/ theorem matched_varying_preimage_eventually (A : ℝ) : ∀ᶠ Y : ℝ in atTop, ∀ (L : ℕ) (p : Fin (L + 1) → ℕ) (N d : ℕ) (Q : NormalPreimageList N (normalityScale (logLog Y))), (L : ℝ) ≤ A * Real.log (logLog Y) → (∀ idx, SNormal (normalityScale (logLog Y)) (p idx)) → (∀ idx, 17 ≤ p idx) → Antitone p → (∀ idx : Fin (L + 1), 0 < idx.val → ∀ hi : idx.val + 1 < L + 1, (1+(logLog Y)^(-1/100 : ℝ)) * logLog (p ⟨idx.val + 1, hi⟩) ≤ logLog (p idx)) → (∀ idx, 0 < idx.val → (p idx : ℝ) ≤ CollisionBox.cutoff Y (1-(logLog Y)^(-1/100 : ℝ)/2)) → Y ^ (9 / 10 : ℝ) < (p 0 : ℝ) → 0 < N → 0 < d → (largestPrimeFactor d : ℝ) ≤ normalityScale (logLog Y) → N.totient = d * ∏ idx, (p idx - 1) → (N.totient : ℝ) ≤ Y → ∃ J : Fin (L + 1), (∀ idx, idx ≤ J ↔ (logLog Y) ^ (-1 / 3 : ℝ) < CollisionBox.shiftedCoordinate (logLog Y) (p idx)) ∧ ∃ ha : J.val + 1 ≤ (largeShiftPrimes N (normalityScale (logLog Y))).card, MatchedPreimage Y p Q (1 / logLog Y) ((logLog Y) ^ (-2 / 5 : ℝ)) ((logLog Y) ^ (-1 / 3 : ℝ)) J ha := by have hT : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [hT.eventually (CollisionBox.prefix_prime_data_eventually 1), hT.eventually FordLower.varying_coordinate_scales_eventually, hT.eventually (FordLower.varying_cutoff_margins_eventually A), hT.eventually head_error_eventually, hT.eventually_ge_atTop 2, eventually_gt_atTop (Real.exp 1)] with Y hpdata hscales hmargin he₀ hT2 hY intro L p N d Q hL hp hp17 horder hstep hlower htop hN hd hdS hphi hsize have hYone : 1 < Y := (Real.one_lt_exp_iff.mpr (by norm_num : (0 : ℝ) < 1)).trans hY have hYpos : 0 < Y := by linarith have hshift : ∀ idx, ((p idx - 1 : ℕ) : ℝ) ≤ Y := fun idx => (Nat.cast_le.mpr (shifted_factor_le_totient hN hphi idx)).trans hsize have hpsize : ∀ idx, (p idx : ℝ) ≤ Y * logLog Y := by intro idx have hi := hshift idx rw [Nat.cast_sub (show 1 ≤ p idx by have := hp17 idx; omega), Nat.cast_one] at hi have hm := mul_le_mul_of_nonneg_left hT2 hYpos.le nlinarith have hYY : Real.exp (Real.exp (logLog Y)) = Y := exp_exp_logLog hYone have hκ : 1 < 1+(logLog Y)^(-1/100 : ℝ) := by have hp := Real.rpow_pos_of_pos (by linarith : 0 < logLog Y) (-1/100 : ℝ) linarith have B := hpdata (1+(logLog Y)^(-1/100 : ℝ)) (1-(logLog Y)^(-1/100 : ℝ)/2) hκ hscales.2.2.2.1 (by linarith [hscales.2.2.2.2.1]) L p hp hp17 (by simpa only [one_mul, hYY] using hpsize) horder hstep (by simpa only [hYY] using hlower) (by simpa only [hYY] using htop) (by simpa only [hYY] using hshift 0) have m := hmargin L hL obtain ⟨J, hprefix, _, _, _, hupp, _, htail⟩ := B.exists_prefix have hJ := (hprefix J).mp le_rfl have hlast' : ∀ idx, J < idx → CollisionBox.shiftedCoordinate (logLog Y) (p idx) ≤ (logLog Y) ^ (-1 / 3 : ℝ) := fun idx hi => (htail idx hi).trans hupp exact ⟨J, hprefix, matched_of_boxes_of_prefix_data hY (by linarith) Q hN B m he₀ hp hp17 hd hdS hphi hsize J hJ hlast'⟩ end Erdos416Proof.CollisionMatching open Filter Finset Asymptotics open scoped Classical Topology BigOperators namespace Erdos416Proof.FordLower /-- The adjacent gap and the actual totient endpoint give the second-prime cap used by the varying-coordinate boxes. The one-prime case is vacuous. -/ /- Original line 36736: Erdos416Proof.FordLower.tuple_lower_cutoff_of_gap -/ theorem tuple_lower_cutoff_of_gap {L : ℕ} {Z : ℝ} (p : Fin (L+1) → ℕ) (hp : ∀ idx, (p idx).Prime) (hodd : ∀ idx, 3 ≤ p idx) (ho : StrictAnti p) (hZ : 1 < Z) (hT : 1 ≤ logLog Z) (hsize : ((∏ idx, p idx).totient : ℝ) ≤ Z) (hg : ∀ idx j : Fin (L+1), j.val = idx.val+1 → (1+(logLog Z)^(-1/100 : ℝ))*logLog (p j) ≤ logLog (p idx)) : ∀ idx, 0 < idx.val → (p idx : ℝ) ≤ CollisionBox.cutoff Z (1-(logLog Z)^(-1/100 : ℝ)/2) := by have hT0 : 0 < logLog Z := by linarith have hk : 0 < 1+(logLog Z)^(-1/100 : ℝ) := by positivity intro idx hi let j : Fin (L+1) := ⟨1, by have := idx.isLt; omega⟩ have hn : 0 < ∏ j, p j := prod_pos (by intro j _; exact (hp j).pos) have hpi : (1 : ℝ) < p idx := by exact_mod_cast (hp idx).one_lt have hhead : (p 0 : ℝ) ≤ Z := by apply le_trans (Nat.cast_le.mpr (prime_le_totient_of_other_odd_prime hn (hp 0) (hp idx) (hodd idx) (ne_of_gt (ho (show (0 : Fin (L+1)) < idx from hi))) (dvd_prod_of_mem _ (mem_univ 0)) (dvd_prod_of_mem _ (mem_univ idx)))) hsize have hlog : logLog (p 0) ≤ logLog Z := logLog_mono (by exact_mod_cast (hp 0).one_lt) hhead have hnext : logLog (p idx) ≤ logLog (p j) := logLog_mono hpi (Nat.cast_le.mpr (ho.antitone (show j ≤ idx from hi))) have hgap := hg 0 j rfl have hpoint : logLog (p idx) ≤ logLog Z/(1+(logLog Z)^(-1/100 : ℝ)) := by apply (le_div_iff₀ hk).mpr nlinarith apply (CollisionMatching.le_cutoff_iff hZ hT0 hpi).mpr calc logLog (p idx)/logLog Z ≤ (logLog Z/(1+(logLog Z)^(-1/100 : ℝ)))/logLog Z := div_le_div_of_nonneg_right hpoint hT0.le _ = 1/(1+(logLog Z)^(-1/100 : ℝ)) := by field_simp _ ≤ _ := by linarith [varying_contraction_lower hT] /-- The product of logarithms below the varying second-coordinate cap uses only a small fixed fraction of log Z. -/ /- Original line 36769: Erdos416Proof.FordLower.varying_lower_log_mass_eventually -/ theorem varying_lower_log_mass_eventually {A : ℝ} (hA : 0 ≤ A) : ∀ᶠ T : ℝ in atTop, ∀ L : ℕ, (L : ℝ) ≤ A*Real.log T → (L : ℝ)*Real.exp ((1-T^(-1/100 : ℝ)/2)*T) ≤ Real.exp T/20 := by let c : ℝ := 1/(20*(A+1)) have hc : 0 < c := by dsimp [c]; positivity have hsmall := (isLittleO_log_rpow_rpow_atTop (1 : ℝ) (by norm_num : (0 : ℝ) < 99/100)).bound (by norm_num : (0 : ℝ) < 1/4) have hlarge := (isLittleO_log_rpow_rpow_atTop (1 : ℝ) (by norm_num : (0 : ℝ) < 2)).bound hc filter_upwards [hsmall, hlarge, eventually_gt_atTop (1 : ℝ)] with T hsmall hlarge hT have hT0 : 0 < T := by linarith have hlog : 0 ≤ Real.log T := (Real.log_pos hT).le simp only [Real.rpow_one, Real.norm_eq_abs, abs_of_nonneg hlog, abs_of_pos (Real.rpow_pos_of_pos hT0 (99/100 : ℝ))] at hsmall simp only [Real.rpow_one, Real.norm_eq_abs, abs_of_nonneg hlog, abs_of_pos (Real.rpow_pos_of_pos hT0 (2 : ℝ))] at hlarge rw [show (2 : ℝ) = (2 : ℕ) by norm_num, Real.rpow_natCast] at hlarge have hpower : T^(-1/100 : ℝ)*T = T^(99/100 : ℝ) := by calc _ = T^(-1/100 : ℝ)*T^(1 : ℝ) := by rw [Real.rpow_one] _ = T^((-1/100 : ℝ)+1) := (Real.rpow_add hT0 _ _).symm _ = _ := by congr 1; norm_num have hexponent : (1-T^(-1/100 : ℝ)/2)*T ≤ T-2*Real.log T := by nlinarith have hexplog : Real.exp (2*Real.log T) = T^2 := by rw [show (2 : ℝ) = (2 : ℕ) by norm_num, Real.exp_nat_mul, Real.exp_log hT0] have hcap : Real.exp ((1-T^(-1/100 : ℝ)/2)*T) ≤ Real.exp T/T^2 := by simpa only [Real.exp_sub, hexplog] using Real.exp_le_exp.mpr hexponent intro L hL have hL0 : (0 : ℝ) ≤ L := Nat.cast_nonneg L have hcoeff : 20*(L : ℝ) ≤ T^2 := by calc _ ≤ (20*(A+1))*Real.log T := by nlinarith _ ≤ (20*(A+1))*(c*T^2) := mul_le_mul_of_nonneg_left hlarge (by positivity) _ = _ := by dsimp [c]; field_simp calc _ ≤ (L : ℝ)*(Real.exp T/T^2) := mul_le_mul_of_nonneg_left hcap hL0 _ = Real.exp T*((L : ℝ)/T^2) := by ring _ ≤ Real.exp T*(1/20 : ℝ) := mul_le_mul_of_nonneg_left ((div_le_iff₀ (pow_pos hT0 2)).mpr (by linarith)) (Real.exp_pos T).le _ = _ := by ring /- Original line 36810: Erdos416Proof.FordLower.tuple_lower_product_eventually -/ theorem tuple_lower_product_eventually {A : ℝ} (hA : 0 ≤ A) : ∀ᶠ Z : ℝ in atTop, ∀ (L : ℕ) (p : Fin (L+1) → ℕ), (L : ℝ) ≤ A*Real.log (logLog Z) → (∀ idx, 0 < idx.val → (p idx : ℝ) ≤ CollisionBox.cutoff Z (1-(logLog Z)^(-1/100 : ℝ)/2)) → (∏ idx : Fin L, (p idx.succ : ℝ)) ≤ Z^(1/20 : ℝ) := by have hLL : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [hLL.eventually (varying_lower_log_mass_eventually hA), eventually_gt_atTop (1 : ℝ)] with Z hmass hZ intro L p hL hp have hZ0 : 0 < Z := by linarith have hlogZ : 0 < Real.log Z := Real.log_pos hZ have hexpT : Real.exp (logLog Z) = Real.log Z := Real.exp_log hlogZ have hpower : (Real.log Z)^(1-(logLog Z)^(-1/100 : ℝ)/2) = Real.exp ((1-(logLog Z)^(-1/100 : ℝ)/2)*logLog Z) := by rw [Real.rpow_def_of_pos hlogZ] congr 1 unfold logLog ring have hm := hmass L hL rw [hexpT, ← hpower] at hm calc _ ≤ ∏ _i : Fin L, CollisionBox.cutoff Z (1-(logLog Z)^(-1/100 : ℝ)/2) := prod_le_prod (by intro idx _; exact Nat.cast_nonneg _) (by intro idx _; exact hp idx.succ (by simp[Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint] )) _ = Real.exp ((L : ℝ)*(Real.log Z)^(1-(logLog Z)^(-1/100 : ℝ)/2)) := by simp only [prod_const, card_univ, Fintype.card_fin, CollisionBox.cutoff, ← Real.exp_nat_mul] _ ≤ Real.exp (Real.log Z/20) := Real.exp_le_exp.mpr hm _ = _ := by rw [Real.rpow_def_of_pos hZ0]; congr 1; ring /-- A surviving tuple with a small leading prime is itself small. It can subsequently be charged by counting original integers. -/ /- Original line 36839: Erdos416Proof.FordLower.tuple_small_of_small_head_eventually -/ theorem tuple_small_of_small_head_eventually {A : ℝ} (hA : 0 ≤ A) : ∀ᶠ Z : ℝ in atTop, ∀ (L : ℕ) (p : Fin (L+1) → ℕ), (L : ℝ) ≤ A*Real.log (logLog Z) → (∀ idx, (p idx).Prime) → (∀ idx, 3 ≤ p idx) → StrictAnti p → ((∏ idx, p idx).totient : ℝ) ≤ Z → (∀ idx j : Fin (L+1), j.val = idx.val+1 → (1+(logLog Z)^(-1/100 : ℝ))*logLog (p j) ≤ logLog (p idx)) → (p 0 : ℝ) ≤ Z^(9/10 : ℝ) → ((∏ idx, p idx : ℕ) : ℝ) ≤ Z^(19/20 : ℝ) := by have hLL : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [tuple_lower_product_eventually hA, hLL.eventually_ge_atTop 1, eventually_gt_atTop (1 : ℝ)] with Z hprod hT hZ intro L p hL hp hodd ho hsize hg htop have hcap := tuple_lower_cutoff_of_gap p hp hodd ho hZ hT hsize hg have htail := hprod L p hL hcap rw [Nat.cast_prod, Fin.prod_univ_succ] calc (p 0 : ℝ)*(∏ idx : Fin L, (p idx.succ : ℝ)) ≤ Z^(9/10 : ℝ)*Z^(1/20 : ℝ) := mul_le_mul htop htail (prod_nonneg (by intro idx _; exact Nat.cast_nonneg _)) (Real.rpow_nonneg (by linarith : 0 ≤ Z) _) _ = Z^((9/10 : ℝ)+1/20) := (Real.rpow_add (by linarith : 0 < Z) _ _).symm _ = _ := by congr 1; norm_num end Erdos416Proof.FordLower namespace Erdos416Proof.FordLower /- Original line 36865: Erdos416Proof.FordLower.survivor_record_eventually -/ theorem survivor_record_eventually (A : ℝ) : ∀ᶠ Y : ℝ in atTop, ∀ (L n w : ℕ) (p : Fin (L+1) → ℕ), (L : ℝ) ≤ A*Real.log (logLog Y) → (∏ idx, p idx) = n → (∀ idx, (p idx).Prime) → (∀ idx, 17 ≤ p idx) → StrictAnti p → (∀ idx j : Fin (L+1), j.val = idx.val+1 → (1+(logLog Y)^(-1/100 : ℝ))*logLog (p j) ≤ logLog (p idx)) → (∑ idx ∈ Icc 1 L, fordWeight idx*CollisionFacet.extend (fun j => CollisionBox.primeCoordinate (logLog Y) (p j)) idx) ≤ 1-(logLog Y)^(-1/8 : ℝ) → SuffixSurvivor Y n w → Y^(9/10 : ℝ) < (p 0 : ℝ) → ∃ r : CollisionSum.RecordWithEmptyTail Y L 1, r.integer = n := by have hLL : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [CollisionMatching.matched_varying_preimage_eventually A, CollisionRecord.preimage_le_top_square_eventually, fourth_log_cutoff_lt_normalityScale, hLL.eventually_ge_atTop 1, eventually_gt_atTop (1 : ℝ)] with Y hmatch htopsize hcut hT hY intro L n w p hL heq hp hp17 ho hg hfacet hs htop have hS : 1 ≤ normalityScale (logLog Y) := (Real.one_lt_exp_iff.mpr (by norm_num : (0 : ℝ) < 1)).le.trans (normalityScale_ge_exp_one _) have hdS : (largestPrimeFactor 1 : ℝ) ≤ normalityScale (logLog Y) := by simpa only [largestPrimeFactor_one, Nat.cast_one] using hS have hleft : ∀ idx, SNormal (normalityScale (logLog Y)) (p idx) := by intro idx apply hs.normal_left (p idx) (hp idx) rw [← heq] exact dvd_prod_of_mem _ (mem_univ idx) have hright : ∀ q ∈ w.primeFactors, SNormal (normalityScale (logLog Y)) q := fun q hq => hs.normal_right q (Nat.prime_of_mem_primeFactors hq) (Nat.dvd_of_mem_primeFactors hq) have hφ : w.totient = 1*∏ idx, (p idx-1) := by rw [one_mul, ← totient_prod_injective_primes univ p (fun idx _ => hp idx) ho.injective.injOn, heq] exact hs.equation have hsize : (w.totient : ℝ) ≤ Y := hs.equation ▸ hs.size have hpsize : ((∏ idx, p idx).totient : ℝ) ≤ Y := by rw [heq]; exact hs.size have hcap := tuple_lower_cutoff_of_gap p hp (fun idx => by have := hp17 idx; omega) ho hY hT hpsize hg have hmax : largestPrimeFactor n = p 0 := by rw [← heq] simpa [Erdos416Proof.CollisionFacet.extend_apply, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.largestPrimeFactor_one, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, suffixProduct] using largestPrimeFactor_suffixProduct hp ho (j := 0) (by omega) have hneq : largestPrimeFactor w ≠ p 0 := by simpa only [hmax] using hs.largest_ne have hsq := hs.square_totient.mono hcut.le obtain ⟨Q⟩ := exists_NormalPreimageList hs.witness_pos hS hright (hs.square_witness.mono hcut.le) hsq obtain ⟨J, _, ha, hm⟩ := hmatch L p w 1 Q hL hleft hp17 ho.antitone (fun idx _ hi => hg idx ⟨idx.val+1, hi⟩ rfl) hcap htop hs.witness_pos (by norm_num) hdS hφ hsize have hc := CollisionRecord.complete_of_matched_with_empty_tail Q J ha hm hs.witness_pos hleft ho.injective hφ hsize hsq htop (htopsize w (p 0) hs.witness_pos hsize htop) hneq refine ⟨CollisionSum.record_of_complete_with_empty_tail hc hp17 ho.antitone hfacet, ?_⟩ exact heq /- Original line 36909: Erdos416Proof.FordLower.small_power_le_pruning_scale_eventually -/ theorem small_power_le_pruning_scale_eventually : ∀ᶠ Y : ℝ in atTop, Y^(19/20 : ℝ) ≤ Y/(Real.log Y*(logLog Y)^2) := by have hsmall := (log_pow_mul_rpow_littleO 3 (by norm_num : (19/20 : ℝ) < 1)).bound (by norm_num : (0 : ℝ) < 1) have hLL : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [hsmall, hLL.eventually_ge_atTop 1, eventually_gt_atTop (1 : ℝ)] with Y hb hT hY have hY0 : 0 < Y := by linarith have hlog : 0 < Real.log Y := Real.log_pos hY have hT0 : 0 < logLog Y := by linarith have hTL : logLog Y ≤ Real.log Y := Real.log_le_self hlog.le have hpow : 0 ≤ Y^(19/20 : ℝ) := Real.rpow_nonneg hY0.le _ simp only [Real.rpow_one, one_mul, Real.norm_eq_abs, abs_of_pos hY0, abs_of_nonneg (mul_nonneg (pow_nonneg hlog.le 3) hpow)] at hb apply (le_div_iff₀ (mul_pos hlog (pow_pos hT0 2))).mpr have hsq := pow_le_pow_left₀ hT0.le hTL 2 have hm := mul_le_mul_of_nonneg_left hsq (mul_nonneg hpow hlog.le) nlinarith /-- The whole surviving family is counted. Small leading primes are charged to small original integers; large leading primes yield actual sieve records. -/ /- Original line 36929: Erdos416Proof.FordLower.suffix_survivors_count_eventually -/ theorem suffix_survivors_count_eventually {A : ℝ} (hA : 0 ≤ A) : ∀ᶠ Y : ℝ in atTop, ∀ (L : ℕ) (F : Finset ℕ) (p : ℕ → Fin (L+1) → ℕ) (w : ℕ → ℕ), (L : ℝ) ≤ A*Real.log (logLog Y) → (∀ n ∈ F, (∏ idx, p n idx) = n) → (∀ n ∈ F, ∀ idx, (p n idx).Prime) → (∀ n ∈ F, ∀ idx, 17 ≤ p n idx) → (∀ n ∈ F, StrictAnti (p n)) → (∀ n ∈ F, ∀ idx j : Fin (L+1), j.val = idx.val+1 → (1+(logLog Y)^(-1/100 : ℝ))*logLog (p n j) ≤ logLog (p n idx)) → (∀ n ∈ F, (∑ idx ∈ Icc 1 L, fordWeight idx*CollisionFacet.extend (fun j => CollisionBox.primeCoordinate (logLog Y) (p n j)) idx) ≤ 1-(logLog Y)^(-1/8 : ℝ)) → (∀ n ∈ F, SuffixSurvivor Y n (w n)) → (F.card : ℝ) ≤ 2*(Y/(Real.log Y*(logLog Y)^2)) := by have hLL : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [survivor_record_eventually A, CollisionSum.retained_count_with_empty_tail_eventually hA 1 (by norm_num), tuple_small_of_small_head_eventually hA, small_power_le_pruning_scale_eventually, hLL.eventually CollisionSum.exponential_saving_le_inv_sq_eventually, eventually_gt_atTop (1 : ℝ)] with Y hrecord hcount hsmall hsmallscale hexpsave hY intro L F p w hL heq hp hp17 ho hg hfacet hs let G := F.filter (fun n => Y^(9/10 : ℝ) < (p n 0 : ℝ)) let B := F\G have hGF : G ⊆ F := filter_subset _ _ have hY0 : 0 < Y := by linarith have hS : 1 ≤ normalityScale (logLog Y) := (Real.one_lt_exp_iff.mpr (by norm_num : (0 : ℝ) < 1)).le.trans (normalityScale_ge_exp_one _) have hdS : (largestPrimeFactor 1 : ℝ) ≤ normalityScale (logLog Y) := by simpa only [largestPrimeFactor_one, Nat.cast_one] using hS have hlarge : (G.card : ℝ) ≤ Y/Real.log Y * Real.exp (-(1/4 : ℝ)*(logLog Y)^(7/8 : ℝ)) := by have h := hcount L G hL hdS (by intro n hn have hnF := hGF hn exact hrecord L n (w n) (p n) hL (heq n hnF) (hp n hnF) (hp17 n hnF) (ho n hnF) (hg n hnF) (hfacet n hnF) (hs n hnF) (mem_filter.mp hn).2) simpa only [Nat.cast_one, one_mul] using h have hlarge' : (G.card : ℝ) ≤ Y/(Real.log Y*(logLog Y)^2) := by apply hlarge.trans have h := mul_le_mul_of_nonneg_left hexpsave (div_nonneg hY0.le (Real.log_pos hY).le) convert h using 1; ring have hBsub : B ⊆ Icc 1 ⌊Y^(19/20 : ℝ)⌋₊ := by intro n hn obtain ⟨hnF, hnG⟩ := mem_sdiff.mp hn have htop : (p n 0 : ℝ) ≤ Y^(9/10 : ℝ) := by by_contra h exact hnG (mem_filter.mpr ⟨hnF, lt_of_not_ge h⟩) have hsize : ((∏ idx, p n idx).totient : ℝ) ≤ Y := by rw [heq n hnF]; exact (hs n hnF).size have h := hsmall L (p n) hL (hp n hnF) (fun idx => by have := hp17 n hnF idx; omega) (ho n hnF) hsize (hg n hnF) htop rw [heq n hnF] at h exact mem_Icc.mpr ⟨(hs n hnF).positive, Nat.le_floor h⟩ have hBcard : B.card ≤ ⌊Y^(19/20 : ℝ)⌋₊ := by simpa [Erdos416Proof.CollisionFacet.extend_apply, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.largestPrimeFactor_one, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint] using card_le_card hBsub have hB : (B.card : ℝ) ≤ Y^(19/20 : ℝ) := (Nat.cast_le.mpr hBcard).trans (Nat.floor_le (Real.rpow_nonneg hY0.le _)) have hcard : (B.card : ℝ)+(G.card : ℝ) = F.card := by exact_mod_cast card_sdiff_add_card_eq_card hGF linarith end Erdos416Proof.FordLower namespace Erdos416Proof.FordLower open FordScale /-- All geometric inputs for counting a suffix, in a tuple type with its leading prime displayed separately. Its dimension is fixed by the prefix. -/ /- Original line 36997: Erdos416Proof.FordLower.SuffixCountData -/ structure SuffixCountData (Z : ℝ) (L n : ℕ) where primes : Fin (L+1) → ℕ integer : (∏ idx, primes idx) = n prime : ∀ idx, (primes idx).Prime minimum : ∀ idx, 17 ≤ primes idx order : StrictAnti primes gaps : ∀ idx j : Fin (L+1), j.val = idx.val+1 → (1+(logLog Z)^(-1/100 : ℝ))*logLog (primes j) ≤ logLog (primes idx) facet : (∑ idx ∈ Icc 1 L, fordWeight idx*CollisionFacet.extend (fun j => CollisionBox.primeCoordinate (logLog Z) (primes j)) idx) ≤ 1-(logLog Z)^(-1/8 : ℝ) dimension : (L : ℝ) ≤ 5*Real.log (logLog Z) /- Original line 37009: Erdos416Proof.FordLower.record_suffix_count_data_eventually -/ theorem record_suffix_count_data_eventually : ∀ᶠ Z : ℝ in atTop, ∀ (M : ℕ) (A y : ℝ) (a : Fin (coreDimension M (logLog y))) (N : ℕ) (R : PrimeProductRecord M A y a N), 2 ≤ M → 4 ≤ A → 1 < y → 0 < logLog y → (M : ℝ) ≤ 10*Real.log (logLog Z) → ∀ j : ℕ, j < coreDimension M (logLog y)+1 → ((suffixProduct R.fullTuple j).totient : ℝ) ≤ Z → Nonempty (SuffixCountData Z (coreDimension M (logLog y)-j) (suffixProduct R.fullTuple j)) := by filter_upwards [record_suffix_factor_count_eventually, record_suffix_gap_eventually (η := 1/100) (by norm_num), record_properSuffixTuple_gap_eventually (η := 1/100) (by norm_num), record_fullTuple_sieve_facet_eventually, record_properSuffixTuple_sieve_facet_eventually] with Z hcount hfullgap hpropergap hfullfacet hproperfacet intro M A y a N R hM hA hy ht hMsize j hj hsize have hA1 : 1 ≤ A := by linarith have hΩ := hcount M A y a N R hA1 ht j hj hsize rw [suffixProduct_factor_count R.fullTuple_prime hj] at hΩ have hdim : ((coreDimension M (logLog y)-j : ℕ) : ℝ) ≤ 5*Real.log (logLog Z) := by apply le_trans (Nat.cast_le.mpr (show coreDimension M (logLog y)-j ≤ coreDimension M (logLog y)+1-j by omega)) hΩ cases j with | zero => have hprod : (∏ idx, R.fullTuple idx) = suffixProduct R.fullTuple 0 := by simp [Erdos416Proof.CollisionFacet.extend_apply, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, suffixProduct] have hN : (N.totient : ℝ) ≤ Z := by rw [← hprod, R.fullTuple_product] at hsize; exact hsize refine ⟨{ primes := R.fullTuple integer := hprod prime := R.fullTuple_prime minimum := record_fullTuple_seventeen R hA order := R.fullTuple_order gaps := ?_ facet := hfullfacet M A y a N R hM hA1 hy ht hMsize hN dimension := hdim }⟩ intro idx k hik simpa only [neg_div] using hfullgap M A y a N R hM hA1 ht hMsize 0 hj hsize idx k (Nat.zero_le _) hik | succ j => let idx : Fin (coreDimension M (logLog y)) := ⟨j, by omega⟩ refine ⟨{ primes := properSuffixTuple R.lower idx integer := record_properSuffixTuple_integer R idx prime := properSuffixTuple_prime R.lower_prime idx minimum := ?_ order := properSuffixTuple_order R.lower_order idx gaps := ?_ facet := hproperfacet M A y a N R hM hA1 ht hMsize idx hsize dimension := hdim }⟩ · intro k simpa only [properSuffixTuple_eq_full R.leading R.lower idx, PrimeProductRecord.fullTuple] using record_fullTuple_seventeen R hA (properSuffixIndex idx k) · intro u v huv simpa only [neg_div] using hpropergap M A y a N R hM hA1 ht hMsize idx hsize u v huv /-- Uniform count for the actual suffix family from the maximal-prefix partition, including its normal-prime and square pruning losses. -/ /- Original line 37061: Erdos416Proof.FordLower.actual_suffix_count_eventually -/ theorem actual_suffix_count_eventually : ∀ᶠ Z : ℝ in atTop, ∀ (M : ℕ) (A y : ℝ) (a : Fin (coreDimension M (logLog y))) (F : Finset ℕ) (q : ℕ → Fin (coreDimension M (logLog y)+1) → ℕ), 2 ≤ M → 4 ≤ A → 1 < y → 0 < logLog y → (M : ℝ) ≤ 10*Real.log (logLog Z) → (∀ n ∈ F, ∃ R : PrimeProductRecord M A y a n, R.fullTuple = q n) → ∀ j : ℕ, ((suffixesUpTo F q j Z).card : ℝ) ≤ 5*(Z/(Real.log Z*(logLog Z)^2)) := by filter_upwards [actual_suffix_pruning_eventually, record_suffix_count_data_eventually, suffix_survivors_count_eventually (A := 5) (by norm_num), eventually_gt_atTop (1 : ℝ)] with Z hprune hdata hcount hZ intro M A y a F q hM hA hy ht hMsize hrecords j obtain ⟨G, w, hGF, _, hG, hpruned⟩ := hprune M A y a F q (by linarith) ht hrecords j have hdataG : ∀ s ∈ G, Nonempty (SuffixCountData Z (coreDimension M (logLog y)-j) s) := by intro s hs obtain ⟨hsF, hsize⟩ := mem_filter.mp (hGF hs) obtain ⟨n, hn, rfl⟩ := mem_image.mp hsF obtain ⟨hnF, hnw, hdepth⟩ := mem_prefixCollisionClass.mp hn obtain ⟨R, hR⟩ := hrecords n hnF have hprod : (∏ idx, q n idx) = n := hR ▸ R.fullTuple_product have hj : j < coreDimension M (logLog y)+1 := hdepth ▸ prefixDepth_lt hprod hnw rw [← hR] at hsize ⊢ exact hdata M A y a n R hM hA hy ht hMsize j hj hsize have hGcount : (G.card : ℝ) ≤ 2*(Z/(Real.log Z*(logLog Z)^2)) := by by_cases hempty : G = ∅ · rw [hempty, card_empty, Nat.cast_zero] exact mul_nonneg (by norm_num) (div_nonneg (by linarith) (mul_nonneg (Real.log_pos hZ).le (sq_nonneg _))) · have hne := nonempty_iff_ne_empty.mpr hempty let r : ∀ s : G, SuffixCountData Z (coreDimension M (logLog y)-j) s := by intro s exact Classical.choice (hdataG s s.property) let p : ℕ → Fin (coreDimension M (logLog y)-j+1) → ℕ := fun s => if hs : s ∈ G then (r ⟨s, hs⟩).primes else fun _ => 1 obtain ⟨s, hs⟩ := hne apply hcount (coreDimension M (logLog y)-j) G p w (r ⟨s, hs⟩).dimension · intro n hn; simpa only [p, dif_pos hn] using (r ⟨n, hn⟩).integer · intro n hn; simpa only [p, dif_pos hn] using (r ⟨n, hn⟩).prime · intro n hn; simpa only [p, dif_pos hn] using (r ⟨n, hn⟩).minimum · intro n hn; simpa only [p, dif_pos hn] using (r ⟨n, hn⟩).order · intro n hn; simpa only [p, dif_pos hn] using (r ⟨n, hn⟩).gaps · intro n hn; simpa only [p, dif_pos hn] using (r ⟨n, hn⟩).facet · exact hG linarith end Erdos416Proof.FordLower /- Actual maximal-prefix class counts: initial polytope geometry, reciprocal mass uniformly in every prefix dimension, and the selected-prime count. -/ open Filter Finset MeasureTheory open scoped Classical Topology BigOperators Pointwise namespace Erdos416Proof.FordGeometry open FordAnalysis FordScale /-- Restricting a nonnegative sum to the first coordinates can only decrease it. -/ /- Original line 37122: Erdos416Proof.FordGeometry.sum_initial_le -/ theorem sum_initial_le {K L : ℕ} (hKL : K ≤ L) (f : Fin L → ℝ) (hf : ∀ idx, 0 ≤ f idx) : (∑ idx : Fin K, f (Fin.castLE hKL idx)) ≤ ∑ idx : Fin L, f idx := by let e : Fin K ↪ Fin L := ⟨Fin.castLE hKL, Fin.castLE_injective hKL⟩ calc _ = ∑ idx ∈ (univ : Finset (Fin K)).map e, f idx := by simp [e] _ ≤ _ := sum_le_sum_of_subset_of_nonneg (subset_univ _) (fun idx _ _ => hf idx) /-- Initial coordinates retain the unit Ford polytope. The last row of the smaller polytope follows from order, because its coefficient is one. -/ /- Original line 37132: Erdos416Proof.FordGeometry.initial_mem_polytope -/ theorem initial_mem_polytope {K L : ℕ} (hKL : K ≤ L) {x : Fin L → ℝ} (hx : x ∈ polytope L (fun _ => 1)) : (fun idx : Fin K => x (Fin.castLE hKL idx)) ∈ polytope K (fun _ => 1) := by refine ⟨fun idx => hx.1 _, fun idx => hx.2.1 _, ?_, ?_, ?_⟩ · intro idx j hij exact hx.2.2.1 hij · apply le_trans _ hx.2.2.2.1 exact sum_initial_le hKL (fun idx => fordWeight (idx.val+1)*x idx) (fun idx => mul_nonneg (fordWeight_bounds (by omega)).1 (hx.1 idx)) · intro idx hi by_cases hrow : idx.val+2 < K · have hrowL : (Fin.castLE hKL idx).val+2 < L := by simpa [Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordGeometry.slackMap_apply] using hrow.trans_le hKL rw [tailForm_eq_sum idx _ hrow] have h := hx.2.2.2.2 (Fin.castLE hKL idx) (by simpa [Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordGeometry.slackMap_apply] using hi.trans_le hKL) rw [tailForm_eq_sum _ _ hrowL, one_mul] at h simp only [one_mul] apply le_trans _ h exact sum_initial_le hKL (fun j => if idx.val < j.val then fordWeight (j.val-idx.val)*x j else 0) (fun j => by split_ifs with hij · exact mul_nonneg (fordWeight_bounds (by omega)).1 (hx.1 j) · rfl) · let j : Fin K := ⟨idx.val+1, hi⟩ rw [tailForm_last idx j (by omega) rfl, one_mul] exact hx.2.2.1 (by change idx.val ≤ idx.val+1; omega) /- Original line 37158: Erdos416Proof.FordGeometry.initial_mem_unit_polytope -/ theorem initial_mem_unit_polytope {K L : ℕ} (hKL : K ≤ L) {ξ : ℕ → ℝ} (hξ : ∀ j, ξ j ≤ 1) {x : Fin L → ℝ} (hx : x ∈ polytope L ξ) : (fun idx : Fin K => x (Fin.castLE hKL idx)) ∈ polytope K (fun _ => 1) := initial_mem_polytope hKL (polytope_mono hξ hx) /-- The explicit unordered volume formula, extended to dimensions zero and one. -/ /- Original line 37165: Erdos416Proof.FordGeometry.modelVolume -/ noncomputable def modelVolume (K : ℕ) : ℝ := 1/((K.factorial : ℝ)*renewalDenominator K) /- Original line 37168: Erdos416Proof.FordGeometry.modelVolume_pos -/ theorem modelVolume_pos (K : ℕ) : 0 < modelVolume K := by unfold modelVolume exact one_div_pos.mpr (mul_pos (by positivity) (renewalDenominator_pos K)) /- Original line 37172: Erdos416Proof.FordGeometry.modelVolume_zero -/ theorem modelVolume_zero : modelVolume 0 = 1 := by simp [Erdos416Proof.FordAnalysis.gStar_zero, modelVolume, renewalDenominator] /- Original line 37175: Erdos416Proof.FordGeometry.modelVolume_one -/ theorem modelVolume_one : modelVolume 1 = 1 := by norm_num [Erdos416Proof.FordAnalysis.g_zero, Erdos416Proof.FordAnalysis.gStar_zero, modelVolume, renewalDenominator, gStar_succ, g_succ] /- Original line 37178: Erdos416Proof.FordGeometry.modelVolume_eq_TStar -/ theorem modelVolume_eq_TStar {K : ℕ} (hK : 2 ≤ K) : modelVolume K = TStar K := (TStar_eq hK).symm /- Original line 37181: Erdos416Proof.FordGeometry.thickened_polytope_box_bound -/ theorem thickened_polytope_box_bound (K : ℕ) {τ : ℝ} (hτ : 0 ≤ τ) : volume.real (polytope K (fun _ => 1)+errorCube K τ) ≤ (1+2*τ)^K := by have hsub : polytope K (fun _ => 1)+errorCube K τ ⊆ Set.Icc (fun _ => -τ) (fun _ => 1+τ) := by rintro z ⟨x, hx, e, he, rfl⟩ exact ⟨fun idx => by dsimp[Erdos416Proof.FordGeometry.slackMap_apply] ; linarith [hx.1 idx, he.1 idx], fun idx => by dsimp[Erdos416Proof.FordGeometry.slackMap_apply] ; linarith [hx.2.1 idx, he.2 idx]⟩ calc _ ≤ volume.real (Set.Icc (fun _ : Fin K => -τ) (fun _ => 1+τ)) := measureReal_mono hsub isCompact_Icc.measure_lt_top.ne _ = _ := by rw [measureReal_def, Real.volume_Icc_pi_toReal (by intro idx; dsimp[Erdos416Proof.FordGeometry.slackMap_apply] ; linarith)] simp only [show 1+τ- -τ = 1+2*τ by ring, prod_const, card_univ, Fintype.card_fin] /-- All prefix dimensions share a constant, including zero and one. -/ /- Original line 37196: Erdos416Proof.FordGeometry.thickened_unit_polytope_model_bound -/ theorem thickened_unit_polytope_model_bound {K : ℕ} {τ : ℝ} (hτ : 0 ≤ τ) (hτ1 : τ ≤ 1) (hsmall : 2 ≤ K → τ ≤ 10*rho^K/(K : ℝ)) : volume.real (polytope K (fun _ => 1)+errorCube K τ) ≤ (3+Real.exp 80)*modelVolume K := by by_cases hK : 2 ≤ K · have h := thickened_polytope_uniform_bound hK (fun _ => le_rfl) hτ (hsmall hK) have hH : H K (fun _ => 1) = 1 := by simp [Erdos416Proof.FordGeometry.modelVolume_one, Erdos416Proof.FordGeometry.modelVolume_zero, H] rw [hH, one_mul, ← modelVolume_eq_TStar hK] at h exact h.trans (mul_le_mul_of_nonneg_right (by linarith) (modelVolume_pos K).le) · have h := thickened_polytope_box_bound K hτ have hK' : K = 0 ∨ K = 1 := by omega rcases hK' with rfl | rfl <;> simp only [modelVolume_zero, modelVolume_one, mul_one] · simpa only [pow_zero] using h.trans (by linarith [Real.exp_pos 80]) · simp only [pow_one] at h linarith [Real.exp_pos 80] /- Original line 37213: Erdos416Proof.FordGeometry.prefix_mesh_bound -/ theorem prefix_mesh_bound (M : ℕ) {t : ℝ} (ht : Real.exp 1 ≤ t) {K : ℕ} (hK : 1 ≤ K) (hKL : K ≤ coreDimension M t) : 1/t ≤ 10*rho^K/(K : ℝ) := by have hKpos : (0 : ℝ) < K := by exact_mod_cast hK have h := coreDimension_mesh_bound M ht (hK.trans hKL) have hr := pow_le_pow_of_le_one rho_pos.le rho_lt_one.le hKL apply h.trans apply div_le_div₀ (mul_nonneg (by norm_num) (pow_pos rho_pos _).le) (mul_le_mul_of_nonneg_left hr (by norm_num)) hKpos exact Nat.cast_le.mpr hKL end Erdos416Proof.FordGeometry namespace Erdos416Proof.FordReciprocal open FordGeometry FordScale FordAnalysis /-- Uniform upper reciprocal mass for every possible lower prefix. -/ /- Original line 37231: Erdos416Proof.FordReciprocal.exists_prefix_tuple_mass_bound -/ theorem exists_prefix_tuple_mass_bound : ∃ B : ℝ, 0 < B ∧ ∀ (M : ℕ) (t : ℝ), Real.exp 1 ≤ t → ∀ K : ℕ, K ≤ coreDimension M t → tupleReciprocalMass K t (polytope K (fun _ => 1)) ≤ B*t^K*modelVolume K := by obtain ⟨C, hC, hbound⟩ := exists_tupleReciprocalMass_volume_bound refine ⟨C*(3+Real.exp 80), by positivity, ?_⟩ intro M t ht K hKL have ht1 : 1 ≤ t := (Real.one_le_exp (by norm_num : (0 : ℝ) ≤ 1)).trans ht have ht0 : 0 < t := lt_of_lt_of_le (Real.exp_pos 1) ht have hvol := thickened_unit_polytope_model_bound (K := K) (one_div_nonneg.mpr ht0.le) ((div_le_one ht0).mpr ht1) (fun hK => prefix_mesh_bound M ht (by omega) hKL) calc _ ≤ C*t^K*volume.real (polytope K (fun _ => 1)+errorCube K (1/t)) := hbound K t _ ht0 (fun x hx => ⟨hx.1, hx.2.1⟩) _ ≤ C*t^K*((3+Real.exp 80)*modelVolume K) := mul_le_mul_of_nonneg_left hvol (mul_nonneg hC.le (pow_nonneg ht0.le K)) _ = _ := by ring end Erdos416Proof.FordReciprocal namespace Erdos416Proof.FordLower open FordGeometry FordScale FordReciprocal FordInner /- Original line 37256: Erdos416Proof.FordLower.recordLowerPrefix -/ noncomputable def recordLowerPrefix {M : ℕ} {A y : ℝ} {a : Fin (coreDimension M (logLog y))} {N : ℕ} (R : PrimeProductRecord M A y a N) {K : ℕ} (hK : K ≤ coreDimension M (logLog y)) : Fin K → ℕ := fun idx => R.lower (Fin.castLE hK idx) /- Original line 37261: Erdos416Proof.FordLower.recordLowerPrefix_mem -/ theorem recordLowerPrefix_mem {M : ℕ} {A y : ℝ} {a : Fin (coreDimension M (logLog y))} {N : ℕ} (R : PrimeProductRecord M A y a N) {K : ℕ} (hK : K ≤ coreDimension M (logLog y)) (ht : 0 < logLog y) : (∏ idx, recordLowerPrefix R hK idx) ∈ tupleIntegers K (logLog y) (polytope K (fun _ => 1)) := by apply (mem_tupleIntegers ht (fun x hx => ⟨hx.1, hx.2.1⟩)).mpr refine ⟨recordLowerPrefix R hK, rfl, fun idx => Or.inl (R.lower_prime _), ?_, ?_⟩ · intro idx j hij exact R.lower_order.antitone hij · exact initial_mem_unit_polytope hK (targetParameter_le_one (coreDimension M (logLog y)) M) R.point.1.1 end Erdos416Proof.FordLower namespace Erdos416Proof.FordLower open FordGeometry FordScale FordReciprocal FordInner /-- Count original integers by a selected prime and two numerical factors. The two factor sets may have repetitions in their representations. -/ /- Original line 37283: Erdos416Proof.FordLower.exists_two_factor_prime_count_bound -/ theorem exists_two_factor_prime_count_bound : ∃ C : ℝ, 0 < C ∧ ∀ (F U W : Finset ℕ) (p u w : ℕ → ℕ) (Y a : ℝ), 0 < Y → 0 < a → (∀ n ∈ F, u n ∈ U ∧ w n ∈ W ∧ 0 < u n ∧ 0 < w n ∧ n = p n*u n*w n ∧ (p n).Prime ∧ a ≤ Real.log (p n) ∧ ((p n : ℝ)-1)*(u n).totient*(w n).totient ≤ Y) → (F.card : ℝ) ≤ C*Y/a*(∑ b ∈ U, invTotient b)*(∑ c ∈ W, invTotient c) := by obtain ⟨C, hC, hcount⟩ := exists_shifted_large_prime_count_bound refine ⟨C, hC, ?_⟩ intro F U W p u w Y a hY ha hF let Q : ℕ → ℕ × ℕ := fun n => (u n, w n) have hmap : ∀ n ∈ F, Q n ∈ U.product W := fun n hn => mem_product.mpr ⟨(hF n hn).1, (hF n hn).2.1⟩ have hfibre : ∀ bc ∈ U.product W, (((F.filter (fun n => Q n = bc)).card : ℕ) : ℝ) ≤ C*Y/a*invTotient bc.1*invTotient bc.2 := by intro bc hbc let G := F.filter (fun n => Q n = bc) let P := G.image p by_cases hG : G.Nonempty · obtain ⟨n, hn⟩ := hG have hnF := (mem_filter.mp hn).1 have hnu : u n = bc.1 := congrArg Prod.fst (mem_filter.mp hn).2 have hnw : w n = bc.2 := congrArg Prod.snd (mem_filter.mp hn).2 have hb : 0 < bc.1 := hnu ▸ (hF n hnF).2.2.1 have hc : 0 < bc.2 := hnw ▸ (hF n hnF).2.2.2.1 have hcard : G.card = P.card := by symm apply card_image_of_injOn intro m hm n hn heq have hmF := (mem_filter.mp hm).1 have hnF := (mem_filter.mp hn).1 have hu : u m = u n := congrArg Prod.fst ((mem_filter.mp hm).2.trans (mem_filter.mp hn).2.symm) have hw : w m = w n := congrArg Prod.snd ((mem_filter.mp hm).2.trans (mem_filter.mp hn).2.symm) rw [(hF m hmF).2.2.2.2.1, (hF n hnF).2.2.2.2.1, heq, hu, hw] have hP : ∀ q ∈ P, q.Prime ∧ a ≤ Real.log q ∧ ((q : ℝ)-1)*(bc.1.totient*bc.2.totient : ℕ) ≤ Y := by intro q hq obtain ⟨m, hm, rfl⟩ := mem_image.mp hq have hmF := (mem_filter.mp hm).1 have hmu : u m = bc.1 := congrArg Prod.fst (mem_filter.mp hm).2 have hmw : w m = bc.2 := congrArg Prod.snd (mem_filter.mp hm).2 refine ⟨(hF m hmF).2.2.2.2.2.1, (hF m hmF).2.2.2.2.2.2.1, ?_⟩ simpa only [hmu, hmw, Nat.cast_mul, ← mul_assoc] using (hF m hmF).2.2.2.2.2.2.2 rw [hcard] have h := hcount Y a (bc.1.totient*bc.2.totient) P hY ha (Nat.mul_pos (Nat.totient_pos.mpr hb) (Nat.totient_pos.mpr hc)) hP simpa only [Nat.cast_mul, invTotient, div_eq_mul_inv, mul_inv_rev, mul_assoc, mul_left_comm, mul_comm] using h · have hempty : G = ∅ := not_nonempty_iff_eq_empty.mp hG change (G.card : ℝ) ≤ _ rw [hempty, card_empty, Nat.cast_zero] exact mul_nonneg (mul_nonneg (div_nonneg (mul_nonneg hC.le hY.le) ha.le) (invTotient_nonneg _)) (invTotient_nonneg _) calc _ = ∑ bc ∈ U.product W, (((F.filter (fun n => Q n = bc)).card : ℕ) : ℝ) := by rw [card_eq_sum_card_fiberwise hmap, Nat.cast_sum] _ ≤ ∑ bc ∈ U.product W, C*Y/a*invTotient bc.1*invTotient bc.2 := sum_le_sum hfibre _ = _ := by rw [Finset.product_eq_sprod, Finset.sum_product] simp_rw [← mul_sum, ← sum_mul] rw [← mul_sum] /- Original line 37348: Erdos416Proof.FordLower.prefixProduct_eq_initial -/ theorem prefixProduct_eq_initial {K L : ℕ} (hKL : K ≤ L) (p : Fin L → ℕ) : prefixProduct p K = ∏ idx : Fin K, p (Fin.castLE hKL idx) := by symm apply prod_bij (fun idx _ => Fin.castLE hKL idx) · intro idx _ exact mem_filter.mpr ⟨mem_univ _, idx.isLt⟩ · intro idx _ j _ hij exact Fin.castLE_injective hKL hij · intro j hj refine ⟨⟨j.val, (mem_filter.mp hj).2⟩, mem_univ _, ?_⟩ exact Fin.ext rfl · intro idx _ rfl /- Original line 37362: Erdos416Proof.FordLower.prefixProduct_totient -/ theorem prefixProduct_totient {L : ℕ} {p : Fin L → ℕ} (hp : ∀ idx, (p idx).Prime) (ho : StrictAnti p) (K : ℕ) : (prefixProduct p K).totient = prefixProduct (fun idx => p idx-1) K := totient_prod_injective_primes _ p (fun idx _ => hp idx) ho.injective.injOn /- Original line 37367: Erdos416Proof.FordLower.suffixProduct_cons -/ theorem suffixProduct_cons {L : ℕ} (P : ℕ) (p : Fin L → ℕ) (K : ℕ) : suffixProduct (Fin.cons P p) (K+1) = suffixProduct p K := by simp only [suffixProduct, prod_filter, Fin.prod_univ_succ, Fin.val_zero, Nat.add_one_le_iff, Nat.not_lt_zero, ↓reduceIte, Fin.val_succ, Nat.lt_add_one_iff, Fin.cons_succ, one_mul] /- Original line 37373: Erdos416Proof.FordLower.lowerPrefixProduct -/ noncomputable def lowerPrefixProduct {L : ℕ} (p : Fin (L+1) → ℕ) (K : ℕ) : ℕ := prefixProduct (Fin.tail p) K /- Original line 37376: Erdos416Proof.FordLower.record_prefix_suffix_factorization -/ theorem record_prefix_suffix_factorization {M : ℕ} {A y : ℝ} {a : Fin (coreDimension M (logLog y))} {N : ℕ} (R : PrimeProductRecord M A y a N) (K : ℕ) : N = R.leading*lowerPrefixProduct R.fullTuple K*suffixProduct R.fullTuple (K+1) ∧ N.totient = (R.leading-1)*(lowerPrefixProduct R.fullTuple K).totient* (suffixProduct R.fullTuple (K+1)).totient := by have htail : lowerPrefixProduct R.fullTuple K = prefixProduct R.lower K := rfl have hsuf : suffixProduct R.fullTuple (K+1) = suffixProduct R.lower K := suffixProduct_cons _ _ _ rw [htail, hsuf] constructor · rw [mul_assoc, prefix_mul_suffix] exact R.integer · rw [prefixProduct_totient R.lower_prime R.lower_order, suffixProduct_totient R.lower_prime R.lower_order, mul_assoc] change N.totient = (R.leading-1)*(prefixProduct (fun idx => R.lower idx-1) K* suffixProduct (fun idx => R.lower idx-1) K) rw [prefix_mul_suffix, R.totient_product, Fin.prod_univ_succ] rfl /- Original line 37396: Erdos416Proof.FordLower.lowerPrefixProduct_mem -/ theorem lowerPrefixProduct_mem {M : ℕ} {A y : ℝ} {a : Fin (coreDimension M (logLog y))} {N : ℕ} (R : PrimeProductRecord M A y a N) {K : ℕ} (hK : K ≤ coreDimension M (logLog y)) (ht : 0 < logLog y) : lowerPrefixProduct R.fullTuple K ∈ tupleIntegers K (logLog y) (polytope K (fun _ => 1)) := by change prefixProduct R.lower K ∈ _ rw [prefixProduct_eq_initial hK] exact recordLowerPrefix_mem R hK ht /-- The reciprocal prefix estimate applies to the actual original integers, with an unrestricted numerical suffix sum and a single global constant. -/ /- Original line 37408: Erdos416Proof.FordLower.exists_actual_prefix_class_bound -/ theorem exists_actual_prefix_class_bound : ∃ C : ℝ, 0 < C ∧ ∀ (M : ℕ) (A y : ℝ) (a : Fin (coreDimension M (logLog y))) (F : Finset ℕ) (q : ℕ → Fin (coreDimension M (logLog y)+1) → ℕ), 1 < y → Real.exp 1 ≤ logLog y → (∀ n ∈ F, ∃ R : PrimeProductRecord M A y a n, R.fullTuple = q n) → ∀ K : ℕ, K ≤ coreDimension M (logLog y) → (F.card : ℝ) ≤ C*(y/Real.log y)*((logLog y)^K*modelVolume K)* ∑ s ∈ F.image (fun n => suffixProduct (q n) (K+1)), invTotient s := by obtain ⟨C, hC, hcount⟩ := exists_two_factor_prime_count_bound obtain ⟨B, hB, hmass⟩ := exists_prefix_tuple_mass_bound refine ⟨C*B*(20/19), by positivity, ?_⟩ intro M A y a F q hy ht hrecords K hK let U := tupleIntegers K (logLog y) (polytope K (fun _ => 1)) let W := F.image (fun n => suffixProduct (q n) (K+1)) have ht0 : 0 < logLog y := lt_of_lt_of_le (Real.exp_pos 1) ht have hy0 : 0 < y := by linarith have hlog : 0 < Real.log y := Real.log_pos hy have h := hcount F U W (fun n => q n 0) (fun n => lowerPrefixProduct (q n) K) (fun n => suffixProduct (q n) (K+1)) y ((19/20)*Real.log y) hy0 (by positivity) ?_ · have hm := hmass M (logLog y) ht K hK have hW : 0 ≤ ∑ s ∈ W, invTotient s := sum_nonneg (fun s _ => invTotient_nonneg s) calc _ ≤ _ := h _ ≤ C*y/((19/20)*Real.log y)*(B*(logLog y)^K*modelVolume K)* ∑ s ∈ W, invTotient s := mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left hm (by positivity)) hW _ = _ := by ring · intro n hn obtain ⟨R, hR⟩ := hrecords n hn have hmem : suffixProduct (q n) (K+1) ∈ W := mem_image.mpr ⟨n, hn, rfl⟩ have hfac := record_prefix_suffix_factorization R K rw [← hR] refine ⟨lowerPrefixProduct_mem R hK ht0, ?_, ?_, suffixProduct_pos R.fullTuple_prime _, hfac.1, R.leading_prime, ?_, ?_⟩ · simpa only [hR] using hmem · exact prefixProduct_pos R.lower_prime K · have hl := Real.log_le_log (Real.rpow_pos_of_pos hy0 (19/20)) R.leading_size.le rw [Real.log_rpow hy0] at hl exact hl · have hφ := R.totient_range.2 rw [hfac.2, Nat.cast_mul, Nat.cast_mul, Nat.cast_sub R.leading_prime.one_le, Nat.cast_one] at hφ exact hφ /-- Apply the bound to each deepest-prefix class without changing the suffix family to which the proved collision estimate applies. -/ /- Original line 37456: Erdos416Proof.FordLower.exists_maximal_prefix_class_bound -/ theorem exists_maximal_prefix_class_bound : ∃ C : ℝ, 0 < C ∧ ∀ (M : ℕ) (A y : ℝ) (a : Fin (coreDimension M (logLog y))) (F : Finset ℕ) (q : ℕ → Fin (coreDimension M (logLog y)+1) → ℕ), 1 < y → Real.exp 1 ≤ logLog y → (∀ n ∈ F, ∃ R : PrimeProductRecord M A y a n, R.fullTuple = q n) → ∀ K : ℕ, K ≤ coreDimension M (logLog y) → ((prefixCollisionClass F q (K+1)).card : ℝ) ≤ C*(y/Real.log y)*((logLog y)^K*modelVolume K)* ∑ s ∈ suffixCollisionFamily F q (K+1), invTotient s := by obtain ⟨C, hC, hbound⟩ := exists_actual_prefix_class_bound refine ⟨C, hC, ?_⟩ intro M A y a F q hy ht hrecords K hK exact hbound M A y a (prefixCollisionClass F q (K+1)) q hy ht (fun n hn => hrecords n (mem_prefixCollisionClass.mp hn).1) K hK end Erdos416Proof.FordLower /- Full suffix reciprocal masses, geometric summation of every prefix class, the actual totient lower bound and the structural normalization by V. -/ open Filter Finset MeasureTheory open scoped Classical Topology BigOperators namespace Erdos416Proof /-- Count the original objects below a numerical weight, retaining multiplicity when different objects have the same weight. -/ /- Original line 37489: Erdos416Proof.finiteWeightedCountBelow -/ noncomputable def finiteWeightedCountBelow {α : Type*} (F : Finset α) (w : α → ℕ) (t : ℝ) : ℝ := ((F.filter (fun n => (w n : ℝ) ≤ t)).card : ℝ) /- Original line 37493: Erdos416Proof.finiteWeightedCountBelow_eq_sum -/ theorem finiteWeightedCountBelow_eq_sum {α : Type*} (F : Finset α) (w : α → ℕ) (t : ℝ) : finiteWeightedCountBelow F w t = ∑ n ∈ F, finiteCountBelow {w n} t := by classical simp [finiteWeightedCountBelow, finiteCountBelow, filter_singleton, apply_ite, sum_boole] /-- Finite Abel summation does not require the numerical weight to be injective. -/ /- Original line 37500: Erdos416Proof.finite_weighted_reciprocal_abel -/ theorem finite_weighted_reciprocal_abel {α : Type*} (F : Finset α) (w : α → ℕ) {u z : ℝ} (hu : 2 ≤ u) (huz : u ≤ z) (hF : ∀ n ∈ F, u ≤ (w n : ℝ) ∧ (w n : ℝ) ≤ z) : IntervalIntegrable (fun t : ℝ => finiteWeightedCountBelow F w t/t^2) volume u z ∧ (∑ n ∈ F, (1 : ℝ)/w n) = finiteWeightedCountBelow F w z/z+ ∫ t : ℝ in u..z, finiteWeightedCountBelow F w t/t^2 := by have hsingle (n : α) (hn : n ∈ F) := finite_reciprocal_abel_lower {w n} hu huz (by intro q hq simpa only [mem_singleton.mp hq] using hF n hn) have hi : IntervalIntegrable (fun t : ℝ => ∑ n ∈ F, finiteCountBelow {w n} t/t^2) volume u z := by simpa only [Finset.sum_fn] using IntervalIntegrable.sum F (fun n hn => (hsingle n hn).1) have hint : IntervalIntegrable (fun t : ℝ => finiteWeightedCountBelow F w t/t^2) volume u z := by simpa only [← sum_div, ← finiteWeightedCountBelow_eq_sum] using hi refine ⟨hint, ?_⟩ calc _ = ∑ n ∈ F, (finiteCountBelow {w n} z/z+ ∫ t : ℝ in u..z, finiteCountBelow {w n} t/t^2) := by apply sum_congr rfl intro n hn simpa only [sum_singleton] using (hsingle n hn).2 _ = _ := by rw [sum_add_distrib, ← intervalIntegral.integral_finsetSum (fun n hn => (hsingle n hn).1)] simp only [← sum_div, ← finiteWeightedCountBelow_eq_sum] /- Original line 37528: Erdos416Proof.integral_inv_mul_log_logLog_sq -/ theorem integral_inv_mul_log_logLog_sq {u z : ℝ} (hu : Real.exp 1 < u) (huz : u ≤ z) : (∫ t : ℝ in u..z, t⁻¹/Real.log t/(logLog t)^2) = 1/logLog u-1/logLog z := by have ht0 (t : ℝ) (ht : t ∈ Set.Icc u z) : 0 < t := (Real.exp_pos 1).trans (hu.trans_le ht.1) have hlog (t : ℝ) (ht : t ∈ Set.Icc u z) : 1 < Real.log t := by simpa only [Real.log_exp] using Real.log_lt_log (Real.exp_pos 1) (hu.trans_le ht.1) have hLL (t : ℝ) (ht : t ∈ Set.Icc u z) : 0 < logLog t := Real.log_pos (hlog t ht) have hc : ContinuousOn (fun t : ℝ => t⁻¹/Real.log t/(logLog t)^2) (Set.Icc u z) := by apply ContinuousOn.div · exact (continuousOn_id.inv₀ (fun t ht => (ht0 t ht).ne')).div (continuousOn_id.log (fun t ht => (ht0 t ht).ne')) (fun t ht => (lt_trans zero_lt_one (hlog t ht)).ne') · exact ((continuousOn_id.log (fun t ht => (ht0 t ht).ne')).log (fun t ht => (lt_trans zero_lt_one (hlog t ht)).ne')).pow 2 · exact fun t ht => pow_ne_zero _ (hLL t ht).ne' have hi : IntervalIntegrable (fun t : ℝ => t⁻¹/Real.log t/(logLog t)^2) volume u z := (intervalIntegrable_iff_integrableOn_Icc_of_le huz).mpr hc.integrableOn_Icc have hd : ∀ t ∈ Set.Icc u z, HasDerivAt (fun t : ℝ => -(logLog t)⁻¹) (t⁻¹/Real.log t/(logLog t)^2) t := by intro t ht have h := (((Real.hasDerivAt_log (ht0 t ht).ne').log (lt_trans zero_lt_one (hlog t ht)).ne').inv (hLL t ht).ne').neg simpa only [logLog, Pi.neg_apply, Pi.inv_apply, neg_div, neg_neg] using! h have h := intervalIntegral.integral_eq_sub_of_hasDerivAt (by intro t ht; exact hd t (by simpa only [Set.uIcc_of_le huz] using ht)) hi rw [h] simp only [one_div] ring /-- The summable density saving gives a reciprocal tail bound for the original family, including every repeated totient value. -/ /- Original line 37561: Erdos416Proof.finite_weighted_reciprocal_tail -/ theorem finite_weighted_reciprocal_tail {α : Type*} (F : Finset α) (w : α → ℕ) {u z D : ℝ} (hu : Real.exp (Real.exp 1) ≤ u) (huz : u ≤ z) (hD : 0 ≤ D) (hF : ∀ n ∈ F, u ≤ (w n : ℝ) ∧ (w n : ℝ) ≤ z) (hdensity : ∀ t : ℝ, u ≤ t → t ≤ z → finiteWeightedCountBelow F w t ≤ D*(t/(Real.log t*(logLog t)^2))) : (∑ n ∈ F, (1 : ℝ)/w n) ≤ 2*D/logLog u := by have he : (1 : ℝ) < Real.exp 1 := Real.one_lt_exp_iff.mpr (by norm_num) have hu' : Real.exp 1 < u := (Real.exp_lt_exp.mpr he).trans_le hu have hu2 : 2 ≤ u := (Real.exp_one_gt_two.le).trans hu'.le have hu0 : 0 < u := (Real.exp_pos _).trans_le hu have hz0 : 0 < z := hu0.trans_le huz have hLu : 1 ≤ logLog u := by simpa only [logLog, Real.log_exp] using logLog_mono (Real.one_lt_exp_iff.mpr (Real.exp_pos 1)) hu have hL (t : ℝ) (ht : t ∈ Set.Icc u z) : 1 ≤ logLog t := hLu.trans (logLog_mono (by linarith) ht.1) have hlog (t : ℝ) (ht : t ∈ Set.Icc u z) : 1 < Real.log t := by simpa only [Real.log_exp] using Real.log_lt_log (Real.exp_pos 1) (hu'.trans_le ht.1) have ht0 (t : ℝ) (ht : t ∈ Set.Icc u z) : 0 < t := hu0.trans_le ht.1 obtain ⟨hi, habel⟩ := finite_weighted_reciprocal_abel F w hu2 huz hF have hc : ContinuousOn (fun t : ℝ => D*(t⁻¹/Real.log t/(logLog t)^2)) (Set.Icc u z) := by apply continuousOn_const.mul apply ContinuousOn.div · exact (continuousOn_id.inv₀ (fun t ht => (ht0 t ht).ne')).div (continuousOn_id.log (fun t ht => (ht0 t ht).ne')) (fun t ht => (lt_trans zero_lt_one (hlog t ht)).ne') · exact ((continuousOn_id.log (fun t ht => (ht0 t ht).ne')).log (fun t ht => (lt_trans zero_lt_one (hlog t ht)).ne')).pow 2 · exact fun t ht => pow_ne_zero _ (lt_of_lt_of_le zero_lt_one (hL t ht)).ne' have hj : IntervalIntegrable (fun t : ℝ => D*(t⁻¹/Real.log t/(logLog t)^2)) volume u z := (intervalIntegrable_iff_integrableOn_Icc_of_le huz).mpr hc.integrableOn_Icc have hInt := intervalIntegral.integral_mono_on huz hi hj (fun t ht => by calc finiteWeightedCountBelow F w t/t^2 ≤ (D*(t/(Real.log t*(logLog t)^2)))/t^2 := div_le_div_of_nonneg_right (hdensity t ht.1 ht.2) (sq_nonneg t) _ = D*(t⁻¹/Real.log t/(logLog t)^2) := by field_simp) rw [intervalIntegral.integral_const_mul, integral_inv_mul_log_logLog_sq hu' huz] at hInt have hLu0 : 0 < logLog u := lt_of_lt_of_le zero_lt_one hLu have hLz : logLog u ≤ logLog z := logLog_mono (by linarith) huz have hLz0 : 0 < logLog z := hLu0.trans_le hLz have hInt' : (∫ t : ℝ in u..z, finiteWeightedCountBelow F w t/t^2) ≤ D/logLog u := hInt.trans (by simp only [div_eq_mul_inv] nlinarith [inv_nonneg.mpr hLz0.le]) have hden : logLog u ≤ Real.log z*(logLog z)^2 := by have hlz := hL z ⟨huz, le_rfl⟩ have hlogz := hlog z ⟨huz, le_rfl⟩ nlinarith [sq_nonneg (logLog z)] have hend : finiteWeightedCountBelow F w z/z ≤ D/logLog u := by calc _ ≤ (D*(z/(Real.log z*(logLog z)^2)))/z := div_le_div_of_nonneg_right (hdensity z huz le_rfl) hz0.le _ = D/(Real.log z*(logLog z)^2) := by field_simp _ ≤ _ := div_le_div_of_nonneg_left hD hLu0 hden rw [habel] calc _ ≤ D/logLog u+D/logLog u := add_le_add hend hInt' _ = _ := by ring end Erdos416Proof namespace Erdos416Proof.FordLower open FordScale /-- Partial summation of the actual suffix count. The starting threshold precedes every original parameter, and equal totients keep their multiplicity. -/ /- Original line 37629: Erdos416Proof.FordLower.actual_suffix_large_mass_eventually -/ theorem actual_suffix_large_mass_eventually : ∀ᶠ u : ℝ in atTop, ∀ (M : ℕ) (A y : ℝ) (a : Fin (coreDimension M (logLog y))) (F : Finset ℕ) (q : ℕ → Fin (coreDimension M (logLog y)+1) → ℕ), 2 ≤ M → 4 ≤ A → 1 < y → 0 < logLog y → (M : ℝ) ≤ 10*Real.log (logLog u) → (∀ n ∈ F, ∃ R : PrimeProductRecord M A y a n, R.fullTuple = q n) → ∀ j : ℕ, (∑ s ∈ (suffixCollisionFamily F q j).filter (fun s => u ≤ (s.totient : ℝ)), invTotient s) ≤ 10/logLog u := by obtain ⟨Z, hZ⟩ := eventually_atTop.mp actual_suffix_count_eventually filter_upwards [eventually_ge_atTop Z, eventually_ge_atTop (Real.exp (Real.exp 1))] with u huZ hu intro M A y a F q hM hA hy ht hMsize hrecords j let G := (suffixCollisionFamily F q j).filter (fun s => u ≤ (s.totient : ℝ)) let z : ℝ := max u (G.sup Nat.totient : ℕ) have huz : u ≤ z := le_max_left _ _ have hu1 : 1 < u := (Real.one_lt_exp_iff.mpr (Real.exp_pos 1)).trans_le hu have hLLu : 0 < logLog u := by have h : 1 ≤ logLog u := by simpa only [logLog, Real.log_exp] using logLog_mono (Real.one_lt_exp_iff.mpr (Real.exp_pos 1)) hu linarith have hG : ∀ s ∈ G, u ≤ (s.totient : ℝ) ∧ (s.totient : ℝ) ≤ z := by intro s hs exact ⟨(mem_filter.mp hs).2, (Nat.cast_le.mpr (le_sup (f := Nat.totient) hs)).trans (le_max_right _ _)⟩ have hdensity : ∀ t : ℝ, u ≤ t → t ≤ z → finiteWeightedCountBelow G Nat.totient t ≤ 5*(t/(Real.log t*(logLog t)^2)) := by intro t hut _ have hMt : (M : ℝ) ≤ 10*Real.log (logLog t) := hMsize.trans (mul_le_mul_of_nonneg_left (Real.log_le_log hLLu (logLog_mono hu1 hut)) (by norm_num)) have hcount := hZ t (huZ.trans hut) M A y a F q hM hA hy ht hMt hrecords j have hsub : G.filter (fun s => (s.totient : ℝ) ≤ t) ⊆ suffixesUpTo F q j t := by intro s hs exact mem_filter.mpr ⟨(mem_filter.mp (mem_filter.mp hs).1).1, (mem_filter.mp hs).2⟩ exact (Nat.cast_le.mpr (card_le_card hsub)).trans hcount have h := finite_weighted_reciprocal_tail G Nat.totient hu huz (D := 5) (by norm_num) hG hdensity simpa only [one_div, invTotient, show (2 : ℝ)*5 = 10 by norm_num] using h /- Original line 37670: Erdos416Proof.FordLower.actual_suffix_mass_split_eventually -/ theorem actual_suffix_mass_split_eventually : ∀ᶠ u : ℝ in atTop, ∀ (M : ℕ) (A y : ℝ) (a : Fin (coreDimension M (logLog y))) (F : Finset ℕ) (q : ℕ → Fin (coreDimension M (logLog y)+1) → ℕ), 2 ≤ M → 4 ≤ A → 1 < y → 0 < logLog y → (M : ℝ) ≤ 10*Real.log (logLog u) → (∀ n ∈ F, ∃ R : PrimeProductRecord M A y a n, R.fullTuple = q n) → ∀ j : ℕ, (∑ s ∈ suffixCollisionFamily F q j, invTotient s) ≤ (∑ s ∈ (suffixCollisionFamily F q j).filter (fun s => (s.totient : ℝ) < u), invTotient s)+10/logLog u := by filter_upwards [actual_suffix_large_mass_eventually] with u h intro M A y a F q hM hA hy ht hMsize hrecords j have hb := h M A y a F q hM hA hy ht hMsize hrecords j have he := sum_filter_add_sum_filter_not (suffixCollisionFamily F q j) (fun s => u ≤ (s.totient : ℝ)) invTotient simp only [not_le] at he linarith end Erdos416Proof.FordLower open Filter Finset open scoped Classical Topology BigOperators namespace Erdos416Proof.FordLower open FordAnalysis FordScale /- Original line 37700: Erdos416Proof.FordLower.prime_le_totient_add_one -/ theorem prime_le_totient_add_one {n p : ℕ} (hn : 0 < n) (hp : p.Prime) (hd : p ∣ n) : p ≤ n.totient+1 := by have h := Nat.le_of_dvd (Nat.totient_pos.mpr hn) (Nat.totient_dvd_of_dvd hd) rw [Nat.totient_prime hp] at h omega /-- Small suffix endpoints force every prime factor into a bounded set. The bound counts original squarefree suffixes, not their totient image. -/ /- Original line 37708: Erdos416Proof.FordLower.small_suffix_reciprocal_mass -/ theorem small_suffix_reciprocal_mass {k : ℕ} (F : Finset ℕ) (q : ℕ → Fin k → ℕ) (hp : ∀ n ∈ F, ∀ idx, (q n idx).Prime) (ho : ∀ n ∈ F, StrictAnti (q n)) (hprod : ∀ n ∈ F, (∏ idx, q n idx) = n) (j : ℕ) (u : ℝ) : (∑ s ∈ (suffixCollisionFamily F q j).filter (fun s => (s.totient : ℝ) < u), invTotient s) ≤ Real.exp 1*(1+∑ p ∈ Nat.primesLE ⌊u+1⌋₊, (1 : ℝ)/((p : ℝ)-1))^(k-j) := by apply squarefree_reciprocal_sum_bound _ _ (k-j) (fun p hp => Nat.prime_of_mem_primesLE hp) intro s hs obtain ⟨hsF, hsu⟩ := mem_filter.mp hs have h := suffixCollisionFamily_properties F q hp ho hprod j hsF refine ⟨h.2.1, ?_, (primeFactors_card_le_cardFactors s).trans_eq h.2.2.1⟩ intro p hps have hppr := Nat.prime_of_mem_primeFactors hps have hle := prime_le_totient_add_one h.1 hppr (Nat.dvd_of_mem_primeFactors hps) have hleR : (p : ℝ) ≤ u+1 := by have hcast : (p : ℝ) ≤ (s.totient : ℝ)+1 := by exact_mod_cast hle linarith exact Nat.mem_primesLE.mpr ⟨Nat.le_floor hleR, hppr⟩ /- Original line 37727: Erdos416Proof.FordLower.logLog_add_one_le -/ theorem logLog_add_one_le {u : ℝ} (hu : 2 ≤ u) : logLog (u+1) ≤ logLog u+1 := by have hu0 : 0 < u := by linarith have hlog : 0 < Real.log u := Real.log_pos (by linarith) have hmono := logLog_mono (by linarith : 1 < u+1) (by nlinarith : u+1 ≤ u^2) have heq : logLog (u^2) = Real.log 2+logLog u := by unfold logLog rw [Real.log_pow] norm_num only [Nat.cast_ofNat] rw [Real.log_mul (by norm_num : (2 : ℝ) ≠ 0) hlog.ne'] rw [heq] at hmono exact hmono.trans (by linarith [Real.log_le_sub_one_of_pos (by norm_num : (0 : ℝ) < 2)]) /-- The endpoint at which the uniform suffix theorem first allows fixed M. -/ /- Original line 37740: Erdos416Proof.FordLower.suffixSmallCutoff -/ noncomputable def suffixSmallCutoff (M : ℕ) : ℝ := Real.exp (Real.exp (Real.exp ((M : ℝ)/10))) /- Original line 37743: Erdos416Proof.FordLower.suffixSmallCutoff_tendsto -/ theorem suffixSmallCutoff_tendsto : Tendsto suffixSmallCutoff atTop atTop := by exact Real.tendsto_exp_atTop.comp (Real.tendsto_exp_atTop.comp (Real.tendsto_exp_atTop.comp ((tendsto_natCast_atTop_atTop (R := ℝ)).atTop_div_const (by norm_num : (0 : ℝ) < 10)))) /- Original line 37748: Erdos416Proof.FordLower.suffixSmallCutoff_logLog -/ theorem suffixSmallCutoff_logLog (M : ℕ) : logLog (suffixSmallCutoff M) = Real.exp ((M : ℝ)/10) := by simp [Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, suffixSmallCutoff, logLog] /- Original line 37752: Erdos416Proof.FordLower.suffixSmallCutoff_parameter -/ theorem suffixSmallCutoff_parameter (M : ℕ) : (M : ℝ) = 10*Real.log (logLog (suffixSmallCutoff M)) := by rw [suffixSmallCutoff_logLog, Real.log_exp] ring /-- The entire small-endpoint reciprocal contribution has a sufficiently small exponential cost in each remaining suffix factor. -/ /- Original line 37759: Erdos416Proof.FordLower.small_suffix_mass_at_cutoff_eventually -/ theorem small_suffix_mass_at_cutoff_eventually : ∀ᶠ M : ℕ in atTop, ∀ (k : ℕ) (F : Finset ℕ) (q : ℕ → Fin k → ℕ), (∀ n ∈ F, ∀ idx, (q n idx).Prime) → (∀ n ∈ F, StrictAnti (q n)) → (∀ n ∈ F, (∏ idx, q n idx) = n) → ∀ j : ℕ, j < k → (∑ s ∈ (suffixCollisionFamily F q j).filter (fun s => (s.totient : ℝ) < suffixSmallCutoff M), invTotient s) ≤ Real.exp (((k-j : ℕ) : ℝ)*(M : ℝ)/9) := by obtain ⟨C, hC, hprime⟩ := shifted_prime_reciprocal_bound have hgrow : Tendsto (fun M : ℕ => Real.exp ((M : ℝ)/90)) atTop atTop := Real.tendsto_exp_atTop.comp ((tendsto_natCast_atTop_atTop (R := ℝ)).atTop_div_const (by norm_num : (0 : ℝ) < 90)) filter_upwards [suffixSmallCutoff_tendsto.eventually_ge_atTop (Real.exp (Real.exp 1)), suffixSmallCutoff_tendsto.eventually_ge_atTop 2, hgrow.eventually_ge_atTop (Real.exp 1*(1+2*C))] with M hMu hM2 hconst intro k F q hp ho hprod j hj let u := suffixSmallCutoff M let b : ℝ := 1+∑ p ∈ Nat.primesLE ⌊u+1⌋₊, (1 : ℝ)/((p : ℝ)-1) have hM0 : (0 : ℝ) ≤ M := Nat.cast_nonneg M have hexp1 : 1 ≤ Real.exp ((M : ℝ)/10) := Real.one_le_exp (by positivity) have hb0 : 0 ≤ b := by dsimp [Erdos416Proof.FordReciprocal.binMass_zero, Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.invTotient_one, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, Erdos416Proof.weightedInvTotient_one, b] apply add_nonneg zero_le_one apply sum_nonneg intro p hp have hp1 : (1 : ℝ) ≤ p := by exact_mod_cast (Nat.prime_of_mem_primesLE hp).one_le exact div_nonneg zero_le_one (sub_nonneg.mpr hp1) have hb : b ≤ 1+C*(Real.exp ((M : ℝ)/10)+1) := by have h := hprime (u+1) (by dsimp [Erdos416Proof.FordReciprocal.binMass_zero, Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.invTotient_one, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, Erdos416Proof.weightedInvTotient_one, u]; linarith) have hLL := logLog_add_one_le hM2 rw [suffixSmallCutoff_logLog] at hLL exact add_le_add_right (h.trans (mul_le_mul_of_nonneg_left hLL hC.le)) 1 have hbase : Real.exp 1*b ≤ Real.exp ((M : ℝ)/9) := by calc _ ≤ Real.exp 1*(1+C*(Real.exp ((M : ℝ)/10)+1)) := mul_le_mul_of_nonneg_left hb (Real.exp_pos 1).le _ ≤ (Real.exp 1*(1+2*C))*Real.exp ((M : ℝ)/10) := by nlinarith [mul_nonneg hC.le (sub_nonneg.mpr hexp1), Real.exp_pos 1] _ ≤ Real.exp ((M : ℝ)/90)*Real.exp ((M : ℝ)/10) := mul_le_mul_of_nonneg_right hconst (Real.exp_pos _).le _ = _ := by rw [← Real.exp_add]; congr 1; ring have hdim : (1 : ℝ) ≤ (k-j : ℕ) := by exact_mod_cast (show 1 ≤ k-j by omega) calc _ ≤ Real.exp 1*b^(k-j) := small_suffix_reciprocal_mass F q hp ho hprod j u _ ≤ Real.exp (((k-j : ℕ) : ℝ)*1)*b^(k-j) := mul_le_mul_of_nonneg_right (Real.exp_le_exp.mpr (by simpa only [mul_one] using hdim)) (pow_nonneg hb0 _) _ = (Real.exp 1*b)^(k-j) := by rw [Real.exp_nat_mul, mul_pow] _ ≤ (Real.exp ((M : ℝ)/9))^(k-j) := pow_le_pow_left₀ (mul_nonneg (Real.exp_pos 1).le hb0) hbase _ _ = _ := by rw [← Real.exp_nat_mul]; congr 1; ring end Erdos416Proof.FordLower namespace Erdos416Proof.FordLower open FordScale /-- Full reciprocal mass of each actual suffix family. The fixed-M threshold includes both the summable large endpoints and the bounded small endpoints. No lower bound on the final prime is additionally assumed. -/ /- Original line 37822: Erdos416Proof.FordLower.actual_suffix_reciprocal_mass_eventually -/ theorem actual_suffix_reciprocal_mass_eventually : ∀ᶠ M : ℕ in atTop, ∀ (A y : ℝ) (a : Fin (coreDimension M (logLog y))) (F : Finset ℕ) (q : ℕ → Fin (coreDimension M (logLog y)+1) → ℕ), 4 ≤ A → 1 < y → 0 < logLog y → (∀ n ∈ F, ∃ R : PrimeProductRecord M A y a n, R.fullTuple = q n) → ∀ j : ℕ, j < coreDimension M (logLog y)+1 → (∑ s ∈ suffixCollisionFamily F q j, invTotient s) ≤ 11*Real.exp (((coreDimension M (logLog y)+1-j : ℕ) : ℝ)*(M : ℝ)/9) := by filter_upwards [suffixSmallCutoff_tendsto.eventually actual_suffix_mass_split_eventually, small_suffix_mass_at_cutoff_eventually, eventually_ge_atTop 2] with M hsplit hsmall hM intro A y a F q hA hy ht hrecords j hj have hp : ∀ n ∈ F, ∀ idx, (q n idx).Prime := by intro n hn obtain ⟨R, hR⟩ := hrecords n hn exact hR ▸ R.fullTuple_prime have ho : ∀ n ∈ F, StrictAnti (q n) := by intro n hn obtain ⟨R, hR⟩ := hrecords n hn exact hR ▸ R.fullTuple_order have hprod : ∀ n ∈ F, (∏ idx, q n idx) = n := by intro n hn obtain ⟨R, hR⟩ := hrecords n hn exact hR ▸ R.fullTuple_product have h := hsplit M A y a F q hM hA hy ht (suffixSmallCutoff_parameter M).le hrecords j have hs := hsmall (coreDimension M (logLog y)+1) F q hp ho hprod j hj have htail : 10/logLog (suffixSmallCutoff M) ≤ 10 := by rw [suffixSmallCutoff_logLog] exact (div_le_self (by norm_num : (0 : ℝ) ≤ 10) (Real.one_le_exp (by positivity))).trans_eq (by ring) have hexp : 1 ≤ Real.exp (((coreDimension M (logLog y)+1-j : ℕ) : ℝ)*(M : ℝ)/9) := Real.one_le_exp (by positivity) linarith end Erdos416Proof.FordLower open Filter Finset open scoped Classical Topology BigOperators namespace Erdos416Proof.FordGeometry open FordAnalysis FordScale FordInner /- Original line 37870: Erdos416Proof.FordGeometry.gStar_scaled_le_one -/ theorem gStar_scaled_le_one (n : ℕ) : gStar n*rho^n ≤ 1 := by by_cases hn : 2 ≤ n · exact (gStar_scaled_uniform_upper hn).le.trans (by norm_num[Erdos416Proof.FordAnalysis.g_zero, Erdos416Proof.FordAnalysis.gStar_zero] ) · have hn' : n = 0 ∨ n = 1 := by omega rcases hn' with rfl | rfl · simp[Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.gStar_zero, Erdos416Proof.FordAnalysis.g_zero, Erdos416Proof.FordGeometry.modelVolume_one] · have heq : gStar 1 = 1 := by norm_num [Erdos416Proof.FordAnalysis.g_zero, Erdos416Proof.FordAnalysis.gStar_zero, gStar_succ, g_succ] simpa only [heq, one_mul, pow_one] using rho_lt_one.le /- Original line 37879: Erdos416Proof.FordGeometry.modelVolume_step -/ theorem modelVolume_step (n : ℕ) : modelVolume n ≤ ((n : ℝ)+1)*gStar (n+1)*modelVolume (n+1) := by let b : ℝ := (n.factorial : ℝ)*(∏ idx ∈ range n, g idx) have hb : 0 < b := mul_pos (by positivity) (prod_pos (fun idx _ => g_pos idx)) have h := one_div_le_one_div_of_le (mul_pos hb (g_pos n)) (mul_le_mul_of_nonneg_left (g_le_gStar n) hb.le) calc _ = 1/(b*gStar n) := by unfold modelVolume renewalDenominator b; ring _ ≤ 1/(b*g n) := h _ = _ := by unfold modelVolume renewalDenominator b rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, prod_range_succ] have hf : (n.factorial : ℝ) ≠ 0 := by positivity have hprod : (∏ idx ∈ range n, g idx) ≠ 0 := (prod_pos (fun idx _ => g_pos idx)).ne' have hn : (n : ℝ)+1 ≠ 0 := by positivity field_simp [hf, hprod, hn, (g_pos n).ne', (gStar_pos (n+1)).ne'] /- Original line 37896: Erdos416Proof.FordGeometry.scaled_modelVolume_step -/ theorem scaled_modelVolume_step {t : ℝ} (ht : 0 < t) (n : ℕ) : t^n*modelVolume n ≤ (((n : ℝ)+1)/(t*rho^(n+1)))*(t^(n+1)*modelVolume (n+1)) := by have hg : gStar (n+1) ≤ 1/rho^(n+1) := (le_div_iff₀ (pow_pos rho_pos _)).mpr (gStar_scaled_le_one _) calc _ ≤ t^n*(((n : ℝ)+1)*gStar (n+1)*modelVolume (n+1)) := mul_le_mul_of_nonneg_left (modelVolume_step n) (pow_nonneg ht.le n) _ ≤ t^n*(((n : ℝ)+1)*(1/rho^(n+1))*modelVolume (n+1)) := by apply mul_le_mul_of_nonneg_left _ (pow_nonneg ht.le n) exact mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left hg (by positivity)) (modelVolume_pos _).le _ = _ := by rw [pow_succ] field_simp [ht.ne', (pow_pos rho_pos (n+1)).ne']; ring /- Original line 37911: Erdos416Proof.FordGeometry.backwards_geometric_bound -/ theorem backwards_geometric_bound (f : ℕ → ℝ) {r : ℝ} (hr : 0 ≤ r) {K L : ℕ} (hKL : K ≤ L) (hstep : ∀ idx : ℕ, K ≤ idx → idx < L → f idx ≤ r*f (idx+1)) : f K ≤ r^(L-K)*f L := by induction L with | zero => have hK : K = 0 := by omega subst K simp | succ L ih => by_cases hK : K ≤ L · have hi := ih hK (fun idx hi hil => hstep idx hi (by omega)) calc _ ≤ r^(L-K)*f L := hi _ ≤ r^(L-K)*(r*f (L+1)) := mul_le_mul_of_nonneg_left (hstep L hK (by omega)) (pow_nonneg hr _) _ = _ := by rw [Nat.succ_sub hK, pow_succ]; ring · have heq : K = L+1 := by omega subst K simp /- Original line 37931: Erdos416Proof.FordGeometry.scaled_modelVolume_prefix_bound -/ theorem scaled_modelVolume_prefix_bound {t : ℝ} (ht : 0 < t) {K L : ℕ} (hKL : K ≤ L) : t^K*modelVolume K ≤ ((L : ℝ)/(t*rho^L))^(L-K)*(t^L*modelVolume L) := by have hden : 0 < t*rho^L := mul_pos ht (pow_pos rho_pos _) apply backwards_geometric_bound (fun idx => t^idx*modelVolume idx) (div_nonneg (Nat.cast_nonneg L) hden.le) hKL intro idx _ hiL apply (scaled_modelVolume_step ht idx).trans have hr : rho^L ≤ rho^(idx+1) := pow_le_pow_of_le_one rho_pos.le rho_lt_one.le (by omega) apply mul_le_mul_of_nonneg_right _ (mul_nonneg (pow_nonneg ht.le _) (modelVolume_pos _).le) exact div_le_div₀ (by positivity) (by exact_mod_cast (show idx+1 ≤ L by omega)) hden (mul_le_mul_of_nonneg_left hr ht.le) /-- Retaining the fixed tail shift M in the mesh estimate gives a geometric gain at every removed prefix coordinate. No Stirling approximation is used. -/ /- Original line 37946: Erdos416Proof.FordGeometry.core_prefix_rate_bound -/ theorem core_prefix_rate_bound (M : ℕ) {t : ℝ} (ht : Real.exp 1 ≤ t) (hadd : coreDimension M t+M = optimalDimension t) : (coreDimension M t : ℝ)/(t*rho^(coreDimension M t)) ≤ 4*rho^M := by have ht1 : 1 < t := (Real.one_lt_exp_iff.mpr (by norm_num : (0 : ℝ) < 1)).trans_le ht have ht0 : 0 < t := by linarith have hρ := coreDimension_rho_lower 0 ht1 have heq : coreDimension 0 t = optimalDimension t := by simp [coreDimension] rw [heq, ← hadd, pow_add] at hρ have hlog : Real.log t ≤ t*rho^(coreDimension M t)*rho^M := by have h := (div_le_iff₀ ht0).mp hρ nlinarith apply (div_le_iff₀ (mul_pos ht0 (pow_pos rho_pos _))).mpr have hdim := coreDimension_le_four_log M ht nlinarith /- Original line 37961: Erdos416Proof.FordGeometry.core_scaled_prefix_bound -/ theorem core_scaled_prefix_bound (M : ℕ) {t : ℝ} (ht : Real.exp 1 ≤ t) (hadd : coreDimension M t+M = optimalDimension t) {K : ℕ} (hK : K ≤ coreDimension M t) : t^K*modelVolume K ≤ (4*rho^M)^(coreDimension M t-K)* (t^(coreDimension M t)*modelVolume (coreDimension M t)) := by have ht0 : 0 < t := lt_of_lt_of_le (Real.exp_pos 1) ht apply (scaled_modelVolume_prefix_bound ht0 hK).trans apply mul_le_mul_of_nonneg_right _ (mul_nonneg (pow_nonneg ht0.le _) (modelVolume_pos _).le) exact pow_le_pow_left₀ (div_nonneg (Nat.cast_nonneg _) (mul_nonneg ht0.le (pow_pos rho_pos _).le)) (core_prefix_rate_bound M ht hadd) _ /- Original line 37974: Erdos416Proof.FordGeometry.prefixDecay -/ noncomputable def prefixDecay (M : ℕ) : ℝ := 4*rho^M*Real.exp ((M : ℝ)/9) /- Original line 37976: Erdos416Proof.FordGeometry.prefixDecay_nonneg -/ theorem prefixDecay_nonneg (M : ℕ) : 0 ≤ prefixDecay M := by unfold prefixDecay exact mul_nonneg (mul_nonneg (by norm_num) (pow_pos rho_pos _).le) (Real.exp_pos _).le /- Original line 37980: Erdos416Proof.FordGeometry.log_rho_add_ninth_neg -/ theorem log_rho_add_ninth_neg : Real.log rho+1/9 < 0 := by have hneg := Real.log_neg rho_pos rho_lt_one have h := mul_lt_mul_of_neg_right two_C_lt_four hneg rw [two_C_mul_log_rho] at h linarith /- Original line 37986: Erdos416Proof.FordGeometry.prefixDecay_tendsto -/ theorem prefixDecay_tendsto : Tendsto prefixDecay atTop (nhds 0) := by have h := Real.tendsto_exp_atBot.comp ((tendsto_natCast_atTop_atTop (R := ℝ)).atTop_mul_const_of_neg log_rho_add_ninth_neg) have heq (M : ℕ) : prefixDecay M = 4*Real.exp ((M : ℝ)*(Real.log rho+1/9)) := by unfold prefixDecay rw [mul_add, Real.exp_add, Real.exp_nat_mul, Real.exp_log rho_pos] rw [show (M : ℝ)*(1/9) = (M : ℝ)/9 by ring] ring change Tendsto (fun M => prefixDecay M) atTop (nhds 0) simpa only [heq, mul_zero, Function.comp_apply] using h.const_mul 4 /- Original line 37997: Erdos416Proof.FordGeometry.finite_geometric_tail_bound -/ theorem finite_geometric_tail_bound {r : ℝ} (hr : 0 ≤ r) (hr2 : r ≤ 1/2) (L : ℕ) : (∑ idx ∈ range L, r^(idx+1)) ≤ 2*r := by induction L with | zero => simp; positivity | succ L ih => rw [sum_range_succ'] have heq : (∑ idx ∈ range L, r^(idx+1+1)) = r*(∑ idx ∈ range L, r^(idx+1)) := by rw [mul_sum] apply sum_congr rfl intro idx _ rw [pow_succ] ring rw [heq, pow_one] nlinarith [mul_le_mul_of_nonneg_left ih hr] /- Original line 38012: Erdos416Proof.FordGeometry.prefixDecay_power -/ theorem prefixDecay_power (M h : ℕ) : (4*rho^M)^h*Real.exp ((h : ℝ)*(M : ℝ)/9) = (prefixDecay M)^h := by unfold prefixDecay rw [show (h : ℝ)*(M : ℝ)/9 = (h : ℝ)*((M : ℝ)/9) by ring, Real.exp_nat_mul] exact (mul_pow _ _ _).symm /- Original line 38018: Erdos416Proof.FordGeometry.finite_reversed_geometric_tail_bound -/ theorem finite_reversed_geometric_tail_bound {r : ℝ} (hr : 0 ≤ r) (hr2 : r ≤ 1/2) (L : ℕ) : (∑ K ∈ range L, r^(L-K)) ≤ 2*r := by have heq : (∑ K ∈ range L, r^(L-K)) = ∑ idx ∈ range L, r^(idx+1) := by rw [← sum_range_reflect (fun idx => r^(idx+1)) L] apply sum_congr rfl intro idx hi congr 1 have hi' := mem_range.mp hi omega rw [heq] exact finite_geometric_tail_bound hr hr2 L /-- Summing the prefix losses needs only geometric decay in M. This uniform estimate avoids a separate Gaussian ratio or Stirling bound. -/ /- Original line 38033: Erdos416Proof.FordGeometry.core_weighted_prefix_sum_bound -/ theorem core_weighted_prefix_sum_bound (M : ℕ) {t : ℝ} (ht : Real.exp 1 ≤ t) (hadd : coreDimension M t+M = optimalDimension t) (hM : prefixDecay M ≤ 1/2) : (∑ K ∈ range (coreDimension M t), (t^K*modelVolume K)*Real.exp (((coreDimension M t-K : ℕ) : ℝ)*(M : ℝ)/9)) ≤ 2*prefixDecay M*(t^(coreDimension M t)*modelVolume (coreDimension M t)) := by have ht0 : 0 < t := lt_of_lt_of_le (Real.exp_pos 1) ht have hbase : 0 ≤ t^(coreDimension M t)*modelVolume (coreDimension M t) := mul_nonneg (pow_nonneg ht0.le _) (modelVolume_pos _).le calc _ ≤ ∑ K ∈ range (coreDimension M t), (prefixDecay M)^(coreDimension M t-K)* (t^(coreDimension M t)*modelVolume (coreDimension M t)) := by apply sum_le_sum intro K hK have h := mul_le_mul_of_nonneg_right (core_scaled_prefix_bound M ht hadd (Nat.le_of_lt (mem_range.mp hK))) (Real.exp_pos (((coreDimension M t-K : ℕ) : ℝ)*(M : ℝ)/9)).le apply h.trans_eq rw [mul_right_comm, prefixDecay_power] _ = (∑ K ∈ range (coreDimension M t), (prefixDecay M)^(coreDimension M t-K))* (t^(coreDimension M t)*modelVolume (coreDimension M t)) := (sum_mul _ _ _).symm _ ≤ _ := mul_le_mul_of_nonneg_right (finite_reversed_geometric_tail_bound (prefixDecay_nonneg M) hM _) hbase end Erdos416Proof.FordGeometry namespace Erdos416Proof.FordLower open FordGeometry FordAnalysis FordScale /-- All nonzero-depth collisions together have a relative loss tending to zero with the fixed tail parameter. The family and scale remain arbitrary. -/ /- Original line 38067: Erdos416Proof.FordLower.exists_nonzero_prefix_loss_bound -/ theorem exists_nonzero_prefix_loss_bound : ∃ C : ℝ, 0 < C ∧ ∀ᶠ M : ℕ in atTop, ∀ (A y : ℝ) (a : Fin (coreDimension M (logLog y))) (F : Finset ℕ) (q : ℕ → Fin (coreDimension M (logLog y)+1) → ℕ), 4 ≤ A → 1 < y → Real.exp 1 ≤ logLog y → coreDimension M (logLog y)+M = optimalDimension (logLog y) → (∀ n ∈ F, ∃ R : PrimeProductRecord M A y a n, R.fullTuple = q n) → (∑ K ∈ range (coreDimension M (logLog y)), ((prefixCollisionClass F q (K+1)).card : ℝ)) ≤ C*prefixDecay M*(y/Real.log y)* ((logLog y)^(coreDimension M (logLog y))*modelVolume (coreDimension M (logLog y))) := by obtain ⟨C, hC, hprefix⟩ := exists_maximal_prefix_class_bound refine ⟨22*C, by positivity, ?_⟩ filter_upwards [actual_suffix_reciprocal_mass_eventually, prefixDecay_tendsto.eventually_lt_const (by norm_num : (0 : ℝ) < 1/2)] with M hmass hdecay intro A y a F q hA hy ht hadd hrecords have ht0 : 0 < logLog y := lt_of_lt_of_le (Real.exp_pos 1) ht have hy0 : 0 < y := by linarith have hlog : 0 < Real.log y := Real.log_pos hy have hterm : ∀ K ∈ range (coreDimension M (logLog y)), ((prefixCollisionClass F q (K+1)).card : ℝ) ≤ (11*C)*(y/Real.log y)* (((logLog y)^K*modelVolume K)* Real.exp (((coreDimension M (logLog y)-K : ℕ) : ℝ)*(M : ℝ)/9)) := by intro K hK have hKL := mem_range.mp hK have hp := hprefix M A y a F q hy ht hrecords K hKL.le have hm := hmass A y a F q hA hy ht0 hrecords (K+1) (by omega) rw [Nat.add_sub_add_right] at hm apply hp.trans calc _ ≤ C*(y/Real.log y)*((logLog y)^K*modelVolume K)* (11*Real.exp (((coreDimension M (logLog y)-K : ℕ) : ℝ)*(M : ℝ)/9)) := mul_le_mul_of_nonneg_left hm (mul_nonneg (mul_nonneg hC.le (div_nonneg hy0.le hlog.le)) (mul_nonneg (pow_nonneg ht0.le K) (modelVolume_pos K).le)) _ = _ := by ring calc _ ≤ ∑ K ∈ range (coreDimension M (logLog y)), (11*C)*(y/Real.log y)* (((logLog y)^K*modelVolume K)* Real.exp (((coreDimension M (logLog y)-K : ℕ) : ℝ)*(M : ℝ)/9)) := sum_le_sum hterm _ = (11*C)*(y/Real.log y)* (∑ K ∈ range (coreDimension M (logLog y)), ((logLog y)^K*modelVolume K)* Real.exp (((coreDimension M (logLog y)-K : ℕ) : ℝ)*(M : ℝ)/9)) := (mul_sum _ _ _).symm _ ≤ (11*C)*(y/Real.log y)*(2*prefixDecay M* ((logLog y)^(coreDimension M (logLog y))*modelVolume (coreDimension M (logLog y)))) := mul_le_mul_of_nonneg_left (core_weighted_prefix_sum_bound M ht hadd hdecay.le) (by positivity) _ = _ := by ring /- Original line 38120: Erdos416Proof.FordLower.suffixesUpTo_zero_eq_class -/ theorem suffixesUpTo_zero_eq_class {M : ℕ} {A y : ℝ} {a : Fin (coreDimension M (logLog y))} (F : Finset ℕ) (q : ℕ → Fin (coreDimension M (logLog y)+1) → ℕ) (hrecords : ∀ n ∈ F, ∃ R : PrimeProductRecord M A y a n, R.fullTuple = q n) : suffixesUpTo F q 0 y = prefixCollisionClass F q 0 := by have heq (n : ℕ) (hn : n ∈ prefixCollisionClass F q 0) : suffixProduct (q n) 0 = n := by obtain ⟨R, hR⟩ := hrecords n (mem_prefixCollisionClass.mp hn).1 simpa only [suffixProduct, Nat.zero_le, filter_true, hR] using R.fullTuple_product ext s constructor · intro hs obtain ⟨n, hn, rfl⟩ := mem_image.mp (mem_filter.mp hs).1 simpa only [heq n hn] using hn · intro hs refine mem_filter.mpr ⟨mem_image.mpr ⟨s, hs, heq s hs⟩, ?_⟩ obtain ⟨R, _⟩ := hrecords s (mem_prefixCollisionClass.mp hs).1 exact R.totient_range.2 /- Original line 38138: Erdos416Proof.FordLower.zero_prefix_class_count_eventually -/ theorem zero_prefix_class_count_eventually (M : ℕ) : ∀ᶠ y : ℝ in atTop, ∀ (A : ℝ) (a : Fin (coreDimension M (logLog y))) (F : Finset ℕ) (q : ℕ → Fin (coreDimension M (logLog y)+1) → ℕ), 2 ≤ M → 4 ≤ A → (∀ n ∈ F, ∃ R : PrimeProductRecord M A y a n, R.fullTuple = q n) → ((prefixCollisionClass F q 0).card : ℝ) ≤ 5*(y/(Real.log y*(logLog y)^2)) := by have hLL : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop have hLLL := Real.tendsto_log_atTop.comp hLL filter_upwards [actual_suffix_count_eventually, eventually_gt_atTop (1 : ℝ), hLL.eventually_gt_atTop 0, hLLL.eventually_ge_atTop ((M : ℝ)/10)] with y hcount hy ht hMsize intro A a F q hM hA hrecords rw [← suffixesUpTo_zero_eq_class F q hrecords] simp only [Function.comp_apply] at hMsize exact hcount M A y a F q hM hA hy ht (by linarith) hrecords 0 end Erdos416Proof.FordLower namespace Erdos416Proof.FordGeometry open FordAnalysis FordScale /- Original line 38160: Erdos416Proof.FordGeometry.core_model_mass_ge_one -/ theorem core_model_mass_ge_one (M : ℕ) {t : ℝ} (ht : Real.exp 1 ≤ t) (hadd : coreDimension M t+M = optimalDimension t) (hM : prefixDecay M ≤ 1) : 1 ≤ t^(coreDimension M t)*modelVolume (coreDimension M t) := by have hr0 : 0 ≤ 4*rho^M := mul_nonneg (by norm_num) (pow_pos rho_pos _).le have hr : 4*rho^M ≤ 1 := by have he : 1 ≤ Real.exp ((M : ℝ)/9) := Real.one_le_exp (by positivity) exact (le_mul_of_one_le_right hr0 he).trans hM have h := core_scaled_prefix_bound M ht hadd (K := 0) (Nat.zero_le _) simp only [pow_zero, modelVolume_zero, mul_one, Nat.sub_zero] at h have ht0 : 0 < t := lt_of_lt_of_le (Real.exp_pos 1) ht apply h.trans exact mul_le_of_le_one_left (mul_nonneg (pow_nonneg ht0.le _) (modelVolume_pos _).le) (pow_le_one₀ hr0 hr) /- Original line 38174: Erdos416Proof.FordGeometry.core_ordered_mass_lower -/ theorem core_ordered_mass_lower (M : ℕ) : ∀ᶠ t : ℝ in atTop, prefixDecay M ≤ 1 → modelVolume (coreDimension M t) ≤ 22*T (coreDimension M t) ∧ 1/22 ≤ t^(coreDimension M t)*T (coreDimension M t) := by filter_upwards [(coreDimension_tendsto M).eventually T_eventually_ge_TStar_div, coreDimension_eventual_mesh M, coreDimension_add_tail M, eventually_ge_atTop (Real.exp 1)] with t hT hmesh hadd ht intro hM have hmodel : modelVolume (coreDimension M t) ≤ 22*T (coreDimension M t) := by rw [modelVolume_eq_TStar hmesh.1] linarith refine ⟨hmodel, ?_⟩ have ht0 : 0 < t := lt_of_lt_of_le (Real.exp_pos 1) ht have h := mul_le_mul_of_nonneg_left hmodel (pow_nonneg ht0.le (coreDimension M t)) have hge := core_model_mass_ge_one M ht hadd hM nlinarith end Erdos416Proof.FordGeometry namespace Erdos416Proof.FordLower open FordGeometry FordAnalysis FordScale FordReciprocal FordInner /-- The actual constructed family supplies an unconditional lower bound for V at its geometric main scale. All maximal-prefix collision losses have been removed; no totient injectivity hypothesis remains. -/ /- Original line 38200: Erdos416Proof.FordLower.exists_core_order_lower_bound -/ theorem exists_core_order_lower_bound : ∃ c : ℝ, 0 < c ∧ ∀ᶠ M : ℕ in atTop, ∀ᶠ y : ℝ in atTop, c*(y/Real.log y)*(logLog y)^(coreDimension M (logLog y))* T (coreDimension M (logLog y)) ≤ V y := by obtain ⟨c, hc, hmain⟩ := exists_core_mainTerm_le_V_add_prefixClasses obtain ⟨C, hC, hloss⟩ := exists_nonzero_prefix_loss_bound refine ⟨c/2, half_pos hc, ?_⟩ filter_upwards [hmain 4 (by norm_num), hloss, prefixDecay_tendsto.eventually_lt_const (by positivity : (0 : ℝ) < c/(88*C)), prefixDecay_tendsto.eventually_lt_const (by norm_num : (0 : ℝ) < 1), eventually_ge_atTop 2] with M hmain hlarge hdecay hMrate hM have hLL : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [hmain, zero_prefix_class_count_eventually M, hLL.eventually (core_ordered_mass_lower M), hLL.eventually (coreDimension_add_tail M), hLL.eventually (coreDimension_eventual_mesh M), hLL.eventually_ge_atTop (Real.exp 1), hLL.eventually_ge_atTop (1+440/c), eventually_gt_atTop (1 : ℝ)] with y hmain hzero hvol hadd hmesh ht htlarge hy have ht0 : 0 < logLog y := lt_of_lt_of_le (Real.exp_pos 1) ht have hy0 : 0 < y := by linarith have hlog : 0 < Real.log y := Real.log_pos hy have hY : 0 ≤ y/Real.log y := (div_pos hy0 hlog).le obtain ⟨hmodel, hordered⟩ := hvol hMrate.le let L := coreDimension M (logLog y) let a : Fin L := ⟨L-1, by dsimp [Erdos416Proof.FordGeometry.modelVolume_one, Erdos416Proof.FordGeometry.modelVolume_zero, Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, L]; omega⟩ have ha : a.val+1 = coreDimension M (logLog y) := by dsimp [Erdos416Proof.FordGeometry.modelVolume_one, Erdos416Proof.FordGeometry.modelVolume_zero, Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, a, L]; omega let B := primeProducts (tupleIntegers L (logLog y) (innerSeed (targetParameter L M) a (4/logLog y))) y obtain ⟨q, hrecords, hineq, _⟩ := hmain a ha change c*(y/Real.log y)*(logLog y)^L*T L ≤ V y+∑ j ∈ range (L+1), ((prefixCollisionClass B q j).card : ℝ) at hineq have hz := hzero 4 a B q hM (by norm_num) hrecords have hnz := hlarge 4 y a B q (by norm_num) hy ht hadd hrecords have hfactor : C*prefixDecay M*22 ≤ c/4 := by have h := (lt_div_iff₀ (by positivity : (0 : ℝ) < 88*C)).mp hdecay nlinarith have hbase : 0 ≤ (logLog y)^L*T L := le_trans (by norm_num) hordered have hnonzero : (∑ K ∈ range L, ((prefixCollisionClass B q (K+1)).card : ℝ)) ≤ (c/4)*(y/Real.log y)*((logLog y)^L*T L) := by apply hnz.trans calc _ ≤ C*prefixDecay M*(y/Real.log y)*((logLog y)^L*(22*T L)) := mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_left hmodel (pow_nonneg ht0.le L)) (mul_nonneg (mul_nonneg hC.le (prefixDecay_nonneg M)) hY) _ = (C*prefixDecay M*22)*(y/Real.log y)*((logLog y)^L*T L) := by ring _ ≤ _ := mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_right hfactor hY) hbase have ht1 : 1 ≤ logLog y := by linarith [div_pos (by norm_num : (0 : ℝ) < 440) hc] have hct : 440 ≤ c*logLog y := by have h : 440/c ≤ logLog y := by linarith simpa only [mul_comm] using (div_le_iff₀ hc).mp h have hct2 : 440 ≤ c*(logLog y)^2 := by have hs : logLog y ≤ (logLog y)^2 := by nlinarith exact hct.trans (mul_le_mul_of_nonneg_left hs hc.le) have hsmall : 5/(logLog y)^2 ≤ c/88 := by apply (div_le_iff₀ (sq_pos_of_pos ht0)).mpr nlinarith have hzquarter : ((prefixCollisionClass B q 0).card : ℝ) ≤ (c/4)*(y/Real.log y)*((logLog y)^L*T L) := by apply hz.trans calc _ = (5/(logLog y)^2)*(y/Real.log y) := by ring _ ≤ (c/88)*(y/Real.log y) := mul_le_mul_of_nonneg_right hsmall hY _ = (c/4)*(y/Real.log y)*(1/22) := by ring _ ≤ _ := mul_le_mul_of_nonneg_left hordered (mul_nonneg (by positivity) hY) rw [sum_range_succ'] at hineq change (c/2)*(y/Real.log y)*(logLog y)^L*T L ≤ V y nlinarith end Erdos416Proof.FordLower namespace Erdos416Proof.FordReciprocal open FordGeometry FordScale FordLower /-- The geometric normalization needed by structural exceptional sets, derived from the actual lower family and its proved collision sum. -/ /- Original line 38279: Erdos416Proof.FordReciprocal.exists_core_geometric_V_comparison -/ theorem exists_core_geometric_V_comparison : ∃ K : ℝ, 0 < K ∧ ∀ᶠ M : ℕ in atTop, ∀ᶠ y : ℝ in atTop, (y/Real.log y)*(logLog y)^(coreDimension M (logLog y))* T (coreDimension M (logLog y)) ≤ K*V y := by obtain ⟨c, hc, hbound⟩ := exists_core_order_lower_bound refine ⟨1/c, one_div_pos.mpr hc, ?_⟩ filter_upwards [hbound] with M hM filter_upwards [hM] with y hy have h := mul_le_mul_of_nonneg_left hy (one_div_nonneg.mpr hc.le) simpa only [one_div, ← mul_assoc, inv_mul_cancel₀ hc.ne', one_mul] using h /- Original line 38290: Erdos416Proof.FordReciprocal.exists_core_tuple_mass_V_bound -/ theorem exists_core_tuple_mass_V_bound : ∃ K : ℝ, 0 < K ∧ ∀ᶠ M : ℕ in atTop, ∀ᶠ y : ℝ in atTop, (y/Real.log y)*coreTupleMass M (logLog y) ≤ K*V y := by obtain ⟨B, hB, hmass⟩ := exists_core_tuple_mass_bound obtain ⟨K, hK, hcompare⟩ := exists_core_geometric_V_comparison refine ⟨B*K, mul_pos hB hK, ?_⟩ have hLL : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [hmass, hcompare] with M hmass hcompare filter_upwards [hLL.eventually hmass, hcompare, eventually_gt_atTop (1 : ℝ)] with y hmass hcompare hy have hY : 0 ≤ y/Real.log y := (div_pos (by linarith) (Real.log_pos hy)).le calc _ ≤ (y/Real.log y)*(B*(logLog y)^(coreDimension M (logLog y))*T (coreDimension M (logLog y))) := mul_le_mul_of_nonneg_left hmass hY _ = B*((y/Real.log y)*(logLog y)^(coreDimension M (logLog y))*T (coreDimension M (logLog y))) := by ring _ ≤ B*(K*V y) := mul_le_mul_of_nonneg_left hcompare hB.le _ = _ := by ring /-- The outer-facet reciprocal error is negligible relative to the actual totient count, not merely to an unconnected geometric expression. -/ /- Original line 38310: Erdos416Proof.FordReciprocal.core_outer_shell_mass_negligible_in_V -/ theorem core_outer_shell_mass_negligible_in_V : ∀ᶠ M : ℕ in atTop, Asymptotics.IsLittleO atTop (fun y : ℝ => (y/Real.log y)*coreOuterShellMass M (logLog y)) V := by obtain ⟨c, hc, hlower⟩ := exists_core_order_lower_bound have hLL : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [hlower, core_outer_shell_mass_negligible] with M hlower hshell apply Asymptotics.IsLittleO.of_bound intro ε hε filter_upwards [hLL.eventually (hshell.def (mul_pos hε hc)), hlower, eventually_gt_atTop (1 : ℝ), hLL.eventually_gt_atTop 0] with y hs hl hy ht have hY : 0 ≤ y/Real.log y := (div_pos (by linarith) (Real.log_pos hy)).le have hmass0 : 0 ≤ coreOuterShellMass M (logLog y) := tupleReciprocalMass_nonneg _ _ _ have hgeo0 : 0 ≤ (logLog y)^(coreDimension M (logLog y))*T (coreDimension M (logLog y)) := mul_nonneg (pow_nonneg ht.le _) measureReal_nonneg simp only [Real.norm_eq_abs, abs_of_nonneg hmass0, abs_of_nonneg hgeo0] at hs simp only [Real.norm_eq_abs, abs_of_nonneg (mul_nonneg hY hmass0), abs_of_nonneg (V_nonneg y)] calc _ ≤ (y/Real.log y)*((ε*c)*((logLog y)^(coreDimension M (logLog y))*T (coreDimension M (logLog y)))) := mul_le_mul_of_nonneg_left hs hY _ = ε*(c*(y/Real.log y)*(logLog y)^(coreDimension M (logLog y))*T (coreDimension M (logLog y))) := by ring _ ≤ ε*V y := mul_le_mul_of_nonneg_left hl hε.le end Erdos416Proof.FordReciprocal /- Positive terminal cutoff bounds at the actual core scale, normalization by V, and Gaussian volume decay for structural exceptional-set sums. -/ open Filter Finset MeasureTheory open scoped Classical Topology BigOperators Pointwise namespace Erdos416Proof.SimplexVolume /- Original line 38347: Erdos416Proof.SimplexVolume.simplexCap_exponential_bound_scale -/ theorem simplexCap_exponential_bound_scale {n : ℕ} {b : Fin n → ℝ} (hb : ∀ idx, 0 < b idx) (p : Fin n) {α t : ℝ} (hα : 0 ≤ α) (ht : 0 < t) : volume.real (simplexCap b p α t) ≤ t^n*Real.exp (-(n : ℝ)*(b p*α)/t)*volume.real (weightedSimplex n b 1) := by have hd : 0 < (n.factorial : ℝ)*∏ idx, b idx := mul_pos (by positivity) (prod_pos (fun idx _ => hb idx)) by_cases hcut : b p*α ≤ t · have hq : b p*α/t ≤ 1 := (div_le_one ht).mpr hcut have hpow : (1-b p*α/t)^n ≤ Real.exp (-(n : ℝ)*(b p*α)/t) := by calc _ ≤ (Real.exp (-(b p*α/t)))^n := pow_le_pow_left₀ (by linarith) (by linarith [Real.add_one_le_exp (-(b p*α/t))]) n _ = _ := by rw [← Real.exp_nat_mul]; congr 1; ring have heq : (t-b p*α)^n = t^n*(1-b p*α/t)^n := by rw [← mul_pow] congr 1 field_simp [ht.ne'] rw [simplexCap_volume hb p hα (by linarith), heq, realVolume_weightedSimplex hb zero_le_one, one_pow] calc _ ≤ (t^n*Real.exp (-(n : ℝ)*(b p*α)/t))/((n.factorial : ℝ)*∏ idx, b idx) := div_le_div_of_nonneg_right (mul_le_mul_of_nonneg_left hpow (pow_nonneg ht.le n)) hd.le _ = _ := by ring · rw [simplexCap_empty_of_lt hb p (lt_of_not_ge hcut)] simp only [measureReal_empty] exact mul_nonneg (mul_nonneg (pow_nonneg ht.le n) (Real.exp_pos _).le) measureReal_nonneg end Erdos416Proof.SimplexVolume namespace Erdos416Proof.FordGeometry open FordAnalysis SimplexVolume variable {L : ℕ} /- Original line 38382: Erdos416Proof.FordGeometry.slackRowRadius_terminal -/ theorem slackRowRadius_terminal (p : Fin L) (hp : p.val+1 = L) : slackRowRadius p = 1 := by have hw (j : Fin L) : tailWeight p j = 0 := tailWeight_zero (by have := j.isLt; change j.val ≤ p.val; omega) simp [Erdos416Proof.FordGeometry.slackMap_apply, slackRowRadius, hw] /- Original line 38387: Erdos416Proof.FordGeometry.thickSlack_terminal -/ theorem thickSlack_terminal (p : Fin L) (hp : p.val+1 = L) (τ : ℝ) (x : Fin L → ℝ) : thickSlack L τ x p = x p+τ := by simp only [thickSlack, Pi.add_apply, slackMap_apply, tailForm_terminal p hp, sub_zero, slackShift, slackRowRadius_terminal p hp, mul_one] /- Original line 38392: Erdos416Proof.FordGeometry.thickSlack_cap_image_subset -/ theorem thickSlack_cap_image_subset (hL : 2 ≤ L) (p : Fin L) (hp : p.val+1 = L) (α τ : ℝ) : thickSlack L τ '' ((unorderedSimplex L ∩ {x | α ≤ x p})+errorCube L τ) ⊆ simplexCap (simplexWeight L) p α (1+2*τ*∑ j, simplexWeight L j) := by rintro z ⟨w, hw, rfl⟩ obtain ⟨x, hx, e, he, rfl⟩ := Set.mem_add.mp hw refine ⟨thickSlack_image_subset hL τ ⟨x+e, Set.mem_add.mpr ⟨x, hx.1, e, he, rfl⟩, rfl⟩, ?_⟩ change α ≤ thickSlack L τ (x+e) p rw [thickSlack_terminal p hp] change α ≤ x p+e p+τ have hxp : α ≤ x p := hx.2 have hep : -τ ≤ e p := he.1 p linarith /- Original line 38407: Erdos416Proof.FordGeometry.thickened_unordered_cap_bound -/ theorem thickened_unordered_cap_bound (hL : 2 ≤ L) (p : Fin L) (hp : p.val+1 = L) {α τ : ℝ} (hα : 0 ≤ α) (hτ : 0 ≤ τ) : volume.real ((unorderedSimplex L ∩ {x | α ≤ x p})+errorCube L τ) ≤ (1+2*τ*∑ j, simplexWeight L j)^L* Real.exp (-(L : ℝ)*(simplexWeight L p*α)/(1+2*τ*∑ j, simplexWeight L j))*TStar L := by have hs : 0 ≤ ∑ j : Fin L, simplexWeight L j := sum_nonneg (fun j _ => (simplexWeight_pos j).le) have hD : 0 < 1+2*τ*∑ j : Fin L, simplexWeight L j := by positivity have hcap : IsCompact (simplexCap (simplexWeight L) p α (1+2*τ*∑ j, simplexWeight L j)) := (weightedSimplex_isCompact (fun j => simplexWeight_pos j) _).inter_right (isClosed_le continuous_const (continuous_apply p)) have hvolume : volume.real (weightedSimplex L (simplexWeight L) 1) = TStar L := by rw [realVolume_weightedSimplex (fun j => simplexWeight_pos j) zero_le_one, one_pow, simplexWeight_product, TStar_eq hL] calc _ = volume.real (thickSlack L τ '' ((unorderedSimplex L ∩ {x | α ≤ x p})+errorCube L τ)) := (thickSlack_volume_image _ _).symm _ ≤ volume.real (simplexCap (simplexWeight L) p α (1+2*τ*∑ j, simplexWeight L j)) := measureReal_mono (thickSlack_cap_image_subset hL p hp α τ) hcap.measure_lt_top.ne _ ≤ _ := by simpa only [hvolume] using simplexCap_exponential_bound_scale (fun j => simplexWeight_pos j) p hα hD /- Original line 38429: Erdos416Proof.FordGeometry.thickening_level_bound -/ theorem thickening_level_bound (hL : 2 ≤ L) {τ : ℝ} (hτ : 0 ≤ τ) (hsmall : τ ≤ 10*rho^L/(L : ℝ)) : 1+2*τ*∑ j : Fin L, simplexWeight L j ≤ 41 := by have hLpos : (0 : ℝ) < L := by exact_mod_cast (show 0 < L by omega) have hL2 : (2 : ℝ) ≤ L := by exact_mod_cast hL have hs : 0 ≤ ∑ j : Fin L, simplexWeight L j := sum_nonneg (fun j _ => (simplexWeight_pos j).le) have hτL := (le_div_iff₀ hLpos).mp hsmall have hprod := mul_le_mul_of_nonneg_right hτL hs have hsum := simplexWeight_scaled_sum_bound hL have hmass : 0 ≤ 2*τ*∑ j : Fin L, simplexWeight L j := by positivity nlinarith [mul_le_mul_of_nonneg_right hL2 hmass] /- Original line 38441: Erdos416Proof.FordGeometry.thickened_unordered_cap_uniform_bound -/ theorem thickened_unordered_cap_uniform_bound (hL : 2 ≤ L) (p : Fin L) (hp : p.val+1 = L) {α τ : ℝ} (hα : 0 ≤ α) (hτ : 0 ≤ τ) (hsmall : τ ≤ 10*rho^L/(L : ℝ)) : volume.real ((unorderedSimplex L ∩ {x | α ≤ x p})+errorCube L τ) ≤ Real.exp 80*Real.exp (-(L : ℝ)*α/(164*rho^L))*TStar L := by let D := 1+2*τ*∑ j : Fin L, simplexWeight L j have hs : 0 ≤ ∑ j : Fin L, simplexWeight L j := sum_nonneg (fun j _ => (simplexWeight_pos j).le) have hD0 : 0 < D := by dsimp [Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.gStar_zero, Erdos416Proof.FordAnalysis.g_zero, Erdos416Proof.FordGeometry.modelVolume_one, D]; positivity have hD : D ≤ 41 := thickening_level_bound hL hτ hsmall have hbp : (1/4 : ℝ) ≤ simplexWeight L p*rho^L := by simpa only [simplexWeight, hp, lt_self_iff_false, ↓reduceIte] using gStar_scaled_lower L have hden : 0 < 164*rho^L := mul_pos (by norm_num) (pow_pos rho_pos _) have hlower : 1/(164*rho^L) ≤ simplexWeight L p/D := by apply (div_le_div_iff₀ hden hD0).mpr nlinarith have he : -(L : ℝ)*(simplexWeight L p*α)/D ≤ -(L : ℝ)*α/(164*rho^L) := by have h := mul_le_mul_of_nonneg_left hlower (mul_nonneg (Nat.cast_nonneg L) hα) calc _ = -((L : ℝ)*α*(simplexWeight L p/D)) := by ring _ ≤ -((L : ℝ)*α*(1/(164*rho^L))) := neg_le_neg h _ = _ := by ring have hpow : D^L ≤ Real.exp 80 := thickening_power_bound hL hτ hsmall apply (thickened_unordered_cap_bound hL p hp hα hτ).trans exact mul_le_mul_of_nonneg_right (mul_le_mul hpow (Real.exp_le_exp.mpr he) (Real.exp_pos _).le (Real.exp_pos _).le) (TStar_pos hL).le end Erdos416Proof.FordGeometry namespace Erdos416Proof.FordGeometry open FordAnalysis SimplexVolume /- Original line 38475: Erdos416Proof.FordGeometry.scaleProduct_le_H -/ theorem scaleProduct_le_H {ξ : ℕ → ℝ} (hξ : ∀ j, 1 ≤ ξ j) (L : ℕ) : scaleProduct ξ L ≤ H L ξ := by unfold scaleProduct H apply prod_le_prod (fun j _ => zero_le_one.trans (hξ j)) intro j hj exact le_self_pow₀ (hξ j) (by have := mem_range.mp hj; omega) /- Original line 38482: Erdos416Proof.FordGeometry.thickened_polytope_cap_subset_diagonal -/ theorem thickened_polytope_cap_subset_diagonal {L : ℕ} {ξ : ℕ → ℝ} (hξ : ∀ j, 1 ≤ ξ j) (hH : H L ξ ≤ 2) (p : Fin L) (hp : p.val+1 = L) {α τ : ℝ} (hα : 0 ≤ α) (hτ : 0 ≤ τ) : (polytope L ξ ∩ {x | α ≤ x p})+errorCube L τ ⊆ diagonal L ξ '' ((unorderedSimplex L ∩ {x | α/2 ≤ x p})+errorCube L τ) := by intro z hz obtain ⟨x, hx, e, he, rfl⟩ := Set.mem_add.mp hz have hQ : scaleProduct ξ L ≤ 2 := (scaleProduct_le_H hξ L).trans hH have hQ0 : 0 < scaleProduct ξ L := lt_of_lt_of_le zero_lt_one (prefix_ge_one hξ L) have hcap : normalized ξ x ∈ unorderedSimplex L ∩ {x | α/2 ≤ x p} := by refine ⟨polytope_subset_unorderedSimplex L (normalized_mem hξ hx.1), ?_⟩ change α/2 ≤ x p/scaleProduct ξ (p.val+1) rw [hp] apply (le_div_iff₀ hQ0).mpr have hxp : α ≤ x p := hx.2 nlinarith refine ⟨normalized ξ x+normalized ξ e, Set.mem_add.mpr ⟨normalized ξ x, hcap, normalized ξ e, normalized_mem_errorCube hξ hτ he, rfl⟩, ?_⟩ rw [map_add, diagonal_normalized (fun j => lt_of_lt_of_le zero_lt_one (hξ j)), diagonal_normalized (fun j => lt_of_lt_of_le zero_lt_one (hξ j))] /-- Positive terminal cutoffs survive both cube thickening and the actual expanded-parameter diagonal map, with a uniform exponential tail. -/ /- Original line 38506: Erdos416Proof.FordGeometry.thickened_polytope_cap_eventual_bound -/ theorem thickened_polytope_cap_eventual_bound : ∀ᶠ L : ℕ in atTop, ∀ (ξ : ℕ → ℝ) (p : Fin L) (α τ : ℝ), p.val+1 = L → (∀ j, 1 ≤ ξ j) → H L ξ ≤ 2 → 0 ≤ α → 0 ≤ τ → τ ≤ 10*rho^L/(L : ℝ) → volume.real ((polytope L ξ ∩ {x | α ≤ x p})+errorCube L τ) ≤ (44*Real.exp 80)*Real.exp (-(L : ℝ)*α/(328*rho^L))*T L := by filter_upwards [T_eventually_ge_TStar_div, eventually_ge_atTop 2] with L hT hL intro ξ p α τ hp hξ hH hα hτ hsmall have hC : IsCompact ((unorderedSimplex L ∩ {x | α/2 ≤ x p})+errorCube L τ) := ((unorderedSimplex_isCompact hL).inter_right (isClosed_le continuous_const (continuous_apply p))).add isCompact_Icc have hH0 : 0 ≤ H L ξ := H_nonneg (fun j => zero_le_one.trans (hξ j)) have hT' : TStar L ≤ 22*T L := by linarith have heq : -(L : ℝ)*(α/2)/(164*rho^L) = -(L : ℝ)*α/(328*rho^L) := by ring calc _ ≤ volume.real (diagonal L ξ '' ((unorderedSimplex L ∩ {x | α/2 ≤ x p})+errorCube L τ)) := measureReal_mono (thickened_polytope_cap_subset_diagonal hξ hH p hp hα hτ) (hC.image (diagonal L ξ).continuous_of_finiteDimensional).measure_lt_top.ne _ = H L ξ*volume.real ((unorderedSimplex L ∩ {x | α/2 ≤ x p})+errorCube L τ) := by rw [diagonal_volume, abs_of_nonneg hH0] _ ≤ H L ξ*(Real.exp 80*Real.exp (-(L : ℝ)*(α/2)/(164*rho^L))*TStar L) := mul_le_mul_of_nonneg_left (thickened_unordered_cap_uniform_bound hL p hp (div_nonneg hα (by norm_num)) hτ hsmall) hH0 _ ≤ 2*(Real.exp 80*Real.exp (-(L : ℝ)*(α/2)/(164*rho^L))*TStar L) := mul_le_mul_of_nonneg_right hH (mul_nonneg (mul_nonneg (Real.exp_pos _).le (Real.exp_pos _).le) (TStar_pos hL).le) _ ≤ 2*(Real.exp 80*Real.exp (-(L : ℝ)*(α/2)/(164*rho^L))*(22*T L)) := mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_left hT' (mul_nonneg (Real.exp_pos _).le (Real.exp_pos _).le)) (by norm_num) _ = _ := by rw [heq]; ring end Erdos416Proof.FordGeometry namespace Erdos416Proof.FordReciprocal open FordGeometry FordAnalysis /- Original line 38542: Erdos416Proof.FordReciprocal.exists_tuple_terminal_cap_mass_bound -/ theorem exists_tuple_terminal_cap_mass_bound : ∃ K : ℝ, 0 < K ∧ ∀ᶠ L : ℕ in atTop, ∀ (ξ : ℕ → ℝ) (p : Fin L) (α t : ℝ), p.val+1 = L → (∀ j, 1 ≤ ξ j) → H L ξ ≤ 2 → 0 ≤ α → 0 < t → 1/t ≤ 10*rho^L/(L : ℝ) → tupleReciprocalMass L t (polytope L ξ ∩ {x | α ≤ x p}) ≤ K*Real.exp (-(L : ℝ)*α/(328*rho^L))*(t^L*T L) := by obtain ⟨C, hC, hmass⟩ := exists_tupleReciprocalMass_volume_bound refine ⟨C*(44*Real.exp 80), by positivity, ?_⟩ filter_upwards [thickened_polytope_cap_eventual_bound] with L hvol intro ξ p α t hp hξ hH hα ht hsmall have hE : polytope L ξ ∩ {x | α ≤ x p} ⊆ Set.Icc (fun _ => 0) (fun _ => 1) := fun x hx => ⟨hx.1.1, hx.1.2.1⟩ calc _ ≤ C*t^L*volume.real ((polytope L ξ ∩ {x | α ≤ x p})+errorCube L (1/t)) := hmass L t _ ht hE _ ≤ C*t^L*((44*Real.exp 80)*Real.exp (-(L : ℝ)*α/(328*rho^L))*T L) := mul_le_mul_of_nonneg_left (hvol ξ p α (1/t) hp hξ hH hα (one_div_nonneg.mpr ht.le) hsmall) (mul_nonneg hC.le (pow_nonneg ht.le L)) _ = _ := by ring end Erdos416Proof.FordReciprocal open Filter Finset MeasureTheory open scoped Classical Topology BigOperators Pointwise namespace Erdos416Proof.FordScale open FordAnalysis FordGeometry /- Original line 38576: Erdos416Proof.FordScale.coreDimension_floor_lower -/ theorem coreDimension_floor_lower (M : ℕ) {t : ℝ} (hadd : coreDimension M t+M = optimalDimension t) : 2*C*(Real.log t-Real.log (Real.log t)) < (coreDimension M t : ℝ)+(M : ℝ)+1 := by have h := Nat.lt_floor_add_one (2*C*(Real.log t-Real.log (Real.log t))) change _ < (optimalDimension t : ℝ)+1 at h rw [← hadd, Nat.cast_add] at h exact h /-- The opposite floor inequality supplies the upper bound on rho^L needed for positive-cutoff decay. The fixed tail M is retained. -/ /- Original line 38587: Erdos416Proof.FordScale.coreDimension_rho_upper_with_tail -/ theorem coreDimension_rho_upper_with_tail (M : ℕ) : ∀ᶠ t : ℝ in atTop, rho^(coreDimension M t)*rho^(M+1) ≤ Real.log t/t := by filter_upwards [coreDimension_add_tail M, eventually_gt_atTop (1 : ℝ)] with t hadd ht have hlog := Real.log_neg rho_pos rho_lt_one have hm := mul_le_mul_of_nonpos_right (coreDimension_floor_lower M hadd).le hlog.le have he : (2*C*(Real.log t-Real.log (Real.log t)))*Real.log rho = Real.log (Real.log t)-Real.log t := by calc _ = ((2*C)*Real.log rho)*(Real.log t-Real.log (Real.log t)) := by ring _ = _ := by rw [two_C_mul_log_rho]; ring rw [he] at hm calc _ = Real.exp (((coreDimension M t : ℝ)+(M : ℝ)+1)*Real.log rho) := by rw [← pow_add] have hcast : (coreDimension M t : ℝ)+(M : ℝ)+1 = ((coreDimension M t+(M+1) : ℕ) : ℝ) := by push_cast; ring rw [hcast, Real.exp_nat_mul, Real.exp_log rho_pos] _ ≤ Real.exp (Real.log (Real.log t)-Real.log t) := Real.exp_le_exp.mpr hm _ = _ := by rw [Real.exp_sub, Real.exp_log (Real.log_pos ht), Real.exp_log (by linarith)] /- Original line 38608: Erdos416Proof.FordScale.coreDimension_ge_C_log -/ theorem coreDimension_ge_C_log (M : ℕ) : ∀ᶠ t : ℝ in atTop, C*Real.log t ≤ (coreDimension M t : ℝ) := by have hsmall : ∀ᶠ t : ℝ in atTop, Real.log (Real.log t) ≤ Real.log t/4 := by filter_upwards [Real.tendsto_log_atTop.eventually (Real.isLittleO_log_id_atTop.def (by norm_num : (0 : ℝ) < 1/4)), eventually_gt_atTop (1 : ℝ)] with t h ht simp only [Real.norm_eq_abs, id_eq, abs_of_nonneg (Real.log_pos ht).le] at h linarith [le_abs_self (Real.log (Real.log t))] have htail : ∀ᶠ t : ℝ in atTop, (M : ℝ)+1 ≤ (C/2)*Real.log t := (Real.tendsto_log_atTop.const_mul_atTop (div_pos C_pos (by norm_num))).eventually_ge_atTop _ filter_upwards [coreDimension_add_tail M, hsmall, htail] with t hadd hs hm have hf := coreDimension_floor_lower M hadd have hmul := mul_le_mul_of_nonneg_left hs (mul_pos (by norm_num : (0 : ℝ) < 2) C_pos).le nlinarith /- Original line 38624: Erdos416Proof.FordScale.core_prefix_rate_lower -/ theorem core_prefix_rate_lower (M : ℕ) : ∀ᶠ t : ℝ in atTop, C*rho^(M+1) ≤ (coreDimension M t : ℝ)/(t*rho^(coreDimension M t)) := by filter_upwards [coreDimension_rho_upper_with_tail M, coreDimension_ge_C_log M, eventually_gt_atTop (0 : ℝ)] with t hr hdim ht have hr' := (le_div_iff₀ ht).mp hr have h := mul_le_mul_of_nonneg_left hr' C_pos.le apply (le_div_iff₀ (mul_pos ht (pow_pos rho_pos _))).mpr calc _ = C*(rho^(coreDimension M t)*rho^(M+1)*t) := by ring _ ≤ C*Real.log t := h _ ≤ _ := hdim /- Original line 38636: Erdos416Proof.FordScale.terminalCapRate -/ noncomputable def terminalCapRate (M : ℕ) : ℝ := C*rho^(M+1)/328 /- Original line 38638: Erdos416Proof.FordScale.terminalCapRate_pos -/ theorem terminalCapRate_pos (M : ℕ) : 0 < terminalCapRate M := by exact div_pos (mul_pos C_pos (pow_pos rho_pos _)) (by norm_num) /- Original line 38641: Erdos416Proof.FordScale.core_terminal_cap_exponent -/ theorem core_terminal_cap_exponent (M : ℕ) : ∀ᶠ t : ℝ in atTop, ∀ A : ℝ, 0 ≤ A → -(coreDimension M t : ℝ)*(A/t)/(328*rho^(coreDimension M t)) ≤ -(terminalCapRate M*A) := by filter_upwards [core_prefix_rate_lower M] with t hr intro A hA have h := mul_le_mul_of_nonneg_right (div_le_div_of_nonneg_right hr (by norm_num : (0 : ℝ) ≤ 328)) hA calc _ = -(((coreDimension M t : ℝ)/(t*rho^(coreDimension M t))/328)*A) := by ring _ ≤ -((C*rho^(M+1)/328)*A) := neg_le_neg h _ = _ := rfl end Erdos416Proof.FordScale namespace Erdos416Proof.FordReciprocal open FordAnalysis FordGeometry FordScale /-- The actual expanded polytope restricted by a cutoff at its last coordinate. The existential also makes the zero-dimensional case empty. -/ /- Original line 38664: Erdos416Proof.FordReciprocal.coreTerminalCap -/ noncomputable def coreTerminalCap (M : ℕ) (A t : ℝ) : Set (Fin (coreDimension M t) → ℝ) := polytope (coreDimension M t) (expandedParameter (optimalDimension t)) ∩ {x | ∃ p : Fin (coreDimension M t), p.val+1 = coreDimension M t ∧ A/t ≤ x p} /- Original line 38669: Erdos416Proof.FordReciprocal.coreTerminalCap_eq -/ theorem coreTerminalCap_eq (M : ℕ) (A t : ℝ) (p : Fin (coreDimension M t)) (hp : p.val+1 = coreDimension M t) : coreTerminalCap M A t = polytope (coreDimension M t) (expandedParameter (optimalDimension t)) ∩ {x | A/t ≤ x p} := by ext x constructor · rintro ⟨hx, q, hq, hcut⟩ have heq : q = p := Fin.ext (by omega) refine ⟨hx, ?_⟩ change A/t ≤ x p simpa only [heq] using hcut · rintro ⟨hx, hcut⟩ exact ⟨hx, p, hp, hcut⟩ /- Original line 38684: Erdos416Proof.FordReciprocal.coreTerminalCapMass -/ noncomputable def coreTerminalCapMass (M : ℕ) (A t : ℝ) : ℝ := tupleReciprocalMass (coreDimension M t) t (coreTerminalCap M A t) /- Original line 38687: Erdos416Proof.FordReciprocal.coreTerminalCapMass_nonneg -/ theorem coreTerminalCapMass_nonneg (M : ℕ) (A t : ℝ) : 0 ≤ coreTerminalCapMass M A t := tupleReciprocalMass_nonneg _ _ _ /-- M is fixed first, then the scale threshold is uniform over every nonnegative cutoff A. The exponential rate is strictly positive for M. -/ /- Original line 38692: Erdos416Proof.FordReciprocal.exists_core_terminal_cap_mass_bound -/ theorem exists_core_terminal_cap_mass_bound : ∃ B : ℝ, 0 < B ∧ ∀ᶠ M : ℕ in atTop, ∀ᶠ t : ℝ in atTop, ∀ A : ℝ, 0 ≤ A → coreTerminalCapMass M A t ≤ B*Real.exp (-(terminalCapRate M*A))*(t^(coreDimension M t)*T (coreDimension M t)) := by obtain ⟨B, hB, hbound⟩ := exists_tuple_terminal_cap_mass_bound refine ⟨B, hB, ?_⟩ filter_upwards [expanded_H_eventually] with M hM filter_upwards [(coreDimension_tendsto M).eventually hbound, coreDimension_eventual_mesh M, coreDimension_add_tail M, core_terminal_cap_exponent M, eventually_gt_atTop (0 : ℝ)] with t hb hmesh hadd he ht intro A hA let p : Fin (coreDimension M t) := ⟨coreDimension M t-1, by have := hmesh.1; omega⟩ have hp : p.val+1 = coreDimension M t := by dsimp [p]; have := hmesh.1; omega have hH : H (coreDimension M t) (expandedParameter (optimalDimension t)) ≤ 2 := by rw [← hadd] exact hM (coreDimension M t) unfold coreTerminalCapMass rw [coreTerminalCap_eq M A t p hp] apply (hb (expandedParameter (optimalDimension t)) p (A/t) t hp (expandedParameter_ge_one _) hH (div_nonneg hA ht.le) ht hmesh.2).trans exact mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left (Real.exp_le_exp.mpr (he A hA)) hB.le) (mul_nonneg (pow_nonneg ht.le _) measureReal_nonneg) /-- The positive terminal tail is bounded relative to the actual totient count, uniformly over the cutoff after the scale threshold. -/ /- Original line 38718: Erdos416Proof.FordReciprocal.exists_core_terminal_cap_mass_V_bound -/ theorem exists_core_terminal_cap_mass_V_bound : ∃ K : ℝ, 0 < K ∧ ∀ᶠ M : ℕ in atTop, ∀ᶠ y : ℝ in atTop, ∀ A : ℝ, 0 ≤ A → (y/Real.log y)*coreTerminalCapMass M A (logLog y) ≤ K*Real.exp (-(terminalCapRate M*A))*V y := by obtain ⟨B, hB, hmass⟩ := exists_core_terminal_cap_mass_bound obtain ⟨J, hJ, hcompare⟩ := exists_core_geometric_V_comparison refine ⟨B*J, mul_pos hB hJ, ?_⟩ have hLL : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [hmass, hcompare] with M hmass hcompare filter_upwards [hLL.eventually hmass, hcompare, eventually_gt_atTop (1 : ℝ)] with y hmass hcompare hy intro A hA have hY : 0 ≤ y/Real.log y := (div_pos (by linarith) (Real.log_pos hy)).le calc _ ≤ (y/Real.log y)*(B*Real.exp (-(terminalCapRate M*A))* ((logLog y)^(coreDimension M (logLog y))*T (coreDimension M (logLog y)))) := mul_le_mul_of_nonneg_left (hmass A hA) hY _ = (B*Real.exp (-(terminalCapRate M*A)))* ((y/Real.log y)*(logLog y)^(coreDimension M (logLog y))*T (coreDimension M (logLog y))) := by ring _ ≤ (B*Real.exp (-(terminalCapRate M*A)))*(J*V y) := mul_le_mul_of_nonneg_left hcompare (mul_nonneg hB.le (Real.exp_pos _).le) _ = _ := by ring /-- For every sufficiently large fixed M, a fixed cutoff makes the terminal reciprocal tail arbitrarily small compared with V(y). The quantifier order is M, epsilon, cutoff, then y. -/ /- Original line 38745: Erdos416Proof.FordReciprocal.core_terminal_cap_mass_small_in_V -/ theorem core_terminal_cap_mass_small_in_V : ∀ᶠ M : ℕ in atTop, ∀ ε : ℝ, 0 < ε → ∀ᶠ A : ℝ in atTop, ∀ᶠ y : ℝ in atTop, (y/Real.log y)*coreTerminalCapMass M A (logLog y) ≤ ε*V y := by obtain ⟨K, hK, hbound⟩ := exists_core_terminal_cap_mass_V_bound filter_upwards [hbound] with M hM intro ε hε have he : Tendsto (fun A : ℝ => K*Real.exp (-(terminalCapRate M*A))) atTop (nhds 0) := by have h := (Real.tendsto_exp_neg_atTop_nhds_zero.comp (tendsto_id.const_mul_atTop (terminalCapRate_pos M))).const_mul K simpa only [Function.comp_def, mul_zero] using! h filter_upwards [he.eventually_lt_const hε, eventually_ge_atTop (0 : ℝ)] with A hA hA0 filter_upwards [hM] with y hy exact (hy A hA0).trans (mul_le_mul_of_nonneg_right hA.le (V_nonneg y)) end Erdos416Proof.FordReciprocal open Filter Finset open scoped Classical Topology BigOperators namespace Erdos416Proof.FordGeometry open FordAnalysis FordScale /-- Keeping the improvement at each earlier coordinate gives the triangular power that is lost by a constant geometric majorant. -/ /- Original line 38774: Erdos416Proof.FordGeometry.backwards_quadratic_bound -/ theorem backwards_quadratic_bound (f : ℕ → ℝ) {r s : ℝ} (hr : 0 ≤ r) (hs : 0 ≤ s) {K L : ℕ} (hKL : K ≤ L) (hstep : ∀ idx : ℕ, idx < L → f idx ≤ (r*s^(L-(idx+1)))*f (idx+1)) : f K ≤ r^(L-K)*s^((L-K).choose 2)*f L := by have hbound : ∀ d : ℕ, d ≤ L → f (L-d) ≤ r^d*s^(d.choose 2)*f L := by intro d induction d with | zero => intro _; simp | succ d ih => intro hd have hdL : d ≤ L := by omega have hiL : L-(d+1) < L := by omega have hnext : L-(d+1)+1 = L-d := by omega have h := hstep (L-(d+1)) hiL rw [hnext, show L-(L-d) = d by omega] at h calc _ ≤ (r*s^d)*f (L-d) := h _ ≤ (r*s^d)*(r^d*s^(d.choose 2)*f L) := mul_le_mul_of_nonneg_left (ih hdL) (mul_nonneg hr (pow_nonneg hs _)) _ = _ := by rw [Nat.choose_succ_succ, Nat.choose_one_right, pow_add, pow_succ] ring simpa only [Nat.sub_sub_self hKL] using hbound (L-K) (Nat.sub_le L K) /- Original line 38798: Erdos416Proof.FordGeometry.scaled_modelVolume_gaussian_prefix_bound -/ theorem scaled_modelVolume_gaussian_prefix_bound {t : ℝ} (ht : 0 < t) {K L : ℕ} (hKL : K ≤ L) : t^K*modelVolume K ≤ ((L : ℝ)/(t*rho^L))^(L-K)*rho^((L-K).choose 2)*(t^L*modelVolume L) := by apply backwards_quadratic_bound (fun idx => t^idx*modelVolume idx) (div_nonneg (Nat.cast_nonneg L) (mul_pos ht (pow_pos rho_pos _)).le) rho_pos.le hKL intro idx hiL have hi : idx+1 ≤ L := by omega have hpow : rho^L = rho^(idx+1)*rho^(L-(idx+1)) := by rw [← pow_add, Nat.add_sub_of_le hi] have hrate : ((idx : ℝ)+1)/(t*rho^(idx+1)) ≤ ((L : ℝ)/(t*rho^L))*rho^(L-(idx+1)) := by calc _ ≤ (L : ℝ)/(t*rho^(idx+1)) := div_le_div_of_nonneg_right (by exact_mod_cast hi) (mul_pos ht (pow_pos rho_pos _)).le _ = _ := by rw [hpow] field_simp [ht.ne', (pow_pos rho_pos (idx+1)).ne', (pow_pos rho_pos (L-(idx+1))).ne'] exact (scaled_modelVolume_step ht idx).trans (mul_le_mul_of_nonneg_right hrate (mul_nonneg (pow_nonneg ht.le _) (modelVolume_pos _).le)) /- Original line 38819: Erdos416Proof.FordGeometry.core_scaled_gaussian_prefix_bound -/ theorem core_scaled_gaussian_prefix_bound (M : ℕ) {t : ℝ} (ht : Real.exp 1 ≤ t) (hadd : coreDimension M t+M = optimalDimension t) {K : ℕ} (hK : K ≤ coreDimension M t) : t^K*modelVolume K ≤ (4*rho^M)^(coreDimension M t-K)*rho^((coreDimension M t-K).choose 2)* (t^(coreDimension M t)*modelVolume (coreDimension M t)) := by have ht0 : 0 < t := lt_of_lt_of_le (Real.exp_pos 1) ht apply (scaled_modelVolume_gaussian_prefix_bound ht0 hK).trans apply mul_le_mul_of_nonneg_right _ (mul_nonneg (pow_nonneg ht0.le _) (modelVolume_pos _).le) apply mul_le_mul_of_nonneg_right _ (pow_nonneg rho_pos.le _) exact pow_le_pow_left₀ (div_nonneg (Nat.cast_nonneg _) (mul_pos ht0 (pow_pos rho_pos _)).le) (core_prefix_rate_bound M ht hadd) _ /- Original line 38834: Erdos416Proof.FordGeometry.log_rho_le_neg_quarter -/ theorem log_rho_le_neg_quarter : Real.log rho ≤ -(1/4 : ℝ) := by linarith [Real.log_le_sub_one_of_pos rho_pos, rho_lt_three_quarters] /-- A convenient explicit Gaussian majorant for the triangular rho power. -/ /- Original line 38838: Erdos416Proof.FordGeometry.rho_choose_two_bound -/ theorem rho_choose_two_bound (d : ℕ) : rho^(d.choose 2) ≤ Real.exp (-((d : ℝ)*((d : ℝ)-1)/8)) := by have he : ((d.choose 2 : ℕ) : ℝ) = (d : ℝ)*((d : ℝ)-1)/2 := by rw [Nat.cast_choose_two] have h := mul_le_mul_of_nonneg_left log_rho_le_neg_quarter (Nat.cast_nonneg (d.choose 2) : (0 : ℝ) ≤ d.choose 2) calc _ = Real.exp (((d.choose 2 : ℕ) : ℝ)*Real.log rho) := by rw [Real.exp_nat_mul, Real.exp_log rho_pos] _ ≤ Real.exp (((d.choose 2 : ℕ) : ℝ)*(-(1/4 : ℝ))) := Real.exp_le_exp.mpr h _ = _ := by rw [he]; congr 1; ring end Erdos416Proof.FordGeometry namespace Erdos416Proof.FordGeometry open FordAnalysis FordScale /- Original line 38856: Erdos416Proof.FordGeometry.summable_exp_neg_quadratic -/ theorem summable_exp_neg_quadratic (B : ℝ) : Summable (fun d : ℕ => Real.exp (-((d : ℝ)^2/10)+B*(d : ℝ))) := by have hgeo := (hasSum_geometric_of_lt_one (Real.exp_pos (-1)).le (Real.exp_lt_one_iff.mpr (by norm_num : (-1 : ℝ) < 0))).summable apply Summable.of_norm_bounded_eventually_nat hgeo filter_upwards [tendsto_natCast_atTop_atTop.eventually_ge_atTop (10*(B+1))] with d hd simp only [Real.norm_eq_abs, abs_of_nonneg (Real.exp_pos _).le] rw [← Real.exp_nat_mul] apply Real.exp_le_exp.mpr have h := mul_le_mul_of_nonneg_right hd (Nat.cast_nonneg d : (0 : ℝ) ≤ d) nlinarith /-- This majorant includes the quadratic residual-factor loss in the first-failed-row argument. It is summable for every fixed linear loss. -/ /- Original line 38870: Erdos416Proof.FordGeometry.weightedPrefixFactor -/ noncomputable def weightedPrefixFactor (M : ℕ) (B : ℝ) (d : ℕ) : ℝ := (4*rho^M)^d*rho^(d.choose 2)* Real.exp ((((M : ℝ)+(d : ℝ))^2/40)+B*((M : ℝ)+(d : ℝ))) /- Original line 38874: Erdos416Proof.FordGeometry.weightedPrefixFactor_nonneg -/ theorem weightedPrefixFactor_nonneg (M : ℕ) (B : ℝ) (d : ℕ) : 0 ≤ weightedPrefixFactor M B d := by unfold weightedPrefixFactor have hρ := rho_pos positivity /- Original line 38880: Erdos416Proof.FordGeometry.weightedPrefixFactor_gaussian_bound -/ theorem weightedPrefixFactor_gaussian_bound (M : ℕ) (B : ℝ) (d : ℕ) : weightedPrefixFactor M B d ≤ Real.exp ((M : ℝ)^2/40+B*(M : ℝ))* Real.exp (-((d : ℝ)^2/10)+(Real.log 4+1/8+(M : ℝ)/20+B)*(d : ℝ)) := by have hρ := rho_pos have hr : 4*rho^M ≤ (4 : ℝ) := by have h : rho^M ≤ 1 := pow_le_one₀ rho_pos.le rho_lt_one.le linarith have hpow := pow_le_pow_left₀ (by positivity : (0 : ℝ) ≤ 4*rho^M) hr d have hfour : (4 : ℝ)^d = Real.exp ((d : ℝ)*Real.log 4) := by rw [Real.exp_nat_mul, Real.exp_log (by norm_num : (0 : ℝ) < 4)] unfold weightedPrefixFactor calc _ ≤ (4 : ℝ)^d*Real.exp (-((d : ℝ)*((d : ℝ)-1)/8))* Real.exp ((((M : ℝ)+(d : ℝ))^2/40)+B*((M : ℝ)+(d : ℝ))) := mul_le_mul_of_nonneg_right (mul_le_mul hpow (rho_choose_two_bound d) (pow_nonneg rho_pos.le _) (by positivity)) (Real.exp_pos _).le _ = _ := by rw [hfour, ← Real.exp_add, ← Real.exp_add, ← Real.exp_add] congr 1 ring /- Original line 38903: Erdos416Proof.FordGeometry.weightedPrefixFactor_summable -/ theorem weightedPrefixFactor_summable (M : ℕ) (B : ℝ) : Summable (weightedPrefixFactor M B) := by apply Summable.of_norm_bounded ((summable_exp_neg_quadratic (Real.log 4+1/8+(M : ℝ)/20+B)).mul_left (Real.exp ((M : ℝ)^2/40+B*(M : ℝ)))) intro d rw [Real.norm_eq_abs, abs_of_nonneg (weightedPrefixFactor_nonneg M B d)] exact weightedPrefixFactor_gaussian_bound M B d /- Original line 38912: Erdos416Proof.FordGeometry.weighted_prefix_tail_tendsto -/ theorem weighted_prefix_tail_tendsto (M : ℕ) (B : ℝ) : Tendsto (fun N : ℕ => ∑' d : ℕ, weightedPrefixFactor M B (d+N)) atTop (nhds 0) := tendsto_sum_nat_add (weightedPrefixFactor M B) end Erdos416Proof.FordGeometry /- Explicit envelope growth, restricted reciprocal sums, and Gaussian absorption at the first-failed-row cutoff. The arithmetic exceptional counts are separate. -/ open Filter Finset open scoped Classical Topology BigOperators namespace Erdos416Proof.FordRestricted /-- The Euler-factor error is summable even when the prime weight grows as a small power of the prime. -/ /- Original line 38933: Erdos416Proof.FordRestricted.weightedTotientEulerFactor_small_power_bound -/ theorem weightedTotientEulerFactor_small_power_bound {p : ℕ} (hp : p.Prime) {z : ℝ} (hz : 0 ≤ z) (hzsq : z^2 ≤ Real.sqrt (p : ℝ)) : weightedTotientEulerFactor p z ≤ Real.exp (z/(p : ℝ)+10*(p : ℝ)^(-3/2 : ℝ)) := by have hp2 : (2 : ℝ) ≤ p := by exact_mod_cast hp.two_le have hp0 : (0 : ℝ) < p := by linarith have hp1 : (1 : ℝ) < p := by linarith have hs0 := Real.sqrt_nonneg (p : ℝ) have hsq := Real.sq_sqrt hp0.le have hsle : Real.sqrt (p : ℝ) ≤ (p : ℝ) := by apply Real.sqrt_le_iff.mpr exact ⟨hp0.le, by nlinarith [mul_le_mul_of_nonneg_right hp1.le hp0.le]⟩ have hzroot : z ≤ Real.sqrt (p : ℝ) := by nlinarith have hsratio : Real.sqrt (p : ℝ) ≤ (7/8 : ℝ)*(p : ℝ) := by apply Real.sqrt_le_iff.mpr refine ⟨by positivity, ?_⟩ nlinarith [mul_le_mul_of_nonneg_right hp2 hp0.le] have ht0 : 0 ≤ z/(p : ℝ) := div_nonneg hz hp0.le have ht : z/(p : ℝ) ≤ 7/8 := (div_le_iff₀ hp0).mpr (hzroot.trans hsratio) have hpratio : (p : ℝ)/((p : ℝ)-1) ≤ 2 := (div_le_iff₀ (by linarith)).mpr (by linarith) have hu : z/((p : ℝ)*((p : ℝ)-1)) ≤ 2*Real.sqrt (p : ℝ)/(p : ℝ)^2 := by calc _ = (z*((p : ℝ)/((p : ℝ)-1)))/(p : ℝ)^2 := by field_simp _ ≤ (Real.sqrt (p : ℝ)*2)/(p : ℝ)^2 := div_le_div_of_nonneg_right (mul_le_mul hzroot hpratio (div_nonneg hp0.le (by linarith)) hs0) (sq_nonneg _) _ = _ := by ring have htsq : (z/(p : ℝ))^2 ≤ Real.sqrt (p : ℝ)/(p : ℝ)^2 := by rw [div_pow] exact div_le_div_of_nonneg_right hzsq (sq_nonneg _) have hnum : 1+z/((p : ℝ)*((p : ℝ)-1)) ≤ Real.exp (z/((p : ℝ)*((p : ℝ)-1))) := by simpa only [add_comm] using Real.add_one_le_exp (z/((p : ℝ)*((p : ℝ)-1))) have hden : 0 ≤ (1-z/(p : ℝ))⁻¹ := by apply inv_nonneg.mpr; linarith have hpower : Real.sqrt (p : ℝ)/(p : ℝ)^2 = (p : ℝ)^(-3/2 : ℝ) := by rw [Real.sqrt_eq_rpow, ← Real.rpow_two, ← Real.rpow_sub hp0] norm_num calc _ = (1+z/((p : ℝ)*((p : ℝ)-1)))*(1-z/(p : ℝ))⁻¹ := rfl _ ≤ Real.exp (z/((p : ℝ)*((p : ℝ)-1)))*Real.exp (z/(p : ℝ)+8*(z/(p : ℝ))^2) := mul_le_mul hnum (inv_one_sub_le_exp_quadratic ht0 ht) hden (Real.exp_pos _).le _ = Real.exp (z/((p : ℝ)*((p : ℝ)-1))+(z/(p : ℝ)+8*(z/(p : ℝ))^2)) := (Real.exp_add _ _).symm _ ≤ Real.exp (z/(p : ℝ)+10*(Real.sqrt (p : ℝ)/(p : ℝ)^2)) := by apply Real.exp_le_exp.mpr ring_nf at hu htsq ⊢ linarith _ = _ := by rw [hpower] /- Original line 38984: Erdos416Proof.FordRestricted.natRpowHom -/ noncomputable def natRpowHom (δ : ℝ) : ℕ →* ℝ where toFun n := (n : ℝ)^δ map_one' := by simp map_mul' m n := by simp only [Nat.cast_mul, Real.mul_rpow (Nat.cast_nonneg m) (Nat.cast_nonneg n)] /- Original line 38990: Erdos416Proof.FordRestricted.primeWeightHom_rpow -/ theorem primeWeightHom_rpow {n : ℕ} (hn : n ≠ 0) (δ : ℝ) : primeWeightHom (fun p : ℕ => (p : ℝ)^δ) n = (n : ℝ)^δ := by rw [primeWeightHom_apply hn] change (n.primeFactorsList.map (natRpowHom δ)).prod = natRpowHom δ n rw [← map_list_prod, Nat.prod_primeFactorsList hn] /- Original line 38996: Erdos416Proof.FordRestricted.weightedInvTotient_rpow -/ theorem weightedInvTotient_rpow {n : ℕ} (hn : n ≠ 0) (δ : ℝ) : weightedInvTotient (fun p : ℕ => (p : ℝ)^δ) n = (n : ℝ)^δ*invTotient n := by rw [weightedInvTotient, primeWeightHom_rpow hn] end Erdos416Proof.FordRestricted namespace Erdos416Proof.FordRestricted /- Original line 39006: Erdos416Proof.FordRestricted.smallPowerError -/ noncomputable def smallPowerError : ℝ := ∑' n : ℕ, (n : ℝ)^(-3/2 : ℝ) /- Original line 39008: Erdos416Proof.FordRestricted.smallPowerError_summable -/ theorem smallPowerError_summable : Summable (fun n : ℕ => (n : ℝ)^(-3/2 : ℝ)) := Real.summable_nat_rpow.mpr (by norm_num) /- Original line 39011: Erdos416Proof.FordRestricted.prime_small_power_data -/ theorem prime_small_power_data {p : ℕ} (hp : p.Prime) {δ : ℝ} (hδ : δ ≤ 1/4) : 0 ≤ (p : ℝ)^δ ∧ (p : ℝ)^δ < p ∧ ((p : ℝ)^δ)^2 ≤ Real.sqrt (p : ℝ) := by have hp1 : (1 : ℝ) < p := by exact_mod_cast hp.one_lt have hp0 : (0 : ℝ) < p := by linarith refine ⟨(Real.rpow_pos_of_pos hp0 δ).le, ?_, ?_⟩ · simpa only [Real.rpow_one] using Real.rpow_lt_rpow_of_exponent_lt hp1 (by linarith : δ < 1) · rw [← Real.rpow_two, ← Real.rpow_mul hp0.le, Real.sqrt_eq_rpow] exact Real.rpow_le_rpow_of_exponent_le hp1.le (by linarith) /- Original line 39021: Erdos416Proof.FordRestricted.small_power_euler_product_bound -/ theorem small_power_euler_product_bound (s : Finset ℕ) (hs : ∀ p ∈ s, p.Prime) {δ : ℝ} (hδ : δ ≤ 1/4) : (∏ p ∈ s, weightedTotientEulerFactor p ((p : ℝ)^δ)) ≤ Real.exp ((∑ p ∈ s, (p : ℝ)^δ/(p : ℝ))+10*smallPowerError) := by have hsum : (∑ p ∈ s, (p : ℝ)^(-3/2 : ℝ)) ≤ smallPowerError := smallPowerError_summable.sum_le_tsum s (fun p _ => Real.rpow_nonneg (Nat.cast_nonneg p) _) calc _ ≤ ∏ p ∈ s, Real.exp ((p : ℝ)^δ/(p : ℝ)+10*(p : ℝ)^(-3/2 : ℝ)) := by apply Finset.prod_le_prod · intro p hp have hd := prime_small_power_data (hs p hp) hδ exact (weightedTotientEulerFactor_pos (hs p hp) hd.1 hd.2.1).le · intro p hp have hd := prime_small_power_data (hs p hp) hδ exact weightedTotientEulerFactor_small_power_bound (hs p hp) hd.1 hd.2.2 _ = Real.exp ((∑ p ∈ s, (p : ℝ)^δ/(p : ℝ))+10*∑ p ∈ s, (p : ℝ)^(-3/2 : ℝ)) := by rw [← Real.exp_sum, sum_add_distrib, mul_sum] _ ≤ _ := Real.exp_le_exp.mpr (by linarith) /- Original line 39040: Erdos416Proof.FordRestricted.exp_sub_one_le_mul_exp_five -/ theorem exp_sub_one_le_mul_exp_five {u : ℝ} (hu : 0 ≤ u) (hu5 : u ≤ 5) : Real.exp u-1 ≤ Real.exp 5*u := by have h := mul_le_mul_of_nonneg_right (Real.add_one_le_exp (-u)) (Real.exp_pos u).le have he : Real.exp (-u)*Real.exp u = 1 := by rw [← Real.exp_add, neg_add_cancel, Real.exp_zero] rw [he] at h have h' := mul_le_mul_of_nonneg_right (Real.exp_le_exp.mpr hu5) hu nlinarith /-- A small power changes the prime reciprocal sum by an absolute constant at delta=5/log(y), preserving its leading log-log coefficient. -/ /- Original line 39050: Erdos416Proof.FordRestricted.exists_rankin_prime_sum_bound -/ theorem exists_rankin_prime_sum_bound : ∃ B : ℝ, ∀ y : ℝ, Real.exp 20 ≤ y → (∑ p ∈ Nat.primesLE ⌊y⌋₊, (p : ℝ)^(5/Real.log y)/(p : ℝ)) ≤ logLog y+B := by obtain ⟨B, hB⟩ := prime_reciprocal_mertens let c : ℝ := Real.log 4+4 refine ⟨B+Real.exp 5*(5+c), ?_⟩ intro y hy have hy2 : 2 ≤ y := by linarith [Real.add_one_le_exp (20 : ℝ)] have hy1 : 1 < y := by linarith have hy0 : 0 ≤ y := by linarith have hlog : 20 ≤ Real.log y := by simpa only [Real.log_exp] using Real.log_le_log (Real.exp_pos 20) hy let δ : ℝ := 5/Real.log y have hδ0 : 0 ≤ δ := by dsimp [Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, δ]; positivity have hδ1 : δ ≤ 1 := (div_le_one (by linarith : 0 < Real.log y)).mpr (by linarith) have hδlog : δ*Real.log y = 5 := div_mul_cancel₀ 5 (by linarith : Real.log y ≠ 0) have hc : 0 ≤ c := by dsimp [Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, c]; positivity have hpterm : ∀ p ∈ Nat.primesLE ⌊y⌋₊, (p : ℝ)^δ/(p : ℝ) ≤ (1 : ℝ)/p+(Real.exp 5*δ)*(Real.log (p : ℝ)/(p : ℝ)) := by intro p hp have hprime := Nat.prime_of_mem_primesLE hp have hp1 : (1 : ℝ) < p := by exact_mod_cast hprime.one_lt have hp0 : (0 : ℝ) < p := by linarith have hpy : (p : ℝ) ≤ y := (Nat.cast_le.mpr (Nat.mem_primesLE.mp hp).1).trans (Nat.floor_le hy0) have hlogp0 := (Real.log_pos hp1).le have hlogpy := Real.log_le_log hp0 hpy have hu0 : 0 ≤ Real.log (p : ℝ)*δ := mul_nonneg hlogp0 hδ0 have hu5 : Real.log (p : ℝ)*δ ≤ 5 := by have h := mul_le_mul_of_nonneg_right hlogpy hδ0 nlinarith have h := div_le_div_of_nonneg_right (exp_sub_one_le_mul_exp_five hu0 hu5) hp0.le rw [← Real.rpow_def_of_pos hp0] at h calc _ = (1 : ℝ)/p+((p : ℝ)^δ-1)/(p : ℝ) := by ring _ ≤ (1 : ℝ)/p+(Real.exp 5*(Real.log (p : ℝ)*δ))/(p : ℝ) := add_le_add le_rfl h _ = _ := by ring have hsum := sum_le_sum hpterm rw [sum_add_distrib, ← mul_sum] at hsum have hrec := (abs_le.mp (hB y hy2)).2 have hlogsum : (∑ p ∈ Nat.primesLE ⌊y⌋₊, Real.log (p : ℝ)/(p : ℝ)) ≤ Real.log y+c := by have h := (abs_le.mp (Mertens.sum_log_prime_div_eq_log hy1.le)).2 rw [← primesLE_eq_Ioc_filter] at h dsimp [Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, c] linarith have hm := mul_le_mul_of_nonneg_left hlogsum hδ0 have hc' := mul_le_mul_of_nonneg_right hδ1 hc have hmass : δ*(∑ p ∈ Nat.primesLE ⌊y⌋₊, Real.log (p : ℝ)/(p : ℝ)) ≤ 5+c := by nlinarith have he := mul_le_mul_of_nonneg_left hmass (Real.exp_pos 5).le change (∑ p ∈ Nat.primesLE ⌊y⌋₊, (p : ℝ)^δ/(p : ℝ)) ≤ _ unfold logLog nlinarith /- Original line 39102: Erdos416Proof.FordRestricted.exists_smooth_weighted_reciprocal_bound -/ theorem exists_smooth_weighted_reciprocal_bound : ∃ K : ℝ, 0 < K ∧ ∀ y : ℝ, Real.exp 20 ≤ y → ∀ F : Finset ℕ, (∀ n ∈ F, n ∈ Nat.factoredNumbers (Nat.primesLE ⌊y⌋₊)) → (∑ n ∈ F, (n : ℝ)^(5/Real.log y)*invTotient n) ≤ K*Real.log y := by obtain ⟨B, hB⟩ := exists_rankin_prime_sum_bound refine ⟨Real.exp (B+10*smallPowerError), Real.exp_pos _, ?_⟩ intro y hy F hF have hlog : 20 ≤ Real.log y := by simpa only [Real.log_exp] using Real.log_le_log (Real.exp_pos 20) hy have hδ : 5/Real.log y ≤ (1/4 : ℝ) := (div_le_iff₀ (by linarith : 0 < Real.log y)).mpr (by linarith) have hw : ∀ p : ℕ, p.Prime → 0 ≤ (p : ℝ)^(5/Real.log y) ∧ (p : ℝ)^(5/Real.log y) < p := by intro p hp have hd := prime_small_power_data hp hδ exact ⟨hd.1, hd.2.1⟩ have h := finite_weightedInvTotient_bound (fun p : ℕ => (p : ℝ)^(5/Real.log y)) hw (Nat.primesLE ⌊y⌋₊) F hF have hs : (Nat.primesLE ⌊y⌋₊).filter Nat.Prime = Nat.primesLE ⌊y⌋₊ := filter_eq_self.mpr (fun _ hp => Nat.prime_of_mem_primesLE hp) rw [hs] at h have hsum : (∑ n ∈ F, (n : ℝ)^(5/Real.log y)*invTotient n) = ∑ n ∈ F, weightedInvTotient (fun p : ℕ => (p : ℝ)^(5/Real.log y)) n := by apply sum_congr rfl intro n hn exact (weightedInvTotient_rpow (Nat.ne_zero_of_mem_factoredNumbers (hF n hn)) _).symm rw [hsum] calc _ ≤ _ := h _ ≤ Real.exp ((∑ p ∈ Nat.primesLE ⌊y⌋₊, (p : ℝ)^(5/Real.log y)/(p : ℝ))+10*smallPowerError) := small_power_euler_product_bound _ (fun _ hp => Nat.prime_of_mem_primesLE hp) hδ _ ≤ Real.exp (logLog y+B+10*smallPowerError) := Real.exp_le_exp.mpr (by linarith [hB y hy]) _ = _ := by rw [show logLog y+B+10*smallPowerError = (B+10*smallPowerError)+Real.log (Real.log y) by unfold logLog; ring, Real.exp_add, Real.exp_log (by linarith : 0 < Real.log y)] end Erdos416Proof.FordRestricted namespace Erdos416Proof.FordRestricted /- Original line 39143: Erdos416Proof.FordRestricted.rankin_cutoff_identity -/ theorem rankin_cutoff_identity {y : ℝ} (hy : 1 < y) : (y^(logLog y))^(5/Real.log y) = (Real.log y)^5 := by have hy0 : 0 < y := by linarith have hl := Real.log_pos hy rw [Real.rpow_def_of_pos (Real.rpow_pos_of_pos hy0 _), Real.log_rpow hy0] calc _ = Real.exp ((5 : ℝ)*Real.log (Real.log y)) := by congr 1 unfold logLog field_simp [hl.ne'] _ = _ := by rw [show (5 : ℝ)*Real.log (Real.log y) = ((5 : ℕ) : ℝ)*Real.log (Real.log y) by norm_num, Real.exp_nat_mul, Real.exp_log hl] /-- The high reciprocal tail is bounded by counting all smooth integers; no separate theorem about smooth totient values is assumed. -/ /- Original line 39159: Erdos416Proof.FordRestricted.exists_finite_smooth_reciprocal_tail_bound -/ theorem exists_finite_smooth_reciprocal_tail_bound : ∃ K : ℝ, 0 < K ∧ ∀ y : ℝ, Real.exp 20 ≤ y → ∀ F : Finset ℕ, (∀ n ∈ F, n ∈ Nat.factoredNumbers (Nat.primesLE ⌊y⌋₊)) → (∀ n ∈ F, y^(logLog y) ≤ (n : ℝ)) → (∑ n ∈ F, (1 : ℝ)/n) ≤ K/(Real.log y)^4 := by obtain ⟨K, hK, hbound⟩ := exists_smooth_weighted_reciprocal_bound refine ⟨K, hK, ?_⟩ intro y hy F hF hcut have hy1 : 1 < y := by linarith [Real.add_one_le_exp (20 : ℝ)] have hl := Real.log_pos hy1 have hδ : 0 ≤ 5/Real.log y := div_nonneg (by norm_num) hl.le have hpoint : ∀ n ∈ F, (Real.log y)^5*((1 : ℝ)/n) ≤ (n : ℝ)^(5/Real.log y)*invTotient n := by intro n hn have hn0 := Nat.ne_zero_of_mem_factoredNumbers (hF n hn) have hnpos : 0 < n := Nat.pos_of_ne_zero hn0 have hnreal : (0 : ℝ) < n := by exact_mod_cast hnpos have hφ : (0 : ℝ) < n.totient := by exact_mod_cast Nat.totient_pos.mpr hnpos have hrec : (1 : ℝ)/n ≤ invTotient n := by simpa only [one_div, invTotient] using one_div_le_one_div_of_le hφ (Nat.cast_le.mpr (Nat.totient_le n)) have hpow := Real.rpow_le_rpow (Real.rpow_pos_of_pos (by linarith : 0 < y) _).le (hcut n hn) hδ rw [rankin_cutoff_identity hy1] at hpow calc _ ≤ (n : ℝ)^(5/Real.log y)*((1 : ℝ)/n) := mul_le_mul_of_nonneg_right hpow (one_div_nonneg.mpr hnreal.le) _ ≤ _ := mul_le_mul_of_nonneg_left hrec (Real.rpow_nonneg hnreal.le _) have hsum : (Real.log y)^5*(∑ n ∈ F, (1 : ℝ)/n) ≤ K*Real.log y := by rw [mul_sum] exact (sum_le_sum hpoint).trans (hbound y hy F hF) apply (le_div_iff₀ (pow_pos hl 4)).mpr apply (mul_le_mul_iff_of_pos_left hl).mp calc _ = (Real.log y)^5*(∑ n ∈ F, (1 : ℝ)/n) := by ring _ ≤ K*Real.log y := hsum _ = _ := by ring /-- Ford's restricted reciprocal estimate, retaining the actual counting envelope rather than assuming its eventual sharp asymptotic bound. -/ /- Original line 39199: Erdos416Proof.FordRestricted.exists_restricted_totient_reciprocal_bound -/ theorem exists_restricted_totient_reciprocal_bound : ∃ C : ℝ, 0 < C ∧ ∀ᶠ y : ℝ in atTop, ∀ F : Finset ℕ, (∀ n ∈ F, n ∈ Nat.factoredNumbers (Nat.primesLE ⌊y⌋₊)) → (∀ n ∈ F, ∃ m : ℕ, 0 < m ∧ m.totient = n) → (∑ n ∈ F, (1 : ℝ)/n) ≤ C*totientUpperEnvelope (y^(logLog y))*(1+logLog (y^(logLog y))) := by obtain ⟨K, hK, htail⟩ := exists_finite_smooth_reciprocal_tail_bound obtain ⟨D, hD, hsmall⟩ := exists_totient_reciprocal_envelope_bound refine ⟨D+K, add_pos hD hK, ?_⟩ have hLL : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [eventually_ge_atTop (Real.exp 20), hLL.eventually_ge_atTop 1] with y hy hu intro F hF hφ have hy1 : 1 < y := by linarith [Real.add_one_le_exp (20 : ℝ)] have hlog : 20 ≤ Real.log y := by simpa only [Real.log_exp] using Real.log_le_log (Real.exp_pos 20) hy let Z := y^(logLog y) have hyZ : y ≤ Z := by simpa only [Real.rpow_one] using Real.rpow_le_rpow_of_exponent_le hy1.le hu have hZ : Real.exp 1 ≤ Z := (Real.exp_le_exp.mpr (by norm_num : (1 : ℝ) ≤ 20)).trans (hy.trans hyZ) have hZ0 : 0 ≤ Z := (Real.exp_pos 1).le.trans hZ have hW := totientUpperEnvelope_ge_one Z have hU := logLog_nonneg hZ let Fsmall : Finset ℕ := F.filter (fun n : ℕ => (n : ℝ) ≤ Z) let Fbig : Finset ℕ := F.filter (fun n : ℕ => ¬ (n : ℝ) ≤ Z) have hsub : Fsmall ⊆ totientsUpTo Z := by intro n hn obtain ⟨hnF, hnZ⟩ := mem_filter.mp hn exact (mem_totientsUpTo hZ0).mpr ⟨Nat.pos_of_ne_zero (Nat.ne_zero_of_mem_factoredNumbers (hF n hnF)), hnZ, hφ n hnF⟩ have hsmallF : (∑ n ∈ Fsmall, (1 : ℝ)/n) ≤ D*totientUpperEnvelope Z*(1+logLog Z) := by apply (sum_le_sum_of_subset_of_nonneg hsub (fun n _ _ => one_div_nonneg.mpr (Nat.cast_nonneg n))).trans exact hsmall Z (totientUpperEnvelope Z) hZ hW (totientUpperEnvelope_spec Z) have hbig := htail y hy Fbig (fun n hn => hF n (mem_filter.mp hn).1) (fun n hn => le_of_lt (lt_of_not_ge (mem_filter.mp hn).2)) have hden : (1 : ℝ) ≤ (Real.log y)^4 := one_le_pow₀ (by linarith : (1 : ℝ) ≤ Real.log y) have hbig' : (∑ n ∈ Fbig, (1 : ℝ)/n) ≤ K := hbig.trans ((div_le_iff₀ (by positivity : 0 < (Real.log y)^4)).mpr (by nlinarith)) have hWU : 1 ≤ totientUpperEnvelope Z*(1+logLog Z) := by nlinarith [mul_nonneg (by linarith : 0 ≤ totientUpperEnvelope Z-1) hU] have hsplit : (∑ n ∈ F, (1 : ℝ)/n) = (∑ n ∈ Fsmall, (1 : ℝ)/n)+(∑ n ∈ Fbig, (1 : ℝ)/n) := (sum_filter_add_sum_filter_not F (fun n => (n : ℝ) ≤ Z) (fun n => (1 : ℝ)/n)).symm rw [hsplit] have hKbound := mul_le_mul_of_nonneg_left hWU hK.le dsimp [Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, Z] at hsmallF hWU hKbound nlinarith end Erdos416Proof.FordRestricted open Filter Finset open scoped Classical Topology BigOperators namespace Erdos416Proof /-- The recurrence constant contributes only a linear logarithmic term. The quadratic coefficient can therefore be chosen explicitly. -/ /- Original line 39264: Erdos416Proof.explicit_log_square_bound_of_geometric_recurrence -/ theorem explicit_log_square_bound_of_geometric_recurrence (F : ℝ → ℝ) (hF : ∀ T : ℝ, 1 ≤ F T) (hmono : ∀ a b : ℝ, 1 ≤ a → a ≤ b → F a ≤ F b) {C : ℝ} (hC : 0 < C) (hstep : ∀ᶠ T : ℝ in atTop, F T ≤ C*T^2*F ((9/10 : ℝ)*T)) : ∀ᶠ T : ℝ in atTop, F T ≤ Real.exp (12*Real.log T^2) := by obtain ⟨T₁, hT₁⟩ := eventually_atTop.mp hstep let T₀ := max 1 T₁ let q : ℝ := 10/9 let A := |Real.log C|+2*|Real.log T₀| let D := |Real.log (F T₀)| have hT₀1 : 1 ≤ T₀ := le_max_left _ _ have hT₀ : 0 < T₀ := by linarith have hq1 : 1 ≤ q := by norm_num [q] have hq0 : 0 < q := by norm_num [q] have hlogq : 0 < Real.log q := Real.log_pos (by norm_num [q]) have hlogq_lower : (1/10 : ℝ) ≤ Real.log q := by have h := Real.log_le_sub_one_of_pos (by norm_num : (0 : ℝ) < 9/10) rw [Real.log_div (by norm_num) (by norm_num)] at h dsimp [q] rw [Real.log_div (by norm_num) (by norm_num)] norm_num at h linarith have hA0 : 0 ≤ A := by dsimp [A]; positivity have hD0 : 0 ≤ D := abs_nonneg _ have hAcost : Real.log C+2*Real.log T₀ ≤ A := by dsimp [A] linarith [le_abs_self (Real.log C), le_abs_self (Real.log T₀)] have hDcost : Real.log (F T₀) ≤ D := le_abs_self _ have hgrid_ge (n : ℕ) : T₀ ≤ T₀*q^n := le_mul_of_one_le_right hT₀.le (one_le_pow₀ hq1) have hgridlog (n : ℕ) : Real.log (T₀*q^n) = Real.log T₀+(n : ℝ)*Real.log q := by rw [Real.log_mul hT₀.ne' (pow_ne_zero _ hq0.ne'), Real.log_pow] have hgrid : ∀ n : ℕ, F (T₀*q^n) ≤ Real.exp (D+A*(n : ℝ)+Real.log q*(n : ℝ)*((n : ℝ)+1)) := by intro n induction n with | zero => have hFpos : 0 < F T₀ := by linarith [hF T₀] simpa only [pow_zero, mul_one, Nat.cast_zero, mul_zero, zero_mul, add_zero] using (Real.log_le_iff_le_exp hFpos).mp hDcost | succ n ih => have hstepn := hT₁ (T₀*q^(n+1)) ((le_max_right _ _).trans (hgrid_ge _)) have hshrink : (9/10 : ℝ)*(T₀*q^(n+1)) = T₀*q^n := by rw [pow_succ] dsimp [q] ring rw [hshrink] at hstepn have hRpos : 0 < T₀*q^(n+1) := mul_pos hT₀ (pow_pos hq0 _) calc _ ≤ C*(T₀*q^(n+1))^2*F (T₀*q^n) := hstepn _ ≤ C*(T₀*q^(n+1))^2* Real.exp (D+A*(n : ℝ)+Real.log q*(n : ℝ)*((n : ℝ)+1)) := mul_le_mul_of_nonneg_left ih (by positivity) _ ≤ _ := by apply (Real.log_le_log_iff (by positivity) (Real.exp_pos _)).mp rw [Real.log_mul (by positivity) (Real.exp_ne_zero _), Real.log_mul hC.ne' (by positivity), Real.log_pow, hgridlog, Real.log_exp, Real.log_exp] push_cast nlinarith let H := 10*A+20*Real.log q+1 let J := A+2*Real.log q+D filter_upwards [eventually_ge_atTop (Real.exp 1), Real.tendsto_log_atTop.eventually_ge_atTop H, Real.tendsto_log_atTop.eventually_ge_atTop J] with T hTe hH hJ have hTpos : 0 < T := (Real.exp_pos 1).trans_le hTe have hT1 : 1 ≤ T := by linarith [Real.add_one_le_exp (1 : ℝ)] have hlogT : 1 ≤ Real.log T := by simpa only [Real.log_exp] using Real.log_le_log (Real.exp_pos 1) hTe have hu0 : 0 ≤ Real.log T := by linarith let n : ℕ := ⌈Real.log T/Real.log q⌉₊ have hTq : T ≤ q^n := by apply (Real.log_le_log_iff hTpos (pow_pos hq0 _)).mp rw [Real.log_pow] exact (div_le_iff₀ hlogq).mp (Nat.le_ceil (Real.log T/Real.log q)) have hTgrid : T ≤ T₀*q^n := hTq.trans (le_mul_of_one_le_left (pow_nonneg hq0.le _) hT₀1) have hn : (n : ℝ) ≤ Real.log T/Real.log q+1 := (Nat.ceil_lt_add_one (div_nonneg hu0 hlogq.le)).le have hn0 : (0 : ℝ) ≤ n := Nat.cast_nonneg n have hqinv : 1/Real.log q ≤ (10 : ℝ) := (div_le_iff₀ hlogq).mpr (by linarith) have hnupper : (n : ℝ) ≤ 10*Real.log T+1 := by calc _ ≤ Real.log T/Real.log q+1 := hn _ = Real.log T*(1/Real.log q)+1 := by ring _ ≤ Real.log T*10+1 := add_le_add (mul_le_mul_of_nonneg_left hqinv hu0) le_rfl _ = _ := by ring have hnlog : (n : ℝ)*Real.log q ≤ Real.log T+Real.log q := by calc _ ≤ (Real.log T/Real.log q+1)*Real.log q := mul_le_mul_of_nonneg_right hn hlogq.le _ = _ := by field_simp [hlogq.ne'] have hpoly : D+A*(n : ℝ)+Real.log q*(n : ℝ)*((n : ℝ)+1) ≤ D+(10*Real.log T+1)*(Real.log T+A+2*Real.log q) := by calc _ = D+(n : ℝ)*(A+(n : ℝ)*Real.log q+Real.log q) := by ring _ ≤ D+(n : ℝ)*(Real.log T+A+2*Real.log q) := add_le_add le_rfl (mul_le_mul_of_nonneg_left (show A+(n : ℝ)*Real.log q+Real.log q ≤ Real.log T+A+2*Real.log q by linarith) hn0) _ ≤ _ := add_le_add le_rfl (mul_le_mul_of_nonneg_right hnupper (by positivity : 0 ≤ Real.log T+A+2*Real.log q)) have hfinal : D+(10*Real.log T+1)*(Real.log T+A+2*Real.log q) ≤ 12*Real.log T^2 := by have hHmul := mul_le_mul_of_nonneg_right hH hu0 have humul := mul_le_mul_of_nonneg_right hlogT hu0 dsimp [H, J] at hHmul hJ nlinarith exact (hmono T _ hT1 hTgrid).trans ((hgrid n).trans (Real.exp_le_exp.mpr (hpoly.trans hfinal))) /-- An explicit coefficient, sufficient for the structural summations. It is not Ford's sharp asymptotic leading constant. -/ /- Original line 39375: Erdos416Proof.totientUpperEnvelope_explicit_growth -/ theorem totientUpperEnvelope_explicit_growth : ∀ᶠ x : ℝ in atTop, totientUpperEnvelope x ≤ Real.exp (12*Real.log (logLog x)^2) := by obtain ⟨C, hC, hrec⟩ := exists_totientUpperEnvelope_recurrence let F : ℝ → ℝ := fun T => totientUpperEnvelope (Real.exp (Real.exp T)) have hF : ∀ T : ℝ, 1 ≤ F T := fun T => totientUpperEnvelope_ge_one _ have hmono : ∀ a b : ℝ, 1 ≤ a → a ≤ b → F a ≤ F b := by intro a b ha hab have he : Real.exp 1 ≤ Real.exp (Real.exp a) := Real.exp_le_exp.mpr (Real.one_le_exp_iff.mpr (by linarith)) exact totientUpperEnvelope_mono (Real.exp_one_gt_two.le.trans he) (Real.exp_le_exp.mpr (Real.exp_le_exp.mpr hab)) have hX : Tendsto (fun T : ℝ => Real.exp (Real.exp T)) atTop atTop := Real.tendsto_exp_atTop.comp Real.tendsto_exp_atTop have hstep : ∀ᶠ T : ℝ in atTop, F T ≤ C*T^2*F ((9/10 : ℝ)*T) := by filter_upwards [hX.eventually hrec] with T hrec simpa only [F, logLog, Real.log_exp, growthTailEndpoint] using hrec have hbound := explicit_log_square_bound_of_geometric_recurrence F hF hmono hC hstep have hT : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [hT.eventually hbound, eventually_gt_atTop (1 : ℝ)] with x hbound hx have heq : Real.exp (Real.exp (logLog x)) = x := by rw [logLog, Real.exp_log (Real.log_pos hx), Real.exp_log (by linarith)] simpa only [F, heq] using hbound end Erdos416Proof namespace Erdos416Proof.FordRestricted /- Original line 39404: Erdos416Proof.FordRestricted.logLog_reciprocal_split -/ theorem logLog_reciprocal_split {y : ℝ} (hy : 1 < y) (hu : 0 < logLog y) : logLog (y^(logLog y)) = logLog y+Real.log (logLog y) := by change Real.log (Real.log (y^(logLog y))) = _ rw [Real.log_rpow (by linarith : 0 < y), Real.log_mul hu.ne' (Real.log_pos hy).ne'] unfold logLog ring /- Original line 39411: Erdos416Proof.FordRestricted.reciprocal_split_tendsto -/ theorem reciprocal_split_tendsto : Tendsto (fun y : ℝ => y^(logLog y)) atTop atTop := by have hLL : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop have hbound : ∀ᶠ y : ℝ in atTop, y ≤ y^(logLog y) := by filter_upwards [eventually_ge_atTop (1 : ℝ), hLL.eventually_ge_atTop 1] with y hy hu simpa only [Real.rpow_one] using Real.rpow_le_rpow_of_exponent_le hy hu exact tendsto_atTop_mono' atTop hbound tendsto_id /- Original line 39419: Erdos416Proof.FordRestricted.linear_factor_log_square_bound -/ theorem linear_factor_log_square_bound {C : ℝ} (hC : 0 < C) : ∀ᶠ u : ℝ in atTop, C*(1+2*u) ≤ Real.exp (Real.log u^2) := by filter_upwards [eventually_ge_atTop (1 : ℝ), Real.tendsto_log_atTop.eventually_ge_atTop 2, Real.tendsto_log_atTop.eventually_ge_atTop (Real.log C+Real.log 3)] with u hu hv hC3 have hu0 : 0 < u := by linarith calc _ ≤ C*(3*u) := mul_le_mul_of_nonneg_left (by linarith) hC.le _ = Real.exp (Real.log C+Real.log 3+Real.log u) := by rw [Real.exp_add, Real.exp_add, Real.exp_log hC, Real.exp_log (by norm_num : (0 : ℝ) < 3), Real.exp_log hu0] ring _ ≤ _ := Real.exp_le_exp.mpr (by nlinarith) /-- An explicit coarse coefficient compatible with the Gaussian structural sums. All finite families and their representations are actual. -/ /- Original line 39435: Erdos416Proof.FordRestricted.restricted_totient_reciprocal_explicit_bound -/ theorem restricted_totient_reciprocal_explicit_bound : ∀ᶠ y : ℝ in atTop, ∀ F : Finset ℕ, (∀ n ∈ F, n ∈ Nat.factoredNumbers (Nat.primesLE ⌊y⌋₊)) → (∀ n ∈ F, ∃ m : ℕ, 0 < m ∧ m.totient = n) → (∑ n ∈ F, (1 : ℝ)/n) ≤ Real.exp (16*Real.log (logLog y)^2) := by obtain ⟨C, hC, hrec⟩ := exists_restricted_totient_reciprocal_bound have hLL : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop have hU : Tendsto (fun y : ℝ => Real.log (logLog y)) atTop atTop := Real.tendsto_log_atTop.comp hLL filter_upwards [hrec, reciprocal_split_tendsto.eventually totientUpperEnvelope_explicit_growth, hLL.eventually (linear_factor_log_square_bound hC), hLL.eventually_ge_atTop 2, hU.eventually_ge_atTop (10*Real.log 2), eventually_gt_atTop (1 : ℝ)] with y hrec henv hfactor hu hv hy intro F hF hφ have hu0 : 0 < logLog y := by linarith have hlogu0 : 0 ≤ Real.log (logLog y) := Real.log_nonneg (by linarith) have hsplit := logLog_reciprocal_split hy hu0 have hLLZlo : 1 ≤ logLog (y^(logLog y)) := by rw [hsplit]; linarith have hLLZhi : logLog (y^(logLog y)) ≤ 2*logLog y := by rw [hsplit] linarith [Real.log_le_sub_one_of_pos hu0] have hlogZ0 : 0 ≤ Real.log (logLog (y^(logLog y))) := Real.log_nonneg hLLZlo have hlogZ : Real.log (logLog (y^(logLog y))) ≤ (11/10 : ℝ)*Real.log (logLog y) := by have h := Real.log_le_log (by linarith : 0 < logLog (y^(logLog y))) hLLZhi rw [Real.log_mul (by norm_num : (2 : ℝ) ≠ 0) hu0.ne'] at h nlinarith have hsquare : 12*Real.log (logLog (y^(logLog y)))^2 ≤ 15*Real.log (logLog y)^2 := by have h := pow_le_pow_left₀ hlogZ0 hlogZ 2 nlinarith [sq_nonneg (Real.log (logLog y))] have henv' : totientUpperEnvelope (y^(logLog y)) ≤ Real.exp (15*Real.log (logLog y)^2) := henv.trans (Real.exp_le_exp.mpr hsquare) have hfactor' : C*(1+logLog (y^(logLog y))) ≤ Real.exp (Real.log (logLog y)^2) := (mul_le_mul_of_nonneg_left (by linarith : 1+logLog (y^(logLog y)) ≤ 1+2*logLog y) hC.le).trans hfactor calc _ ≤ C*totientUpperEnvelope (y^(logLog y))*(1+logLog (y^(logLog y))) := hrec F hF hφ _ = totientUpperEnvelope (y^(logLog y))*(C*(1+logLog (y^(logLog y)))) := by ring _ ≤ Real.exp (15*Real.log (logLog y)^2)*(C*(1+logLog (y^(logLog y)))) := mul_le_mul_of_nonneg_right henv' (mul_nonneg hC.le (by linarith)) _ ≤ Real.exp (15*Real.log (logLog y)^2)*Real.exp (Real.log (logLog y)^2) := mul_le_mul_of_nonneg_left hfactor' (Real.exp_pos _).le _ = _ := by rw [← Real.exp_add]; congr 1; ring end Erdos416Proof.FordRestricted open Filter Finset open scoped Classical Topology BigOperators namespace Erdos416Proof.FordGeometry open FordAnalysis FordScale /- Original line 39490: Erdos416Proof.FordGeometry.summable_exp_neg_positive_quadratic -/ theorem summable_exp_neg_positive_quadratic {a : ℝ} (ha : 0 < a) (B : ℝ) : Summable (fun d : ℕ => Real.exp (-a*(d : ℝ)^2+B*(d : ℝ))) := by have hgeo := (hasSum_geometric_of_lt_one (Real.exp_pos (-1)).le (Real.exp_lt_one_iff.mpr (by norm_num : (-1 : ℝ) < 0))).summable apply Summable.of_norm_bounded_eventually_nat hgeo filter_upwards [tendsto_natCast_atTop_atTop.eventually_ge_atTop ((B+1)/a)] with d hd simp only [Real.norm_eq_abs, abs_of_nonneg (Real.exp_pos _).le] rw [← Real.exp_nat_mul] apply Real.exp_le_exp.mpr have h := mul_le_mul_of_nonneg_right ((div_le_iff₀ ha).mp hd) (Nat.cast_nonneg d : (0 : ℝ) ≤ d) nlinarith /- Original line 39503: Erdos416Proof.FordGeometry.quadraticPrefixFactor -/ noncomputable def quadraticPrefixFactor (a : ℝ) (M : ℕ) (B : ℝ) (d : ℕ) : ℝ := (4*rho^M)^d*rho^(d.choose 2)*Real.exp (a*((M : ℝ)+(d : ℝ))^2+B*((M : ℝ)+(d : ℝ))) /- Original line 39506: Erdos416Proof.FordGeometry.quadraticPrefixFactor_nonneg -/ theorem quadraticPrefixFactor_nonneg (a : ℝ) (M : ℕ) (B : ℝ) (d : ℕ) : 0 ≤ quadraticPrefixFactor a M B d := by unfold quadraticPrefixFactor have hρ := rho_pos positivity /- Original line 39512: Erdos416Proof.FordGeometry.quadraticPrefixFactor_gaussian_bound -/ theorem quadraticPrefixFactor_gaussian_bound (a : ℝ) (M : ℕ) (B : ℝ) (d : ℕ) : quadraticPrefixFactor a M B d ≤ Real.exp (a*(M : ℝ)^2+B*(M : ℝ))* Real.exp (-(1/8-a)*(d : ℝ)^2+(Real.log 4+1/8+2*a*(M : ℝ)+B)*(d : ℝ)) := by have hρ := rho_pos have hr : 4*rho^M ≤ (4 : ℝ) := by have h : rho^M ≤ 1 := pow_le_one₀ rho_pos.le rho_lt_one.le linarith have hpow := pow_le_pow_left₀ (by positivity : (0 : ℝ) ≤ 4*rho^M) hr d have hfour : (4 : ℝ)^d = Real.exp ((d : ℝ)*Real.log 4) := by rw [Real.exp_nat_mul, Real.exp_log (by norm_num : (0 : ℝ) < 4)] unfold quadraticPrefixFactor calc _ ≤ (4 : ℝ)^d*Real.exp (-((d : ℝ)*((d : ℝ)-1)/8))* Real.exp (a*((M : ℝ)+(d : ℝ))^2+B*((M : ℝ)+(d : ℝ))) := mul_le_mul_of_nonneg_right (mul_le_mul hpow (rho_choose_two_bound d) (pow_nonneg rho_pos.le _) (by positivity)) (Real.exp_pos _).le _ = _ := by rw [hfour, ← Real.exp_add, ← Real.exp_add, ← Real.exp_add] congr 1 ring /-- Any residual quadratic coefficient below 1/8 is absorbed by the proved prefix geometry; no particular numerical coefficient is assumed. -/ /- Original line 39537: Erdos416Proof.FordGeometry.quadraticPrefixFactor_summable -/ theorem quadraticPrefixFactor_summable {a : ℝ} (ha : a < 1/8) (M : ℕ) (B : ℝ) : Summable (quadraticPrefixFactor a M B) := by apply Summable.of_norm_bounded ((summable_exp_neg_positive_quadratic (by linarith : 0 < 1/8-a) (Real.log 4+1/8+2*a*(M : ℝ)+B)).mul_left (Real.exp (a*(M : ℝ)^2+B*(M : ℝ)))) intro d rw [Real.norm_eq_abs, abs_of_nonneg (quadraticPrefixFactor_nonneg a M B d)] exact quadraticPrefixFactor_gaussian_bound a M B d /- Original line 39547: Erdos416Proof.FordGeometry.quadratic_prefix_tail_tendsto -/ theorem quadratic_prefix_tail_tendsto (a : ℝ) (M : ℕ) (B : ℝ) : Tendsto (fun N : ℕ => ∑' d : ℕ, quadraticPrefixFactor a M B (d+N)) atTop (nhds 0) := tendsto_sum_nat_add (quadraticPrefixFactor a M B) /- Original line 39551: Erdos416Proof.FordGeometry.finite_quadratic_prefix_tail_bound -/ theorem finite_quadratic_prefix_tail_bound {a : ℝ} (ha : a < 1/8) (M : ℕ) (B : ℝ) (N : ℕ) (F : Finset ℕ) (hF : ∀ d ∈ F, N ≤ d) : (∑ d ∈ F, quadraticPrefixFactor a M B d) ≤ ∑' d : ℕ, quadraticPrefixFactor a M B (d+N) := by let G : Finset ℕ := F.image (fun d => d-N) have hinj : Set.InjOn (fun d : ℕ => d-N) (F : Set ℕ) := by intro d hd e he hde have hdN := hF d hd have heN := hF e he change d-N = e-N at hde omega have heq : (∑ d ∈ F, quadraticPrefixFactor a M B d) = ∑ d ∈ G, quadraticPrefixFactor a M B (d+N) := by rw [show G = F.image (fun d => d-N) by rfl, sum_image hinj] apply sum_congr rfl intro d hd rw [Nat.sub_add_cancel (hF d hd)] have hs : Summable (fun d : ℕ => quadraticPrefixFactor a M B (d+N)) := (quadraticPrefixFactor_summable ha M B).comp_injective (fun _ _ h => Nat.add_right_cancel h) rw [heq] exact hs.sum_le_tsum G (fun d _ => quadraticPrefixFactor_nonneg a M B (d+N)) /- Original line 39573: Erdos416Proof.FordGeometry.finite_quadratic_prefix_tails_small -/ theorem finite_quadratic_prefix_tails_small {a : ℝ} (ha : a < 1/8) (M : ℕ) (B : ℝ) {ε : ℝ} (hε : 0 < ε) : ∀ᶠ N : ℕ in atTop, ∀ F : Finset ℕ, (∀ d ∈ F, N ≤ d) → (∑ d ∈ F, quadraticPrefixFactor a M B d) ≤ ε := by filter_upwards [(quadratic_prefix_tail_tendsto a M B).eventually_lt_const hε] with N hN intro F hF exact (finite_quadratic_prefix_tail_bound ha M B N F hF).trans hN.le end Erdos416Proof.FordGeometry namespace Erdos416Proof.FordRestricted /-- The endpoint used in the first-failed-row split. -/ /- Original line 39587: Erdos416Proof.FordRestricted.structuralReciprocalCutoff -/ noncomputable def structuralReciprocalCutoff (k : ℕ) : ℝ := Real.exp (Real.exp (Real.exp ((k : ℝ)/20+1000))) /- Original line 39590: Erdos416Proof.FordRestricted.structuralReciprocalCutoff_tendsto -/ theorem structuralReciprocalCutoff_tendsto : Tendsto structuralReciprocalCutoff atTop atTop := by have h : Tendsto (fun k : ℕ => (k : ℝ)/20+1000) atTop atTop := tendsto_atTop_add_const_right _ _ (tendsto_natCast_atTop_atTop.atTop_div_const (by norm_num : (0 : ℝ) < 20)) exact Real.tendsto_exp_atTop.comp (Real.tendsto_exp_atTop.comp (Real.tendsto_exp_atTop.comp h)) /- Original line 39597: Erdos416Proof.FordRestricted.structuralReciprocalCutoff_log3 -/ theorem structuralReciprocalCutoff_log3 (k : ℕ) : Real.log (logLog (structuralReciprocalCutoff k)) = (k : ℝ)/20+1000 := by simp only [structuralReciprocalCutoff, logLog, Real.log_exp] /-- The actual restricted reciprocal sum at the structural endpoint has quadratic coefficient 1/25, which the proved Gaussian prefix bound absorbs. -/ /- Original line 39603: Erdos416Proof.FordRestricted.restricted_reciprocal_at_structural_cutoff -/ theorem restricted_reciprocal_at_structural_cutoff : ∀ᶠ k : ℕ in atTop, ∀ F : Finset ℕ, (∀ n ∈ F, n ∈ Nat.factoredNumbers (Nat.primesLE ⌊structuralReciprocalCutoff k⌋₊)) → (∀ n ∈ F, ∃ m : ℕ, 0 < m ∧ m.totient = n) → (∑ n ∈ F, (1 : ℝ)/n) ≤ Real.exp ((k : ℝ)^2/25+16001600*(k : ℝ)) := by filter_upwards [structuralReciprocalCutoff_tendsto.eventually restricted_totient_reciprocal_explicit_bound, eventually_ge_atTop 1] with k hk hk1 intro F hF hφ apply (hk F hF hφ).trans rw [structuralReciprocalCutoff_log3] apply Real.exp_le_exp.mpr have hkreal : (1 : ℝ) ≤ k := by exact_mod_cast hk1 nlinarith /- Original line 39617: Erdos416Proof.FordRestricted.small_totient_reciprocal_at_structural_cutoff -/ theorem small_totient_reciprocal_at_structural_cutoff : ∀ᶠ k : ℕ in atTop, (∑ n ∈ totientsUpTo (structuralReciprocalCutoff k), (1 : ℝ)/n) ≤ Real.exp ((k : ℝ)^2/25+16001600*(k : ℝ)) := by filter_upwards [restricted_reciprocal_at_structural_cutoff] with k hk have hY : 0 ≤ structuralReciprocalCutoff k := (Real.exp_pos _).le apply hk · intro n hn have hd := (mem_totientsUpTo hY).mp hn exact factored_primesLE_of_positive_le hd.1 hd.2.1 · intro n hn exact ((mem_totientsUpTo hY).mp hn).2.2 end Erdos416Proof.FordRestricted /- Uniform interval avoidance and its actual middle-prime-factor application. The normality-constrained reciprocal sum and structural coverage are separate. -/ open Filter Finset BoundingSieve SelbergSieve Sieve open scoped Classical Topology BigOperators Nat ArithmeticFunction ArithmeticFunction.zeta ArithmeticFunction.omega namespace Erdos416Proof.FordSieve /- Original line 39645: Erdos416Proof.FordSieve.reciprocalDensity -/ noncomputable def reciprocalDensity : ArithmeticFunction ℝ := ⟨fun n => (n : ℝ)⁻¹, by simp⟩ /- Original line 39648: Erdos416Proof.FordSieve.reciprocalDensity_apply -/ theorem reciprocalDensity_apply (n : ℕ) : reciprocalDensity n = (n : ℝ)⁻¹ := rfl /- Original line 39650: Erdos416Proof.FordSieve.reciprocalDensity_complete -/ theorem reciprocalDensity_complete : Sieve.CompletelyMultiplicative reciprocalDensity := by refine ⟨by simp[Erdos416Proof.FordSieve.reciprocalDensity_apply] , ?_⟩ intro m n simp [Erdos416Proof.FordSieve.reciprocalDensity_apply, mul_comm] /-- Omitting all primes dividing b costs just phi(b)/b in the denominator. -/ /- Original line 39656: Erdos416Proof.FordSieve.reciprocal_selberg_boundingSum_lower -/ theorem reciprocal_selberg_boundingSum_lower (s : SelbergSieve) {b : ℕ} (hb : 0 < b) (hnu : s.nu = reciprocalDensity) (hP : ∀ p : ℕ, p.Prime → (p : ℝ) ≤ s.level → ¬p ∣ b → p ∣ s.prodPrimes) : (b.totient : ℝ)/b * Real.log s.level/2 ≤ s.selbergBoundingSum := by let F := (Icc 1 ⌊Real.sqrt s.level⌋₊).filter (fun n => n.Coprime b) have hstart := selbergBoundingSum_ge_supported_sum s F (by intro m hm obtain ⟨hm, hcop⟩ := mem_filter.mp hm obtain ⟨hm1, hmL⟩ := mem_Icc.mp hm have hmr : (m : ℝ) ≤ Real.sqrt s.level := (Nat.cast_le.mpr hmL).trans (Nat.floor_le (Real.sqrt_nonneg _)) refine ⟨hm1, hmr, ?_⟩ intro p hp hpm apply hP p hp · exact (Nat.cast_le.mpr (Nat.le_of_dvd hm1 hpm)).trans (hmr.trans (Sieve.sqrt_le_self s.level s.one_le_level)) · intro hpb exact hp.not_dvd_one (hcop ▸ Nat.dvd_gcd hpm hpb)) (by rw [hnu]; exact reciprocalDensity_complete) (by intro n; rw [hnu, reciprocalDensity_apply]; positivity) (by intro p hp _; rw [hnu, reciprocalDensity_apply] exact inv_lt_one_of_one_lt₀ (by exact_mod_cast hp.one_lt)) simp only [hnu, reciprocalDensity_apply] at hstart have hlog : Real.log s.level/2 ≤ ∑ n ∈ Icc 1 ⌊Real.sqrt s.level⌋₊, (n : ℝ)⁻¹ := by have h := Aux.log_le_sum_inv (Real.sqrt s.level) (Real.le_sqrt_of_sq_le (by simpa only [one_pow] using s.one_le_level)) rwa [Real.log_sqrt (s.one_le_level.trans' zero_le_one)] at h calc _ = (b.totient : ℝ)/b * (Real.log s.level/2) := by ring _ ≤ (b.totient : ℝ)/b * (∑ n ∈ Icc 1 ⌊Real.sqrt s.level⌋₊, (n : ℝ)⁻¹) := mul_le_mul_of_nonneg_left hlog (by positivity) _ ≤ ∑ n ∈ F, (n : ℝ)⁻¹ := reciprocal_coprime_sum_lower_bound _ hb _ ≤ _ := hstart /- Original line 39690: Erdos416Proof.FordSieve.intervalSieve -/ noncomputable def intervalSieve (b N : ℕ) (L : ℝ) (hL : 1 ≤ L) : SelbergSieve where support := Icc 1 N prodPrimes := threeFormSieveProduct b L prodPrimes_squarefree := threeFormSieveProduct_squarefree _ _ weights := fun _ => 1 weights_nonneg := fun _ => zero_le_one totalMass := N nu := reciprocalDensity nu_mult := ⟨reciprocalDensity_complete.1, fun {m n} _ => reciprocalDensity_complete.2 m n⟩ nu_pos_of_prime := fun _ hp _ => inv_pos.mpr (by exact_mod_cast hp.pos) nu_lt_one_of_prime := fun _ hp _ => inv_lt_one_of_one_lt₀ (by exact_mod_cast hp.one_lt) level := L one_le_level := hL /- Original line 39705: Erdos416Proof.FordSieve.intervalSieve_multSum -/ theorem intervalSieve_multSum (b N d : ℕ) (L : ℝ) (hL : 1 ≤ L) : BoundingSieve.multSum (s := (intervalSieve b N L hL).toBoundingSieve) d = (N/d : ℕ) := by change (∑ n ∈ Icc 1 N, if d ∣ n then (1 : ℝ) else 0) = _ rw [Finset.sum_boole] exact congrArg (fun n : ℕ => (n : ℝ)) (positiveMultiples_card N d) /- Original line 39711: Erdos416Proof.FordSieve.intervalSieve_rem_bound -/ theorem intervalSieve_rem_bound (b N : ℕ) (L : ℝ) (hL : 1 ≤ L) {d : ℕ} (hd : 0 < d) : |BoundingSieve.rem (s := (intervalSieve b N L hL).toBoundingSieve) d| ≤ 1 := by rw [BoundingSieve.rem, intervalSieve_multSum] change |((N/d : ℕ) : ℝ) - (d : ℝ)⁻¹*N| ≤ 1 have hdR : (0 : ℝ) < d := by exact_mod_cast hd have hlo : ((N/d : ℕ) : ℝ) ≤ (N : ℝ)/d := Nat.cast_div_le have hhi : (N : ℝ)/d < ((N/d : ℕ) : ℝ)+1 := by apply (div_lt_iff₀ hdR).mpr have h := Nat.div_add_mod N d have hm := Nat.mod_lt N hd have hR := congrArg (fun n : ℕ => (n : ℝ)) h have hmR : ((N%d : ℕ) : ℝ) < d := by exact_mod_cast hm push_cast at hR nlinarith rw [show (d : ℝ)⁻¹*N = (N : ℝ)/d by ring, abs_of_nonpos (sub_nonpos.mpr hlo)] linarith /- Original line 39728: Erdos416Proof.FordSieve.intervalSieve_siftedSum -/ theorem intervalSieve_siftedSum (b N : ℕ) (L : ℝ) (hL : 1 ≤ L) : BoundingSieve.siftedSum (s := (intervalSieve b N L hL).toBoundingSieve) = (((Icc 1 N).filter (fun n => (threeFormSieveProduct b L).Coprime n)).card : ℝ) := by exact Finset.sum_boole _ _ /-- A finite, unconditional count before choosing the level. -/ /- Original line 39734: Erdos416Proof.FordSieve.interval_sifted_count_bound -/ theorem interval_sifted_count_bound {b : ℕ} (hb : 0 < b) (N : ℕ) {L : ℝ} (hL : 1 < L) : (((Icc 1 N).filter (fun n => (threeFormSieveProduct b L).Coprime n)).card : ℝ) ≤ 2*((b : ℝ)/b.totient)*N/Real.log L + L*(1+Real.log L)^3 := by let s := intervalSieve b N L hL.le have hlow := reciprocal_selberg_boundingSum_lower s hb rfl (by intro p hp hpL hpb exact (prime_dvd_threeFormSieveProduct_iff _ _ hp).mpr ⟨Nat.le_floor hpL, hpb⟩) have hlog : 0 < Real.log L := Real.log_pos hL have hbR : (0 : ℝ) < b := by exact_mod_cast hb have hφR : (0 : ℝ) < b.totient := by exact_mod_cast Nat.totient_pos.mpr hb have hmain : s.totalMass/s.selbergBoundingSum ≤ 2*((b : ℝ)/b.totient)*N/Real.log L := by calc _ ≤ (N : ℝ)/((b.totient : ℝ)/b*Real.log L/2) := div_le_div_of_nonneg_left (by change (0 : ℝ) ≤ N; positivity) (by positivity) hlow _ = _ := by field_simp have herr := Sieve.rem_sum_le_of_const s 1 (fun d hd => intervalSieve_rem_bound b N L hL.le hd) simp only [one_mul] at herr have h := s.selberg_bound_simple.trans (add_le_add hmain herr) rwa [intervalSieve_siftedSum] at h /- Original line 39755: Erdos416Proof.FordSieve.exists_primorial_ratio_bound -/ theorem exists_primorial_ratio_bound : ∃ C : ℝ, 0 < C ∧ ∀ S : ℝ, 2 ≤ S → ((primorial ⌊S⌋₊ : ℕ) : ℝ)/(primorial ⌊S⌋₊).totient ≤ C*Real.log S := by obtain ⟨A, hA, hbound⟩ := inverse_prime_euler_product_bound obtain ⟨X, hX⟩ := eventually_atTop.mp hbound let Z := max 2 X let B := ∏ p ∈ Nat.primesLE ⌊Z⌋₊, totientFactor p have hB : 0 < B := Finset.prod_pos fun p hp => totientFactor_pos (Nat.prime_of_mem_primesLE hp) have hl2 : 0 < Real.log (2 : ℝ) := Real.log_pos (by norm_num) refine ⟨A+B/Real.log 2, by positivity, ?_⟩ intro S hS have hlS : 0 < Real.log S := Real.log_pos (by linarith) rw [totient_ratio_eq_prod (primorial_pos _), primeFactors_primorial] by_cases hZS : Z ≤ S · have h := hX S ((le_max_right _ _).trans hZS) exact h.trans (mul_le_mul_of_nonneg_right (le_add_of_nonneg_right (by positivity)) hlS.le) have hSZ : S ≤ Z := (lt_of_not_ge hZS).le have hp : (∏ p ∈ Nat.primesLE ⌊S⌋₊, totientFactor p) ≤ B := by apply Finset.prod_le_prod_of_subset_of_one_le · exact Nat.primesLE_mono (Nat.floor_mono hSZ) · intro p hp exact (totientFactor_pos (Nat.prime_of_mem_primesLE hp)).le · intro p hp _ exact one_le_totientFactor (Nat.prime_of_mem_primesLE hp) have hlog : Real.log (2 : ℝ) ≤ Real.log S := Real.log_le_log (by norm_num) hS calc _ ≤ B := hp _ = (B/Real.log 2)*Real.log 2 := (div_mul_cancel₀ _ hl2.ne').symm _ ≤ (B/Real.log 2)*Real.log S := mul_le_mul_of_nonneg_left hlog (by positivity) _ ≤ _ := by nlinarith /-- Actual positive integers with no prime divisor in (S,z]. -/ /- Original line 39786: Erdos416Proof.FordSieve.intervalAvoiders -/ noncomputable def intervalAvoiders (x S z : ℝ) : Finset ℕ := (Icc 1 ⌊x⌋₊).filter (fun n => ∀ p : ℕ, p.Prime → S < (p : ℝ) → (p : ℝ) ≤ z → ¬p ∣ n) /- Original line 39789: Erdos416Proof.FordSieve.intervalAvoiders_le_sifted -/ theorem intervalAvoiders_le_sifted {x S z L : ℝ} (hLz : L ≤ z) : intervalAvoiders x S z ⊆ (Icc 1 ⌊x⌋₊).filter (fun n => (threeFormSieveProduct (primorial ⌊S⌋₊) L).Coprime n) := by intro n hn obtain ⟨hnx, hn⟩ := mem_filter.mp hn refine mem_filter.mpr ⟨hnx, ?_⟩ apply Nat.coprime_of_dvd intro p hp hpP hpn obtain ⟨hpL, hpS⟩ := (prime_dvd_threeFormSieveProduct_iff _ _ hp).mp hpP have hSp : S < (p : ℝ) := by by_contra h exact hpS (hp.dvd_primorial_iff.mpr (Nat.le_floor (le_of_not_gt h))) have hpL' : (p : ℝ) ≤ L := by have hLp : 0 ≤ L := (Nat.pos_of_floor_pos (hp.pos.trans_le hpL)).le exact (Nat.cast_le.mpr hpL).trans (Nat.floor_le hLp) exact hn p hp hSp (hpL'.trans hLz) hpn /- Original line 39806: Erdos416Proof.FordSieve.intervalAvoiders_finite_bound -/ theorem intervalAvoiders_finite_bound {x S z L : ℝ} (hL : 1 < L) (hLz : L ≤ z) : ((intervalAvoiders x S z).card : ℝ) ≤ 2*((primorial ⌊S⌋₊ : ℕ) : ℝ)/(primorial ⌊S⌋₊).totient * ⌊x⌋₊/Real.log L + L*(1+Real.log L)^3 := by have hcard : ((intervalAvoiders x S z).card : ℝ) ≤ (((Icc 1 ⌊x⌋₊).filter (fun n => (threeFormSieveProduct (primorial ⌊S⌋₊) L).Coprime n)).card : ℝ) := by exact_mod_cast Finset.card_le_card (intervalAvoiders_le_sifted hLz) have h := interval_sifted_count_bound (primorial_pos ⌊S⌋₊) ⌊x⌋₊ hL simpa only [mul_div_assoc] using hcard.trans h /- Original line 39817: Erdos416Proof.FordSieve.interval_sieve_error_eventually -/ theorem interval_sieve_error_eventually : ∀ᶠ x : ℝ in atTop, ∀ L : ℝ, 1 ≤ L → L ≤ x^(1/2 : ℝ) → L*(1+Real.log L)^3 ≤ x/Real.log x := by filter_upwards [twoForm_sieve_error_eventually, Real.tendsto_log_atTop.eventually (eventually_ge_atTop (2 : ℝ)), eventually_gt_atTop (1 : ℝ)] with x herr hxlog hx intro L hL hLx have hx0 : 0 < x := by linarith have hroot0 := Real.rpow_pos_of_pos hx0 (1/2 : ℝ) have hroot1 := Real.one_lt_rpow hx (by norm_num : (0 : ℝ) < 1/2) have hlogL : 0 ≤ Real.log L := Real.log_nonneg hL have hlogs := Real.log_le_log (by linarith : 0 < L) hLx have hlogroot : 0 ≤ Real.log (x^(1/2 : ℝ)) := Real.log_nonneg hroot1.le have hpow : (1+Real.log L)^3 ≤ (1+Real.log (x^(1/2 : ℝ)))^6 := by calc _ ≤ (1+Real.log (x^(1/2 : ℝ)))^3 := by gcongr _ ≤ _ := pow_le_pow_right₀ (by linarith) (by norm_num : 3 ≤ 6) calc _ ≤ x^(1/2 : ℝ)*(1+Real.log (x^(1/2 : ℝ)))^6 := by gcongr _ ≤ x/Real.log x^2 := by linarith _ ≤ _ := div_le_div_of_nonneg_left hx0.le (by linarith) (by nlinarith) /-- A single constant works for every interval of forbidden primes at each sufficiently large x. The endpoints S and z may vary with x. -/ /- Original line 39841: Erdos416Proof.FordSieve.exists_intervalAvoiders_eventually_bound -/ theorem exists_intervalAvoiders_eventually_bound : ∃ C : ℝ, 0 < C ∧ ∀ᶠ x : ℝ in atTop, ∀ S z : ℝ, 2 ≤ S → S ≤ z → z ≤ x → ((intervalAvoiders x S z).card : ℝ) ≤ C*x*Real.log S/Real.log z := by obtain ⟨C, hC, hratio⟩ := exists_primorial_ratio_bound have hl2 : 0 < Real.log (2 : ℝ) := Real.log_pos (by norm_num) refine ⟨4*C+1/Real.log 2, by positivity, ?_⟩ filter_upwards [interval_sieve_error_eventually, eventually_gt_atTop (1 : ℝ)] with x herr hx intro S z hS hSz hzx have hx0 : 0 < x := by linarith have hz : 1 < z := by linarith have hS0 : 0 < S := by linarith have hz0 : 0 < z := by linarith have hlogz := Real.log_pos hz have hlogS := Real.log_pos (by linarith : 1 < S) have hlogx := Real.log_pos hx have hlogsx := Real.log_le_log hz0 hzx let L := min z (x^(1/2 : ℝ)) have hL : 1 < L := lt_min hz (Real.one_lt_rpow hx (by norm_num : (0 : ℝ) < 1/2)) have hLz : L ≤ z := min_le_left _ _ have hLx : L ≤ x^(1/2 : ℝ) := min_le_right _ _ have hlogL : Real.log z/2 ≤ Real.log L := by rcases le_total z (x^(1/2 : ℝ)) with h | h · rw [show L = z from min_eq_left h] linarith · rw [show L = x^(1/2 : ℝ) from min_eq_right h, Real.log_rpow hx0] linarith have hbase := intervalAvoiders_finite_bound (x := x) (S := S) hL hLz have hq := hratio S hS have hfloor : (⌊x⌋₊ : ℝ) ≤ x := Nat.floor_le hx0.le have hmain : 2*((primorial ⌊S⌋₊ : ℕ) : ℝ)/(primorial ⌊S⌋₊).totient * ⌊x⌋₊/Real.log L ≤ 4*C*x*Real.log S/Real.log z := by calc _ = 2*(((primorial ⌊S⌋₊ : ℕ) : ℝ)/(primorial ⌊S⌋₊).totient)*⌊x⌋₊/Real.log L := by ring _ ≤ 2*(C*Real.log S)*x/(Real.log z/2) := by gcongr _ = _ := by ring have herror : x/Real.log x ≤ (1/Real.log 2)*x*Real.log S/Real.log z := by have hlS : Real.log (2 : ℝ) ≤ Real.log S := Real.log_le_log (by norm_num) hS calc _ ≤ x/Real.log z := div_le_div_of_nonneg_left hx0.le hlogz hlogsx _ = ((1/Real.log 2)*x*Real.log 2)/Real.log z := by field_simp _ ≤ _ := by gcongr calc _ ≤ 4*C*x*Real.log S/Real.log z + (1/Real.log 2)*x*Real.log S/Real.log z := hbase.trans (add_le_add hmain ((herr L hL.le hLx).trans herror)) _ = _ := by ring end Erdos416Proof.FordSieve namespace Erdos416Proof.FordSieve /-- Ford's interval-avoidance estimate in the range needed for the structural argument, uniform for every 2 <= S <= z <= x. -/ /- Original line 39894: Erdos416Proof.FordSieve.exists_intervalAvoiders_bound -/ theorem exists_intervalAvoiders_bound : ∃ C : ℝ, 0 < C ∧ ∀ x S z : ℝ, 2 ≤ S → S ≤ z → z ≤ x → ((intervalAvoiders x S z).card : ℝ) ≤ C*x*Real.log S/Real.log z := by obtain ⟨C, hC, hbound⟩ := exists_intervalAvoiders_eventually_bound obtain ⟨X, hX⟩ := eventually_atTop.mp hbound let Y := max 2 X let D := C+Real.log Y/Real.log 2 have hY : 2 ≤ Y := le_max_left _ _ have hlogY : 0 < Real.log Y := Real.log_pos (by linarith) have hlog2 : 0 < Real.log (2 : ℝ) := Real.log_pos (by norm_num) have hCD : C ≤ D := le_add_of_nonneg_right (by positivity) have hD : 0 < D := hC.trans_le hCD refine ⟨D, hD, ?_⟩ intro x S z hS hSz hzx have hx : 2 ≤ x := hS.trans (hSz.trans hzx) have hx0 : 0 < x := by linarith have hS0 : 0 < S := by linarith have hz : 1 < z := by linarith have hlogz := Real.log_pos hz have hlogS := Real.log_pos (by linarith : 1 < S) by_cases hYx : Y ≤ x · exact (hX x ((le_max_right _ _).trans hYx) S z hS hSz hzx).trans (by gcongr) have hxY : x ≤ Y := (lt_of_not_ge hYx).le have hlogzY : Real.log z ≤ Real.log Y := Real.log_le_log (by linarith) (hzx.trans hxY) have hlog2S : Real.log (2 : ℝ) ≤ Real.log S := Real.log_le_log (by norm_num) hS have hcoef : Real.log z ≤ D*Real.log S := by calc _ ≤ Real.log Y := hlogzY _ = (Real.log Y/Real.log 2)*Real.log 2 := (div_mul_cancel₀ _ hlog2.ne').symm _ ≤ (Real.log Y/Real.log 2)*Real.log S := mul_le_mul_of_nonneg_left hlog2S (by positivity) _ ≤ _ := by dsimp [D]; nlinarith have hcard : ((intervalAvoiders x S z).card : ℝ) ≤ x := by calc _ ≤ ((Icc 1 ⌊x⌋₊).card : ℝ) := by exact_mod_cast Finset.card_filter_le (Icc 1 ⌊x⌋₊) _ _ = (⌊x⌋₊ : ℝ) := by simp _ ≤ x := Nat.floor_le hx0.le apply hcard.trans apply (le_div_iff₀ hlogz).mpr nlinarith [mul_le_mul_of_nonneg_right hcoef hx0.le] end Erdos416Proof.FordSieve namespace Erdos416Proof.FordSieve /- Original line 39940: Erdos416Proof.FordSieve.intervalFactor -/ noncomputable def intervalFactor (n : ℕ) (S z : ℝ) : ℕ := primePart n (fun p => S < (p : ℝ) ∧ (p : ℝ) ≤ z) /- Original line 39943: Erdos416Proof.FordSieve.intervalCofactor -/ noncomputable def intervalCofactor (n : ℕ) (S z : ℝ) : ℕ := primePart n (fun p => ¬(S < (p : ℝ) ∧ (p : ℝ) ≤ z)) /- Original line 39946: Erdos416Proof.FordSieve.intervalFactor_mul_cofactor -/ theorem intervalFactor_mul_cofactor {n : ℕ} (hn : n ≠ 0) (S z : ℝ) : intervalFactor n S z * intervalCofactor n S z = n := primePart_mul_compl hn _ /- Original line 39949: Erdos416Proof.FordSieve.intervalCofactor_mem_avoiders -/ theorem intervalCofactor_mem_avoiders {n : ℕ} (hn : 0 < n) {x S z : ℝ} (hnx : (n : ℝ) ≤ x) : intervalCofactor n S z ∈ intervalAvoiders (x/intervalFactor n S z) S z := by have hm : 0 < intervalFactor n S z := primePart_pos _ _ have hr : 0 < intervalCofactor n S z := primePart_pos _ _ have hmR : (0 : ℝ) < intervalFactor n S z := by exact_mod_cast hm refine mem_filter.mpr ⟨mem_Icc.mpr ⟨hr, Nat.le_floor ?_⟩, ?_⟩ · apply (le_div_iff₀ hmR).mpr have heq := congrArg (fun n : ℕ => (n : ℝ)) (intervalFactor_mul_cofactor hn.ne' S z) push_cast at heq nlinarith · intro p hp hSp hpz hpr have hmem := (Nat.mem_primeFactorsList hr.ne').mpr ⟨hp, hpr⟩ exact ((mem_primeFactorsList_primePart n p _).mp hmem).2 ⟨hSp, hpz⟩ /-- An actual family is partitioned by its complete factor supported in (S,z]. For each fixed factor the residual integers avoid that interval. The constant is uniform over both finite families and all endpoints. -/ /- Original line 39967: Erdos416Proof.FordSieve.exists_interval_factor_fiber_bound -/ theorem exists_interval_factor_fiber_bound : ∃ C : ℝ, 0 < C ∧ ∀ x S z : ℝ, 2 ≤ S → S ≤ z → ∀ G M : Finset ℕ, (∀ n ∈ G, 0 < n ∧ (n : ℝ) ≤ x) → (∀ n ∈ G, intervalFactor n S z ∈ M) → (∀ m ∈ M, 0 < m ∧ z ≤ x/m) → (G.card : ℝ) ≤ C*x*Real.log S/Real.log z * (∑ m ∈ M, (m : ℝ)⁻¹) := by obtain ⟨C, hC, hbound⟩ := exists_intervalAvoiders_bound refine ⟨C, hC, ?_⟩ intro x S z hS hSz G M hG hM hcut let f : ℕ → Σ _ : ℕ, ℕ := fun n => ⟨intervalFactor n S z, intervalCofactor n S z⟩ have hprod (n : ℕ) (hn : n ∈ G) : (f n).1*(f n).2 = n := intervalFactor_mul_cofactor (hG n hn).1.ne' S z have hinj : Set.InjOn f (G : Set ℕ) := by intro n hn m hm heq have h := congrArg (fun v : Σ _ : ℕ, ℕ => v.1*v.2) heq rwa [hprod n hn, hprod m hm] at h have hsub : G.image f ⊆ M.sigma (fun m => intervalAvoiders (x/m) S z) := by intro v hv obtain ⟨n, hn, rfl⟩ := mem_image.mp hv exact mem_sigma.mpr ⟨hM n hn, intervalCofactor_mem_avoiders (hG n hn).1 (hG n hn).2⟩ have hcard : (G.card : ℝ) ≤ ∑ m ∈ M, ((intervalAvoiders (x/m) S z).card : ℝ) := by have hnat := Finset.card_le_card hsub rw [Finset.card_image_of_injOn hinj, Finset.card_sigma] at hnat exact_mod_cast hnat calc _ ≤ ∑ m ∈ M, ((intervalAvoiders (x/m) S z).card : ℝ) := hcard _ ≤ ∑ m ∈ M, C*(x/m)*Real.log S/Real.log z := sum_le_sum fun m hm => hbound (x/m) S z hS hSz (hcut m hm).2 _ = _ := by rw [mul_sum] apply sum_congr rfl intro m _ ring end Erdos416Proof.FordSieve namespace Erdos416Proof.FordSieve /- Original line 40006: Erdos416Proof.FordSieve.intervalFactor_le_sqrt -/ theorem intervalFactor_le_sqrt {x S z : ℝ} (hx : 1 < x) (hT : 1 ≤ logLog x) (hz : 1 ≤ z) (hcut : z ≤ x^(1/(20*logLog x))) (n : ℕ) (hOmega : (ArithmeticFunction.cardFactors n : ℝ) ≤ 5*logLog x) : (intervalFactor n S z : ℝ) ≤ x^(1/2 : ℝ) := by have hx0 : 0 < x := by linarith have hT0 : 0 < logLog x := by linarith have hz0 : 0 < z := by linarith have hm : 0 < intervalFactor n S z := primePart_pos _ _ have hmR : (0 : ℝ) < intervalFactor n S z := by exact_mod_cast hm have hP : (largestPrimeFactor (intervalFactor n S z) : ℝ) ≤ z := primePart_largestPrimeFactor_le n _ hz (fun _ _ h => h.2) have hP0 : (0 : ℝ) < largestPrimeFactor (intervalFactor n S z) := by exact_mod_cast (lt_of_lt_of_le Nat.zero_lt_one (le_max_left _ _) : 0 < largestPrimeFactor (intervalFactor n S z)) have hcount : (ArithmeticFunction.cardFactors (intervalFactor n S z) : ℝ) ≤ 5*logLog x := (Nat.cast_le.mpr (primePart_cardFactors_le n _)).trans hOmega have hlogm : Real.log (intervalFactor n S z) ≤ 5*logLog x*Real.log z := by calc _ ≤ ArithmeticFunction.cardFactors (intervalFactor n S z) * Real.log (largestPrimeFactor (intervalFactor n S z)) := log_le_cardFactors_mul_log_largestPrimeFactor hm _ ≤ ArithmeticFunction.cardFactors (intervalFactor n S z) * Real.log z := mul_le_mul_of_nonneg_left (Real.log_le_log hP0 hP) (by positivity) _ ≤ _ := mul_le_mul_of_nonneg_right hcount (Real.log_nonneg hz) have hlogz := Real.log_le_log hz0 hcut rw [Real.log_rpow hx0] at hlogz have hquarter : 5*logLog x*Real.log z ≤ Real.log x/4 := by calc _ ≤ 5*logLog x*((1/(20*logLog x))*Real.log x) := mul_le_mul_of_nonneg_left hlogz (by positivity) _ = _ := by field_simp; ring apply (Real.log_le_log_iff hmR (Real.rpow_pos_of_pos hx0 _)).mp rw [Real.log_rpow hx0] linarith [hlogm.trans hquarter, Real.log_pos hx] /-- The size condition needed by the interval sieve follows from the actual factor-count cutoff, uniformly over all values in the family. -/ /- Original line 40043: Erdos416Proof.FordSieve.exists_interval_factor_image_bound -/ theorem exists_interval_factor_image_bound : ∃ C : ℝ, 0 < C ∧ ∀ x S z : ℝ, 1 < x → 1 ≤ logLog x → 2 ≤ S → S ≤ z → z ≤ x^(1/(20*logLog x)) → ∀ G : Finset ℕ, (∀ n ∈ G, 0 < n ∧ (n : ℝ) ≤ x) → (∀ n ∈ G, (ArithmeticFunction.cardFactors n : ℝ) ≤ 5*logLog x) → (G.card : ℝ) ≤ C*x*Real.log S/Real.log z * (∑ m ∈ G.image (fun n => intervalFactor n S z), (m : ℝ)⁻¹) := by obtain ⟨C, hC, hbound⟩ := exists_interval_factor_fiber_bound refine ⟨C, hC, ?_⟩ intro x S z hx hT hS hSz hcut G hG hOmega have hx0 : 0 < x := by linarith have hz : 1 ≤ z := by linarith have hT0 : 0 < logLog x := by linarith have hfrac : 1/(20*logLog x) ≤ (1/2 : ℝ) := (div_le_iff₀ (by positivity)).mpr (by linarith) have hzroot : z ≤ x^(1/2 : ℝ) := hcut.trans (Real.rpow_le_rpow_of_exponent_le hx.le hfrac) apply hbound x S z hS hSz G (G.image (fun n => intervalFactor n S z)) hG (fun n hn => mem_image.mpr ⟨n, hn, rfl⟩) intro m hm obtain ⟨n, hn, rfl⟩ := mem_image.mp hm have hmpos : 0 < intervalFactor n S z := primePart_pos _ _ refine ⟨hmpos, ?_⟩ apply (le_div_iff₀ (by exact_mod_cast hmpos : (0 : ℝ) < intervalFactor n S z)).mpr have hmroot := intervalFactor_le_sqrt (S := S) hx hT hz hcut n (hOmega n hn) calc _ ≤ x^(1/2 : ℝ)*x^(1/2 : ℝ) := mul_le_mul hzroot hmroot (by positivity) (by positivity) _ = x := by rw [← pow_two, ← Real.sqrt_eq_rpow, Real.sq_sqrt hx0.le] end Erdos416Proof.FordSieve end /- Consolidated component: FordCappedNormality.lean. -/ section open Filter Finset open scoped Classical Topology BigOperators Nat namespace Erdos416Proof.FordBadFacet /- Original line 40088: Erdos416Proof.FordBadFacet.omegaInterval_primePart_eq_of_contains -/ theorem omegaInterval_primePart_eq_of_contains (n : ℕ) (A : ℕ → Prop) (u v : ℝ) (hA : ∀ p ∈ n.primeFactorsList, u < (p : ℝ) ∧ (p : ℝ) ≤ v → A p) : omegaInterval (primePart n A) u v = omegaInterval n u v := by unfold omegaInterval rw [← (primePart_factors_perm n A).countP_eq, List.countP_filter] apply List.countP_congr intro p hp simp only [Bool.and_eq_true, decide_eq_true_eq] exact ⟨fun h => h.1, fun h => ⟨h, hA p hp h⟩⟩ /- Original line 40098: Erdos416Proof.FordBadFacet.normal_primes_interval_lower -/ theorem normal_primes_interval_lower {n : ℕ} (hn : 0 < n) (P : Finset ℕ) {S T u v : ℝ} (hS : Real.exp 1 ≤ S) (hSu : S ≤ u) (huv : u < v) (hvT : logLog v ≤ T) (hP : ∀ p ∈ P, SNormal S p ∧ p ∣ n ∧ v ≤ (p-1 : ℕ)) : (P.card : ℝ)*(logLog v-logLog u-Real.sqrt (logLog S*T)) ≤ (omegaInterval n.totient u v : ℝ) := by have hprime : ∀ p ∈ P, p.Prime := fun p hp => (hP p hp).1.1 have hprod : ∏ p ∈ P, p ∣ n := Finset.prod_primes_dvd n (fun p hp => Nat.prime_iff.mp (hprime p hp)) (fun p hp => (hP p hp).2.1) have hφ := Nat.totient_dvd_of_dvd hprod rw [totient_prod_primes P hprime] at hφ have hω := omegaInterval_mono_dvd (Nat.totient_pos.mpr hn) hφ u v rw [omegaInterval_prod P (fun p => p-1) (fun p hp => by have := (hprime p hp).two_le; omega)] at hω have hsum : (∑ p ∈ P, (omegaInterval (p-1) u v : ℝ)) ≤ (omegaInterval n.totient u v : ℝ) := by exact_mod_cast hω calc _ = ∑ _p ∈ P, (logLog v-logLog u-Real.sqrt (logLog S*T)) := by simp only [Finset.sum_const, nsmul_eq_mul] _ ≤ ∑ p ∈ P, (omegaInterval (p-1) u v : ℝ) := sum_le_sum fun p hp => ((hP p hp).1.interval_bounds hS hSu huv hvT (hP p hp).2.2).1 _ ≤ _ := hsum /- Original line 40121: Erdos416Proof.FordBadFacet.cappedNormalityEndpoint -/ noncomputable def cappedNormalityEndpoint (F v : ℝ) : ℝ := min F (v/2) /-- The cap is inside the actual middle factor and inside every p-1, even when the only given prime threshold is v <= p. -/ /- Original line 40125: Erdos416Proof.FordBadFacet.normal_primes_capped_interval_lower -/ theorem normal_primes_capped_interval_lower {n : ℕ} (hn : 0 < n) (P : Finset ℕ) {S F u v : ℝ} (hS : Real.exp 1 ≤ S) (hSF : S ≤ F) (hSu : S ≤ u) (huv : u ≤ v) (hP : ∀ p ∈ P, SNormal S p ∧ p ∣ n ∧ v ≤ (p : ℝ)) : (P.card : ℝ)*(logLog (cappedNormalityEndpoint F v)-logLog u- Real.sqrt (logLog S*logLog v)) ≤ (omegaInterval (primePart n.totient (fun q => S < (q : ℝ) ∧ (q : ℝ) ≤ F)) u v : ℝ) := by let w := cappedNormalityEndpoint F v have hS2 : 2 < S := Real.exp_one_gt_two.trans_le hS have hv2 : 2 < v := hS2.trans_le (hSu.trans huv) have hw1 : 1 < w := lt_min (by linarith) (by linarith) have hwF : w ≤ F := min_le_left _ _ have hwv : w ≤ v := (min_le_right F (v/2)).trans (by linarith) by_cases huw : u < w · have hlow := normal_primes_interval_lower hn P hS hSu huw (logLog_mono hw1 hwv) (by intro p hp have hprime := (hP p hp).1.1 refine ⟨(hP p hp).1, (hP p hp).2.1, ?_⟩ have hp2 : (2 : ℝ) ≤ p := by exact_mod_cast hprime.two_le have hsub : ((p-1 : ℕ) : ℝ) = (p : ℝ)-1 := by rw [Nat.cast_sub (by have := hprime.two_le; omega), Nat.cast_one] rw [hsub] have hw : w ≤ v/2 := min_le_right _ _ nlinarith [(hP p hp).2.2]) have heq := omegaInterval_primePart_eq_of_contains n.totient (fun q => S < (q : ℝ) ∧ (q : ℝ) ≤ F) u w (fun q _ hq => ⟨hSu.trans_lt hq.1, hq.2.trans hwF⟩) rw [← heq] at hlow exact hlow.trans (Nat.cast_le.mpr (omegaInterval_mono_bounds _ le_rfl hwv)) · have hlog := logLog_mono hw1 (le_of_not_gt huw) have hnonpos : logLog w-logLog u-Real.sqrt (logLog S*logLog v) ≤ 0 := by linarith [Real.sqrt_nonneg (logLog S*logLog v)] exact (mul_nonpos_of_nonneg_of_nonpos (Nat.cast_nonneg _) hnonpos).trans (by positivity) /- Original line 40160: Erdos416Proof.FordBadFacet.normal_primes_capped_lower_of_logLoss -/ theorem normal_primes_capped_lower_of_logLoss {n : ℕ} (hn : 0 < n) (P : Finset ℕ) {S F u v E : ℝ} (hS : Real.exp 1 ≤ S) (hSF : S ≤ F) (hSu : S ≤ u) (huv : u ≤ v) (hP : ∀ p ∈ P, SNormal S p ∧ p ∣ n ∧ v ≤ (p : ℝ)) (hLoss : logLog v-logLog (cappedNormalityEndpoint F v) ≤ E) : (P.card : ℝ)*(logLog v-logLog u-E-Real.sqrt (logLog S*logLog v)) ≤ (omegaInterval (primePart n.totient (fun q => S < (q : ℝ) ∧ (q : ℝ) ≤ F)) u v : ℝ) := by apply le_trans _ (normal_primes_capped_interval_lower hn P hS hSF hSu huv hP) exact mul_le_mul_of_nonneg_left (by linarith) (Nat.cast_nonneg _) /- Original line 40170: Erdos416Proof.FordBadFacet.logLog_half_loss -/ theorem logLog_half_loss {v : ℝ} (hv : 4 ≤ v) : logLog v-logLog (v/2) ≤ Real.log 2 := by have hv0 : 0 < v := by linarith have hv1 : 1 < v := by linarith have hlv := Real.log_pos hv1 have hlog4 : 2*Real.log (2 : ℝ) ≤ Real.log v := by have h := Real.log_le_log (by norm_num : (0 : ℝ) < 4) hv rw [show (4 : ℝ) = 2^2 by norm_num, Real.log_pow] at h norm_num at h ⊢ exact h have hhalf : Real.log v/2 ≤ Real.log (v/2) := by rw [Real.log_div hv0.ne' (by norm_num)] linarith have h := Real.log_le_log (by positivity : 0 < Real.log v/2) hhalf rw [Real.log_div hlv.ne' (by norm_num)] at h unfold logLog linarith /- Original line 40187: Erdos416Proof.FordBadFacet.capped_logLoss_le -/ theorem capped_logLoss_le {F v E : ℝ} (hv : 4 ≤ v) (hF : logLog v-logLog F ≤ E) (hE : Real.log 2 ≤ E) : logLog v-logLog (cappedNormalityEndpoint F v) ≤ E := by rcases le_total F (v/2) with h | h · simpa only [cappedNormalityEndpoint, min_eq_left h] using hF · simpa only [cappedNormalityEndpoint, min_eq_right h] using (logLog_half_loss hv).trans hE /- Original line 40194: Erdos416Proof.FordBadFacet.logLog_ford_power_cutoff -/ theorem logLog_ford_power_cutoff {x : ℝ} (hx : 1 < x) (hT : 0 < logLog x) : logLog (x^(1/(20*logLog x))) = logLog x-Real.log (20*logLog x) := by have hx0 : 0 < x := by linarith have hlog := Real.log_pos hx change Real.log (Real.log (x^(1/(20*logLog x)))) = _ rw [Real.log_rpow hx0, show 1/(20*logLog x)*Real.log x = Real.log x/(20*logLog x) by ring, Real.log_div hlog.ne' (by positivity)] rfl /-- The complete cap, including p versus p-1, loses at most log(20*T) in double-logarithmic width when T=log_2(x). -/ /- Original line 40205: Erdos416Proof.FordBadFacet.ford_capped_logLoss -/ theorem ford_capped_logLoss {x E₁ v : ℝ} (hx : 1 < x) (hT : 1 ≤ logLog x) (hv : 4 ≤ v) (hvE : v ≤ E₁) (hvx : v ≤ x) : logLog v-logLog (cappedNormalityEndpoint (min E₁ (x^(1/(20*logLog x)))) v) ≤ Real.log (20*logLog x) := by have hT0 : 0 < logLog x := by linarith have hE : Real.log (2 : ℝ) ≤ Real.log (20*logLog x) := Real.log_le_log (by norm_num) (by linarith) apply capped_logLoss_le hv _ hE rcases le_total E₁ (x^(1/(20*logLog x))) with h | h · rw [min_eq_left h] have hlog := logLog_mono (by linarith : 1 < v) hvE have hE0 : 0 ≤ Real.log (20*logLog x) := Real.log_nonneg (by linarith) linarith · rw [min_eq_right h, logLog_ford_power_cutoff hx hT0] have hlog := logLog_mono (by linarith : 1 < v) hvx linarith /- Original line 40222: Erdos416Proof.FordBadFacet.ford_scale_logLoss_le -/ theorem ford_scale_logLoss_le {x S : ℝ} (hT : 20 ≤ logLog x) (hscale : Real.exp ((logLog x)^36) ≤ S) : Real.log (20*logLog x) ≤ logLog S := by have hT0 : 0 < logLog x := by linarith have hlog : 0 ≤ Real.log (logLog x) := Real.log_nonneg (by linarith) have hS := Real.log_le_log (Real.exp_pos _) hscale rw [Real.log_exp] at hS have hSS := Real.log_le_log (pow_pos hT0 36) hS rw [Real.log_pow] at hSS have h20 := Real.log_le_log (by norm_num : (0 : ℝ) < 20) hT rw [Real.log_mul (by norm_num) hT0.ne'] change _ ≤ Real.log (Real.log S) norm_num at hSS linarith /- Original line 40237: Erdos416Proof.FordBadFacet.normal_primes_ford_capped_lower -/ theorem normal_primes_ford_capped_lower {n : ℕ} (hn : 0 < n) (P : Finset ℕ) {x S E₁ u v : ℝ} (hx : 1 < x) (hT : 20 ≤ logLog x) (hS : Real.exp 1 ≤ S) (hS4 : 4 ≤ S) (hscale : Real.exp ((logLog x)^36) ≤ S) (hSF : S ≤ min E₁ (x^(1/(20*logLog x)))) (hSu : S ≤ u) (huv : u ≤ v) (hvE : v ≤ E₁) (hvx : v ≤ x) (hP : ∀ p ∈ P, SNormal S p ∧ p ∣ n ∧ v ≤ (p : ℝ)) : (P.card : ℝ)*(logLog v-logLog u-2*Real.sqrt (logLog S*logLog v)) ≤ (omegaInterval (primePart n.totient (fun q => S < (q : ℝ) ∧ (q : ℝ) ≤ min E₁ (x^(1/(20*logLog x))))) u v : ℝ) := by have hv4 : 4 ≤ v := hS4.trans (hSu.trans huv) have hLoss := ford_capped_logLoss hx (by linarith) hv4 hvE hvx have hlow := normal_primes_capped_lower_of_logLoss hn P hS hSF hSu huv hP hLoss have hLLS : 0 ≤ logLog S := logLog_nonneg hS have hLLv : logLog S ≤ logLog v := logLog_mono (by linarith : 1 < S) (hSu.trans huv) have hsqrt : logLog S ≤ Real.sqrt (logLog S*logLog v) := by apply Real.le_sqrt_of_sq_le nlinarith [mul_le_mul_of_nonneg_left hLLv hLLS] have he := (ford_scale_logLoss_le hT hscale).trans hsqrt exact (mul_le_mul_of_nonneg_left (by linarith) (Nat.cast_nonneg P.card)).trans hlow end Erdos416Proof.FordBadFacet end /- Consolidated component: FordSquarefreeChernoff.lean. -/ section open Filter Finset open scoped Classical Topology BigOperators Nat namespace Erdos416Proof.FordBadFacet /-- The exponential-moment bound for an actual finite squarefree family. The threshold R is real; no rounding or factorial estimate is assumed. -/ /- Original line 40277: Erdos416Proof.FordBadFacet.squarefree_reciprocal_chernoff -/ theorem squarefree_reciprocal_chernoff (M P : Finset ℕ) {a R H : ℝ} (ha : 1 ≤ a) (hM : ∀ n ∈ M, Squarefree n ∧ n.primeFactors ⊆ P ∧ R ≤ (ArithmeticFunction.cardFactors n : ℝ)) (hH : (∑ p ∈ P, (1 : ℝ)/p) ≤ H) : (∑ n ∈ M, (n : ℝ)⁻¹) ≤ Real.exp (a*H-R*Real.log a) := by have ha0 : 0 < a := by linarith have hweight : ∀ n ∈ M, a^R*(n : ℝ)⁻¹ ≤ a^ArithmeticFunction.cardFactors n/(n : ℝ) := by intro n hn have hpow := Real.rpow_le_rpow_of_exponent_le ha (hM n hn).2.2 rw [Real.rpow_natCast] at hpow simpa only [div_eq_mul_inv] using mul_le_mul_of_nonneg_right hpow (by positivity : (0 : ℝ) ≤ (n : ℝ)⁻¹) have hsum : a^R*(∑ n ∈ M, (n : ℝ)⁻¹) ≤ Real.exp (a*H) := by calc _ = ∑ n ∈ M, a^R*(n : ℝ)⁻¹ := mul_sum _ _ _ _ ≤ ∑ n ∈ M, a^ArithmeticFunction.cardFactors n/(n : ℝ) := sum_le_sum hweight _ ≤ ∏ p ∈ P, (1+a/(p : ℝ)) := squarefree_omega_weight_sum_le_product M P ha0.le (fun n hn => ⟨(hM n hn).1, (hM n hn).2.1⟩) _ ≤ Real.exp (a*∑ p ∈ P, (1 : ℝ)/p) := finite_prime_weight_product_le_exp P ha0.le _ ≤ _ := Real.exp_le_exp.mpr (mul_le_mul_of_nonneg_left hH ha0.le) calc _ ≤ Real.exp (a*H)/(a^R) := (le_div_iff₀ (Real.rpow_pos_of_pos ha0 R)).mpr (by simpa [mul_comm] using hsum) _ = _ := by rw [Real.rpow_def_of_pos ha0, ← Real.exp_sub]; congr 1; ring /-- Tilt by the interval index itself. This keeps the required linear coefficient and absorbs the cap repair without a factorial-tail split. -/ /- Original line 40302: Erdos416Proof.FordBadFacet.squarefree_reciprocal_interval_bound -/ theorem squarefree_reciprocal_interval_bound (M P : Finset ℕ) {a Δ δ C : ℝ} (ha : 1 ≤ a) (hM : ∀ n ∈ M, Squarefree n ∧ n.primeFactors ⊆ P ∧ a*(Δ-2*δ) ≤ (ArithmeticFunction.cardFactors n : ℝ)) (hH : (∑ p ∈ P, (1 : ℝ)/p) ≤ Δ+C) (hC : C ≤ 2*δ*Real.log a) : (∑ n ∈ M, (n : ℝ)⁻¹) ≤ Real.exp ((a-a*Real.log a)*Δ+4*a*δ*Real.log a) := by apply (squarefree_reciprocal_chernoff M P ha hM hH).trans apply Real.exp_le_exp.mpr nlinarith [mul_le_mul_of_nonneg_left hC (by linarith : 0 ≤ a)] /- Original line 40312: Erdos416Proof.FordBadFacet.finite_factor_image_reciprocal -/ theorem finite_factor_image_reciprocal {ι : Type*} [Fintype ι] (M : Finset ℕ) (f : ℕ → ι → ℕ) (hprod : ∀ n ∈ M, (∏ idx, f n idx) = n) : (∑ n ∈ M, (n : ℝ)⁻¹) ≤ ∏ idx, ∑ k ∈ M.image (fun n => f n idx), (k : ℝ)⁻¹ := by have hinj : Set.InjOn f (M : Set ℕ) := by intro n hn m hm heq rw [← hprod n hn, ← hprod m hm, heq] have hweight : ∀ n ∈ M, (n : ℝ)⁻¹ = ∏ idx, ((f n idx : ℕ) : ℝ)⁻¹ := by intro n hn have h := congrArg (fun n : ℕ => (n : ℝ)⁻¹) (hprod n hn) simpa only [Nat.cast_prod, Finset.prod_inv_distrib] using h.symm calc _ = ∑ n ∈ M, ∏ idx, ((f n idx : ℕ) : ℝ)⁻¹ := sum_congr rfl hweight _ = ∑ b ∈ M.image f, ∏ idx, ((b idx : ℕ) : ℝ)⁻¹ := by rw [sum_image hinj] _ ≤ ∑ b ∈ Fintype.piFinset (fun idx => M.image (fun n => f n idx)), ∏ idx, ((b idx : ℕ) : ℝ)⁻¹ := by apply sum_le_sum_of_subset_of_nonneg · intro b hb obtain ⟨n, hn, rfl⟩ := mem_image.mp hb exact Fintype.mem_piFinset.mpr (fun idx => mem_image.mpr ⟨n, hn, rfl⟩) · intro b _ _ positivity _ = _ := (prod_univ_sum (fun idx => M.image (fun n => f n idx)) (fun _ k => (k : ℝ)⁻¹)).symm /- Original line 40334: Erdos416Proof.FordBadFacet.factor_image_reciprocal_interval_bound -/ theorem factor_image_reciprocal_interval_bound {ι : Type*} [Fintype ι] (M : Finset ℕ) (f : ℕ → ι → ℕ) (P : ι → Finset ℕ) (a Δ δ : ι → ℝ) (C : ℝ) (hprod : ∀ n ∈ M, (∏ idx, f n idx) = n) (ha : ∀ idx, 1 ≤ a idx) (hdata : ∀ n ∈ M, ∀ idx, Squarefree (f n idx) ∧ (f n idx).primeFactors ⊆ P idx ∧ a idx*(Δ idx-2*δ idx) ≤ (ArithmeticFunction.cardFactors (f n idx) : ℝ)) (hH : ∀ idx, (∑ p ∈ P idx, (1 : ℝ)/p) ≤ Δ idx+C) (hC : ∀ idx, C ≤ 2*δ idx*Real.log (a idx)) : (∑ n ∈ M, (n : ℝ)⁻¹) ≤ Real.exp (∑ idx, ((a idx-a idx*Real.log (a idx))*Δ idx+4*a idx*δ idx*Real.log (a idx))) := by apply (finite_factor_image_reciprocal M f hprod).trans calc _ ≤ ∏ idx, Real.exp ((a idx-a idx*Real.log (a idx))*Δ idx+4*a idx*δ idx*Real.log (a idx)) := by apply Finset.prod_le_prod · intro idx _ positivity · intro idx _ apply squarefree_reciprocal_interval_bound _ (P idx) (ha idx) _ (hH idx) (hC idx) intro k hk obtain ⟨n, hn, rfl⟩ := mem_image.mp hk exact hdata n hn idx _ = _ := (Real.exp_sum _ _).symm end Erdos416Proof.FordBadFacet end /- Consolidated component: NextBounds.lean. -/ section open Filter Finset open scoped Classical Topology BigOperators Nat namespace Erdos416Proof.FordSieve /- Original line 40372: Erdos416Proof.FordSieve.intervalFactor_self -/ theorem intervalFactor_self (n : ℕ) (S : ℝ) : intervalFactor n S S = 1 := by unfold intervalFactor primePart apply List.prod_eq_one intro p hp have h := (List.mem_filter.mp hp).2 simp only [decide_eq_true_eq] at h exact ((not_lt_of_ge h.2) h.1).elim /- Original line 40380: Erdos416Proof.FordSieve.intervalFactor_nested -/ theorem intervalFactor_nested (n : ℕ) {S u v z : ℝ} (hSu : S ≤ u) (hvz : v ≤ z) : intervalFactor (intervalFactor n S z) u v = intervalFactor n u v := by unfold intervalFactor rw [primePart_primePart] congr 1 funext p apply propext constructor · exact fun h => h.2 · exact fun h => ⟨⟨hSu.trans_lt h.1, h.2.trans hvz⟩, h⟩ /- Original line 40391: Erdos416Proof.FordSieve.intervalFactor_split -/ theorem intervalFactor_split (n : ℕ) {S u z : ℝ} (hSu : S ≤ u) (huz : u ≤ z) : intervalFactor n S u * intervalFactor n u z = intervalFactor n S z := by have h := primePart_mul_compl (primePart_pos n (fun p => S < (p : ℝ) ∧ (p : ℝ) ≤ z)).ne' (fun p => (p : ℝ) ≤ u) have hleft : primePart (intervalFactor n S z) (fun p => (p : ℝ) ≤ u) = intervalFactor n S u := by unfold intervalFactor rw [primePart_primePart] congr 1 funext p apply propext constructor · exact fun h => ⟨h.1.1, h.2⟩ · exact fun h => ⟨⟨h.1, h.2.trans huz⟩, h.2⟩ have hright : primePart (intervalFactor n S z) (fun p => ¬(p : ℝ) ≤ u) = intervalFactor n u z := by unfold intervalFactor rw [primePart_primePart] congr 1 funext p apply propext constructor · exact fun h => ⟨lt_of_not_ge h.2, h.1.2⟩ · exact fun h => ⟨⟨hSu.trans_lt h.1, h.2⟩, not_le_of_gt h.1⟩ change primePart (intervalFactor n S z) (fun p => (p : ℝ) ≤ u) * primePart (intervalFactor n S z) (fun p => ¬(p : ℝ) ≤ u) = _ at h rwa [hleft, hright] at h /-- Every prime power in the full middle factor belongs to exactly one adjacent half-open interval. Equal consecutive endpoints are allowed. -/ /- Original line 40421: Erdos416Proof.FordSieve.intervalFactor_grid_prod -/ theorem intervalFactor_grid_prod (n : ℕ) (w : ℕ → ℝ) (k : ℕ) (hw : ∀ idx j, idx ≤ j → j ≤ k → w idx ≤ w j) : (∏ idx ∈ range k, intervalFactor n (w idx) (w (idx+1))) = intervalFactor n (w 0) (w k) := by induction k with | zero => simp[Erdos416Proof.FordSieve.intervalFactor_self] | succ k ih => rw [prod_range_succ, ih (fun idx j hij hj => hw idx j hij (by omega))] exact intervalFactor_split n (hw 0 k (by omega) (by omega)) (hw k (k+1) (by omega) le_rfl) /- Original line 40431: Erdos416Proof.FordSieve.intervalFactor_grid_prod_fin -/ theorem intervalFactor_grid_prod_fin (n : ℕ) (w : ℕ → ℝ) (k : ℕ) (hw : ∀ idx j, idx ≤ j → j ≤ k → w idx ≤ w j) : (∏ idx : Fin k, intervalFactor n (w idx.val) (w (idx.val+1))) = intervalFactor n (w 0) (w k) := by rw [Fin.prod_univ_eq_prod_range (fun j : ℕ => intervalFactor n (w j) (w (j+1))) k] exact intervalFactor_grid_prod n w k hw /- Original line 40438: Erdos416Proof.FordSieve.intervalFactor_cardFactors -/ theorem intervalFactor_cardFactors (n : ℕ) (u v : ℝ) : ArithmeticFunction.cardFactors (intervalFactor n u v) = omegaInterval n u v := by unfold intervalFactor omegaInterval rw [primePart_cardFactors] apply List.countP_congr intro p _ simp only [decide_eq_true_eq] /- Original line 40446: Erdos416Proof.FordSieve.intervalFactor_prime_support -/ theorem intervalFactor_prime_support (n : ℕ) (u v : ℝ) : ∀ p ∈ (intervalFactor n u v).primeFactors, u < (p : ℝ) ∧ (p : ℝ) ≤ v := by intro p hp have hmem : p ∈ (intervalFactor n u v).primeFactorsList := by simpa only [Nat.primeFactors, List.mem_toFinset] using hp exact ((mem_primeFactorsList_primePart n p _).mp hmem).2 /- Original line 40453: Erdos416Proof.FordSieve.intervalFactor_squarefree -/ theorem intervalFactor_squarefree {n : ℕ} (hn : n ≠ 0) {S u v : ℝ} (hSq : NoLargePrimeSquare n S) (hSu : S ≤ u) : Squarefree (intervalFactor n u v) := primePart_squarefree_of_no_large_square hn hSq _ (fun _ _ h => hSu.trans_lt h.1) end Erdos416Proof.FordSieve namespace Erdos416Proof.FordBadFacet open Erdos416Proof.FordSieve /-- Keep the Mertens error explicit, so a cell with tilt exactly one is allowed and no artificial positive logarithmic slack is required. -/ /- Original line 40465: Erdos416Proof.FordBadFacet.factor_image_reciprocal_chernoff_bound -/ theorem factor_image_reciprocal_chernoff_bound {ι : Type*} [Fintype ι] (M : Finset ℕ) (f : ℕ → ι → ℕ) (P : ι → Finset ℕ) (a Δ δ : ι → ℝ) (B : ℝ) (hprod : ∀ n ∈ M, (∏ idx, f n idx) = n) (ha : ∀ idx, 1 ≤ a idx) (hdata : ∀ n ∈ M, ∀ idx, Squarefree (f n idx) ∧ (f n idx).primeFactors ⊆ P idx ∧ a idx*(Δ idx-2*δ idx) ≤ (ArithmeticFunction.cardFactors (f n idx) : ℝ)) (hH : ∀ idx, (∑ p ∈ P idx, (1 : ℝ)/p) ≤ Δ idx+B) : (∑ n ∈ M, (n : ℝ)⁻¹) ≤ Real.exp (∑ idx, ((a idx-a idx*Real.log (a idx))*Δ idx+2*a idx*δ idx*Real.log (a idx)+a idx*B)) := by apply (finite_factor_image_reciprocal M f hprod).trans calc _ ≤ ∏ idx, Real.exp ((a idx-a idx*Real.log (a idx))*Δ idx+2*a idx*δ idx*Real.log (a idx)+a idx*B) := by apply Finset.prod_le_prod · intro idx _ positivity · intro idx _ have h := squarefree_reciprocal_chernoff (M.image (fun n => f n idx)) (P idx) (ha idx) (R := a idx*(Δ idx-2*δ idx)) (by intro k hk obtain ⟨n, hn, rfl⟩ := mem_image.mp hk exact hdata n hn idx) (hH idx) have heq : a idx*(Δ idx+B)-(a idx*(Δ idx-2*δ idx))*Real.log (a idx) = (a idx-a idx*Real.log (a idx))*Δ idx+2*a idx*δ idx*Real.log (a idx)+a idx*B := by ring rwa [heq] at h _ = _ := (Real.exp_sum _ _).symm /-- The Mertens error and exact prime-factor reconstruction are supplied here for the actual interval-factor images of a finite family. -/ /- Original line 40492: Erdos416Proof.FordBadFacet.exists_actual_interval_reciprocal_bound -/ theorem exists_actual_interval_reciprocal_bound : ∃ B : ℝ, 0 ≤ B ∧ ∀ (k : ℕ) (w : ℕ → ℝ) (a δ : Fin k → ℝ) (G : Finset ℕ), 2 ≤ w 0 → (∀ idx j, idx ≤ j → j ≤ k → w idx ≤ w j) → (∀ idx, 1 ≤ a idx) → (∀ n ∈ G, n ≠ 0 ∧ NoLargePrimeSquare n (w 0)) → (∀ n ∈ G, ∀ idx : Fin k, a idx*(logLog (w (idx.val+1))-logLog (w idx.val)-2*δ idx) ≤ (omegaInterval n (w idx.val) (w (idx.val+1)) : ℝ)) → (∑ m ∈ G.image (fun n => intervalFactor n (w 0) (w k)), (m : ℝ)⁻¹) ≤ Real.exp (∑ idx : Fin k, ((a idx-a idx*Real.log (a idx))* (logLog (w (idx.val+1))-logLog (w idx.val))+2*a idx*δ idx*Real.log (a idx)+a idx*B)) := by obtain ⟨B, hB⟩ := prime_reciprocal_mertens refine ⟨2*|B|, by positivity, ?_⟩ intro k w a δ G hw0 hw ha hSq hlow let M := G.image (fun n => intervalFactor n (w 0) (w k)) let f : ℕ → Fin k → ℕ := fun n idx => intervalFactor n (w idx.val) (w (idx.val+1)) let P : Fin k → Finset ℕ := fun idx => (Nat.primesLE ⌊w (idx.val+1)⌋₊).filter (fun p : ℕ => w idx.val < (p : ℝ) ∧ (p : ℝ) ≤ w (idx.val+1)) let Δ : Fin k → ℝ := fun idx => logLog (w (idx.val+1))-logLog (w idx.val) have hnested (n : ℕ) (idx : Fin k) : f (intervalFactor n (w 0) (w k)) idx = intervalFactor n (w idx.val) (w (idx.val+1)) := intervalFactor_nested n (hw 0 idx.val (by omega) (by omega)) (hw (idx.val+1) k (by omega) le_rfl) have hprod : ∀ n ∈ M, (∏ idx, f n idx) = n := by intro n hn obtain ⟨m, hm, rfl⟩ := mem_image.mp hn change (∏ idx : Fin k, intervalFactor (intervalFactor m (w 0) (w k)) (w idx.val) (w (idx.val+1))) = _ rw [intervalFactor_grid_prod_fin _ w k hw, intervalFactor_nested _ le_rfl le_rfl] apply factor_image_reciprocal_chernoff_bound M f P a Δ δ (2*|B|) hprod ha · intro m hm idx obtain ⟨n, hn, rfl⟩ := mem_image.mp hm rw [hnested] refine ⟨intervalFactor_squarefree (hSq n hn).1 (hSq n hn).2 (hw 0 idx.val (by omega) (by omega)), ?_, ?_⟩ · intro p hp have hs := intervalFactor_prime_support n (w idx.val) (w (idx.val+1)) p hp exact mem_filter.mpr ⟨Nat.mem_primesLE.mpr ⟨Nat.le_floor hs.2, Nat.prime_of_mem_primeFactors hp⟩, hs⟩ · rw [intervalFactor_cardFactors] exact hlow n hn idx · intro idx have h := (abs_le.mp (prime_interval_reciprocal_error hB (hw0.trans (hw 0 idx.val (by omega) (by omega))) (hw idx.val (idx.val+1) (by omega) (by omega)) le_rfl)).2 change (∑ p ∈ P idx, (1 : ℝ)/p)-Δ idx ≤ 2*|B| at h linarith /-- A uniform exceptional-integer count combining the interval sieve with the actual adjacent-interval reciprocal bound. -/ /- Original line 40543: Erdos416Proof.FordBadFacet.exists_actual_interval_family_bound -/ theorem exists_actual_interval_family_bound : ∃ C B : ℝ, 0 < C ∧ 0 ≤ B ∧ ∀ (x : ℝ) (k : ℕ) (w : ℕ → ℝ) (a δ : Fin k → ℝ) (G : Finset ℕ), 1 < x → 1 ≤ logLog x → 2 ≤ w 0 → (∀ idx j, idx ≤ j → j ≤ k → w idx ≤ w j) → w k ≤ x^(1/(20*logLog x)) → (∀ idx, 1 ≤ a idx) → (∀ n ∈ G, 0 < n ∧ (n : ℝ) ≤ x) → (∀ n ∈ G, (ArithmeticFunction.cardFactors n : ℝ) ≤ 5*logLog x) → (∀ n ∈ G, NoLargePrimeSquare n (w 0)) → (∀ n ∈ G, ∀ idx : Fin k, a idx*(logLog (w (idx.val+1))-logLog (w idx.val)-2*δ idx) ≤ (omegaInterval n (w idx.val) (w (idx.val+1)) : ℝ)) → (G.card : ℝ) ≤ C*x*Real.log (w 0)/Real.log (w k)* Real.exp (∑ idx : Fin k, ((a idx-a idx*Real.log (a idx))* (logLog (w (idx.val+1))-logLog (w idx.val))+2*a idx*δ idx*Real.log (a idx)+a idx*B)) := by obtain ⟨C, hC, hcount⟩ := exists_interval_factor_image_bound obtain ⟨B, hB, hrec⟩ := exists_actual_interval_reciprocal_bound refine ⟨C, B, hC, hB, ?_⟩ intro x k w a δ G hx hT hw0 hw hcut ha hG hOmega hSq hlow have hwk : w 0 ≤ w k := hw 0 k (by omega) le_rfl have hmain := hcount x (w 0) (w k) hx hT hw0 hwk hcut G hG hOmega apply hmain.trans apply mul_le_mul_of_nonneg_left (hrec k w a δ G hw0 hw ha (fun n hn => ⟨(hG n hn).1.ne', hSq n hn⟩) hlow) have hx0 : 0 < x := by linarith have hlog0 : 0 ≤ Real.log (w 0) := Real.log_nonneg (by linarith) have hlogk : 0 < Real.log (w k) := Real.log_pos (by linarith) positivity /-- Normal primes from an actual totient preimage give exactly the interval-count hypotheses used above. The cap repairs both the power cutoff and the difference between p and p-1. -/ /- Original line 40575: Erdos416Proof.FordBadFacet.normal_preimage_grid_lower -/ theorem normal_preimage_grid_lower (N : ℕ) (hN : 0 < N) (x : ℝ) (k : ℕ) (w : ℕ → ℝ) (P : Fin k → Finset ℕ) (hx : 1 < x) (hT : 20 ≤ logLog x) (hS : Real.exp 1 ≤ w 0) (hS4 : 4 ≤ w 0) (hscale : Real.exp ((logLog x)^36) ≤ w 0) (hw : ∀ idx j, idx ≤ j → j ≤ k → w idx ≤ w j) (hcut : w k ≤ x^(1/(20*logLog x))) (hP : ∀ idx, ∀ p ∈ P idx, SNormal (w 0) p ∧ p ∣ N ∧ w (idx.val+1) ≤ (p : ℝ)) : ∀ idx : Fin k, ((P idx).card : ℝ)*(logLog (w (idx.val+1))-logLog (w idx.val)- 2*Real.sqrt (logLog (w 0)*logLog (w (idx.val+1)))) ≤ (omegaInterval N.totient (w idx.val) (w (idx.val+1)) : ℝ) := by intro idx have hT0 : 0 < logLog x := by linarith have hfrac : 1/(20*logLog x) ≤ (1 : ℝ) := (div_le_iff₀ (by positivity)).mpr (by linarith) have hwkx : w k ≤ x := by calc _ ≤ x^(1/(20*logLog x)) := hcut _ ≤ x^(1 : ℝ) := Real.rpow_le_rpow_of_exponent_le hx.le hfrac _ = x := Real.rpow_one _ have hmin : min (w k) (x^(1/(20*logLog x))) = w k := min_eq_left hcut have hsu := hw 0 idx.val (by omega) (by omega) have huv := hw idx.val (idx.val+1) (by omega) (by omega) have hvk := hw (idx.val+1) k (by omega) le_rfl have hbound := normal_primes_ford_capped_lower (E₁ := w k) hN (P idx) hx hT hS hS4 hscale (by rw [hmin]; exact hw 0 k (by omega) le_rfl) hsu huv hvk (hvk.trans hwkx) (hP idx) rw [hmin] at hbound have heq := omegaInterval_primePart_eq_of_contains N.totient (fun q => w 0 < (q : ℝ) ∧ (q : ℝ) ≤ w k) (w idx.val) (w (idx.val+1)) (fun q _ hq => ⟨hsu.trans_lt hq.1, hq.2.trans hvk⟩) rwa [heq] at hbound end Erdos416Proof.FordBadFacet end /- Consolidated component: EndpointReduction.lean. -/ section open Filter Finset open scoped Topology BigOperators Classical namespace Erdos416Proof.Simplified /-- An error measured relative to the larger count controls its quotient by the smaller count. No upper bound on that quotient is assumed. -/ /- Original line 40625: Erdos416Proof.Simplified.quotient_error_of_relative_doubling_error -/ theorem quotient_error_of_relative_doubling_error {v w δ : ℝ} (hv : 0 < v) (hδ : 0 ≤ δ) (hsmall : δ ≤ 1 / 2) (herror : |w - 2 * v| ≤ δ * w) : |w / v - 2| ≤ 4 * δ := by have hwv : w ≤ 4 * v := by by_cases hw : 0 ≤ w · have hupper := (abs_le.mp herror).2 have := mul_le_mul_of_nonneg_right hsmall hw nlinarith · linarith have herr : |w - 2 * v| ≤ 4 * δ * v := by have := mul_le_mul_of_nonneg_left hwv hδ nlinarith have heq : w / v - 2 = (w - 2 * v) / v := by field_simp rw [heq, abs_div, abs_of_pos hv] exact (div_le_iff₀ hv).mpr herr /-- Vanishing relative doubling errors imply the desired quotient limit. -/ /- Original line 40644: Erdos416Proof.Simplified.doubling_of_eventual_relative_error -/ theorem doubling_of_eventual_relative_error (W : ℝ → ℝ) (hpos : ∀ᶠ x in atTop, 0 < W x) (herror : ∀ δ : ℝ, 0 < δ → ∀ᶠ x in atTop, |W (2 * x) - 2 * W x| ≤ δ * W (2 * x)) : Tendsto (fun x => W (2 * x) / W x) atTop (𝓝 2) := by apply Metric.tendsto_nhds.mpr intro ε hε let δ : ℝ := min (1 / 2) (ε / 8) have hδ : 0 < δ := lt_min (by norm_num) (by positivity) have hsmall : δ ≤ 1 / 2 := min_le_left _ _ have hεbound : 4 * δ < ε := by have : δ ≤ ε / 8 := min_le_right _ _ linarith filter_upwards [hpos, herror δ hδ] with x hx he rw [Real.dist_eq] exact (quotient_error_of_relative_doubling_error hx hδ.le hsmall he).trans_lt hεbound end Erdos416Proof.Simplified namespace Erdos416Proof.Simplified /-- A finite-pair endpoint for the actual totient counting function. The finite family and its map may depend on both the accuracy and the endpoint. The two quantitative hypotheses are the missing-value plus excess error, and the pair doubling error, each measured relative to `V (2 * x)`. -/ /- Original line 40669: Erdos416Proof.Simplified.doubling_of_finite_counting_contracts -/ theorem doubling_of_finite_counting_contracts {α : Type*} (hcontracts : ∀ δ : ℝ, 0 < δ → ∀ᶠ x : ℝ in atTop, ∃ (P : Finset α) (f : α → ℕ), (∀ a ∈ P, f a ∈ totientsUpTo (2 * x)) ∧ ((V (2 * x) - (P.image f).card) + ((P.card : ℝ) - (P.image f).card) ≤ δ * V (2 * x)) ∧ |(P.card : ℝ) - 2 * (P.filter (fun a => f a ∈ totientsUpTo x)).card| ≤ δ * V (2 * x)) : Tendsto (fun x => V (2 * x) / V x) atTop (𝓝 2) := by apply doubling_of_eventual_relative_error V eventually_V_pos intro δ hδ filter_upwards [hcontracts (δ / 2) (by positivity), eventually_ge_atTop (0 : ℝ)] with x hx hx0 obtain ⟨P, f, hmap, herrors, himbalance⟩ := hx have hsub : totientsUpTo x ⊆ totientsUpTo (2 * x) := totientsUpTo_mono (by linarith) have hfinite : |V (2 * x) - 2 * V x| ≤ |(P.card : ℝ) - 2 * (P.filter (fun a => f a ∈ totientsUpTo x)).card| + (V (2 * x) - (P.image f).card) + ((P.card : ℝ) - (P.image f).card) := by convert finite_counting_error P (totientsUpTo (2 * x)) (totientsUpTo x) f hsub hmap using 1 <;> simp only [V] congr! linarith /-- The manuscript's abstract endpoint, with all analytic input retained as explicit assumptions. Missing values may have a fixed arbitrarily small relative error. Excess representations are little-o of `V (2 * x)`, while pair imbalance need only be little-o of the number of pairs. -/ /- Original line 40697: Erdos416Proof.Simplified.doubling_of_finite_counting_littleO -/ theorem doubling_of_finite_counting_littleO {α : Type*} (hcontracts : ∀ ε : ℝ, 0 < ε → ε < 1 / 2 → ∃ (P : ℝ → Finset α) (f : ℝ → α → ℕ) (r : ℝ → ℝ), (∀ᶠ x : ℝ in atTop, (∀ a ∈ P x, f x a ∈ totientsUpTo (2 * x)) ∧ V (2 * x) - ((P x).image (f x)).card ≤ ε * V (2 * x) + r x) ∧ r =o[atTop] (fun x => V (2 * x)) ∧ (fun x => ((P x).card : ℝ) - ((P x).image (f x)).card) =o[atTop] (fun x => V (2 * x)) ∧ (fun x => ((P x).card : ℝ) - 2 * ((P x).filter (fun a => f x a ∈ totientsUpTo x)).card) =o[atTop] (fun x => ((P x).card : ℝ))) : Tendsto (fun x => V (2 * x) / V x) atTop (𝓝 2) := by apply doubling_of_finite_counting_contracts intro δ hδ let ε : ℝ := min (δ / 4) (1 / 4) have hε : 0 < ε := lt_min (by positivity) (by norm_num) have hεsmall : ε < 1 / 2 := lt_of_le_of_lt (min_le_right _ _) (by norm_num) have hεδ : ε ≤ δ / 4 := min_le_left _ _ obtain ⟨P, f, r, hmap, hr, hE, hD⟩ := hcontracts ε hε hεsmall let η : ℝ := min (δ / 8) 1 have hη : 0 < η := lt_min (by positivity) (by norm_num) have hηδ : η ≤ δ / 8 := min_le_left _ _ have hηone : η ≤ 1 := min_le_right _ _ filter_upwards [hmap, hr.def (by positivity : 0 < δ / 8), hE.def hη, hD.def (by positivity : 0 < δ / 2)] with x hx hrx hEx hDx have hV := V_nonneg (2 * x) have hP : (0 : ℝ) ≤ (P x).card := Nat.cast_nonneg _ simp only [Real.norm_eq_abs, abs_of_nonneg hV] at hrx hEx simp only [Real.norm_eq_abs, abs_of_nonneg hP] at hDx have hEr : ((P x).card : ℝ) - ((P x).image (f x)).card ≤ η * V (2 * x) := (le_abs_self _).trans hEx have himage : (((P x).image (f x)).card : ℝ) ≤ V (2 * x) := by unfold V exact_mod_cast Finset.card_le_card (Finset.image_subset_iff.mpr hx.1) have hcard : ((P x).card : ℝ) ≤ 2 * V (2 * x) := by have := mul_le_mul_of_nonneg_right hηone hV linarith refine ⟨P x, f x, hx.1, ?_, ?_⟩ · have hrupper : r x ≤ δ / 8 * V (2 * x) := (le_abs_self _).trans hrx have heps := mul_le_mul_of_nonneg_right hεδ hV have heta := mul_le_mul_of_nonneg_right hηδ hV have hδV : 0 ≤ δ * V (2 * x) := mul_nonneg hδ.le hV linarith [hx.2] · have := mul_le_mul_of_nonneg_left hcard (by positivity : 0 ≤ δ / 2) nlinarith end Erdos416Proof.Simplified end /- Consolidated component: BadFacetFamilies.lean. -/ section open Filter Finset open scoped Classical Topology BigOperators Nat namespace Erdos416Proof.FordBadFacet /-- The finite set of eligible prime divisors of an actual preimage. -/ /- Original line 40761: Erdos416Proof.FordBadFacet.normalLargePrimeDivisors -/ noncomputable def normalLargePrimeDivisors (N : ℕ) (S v : ℝ) : Finset ℕ := N.primeFactors.filter (fun p => SNormal S p ∧ v ≤ (p : ℝ)) /-- A record fixes the thresholds and the required numbers of prime divisors. The dimension can vary between records in the same finite union. -/ /- Original line 40766: Erdos416Proof.FordBadFacet.NormalGridRecord -/ structure NormalGridRecord where dimension : ℕ endpoint : ℕ → ℝ multiplicity : Fin dimension → ℕ /-- These are explicit numerical conditions on a record, independent of any counting conclusion or choice of totient preimage. -/ /- Original line 40773: Erdos416Proof.FordBadFacet.NormalGridAdmissible -/ structure NormalGridAdmissible (x : ℝ) (r : NormalGridRecord) : Prop where large_x : 1 < x large_logLog : 20 ≤ logLog x normality_scale : Real.exp 1 ≤ r.endpoint 0 four_le_scale : 4 ≤ r.endpoint 0 power_scale : Real.exp ((logLog x)^36) ≤ r.endpoint 0 increasing : ∀ idx j, idx ≤ j → j ≤ r.dimension → r.endpoint idx ≤ r.endpoint j cutoff : r.endpoint r.dimension ≤ x^(1/(20*logLog x)) positive_counts : ∀ idx, 0 < r.multiplicity idx /-- Membership requires an actual preimage with sufficiently many eligible prime divisors. Existence quantification covers bad alternative preimages as well as any preferred preimage, without counting their multiplicity. -/ /- Original line 40786: Erdos416Proof.FordBadFacet.NormalGridWitness -/ def NormalGridWitness (r : NormalGridRecord) (m : ℕ) : Prop := ∃ N : ℕ, 0 < N ∧ N.totient = m ∧ ∀ idx : Fin r.dimension, r.multiplicity idx ≤ (normalLargePrimeDivisors N (r.endpoint 0) (r.endpoint (idx.val+1))).card /-- A distinct tuple of actual normal prime divisors supplies the witness; there is no prime-factor-count estimate among the hypotheses. -/ /- Original line 40793: Erdos416Proof.FordBadFacet.NormalGridWitness.of_prime_tuple -/ theorem NormalGridWitness.of_prime_tuple {r : NormalGridRecord} {N L : ℕ} (hN : 0 < N) (q : Fin L → ℕ) (hinj : Function.Injective q) (hq : ∀ j, SNormal (r.endpoint 0) (q j) ∧ q j ∣ N) (hd : ∀ idx, r.multiplicity idx ≤ L) (hlarge : ∀ idx, ∀ j : Fin (r.multiplicity idx), r.endpoint (idx.val+1) ≤ (q (Fin.castLE (hd idx) j) : ℝ)) : NormalGridWitness r N.totient := by refine ⟨N, hN, rfl, ?_⟩ intro idx let f : Fin (r.multiplicity idx) → ℕ := fun j => q (Fin.castLE (hd idx) j) have hf : Function.Injective f := by intro j l hjl apply Fin.ext exact congrArg (fun a : Fin L => a.val) (hinj hjl) have hcard : (univ.image f).card = r.multiplicity idx := by rw [card_image_of_injective _ hf, card_univ, Fintype.card_fin] rw [← hcard] apply card_le_card intro p hp obtain ⟨j, _, rfl⟩ := mem_image.mp hp refine mem_filter.mpr ⟨?_, (hq (Fin.castLE (hd idx) j)).1, hlarge idx j⟩ exact Nat.mem_primeFactors.mpr ⟨(hq (Fin.castLE (hd idx) j)).1.1, (hq (Fin.castLE (hd idx) j)).2, hN.ne'⟩ /-- For a decreasing tuple, each cell needs only the threshold at its last required prime. This is the form used by coordinate boxes. -/ /- Original line 40819: Erdos416Proof.FordBadFacet.NormalGridWitness.of_antitone_prime_tuple -/ theorem NormalGridWitness.of_antitone_prime_tuple {r : NormalGridRecord} {N L : ℕ} (hN : 0 < N) (q : Fin L → ℕ) (hinj : Function.Injective q) (hanti : Antitone (fun j => (q j : ℝ))) (hq : ∀ j, SNormal (r.endpoint 0) (q j) ∧ q j ∣ N) (hpos : ∀ idx, 0 < r.multiplicity idx) (hd : ∀ idx, r.multiplicity idx ≤ L) (hthreshold : ∀ idx, r.endpoint (idx.val+1) ≤ (q ⟨r.multiplicity idx-1, by have := hpos idx; have := hd idx; omega⟩ : ℝ)) : NormalGridWitness r N.totient := by apply NormalGridWitness.of_prime_tuple hN q hinj hq hd intro idx j apply (hthreshold idx).trans apply hanti change j.val ≤ r.multiplicity idx-1 omega /-- Actual distinct totient values after the explicit square and factor-count pruning. No interval-factor lower bound is part of this definition. -/ /- Original line 40836: Erdos416Proof.FordBadFacet.normalGridValues -/ noncomputable def normalGridValues (x : ℝ) (r : NormalGridRecord) : Finset ℕ := (totientsUpTo x).filter (fun m => NoLargePrimeSquare m (r.endpoint 0) ∧ (ArithmeticFunction.cardFactors m : ℝ) ≤ 5*logLog x ∧ NormalGridWitness r m) /- Original line 40841: Erdos416Proof.FordBadFacet.normalGridValues_subset_totients -/ theorem normalGridValues_subset_totients (x : ℝ) (r : NormalGridRecord) : normalGridValues x r ⊆ totientsUpTo x := filter_subset _ _ /- Original line 40844: Erdos416Proof.FordBadFacet.mem_normalGridValues_of_preimage -/ theorem mem_normalGridValues_of_preimage {x : ℝ} {r : NormalGridRecord} {N : ℕ} (hx : 0 ≤ x) (hN : 0 < N) (hmx : (N.totient : ℝ) ≤ x) (hSq : NoLargePrimeSquare N.totient (r.endpoint 0)) (hOmega : (ArithmeticFunction.cardFactors N.totient : ℝ) ≤ 5*logLog x) (hcount : ∀ idx : Fin r.dimension, r.multiplicity idx ≤ (normalLargePrimeDivisors N (r.endpoint 0) (r.endpoint (idx.val+1))).card) : N.totient ∈ normalGridValues x r := by apply mem_filter.mpr exact ⟨(mem_totientsUpTo hx).mpr ⟨Nat.totient_pos.mpr hN, hmx, N, hN, rfl⟩, hSq, hOmega, N, hN, rfl, hcount⟩ /-- Select prescribed-size subsets of the actual eligible divisors, and derive the interval inequalities from capped normality. -/ /- Original line 40857: Erdos416Proof.FordBadFacet.NormalGridWitness.interval_lower -/ theorem NormalGridWitness.interval_lower {x : ℝ} {r : NormalGridRecord} {m : ℕ} (ha : NormalGridAdmissible x r) (hm : NormalGridWitness r m) : ∀ idx : Fin r.dimension, (r.multiplicity idx : ℝ)*(logLog (r.endpoint (idx.val+1))-logLog (r.endpoint idx.val)- 2*Real.sqrt (logLog (r.endpoint 0)*logLog (r.endpoint (idx.val+1)))) ≤ (omegaInterval m (r.endpoint idx.val) (r.endpoint (idx.val+1)) : ℝ) := by obtain ⟨N, hN, hNm, hcount⟩ := hm choose P hsub hcard using fun idx => Finset.exists_subset_card_eq (hcount idx) have hnormal := normal_preimage_grid_lower N hN x r.dimension r.endpoint P ha.large_x ha.large_logLog ha.normality_scale ha.four_le_scale ha.power_scale ha.increasing ha.cutoff (by intro idx p hp obtain ⟨hfactor, hnormal, hlarge⟩ := mem_filter.mp (hsub idx hp) exact ⟨hnormal, (Nat.mem_primeFactors.mp hfactor).2.1, hlarge⟩) intro idx have hi := hnormal idx rwa [hNm, hcard idx] at hi /- Original line 40875: Erdos416Proof.FordBadFacet.normalGridExponent -/ noncomputable def normalGridExponent (B : ℝ) (r : NormalGridRecord) : ℝ := ∑ idx : Fin r.dimension, (((r.multiplicity idx : ℝ)-(r.multiplicity idx : ℝ)*Real.log (r.multiplicity idx))* (logLog (r.endpoint (idx.val+1))-logLog (r.endpoint idx.val))+ 2*(r.multiplicity idx : ℝ)*Real.sqrt (logLog (r.endpoint 0)* logLog (r.endpoint (idx.val+1)))*Real.log (r.multiplicity idx)+(r.multiplicity idx : ℝ)*B) /- Original line 40882: Erdos416Proof.FordBadFacet.normalGridWeight -/ noncomputable def normalGridWeight (B : ℝ) (r : NormalGridRecord) : ℝ := Real.log (r.endpoint 0)/Real.log (r.endpoint r.dimension)*Real.exp (normalGridExponent B r) /-- Absolute constants apply to the actual existential-preimage family. All interval lower estimates and prime selections have been discharged. -/ /- Original line 40887: Erdos416Proof.FordBadFacet.exists_normalGridValues_bound -/ theorem exists_normalGridValues_bound : ∃ C B : ℝ, 0 < C ∧ 0 ≤ B ∧ ∀ (x : ℝ) (r : NormalGridRecord), NormalGridAdmissible x r → ((normalGridValues x r).card : ℝ) ≤ C*x*normalGridWeight B r := by obtain ⟨C, B, hC, hB, hbound⟩ := exists_actual_interval_family_bound refine ⟨C, B, hC, hB, ?_⟩ intro x r ha have hx0 : 0 ≤ x := by linarith [ha.large_x] have hdata (m : ℕ) (hm : m ∈ normalGridValues x r) : 0 < m ∧ (m : ℝ) ≤ x ∧ NoLargePrimeSquare m (r.endpoint 0) ∧ (ArithmeticFunction.cardFactors m : ℝ) ≤ 5*logLog x ∧ NormalGridWitness r m := by obtain ⟨hmval, hSq, hOmega, hwit⟩ := mem_filter.mp hm obtain ⟨hmpos, hmx, _⟩ := (mem_totientsUpTo hx0).mp hmval exact ⟨hmpos, hmx, hSq, hOmega, hwit⟩ have h := hbound x r.dimension r.endpoint (fun idx => (r.multiplicity idx : ℝ)) (fun idx => Real.sqrt (logLog (r.endpoint 0)*logLog (r.endpoint (idx.val+1)))) (normalGridValues x r) ha.large_x (by linarith [ha.large_logLog]) (by linarith [ha.four_le_scale]) ha.increasing ha.cutoff (fun idx => by exact_mod_cast ha.positive_counts idx) (fun m hm => ⟨(hdata m hm).1, (hdata m hm).2.1⟩) (fun m hm => (hdata m hm).2.2.2.1) (fun m hm => (hdata m hm).2.2.1) (fun m hm => NormalGridWitness.interval_lower ha ((hdata m hm).2.2.2.2)) apply h.trans_eq unfold normalGridWeight normalGridExponent ring /-- Arbitrarily overlapping preimage families are united as sets of values; no injective assignment of preimages or disjointness assumption is needed. -/ /- Original line 40915: Erdos416Proof.FordBadFacet.exists_normalGridUnion_bound -/ theorem exists_normalGridUnion_bound : ∃ C B : ℝ, 0 < C ∧ 0 ≤ B ∧ ∀ (x : ℝ) (R : Finset NormalGridRecord), (∀ r ∈ R, NormalGridAdmissible x r) → (((R.biUnion (normalGridValues x)).card : ℕ) : ℝ) ≤ C*x*∑ r ∈ R, normalGridWeight B r := by obtain ⟨C, B, hC, hB, hbound⟩ := exists_normalGridValues_bound refine ⟨C, B, hC, hB, ?_⟩ intro x R ha calc _ ≤ ∑ r ∈ R, ((normalGridValues x r).card : ℝ) := by exact_mod_cast (Finset.card_biUnion_le (s := R) (t := normalGridValues x)) _ ≤ ∑ r ∈ R, C*x*normalGridWeight B r := sum_le_sum fun r hr => hbound x r (ha r hr) _ = _ := (mul_sum _ _ _).symm /-- Membership in finitely many records can depend on any bad alternative preimage. The family of distinct values is charged only once on the left. -/ /- Original line 40932: Erdos416Proof.FordBadFacet.exists_finitely_recorded_preimage_bound -/ theorem exists_finitely_recorded_preimage_bound : ∃ C B : ℝ, 0 < C ∧ 0 ≤ B ∧ ∀ (x : ℝ) (R : Finset NormalGridRecord) (G : Finset ℕ), (∀ r ∈ R, NormalGridAdmissible x r) → (∀ m ∈ G, ∃ r ∈ R, ∃ N : ℕ, 0 < N ∧ N.totient = m ∧ (m : ℝ) ≤ x ∧ NoLargePrimeSquare m (r.endpoint 0) ∧ (ArithmeticFunction.cardFactors m : ℝ) ≤ 5*logLog x ∧ ∀ idx : Fin r.dimension, r.multiplicity idx ≤ (normalLargePrimeDivisors N (r.endpoint 0) (r.endpoint (idx.val+1))).card) → (G.card : ℝ) ≤ C*x*∑ r ∈ R, normalGridWeight B r := by obtain ⟨C, B, hC, hB, hbound⟩ := exists_normalGridUnion_bound refine ⟨C, B, hC, hB, ?_⟩ intro x R G ha hG have hsub : G ⊆ R.biUnion (normalGridValues x) := by intro m hm obtain ⟨r, hr, N, hN, hNm, hmx, hSq, hOmega, hcount⟩ := hG m hm apply mem_biUnion.mpr refine ⟨r, hr, ?_⟩ subst m exact mem_normalGridValues_of_preimage (by linarith [(ha r hr).large_x]) hN hmx hSq hOmega hcount exact (Nat.cast_le.mpr (card_le_card hsub)).trans (hbound x R ha) end Erdos416Proof.FordBadFacet end /- Consolidated component: FacetGrid.lean. -/ section open Finset open scoped Classical BigOperators namespace Erdos416Proof.FordBadFacet /-- Round a nonnegative coordinate down to a fixed mesh. -/ /- Original line 40971: Erdos416Proof.FordBadFacet.lowerGridPoint -/ noncomputable def lowerGridPoint (h x : ℝ) : ℝ := h * (⌊x / h⌋₊ : ℝ) /- Original line 40973: Erdos416Proof.FordBadFacet.lowerGridPoint_bounds -/ theorem lowerGridPoint_bounds {h x : ℝ} (hh : 0 < h) (hx : 0 ≤ x) : 0 ≤ lowerGridPoint h x ∧ lowerGridPoint h x ≤ x ∧ x - h ≤ lowerGridPoint h x := by have hf := Nat.floor_le (div_nonneg hx hh.le) have hg := Nat.lt_floor_add_one (x / h) have hmul := mul_le_mul_of_nonneg_left hf hh.le have hmul' := mul_lt_mul_of_pos_left hg hh have hc : h * (x / h) = x := by field_simp rw [hc] at hmul hmul' dsimp [lowerGridPoint] exact ⟨mul_nonneg hh.le (Nat.cast_nonneg _), hmul, by nlinarith⟩ /- Original line 40985: Erdos416Proof.FordBadFacet.lowerGridPoint_mono -/ theorem lowerGridPoint_mono {h : ℝ} (hh : 0 < h) : Monotone (lowerGridPoint h) := by intro x y hxy exact mul_le_mul_of_nonneg_left (Nat.cast_le.mpr (Nat.floor_mono (div_le_div_of_nonneg_right hxy hh.le))) hh.le /-- The entire finite mesh, before imposing ordering or a facet condition. -/ /- Original line 40991: Erdos416Proof.FordBadFacet.coordinateGrid -/ noncomputable def coordinateGrid (k : ℕ) (h X : ℝ) : Finset (Fin k → ℝ) := Finset.univ.image (fun u : Fin k → Fin (⌊X / h⌋₊ + 1) => fun idx => h * ((u idx).val : ℝ)) /- Original line 40995: Erdos416Proof.FordBadFacet.coordinateGrid_card_le -/ theorem coordinateGrid_card_le (k : ℕ) (h X : ℝ) : (coordinateGrid k h X).card ≤ (⌊X / h⌋₊ + 1)^k := by calc _ ≤ (Finset.univ : Finset (Fin k → Fin (⌊X / h⌋₊ + 1))).card := Finset.card_image_le _ = _ := by simp /- Original line 41002: Erdos416Proof.FordBadFacet.lowerGridPoint_mem_grid -/ theorem lowerGridPoint_mem_grid {k : ℕ} {h X : ℝ} (hh : 0 < h) (x : Fin k → ℝ) (hX : ∀ idx, x idx ≤ X) : (fun idx => lowerGridPoint h (x idx)) ∈ coordinateGrid k h X := by let u : Fin k → Fin (⌊X / h⌋₊ + 1) := fun idx => ⟨⌊x idx / h⌋₊, Nat.lt_succ_of_le (Nat.floor_mono (div_le_div_of_nonneg_right (hX idx) hh.le))⟩ exact Finset.mem_image.mpr ⟨u, Finset.mem_univ _, rfl⟩ /-- Scaling the vector first avoids an upper-facet loss when the original weighted sum is arbitrarily far above the threshold. -/ /- Original line 41012: Erdos416Proof.FordBadFacet.exists_scaled_facet -/ theorem exists_scaled_facet {k : ℕ} (a x : Fin k → ℝ) {t : ℝ} (ht : 0 < t) (hx : ∀ idx, 0 ≤ x idx) (hxmono : Antitone x) (hfacet : t ≤ ∑ idx, a idx * x idx) : ∃ u : Fin k → ℝ, Antitone u ∧ (∀ idx, 0 ≤ u idx ∧ u idx ≤ x idx) ∧ (∑ idx, a idx * u idx) = t := by let s : ℝ := ∑ idx, a idx * x idx have hs : 0 < s := lt_of_lt_of_le ht hfacet let c : ℝ := t / s have hc : 0 < c := div_pos ht hs have hc1 : c ≤ 1 := (div_le_one hs).mpr hfacet refine ⟨fun idx => c * x idx, ?_, ?_, ?_⟩ · intro idx j hij exact mul_le_mul_of_nonneg_left (hxmono hij) hc.le · intro idx exact ⟨mul_nonneg hc.le (hx idx), by nlinarith [hx idx]⟩ · calc _ = c * s := by dsimp [s] rw [mul_sum] apply sum_congr rfl intro idx _ ring _ = t := div_mul_cancel₀ t hs.ne' /-- Every ordered vector above a positive facet has a finite mesh witness below it whose facet lies in an interval of width `h * ∑ aᵢ`. -/ /- Original line 41038: Erdos416Proof.FordBadFacet.exists_facet_grid_witness -/ theorem exists_facet_grid_witness {k : ℕ} (a x : Fin k → ℝ) {h X t : ℝ} (hh : 0 < h) (ht : 0 < t) (ha : ∀ idx, 0 ≤ a idx) (hx : ∀ idx, 0 ≤ x idx ∧ x idx ≤ X) (hxmono : Antitone x) (hfacet : t ≤ ∑ idx, a idx * x idx) : ∃ θ ∈ coordinateGrid k h X, Antitone θ ∧ (∀ idx, 0 ≤ θ idx ∧ θ idx ≤ x idx) ∧ t - h * (∑ idx, a idx) ≤ ∑ idx, a idx * θ idx ∧ (∑ idx, a idx * θ idx) ≤ t := by obtain ⟨u, humono, hu, hsum⟩ := exists_scaled_facet a x ht (fun idx => (hx idx).1) hxmono hfacet let θ : Fin k → ℝ := fun idx => lowerGridPoint h (u idx) have hb idx := lowerGridPoint_bounds hh (hu idx).1 refine ⟨θ, lowerGridPoint_mem_grid hh u (fun idx => (hu idx).2.trans (hx idx).2), ?_, ?_, ?_, ?_⟩ · intro idx j hij exact lowerGridPoint_mono hh (humono hij) · intro idx exact ⟨(hb idx).1, (hb idx).2.1.trans (hu idx).2⟩ · calc _ = ∑ idx, a idx * (u idx - h) := by rw [← hsum, mul_sum, ← sum_sub_distrib] apply sum_congr rfl intro idx _ ring _ ≤ _ := sum_le_sum fun idx _ => mul_le_mul_of_nonneg_left (hb idx).2.2 (ha idx) · calc _ ≤ ∑ idx, a idx * u idx := sum_le_sum fun idx _ => mul_le_mul_of_nonneg_left (hb idx).2.1 (ha idx) _ = t := hsum /-- The grid approximation used for a violated Ford facet. -/ /- Original line 41068: Erdos416Proof.FordBadFacet.exists_ford_facet_grid_witness -/ theorem exists_ford_facet_grid_witness {k : ℕ} (x : Fin k → ℝ) {h X ω : ℝ} (hh : 0 < h) (hω : 0 < ω) (hx : ∀ idx, 0 ≤ x idx ∧ x idx ≤ X) (hxmono : Antitone x) (hfacet : 1 + ω ≤ ∑ idx, fordWeight (idx.val + 1) * x idx) : ∃ θ ∈ coordinateGrid k h X, Antitone θ ∧ (∀ idx, 0 ≤ θ idx ∧ θ idx ≤ x idx) ∧ 1 + ω - h * (∑ idx : Fin k, fordWeight (idx.val + 1)) ≤ ∑ idx : Fin k, fordWeight (idx.val + 1) * θ idx ∧ (∑ idx : Fin k, fordWeight (idx.val + 1) * θ idx) ≤ 1 + ω := by exact exists_facet_grid_witness (fun idx => fordWeight (idx.val + 1)) x hh (by linarith) (fun idx => (fordWeight_bounds (by omega)).1) hx hxmono hfacet /-- The coordinates at least a given threshold form an initial segment, including the cases of an empty or full segment. -/ /- Original line 41082: Erdos416Proof.FordBadFacet.exists_threshold_prefix -/ theorem exists_threshold_prefix {k : ℕ} (θ : Fin k → ℝ) (hθ : Antitone θ) (s : ℝ) : ∃ j : ℕ, j ≤ k ∧ ∀ idx : Fin k, s ≤ θ idx ↔ idx.val < j := by let P : ℕ → Prop := fun j => j = k ∨ ∃ hj : j < k, θ ⟨j, hj⟩ < s have hex : ∃ j, P j := ⟨k, Or.inl rfl⟩ let j := Nat.find hex have hjk : j ≤ k := Nat.find_min' hex (Or.inl rfl) refine ⟨j, hjk, ?_⟩ intro idx constructor · intro hi by_contra hij have hji : j ≤ idx.val := by omega rcases Nat.find_spec hex with hj | ⟨hj, hlow⟩ · change j = k at hj omega · have hiθ : θ idx ≤ θ ⟨j, hj⟩ := hθ hji linarith · intro hij have hnot : ¬P idx.val := Nat.find_min hex hij by_contra hlow exact hnot (Or.inr ⟨idx.isLt, lt_of_not_ge hlow⟩) /-- Omitting coordinates below the normality scale costs at most that scale times the sum of the nonnegative facet weights. -/ /- Original line 41106: Erdos416Proof.FordBadFacet.facet_prefix_loss -/ theorem facet_prefix_loss {k : ℕ} (a θ : Fin k → ℝ) (s : ℝ) (hs : 0 ≤ s) (ha : ∀ idx, 0 ≤ a idx) (j : ℕ) (hprefix : ∀ idx : Fin k, s ≤ θ idx ↔ idx.val < j) : (∑ idx, a idx * θ idx) - s * (∑ idx, a idx) ≤ ∑ idx : Fin k, if idx.val < j then a idx * θ idx else 0 := by calc _ = ∑ idx, (a idx * θ idx - s * a idx) := by rw [mul_sum, sum_sub_distrib] _ ≤ _ := by apply sum_le_sum intro idx _ split_ifs with hi · linarith [mul_nonneg hs (ha idx)] · have hlow : θ idx < s := lt_of_not_ge (fun h => hi ((hprefix idx).mp h)) nlinarith [mul_le_mul_of_nonneg_left hlow.le (ha idx)] /-- Capping all coordinates at the sieve endpoint loses at most the cap distance times the sum of the weights. -/ /- Original line 41123: Erdos416Proof.FordBadFacet.facet_cap_loss -/ theorem facet_cap_loss {k : ℕ} (a θ : Fin k → ℝ) (X F : ℝ) (ha : ∀ idx, 0 ≤ a idx) (hX : ∀ idx, θ idx ≤ X) (hF : F ≤ X) : (∑ idx, a idx * θ idx) - (X - F) * (∑ idx, a idx) ≤ ∑ idx, a idx * min (θ idx) F := by calc _ = ∑ idx, a idx * (θ idx - (X - F)) := by rw [mul_sum, ← sum_sub_distrib] apply sum_congr rfl intro idx _ ring _ ≤ _ := by apply sum_le_sum intro idx _ apply mul_le_mul_of_nonneg_left _ (ha idx) exact le_min (by linarith) (by linarith [hX idx]) /-- A coarse but uniform weight sum bound, sufficient for discretization. -/ /- Original line 41140: Erdos416Proof.FordBadFacet.sum_fordWeight_fin_le_square -/ theorem sum_fordWeight_fin_le_square (k : ℕ) : (∑ idx : Fin k, fordWeight (idx.val + 1)) ≤ ((k + 1 : ℕ) : ℝ)^2 := by have hterm (idx : Fin k) : fordWeight (idx.val + 1) ≤ ((k + 1 : ℕ) : ℝ) := by have hweight := (fordWeight_bounds (show 1 ≤ idx.val + 1 by omega)).2 have hlog := Real.log_le_sub_one_of_pos (by positivity : 0 < ((idx.val + 1 : ℕ) : ℝ) + 1) have hi : ((idx.val + 1 : ℕ) : ℝ) ≤ ((k + 1 : ℕ) : ℝ) := by exact_mod_cast (by omega : idx.val + 1 ≤ k + 1) linarith calc _ ≤ ∑ _i : Fin k, ((k + 1 : ℕ) : ℝ) := sum_le_sum fun idx _ => hterm idx _ = (k : ℝ) * ((k + 1 : ℕ) : ℝ) := by simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] _ ≤ _ := by have hk0 : (0 : ℝ) ≤ k := Nat.cast_nonneg k push_cast nlinarith /-- A prescribed facet margin survives a finite grid with an explicit mesh. -/ /- Original line 41158: Erdos416Proof.FordBadFacet.exists_facet_grid_margin -/ theorem exists_facet_grid_margin {k : ℕ} (a x : Fin k → ℝ) {A ω : ℝ} (hA : 0 < A) (hω : 0 < ω) (ha : ∀ idx, 0 ≤ a idx) (haA : (∑ idx, a idx) ≤ A) (hx : ∀ idx, 0 ≤ x idx ∧ x idx ≤ 1) (hxmono : Antitone x) (hfacet : 1 + ω ≤ ∑ idx, a idx * x idx) : ∃ θ ∈ coordinateGrid k (ω / (10 * A)) 1, Antitone θ ∧ (∀ idx, 0 ≤ θ idx ∧ θ idx ≤ x idx) ∧ 1 + 9 * ω / 10 ≤ ∑ idx, a idx * θ idx ∧ (∑ idx, a idx * θ idx) ≤ 1 + ω := by have hmesh : 0 < ω / (10 * A) := div_pos hω (by positivity) obtain ⟨θ, hθmem, hθmono, hθx, hθlow, hθhigh⟩ := exists_facet_grid_witness a x hmesh (by linarith) ha hx hxmono hfacet refine ⟨θ, hθmem, hθmono, hθx, ?_, hθhigh⟩ have hloss := mul_le_mul_of_nonneg_left haA hmesh.le have hc : ω / (10 * A) * A = ω / 10 := by field_simp rw [hc] at hloss linarith /- Original line 41174: Erdos416Proof.FordBadFacet.facet_coordinateGrid_card_bound -/ theorem facet_coordinateGrid_card_bound (k : ℕ) {A ω : ℝ} (hA : 0 < A) (hω : 0 < ω) : ((coordinateGrid k (ω / (10 * A)) 1).card : ℝ) ≤ (1 + 10 * A / ω)^k := by have hmesh : 0 < ω / (10 * A) := div_pos hω (by positivity) have hfloor := Nat.floor_le (div_nonneg (by norm_num : (0 : ℝ) ≤ 1) hmesh.le) have hdiv : 1 / (ω / (10 * A)) = 10 * A / ω := by field_simp rw [hdiv] at hfloor have hcast : (((⌊1 / (ω / (10 * A))⌋₊ + 1)^k : ℕ) : ℝ) ≤ (1 + 10 * A / ω)^k := by push_cast rw [hdiv] apply pow_le_pow_left₀ (by positivity) linarith exact (Nat.cast_le.mpr (coordinateGrid_card_le k (ω / (10 * A)) 1)).trans hcast end Erdos416Proof.FordBadFacet end /- Consolidated component: FacetEntropy.lean. -/ section open Filter Finset open scoped Classical Topology BigOperators namespace Erdos416Proof.FordBadFacet /-- The entropy coefficient at a positive integer tilt. -/ /- Original line 41206: Erdos416Proof.FordBadFacet.integerEntropy -/ noncomputable def integerEntropy (n : ℕ) : ℝ := (n : ℝ) - (n : ℝ) * Real.log n /- Original line 41209: Erdos416Proof.FordBadFacet.integerEntropy_one -/ theorem integerEntropy_one : integerEntropy 1 = 1 := by simp [integerEntropy] /-- Ford's coefficients are the successive drops of the entropy coefficient. -/ /- Original line 41213: Erdos416Proof.FordBadFacet.integerEntropy_difference -/ theorem integerEntropy_difference (n : ℕ) : integerEntropy n - integerEntropy (n + 1) = fordWeight n := by simp only [integerEntropy, fordWeight, Nat.cast_add, Nat.cast_one] ring /- Original line 41218: Erdos416Proof.FordBadFacet.integerEntropy_difference_eq_coeff -/ theorem integerEntropy_difference_eq_coeff {n : ℕ} (hn : 1 ≤ n) : integerEntropy n - integerEntropy (n + 1) = FordAnalysis.coeff n := by rw [integerEntropy_difference, FordAnalysis.coeff_eq hn] /-- Summation by parts for the integer tilts `1, ..., k+1`. Coordinates are listed from the largest logarithmic endpoint to the smallest. -/ /- Original line 41224: Erdos416Proof.FordBadFacet.integerEntropy_telescope -/ theorem integerEntropy_telescope (k : ℕ) (t : ℕ → ℝ) : (∑ idx ∈ range (k + 1), integerEntropy (idx + 1) * (t idx - t (idx + 1))) = t 0 - (∑ idx ∈ range k, fordWeight (idx + 1) * t (idx + 1)) - integerEntropy (k + 1) * t (k + 1) := by induction k with | zero => simp[Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordBadFacet.integerEntropy_one] | succ k ih => rw [Finset.sum_range_succ, ih, Finset.sum_range_succ] have h := congrArg (fun r : ℝ => r * t (k + 1)) (integerEntropy_difference (k + 1)) nlinarith /- Original line 41235: Erdos416Proof.FordBadFacet.integerEntropy_telescope_fin -/ theorem integerEntropy_telescope_fin (k : ℕ) (t : ℕ → ℝ) : (∑ idx : Fin (k + 1), integerEntropy (idx.val + 1) * (t idx.val - t (idx.val + 1))) = t 0 - (∑ idx ∈ range k, fordWeight (idx + 1) * t (idx + 1)) - integerEntropy (k + 1) * t (k + 1) := by rw [Fin.sum_univ_eq_sum_range (fun idx : ℕ => integerEntropy (idx + 1) * (t idx - t (idx + 1))) (k + 1)] exact integerEntropy_telescope k t /-- A uniform bound for the full normality and Mertens errors. -/ /- Original line 41244: Erdos416Proof.FordBadFacet.chernoff_error_le -/ theorem chernoff_error_le {ι : Type*} [Fintype ι] (a δ : ι → ℝ) (A D B : ℝ) (hA : 1 ≤ A) (hD : 0 ≤ D) (hB : 0 ≤ B) (ha : ∀ idx, 1 ≤ a idx ∧ a idx ≤ A) (hδ : ∀ idx, 0 ≤ δ idx ∧ δ idx ≤ D) : (∑ idx, (2 * a idx * δ idx * Real.log (a idx) + a idx * B)) ≤ (Fintype.card ι : ℝ) * (2 * A * D * Real.log A + A * B) := by calc _ ≤ ∑ _i : ι, (2 * A * D * Real.log A + A * B) := by apply sum_le_sum intro idx _ have hai : 0 ≤ a idx := le_trans (by norm_num) (ha idx).1 have hlogi := Real.log_nonneg (ha idx).1 have hlog := Real.log_le_log (by linarith [(ha idx).1]) (ha idx).2 have hprod := mul_le_mul (ha idx).2 (hδ idx).2 (hδ idx).1 (by linarith : 0 ≤ A) have hmain := mul_le_mul hprod hlog hlogi (mul_nonneg (by linarith) hD) have hlast := mul_le_mul_of_nonneg_right (ha idx).2 hB nlinarith _ = _ := by simp only [sum_const, card_univ, nsmul_eq_mul] /-- The canonical integer tilts have maximum equal to the number of cells, giving a quadratic count factor instead of a factor of `logLog x`. -/ /- Original line 41265: Erdos416Proof.FordBadFacet.integer_chernoff_error_le -/ theorem integer_chernoff_error_le (k : ℕ) (δ : Fin (k + 1) → ℝ) (D B : ℝ) (hD : 0 ≤ D) (hB : 0 ≤ B) (hδ : ∀ idx, 0 ≤ δ idx ∧ δ idx ≤ D) : (∑ idx : Fin (k + 1), (2 * (idx.val + 1 : ℕ) * δ idx * Real.log (idx.val + 1 : ℕ) + (idx.val + 1 : ℕ) * B)) ≤ ((k + 1 : ℕ) : ℝ)^2 * (2 * D * Real.log (k + 1 : ℕ) + B) := by have h := chernoff_error_le (fun idx : Fin (k + 1) => ((idx.val + 1 : ℕ) : ℝ)) δ (k + 1) D B (by exact_mod_cast Nat.succ_pos k) hD hB (fun idx => ⟨by exact_mod_cast Nat.succ_pos idx.val, by exact_mod_cast Nat.succ_le_of_lt idx.isLt⟩) hδ simp only [Fintype.card_fin] at h convert h using 1 push_cast ring /-- A violated Ford facet creates a negative entropy exponent. The lower endpoint and the two analytic errors remain explicit on the right. -/ /- Original line 41281: Erdos416Proof.FordBadFacet.integer_entropy_exponent_le -/ theorem integer_entropy_exponent_le (k : ℕ) (t : ℕ → ℝ) (δ : Fin (k + 1) → ℝ) (D B σ : ℝ) (hbottom : 0 ≤ t (k + 1)) (hD : 0 ≤ D) (hB : 0 ≤ B) (hδ : ∀ idx, 0 ≤ δ idx ∧ δ idx ≤ D) (hfacet : (1 + σ) * t 0 ≤ ∑ idx ∈ range k, fordWeight (idx + 1) * t (idx + 1)) : (∑ idx : Fin (k + 1), (integerEntropy (idx.val + 1) * (t idx.val - t (idx.val + 1)) + 2 * (idx.val + 1 : ℕ) * δ idx * Real.log (idx.val + 1 : ℕ) + (idx.val + 1 : ℕ) * B)) ≤ -σ * t 0 + (k + 1 : ℕ) * Real.log (k + 1 : ℕ) * t (k + 1) + ((k + 1 : ℕ) : ℝ)^2 * (2 * D * Real.log (k + 1 : ℕ) + B) := by have he := integer_chernoff_error_le k δ D B hD hB hδ have ht := integerEntropy_telescope_fin k t have hsplit : (∑ idx : Fin (k + 1), (integerEntropy (idx.val + 1) * (t idx.val - t (idx.val + 1)) + 2 * (idx.val + 1 : ℕ) * δ idx * Real.log (idx.val + 1 : ℕ) + (idx.val + 1 : ℕ) * B)) = (∑ idx : Fin (k + 1), integerEntropy (idx.val + 1) * (t idx.val - t (idx.val + 1))) + (∑ idx : Fin (k + 1), (2 * (idx.val + 1 : ℕ) * δ idx * Real.log (idx.val + 1 : ℕ) + (idx.val + 1 : ℕ) * B)) := by rw [← sum_add_distrib] apply sum_congr rfl intro idx _ ring rw [hsplit, ht] unfold integerEntropy have hnonneg : (0 : ℝ) ≤ (k + 1 : ℕ) * t (k + 1) := mul_nonneg (by positivity) hbottom nlinarith /-- The finite error budget can be checked directly against the facet margin. -/ /- Original line 41310: Erdos416Proof.FordBadFacet.integer_entropy_exponential_saving -/ theorem integer_entropy_exponential_saving (k : ℕ) (t : ℕ → ℝ) (δ : Fin (k + 1) → ℝ) (D B σ : ℝ) (hbottom : 0 ≤ t (k + 1)) (hD : 0 ≤ D) (hB : 0 ≤ B) (hδ : ∀ idx, 0 ≤ δ idx ∧ δ idx ≤ D) (hfacet : (1 + σ) * t 0 ≤ ∑ idx ∈ range k, fordWeight (idx + 1) * t (idx + 1)) (hbudget : (k + 1 : ℕ) * Real.log (k + 1 : ℕ) * t (k + 1) + ((k + 1 : ℕ) : ℝ)^2 * (2 * D * Real.log (k + 1 : ℕ) + B) ≤ σ / 2 * t 0) : Real.exp (∑ idx : Fin (k + 1), (integerEntropy (idx.val + 1) * (t idx.val - t (idx.val + 1)) + 2 * (idx.val + 1 : ℕ) * δ idx * Real.log (idx.val + 1 : ℕ) + (idx.val + 1 : ℕ) * B)) ≤ Real.exp (-(σ / 2) * t 0) := by apply Real.exp_le_exp.mpr have h := integer_entropy_exponent_le k t δ D B σ hbottom hD hB hδ hfacet linarith /-- If the number of selected primes is bounded by `A`, all entropy losses are bounded at that scale. One may take `A = C * log T` with `T = logLog x`, `R = logLog S`, and `D = sqrt (R * T)`. -/ /- Original line 41328: Erdos416Proof.FordBadFacet.integer_entropy_loss_le_scale -/ theorem integer_entropy_loss_le_scale {n : ℕ} (hn : 1 ≤ n) {A R D B : ℝ} (hnA : (n : ℝ) ≤ A) (hR : 0 ≤ R) (hD : 0 ≤ D) (hB : 0 ≤ B) : (n : ℝ) * Real.log n * R + (n : ℝ)^2 * (2 * D * Real.log n + B) ≤ A * Real.log A * R + A^2 * (2 * D * Real.log A + B) := by have hn1 : (1 : ℝ) ≤ n := by exact_mod_cast hn have hn0 : (0 : ℝ) < n := by linarith have hA : 0 ≤ A := by linarith have hlogn := Real.log_nonneg hn1 have hlog := Real.log_le_log hn0 hnA have hprod := mul_le_mul hnA hlog hlogn hA have hfirst := mul_le_mul_of_nonneg_right hprod hR have hsquare : (n : ℝ)^2 ≤ A^2 := (sq_le_sq₀ hn0.le hA).mpr hnA have hfactor : 2 * D * Real.log n + B ≤ 2 * D * Real.log A + B := by have hmul : (2 * D) * Real.log n ≤ (2 * D) * Real.log A := mul_le_mul_of_nonneg_left hlog (mul_nonneg (by norm_num) hD) linarith have hsecond := mul_le_mul hsquare hfactor (by positivity : 0 ≤ 2 * D * Real.log n + B) (sq_nonneg A) exact add_le_add hfirst hsecond end Erdos416Proof.FordBadFacet namespace Erdos416Proof.FordBadFacet /-- Incorporating the interval-sieve prefactor leaves exactly the negative Ford facet. The actual cells now have tilts `2, ..., k+1`. -/ /- Original line 41356: Erdos416Proof.FordBadFacet.shifted_integerEntropy_telescope -/ theorem shifted_integerEntropy_telescope (k : ℕ) (t : ℕ → ℝ) : (t (k + 1) - t 1) + (∑ idx ∈ range k, integerEntropy (idx + 2) * (t (idx + 1) - t (idx + 2))) = -(∑ idx ∈ range k, fordWeight (idx + 1) * t (idx + 1)) + (1 - integerEntropy (k + 1)) * t (k + 1) := by induction k with | zero => simp[Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordBadFacet.integerEntropy_one] | succ k ih => rw [Finset.sum_range_succ, Finset.sum_range_succ] have h := congrArg (fun r : ℝ => r * t (k + 1)) (integerEntropy_difference (k + 1)) nlinarith /- Original line 41368: Erdos416Proof.FordBadFacet.shifted_integerEntropy_telescope_fin -/ theorem shifted_integerEntropy_telescope_fin (k : ℕ) (t : ℕ → ℝ) : (t (k + 1) - t 1) + (∑ idx : Fin k, integerEntropy (idx.val + 2) * (t (idx.val + 1) - t (idx.val + 2))) = -(∑ idx ∈ range k, fordWeight (idx + 1) * t (idx + 1)) + (1 - integerEntropy (k + 1)) * t (k + 1) := by rw [Fin.sum_univ_eq_sum_range (fun idx : ℕ => integerEntropy (idx + 2) * (t (idx + 1) - t (idx + 2))) k] exact shifted_integerEntropy_telescope k t /- Original line 41377: Erdos416Proof.FordBadFacet.shifted_integer_chernoff_error_le -/ theorem shifted_integer_chernoff_error_le (k : ℕ) (δ : Fin k → ℝ) (D B : ℝ) (hD : 0 ≤ D) (hB : 0 ≤ B) (hδ : ∀ idx, 0 ≤ δ idx ∧ δ idx ≤ D) : (∑ idx : Fin k, (2 * (idx.val + 2 : ℕ) * δ idx * Real.log (idx.val + 2 : ℕ) + (idx.val + 2 : ℕ) * B)) ≤ ((k + 1 : ℕ) : ℝ)^2 * (2 * D * Real.log (k + 1 : ℕ) + B) := by have hN : (1 : ℝ) ≤ (k + 1 : ℕ) := by exact_mod_cast (show 1 ≤ k + 1 by omega) have hlogN := Real.log_nonneg hN have h := chernoff_error_le (fun idx : Fin k => ((idx.val + 2 : ℕ) : ℝ)) δ ((k + 1 : ℕ) : ℝ) D B hN hD hB (fun idx => ⟨by exact_mod_cast (show 1 ≤ idx.val + 2 by omega), by exact_mod_cast (show idx.val + 2 ≤ k + 1 by omega)⟩) hδ simp only [Fintype.card_fin] at h calc _ ≤ (k : ℝ) * (2 * (k + 1 : ℕ) * D * Real.log (k + 1 : ℕ) + (k + 1 : ℕ) * B) := h _ ≤ (k + 1 : ℕ) * (2 * (k + 1 : ℕ) * D * Real.log (k + 1 : ℕ) + (k + 1 : ℕ) * B) := by apply mul_le_mul_of_nonneg_right · exact_mod_cast Nat.le_succ k · positivity _ = _ := by ring /-- An actual bad facet, including the interval-sieve logarithmic prefactor, has an exponent strictly below `-T` once its finite loss budget is absorbed. -/ /- Original line 41401: Erdos416Proof.FordBadFacet.shifted_integer_entropy_exponential_saving -/ theorem shifted_integer_entropy_exponential_saving (k : ℕ) (t : ℕ → ℝ) (δ : Fin k → ℝ) (D B ω T : ℝ) (hbottom : 0 ≤ t (k + 1)) (hD : 0 ≤ D) (hB : 0 ≤ B) (hδ : ∀ idx, 0 ≤ δ idx ∧ δ idx ≤ D) (hfacet : (1 + ω) * T ≤ ∑ idx ∈ range k, fordWeight (idx + 1) * t (idx + 1)) (hbudget : (k + 1 : ℕ) * Real.log (k + 1 : ℕ) * t (k + 1) + ((k + 1 : ℕ) : ℝ)^2 * (2 * D * Real.log (k + 1 : ℕ) + B) ≤ ω / 2 * T) : Real.exp ((t (k + 1) - t 1) + (∑ idx : Fin k, (integerEntropy (idx.val + 2) * (t (idx.val + 1) - t (idx.val + 2)) + 2 * (idx.val + 2 : ℕ) * δ idx * Real.log (idx.val + 2 : ℕ) + (idx.val + 2 : ℕ) * B))) ≤ Real.exp (-(1 + ω / 2) * T) := by have he := shifted_integer_chernoff_error_le k δ D B hD hB hδ have ht := shifted_integerEntropy_telescope_fin k t have hsplit : (∑ idx : Fin k, (integerEntropy (idx.val + 2) * (t (idx.val + 1) - t (idx.val + 2)) + 2 * (idx.val + 2 : ℕ) * δ idx * Real.log (idx.val + 2 : ℕ) + (idx.val + 2 : ℕ) * B)) = (∑ idx : Fin k, integerEntropy (idx.val + 2) * (t (idx.val + 1) - t (idx.val + 2))) + (∑ idx : Fin k, (2 * (idx.val + 2 : ℕ) * δ idx * Real.log (idx.val + 2 : ℕ) + (idx.val + 2 : ℕ) * B)) := by rw [← sum_add_distrib] apply sum_congr rfl intro idx _ ring apply Real.exp_le_exp.mpr rw [hsplit, ← add_assoc, ht] unfold integerEntropy have hnonneg : 0 ≤ ((k + 1 : ℕ) - (1 : ℝ)) * t (k + 1) := by apply mul_nonneg _ hbottom exact sub_nonneg.mpr (by exact_mod_cast (show 1 ≤ k + 1 by omega)) nlinarith /-- The interval-sieve logarithmic ratio is the exponential contribution used by `shifted_integerEntropy_telescope`. -/ /- Original line 41435: Erdos416Proof.FordBadFacet.log_ratio_mul_exp -/ theorem log_ratio_mul_exp (S F E : ℝ) (hS : 1 < S) (hF : 1 < F) : Real.log S / Real.log F * Real.exp E = Real.exp (logLog S - logLog F + E) := by rw [Real.exp_add, Real.exp_sub] simp only [logLog, Real.exp_log (Real.log_pos hS), Real.exp_log (Real.log_pos hF)] /-- Capping the top coordinates loses at most the total facet weight times the distance from the original top to the cap. -/ /- Original line 41442: Erdos416Proof.FordBadFacet.capped_weighted_facet_lower -/ theorem capped_weighted_facet_lower {ι : Type*} (I : Finset ι) (a t : ι → ℝ) (T cap : ℝ) (hcap : cap ≤ T) (ha : ∀ idx ∈ I, 0 ≤ a idx) (ht : ∀ idx ∈ I, t idx ≤ T) : (∑ idx ∈ I, a idx * t idx) - (∑ idx ∈ I, a idx) * (T - cap) ≤ ∑ idx ∈ I, a idx * min (t idx) cap := by have hi (idx : ι) (him : idx ∈ I) : a idx * (t idx - min (t idx) cap) ≤ a idx * (T - cap) := by apply mul_le_mul_of_nonneg_left _ (ha idx him) rcases le_total (t idx) cap with hc | hc · rw [min_eq_left hc] linarith · rw [min_eq_right hc] linarith [ht idx him] have hsum := sum_le_sum hi simp only [mul_sub, sum_sub_distrib, ← sum_mul] at hsum linarith end Erdos416Proof.FordBadFacet end /- Consolidated component: FacetBudget.lean. -/ section open scoped BigOperators namespace Erdos416Proof.FordBadFacet /-- A single scale that bounds the three integer-tilt coefficients. -/ /- Original line 41474: Erdos416Proof.FordBadFacet.normalityCost -/ noncomputable def normalityCost (N : ℝ) : ℝ := N^2 * (1 + Real.log N) /- Original line 41476: Erdos416Proof.FordBadFacet.normalityCost_bounds -/ theorem normalityCost_bounds {N : ℝ} (hN : 1 ≤ N) : 1 ≤ normalityCost N ∧ N * Real.log N ≤ normalityCost N ∧ N^2 * Real.log N ≤ normalityCost N ∧ N^2 ≤ normalityCost N := by have hlog := Real.log_nonneg hN have hNsq : N ≤ N^2 := by nlinarith have hlogsq := mul_le_mul_of_nonneg_right hNsq hlog dsimp [normalityCost] refine ⟨?_, ?_, ?_, ?_⟩ <;> nlinarith [sq_nonneg N, mul_nonneg (sq_nonneg N) hlog] /-- The logarithm of the logarithm of the chosen normality scale. -/ /- Original line 41487: Erdos416Proof.FordBadFacet.facetNormalityParameter -/ noncomputable def facetNormalityParameter (N ω T : ℝ) : ℝ := (ω / (32 * normalityCost N))^2 * T /- Original line 41490: Erdos416Proof.FordBadFacet.sqrt_facetNormalityParameter -/ theorem sqrt_facetNormalityParameter {N ω T : ℝ} (hN : 1 ≤ N) (hω : 0 ≤ ω) (hT : 0 ≤ T) : Real.sqrt (facetNormalityParameter N ω T * T) = ω / (32 * normalityCost N) * T := by have hA := (normalityCost_bounds hN).1 have hc : 0 ≤ ω / (32 * normalityCost N) := div_nonneg hω (by linarith) rw [show facetNormalityParameter N ω T * T = (ω / (32 * normalityCost N) * T)^2 by dsimp [facetNormalityParameter]; ring] exact Real.sqrt_sq (mul_nonneg hc hT) /-- This choice of normality scale discharges the entropy loss budget. The remaining size condition is explicit and linear in the Mertens constant. -/ /- Original line 41502: Erdos416Proof.FordBadFacet.facet_normality_budget -/ theorem facet_normality_budget {N B ω T : ℝ} (hN : 1 ≤ N) (hB : 0 ≤ B) (hω : 0 ≤ ω) (hω1 : ω ≤ 1) (hT : 0 ≤ T) (hlarge : 16 * normalityCost N * B ≤ ω * T) : N * Real.log N * facetNormalityParameter N ω T + N^2 * (2 * Real.sqrt (facetNormalityParameter N ω T * T) * Real.log N + B) ≤ ω / 2 * T := by let A := normalityCost N let c := ω / (32 * A) let R := facetNormalityParameter N ω T let D := c * T obtain ⟨hA, hNlog, hN2log, hN2⟩ := normalityCost_bounds hN have hApos : 0 < A := by dsimp [A]; linarith have hc : 0 ≤ c := div_nonneg hω (by positivity) have hc1 : c ≤ 1 := (div_le_one (by positivity : 0 < 32 * A)).mpr (by dsimp [A] linarith) have hR : 0 ≤ R := mul_nonneg (sq_nonneg _) hT have hD : 0 ≤ D := mul_nonneg hc hT have hRD : R ≤ D := by have hc2 : c^2 ≤ c := by nlinarith exact mul_le_mul_of_nonneg_right hc2 hT have hAc : A * c = ω / 32 := by dsimp [c]; field_simp have hAD : A * D = ω * T / 32 := by dsimp [D] rw [← mul_assoc, hAc] ring have hroot : Real.sqrt (facetNormalityParameter N ω T * T) = D := sqrt_facetNormalityParameter hN hω hT rw [hroot] calc _ ≤ A * R + 2 * A * D + A * B := by have hfirst := mul_le_mul_of_nonneg_right hNlog hR have hsecond := mul_le_mul_of_nonneg_right hN2log (by positivity : 0 ≤ 2 * D) have hthird := mul_le_mul_of_nonneg_right hN2 hB change N * Real.log N * R + N^2 * (2 * D * Real.log N + B) ≤ _ nlinarith _ ≤ 3 * (A * D) + A * B := by nlinarith [mul_le_mul_of_nonneg_left hRD hApos.le] _ ≤ ω / 2 * T := by rw [hAD] change 16 * A * B ≤ ω * T at hlarge nlinarith [mul_nonneg hω hT] /-- The chosen parameter is safely below the main logarithmic scale. -/ /- Original line 41546: Erdos416Proof.FordBadFacet.facetNormalityParameter_le -/ theorem facetNormalityParameter_le {N ω T : ℝ} (hN : 1 ≤ N) (hω : 0 ≤ ω) (hω1 : ω ≤ 1) (hT : 0 ≤ T) : 0 ≤ facetNormalityParameter N ω T ∧ facetNormalityParameter N ω T ≤ T / 1024 := by have hA := (normalityCost_bounds hN).1 have hc : 0 ≤ ω / (32 * normalityCost N) := div_nonneg hω (by linarith) have hc32 : ω / (32 * normalityCost N) ≤ (1 / 32 : ℝ) := by apply (div_le_iff₀ (by linarith : 0 < 32 * normalityCost N)).mpr linarith have hc2 : (ω / (32 * normalityCost N))^2 ≤ (1 / 1024 : ℝ) := by nlinarith refine ⟨mul_nonneg (sq_nonneg _) hT, ?_⟩ have h := mul_le_mul_of_nonneg_right hc2 hT dsimp [facetNormalityParameter] linarith /-- The corresponding threshold for normal primes. -/ /- Original line 41561: Erdos416Proof.FordBadFacet.facetNormalityScale -/ noncomputable def facetNormalityScale (N ω T : ℝ) : ℝ := Real.exp (Real.exp (facetNormalityParameter N ω T)) /- Original line 41564: Erdos416Proof.FordBadFacet.facetNormalityScale_logLog -/ theorem facetNormalityScale_logLog (N ω T : ℝ) : Real.log (Real.log (facetNormalityScale N ω T)) = facetNormalityParameter N ω T := by simp [facetNormalityScale] /-- The nontrivial-range inequality in the bad-facet argument implies exactly the lower scale required by capped normality. -/ /- Original line 41570: Erdos416Proof.FordBadFacet.facetNormalityScale_power_lower -/ theorem facetNormalityScale_power_lower {N ω T : ℝ} (hT : 0 < T) (hlarge : 36 * Real.log T ≤ facetNormalityParameter N ω T) : Real.exp (T^36) ≤ facetNormalityScale N ω T := by apply Real.exp_le_exp.mpr calc T^36 = Real.exp (Real.log (T^36)) := (Real.exp_log (pow_pos hT _)).symm _ ≤ Real.exp (facetNormalityParameter N ω T) := by apply Real.exp_le_exp.mpr simpa only [Real.log_pow, Nat.cast_ofNat] using hlarge end Erdos416Proof.FordBadFacet end /- Consolidated component: FacetCoverGeometry.lean. -/ section open Finset open scoped Classical BigOperators namespace Erdos416Proof.FordBadFacet /-- Reindex the initial segment without padding it by zero coordinates. -/ /- Original line 41597: Erdos416Proof.FordBadFacet.sum_prefix_eq_indicator -/ theorem sum_prefix_eq_indicator {j k : ℕ} (hjk : j ≤ k) (f : Fin k → ℝ) : (∑ idx : Fin j, f (Fin.castLE hjk idx)) = ∑ idx : Fin k, if idx.val < j then f idx else 0 := by calc _ = ∑ idx ∈ Finset.univ.filter (fun idx : Fin k => idx.val < j), f idx := by apply Finset.sum_bij (fun idx (_ : idx ∈ Finset.univ) => Fin.castLE hjk idx) · intro idx _ exact Finset.mem_filter.mpr ⟨Finset.mem_univ _, idx.isLt⟩ · intro idx _ l _ hil exact Fin.ext (congrArg (fun z : Fin k => z.val) hil) · intro idx hi refine ⟨⟨idx.val, (Finset.mem_filter.mp hi).2⟩, Finset.mem_univ _, ?_⟩ exact Fin.ext rfl · intro idx _ rfl _ = _ := Finset.sum_filter _ _ /- Original line 41614: Erdos416Proof.FordBadFacet.sum_prefix_le_total -/ theorem sum_prefix_le_total {j k : ℕ} (hjk : j ≤ k) (f : Fin k → ℝ) (hf : ∀ idx, 0 ≤ f idx) : (∑ idx : Fin j, f (Fin.castLE hjk idx)) ≤ ∑ idx : Fin k, f idx := by rw [sum_prefix_eq_indicator] apply Finset.sum_le_sum intro idx _ split_ifs · rfl · exact hf idx /- Original line 41624: Erdos416Proof.FordBadFacet.logLog_min -/ theorem logLog_min {u v : ℝ} (hu : 1 < u) (hv : 1 < v) : logLog (min u v) = min (logLog u) (logLog v) := by rcases le_total u v with huv | hvu · rw [min_eq_left huv, min_eq_left (logLog_mono hu huv)] · rw [min_eq_right hvu, min_eq_right (logLog_mono hv hvu)] /- Original line 41630: Erdos416Proof.FordBadFacet.capped_exp_threshold_log -/ theorem capped_exp_threshold_log {F θ T : ℝ} (hF : 1 < F) : logLog (min F (Real.exp (Real.exp (θ * T)))) = min (logLog F) (θ * T) := by rw [logLog_min hF (Real.one_lt_exp_iff.mpr (Real.exp_pos _))] simp only [logLog, Real.log_exp] /-- Removing the initial-segment tail costs exactly its cutoff times the total nonnegative weight, before the sieve cap is imposed. -/ /- Original line 41637: Erdos416Proof.FordBadFacet.weighted_prefix_log_lower -/ theorem weighted_prefix_log_lower {j k : ℕ} (hjk : j ≤ k) (a θ : Fin k → ℝ) {R T : ℝ} (hR : 0 ≤ R) (hT : 0 < T) (ha : ∀ idx, 0 ≤ a idx) (hprefix : ∀ idx : Fin k, R / T ≤ θ idx ↔ idx.val < j) : (∑ idx, a idx * θ idx) * T - R * (∑ idx, a idx) ≤ ∑ idx : Fin j, a (Fin.castLE hjk idx) * (θ (Fin.castLE hjk idx) * T) := by have h := mul_le_mul_of_nonneg_right (facet_prefix_loss a θ (R / T) (div_nonneg hR hT.le) ha j hprefix) hT.le have heq : (∑ idx : Fin k, if idx.val < j then a idx * θ idx else 0) * T = ∑ idx : Fin j, a (Fin.castLE hjk idx) * (θ (Fin.castLE hjk idx) * T) := by rw [← sum_prefix_eq_indicator hjk (fun idx => a idx * θ idx), Finset.sum_mul] apply Finset.sum_congr rfl intro idx _ ring rw [heq] at h have hl : ((∑ idx, a idx * θ idx) - R / T * (∑ idx, a idx)) * T = (∑ idx, a idx * θ idx) * T - R * (∑ idx, a idx) := by field_simp rwa [hl] at h /-- The exact loss from rounding-tail truncation and capping, expressed in the actual logarithms of the retained prime thresholds. -/ /- Original line 41660: Erdos416Proof.FordBadFacet.retained_capped_facet_lower -/ theorem retained_capped_facet_lower {j k : ℕ} (hjk : j ≤ k) (a θ : Fin k → ℝ) {R T X F : ℝ} (hR : 0 ≤ R) (hT : 0 < T) (hF : 1 < F) (hFX : logLog F ≤ X) (ha : ∀ idx, 0 ≤ a idx) (hθX : ∀ idx, θ idx * T ≤ X) (hprefix : ∀ idx : Fin k, R / T ≤ θ idx ↔ idx.val < j) : (∑ idx, a idx * θ idx) * T - (R + X - logLog F) * (∑ idx, a idx) ≤ ∑ idx : Fin j, a (Fin.castLE hjk idx) * logLog (min F (Real.exp (Real.exp (θ (Fin.castLE hjk idx) * T)))) := by have hpre := weighted_prefix_log_lower hjk a θ hR hT ha hprefix have hweights := sum_prefix_le_total hjk a ha have hcap := capped_weighted_facet_lower (Finset.univ : Finset (Fin j)) (fun idx => a (Fin.castLE hjk idx)) (fun idx => θ (Fin.castLE hjk idx) * T) X (logLog F) hFX (fun idx _ => ha _) (fun idx _ => hθX _) have hloss := mul_le_mul_of_nonneg_right hweights (sub_nonneg.mpr hFX) have heq : (∑ idx : Fin j, a (Fin.castLE hjk idx) * min (θ (Fin.castLE hjk idx) * T) (logLog F)) = ∑ idx : Fin j, a (Fin.castLE hjk idx) * logLog (min F (Real.exp (Real.exp (θ (Fin.castLE hjk idx) * T)))) := by apply Finset.sum_congr rfl intro idx _ rw [capped_exp_threshold_log hF, min_comm] rw [heq] at hcap nlinarith end Erdos416Proof.FordBadFacet end /- Consolidated component: ReversedNormalGrid.lean. -/ section open Filter Finset open scoped Classical Topology BigOperators Nat namespace Erdos416Proof.FordBadFacet /-- Read decreasing prime thresholds from bottom to top. Cell multiplicities are k+1, k, ..., 2, since the top prime accompanies every lower prime. -/ /- Original line 41702: Erdos416Proof.FordBadFacet.reversedPrimeGrid -/ noncomputable abbrev reversedPrimeGrid (k : ℕ) (S F : ℝ) (v : Fin k → ℝ) : NormalGridRecord where dimension := k endpoint := fun j => if hj : j = 0 then S else if hjk : j ≤ k then min F (v ⟨k-j, by omega⟩) else F multiplicity := fun idx => k+1-idx.val /- Original line 41708: Erdos416Proof.FordBadFacet.reversedPrimeGrid_dimension -/ theorem reversedPrimeGrid_dimension (k : ℕ) (S F : ℝ) (v : Fin k → ℝ) : (reversedPrimeGrid k S F v).dimension = k := rfl /- Original line 41711: Erdos416Proof.FordBadFacet.reversedPrimeGrid_zero -/ theorem reversedPrimeGrid_zero (k : ℕ) (S F : ℝ) (v : Fin k → ℝ) : (reversedPrimeGrid k S F v).endpoint 0 = S := by simp[Erdos416Proof.FordBadFacet.reversedPrimeGrid_dimension] /- Original line 41714: Erdos416Proof.FordBadFacet.reversedPrimeGrid_endpoint -/ theorem reversedPrimeGrid_endpoint {k : ℕ} (S F : ℝ) (v : Fin k → ℝ) {j : ℕ} (hj : 0 < j) (hjk : j ≤ k) : (reversedPrimeGrid k S F v).endpoint j = min F (v ⟨k-j, by omega⟩) := by simp [Erdos416Proof.FordBadFacet.reversedPrimeGrid_dimension, Erdos416Proof.FordBadFacet.reversedPrimeGrid_zero, ne_of_gt hj, hjk] /- Original line 41719: Erdos416Proof.FordBadFacet.reversedPrimeGrid_endpoint_succ -/ theorem reversedPrimeGrid_endpoint_succ {k : ℕ} (S F : ℝ) (v : Fin k → ℝ) (idx : Fin k) : (reversedPrimeGrid k S F v).endpoint (idx.val+1) = min F (v idx.rev) := by exact reversedPrimeGrid_endpoint (j := idx.val+1) S F v (by omega) (by omega) /- Original line 41724: Erdos416Proof.FordBadFacet.reversedPrimeGrid_endpoint_rev_succ -/ theorem reversedPrimeGrid_endpoint_rev_succ {k : ℕ} (S F : ℝ) (v : Fin k → ℝ) (idx : Fin k) : (reversedPrimeGrid k S F v).endpoint (idx.rev.val+1) = min F (v idx) := by rw [reversedPrimeGrid_endpoint_succ, Fin.rev_rev] /- Original line 41729: Erdos416Proof.FordBadFacet.reversedPrimeGrid_endpoint_dimension -/ theorem reversedPrimeGrid_endpoint_dimension {k : ℕ} (S F : ℝ) (v : Fin k → ℝ) (hk : 0 < k) : (reversedPrimeGrid k S F v).endpoint k = min F (v ⟨0, hk⟩) := by rw [reversedPrimeGrid_endpoint S F v hk le_rfl] simp[Erdos416Proof.FordBadFacet.reversedPrimeGrid_dimension, Erdos416Proof.FordBadFacet.reversedPrimeGrid_endpoint_succ, Erdos416Proof.FordBadFacet.reversedPrimeGrid_zero] /- Original line 41735: Erdos416Proof.FordBadFacet.reversedPrimeGrid_endpoint_rev -/ theorem reversedPrimeGrid_endpoint_rev {k : ℕ} (S F : ℝ) (v : Fin k → ℝ) (idx : Fin k) : (reversedPrimeGrid k S F v).endpoint idx.rev.val = if hi : idx.val+1 < k then min F (v ⟨idx.val+1, hi⟩) else S := by by_cases hi : idx.val+1 < k · have hr : 0 < idx.rev.val := by rw [Fin.val_rev]; omega rw [dif_pos hi, reversedPrimeGrid_endpoint S F v hr (by omega)] apply congrArg (fun j : Fin k => min F (v j)) apply Fin.ext simp only [Fin.val_rev] omega · have hr : idx.rev.val = 0 := by rw [Fin.val_rev]; omega rw [dif_neg hi, hr, reversedPrimeGrid_zero] /- Original line 41749: Erdos416Proof.FordBadFacet.reversedPrimeGrid_multiplicity -/ theorem reversedPrimeGrid_multiplicity {k : ℕ} (S F : ℝ) (v : Fin k → ℝ) (idx : Fin k) : (reversedPrimeGrid k S F v).multiplicity idx = k+1-idx.val := rfl /- Original line 41752: Erdos416Proof.FordBadFacet.reversedPrimeGrid_multiplicity_rev -/ theorem reversedPrimeGrid_multiplicity_rev {k : ℕ} (S F : ℝ) (v : Fin k → ℝ) (idx : Fin k) : (reversedPrimeGrid k S F v).multiplicity idx.rev = idx.val+2 := by rw [reversedPrimeGrid_multiplicity, Fin.val_rev] omega /- Original line 41757: Erdos416Proof.FordBadFacet.reversedPrimeGrid_increasing -/ theorem reversedPrimeGrid_increasing {k : ℕ} {S F : ℝ} (v : Fin k → ℝ) (hSF : S ≤ F) (hvS : ∀ idx, S ≤ v idx) (hv : Antitone v) : ∀ idx j, idx ≤ j → j ≤ k → (reversedPrimeGrid k S F v).endpoint idx ≤ (reversedPrimeGrid k S F v).endpoint j := by intro idx j hij hjk by_cases hi : idx = 0 · subst idx rw [reversedPrimeGrid_zero] by_cases hj : j = 0 · subst j simp[Erdos416Proof.FordBadFacet.reversedPrimeGrid_dimension, Erdos416Proof.FordBadFacet.reversedPrimeGrid_endpoint_succ, Erdos416Proof.FordBadFacet.reversedPrimeGrid_multiplicity, Erdos416Proof.FordBadFacet.reversedPrimeGrid_zero] · rw [reversedPrimeGrid_endpoint S F v (by omega) hjk] exact le_min hSF (hvS _) · have hj : 0 < j := by omega rw [reversedPrimeGrid_endpoint (j := idx) S F v (by omega) (by omega), reversedPrimeGrid_endpoint S F v hj hjk] apply min_le_min_left F apply hv change k-j ≤ k-idx omega /- Original line 41778: Erdos416Proof.FordBadFacet.reversedPrimeGrid_endpoint_le -/ theorem reversedPrimeGrid_endpoint_le {k : ℕ} {S F : ℝ} (v : Fin k → ℝ) (hSF : S ≤ F) (j : ℕ) : (reversedPrimeGrid k S F v).endpoint j ≤ F := by by_cases hj : j = 0 · subst j simpa [Erdos416Proof.FordBadFacet.reversedPrimeGrid_dimension, Erdos416Proof.FordBadFacet.reversedPrimeGrid_endpoint_succ, Erdos416Proof.FordBadFacet.reversedPrimeGrid_multiplicity, Erdos416Proof.FordBadFacet.reversedPrimeGrid_zero] using hSF · by_cases hjk : j ≤ k · rw [reversedPrimeGrid_endpoint S F v (by omega) hjk] exact min_le_left _ _ · simp [Erdos416Proof.FordBadFacet.reversedPrimeGrid_dimension, Erdos416Proof.FordBadFacet.reversedPrimeGrid_endpoint_succ, Erdos416Proof.FordBadFacet.reversedPrimeGrid_multiplicity, Erdos416Proof.FordBadFacet.reversedPrimeGrid_zero, hj, hjk] /-- All admissibility conditions follow from endpoint inequalities and the fixed scale assumptions, with no count of exceptional values assumed. -/ /- Original line 41790: Erdos416Proof.FordBadFacet.reversedPrimeGrid_admissible -/ theorem reversedPrimeGrid_admissible {x S F : ℝ} {k : ℕ} (v : Fin k → ℝ) (hx : 1 < x) (hT : 20 ≤ logLog x) (hS : Real.exp 1 ≤ S) (hS4 : 4 ≤ S) (hscale : Real.exp ((logLog x)^36) ≤ S) (hSF : S ≤ F) (hvS : ∀ idx, S ≤ v idx) (hv : Antitone v) (hcut : F ≤ x^(1/(20*logLog x))) : NormalGridAdmissible x (reversedPrimeGrid k S F v) where large_x := hx large_logLog := hT normality_scale := by simpa [Erdos416Proof.FordBadFacet.reversedPrimeGrid_dimension, Erdos416Proof.FordBadFacet.reversedPrimeGrid_endpoint_succ, Erdos416Proof.FordBadFacet.reversedPrimeGrid_multiplicity, Erdos416Proof.FordBadFacet.reversedPrimeGrid_zero, Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint] using hS four_le_scale := by simpa [Erdos416Proof.FordBadFacet.reversedPrimeGrid_dimension, Erdos416Proof.FordBadFacet.reversedPrimeGrid_endpoint_succ, Erdos416Proof.FordBadFacet.reversedPrimeGrid_multiplicity, Erdos416Proof.FordBadFacet.reversedPrimeGrid_zero, Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint] using hS4 power_scale := by simpa [Erdos416Proof.FordBadFacet.reversedPrimeGrid_dimension, Erdos416Proof.FordBadFacet.reversedPrimeGrid_endpoint_succ, Erdos416Proof.FordBadFacet.reversedPrimeGrid_multiplicity, Erdos416Proof.FordBadFacet.reversedPrimeGrid_zero, Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint] using hscale increasing := reversedPrimeGrid_increasing v hSF hvS hv cutoff := (reversedPrimeGrid_endpoint_le v hSF k).trans hcut positive_counts := by intro idx have hi : idx.val < k := idx.isLt change 0 < k+1-idx.val omega /-- An actual decreasing tuple of k+1 distinct normal prime divisors has a record for every threshold vector lying below its lower k primes. -/ /- Original line 41811: Erdos416Proof.FordBadFacet.reversedPrimeGrid_witness -/ theorem reversedPrimeGrid_witness {N k : ℕ} (hN : 0 < N) (S F : ℝ) (v : Fin k → ℝ) (q : Fin (k+1) → ℕ) (hinj : Function.Injective q) (hanti : Antitone (fun j => (q j : ℝ))) (hq : ∀ j, SNormal S (q j) ∧ q j ∣ N) (hvq : ∀ idx, v idx ≤ (q idx.succ : ℝ)) : NormalGridWitness (reversedPrimeGrid k S F v) N.totient := by apply NormalGridWitness.of_prime_tuple (r := reversedPrimeGrid k S F v) hN q hinj (by intro j; simpa [Erdos416Proof.FordBadFacet.reversedPrimeGrid_dimension, Erdos416Proof.FordBadFacet.reversedPrimeGrid_endpoint_succ, Erdos416Proof.FordBadFacet.reversedPrimeGrid_multiplicity, Erdos416Proof.FordBadFacet.reversedPrimeGrid_zero] using hq j) (by intro idx; change k+1-idx.val ≤ k+1; omega) intro idx j rw [reversedPrimeGrid_endpoint_succ] apply (min_le_right F (v idx.rev)).trans apply (hvq idx.rev).trans apply hanti change j.val ≤ k-(idx.val+1)+1 have hi : idx.val < k := idx.isLt have hj : j.val < k+1-idx.val := j.isLt omega /- Original line 41830: Erdos416Proof.FordBadFacet.totient_mem_reversedPrimeGrid -/ theorem totient_mem_reversedPrimeGrid {x : ℝ} {N k : ℕ} (hx : 0 ≤ x) (hN : 0 < N) (S F : ℝ) (v : Fin k → ℝ) (q : Fin (k+1) → ℕ) (hinj : Function.Injective q) (hanti : Antitone (fun j => (q j : ℝ))) (hq : ∀ j, SNormal S (q j) ∧ q j ∣ N) (hvq : ∀ idx, v idx ≤ (q idx.succ : ℝ)) (hmx : (N.totient : ℝ) ≤ x) (hSq : NoLargePrimeSquare N.totient S) (hOmega : (ArithmeticFunction.cardFactors N.totient : ℝ) ≤ 5*logLog x) : N.totient ∈ normalGridValues x (reversedPrimeGrid k S F v) := by apply mem_filter.mpr refine ⟨(mem_totientsUpTo hx).mpr ⟨Nat.totient_pos.mpr hN, hmx, N, hN, rfl⟩, ?_, hOmega, reversedPrimeGrid_witness hN S F v q hinj hanti hq hvq⟩ simpa [Erdos416Proof.FordBadFacet.reversedPrimeGrid_dimension, Erdos416Proof.FordBadFacet.reversedPrimeGrid_endpoint_succ, Erdos416Proof.FordBadFacet.reversedPrimeGrid_multiplicity, Erdos416Proof.FordBadFacet.reversedPrimeGrid_zero, Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint] using hSq end Erdos416Proof.FordBadFacet end /- Consolidated component: ActualFacetBound.lean. -/ section open Filter Finset open scoped Classical Topology BigOperators Nat namespace Erdos416Proof.FordBadFacet /-- The descending logarithmic coordinates of the actual reversed prime grid. Coordinates `1, ..., k` are capped prime thresholds, and coordinate `k+1` is the normality scale. Coordinate zero is unused. -/ /- Original line 41861: Erdos416Proof.FordBadFacet.reversedFacetLog -/ noncomputable def reversedFacetLog (k : ℕ) (S F : ℝ) (v : Fin k → ℝ) (j : ℕ) : ℝ := logLog ((reversedPrimeGrid k S F v).endpoint (k+1-j)) /- Original line 41865: Erdos416Proof.FordBadFacet.reversedFacetLog_bottom -/ theorem reversedFacetLog_bottom (k : ℕ) (S F : ℝ) (v : Fin k → ℝ) : reversedFacetLog k S F v (k+1) = logLog S := by simp [Erdos416Proof.FordBadFacet.reversedPrimeGrid_dimension, Erdos416Proof.FordBadFacet.reversedPrimeGrid_endpoint_succ, Erdos416Proof.FordBadFacet.reversedPrimeGrid_multiplicity, Erdos416Proof.FordBadFacet.reversedPrimeGrid_zero, Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, reversedFacetLog] /- Original line 41869: Erdos416Proof.FordBadFacet.reversedFacetLog_one -/ theorem reversedFacetLog_one (k : ℕ) (S F : ℝ) (v : Fin k → ℝ) : reversedFacetLog k S F v 1 = logLog ((reversedPrimeGrid k S F v).endpoint k) := by simp [Erdos416Proof.FordBadFacet.reversedFacetLog_bottom, Erdos416Proof.FordBadFacet.reversedPrimeGrid_dimension, Erdos416Proof.FordBadFacet.reversedPrimeGrid_endpoint_succ, Erdos416Proof.FordBadFacet.reversedPrimeGrid_multiplicity, Erdos416Proof.FordBadFacet.reversedPrimeGrid_zero, Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, reversedFacetLog] /- Original line 41873: Erdos416Proof.FordBadFacet.reversedFacetLog_succ -/ theorem reversedFacetLog_succ {k : ℕ} (S F : ℝ) (v : Fin k → ℝ) (idx : Fin k) : reversedFacetLog k S F v (idx.val+1) = logLog (min F (v idx)) := by unfold reversedFacetLog have he : k+1-(idx.val+1) = idx.rev.val+1 := by rw [Fin.val_rev] omega rw [he, reversedPrimeGrid_endpoint_rev_succ] /- Original line 41882: Erdos416Proof.FordBadFacet.reversedFacetLog_rev_lower -/ theorem reversedFacetLog_rev_lower {k : ℕ} (S F : ℝ) (v : Fin k → ℝ) (idx : Fin k) : reversedFacetLog k S F v (idx.rev.val+2) = logLog ((reversedPrimeGrid k S F v).endpoint idx.val) := by unfold reversedFacetLog have he : k+1-(idx.rev.val+2) = idx.val := by rw [Fin.val_rev] omega rw [he] /-- Reverse the actual sieve cells using `Fin.rev`. Their multiplicities become `2, ..., k+1`, exactly the integer tilts of the Ford facet identity. -/ /- Original line 41894: Erdos416Proof.FordBadFacet.reversedPrimeGrid_exponent_eq -/ theorem reversedPrimeGrid_exponent_eq (k : ℕ) (S F B : ℝ) (v : Fin k → ℝ) : normalGridExponent B (reversedPrimeGrid k S F v) = ∑ idx : Fin k, (integerEntropy (idx.val+2) * (reversedFacetLog k S F v (idx.val+1)-reversedFacetLog k S F v (idx.val+2)) + 2*(idx.val+2 : ℕ)*Real.sqrt (logLog S*logLog (min F (v idx)))* Real.log (idx.val+2 : ℕ)+(idx.val+2 : ℕ)*B) := by unfold normalGridExponent change (∑ idx : Fin k, ((((reversedPrimeGrid k S F v).multiplicity idx : ℝ) - ((reversedPrimeGrid k S F v).multiplicity idx : ℝ) * Real.log ((reversedPrimeGrid k S F v).multiplicity idx)) * (logLog ((reversedPrimeGrid k S F v).endpoint (idx.val+1)) - logLog ((reversedPrimeGrid k S F v).endpoint idx.val)) + 2 * ((reversedPrimeGrid k S F v).multiplicity idx : ℝ) * Real.sqrt (logLog ((reversedPrimeGrid k S F v).endpoint 0) * logLog ((reversedPrimeGrid k S F v).endpoint (idx.val+1))) * Real.log ((reversedPrimeGrid k S F v).multiplicity idx) + ((reversedPrimeGrid k S F v).multiplicity idx : ℝ)*B)) = _ apply Fintype.sum_equiv Fin.revPerm _ _ intro idx have hi : idx.val < k := idx.isLt have hm : k+1-idx.val = idx.rev.val+2 := by rw [Fin.val_rev] omega have hupper : idx.val+1 ≤ k := by omega have hindex : (⟨k-(idx.val+1), by omega⟩ : Fin k) = idx.rev := by apply Fin.ext exact (Fin.val_rev idx).symm simp only [Fin.revPerm_apply] rw [reversedFacetLog_succ, reversedFacetLog_rev_lower] simp [Erdos416Proof.FordBadFacet.integerEntropy_one, Erdos416Proof.FordBadFacet.reversedFacetLog_bottom, Erdos416Proof.FordBadFacet.reversedFacetLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_succ, Erdos416Proof.FordBadFacet.reversedPrimeGrid_dimension, Erdos416Proof.FordBadFacet.reversedPrimeGrid_endpoint_succ, Erdos416Proof.FordBadFacet.reversedPrimeGrid_multiplicity, Erdos416Proof.FordBadFacet.reversedPrimeGrid_zero, Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, hm, hupper, hindex, integerEntropy] /-- A failed facet gives an exponentially smaller sieve weight for the actual prime grid. The only analytic assumption is the displayed finite loss budget; there is no assumed estimate for the number of bad values. -/ /- Original line 41930: Erdos416Proof.FordBadFacet.reversedPrimeGrid_weight_saving -/ theorem reversedPrimeGrid_weight_saving {x : ℝ} (k : ℕ) (S F B D ω T : ℝ) (v : Fin k → ℝ) (ha : NormalGridAdmissible x (reversedPrimeGrid k S F v)) (hbottom : 0 ≤ logLog S) (hD : 0 ≤ D) (hB : 0 ≤ B) (hδ : ∀ idx, 0 ≤ Real.sqrt (logLog S*logLog (min F (v idx))) ∧ Real.sqrt (logLog S*logLog (min F (v idx))) ≤ D) (hfacet : (1+ω)*T ≤ ∑ idx : Fin k, fordWeight (idx.val+1)*logLog (min F (v idx))) (hbudget : (k+1 : ℕ)*Real.log (k+1 : ℕ)*logLog S + ((k+1 : ℕ) : ℝ)^2*(2*D*Real.log (k+1 : ℕ)+B) ≤ ω/2*T) : normalGridWeight B (reversedPrimeGrid k S F v) ≤ Real.exp (-(1+ω/2)*T) := by have hfacet' : (1+ω)*T ≤ ∑ idx ∈ range k, fordWeight (idx+1)*reversedFacetLog k S F v (idx+1) := by rw [← Fin.sum_univ_eq_sum_range (fun idx : ℕ => fordWeight (idx+1)*reversedFacetLog k S F v (idx+1)) k] simpa only [reversedFacetLog_succ] using hfacet have hsave := shifted_integer_entropy_exponential_saving k (reversedFacetLog k S F v) (fun idx => Real.sqrt (logLog S*logLog (min F (v idx)))) D B ω T (by simpa only [reversedFacetLog_bottom] using hbottom) hD hB hδ hfacet' (by simpa only [reversedFacetLog_bottom] using hbudget) have hS : 1 < S := by have h : 4 ≤ S := by simpa [Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordBadFacet.integerEntropy_one, Erdos416Proof.FordBadFacet.reversedFacetLog_bottom, Erdos416Proof.FordBadFacet.reversedFacetLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_succ, Erdos416Proof.FordBadFacet.reversedPrimeGrid_dimension, Erdos416Proof.FordBadFacet.reversedPrimeGrid_endpoint_succ, Erdos416Proof.FordBadFacet.reversedPrimeGrid_multiplicity, Erdos416Proof.FordBadFacet.reversedPrimeGrid_zero, Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint] using ha.four_le_scale linarith have htop : 1 < (reversedPrimeGrid k S F v).endpoint k := by have h : S ≤ (reversedPrimeGrid k S F v).endpoint k := by simpa [Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordBadFacet.integerEntropy_one, Erdos416Proof.FordBadFacet.reversedFacetLog_bottom, Erdos416Proof.FordBadFacet.reversedFacetLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_succ, Erdos416Proof.FordBadFacet.reversedPrimeGrid_dimension, Erdos416Proof.FordBadFacet.reversedPrimeGrid_endpoint_succ, Erdos416Proof.FordBadFacet.reversedPrimeGrid_multiplicity, Erdos416Proof.FordBadFacet.reversedPrimeGrid_zero, Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint] using ha.increasing 0 k (Nat.zero_le k) (by rfl) linarith change Real.log S / Real.log ((reversedPrimeGrid k S F v).endpoint k) * Real.exp (normalGridExponent B (reversedPrimeGrid k S F v)) ≤ _ rw [log_ratio_mul_exp _ _ _ hS htop, reversedPrimeGrid_exponent_eq] simpa only [reversedFacetLog_bottom, reversedFacetLog_one] using hsave /-- The common square-root error can be bounded from the capped coordinate upper bound alone. This is the input used with a concrete normality scale. -/ /- Original line 41964: Erdos416Proof.FordBadFacet.reversedPrimeGrid_error_le -/ theorem reversedPrimeGrid_error_le {k : ℕ} (S F T : ℝ) (v : Fin k → ℝ) (hbottom : 0 ≤ logLog S) (htop : ∀ idx, logLog (min F (v idx)) ≤ T) : ∀ idx, 0 ≤ Real.sqrt (logLog S*logLog (min F (v idx))) ∧ Real.sqrt (logLog S*logLog (min F (v idx))) ≤ Real.sqrt (logLog S*T) := by intro idx exact ⟨Real.sqrt_nonneg _, Real.sqrt_le_sqrt (mul_le_mul_of_nonneg_left (htop idx) hbottom)⟩ /-- An actual Lemma 4.1/4.2 bound for the finite set of distinct totient values admitting the prescribed normal-prime grid. Constants are absolute, and the facet and loss hypotheses are purely numerical. -/ /- Original line 41975: Erdos416Proof.FordBadFacet.exists_actualFacet_bound -/ theorem exists_actualFacet_bound : ∃ C B : ℝ, 0 < C ∧ 0 ≤ B ∧ ∀ (x : ℝ) (k : ℕ) (S F D ω T : ℝ) (v : Fin k → ℝ), NormalGridAdmissible x (reversedPrimeGrid k S F v) → 0 ≤ logLog S → 0 ≤ D → (∀ idx, 0 ≤ Real.sqrt (logLog S*logLog (min F (v idx))) ∧ Real.sqrt (logLog S*logLog (min F (v idx))) ≤ D) → (1+ω)*T ≤ ∑ idx : Fin k, fordWeight (idx.val+1)*logLog (min F (v idx)) → (k+1 : ℕ)*Real.log (k+1 : ℕ)*logLog S + ((k+1 : ℕ) : ℝ)^2*(2*D*Real.log (k+1 : ℕ)+B) ≤ ω/2*T → ((normalGridValues x (reversedPrimeGrid k S F v)).card : ℝ) ≤ C*x*Real.exp (-(1+ω/2)*T) := by obtain ⟨C, B, hC, hB, hbound⟩ := exists_normalGridValues_bound refine ⟨C, B, hC, hB, ?_⟩ intro x k S F D ω T v ha hbottom hD hδ hfacet hbudget apply (hbound x (reversedPrimeGrid k S F v) ha).trans exact mul_le_mul_of_nonneg_left (reversedPrimeGrid_weight_saving k S F B D ω T v ha hbottom hD hB hδ hfacet hbudget) (mul_nonneg hC.le (by linarith [ha.large_x])) /-- Coordinate boxes may overlap. Their finite union is charged once per distinct totient value, with only the number of boxes appearing as a loss. -/ /- Original line 41996: Erdos416Proof.FordBadFacet.exists_actualFacet_union_bound -/ theorem exists_actualFacet_union_bound : ∃ C B : ℝ, 0 < C ∧ 0 ≤ B ∧ ∀ (x : ℝ) (k : ℕ) (S F D ω T : ℝ) (R : Finset (Fin k → ℝ)), (∀ v ∈ R, NormalGridAdmissible x (reversedPrimeGrid k S F v)) → 0 ≤ logLog S → 0 ≤ D → (∀ v ∈ R, ∀ idx, 0 ≤ Real.sqrt (logLog S*logLog (min F (v idx))) ∧ Real.sqrt (logLog S*logLog (min F (v idx))) ≤ D) → (∀ v ∈ R, (1+ω)*T ≤ ∑ idx : Fin k, fordWeight (idx.val+1)*logLog (min F (v idx))) → (k+1 : ℕ)*Real.log (k+1 : ℕ)*logLog S + ((k+1 : ℕ) : ℝ)^2*(2*D*Real.log (k+1 : ℕ)+B) ≤ ω/2*T → ((R.biUnion (fun v => normalGridValues x (reversedPrimeGrid k S F v))).card : ℝ) ≤ (R.card : ℝ)*C*x*Real.exp (-(1+ω/2)*T) := by obtain ⟨C, B, hC, hB, hbound⟩ := exists_actualFacet_bound refine ⟨C, B, hC, hB, ?_⟩ intro x k S F D ω T R ha hbottom hD hδ hfacet hbudget calc _ ≤ ∑ v ∈ R, ((normalGridValues x (reversedPrimeGrid k S F v)).card : ℝ) := by exact_mod_cast (Finset.card_biUnion_le (s := R) (t := fun v => normalGridValues x (reversedPrimeGrid k S F v))) _ ≤ ∑ _v ∈ R, C*x*Real.exp (-(1+ω/2)*T) := by exact sum_le_sum fun v hv => hbound x k S F D ω T v (ha v hv) hbottom hD (hδ v hv) (hfacet v hv) hbudget _ = _ := by simp only [sum_const, nsmul_eq_mul]; ring /-- Substituting the chosen normality scale removes the free error parameter and the entropy budget from the actual-grid weight estimate. -/ /- Original line 42021: Erdos416Proof.FordBadFacet.reversedPrimeGrid_concrete_scale_weight_saving -/ theorem reversedPrimeGrid_concrete_scale_weight_saving {x : ℝ} (k : ℕ) (F B ω T : ℝ) (v : Fin k → ℝ) (ha : NormalGridAdmissible x (reversedPrimeGrid k (facetNormalityScale ((k+1 : ℕ) : ℝ) ω T) F v)) (hB : 0 ≤ B) (hω : 0 ≤ ω) (hω1 : ω ≤ 1) (hT : 0 ≤ T) (hlarge : 16*normalityCost ((k+1 : ℕ) : ℝ)*B ≤ ω*T) (htop : ∀ idx, logLog (min F (v idx)) ≤ T) (hfacet : (1+ω)*T ≤ ∑ idx : Fin k, fordWeight (idx.val+1)*logLog (min F (v idx))) : normalGridWeight B (reversedPrimeGrid k (facetNormalityScale ((k+1 : ℕ) : ℝ) ω T) F v) ≤ Real.exp (-(1+ω/2)*T) := by have hN : (1 : ℝ) ≤ ((k+1 : ℕ) : ℝ) := by exact_mod_cast (show 1 ≤ k+1 by omega) have hlog : logLog (facetNormalityScale ((k+1 : ℕ) : ℝ) ω T) = facetNormalityParameter ((k+1 : ℕ) : ℝ) ω T := by exact facetNormalityScale_logLog _ _ _ have hbottom : 0 ≤ logLog (facetNormalityScale ((k+1 : ℕ) : ℝ) ω T) := by rw [hlog] exact (facetNormalityParameter_le hN hω hω1 hT).1 apply reversedPrimeGrid_weight_saving k _ F B (Real.sqrt (logLog (facetNormalityScale ((k+1 : ℕ) : ℝ) ω T)*T)) ω T v ha hbottom (Real.sqrt_nonneg _) hB (reversedPrimeGrid_error_le _ F T v hbottom htop) hfacet rw [hlog] exact facet_normality_budget hN hB hω hω1 hT hlarge /-- The actual-value facet bound with the normality scale substituted. Only endpoint admissibility, the violated facet, and the explicit linear size condition on the absolute Mertens constant remain. -/ /- Original line 42050: Erdos416Proof.FordBadFacet.exists_actualFacet_concrete_scale_bound -/ theorem exists_actualFacet_concrete_scale_bound : ∃ C B : ℝ, 0 < C ∧ 0 ≤ B ∧ ∀ (x : ℝ) (k : ℕ) (F ω T : ℝ) (v : Fin k → ℝ), NormalGridAdmissible x (reversedPrimeGrid k (facetNormalityScale ((k+1 : ℕ) : ℝ) ω T) F v) → 0 ≤ ω → ω ≤ 1 → 0 ≤ T → 16*normalityCost ((k+1 : ℕ) : ℝ)*B ≤ ω*T → (∀ idx, logLog (min F (v idx)) ≤ T) → (1+ω)*T ≤ ∑ idx : Fin k, fordWeight (idx.val+1)*logLog (min F (v idx)) → ((normalGridValues x (reversedPrimeGrid k (facetNormalityScale ((k+1 : ℕ) : ℝ) ω T) F v)).card : ℝ) ≤ C*x*Real.exp (-(1+ω/2)*T) := by obtain ⟨C, B, hC, hB, hbound⟩ := exists_normalGridValues_bound refine ⟨C, B, hC, hB, ?_⟩ intro x k F ω T v ha hω hω1 hT hlarge htop hfacet apply (hbound x _ ha).trans exact mul_le_mul_of_nonneg_left (reversedPrimeGrid_concrete_scale_weight_saving k F B ω T v ha hB hω hω1 hT hlarge htop hfacet) (mul_nonneg hC.le (by linarith [ha.large_x])) /-- The same fully substituted estimate for any finite collection of boxes. -/ /- Original line 42070: Erdos416Proof.FordBadFacet.exists_actualFacet_concrete_scale_union_bound -/ theorem exists_actualFacet_concrete_scale_union_bound : ∃ C B : ℝ, 0 < C ∧ 0 ≤ B ∧ ∀ (x : ℝ) (k : ℕ) (F ω T : ℝ) (R : Finset (Fin k → ℝ)), (∀ v ∈ R, NormalGridAdmissible x (reversedPrimeGrid k (facetNormalityScale ((k+1 : ℕ) : ℝ) ω T) F v)) → 0 ≤ ω → ω ≤ 1 → 0 ≤ T → 16*normalityCost ((k+1 : ℕ) : ℝ)*B ≤ ω*T → (∀ v ∈ R, ∀ idx, logLog (min F (v idx)) ≤ T) → (∀ v ∈ R, (1+ω)*T ≤ ∑ idx : Fin k, fordWeight (idx.val+1)*logLog (min F (v idx))) → ((R.biUnion (fun v => normalGridValues x (reversedPrimeGrid k (facetNormalityScale ((k+1 : ℕ) : ℝ) ω T) F v))).card : ℝ) ≤ (R.card : ℝ)*C*x*Real.exp (-(1+ω/2)*T) := by obtain ⟨C, B, hC, hB, hbound⟩ := exists_actualFacet_concrete_scale_bound refine ⟨C, B, hC, hB, ?_⟩ intro x k F ω T R ha hω hω1 hT hlarge htop hfacet calc _ ≤ ∑ v ∈ R, ((normalGridValues x (reversedPrimeGrid k (facetNormalityScale ((k+1 : ℕ) : ℝ) ω T) F v)).card : ℝ) := by exact_mod_cast (Finset.card_biUnion_le (s := R) (t := fun v => normalGridValues x (reversedPrimeGrid k (facetNormalityScale ((k+1 : ℕ) : ℝ) ω T) F v))) _ ≤ ∑ _v ∈ R, C*x*Real.exp (-(1+ω/2)*T) := by exact sum_le_sum fun v hv => hbound x k F ω T v (ha v hv) hω hω1 hT hlarge (htop v hv) (hfacet v hv) _ = _ := by simp only [sum_const, nsmul_eq_mul]; ring end Erdos416Proof.FordBadFacet end /- Consolidated component: SuffixCutoff.lean. -/ section open Filter Asymptotics Finset open scoped Classical Topology BigOperators namespace Erdos416Proof.FordRestricted /-- The exact margin in the first-failed-row decomposition. -/ /- Original line 42111: Erdos416Proof.FordRestricted.suffixMargin -/ noncomputable def suffixMargin (k : ℕ) : ℝ := (1 / 10000 : ℝ) * Real.exp (-(k : ℝ) / 40) /- Original line 42114: Erdos416Proof.FordRestricted.suffixMargin_pos -/ theorem suffixMargin_pos (k : ℕ) : 0 < suffixMargin k := by unfold suffixMargin positivity /- Original line 42118: Erdos416Proof.FordRestricted.suffixMargin_le_one -/ theorem suffixMargin_le_one (k : ℕ) : suffixMargin k ≤ 1 := by have he : Real.exp (-(k : ℝ)/40) ≤ 1 := by rw [← Real.exp_zero] apply Real.exp_le_exp.mpr have hk : (0 : ℝ) ≤ k := Nat.cast_nonneg k linarith unfold suffixMargin calc _ ≤ (1/10000 : ℝ)*1 := mul_le_mul_of_nonneg_left he (by norm_num) _ ≤ 1 := by norm_num /-- A positive exponential remains after squaring the margin at slope 1/15. -/ /- Original line 42130: Erdos416Proof.FordRestricted.suffix_margin_squared_exp -/ theorem suffix_margin_squared_exp (k : ℕ) (K : ℝ) : suffixMargin k ^ 2 * Real.exp ((k : ℝ) / 15 + K) = (Real.exp K / 100000000) * Real.exp ((k : ℝ) / 60) := by calc _ = (1 / 100000000 : ℝ) * (Real.exp (-(k : ℝ) / 40) * Real.exp (-(k : ℝ) / 40) * Real.exp ((k : ℝ) / 15 + K)) := by unfold suffixMargin ring _ = (1 / 100000000 : ℝ) * Real.exp (K + (k : ℝ) / 60) := by rw [← Real.exp_add, ← Real.exp_add] congr 1 congr 1 ring _ = _ := by rw [Real.exp_add]; ring /-- At slope 1/20 the same quantity is constant in k, so it cannot absorb an unbounded polynomial loss uniformly. -/ /- Original line 42148: Erdos416Proof.FordRestricted.suffix_margin_old_slope -/ theorem suffix_margin_old_slope (k : ℕ) (K : ℝ) : suffixMargin k ^ 2 * Real.exp ((k : ℝ) / 20 + K) = Real.exp K / 100000000 := by calc _ = (1 / 100000000 : ℝ) * (Real.exp (-(k : ℝ) / 40) * Real.exp (-(k : ℝ) / 40) * Real.exp ((k : ℝ) / 20 + K)) := by unfold suffixMargin ring _ = (1 / 100000000 : ℝ) * Real.exp K := by rw [← Real.exp_add, ← Real.exp_add] congr 1 congr 1 ring _ = _ := by ring /-- Every fixed power loss is absorbed at the corrected cutoff. The multiplier D need not be positive. -/ /- Original line 42166: Erdos416Proof.FordRestricted.suffix_margin_dominates_power -/ theorem suffix_margin_dominates_power (K D : ℝ) (n : ℕ) : ∀ᶠ k : ℕ in atTop, D * ((k : ℝ) + 1) ^ n ≤ suffixMargin k ^ 2 * Real.exp ((k : ℝ) / 15 + K) := by let A : ℝ := Real.exp K / 100000000 have hA : 0 < A := by dsimp [A]; positivity have hsmall := (isLittleO_pow_exp_pos_mul_atTop n (show (0 : ℝ) < 1 / 60 by norm_num)).const_mul_left (|D| * (2 : ℝ) ^ n) filter_upwards [tendsto_natCast_atTop_atTop.eventually (hsmall.def hA), eventually_ge_atTop (1 : ℕ)] with k hk hk1 have hkR : (1 : ℝ) ≤ k := by exact_mod_cast hk1 have hk0 : (0 : ℝ) ≤ k := Nat.cast_nonneg k have hbound : (|D| * (2 : ℝ) ^ n) * (k : ℝ) ^ n ≤ A * Real.exp ((1 / 60 : ℝ) * (k : ℝ)) := by apply (le_abs_self _).trans simpa only [Real.norm_eq_abs, abs_of_pos (Real.exp_pos _)] using hk have hp : ((k : ℝ) + 1) ^ n ≤ (2 : ℝ) ^ n * (k : ℝ) ^ n := by have h := pow_le_pow_left₀ (by positivity : (0 : ℝ) ≤ (k : ℝ) + 1) (show (k : ℝ) + 1 ≤ 2 * (k : ℝ) by linarith) n simpa only [mul_pow] using h rw [suffix_margin_squared_exp] calc _ ≤ |D| * ((k : ℝ) + 1) ^ n := mul_le_mul_of_nonneg_right (le_abs_self D) (by positivity) _ ≤ |D| * ((2 : ℝ) ^ n * (k : ℝ) ^ n) := mul_le_mul_of_nonneg_left hp (abs_nonneg D) _ = (|D| * (2 : ℝ) ^ n) * (k : ℝ) ^ n := by ring _ ≤ A * Real.exp ((1 / 60 : ℝ) * (k : ℝ)) := hbound _ = _ := by dsimp [A] congr 1 congr 1 ring /-- This includes arbitrary fixed polynomial and logarithmic losses. -/ /- Original line 42202: Erdos416Proof.FordRestricted.suffix_margin_dominates_polylog -/ theorem suffix_margin_dominates_polylog (K D : ℝ) (hD : 0 ≤ D) (m n : ℕ) : ∀ᶠ k : ℕ in atTop, D * ((k : ℝ) + 1) ^ m * (1 + Real.log ((k : ℝ) + 1)) ^ n ≤ suffixMargin k ^ 2 * Real.exp ((k : ℝ) / 15 + K) := by filter_upwards [suffix_margin_dominates_power K D (m + n)] with k hk have hk0 : (0 : ℝ) ≤ k := Nat.cast_nonneg k have hlog0 : 0 ≤ Real.log ((k : ℝ) + 1) := Real.log_nonneg (by linarith) have hlog : 1 + Real.log ((k : ℝ) + 1) ≤ (k : ℝ) + 1 := by have h := Real.log_le_sub_one_of_pos (by positivity : (0 : ℝ) < (k : ℝ) + 1) linarith have hp := pow_le_pow_left₀ (by linarith : (0 : ℝ) ≤ 1 + Real.log ((k : ℝ) + 1)) hlog n calc _ ≤ D * ((k : ℝ) + 1) ^ m * ((k : ℝ) + 1) ^ n := mul_le_mul_of_nonneg_left hp (mul_nonneg hD (by positivity)) _ = D * ((k : ℝ) + 1) ^ (m + n) := by rw [pow_add]; ring _ ≤ _ := hk /-- The coarse k^4 log^2 k denominator still leaves enough saving to dominate a quadratic envelope loss. No weighted Cauchy--Schwarz estimate is needed merely to absorb these losses. -/ /- Original line 42222: Erdos416Proof.FordRestricted.suffix_margin_coarse_budget -/ theorem suffix_margin_coarse_budget (K D : ℝ) (hD : 0 ≤ D) : ∀ᶠ k : ℕ in atTop, D * ((k : ℝ) + 1) ^ 4 * (1 + Real.log ((k : ℝ) + 1)) ^ 2 * ((k : ℝ) + 1) ^ 2 ≤ suffixMargin k ^ 2 * Real.exp ((k : ℝ) / 15 + K) := by filter_upwards [suffix_margin_dominates_polylog K D hD 6 2] with k hk convert hk using 1 ring /-- Enlarge the cutoff constant once to absorb every finite exceptional row. This turns eventual absorption in the row index into a uniform all-row bound. -/ /- Original line 42233: Erdos416Proof.FordRestricted.suffix_margin_uniformize -/ theorem suffix_margin_uniformize (f : ℕ → ℝ) (hf : ∀ᶠ k : ℕ in atTop, f k ≤ suffixMargin k^2*Real.exp ((k : ℝ)/15)) : ∃ K : ℝ, 0 ≤ K ∧ ∀ k : ℕ, f k ≤ suffixMargin k^2*Real.exp ((k : ℝ)/15+K) := by obtain ⟨k₀, hk₀⟩ := eventually_atTop.mp hf let c : ℕ → ℝ := fun k => suffixMargin k^2*Real.exp ((k : ℝ)/15) have hc (k : ℕ) : 0 < c k := by dsimp [c] exact mul_pos (sq_pos_of_pos (suffixMargin_pos k)) (Real.exp_pos _) let A : ℝ := 1 + ∑ j ∈ range k₀, |f j|/c j have hsum : 0 ≤ ∑ j ∈ range k₀, |f j|/c j := sum_nonneg fun j _ => div_nonneg (abs_nonneg _) (hc j).le have hA : 1 ≤ A := by dsimp [A]; linarith have hApos : 0 < A := by linarith have hall (k : ℕ) : f k ≤ A*c k := by by_cases hk : k < k₀ · have hsingle : |f k|/c k ≤ ∑ j ∈ range k₀, |f j|/c j := single_le_sum (fun j _ => div_nonneg (abs_nonneg _) (hc j).le) (mem_range.mpr hk) have hratio : |f k|/c k ≤ A := by dsimp [A]; linarith exact (le_abs_self _).trans ((div_le_iff₀ (hc k)).mp hratio) · have htail : f k ≤ c k := hk₀ k (by omega) apply htail.trans simpa only [one_mul] using mul_le_mul_of_nonneg_right hA (hc k).le refine ⟨Real.log A, Real.log_nonneg hA, ?_⟩ intro k apply (hall k).trans_eq rw [Real.exp_add, Real.exp_log hApos] dsimp [c] ring /-- A single nonnegative cutoff constant absorbs any prescribed fixed polynomial and logarithmic loss, uniformly for every row index. -/ /- Original line 42266: Erdos416Proof.FordRestricted.exists_suffix_margin_dominates_polylog -/ theorem exists_suffix_margin_dominates_polylog (D : ℝ) (hD : 0 ≤ D) (m n : ℕ) : ∃ K : ℝ, 0 ≤ K ∧ ∀ k : ℕ, D*((k : ℝ)+1)^m*(1+Real.log ((k : ℝ)+1))^n ≤ suffixMargin k^2*Real.exp ((k : ℝ)/15+K) := by apply suffix_margin_uniformize simpa only [add_zero] using suffix_margin_dominates_polylog 0 D hD m n /-- Uniform absorption persists throughout the range above the corrected cutoff. Here `T` is the logarithm of the logarithm of the counting endpoint. -/ /- Original line 42275: Erdos416Proof.FordRestricted.exists_suffix_margin_dominates_polylog_above -/ theorem exists_suffix_margin_dominates_polylog_above (D : ℝ) (hD : 0 ≤ D) (m n : ℕ) : ∃ K : ℝ, 0 ≤ K ∧ ∀ (k : ℕ) (T : ℝ), Real.exp ((k : ℝ)/15+K) ≤ T → D*((k : ℝ)+1)^m*(1+Real.log ((k : ℝ)+1))^n ≤ suffixMargin k^2*T := by obtain ⟨K, hK, hbound⟩ := exists_suffix_margin_dominates_polylog D hD m n exact ⟨K, hK, fun k T hT => (hbound k).trans (mul_le_mul_of_nonneg_left hT (sq_nonneg _))⟩ /-- Corrected endpoint for first-failed-row suffix sums. -/ /- Original line 42284: Erdos416Proof.FordRestricted.suffixCutoff -/ noncomputable def suffixCutoff (K : ℝ) (k : ℕ) : ℝ := Real.exp (Real.exp (Real.exp ((k : ℝ) / 15 + K))) /- Original line 42287: Erdos416Proof.FordRestricted.suffixCutoff_tendsto -/ theorem suffixCutoff_tendsto (K : ℝ) : Tendsto (suffixCutoff K) atTop atTop := by have h : Tendsto (fun k : ℕ => (k : ℝ) / 15 + K) atTop atTop := tendsto_atTop_add_const_right _ _ (tendsto_natCast_atTop_atTop.atTop_div_const (by norm_num : (0 : ℝ) < 15)) exact Real.tendsto_exp_atTop.comp (Real.tendsto_exp_atTop.comp (Real.tendsto_exp_atTop.comp h)) /- Original line 42294: Erdos416Proof.FordRestricted.suffixCutoff_log3 -/ theorem suffixCutoff_log3 (K : ℝ) (k : ℕ) : Real.log (logLog (suffixCutoff K k)) = (k : ℝ) / 15 + K := by simp only [suffixCutoff, logLog, Real.log_exp] /-- The cost of the corrected cutoff has quadratic coefficient 16/225, which remains strictly below the available Gaussian threshold 1/8. -/ /- Original line 42300: Erdos416Proof.FordRestricted.suffixCutoff_quadratic_budget -/ theorem suffixCutoff_quadratic_budget : (16 / 225 : ℝ) < 1 / 8 := by norm_num /- Original line 42302: Erdos416Proof.FordRestricted.restricted_reciprocal_at_suffixCutoff -/ theorem restricted_reciprocal_at_suffixCutoff (K : ℝ) : ∀ᶠ k : ℕ in atTop, ∀ F : Finset ℕ, (∀ n ∈ F, n ∈ Nat.factoredNumbers (Nat.primesLE ⌊suffixCutoff K k⌋₊)) → (∀ n ∈ F, ∃ m : ℕ, 0 < m ∧ m.totient = n) → (∑ n ∈ F, (1 : ℝ) / n) ≤ Real.exp ((16 / 225 : ℝ) * (k : ℝ) ^ 2 + ((32 / 15 : ℝ) * |K| + 16 * K ^ 2) * (k : ℝ)) := by filter_upwards [(suffixCutoff_tendsto K).eventually restricted_totient_reciprocal_explicit_bound, eventually_ge_atTop (1 : ℕ)] with k hk hk1 intro F hF hφ apply (hk F hF hφ).trans rw [suffixCutoff_log3] apply Real.exp_le_exp.mpr have hkR : (1 : ℝ) ≤ k := by exact_mod_cast hk1 have hcross := mul_le_mul_of_nonneg_right (le_abs_self K) (show (0 : ℝ) ≤ k by positivity) have hconstant := mul_le_mul_of_nonneg_left hkR (sq_nonneg K) nlinarith /- Original line 42322: Erdos416Proof.FordRestricted.suffixCutoff_prefix_factor_summable -/ theorem suffixCutoff_prefix_factor_summable (K : ℝ) (M : ℕ) : Summable (FordGeometry.quadraticPrefixFactor (16 / 225) M ((32 / 15 : ℝ) * |K| + 16 * K ^ 2)) := FordGeometry.quadraticPrefixFactor_summable suffixCutoff_quadratic_budget M _ end Erdos416Proof.FordRestricted end /- Consolidated component: PowerCutoff.lean. -/ section open Filter Finset Asymptotics open scoped Classical Topology namespace Erdos416Proof.Simplified /- Original line 42343: Erdos416Proof.Simplified.V_le_endpoint -/ theorem V_le_endpoint {x : ℝ} (hx : 0 ≤ x) : V x ≤ x := by exact finite_positive_card_le hx (totientsUpTo x) (fun n hn => ⟨((mem_totientsUpTo hx).mp hn).1, ((mem_totientsUpTo hx).mp hn).2.1⟩) /-- Every fixed power below one is negligible relative to the actual totient count. Only its proved Chebyshev lower bound is needed. -/ /- Original line 42349: Erdos416Proof.Simplified.rpow_negligible_in_V -/ theorem rpow_negligible_in_V {a : ℝ} (ha : a < 1) : (fun x : ℝ => x ^ a) =o[atTop] V := by rw [isLittleO_iff] intro ε hε have hsmall := (log_pow_mul_rpow_littleO 1 ha).def (half_pos hε) filter_upwards [hsmall, V_lower_bound_eventually, eventually_gt_atTop (1 : ℝ)] with x hsmall hV hx have hx0 : 0 < x := by linarith have hlog : 0 < Real.log x := Real.log_pos hx have hpow : 0 ≤ x ^ a := Real.rpow_nonneg hx0.le a simp only [Real.norm_eq_abs, pow_one, Real.rpow_one, abs_of_nonneg (mul_nonneg hlog.le hpow), abs_of_pos hx0] at hsmall simp only [Real.norm_eq_abs, abs_of_nonneg hpow, abs_of_nonneg (V_nonneg x)] have hden := (div_le_iff₀ (by positivity : 0 < 2 * Real.log x)).mp hV have hmul := mul_le_mul_of_nonneg_left hden (half_pos hε).le apply (mul_le_mul_iff_of_pos_left hlog).mp nlinarith /-- Distinct totients below a fixed power cutoff have vanishing relative count. -/ /- Original line 42368: Erdos416Proof.Simplified.V_rpow_negligible -/ theorem V_rpow_negligible {a : ℝ} (ha : a < 1) : (fun x : ℝ => V (x ^ a)) =o[atTop] V := by have hdom : (fun x : ℝ => V (x ^ a)) =O[atTop] (fun x : ℝ => x ^ a) := by apply IsBigO.of_norm_eventuallyLE filter_upwards [eventually_ge_atTop (0 : ℝ)] with x hx have hpow := Real.rpow_nonneg hx a simpa only [Real.norm_eq_abs, abs_of_nonneg (V_nonneg _), abs_of_nonneg hpow] using V_le_endpoint hpow exact hdom.trans_isLittleO (rpow_negligible_in_V ha) /- Original line 42378: Erdos416Proof.Simplified.V_power_cutoff_negligible -/ theorem V_power_cutoff_negligible : (fun x : ℝ => V (x ^ (99 / 100 : ℝ))) =o[atTop] V := V_rpow_negligible (by norm_num) /-- The actual distinct totients in the retained interval `(x^a, x]`. -/ /- Original line 42383: Erdos416Proof.Simplified.powerRangeTotients -/ noncomputable def powerRangeTotients (a x : ℝ) : Finset ℕ := (totientsUpTo x).filter (fun n => x ^ a < (n : ℝ)) /- Original line 42386: Erdos416Proof.Simplified.powerRangeTotients_eq_sdiff -/ theorem powerRangeTotients_eq_sdiff (a : ℝ) {x : ℝ} (hx : 0 ≤ x) : powerRangeTotients a x = totientsUpTo x \ totientsUpTo (x ^ a) := by have hpow := Real.rpow_nonneg hx a apply Finset.ext intro n simp only [powerRangeTotients, Finset.mem_filter, Finset.mem_sdiff] constructor · rintro ⟨hn, hcut⟩ exact ⟨hn, fun hlow => (not_lt_of_ge ((mem_totientsUpTo hpow).mp hlow).2.1) hcut⟩ · rintro ⟨hn, hlow⟩ refine ⟨hn, ?_⟩ by_contra hcut apply hlow obtain ⟨hnpos, _, hnvalue⟩ := (mem_totientsUpTo hx).mp hn exact (mem_totientsUpTo hpow).mpr ⟨hnpos, le_of_not_gt hcut, hnvalue⟩ /- Original line 42402: Erdos416Proof.Simplified.powerRangeTotients_count_defect -/ theorem powerRangeTotients_count_defect {a x : ℝ} (ha : a ≤ 1) (hx : 1 ≤ x) : V x - ((powerRangeTotients a x).card : ℝ) = V (x ^ a) := by have hx0 : 0 ≤ x := by linarith have hsub := totientsUpTo_mono (Real.rpow_le_self_of_one_le hx ha) unfold V rw [powerRangeTotients_eq_sdiff a hx0, Finset.card_sdiff_of_subset hsub, Nat.cast_sub (Finset.card_le_card hsub)] ring /-- The retained interval differs from the full distinct-totient count by little-o of that count; the lower endpoint is excluded exactly. -/ /- Original line 42413: Erdos416Proof.Simplified.powerRangeTotients_count_defect_negligible -/ theorem powerRangeTotients_count_defect_negligible {a : ℝ} (ha : a < 1) : (fun x : ℝ => V x - ((powerRangeTotients a x).card : ℝ)) =o[atTop] V := by apply (V_rpow_negligible ha).congr' _ (Eventually.of_forall fun _ => rfl) filter_upwards [eventually_ge_atTop (1 : ℝ)] with x hx exact (powerRangeTotients_count_defect ha.le hx).symm /- Original line 42419: Erdos416Proof.Simplified.powerRangeTotients_99_count_defect_negligible -/ theorem powerRangeTotients_99_count_defect_negligible : (fun x : ℝ => V x - ((powerRangeTotients (99 / 100) x).card : ℝ)) =o[atTop] V := powerRangeTotients_count_defect_negligible (by norm_num) end Erdos416Proof.Simplified end /- Consolidated component: FacetCoordinates.lean. -/ section open scoped Classical namespace Erdos416Proof.FordBadFacet /-- Ford's logarithmic coordinate is truncated at zero, including the padding prime 1 and the prime 2. -/ /- Original line 42440: Erdos416Proof.FordBadFacet.positiveLogLog -/ noncomputable def positiveLogLog (x : ℝ) : ℝ := max 0 (logLog x) /- Original line 42442: Erdos416Proof.FordBadFacet.positiveLogLog_one -/ theorem positiveLogLog_one : positiveLogLog 1 = 0 := by simp [Erdos416Proof.FordBadFacet.reversedFacetLog_bottom, Erdos416Proof.FordBadFacet.reversedFacetLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_succ, Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.FordRestricted.suffixCutoff_log3, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, positiveLogLog, logLog] /- Original line 42445: Erdos416Proof.FordBadFacet.positiveLogLog_mono -/ theorem positiveLogLog_mono {x y : ℝ} (hx : 1 ≤ x) (hxy : x ≤ y) : positiveLogLog x ≤ positiveLogLog y := by rcases eq_or_lt_of_le hx with heq | hlt · rw [← heq, positiveLogLog_one] exact le_max_left _ _ · exact max_le_max_left 0 (logLog_mono hlt hxy) /- Original line 42452: Erdos416Proof.FordBadFacet.fordPrimeCoordinate -/ noncomputable def fordPrimeCoordinate (T : ℝ) (p : ℕ) : ℝ := positiveLogLog p / T /- Original line 42454: Erdos416Proof.FordBadFacet.fordPrimeCoordinate_antitone -/ theorem fordPrimeCoordinate_antitone {ι : Type*} [Preorder ι] (q : ι → ℕ) (hq : ∀ idx, 1 ≤ q idx) (hanti : Antitone q) {T : ℝ} (hT : 0 ≤ T) : Antitone (fun idx => fordPrimeCoordinate T (q idx)) := by intro idx j hij exact div_le_div_of_nonneg_right (positiveLogLog_mono (by exact_mod_cast hq j) (by exact_mod_cast hanti hij)) hT /-- Every prime divisor of every positive preimage is bounded through the totient value itself; no selected-preimage size theorem is needed here. -/ /- Original line 42463: Erdos416Proof.FordBadFacet.preimage_prime_le_endpoint_add_one -/ theorem preimage_prime_le_endpoint_add_one {N p : ℕ} {x : ℝ} (hN : 0 < N) (hp : p.Prime) (hpn : p ∣ N) (hphi : (N.totient : ℝ) ≤ x) : (p : ℝ) ≤ x + 1 := by have hd := Nat.totient_dvd_of_dvd hpn rw [Nat.totient_prime hp] at hd have hn := Nat.le_of_dvd (Nat.totient_pos.mpr hN) hd have hr : ((p - 1 : ℕ) : ℝ) ≤ (N.totient : ℝ) := Nat.cast_le.mpr hn rw [Nat.cast_sub hp.one_le, Nat.cast_one] at hr linarith /-- The sharper upper coordinate bound is T+1 before normalization. This keeps the loss from capping at the sieve endpoint logarithmic in T. -/ /- Original line 42475: Erdos416Proof.FordBadFacet.preimage_prime_positiveLogLog_le -/ theorem preimage_prime_positiveLogLog_le {N p : ℕ} {x : ℝ} (hx : 2 ≤ x) (hT : 0 ≤ logLog x) (hN : 0 < N) (hp : p.Prime) (hpn : p ∣ N) (hphi : (N.totient : ℝ) ≤ x) : positiveLogLog p ≤ logLog x + 1 := by have hpbound := preimage_prime_le_endpoint_add_one hN hp hpn hphi have hlog := logLog_mono (by exact_mod_cast hp.one_lt : (1 : ℝ) < p) (show (p : ℝ) ≤ 2 * x by linarith) have hd := logLog_double_le hx exact max_le (by linarith) (by linarith) /- Original line 42485: Erdos416Proof.FordBadFacet.preimage_prime_coordinate_bounds -/ theorem preimage_prime_coordinate_bounds {N p : ℕ} {x : ℝ} (hx : 2 ≤ x) (hT : 1 ≤ logLog x) (hN : 0 < N) (hp : p.Prime) (hpn : p ∣ N) (hphi : (N.totient : ℝ) ≤ x) : 0 ≤ fordPrimeCoordinate (logLog x) p ∧ fordPrimeCoordinate (logLog x) p ≤ 2 := by have hTpos : 0 < logLog x := by linarith have hu := preimage_prime_positiveLogLog_le hx (by linarith) hN hp hpn hphi refine ⟨div_nonneg (le_max_left _ _) hTpos.le, ?_⟩ apply (div_le_iff₀ hTpos).mpr linarith /-- A positive lower bound on the truncated coordinate can be converted back to an actual prime threshold, including padded prime lists. -/ /- Original line 42497: Erdos416Proof.FordBadFacet.threshold_le_of_positiveLogLog -/ theorem threshold_le_of_positiveLogLog {p : ℕ} {S : ℝ} (hp : 1 ≤ p) (hS : Real.exp 1 < S) (hlow : logLog S ≤ positiveLogLog p) : S ≤ (p : ℝ) := by have hSpos : 0 < S := (Real.exp_pos 1).trans hS have hlogS : 1 < Real.log S := by have h := Real.log_lt_log (Real.exp_pos 1) hS simpa only [Real.log_exp] using h have hR : 0 < logLog S := Real.log_pos hlogS have hLL : logLog S ≤ logLog p := by rcases le_max_iff.mp hlow with hzero | hlog · linarith · exact hlog have hpne : p ≠ 1 := by intro heq subst p simp only [Nat.cast_one, logLog, Real.log_one, Real.log_zero] at hLL change logLog S ≤ 0 at hLL linarith have hp1 : (1 : ℝ) < p := by exact_mod_cast (by omega : 1 < p) have h := Real.exp_le_exp.mpr hLL change Real.exp (Real.log (Real.log S)) ≤ Real.exp (Real.log (Real.log (p : ℝ))) at h rw [Real.exp_log (by linarith : 0 < Real.log S), Real.exp_log (Real.log_pos hp1)] at h exact (Real.log_le_log_iff hSpos (by linarith)).mp h /- Original line 42522: Erdos416Proof.FordBadFacet.exp_exp_threshold_of_coordinate -/ theorem exp_exp_threshold_of_coordinate {p : ℕ} {θ T : ℝ} (hp : 1 ≤ p) (hθ : 0 < θ) (hT : 0 < T) (hbound : θ ≤ fordPrimeCoordinate T p) : Real.exp (Real.exp (θ * T)) ≤ (p : ℝ) := by have hS : Real.exp 1 < Real.exp (Real.exp (θ * T)) := Real.exp_lt_exp.mpr (Real.one_lt_exp_iff.mpr (mul_pos hθ hT)) apply threshold_le_of_positiveLogLog hp hS simp only [logLog, Real.log_exp] exact (le_div_iff₀ hT).mp hbound end Erdos416Proof.FordBadFacet end /- Consolidated component: OrdinaryPrimePrefix.lean. -/ section open Filter Finset open scoped Classical Topology BigOperators Nat namespace Erdos416Proof.FordBadFacet /-- Ordinary prime factors, with their original multiplicities, in decreasing order. No ordering by the largest factor of p-1 is used here. -/ /- Original line 42549: Erdos416Proof.FordBadFacet.ordinaryPrimeList -/ abbrev ordinaryPrimeList (N : ℕ) : List ℕ := N.primeFactorsList.reverse /- Original line 42551: Erdos416Proof.FordBadFacet.ordinaryPrimeList_sorted -/ theorem ordinaryPrimeList_sorted (N : ℕ) : (ordinaryPrimeList N).SortedGE := (Nat.primeFactorsList_sorted N).reverse /- Original line 42554: Erdos416Proof.FordBadFacet.ordinaryPrimeList_prod -/ theorem ordinaryPrimeList_prod {N : ℕ} (hN : N ≠ 0) : (ordinaryPrimeList N).prod = N := by rw [List.prod_reverse, Nat.prod_primeFactorsList hN] /- Original line 42557: Erdos416Proof.FordBadFacet.ordinaryPrimeList_length -/ theorem ordinaryPrimeList_length (N : ℕ) : (ordinaryPrimeList N).length = ArithmeticFunction.cardFactors N := by simp [ArithmeticFunction.cardFactors_apply] /- Original line 42561: Erdos416Proof.FordBadFacet.ordinaryPrimePrefix -/ abbrev ordinaryPrimePrefix (N L : ℕ) (hL : L ≤ (ordinaryPrimeList N).length) : Fin L → ℕ := fun idx => (ordinaryPrimeList N).get ⟨idx.val, idx.isLt.trans_le hL⟩ /-- Missing coordinates are padded by one, so every coordinate is positive. -/ /- Original line 42565: Erdos416Proof.FordBadFacet.ordinaryPrimeAt -/ abbrev ordinaryPrimeAt (N idx : ℕ) : ℕ := (ordinaryPrimeList N).getD idx 1 /- Original line 42567: Erdos416Proof.FordBadFacet.ordinaryPrimeAt_eq_prefix -/ theorem ordinaryPrimeAt_eq_prefix (N L : ℕ) (hL : L ≤ (ordinaryPrimeList N).length) (idx : Fin L) : ordinaryPrimeAt N idx.val = ordinaryPrimePrefix N L hL idx := List.getD_eq_get _ 1 ⟨idx.val, idx.isLt.trans_le hL⟩ /- Original line 42571: Erdos416Proof.FordBadFacet.ordinaryPrimeAt_eq_one -/ theorem ordinaryPrimeAt_eq_one {N idx : ℕ} (hi : (ordinaryPrimeList N).length ≤ idx) : ordinaryPrimeAt N idx = 1 := List.getD_eq_default _ _ hi /- Original line 42574: Erdos416Proof.FordBadFacet.ordinaryPrimeAt_spec -/ theorem ordinaryPrimeAt_spec (N idx : ℕ) : ordinaryPrimeAt N idx = 1 ∨ (ordinaryPrimeAt N idx).Prime ∧ ordinaryPrimeAt N idx ∣ N := by by_cases hi : idx < (ordinaryPrimeList N).length · right change ((ordinaryPrimeList N).getD idx 1).Prime ∧ (ordinaryPrimeList N).getD idx 1 ∣ N rw [List.getD_eq_getElem _ 1 hi] have hm : (ordinaryPrimeList N).get ⟨idx, hi⟩ ∈ N.primeFactorsList := List.mem_reverse.mp (List.get_mem _ _) exact ⟨Nat.prime_of_mem_primeFactorsList hm, Nat.dvd_of_mem_primeFactorsList hm⟩ · exact Or.inl (ordinaryPrimeAt_eq_one (by omega)) /- Original line 42585: Erdos416Proof.FordBadFacet.ordinaryPrimeAt_one_le -/ theorem ordinaryPrimeAt_one_le (N idx : ℕ) : 1 ≤ ordinaryPrimeAt N idx := by rcases ordinaryPrimeAt_spec N idx with h | ⟨h, _⟩ · rw [h] · exact h.one_le /- Original line 42590: Erdos416Proof.FordBadFacet.ordinaryPrimeAt_antitone -/ theorem ordinaryPrimeAt_antitone (N : ℕ) : Antitone (ordinaryPrimeAt N) := by intro idx j hij by_cases hj : j < (ordinaryPrimeList N).length · have hi : idx < (ordinaryPrimeList N).length := hij.trans_lt hj change (ordinaryPrimeList N).getD j 1 ≤ (ordinaryPrimeList N).getD idx 1 rw [List.getD_eq_getElem _ 1 hi, List.getD_eq_getElem _ 1 hj] exact (ordinaryPrimeList_sorted N).antitone_get hij · rw [ordinaryPrimeAt_eq_one (by omega)] exact ordinaryPrimeAt_one_le N idx /- Original line 42600: Erdos416Proof.FordBadFacet.ordinaryPrimePrefix_antitone -/ theorem ordinaryPrimePrefix_antitone (N L : ℕ) (hL : L ≤ (ordinaryPrimeList N).length) : Antitone (ordinaryPrimePrefix N L hL) := by intro idx j hij exact (ordinaryPrimeList_sorted N).antitone_get hij /- Original line 42605: Erdos416Proof.FordBadFacet.ordinaryPrimePrefix_mem -/ theorem ordinaryPrimePrefix_mem (N L : ℕ) (hL : L ≤ (ordinaryPrimeList N).length) (idx : Fin L) : ordinaryPrimePrefix N L hL idx ∈ N.primeFactorsList := by exact List.mem_reverse.mp (List.get_mem _ _) /- Original line 42609: Erdos416Proof.FordBadFacet.ordinaryPrimePrefix_prime -/ theorem ordinaryPrimePrefix_prime (N L : ℕ) (hL : L ≤ (ordinaryPrimeList N).length) (idx : Fin L) : (ordinaryPrimePrefix N L hL idx).Prime := Nat.prime_of_mem_primeFactorsList (ordinaryPrimePrefix_mem N L hL idx) /- Original line 42613: Erdos416Proof.FordBadFacet.ordinaryPrimePrefix_dvd -/ theorem ordinaryPrimePrefix_dvd (N L : ℕ) (hL : L ≤ (ordinaryPrimeList N).length) (idx : Fin L) : ordinaryPrimePrefix N L hL idx ∣ N := Nat.dvd_of_mem_primeFactorsList (ordinaryPrimePrefix_mem N L hL idx) /-- A squarefree large-prime part removes repeated entries only above H; the small prime factors retain all of their multiplicities. -/ /- Original line 42619: Erdos416Proof.FordBadFacet.ordinaryPrimeList_large_filter_nodup -/ theorem ordinaryPrimeList_large_filter_nodup {N : ℕ} (hN : N ≠ 0) {H : ℝ} (hSq : NoLargePrimeSquare N H) : ((ordinaryPrimeList N).filter (fun p : ℕ => decide (H < (p : ℝ)))).Nodup := by have hs := primePart_squarefree_of_no_large_square hN hSq (fun p => H < (p : ℝ)) (fun _ _ h => h) have hp := (primePart_factors_perm N (fun p => H < (p : ℝ))).nodup_iff.mpr hs.nodup_primeFactorsList have hr := List.nodup_reverse.mpr hp simpa only [List.filter_reverse] using hr /- Original line 42629: Erdos416Proof.FordBadFacet.ordinaryPrimeList_take_nodup -/ theorem ordinaryPrimeList_take_nodup {N L : ℕ} (hN : N ≠ 0) {H : ℝ} (hSq : NoLargePrimeSquare N H) (hlarge : ∀ p ∈ (ordinaryPrimeList N).take L, H < (p : ℝ)) : ((ordinaryPrimeList N).take L).Nodup := by have heq : ((ordinaryPrimeList N).take L).filter (fun p : ℕ => decide (H < (p : ℝ))) = (ordinaryPrimeList N).take L := by apply List.filter_eq_self.mpr intro p hp simpa only [decide_eq_true_eq] using hlarge p hp have hsub := (List.take_sublist L (ordinaryPrimeList N)).filter (fun p : ℕ => decide (H < (p : ℝ))) rw [heq] at hsub exact hsub.nodup (ordinaryPrimeList_large_filter_nodup hN hSq) /-- The initial ordinary prime-factor segment is injective whenever all its entries are above the cutoff for repeated prime factors of N itself. -/ /- Original line 42645: Erdos416Proof.FordBadFacet.ordinaryPrimePrefix_injective -/ theorem ordinaryPrimePrefix_injective {N L : ℕ} (hN : N ≠ 0) (hL : L ≤ (ordinaryPrimeList N).length) {H : ℝ} (hSq : NoLargePrimeSquare N H) (hlarge : ∀ idx, H < (ordinaryPrimePrefix N L hL idx : ℝ)) : Function.Injective (ordinaryPrimePrefix N L hL) := by have htakeLength : ((ordinaryPrimeList N).take L).length = L := List.length_take_of_le hL have htake : ((ordinaryPrimeList N).take L).Nodup := ordinaryPrimeList_take_nodup hN hSq (by intro p hp obtain ⟨idx, hi⟩ := List.mem_iff_get.mp hp have hiL : idx.val < L := by simpa only [htakeLength] using idx.isLt have heq : ordinaryPrimePrefix N L hL ⟨idx.val, hiL⟩ = p := by simpa only [List.get_eq_getElem, List.getElem_take] using hi simpa only [heq] using hlarge ⟨idx.val, hiL⟩) intro idx j hij have hi : idx.val < ((ordinaryPrimeList N).take L).length := by simpa only [htakeLength] using idx.isLt have hj : j.val < ((ordinaryPrimeList N).take L).length := by simpa only [htakeLength] using j.isLt have hget : ((ordinaryPrimeList N).take L).get ⟨idx.val, hi⟩ = ((ordinaryPrimeList N).take L).get ⟨j.val, hj⟩ := by simpa only [List.get_eq_getElem, List.getElem_take] using hij have heq := htake.injective_get hget exact Fin.ext (congrArg (fun a : Fin ((ordinaryPrimeList N).take L).length => a.val) heq) /- Original line 42667: Erdos416Proof.FordBadFacet.ordinaryPrimeAt_prefix_length -/ theorem ordinaryPrimeAt_prefix_length {N L : ℕ} {H : ℝ} (hH : 1 ≤ H) (hlarge : ∀ idx : Fin L, H < (ordinaryPrimeAt N idx.val : ℝ)) : L ≤ (ordinaryPrimeList N).length := by by_contra h have hi := hlarge ⟨(ordinaryPrimeList N).length, by omega⟩ rw [ordinaryPrimeAt_eq_one le_rfl, Nat.cast_one] at hi linarith /-- Excluding a value from nonNormalTotients controls every positive preimage, not just a preimage selected when defining the exceptional set. -/ /- Original line 42677: Erdos416Proof.FordBadFacet.prime_divisor_normal_of_good_totient -/ theorem prime_divisor_normal_of_good_totient {N : ℕ} {S x : ℝ} (hN : 0 < N) (hmV : N.totient ∈ totientsUpTo x) (hnormal : N.totient ∉ nonNormalTotients S x) {p : ℕ} (hp : p.Prime) (hpdvd : p ∣ N) : SNormal S p := by by_contra hbad exact hnormal (mem_filter.mpr ⟨hmV, N, hN, rfl, p, hp, hpdvd, hbad⟩) /- Original line 42683: Erdos416Proof.FordBadFacet.ordinaryPrimePrefix_normal -/ theorem ordinaryPrimePrefix_normal {N L : ℕ} {S x : ℝ} (hN : 0 < N) (hL : L ≤ (ordinaryPrimeList N).length) (hmV : N.totient ∈ totientsUpTo x) (hnormal : N.totient ∉ nonNormalTotients S x) (idx : Fin L) : SNormal S (ordinaryPrimePrefix N L hL idx) := prime_divisor_normal_of_good_totient hN hmV hnormal (ordinaryPrimePrefix_prime N L hL idx) (ordinaryPrimePrefix_dvd N L hL idx) /-- The concrete arithmetic bridge from an arbitrary retained preimage to a grid witness, using its own ordinary ordered prime-factor list. -/ /- Original line 42692: Erdos416Proof.FordBadFacet.ordinaryPrimePrefix_gridWitness -/ theorem ordinaryPrimePrefix_gridWitness {N k : ℕ} {S H x : ℝ} (hN : 0 < N) (hk : k+1 ≤ (ordinaryPrimeList N).length) (hmV : N.totient ∈ totientsUpTo x) (hnormal : N.totient ∉ nonNormalTotients S x) (hSq : NoLargePrimeSquare N H) (hlarge : ∀ idx, H < (ordinaryPrimePrefix N (k+1) hk idx : ℝ)) (F : ℝ) (v : Fin k → ℝ) (hvq : ∀ idx, v idx ≤ (ordinaryPrimePrefix N (k+1) hk idx.succ : ℝ)) : NormalGridWitness (reversedPrimeGrid k S F v) N.totient := by apply reversedPrimeGrid_witness hN S F v (ordinaryPrimePrefix N (k+1) hk) (ordinaryPrimePrefix_injective hN.ne' hk hSq hlarge) · intro idx j hij exact Nat.cast_le.mpr (ordinaryPrimePrefix_antitone N (k+1) hk hij) · intro idx exact ⟨ordinaryPrimePrefix_normal hN hk hmV hnormal idx, ordinaryPrimePrefix_dvd N (k+1) hk idx⟩ · exact hvq /- Original line 42707: Erdos416Proof.FordBadFacet.ordinaryPrimeAt_gridWitness -/ theorem ordinaryPrimeAt_gridWitness {N k : ℕ} {S H x : ℝ} (hN : 0 < N) (hH : 1 ≤ H) (hmV : N.totient ∈ totientsUpTo x) (hnormal : N.totient ∉ nonNormalTotients S x) (hSq : NoLargePrimeSquare N H) (hlarge : ∀ idx : Fin (k+1), H < (ordinaryPrimeAt N idx.val : ℝ)) (F : ℝ) (v : Fin k → ℝ) (hvq : ∀ idx, v idx ≤ (ordinaryPrimeAt N (idx.val+1) : ℝ)) : NormalGridWitness (reversedPrimeGrid k S F v) N.totient := by have hk := ordinaryPrimeAt_prefix_length hH hlarge have hlarge' : ∀ idx : Fin (k+1), H < (ordinaryPrimePrefix N (k+1) hk idx : ℝ) := by intro idx rw [← ordinaryPrimeAt_eq_prefix N (k+1) hk idx] exact hlarge idx apply ordinaryPrimePrefix_gridWitness hN hk hmV hnormal hSq hlarge' F v intro idx rw [← ordinaryPrimeAt_eq_prefix N (k+1) hk idx.succ] exact hvq idx /-- Only the last retained threshold is needed to rule out padding and repeated primes in the entire initial segment. -/ /- Original line 42725: Erdos416Proof.FordBadFacet.ordinaryPrimeAt_gridWitness_of_last_threshold -/ theorem ordinaryPrimeAt_gridWitness_of_last_threshold {N k : ℕ} {S H x : ℝ} (hN : 0 < N) (hk : 0 < k) (hH : 1 ≤ H) (hHS : H < S) (hmV : N.totient ∈ totientsUpTo x) (hnormal : N.totient ∉ nonNormalTotients S x) (hSq : NoLargePrimeSquare N H) (F : ℝ) (v : Fin k → ℝ) (hSlast : S ≤ v ⟨k-1, by omega⟩) (hvq : ∀ idx, v idx ≤ (ordinaryPrimeAt N (idx.val+1) : ℝ)) : NormalGridWitness (reversedPrimeGrid k S F v) N.totient := by apply ordinaryPrimeAt_gridWitness hN hH hmV hnormal hSq _ F v hvq intro idx have hlast := hvq ⟨k-1, by omega⟩ have hklast : k-1+1 = k := by omega simp only [hklast] at hlast have hanti : (ordinaryPrimeAt N k : ℝ) ≤ ordinaryPrimeAt N idx.val := by exact_mod_cast ordinaryPrimeAt_antitone N (show idx.val ≤ k by omega) exact hHS.trans_le ((hSlast.trans hlast).trans hanti) /- Original line 42741: Erdos416Proof.FordBadFacet.ordinaryPrimeAt_totient_mem_grid -/ theorem ordinaryPrimeAt_totient_mem_grid {N k : ℕ} {S H x : ℝ} (hN : 0 < N) (hk : 0 < k) (hH : 1 ≤ H) (hHS : H < S) (hmV : N.totient ∈ totientsUpTo x) (hnormal : N.totient ∉ nonNormalTotients S x) (hPreSq : NoLargePrimeSquare N H) (hSq : NoLargePrimeSquare N.totient S) (hOmega : (ArithmeticFunction.cardFactors N.totient : ℝ) ≤ 5*logLog x) (F : ℝ) (v : Fin k → ℝ) (hSlast : S ≤ v ⟨k-1, by omega⟩) (hvq : ∀ idx, v idx ≤ (ordinaryPrimeAt N (idx.val+1) : ℝ)) : N.totient ∈ normalGridValues x (reversedPrimeGrid k S F v) := by apply mem_filter.mpr refine ⟨hmV, ?_, hOmega, ordinaryPrimeAt_gridWitness_of_last_threshold hN hk hH hHS hmV hnormal hPreSq F v hSlast hvq⟩ simpa [Erdos416Proof.FordBadFacet.positiveLogLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_bottom, Erdos416Proof.FordBadFacet.reversedFacetLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_succ, Erdos416Proof.FordBadFacet.reversedPrimeGrid_dimension, Erdos416Proof.FordBadFacet.reversedPrimeGrid_endpoint_succ, Erdos416Proof.FordBadFacet.reversedPrimeGrid_multiplicity, Erdos416Proof.FordBadFacet.reversedPrimeGrid_zero, Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.FordRestricted.suffixCutoff_log3, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint] using hSq end Erdos416Proof.FordBadFacet end /- Consolidated component: OrdinaryFacetCoordinates.lean. -/ section open Filter Finset open scoped Classical Topology BigOperators Nat namespace Erdos416Proof.FordBadFacet /-- Ford coordinates formed from the ordinary prime factors of this preimage, with their multiplicities and with padding by one. -/ /- Original line 42772: Erdos416Proof.FordBadFacet.ordinaryPrimeCoordinate -/ noncomputable abbrev ordinaryPrimeCoordinate (T : ℝ) (N idx : ℕ) : ℝ := fordPrimeCoordinate T (ordinaryPrimeAt N idx) /- Original line 42775: Erdos416Proof.FordBadFacet.ordinaryPrimeCoordinate_antitone -/ theorem ordinaryPrimeCoordinate_antitone (N : ℕ) {T : ℝ} (hT : 0 ≤ T) : Antitone (ordinaryPrimeCoordinate T N) := fordPrimeCoordinate_antitone (ordinaryPrimeAt N) (ordinaryPrimeAt_one_le N) (ordinaryPrimeAt_antitone N) hT /- Original line 42780: Erdos416Proof.FordBadFacet.ordinaryPrimeAt_positiveLogLog_le -/ theorem ordinaryPrimeAt_positiveLogLog_le {N : ℕ} {x : ℝ} (hx : 2 ≤ x) (hT : 0 ≤ logLog x) (hN : 0 < N) (hphi : (N.totient : ℝ) ≤ x) (idx : ℕ) : positiveLogLog (ordinaryPrimeAt N idx) ≤ logLog x + 1 := by rcases ordinaryPrimeAt_spec N idx with hi | ⟨hp, hdvd⟩ · rw [hi, Nat.cast_one, positiveLogLog_one] linarith · exact preimage_prime_positiveLogLog_le hx hT hN hp hdvd hphi /- Original line 42789: Erdos416Proof.FordBadFacet.ordinaryPrimeCoordinate_bounds -/ theorem ordinaryPrimeCoordinate_bounds {N : ℕ} {x : ℝ} (hx : 2 ≤ x) (hT : 1 ≤ logLog x) (hN : 0 < N) (hphi : (N.totient : ℝ) ≤ x) (idx : ℕ) : 0 ≤ ordinaryPrimeCoordinate (logLog x) N idx ∧ ordinaryPrimeCoordinate (logLog x) N idx ≤ 2 := by rcases ordinaryPrimeAt_spec N idx with hi | ⟨hp, hdvd⟩ · simp only [ordinaryPrimeCoordinate, fordPrimeCoordinate, hi, Nat.cast_one, positiveLogLog_one, zero_div] constructor <;> norm_num · exact preimage_prime_coordinate_bounds hx hT hN hp hdvd hphi /- Original line 42800: Erdos416Proof.FordBadFacet.ordinaryPrimeCoordinate_threshold -/ theorem ordinaryPrimeCoordinate_threshold {N idx : ℕ} {θ T : ℝ} (hθ : 0 < θ) (hT : 0 < T) (hlow : θ ≤ ordinaryPrimeCoordinate T N idx) : Real.exp (Real.exp (θ*T)) ≤ (ordinaryPrimeAt N idx : ℝ) := exp_exp_threshold_of_coordinate (ordinaryPrimeAt_one_le N idx) hθ hT hlow /-- Positive retained grid coordinates certify membership in the actual preimage family. The square exclusion for N uses S/2, so a threshold equal to S still excludes repeated prime factors. -/ /- Original line 42809: Erdos416Proof.FordBadFacet.ordinaryFacet_grid_member -/ theorem ordinaryFacet_grid_member {N k : ℕ} {S F x : ℝ} (hN : 0 < N) (hk : 0 < k) (hT : 0 < logLog x) (hS : 2 ≤ S) (hmV : N.totient ∈ totientsUpTo x) (hnormal : N.totient ∉ nonNormalTotients S x) (hPreSq : NoLargePrimeSquare N (S/2)) (hSq : NoLargePrimeSquare N.totient S) (hOmega : (ArithmeticFunction.cardFactors N.totient : ℝ) ≤ 5*logLog x) (θ : Fin k → ℝ) (hθ : ∀ idx, 0 < θ idx) (hSlast : S ≤ Real.exp (Real.exp (θ ⟨k-1, by omega⟩ * logLog x))) (hlow : ∀ idx, θ idx ≤ ordinaryPrimeCoordinate (logLog x) N (idx.val+1)) : N.totient ∈ normalGridValues x (reversedPrimeGrid k S F (fun idx => Real.exp (Real.exp (θ idx * logLog x)))) := by apply ordinaryPrimeAt_totient_mem_grid hN hk (by linarith : 1 ≤ S/2) (by linarith : S/2 < S) hmV hnormal hPreSq hSq hOmega F (fun idx => Real.exp (Real.exp (θ idx * logLog x))) hSlast intro idx exact ordinaryPrimeCoordinate_threshold (hθ idx) hT (hlow idx) end Erdos416Proof.FordBadFacet end /- Consolidated component: FacetCover.lean. -/ section open Filter Finset open scoped Classical Topology BigOperators Nat namespace Erdos416Proof.FordBadFacet /-- All possible retained dimensions and coordinate boxes. -/ /- Original line 42843: Erdos416Proof.FordBadFacet.facetCandidateIndices -/ noncomputable def facetCandidateIndices (k : ℕ) (h : ℝ) : Finset (Fin (k+1) × (Fin k → ℝ)) := (univ : Finset (Fin (k+1))).product (coordinateGrid k h 2) /- Original line 42847: Erdos416Proof.FordBadFacet.facetCandidateThreshold -/ noncomputable abbrev facetCandidateThreshold {k : ℕ} (T : ℝ) (a : Fin (k+1) × (Fin k → ℝ)) : Fin a.1.val → ℝ := fun idx => Real.exp (Real.exp (a.2 (Fin.castLE (Nat.le_of_lt_succ a.1.isLt) idx) * T)) /- Original line 42851: Erdos416Proof.FordBadFacet.facetCandidateRecord -/ noncomputable abbrev facetCandidateRecord {k : ℕ} (x S F : ℝ) (a : Fin (k+1) × (Fin k → ℝ)) : NormalGridRecord := reversedPrimeGrid a.1.val S F (facetCandidateThreshold (logLog x) a) /-- The filter is entirely numerical. In particular, neither a preimage nor an estimate for the number of values is part of this condition. -/ /- Original line 42857: Erdos416Proof.FordBadFacet.FacetCandidateAdmissible -/ def FacetCandidateAdmissible {k : ℕ} (x S F σ : ℝ) (a : Fin (k+1) × (Fin k → ℝ)) : Prop := 0 < a.1.val ∧ NormalGridAdmissible x (facetCandidateRecord x S F a) ∧ (1+σ)*logLog x ≤ ∑ idx : Fin a.1.val, fordWeight (idx.val+1)*logLog (min F (facetCandidateThreshold (logLog x) a idx)) /- Original line 42863: Erdos416Proof.FordBadFacet.admissibleFacetIndices -/ noncomputable def admissibleFacetIndices (x : ℝ) (k : ℕ) (h S F σ : ℝ) : Finset (Fin (k+1) × (Fin k → ℝ)) := (facetCandidateIndices k h).filter (FacetCandidateAdmissible x S F σ) /- Original line 42867: Erdos416Proof.FordBadFacet.facetCoverRecords -/ noncomputable def facetCoverRecords (x : ℝ) (k : ℕ) (h S F σ : ℝ) : Finset NormalGridRecord := (admissibleFacetIndices x k h S F σ).image (facetCandidateRecord x S F) /- Original line 42871: Erdos416Proof.FordBadFacet.facetCandidateIndices_card -/ theorem facetCandidateIndices_card (k : ℕ) (h : ℝ) : (facetCandidateIndices k h).card = (k+1)*(coordinateGrid k h 2).card := by simp [facetCandidateIndices] /- Original line 42875: Erdos416Proof.FordBadFacet.facetCoverRecords_card_le -/ theorem facetCoverRecords_card_le (x : ℝ) (k : ℕ) (h S F σ : ℝ) : (facetCoverRecords x k h S F σ).card ≤ (k+1)*(coordinateGrid k h 2).card := by calc _ ≤ (admissibleFacetIndices x k h S F σ).card := card_image_le _ ≤ (facetCandidateIndices k h).card := card_filter_le _ _ _ = _ := facetCandidateIndices_card k h /- Original line 42882: Erdos416Proof.FordBadFacet.facetCoverRecords_card_le_box -/ theorem facetCoverRecords_card_le_box (x : ℝ) (k : ℕ) (h S F σ : ℝ) : (facetCoverRecords x k h S F σ).card ≤ (k+1)*(⌊2/h⌋₊+1)^k := (facetCoverRecords_card_le x k h S F σ).trans (Nat.mul_le_mul_left (k+1) (coordinateGrid_card_le k h 2)) /- Original line 42887: Erdos416Proof.FordBadFacet.facetCoverRecords_admissible -/ theorem facetCoverRecords_admissible {x h S F σ : ℝ} {k : ℕ} {r : NormalGridRecord} (hr : r ∈ facetCoverRecords x k h S F σ) : NormalGridAdmissible x r := by obtain ⟨a, ha, rfl⟩ := mem_image.mp hr exact (mem_filter.mp ha).2.2.1 /-- Every coordinate satisfying the retained lower cutoff exponentiates to a threshold at least S. -/ /- Original line 42895: Erdos416Proof.FordBadFacet.scale_le_exp_exp_of_logLog -/ theorem scale_le_exp_exp_of_logLog {S θ T : ℝ} (hS : 1 < S) (hT : 0 < T) (hθ : logLog S / T ≤ θ) : S ≤ Real.exp (Real.exp (θ*T)) := by have heq : Real.exp (Real.exp (logLog S)) = S := by rw [logLog, Real.exp_log (Real.log_pos hS), Real.exp_log (by linarith : 0 < S)] rw [← heq] exact Real.exp_le_exp.mpr (Real.exp_le_exp.mpr ((div_le_iff₀ hT).mp hθ)) /-- An actual failed ordinary-prime facet has a numerically admissible finite grid record. All analytic losses are shown in the explicit budget. -/ /- Original line 42905: Erdos416Proof.FordBadFacet.good_preimage_mem_facetCover -/ theorem good_preimage_mem_facetCover {N k : ℕ} {x h S F ω σ : ℝ} (hx : 2 ≤ x) (hT : 20 ≤ logLog x) (hh : 0 < h) (hω : 0 < ω) (hσ : 0 ≤ σ) (hS : Real.exp 1 < S) (hS4 : 4 ≤ S) (hscale : Real.exp ((logLog x)^36) ≤ S) (hSF : S ≤ F) (hcut : F ≤ x^(1/(20*logLog x))) (hFlog : logLog F ≤ logLog x+1) (hloss : (∑ idx : Fin k, fordWeight (idx.val+1))* (h*logLog x+logLog S+logLog x+1-logLog F) ≤ (ω-σ)*logLog x) (hN : 0 < N) (hmV : N.totient ∈ totientsUpTo x) (hnormal : N.totient ∉ nonNormalTotients S x) (hPreSq : NoLargePrimeSquare N (S/2)) (hSq : NoLargePrimeSquare N.totient S) (hOmega : (ArithmeticFunction.cardFactors N.totient : ℝ) ≤ 5*logLog x) (hfacet : 1+ω ≤ ∑ idx : Fin k, fordWeight (idx.val+1)* ordinaryPrimeCoordinate (logLog x) N (idx.val+1)) : N.totient ∈ (facetCoverRecords x k h S F σ).biUnion (normalGridValues x) := by have hTpos : 0 < logLog x := by linarith have hS1 : 1 < S := by linarith have hF1 : 1 < F := hS1.trans_le hSF have hlogS : 1 < Real.log S := by have he := Real.log_lt_log (Real.exp_pos 1) hS simpa only [Real.log_exp] using he have hRpos : 0 < logLog S := Real.log_pos hlogS have hphi : (N.totient : ℝ) ≤ x := ((mem_totientsUpTo (by linarith)).mp hmV).2.1 let q : Fin k → ℝ := fun idx => ordinaryPrimeCoordinate (logLog x) N (idx.val+1) have hqbound : ∀ idx, 0 ≤ q idx ∧ q idx ≤ 2 := fun idx => ordinaryPrimeCoordinate_bounds hx (by linarith) hN hphi (idx.val+1) have hqanti : Antitone q := by intro idx j hij apply ordinaryPrimeCoordinate_antitone N hTpos.le change idx.val+1 ≤ j.val+1 exact Nat.add_le_add_right hij 1 obtain ⟨θ, hθmem, hθanti, hθq, hθlow, _hθhigh⟩ := exists_ford_facet_grid_witness q hh hω hqbound hqanti hfacet obtain ⟨j, hjk, hprefix⟩ := exists_threshold_prefix θ hθanti (logLog S / logLog x) let θj : Fin j → ℝ := fun idx => θ (Fin.castLE hjk idx) let v : Fin j → ℝ := fun idx => Real.exp (Real.exp (θj idx*logLog x)) have hθsharp : ∀ idx, θ idx*logLog x ≤ logLog x+1 := by intro idx have hc := mul_le_mul_of_nonneg_right (hθq idx).2 hTpos.le have hcancel : q idx*logLog x = positiveLogLog (ordinaryPrimeAt N (idx.val+1)) := by dsimp [Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordBadFacet.positiveLogLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_bottom, Erdos416Proof.FordBadFacet.reversedFacetLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_succ, Erdos416Proof.FordBadFacet.reversedPrimeGrid_dimension, Erdos416Proof.FordBadFacet.reversedPrimeGrid_endpoint_succ, Erdos416Proof.FordBadFacet.reversedPrimeGrid_multiplicity, Erdos416Proof.FordBadFacet.reversedPrimeGrid_zero, Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.FordRestricted.suffixCutoff_log3, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, q, ordinaryPrimeCoordinate, fordPrimeCoordinate] exact div_mul_cancel₀ _ hTpos.ne' rw [hcancel] at hc exact hc.trans (ordinaryPrimeAt_positiveLogLog_le hx hTpos.le hN hphi (idx.val+1)) have hretained := retained_capped_facet_lower hjk (fun idx => fordWeight (idx.val+1)) θ hRpos.le hTpos hF1 hFlog (fun idx => (fordWeight_bounds (by omega)).1) hθsharp hprefix have hrounded := mul_le_mul_of_nonneg_right hθlow hTpos.le have hfinal : (1+σ)*logLog x ≤ ∑ idx : Fin j, fordWeight (idx.val+1)*logLog (min F (v idx)) := by change (∑ idx : Fin k, fordWeight (idx.val+1)*θ idx)*logLog x - (logLog S+(logLog x+1)-logLog F)*(∑ idx : Fin k, fordWeight (idx.val+1)) ≤ ∑ idx : Fin j, fordWeight (idx.val+1)*logLog (min F (v idx)) at hretained nlinarith have hjpos : 0 < j := by by_contra hj have hjzero : j = 0 := by omega subst j simp only [Finset.univ_eq_empty, Finset.sum_empty] at hfinal have hpositive : 0 < (1+σ)*logLog x := mul_pos (by linarith) hTpos linarith have hθjcut : ∀ idx, logLog S / logLog x ≤ θj idx := by intro idx exact (hprefix (Fin.castLE hjk idx)).mpr idx.isLt have hθjpos : ∀ idx, 0 < θj idx := fun idx => (div_pos hRpos hTpos).trans_le (hθjcut idx) have hvS : ∀ idx, S ≤ v idx := fun idx => scale_le_exp_exp_of_logLog hS1 hTpos (hθjcut idx) have hvanti : Antitone v := by intro idx l hil apply Real.exp_le_exp.mpr apply Real.exp_le_exp.mpr apply mul_le_mul_of_nonneg_right _ hTpos.le exact hθanti hil have hadm : NormalGridAdmissible x (reversedPrimeGrid j S F v) := reversedPrimeGrid_admissible v (by linarith) hT hS.le hS4 hscale hSF hvS hvanti hcut have hmember : N.totient ∈ normalGridValues x (reversedPrimeGrid j S F v) := by apply ordinaryFacet_grid_member hN hjpos hTpos (by linarith) hmV hnormal hPreSq hSq hOmega θj hθjpos (hvS ⟨j-1, by omega⟩) intro idx exact (hθq (Fin.castLE hjk idx)).2 let a : Fin (k+1) × (Fin k → ℝ) := (⟨j, by omega⟩, θ) have heq : facetCandidateRecord x S F a = reversedPrimeGrid j S F v := by rfl have haindex : a ∈ facetCandidateIndices k h := mem_product.mpr ⟨mem_univ _, hθmem⟩ have haadm : FacetCandidateAdmissible x S F σ a := by exact ⟨hjpos, hadm, hfinal⟩ have harecord : reversedPrimeGrid j S F v ∈ facetCoverRecords x k h S F σ := by exact mem_image.mpr ⟨a, mem_filter.mpr ⟨haindex, haadm⟩, heq⟩ exact mem_biUnion.mpr ⟨reversedPrimeGrid j S F v, harecord, hmember⟩ /-- Distinct values admitting a failed facet in some positive preimage, after the three explicit arithmetic exclusions. -/ /- Original line 42997: Erdos416Proof.FordBadFacet.retainedBadFacetValues -/ noncomputable def retainedBadFacetValues (x : ℝ) (k : ℕ) (S ω : ℝ) : Finset ℕ := (totientsUpTo x).filter (fun m => m ∉ nonNormalTotients S x ∧ NoLargePrimeSquare m S ∧ (ArithmeticFunction.cardFactors m : ℝ) ≤ 5*logLog x ∧ ∃ N : ℕ, 0 < N ∧ N.totient = m ∧ NoLargePrimeSquare N (S/2) ∧ 1+ω ≤ ∑ idx : Fin k, fordWeight (idx.val+1)* ordinaryPrimeCoordinate (logLog x) N (idx.val+1)) /- Original line 43005: Erdos416Proof.FordBadFacet.retainedBadFacetValues_subset_cover -/ theorem retainedBadFacetValues_subset_cover {x h S F ω σ : ℝ} {k : ℕ} (hx : 2 ≤ x) (hT : 20 ≤ logLog x) (hh : 0 < h) (hω : 0 < ω) (hσ : 0 ≤ σ) (hS : Real.exp 1 < S) (hS4 : 4 ≤ S) (hscale : Real.exp ((logLog x)^36) ≤ S) (hSF : S ≤ F) (hcut : F ≤ x^(1/(20*logLog x))) (hFlog : logLog F ≤ logLog x+1) (hloss : (∑ idx : Fin k, fordWeight (idx.val+1))* (h*logLog x+logLog S+logLog x+1-logLog F) ≤ (ω-σ)*logLog x) : retainedBadFacetValues x k S ω ⊆ (facetCoverRecords x k h S F σ).biUnion (normalGridValues x) := by intro m hm obtain ⟨hmV, hnormal, hSq, hOmega, N, hN, hNm, hPreSq, hfacet⟩ := mem_filter.mp hm subst m exact good_preimage_mem_facetCover hx hT hh hω hσ hS hS4 hscale hSF hcut hFlog hloss hN hmV hnormal hPreSq hSq hOmega hfacet /-- A single loss budget at k controls every retained dimension j ≤ k. All candidate thresholds have positive logarithms before capping. -/ /- Original line 43022: Erdos416Proof.FordBadFacet.facetCoverRecords_weight_le -/ theorem facetCoverRecords_weight_le {x h S F σ U B : ℝ} {k : ℕ} (hF : 1 < F) (hbottom : 0 ≤ logLog S) (hB : 0 ≤ B) (hFU : logLog F ≤ U) (hbudget : ((k+1 : ℕ) : ℝ)*Real.log (k+1 : ℕ)*logLog S + ((k+1 : ℕ) : ℝ)^2*(2*Real.sqrt (logLog S*U)*Real.log (k+1 : ℕ)+B) ≤ σ/2*logLog x) {r : NormalGridRecord} (hr : r ∈ facetCoverRecords x k h S F σ) : normalGridWeight B r ≤ Real.exp (-(1+σ/2)*logLog x) := by obtain ⟨a, ha, rfl⟩ := mem_image.mp hr obtain ⟨_hj, hadm, hfacet⟩ := (mem_filter.mp ha).2 have htop : ∀ idx, logLog (min F (facetCandidateThreshold (logLog x) a idx)) ≤ U := by intro idx have hv : 1 < facetCandidateThreshold (logLog x) a idx := Real.one_lt_exp_iff.mpr (Real.exp_pos _) exact (logLog_mono (lt_min hF hv) (min_le_left _ _)).trans hFU apply reversedPrimeGrid_weight_saving a.1.val S F B (Real.sqrt (logLog S*U)) σ (logLog x) (facetCandidateThreshold (logLog x) a) hadm hbottom (Real.sqrt_nonneg _) hB (reversedPrimeGrid_error_le S F U _ hbottom htop) hfacet apply (integer_entropy_loss_le_scale (show 1 ≤ a.1.val+1 by omega) (show ((a.1.val+1 : ℕ) : ℝ) ≤ ((k+1 : ℕ) : ℝ) by exact_mod_cast (show a.1.val+1 ≤ k+1 from Nat.succ_le_succ (Nat.le_of_lt_succ a.1.isLt))) hbottom (Real.sqrt_nonneg _) hB).trans exact hbudget /-- The whole finite cover has the same exponential saving, charged only for its finite number of candidate boxes and possible retained dimensions. -/ /- Original line 43047: Erdos416Proof.FordBadFacet.exists_facetCover_count_bound -/ theorem exists_facetCover_count_bound : ∃ C B : ℝ, 0 < C ∧ 0 ≤ B ∧ ∀ (x : ℝ) (k : ℕ) (h S F σ U : ℝ), 0 ≤ x → 1 < F → 0 ≤ logLog S → logLog F ≤ U → ((k+1 : ℕ) : ℝ)*Real.log (k+1 : ℕ)*logLog S + ((k+1 : ℕ) : ℝ)^2*(2*Real.sqrt (logLog S*U)*Real.log (k+1 : ℕ)+B) ≤ σ/2*logLog x → (((facetCoverRecords x k h S F σ).biUnion (normalGridValues x)).card : ℝ) ≤ C*x*((k+1)*(coordinateGrid k h 2).card : ℕ)*Real.exp (-(1+σ/2)*logLog x) := by obtain ⟨C, B, hC, hB, hbound⟩ := exists_normalGridUnion_bound refine ⟨C, B, hC, hB, ?_⟩ intro x k h S F σ U hx hF hbottom hFU hbudget let R := facetCoverRecords x k h S F σ have hsum : (∑ r ∈ R, normalGridWeight B r) ≤ (R.card : ℝ)*Real.exp (-(1+σ/2)*logLog x) := by calc _ ≤ ∑ _r ∈ R, Real.exp (-(1+σ/2)*logLog x) := by exact sum_le_sum fun r hr => facetCoverRecords_weight_le hF hbottom hB hFU hbudget hr _ = _ := by simp[Erdos416Proof.FordBadFacet.positiveLogLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_bottom, Erdos416Proof.FordBadFacet.reversedFacetLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_succ, Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.FordRestricted.suffixCutoff_log3, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint] have hcard : (R.card : ℝ) ≤ ((k+1)*(coordinateGrid k h 2).card : ℕ) := Nat.cast_le.mpr (facetCoverRecords_card_le x k h S F σ) have hsum' := hsum.trans (mul_le_mul_of_nonneg_right hcard (Real.exp_pos _).le) have hc := hbound x R (fun r hr => facetCoverRecords_admissible hr) have hh := mul_le_mul_of_nonneg_left hsum' (mul_nonneg hC.le hx) calc _ ≤ C*x*∑ r ∈ R, normalGridWeight B r := hc _ ≤ C*x*(((k+1)*(coordinateGrid k h 2).card : ℕ)*Real.exp (-(1+σ/2)*logLog x)) := hh _ = _ := by ring /-- Actual distinct bad-facet values satisfy the finite-grid saving under explicit numerical conditions, uniformly over all their positive preimages. -/ /- Original line 43078: Erdos416Proof.FordBadFacet.exists_retainedBadFacet_count_bound -/ theorem exists_retainedBadFacet_count_bound : ∃ C B : ℝ, 0 < C ∧ 0 ≤ B ∧ ∀ (x : ℝ) (k : ℕ) (h S F ω σ : ℝ), 2 ≤ x → 20 ≤ logLog x → 0 < h → 0 < ω → 0 ≤ σ → Real.exp 1 < S → 4 ≤ S → Real.exp ((logLog x)^36) ≤ S → S ≤ F → F ≤ x^(1/(20*logLog x)) → logLog F ≤ logLog x+1 → (∑ idx : Fin k, fordWeight (idx.val+1))* (h*logLog x+logLog S+logLog x+1-logLog F) ≤ (ω-σ)*logLog x → ((k+1 : ℕ) : ℝ)*Real.log (k+1 : ℕ)*logLog S + ((k+1 : ℕ) : ℝ)^2* (2*Real.sqrt (logLog S*(logLog x+1))*Real.log (k+1 : ℕ)+B) ≤ σ/2*logLog x → ((retainedBadFacetValues x k S ω).card : ℝ) ≤ C*x*((k+1)*(coordinateGrid k h 2).card : ℕ)*Real.exp (-(1+σ/2)*logLog x) := by obtain ⟨C, B, hC, hB, hbound⟩ := exists_facetCover_count_bound refine ⟨C, B, hC, hB, ?_⟩ intro x k h S F ω σ hx hT hh hω hσ hS hS4 hscale hSF hcut hFlog hloss hbudget have hsub := retainedBadFacetValues_subset_cover hx hT hh hω hσ hS hS4 hscale hSF hcut hFlog hloss apply (Nat.cast_le.mpr (card_le_card hsub)).trans exact hbound x k h S F σ (logLog x+1) (by linarith) (by linarith) (logLog_nonneg hS.le) hFlog hbudget end Erdos416Proof.FordBadFacet end /- Consolidated component: FacetScale.lean. -/ section open Filter Asymptotics Finset open scoped Classical Topology BigOperators namespace Erdos416Proof.FordBadFacet /-- The endpoint permitted by the capped normality estimate. -/ /- Original line 43117: Erdos416Proof.FordBadFacet.facetSieveCap -/ noncomputable def facetSieveCap (x : ℝ) : ℝ := x^(1/(20*logLog x)) /-- The mesh used for a row with coefficient-sum bound `N^2`. -/ /- Original line 43120: Erdos416Proof.FordBadFacet.facetMesh -/ noncomputable def facetMesh (N ω : ℝ) : ℝ := ω/(10*N^2) /- Original line 43122: Erdos416Proof.FordBadFacet.facetSieveCap_one_lt -/ theorem facetSieveCap_one_lt {x : ℝ} (hx : 1 < x) (hT : 0 < logLog x) : 1 < facetSieveCap x := by exact Real.one_lt_rpow hx (div_pos (by norm_num) (mul_pos (by norm_num) hT)) /- Original line 43126: Erdos416Proof.FordBadFacet.facetSieveCap_logLog -/ theorem facetSieveCap_logLog {x : ℝ} (hx : 1 < x) (hT : 0 < logLog x) : logLog (facetSieveCap x) = logLog x-Real.log (20*logLog x) := by change Real.log (Real.log (x^(1/(20*logLog x)))) = _ rw [Real.log_rpow (by linarith : 0 < x)] rw [show 1/(20*logLog x)*Real.log x = Real.log x/(20*logLog x) by ring] exact Real.log_div (Real.log_pos hx).ne' (mul_pos (by norm_num) hT).ne' /- Original line 43133: Erdos416Proof.FordBadFacet.facetSieveCap_logLog_le -/ theorem facetSieveCap_logLog_le {x : ℝ} (hx : 1 < x) (hT : 1 ≤ logLog x) : logLog (facetSieveCap x) ≤ logLog x := by rw [facetSieveCap_logLog hx (by linarith)] have hlog := Real.log_nonneg (show 1 ≤ 20*logLog x by linarith) linarith /- Original line 43139: Erdos416Proof.FordBadFacet.facetSieveCap_loss -/ theorem facetSieveCap_loss {x : ℝ} (hx : 1 < x) (hT : 0 < logLog x) : logLog x+1-logLog (facetSieveCap x) = 1+Real.log (20*logLog x) := by rw [facetSieveCap_logLog hx hT] ring /- Original line 43144: Erdos416Proof.FordBadFacet.facetMesh_pos -/ theorem facetMesh_pos {N ω : ℝ} (hN : 1 ≤ N) (hω : 0 < ω) : 0 < facetMesh N ω := by unfold facetMesh positivity /-- Rounding uses at most one tenth of the original margin. -/ /- Original line 43150: Erdos416Proof.FordBadFacet.facetMesh_weighted_loss -/ theorem facetMesh_weighted_loss {N α ω T : ℝ} (hN : 1 ≤ N) (hα : α ≤ N^2) (hω : 0 ≤ ω) (hT : 0 ≤ T) : α*(facetMesh N ω*T) ≤ ω/10*T := by have hN0 : 0 < N := by linarith have hmesh : 0 ≤ facetMesh N ω := div_nonneg hω (by positivity) have h := mul_le_mul_of_nonneg_right hα (mul_nonneg hmesh hT) have heq : N^2*(facetMesh N ω*T) = ω/10*T := by unfold facetMesh field_simp exact h.trans_eq heq /-- With retained margin `ω/2`, the global normality scale spends at most `ω/64` of the original margin on discarded coordinates. -/ /- Original line 43163: Erdos416Proof.FordBadFacet.halfMargin_normality_weighted_loss -/ theorem halfMargin_normality_weighted_loss {N α ω T : ℝ} (hN : 1 ≤ N) (hα : α ≤ N^2) (hω : 0 ≤ ω) (hω1 : ω ≤ 1) (hT : 0 ≤ T) : α*facetNormalityParameter N (ω/2) T ≤ ω/64*T := by let A := normalityCost N let c := (ω/2)/(32*A) obtain ⟨hA, _, _, hN2⟩ := normalityCost_bounds hN have hApos : 0 < A := by dsimp [Erdos416Proof.FordBadFacet.facetNormalityScale_logLog, A]; linarith have hc : 0 ≤ c := div_nonneg (by linarith) (by positivity) have hc1 : c ≤ 1 := (div_le_one (by positivity : 0 < 32*A)).mpr (by dsimp [Erdos416Proof.FordBadFacet.facetNormalityScale_logLog, A] linarith) have hc2 : c^2 ≤ c := by nlinarith have hAc : A*c = ω/64 := by dsimp [Erdos416Proof.FordBadFacet.facetNormalityScale_logLog, c] field_simp ring have hαA : α ≤ A := hα.trans hN2 have hR : 0 ≤ c^2*T := mul_nonneg (sq_nonneg _) hT change α*(c^2*T) ≤ _ calc _ ≤ A*(c^2*T) := mul_le_mul_of_nonneg_right hαA hR _ ≤ A*(c*T) := mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_right hc2 hT) hApos.le _ = ω/64*T := by rw [← mul_assoc, hAc] /-- The remaining cap condition is explicit; all mesh and normality losses have already been absorbed. This is precisely the loss used by the retained capped-facet geometry, with `X=T+1` and retained margin `ω/2`. -/ /- Original line 43191: Erdos416Proof.FordBadFacet.facet_mesh_prefix_cap_budget -/ theorem facet_mesh_prefix_cap_budget {N α ω T : ℝ} (hN : 1 ≤ N) (hα : α ≤ N^2) (hω : 0 ≤ ω) (hω1 : ω ≤ 1) (hT : 1 ≤ T) (hcap : N^2*(1+Real.log (20*T)) ≤ ω/4*T) : α*(facetMesh N ω*T+facetNormalityParameter N (ω/2) T+1+Real.log (20*T)) ≤ (ω/2)*T := by have hmesh := facetMesh_weighted_loss hN hα hω (by linarith : 0 ≤ T) have hnormal := halfMargin_normality_weighted_loss hN hα hω hω1 (by linarith : 0 ≤ T) have hlog : 0 ≤ 1+Real.log (20*T) := by have h := Real.log_nonneg (show 1 ≤ 20*T by linarith) linarith have hcap' := (mul_le_mul_of_nonneg_right hα hlog).trans hcap have hωT := mul_nonneg hω (show 0 ≤ T by linarith) nlinarith /-- A fixed constant plus a logarithm is eventually smaller than any positive multiple of its argument. -/ /- Original line 43207: Erdos416Proof.FordBadFacet.eventually_const_add_log_le_linear -/ theorem eventually_const_add_log_le_linear (c ε : ℝ) (hε : 0 < ε) : ∀ᶠ T : ℝ in atTop, 1 ≤ T ∧ c+Real.log T ≤ ε*T := by have hsmall : (fun T : ℝ => c+Real.log T) =o[atTop] (fun T : ℝ => T) := (isLittleO_const_id_atTop c).add Real.isLittleO_log_id_atTop filter_upwards [hsmall.bound hε, eventually_ge_atTop (1 : ℝ)] with T hbound hT refine ⟨hT, (le_abs_self _).trans ?_⟩ simpa only [Real.norm_eq_abs, abs_of_nonneg (show 0 ≤ T by linarith)] using hbound /- Original line 43215: Erdos416Proof.FordBadFacet.eventually_facet_cap_budget -/ theorem eventually_facet_cap_budget (N ω : ℝ) (hN : 1 ≤ N) (hω : 0 < ω) : ∀ᶠ T : ℝ in atTop, 1 ≤ T ∧ N^2*(1+Real.log (20*T)) ≤ ω/4*T := by have hN0 : 0 < N := by linarith have hε : 0 < ω/(4*N^2) := by positivity filter_upwards [eventually_const_add_log_le_linear (1+Real.log 20) (ω/(4*N^2)) hε] with T hT have hlog : 1+Real.log (20*T) = (1+Real.log 20)+Real.log T := by rw [Real.log_mul (by norm_num : (20 : ℝ) ≠ 0) (by linarith : T ≠ 0)] ring refine ⟨hT.1, ?_⟩ rw [hlog] have h := mul_le_mul_of_nonneg_left hT.2 (sq_nonneg N) have heq : N^2*(ω/(4*N^2)*T) = ω/4*T := by field_simp exact h.trans_eq heq /-- Fixed-row eventual inequalities needed by the actual finite cover. No estimate for a family of arithmetic values occurs in these hypotheses. -/ /- Original line 43232: Erdos416Proof.FordBadFacet.eventually_fixed_facet_scale_conditions -/ theorem eventually_fixed_facet_scale_conditions (k : ℕ) (ω B : ℝ) (hω : 0 < ω) (hω1 : ω ≤ 1) : ∀ᶠ T : ℝ in atTop, 20 ≤ T ∧ 36*Real.log T ≤ facetNormalityParameter ((k+1 : ℕ) : ℝ) (ω/2) T ∧ Real.log (20*T) ≤ T/2 ∧ 16*normalityCost ((k+1 : ℕ) : ℝ)*B ≤ (ω/2)*T ∧ (∑ idx : Fin k, fordWeight (idx.val+1))* (facetMesh ((k+1 : ℕ) : ℝ) ω*T+ facetNormalityParameter ((k+1 : ℕ) : ℝ) (ω/2) T+1+Real.log (20*T)) ≤ (ω/2)*T := by let N : ℝ := ((k+1 : ℕ) : ℝ) let A := normalityCost N let c := ((ω/2)/(32*A))^2 have hN : 1 ≤ N := by dsimp [Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordBadFacet.facetNormalityScale_logLog, N]; exact_mod_cast (show 1 ≤ k+1 by omega) have hA : 0 < A := by have := (normalityCost_bounds hN).1; dsimp [Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordBadFacet.facetNormalityScale_logLog, A]; linarith have hc : 0 < c := by dsimp [Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordBadFacet.facetNormalityScale_logLog, c]; positivity filter_upwards [eventually_ge_atTop (20 : ℝ), eventually_const_add_log_le_linear 0 (c/36) (by positivity), eventually_const_add_log_le_linear (Real.log 20) (1/2) (by norm_num), eventually_ge_atTop (32*A*B/ω), eventually_facet_cap_budget N ω hN hω] with T hT hnormal hcap hB hmesh refine ⟨hT, ?_, ?_, ?_, ?_⟩ · have h := hnormal.2 change 36*Real.log T ≤ c*T linarith · rw [Real.log_mul (by norm_num : (20 : ℝ) ≠ 0) (by linarith : T ≠ 0)] linarith [hcap.2] · have h := (div_le_iff₀ hω).mp hB change 16*A*B ≤ (ω/2)*T nlinarith · exact facet_mesh_prefix_cap_budget hN (sum_fordWeight_fin_le_square k) hω.le hω1 (by linarith) hmesh.2 /-- Reconstructing the endpoint from its double logarithm converts the numerical lower-to-upper comparison into the actual sieve threshold bound. -/ /- Original line 43268: Erdos416Proof.FordBadFacet.facetNormalityScale_le_cap -/ theorem facetNormalityScale_le_cap {x N ω T : ℝ} (hx : 1 < x) (hTx : 0 < logLog x) (hR : facetNormalityParameter N ω T ≤ logLog (facetSieveCap x)) : facetNormalityScale N ω T ≤ facetSieveCap x := by have hF := facetSieveCap_one_lt hx hTx calc _ ≤ Real.exp (Real.exp (logLog (facetSieveCap x))) := Real.exp_le_exp.mpr (Real.exp_le_exp.mpr hR) _ = _ := by simp only [logLog, Real.exp_log (Real.log_pos hF), Real.exp_log (by linarith : 0 < facetSieveCap x)] /-- Fixed-row endpoint conditions in the original counting variable. -/ /- Original line 43281: Erdos416Proof.FordBadFacet.eventually_fixed_facet_endpoints -/ theorem eventually_fixed_facet_endpoints (k : ℕ) (ω B : ℝ) (hω : 0 < ω) (hω1 : ω ≤ 1) : ∀ᶠ x : ℝ in atTop, 1 < x ∧ 20 ≤ logLog x ∧ Real.exp ((logLog x)^36) ≤ facetNormalityScale ((k+1 : ℕ) : ℝ) (ω/2) (logLog x) ∧ facetNormalityScale ((k+1 : ℕ) : ℝ) (ω/2) (logLog x) ≤ facetSieveCap x ∧ 16*normalityCost ((k+1 : ℕ) : ℝ)*B ≤ (ω/2)*logLog x ∧ (∑ idx : Fin k, fordWeight (idx.val+1))* (facetMesh ((k+1 : ℕ) : ℝ) ω*logLog x+ logLog (facetNormalityScale ((k+1 : ℕ) : ℝ) (ω/2) (logLog x))+ logLog x+1-logLog (facetSieveCap x)) ≤ (ω/2)*logLog x := by have hT : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [eventually_gt_atTop (1 : ℝ), hT.eventually (eventually_fixed_facet_scale_conditions k ω B hω hω1)] with x hx h have hTx : 0 < logLog x := by linarith [h.1] have hN : (1 : ℝ) ≤ ((k+1 : ℕ) : ℝ) := by exact_mod_cast (show 1 ≤ k+1 by omega) have hhalf : 0 ≤ ω/2 := by linarith have hhalf1 : ω/2 ≤ 1 := by linarith have hR := (facetNormalityParameter_le hN hhalf hhalf1 hTx.le).2 have hlogS : logLog (facetNormalityScale ((k+1 : ℕ) : ℝ) (ω/2) (logLog x)) = facetNormalityParameter ((k+1 : ℕ) : ℝ) (ω/2) (logLog x) := facetNormalityScale_logLog _ _ _ refine ⟨hx, h.1, facetNormalityScale_power_lower hTx h.2.1, ?_, h.2.2.2.1, ?_⟩ · apply facetNormalityScale_le_cap hx hTx rw [facetSieveCap_logLog hx hTx] linarith [h.2.2.1] · rw [hlogS, facetSieveCap_logLog hx hTx] convert h.2.2.2.2 using 1 ring /-- Sharp persistence above an exponential cutoff. Keeping `(c+log T)/T` instead of replacing the logarithm by a fractional power preserves the `ω^2*T` saving used by the corrected slope `1/15`. -/ /- Original line 43316: Erdos416Proof.FordBadFacet.const_add_log_le_linear_above_exp -/ theorem const_add_log_le_linear_above_exp {c u d T : ℝ} (hc : 0 ≤ c) (hu : 1 ≤ u) (hT : Real.exp u ≤ T) (hbase : c+u ≤ d*Real.exp u) : c+Real.log T ≤ d*T := by have hexp : Real.exp 1 ≤ Real.exp u := Real.exp_le_exp.mpr hu have hTpos : 0 < T := (Real.exp_pos u).trans_le hT have hlog := Real.log_div_self_antitoneOn hexp (hexp.trans hT) hT have hconst := div_le_div_of_nonneg_left hc (Real.exp_pos u) hT have hratio : (c+Real.log T)/T ≤ (c+u)/Real.exp u := by rw [add_div, add_div] simpa only [Real.log_exp] using add_le_add hconst hlog exact (div_le_iff₀ hTpos).mp (hratio.trans ((div_le_iff₀ (Real.exp_pos u)).mpr hbase)) /- Original line 43329: Erdos416Proof.FordBadFacet.sqrt_scale_top_add_one -/ theorem sqrt_scale_top_add_one {R T : ℝ} (hR : 0 ≤ R) (hT : 1 ≤ T) : Real.sqrt (R*(T+1)) ≤ 2*Real.sqrt (R*T) := by calc _ ≤ Real.sqrt (4*(R*T)) := Real.sqrt_le_sqrt (by nlinarith [mul_nonneg hR (sub_nonneg.mpr hT)]) _ = _ := by rw [Real.sqrt_mul (by norm_num : (0 : ℝ) ≤ 4)]; norm_num /-- The extra `+1` in the all-preimage coordinate bound still fits inside the chosen normality budget. The original scale has ample room for the factor two in its square-root error. -/ /- Original line 43339: Erdos416Proof.FordBadFacet.facet_normality_budget_top_add_one -/ theorem facet_normality_budget_top_add_one {N B σ T : ℝ} (hN : 1 ≤ N) (hB : 0 ≤ B) (hσ : 0 ≤ σ) (hσ1 : σ ≤ 1) (hT : 1 ≤ T) (hlarge : 16*normalityCost N*B ≤ σ*T) : N*Real.log N*facetNormalityParameter N σ T+ N^2*(2*Real.sqrt (facetNormalityParameter N σ T*(T+1))*Real.log N+B) ≤ σ/2*T := by let A := normalityCost N let c := σ/(32*A) let R := facetNormalityParameter N σ T let D := Real.sqrt (R*(T+1)) let E := c*T obtain ⟨hA, hNlog, hN2log, hN2⟩ := normalityCost_bounds hN have hApos : 0 < A := by dsimp [Erdos416Proof.FordBadFacet.facetNormalityScale_logLog, A]; linarith have hT0 : 0 ≤ T := by linarith have hc : 0 ≤ c := div_nonneg hσ (by positivity) have hc1 : c ≤ 1 := (div_le_one (by positivity : 0 < 32*A)).mpr (by dsimp [Erdos416Proof.FordBadFacet.facetNormalityScale_logLog, A] linarith) have hR : 0 ≤ R := mul_nonneg (sq_nonneg _) hT0 have hE : 0 ≤ E := mul_nonneg hc hT0 have hD : 0 ≤ D := Real.sqrt_nonneg _ have hRE : R ≤ E := by have hc2 : c^2 ≤ c := by nlinarith exact mul_le_mul_of_nonneg_right hc2 hT0 have hroot : Real.sqrt (R*T) = E := sqrt_facetNormalityParameter hN hσ hT0 have hDE : D ≤ 2*E := by have h := sqrt_scale_top_add_one hR hT rwa [hroot] at h have hAc : A*c = σ/32 := by dsimp [Erdos416Proof.FordBadFacet.facetNormalityScale_logLog, c]; field_simp have hAE : A*E = σ*T/32 := by dsimp [Erdos416Proof.FordBadFacet.facetNormalityScale_logLog, E]; rw [← mul_assoc, hAc]; ring calc _ ≤ A*R+2*A*D+A*B := by have hfirst := mul_le_mul_of_nonneg_right hNlog hR have hsecond := mul_le_mul_of_nonneg_right hN2log (by positivity : 0 ≤ 2*D) have hthird := mul_le_mul_of_nonneg_right hN2 hB change N*Real.log N*R+N^2*(2*D*Real.log N+B) ≤ _ nlinarith _ ≤ 5*(A*E)+A*B := by have hfirst := mul_le_mul_of_nonneg_left hRE hApos.le have hsecond := mul_le_mul_of_nonneg_left hDE hApos.le nlinarith _ ≤ σ/2*T := by rw [hAE] change 16*A*B ≤ σ*T at hlarge nlinarith [mul_nonneg hσ hT0] /- Original line 43385: Erdos416Proof.FordBadFacet.eventually_fixed_facet_entropy_budget -/ theorem eventually_fixed_facet_entropy_budget (k : ℕ) (ω B : ℝ) (hω : 0 < ω) (hω1 : ω ≤ 1) (hB : 0 ≤ B) : ∀ᶠ T : ℝ in atTop, ((k+1 : ℕ) : ℝ)*Real.log (k+1 : ℕ)* facetNormalityParameter ((k+1 : ℕ) : ℝ) (ω/2) T+ ((k+1 : ℕ) : ℝ)^2* (2*Real.sqrt (facetNormalityParameter ((k+1 : ℕ) : ℝ) (ω/2) T*(T+1))* Real.log (k+1 : ℕ)+B) ≤ (ω/2)/2*T := by filter_upwards [eventually_fixed_facet_scale_conditions k ω B hω hω1] with T h apply facet_normality_budget_top_add_one (by exact_mod_cast (show 1 ≤ k+1 by omega)) hB (by linarith) (by linarith) (by linarith [h.1]) exact h.2.2.2.1 end Erdos416Proof.FordBadFacet end /- Consolidated component: FacetUniformScale.lean. -/ section open Filter Asymptotics Finset open scoped Classical Topology BigOperators namespace Erdos416Proof.FordBadFacet open FordRestricted /-- A finite number of exceptional rows can be handled by enlarging the exponential cutoff once. No monotonicity of `P` is assumed: both inputs already hold throughout their respective tails in `T`. -/ /- Original line 43420: Erdos416Proof.FordBadFacet.uniformize_exponential_threshold -/ theorem uniformize_exponential_threshold (P : ℕ → ℝ → Prop) (hfixed : ∀ k, ∀ᶠ T : ℝ in atTop, P k T) (htail : ∀ᶠ k : ℕ in atTop, ∀ T : ℝ, Real.exp ((k : ℝ)/15) ≤ T → P k T) : ∃ K : ℝ, 0 ≤ K ∧ ∀ (k : ℕ) (T : ℝ), Real.exp ((k : ℝ)/15+K) ≤ T → P k T := by obtain ⟨k₀, hk₀⟩ := eventually_atTop.mp htail choose b hb using fun k => eventually_atTop.mp (hfixed k) let A : ℝ := 1+∑ j ∈ range k₀, max 0 (b j) have hsum : 0 ≤ ∑ j ∈ range k₀, max 0 (b j) := sum_nonneg fun _ _ => le_max_left _ _ have hA : 1 ≤ A := by dsimp [A]; linarith have hApos : 0 < A := by linarith have hK : 0 ≤ Real.log A := Real.log_nonneg hA refine ⟨Real.log A, hK, ?_⟩ intro k T hT by_cases hk : k < k₀ · have hsingle : max 0 (b k) ≤ ∑ j ∈ range k₀, max 0 (b j) := single_le_sum (fun _ _ => le_max_left _ _) (mem_range.mpr hk) have hbA : b k ≤ A := by dsimp [A]; linarith [le_max_right 0 (b k)] have hexp : 1 ≤ Real.exp ((k : ℝ)/15) := Real.one_le_exp_iff.mpr (by positivity) have hAE : A ≤ Real.exp ((k : ℝ)/15+Real.log A) := by rw [Real.exp_add, Real.exp_log hApos] simpa only [one_mul] using mul_le_mul_of_nonneg_right hexp hApos.le exact hb k T (hbA.trans (hAE.trans hT)) · apply hk₀ k (by omega) T exact (Real.exp_le_exp.mpr (by linarith : (k : ℝ)/15 ≤ (k : ℝ)/15+Real.log A)).trans hT /- Original line 43447: Erdos416Proof.FordBadFacet.weighted_log_budget_above_exp -/ theorem weighted_log_budget_above_exp {f c u d T : ℝ} (hf : 0 ≤ f) (hc : 0 ≤ c) (hu : 1 ≤ u) (hT : Real.exp u ≤ T) (hbase : f*(c+u) ≤ d*Real.exp u) : f*(c+Real.log T) ≤ d*T := by have hexp : Real.exp 1 ≤ Real.exp u := Real.exp_le_exp.mpr hu have hTpos : 0 < T := (Real.exp_pos u).trans_le hT have hlog := Real.log_div_self_antitoneOn hexp (hexp.trans hT) hT have hconst := div_le_div_of_nonneg_left hc (Real.exp_pos u) hT have hratio : (c+Real.log T)/T ≤ (c+u)/Real.exp u := by rw [add_div, add_div] simpa only [Real.log_exp] using add_le_add hconst hlog apply (div_le_iff₀ hTpos).mp calc _ = f*((c+Real.log T)/T) := by ring _ ≤ f*((c+u)/Real.exp u) := mul_le_mul_of_nonneg_left hratio hf _ = (f*(c+u))/Real.exp u := by ring _ ≤ d := (div_le_iff₀ (Real.exp_pos u)).mpr hbase /-- The corrected cutoff absorbs a polynomial/polylogarithmic coefficient times a logarithm uniformly in both the row index and the endpoint. -/ /- Original line 43466: Erdos416Proof.FordBadFacet.exists_uniform_suffix_log_budget -/ theorem exists_uniform_suffix_log_budget (D c : ℝ) (hD : 0 ≤ D) (hc : 0 ≤ c) (m n : ℕ) : ∃ K : ℝ, 0 ≤ K ∧ ∀ (k : ℕ) (T : ℝ), Real.exp ((k : ℝ)/15+K) ≤ T → D*((k : ℝ)+1)^m*(1+Real.log ((k : ℝ)+1))^n*(c+Real.log T) ≤ suffixMargin k^2*T := by let f : ℕ → ℝ := fun k => D*((k : ℝ)+1)^m*(1+Real.log ((k : ℝ)+1))^n have hf (k : ℕ) : 0 ≤ f k := by have hk0 : (0 : ℝ) ≤ k := Nat.cast_nonneg k have hlog : 0 ≤ Real.log ((k : ℝ)+1) := Real.log_nonneg (by linarith) dsimp [f] positivity apply uniformize_exponential_threshold · intro k have hsmall : (fun T : ℝ => f k*(c+Real.log T)) =o[atTop] (fun T : ℝ => T) := ((isLittleO_const_id_atTop c).add Real.isLittleO_log_id_atTop).const_mul_left (f k) have hε : 0 < suffixMargin k^2 := sq_pos_of_pos (suffixMargin_pos k) filter_upwards [hsmall.bound hε, eventually_ge_atTop (1 : ℝ)] with T h hT apply (le_abs_self _).trans simpa only [Real.norm_eq_abs, abs_of_nonneg (show 0 ≤ T by linarith)] using h · filter_upwards [suffix_margin_dominates_polylog 0 (D*(c+1)) (by positivity) (m+1) n, eventually_ge_atTop (15 : ℕ)] with k hk hk15 intro T hT have hk0 : (0 : ℝ) ≤ k := Nat.cast_nonneg k have hu : 1 ≤ (k : ℝ)/15 := by have hkR : (15 : ℝ) ≤ k := by exact_mod_cast hk15 linarith apply weighted_log_budget_above_exp (hf k) hc hu hT have hcub : c+(k : ℝ)/15 ≤ (c+1)*((k : ℝ)+1) := by nlinarith [mul_nonneg hc hk0] calc _ ≤ f k*((c+1)*((k : ℝ)+1)) := mul_le_mul_of_nonneg_left hcub (hf k) _ = D*(c+1)*((k : ℝ)+1)^(m+1)*(1+Real.log ((k : ℝ)+1))^n := by dsimp [f] rw [pow_succ] ring _ ≤ _ := by simpa only [add_zero] using hk /-- One sufficiently large majorant controls the cap, normality scale and Mertens losses simultaneously. -/ /- Original line 43505: Erdos416Proof.FordBadFacet.majorant_facet_conditions -/ theorem majorant_facet_conditions {N ω B D T : ℝ} (hN : 1 ≤ N) (hω : 0 ≤ ω) (hω1 : ω ≤ 1) (_hB : 0 ≤ B) (hT : 20 ≤ T) (hD : 147456 ≤ D) (hDB : 32*B ≤ D) (hmajor : D*(normalityCost N)^2*(1+Real.log (20*T)) ≤ ω^2*T) : 36*Real.log T ≤ facetNormalityParameter N (ω/2) T ∧ N^2*(1+Real.log (20*T)) ≤ ω/4*T ∧ 16*normalityCost N*B ≤ (ω/2)*T := by let A := normalityCost N let L := 1+Real.log (20*T) obtain ⟨hA, _, _, hN2⟩ := normalityCost_bounds hN have hApos : 0 < A := by dsimp [Erdos416Proof.FordBadFacet.facetNormalityScale_logLog, A]; linarith have hTpos : 0 < T := by linarith have hD0 : 0 ≤ D := by linarith have hlogT : 0 ≤ Real.log T := Real.log_nonneg (by linarith) have hL1 : 1 ≤ L := by have h := Real.log_nonneg (show 1 ≤ 20*T by linarith) dsimp [Erdos416Proof.FordBadFacet.facetNormalityScale_logLog, L] linarith have hlogL : Real.log T ≤ L := by have h := Real.log_le_log hTpos (show T ≤ 20*T by linarith) dsimp [Erdos416Proof.FordBadFacet.facetNormalityScale_logLog, L] linarith have hA2 : A ≤ A^2 := by change 1 ≤ A at hA; nlinarith have hA2L : A ≤ A^2*L := hA2.trans (by simpa only [mul_one] using mul_le_mul_of_nonneg_left hL1 (sq_nonneg A)) have hω2 : ω^2*T ≤ ω*T := mul_le_mul_of_nonneg_right (by nlinarith : ω^2 ≤ ω) hTpos.le change D*A^2*L ≤ ω^2*T at hmajor refine ⟨?_, ?_, ?_⟩ · have hscaled : 147456*A^2*Real.log T ≤ ω^2*T := by calc _ ≤ 147456*A^2*L := mul_le_mul_of_nonneg_left hlogL (by positivity) _ ≤ D*A^2*L := by have h := mul_le_mul_of_nonneg_right hD (mul_nonneg (sq_nonneg A) (by linarith : 0 ≤ L)) nlinarith _ ≤ _ := hmajor have hR : facetNormalityParameter N (ω/2) T = ω^2*T/(4096*A^2) := by change ((ω/2)/(32*A))^2*T = ω^2*T/(4096*A^2) field_simp ring rw [hR] apply (le_div_iff₀ (by positivity : 0 < 4096*A^2)).mpr nlinarith · have hsmall : 4*N^2*L ≤ D*A^2*L := by have hNL := mul_le_mul_of_nonneg_right (hN2.trans hA2) (by linarith : 0 ≤ L) have hD4 : 4 ≤ D := by linarith have hDL := mul_le_mul_of_nonneg_right hD4 (mul_nonneg (sq_nonneg A) (by linarith : 0 ≤ L)) nlinarith change N^2*L ≤ ω/4*T nlinarith [hsmall.trans (hmajor.trans hω2)] · have hsmall : 32*A*B ≤ D*A^2*L := by have h₁ := mul_le_mul_of_nonneg_left hDB hApos.le have h₂ := mul_le_mul_of_nonneg_left hA2L hD0 nlinarith change 16*A*B ≤ (ω/2)*T nlinarith [hsmall.trans (hmajor.trans hω2)] /-- All three numerical budgets needed by the retained cover hold above a single corrected cutoff, uniformly over every row. -/ /- Original line 43563: Erdos416Proof.FordBadFacet.exists_uniform_suffix_facet_conditions -/ theorem exists_uniform_suffix_facet_conditions (B : ℝ) (hB : 0 ≤ B) : ∃ K : ℝ, 0 ≤ K ∧ ∀ (k : ℕ) (T : ℝ), Real.exp ((k : ℝ)/15+K) ≤ T → 20 ≤ T ∧ 36*Real.log T ≤ facetNormalityParameter ((k+1 : ℕ) : ℝ) (suffixMargin k/2) T ∧ Real.log (20*T) ≤ T/2 ∧ 16*normalityCost ((k+1 : ℕ) : ℝ)*B ≤ (suffixMargin k/2)*T ∧ (∑ idx : Fin k, fordWeight (idx.val+1))* (facetMesh ((k+1 : ℕ) : ℝ) (suffixMargin k)*T+ facetNormalityParameter ((k+1 : ℕ) : ℝ) (suffixMargin k/2) T+1+Real.log (20*T)) ≤ (suffixMargin k/2)*T ∧ ((k+1 : ℕ) : ℝ)*Real.log (k+1 : ℕ)* facetNormalityParameter ((k+1 : ℕ) : ℝ) (suffixMargin k/2) T+ ((k+1 : ℕ) : ℝ)^2* (2*Real.sqrt (facetNormalityParameter ((k+1 : ℕ) : ℝ) (suffixMargin k/2) T*(T+1))* Real.log (k+1 : ℕ)+B) ≤ (suffixMargin k/2)/2*T := by let D := (147456 : ℝ)+32*B let c := 1+Real.log (20 : ℝ) have hc : 0 ≤ c := by have := Real.log_nonneg (show (1 : ℝ) ≤ 20 by norm_num); dsimp [Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordBadFacet.facetNormalityScale_logLog, c]; linarith obtain ⟨K, hK, hbound⟩ := exists_uniform_suffix_log_budget D c (by dsimp [Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordBadFacet.facetNormalityScale_logLog, D]; positivity) hc 4 2 refine ⟨K+20, by linarith, ?_⟩ intro k T hT have hk0 : (0 : ℝ) ≤ k := Nat.cast_nonneg k have hT20 : 20 ≤ T := by have h₁ : Real.exp 20 ≤ Real.exp ((k : ℝ)/15+(K+20)) := Real.exp_le_exp.mpr (by linarith) have h₂ := Real.add_one_le_exp (20 : ℝ) linarith [h₁.trans hT] have hT' : Real.exp ((k : ℝ)/15+K) ≤ T := (Real.exp_le_exp.mpr (by linarith)).trans hT have hb := hbound k T hT' have hN : (1 : ℝ) ≤ ((k+1 : ℕ) : ℝ) := by exact_mod_cast (show 1 ≤ k+1 by omega) have hlog : c+Real.log T = 1+Real.log (20*T) := by rw [Real.log_mul (by norm_num : (20 : ℝ) ≠ 0) (by linarith : T ≠ 0)] dsimp [Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordBadFacet.facetNormalityScale_logLog, c] ring have hmajor : D*(normalityCost ((k+1 : ℕ) : ℝ))^2*(1+Real.log (20*T)) ≤ suffixMargin k^2*T := by rw [hlog] at hb convert hb using 1 dsimp [Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordBadFacet.facetNormalityScale_logLog, normalityCost] push_cast ring obtain ⟨hnormal, hcap, hMertens⟩ := majorant_facet_conditions hN (suffixMargin_pos k).le (suffixMargin_le_one k) hB hT20 (by dsimp [Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordBadFacet.facetNormalityScale_logLog, D]; linarith) (by dsimp [Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordBadFacet.facetNormalityScale_logLog, D]; linarith) hmajor have hlogcap : Real.log (20*T) ≤ T/2 := by have hN2 : (1 : ℝ) ≤ ((k+1 : ℕ) : ℝ)^2 := by nlinarith have hL : 0 ≤ 1+Real.log (20*T) := by have := Real.log_nonneg (show 1 ≤ 20*T by linarith) linarith have h₁ := mul_le_mul_of_nonneg_right hN2 hL have h₂ := mul_le_mul_of_nonneg_right (suffixMargin_le_one k) (show 0 ≤ T by linarith) nlinarith refine ⟨hT20, hnormal, hlogcap, hMertens, ?_, ?_⟩ · exact facet_mesh_prefix_cap_budget hN (sum_fordWeight_fin_le_square k) (suffixMargin_pos k).le (suffixMargin_le_one k) (by linarith) hcap · exact facet_normality_budget_top_add_one hN hB (by linarith [suffixMargin_pos k]) (by linarith [suffixMargin_le_one k]) (by linarith) hMertens /-- The same uniform numerical conditions at an actual counting endpoint. All normality, sieve-cap and retained-margin inputs of the finite cover are now expressed at their concrete values. -/ /- Original line 43625: Erdos416Proof.FordBadFacet.exists_uniform_suffix_endpoints -/ theorem exists_uniform_suffix_endpoints (B : ℝ) (hB : 0 ≤ B) : ∃ K : ℝ, 0 ≤ K ∧ ∀ (k : ℕ) (x : ℝ), suffixCutoff K k ≤ x → 16 ≤ x ∧ 20 ≤ logLog x ∧ Real.exp 1 < facetNormalityScale ((k+1 : ℕ) : ℝ) (suffixMargin k/2) (logLog x) ∧ 4 ≤ facetNormalityScale ((k+1 : ℕ) : ℝ) (suffixMargin k/2) (logLog x) ∧ Real.exp ((logLog x)^36) ≤ facetNormalityScale ((k+1 : ℕ) : ℝ) (suffixMargin k/2) (logLog x) ∧ facetNormalityScale ((k+1 : ℕ) : ℝ) (suffixMargin k/2) (logLog x) ≤ facetSieveCap x ∧ logLog (facetSieveCap x) ≤ logLog x+1 ∧ logLog (facetNormalityScale ((k+1 : ℕ) : ℝ) (suffixMargin k/2) (logLog x)) = facetNormalityParameter ((k+1 : ℕ) : ℝ) (suffixMargin k/2) (logLog x) ∧ (∑ idx : Fin k, fordWeight (idx.val+1))* (facetMesh ((k+1 : ℕ) : ℝ) (suffixMargin k)*logLog x+ logLog (facetNormalityScale ((k+1 : ℕ) : ℝ) (suffixMargin k/2) (logLog x))+ logLog x+1-logLog (facetSieveCap x)) ≤ (suffixMargin k-suffixMargin k/2)*logLog x ∧ ((k+1 : ℕ) : ℝ)*Real.log (k+1 : ℕ)* logLog (facetNormalityScale ((k+1 : ℕ) : ℝ) (suffixMargin k/2) (logLog x))+ ((k+1 : ℕ) : ℝ)^2* (2*Real.sqrt (logLog (facetNormalityScale ((k+1 : ℕ) : ℝ) (suffixMargin k/2) (logLog x))*(logLog x+1))*Real.log (k+1 : ℕ)+B) ≤ (suffixMargin k/2)/2*logLog x := by obtain ⟨K, hK, hbound⟩ := exists_uniform_suffix_facet_conditions B hB refine ⟨K+20, by linarith, ?_⟩ intro k x hx have hcut16 : 16 ≤ suffixCutoff (K+20) k := by have hk0 : (0 : ℝ) ≤ k := Nat.cast_nonneg k have hu : 20 ≤ (k : ℝ)/15+(K+20) := by linarith have h₁ := Real.add_one_le_exp ((k : ℝ)/15+(K+20)) have h₂ := Real.add_one_le_exp (Real.exp ((k : ℝ)/15+(K+20))) have h₃ := Real.add_one_le_exp (Real.exp (Real.exp ((k : ℝ)/15+(K+20)))) dsimp [Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordBadFacet.facetNormalityScale_logLog, Erdos416Proof.FordBadFacet.positiveLogLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_bottom, Erdos416Proof.FordBadFacet.reversedFacetLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_succ, Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.FordRestricted.suffixCutoff_log3, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, suffixCutoff] linarith have hx16 := hcut16.trans hx have hx1 : 1 < x := by linarith have hTx : Real.exp ((k : ℝ)/15+K) ≤ logLog x := by have h := logLog_mono (by linarith : 1 < suffixCutoff (K+20) k) hx have h' : Real.exp ((k : ℝ)/15+(K+20)) ≤ logLog x := by simpa only [suffixCutoff, logLog, Real.log_exp] using h exact (Real.exp_le_exp.mpr (by linarith)).trans h' have h := hbound k (logLog x) hTx have hTpos : 0 < logLog x := by linarith [h.1] have hN : (1 : ℝ) ≤ ((k+1 : ℕ) : ℝ) := by exact_mod_cast (show 1 ≤ k+1 by omega) have hA : 0 < normalityCost ((k+1 : ℕ) : ℝ) := by have := (normalityCost_bounds hN).1 linarith have hσ : 0 < suffixMargin k/2 := by linarith [suffixMargin_pos k] have hσ1 : suffixMargin k/2 ≤ 1 := by linarith [suffixMargin_le_one k] have hRpos : 0 < facetNormalityParameter ((k+1 : ℕ) : ℝ) (suffixMargin k/2) (logLog x) := by unfold facetNormalityParameter positivity have hS : Real.exp 1 < facetNormalityScale ((k+1 : ℕ) : ℝ) (suffixMargin k/2) (logLog x) := Real.exp_lt_exp.mpr (Real.one_lt_exp_iff.mpr hRpos) have hpower := facetNormalityScale_power_lower hTpos h.2.1 have hS4 : 4 ≤ facetNormalityScale ((k+1 : ℕ) : ℝ) (suffixMargin k/2) (logLog x) := by have hpow := pow_le_pow_left₀ (by norm_num : (0 : ℝ) ≤ 3) (show 3 ≤ logLog x by linarith [h.1]) 36 have hpow3 : (3 : ℝ) ≤ (logLog x)^36 := (by norm_num : (3 : ℝ) ≤ 3^36).trans hpow have he := Real.add_one_le_exp ((logLog x)^36) linarith have hR := (facetNormalityParameter_le hN hσ.le hσ1 hTpos.le).2 have hSF : facetNormalityScale ((k+1 : ℕ) : ℝ) (suffixMargin k/2) (logLog x) ≤ facetSieveCap x := by apply facetNormalityScale_le_cap hx1 hTpos rw [facetSieveCap_logLog hx1 hTpos] linarith [h.2.2.1] have hFlog : logLog (facetSieveCap x) ≤ logLog x+1 := (facetSieveCap_logLog_le hx1 (by linarith [h.1])).trans (by linarith) have hlogS : logLog (facetNormalityScale ((k+1 : ℕ) : ℝ) (suffixMargin k/2) (logLog x)) = facetNormalityParameter ((k+1 : ℕ) : ℝ) (suffixMargin k/2) (logLog x) := facetNormalityScale_logLog _ _ _ refine ⟨hx16, h.1, hS, hS4, hpower, hSF, hFlog, hlogS, ?_, ?_⟩ · rw [hlogS, facetSieveCap_logLog hx1 hTpos] convert h.2.2.2.2.1 using 1 · ring · ring · rw [hlogS] exact h.2.2.2.2.2 /-- Squaring the monotone ratio at the square-root endpoint gives the sharp `log^2(T)/T` persistence needed for normality exception envelopes. -/ /- Original line 43705: Erdos416Proof.FordBadFacet.log_sq_div_self_le_above_exp -/ theorem log_sq_div_self_le_above_exp {u T : ℝ} (hu : 2 ≤ u) (hT : Real.exp u ≤ T) : (Real.log T)^2/T ≤ u^2/Real.exp u := by have hTpos : 0 < T := (Real.exp_pos u).trans_le hT have hsquare : (Real.exp (u/2))^2 = Real.exp u := by rw [pow_two, ← Real.exp_add] congr 1 ring have hroot : Real.exp (u/2) ≤ Real.sqrt T := by have h := Real.sqrt_le_sqrt hT rw [← hsquare, Real.sqrt_sq (Real.exp_pos _).le] at h exact h have hhalf : Real.exp 1 ≤ Real.exp (u/2) := Real.exp_le_exp.mpr (by linarith) have hlog := Real.log_div_self_antitoneOn hhalf (hhalf.trans hroot) hroot have hlinear : Real.log T/Real.sqrt T ≤ u/Real.exp (u/2) := by have h := mul_le_mul_of_nonneg_left hlog (show (0 : ℝ) ≤ 2 by norm_num) dsimp only at h rw [Real.log_sqrt hTpos.le, Real.log_exp] at h calc Real.log T/Real.sqrt T = 2*(Real.log T/2/Real.sqrt T) := by ring _ ≤ 2*((u/2)/Real.exp (u/2)) := h _ = u/Real.exp (u/2) := by ring have hlogT : 0 ≤ Real.log T := by have h := (Real.le_log_iff_exp_le hTpos).mpr hT linarith have hsq := pow_le_pow_left₀ (div_nonneg hlogT (Real.sqrt_nonneg T)) hlinear 2 rw [div_pow, div_pow, Real.sq_sqrt hTpos.le, hsquare] at hsq exact hsq /- Original line 43733: Erdos416Proof.FordBadFacet.weighted_log_sq_budget_above_exp -/ theorem weighted_log_sq_budget_above_exp {f u d T : ℝ} (hf : 0 ≤ f) (hu : 2 ≤ u) (hT : Real.exp u ≤ T) (hbase : f*u^2 ≤ d*Real.exp u) : f*(Real.log T)^2 ≤ d*T := by have hTpos : 0 < T := (Real.exp_pos u).trans_le hT apply (div_le_iff₀ hTpos).mp calc _ = f*((Real.log T)^2/T) := by ring _ ≤ f*(u^2/Real.exp u) := mul_le_mul_of_nonneg_left (log_sq_div_self_le_above_exp hu hT) hf _ = (f*u^2)/Real.exp u := by ring _ ≤ d := (div_le_iff₀ (Real.exp_pos u)).mpr hbase /-- Uniform squared-log absorption retains the same corrected cutoff slope. It can be specialized to the quadratic logarithmic normality envelope. -/ /- Original line 43746: Erdos416Proof.FordBadFacet.exists_uniform_suffix_log_sq_budget -/ theorem exists_uniform_suffix_log_sq_budget (D : ℝ) (hD : 0 ≤ D) (m n : ℕ) : ∃ K : ℝ, 0 ≤ K ∧ ∀ (k : ℕ) (T : ℝ), Real.exp ((k : ℝ)/15+K) ≤ T → D*((k : ℝ)+1)^m*(1+Real.log ((k : ℝ)+1))^n*(Real.log T)^2 ≤ suffixMargin k^2*T := by let f : ℕ → ℝ := fun k => D*((k : ℝ)+1)^m*(1+Real.log ((k : ℝ)+1))^n have hf (k : ℕ) : 0 ≤ f k := by have hk0 : (0 : ℝ) ≤ k := Nat.cast_nonneg k have hlog : 0 ≤ Real.log ((k : ℝ)+1) := Real.log_nonneg (by linarith) dsimp [f] positivity apply uniformize_exponential_threshold · intro k have hsmall : (fun T : ℝ => f k*(Real.log T)^2) =o[atTop] (fun T : ℝ => T) := (Real.isLittleO_pow_log_id_atTop (n := 2)).const_mul_left (f k) have hε : 0 < suffixMargin k^2 := sq_pos_of_pos (suffixMargin_pos k) filter_upwards [hsmall.bound hε, eventually_ge_atTop (1 : ℝ)] with T h hT apply (le_abs_self _).trans simpa only [Real.norm_eq_abs, abs_of_nonneg (show 0 ≤ T by linarith)] using h · filter_upwards [suffix_margin_dominates_polylog 0 D hD (m+2) n, eventually_ge_atTop (30 : ℕ)] with k hk hk30 intro T hT have hk0 : (0 : ℝ) ≤ k := Nat.cast_nonneg k have hu : 2 ≤ (k : ℝ)/15 := by have hkR : (30 : ℝ) ≤ k := by exact_mod_cast hk30 linarith apply weighted_log_sq_budget_above_exp (hf k) hu hT have hpow : ((k : ℝ)/15)^2 ≤ ((k : ℝ)+1)^2 := pow_le_pow_left₀ (by positivity) (by linarith) 2 calc _ ≤ f k*((k : ℝ)+1)^2 := mul_le_mul_of_nonneg_left hpow (hf k) _ = D*((k : ℝ)+1)^(m+2)*(1+Real.log ((k : ℝ)+1))^n := by dsimp [f] rw [pow_add] ring _ ≤ _ := by simpa only [add_zero] using hk /-- The squared-log envelope is absorbed directly by the chosen logarithmic normality parameter, rather than by a generic exponential surrogate. -/ /- Original line 43783: Erdos416Proof.FordBadFacet.exists_uniform_suffix_normality_log_sq_budget -/ theorem exists_uniform_suffix_normality_log_sq_budget (E : ℝ) (hE : 0 ≤ E) : ∃ K : ℝ, 0 ≤ K ∧ ∀ (k : ℕ) (T : ℝ), Real.exp ((k : ℝ)/15+K) ≤ T → E*(Real.log T)^2 ≤ facetNormalityParameter ((k+1 : ℕ) : ℝ) (suffixMargin k/2) T := by obtain ⟨K, hK, hbound⟩ := exists_uniform_suffix_log_sq_budget (4096*E) (by positivity) 4 2 refine ⟨K, hK, ?_⟩ intro k T hT let A := normalityCost ((k+1 : ℕ) : ℝ) have hN : (1 : ℝ) ≤ ((k+1 : ℕ) : ℝ) := by exact_mod_cast (show 1 ≤ k+1 by omega) have hA : 0 < A := by have := (normalityCost_bounds hN).1; dsimp [Erdos416Proof.FordBadFacet.facetNormalityScale_logLog, A]; linarith have hmajor : 4096*E*A^2*(Real.log T)^2 ≤ suffixMargin k^2*T := by have h := hbound k T hT convert h using 1 dsimp [Erdos416Proof.FordBadFacet.facetNormalityScale_logLog, A, normalityCost] push_cast ring have hR : facetNormalityParameter ((k+1 : ℕ) : ℝ) (suffixMargin k/2) T = suffixMargin k^2*T/(4096*A^2) := by change ((suffixMargin k/2)/(32*A))^2*T = _ field_simp ring rw [hR] apply (le_div_iff₀ (by positivity : 0 < 4096*A^2)).mpr nlinarith end Erdos416Proof.FordBadFacet end /- Consolidated component: BadFacetPruning.lean. -/ section open Filter Finset Asymptotics open scoped Classical Topology BigOperators Nat namespace Erdos416Proof.FordBadFacet /-- A square failure in any positive preimage, or in its totient. The existential quantifier is essential: exclusion controls every preimage. -/ /- Original line 43825: Erdos416Proof.FordBadFacet.thresholdSquareTotients -/ noncomputable def thresholdSquareTotients (x H : ℝ) : Finset ℕ := (totientsUpTo x).filter (fun m => ∃ n : ℕ, 0 < n ∧ n.totient = m ∧ ∃ q : ℕ, q.Prime ∧ H < (q : ℝ) ∧ (q^2 ∣ n ∨ q^2 ∣ n.totient)) /- Original line 43829: Erdos416Proof.FordBadFacet.thresholdSquareTotients_card_le -/ theorem thresholdSquareTotients_card_le {x z H : ℝ} (hx : 0 ≤ x) (hsize : ∀ n : ℕ, 0 < n → (n.totient : ℝ) ≤ x → (n : ℝ) ≤ z) : (thresholdSquareTotients x H).card ≤ (largePrimeSquareBad ⌊z⌋₊ H).card := by let w : ℕ → ℕ := fun m => if h : m ∈ thresholdSquareTotients x H then Classical.choose (Finset.mem_filter.mp h).2 else 1 have hw (m : ℕ) (hm : m ∈ thresholdSquareTotients x H) : 0 < w m ∧ (w m).totient = m ∧ ∃ q : ℕ, q.Prime ∧ H < (q : ℝ) ∧ (q^2 ∣ w m ∨ q^2 ∣ (w m).totient) := by simpa only [w, dif_pos hm] using Classical.choose_spec (Finset.mem_filter.mp hm).2 apply Finset.card_le_card_of_injOn w · intro m hm obtain ⟨hw0, hwφ, hbad⟩ := hw m hm have hmV := (mem_totientsUpTo hx).mp (Finset.mem_filter.mp hm).1 have hwz := hsize (w m) hw0 (by simpa only [hwφ] using hmV.2.1) exact Finset.mem_filter.mpr ⟨Finset.mem_Icc.mpr ⟨hw0, Nat.le_floor hwz⟩, hbad⟩ · intro m hm r hr heq exact (hw m hm).2.1.symm.trans ((congrArg Nat.totient heq).trans (hw r hr).2.1) /- Original line 43847: Erdos416Proof.FordBadFacet.thresholdSquareTotients_real_bound -/ theorem thresholdSquareTotients_real_bound {x z H : ℝ} (hx : 0 ≤ x) (hz : 1 ≤ z) (hH : 2 ≤ H) (hsize : ∀ n : ℕ, 0 < n → (n.totient : ℝ) ≤ x → (n : ℝ) ≤ z) : ((thresholdSquareTotients x H).card : ℝ) ≤ 12*z*(1+Real.log z)^2/H := by have hfpos : 0 < ⌊z⌋₊ := Nat.floor_pos.mpr hz have hfreal : (0 : ℝ) < ⌊z⌋₊ := by exact_mod_cast hfpos have hfle : (⌊z⌋₊ : ℝ) ≤ z := Nat.floor_le (by linarith) have hflog : Real.log (⌊z⌋₊ : ℝ) ≤ Real.log z := Real.log_le_log hfreal hfle have hflog0 : 0 ≤ Real.log (⌊z⌋₊ : ℝ) := Real.log_nonneg (by exact_mod_cast (show 1 ≤ ⌊z⌋₊ by omega)) have hsq : (1+Real.log (⌊z⌋₊ : ℝ))^2 ≤ (1+Real.log z)^2 := by nlinarith have hcard : ((thresholdSquareTotients x H).card : ℝ) ≤ ((largePrimeSquareBad ⌊z⌋₊ H).card : ℝ) := by exact_mod_cast thresholdSquareTotients_card_le hx hsize apply hcard.trans ((largePrimeSquareBad_card_le hfpos hH).trans ?_) apply div_le_div_of_nonneg_right _ (by linarith) exact mul_le_mul (mul_le_mul_of_nonneg_left hfle (by norm_num)) hsq (sq_nonneg _) (by linarith) /- Original line 43866: Erdos416Proof.FordBadFacet.square_exclusion_of_not_mem -/ theorem square_exclusion_of_not_mem {x H : ℝ} {m n : ℕ} (hm : m ∈ totientsUpTo x) (hn : 0 < n) (hφ : n.totient = m) (hgood : m ∉ thresholdSquareTotients x H) : NoLargePrimeSquare n H ∧ NoLargePrimeSquare m H := by constructor · intro q hq hH hdiv exact hgood (Finset.mem_filter.mpr ⟨hm, n, hn, hφ, q, hq, hH, Or.inl hdiv⟩) · intro q hq hH hdiv exact hgood (Finset.mem_filter.mpr ⟨hm, n, hn, hφ, q, hq, hH, Or.inr (by simpa only [hφ] using hdiv)⟩) /-- The global endpoint threshold agrees with the one used by the sieve. -/ /- Original line 43878: Erdos416Proof.FordBadFacet.facetOmegaTotients -/ noncomputable def facetOmegaTotients (x : ℝ) : Finset ℕ := (totientsUpTo x).filter (fun m => 5*logLog x < (ArithmeticFunction.cardFactors m : ℝ)) /- Original line 43881: Erdos416Proof.FordBadFacet.exists_facetOmegaTotients_bound -/ theorem exists_facetOmegaTotients_bound : ∃ K : ℝ, 0 < K ∧ ∀ x : ℝ, Real.exp 1 ≤ x → ((facetOmegaTotients x).card : ℝ) ≤ K*x*Real.log x^(-37/36 : ℝ) := by obtain ⟨K, hK, hcount⟩ := exists_fiveLogOmega_threshold_bound refine ⟨K, hK, fun x hx => hcount x (facetOmegaTotients x) hx ?_⟩ intro m hm obtain ⟨hmV, hOmega⟩ := Finset.mem_filter.mp hm have hx0 : 0 ≤ x := (Real.exp_pos 1).le.trans hx have hmdata := (mem_totientsUpTo hx0).mp hmV refine ⟨hmdata.1, hmdata.2.1, ?_⟩ have hlog : 0 ≤ Real.log (2 : ℝ) := Real.log_nonneg (by norm_num) linarith /-- All distinct totient values with a failed ordinary-prime facet in at least one positive preimage, before arithmetic pruning. -/ /- Original line 43896: Erdos416Proof.FordBadFacet.badFacetValues -/ noncomputable def badFacetValues (x : ℝ) (k : ℕ) (ω : ℝ) : Finset ℕ := (totientsUpTo x).filter (fun m => ∃ N : ℕ, 0 < N ∧ N.totient = m ∧ 1+ω ≤ ∑ idx : Fin k, fordWeight (idx.val+1)* ordinaryPrimeCoordinate (logLog x) N (idx.val+1)) /- Original line 43901: Erdos416Proof.FordBadFacet.badFacetValues_subset_exceptions -/ theorem badFacetValues_subset_exceptions {x S ω : ℝ} {k : ℕ} (hS : 0 ≤ S) : badFacetValues x k ω ⊆ nonNormalTotients S x ∪ thresholdSquareTotients x (S/2) ∪ facetOmegaTotients x ∪ retainedBadFacetValues x k S ω := by intro m hm obtain ⟨hmV, N, hN, hNm, hfacet⟩ := Finset.mem_filter.mp hm simp only [Finset.mem_union] by_cases hnormal : m ∈ nonNormalTotients S x · tauto by_cases hsquare : m ∈ thresholdSquareTotients x (S/2) · tauto by_cases hOmega : m ∈ facetOmegaTotients x · tauto have hOmegaBound : (ArithmeticFunction.cardFactors m : ℝ) ≤ 5*logLog x := by by_contra h exact hOmega (Finset.mem_filter.mpr ⟨hmV, lt_of_not_ge h⟩) obtain ⟨hPreSq, hSq⟩ := square_exclusion_of_not_mem hmV hN hNm hsquare have hret : m ∈ retainedBadFacetValues x k S ω := Finset.mem_filter.mpr ⟨hmV, hnormal, hSq.mono (by linarith), hOmegaBound, N, hN, hNm, hPreSq, hfacet⟩ tauto /- Original line 43922: Erdos416Proof.FordBadFacet.badFacetValues_card_le_exceptions -/ theorem badFacetValues_card_le_exceptions {x S ω : ℝ} {k : ℕ} (hS : 0 ≤ S) : (badFacetValues x k ω).card ≤ (nonNormalTotients S x).card + (thresholdSquareTotients x (S/2)).card + (facetOmegaTotients x).card + (retainedBadFacetValues x k S ω).card := by have hcover := Finset.card_le_card (badFacetValues_subset_exceptions (x := x) (k := k) (ω := ω) hS) have h₁ := Finset.card_union_le (nonNormalTotients S x) (thresholdSquareTotients x (S/2)) have h₂ := Finset.card_union_le (nonNormalTotients S x ∪ thresholdSquareTotients x (S/2)) (facetOmegaTotients x) have h₃ := Finset.card_union_le (nonNormalTotients S x ∪ thresholdSquareTotients x (S/2) ∪ facetOmegaTotients x) (retainedBadFacetValues x k S ω) omega /-- The full bad-value count is reduced to the numerically defined finite grid cover, with every exceptional term explicitly counted. -/ /- Original line 43938: Erdos416Proof.FordBadFacet.exists_badFacetValues_count_bound -/ theorem exists_badFacetValues_count_bound : ∃ C K : ℝ, 0 < C ∧ 0 < K ∧ ∀ (x z S ω : ℝ) (k : ℕ), 16 ≤ x → 1 ≤ z → Real.exp 1 ≤ S → 4 ≤ S → (∀ n : ℕ, 0 < n → (n.totient : ℝ) ≤ x → (n : ℝ) ≤ z) → ((badFacetValues x k ω).card : ℝ) ≤ C*totientUpperEnvelope x*x/Real.log x*(1+logLog x)^6*Real.exp (-logLog S/6) + 24*z*(1+Real.log z)^2/S + K*x*Real.log x^(-37/36 : ℝ) + ((retainedBadFacetValues x k S ω).card : ℝ) := by obtain ⟨C, hC, hnormal⟩ := exists_nonNormalTotients_envelope_bound obtain ⟨K, hK, hOmega⟩ := exists_facetOmegaTotients_bound refine ⟨C, K, hC, hK, ?_⟩ intro x z S ω k hx hz hS hS4 hsize have hx0 : 0 ≤ x := by linarith have hxexp : Real.exp 1 ≤ x := by have he : Real.exp 1 ≤ 3 := Real.exp_one_lt_d9.le.trans (by norm_num) linarith have h₁ := hnormal S x hS hx have h₂ := thresholdSquareTotients_real_bound hx0 hz (show 2 ≤ S/2 by linarith) hsize have h₃ := hOmega x hxexp have hsum : ((badFacetValues x k ω).card : ℝ) ≤ (nonNormalTotients S x).card + (thresholdSquareTotients x (S/2)).card + (facetOmegaTotients x).card + (retainedBadFacetValues x k S ω).card := by exact_mod_cast badFacetValues_card_le_exceptions (x := x) (k := k) (ω := ω) (show 0 ≤ S by linarith) have heq : 12*z*(1+Real.log z)^2/(S/2) = 24*z*(1+Real.log z)^2/S := by ring rw [heq] at h₂ linarith /-- The exceptional arithmetic and the actual finite cover together give an unconditional finite count once the displayed numerical budgets hold. -/ /- Original line 43968: Erdos416Proof.FordBadFacet.exists_badFacetValues_full_bound -/ theorem exists_badFacetValues_full_bound : ∃ C K J B : ℝ, 0 < C ∧ 0 < K ∧ 0 < J ∧ 0 ≤ B ∧ ∀ (x z h S F ω σ : ℝ) (k : ℕ), 16 ≤ x → 1 ≤ z → 20 ≤ logLog x → 0 < h → 0 < ω → 0 ≤ σ → Real.exp 1 < S → 4 ≤ S → Real.exp ((logLog x)^36) ≤ S → S ≤ F → F ≤ x^(1/(20*logLog x)) → logLog F ≤ logLog x+1 → (∀ n : ℕ, 0 < n → (n.totient : ℝ) ≤ x → (n : ℝ) ≤ z) → (∑ idx : Fin k, fordWeight (idx.val+1))* (h*logLog x+logLog S+logLog x+1-logLog F) ≤ (ω-σ)*logLog x → ((k+1 : ℕ) : ℝ)*Real.log (k+1 : ℕ)*logLog S + ((k+1 : ℕ) : ℝ)^2* (2*Real.sqrt (logLog S*(logLog x+1))*Real.log (k+1 : ℕ)+B) ≤ σ/2*logLog x → ((badFacetValues x k ω).card : ℝ) ≤ C*totientUpperEnvelope x*x/Real.log x*(1+logLog x)^6*Real.exp (-logLog S/6) + 24*z*(1+Real.log z)^2/S + K*x*Real.log x^(-37/36 : ℝ) + J*x*((k+1)*(coordinateGrid k h 2).card : ℕ)*Real.exp (-(1+σ/2)*logLog x) := by obtain ⟨C, K, hC, hK, hprune⟩ := exists_badFacetValues_count_bound obtain ⟨J, B, hJ, hB, hcover⟩ := exists_retainedBadFacet_count_bound refine ⟨C, K, J, B, hC, hK, hJ, hB, ?_⟩ intro x z h S F ω σ k hx hz hT hh hω hσ hS hS4 hscale hSF hcut hFlog hsize hloss hbudget have h₁ := hprune x z S ω k hx hz hS.le hS4 hsize have h₂ := hcover x k h S F ω σ (by linarith) hT hh hω hσ hS hS4 hscale hSF hcut hFlog hloss hbudget linarith end Erdos416Proof.FordBadFacet end /- Consolidated component: ConcentrationCoefficients.lean. -/ section open Filter Finset open scoped Classical Topology BigOperators namespace Erdos416Proof.FordGeometry open FordAnalysis variable {L : ℕ} /-- Slack coordinates in the ordinary positive simplex. -/ /- Original line 44014: Erdos416Proof.FordGeometry.normalizedSlack -/ noncomputable def normalizedSlack (x : Fin L → ℝ) (j : Fin L) : ℝ := simplexWeight L j * slackMap L x j /-- A normalized original coordinate is a linear statistic of simplex coordinates. The last inverse-slack column retains its gStar coefficient. -/ /- Original line 44019: Erdos416Proof.FordGeometry.concentrationCoefficient -/ noncomputable def concentrationCoefficient (idx j : Fin L) : ℝ := inverseSlackWeight idx j / (rho^(idx.val+1)*simplexWeight L j) /- Original line 44022: Erdos416Proof.FordGeometry.normalizedSlack_mem_simplex -/ theorem normalizedSlack_mem_simplex (hL : 2 ≤ L) {x : Fin L → ℝ} (hx : x ∈ unorderedSimplex L) : normalizedSlack x ∈ SimplexVolume.positiveSimplex L 1 := by have hs := (slack_mem_weightedSimplex_iff hL x).mpr hx exact ⟨fun j => mul_nonneg (simplexWeight_pos j).le (hs.1 j), hs.2⟩ /- Original line 44028: Erdos416Proof.FordGeometry.concentrationCoefficient_nonneg -/ theorem concentrationCoefficient_nonneg (idx j : Fin L) : 0 ≤ concentrationCoefficient idx j := by exact div_nonneg (inverseSlackWeight_nonneg idx j) (mul_pos (pow_pos rho_pos _) (simplexWeight_pos j)).le /- Original line 44033: Erdos416Proof.FordGeometry.concentrationCoefficient_zero -/ theorem concentrationCoefficient_zero {idx j : Fin L} (hji : j.val < idx.val) : concentrationCoefficient idx j = 0 := by simp only [concentrationCoefficient, inverseSlackWeight_zero hji, zero_div] /- Original line 44037: Erdos416Proof.FordGeometry.normalized_slack_coordinate -/ theorem normalized_slack_coordinate (idx : Fin L) (x : Fin L → ℝ) : (∑ j : Fin L, concentrationCoefficient idx j * normalizedSlack x j) = x idx / rho^(idx.val+1) := by have hp : rho^(idx.val+1) ≠ 0 := (pow_pos rho_pos _).ne' calc _ = ∑ j : Fin L, (inverseSlackWeight idx j*slackMap L x j)/rho^(idx.val+1) := by apply Finset.sum_congr rfl intro j _ unfold concentrationCoefficient normalizedSlack field_simp [hp, (simplexWeight_pos j).ne'] _ = (∑ j : Fin L, inverseSlackWeight idx j*slackMap L x j)/rho^(idx.val+1) := (Finset.sum_div _ _ _).symm _ = _ := by rw [inverse_slack_coordinates] /- Original line 44051: Erdos416Proof.FordGeometry.scaled_g_lower_fifth -/ theorem scaled_g_lower_fifth {n : ℕ} (hn : 1 ≤ n) : (1/5 : ℝ) ≤ g n*rho^n := by by_cases htwo : 2 ≤ n · linarith [(g_scaled_uniform_lower htwo).le] · have hne : n = 1 := by omega subst n have hg : g 1 = coeff 1 := by simpa [Erdos416Proof.FordAnalysis.FComplex_ofReal, Erdos416Proof.FordAnalysis.F_zero, Erdos416Proof.FordAnalysis.GComplex_ofReal, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordAnalysis.g_zero, Erdos416Proof.FordGeometry.modelVolume_one] using g_succ 0 rw [hg, pow_one] have hc := coeff_one_numeric_lower have hr := rho_numeric_bounds.1 have hprod := mul_le_mul hc.le hr.le (by norm_num : (0 : ℝ) ≤ 217/400) (coeff_bounds 1).1 norm_num at hprod linarith /- Original line 44066: Erdos416Proof.FordGeometry.scale_ratio_by_rho -/ theorem scale_ratio_by_rho {a b : ℝ} {idx j : ℕ} (hij : idx ≤ j) (hb : b ≠ 0) : a/(rho^(idx+1)*b) = (a*rho^(j-idx))/(b*rho^(j+1)) := by have he : rho^(j+1) = rho^(idx+1)*rho^(j-idx) := by rw [← pow_add] congr 1 omega rw [he] field_simp [hb, (pow_pos rho_pos (idx+1)).ne', (pow_pos rho_pos (j-idx)).ne'] /- Original line 44076: Erdos416Proof.FordGeometry.concentrationCoefficient_nonterminal -/ theorem concentrationCoefficient_nonterminal {idx j : Fin L} (hij : idx.val ≤ j.val) (hj : j.val+1 < L) : concentrationCoefficient idx j = (g (j.val-idx.val)*rho^(j.val-idx.val))/(g (j.val+1)*rho^(j.val+1)) := by unfold concentrationCoefficient inverseSlackWeight simplexWeight rw [if_pos hij, if_pos hj, if_pos hj] exact scale_ratio_by_rho hij (g_pos _).ne' /- Original line 44084: Erdos416Proof.FordGeometry.concentrationCoefficient_terminal -/ theorem concentrationCoefficient_terminal {idx j : Fin L} (hij : idx.val ≤ j.val) (hj : ¬j.val+1 < L) : concentrationCoefficient idx j = (gStar (j.val-idx.val)*rho^(j.val-idx.val))/(gStar (j.val+1)*rho^(j.val+1)) := by unfold concentrationCoefficient inverseSlackWeight simplexWeight rw [if_pos hij, if_neg hj, if_neg hj] exact scale_ratio_by_rho hij (gStar_pos _).ne' /- Original line 44092: Erdos416Proof.FordGeometry.concentrationCoefficient_le_five -/ theorem concentrationCoefficient_le_five (idx j : Fin L) : concentrationCoefficient idx j ≤ 5 := by by_cases hij : idx.val ≤ j.val · by_cases hj : j.val+1 < L · rw [concentrationCoefficient_nonterminal hij hj] apply (div_le_iff₀ (mul_pos (g_pos _) (pow_pos rho_pos _))).mpr have hl := scaled_g_lower_fifth (show 1 ≤ j.val+1 by omega) have hu := g_scaled_le_one (j.val-idx.val) linarith · rw [concentrationCoefficient_terminal hij hj] apply (div_le_iff₀ (mul_pos (gStar_pos _) (pow_pos rho_pos _))).mpr have hl := gStar_scaled_lower (j.val+1) have hu := gStar_scaled_le_one (j.val-idx.val) linarith · rw [concentrationCoefficient_zero (by omega)] norm_num /- Original line 44109: Erdos416Proof.FordGeometry.concentrationCoefficient_terminal_error -/ theorem concentrationCoefficient_terminal_error {idx j : Fin L} : |concentrationCoefficient idx j-1| ≤ 5 := by rw [abs_le] constructor <;> linarith [concentrationCoefficient_nonneg idx j, concentrationCoefficient_le_five idx j] /- Original line 44115: Erdos416Proof.FordGeometry.concentrationCoefficient_nonterminal_error -/ theorem concentrationCoefficient_nonterminal_error {idx j : Fin L} (hij : idx.val ≤ j.val) (hj : j.val+1 < L) : |concentrationCoefficient idx j-1| ≤ 25*(rho^(j.val-idx.val)+rho^(j.val+1)) := by rw [concentrationCoefficient_nonterminal hij hj] have hd : 0 < g (j.val+1)*rho^(j.val+1) := mul_pos (g_pos _) (pow_pos rho_pos _) have hl := scaled_g_lower_fifth (show 1 ≤ j.val+1 by omega) have hnum := g_scaled_error_bounds (j.val-idx.val) have hden := g_scaled_error_bounds (j.val+1) have herr : |g (j.val-idx.val)*rho^(j.val-idx.val)-g (j.val+1)*rho^(j.val+1)| ≤ 5*(rho^(j.val-idx.val)+rho^(j.val+1)) := by rw [abs_le] constructor <;> linarith have heq : (g (j.val-idx.val)*rho^(j.val-idx.val))/(g (j.val+1)*rho^(j.val+1))-1 = (g (j.val-idx.val)*rho^(j.val-idx.val)-g (j.val+1)*rho^(j.val+1))/ (g (j.val+1)*rho^(j.val+1)) := by rw [sub_div, div_self hd.ne'] rw [heq, abs_div, abs_of_pos hd] apply (div_le_iff₀ hd).mpr have hp : 0 ≤ rho^(j.val-idx.val)+rho^(j.val+1) := add_nonneg (pow_pos rho_pos _).le (pow_pos rho_pos _).le have hb := mul_le_mul_of_nonneg_left hl (mul_nonneg (by norm_num : (0 : ℝ) ≤ 25) hp) nlinarith /- Original line 44137: Erdos416Proof.FordGeometry.suffix_geometric_sum_le_four -/ theorem suffix_geometric_sum_le_four (idx : Fin L) : (∑ j : Fin L, if idx.val ≤ j.val then rho^(j.val-idx.val) else 0) ≤ 4 := by have he : (∑ j : Fin L, if idx.val ≤ j.val then rho^(j.val-idx.val) else 0) = ∑ j ∈ Ico idx.val L, rho^(j-idx.val) := by simpa only [Fin.isLt, and_true] using (sum_fin_Ico (L := L) (a := idx.val) (b := L) le_rfl (fun j => rho^(j-idx.val))) rw [he, Finset.sum_Ico_eq_sum_range] simp only [Nat.add_sub_cancel_left] calc (∑ j ∈ range (L-idx.val), rho^j) ≤ (1-rho)⁻¹ := by have hs := hasSum_geometric_of_lt_one rho_pos.le rho_lt_one rw [← hs.tsum_eq] exact hs.summable.sum_le_tsum _ (fun _ _ => (pow_pos rho_pos _).le) _ ≤ 4 := by rw [← one_div] apply (div_le_iff₀ (sub_pos.mpr rho_lt_one)).mpr linarith [rho_lt_three_quarters] /-- Only a uniformly summable renewal error separates this statistic from a suffix sum of barycentric coordinates. -/ /- Original line 44157: Erdos416Proof.FordGeometry.concentrationCoefficient_total_error -/ theorem concentrationCoefficient_total_error (idx : Fin L) : (∑ j : Fin L, |concentrationCoefficient idx j-(if idx.val ≤ j.val then 1 else 0)|) ≤ 205 := by have hpoint (j : Fin L) : |concentrationCoefficient idx j-(if idx.val ≤ j.val then 1 else 0)| ≤ 50*(if idx.val ≤ j.val then rho^(j.val-idx.val) else 0)+ (if j.val+1=L then 5 else 0) := by by_cases hij : idx.val ≤ j.val · rw [if_pos hij, if_pos hij] by_cases hj : j.val+1 < L · rw [if_neg (by omega : ¬j.val+1=L), add_zero] have he := concentrationCoefficient_nonterminal_error hij hj have hp := pow_le_pow_of_le_one rho_pos.le rho_lt_one.le (show j.val-idx.val ≤ j.val+1 by omega) nlinarith · rw [if_pos (by have := j.isLt; omega : j.val+1=L)] have he := concentrationCoefficient_terminal_error (idx := idx) (j := j) have hp := (pow_pos rho_pos (j.val-idx.val)).le linarith · rw [concentrationCoefficient_zero (by omega), if_neg hij, if_neg hij] split_ifs <;> norm_num let last : Fin L := ⟨L-1, by have := idx.isLt; omega⟩ have hlast (j : Fin L) : j.val+1=L ↔ j=last := by constructor · intro hj apply Fin.ext dsimp [last] omega · intro hj subst j dsimp [last] have := idx.isLt omega calc _ ≤ ∑ j : Fin L, (50*(if idx.val ≤ j.val then rho^(j.val-idx.val) else 0)+ (if j.val+1=L then 5 else 0)) := Finset.sum_le_sum (fun j _ => hpoint j) _ = 50*(∑ j : Fin L, if idx.val ≤ j.val then rho^(j.val-idx.val) else 0)+5 := by rw [Finset.sum_add_distrib, ← Finset.mul_sum] simp_rw [hlast] simp _ ≤ 205 := by linarith [suffix_geometric_sum_le_four idx] /- Original line 44198: Erdos416Proof.FordGeometry.suffix_indicator_sum -/ theorem suffix_indicator_sum (idx : Fin L) : (∑ j : Fin L, if idx.val ≤ j.val then (1 : ℝ) else 0) = (L-idx.val : ℕ) := by have he := sum_fin_Ico (L := L) (a := idx.val) (b := L) le_rfl (fun _ => (1 : ℝ)) simpa only [Fin.isLt, and_true, Finset.sum_const, Nat.card_Ico, nsmul_eq_mul, mul_one] using he /- Original line 44204: Erdos416Proof.FordGeometry.concentrationCoefficient_sum_error -/ theorem concentrationCoefficient_sum_error (idx : Fin L) : |(∑ j : Fin L, concentrationCoefficient idx j)-(L-idx.val : ℕ)| ≤ 205 := by rw [← suffix_indicator_sum idx, ← Finset.sum_sub_distrib] exact (Finset.abs_sum_le_sum_abs _ _).trans (concentrationCoefficient_total_error idx) /-- Converting the bounded renewal bias to the relative coordinate scale costs the reciprocal distance from the last retained coordinate. -/ /- Original line 44211: Erdos416Proof.FordGeometry.relative_mean_error -/ theorem relative_mean_error {s n r : ℝ} (hn : 1 ≤ n) (hr : 0 < r) (hrn : r ≤ n) (hs : |s-(r+1)| ≤ 205) : |(s/(n+1))/(r/n)-1| ≤ 206/r := by have hn0 : 0 < n := by linarith have hn1 : 0 < n+1 := by linarith have hd : 0 < (n+1)*r := mul_pos hn1 hr have heq : (s/(n+1))/(r/n)-1 = (n*s-(n+1)*r)/((n+1)*r) := by field_simp [hn0.ne', hn1.ne', hr.ne'] have hslo := mul_le_mul_of_nonneg_left (abs_le.mp hs).1 hn0.le have hshi := mul_le_mul_of_nonneg_left (abs_le.mp hs).2 hn0.le have hb : |n*s-(n+1)*r| ≤ 206*(n+1) := by rw [abs_le] constructor <;> nlinarith rw [heq, abs_div, abs_of_pos hd] apply (div_le_iff₀ hd).mpr have hcancel : 206/r*((n+1)*r) = 206*(n+1) := by field_simp rw [hcancel] exact hb /- Original line 44230: Erdos416Proof.FordGeometry.concentrationMean -/ noncomputable def concentrationMean (idx : Fin L) : ℝ := (∑ j : Fin L, concentrationCoefficient idx j)/((L : ℝ)+1) /- Original line 44233: Erdos416Proof.FordGeometry.concentrationMean_relative_error -/ theorem concentrationMean_relative_error (idx : Fin L) (hi : idx.val+1 < L) : |concentrationMean idx/((L-(idx.val+1) : ℕ)/(L : ℝ))-1| ≤ 206/(L-(idx.val+1) : ℕ) := by have hL : 1 ≤ L := by omega have hr : 0 < L-(idx.val+1) := by omega have heq : ((L-idx.val : ℕ) : ℝ) = (L-(idx.val+1) : ℕ)+1 := by exact_mod_cast (show L-idx.val = L-(idx.val+1)+1 by omega) have hs := concentrationCoefficient_sum_error idx rw [heq] at hs exact relative_mean_error (by exact_mod_cast hL) (by exact_mod_cast hr) (by exact_mod_cast (Nat.sub_le L (idx.val+1))) hs /- Original line 44245: Erdos416Proof.FordGeometry.concentrationMean_bounds -/ theorem concentrationMean_bounds (idx : Fin L) : 0 ≤ concentrationMean idx ∧ concentrationMean idx ≤ 5 := by have hden : 0 < (L : ℝ)+1 := by positivity constructor · exact div_nonneg (Finset.sum_nonneg (fun j _ => concentrationCoefficient_nonneg idx j)) hden.le · apply (div_le_iff₀ hden).mpr have hs : (∑ j : Fin L, concentrationCoefficient idx j) ≤ ∑ _j : Fin L, (5 : ℝ) := Finset.sum_le_sum (fun j _ => concentrationCoefficient_le_five idx j) simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] at hs linarith /-- Include the residual barycentric coordinate, whose coefficient is zero. -/ /- Original line 44257: Erdos416Proof.FordGeometry.barycentricCoefficient -/ noncomputable def barycentricCoefficient (idx : Fin L) : Fin (L+1) → ℝ := Fin.cons 0 (concentrationCoefficient idx) /- Original line 44260: Erdos416Proof.FordGeometry.centeredCoefficient -/ noncomputable def centeredCoefficient (idx : Fin L) (j : Fin (L+1)) : ℝ := barycentricCoefficient idx j-concentrationMean idx /- Original line 44263: Erdos416Proof.FordGeometry.barycentricCoefficient_bounds -/ theorem barycentricCoefficient_bounds (idx : Fin L) (j : Fin (L+1)) : 0 ≤ barycentricCoefficient idx j ∧ barycentricCoefficient idx j ≤ 5 := by refine Fin.cases ?_ (fun l => ?_) j · norm_num [barycentricCoefficient] · exact ⟨concentrationCoefficient_nonneg idx l, concentrationCoefficient_le_five idx l⟩ /- Original line 44269: Erdos416Proof.FordGeometry.centeredCoefficient_sum -/ theorem centeredCoefficient_sum (idx : Fin L) : (∑ j : Fin (L+1), centeredCoefficient idx j) = 0 := by have hden : (L : ℝ)+1 ≠ 0 := by positivity unfold centeredCoefficient rw [Finset.sum_sub_distrib] simp only [barycentricCoefficient, Fin.sum_univ_succ, Fin.cons_zero, Fin.cons_succ, zero_add, Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul, Nat.cast_add, Nat.cast_one] unfold concentrationMean field_simp [hden] ring /- Original line 44281: Erdos416Proof.FordGeometry.centeredCoefficient_abs_le_five -/ theorem centeredCoefficient_abs_le_five (idx : Fin L) (j : Fin (L+1)) : |centeredCoefficient idx j| ≤ 5 := by unfold centeredCoefficient rw [abs_le] constructor <;> linarith [(barycentricCoefficient_bounds idx j).1, (barycentricCoefficient_bounds idx j).2, (concentrationMean_bounds idx).1, (concentrationMean_bounds idx).2] /- Original line 44289: Erdos416Proof.FordGeometry.coefficient_square_sum_le -/ theorem coefficient_square_sum_le (idx : Fin L) : (∑ j : Fin L, (concentrationCoefficient idx j)^2) ≤ 25*(L-idx.val : ℕ) := by have hpoint (j : Fin L) : (concentrationCoefficient idx j)^2 ≤ 25*(if idx.val ≤ j.val then (1 : ℝ) else 0) := by by_cases hij : idx.val ≤ j.val · rw [if_pos hij, mul_one] nlinarith [concentrationCoefficient_nonneg idx j, concentrationCoefficient_le_five idx j] · rw [if_neg hij, concentrationCoefficient_zero (by omega)] norm_num calc _ ≤ ∑ j : Fin L, 25*(if idx.val ≤ j.val then (1 : ℝ) else 0) := Finset.sum_le_sum (fun j _ => hpoint j) _ = _ := by rw [← Finset.mul_sum, suffix_indicator_sum] /- Original line 44303: Erdos416Proof.FordGeometry.centeredCoefficient_square_sum_le -/ theorem centeredCoefficient_square_sum_le (idx : Fin L) : (∑ j : Fin (L+1), (centeredCoefficient idx j)^2) ≤ 25*(L-idx.val : ℕ) := by have hcenter (j : Fin (L+1)) : (centeredCoefficient idx j)^2 = (barycentricCoefficient idx j)^2-2*concentrationMean idx*centeredCoefficient idx j- (concentrationMean idx)^2 := by unfold centeredCoefficient; ring have he : (∑ j : Fin (L+1), (centeredCoefficient idx j)^2) = (∑ j : Fin L, (concentrationCoefficient idx j)^2)- ((L : ℝ)+1)*(concentrationMean idx)^2 := by simp_rw [hcenter] rw [Finset.sum_sub_distrib, Finset.sum_sub_distrib, ← Finset.mul_sum, centeredCoefficient_sum] simp only [mul_zero, sub_zero, barycentricCoefficient, Fin.sum_univ_succ, Fin.cons_zero, Fin.cons_succ, zero_pow (by norm_num : 2 ≠ 0), zero_add, Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul, Nat.cast_add, Nat.cast_one] rw [he] have hn : 0 ≤ ((L : ℝ)+1)*(concentrationMean idx)^2 := by positivity linarith [coefficient_square_sum_le idx] /- Original line 44322: Erdos416Proof.FordGeometry.centeredCoefficient_fourth_sum_le -/ theorem centeredCoefficient_fourth_sum_le (idx : Fin L) : (∑ j : Fin (L+1), (centeredCoefficient idx j)^4) ≤ 25*(∑ j : Fin (L+1), (centeredCoefficient idx j)^2) := by rw [Finset.mul_sum] apply Finset.sum_le_sum intro j _ have ha := centeredCoefficient_abs_le_five idx j have hsq : (centeredCoefficient idx j)^2 ≤ 25 := by nlinarith [sq_abs (centeredCoefficient idx j), abs_nonneg (centeredCoefficient idx j)] nlinarith [mul_le_mul_of_nonneg_right hsq (sq_nonneg (centeredCoefficient idx j))] /-- The numerator of the exact simplex fourth moment has the quadratic suffix bound needed for a summable family of coordinate errors. -/ /- Original line 44335: Erdos416Proof.FordGeometry.centeredCoefficient_fourth_numerator_le -/ theorem centeredCoefficient_fourth_numerator_le (idx : Fin L) (hi : idx.val+1 < L) : 3*(∑ j : Fin (L+1), (centeredCoefficient idx j)^2)^2 + 6*(∑ j : Fin (L+1), (centeredCoefficient idx j)^4) ≤ 22500*((L-(idx.val+1) : ℕ) : ℝ)^2 := by let r : ℝ := (L-(idx.val+1) : ℕ) have hr : 1 ≤ r := by dsimp [r] exact_mod_cast (show 1 ≤ L-(idx.val+1) by omega) have he : ((L-idx.val : ℕ) : ℝ) = r+1 := by dsimp [r] exact_mod_cast (show L-idx.val = L-(idx.val+1)+1 by omega) have hs0 : 0 ≤ ∑ j : Fin (L+1), (centeredCoefficient idx j)^2 := Finset.sum_nonneg (fun j _ => sq_nonneg _) have hs := centeredCoefficient_square_sum_le idx rw [he] at hs have hs' : (∑ j : Fin (L+1), (centeredCoefficient idx j)^2) ≤ 50*r := by linarith have hsq := mul_self_le_mul_self hs0 hs' have hf := centeredCoefficient_fourth_sum_le idx change _ ≤ 22500*r^2 nlinarith end Erdos416Proof.FordGeometry end /- Consolidated component: UniformBadFacetCount.lean. -/ section open Filter Finset open scoped Classical Topology BigOperators namespace Erdos416Proof.FordBadFacet open FordRestricted /- Original line 44374: Erdos416Proof.FordBadFacet.ordinary_facet_sum_mono_length -/ theorem ordinary_facet_sum_mono_length {T : ℝ} (hT : 0 ≤ T) (N : ℕ) {k l : ℕ} (hkl : k ≤ l) : (∑ idx : Fin k, fordWeight (idx.val+1)*ordinaryPrimeCoordinate T N (idx.val+1)) ≤ ∑ idx : Fin l, fordWeight (idx.val+1)*ordinaryPrimeCoordinate T N (idx.val+1) := by let f : ℕ → ℝ := fun n => fordWeight (n+1)*ordinaryPrimeCoordinate T N (n+1) have hf (n : ℕ) : 0 ≤ f n := by apply mul_nonneg (fordWeight_bounds (by omega : 1 ≤ n+1)).1 exact div_nonneg (le_max_left _ _) hT change (∑ idx : Fin k, f idx.val) ≤ ∑ idx : Fin l, f idx.val rw [Fin.sum_univ_eq_sum_range f k, Fin.sum_univ_eq_sum_range f l] exact Finset.sum_le_sum_of_subset_of_nonneg (Finset.range_mono hkl) (fun n _ _ => hf n) /- Original line 44387: Erdos416Proof.FordBadFacet.badFacetValues_mono_length -/ theorem badFacetValues_mono_length {x ω : ℝ} (hT : 0 ≤ logLog x) {k l : ℕ} (hkl : k ≤ l) : badFacetValues x k ω ⊆ badFacetValues x l ω := by intro m hm obtain ⟨hmV, N, hN, hNm, hfacet⟩ := Finset.mem_filter.mp hm exact Finset.mem_filter.mpr ⟨hmV, N, hN, hNm, hfacet.trans (ordinary_facet_sum_mono_length hT N hkl)⟩ /- Original line 44394: Erdos416Proof.FordBadFacet.badFacetValues_mono_margin -/ theorem badFacetValues_mono_margin {x ω σ : ℝ} {k : ℕ} (hσω : σ ≤ ω) : badFacetValues x k ω ⊆ badFacetValues x k σ := by intro m hm obtain ⟨hmV, N, hN, hNm, hfacet⟩ := Finset.mem_filter.mp hm exact Finset.mem_filter.mpr ⟨hmV, N, hN, hNm, by linarith⟩ /-- A shorter actual suffix with a shifted margin is covered by padding its facet with further nonnegative ordinary-prime coordinates. -/ /- Original line 44402: Erdos416Proof.FordBadFacet.shifted_margin_badFacet_card_le -/ theorem shifted_margin_badFacet_card_le {x σ : ℝ} {k l : ℕ} (hT : 0 ≤ logLog x) (hkl : k ≤ l) (hmargin : suffixMargin l ≤ σ) : (badFacetValues x k σ).card ≤ (badFacetValues x l (suffixMargin l)).card := by apply Finset.card_le_card exact (badFacetValues_mono_margin hmargin).trans (badFacetValues_mono_length hT hkl) /- Original line 44408: Erdos416Proof.FordBadFacet.suffixMargin_add_forty_le_half -/ theorem suffixMargin_add_forty_le_half (k : ℕ) : suffixMargin (k+40) ≤ suffixMargin k/2 := by have hE : Real.exp (-1) ≤ (1/2 : ℝ) := by rw [Real.exp_neg, inv_eq_one_div] apply one_div_le_one_div_of_le (by norm_num : (0 : ℝ) < 2) linarith [Real.add_one_le_exp (1 : ℝ)] have he : suffixMargin (k+40) = suffixMargin k*Real.exp (-1) := by unfold suffixMargin push_cast rw [show -((k : ℝ)+40)/40 = -(k : ℝ)/40+(-1) by ring, Real.exp_add] ring rw [he] calc _ ≤ suffixMargin k*(1/2) := mul_le_mul_of_nonneg_left hE (suffixMargin_pos k).le _ = _ := by ring /- Original line 44424: Erdos416Proof.FordBadFacet.half_shifted_margin_badFacet_card_le -/ theorem half_shifted_margin_badFacet_card_le {x : ℝ} (hT : 0 ≤ logLog x) (k d : ℕ) : (badFacetValues x k (suffixMargin (k+d)/2)).card ≤ (badFacetValues x (k+d+40) (suffixMargin (k+d+40))).card := shifted_margin_badFacet_card_le hT (by omega) (suffixMargin_add_forty_le_half (k+d)) /-- An actual count for every facet length above one common cutoff. The normality parameter, grid mesh, preimage-size bound, and sieve endpoint are all concrete; no structural coverage or counting premise remains. -/ /- Original line 44432: Erdos416Proof.FordBadFacet.exists_uniform_actual_badFacet_bound -/ theorem exists_uniform_actual_badFacet_bound : ∃ C K J c H : ℝ, 0 < C ∧ 0 < K ∧ 0 < J ∧ 0 < c ∧ 0 ≤ H ∧ ∀ᶠ x : ℝ in atTop, ∀ k : ℕ, suffixCutoff H k ≤ x → let N : ℝ := ((k+1 : ℕ) : ℝ) let S := facetNormalityScale N (suffixMargin k/2) (logLog x) let h := facetMesh N (suffixMargin k) ((badFacetValues x k (suffixMargin k)).card : ℝ) ≤ C*totientUpperEnvelope x*x/Real.log x*(1+logLog x)^6*Real.exp (-logLog S/6) + 24*(c*x*logLog x)*(1+Real.log (c*x*logLog x))^2/S + K*x*Real.log x^(-37/36 : ℝ) + J*x*((k+1)*(coordinateGrid k h 2).card : ℕ)* Real.exp (-(1+suffixMargin k/4)*logLog x) := by obtain ⟨C, K, J, B, hC, hK, hJ, hB, hbound⟩ := exists_badFacetValues_full_bound obtain ⟨H, hH, hparams⟩ := exists_uniform_suffix_endpoints B hB obtain ⟨c, hc, hsize⟩ := inverse_totient_bound_eventually refine ⟨C, K, J, c, H, hC, hK, hJ, hc, hH, ?_⟩ filter_upwards [hsize] with x hsize intro k hcutoff obtain ⟨hx, hT, hS, hS4, hscale, hSF, hFlog, _hlogS, hloss, hbudget⟩ := hparams k x hcutoff have hsize' : ∀ n : ℕ, 0 < n → (n.totient : ℝ) ≤ x → (n : ℝ) ≤ c*x*logLog x := by simpa only [logLog] using hsize have hz : 1 ≤ c*x*logLog x := by have hφ : ((1 : ℕ).totient : ℝ) ≤ x := by norm_num; linarith simpa only [Nat.cast_one] using hsize' 1 (by decide) hφ have hN : (1 : ℝ) ≤ ((k+1 : ℕ) : ℝ) := by exact_mod_cast (show 1 ≤ k+1 by omega) have hω := suffixMargin_pos k have hb := hbound x (c*x*logLog x) (facetMesh ((k+1 : ℕ) : ℝ) (suffixMargin k)) (facetNormalityScale ((k+1 : ℕ) : ℝ) (suffixMargin k/2) (logLog x)) (facetSieveCap x) (suffixMargin k) (suffixMargin k/2) k hx hz hT (facetMesh_pos hN hω) hω (by linarith) hS hS4 hscale hSF le_rfl hFlog hsize' hloss hbudget have he : (suffixMargin k/2)/2 = suffixMargin k/4 := by ring simpa only [he] using hb end Erdos416Proof.FordBadFacet end /- Consolidated component: FirstFailedFacet.lean. -/ section open Filter Finset open scoped Classical Topology BigOperators Nat namespace Erdos416Proof.FordBadFacet open FordGeometry FordAnalysis /-- The actual prefix and suffix include the original multiplicities. -/ /- Original line 44487: Erdos416Proof.FordBadFacet.ordinaryPrefix -/ noncomputable abbrev ordinaryPrefix (N j : ℕ) : ℕ := ((ordinaryPrimeList N).take j).prod /- Original line 44488: Erdos416Proof.FordBadFacet.ordinarySuffix -/ noncomputable abbrev ordinarySuffix (N j : ℕ) : ℕ := ((ordinaryPrimeList N).drop j).prod /- Original line 44490: Erdos416Proof.FordBadFacet.ordinary_split -/ theorem ordinary_split {N : ℕ} (hN : 0 < N) (j : ℕ) : ordinaryPrefix N j * ordinarySuffix N j = N := by rw [List.prod_take_mul_prod_drop, ordinaryPrimeList_prod hN.ne'] /- Original line 44494: Erdos416Proof.FordBadFacet.ordinarySuffix_pos -/ theorem ordinarySuffix_pos (N j : ℕ) : 0 < ordinarySuffix N j := by apply List.prod_pos intro p hp exact (Nat.prime_of_mem_primeFactorsList (List.mem_reverse.mp (List.mem_of_mem_drop hp))).pos /- Original line 44500: Erdos416Proof.FordBadFacet.ordinaryPrefix_pos -/ theorem ordinaryPrefix_pos (N j : ℕ) : 0 < ordinaryPrefix N j := by apply List.prod_pos intro p hp exact (Nat.prime_of_mem_primeFactorsList (List.mem_reverse.mp (List.mem_of_mem_take hp))).pos /- Original line 44506: Erdos416Proof.FordBadFacet.ordinarySuffix_list -/ theorem ordinarySuffix_list (N j : ℕ) : ordinaryPrimeList (ordinarySuffix N j) = (ordinaryPrimeList N).drop j := by have hp := Nat.primeFactorsList_unique (n := ordinarySuffix N j) rfl (fun p hp => Nat.prime_of_mem_primeFactorsList (List.mem_reverse.mp (List.mem_of_mem_drop hp))) have hperm := (List.reverse_perm (ordinarySuffix N j).primeFactorsList).trans hp.symm exact hperm.eq_of_sortedGE (ordinaryPrimeList_sorted _) (List.sortedGE_iff_pairwise.mpr (ordinaryPrimeList_sorted N).pairwise.drop) /- Original line 44515: Erdos416Proof.FordBadFacet.ordinaryPrimeAt_suffix -/ theorem ordinaryPrimeAt_suffix (N j idx : ℕ) : ordinaryPrimeAt (ordinarySuffix N j) idx = ordinaryPrimeAt N (j+idx) := by change (ordinaryPrimeList (ordinarySuffix N j)).getD idx 1 = (ordinaryPrimeList N).getD (j+idx) 1 rw [ordinarySuffix_list] simp only [List.getD_eq_getElem?_getD, List.getElem?_drop] /-- A strict gap at the split makes the actual prefix and suffix coprime. -/ /- Original line 44522: Erdos416Proof.FordBadFacet.ordinary_split_coprime -/ theorem ordinary_split_coprime {N j : ℕ} (hj : 0 < j) (hgap : ordinaryPrimeAt N j < ordinaryPrimeAt N (j-1)) : (ordinaryPrefix N j).Coprime (ordinarySuffix N j) := by apply Nat.coprime_list_prod_left_iff.mpr intro p hp apply Nat.coprime_list_prod_right_iff.mpr intro q hq have hpPrime := Nat.prime_of_mem_primeFactorsList (List.mem_reverse.mp (List.mem_of_mem_take hp)) have hqPrime := Nat.prime_of_mem_primeFactorsList (List.mem_reverse.mp (List.mem_of_mem_drop hq)) obtain ⟨a, ha, hpa⟩ := List.mem_take_iff_getElem.mp hp obtain ⟨b, hb, hqb⟩ := List.mem_drop_iff_getElem.mp hq have haj : a < j := lt_of_lt_of_le ha (Nat.min_le_left _ _) have haL : a < (ordinaryPrimeList N).length := lt_of_lt_of_le ha (Nat.min_le_right _ _) have hbL : j+b < (ordinaryPrimeList N).length := by omega have hpa' : ordinaryPrimeAt N a = p := by change (ordinaryPrimeList N).getD a 1 = p rw [List.getD_eq_getElem _ 1 haL] exact hpa have hqb' : ordinaryPrimeAt N (j+b) = q := by change (ordinaryPrimeList N).getD (j+b) 1 = q rw [List.getD_eq_getElem _ 1 hbL] exact hqb have hleft := ordinaryPrimeAt_antitone N (show a ≤ j-1 by omega) have hright := ordinaryPrimeAt_antitone N (show j ≤ j+b by omega) rw [hpa'] at hleft rw [hqb'] at hright exact (Nat.coprime_primes hpPrime hqPrime).mpr (by omega) /- Original line 44552: Erdos416Proof.FordBadFacet.ordinary_split_totient -/ theorem ordinary_split_totient {N j : ℕ} (hN : 0 < N) (hj : 0 < j) (hgap : ordinaryPrimeAt N j < ordinaryPrimeAt N (j-1)) : N.totient = (ordinaryPrefix N j).totient * (ordinarySuffix N j).totient := by calc N.totient = (ordinaryPrefix N j * ordinarySuffix N j).totient := congrArg Nat.totient (ordinary_split hN j).symm _ = _ := Nat.totient_mul (ordinary_split_coprime hj hgap) /-- The arithmetic box bound for every coordinate except the largest prime. -/ /- Original line 44561: Erdos416Proof.FordBadFacet.second_prime_le_totient_product -/ theorem second_prime_le_totient_product {p q : ℕ} (hp : p.Prime) (hq : q.Prime) (hqp : q ≤ p) : q ≤ (p*q).totient := by by_cases he : p = q · subst q rw [Nat.totient_mul_of_prime_of_dvd hp dvd_rfl, Nat.totient_prime hp] have h := hp.two_le exact Nat.le_mul_of_pos_right p (by omega) · have hqp' : q ≤ p-1 := by omega have hq1 : 1 ≤ q-1 := by have := hq.two_le; omega have hs := Nat.totient_super_multiplicative p q rw [Nat.totient_prime hp, Nat.totient_prime hq] at hs exact hqp'.trans ((Nat.le_mul_of_pos_right (p-1) (by omega)).trans hs) /- Original line 44574: Erdos416Proof.FordBadFacet.ordinaryPrimeAt_one_le_totient -/ theorem ordinaryPrimeAt_one_le_totient {N : ℕ} (hN : 0 < N) : ordinaryPrimeAt N 1 ≤ N.totient := by generalize he : ordinaryPrimeList N = l have hprod : l.prod = N := by rw [← he]; exact ordinaryPrimeList_prod hN.ne' cases l with | nil => have ht : 1 ≤ N.totient := Nat.totient_pos.mpr hN simpa [ordinaryPrimeAt, he] using ht | cons p l => cases l with | nil => have ht : 1 ≤ N.totient := Nat.totient_pos.mpr hN simpa [ordinaryPrimeAt, he] using ht | cons q l => have hp : p.Prime := Nat.prime_of_mem_primeFactorsList (show p ∈ N.primeFactorsList from List.mem_reverse.mp (by change p ∈ ordinaryPrimeList N; rw [he]; simp)) have hq : q.Prime := Nat.prime_of_mem_primeFactorsList (show q ∈ N.primeFactorsList from List.mem_reverse.mp (by change q ∈ ordinaryPrimeList N; rw [he]; simp)) have hqp : q ≤ p := by have hs := ordinaryPrimeAt_antitone N (show 0 ≤ 1 by omega) simpa [ordinaryPrimeAt, he] using hs have hd : p*q ∣ N := ⟨l.prod, by simpa [mul_assoc] using hprod.symm⟩ have ht := Nat.le_of_dvd (Nat.totient_pos.mpr hN) (Nat.totient_dvd_of_dvd hd) simpa [ordinaryPrimeAt, he] using (second_prime_le_totient_product hp hq hqp).trans ht /- Original line 44599: Erdos416Proof.FordBadFacet.ordinaryPrimeCoordinate_le_one -/ theorem ordinaryPrimeCoordinate_le_one {N : ℕ} {x : ℝ} (hN : 0 < N) (hx : Real.exp 1 ≤ x) (hT : 0 < logLog x) (hphi : (N.totient : ℝ) ≤ x) {idx : ℕ} (hi : 1 ≤ idx) : ordinaryPrimeCoordinate (logLog x) N idx ≤ 1 := by have hq : (ordinaryPrimeAt N idx : ℝ) ≤ x := (Nat.cast_le.mpr ((ordinaryPrimeAt_antitone N hi).trans (ordinaryPrimeAt_one_le_totient hN))).trans hphi have hlog := positiveLogLog_mono (by exact_mod_cast ordinaryPrimeAt_one_le N idx) hq have hxx : positiveLogLog x = logLog x := max_eq_right (logLog_nonneg hx) rw [hxx] at hlog exact (div_le_one hT).mpr hlog /- Original line 44609: Erdos416Proof.FordBadFacet.shiftedFacet -/ noncomputable def shiftedFacet (q : ℕ → ℝ) (j k : ℕ) : ℝ := ∑ idx : Fin k, fordWeight (idx.val+1)*q (j+idx.val+1) /-- Row zero has constant right side. The remaining nonterminal rows are normalized by the ordinary prime at the beginning of their suffix. -/ /- Original line 44614: Erdos416Proof.FordBadFacet.RowHolds -/ def RowHolds (L : ℕ) (ξ q : ℕ → ℝ) (j : ℕ) : Prop := if j = 0 then shiftedFacet q 0 L ≤ ξ 0 else shiftedFacet q j (L-j) ≤ ξ j*q j /- Original line 44618: Erdos416Proof.FordBadFacet.FirstFailedRow -/ def FirstFailedRow (L : ℕ) (ξ q : ℕ → ℝ) (j : ℕ) : Prop := j+1 < L ∧ ¬RowHolds L ξ q j ∧ ∀ idx < j, RowHolds L ξ q idx /- Original line 44621: Erdos416Proof.FordBadFacet.expandedParameter_monotone -/ theorem expandedParameter_monotone (A : ℕ) : Monotone (expandedParameter A) := by intro idx j hij unfold expandedParameter have hcast : (idx : ℝ) ≤ j := by exact_mod_cast hij have he : Real.exp (-(((A : ℝ) - idx) / 40)) ≤ Real.exp (-(((A : ℝ) - j) / 40)) := Real.exp_le_exp.mpr (by linarith) nlinarith /-- In Theorem 16 the margin uses the original dimension A, while the retained suffix length is L-j. These quantities need not be equal. -/ /- Original line 44631: Erdos416Proof.FordBadFacet.expandedParameter_row_margin -/ theorem expandedParameter_row_margin {A j : ℕ} (hj : j ≤ A) : expandedParameter A j = 1 + FordRestricted.suffixMargin (A-j) := by unfold expandedParameter FordRestricted.suffixMargin rw [Nat.cast_sub hj] congr 2 congr 1 ring /- Original line 44639: Erdos416Proof.FordBadFacet.exists_firstFailedRow -/ theorem exists_firstFailedRow {L : ℕ} (ξ q : ℕ → ℝ) (hbad : ∃ j, j+1 < L ∧ ¬RowHolds L ξ q j) : ∃ j, FirstFailedRow L ξ q j := by let j := Nat.find hbad have hj := Nat.find_spec hbad refine ⟨j, hj.1, hj.2, ?_⟩ intro idx hij by_contra hi exact Nat.find_min hbad hij ⟨by omega, hi⟩ /- Original line 44649: Erdos416Proof.FordBadFacet.shiftedFacet_full_sum -/ theorem shiftedFacet_full_sum (q : ℕ → ℝ) (L j : ℕ) : shiftedFacet q j (L-j) = ∑ idx : Fin L, if j ≤ idx.val then fordWeight (idx.val+1-j)*q (idx.val+1) else 0 := by have he := sum_fin_Ico (L := L) (a := j) (b := L) le_rfl (fun idx => fordWeight (idx+1-j)*q (idx+1)) simp only [Fin.isLt, and_true] at he rw [he, Finset.sum_Ico_eq_sum_range] rw [shiftedFacet, Fin.sum_univ_eq_sum_range (fun idx : ℕ => fordWeight (idx+1)*q (j+idx+1)) (L-j)] apply Finset.sum_congr rfl intro idx hi congr 2 omega /- Original line 44663: Erdos416Proof.FordBadFacet.shiftedFacet_tailForm -/ theorem shiftedFacet_tailForm {L j : ℕ} (q : ℕ → ℝ) (hj : 0 < j) (hjL : j+1 < L) : shiftedFacet q j (L-j) = tailForm ⟨j-1, by omega⟩ (fun idx : Fin L => q (idx.val+1)) := by rw [shiftedFacet_full_sum, tailForm_eq_sum _ _ (by simp only; omega)] apply Finset.sum_congr rfl intro idx _ have hc : j ≤ idx.val ↔ j-1 < idx.val := by omega simp only [hc] split_ifs · congr 2 omega · rfl /- Original line 44676: Erdos416Proof.FordBadFacet.shiftedFacet_nonneg -/ theorem shiftedFacet_nonneg (q : ℕ → ℝ) (hq : ∀ idx, 0 ≤ q idx) (j k : ℕ) : 0 ≤ shiftedFacet q j k := sum_nonneg (fun idx _ => mul_nonneg (fordWeight_bounds (by omega)).1 (hq _)) /- Original line 44680: Erdos416Proof.FordBadFacet.shiftedFacet_length_mono -/ theorem shiftedFacet_length_mono (q : ℕ → ℝ) (hq : ∀ idx, 0 ≤ q idx) (j : ℕ) {k K : ℕ} (hk : k ≤ K) : shiftedFacet q j k ≤ shiftedFacet q j K := by exact sum_initial_le hk (fun idx : Fin K => fordWeight (idx.val+1)*q (j+idx.val+1)) (fun idx => mul_nonneg (fordWeight_bounds (by omega)).1 (hq _)) /- Original line 44685: Erdos416Proof.FordBadFacet.fordWeight_mono_positive -/ theorem fordWeight_mono_positive {idx j : ℕ} (hi : 1 ≤ idx) (hij : idx ≤ j) : fordWeight idx ≤ fordWeight j := by simpa only [coeff_eq hi, coeff_eq (hi.trans hij)] using coeff_monotone hij /- Original line 44689: Erdos416Proof.FordBadFacet.shiftedFacet_row_antitone -/ theorem shiftedFacet_row_antitone (q : ℕ → ℝ) (hq : ∀ idx, 0 ≤ q idx) (L : ℕ) {j : ℕ} (hj : 0 < j) : shiftedFacet q j (L-j) ≤ shiftedFacet q (j-1) (L-(j-1)) := by rw [shiftedFacet_full_sum, shiftedFacet_full_sum] apply Finset.sum_le_sum intro idx _ by_cases hji : j ≤ idx.val · rw [if_pos hji, if_pos (by omega : j-1 ≤ idx.val)] exact mul_le_mul_of_nonneg_right (fordWeight_mono_positive (by omega) (by omega)) (hq _) · rw [if_neg hji] split_ifs · exact mul_nonneg (fordWeight_bounds (by omega)).1 (hq _) · rfl /- Original line 44703: Erdos416Proof.FordBadFacet.firstFailedRow_strict_gap -/ theorem firstFailedRow_strict_gap {L j : ℕ} {ξ q : ℕ → ℝ} (hfirst : FirstFailedRow L ξ q j) (hj : 2 ≤ j) (hq : ∀ idx, 0 ≤ q idx) (hξ : ∀ idx, 0 < ξ idx) (hξmono : Monotone ξ) : q j < q (j-1) := by have hfail : ξ j*q j < shiftedFacet q j (L-j) := by exact lt_of_not_ge (by simpa only [RowHolds, if_neg (by omega : j ≠ 0)] using hfirst.2.1) have hprev : shiftedFacet q (j-1) (L-(j-1)) ≤ ξ (j-1)*q (j-1) := by simpa only [RowHolds, if_neg (by omega : j-1 ≠ 0)] using hfirst.2.2 (j-1) (by omega) have hrows := shiftedFacet_row_antitone q hq L (by omega : 0 < j) have hpar := mul_le_mul_of_nonneg_right (hξmono (show j-1 ≤ j by omega)) (hq j) have hstrict := lt_of_le_of_lt hpar (hfail.trans_le (hrows.trans hprev)) nlinarith [hξ (j-1)] /-- All nonterminal rows characterize the polytope once order and the unit coordinate bounds are known; the last row then follows automatically. -/ /- Original line 44718: Erdos416Proof.FordBadFacet.mem_polytope_of_rows -/ theorem mem_polytope_of_rows {L : ℕ} (ξ q : ℕ → ℝ) (hq0 : ∀ idx, 0 ≤ q idx) (hq1 : ∀ idx, 1 ≤ idx → q idx ≤ 1) (hanti : Antitone q) (hξ : ∀ idx, 1 ≤ ξ idx) (hrows : ∀ j, j+1 < L → RowHolds L ξ q j) (houter : shiftedFacet q 0 L ≤ ξ 0) : (fun idx : Fin L => q (idx.val+1)) ∈ polytope L ξ := by refine ⟨fun idx => hq0 _, fun idx => hq1 _ (by omega), ?_, ?_, ?_⟩ · intro idx j hij exact hanti (Nat.add_le_add_right hij 1) · simpa only [outerForm, weightedForm_apply, shiftedFacet, Nat.zero_add] using houter · intro idx hi by_cases hrow : idx.val+2 < L · have hh : shiftedFacet q (idx.val+1) (L-(idx.val+1)) ≤ ξ (idx.val+1)*q (idx.val+1) := by simpa only [RowHolds, if_neg (by omega : idx.val+1 ≠ 0)] using hrows (idx.val+1) hrow rw [shiftedFacet_tailForm q (by omega) hrow] at hh simpa only [Nat.add_sub_cancel] using hh · have hiL : idx.val+2 = L := by omega rw [tailForm_last idx ⟨idx.val+1, hi⟩ hiL rfl] exact (hanti (show idx.val+1 ≤ (idx.val+1)+1 by omega)).trans (le_mul_of_one_le_left (hq0 _) (hξ _)) /- Original line 44739: Erdos416Proof.FordBadFacet.firstFailedRow_prefix_mem -/ theorem firstFailedRow_prefix_mem {L j : ℕ} {ξ q : ℕ → ℝ} (hfirst : FirstFailedRow L ξ q j) (hj : 0 < j) (hq0 : ∀ idx, 0 ≤ q idx) (hq1 : ∀ idx, 1 ≤ idx → q idx ≤ 1) (hanti : Antitone q) (hξ : ∀ idx, 1 ≤ ξ idx) : (fun idx : Fin (j-1) => q (idx.val+1)) ∈ polytope (j-1) ξ := by have houter : shiftedFacet q 0 (j-1) ≤ ξ 0 := by apply (shiftedFacet_length_mono q hq0 0 (show j-1 ≤ L by have := hfirst.1; omega)).trans simpa [RowHolds] using hfirst.2.2 0 hj apply mem_polytope_of_rows ξ q hq0 hq1 hanti hξ _ houter intro idx hi by_cases hi0 : idx = 0 · simpa only [RowHolds, if_pos hi0] using houter · have hprev : shiftedFacet q idx (L-idx) ≤ ξ idx*q idx := by simpa only [RowHolds, if_neg hi0] using hfirst.2.2 idx (by omega) simpa only [RowHolds, if_neg hi0] using (shiftedFacet_length_mono q hq0 idx (show (j-1)-idx ≤ L-idx by have := hfirst.1; omega)).trans hprev /- Original line 44756: Erdos416Proof.FordBadFacet.not_mem_polytope_iff_failed_row -/ theorem not_mem_polytope_iff_failed_row {L : ℕ} (hL : 2 ≤ L) (ξ q : ℕ → ℝ) (hq0 : ∀ idx, 0 ≤ q idx) (hq1 : ∀ idx, 1 ≤ idx → q idx ≤ 1) (hanti : Antitone q) (hξ : ∀ idx, 1 ≤ ξ idx) : (fun idx : Fin L => q (idx.val+1)) ∉ polytope L ξ ↔ ∃ j, j+1 < L ∧ ¬RowHolds L ξ q j := by constructor · intro hnot by_contra hbad have hrows : ∀ j, j+1 < L → RowHolds L ξ q j := by intro j hj by_contra hrow exact hbad ⟨j, hj, hrow⟩ apply hnot apply mem_polytope_of_rows ξ q hq0 hq1 hanti hξ hrows simpa [Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordGeometry.slackMap_apply, RowHolds] using hrows 0 (by omega) · rintro ⟨j, hjL, hjbad⟩ hx apply hjbad by_cases hj : j = 0 · subst j simpa [Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordGeometry.slackMap_apply, RowHolds, shiftedFacet, outerForm, weightedForm_apply, Nat.zero_add] using hx.2.2.2.1 · have hrow := hx.2.2.2.2 ⟨j-1, by omega⟩ (by simp only; omega) rw [← shiftedFacet_tailForm q (by omega) hjL] at hrow simpa only [RowHolds, if_neg hj, Nat.sub_add_cancel (by omega : 1 ≤ j)] using hrow /- Original line 44781: Erdos416Proof.FordBadFacet.ordinary_coordinate_nonneg -/ theorem ordinary_coordinate_nonneg (N idx : ℕ) {T : ℝ} (hT : 0 ≤ T) : 0 ≤ ordinaryPrimeCoordinate T N idx := div_nonneg (le_max_left _ _) hT /- Original line 44785: Erdos416Proof.FordBadFacet.actual_firstFailed_prefix -/ theorem actual_firstFailed_prefix {N L j : ℕ} {x : ℝ} {ξ : ℕ → ℝ} (hN : 0 < N) (hx : Real.exp 1 ≤ x) (hT : 0 < logLog x) (hphi : (N.totient : ℝ) ≤ x) (hξ : ∀ idx, 1 ≤ ξ idx) (hfirst : FirstFailedRow L ξ (ordinaryPrimeCoordinate (logLog x) N) j) (hj : 0 < j) : (fun idx : Fin (j-1) => ordinaryPrimeCoordinate (logLog x) N (idx.val+1)) ∈ polytope (j-1) ξ := firstFailedRow_prefix_mem hfirst hj (fun idx => ordinary_coordinate_nonneg N idx hT.le) (fun _i hi => ordinaryPrimeCoordinate_le_one hN hx hT hphi hi) (ordinaryPrimeCoordinate_antitone N hT.le) hξ /- Original line 44796: Erdos416Proof.FordBadFacet.actual_firstFailed_prefix_tuple -/ theorem actual_firstFailed_prefix_tuple {N L j : ℕ} {x : ℝ} {ξ : ℕ → ℝ} (hN : 0 < N) (hx : Real.exp 1 ≤ x) (hT : 0 < logLog x) (hphi : (N.totient : ℝ) ≤ x) (hξ : ∀ idx, 1 ≤ ξ idx) (hfirst : FirstFailedRow L ξ (ordinaryPrimeCoordinate (logLog x) N) j) (hj : 0 < j) : (∏ idx : Fin (j-1), ordinaryPrimeAt N (idx.val+1)) ∈ FordReciprocal.tupleIntegers (j-1) (logLog x) (polytope (j-1) ξ) := by apply (FordReciprocal.mem_tupleIntegers hT (fun _ hx => ⟨hx.1, hx.2.1⟩)).mpr refine ⟨fun idx => ordinaryPrimeAt N (idx.val+1), rfl, ?_, ?_, ?_⟩ · intro idx rcases ordinaryPrimeAt_spec N (idx.val+1) with hi | ⟨hp, _⟩ · exact Or.inr hi · exact Or.inl hp · intro idx k hik exact ordinaryPrimeAt_antitone N (Nat.add_le_add_right hik 1) · exact actual_firstFailed_prefix hN hx hT hphi hξ hfirst hj /- Original line 44813: Erdos416Proof.FordBadFacet.actual_firstFailed_gap -/ theorem actual_firstFailed_gap {N L j : ℕ} {T : ℝ} {ξ : ℕ → ℝ} (hT : 0 < T) (hξ : ∀ idx, 0 < ξ idx) (hξmono : Monotone ξ) (hfirst : FirstFailedRow L ξ (ordinaryPrimeCoordinate T N) j) (hj : 2 ≤ j) : ordinaryPrimeAt N j < ordinaryPrimeAt N (j-1) := by have hg := firstFailedRow_strict_gap hfirst hj (fun idx => ordinary_coordinate_nonneg N idx hT.le) hξ hξmono by_contra hgap have hq : (ordinaryPrimeAt N (j-1) : ℝ) ≤ ordinaryPrimeAt N j := Nat.cast_le.mpr (le_of_not_gt hgap) have hc := div_le_div_of_nonneg_right (positiveLogLog_mono (by exact_mod_cast ordinaryPrimeAt_one_le N (j-1)) hq) hT.le exact (not_lt_of_ge hc) hg /- Original line 44826: Erdos416Proof.FordBadFacet.actual_firstFailed_totient_split -/ theorem actual_firstFailed_totient_split {N L j : ℕ} {T : ℝ} {ξ : ℕ → ℝ} (hN : 0 < N) (hT : 0 < T) (hξ : ∀ idx, 0 < ξ idx) (hξmono : Monotone ξ) (hfirst : FirstFailedRow L ξ (ordinaryPrimeCoordinate T N) j) (hj : 2 ≤ j) : N.totient = (ordinaryPrefix N j).totient * (ordinarySuffix N j).totient := ordinary_split_totient hN (by omega) (actual_firstFailed_gap hT hξ hξmono hfirst hj) /-- The first internal row has no previous internal row. Its top gap instead follows from the explicit square exclusion and a large second prime. -/ /- Original line 44834: Erdos416Proof.FordBadFacet.ordinary_top_gap_of_square_exclusion -/ theorem ordinary_top_gap_of_square_exclusion {N : ℕ} {H : ℝ} (hN : 0 < N) (hH : 1 ≤ H) (hSq : NoLargePrimeSquare N H) (hlarge : H < (ordinaryPrimeAt N 1 : ℝ)) : ordinaryPrimeAt N 1 < ordinaryPrimeAt N 0 := by have hlarge' : ∀ idx : Fin 2, H < (ordinaryPrimeAt N idx.val : ℝ) := by intro idx have hi : idx.val ≤ 1 := by have := idx.isLt; omega exact hlarge.trans_le (Nat.cast_le.mpr (ordinaryPrimeAt_antitone N hi)) have hlength := ordinaryPrimeAt_prefix_length hH hlarge' have hinj := ordinaryPrimePrefix_injective hN.ne' hlength hSq (by intro idx rw [← ordinaryPrimeAt_eq_prefix N 2 hlength idx] exact hlarge' idx) have hne : ordinaryPrimeAt N 0 ≠ ordinaryPrimeAt N 1 := by intro he change ordinaryPrimeAt N (0 : Fin 2).val = ordinaryPrimeAt N (1 : Fin 2).val at he rw [ordinaryPrimeAt_eq_prefix N 2 hlength (0 : Fin 2), ordinaryPrimeAt_eq_prefix N 2 hlength (1 : Fin 2)] at he have hf := hinj he exact (by decide : (0 : Fin 2) ≠ 1) hf exact lt_of_le_of_ne (ordinaryPrimeAt_antitone N (by omega : 0 ≤ 1)) hne.symm /- Original line 44855: Erdos416Proof.FordBadFacet.ordinaryPrimeCoordinate_suffix_scale -/ theorem ordinaryPrimeCoordinate_suffix_scale (N j idx : ℕ) {T U : ℝ} (hT : T ≠ 0) (hU : U ≠ 0) : ordinaryPrimeCoordinate U (ordinarySuffix N j) idx = (T/U)*ordinaryPrimeCoordinate T N (j+idx) := by unfold ordinaryPrimeCoordinate fordPrimeCoordinate rw [ordinaryPrimeAt_suffix] field_simp [hT, hU] /- Original line 44863: Erdos416Proof.FordBadFacet.shiftedFacet_suffix_scale -/ theorem shiftedFacet_suffix_scale (N j k : ℕ) {T U : ℝ} (hT : T ≠ 0) (hU : U ≠ 0) : shiftedFacet (ordinaryPrimeCoordinate U (ordinarySuffix N j)) 0 k = (T/U)*shiftedFacet (ordinaryPrimeCoordinate T N) j k := by unfold shiftedFacet rw [Finset.mul_sum] apply Finset.sum_congr rfl intro idx _ rw [ordinaryPrimeCoordinate_suffix_scale N j _ hT hU] simp only [Nat.zero_add, Nat.add_assoc] ring /-- A nonsmooth leading prime retains the normalized scale, with the exact logarithmic loss used in the suffix argument. -/ /- Original line 44876: Erdos416Proof.FordBadFacet.fordPrimeCoordinate_lower_of_large_prime -/ theorem fordPrimeCoordinate_lower_of_large_prime {y : ℝ} {p : ℕ} (hy : 1 < y) (hU : 0 < logLog y) (hp : y ^ (1 / logLog y) ≤ (p : ℝ)) : 1 - Real.log (logLog y) / logLog y ≤ fordPrimeCoordinate (logLog y) p := by have hthreshold : 1 < y ^ (1 / logLog y) := Real.one_lt_rpow hy (one_div_pos.mpr hU) have hlog := logLog_mono hthreshold hp have heq : logLog (y ^ (1 / logLog y)) = logLog y - Real.log (logLog y) := by rw [logLog, Real.log_rpow (by linarith : 0 < y), Real.log_mul (one_div_ne_zero hU.ne') (Real.log_pos hy).ne'] simp only [one_div, Real.log_inv] change -Real.log (logLog y) + logLog y = logLog y - Real.log (logLog y) ring rw [heq] at hlog apply (le_div_iff₀ hU).mpr have hmax : logLog (p : ℝ) ≤ positiveLogLog p := le_max_right _ _ have hdiv : (Real.log (logLog y) / logLog y) * logLog y = Real.log (logLog y) := div_mul_cancel₀ _ hU.ne' change (1 - Real.log (logLog y) / logLog y) * logLog y ≤ positiveLogLog p nlinarith /-- After changing the endpoint, a failed suffix row is an actual failed ordinary-prime facet, provided its leading prime retains enough scale. -/ /- Original line 44898: Erdos416Proof.FordBadFacet.firstFailedRow_suffix_facet -/ theorem firstFailedRow_suffix_facet {N L j : ℕ} {T U δ ω σ : ℝ} {ξ : ℕ → ℝ} (hfirst : FirstFailedRow L ξ (ordinaryPrimeCoordinate T N) j) (hj : 0 < j) (hT : 0 < T) (hU : 0 < U) (hξ : ξ j = 1+ω) (hω : 0 ≤ ω) (hlarge : 1-δ ≤ ordinaryPrimeCoordinate U (ordinarySuffix N j) 0) (hbudget : (1+ω)*δ ≤ ω-σ) : 1+σ ≤ shiftedFacet (ordinaryPrimeCoordinate U (ordinarySuffix N j)) 0 (L-j) := by have hfail : (1+ω)*ordinaryPrimeCoordinate T N j < shiftedFacet (ordinaryPrimeCoordinate T N) j (L-j) := by have hf := hfirst.2.1 simpa only [RowHolds, if_neg (by omega : j ≠ 0), hξ, not_le] using hf have hscaled := mul_lt_mul_of_pos_left hfail (div_pos hT hU) rw [← shiftedFacet_suffix_scale N j (L-j) hT.ne' hU.ne'] at hscaled have hcoordinate := ordinaryPrimeCoordinate_suffix_scale N j 0 hT.ne' hU.ne' simp only [Nat.add_zero] at hcoordinate have hlow := mul_le_mul_of_nonneg_left hlarge (by linarith : 0 ≤ 1+ω) nlinarith /- Original line 44915: Erdos416Proof.FordBadFacet.firstFailedRow_nonsmooth_suffix_facet -/ theorem firstFailedRow_nonsmooth_suffix_facet {N L j : ℕ} {T y ω σ : ℝ} {ξ : ℕ → ℝ} (hfirst : FirstFailedRow L ξ (ordinaryPrimeCoordinate T N) j) (hj : 0 < j) (hT : 0 < T) (hy : 1 < y) (hU : 0 < logLog y) (hξ : ξ j = 1 + ω) (hω : 0 ≤ ω) (hlarge : y ^ (1 / logLog y) ≤ (ordinaryPrimeAt N j : ℝ)) (hbudget : (1 + ω) * (Real.log (logLog y) / logLog y) ≤ ω - σ) : 1 + σ ≤ shiftedFacet (ordinaryPrimeCoordinate (logLog y) (ordinarySuffix N j)) 0 (L-j) := by apply firstFailedRow_suffix_facet hfirst hj hT hU hξ hω _ hbudget have hlarge' : y ^ (1 / logLog y) ≤ (ordinaryPrimeAt (ordinarySuffix N j) 0 : ℝ) := by simpa only [ordinaryPrimeAt_suffix, Nat.add_zero] using hlarge exact fordPrimeCoordinate_lower_of_large_prime hy hU hlarge' /-- A finite classification of actual totient values, with no chosen preimage shared between the different row classes. -/ /- Original line 44929: Erdos416Proof.FordBadFacet.firstFailedFacetValues -/ noncomputable def firstFailedFacetValues (x : ℝ) (L : ℕ) (ξ : ℕ → ℝ) (j : ℕ) : Finset ℕ := (totientsUpTo x).filter (fun m => ∃ N : ℕ, 0 < N ∧ N.totient = m ∧ FirstFailedRow L ξ (ordinaryPrimeCoordinate (logLog x) N) j) /- Original line 44933: Erdos416Proof.FordBadFacet.failedRowsValues -/ noncomputable def failedRowsValues (x : ℝ) (L : ℕ) (ξ : ℕ → ℝ) : Finset ℕ := (totientsUpTo x).filter (fun m => ∃ N : ℕ, 0 < N ∧ N.totient = m ∧ ∃ j, j+1 < L ∧ ¬RowHolds L ξ (ordinaryPrimeCoordinate (logLog x) N) j) /- Original line 44937: Erdos416Proof.FordBadFacet.polytopeFailureValues -/ noncomputable def polytopeFailureValues (x : ℝ) (L : ℕ) (ξ : ℕ → ℝ) : Finset ℕ := (totientsUpTo x).filter (fun m => ∃ N : ℕ, 0 < N ∧ N.totient = m ∧ (fun idx : Fin L => ordinaryPrimeCoordinate (logLog x) N (idx.val+1)) ∉ polytope L ξ) /- Original line 44941: Erdos416Proof.FordBadFacet.polytopeFailureValues_eq_failedRows -/ theorem polytopeFailureValues_eq_failedRows {x : ℝ} {L : ℕ} {ξ : ℕ → ℝ} (hL : 2 ≤ L) (hx : Real.exp 1 ≤ x) (hT : 0 < logLog x) (hξ : ∀ idx, 1 ≤ ξ idx) : polytopeFailureValues x L ξ = failedRowsValues x L ξ := by ext m simp only [polytopeFailureValues, failedRowsValues, mem_filter] constructor · rintro ⟨hmV, N, hN, hNm, hbad⟩ have hphi : (N.totient : ℝ) ≤ x := by rw [hNm] exact ((mem_totientsUpTo ((Real.exp_pos 1).le.trans hx)).mp hmV).2.1 refine ⟨hmV, N, hN, hNm, ?_⟩ exact (not_mem_polytope_iff_failed_row hL ξ _ (fun idx => ordinary_coordinate_nonneg N idx hT.le) (fun idx hi => ordinaryPrimeCoordinate_le_one hN hx hT hphi hi) (ordinaryPrimeCoordinate_antitone N hT.le) hξ).mp hbad · rintro ⟨hmV, N, hN, hNm, hbad⟩ have hphi : (N.totient : ℝ) ≤ x := by rw [hNm] exact ((mem_totientsUpTo ((Real.exp_pos 1).le.trans hx)).mp hmV).2.1 refine ⟨hmV, N, hN, hNm, ?_⟩ exact (not_mem_polytope_iff_failed_row hL ξ _ (fun idx => ordinary_coordinate_nonneg N idx hT.le) (fun idx hi => ordinaryPrimeCoordinate_le_one hN hx hT hphi hi) (ordinaryPrimeCoordinate_antitone N hT.le) hξ).mpr hbad /- Original line 44966: Erdos416Proof.FordBadFacet.failedRowsValues_eq_union -/ theorem failedRowsValues_eq_union (x : ℝ) (L : ℕ) (ξ : ℕ → ℝ) : failedRowsValues x L ξ = (range (L-1)).biUnion (firstFailedFacetValues x L ξ) := by ext m constructor · intro hm obtain ⟨hmV, N, hN, hNm, hbad⟩ := mem_filter.mp hm obtain ⟨j, hj⟩ := exists_firstFailedRow ξ (ordinaryPrimeCoordinate (logLog x) N) hbad exact mem_biUnion.mpr ⟨j, mem_range.mpr (by have := hj.1; omega), mem_filter.mpr ⟨hmV, N, hN, hNm, hj⟩⟩ · intro hm obtain ⟨j, _, hmj⟩ := mem_biUnion.mp hm obtain ⟨hmV, N, hN, hNm, hj⟩ := mem_filter.mp hmj exact mem_filter.mpr ⟨hmV, N, hN, hNm, j, hj.1, hj.2.1⟩ /- Original line 44980: Erdos416Proof.FordBadFacet.failedRowsValues_card_le -/ theorem failedRowsValues_card_le (x : ℝ) (L : ℕ) (ξ : ℕ → ℝ) : (failedRowsValues x L ξ).card ≤ ∑ j ∈ range (L-1), (firstFailedFacetValues x L ξ j).card := by rw [failedRowsValues_eq_union] exact card_biUnion_le /- Original line 44985: Erdos416Proof.FordBadFacet.polytopeFailureValues_card_le_firstFailed -/ theorem polytopeFailureValues_card_le_firstFailed {x : ℝ} {L : ℕ} {ξ : ℕ → ℝ} (hL : 2 ≤ L) (hx : Real.exp 1 ≤ x) (hT : 0 < logLog x) (hξ : ∀ idx, 1 ≤ ξ idx) : (polytopeFailureValues x L ξ).card ≤ ∑ j ∈ range (L-1), (firstFailedFacetValues x L ξ j).card := by rw [polytopeFailureValues_eq_failedRows hL hx hT hξ] exact failedRowsValues_card_le x L ξ end Erdos416Proof.FordBadFacet end /- Consolidated component: FirstFailedArithmetic.lean. -/ section open Filter Finset open scoped Classical Topology BigOperators Nat namespace Erdos416Proof.FordBadFacet open FordGeometry FordAnalysis /-- The lower-prime prefix is taken from the actual suffix after q₀. -/ /- Original line 45011: Erdos416Proof.FordBadFacet.ordinaryLowerPrefix -/ noncomputable abbrev ordinaryLowerPrefix (N j : ℕ) : ℕ := ordinaryPrefix (ordinarySuffix N 1) (j-1) /- Original line 45014: Erdos416Proof.FordBadFacet.ordinaryPrefix_succ -/ theorem ordinaryPrefix_succ (N j : ℕ) : ordinaryPrefix N (j+1) = ordinaryPrefix N j * ordinaryPrimeAt N j := by by_cases hj : j < (ordinaryPrimeList N).length · change ((ordinaryPrimeList N).take (j+1)).prod = ((ordinaryPrimeList N).take j).prod * (ordinaryPrimeList N).getD j 1 rw [List.getD_eq_getElem _ 1 hj] exact List.prod_take_succ _ _ hj · rw [ordinaryPrimeAt_eq_one (by omega), mul_one] change ((ordinaryPrimeList N).take (j+1)).prod = ((ordinaryPrimeList N).take j).prod rw [List.take_of_length_le (by omega), List.take_of_length_le (by omega)] /- Original line 45025: Erdos416Proof.FordBadFacet.ordinaryPrefix_eq_fin_prod -/ theorem ordinaryPrefix_eq_fin_prod (N j : ℕ) : ordinaryPrefix N j = ∏ idx : Fin j, ordinaryPrimeAt N idx.val := by induction j with | zero => simp [ordinaryPrefix] | succ j ih => rw [ordinaryPrefix_succ, Fin.prod_univ_castSucc] simpa only [Fin.val_castSucc, Fin.val_last] using congrArg (· * ordinaryPrimeAt N j) ih /- Original line 45033: Erdos416Proof.FordBadFacet.ordinaryLowerPrefix_eq_fin_prod -/ theorem ordinaryLowerPrefix_eq_fin_prod (N j : ℕ) : ordinaryLowerPrefix N j = ∏ idx : Fin (j-1), ordinaryPrimeAt N (idx.val+1) := by change ordinaryPrefix (ordinarySuffix N 1) (j-1) = _ rw [ordinaryPrefix_eq_fin_prod] apply Finset.prod_congr rfl intro idx _ rw [ordinaryPrimeAt_suffix] congr 1 omega /- Original line 45043: Erdos416Proof.FordBadFacet.ordinaryPrefix_top_lowerPrefix -/ theorem ordinaryPrefix_top_lowerPrefix (N : ℕ) {j : ℕ} (hj : 0 < j) : ordinaryPrefix N j = ordinaryPrimeAt N 0 * ordinaryLowerPrefix N j := by obtain ⟨r, rfl⟩ := Nat.exists_eq_succ_of_ne_zero (by omega : j ≠ 0) rw [ordinaryPrefix_eq_fin_prod, Fin.prod_univ_succ, ordinaryLowerPrefix_eq_fin_prod] rfl /- Original line 45049: Erdos416Proof.FordBadFacet.ordinaryPrefix_dvd -/ theorem ordinaryPrefix_dvd {N : ℕ} (hN : 0 < N) (j : ℕ) : ordinaryPrefix N j ∣ N := ⟨ordinarySuffix N j, (ordinary_split hN j).symm⟩ /- Original line 45052: Erdos416Proof.FordBadFacet.ordinarySuffix_dvd -/ theorem ordinarySuffix_dvd {N : ℕ} (hN : 0 < N) (j : ℕ) : ordinarySuffix N j ∣ N := ⟨ordinaryPrefix N j, by simpa only [mul_comm] using (ordinary_split hN j).symm⟩ /- Original line 45055: Erdos416Proof.FordBadFacet.ordinarySuffix_totient_le -/ theorem ordinarySuffix_totient_le {N : ℕ} (hN : 0 < N) (j : ℕ) : (ordinarySuffix N j).totient ≤ N.totient := Nat.le_of_dvd (Nat.totient_pos.mpr hN) (Nat.totient_dvd_of_dvd (ordinarySuffix_dvd hN j)) /- Original line 45059: Erdos416Proof.FordBadFacet.prime_divisor_le_ordinary_top -/ theorem prime_divisor_le_ordinary_top {N p : ℕ} (hN : 0 < N) (hp : p.Prime) (hd : p ∣ N) : p ≤ ordinaryPrimeAt N 0 := by have hm : p ∈ ordinaryPrimeList N := List.mem_reverse.mpr ((Nat.mem_primeFactorsList hN.ne').mpr ⟨hp, hd⟩) obtain ⟨idx, hi⟩ := List.mem_iff_get.mp hm have he : ordinaryPrimeAt N idx.val = p := (List.getD_eq_get _ 1 idx).trans hi rw [← he] exact ordinaryPrimeAt_antitone N (Nat.zero_le _) /- Original line 45068: Erdos416Proof.FordBadFacet.ordinary_factored_of_top_le -/ theorem ordinary_factored_of_top_le {N : ℕ} {z : ℝ} (hN : 0 < N) (hz : (ordinaryPrimeAt N 0 : ℝ) ≤ z) : N ∈ Nat.factoredNumbers (Nat.primesLE ⌊z⌋₊) := by apply Nat.mem_factoredNumbers_iff_primeFactors_subset.mpr refine ⟨hN.ne', ?_⟩ intro p hp have hdata := Nat.mem_primeFactors.mp hp apply Nat.mem_primesLE.mpr refine ⟨Nat.le_floor ?_, hdata.1⟩ exact (Nat.cast_le.mpr (prime_divisor_le_ordinary_top hN hdata.1 hdata.2.1)).trans hz /-- The smooth branch is represented by the actual smooth suffix integer, so the existing weighted inverse-totient Rankin estimate applies to it. -/ /- Original line 45081: Erdos416Proof.FordBadFacet.ordinarySuffix_factored_of_boundary_le -/ theorem ordinarySuffix_factored_of_boundary_le {N j : ℕ} {z : ℝ} (hz : (ordinaryPrimeAt N j : ℝ) ≤ z) : ordinarySuffix N j ∈ Nat.factoredNumbers (Nat.primesLE ⌊z⌋₊) := by apply ordinary_factored_of_top_le (ordinarySuffix_pos N j) simpa only [ordinaryPrimeAt_suffix, Nat.add_zero] using hz /- Original line 45087: Erdos416Proof.FordBadFacet.ordinary_top_lowerPrefix_coprime -/ theorem ordinary_top_lowerPrefix_coprime {N : ℕ} (j : ℕ) (hgap : ordinaryPrimeAt N 1 < ordinaryPrimeAt N 0) : (ordinaryPrimeAt N 0).Coprime (ordinaryLowerPrefix N j) := by have hc := ordinary_split_coprime (N := N) (j := 1) (by decide) (by simpa only [Nat.sub_self] using hgap) have hp : ordinaryPrefix N 1 = ordinaryPrimeAt N 0 := by rw [ordinaryPrefix_eq_fin_prod] simp rw [hp] at hc exact hc.of_dvd_right (ordinaryPrefix_dvd (ordinarySuffix_pos N 1) (j-1)) /-- Every actual lower-prime prefix has its existing finite tuple witness. -/ /- Original line 45098: Erdos416Proof.FordBadFacet.actual_firstFailed_lowerPrefix_tuple -/ theorem actual_firstFailed_lowerPrefix_tuple {N L j : ℕ} {x : ℝ} {ξ : ℕ → ℝ} (hN : 0 < N) (hx : Real.exp 1 ≤ x) (hT : 0 < logLog x) (hphi : (N.totient : ℝ) ≤ x) (hξ : ∀ idx, 1 ≤ ξ idx) (hfirst : FirstFailedRow L ξ (ordinaryPrimeCoordinate (logLog x) N) j) (hj : 0 < j) : ordinaryLowerPrefix N j ∈ FordReciprocal.tupleIntegers (j-1) (logLog x) (polytope (j-1) ξ) := by rw [ordinaryLowerPrefix_eq_fin_prod] exact actual_firstFailed_prefix_tuple hN hx hT hphi hξ hfirst hj /- Original line 45107: Erdos416Proof.FordBadFacet.ordinary_top_gap_of_top_large_square_exclusion -/ theorem ordinary_top_gap_of_top_large_square_exclusion {N : ℕ} {H : ℝ} (hN : 0 < N) (hH : 1 ≤ H) (hSq : NoLargePrimeSquare N H) (hlarge : H < (ordinaryPrimeAt N 0 : ℝ)) : ordinaryPrimeAt N 1 < ordinaryPrimeAt N 0 := by by_cases hsmall : (ordinaryPrimeAt N 1 : ℝ) ≤ H · exact_mod_cast hsmall.trans_lt hlarge · exact ordinary_top_gap_of_square_exclusion hN hH hSq (lt_of_not_ge hsmall) /-- Square exclusion above H provides the top gap, including the exceptional first internal row, while later boundary gaps follow from the failed-row classification itself. All three factors come from the same actual N. -/ /- Original line 45117: Erdos416Proof.FordBadFacet.actual_firstFailed_totient_three_factors_of_top_large -/ theorem actual_firstFailed_totient_three_factors_of_top_large {N L j : ℕ} {T H : ℝ} {ξ : ℕ → ℝ} (hN : 0 < N) (hT : 0 < T) (hξ : ∀ idx, 0 < ξ idx) (hξmono : Monotone ξ) (hfirst : FirstFailedRow L ξ (ordinaryPrimeCoordinate T N) j) (hj : 0 < j) (hH : 1 ≤ H) (hSq : NoLargePrimeSquare N H) (hlarge : H < (ordinaryPrimeAt N 0 : ℝ)) : (ordinaryPrimeAt N 0).Prime ∧ N.totient = (ordinaryPrimeAt N 0 - 1) * (ordinaryLowerPrefix N j).totient * (ordinarySuffix N j).totient := by have htop := ordinary_top_gap_of_top_large_square_exclusion hN hH hSq hlarge have hp : (ordinaryPrimeAt N 0).Prime := by rcases ordinaryPrimeAt_spec N 0 with he | ⟨hp, _⟩ · have hq1 := ordinaryPrimeAt_one_le N 1 omega · exact hp have hgap : ordinaryPrimeAt N j < ordinaryPrimeAt N (j-1) := by by_cases hj1 : j = 1 · simpa only [hj1, Nat.sub_self] using htop · exact actual_firstFailed_gap hT hξ hξmono hfirst (by omega) refine ⟨hp, ?_⟩ rw [ordinary_split_totient hN hj hgap, ordinaryPrefix_top_lowerPrefix N hj, Nat.totient_mul (ordinary_top_lowerPrefix_coprime j htop), Nat.totient_prime hp] /- Original line 45139: Erdos416Proof.FordBadFacet.actual_firstFailed_totient_three_factors -/ theorem actual_firstFailed_totient_three_factors {N L j : ℕ} {T H : ℝ} {ξ : ℕ → ℝ} (hN : 0 < N) (hT : 0 < T) (hξ : ∀ idx, 0 < ξ idx) (hξmono : Monotone ξ) (hfirst : FirstFailedRow L ξ (ordinaryPrimeCoordinate T N) j) (hj : 0 < j) (hH : 1 ≤ H) (hSq : NoLargePrimeSquare N H) (hlarge : H < (ordinaryPrimeAt N j : ℝ)) : (ordinaryPrimeAt N 0).Prime ∧ N.totient = (ordinaryPrimeAt N 0 - 1) * (ordinaryLowerPrefix N j).totient * (ordinarySuffix N j).totient := actual_firstFailed_totient_three_factors_of_top_large hN hT hξ hξmono hfirst hj hH hSq (hlarge.trans_le (Nat.cast_le.mpr (ordinaryPrimeAt_antitone N (Nat.zero_le _)))) /-- Concrete representation for the prime-counting and reciprocal-mass arguments. The tuple and suffix value are the actual factors of N. -/ /- Original line 45152: Erdos416Proof.FordBadFacet.actual_firstFailed_arithmetic_witness_of_top_large -/ theorem actual_firstFailed_arithmetic_witness_of_top_large {N L j : ℕ} {x H : ℝ} {ξ : ℕ → ℝ} (hN : 0 < N) (hx : Real.exp 1 ≤ x) (hT : 0 < logLog x) (hphi : (N.totient : ℝ) ≤ x) (hξ : ∀ idx, 1 ≤ ξ idx) (hξmono : Monotone ξ) (hfirst : FirstFailedRow L ξ (ordinaryPrimeCoordinate (logLog x) N) j) (hj : 0 < j) (hH : 1 ≤ H) (hSq : NoLargePrimeSquare N H) (hlarge : H < (ordinaryPrimeAt N 0 : ℝ)) : (ordinaryPrimeAt N 0).Prime ∧ ordinaryLowerPrefix N j ∈ FordReciprocal.tupleIntegers (j-1) (logLog x) (polytope (j-1) ξ) ∧ 0 < (ordinarySuffix N j).totient ∧ ((ordinarySuffix N j).totient : ℝ) ≤ x ∧ N.totient = (ordinaryPrimeAt N 0 - 1) * (ordinaryLowerPrefix N j).totient * (ordinarySuffix N j).totient := by obtain ⟨hp, hprod⟩ := actual_firstFailed_totient_three_factors_of_top_large hN hT (fun idx => lt_of_lt_of_le (by norm_num : (0 : ℝ) < 1) (hξ idx)) hξmono hfirst hj hH hSq hlarge refine ⟨hp, actual_firstFailed_lowerPrefix_tuple hN hx hT hphi hξ hfirst hj, Nat.totient_pos.mpr (ordinarySuffix_pos N j), ?_, hprod⟩ exact (Nat.cast_le.mpr (ordinarySuffix_totient_le hN j)).trans hphi /- Original line 45169: Erdos416Proof.FordBadFacet.actual_firstFailed_arithmetic_witness -/ theorem actual_firstFailed_arithmetic_witness {N L j : ℕ} {x H : ℝ} {ξ : ℕ → ℝ} (hN : 0 < N) (hx : Real.exp 1 ≤ x) (hT : 0 < logLog x) (hphi : (N.totient : ℝ) ≤ x) (hξ : ∀ idx, 1 ≤ ξ idx) (hξmono : Monotone ξ) (hfirst : FirstFailedRow L ξ (ordinaryPrimeCoordinate (logLog x) N) j) (hj : 0 < j) (hH : 1 ≤ H) (hSq : NoLargePrimeSquare N H) (hlarge : H < (ordinaryPrimeAt N j : ℝ)) : (ordinaryPrimeAt N 0).Prime ∧ ordinaryLowerPrefix N j ∈ FordReciprocal.tupleIntegers (j-1) (logLog x) (polytope (j-1) ξ) ∧ 0 < (ordinarySuffix N j).totient ∧ ((ordinarySuffix N j).totient : ℝ) ≤ x ∧ N.totient = (ordinaryPrimeAt N 0 - 1) * (ordinaryLowerPrefix N j).totient * (ordinarySuffix N j).totient := actual_firstFailed_arithmetic_witness_of_top_large hN hx hT hphi hξ hξmono hfirst hj hH hSq (hlarge.trans_le (Nat.cast_le.mpr (ordinaryPrimeAt_antitone N (Nat.zero_le _)))) /-- The outer first-failed class is already an actual bad-facet family. -/ /- Original line 45184: Erdos416Proof.FordBadFacet.firstFailedFacetValues_zero_subset_badFacet -/ theorem firstFailedFacetValues_zero_subset_badFacet {x ω : ℝ} {L : ℕ} {ξ : ℕ → ℝ} (hξ : 1 + ω ≤ ξ 0) : firstFailedFacetValues x L ξ 0 ⊆ badFacetValues x L ω := by intro m hm obtain ⟨hmV, N, hN, hNm, hfirst⟩ := Finset.mem_filter.mp hm have hfail : ξ 0 < shiftedFacet (ordinaryPrimeCoordinate (logLog x) N) 0 L := by simpa [Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordBadFacet.positiveLogLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_bottom, Erdos416Proof.FordBadFacet.reversedFacetLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_succ, Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.FordRestricted.suffixCutoff_log3, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, RowHolds] using hfirst.2.1 refine Finset.mem_filter.mpr ⟨hmV, N, hN, hNm, ?_⟩ simpa only [shiftedFacet, Nat.zero_add] using hξ.trans hfail.le /-- Nonsmooth actual suffixes belong to the previously counted family at their own endpoint; the existence of their preimage is supplied explicitly. -/ /- Original line 45195: Erdos416Proof.FordBadFacet.actual_firstFailed_nonsmooth_suffix_mem_badFacet -/ theorem actual_firstFailed_nonsmooth_suffix_mem_badFacet {N L j : ℕ} {T y ω σ : ℝ} {ξ : ℕ → ℝ} (hfirst : FirstFailedRow L ξ (ordinaryPrimeCoordinate T N) j) (hj : 0 < j) (hT : 0 < T) (hy : 1 < y) (hU : 0 < logLog y) (hξ : ξ j = 1 + ω) (hω : 0 ≤ ω) (hvalue : ((ordinarySuffix N j).totient : ℝ) ≤ y) (hlarge : y ^ (1 / logLog y) ≤ (ordinaryPrimeAt N j : ℝ)) (hbudget : (1 + ω) * (Real.log (logLog y) / logLog y) ≤ ω - σ) : (ordinarySuffix N j).totient ∈ badFacetValues y (L-j) σ := by have hS := ordinarySuffix_pos N j have hmV : (ordinarySuffix N j).totient ∈ totientsUpTo y := (mem_totientsUpTo (by linarith : 0 ≤ y)).mpr ⟨Nat.totient_pos.mpr hS, hvalue, ordinarySuffix N j, hS, rfl⟩ refine Finset.mem_filter.mpr ⟨hmV, ordinarySuffix N j, hS, rfl, ?_⟩ simpa only [shiftedFacet, Nat.zero_add] using firstFailedRow_nonsmooth_suffix_facet hfirst hj hT hy hU hξ hω hlarge hbudget /-- The original Theorem 16 parameter is A, rather than the truncated dimension L. Padding by A-L+40 places the actual normalized suffix in the uniformly counted family, including the factor-two margin loss. -/ /- Original line 45214: Erdos416Proof.FordBadFacet.actual_expanded_firstFailed_suffix_mem_uniform_family -/ theorem actual_expanded_firstFailed_suffix_mem_uniform_family {N A L j : ℕ} {T y : ℝ} (hLA : L ≤ A) (hfirst : FirstFailedRow L (expandedParameter A) (ordinaryPrimeCoordinate T N) j) (hj : 0 < j) (hT : 0 < T) (hy : 1 < y) (hU : 0 < logLog y) (hvalue : ((ordinarySuffix N j).totient : ℝ) ≤ y) (hlarge : y ^ (1 / logLog y) ≤ (ordinaryPrimeAt N j : ℝ)) (hbudget : (1 + FordRestricted.suffixMargin (A-j)) * (Real.log (logLog y) / logLog y) ≤ FordRestricted.suffixMargin (A-j) / 2) : (ordinarySuffix N j).totient ∈ badFacetValues y (A-j+40) (FordRestricted.suffixMargin (A-j+40)) := by have hjA : j ≤ A := by have := hfirst.1; omega have hmem := actual_firstFailed_nonsmooth_suffix_mem_badFacet hfirst hj hT hy hU (expandedParameter_row_margin hjA) (FordRestricted.suffixMargin_pos (A-j)).le hvalue hlarge (σ := FordRestricted.suffixMargin (A-j)/2) (by linarith) have hmargin := suffixMargin_add_forty_le_half (A-j) exact badFacetValues_mono_length hU.le (show L-j ≤ A-j+40 by omega) (badFacetValues_mono_margin hmargin hmem) end Erdos416Proof.FordBadFacet end /- Consolidated component: SmoothSuffixValues.lean. -/ section open Filter Finset open scoped Classical Topology BigOperators Nat namespace Erdos416Proof.FordBadFacet /-- Select one actual smooth preimage for each distinct totient value. The totient identity makes this selection injective, so a sum over all smooth integers bounds the distinct-value sum without any multiplicity premise. -/ /- Original line 45251: Erdos416Proof.FordBadFacet.exists_smooth_preimage_value_bounds -/ theorem exists_smooth_preimage_value_bounds : ∃ K : ℝ, 0 < K ∧ ∀ z : ℝ, Real.exp 20 ≤ z → ∀ a y : ℝ, 0 < a → 0 ≤ y → ∀ F : Finset ℕ, (∀ m ∈ F, ∃ N : ℕ, 0 < N ∧ N.totient = m ∧ N ∈ Nat.factoredNumbers (Nat.primesLE ⌊z⌋₊)) → (∀ m ∈ F, a ≤ (m : ℝ)) → (∀ m ∈ F, (m : ℝ) ≤ y) → a^(5/Real.log z)*(∑ m ∈ F, (1 : ℝ)/m) ≤ K*Real.log z ∧ a^(5/Real.log z)*(F.card : ℝ) ≤ K*y*Real.log z := by obtain ⟨K, hK, hbound⟩ := FordRestricted.exists_smooth_weighted_reciprocal_bound refine ⟨K, hK, ?_⟩ intro z hz a y ha hy F hpre hlow hupp choose P hPpos hPtot hPsmooth using (fun m : F => hpre m.val m.property) have hPinj : Function.Injective P := by intro m n hmn apply Subtype.ext rw [← hPtot m, ← hPtot n, hmn] let G : Finset ℕ := univ.image P have hG : ∀ n ∈ G, n ∈ Nat.factoredNumbers (Nat.primesLE ⌊z⌋₊) := by intro n hn obtain ⟨m, _, rfl⟩ := mem_image.mp hn exact hPsmooth m have hsum := hbound z hz G hG have he : (∑ n ∈ G, (n : ℝ)^(5/Real.log z)*invTotient n) = ∑ m : F, (P m : ℝ)^(5/Real.log z)*invTotient (P m) := by exact sum_image (fun _ _ _ _ he => hPinj he) rw [he] at hsum have hlog : 20 ≤ Real.log z := by simpa only [Real.log_exp] using Real.log_le_log (Real.exp_pos 20) hz have hδ : 0 ≤ 5/Real.log z := div_nonneg (by norm_num) (by linarith) have hpoint (m : F) : a^(5/Real.log z)*((1 : ℝ)/(m.val : ℝ)) ≤ (P m : ℝ)^(5/Real.log z)*invTotient (P m) := by have hNm : (m.val : ℝ) ≤ P m := by rw [← hPtot m] exact Nat.cast_le.mpr (Nat.totient_le _) have hr := Real.rpow_le_rpow ha.le ((hlow m.val m.property).trans hNm) hδ have hi : invTotient (P m) = (1 : ℝ)/(m.val : ℝ) := by simp only [invTotient, hPtot m, one_div] rw [hi] exact mul_le_mul_of_nonneg_right hr (one_div_nonneg.mpr (Nat.cast_nonneg _)) have hrecip := (sum_le_sum (fun m _ => hpoint m)).trans hsum rw [← mul_sum, Finset.sum_coe_sort F (fun m : ℕ => (1 : ℝ)/m)] at hrecip refine ⟨hrecip, ?_⟩ have hcard : (F.card : ℝ) ≤ y*(∑ m ∈ F, (1 : ℝ)/m) := by calc _ = ∑ m ∈ F, (1 : ℝ) := by simp[Erdos416Proof.FordReciprocal.binMass_zero, Erdos416Proof.invTotient_one, Erdos416Proof.weightedInvTotient_one] _ ≤ ∑ m ∈ F, y*((1 : ℝ)/m) := by apply sum_le_sum intro m hm have hmpos : (0 : ℝ) < m := ha.trans_le (hlow m hm) have hmy : (1 : ℝ) ≤ y/(m : ℝ) := (le_div_iff₀ hmpos).mpr (by simpa [Erdos416Proof.FordReciprocal.binMass_zero, Erdos416Proof.invTotient_one, Erdos416Proof.weightedInvTotient_one] using hupp m hm) simpa only [mul_one_div] using hmy _ = _ := (mul_sum _ _ _).symm have haδ := Real.rpow_nonneg ha.le (5/Real.log z) have hc := mul_le_mul_of_nonneg_left hcard haδ have hr := mul_le_mul_of_nonneg_left hrecip hy nlinarith /-- Distinct totient values in the upper half of an endpoint that possess an actual z-smooth preimage. -/ /- Original line 45311: Erdos416Proof.FordBadFacet.smoothPreimageBand -/ noncomputable def smoothPreimageBand (y z : ℝ) : Finset ℕ := (totientsUpTo y).filter (fun m => y/2 < (m : ℝ) ∧ ∃ N : ℕ, 0 < N ∧ N.totient = m ∧ N ∈ Nat.factoredNumbers (Nat.primesLE ⌊z⌋₊)) /-- The small-leading-prime branch has a fourth logarithmic power saving. This is a distinct-value estimate derived from actual smooth preimages. -/ /- Original line 45317: Erdos416Proof.FordBadFacet.exists_smoothPreimageBand_count_bound -/ theorem exists_smoothPreimageBand_count_bound : ∃ C : ℝ, 0 < C ∧ ∀ y : ℝ, 1 < y → 1 ≤ logLog y → Real.exp 20 ≤ y^(1/logLog y) → ((smoothPreimageBand y (y^(1/logLog y))).card : ℝ) ≤ C*y/(Real.log y)^4 := by obtain ⟨K, hK, hbound⟩ := exists_smooth_preimage_value_bounds refine ⟨2*K, by positivity, ?_⟩ intro y hy hU hz have hy0 : 0 < y := by linarith have hlog : 0 < Real.log y := Real.log_pos hy have hUpos : 0 < logLog y := by linarith let z : ℝ := y^(1/logLog y) have hlogz : Real.log z = (1/logLog y)*Real.log y := Real.log_rpow hy0 _ have hlogz20 : 20 ≤ Real.log z := by simpa only [Real.log_exp] using Real.log_le_log (Real.exp_pos 20) hz have hlogzy : Real.log z ≤ Real.log y := by rw [hlogz] have hh : Real.log y / logLog y ≤ Real.log y := (div_le_iff₀ hUpos).mpr (by nlinarith) simpa only [one_div_mul_eq_div] using hh have hδone : 5/Real.log z ≤ 1 := (div_le_one (by linarith)).mpr (by linarith) have htwo : (2 : ℝ)^(5/Real.log z) ≤ 2 := by simpa only [Real.rpow_one] using Real.rpow_le_rpow_of_exponent_le (by norm_num : (1 : ℝ) ≤ 2) hδone have hyPow : y^(5/Real.log z) = (Real.log y)^5 := by rw [Real.rpow_def_of_pos hy0] have he : Real.log y*(5/Real.log z) = 5*Real.log (Real.log y) := by rw [hlogz] change Real.log y*(5/((1/logLog y)*Real.log y)) = 5*logLog y field_simp [hlog.ne', hUpos.ne'] rw [he] simpa only [Nat.cast_ofNat, Real.exp_log hlog] using Real.exp_nat_mul (Real.log (Real.log y)) 5 have hyMul : y^(5/Real.log z) = (2 : ℝ)^(5/Real.log z)*(y/2)^(5/Real.log z) := by rw [← Real.mul_rpow (by norm_num : (0 : ℝ) ≤ 2) (by positivity : 0 ≤ y/2)] congr 1 ring have hhalf : (Real.log y)^5 ≤ 2*(y/2)^(5/Real.log z) := by rw [← hyPow, hyMul] exact mul_le_mul_of_nonneg_right htwo (Real.rpow_nonneg (by positivity) _) have hF := hbound z hz (y/2) y (by positivity) hy0.le (smoothPreimageBand y z) (fun m hm => (mem_filter.mp hm).2.2) (fun m hm => (mem_filter.mp hm).2.1.le) (fun m hm => ((mem_totientsUpTo hy0.le).mp (mem_filter.mp hm).1).2.1) have hcard : (0 : ℝ) ≤ (smoothPreimageBand y z).card := Nat.cast_nonneg _ have hs := mul_le_mul_of_nonneg_right hhalf hcard have hzsave := mul_le_mul_of_nonneg_left hlogzy (mul_nonneg hK.le hy0.le) apply (le_div_iff₀ (pow_pos hlog 4)).mpr apply (mul_le_mul_iff_of_pos_right hlog).mp dsimp [Erdos416Proof.FordBadFacet.positiveLogLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_bottom, Erdos416Proof.FordBadFacet.reversedFacetLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_succ, Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.FordRestricted.suffixCutoff_log3, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, z] at hF hs hcard ⊢ nlinarith [hF.2] /- Original line 45367: Erdos416Proof.FordBadFacet.actual_smooth_suffix_mem_band -/ theorem actual_smooth_suffix_mem_band {N j : ℕ} {y z : ℝ} (hy : 0 ≤ y) (hlow : y/2 < ((ordinarySuffix N j).totient : ℝ)) (hupp : ((ordinarySuffix N j).totient : ℝ) ≤ y) (htop : (ordinaryPrimeAt N j : ℝ) ≤ z) : (ordinarySuffix N j).totient ∈ smoothPreimageBand y z := by have hN := ordinarySuffix_pos N j exact mem_filter.mpr ⟨(mem_totientsUpTo hy).mpr ⟨Nat.totient_pos.mpr hN, hupp, ordinarySuffix N j, hN, rfl⟩, hlow, ordinarySuffix N j, hN, rfl, ordinarySuffix_factored_of_boundary_le htop⟩ /-- Actual suffix totients from first-failed preimages in one dyadic band. The same original preimage supplies both the failed row and the suffix. -/ /- Original line 45379: Erdos416Proof.FordBadFacet.firstFailedSuffixBand -/ noncomputable def firstFailedSuffixBand (y T : ℝ) (A L j : ℕ) : Finset ℕ := (totientsUpTo y).filter (fun m => y/2 < (m : ℝ) ∧ ∃ N : ℕ, 0 < N ∧ (ordinarySuffix N j).totient = m ∧ FirstFailedRow L (FordGeometry.expandedParameter A) (ordinaryPrimeCoordinate T N) j) /- Original line 45384: Erdos416Proof.FordBadFacet.firstFailedSuffixBand_subset_smooth_union_bad -/ theorem firstFailedSuffixBand_subset_smooth_union_bad {y T : ℝ} {A L j : ℕ} (hy : 1 < y) (hU : 0 < logLog y) (hT : 0 < T) (hLA : L ≤ A) (hj : 0 < j) (hbudget : (1 + FordRestricted.suffixMargin (A-j)) * (Real.log (logLog y) / logLog y) ≤ FordRestricted.suffixMargin (A-j) / 2) : firstFailedSuffixBand y T A L j ⊆ smoothPreimageBand y (y^(1/logLog y)) ∪ badFacetValues y (A-j+40) (FordRestricted.suffixMargin (A-j+40)) := by intro m hm obtain ⟨hmV, hlow, N, _hN, hNm, hfirst⟩ := mem_filter.mp hm have hvalue : ((ordinarySuffix N j).totient : ℝ) ≤ y := by rw [hNm] exact ((mem_totientsUpTo (by linarith : 0 ≤ y)).mp hmV).2.1 by_cases hsmall : (ordinaryPrimeAt N j : ℝ) ≤ y^(1/logLog y) · apply mem_union.mpr left rw [← hNm] exact actual_smooth_suffix_mem_band (by linarith) (by simpa only [hNm] using hlow) hvalue hsmall · apply mem_union.mpr right rw [← hNm] exact actual_expanded_firstFailed_suffix_mem_uniform_family hLA hfirst hj hT hy hU hvalue (le_of_lt (lt_of_not_ge hsmall)) hbudget /- Original line 45408: Erdos416Proof.FordBadFacet.firstFailedSuffixBand_card_le_smooth_add_bad -/ theorem firstFailedSuffixBand_card_le_smooth_add_bad {y T : ℝ} {A L j : ℕ} (hy : 1 < y) (hU : 0 < logLog y) (hT : 0 < T) (hLA : L ≤ A) (hj : 0 < j) (hbudget : (1 + FordRestricted.suffixMargin (A-j)) * (Real.log (logLog y) / logLog y) ≤ FordRestricted.suffixMargin (A-j) / 2) : (firstFailedSuffixBand y T A L j).card ≤ (smoothPreimageBand y (y^(1/logLog y))).card + (badFacetValues y (A-j+40) (FordRestricted.suffixMargin (A-j+40))).card := (card_le_card (firstFailedSuffixBand_subset_smooth_union_bad hy hU hT hLA hj hbudget)).trans (card_union_le _ _) /- Original line 45418: Erdos416Proof.FordBadFacet.exists_firstFailedSuffixBand_count_bound -/ theorem exists_firstFailedSuffixBand_count_bound : ∃ C : ℝ, 0 < C ∧ ∀ (y T : ℝ) (A L j : ℕ), 1 < y → 1 ≤ logLog y → Real.exp 20 ≤ y^(1/logLog y) → 0 < T → L ≤ A → 0 < j → (1 + FordRestricted.suffixMargin (A-j)) * (Real.log (logLog y) / logLog y) ≤ FordRestricted.suffixMargin (A-j) / 2 → ((firstFailedSuffixBand y T A L j).card : ℝ) ≤ C*y/(Real.log y)^4 + (badFacetValues y (A-j+40) (FordRestricted.suffixMargin (A-j+40))).card := by obtain ⟨C, hC, hbound⟩ := exists_smoothPreimageBand_count_bound refine ⟨C, hC, ?_⟩ intro y T A L j hy hU hz hT hLA hj hbudget have hc := (Nat.cast_le (α := ℝ)).mpr (firstFailedSuffixBand_card_le_smooth_add_bad hy (by linarith) hT hLA hj hbudget) rw [Nat.cast_add] at hc exact hc.trans (add_le_add (hbound y hy hU hz) le_rfl) end Erdos416Proof.FordBadFacet end /- Consolidated component: ExpandedPrefix.lean. -/ section open Filter Finset MeasureTheory open scoped Classical Topology BigOperators Pointwise namespace Erdos416Proof.FordGeometry open FordAnalysis FordScale /- Original line 45452: Erdos416Proof.FordGeometry.H_mono_parameter -/ theorem H_mono_parameter (L : ℕ) {ξ ζ : ℕ → ℝ} (hξ : ∀ j, 0 ≤ ξ j) (hle : ∀ j, ξ j ≤ ζ j) : H L ξ ≤ H L ζ := by unfold H apply Finset.prod_le_prod · intro j _ exact pow_nonneg (hξ j) _ · intro j _ exact pow_le_pow_left₀ (hξ j) (hle j) _ /- Original line 45461: Erdos416Proof.FordGeometry.expandedParameter_antitone_dimension -/ theorem expandedParameter_antitone_dimension {A B : ℕ} (hAB : A ≤ B) (j : ℕ) : expandedParameter B j ≤ expandedParameter A j := by unfold expandedParameter apply add_le_add le_rfl apply mul_le_mul_of_nonneg_left _ (by norm_num : (0 : ℝ) ≤ 1/10000) apply Real.exp_le_exp.mpr have hABreal : (A : ℝ) ≤ B := by exact_mod_cast hAB linarith /- Original line 45470: Erdos416Proof.FordGeometry.expanded_prefix_H_eventually -/ theorem expanded_prefix_H_eventually : ∀ᶠ M : ℕ in atTop, ∀ A K : ℕ, K+M ≤ A → H K (expandedParameter A) ≤ 2 := by filter_upwards [expanded_H_eventually] with M hM intro A K hKA exact (H_mono_parameter K (fun j => le_trans zero_le_one (expandedParameter_ge_one A j)) (expandedParameter_antitone_dimension hKA)).trans (hM K) /-- The coordinate box is independent of the facet perturbations, which also controls dimensions zero and one in the prefix estimate. -/ /- Original line 45480: Erdos416Proof.FordGeometry.thickened_any_polytope_box_bound -/ theorem thickened_any_polytope_box_bound (K : ℕ) (ξ : ℕ → ℝ) {τ : ℝ} (hτ : 0 ≤ τ) : volume.real (polytope K ξ+errorCube K τ) ≤ (1+2*τ)^K := by have hsub : polytope K ξ+errorCube K τ ⊆ Set.Icc (fun _ => -τ) (fun _ => 1+τ) := by rintro z ⟨x, hx, e, he, rfl⟩ exact ⟨fun idx => by dsimp[Erdos416Proof.FordGeometry.slackMap_apply] ; linarith [hx.1 idx, he.1 idx], fun idx => by dsimp[Erdos416Proof.FordGeometry.slackMap_apply] ; linarith [hx.2.1 idx, he.2 idx]⟩ calc _ ≤ volume.real (Set.Icc (fun _ : Fin K => -τ) (fun _ => 1+τ)) := measureReal_mono hsub isCompact_Icc.measure_lt_top.ne _ = _ := by rw [measureReal_def, Real.volume_Icc_pi_toReal (by intro idx; dsimp[Erdos416Proof.FordGeometry.slackMap_apply] ; linarith)] simp only [show 1+τ- -τ = 1+2*τ by ring, prod_const, card_univ, Fintype.card_fin] /- Original line 45494: Erdos416Proof.FordGeometry.thickened_expanded_prefix_model_bound -/ theorem thickened_expanded_prefix_model_bound {K : ℕ} {ξ : ℕ → ℝ} {τ : ℝ} (hξ : ∀ j, 1 ≤ ξ j) (hH : H K ξ ≤ 2) (hτ : 0 ≤ τ) (hτ1 : τ ≤ 1) (hsmall : 2 ≤ K → τ ≤ 10*rho^K/(K : ℝ)) : volume.real (polytope K ξ+errorCube K τ) ≤ (3+2*Real.exp 80)*modelVolume K := by by_cases hK : 2 ≤ K · have h := thickened_polytope_uniform_bound hK hξ hτ (hsmall hK) rw [← modelVolume_eq_TStar hK] at h have hfactor : H K ξ*Real.exp 80 ≤ 3+2*Real.exp 80 := by linarith [mul_le_mul_of_nonneg_right hH (Real.exp_pos 80).le] exact h.trans (mul_le_mul_of_nonneg_right hfactor (modelVolume_pos K).le) · have h := thickened_any_polytope_box_bound K ξ hτ have hK' : K = 0 ∨ K = 1 := by omega rcases hK' with rfl | rfl <;> simp only [modelVolume_zero, modelVolume_one, mul_one] · simpa only [pow_zero] using h.trans (by linarith [Real.exp_pos 80]) · simp only [pow_one] at h linarith [Real.exp_pos 80] end Erdos416Proof.FordGeometry namespace Erdos416Proof.FordReciprocal open FordGeometry FordAnalysis FordScale /-- The prefix reciprocal estimate allows every expanded facet parameter with bounded total volume distortion, uniformly including short prefixes. -/ /- Original line 45519: Erdos416Proof.FordReciprocal.exists_expanded_prefix_tuple_mass_bound -/ theorem exists_expanded_prefix_tuple_mass_bound : ∃ B : ℝ, 0 < B ∧ ∀ (M : ℕ) (t : ℝ), Real.exp 1 ≤ t → ∀ (K : ℕ) (ξ : ℕ → ℝ), K ≤ coreDimension M t → (∀ j, 1 ≤ ξ j) → H K ξ ≤ 2 → tupleReciprocalMass K t (polytope K ξ) ≤ B*t^K*modelVolume K := by obtain ⟨C, hC, hbound⟩ := exists_tupleReciprocalMass_volume_bound refine ⟨C*(3+2*Real.exp 80), by positivity, ?_⟩ intro M t ht K ξ hKL hξ hH have ht1 : 1 ≤ t := (Real.one_le_exp (by norm_num : (0 : ℝ) ≤ 1)).trans ht have ht0 : 0 < t := (Real.exp_pos 1).trans_le ht have hvol := thickened_expanded_prefix_model_bound hξ hH (one_div_nonneg.mpr ht0.le) ((div_le_one ht0).mpr ht1) (fun hK => prefix_mesh_bound M ht (by omega) hKL) calc _ ≤ C*t^K*volume.real (polytope K ξ+errorCube K (1/t)) := hbound K t _ ht0 (fun x hx => ⟨hx.1, hx.2.1⟩) _ ≤ C*t^K*((3+2*Real.exp 80)*modelVolume K) := mul_le_mul_of_nonneg_left hvol (mul_nonneg hC.le (pow_nonneg ht0.le K)) _ = _ := by ring /- Original line 45539: Erdos416Proof.FordReciprocal.exists_actual_expanded_prefix_mass_bound -/ theorem exists_actual_expanded_prefix_mass_bound : ∃ B : ℝ, 0 < B ∧ ∀ᶠ M : ℕ in atTop, ∀ᶠ t : ℝ in atTop, ∀ K : ℕ, K ≤ coreDimension M t → tupleReciprocalMass K t (polytope K (expandedParameter (optimalDimension t))) ≤ B*t^K*modelVolume K := by obtain ⟨B, hB, hbound⟩ := exists_expanded_prefix_tuple_mass_bound refine ⟨B, hB, ?_⟩ filter_upwards [expanded_prefix_H_eventually] with M hM filter_upwards [coreDimension_add_tail M, eventually_ge_atTop (Real.exp 1)] with t hadd ht intro K hK apply hbound M t ht K _ hK (expandedParameter_ge_one _) apply hM omega /-- The actual expanded-prefix masses have the Gaussian decay used in the first-failed-row sum; the constant is independent of the retained gap. -/ /- Original line 45555: Erdos416Proof.FordReciprocal.exists_actual_expanded_prefix_gaussian_bound -/ theorem exists_actual_expanded_prefix_gaussian_bound : ∃ B : ℝ, 0 < B ∧ ∀ᶠ M : ℕ in atTop, ∀ᶠ t : ℝ in atTop, ∀ K : ℕ, K ≤ coreDimension M t → tupleReciprocalMass K t (polytope K (expandedParameter (optimalDimension t))) ≤ B*(4*rho^M)^(coreDimension M t-K)*rho^((coreDimension M t-K).choose 2)* (t^(coreDimension M t)*modelVolume (coreDimension M t)) := by obtain ⟨B, hB, hbound⟩ := exists_actual_expanded_prefix_mass_bound refine ⟨B, hB, ?_⟩ filter_upwards [hbound] with M hM filter_upwards [hM, coreDimension_add_tail M, eventually_ge_atTop (Real.exp 1)] with t htBound hadd ht intro K hK have hgaussian := mul_le_mul_of_nonneg_left (core_scaled_gaussian_prefix_bound M ht hadd hK) hB.le calc _ ≤ B*t^K*modelVolume K := htBound K hK _ = B*(t^K*modelVolume K) := by ring _ ≤ _ := hgaussian _ = _ := by ring end Erdos416Proof.FordReciprocal end /- Consolidated component: FacetErrorDecay.lean. -/ section open Filter Asymptotics Finset open scoped Classical Topology BigOperators namespace Erdos416Proof.FordBadFacet open FordRestricted /- Original line 45592: Erdos416Proof.FordBadFacet.normality_envelope_factor_decay -/ theorem normality_envelope_factor_decay {T R E : ℝ} (hT : 20 ≤ T) (hE : E ≤ Real.exp (12*(Real.log T)^2)) (hR : 288*(Real.log T)^2 ≤ R) : E*(1+T)^6*Real.exp (-R/6) ≤ Real.exp (-R/12) := by have hTpos : 0 < T := by linarith have hlog1 : 1 ≤ Real.log T := by apply (Real.le_log_iff_exp_le hTpos).mpr have he : Real.exp 1 ≤ 3 := Real.exp_one_lt_d9.le.trans (by norm_num) linarith have hlog : Real.log (1+T) ≤ 2*Real.log T := by have h := Real.log_le_log (by linarith : 0 < 1+T) (show 1+T ≤ T^2 by nlinarith) simpa only [Real.log_pow, Nat.cast_ofNat] using h have hpoly : (1+T)^6 ≤ Real.exp (12*Real.log T) := by calc _ = Real.exp (Real.log ((1+T)^6)) := (Real.exp_log (by positivity)).symm _ ≤ _ := Real.exp_le_exp.mpr (by rw [Real.log_pow]; norm_num; linarith) calc _ ≤ Real.exp (12*(Real.log T)^2)*Real.exp (12*Real.log T)*Real.exp (-R/6) := by exact mul_le_mul_of_nonneg_right (mul_le_mul hE hpoly (by positivity) (Real.exp_pos _).le) (Real.exp_pos _).le _ = Real.exp (12*(Real.log T)^2+12*Real.log T-R/6) := by rw [← Real.exp_add, ← Real.exp_add] congr 1 ring _ ≤ _ := Real.exp_le_exp.mpr (by nlinarith) /- Original line 45617: Erdos416Proof.FordBadFacet.omega_exception_factor_decay -/ theorem omega_exception_factor_decay {T R : ℝ} (hT : 0 ≤ T) (hR : R ≤ T/1024) : Real.exp (-T/36) ≤ Real.exp (-R/12) := Real.exp_le_exp.mpr (by linarith) /- Original line 45621: Erdos416Proof.FordBadFacet.omega_exception_decay -/ theorem omega_exception_decay {x R : ℝ} (hx : 1 < x) (hT : 0 ≤ logLog x) (hR : R ≤ logLog x/1024) : x*Real.log x^(-37/36 : ℝ) ≤ x/Real.log x*Real.exp (-R/12) := by have hlog := Real.log_pos hx have heT : Real.exp (logLog x) = Real.log x := Real.exp_log hlog have heq : x*Real.log x^(-37/36 : ℝ) = x/Real.log x*Real.exp (-logLog x/36) := by rw [Real.rpow_def_of_pos hlog] rw [show Real.log (Real.log x)*(-37/36 : ℝ) = -logLog x-logLog x/36 by unfold logLog; ring, Real.exp_sub, Real.exp_neg, heT] simp only [neg_div, Real.exp_neg] ring rw [heq] exact mul_le_mul_of_nonneg_left (omega_exception_factor_decay hT hR) (div_nonneg (by linarith) hlog.le) /- Original line 45637: Erdos416Proof.FordBadFacet.square_exception_exponent_decay -/ theorem square_exception_exponent_decay {T R : ℝ} (hT : 20 ≤ T) (hscale : 36*Real.log T ≤ R) (hR : R ≤ T) : Real.log T+3*T-Real.exp R ≤ -R/12 := by have hTpos : 0 < T := by linarith have hp : T^2 ≤ T^36 := pow_le_pow_right₀ (by linarith) (by norm_num : 2 ≤ 36) have hpow : T^36 ≤ Real.exp R := by calc _ = Real.exp (Real.log (T^36)) := (Real.exp_log (pow_pos hTpos _)).symm _ ≤ _ := Real.exp_le_exp.mpr (by simpa only [Real.log_pow, Nat.cast_ofNat] using hscale) have hlog := Real.log_le_sub_one_of_pos hTpos nlinarith /- Original line 45649: Erdos416Proof.FordBadFacet.square_exception_decay -/ theorem square_exception_decay {x c R : ℝ} (hx : 1 < x) (hc : 0 < c) (hT : 20 ≤ logLog x) (hz : 1 ≤ c*x*logLog x) (hzlog : Real.log (c*x*logLog x) ≤ 2*Real.log x) (hscale : 36*Real.log (logLog x) ≤ R) (hR : R ≤ logLog x) : 24*(c*x*logLog x)*(1+Real.log (c*x*logLog x))^2/Real.exp (Real.exp R) ≤ 216*c*(x/Real.log x)*Real.exp (-R/12) := by have hxpos : 0 < x := by linarith have hlog := Real.log_pos hx have hTpos : 0 < logLog x := by linarith have heT : Real.exp (logLog x) = Real.log x := Real.exp_log hlog have hlog1 : 1 ≤ Real.log x := by have h := Real.add_one_le_exp (logLog x) rw [heT] at h linarith have hzlog0 := Real.log_nonneg hz have hsquare : (1+Real.log (c*x*logLog x))^2 ≤ (3*Real.log x)^2 := by nlinarith have he3 : Real.exp (3*logLog x) = (Real.log x)^3 := by rw [show 3*logLog x = logLog x+logLog x+logLog x by ring, Real.exp_add, Real.exp_add, heT] ring have heq : 24*(c*x*logLog x)*(3*Real.log x)^2/Real.exp (Real.exp R) = 216*c*(x/Real.log x)*Real.exp (Real.log (logLog x)+3*logLog x-Real.exp R) := by rw [Real.exp_sub, Real.exp_add, Real.exp_log hTpos, he3] field_simp [hlog.ne'] ring calc _ ≤ 24*(c*x*logLog x)*(3*Real.log x)^2/Real.exp (Real.exp R) := by exact div_le_div_of_nonneg_right (mul_le_mul_of_nonneg_left hsquare (by positivity)) (Real.exp_pos _).le _ = _ := heq _ ≤ _ := mul_le_mul_of_nonneg_left (Real.exp_le_exp.mpr (square_exception_exponent_decay hT hscale hR)) (by positivity) /- Original line 45682: Erdos416Proof.FordBadFacet.eventually_inverse_size_log_bound -/ theorem eventually_inverse_size_log_bound (c : ℝ) (hc : 0 < c) : ∀ᶠ x : ℝ in atTop, 1 < x ∧ 20 ≤ logLog x ∧ 1 ≤ c*x*logLog x ∧ Real.log (c*x*logLog x) ≤ 2*Real.log x := by have hTend : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [eventually_gt_atTop (1 : ℝ), hTend.eventually_ge_atTop 20, eventually_ge_atTop (1/c), hTend.eventually (eventually_const_add_log_le_linear (Real.log c) 1 (by norm_num))] with x hx hT hcx hlog have hxpos : 0 < x := by linarith have hTpos : 0 < logLog x := by linarith have hcx1 : 1 ≤ c*x := by have h := (div_le_iff₀ hc).mp hcx nlinarith have hz : 1 ≤ c*x*logLog x := by nlinarith refine ⟨hx, hT, hz, ?_⟩ rw [Real.log_mul (mul_ne_zero hc.ne' hxpos.ne') hTpos.ne', Real.log_mul hc.ne' hxpos.ne'] have he := Real.add_one_le_exp (logLog x) have heT : Real.exp (logLog x) = Real.log x := Real.exp_log (Real.log_pos hx) rw [heT] at he nlinarith [hlog.2] /- Original line 45704: Erdos416Proof.FordBadFacet.grid_exception_decay -/ theorem grid_exception_decay {x G R ω : ℝ} (hx : 1 < x) (hT : 0 ≤ logLog x) (hω : 0 ≤ ω) (hG : G ≤ Real.exp (ω*logLog x/8)) (hR : R ≤ ω*logLog x/64) : x*G*Real.exp (-(1+ω/4)*logLog x) ≤ x/Real.log x*Real.exp (-R/12) := by have hlog := Real.log_pos hx have heT : Real.exp (logLog x) = Real.log x := Real.exp_log hlog have heq : x*Real.exp (ω*logLog x/8)*Real.exp (-(1+ω/4)*logLog x) = x/Real.log x*Real.exp (-ω*logLog x/8) := by rw [mul_assoc, ← Real.exp_add] rw [show ω*logLog x/8+(-(1+ω/4)*logLog x) = -logLog x-ω*logLog x/8 by ring, Real.exp_sub, Real.exp_neg, heT] simp only [neg_div, neg_mul, Real.exp_neg] ring calc _ ≤ x*Real.exp (ω*logLog x/8)*Real.exp (-(1+ω/4)*logLog x) := mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left hG (by linarith)) (Real.exp_pos _).le _ = _ := heq _ ≤ _ := mul_le_mul_of_nonneg_left (Real.exp_le_exp.mpr (by nlinarith [mul_nonneg hω hT])) (div_nonneg (by linarith) hlog.le) /- Original line 45724: Erdos416Proof.FordBadFacet.coordinateGrid_two_mesh_card_bound -/ theorem coordinateGrid_two_mesh_card_bound (k : ℕ) {N ω : ℝ} (hN : 0 < N) (hω : 0 < ω) : ((coordinateGrid k (facetMesh N ω) 2).card : ℝ) ≤ (1+20*N^2/ω)^k := by have hmesh : 0 < facetMesh N ω := by unfold facetMesh; positivity have hfloor := Nat.floor_le (div_nonneg (by norm_num : (0 : ℝ) ≤ 2) hmesh.le) have hdiv : 2/facetMesh N ω = 20*N^2/ω := by unfold facetMesh; field_simp; ring rw [hdiv] at hfloor have hcast : (((⌊2/facetMesh N ω⌋₊+1)^k : ℕ) : ℝ) ≤ (1+20*N^2/ω)^k := by push_cast rw [hdiv] apply pow_le_pow_left₀ (by positivity) linarith exact (Nat.cast_le.mpr (coordinateGrid_card_le k (facetMesh N ω) 2)).trans hcast /-- A deliberately coarse, uniform polynomial bound on the logarithm of the number of actual finite grid records. -/ /- Original line 45740: Erdos416Proof.FordBadFacet.suffix_grid_factor_bound -/ theorem suffix_grid_factor_bound (k : ℕ) : (((k+1)*(coordinateGrid k (facetMesh ((k+1 : ℕ) : ℝ) (suffixMargin k)) 2).card : ℕ) : ℝ) ≤ Real.exp (300000*((k+1 : ℕ) : ℝ)^2) := by let N : ℝ := ((k+1 : ℕ) : ℝ) have hN : 1 ≤ N := by dsimp [N]; exact_mod_cast (show 1 ≤ k+1 by omega) have hk : (0 : ℝ) ≤ k := Nat.cast_nonneg k have hkN : (k : ℝ) ≤ N := by dsimp [N]; push_cast; linarith have hω := suffixMargin_pos k have he0 : 1 ≤ Real.exp ((k : ℝ)/40) := Real.one_le_exp_iff.mpr (by positivity) have heq : 20*N^2/suffixMargin k = 200000*N^2*Real.exp ((k : ℝ)/40) := by unfold suffixMargin rw [neg_div, Real.exp_neg] field_simp ring have hbase : 1+20*N^2/suffixMargin k ≤ Real.exp (200004*N) := by rw [heq] have hNexp : N ≤ Real.exp N := by linarith [Real.add_one_le_exp N] have hc : (200001 : ℝ) ≤ Real.exp 200001 := by linarith [Real.add_one_le_exp (200001 : ℝ)] have hNsqexp : N^2 ≤ Real.exp (2*N) := by have h := pow_le_pow_left₀ (by linarith : 0 ≤ N) hNexp 2 simpa only [← Real.exp_nat_mul, Nat.cast_ofNat] using h calc _ ≤ 200001*N^2*Real.exp ((k : ℝ)/40) := by nlinarith [mul_le_mul (show (1 : ℝ) ≤ N^2 by nlinarith) he0 (by norm_num) (sq_nonneg N)] _ ≤ Real.exp 200001*Real.exp (2*N)*Real.exp ((k : ℝ)/40) := mul_le_mul_of_nonneg_right (mul_le_mul hc hNsqexp (sq_nonneg N) (Real.exp_pos _).le) (Real.exp_pos _).le _ = Real.exp (200001+2*N+(k : ℝ)/40) := by rw [← Real.exp_add, ← Real.exp_add] _ ≤ _ := Real.exp_le_exp.mpr (by linarith) have hcard := coordinateGrid_two_mesh_card_bound k (by linarith : 0 < N) hω have hcardexp : ((coordinateGrid k (facetMesh N (suffixMargin k)) 2).card : ℝ) ≤ Real.exp ((k : ℝ)*(200004*N)) := by calc _ ≤ _ := hcard _ ≤ (Real.exp (200004*N))^k := pow_le_pow_left₀ (by positivity) hbase k _ = _ := (Real.exp_nat_mul _ _).symm have hNexp : N ≤ Real.exp N := by linarith [Real.add_one_le_exp N] rw [Nat.cast_mul] change N*((coordinateGrid k (facetMesh N (suffixMargin k)) 2).card : ℝ) ≤ _ calc _ ≤ Real.exp N*Real.exp ((k : ℝ)*(200004*N)) := mul_le_mul hNexp hcardexp (Nat.cast_nonneg _) (Real.exp_pos _).le _ = Real.exp (N+(k : ℝ)*(200004*N)) := (Real.exp_add _ _).symm _ ≤ _ := Real.exp_le_exp.mpr (by change N+(k : ℝ)*(200004*N) ≤ 300000*N^2 nlinarith [mul_le_mul_of_nonneg_right hkN (by linarith : 0 ≤ N)]) /- Original line 45787: Erdos416Proof.FordBadFacet.exists_uniform_suffix_grid_factor_budget -/ theorem exists_uniform_suffix_grid_factor_budget : ∃ K : ℝ, 0 ≤ K ∧ ∀ (k : ℕ) (T : ℝ), Real.exp ((k : ℝ)/15+K) ≤ T → (((k+1)*(coordinateGrid k (facetMesh ((k+1 : ℕ) : ℝ) (suffixMargin k)) 2).card : ℕ) : ℝ) ≤ Real.exp (suffixMargin k*T/8) := by obtain ⟨K, hK, hbound⟩ := exists_suffix_margin_dominates_polylog_above 2400000 (by norm_num) 2 0 refine ⟨K, hK, ?_⟩ intro k T hT have hT0 : 0 ≤ T := (Real.exp_pos _).le.trans hT have hω := suffixMargin_pos k have hω1 := suffixMargin_le_one k have hmajor : 2400000*((k+1 : ℕ) : ℝ)^2 ≤ suffixMargin k^2*T := by simpa only [pow_zero, mul_one, Nat.cast_add, Nat.cast_one] using hbound k T hT apply (suffix_grid_factor_bound k).trans apply Real.exp_le_exp.mpr nlinarith [mul_le_mul_of_nonneg_right (show suffixMargin k^2 ≤ suffixMargin k by nlinarith) hT0] /- Original line 45804: Erdos416Proof.FordBadFacet.suffixCutoff_mono_parameters -/ theorem suffixCutoff_mono_parameters {K H : ℝ} {k l : ℕ} (hKH : K ≤ H) (hkl : k ≤ l) : suffixCutoff K k ≤ suffixCutoff H l := by apply Real.exp_le_exp.mpr apply Real.exp_le_exp.mpr apply Real.exp_le_exp.mpr have hkl' : (k : ℝ) ≤ l := by exact_mod_cast hkl linarith /- Original line 45812: Erdos416Proof.FordBadFacet.suffixCutoff_logLog_lower -/ theorem suffixCutoff_logLog_lower {K x : ℝ} {k : ℕ} (hcut : suffixCutoff K k ≤ x) : Real.exp ((k : ℝ)/15+K) ≤ logLog x := by have h₁ := Real.log_le_log (Real.exp_pos _) hcut simp only [Real.log_exp] at h₁ have h₂ := Real.log_le_log (Real.exp_pos _) h₁ simpa only [Real.log_exp, logLog] using h₂ /-- A single enlargement of the suffix cutoff absorbs an unrelated eventual condition in the endpoint, uniformly for every facet length. -/ /- Original line 45821: Erdos416Proof.FordBadFacet.suffixCutoff_absorb_eventual -/ theorem suffixCutoff_absorb_eventual {P : ℝ → Prop} (hP : ∀ᶠ x : ℝ in atTop, P x) (K : ℝ) : ∃ H : ℝ, K ≤ H ∧ 0 ≤ H ∧ ∀ k x, suffixCutoff H k ≤ x → P x := by obtain ⟨b, hb⟩ := eventually_atTop.mp hP let H : ℝ := max 0 (max K b) have hH0 : 0 ≤ H := le_max_left _ _ have hKH : K ≤ H := (le_max_left K b).trans (le_max_right 0 _) have hbH : b ≤ H := (le_max_right K b).trans (le_max_right 0 _) refine ⟨H, hKH, hH0, ?_⟩ intro k x hx apply hb apply (hbH.trans ?_).trans hx have hk0 : (0 : ℝ) ≤ k := Nat.cast_nonneg k have h₁ := Real.add_one_le_exp ((k : ℝ)/15+H) have h₂ := Real.add_one_le_exp (Real.exp ((k : ℝ)/15+H)) have h₃ := Real.add_one_le_exp (Real.exp (Real.exp ((k : ℝ)/15+H))) dsimp [Erdos416Proof.FordRestricted.suffixCutoff_log3, suffixCutoff] linarith /-- The actual arithmetic exceptional count has a uniform exponential saving in the concrete normality parameter. -/ /- Original line 45841: Erdos416Proof.FordBadFacet.exists_eventually_uniform_badFacet_decay -/ theorem exists_eventually_uniform_badFacet_decay : ∃ C H : ℝ, 0 < C ∧ 0 ≤ H ∧ ∀ᶠ x : ℝ in atTop, ∀ k : ℕ, suffixCutoff H k ≤ x → ((badFacetValues x k (suffixMargin k)).card : ℝ) ≤ C*(x/Real.log x)*Real.exp (-facetNormalityParameter ((k+1 : ℕ) : ℝ) (suffixMargin k/2) (logLog x)/12) := by obtain ⟨C, K, J, c, H, hC, hK, hJ, hc, hH, hraw⟩ := exists_uniform_actual_badFacet_bound obtain ⟨Hn, hHn, hn⟩ := exists_uniform_suffix_normality_log_sq_budget 288 (by norm_num) obtain ⟨Hg, hHg, hg⟩ := exists_uniform_suffix_grid_factor_budget obtain ⟨Hp, hHp, hp⟩ := exists_uniform_suffix_facet_conditions 0 (by norm_num) let H₀ := max H (max Hn (max Hg Hp)) have hHH : H ≤ H₀ := le_max_left _ _ have hHnH : Hn ≤ H₀ := (le_max_left _ _).trans (le_max_right _ _) have hHgH : Hg ≤ H₀ := (le_max_left _ _).trans ((le_max_right _ _).trans (le_max_right _ _)) have hHpH : Hp ≤ H₀ := (le_max_right _ _).trans ((le_max_right _ _).trans (le_max_right _ _)) refine ⟨C+216*c+K+J, H₀, by positivity, hH.trans hHH, ?_⟩ filter_upwards [hraw, totientUpperEnvelope_explicit_growth, eventually_inverse_size_log_bound c hc] with x hraw henvelope hxdata obtain ⟨hx, hT, hz, hzlog⟩ := hxdata intro k hcut let N : ℝ := ((k+1 : ℕ) : ℝ) let T := logLog x let ω := suffixMargin k let R := facetNormalityParameter N (ω/2) T let S := facetNormalityScale N (ω/2) T let G : ℝ := (((k+1)*(coordinateGrid k (facetMesh N ω) 2).card : ℕ) : ℝ) have hN : 1 ≤ N := by dsimp [Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordBadFacet.facetNormalityScale_logLog, Erdos416Proof.FordBadFacet.positiveLogLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_bottom, Erdos416Proof.FordBadFacet.reversedFacetLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_succ, Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.FordRestricted.suffixCutoff_log3, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, N]; exact_mod_cast (show 1 ≤ k+1 by omega) have hω : 0 < ω := suffixMargin_pos k have hω1 : ω ≤ 1 := suffixMargin_le_one k have hT0 : 0 ≤ T := by dsimp [Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordBadFacet.facetNormalityScale_logLog, Erdos416Proof.FordBadFacet.positiveLogLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_bottom, Erdos416Proof.FordBadFacet.reversedFacetLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_succ, Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.FordRestricted.suffixCutoff_log3, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, T]; linarith have hbase := suffixCutoff_logLog_lower hcut have hcutT (a : ℝ) (ha : a ≤ H₀) : Real.exp ((k : ℝ)/15+a) ≤ T := (Real.exp_le_exp.mpr (by linarith)).trans hbase have hnormal : 288*(Real.log T)^2 ≤ R := hn k T (hcutT Hn hHnH) have hgrid : G ≤ Real.exp (ω*T/8) := hg k T (hcutT Hg hHgH) have hscale : 36*Real.log T ≤ R := (hp k T (hcutT Hp hHpH)).2.1 have hR := facetNormalityParameter_le hN (show 0 ≤ ω/2 by linarith) (show ω/2 ≤ 1 by linarith) hT0 change 0 ≤ R ∧ R ≤ T/1024 at hR have hRgrid : R ≤ ω*T/64 := by have h := halfMargin_normality_weighted_loss hN (show (1 : ℝ) ≤ N^2 by nlinarith) hω.le hω1 hT0 simpa only [one_mul, div_mul_eq_mul_div] using h have hlog : 0 < Real.log x := Real.log_pos hx have hQ : 0 ≤ x/Real.log x := div_nonneg (by linarith) hlog.le have hn' := normality_envelope_factor_decay hT henvelope hnormal have hs' := square_exception_decay hx hc hT hz hzlog hscale (show R ≤ logLog x by change R ≤ T; linarith [hR.2]) have ho' := omega_exception_decay hx hT0 hR.2 have hg' := grid_exception_decay hx hT0 hω.le hgrid hRgrid specialize hraw k ((suffixCutoff_mono_parameters hHH (le_refl k)).trans hcut) dsimp only at hraw have hlogS : logLog S = R := by simp [Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordBadFacet.facetNormalityScale_logLog, Erdos416Proof.FordBadFacet.positiveLogLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_bottom, Erdos416Proof.FordBadFacet.reversedFacetLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_succ, Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.FordRestricted.suffixCutoff_log3, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, S, R, logLog, facetNormalityScale] change ((badFacetValues x k ω).card : ℝ) ≤ C*totientUpperEnvelope x*x/Real.log x*(1+T)^6*Real.exp (-logLog S/6)+ 24*(c*x*T)*(1+Real.log (c*x*T))^2/S+ K*x*Real.log x^(-37/36 : ℝ)+J*x*G*Real.exp (-(1+ω/4)*T) at hraw rw [hlogS] at hraw have hnormalTerm : C*totientUpperEnvelope x*x/Real.log x*(1+T)^6*Real.exp (-R/6) ≤ C*(x/Real.log x)*Real.exp (-R/12) := by calc _ = C*(x/Real.log x)*(totientUpperEnvelope x*(1+T)^6*Real.exp (-R/6)) := by ring _ ≤ _ := mul_le_mul_of_nonneg_left hn' (mul_nonneg hC.le hQ) have hsquareTerm : 24*(c*x*T)*(1+Real.log (c*x*T))^2/S ≤ 216*c*(x/Real.log x)*Real.exp (-R/12) := by simpa only [S, facetNormalityScale] using hs' have homegaTerm : K*x*Real.log x^(-37/36 : ℝ) ≤ K*(x/Real.log x)*Real.exp (-R/12) := by simpa only [mul_assoc] using mul_le_mul_of_nonneg_left ho' hK.le have hgridTerm : J*x*G*Real.exp (-(1+ω/4)*T) ≤ J*(x/Real.log x)*Real.exp (-R/12) := by simpa only [mul_assoc] using mul_le_mul_of_nonneg_left hg' hJ.le change ((badFacetValues x k ω).card : ℝ) ≤ (C+216*c+K+J)*(x/Real.log x)*Real.exp (-R/12) nlinarith /-- Uniform absolute cutoffs for the actual bad-facet values. This form is suitable for subsequent suffix partial summation. -/ /- Original line 45918: Erdos416Proof.FordBadFacet.exists_uniform_badFacet_decay -/ theorem exists_uniform_badFacet_decay : ∃ C H : ℝ, 0 < C ∧ 0 ≤ H ∧ ∀ (k : ℕ) (x : ℝ), suffixCutoff H k ≤ x → ((badFacetValues x k (suffixMargin k)).card : ℝ) ≤ C*(x/Real.log x)*Real.exp (-facetNormalityParameter ((k+1 : ℕ) : ℝ) (suffixMargin k/2) (logLog x)/12) := by obtain ⟨C, H, hC, hH, hbound⟩ := exists_eventually_uniform_badFacet_decay obtain ⟨H', hHH', hH', habsolute⟩ := suffixCutoff_absorb_eventual hbound H refine ⟨C, H', hC, hH', ?_⟩ intro k x hcut exact habsolute k x hcut k ((suffixCutoff_mono_parameters hHH' (le_refl k)).trans hcut) /- Original line 45929: Erdos416Proof.FordBadFacet.exists_uniform_suffix_normality_polynomial_budget -/ theorem exists_uniform_suffix_normality_polynomial_budget (E : ℝ) (hE : 0 ≤ E) (m : ℕ) : ∃ H : ℝ, 0 ≤ H ∧ ∀ (k : ℕ) (T : ℝ), Real.exp ((k : ℝ)/15+H) ≤ T → E*((k+1 : ℕ) : ℝ)^m ≤ facetNormalityParameter ((k+1 : ℕ) : ℝ) (suffixMargin k/2) T := by obtain ⟨H, hH, hbound⟩ := exists_suffix_margin_dominates_polylog_above (4096*E) (by positivity) (m+4) 2 refine ⟨H, hH, ?_⟩ intro k T hT let N : ℝ := ((k+1 : ℕ) : ℝ) let A := normalityCost N have hN : 1 ≤ N := by dsimp [Erdos416Proof.FordBadFacet.facetNormalityScale_logLog, N]; exact_mod_cast (show 1 ≤ k+1 by omega) have hA : 0 < A := by have := (normalityCost_bounds hN).1; dsimp [Erdos416Proof.FordBadFacet.facetNormalityScale_logLog, A]; linarith have hmajor : 4096*E*N^m*A^2 ≤ suffixMargin k^2*T := by have h := hbound k T hT convert h using 1 dsimp [Erdos416Proof.FordBadFacet.facetNormalityScale_logLog, A, normalityCost, N] push_cast rw [pow_add] ring have hR : facetNormalityParameter N (suffixMargin k/2) T = suffixMargin k^2*T/(4096*A^2) := by change ((suffixMargin k/2)/(32*A))^2*T = _ field_simp ring change E*N^m ≤ facetNormalityParameter N (suffixMargin k/2) T rw [hR] apply (le_div_iff₀ (by positivity : 0 < 4096*A^2)).mpr nlinarith /- Original line 45958: Erdos416Proof.FordBadFacet.normality_decay_gaussian_log_sq -/ theorem normality_decay_gaussian_log_sq {T R N : ℝ} (hT : 20 ≤ T) (hRlog : 288*(Real.log T)^2 ≤ R) (hRN : 24*N^2 ≤ R) : Real.exp (-R/12) ≤ Real.exp (-N^2)/T^2 := by have hTpos : 0 < T := by linarith have hlog1 : 1 ≤ Real.log T := by apply (Real.le_log_iff_exp_le hTpos).mpr have he : Real.exp 1 ≤ 3 := Real.exp_one_lt_d9.le.trans (by norm_num) linarith calc _ ≤ Real.exp (-N^2-2*Real.log T) := Real.exp_le_exp.mpr (by nlinarith) _ = _ := by rw [Real.exp_sub, show (2 : ℝ) = ((2 : ℕ) : ℝ) by norm_num, Real.exp_nat_mul, Real.exp_log hTpos] /-- An integrable density envelope with Gaussian decay in the facet length. The existing finite Abel-summation theorem applies directly to this bound. -/ /- Original line 45973: Erdos416Proof.FordBadFacet.exists_uniform_badFacet_gaussian_density -/ theorem exists_uniform_badFacet_gaussian_density : ∃ C H : ℝ, 0 < C ∧ 0 ≤ H ∧ ∀ (k : ℕ) (x : ℝ), suffixCutoff H k ≤ x → ((badFacetValues x k (suffixMargin k)).card : ℝ) ≤ C*Real.exp (-((k+1 : ℕ) : ℝ)^2)*(x/(Real.log x*(logLog x)^2)) := by obtain ⟨C, H, hC, hH, hbound⟩ := exists_uniform_badFacet_decay obtain ⟨Hp, hHp, hp⟩ := exists_uniform_suffix_normality_polynomial_budget 24 (by norm_num) 2 obtain ⟨Hn, hHn, hn⟩ := exists_uniform_suffix_normality_log_sq_budget 288 (by norm_num) let H' := max H (max Hp Hn)+20 have hHH' : H ≤ H' := by dsimp [Erdos416Proof.FordBadFacet.facetNormalityScale_logLog, Erdos416Proof.FordBadFacet.positiveLogLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_bottom, Erdos416Proof.FordBadFacet.reversedFacetLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_succ, Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.FordRestricted.suffixCutoff_log3, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, H']; linarith [le_max_left H (max Hp Hn)] have hHpH' : Hp ≤ H' := by have h := (le_max_left Hp Hn).trans (le_max_right H (max Hp Hn)) dsimp [Erdos416Proof.FordBadFacet.facetNormalityScale_logLog, Erdos416Proof.FordBadFacet.positiveLogLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_bottom, Erdos416Proof.FordBadFacet.reversedFacetLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_succ, Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.FordRestricted.suffixCutoff_log3, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, H']; linarith have hHnH' : Hn ≤ H' := by have h := (le_max_right Hp Hn).trans (le_max_right H (max Hp Hn)) dsimp [Erdos416Proof.FordBadFacet.facetNormalityScale_logLog, Erdos416Proof.FordBadFacet.positiveLogLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_bottom, Erdos416Proof.FordBadFacet.reversedFacetLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_succ, Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.FordRestricted.suffixCutoff_log3, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, H']; linarith have hH'20 : 20 ≤ H' := by dsimp [Erdos416Proof.FordBadFacet.facetNormalityScale_logLog, Erdos416Proof.FordBadFacet.positiveLogLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_bottom, Erdos416Proof.FordBadFacet.reversedFacetLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_succ, Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.FordRestricted.suffixCutoff_log3, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, H']; linarith [le_max_left H (max Hp Hn)] refine ⟨C, H', hC, by linarith, ?_⟩ intro k x hcut have hTcut := suffixCutoff_logLog_lower hcut have hT : 20 ≤ logLog x := by have hk : (0 : ℝ) ≤ k := Nat.cast_nonneg k have he := Real.add_one_le_exp ((k : ℝ)/15+H') linarith have hx : 1 < x := by have he : 1 < suffixCutoff H' k := Real.one_lt_exp_iff.mpr (Real.exp_pos _) exact he.trans_le hcut have hn' := hn k (logLog x) ((Real.exp_le_exp.mpr (by linarith : (k : ℝ)/15+Hn ≤ (k : ℝ)/15+H')).trans hTcut) have hp' := hp k (logLog x) ((Real.exp_le_exp.mpr (by linarith : (k : ℝ)/15+Hp ≤ (k : ℝ)/15+H')).trans hTcut) have he := normality_decay_gaussian_log_sq hT hn' hp' calc _ ≤ _ := hbound k x ((suffixCutoff_mono_parameters hHH' (le_refl k)).trans hcut) _ ≤ C*(x/Real.log x)*(Real.exp (-((k+1 : ℕ) : ℝ)^2)/(logLog x)^2) := mul_le_mul_of_nonneg_left he (mul_nonneg hC.le (div_nonneg (by linarith) (Real.log_pos hx).le)) _ = _ := by ring /- Original line 46011: Erdos416Proof.FordBadFacet.badFacetValues_mem_at_smaller_endpoint -/ theorem badFacetValues_mem_at_smaller_endpoint {z t ω : ℝ} {k m : ℕ} (ht : Real.exp 1 < t) (htz : t ≤ z) (hm : m ∈ badFacetValues z k ω) (hmt : (m : ℝ) ≤ t) : m ∈ badFacetValues t k ω := by have ht1 : 1 < t := (Real.one_lt_exp_iff.mpr (by norm_num : (0 : ℝ) < 1)).trans ht have ht0 : 0 ≤ t := by linarith have hz0 : 0 ≤ z := ht0.trans htz obtain ⟨hmV, N, hN, hNm, hfacet⟩ := Finset.mem_filter.mp hm have hmpos := ((mem_totientsUpTo hz0).mp hmV).1 have hT : 0 < logLog t := by apply Real.log_pos simpa only [Real.log_exp] using Real.log_lt_log (Real.exp_pos 1) ht have hTZ : logLog t ≤ logLog z := logLog_mono ht1 htz refine Finset.mem_filter.mpr ⟨(mem_totientsUpTo ht0).mpr ⟨hmpos, hmt, N, hN, hNm⟩, N, hN, hNm, hfacet.trans ?_⟩ apply Finset.sum_le_sum intro idx _ apply mul_le_mul_of_nonneg_left _ (fordWeight_bounds (by omega : 1 ≤ idx.val+1)).1 exact div_le_div_of_nonneg_left (le_max_left 0 _) hT hTZ /-- Reciprocal tails of an actual finite bad-facet family at a common upper endpoint. The membership assumption supplies the arithmetic density bound. -/ /- Original line 46032: Erdos416Proof.FordBadFacet.exists_uniform_badFacet_reciprocal_tail -/ theorem exists_uniform_badFacet_reciprocal_tail : ∃ C H : ℝ, 0 < C ∧ 0 ≤ H ∧ ∀ (k : ℕ) (u z : ℝ) (F : Finset ℕ), suffixCutoff H k ≤ u → u ≤ z → F ⊆ badFacetValues z k (suffixMargin k) → (∀ n ∈ F, u ≤ (n : ℝ)) → (∑ n ∈ F, (1 : ℝ)/n) ≤ 2*C*Real.exp (-((k+1 : ℕ) : ℝ)^2)/logLog u := by obtain ⟨C, H, hC, hH, hcount⟩ := exists_uniform_badFacet_gaussian_density refine ⟨C, H, hC, hH, ?_⟩ intro k u z F hcut huz hF hFlow have hcutlarge : Real.exp (Real.exp 1) ≤ suffixCutoff H k := by apply Real.exp_le_exp.mpr apply Real.exp_le_exp.mpr apply Real.one_le_exp_iff.mpr have hk : (0 : ℝ) ≤ k := Nat.cast_nonneg k linarith have hu : Real.exp (Real.exp 1) ≤ u := hcutlarge.trans hcut have hu' : Real.exp 1 < u := (Real.exp_lt_exp.mpr (Real.one_lt_exp_iff.mpr (by norm_num : (0 : ℝ) < 1))).trans_le hu have hz0 : 0 ≤ z := ((Real.exp_pos 1).le.trans hu'.le).trans huz have hFbounds (n : ℕ) (hn : n ∈ F) : u ≤ (n : ℝ) ∧ (n : ℝ) ≤ z := by exact ⟨hFlow n hn, ((mem_totientsUpTo hz0).mp (Finset.mem_filter.mp (hF hn)).1).2.1⟩ have hdensity (t : ℝ) (hut : u ≤ t) (htz : t ≤ z) : finiteWeightedCountBelow F id t ≤ (C*Real.exp (-((k+1 : ℕ) : ℝ)^2))*(t/(Real.log t*(logLog t)^2)) := by apply le_trans _ (hcount k t (hcut.trans hut)) apply Nat.cast_le.mpr apply Finset.card_le_card intro n hn obtain ⟨hnF, hnt⟩ := Finset.mem_filter.mp hn exact badFacetValues_mem_at_smaller_endpoint (hu'.trans_le hut) htz (hF hnF) hnt have h := finite_weighted_reciprocal_tail F id hu huz (mul_nonneg hC.le (Real.exp_pos _).le) hFbounds hdensity simpa only [id_eq, mul_assoc] using h end Erdos416Proof.FordBadFacet end /- Consolidated component: PrimePrefixCount.lean. -/ section open Filter Finset open scoped Classical Topology BigOperators namespace Erdos416Proof.FordBadFacet open FordReciprocal FordGeometry FordScale /-- Numerical cores obtained from an actual prefix integer and a suffix value. The image removes any repeated numerical cores before prime counting. -/ /- Original line 46085: Erdos416Proof.FordBadFacet.prefixSuffixCores -/ noncomputable def prefixSuffixCores (P W : Finset ℕ) : Finset ℕ := (P.product W).image (fun aw : ℕ × ℕ => aw.1.totient * aw.2) /- Original line 46088: Erdos416Proof.FordBadFacet.prefixSuffixCores_pos -/ theorem prefixSuffixCores_pos {P W : Finset ℕ} (hP : ∀ a ∈ P, 0 < a) (hW : ∀ m ∈ W, 0 < m) : ∀ b ∈ prefixSuffixCores P W, 0 < b := by intro b hb obtain ⟨⟨a,m⟩, ham, rfl⟩ := Finset.mem_image.mp hb obtain ⟨ha,hm⟩ := Finset.mem_product.mp ham exact Nat.mul_pos (Nat.totient_pos.mpr (hP a ha)) (hW m hm) /- Original line 46096: Erdos416Proof.FordBadFacet.prefixSuffixCores_reciprocal_bound -/ theorem prefixSuffixCores_reciprocal_bound (P W : Finset ℕ) : (∑ b ∈ prefixSuffixCores P W, (1 : ℝ)/b) ≤ (∑ a ∈ P, invTotient a) * ∑ m ∈ W, (1 : ℝ)/m := by have hi : (∑ b ∈ prefixSuffixCores P W, (1 : ℝ)/b) ≤ ∑ aw ∈ P.product W, (1 : ℝ)/(aw.1.totient * aw.2 : ℕ) := Finset.sum_image_le_of_nonneg (fun b _ => by positivity) apply hi.trans_eq rw [Finset.product_eq_sprod, Finset.sum_product, Finset.sum_mul] apply Finset.sum_congr rfl intro a ha rw [Finset.mul_sum] apply Finset.sum_congr rfl intro m hm simp only [Nat.cast_mul, invTotient, one_div, mul_inv_rev] ring /-- Count distinct represented values using a large top prime, independently of how many choices of prefix and suffix yield the same numerical core. -/ /- Original line 46114: Erdos416Proof.FordBadFacet.exists_prime_prefix_suffix_count -/ theorem exists_prime_prefix_suffix_count : ∃ C : ℝ, 0 < C ∧ ∀ (P W F : Finset ℕ) (x a : ℝ), 0 < x → 0 < a → (∀ b ∈ P, 0 < b) → (∀ m ∈ W, 0 < m) → (∀ v ∈ F, (v : ℝ) ≤ x ∧ ∃ p b m : ℕ, p.Prime ∧ a ≤ Real.log p ∧ b ∈ P ∧ m ∈ W ∧ v = (p-1)*b.totient*m) → (F.card : ℝ) ≤ C*x/a*(∑ b ∈ P, invTotient b)*(∑ m ∈ W, (1 : ℝ)/m) := by obtain ⟨C, hC, hcount⟩ := exists_largePrimeCorePairs_bound refine ⟨C, hC, ?_⟩ intro P W F x a hx ha hP hW hF let B := prefixSuffixCores P W let Q := largePrimeCorePairs B x a have hB : ∀ b ∈ B, 0 < b := prefixSuffixCores_pos hP hW have hsub : F ⊆ Q.image corePairValue := by intro v hv obtain ⟨hvx,p,b,m,hp,hpa,hb,hm,hval⟩ := hF v hv have hcore : b.totient*m ∈ B := Finset.mem_image.mpr ⟨(b,m), Finset.mem_product.mpr ⟨hb,hm⟩, rfl⟩ have heq : corePairValue (b.totient*m,p) = v := by change (p-1)*(b.totient*m) = v rw [hval, mul_assoc] refine Finset.mem_image.mpr ⟨(b.totient*m,p), ?_, heq⟩ apply Finset.mem_filter.mpr refine ⟨(mem_corePairs hx.le hB).mpr ⟨hcore,hp,?_,?_⟩, hpa⟩ · exact_mod_cast corePairValue_pos (hB _ hcore) hp · simpa only [heq] using hvx have hc : (F.card : ℝ) ≤ Q.card := by exact_mod_cast (Finset.card_le_card hsub).trans Finset.card_image_le calc _ ≤ C*x/a*(∑ b ∈ B, (1 : ℝ)/b) := hc.trans (hcount B x a hx ha hB) _ ≤ C*x/a*((∑ b ∈ P, invTotient b)*(∑ m ∈ W, (1 : ℝ)/m)) := mul_le_mul_of_nonneg_left (prefixSuffixCores_reciprocal_bound P W) (by positivity) _ = _ := by ring /-- The generic finite count with the actual tuple family supplied explicitly. -/ /- Original line 46149: Erdos416Proof.FordBadFacet.exists_prime_tuple_suffix_count -/ theorem exists_prime_tuple_suffix_count : ∃ C : ℝ, 0 < C ∧ ∀ (K : ℕ) (t x a : ℝ) (E : Set (Fin K → ℝ)) (W F : Finset ℕ), 0 < x → 0 < a → (∀ m ∈ W, 0 < m) → (∀ v ∈ F, (v : ℝ) ≤ x ∧ ∃ p b m : ℕ, p.Prime ∧ a ≤ Real.log p ∧ b ∈ tupleIntegers K t E ∧ m ∈ W ∧ v = (p-1)*b.totient*m) → (F.card : ℝ) ≤ C*x/a*tupleReciprocalMass K t E*(∑ m ∈ W, (1 : ℝ)/m) := by obtain ⟨C,hC,hcount⟩ := exists_prime_prefix_suffix_count refine ⟨C,hC,?_⟩ intro K t x a E W F hx ha hW hF exact hcount (tupleIntegers K t E) W F x a hx ha (fun b hb => (Finset.mem_Icc.mp (Finset.mem_filter.mp hb).1).1) hW hF /-- Combine the large-prime count with the expanded-prefix Gaussian bound. The finite family is counted by its actual representations. -/ /- Original line 46164: Erdos416Proof.FordBadFacet.exists_expanded_prime_tuple_suffix_gaussian_count -/ theorem exists_expanded_prime_tuple_suffix_gaussian_count : ∃ C : ℝ, 0 < C ∧ ∀ᶠ M : ℕ in atTop, ∀ᶠ x : ℝ in atTop, ∀ (K : ℕ) (W F : Finset ℕ), K ≤ coreDimension M (logLog x) → (∀ m ∈ W, 0 < m) → (∀ v ∈ F, (v : ℝ) ≤ x ∧ ∃ p b m : ℕ, p.Prime ∧ Real.log x/6 ≤ Real.log p ∧ b ∈ tupleIntegers K (logLog x) (polytope K (expandedParameter (optimalDimension (logLog x)))) ∧ m ∈ W ∧ v = (p-1)*b.totient*m) → (F.card : ℝ) ≤ C*x/Real.log x* (4*FordAnalysis.rho^M)^(coreDimension M (logLog x)-K)* FordAnalysis.rho^((coreDimension M (logLog x)-K).choose 2)* ((logLog x)^(coreDimension M (logLog x))*modelVolume (coreDimension M (logLog x)))* (∑ m ∈ W, (1 : ℝ)/m) := by obtain ⟨C,hC,hcount⟩ := exists_prime_tuple_suffix_count obtain ⟨B,hB,hbound⟩ := exists_actual_expanded_prefix_gaussian_bound refine ⟨6*C*B,by positivity,?_⟩ filter_upwards [hbound] with M hM have hT : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [hT.eventually hM, eventually_gt_atTop (1 : ℝ)] with x hmass hx intro K W F hK hW hF have hx0 : 0 < x := by linarith have hlog : 0 < Real.log x := Real.log_pos hx have hrecip : 0 ≤ ∑ m ∈ W, (1 : ℝ)/m := Finset.sum_nonneg (fun _ _ => by positivity) have hc := hcount K (logLog x) x (Real.log x/6) _ W F hx0 (by positivity) hW hF have hb := mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left (hmass K hK) (show 0 ≤ C*x/(Real.log x/6) by positivity)) hrecip exact (hc.trans hb).trans_eq (by ring) end Erdos416Proof.FordBadFacet end /- Consolidated component: OrdinaryTopPrime.lean. -/ section open Filter Finset open scoped Classical Topology BigOperators namespace Erdos416Proof.FordBadFacet /-- The coarse growth pruning already guarantees a large largest prime in each retained preimage. This estimate does not require concentration of q₁. -/ /- Original line 46211: Erdos416Proof.FordBadFacet.ordinary_top_log_lower_of_growth_data -/ theorem ordinary_top_log_lower_of_growth_data : ∀ᶠ x : ℝ in atTop, ∀ N : ℕ, 0 < N → Real.sqrt x ≤ (N.totient : ℝ) → (ArithmeticFunction.cardFactors N.totient : ℝ) ≤ 5*logLog x → NoLargePrimeSquare N (growthLargePrimeCutoff (logLog x)) → (N.primeFactors.filter (fun p : ℕ => growthLargePrimeCutoff (logLog x) < (p : ℝ))).card ≤ 2 → (ordinaryPrimeAt N 0).Prime ∧ Real.log x/6 ≤ Real.log (ordinaryPrimeAt N 0) := by filter_upwards [growth_tail_parameters] with x hparams obtain ⟨hx,hT1,hY,hYx,hcut,hYlog⟩ := hparams have hx0 : 0 < x := (Real.exp_pos _).trans_le hx intro N hN hlarge hΩm hsq hcard have hΩN : (ArithmeticFunction.cardFactors N : ℝ) ≤ 6*logLog x := by have hc : (ArithmeticFunction.cardFactors N : ℝ) ≤ ArithmeticFunction.cardFactors N.totient+1 := by exact_mod_cast cardFactors_le_totient_add_one N linarith let H := growthLargePrimeCutoff (logLog x) let w := lowPrimePart N H let b := highPrimePart N H have hw : 0 < w := primePart_pos _ _ have hb : 0 < b := primePart_pos _ _ have hwR : (0 : ℝ) < w := by exact_mod_cast hw have hbR : (0 : ℝ) < b := by exact_mod_cast hb have hprod : w*b = N := low_mul_high hN.ne' H have hwY : (w : ℝ) ≤ growthTailEndpoint (logLog x) := lowPrimePart_le_growthTail (by linarith) hΩN hcut have hwlog : Real.log w ≤ Real.log x/6 := (Real.log_le_log hwR hwY).trans hYlog have hNlarge : Real.sqrt x ≤ (N : ℝ) := hlarge.trans (by exact_mod_cast Nat.totient_le N) have hNlog : Real.log x/2 ≤ Real.log N := by simpa only [Real.log_sqrt hx0.le] using Real.log_le_log (Real.sqrt_pos.mpr hx0) hNlarge have hlogprod : Real.log N = Real.log w+Real.log b := by rw [← hprod, Nat.cast_mul, Real.log_mul hwR.ne' hbR.ne'] have hfinish (p : ℕ) (hp : p.Prime) (hpd : p ∣ N) (hb2 : b ≤ p^2) : (ordinaryPrimeAt N 0).Prime ∧ Real.log x/6 ≤ Real.log (ordinaryPrimeAt N 0) := by have hptop := prime_divisor_le_ordinary_top hN hp hpd have htop : (ordinaryPrimeAt N 0).Prime := by rcases ordinaryPrimeAt_spec N 0 with h | ⟨h,_⟩ · have := hp.two_le omega · exact h refine ⟨htop, ?_⟩ have hb2R : (b : ℝ) ≤ (p : ℝ)^2 := by exact_mod_cast hb2 have hl := Real.log_le_log hbR hb2R rw [Real.log_pow] at hl have hplog : Real.log x/6 ≤ Real.log p := by norm_num at hl; linarith exact hplog.trans (Real.log_le_log (by exact_mod_cast hp.pos) (Nat.cast_le.mpr hptop)) have hbSF : Squarefree b := primePart_squarefree_of_no_large_square hN.ne' hsq (fun p => H < (p : ℝ)) (fun _ _ hp => hp) have hbcard : b.primeFactors.card ≤ 2 := by change (highPrimePart N H).primeFactors.card ≤ 2 rwa [highPrimePart_primeFactors] rcases squarefree_two_prime_cases hbSF hbcard with hb1 | hp | ⟨p,q,hp,hq,hqp,hpq,hbpq⟩ · have hl0 : Real.log b = 0 := by rw [hb1]; norm_num have hlogx : 0 < Real.log x := Real.log_pos ((Real.one_lt_exp_iff.mpr (Real.exp_pos 1)).trans_le hx) linarith · exact hfinish b hp (primePart_dvd hN.ne' _) (by nlinarith [hp.one_le]) · have hpd : p ∣ N := (show p ∣ b from ⟨q,hbpq⟩).trans (primePart_dvd hN.ne' _) exact hfinish p hp hpd (by rw [hbpq,pow_two]; exact Nat.mul_le_mul_left p hqp) /-- All positive preimages of a retained numerical value satisfy the top prime estimate under the specified growth exclusions. -/ /- Original line 46274: Erdos416Proof.FordBadFacet.ordinary_top_log_lower_outside_growth_exceptions -/ theorem ordinary_top_log_lower_outside_growth_exceptions : ∀ᶠ x : ℝ in atTop, ∀ m N : ℕ, m ∈ totientsUpTo x → Real.sqrt x ≤ (m : ℝ) → 0 < N → N.totient = m → m ∉ nonNormalTotients (growthNormalityScale (logLog x)) x → m ∉ fiveLogOmegaTotients x → m ∉ threeLargeNormalTotients x → m ∉ largeSquareTotients x → (ordinaryPrimeAt N 0).Prime ∧ Real.log x/6 ≤ Real.log (ordinaryPrimeAt N 0) := by filter_upwards [ordinary_top_log_lower_of_growth_data, eventually_ge_atTop (9 : ℝ), fourth_log_cutoff_le_growthLargePrimeCutoff] with x htop hx hcut intro m N hm hlarge hN hphi hnormal hΩ hthree hSq have hx0 : 0 ≤ x := by linarith have hmdata := (mem_totientsUpTo hx0).mp hm have hm3 : 3 ≤ m := by have hs : (3 : ℝ) ≤ Real.sqrt x := Real.le_sqrt_of_sq_le (by norm_num; exact hx) exact_mod_cast hs.trans hlarge have hΩm : (ArithmeticFunction.cardFactors m : ℝ) ≤ 5*logLog (m : ℝ) := by by_contra h exact hΩ (Finset.mem_filter.mpr ⟨hm,hm3,lt_of_not_ge h⟩) have hΩx : (ArithmeticFunction.cardFactors m : ℝ) ≤ 5*logLog x := hΩm.trans (mul_le_mul_of_nonneg_left (logLog_mono (by exact_mod_cast (show 1 < m by omega)) hmdata.2.1) (by norm_num)) have hsqN : NoLargePrimeSquare N (Real.log x^4) := by intro q hq hlargeq hqd exact hSq (Finset.mem_filter.mpr ⟨hm,N,hN,hphi,q,hq,hlargeq,Or.inl hqd⟩) apply htop N hN (by simpa only [hphi] using hlarge) (by simpa only [hphi] using hΩx) (hsqN.mono hcut) exact at_most_two_large_prime_divisors hx hm hlarge hN hphi hnormal hΩ hthree /- Original line 46302: Erdos416Proof.FordBadFacet.large_prime_filter_card_le_two_of_second_bound -/ theorem large_prime_filter_card_le_two_of_second_bound {N : ℕ} (hN : 0 < N) {H : ℝ} (hsecond : (ordinaryPrimeAt N 2 : ℝ) ≤ H) : (N.primeFactors.filter (fun p : ℕ => H < (p : ℝ))).card ≤ 2 := by have hsub : N.primeFactors.filter (fun p : ℕ => H < (p : ℝ)) ⊆ {ordinaryPrimeAt N 0, ordinaryPrimeAt N 1} := by intro p hp obtain ⟨hpN,hpH⟩ := Finset.mem_filter.mp hp have hm : p ∈ ordinaryPrimeList N := List.mem_reverse.mpr ((Nat.mem_primeFactorsList hN.ne').mpr ⟨Nat.prime_of_mem_primeFactors hpN,Nat.dvd_of_mem_primeFactors hpN⟩) obtain ⟨idx,hi⟩ := List.mem_iff_get.mp hm have he : ordinaryPrimeAt N idx.val = p := (List.getD_eq_get _ 1 idx).trans hi have hi2 : idx.val < 2 := by by_contra h have hle := (Nat.cast_le.mpr (ordinaryPrimeAt_antitone N (by omega : 2 ≤ idx.val))).trans hsecond rw [he] at hle linarith have hi01 : idx.val = 0 ∨ idx.val = 1 := by omega rcases hi01 with hi0 | hi1 · simp only [hi0] at he simp only [Finset.mem_insert, Finset.mem_singleton] exact Or.inl he.symm · simp only [hi1] at he simp only [Finset.mem_insert, Finset.mem_singleton] exact Or.inr he.symm have hpair : ({ordinaryPrimeAt N 0, ordinaryPrimeAt N 1} : Finset ℕ).card ≤ 2 := by calc _ ≤ ({ordinaryPrimeAt N 1} : Finset ℕ).card+1 := Finset.card_insert_le _ _ _ = 2 := by simp exact (Finset.card_le_card hsub).trans hpair /-- A fixed two-coordinate facet bounds the third largest prime in every preimage of a nonexceptional value. Its margin is fixed and positive. -/ /- Original line 46335: Erdos416Proof.FordBadFacet.ordinary_second_le_growthCutoff_of_not_bad -/ theorem ordinary_second_le_growthCutoff_of_not_bad {x : ℝ} {m N : ℕ} (hT : 0 < logLog x) (hm : m ∈ totientsUpTo x) (hN : 0 < N) (hphi : N.totient = m) (hbad : m ∉ badFacetValues x 2 (1/1000)) : (ordinaryPrimeAt N 2 : ℝ) ≤ growthLargePrimeCutoff (logLog x) := by have hsum : (∑ idx : Fin 2, fordWeight (idx.val+1)* ordinaryPrimeCoordinate (logLog x) N (idx.val+1)) < 1+1/1000 := by apply lt_of_not_ge intro h exact hbad (Finset.mem_filter.mpr ⟨hm,N,hN,hphi,h⟩) rw [Fin.sum_univ_two] at hsum change fordWeight 1*ordinaryPrimeCoordinate (logLog x) N 1+ fordWeight 2*ordinaryPrimeCoordinate (logLog x) N 2 < 1+1/1000 at hsum have hanti := ordinaryPrimeCoordinate_antitone N hT.le (by decide : 1 ≤ 2) have hw : (9/7 : ℝ) ≤ fordWeight 1+fordWeight 2 := by have hid : fordWeight 1+fordWeight 2 = 3*Real.log 3-2 := by norm_num [fordWeight] ring rw [hid] linarith [log_three_lower_bound] have hnonneg : 0 ≤ ordinaryPrimeCoordinate (logLog x) N 2 := div_nonneg (le_max_left _ _) hT.le have hlow := mul_le_mul_of_nonneg_right hw hnonneg have hanti' := mul_le_mul_of_nonneg_left hanti (fordWeight_bounds (by decide : 1 ≤ 1)).1 have hcoord : ordinaryPrimeCoordinate (logLog x) N 2 < 4/5 := by nlinarith by_contra h have hq : growthLargePrimeCutoff (logLog x) ≤ (ordinaryPrimeAt N 2 : ℝ) := (lt_of_not_ge h).le have hH : 1 < growthLargePrimeCutoff (logLog x) := Real.one_lt_exp_iff.mpr (Real.exp_pos _) have hl := logLog_mono hH hq have hHlog : logLog (growthLargePrimeCutoff (logLog x)) = (4/5 : ℝ)*logLog x := by simp only [logLog,growthLargePrimeCutoff,Real.log_exp] rw [hHlog] at hl have hclip := le_max_right 0 (logLog (ordinaryPrimeAt N 2)) have hc : (4/5 : ℝ) ≤ ordinaryPrimeCoordinate (logLog x) N 2 := by change _ ≤ max 0 (logLog (ordinaryPrimeAt N 2))/logLog x apply (le_div_iff₀ hT).mpr exact hl.trans hclip linarith /-- Only the fixed two-coordinate facet, Ω, and large-square exceptions are needed to ensure a large top prime in every positive preimage. -/ /- Original line 46376: Erdos416Proof.FordBadFacet.ordinary_top_log_lower_outside_fixed_facet -/ theorem ordinary_top_log_lower_outside_fixed_facet : ∀ᶠ x : ℝ in atTop, ∀ m N : ℕ, m ∈ totientsUpTo x → Real.sqrt x ≤ (m : ℝ) → 0 < N → N.totient = m → m ∉ badFacetValues x 2 (1/1000) → m ∉ fiveLogOmegaTotients x → m ∉ largeSquareTotients x → (ordinaryPrimeAt N 0).Prime ∧ Real.log x/6 ≤ Real.log (ordinaryPrimeAt N 0) := by filter_upwards [ordinary_top_log_lower_of_growth_data, eventually_ge_atTop (9 : ℝ), fourth_log_cutoff_le_growthLargePrimeCutoff] with x htop hx hcut intro m N hm hlarge hN hphi hbad hΩ hSq have hT : 0 < logLog x := logLog_pos_of_three_le (by linarith) have hmdata := (mem_totientsUpTo (by linarith : 0 ≤ x)).mp hm have hm3 : 3 ≤ m := by have hs : (3 : ℝ) ≤ Real.sqrt x := Real.le_sqrt_of_sq_le (by norm_num; exact hx) exact_mod_cast hs.trans hlarge have hΩm : (ArithmeticFunction.cardFactors m : ℝ) ≤ 5*logLog (m : ℝ) := by by_contra h exact hΩ (Finset.mem_filter.mpr ⟨hm,hm3,lt_of_not_ge h⟩) have hΩx : (ArithmeticFunction.cardFactors m : ℝ) ≤ 5*logLog x := hΩm.trans (mul_le_mul_of_nonneg_left (logLog_mono (by exact_mod_cast (show 1 < m by omega)) hmdata.2.1) (by norm_num)) have hsqN : NoLargePrimeSquare N (Real.log x^4) := by intro q hq hlargeq hqd exact hSq (Finset.mem_filter.mpr ⟨hm,N,hN,hphi,q,hq,hlargeq,Or.inl hqd⟩) apply htop N hN (by simpa only [hphi] using hlarge) (by simpa only [hphi] using hΩx) (hsqN.mono hcut) exact large_prime_filter_card_le_two_of_second_bound hN (ordinary_second_le_growthCutoff_of_not_bad hT hm hN hphi hbad) end Erdos416Proof.FordBadFacet end /- Consolidated component: FixedFacetPruning.lean. -/ section open Filter Finset Asymptotics open scoped Classical Topology BigOperators namespace Erdos416Proof.FordBadFacet open FordRestricted /-- Every fixed facet family above the standard positive margin has vanishing size relative to the actual totient count. -/ /- Original line 46424: Erdos416Proof.FordBadFacet.fixed_badFacet_negligible_in_V -/ theorem fixed_badFacet_negligible_in_V (k : ℕ) {ω : ℝ} (hω : suffixMargin k ≤ ω) : (fun x : ℝ => ((badFacetValues x k ω).card : ℝ)) =o[atTop] V := by obtain ⟨C,H,hC,_hH,hbound⟩ := exists_uniform_badFacet_gaussian_density let D := C*Real.exp (-((k+1 : ℕ) : ℝ)^2) have hD : 0 < D := mul_pos hC (Real.exp_pos _) have hT : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop rw [isLittleO_iff] intro ε hε filter_upwards [eventually_ge_atTop (suffixCutoff H k), eventually_gt_atTop (1 : ℝ), hT.eventually_ge_atTop (max 1 (2*D/ε)), V_lower_bound_eventually] with x hcut hx hlarge hV have hx0 : 0 < x := by linarith have hlog : 0 < Real.log x := Real.log_pos hx have hT1 : 1 ≤ logLog x := (le_max_left _ _).trans hlarge have hTpos : 0 < logLog x := by linarith have hsmall : 2*D ≤ ε*(logLog x)^2 := by have hlinear := (div_le_iff₀ hε).mp ((le_max_right _ _).trans hlarge) have hsq : logLog x ≤ (logLog x)^2 := by nlinarith have hm := mul_le_mul_of_nonneg_left hsq hε.le nlinarith have hcard : ((badFacetValues x k ω).card : ℝ) ≤ D*(x/Real.log x)/(logLog x)^2 := by have hsub := (Nat.cast_le (α := ℝ)).mpr (Finset.card_le_card (badFacetValues_mono_margin (x := x) (k := k) hω)) apply (hsub.trans (hbound k x hcut)).trans_eq dsimp [Erdos416Proof.FordBadFacet.positiveLogLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_bottom, Erdos416Proof.FordBadFacet.reversedFacetLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_succ, Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.FordRestricted.suffixCutoff_log3, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, D] ring have hc := (le_div_iff₀ (pow_pos hTpos 2)).mp hcard have hV' : x/Real.log x ≤ 2*V x := by have hid : x/Real.log x = 2*(x/(2*Real.log x)) := by ring rw [hid] exact mul_le_mul_of_nonneg_left hV (by norm_num) have hmul := mul_le_mul_of_nonneg_left hV' hD.le have he := mul_le_mul_of_nonneg_right hsmall (V_nonneg x) have hfinal : ((badFacetValues x k ω).card : ℝ) ≤ ε*V x := by apply (mul_le_mul_iff_of_pos_right (pow_pos hTpos 2)).mp nlinarith simpa only [Real.norm_eq_abs, Nat.abs_cast, abs_of_nonneg (V_nonneg x)] using hfinal /- Original line 46464: Erdos416Proof.FordBadFacet.fixed_two_badFacet_negligible_in_V -/ theorem fixed_two_badFacet_negligible_in_V : (fun x : ℝ => ((badFacetValues x 2 (1/1000)).card : ℝ)) =o[atTop] V := by apply fixed_badFacet_negligible_in_V have he : Real.exp (-(2 : ℝ)/40) ≤ 1 := Real.exp_le_one_iff.mpr (by norm_num) unfold suffixMargin nlinarith /-- The absolute suffix cutoff is eventually below the original endpoint uniformly through its optimal dimension. -/ /- Original line 46474: Erdos416Proof.FordBadFacet.suffixCutoff_below_endpoint_optimalDimension -/ theorem suffixCutoff_below_endpoint_optimalDimension (H : ℝ) : ∀ᶠ x : ℝ in atTop, ∀ k : ℕ, k ≤ FordScale.optimalDimension (logLog x) → suffixCutoff H k ≤ x := by have hT : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [hT.eventually_ge_atTop (Real.exp 1), (Real.tendsto_log_atTop.comp hT).eventually_ge_atTop (15*H/11), eventually_gt_atTop (1 : ℝ)] with x hTlarge hloglarge hx dsimp only [Function.comp_def] at hloglarge intro k hk have hdim : (FordScale.optimalDimension (logLog x) : ℝ) ≤ 4*Real.log (logLog x) := by simpa only [FordScale.coreDimension,Nat.sub_zero] using FordScale.coreDimension_le_four_log 0 hTlarge have hkR : (k : ℝ) ≤ FordScale.optimalDimension (logLog x) := by exact_mod_cast hk have hexp : Real.exp ((k : ℝ)/15+H) ≤ logLog x := by calc _ ≤ Real.exp (Real.log (logLog x)) := Real.exp_le_exp.mpr (by linarith) _ = _ := Real.exp_log ((Real.exp_pos 1).trans_le hTlarge) calc _ ≤ Real.exp (Real.exp (logLog x)) := Real.exp_le_exp.mpr (Real.exp_le_exp.mpr hexp) _ = x := by change Real.exp (Real.exp (Real.log (Real.log x))) = x rw [Real.exp_log (Real.log_pos hx),Real.exp_log (by linarith : 0 < x)] /-- The varying outer-facet family also has the integrable density, despite its margin shrinking with the optimal dimension. -/ /- Original line 46501: Erdos416Proof.FordBadFacet.exists_optimal_outer_badFacet_density -/ theorem exists_optimal_outer_badFacet_density : ∃ C : ℝ, 0 < C ∧ ∀ᶠ x : ℝ in atTop, ((badFacetValues x (FordScale.optimalDimension (logLog x)) (suffixMargin (FordScale.optimalDimension (logLog x)))).card : ℝ) ≤ C*(x/(Real.log x*(logLog x)^2)) := by obtain ⟨C,H,hC,_hH,hbound⟩ := exists_uniform_badFacet_gaussian_density refine ⟨C,hC,?_⟩ filter_upwards [suffixCutoff_below_endpoint_optimalDimension H, eventually_gt_atTop (1 : ℝ)] with x hcut hx have h := hbound _ x (hcut _ le_rfl) have he : Real.exp (-((FordScale.optimalDimension (logLog x)+1 : ℕ) : ℝ)^2) ≤ 1 := Real.exp_le_one_iff.mpr (by nlinarith [sq_nonneg ((FordScale.optimalDimension (logLog x)+1 : ℕ) : ℝ)]) have hnonneg : 0 ≤ x/(Real.log x*(logLog x)^2) := div_nonneg (by linarith) (mul_nonneg (Real.log_pos hx).le (sq_nonneg _)) exact h.trans (by simpa only [mul_one] using mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left he hC.le) hnonneg) /- Original line 46518: Erdos416Proof.FordBadFacet.negligible_in_V_of_logLog_sq_density -/ theorem negligible_in_V_of_logLog_sq_density {f : ℝ → ℝ} {C : ℝ} (hf : ∀ x, 0 ≤ f x) (hC : 0 < C) (hbound : ∀ᶠ x : ℝ in atTop, f x ≤ C*(x/(Real.log x*(logLog x)^2))) : f =o[atTop] V := by have hT : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop rw [isLittleO_iff] intro ε hε filter_upwards [hbound, V_lower_bound_eventually, eventually_gt_atTop (1 : ℝ), hT.eventually_ge_atTop (max 1 (2*C/ε))] with x hb hV hx hlarge have hlog : 0 < Real.log x := Real.log_pos hx have hT1 : 1 ≤ logLog x := (le_max_left _ _).trans hlarge have hTpos : 0 < logLog x := by linarith have hsmall : 2*C ≤ ε*(logLog x)^2 := by have hlinear := (div_le_iff₀ hε).mp ((le_max_right _ _).trans hlarge) have hsq : logLog x ≤ (logLog x)^2 := by nlinarith have hm := mul_le_mul_of_nonneg_left hsq hε.le nlinarith have hc : f x*(logLog x)^2 ≤ C*(x/Real.log x) := by apply (le_div_iff₀ (pow_pos hTpos 2)).mp exact hb.trans_eq (by ring) have hV' : x/Real.log x ≤ 2*V x := by have hid : x/Real.log x = 2*(x/(2*Real.log x)) := by ring rw [hid] exact mul_le_mul_of_nonneg_left hV (by norm_num) have hmul := mul_le_mul_of_nonneg_left hV' hC.le have he := mul_le_mul_of_nonneg_right hsmall (V_nonneg x) have hfinal : f x ≤ ε*V x := by apply (mul_le_mul_iff_of_pos_right (pow_pos hTpos 2)).mp nlinarith simpa only [Real.norm_eq_abs, abs_of_nonneg (hf x), abs_of_nonneg (V_nonneg x)] using hfinal /- Original line 46550: Erdos416Proof.FordBadFacet.optimal_outer_badFacet_negligible_in_V -/ theorem optimal_outer_badFacet_negligible_in_V : (fun x : ℝ => ((badFacetValues x (FordScale.optimalDimension (logLog x)) (suffixMargin (FordScale.optimalDimension (logLog x)))).card : ℝ)) =o[atTop] V := by obtain ⟨C,hC,hbound⟩ := exists_optimal_outer_badFacet_density exact negligible_in_V_of_logLog_sq_density (fun _ => Nat.cast_nonneg _) hC hbound end Erdos416Proof.FordBadFacet end /- Consolidated component: SuffixDensity.lean. -/ section open Filter Asymptotics Finset open scoped Classical Topology BigOperators namespace Erdos416Proof.FordBadFacet open FordRestricted /-- The provenance predicate is independent of the counting endpoint. -/ /- Original line 46575: Erdos416Proof.FordBadFacet.IsFirstFailedSuffixValue -/ def IsFirstFailedSuffixValue (T : ℝ) (A L j m : ℕ) : Prop := ∃ N : ℕ, 0 < N ∧ (ordinarySuffix N j).totient = m ∧ FirstFailedRow L (FordGeometry.expandedParameter A) (ordinaryPrimeCoordinate T N) j /- Original line 46579: Erdos416Proof.FordBadFacet.firstFailedSuffixValues -/ noncomputable def firstFailedSuffixValues (y T : ℝ) (A L j : ℕ) : Finset ℕ := (totientsUpTo y).filter (IsFirstFailedSuffixValue T A L j) /- Original line 46582: Erdos416Proof.FordBadFacet.upperSmoothPreimageValues -/ noncomputable def upperSmoothPreimageValues (y z : ℝ) : Finset ℕ := (totientsUpTo y).filter (fun m => y^(4/5 : ℝ) < (m : ℝ) ∧ ∃ N : ℕ, 0 < N ∧ N.totient = m ∧ N ∈ Nat.factoredNumbers (Nat.primesLE ⌊z⌋₊)) /- Original line 46586: Erdos416Proof.FordBadFacet.totientsUpTo_card_le_endpoint -/ theorem totientsUpTo_card_le_endpoint {y : ℝ} (hy : 0 ≤ y) : ((totientsUpTo y).card : ℝ) ≤ y := by have hc : (totientsUpTo y).card ≤ ⌊y⌋₊ := by apply le_trans (Finset.card_filter_le _ _) simp only [Nat.card_Icc] omega exact (Nat.cast_le.mpr hc).trans (Nat.floor_le hy) /- Original line 46594: Erdos416Proof.FordBadFacet.exists_upperSmoothPreimageValues_count_bound -/ theorem exists_upperSmoothPreimageValues_count_bound : ∃ C : ℝ, 0 < C ∧ ∀ y : ℝ, 1 < y → 1 ≤ logLog y → Real.exp 20 ≤ y^(1/logLog y) → ((upperSmoothPreimageValues y (y^(1/logLog y))).card : ℝ) ≤ C*y/(Real.log y)^3 := by obtain ⟨C, hC, hbound⟩ := exists_smooth_preimage_value_bounds refine ⟨C, hC, ?_⟩ intro y hy hU hz have hy0 : 0 < y := by linarith have hlog : 0 < Real.log y := Real.log_pos hy have hUpos : 0 < logLog y := by linarith let z := y^(1/logLog y) have hlogz : Real.log z = (1/logLog y)*Real.log y := Real.log_rpow hy0 _ have hlogzy : Real.log z ≤ Real.log y := by rw [hlogz] have h : Real.log y/logLog y ≤ Real.log y := (div_le_iff₀ hUpos).mpr (by nlinarith) simpa only [one_div_mul_eq_div] using h have hweight : (y^(4/5 : ℝ))^(5/Real.log z) = (Real.log y)^4 := by rw [Real.rpow_def_of_pos (Real.rpow_pos_of_pos hy0 _), Real.log_rpow hy0] have he : ((4/5 : ℝ)*Real.log y)*(5/Real.log z) = 4*Real.log (Real.log y) := by rw [hlogz] change ((4/5 : ℝ)*Real.log y)*(5/((1/logLog y)*Real.log y)) = 4*logLog y field_simp [hlog.ne', hUpos.ne'] rw [he] simpa only [Real.exp_log hlog, Nat.cast_ofNat] using Real.exp_nat_mul (Real.log (Real.log y)) 4 have hb := (hbound z hz (y^(4/5 : ℝ)) y (Real.rpow_pos_of_pos hy0 _) hy0.le (upperSmoothPreimageValues y z) (fun m hm => (Finset.mem_filter.mp hm).2.2) (fun m hm => (Finset.mem_filter.mp hm).2.1.le) (fun m hm => ((mem_totientsUpTo hy0.le).mp (Finset.mem_filter.mp hm).1).2.1)).2 rw [hweight] at hb have hb' := hb.trans (mul_le_mul_of_nonneg_left hlogzy (mul_nonneg hC.le hy0.le)) apply (le_div_iff₀ (pow_pos hlog 3)).mpr apply (mul_le_mul_iff_of_pos_right hlog).mp dsimp [Erdos416Proof.FordBadFacet.positiveLogLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_bottom, Erdos416Proof.FordBadFacet.reversedFacetLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_succ, Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.FordRestricted.suffixCutoff_log3, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, z] at hb' ⊢ nlinarith /- Original line 46630: Erdos416Proof.FordBadFacet.firstFailedSuffixValues_subset_small_smooth_bad -/ theorem firstFailedSuffixValues_subset_small_smooth_bad {y T : ℝ} {A L j : ℕ} (hy : 1 < y) (hU : 0 < logLog y) (hT : 0 < T) (hLA : L ≤ A) (hj : 0 < j) (hbudget : (1+suffixMargin (A-j))*(Real.log (logLog y)/logLog y) ≤ suffixMargin (A-j)/2) : firstFailedSuffixValues y T A L j ⊆ totientsUpTo (y^(4/5 : ℝ)) ∪ upperSmoothPreimageValues y (y^(1/logLog y)) ∪ badFacetValues y (A-j+40) (suffixMargin (A-j+40)) := by intro m hm obtain ⟨hmV, N, hN, hNm, hfirst⟩ := Finset.mem_filter.mp hm have hmdata := (mem_totientsUpTo (by linarith : 0 ≤ y)).mp hmV by_cases hsmallvalue : (m : ℝ) ≤ y^(4/5 : ℝ) · exact Finset.mem_union.mpr (Or.inl (Finset.mem_union.mpr (Or.inl ((mem_totientsUpTo (Real.rpow_nonneg (by linarith) _)).mpr ⟨hmdata.1, hsmallvalue, hmdata.2.2⟩)))) by_cases hsmallprime : (ordinaryPrimeAt N j : ℝ) ≤ y^(1/logLog y) · exact Finset.mem_union.mpr (Or.inl (Finset.mem_union.mpr (Or.inr (Finset.mem_filter.mpr ⟨hmV, lt_of_not_ge hsmallvalue, ordinarySuffix N j, ordinarySuffix_pos N j, hNm, ordinarySuffix_factored_of_boundary_le hsmallprime⟩)))) · apply Finset.mem_union.mpr right rw [← hNm] exact actual_expanded_firstFailed_suffix_mem_uniform_family hLA hfirst hj hT hy hU (by simpa only [hNm] using hmdata.2.1) (lt_of_not_ge hsmallprime).le hbudget /- Original line 46653: Erdos416Proof.FordBadFacet.eventually_four_fifths_le_log_cube -/ theorem eventually_four_fifths_le_log_cube : ∀ᶠ y : ℝ in atTop, y^(4/5 : ℝ) ≤ y/(Real.log y)^3 := by filter_upwards [eventually_gt_atTop (1 : ℝ), Real.tendsto_log_atTop.eventually (eventually_const_add_log_le_linear 0 (1/15) (by norm_num))] with y hy hsmall have hy0 : 0 < y := by linarith have hlog : 0 < Real.log y := Real.log_pos hy apply (le_div_iff₀ (pow_pos hlog 3)).mpr have hpow : (Real.log y)^3 = Real.exp (3*Real.log (Real.log y)) := by simpa only [Real.exp_log hlog, Nat.cast_ofNat] using (Real.exp_nat_mul (Real.log (Real.log y)) 3).symm rw [Real.rpow_def_of_pos hy0, hpow, ← Real.exp_add] calc _ ≤ Real.exp (Real.log y) := Real.exp_le_exp.mpr (by linarith [hsmall.2]) _ = _ := Real.exp_log hy0 /- Original line 46668: Erdos416Proof.FordBadFacet.exists_eventually_firstFailedSuffixValues_count_bound -/ theorem exists_eventually_firstFailedSuffixValues_count_bound : ∃ C : ℝ, 0 < C ∧ ∀ᶠ y : ℝ in atTop, ∀ (T : ℝ) (A L j : ℕ), 1 < y → 1 ≤ logLog y → Real.exp 20 ≤ y^(1/logLog y) → 0 < T → L ≤ A → 0 < j → (1+suffixMargin (A-j))*(Real.log (logLog y)/logLog y) ≤ suffixMargin (A-j)/2 → ((firstFailedSuffixValues y T A L j).card : ℝ) ≤ C*y/(Real.log y)^3+ (badFacetValues y (A-j+40) (suffixMargin (A-j+40))).card := by obtain ⟨C, hC, hbound⟩ := exists_upperSmoothPreimageValues_count_bound refine ⟨1+C, by positivity, ?_⟩ filter_upwards [eventually_four_fifths_le_log_cube] with y hsmall intro T A L j hy hU hz hT hLA hj hbudget have hc := Finset.card_le_card (firstFailedSuffixValues_subset_small_smooth_bad hy (by linarith) hT hLA hj hbudget) have hc' : (firstFailedSuffixValues y T A L j).card ≤ (totientsUpTo (y^(4/5 : ℝ))).card+(upperSmoothPreimageValues y (y^(1/logLog y))).card+ (badFacetValues y (A-j+40) (suffixMargin (A-j+40))).card := hc.trans ((Finset.card_union_le _ _).trans (Nat.add_le_add_right (Finset.card_union_le _ _) _)) have hreal := (Nat.cast_le (α := ℝ)).mpr hc' push_cast at hreal have hsmall' := (totientsUpTo_card_le_endpoint (Real.rpow_nonneg (by linarith) _)).trans hsmall have hsmooth := hbound y hy hU hz calc _ ≤ _ := hreal _ ≤ y/(Real.log y)^3+C*y/(Real.log y)^3+ (badFacetValues y (A-j+40) (suffixMargin (A-j+40))).card := add_le_add (add_le_add hsmall' hsmooth) le_rfl _ = _ := by ring /- Original line 46697: Erdos416Proof.FordBadFacet.eventually_smooth_cutoff_admissible -/ theorem eventually_smooth_cutoff_admissible : ∀ᶠ y : ℝ in atTop, 1 < y ∧ 20 ≤ logLog y ∧ Real.exp 20 ≤ y^(1/logLog y) := by have hTend : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [eventually_gt_atTop (1 : ℝ), hTend.eventually_ge_atTop 20, hTend.eventually (eventually_const_add_log_le_linear (Real.log 20) 1 (by norm_num))] with y hy hT hbudget refine ⟨hy, hT, ?_⟩ have hy0 : 0 < y := by linarith have hTpos : 0 < logLog y := by linarith have heT : Real.exp (logLog y) = Real.log y := Real.exp_log (Real.log_pos hy) have h20 : 20*logLog y ≤ Real.log y := by have h := Real.exp_le_exp.mpr hbudget.2 simpa only [Real.exp_add, Real.exp_log (by norm_num : (0 : ℝ) < 20), Real.exp_log hTpos, one_mul, heT] using h rw [Real.rpow_def_of_pos hy0] apply Real.exp_le_exp.mpr have h := (le_div_iff₀ hTpos).mpr h20 simpa only [mul_one_div] using h /- Original line 46717: Erdos416Proof.FordBadFacet.log_le_half_of_pos -/ theorem log_le_half_of_pos {U : ℝ} (hU : 0 < U) : Real.log U ≤ U/2 := by have h := Real.log_le_sub_one_of_pos (show 0 < U/2 by positivity) rw [Real.log_div hU.ne' (by norm_num : (2 : ℝ) ≠ 0)] at h have htwo := Real.log_le_sub_one_of_pos (by norm_num : (0 : ℝ) < 2) nlinarith /- Original line 46723: Erdos416Proof.FordBadFacet.log_cube_le_gaussian_density -/ theorem log_cube_le_gaussian_density {y N : ℝ} (hy : 1 < y) (hU : 0 < logLog y) (hN : N^2 ≤ logLog y) : y/(Real.log y)^3 ≤ Real.exp (-N^2)*(y/(Real.log y*(logLog y)^2)) := by have hlog : 0 < Real.log y := Real.log_pos hy have heT : Real.exp (logLog y) = Real.log y := Real.exp_log hlog have he : Real.exp (-2*logLog y) ≤ Real.exp (-N^2)/(logLog y)^2 := by calc _ ≤ Real.exp (-N^2-2*Real.log (logLog y)) := Real.exp_le_exp.mpr (by linarith [log_le_half_of_pos hU]) _ = _ := by rw [Real.exp_sub, show (2 : ℝ) = ((2 : ℕ) : ℝ) by norm_num, Real.exp_nat_mul, Real.exp_log hU] have hexact : y/(Real.log y)^3 = (y/Real.log y)*Real.exp (-2*logLog y) := by rw [show -2*logLog y = -(2*logLog y) by ring, Real.exp_neg, show (2 : ℝ) = ((2 : ℕ) : ℝ) by norm_num, Real.exp_nat_mul, heT] ring rw [hexact] calc _ ≤ (y/Real.log y)*(Real.exp (-N^2)/(logLog y)^2) := mul_le_mul_of_nonneg_left he (div_nonneg (by linarith) hlog.le) _ = _ := by ring /- Original line 46744: Erdos416Proof.FordBadFacet.exists_uniform_suffix_normalization_budget -/ theorem exists_uniform_suffix_normalization_budget : ∃ H : ℝ, 0 ≤ H ∧ ∀ (a : ℕ) (U : ℝ), 0 < U → Real.exp (((a+40 : ℕ) : ℝ)/15+H) ≤ U → (1+suffixMargin a)*(Real.log U/U) ≤ suffixMargin a/2 := by obtain ⟨H, hH, hbound⟩ := exists_uniform_suffix_log_budget 4 0 (by norm_num) (by norm_num) 0 0 refine ⟨H, hH, ?_⟩ intro a U hU hcut have hmajor : 4*Real.log U ≤ suffixMargin (a+40)^2*U := by simpa only [pow_zero, mul_one, zero_add] using hbound (a+40) U hcut have hω := suffixMargin_pos a have hω1 := suffixMargin_le_one a have hω' := suffixMargin_pos (a+40) have hω'1 := suffixMargin_le_one (a+40) have hhalf := suffixMargin_add_forty_le_half a have hsq : suffixMargin (a+40)^2 ≤ suffixMargin a := by nlinarith have hmajor' := hmajor.trans (mul_le_mul_of_nonneg_right hsq hU.le) by_cases hlog : 0 ≤ Real.log U · rw [← mul_div_assoc] apply (div_le_iff₀ hU).mpr nlinarith [mul_le_mul_of_nonneg_right hω1 hlog] · exact (mul_nonpos_of_nonneg_of_nonpos (by linarith) (div_nonpos_of_nonpos_of_nonneg (le_of_not_ge hlog) hU.le)).trans (by positivity) /-- The cumulative actual suffix family has an integrable Gaussian density. Only the original failed-row provenance appears in the family definition. -/ /- Original line 46769: Erdos416Proof.FordBadFacet.exists_uniform_firstFailedSuffixValues_density -/ theorem exists_uniform_firstFailedSuffixValues_density : ∃ C H : ℝ, 0 < C ∧ 0 ≤ H ∧ ∀ (y T : ℝ) (A L j : ℕ), 0 < T → L ≤ A → 0 < j → suffixCutoff H (A-j+40) ≤ y → ((firstFailedSuffixValues y T A L j).card : ℝ) ≤ C*Real.exp (-((A-j+40+1 : ℕ) : ℝ)^2)*(y/(Real.log y*(logLog y)^2)) := by obtain ⟨Cs, hCs, hs⟩ := exists_eventually_firstFailedSuffixValues_count_bound obtain ⟨Cb, Hb, hCb, hHb, hb⟩ := exists_uniform_badFacet_gaussian_density obtain ⟨Hn, hHn, hn⟩ := exists_uniform_suffix_normalization_budget obtain ⟨Hp, hHp, hp⟩ := exists_suffix_margin_dominates_polylog_above 1 (by norm_num) 2 0 let H₀ := max Hb (max Hn Hp) have hHbH : Hb ≤ H₀ := le_max_left _ _ have hHnH : Hn ≤ H₀ := (le_max_left _ _).trans (le_max_right _ _) have hHpH : Hp ≤ H₀ := (le_max_right _ _).trans (le_max_right _ _) obtain ⟨H, hHH, hH, hglobal⟩ := suffixCutoff_absorb_eventual (hs.and eventually_smooth_cutoff_admissible) H₀ refine ⟨Cs+Cb, H, by positivity, hH, ?_⟩ intro y T A L j hT hLA hj hcut obtain ⟨hs', hy, hU, hz⟩ := hglobal (A-j+40) y hcut have hUpos : 0 < logLog y := by linarith have hcutT := suffixCutoff_logLog_lower hcut have hnormal := hn (A-j) (logLog y) hUpos ((Real.exp_le_exp.mpr (by linarith [hHnH.trans hHH])).trans hcutT) have hpoly : ((A-j+40+1 : ℕ) : ℝ)^2 ≤ suffixMargin (A-j+40)^2*logLog y := by have h := hp (A-j+40) (logLog y) ((Real.exp_le_exp.mpr (by linarith [hHpH.trans hHH])).trans hcutT) simpa only [pow_zero, mul_one, one_mul, Nat.cast_add, Nat.cast_one] using h have hω := suffixMargin_pos (A-j+40) have hω1 := suffixMargin_le_one (A-j+40) have hN : ((A-j+40+1 : ℕ) : ℝ)^2 ≤ logLog y := by have hsquare : suffixMargin (A-j+40)^2 ≤ 1 := by nlinarith have h := mul_le_mul_of_nonneg_right hsquare hUpos.le exact hpoly.trans (by simpa only [one_mul] using h) have hsmooth := log_cube_le_gaussian_density hy hUpos hN have hactual := hs' T A L j hy (by linarith) hz hT hLA hj hnormal have hbad := hb (A-j+40) y ((suffixCutoff_mono_parameters (hHbH.trans hHH) (le_refl _)).trans hcut) have hsmooth' := mul_le_mul_of_nonneg_left hsmooth hCs.le calc _ ≤ _ := hactual _ ≤ Cs*(y/(Real.log y)^3)+ Cb*Real.exp (-((A-j+40+1 : ℕ) : ℝ)^2)*(y/(Real.log y*(logLog y)^2)) := add_le_add (le_of_eq (by ring)) hbad _ ≤ Cs*(Real.exp (-((A-j+40+1 : ℕ) : ℝ)^2)*(y/(Real.log y*(logLog y)^2)))+ Cb*Real.exp (-((A-j+40+1 : ℕ) : ℝ)^2)*(y/(Real.log y*(logLog y)^2)) := add_le_add hsmooth' le_rfl _ = _ := by ring /-- Finite Abel summation for suffix values carrying the actual original first-failed-row provenance, with no assumed counting bound. -/ /- Original line 46818: Erdos416Proof.FordBadFacet.exists_uniform_firstFailedSuffix_reciprocal_tail -/ theorem exists_uniform_firstFailedSuffix_reciprocal_tail : ∃ C H : ℝ, 0 < C ∧ 0 ≤ H ∧ ∀ (T u z : ℝ) (A L j : ℕ) (F : Finset ℕ), 0 < T → L ≤ A → 0 < j → suffixCutoff H (A-j+40) ≤ u → u ≤ z → (∀ m ∈ F, IsFirstFailedSuffixValue T A L j m) → (∀ m ∈ F, u ≤ (m : ℝ) ∧ (m : ℝ) ≤ z) → (∑ m ∈ F, (1 : ℝ)/m) ≤ 2*C*Real.exp (-((A-j+40+1 : ℕ) : ℝ)^2)/logLog u := by obtain ⟨C, H, hC, hH, hcount⟩ := exists_uniform_firstFailedSuffixValues_density refine ⟨C, H, hC, hH, ?_⟩ intro T u z A L j F hT hLA hj hcut huz hF hFbounds have hcutlarge : Real.exp (Real.exp 1) ≤ suffixCutoff H (A-j+40) := by apply Real.exp_le_exp.mpr apply Real.exp_le_exp.mpr apply Real.one_le_exp_iff.mpr have hk : (0 : ℝ) ≤ ((A-j+40 : ℕ) : ℝ) := Nat.cast_nonneg _ linarith have hu : Real.exp (Real.exp 1) ≤ u := hcutlarge.trans hcut have hu0 : 0 < u := (Real.exp_pos _).trans_le hu have hdensity (t : ℝ) (hut : u ≤ t) (htz : t ≤ z) : finiteWeightedCountBelow F id t ≤ (C*Real.exp (-((A-j+40+1 : ℕ) : ℝ)^2))*(t/(Real.log t*(logLog t)^2)) := by apply le_trans _ (hcount t T A L j hT hLA hj (hcut.trans hut)) apply Nat.cast_le.mpr apply Finset.card_le_card intro m hm obtain ⟨hmF, hmt⟩ := Finset.mem_filter.mp hm obtain ⟨N, hN, hNm, hfirst⟩ := hF m hmF have hpre := ordinarySuffix_pos N j refine Finset.mem_filter.mpr ⟨(mem_totientsUpTo (hu0.le.trans hut)).mpr ?_, hF m hmF⟩ exact ⟨by rw [← hNm]; exact Nat.totient_pos.mpr hpre, hmt, ordinarySuffix N j, hpre, hNm⟩ have h := finite_weighted_reciprocal_tail F id hu huz (mul_nonneg hC.le (Real.exp_pos _).le) hFbounds hdensity simpa only [id_eq, mul_assoc] using h /-- Bounded distinct totient values require no separate prime-support premise. The finite initial facet lengths are absorbed into one multiplicative constant. -/ /- Original line 46854: Erdos416Proof.FordBadFacet.exists_all_small_totient_reciprocal_at_suffixCutoff -/ theorem exists_all_small_totient_reciprocal_at_suffixCutoff (H : ℝ) : ∃ D B : ℝ, 0 < D ∧ 0 ≤ B ∧ ∀ k : ℕ, (∑ m ∈ totientsUpTo (suffixCutoff H k), (1 : ℝ)/m) ≤ D*Real.exp ((16/225 : ℝ)*(k : ℝ)^2+B*(k : ℝ)) := by let B : ℝ := (32/15)*|H|+16*H^2 have hB : 0 ≤ B := by dsimp [Erdos416Proof.FordRestricted.suffixCutoff_log3, B]; positivity have hevent : ∀ᶠ k : ℕ in atTop, (∑ m ∈ totientsUpTo (suffixCutoff H k), (1 : ℝ)/m) ≤ Real.exp ((16/225 : ℝ)*(k : ℝ)^2+B*(k : ℝ)) := by filter_upwards [restricted_reciprocal_at_suffixCutoff H] with k hk apply hk · intro n hn have hd := (mem_totientsUpTo (Real.exp_pos _).le).mp hn exact factored_primesLE_of_positive_le hd.1 hd.2.1 · intro n hn exact ((mem_totientsUpTo (Real.exp_pos _).le).mp hn).2.2 obtain ⟨k₀, hk₀⟩ := eventually_atTop.mp hevent let f : ℕ → ℝ := fun k => ∑ m ∈ totientsUpTo (suffixCutoff H k), (1 : ℝ)/m have hf (k : ℕ) : 0 ≤ f k := Finset.sum_nonneg (fun m _ => by positivity) let D : ℝ := 1+∑ k ∈ Finset.range k₀, f k have hD : 1 ≤ D := by dsimp [Erdos416Proof.FordRestricted.suffixCutoff_log3, D]; exact le_add_of_nonneg_right (Finset.sum_nonneg fun k _ => hf k) refine ⟨D, B, by linarith, hB, ?_⟩ intro k have he1 : 1 ≤ Real.exp ((16/225 : ℝ)*(k : ℝ)^2+B*(k : ℝ)) := Real.one_le_exp_iff.mpr (by positivity) by_cases hk : k₀ ≤ k · exact (hk₀ k hk).trans (le_mul_of_one_le_left (Real.exp_pos _).le hD) · have hsum := Finset.single_le_sum (fun idx _ => hf idx) (Finset.mem_range.mpr (by omega : k < k₀)) have hfD : f k ≤ D := by dsimp [Erdos416Proof.FordRestricted.suffixCutoff_log3, D]; linarith exact hfD.trans (le_mul_of_one_le_right (by linarith : 0 ≤ D) he1) /-- The full reciprocal mass of actual first-failed suffix values, including all values below the analytic cutoff. The quadratic coefficient remains `16/225 < 1/8`, as required by the Gaussian prefix estimate. -/ /- Original line 46888: Erdos416Proof.FordBadFacet.exists_firstFailedSuffix_reciprocal_mass_bound -/ theorem exists_firstFailedSuffix_reciprocal_mass_bound : ∃ C B : ℝ, 0 < C ∧ 0 ≤ B ∧ ∀ (T : ℝ) (A L j : ℕ) (F : Finset ℕ), 0 < T → L ≤ A → 0 < j → (∀ m ∈ F, IsFirstFailedSuffixValue T A L j m) → (∑ m ∈ F, (1 : ℝ)/m) ≤ C*Real.exp ((16/225 : ℝ)*((A-j+40 : ℕ) : ℝ)^2+B*((A-j+40 : ℕ) : ℝ)) := by obtain ⟨C, H, hC, hH, htail⟩ := exists_uniform_firstFailedSuffix_reciprocal_tail obtain ⟨D, B, hD, hB, hsmall⟩ := exists_all_small_totient_reciprocal_at_suffixCutoff H refine ⟨D+2*C, B, by positivity, hB, ?_⟩ intro T A L j F hT hLA hj hF let k := A-j+40 let u := suffixCutoff H k let z := max u (∑ m ∈ F, (m : ℝ)) let Fsmall : Finset ℕ := F.filter (fun m : ℕ => (m : ℝ) ≤ u) let Fbig : Finset ℕ := F.filter (fun m : ℕ => ¬(m : ℝ) ≤ u) have hu0 : 0 < u := Real.exp_pos _ have hsmallset : Fsmall ⊆ totientsUpTo u := by intro m hm obtain ⟨hmF, hmu⟩ := Finset.mem_filter.mp hm obtain ⟨N, hN, hNm, hfirst⟩ := hF m hmF have hpre := ordinarySuffix_pos N j exact (mem_totientsUpTo hu0.le).mpr ⟨by rw [← hNm]; exact Nat.totient_pos.mpr hpre, hmu, ordinarySuffix N j, hpre, hNm⟩ have hsmall' : (∑ m ∈ Fsmall, (1 : ℝ)/m) ≤ D*Real.exp ((16/225 : ℝ)*(k : ℝ)^2+B*(k : ℝ)) := by apply (Finset.sum_le_sum_of_subset_of_nonneg hsmallset (fun m _ _ => by positivity)).trans (hsmall k) have hbig := htail T u z A L j Fbig hT hLA hj le_rfl (le_max_left _ _) (fun m hm => hF m (Finset.mem_filter.mp hm).1) (by intro m hm obtain ⟨hmF, hmu⟩ := Finset.mem_filter.mp hm refine ⟨(lt_of_not_ge hmu).le, ?_⟩ exact (Finset.single_le_sum (fun idx _ => Nat.cast_nonneg idx) hmF).trans (le_max_right _ _)) have hU : 1 ≤ logLog u := by change 1 ≤ logLog (suffixCutoff H k) simp only [suffixCutoff, logLog, Real.log_exp] apply Real.one_le_exp_iff.mpr have hk : (0 : ℝ) ≤ k := Nat.cast_nonneg k linarith have he : Real.exp (-((A-j+40+1 : ℕ) : ℝ)^2) ≤ 1 := Real.exp_le_one_iff.mpr (by nlinarith [sq_nonneg (((A-j+40+1 : ℕ) : ℝ))]) have hbig' : (∑ m ∈ Fbig, (1 : ℝ)/m) ≤ 2*C := by apply hbig.trans apply (div_le_iff₀ (by linarith : 0 < logLog u)).mpr have h₁ := mul_le_mul_of_nonneg_left he (by positivity : 0 ≤ 2*C) have h₂ := mul_le_mul_of_nonneg_left hU (by positivity : 0 ≤ 2*C) linarith have hsplit : (∑ m ∈ F, (1 : ℝ)/m) = (∑ m ∈ Fsmall, (1 : ℝ)/m)+(∑ m ∈ Fbig, (1 : ℝ)/m) := (Finset.sum_filter_add_sum_filter_not F (fun m => (m : ℝ) ≤ u) (fun m => (1 : ℝ)/m)).symm have hP : 1 ≤ Real.exp ((16/225 : ℝ)*(k : ℝ)^2+B*(k : ℝ)) := Real.one_le_exp_iff.mpr (by positivity) rw [hsplit] change _ ≤ (D+2*C)*Real.exp ((16/225 : ℝ)*(k : ℝ)^2+B*(k : ℝ)) calc _ ≤ D*Real.exp ((16/225 : ℝ)*(k : ℝ)^2+B*(k : ℝ))+2*C := add_le_add hsmall' hbig' _ ≤ D*Real.exp ((16/225 : ℝ)*(k : ℝ)^2+B*(k : ℝ))+ 2*C*Real.exp ((16/225 : ℝ)*(k : ℝ)^2+B*(k : ℝ)) := add_le_add le_rfl (by simpa only [mul_one] using mul_le_mul_of_nonneg_left hP (by positivity : 0 ≤ 2*C)) _ = _ := by ring /-- Recentring the harmless margin-padding shift changes only the linear coefficient and the fixed constant. -/ /- Original line 46952: Erdos416Proof.FordBadFacet.exists_firstFailedSuffix_reciprocal_mass_unshifted -/ theorem exists_firstFailedSuffix_reciprocal_mass_unshifted : ∃ C B : ℝ, 0 < C ∧ 0 ≤ B ∧ ∀ (T : ℝ) (A L j : ℕ) (F : Finset ℕ), 0 < T → L ≤ A → 0 < j → (∀ m ∈ F, IsFirstFailedSuffixValue T A L j m) → (∑ m ∈ F, (1 : ℝ)/m) ≤ C*Real.exp ((16/225 : ℝ)*((A-j : ℕ) : ℝ)^2+B*((A-j : ℕ) : ℝ)) := by obtain ⟨C, B, hC, hB, hbound⟩ := exists_firstFailedSuffix_reciprocal_mass_bound refine ⟨C*Real.exp ((16/225 : ℝ)*40^2+40*B), B+256/45, by positivity, by positivity, ?_⟩ intro T A L j F hT hLA hj hF apply (hbound T A L j F hT hLA hj hF).trans_eq rw [mul_assoc, ← Real.exp_add] congr 2 push_cast ring end Erdos416Proof.FordBadFacet end /- Consolidated component: BoundaryOverlap.lean. -/ section open Filter Finset open scoped Classical Topology BigOperators namespace Erdos416Proof.FordBadFacet /-- Prime factors of the second factor lie below those of the first. Equality at the boundary is allowed, with arbitrary multiplicities. -/ /- Original line 46985: Erdos416Proof.FordBadFacet.PrimeSeparated -/ def PrimeSeparated (a b : ℕ) : Prop := ∀ p q : ℕ, p.Prime → p ∣ a → q.Prime → q ∣ b → q ≤ p /- Original line 46988: Erdos416Proof.FordBadFacet.common_prime_eq_minFac -/ theorem common_prime_eq_minFac {a b p : ℕ} (hsep : PrimeSeparated a b) (ha1 : a ≠ 1) (hp : p.Prime) (hpa : p ∣ a) (hpb : p ∣ b) : p = a.minFac := by exact le_antisymm (hsep a.minFac p (Nat.minFac_prime ha1) (Nat.minFac_dvd a) hp hpb) (Nat.minFac_le_of_dvd hp.two_le hpa) /-- Any overlap in an ordered split has just one prime base. -/ /- Original line 46994: Erdos416Proof.FordBadFacet.separated_gcd_prime_power -/ theorem separated_gcd_prime_power {a b : ℕ} (ha : 0 < a) (hsep : PrimeSeparated a b) (hnot : ¬ a.Coprime b) : ∃ e : ℕ, (a.minFac).Prime ∧ Nat.gcd a b = a.minFac^(e+1) := by have ha1 : a ≠ 1 := by intro h; subst a; exact hnot (Nat.coprime_one_left b) have hp := Nat.minFac_prime ha1 have hg : 0 < Nat.gcd a b := Nat.gcd_pos_of_pos_left b ha have heq : Nat.gcd a b = a.minFac^(Nat.gcd a b).primeFactorsList.length := Nat.eq_prime_pow_of_unique_prime_dvd hg.ne' (by intro p hprime hdiv exact common_prime_eq_minFac hsep ha1 hprime (hdiv.trans (Nat.gcd_dvd_left a b)) (hdiv.trans (Nat.gcd_dvd_right a b))) have hlength : 0 < (Nat.gcd a b).primeFactorsList.length := by by_contra h have hl0 : (Nat.gcd a b).primeFactorsList.length = 0 := by omega simp only [hl0,pow_zero] at heq exact hnot heq obtain ⟨e,he⟩ := Nat.exists_eq_succ_of_ne_zero (by omega : (Nat.gcd a b).primeFactorsList.length ≠ 0) exact ⟨e,hp,by simpa only [he] using heq⟩ /- Original line 47013: Erdos416Proof.FordBadFacet.separated_totient_overlap_identity -/ theorem separated_totient_overlap_identity {a b : ℕ} (ha : 0 < a) (hsep : PrimeSeparated a b) (hnot : ¬ a.Coprime b) : (a.minFac-1)*(a*b).totient = a.minFac*(a.totient*b.totient) := by obtain ⟨e,hp,hg⟩ := separated_gcd_prime_power ha hsep hnot have h := Nat.totient_gcd_mul_totient_mul a b rw [hg,Nat.totient_prime_pow_succ hp,pow_succ] at h apply Nat.eq_of_mul_eq_mul_left (pow_pos hp.pos e) nlinarith /-- The second possible numerical core when the prefix and suffix share their boundary prime. The unit prefix uses its ordinary core. -/ /- Original line 47024: Erdos416Proof.FordBadFacet.overlapCore -/ noncomputable def overlapCore (a m : ℕ) : ℕ := if a = 1 then m else a.minFac*(a.totient*m)/(a.minFac-1) /- Original line 47027: Erdos416Proof.FordBadFacet.separated_totient_two_cases -/ theorem separated_totient_two_cases {a b : ℕ} (ha : 0 < a) (hsep : PrimeSeparated a b) : (a*b).totient = a.totient*b.totient ∨ (a*b).totient = overlapCore a b.totient := by by_cases hcop : a.Coprime b · exact Or.inl (Nat.totient_mul hcop) · right have ha1 : a ≠ 1 := by intro h; subst a; exact hcop (Nat.coprime_one_left b) have hp := Nat.minFac_prime ha1 have heq := separated_totient_overlap_identity ha hsep hcop rw [overlapCore,if_neg ha1,← heq,Nat.mul_div_cancel_left _ (Nat.sub_pos_of_lt hp.one_lt)] /- Original line 47038: Erdos416Proof.FordBadFacet.ordinary_prefix_suffix_primeSeparated -/ theorem ordinary_prefix_suffix_primeSeparated (N D : ℕ) : PrimeSeparated (ordinaryPrefix N D) (ordinarySuffix N D) := by intro p q hp hpa hq hqb have hpMem : p ∈ (ordinaryPrimeList N).take D := mem_list_primes_of_dvd_prod (Nat.prime_iff.mp hp) (fun r hr => Nat.prime_iff.mp (Nat.prime_of_mem_primeFactorsList (List.mem_reverse.mp (List.mem_of_mem_take hr)))) hpa have hqMem : q ∈ (ordinaryPrimeList N).drop D := mem_list_primes_of_dvd_prod (Nat.prime_iff.mp hq) (fun r hr => Nat.prime_iff.mp (Nat.prime_of_mem_primeFactorsList (List.mem_reverse.mp (List.mem_of_mem_drop hr)))) hqb obtain ⟨idx,hi,hpi⟩ := List.mem_take_iff_getElem.mp hpMem obtain ⟨j,hj,hqj⟩ := List.mem_drop_iff_getElem.mp hqMem have hiL : idx < (ordinaryPrimeList N).length := lt_of_lt_of_le hi (Nat.min_le_right _ _) have hjL : D+j < (ordinaryPrimeList N).length := by omega have hpi' : ordinaryPrimeAt N idx = p := by change (ordinaryPrimeList N).getD idx 1 = p rw [List.getD_eq_getElem _ 1 hiL] exact hpi have hqj' : ordinaryPrimeAt N (D+j) = q := by change (ordinaryPrimeList N).getD (D+j) 1 = q rw [List.getD_eq_getElem _ 1 hjL] exact hqj have ho := ordinaryPrimeAt_antitone N (show idx ≤ D+j by omega) simpa only [hpi',hqj'] using ho /- Original line 47064: Erdos416Proof.FordBadFacet.overlapCore_ge -/ theorem overlapCore_ge (a m : ℕ) : a.totient*m ≤ overlapCore a m := by by_cases ha : a = 1 · simp [overlapCore,ha] · have hp := Nat.minFac_prime ha rw [overlapCore,if_neg ha] apply (Nat.le_div_iff_mul_le (Nat.sub_pos_of_lt hp.one_lt)).mpr have hpred : a.minFac-1 ≤ a.minFac := Nat.sub_le _ _ simpa only [Nat.mul_comm] using Nat.mul_le_mul_left (a.totient*m) hpred /- Original line 47073: Erdos416Proof.FordBadFacet.overlapCore_pos -/ theorem overlapCore_pos {a m : ℕ} (ha : 0 < a) (hm : 0 < m) : 0 < overlapCore a m := (Nat.mul_pos (Nat.totient_pos.mpr ha) hm).trans_le (overlapCore_ge a m) /- Original line 47076: Erdos416Proof.FordBadFacet.orderedPrefixSuffixCores -/ noncomputable def orderedPrefixSuffixCores (P W : Finset ℕ) : Finset ℕ := prefixSuffixCores P W ∪ (P.product W).image (fun am : ℕ × ℕ => overlapCore am.1 am.2) /- Original line 47079: Erdos416Proof.FordBadFacet.orderedPrefixSuffixCores_pos -/ theorem orderedPrefixSuffixCores_pos {P W : Finset ℕ} (hP : ∀ a ∈ P, 0 < a) (hW : ∀ m ∈ W, 0 < m) : ∀ b ∈ orderedPrefixSuffixCores P W, 0 < b := by intro b hb rcases Finset.mem_union.mp hb with hb | hb · exact prefixSuffixCores_pos hP hW b hb · obtain ⟨⟨a,m⟩,ham,rfl⟩ := Finset.mem_image.mp hb obtain ⟨ha,hm⟩ := Finset.mem_product.mp ham exact overlapCore_pos (hP a ha) (hW m hm) /- Original line 47089: Erdos416Proof.FordBadFacet.separated_totient_mem_orderedCores -/ theorem separated_totient_mem_orderedCores {P W : Finset ℕ} {a b : ℕ} (ha : 0 < a) (haP : a ∈ P) (hbW : b.totient ∈ W) (hsep : PrimeSeparated a b) : (a*b).totient ∈ orderedPrefixSuffixCores P W := by rcases separated_totient_two_cases ha hsep with h | h · exact Finset.mem_union_left _ (Finset.mem_image.mpr ⟨(a,b.totient),Finset.mem_product.mpr ⟨haP,hbW⟩,h.symm⟩) · exact Finset.mem_union_right _ (Finset.mem_image.mpr ⟨(a,b.totient),Finset.mem_product.mpr ⟨haP,hbW⟩,h.symm⟩) /-- A repeated boundary prime costs at most a factor two in the reciprocal core count, with arbitrary prime multiplicities in both factors. -/ /- Original line 47100: Erdos416Proof.FordBadFacet.orderedPrefixSuffixCores_reciprocal_bound -/ theorem orderedPrefixSuffixCores_reciprocal_bound (P W : Finset ℕ) (hP : ∀ a ∈ P, 0 < a) (hW : ∀ m ∈ W, 0 < m) : (∑ b ∈ orderedPrefixSuffixCores P W, (1 : ℝ)/b) ≤ 2*(∑ a ∈ P, invTotient a)*(∑ m ∈ W, (1 : ℝ)/m) := by let R := (P.product W).image (fun am : ℕ × ℕ => overlapCore am.1 am.2) have hi : (∑ b ∈ R, (1 : ℝ)/b) ≤ ∑ am ∈ P.product W, (1 : ℝ)/overlapCore am.1 am.2 := Finset.sum_image_le_of_nonneg (fun b _ => by positivity) have hR : (∑ b ∈ R, (1 : ℝ)/b) ≤ (∑ a ∈ P, invTotient a)*(∑ m ∈ W, (1 : ℝ)/m) := by apply hi.trans calc _ ≤ ∑ am ∈ P.product W, (1 : ℝ)/(am.1.totient*am.2 : ℕ) := by apply Finset.sum_le_sum intro am ham obtain ⟨ha,hm⟩ := Finset.mem_product.mp ham exact one_div_le_one_div_of_le (by exact_mod_cast Nat.mul_pos (Nat.totient_pos.mpr (hP am.1 ha)) (hW am.2 hm)) (by exact_mod_cast overlapCore_ge am.1 am.2) _ = _ := by rw [Finset.product_eq_sprod,Finset.sum_product,Finset.sum_mul] apply Finset.sum_congr rfl intro a ha rw [Finset.mul_sum] apply Finset.sum_congr rfl intro m hm simp only [Nat.cast_mul,invTotient,one_div,mul_inv_rev] ring have hU := Finset.sum_union_inter (s₁ := prefixSuffixCores P W) (s₂ := R) (f := fun b : ℕ => (1 : ℝ)/b) have hI : 0 ≤ ∑ b ∈ prefixSuffixCores P W ∩ R, (1 : ℝ)/b := Finset.sum_nonneg (fun _ _ => by positivity) have hB := prefixSuffixCores_reciprocal_bound P W change (∑ b ∈ prefixSuffixCores P W ∪ R, (1 : ℝ)/b) ≤ _ nlinarith /-- Count actual totients whose cofactor has an ordered prefix/suffix split. There is no coprimality requirement at that split. -/ /- Original line 47138: Erdos416Proof.FordBadFacet.exists_ordered_prime_prefix_suffix_count -/ theorem exists_ordered_prime_prefix_suffix_count : ∃ C : ℝ, 0 < C ∧ ∀ (P W F : Finset ℕ) (x h : ℝ), 0 < x → 0 < h → (∀ a ∈ P, 0 < a) → (∀ m ∈ W, 0 < m) → (∀ v ∈ F, (v : ℝ) ≤ x ∧ ∃ p a b : ℕ, p.Prime ∧ h ≤ Real.log p ∧ a ∈ P ∧ b.totient ∈ W ∧ PrimeSeparated a b ∧ v = (p-1)*(a*b).totient) → (F.card : ℝ) ≤ C*x/h*(∑ a ∈ P, invTotient a)*(∑ m ∈ W, (1 : ℝ)/m) := by obtain ⟨C,hC,hcount⟩ := exists_largePrimeCorePairs_bound refine ⟨2*C,by positivity,?_⟩ intro P W F x h hx hh hP hW hF let B := orderedPrefixSuffixCores P W let Q := largePrimeCorePairs B x h have hB : ∀ b ∈ B, 0 < b := orderedPrefixSuffixCores_pos hP hW have hsub : F ⊆ Q.image corePairValue := by intro v hv obtain ⟨hvx,p,a,b,hp,hph,ha,hb,hsep,hval⟩ := hF v hv have hcore : (a*b).totient ∈ B := separated_totient_mem_orderedCores (hP a ha) ha hb hsep have heq : corePairValue ((a*b).totient,p) = v := hval.symm refine Finset.mem_image.mpr ⟨((a*b).totient,p),?_,heq⟩ apply Finset.mem_filter.mpr refine ⟨(mem_corePairs hx.le hB).mpr ⟨hcore,hp,?_,?_⟩,hph⟩ · exact_mod_cast corePairValue_pos (hB _ hcore) hp · simpa only [heq] using hvx have hc : (F.card : ℝ) ≤ Q.card := by exact_mod_cast (Finset.card_le_card hsub).trans Finset.card_image_le calc _ ≤ C*x/h*(∑ b ∈ B, (1 : ℝ)/b) := hc.trans (hcount B x h hx hh hB) _ ≤ C*x/h*(2*(∑ a ∈ P, invTotient a)*(∑ m ∈ W, (1 : ℝ)/m)) := mul_le_mul_of_nonneg_left (orderedPrefixSuffixCores_reciprocal_bound P W hP hW) (by positivity) _ = _ := by ring end Erdos416Proof.FordBadFacet end /- Consolidated component: FirstFailedCount.lean. -/ section open Filter Asymptotics Finset open scoped Classical Topology BigOperators namespace Erdos416Proof.FordBadFacet open FordGeometry FordReciprocal FordScale /- Original line 47187: Erdos416Proof.FordBadFacet.actual_preimage_mem_polytope_of_not_failure -/ theorem actual_preimage_mem_polytope_of_not_failure {x : ℝ} {L m N : ℕ} {ξ : ℕ → ℝ} (hm : m ∈ totientsUpTo x) (hgood : m ∉ polytopeFailureValues x L ξ) (hN : 0 < N) (hphi : N.totient = m) : (fun idx : Fin L => ordinaryPrimeCoordinate (logLog x) N (idx.val+1)) ∈ polytope L ξ := by by_contra hnot exact hgood (mem_filter.mpr ⟨hm, N, hN, hphi, hnot⟩) /- Original line 47194: Erdos416Proof.FordBadFacet.eventually_fourth_log_cutoff_lt_large_prime -/ theorem eventually_fourth_log_cutoff_lt_large_prime : ∀ᶠ x : ℝ in atTop, 1 ≤ Real.log x^4 ∧ ∀ p : ℕ, p.Prime → Real.log x/6 ≤ Real.log p → Real.log x^4 < (p : ℝ) := by have hT : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop have hs : (fun T : ℝ => 4*T) =o[atTop] (fun T => Real.exp T) := by simpa only [pow_one, one_mul] using (isLittleO_pow_exp_pos_mul_atTop 1 (by norm_num : (0 : ℝ) < 1)).const_mul_left 4 filter_upwards [hT.eventually (hs.def (by norm_num : (0 : ℝ) < 1/12)), hT.eventually_ge_atTop 1, eventually_ge_atTop (Real.exp 1)] with x hsmall hTx hx have hx1 : 1 < x := (Real.one_lt_exp_iff.mpr (by norm_num : (0 : ℝ) < 1)).trans_le hx have hlog : 0 < Real.log x := Real.log_pos hx1 have hlog1 : 1 ≤ Real.log x := by simpa only [Real.log_exp] using Real.log_le_log (Real.exp_pos 1) hx have hexp : Real.exp (logLog x) = Real.log x := Real.exp_log hlog simp only [Real.norm_eq_abs, abs_of_nonneg (by positivity : 0 ≤ 4*logLog x), hexp, abs_of_pos hlog] at hsmall refine ⟨one_le_pow₀ hlog1, ?_⟩ intro p hp hplog have hpow : Real.log x^4 = Real.exp (4*logLog x) := by rw [show (4 : ℝ) = ((4 : ℕ) : ℝ) by norm_num, Real.exp_nat_mul, hexp] rw [hpow, ← Real.exp_log (by exact_mod_cast hp.pos : (0 : ℝ) < p)] exact Real.exp_lt_exp.mpr (by linarith) /-- The retained first-failed class uses only the three already counted arithmetic exceptions and the small-value cutoff. -/ /- Original line 47219: Erdos416Proof.FordBadFacet.retainedFirstFailedValues -/ noncomputable def retainedFirstFailedValues (x : ℝ) (A L j : ℕ) : Finset ℕ := (firstFailedFacetValues x L (expandedParameter A) j).filter (fun m => Real.sqrt x ≤ (m : ℝ) ∧ m ∉ badFacetValues x 2 (1/1000) ∧ m ∉ fiveLogOmegaTotients x ∧ m ∉ largeSquareTotients x) /-- Finite actual suffix values with their original retained preimage and first-failed row. No numerical suffix family is supplied as an assumption. -/ /- Original line 47226: Erdos416Proof.FordBadFacet.retainedFirstFailedSuffixes -/ noncomputable def retainedFirstFailedSuffixes (x : ℝ) (A L j : ℕ) : Finset ℕ := (totientsUpTo x).filter (fun m => ∃ N : ℕ, 0 < N ∧ N.totient ∈ retainedFirstFailedValues x A L j ∧ FirstFailedRow L (expandedParameter A) (ordinaryPrimeCoordinate (logLog x) N) j ∧ (ordinarySuffix N j).totient = m) /- Original line 47232: Erdos416Proof.FordBadFacet.retainedFirstFailedValues_zero_subset_full_badFacet -/ theorem retainedFirstFailedValues_zero_subset_full_badFacet {x : ℝ} {A L : ℕ} (hT : 0 ≤ logLog x) (hLA : L ≤ A) : retainedFirstFailedValues x A L 0 ⊆ badFacetValues x A (FordRestricted.suffixMargin A) := by intro m hm have hmargin : 1 + FordRestricted.suffixMargin A ≤ expandedParameter A 0 := by simpa only [Nat.sub_zero] using (expandedParameter_row_margin (Nat.zero_le A)).ge exact badFacetValues_mono_length hT hLA (firstFailedFacetValues_zero_subset_badFacet hmargin (mem_filter.mp hm).1) /- Original line 47241: Erdos416Proof.FordBadFacet.retainedFirstFailedSuffixes_pos -/ theorem retainedFirstFailedSuffixes_pos {x : ℝ} {A L j : ℕ} (hx : 0 ≤ x) : ∀ m ∈ retainedFirstFailedSuffixes x A L j, 0 < m := by intro m hm exact ((mem_totientsUpTo hx).mp (mem_filter.mp hm).1).1 /- Original line 47246: Erdos416Proof.FordBadFacet.retainedFirstFailedSuffixes_provenance -/ theorem retainedFirstFailedSuffixes_provenance {x : ℝ} {A L j m : ℕ} (hm : m ∈ retainedFirstFailedSuffixes x A L j) : m ∈ totientsUpTo x ∧ ∃ N : ℕ, 0 < N ∧ (ordinarySuffix N j).totient = m ∧ FirstFailedRow L (expandedParameter A) (ordinaryPrimeCoordinate (logLog x) N) j := by obtain ⟨hmV, N, hN, _hretained, hfirst, hNm⟩ := mem_filter.mp hm exact ⟨hmV, N, hN, hNm, hfirst⟩ /-- The arithmetic exceptions are removed once, before summing over rows. -/ /- Original line 47254: Erdos416Proof.FordBadFacet.polytopeFailureValues_subset_retained_union -/ theorem polytopeFailureValues_subset_retained_union {x : ℝ} {A L : ℕ} (hx : Real.exp 1 ≤ x) (hT : 0 < logLog x) (hL : 2 ≤ L) : polytopeFailureValues x L (expandedParameter A) ⊆ totientsUpTo (Real.sqrt x) ∪ badFacetValues x 2 (1/1000) ∪ fiveLogOmegaTotients x ∪ largeSquareTotients x ∪ (range (L-1)).biUnion (retainedFirstFailedValues x A L) := by intro m hm have hmV := (mem_filter.mp hm).1 have hmdata := (mem_totientsUpTo ((Real.exp_pos 1).le.trans hx)).mp hmV simp only [mem_union] by_cases hsmall : (m : ℝ) ≤ Real.sqrt x · exact Or.inl (Or.inl (Or.inl (Or.inl ((mem_totientsUpTo (Real.sqrt_nonneg x)).mpr ⟨hmdata.1, hsmall, hmdata.2.2⟩)))) by_cases hbad : m ∈ badFacetValues x 2 (1/1000) · exact Or.inl (Or.inl (Or.inl (Or.inr hbad))) by_cases hΩ : m ∈ fiveLogOmegaTotients x · exact Or.inl (Or.inl (Or.inr hΩ)) by_cases hSq : m ∈ largeSquareTotients x · exact Or.inl (Or.inr hSq) right rw [polytopeFailureValues_eq_failedRows hL hx hT (expandedParameter_ge_one A), failedRowsValues_eq_union] at hm obtain ⟨j, hj, hmj⟩ := mem_biUnion.mp hm exact mem_biUnion.mpr ⟨j, hj, mem_filter.mpr ⟨hmj, (lt_of_not_ge hsmall).le, hbad, hΩ, hSq⟩⟩ /- Original line 47279: Erdos416Proof.FordBadFacet.firstFailedExceptionalValues -/ noncomputable def firstFailedExceptionalValues (x : ℝ) (A : ℕ) : Finset ℕ := totientsUpTo (Real.sqrt x) ∪ badFacetValues x 2 (1/1000) ∪ fiveLogOmegaTotients x ∪ largeSquareTotients x ∪ badFacetValues x A (FordRestricted.suffixMargin A) /- Original line 47283: Erdos416Proof.FordBadFacet.polytopeFailureValues_subset_exceptions_positive_rows -/ theorem polytopeFailureValues_subset_exceptions_positive_rows {x : ℝ} {A L : ℕ} (hx : Real.exp 1 ≤ x) (hT : 0 < logLog x) (hL : 2 ≤ L) (hLA : L ≤ A) : polytopeFailureValues x L (expandedParameter A) ⊆ firstFailedExceptionalValues x A ∪ (Ico 1 (L-1)).biUnion (retainedFirstFailedValues x A L) := by intro m hm have hcover := polytopeFailureValues_subset_retained_union hx hT hL hm rcases mem_union.mp hcover with hexception | hrow · exact mem_union.mpr (Or.inl (mem_union.mpr (Or.inl hexception))) · obtain ⟨j, hj, hmj⟩ := mem_biUnion.mp hrow by_cases hj0 : j = 0 · subst j exact mem_union.mpr (Or.inl (mem_union.mpr (Or.inr (retainedFirstFailedValues_zero_subset_full_badFacet hT.le hLA hmj)))) · exact mem_union.mpr (Or.inr (mem_biUnion.mpr ⟨j, mem_Ico.mpr ⟨by omega, mem_range.mp hj⟩, hmj⟩)) /- Original line 47299: Erdos416Proof.FordBadFacet.actual_retained_firstFailed_suffix_mem -/ theorem actual_retained_firstFailed_suffix_mem {x : ℝ} {N A L j : ℕ} (hx : 0 ≤ x) (hN : 0 < N) (hm : N.totient ∈ retainedFirstFailedValues x A L j) (hfirst : FirstFailedRow L (expandedParameter A) (ordinaryPrimeCoordinate (logLog x) N) j) : (ordinarySuffix N j).totient ∈ retainedFirstFailedSuffixes x A L j := by have hmV : N.totient ∈ totientsUpTo x := (mem_filter.mp (mem_filter.mp hm).1).1 have hv := (mem_totientsUpTo hx).mp hmV have hS := ordinarySuffix_pos N j exact mem_filter.mpr ⟨(mem_totientsUpTo hx).mpr ⟨Nat.totient_pos.mpr hS, (Nat.cast_le.mpr (ordinarySuffix_totient_le hN j)).trans hv.2.1, ordinarySuffix N j, hS, rfl⟩, N, hN, hm, hfirst, rfl⟩ /-- Actual representations supplied by every retained first-failed value. A larger finite W may be used solely by checking that it contains the explicit actual suffix set; no estimate for W is assumed here. -/ /- Original line 47313: Erdos416Proof.FordBadFacet.retainedFirstFailedValues_representable_eventually -/ theorem retainedFirstFailedValues_representable_eventually : ∀ᶠ x : ℝ in atTop, ∀ (A L j : ℕ) (W : Finset ℕ), 0 < j → retainedFirstFailedSuffixes x A L j ⊆ W → ∀ v ∈ retainedFirstFailedValues x A L j, (v : ℝ) ≤ x ∧ ∃ p b m : ℕ, p.Prime ∧ Real.log x/6 ≤ Real.log p ∧ b ∈ tupleIntegers (j-1) (logLog x) (polytope (j-1) (expandedParameter A)) ∧ m ∈ W ∧ v = (p-1)*b.totient*m := by have hT : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [ordinary_top_log_lower_outside_fixed_facet, eventually_fourth_log_cutoff_lt_large_prime, hT.eventually_gt_atTop 0, eventually_ge_atTop (Real.exp 1)] with x htop hlargeTop hTx hx have hx0 : 0 ≤ x := (Real.exp_pos 1).le.trans hx intro A L j W hj hW v hv obtain ⟨hvfirst, hvlarge, hvbad, hvΩ, hvSq⟩ := mem_filter.mp hv obtain ⟨hvV, N, hN, hphi, hfirst⟩ := mem_filter.mp hvfirst have hvx := ((mem_totientsUpTo hx0).mp hvV).2.1 obtain ⟨hp, hplog⟩ := htop v N hvV hvlarge hN hphi hvbad hvΩ hvSq have hSqN : NoLargePrimeSquare N (Real.log x^4) := by intro p hp hlarge hdiv exact hvSq (mem_filter.mpr ⟨hvV, N, hN, hphi, p, hp, hlarge, Or.inl hdiv⟩) obtain ⟨hprime, htuple, _hpositive, _hvalue, hproduct⟩ := actual_firstFailed_arithmetic_witness_of_top_large hN hx hTx (by simpa only [hphi] using hvx) (expandedParameter_ge_one A) (expandedParameter_monotone A) hfirst hj hlargeTop.1 hSqN (hlargeTop.2 _ hp hplog) have hretained : N.totient ∈ retainedFirstFailedValues x A L j := by simpa only [hphi] using hv have hsuffix := hW (actual_retained_firstFailed_suffix_mem hx0 hN hretained hfirst) refine ⟨hvx, ordinaryPrimeAt N 0, ordinaryLowerPrefix N j, (ordinarySuffix N j).totient, hprime, hplog, htuple, hsuffix, ?_⟩ simpa only [hphi] using hproduct /- Original line 47344: Erdos416Proof.FordBadFacet.exists_retainedFirstFailedValues_count -/ theorem exists_retainedFirstFailedValues_count : ∃ C : ℝ, 0 < C ∧ ∀ᶠ x : ℝ in atTop, ∀ (A L j : ℕ) (W : Finset ℕ), 0 < j → (∀ m ∈ W, 0 < m) → retainedFirstFailedSuffixes x A L j ⊆ W → ((retainedFirstFailedValues x A L j).card : ℝ) ≤ C*x/Real.log x*tupleReciprocalMass (j-1) (logLog x) (polytope (j-1) (expandedParameter A))*(∑ m ∈ W, (1 : ℝ)/m) := by obtain ⟨C, hC, hcount⟩ := exists_prime_tuple_suffix_count refine ⟨6*C, by positivity, ?_⟩ filter_upwards [retainedFirstFailedValues_representable_eventually, eventually_gt_atTop (1 : ℝ)] with x hrepr hx intro A L j W hj hW hcontains have hlog : 0 < Real.log x := Real.log_pos hx have hc := hcount (j-1) (logLog x) x (Real.log x/6) _ W (retainedFirstFailedValues x A L j) (by linarith) (by positivity) hW (hrepr A L j W hj hcontains) exact hc.trans_eq (by ring) /- Original line 47361: Erdos416Proof.FordBadFacet.exists_actual_retainedFirstFailedValues_count -/ theorem exists_actual_retainedFirstFailedValues_count : ∃ C : ℝ, 0 < C ∧ ∀ᶠ x : ℝ in atTop, ∀ A L j : ℕ, 0 < j → ((retainedFirstFailedValues x A L j).card : ℝ) ≤ C*x/Real.log x*tupleReciprocalMass (j-1) (logLog x) (polytope (j-1) (expandedParameter A))* (∑ m ∈ retainedFirstFailedSuffixes x A L j, (1 : ℝ)/m) := by obtain ⟨C, hC, hcount⟩ := exists_retainedFirstFailedValues_count refine ⟨C, hC, ?_⟩ filter_upwards [hcount, eventually_ge_atTop (0 : ℝ)] with x hx hx0 intro A L j hj exact hx A L j _ hj (retainedFirstFailedSuffixes_pos hx0) (Subset.refl _) /- Original line 47373: Erdos416Proof.FordBadFacet.exists_retainedFirstFailedValues_gaussian_count -/ theorem exists_retainedFirstFailedValues_gaussian_count : ∃ C : ℝ, 0 < C ∧ ∀ᶠ M : ℕ in atTop, ∀ᶠ x : ℝ in atTop, ∀ (L j : ℕ) (W : Finset ℕ), 0 < j → j-1 ≤ coreDimension M (logLog x) → (∀ m ∈ W, 0 < m) → retainedFirstFailedSuffixes x (optimalDimension (logLog x)) L j ⊆ W → ((retainedFirstFailedValues x (optimalDimension (logLog x)) L j).card : ℝ) ≤ C*x/Real.log x*(4*FordAnalysis.rho^M)^(coreDimension M (logLog x)-(j-1))* FordAnalysis.rho^((coreDimension M (logLog x)-(j-1)).choose 2)* ((logLog x)^(coreDimension M (logLog x))*modelVolume (coreDimension M (logLog x)))* (∑ m ∈ W, (1 : ℝ)/m) := by obtain ⟨C, hC, hcount⟩ := exists_expanded_prime_tuple_suffix_gaussian_count refine ⟨C, hC, ?_⟩ filter_upwards [hcount] with M hM filter_upwards [hM, retainedFirstFailedValues_representable_eventually] with x hx hrepr intro L j W hj hdim hW hcontains exact hx (j-1) W _ hdim hW (hrepr _ L j W hj hcontains) end Erdos416Proof.FordBadFacet end /- Consolidated component: ShiftedPrefixTails.lean. -/ section open Filter Finset open scoped Classical Topology BigOperators namespace Erdos416Proof.FordBadFacet open FordGeometry FordAnalysis FordScale /-- The suffix reciprocal exponent includes a fixed extra shift. Keeping the reference gap M fixed gives a summable sequence in the prefix deficit. -/ /- Original line 47410: Erdos416Proof.FordBadFacet.shiftedQuadraticPrefixFactor -/ noncomputable def shiftedQuadraticPrefixFactor (a : ℝ) (M : ℕ) (B : ℝ) (s d : ℕ) : ℝ := (4*rho^M)^d*rho^(d.choose 2)* Real.exp (a*((M+d+s : ℕ) : ℝ)^2+B*((M+d+s : ℕ) : ℝ)) /- Original line 47414: Erdos416Proof.FordBadFacet.shiftedQuadraticPrefixFactor_eq -/ theorem shiftedQuadraticPrefixFactor_eq (a : ℝ) (M : ℕ) (B : ℝ) (s d : ℕ) : shiftedQuadraticPrefixFactor a M B s d = Real.exp (a*(s : ℝ)^2+B*(s : ℝ))*quadraticPrefixFactor a M (B+2*a*s) d := by unfold shiftedQuadraticPrefixFactor quadraticPrefixFactor push_cast rw [show a*((M : ℝ)+d+s)^2+B*((M : ℝ)+d+s) = (a*(s : ℝ)^2+B*s)+(a*((M : ℝ)+d)^2+(B+2*a*s)*((M : ℝ)+d)) by ring, Real.exp_add] ring /- Original line 47424: Erdos416Proof.FordBadFacet.shiftedQuadraticPrefixFactor_nonneg -/ theorem shiftedQuadraticPrefixFactor_nonneg (a : ℝ) (M : ℕ) (B : ℝ) (s d : ℕ) : 0 ≤ shiftedQuadraticPrefixFactor a M B s d := by unfold shiftedQuadraticPrefixFactor have hρ := rho_pos positivity /- Original line 47430: Erdos416Proof.FordBadFacet.shiftedQuadraticPrefixFactor_summable -/ theorem shiftedQuadraticPrefixFactor_summable {a : ℝ} (ha : a < 1/8) (M : ℕ) (B : ℝ) (s : ℕ) : Summable (shiftedQuadraticPrefixFactor a M B s) := by have he : shiftedQuadraticPrefixFactor a M B s = fun d => Real.exp (a*(s : ℝ)^2+B*(s : ℝ))*quadraticPrefixFactor a M (B+2*a*s) d := by funext d exact shiftedQuadraticPrefixFactor_eq a M B s d rw [he] exact (quadraticPrefixFactor_summable ha M _).mul_left _ /- Original line 47439: Erdos416Proof.FordBadFacet.shiftedPrefixTail -/ noncomputable def shiftedPrefixTail (a : ℝ) (M : ℕ) (B : ℝ) (s N : ℕ) : ℝ := ∑' d : ℕ, shiftedQuadraticPrefixFactor a M B s (d+N) /- Original line 47442: Erdos416Proof.FordBadFacet.shiftedPrefixTail_nonneg -/ theorem shiftedPrefixTail_nonneg (a : ℝ) (M : ℕ) (B : ℝ) (s N : ℕ) : 0 ≤ shiftedPrefixTail a M B s N := tsum_nonneg (fun d => shiftedQuadraticPrefixFactor_nonneg a M B s (d+N)) /- Original line 47446: Erdos416Proof.FordBadFacet.shiftedPrefixTail_tendsto -/ theorem shiftedPrefixTail_tendsto (a : ℝ) (M : ℕ) (B : ℝ) (s : ℕ) : Tendsto (shiftedPrefixTail a M B s) atTop (nhds 0) := tendsto_sum_nat_add (shiftedQuadraticPrefixFactor a M B s) /- Original line 47450: Erdos416Proof.FordBadFacet.finite_shiftedPrefixFactor_tail_bound -/ theorem finite_shiftedPrefixFactor_tail_bound {a : ℝ} (ha : a < 1/8) (M : ℕ) (B : ℝ) (s N : ℕ) (F : Finset ℕ) (hF : ∀ d ∈ F, N ≤ d) : (∑ d ∈ F, shiftedQuadraticPrefixFactor a M B s d) ≤ shiftedPrefixTail a M B s N := by let G := F.image (fun d => d-N) have hinj : Set.InjOn (fun d : ℕ => d-N) (F : Set ℕ) := by intro d hd e he hde have hdN := hF d hd have heN := hF e he change d-N = e-N at hde omega have he : (∑ d ∈ F, shiftedQuadraticPrefixFactor a M B s d) = ∑ d ∈ G, shiftedQuadraticPrefixFactor a M B s (d+N) := by rw [show G = F.image (fun d => d-N) by rfl, sum_image hinj] apply sum_congr rfl intro d hd rw [Nat.sub_add_cancel (hF d hd)] have hs : Summable (fun d : ℕ => shiftedQuadraticPrefixFactor a M B s (d+N)) := (shiftedQuadraticPrefixFactor_summable ha M B s).comp_injective (fun _ _ h => Nat.add_right_cancel h) rw [he] exact hs.sum_le_tsum G (fun d _ => shiftedQuadraticPrefixFactor_nonneg a M B s (d+N)) /- Original line 47472: Erdos416Proof.FordBadFacet.firstFailedDeficit -/ def firstFailedDeficit (R j : ℕ) : ℕ := R-(j-1) /- Original line 47474: Erdos416Proof.FordBadFacet.firstFailedDeficit_injOn -/ theorem firstFailedDeficit_injOn {R : ℕ} {J : Finset ℕ} (hJ : ∀ j ∈ J, 0 < j ∧ j ≤ R) : Set.InjOn (firstFailedDeficit R) (J : Set ℕ) := by intro j hj k hk he have hjR := hJ j hj have hkR := hJ k hk unfold firstFailedDeficit at he omega /- Original line 47482: Erdos416Proof.FordBadFacet.firstFailedDeficit_shift_index -/ theorem firstFailedDeficit_shift_index {A R M j : ℕ} (hA : R+M = A) (hj : 0 < j) (hjR : j ≤ R) : A-j+40 = M+firstFailedDeficit R j+39 := by unfold firstFailedDeficit omega /- Original line 47488: Erdos416Proof.FordBadFacet.firstFailedDeficit_lower -/ theorem firstFailedDeficit_lower {A R D M H j : ℕ} (hRef : R+M = A) (hTrunc : D+H = A) (hMH : M ≤ H) (hj : 0 < j) (hjD : j ≤ D) : H-M+1 ≤ firstFailedDeficit R j := by unfold firstFailedDeficit omega /-- Reindex the actual failed rows by their deficit from a fixed reference dimension. The suffix index is the deficit plus the fixed shift M+39. -/ /- Original line 47496: Erdos416Proof.FordBadFacet.sum_firstFailed_row_factors_le_tail -/ theorem sum_firstFailed_row_factors_le_tail {a : ℝ} (ha : a < 1/8) (M : ℕ) (B : ℝ) {A R D H : ℕ} (hRef : R+M = A) (hTrunc : D+H = A) (hMH : M ≤ H) (J : Finset ℕ) (hJ : ∀ j ∈ J, 0 < j ∧ j ≤ D) : (∑ j ∈ J, (4*rho^M)^(firstFailedDeficit R j)* rho^((firstFailedDeficit R j).choose 2)* Real.exp (a*((A-j+40 : ℕ) : ℝ)^2+B*((A-j+40 : ℕ) : ℝ))) ≤ shiftedPrefixTail a M B 39 (H-M+1) := by have hDR : D ≤ R := by omega have hJR : ∀ j ∈ J, 0 < j ∧ j ≤ R := fun j hj => ⟨(hJ j hj).1, (hJ j hj).2.trans hDR⟩ let F := J.image (firstFailedDeficit R) have he : (∑ j ∈ J, (4*rho^M)^(firstFailedDeficit R j)* rho^((firstFailedDeficit R j).choose 2)* Real.exp (a*((A-j+40 : ℕ) : ℝ)^2+B*((A-j+40 : ℕ) : ℝ))) = ∑ d ∈ F, shiftedQuadraticPrefixFactor a M B 39 d := by rw [show F = J.image (firstFailedDeficit R) by rfl, sum_image (firstFailedDeficit_injOn hJR)] apply sum_congr rfl intro j hj rw [firstFailedDeficit_shift_index hRef (hJR j hj).1 (hJR j hj).2] rfl rw [he] apply finite_shiftedPrefixFactor_tail_bound ha M B 39 (H-M+1) F intro d hd obtain ⟨j, hj, rfl⟩ := mem_image.mp hd exact firstFailedDeficit_lower hRef hTrunc hMH (hJ j hj).1 (hJ j hj).2 /- Original line 47523: Erdos416Proof.FordBadFacet.fixed_reference_shifted_tail_tendsto -/ theorem fixed_reference_shifted_tail_tendsto (a : ℝ) (M : ℕ) (B : ℝ) : Tendsto (fun H : ℕ => shiftedPrefixTail a M B 39 (H-M+1)) atTop (nhds 0) := by apply (shiftedPrefixTail_tendsto a M B 39).comp refine tendsto_atTop.2 (fun b => eventually_atTop.2 ⟨b+M, ?_⟩) intro H hH omega end Erdos416Proof.FordBadFacet end /- Consolidated component: FirstFailedRowSum.lean. -/ section open Filter Finset open scoped Classical Topology BigOperators namespace Erdos416Proof.FordBadFacet open FordGeometry FordAnalysis FordScale FordRestricted /-- A fixed reference gap controls all shorter truncations. The actual suffix mass contributes only a summable shifted Gaussian, whose starting index tends to infinity with the truncation gap H. -/ /- Original line 47551: Erdos416Proof.FordBadFacet.exists_firstFailed_row_sum_tail_bound -/ theorem exists_firstFailed_row_sum_tail_bound : ∃ C B : ℝ, 0 < C ∧ 0 ≤ B ∧ ∀ᶠ M : ℕ in atTop, ∀ H : ℕ, M ≤ H → ∀ᶠ x : ℝ in atTop, let T := logLog x let A := optimalDimension T let R := coreDimension M T let D := coreDimension H T (∑ j ∈ Ico 1 (D-1), ((retainedFirstFailedValues x A D j).card : ℝ)) ≤ C*x/Real.log x*(T^R*modelVolume R)*shiftedPrefixTail (16/225) M B 39 (H-M+1) := by obtain ⟨Cg, hCg, hgauss⟩ := exists_retainedFirstFailedValues_gaussian_count obtain ⟨Cs, B, hCs, hB, hsuffix⟩ := exists_firstFailedSuffix_reciprocal_mass_bound refine ⟨Cg*Cs, B, by positivity, hB, ?_⟩ filter_upwards [hgauss] with M hM intro H hMH have hTend : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [hM, hTend.eventually (coreDimension_add_tail M), hTend.eventually (coreDimension_add_tail H), hTend.eventually_gt_atTop 0, eventually_gt_atTop (1 : ℝ)] with x hcount hRef hTrunc hTpos hx let T := logLog x let A := optimalDimension T let R := coreDimension M T let D := coreDimension H T let J : Finset ℕ := Ico 1 (D-1) let P : ℝ := (Cg*Cs)*x/Real.log x*(T^R*modelVolume R) have hR : R+M = A := hRef have hD : D+H = A := hTrunc have hDR : D ≤ R := by omega have hDA : D ≤ A := by omega have hx0 : 0 < x := by linarith have hlog : 0 < Real.log x := Real.log_pos hx have hρ := rho_pos have hvol := modelVolume_pos R have hT : 0 < T := hTpos have hP : 0 ≤ P := by dsimp [Erdos416Proof.FordBadFacet.positiveLogLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_bottom, Erdos416Proof.FordBadFacet.reversedFacetLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_succ, Erdos416Proof.FordGeometry.modelVolume_one, Erdos416Proof.FordGeometry.modelVolume_zero, Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.FordRestricted.suffixCutoff_log3, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, P]; positivity have hJ : ∀ j ∈ J, 0 < j ∧ j ≤ D := by intro j hj have hj' := mem_Ico.mp hj omega have hpoint : ∀ j ∈ J, ((retainedFirstFailedValues x A D j).card : ℝ) ≤ P*((4*rho^M)^(firstFailedDeficit R j)*rho^((firstFailedDeficit R j).choose 2)* Real.exp ((16/225 : ℝ)*((A-j+40 : ℕ) : ℝ)^2+B*((A-j+40 : ℕ) : ℝ))) := by intro j hj let W := retainedFirstFailedSuffixes x A D j have hjpos := (hJ j hj).1 have hjR : j-1 ≤ R := by have := (hJ j hj).2; omega have hW : ∀ m ∈ W, 0 < m := retainedFirstFailedSuffixes_pos hx0.le have hc := hcount D j W hjpos hjR hW (Subset.refl _) have hs := hsuffix T A D j W hT hDA hjpos (fun m hm => (retainedFirstFailedSuffixes_provenance hm).2) have hcoeff : 0 ≤ Cg*x/Real.log x*(4*rho^M)^(R-(j-1))* rho^((R-(j-1)).choose 2)*(T^R*modelVolume R) := by positivity have hb := mul_le_mul_of_nonneg_left hs hcoeff apply (hc.trans hb).trans_eq dsimp [Erdos416Proof.FordBadFacet.positiveLogLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_bottom, Erdos416Proof.FordBadFacet.reversedFacetLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_succ, Erdos416Proof.FordGeometry.modelVolume_one, Erdos416Proof.FordGeometry.modelVolume_zero, Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.FordRestricted.suffixCutoff_log3, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, P, firstFailedDeficit] ring have hsum : (∑ j ∈ J, ((retainedFirstFailedValues x A D j).card : ℝ)) ≤ P*∑ j ∈ J, (4*rho^M)^(firstFailedDeficit R j)*rho^((firstFailedDeficit R j).choose 2)* Real.exp ((16/225 : ℝ)*((A-j+40 : ℕ) : ℝ)^2+B*((A-j+40 : ℕ) : ℝ)) := by rw [mul_sum] exact sum_le_sum hpoint exact hsum.trans (mul_le_mul_of_nonneg_left (sum_firstFailed_row_factors_le_tail suffixCutoff_quadratic_budget M B hR hD hMH J hJ) hP) /- Original line 47614: Erdos416Proof.FordBadFacet.exists_firstFailed_row_union_tail_bound -/ theorem exists_firstFailed_row_union_tail_bound : ∃ C B : ℝ, 0 < C ∧ 0 ≤ B ∧ ∀ᶠ M : ℕ in atTop, ∀ H : ℕ, M ≤ H → ∀ᶠ x : ℝ in atTop, let T := logLog x let A := optimalDimension T let R := coreDimension M T let D := coreDimension H T (((Ico 1 (D-1)).biUnion (retainedFirstFailedValues x A D)).card : ℝ) ≤ C*x/Real.log x*(T^R*modelVolume R)*shiftedPrefixTail (16/225) M B 39 (H-M+1) := by obtain ⟨C, B, hC, hB, hbound⟩ := exists_firstFailed_row_sum_tail_bound refine ⟨C, B, hC, hB, ?_⟩ filter_upwards [hbound] with M hM intro H hMH filter_upwards [hM H hMH] with x hx have hc : (((Ico 1 (coreDimension H (logLog x)-1)).biUnion (retainedFirstFailedValues x (optimalDimension (logLog x)) (coreDimension H (logLog x)))).card : ℝ) ≤ ∑ j ∈ Ico 1 (coreDimension H (logLog x)-1), ((retainedFirstFailedValues x (optimalDimension (logLog x)) (coreDimension H (logLog x)) j).card : ℝ) := by exact_mod_cast Finset.card_biUnion_le exact hc.trans hx /- Original line 47635: Erdos416Proof.FordBadFacet.exists_firstFailed_row_union_V_tail_bound -/ theorem exists_firstFailed_row_union_V_tail_bound : ∃ C B : ℝ, 0 < C ∧ 0 ≤ B ∧ ∀ᶠ M : ℕ in atTop, ∀ H : ℕ, M ≤ H → ∀ᶠ x : ℝ in atTop, (((Ico 1 (coreDimension H (logLog x)-1)).biUnion (retainedFirstFailedValues x (optimalDimension (logLog x)) (coreDimension H (logLog x)))).card : ℝ) ≤ C*shiftedPrefixTail (16/225) M B 39 (H-M+1)*V x := by obtain ⟨C, B, hC, hB, hrows⟩ := exists_firstFailed_row_union_tail_bound obtain ⟨K, hK, hcompare⟩ := FordReciprocal.exists_core_geometric_V_comparison refine ⟨22*C*K, B, by positivity, hB, ?_⟩ filter_upwards [hrows, hcompare, prefixDecay_tendsto.eventually_lt_const (by norm_num : (0 : ℝ) < 1)] with M hM hKM hdecay intro H hMH have hTend : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [hM H hMH, hKM, hTend.eventually (core_ordered_mass_lower M), hTend.eventually_gt_atTop 0, eventually_gt_atTop (1 : ℝ)] with x hrow hV hmodel hT hx have hvol := (hmodel hdecay.le).1 have hx0 : 0 < x := by linarith have hlog : 0 < Real.log x := Real.log_pos hx have hscale : x/Real.log x*((logLog x)^(coreDimension M (logLog x))* modelVolume (coreDimension M (logLog x))) ≤ 22*K*V x := by have hm := mul_le_mul_of_nonneg_left hvol (show 0 ≤ x/Real.log x*(logLog x)^(coreDimension M (logLog x)) by positivity) have hk := mul_le_mul_of_nonneg_left hV (by norm_num : (0 : ℝ) ≤ 22) nlinarith have htail := shiftedPrefixTail_nonneg (16/225) M B 39 (H-M+1) have hb := mul_le_mul_of_nonneg_left hscale (mul_nonneg hC.le htail) apply hrow.trans simpa only [mul_assoc, mul_left_comm, mul_comm, mul_div_assoc] using hb /- Original line 47664: Erdos416Proof.FordBadFacet.firstFailedExceptionalValues_negligible_in_V -/ theorem firstFailedExceptionalValues_negligible_in_V : (fun x : ℝ => ((firstFailedExceptionalValues x (optimalDimension (logLog x))).card : ℝ)) =o[atTop] V := by have hsqrt := V_sqrt_negligible.trans_isBigO square_pruning_scale_isBigO_V have hsquare := largeSquareTotients_negligible.trans_isBigO square_pruning_scale_isBigO_V have hsum := (((hsqrt.add fixed_two_badFacet_negligible_in_V).add fiveLogOmegaTotients_negligible_in_V).add hsquare).add optimal_outer_badFacet_negligible_in_V apply Asymptotics.IsBigO.trans_isLittleO _ hsum apply Asymptotics.IsBigO.of_norm_eventuallyLE filter_upwards [] with x have h₁ := Finset.card_union_le (totientsUpTo (Real.sqrt x)) (badFacetValues x 2 (1/1000)) have h₂ := Finset.card_union_le (totientsUpTo (Real.sqrt x) ∪ badFacetValues x 2 (1/1000)) (fiveLogOmegaTotients x) have h₃ := Finset.card_union_le (totientsUpTo (Real.sqrt x) ∪ badFacetValues x 2 (1/1000) ∪ fiveLogOmegaTotients x) (largeSquareTotients x) have h₄ := Finset.card_union_le (totientsUpTo (Real.sqrt x) ∪ badFacetValues x 2 (1/1000) ∪ fiveLogOmegaTotients x ∪ largeSquareTotients x) (badFacetValues x (optimalDimension (logLog x)) (suffixMargin (optimalDimension (logLog x)))) have hc : (firstFailedExceptionalValues x (optimalDimension (logLog x))).card ≤ (totientsUpTo (Real.sqrt x)).card+(badFacetValues x 2 (1/1000)).card+ (fiveLogOmegaTotients x).card+(largeSquareTotients x).card+ (badFacetValues x (optimalDimension (logLog x)) (suffixMargin (optimalDimension (logLog x)))).card := by unfold firstFailedExceptionalValues omega have hcR : ((firstFailedExceptionalValues x (optimalDimension (logLog x))).card : ℝ) ≤ V (Real.sqrt x)+((badFacetValues x 2 (1/1000)).card : ℝ)+ (fiveLogOmegaTotients x).card+(largeSquareTotients x).card+ (badFacetValues x (optimalDimension (logLog x)) (suffixMargin (optimalDimension (logLog x)))).card := by unfold V exact_mod_cast hc have hnonneg : 0 ≤ V (Real.sqrt x)+((badFacetValues x 2 (1/1000)).card : ℝ)+ (fiveLogOmegaTotients x).card+(largeSquareTotients x).card+ (badFacetValues x (optimalDimension (logLog x)) (suffixMargin (optimalDimension (logLog x)))).card := by have := V_nonneg (Real.sqrt x) positivity have hFnonneg : (0 : ℝ) ≤ (firstFailedExceptionalValues x (optimalDimension (logLog x))).card := Nat.cast_nonneg _ simpa only [Real.norm_eq_abs, abs_of_nonneg hFnonneg, abs_of_nonneg hnonneg] using hcR /-- The missing arithmetic first-failed-row coverage estimate. Increasing the truncation gap makes the actual all-preimage polytope failures an arbitrarily small fraction of the distinct totient values. -/ /- Original line 47706: Erdos416Proof.FordBadFacet.actual_expanded_polytope_failures_small -/ theorem actual_expanded_polytope_failures_small : ∀ ε : ℝ, 0 < ε → ∀ᶠ H : ℕ in atTop, ∀ᶠ x : ℝ in atTop, ((polytopeFailureValues x (coreDimension H (logLog x)) (expandedParameter (optimalDimension (logLog x)))).card : ℝ) ≤ ε*V x := by obtain ⟨C, B, hC, _hB, hrows⟩ := exists_firstFailed_row_union_V_tail_bound obtain ⟨M, hM⟩ := hrows.exists intro ε hε have hsmall : 0 < ε/(2*C) := by positivity filter_upwards [eventually_ge_atTop M, (fixed_reference_shifted_tail_tendsto (16/225) M B).eventually_lt_const hsmall] with H hMH htail have hTend : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [hM H hMH, firstFailedExceptionalValues_negligible_in_V.def (half_pos hε), ((coreDimension_tendsto H).comp hTend).eventually_ge_atTop 2, hTend.eventually_gt_atTop 0, eventually_ge_atTop (Real.exp 1)] with x hrow hexcept hdim hT hx have hLA : coreDimension H (logLog x) ≤ optimalDimension (logLog x) := Nat.sub_le _ _ have hsub := polytopeFailureValues_subset_exceptions_positive_rows hx hT hdim hLA have hcard := (Finset.card_le_card hsub).trans (Finset.card_union_le _ _) have hcardR : ((polytopeFailureValues x (coreDimension H (logLog x)) (expandedParameter (optimalDimension (logLog x)))).card : ℝ) ≤ ((firstFailedExceptionalValues x (optimalDimension (logLog x))).card : ℝ)+ (((Ico 1 (coreDimension H (logLog x)-1)).biUnion (retainedFirstFailedValues x (optimalDimension (logLog x)) (coreDimension H (logLog x)))).card : ℝ) := by exact_mod_cast hcard have he : ((firstFailedExceptionalValues x (optimalDimension (logLog x))).card : ℝ) ≤ ε/2*V x := by have hFnonneg : (0 : ℝ) ≤ (firstFailedExceptionalValues x (optimalDimension (logLog x))).card := Nat.cast_nonneg _ simpa only [Real.norm_eq_abs, abs_of_nonneg hFnonneg, abs_of_nonneg (V_nonneg x)] using hexcept have hcoef : C*shiftedPrefixTail (16/225) M B 39 (H-M+1) ≤ ε/2 := by have ht := (lt_div_iff₀ (by positivity : 0 < 2*C)).mp htail linarith have hr := hrow.trans (mul_le_mul_of_nonneg_right hcoef (V_nonneg x)) linarith end Erdos416Proof.FordBadFacet end /- Consolidated component: OrdinarySplitCount.lean. -/ section open Filter Finset open scoped Classical Topology BigOperators namespace Erdos416Proof.FordBadFacet open FordReciprocal /- Original line 47757: Erdos416Proof.FordBadFacet.ordinary_lower_prefix_mem_tuple -/ theorem ordinary_lower_prefix_mem_tuple {N D : ℕ} {T : ℝ} {E : Set (Fin D → ℝ)} (hT : 0 < T) (hE : E ⊆ Set.Icc (fun _ => 0) (fun _ => 1)) (hpoint : (fun idx : Fin D => ordinaryPrimeCoordinate T N (idx.val+1)) ∈ E) : ordinaryPrefix (ordinarySuffix N 1) D ∈ tupleIntegers D T E := by apply (mem_tupleIntegers hT hE).mpr refine ⟨fun idx => ordinaryPrimeAt (ordinarySuffix N 1) idx.val, (ordinaryPrefix_eq_fin_prod _ _).symm,?_,?_,?_⟩ · intro idx rcases ordinaryPrimeAt_spec (ordinarySuffix N 1) idx.val with h | ⟨h,_⟩ · exact Or.inr h · exact Or.inl h · intro idx j hij exact ordinaryPrimeAt_antitone _ hij · change (fun idx : Fin D => max 0 (logLog (ordinaryPrimeAt (ordinarySuffix N 1) idx.val))/T) ∈ E simpa only [ordinaryPrimeCoordinate,fordPrimeCoordinate,positiveLogLog, ordinaryPrimeAt_suffix,Nat.add_comm] using hpoint /-- The top prime is separated, and the remaining ordered split is allowed to share a boundary prime. All factors are from the same actual integer. -/ /- Original line 47777: Erdos416Proof.FordBadFacet.ordinary_ordered_arithmetic_witness -/ theorem ordinary_ordered_arithmetic_witness {N D : ℕ} {T : ℝ} {E : Set (Fin D → ℝ)} (hN : 0 < N) (hT : 0 < T) (hE : E ⊆ Set.Icc (fun _ => 0) (fun _ => 1)) (hp : (ordinaryPrimeAt N 0).Prime) (hgap : ordinaryPrimeAt N 1 < ordinaryPrimeAt N 0) (hpoint : (fun idx : Fin D => ordinaryPrimeCoordinate T N (idx.val+1)) ∈ E) : ordinaryPrefix (ordinarySuffix N 1) D ∈ tupleIntegers D T E ∧ PrimeSeparated (ordinaryPrefix (ordinarySuffix N 1) D) (ordinarySuffix (ordinarySuffix N 1) D) ∧ N.totient = (ordinaryPrimeAt N 0-1)* (ordinaryPrefix (ordinarySuffix N 1) D*ordinarySuffix (ordinarySuffix N 1) D).totient := by refine ⟨ordinary_lower_prefix_mem_tuple hT hE hpoint, ordinary_prefix_suffix_primeSeparated _ _,?_⟩ have hpre : ordinaryPrefix N 1 = ordinaryPrimeAt N 0 := by rw [ordinaryPrefix_eq_fin_prod] simp have htop := ordinary_split_totient hN (by decide : 0 < 1) (by simpa only [Nat.sub_self] using hgap) rw [hpre,Nat.totient_prime hp] at htop rw [ordinary_split (ordinarySuffix_pos N 1) D] exact htop /-- An actual represented-value count for any geometric subset of the ordinary lower-prime tuple, retaining all boundary multiplicities. -/ /- Original line 47800: Erdos416Proof.FordBadFacet.exists_ordinary_geometric_split_count -/ theorem exists_ordinary_geometric_split_count : ∃ C : ℝ, 0 < C ∧ ∀ (D : ℕ) (T x h : ℝ) (E : Set (Fin D → ℝ)) (W F : Finset ℕ), 0 < T → 0 < x → 0 < h → E ⊆ Set.Icc (fun _ => 0) (fun _ => 1) → (∀ m ∈ W, 0 < m) → (∀ v ∈ F, (v : ℝ) ≤ x ∧ ∃ N : ℕ, 0 < N ∧ N.totient = v ∧ (ordinaryPrimeAt N 0).Prime ∧ h ≤ Real.log (ordinaryPrimeAt N 0) ∧ ordinaryPrimeAt N 1 < ordinaryPrimeAt N 0 ∧ (fun idx : Fin D => ordinaryPrimeCoordinate T N (idx.val+1)) ∈ E ∧ (ordinarySuffix (ordinarySuffix N 1) D).totient ∈ W) → (F.card : ℝ) ≤ C*x/h*tupleReciprocalMass D T E*(∑ m ∈ W, (1 : ℝ)/m) := by obtain ⟨C,hC,hcount⟩ := exists_ordered_prime_prefix_suffix_count refine ⟨C,hC,?_⟩ intro D T x h E W F hT hx hh hE hW hF apply hcount (tupleIntegers D T E) W F x h hx hh (fun a ha => (Finset.mem_Icc.mp (Finset.mem_filter.mp ha).1).1) hW intro v hv obtain ⟨hvx,N,hN,hNv,hp,hlog,hgap,hpoint,hWmem⟩ := hF v hv obtain ⟨htuple,hsep,hprod⟩ := ordinary_ordered_arithmetic_witness hN hT hE hp hgap hpoint exact ⟨hvx,ordinaryPrimeAt N 0,ordinaryPrefix (ordinarySuffix N 1) D, ordinarySuffix (ordinarySuffix N 1) D,hp,hlog,htuple,hWmem,hsep,hNv ▸ hprod⟩ end Erdos416Proof.FordBadFacet end /- Consolidated component: LargeSmoothTail.lean. -/ section open Filter Finset open scoped Classical Topology BigOperators namespace Erdos416Proof.FordBadFacet /-- A size cutoff on an actual smooth preimage, rather than on its totient, already yields a reciprocal saving for the distinct resulting values. -/ /- Original line 47839: Erdos416Proof.FordBadFacet.exists_large_smooth_preimage_reciprocal_bound -/ theorem exists_large_smooth_preimage_reciprocal_bound : ∃ C : ℝ, 0 < C ∧ ∀ z R : ℝ, Real.exp 20 ≤ z → 0 < R → ∀ F : Finset ℕ, (∀ m ∈ F, ∃ N : ℕ, 0 < N ∧ N.totient = m ∧ R ≤ (N : ℝ) ∧ N ∈ Nat.factoredNumbers (Nat.primesLE ⌊z⌋₊)) → R^(5/Real.log z)*(∑ m ∈ F, (1 : ℝ)/m) ≤ C*Real.log z := by obtain ⟨C,hC,hbound⟩ := FordRestricted.exists_smooth_weighted_reciprocal_bound refine ⟨C,hC,?_⟩ intro z R hz hR F hF choose P hPpos hPtot hPlarge hPsmooth using (fun m : F => hF m.val m.property) have hPinj : Function.Injective P := by intro m n hmn apply Subtype.ext rw [← hPtot m,← hPtot n,hmn] let G : Finset ℕ := univ.image P have hG : ∀ n ∈ G, n ∈ Nat.factoredNumbers (Nat.primesLE ⌊z⌋₊) := by intro n hn obtain ⟨m,_,rfl⟩ := mem_image.mp hn exact hPsmooth m have hsum := hbound z hz G hG have he : (∑ n ∈ G, (n : ℝ)^(5/Real.log z)*invTotient n) = ∑ m : F, (P m : ℝ)^(5/Real.log z)*invTotient (P m) := sum_image (fun _ _ _ _ he => hPinj he) rw [he] at hsum have hlog : 20 ≤ Real.log z := by simpa only [Real.log_exp] using Real.log_le_log (Real.exp_pos 20) hz have hδ : 0 ≤ 5/Real.log z := div_nonneg (by norm_num) (by linarith) have hpoint (m : F) : R^(5/Real.log z)*((1 : ℝ)/m.val) ≤ (P m : ℝ)^(5/Real.log z)*invTotient (P m) := by have hr := Real.rpow_le_rpow hR.le (hPlarge m) hδ have hi : invTotient (P m) = (1 : ℝ)/m.val := by simp only [invTotient,hPtot m,one_div] rw [hi] exact mul_le_mul_of_nonneg_right hr (one_div_nonneg.mpr (Nat.cast_nonneg _)) have hrecip := (sum_le_sum (fun m _ => hpoint m)).trans hsum rwa [← mul_sum,Finset.sum_coe_sort F (fun m : ℕ => (1 : ℝ)/m)] at hrecip /-- For each fixed smoothness bound, large actual residual preimages have arbitrarily small reciprocal mass, uniformly over every finite value set. -/ /- Original line 47877: Erdos416Proof.FordBadFacet.large_smooth_preimage_reciprocal_small -/ theorem large_smooth_preimage_reciprocal_small {z : ℝ} (hz : Real.exp 20 ≤ z) {ε : ℝ} (hε : 0 < ε) : ∀ᶠ R : ℝ in atTop, ∀ F : Finset ℕ, (∀ m ∈ F, ∃ N : ℕ, 0 < N ∧ N.totient = m ∧ R ≤ (N : ℝ) ∧ N ∈ Nat.factoredNumbers (Nat.primesLE ⌊z⌋₊)) → (∑ m ∈ F, (1 : ℝ)/m) ≤ ε := by obtain ⟨C,hC,hbound⟩ := exists_large_smooth_preimage_reciprocal_bound have hlog : 20 ≤ Real.log z := by simpa only [Real.log_exp] using Real.log_le_log (Real.exp_pos 20) hz have hδ : 0 < 5/Real.log z := div_pos (by norm_num) (by linarith) filter_upwards [(tendsto_rpow_atTop hδ).eventually_ge_atTop (C*Real.log z/ε), eventually_gt_atTop (0 : ℝ)] with R hlarge hR intro F hF have h := hbound z R hz hR F hF have hsmall := (div_le_iff₀ hε).mp hlarge apply (mul_le_mul_iff_of_pos_left (Real.rpow_pos_of_pos hR (5/Real.log z))).mp nlinarith end Erdos416Proof.FordBadFacet end /- Consolidated component: GeometricValueCount.lean. -/ section open Filter Finset open scoped Classical Topology BigOperators namespace Erdos416Proof.FordBadFacet open FordReciprocal FordScale /- Original line 47913: Erdos416Proof.FordBadFacet.preimagePropertyValues -/ noncomputable def preimagePropertyValues (x : ℝ) (Q : ℕ → Prop) : Finset ℕ := (totientsUpTo x).filter (fun m => ∃ n : ℕ, 0 < n ∧ n.totient = m ∧ Q n) /- Original line 47916: Erdos416Proof.FordBadFacet.retainedGeometricValues -/ noncomputable def retainedGeometricValues (x : ℝ) (D : ℕ) (E : Set (Fin D → ℝ)) (Q : ℕ → Prop) : Finset ℕ := (totientsUpTo x).filter (fun m => Real.sqrt x ≤ (m : ℝ) ∧ m ∉ badFacetValues x 2 (1/1000) ∧ m ∉ fiveLogOmegaTotients x ∧ m ∉ largeSquareTotients x ∧ ∃ N : ℕ, 0 < N ∧ N.totient = m ∧ (fun idx : Fin D => ordinaryPrimeCoordinate (logLog x) N (idx.val+1)) ∈ E ∧ Q (ordinarySuffix (ordinarySuffix N 1) D)) /- Original line 47924: Erdos416Proof.FordBadFacet.preimagePropertyValues_pos -/ theorem preimagePropertyValues_pos {x : ℝ} {Q : ℕ → Prop} (hx : 0 ≤ x) : ∀ m ∈ preimagePropertyValues x Q, 0 < m := by intro m hm exact ((mem_totientsUpTo hx).mp (Finset.mem_filter.mp hm).1).1 /- Original line 47929: Erdos416Proof.FordBadFacet.ordinary_residual_totient_le -/ theorem ordinary_residual_totient_le {N : ℕ} (hN : 0 < N) (D : ℕ) : (ordinarySuffix (ordinarySuffix N 1) D).totient ≤ N.totient := (ordinarySuffix_totient_le (ordinarySuffix_pos N 1) D).trans (ordinarySuffix_totient_le hN 1) /-- A uniform arithmetic transfer from arbitrary actual lower-prime geometry and an actual residual property to reciprocal masses. -/ /- Original line 47935: Erdos416Proof.FordBadFacet.exists_retained_geometric_value_count -/ theorem exists_retained_geometric_value_count : ∃ C : ℝ, 0 < C ∧ ∀ᶠ x : ℝ in atTop, ∀ (D : ℕ) (E : Set (Fin D → ℝ)) (Q : ℕ → Prop), E ⊆ Set.Icc (fun _ => 0) (fun _ => 1) → ((retainedGeometricValues x D E Q).card : ℝ) ≤ C*x/Real.log x*tupleReciprocalMass D (logLog x) E* (∑ m ∈ preimagePropertyValues x Q, (1 : ℝ)/m) := by obtain ⟨C,hC,hcount⟩ := exists_ordinary_geometric_split_count refine ⟨6*C,by positivity,?_⟩ have hLL : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [ordinary_top_log_lower_outside_fixed_facet, eventually_fourth_log_cutoff_lt_large_prime,hLL.eventually_gt_atTop 0, eventually_gt_atTop (1 : ℝ)] with x htop hcut hT hx have hx0 : 0 < x := by linarith have hlog : 0 < Real.log x := Real.log_pos hx intro D E Q hE have hrepr : ∀ v ∈ retainedGeometricValues x D E Q, (v : ℝ) ≤ x ∧ ∃ N : ℕ, 0 < N ∧ N.totient = v ∧ (ordinaryPrimeAt N 0).Prime ∧ Real.log x/6 ≤ Real.log (ordinaryPrimeAt N 0) ∧ ordinaryPrimeAt N 1 < ordinaryPrimeAt N 0 ∧ (fun idx : Fin D => ordinaryPrimeCoordinate (logLog x) N (idx.val+1)) ∈ E ∧ (ordinarySuffix (ordinarySuffix N 1) D).totient ∈ preimagePropertyValues x Q := by intro v hv obtain ⟨hvV,hvlarge,hvbad,hvΩ,hvSq,N,hN,hNv,hpoint,hQ⟩ := Finset.mem_filter.mp hv have hvx := ((mem_totientsUpTo hx0.le).mp hvV).2.1 obtain ⟨hp,hplog⟩ := htop v N hvV hvlarge hN hNv hvbad hvΩ hvSq have hSqN : NoLargePrimeSquare N (Real.log x^4) := by intro q hq hlarge hdiv exact hvSq (Finset.mem_filter.mpr ⟨hvV,N,hN,hNv,q,hq,hlarge,Or.inl hdiv⟩) have hgap := ordinary_top_gap_of_top_large_square_exclusion hN hcut.1 hSqN (hcut.2 _ hp hplog) have hres := ordinarySuffix_pos (ordinarySuffix N 1) D have hresle : ((ordinarySuffix (ordinarySuffix N 1) D).totient : ℝ) ≤ x := by have h : ((ordinarySuffix (ordinarySuffix N 1) D).totient : ℝ) ≤ N.totient := Nat.cast_le.mpr (ordinary_residual_totient_le hN D) rw [hNv] at h exact h.trans hvx refine ⟨hvx,N,hN,hNv,hp,hplog,hgap,hpoint,?_⟩ exact Finset.mem_filter.mpr ⟨(mem_totientsUpTo hx0.le).mpr ⟨Nat.totient_pos.mpr hres,hresle,ordinarySuffix (ordinarySuffix N 1) D,hres,rfl⟩, ordinarySuffix (ordinarySuffix N 1) D,hres,rfl,hQ⟩ have hc := hcount D (logLog x) x (Real.log x/6) E (preimagePropertyValues x Q) (retainedGeometricValues x D E Q) hT hx0 (by positivity) hE (preimagePropertyValues_pos hx0.le) hrepr exact hc.trans_eq (by ring) end Erdos416Proof.FordBadFacet end /- Consolidated component: TerminalValueCount.lean. -/ section open Filter Asymptotics Finset open scoped Classical Topology BigOperators namespace Erdos416Proof.FordBadFacet open FordRestricted FordReciprocal FordScale FordGeometry /-- Totient values preserve an upper bound on all prime divisors of a positive preimage. -/ /- Original line 47999: Erdos416Proof.FordBadFacet.totient_mem_factored_primesLE -/ theorem totient_mem_factored_primesLE {n : ℕ} {z : ℝ} (hz : 0 ≤ z) (hn : n ∈ Nat.factoredNumbers (Nat.primesLE ⌊z⌋₊)) : n.totient ∈ Nat.factoredNumbers (Nat.primesLE ⌊z⌋₊) := by have hpred (p : ℕ) (hp : p ∈ n.primeFactors) : p-1 ∈ Nat.factoredNumbers (Nat.primesLE ⌊z⌋₊) := by have hpprime := (Nat.mem_primeFactors.mp hp).1 have hple := (Nat.mem_primesLE.mp ((Nat.primeFactors_subset_of_mem_factoredNumbers hn) hp)).1 apply factored_primesLE_of_positive_le (by have := hpprime.two_le; omega) exact (Nat.cast_le.mpr ((Nat.sub_le p 1).trans hple)).trans (Nat.floor_le hz) have hprod (S : Finset ℕ) (hS : S ⊆ n.primeFactors) : (∏ p ∈ S, (p-1)) ∈ Nat.factoredNumbers (Nat.primesLE ⌊z⌋₊) := by induction S using Finset.induction_on with | empty => simp [Nat.mem_factoredNumbers] | @insert p S hp ih => rw [Finset.prod_insert hp] exact Nat.mul_mem_factoredNumbers (hpred p (hS (Finset.mem_insert_self _ _))) (ih (fun q hq => hS (Finset.mem_insert_of_mem hq))) apply Nat.mem_factoredNumbers_of_dvd (Nat.mul_mem_factoredNumbers hn (hprod n.primeFactors (fun _ h => h))) exact ⟨∏ p ∈ n.primeFactors, p, (Nat.totient_mul_prod_primeFactors n).symm⟩ /- Original line 48021: Erdos416Proof.FordBadFacet.terminalBandCutoff -/ noncomputable def terminalBandCutoff (b : ℕ) : ℝ := Real.exp (Real.exp ((b : ℝ)+1)) /- Original line 48023: Erdos416Proof.FordBadFacet.terminalBandSuffixValues -/ noncomputable def terminalBandSuffixValues (x : ℝ) (b : ℕ) : Finset ℕ := (totientsUpTo x).filter (fun m => m ∈ Nat.factoredNumbers (Nat.primesLE ⌊terminalBandCutoff b⌋₊)) /- Original line 48027: Erdos416Proof.FordBadFacet.terminalBandCutoff_tendsto -/ theorem terminalBandCutoff_tendsto : Tendsto terminalBandCutoff atTop atTop := Real.tendsto_exp_atTop.comp (Real.tendsto_exp_atTop.comp (tendsto_atTop_add_const_right _ _ tendsto_natCast_atTop_atTop)) /- Original line 48031: Erdos416Proof.FordBadFacet.terminalBandSuffixValues_pos -/ theorem terminalBandSuffixValues_pos {x : ℝ} {b m : ℕ} (hx : 0 ≤ x) (hm : m ∈ terminalBandSuffixValues x b) : 0 < m := ((mem_totientsUpTo hx).mp (Finset.mem_filter.mp hm).1).1 /-- The reciprocal suffix factor in each terminal-coordinate band is subexponential in the band index. The endpoint x is arbitrary. -/ /- Original line 48037: Erdos416Proof.FordBadFacet.eventually_terminalBandSuffixValues_reciprocal_bound -/ theorem eventually_terminalBandSuffixValues_reciprocal_bound : ∀ᶠ b : ℕ in atTop, ∀ x : ℝ, 0 ≤ x → (∑ m ∈ terminalBandSuffixValues x b, (1 : ℝ)/m) ≤ Real.exp (16*(Real.log ((b : ℝ)+1))^2) := by filter_upwards [terminalBandCutoff_tendsto.eventually restricted_totient_reciprocal_explicit_bound] with b hb intro x hx have h := hb (terminalBandSuffixValues x b) (fun m hm => (Finset.mem_filter.mp hm).2) (fun m hm => ((mem_totientsUpTo hx).mp (Finset.mem_filter.mp hm).1).2.2) simpa only [terminalBandCutoff, logLog, Real.log_exp] using h /- Original line 48049: Erdos416Proof.FordBadFacet.terminalBandEnvelope -/ noncomputable def terminalBandEnvelope (M b : ℕ) : ℝ := Real.exp (-terminalCapRate M*(b : ℝ)+16*(Real.log ((b : ℝ)+1))^2) /- Original line 48052: Erdos416Proof.FordBadFacet.terminalBandEnvelope_nonneg -/ theorem terminalBandEnvelope_nonneg (M b : ℕ) : 0 ≤ terminalBandEnvelope M b := (Real.exp_pos _).le /- Original line 48054: Erdos416Proof.FordBadFacet.terminalBandEnvelope_summable -/ theorem terminalBandEnvelope_summable (M : ℕ) : Summable (terminalBandEnvelope M) := by have hr := terminalCapRate_pos M have hgeo : Summable (fun b : ℕ => Real.exp ((b : ℝ)*(-terminalCapRate M/2))) := Real.summable_exp_nat_mul_iff.mpr (by linarith) apply hgeo.of_norm_bounded_eventually_nat have ht : Tendsto (fun b : ℕ => (b : ℝ)+1) atTop atTop := tendsto_atTop_add_const_right _ _ tendsto_natCast_atTop_atTop filter_upwards [ht.eventually ((Real.isLittleO_pow_log_id_atTop (n := 2)).bound (show 0 < terminalCapRate M/64 by positivity)), eventually_ge_atTop (1 : ℕ)] with b hb hb1 have hb0 : (0 : ℝ) ≤ b := Nat.cast_nonneg b have hb1' : (1 : ℝ) ≤ b := by exact_mod_cast hb1 have hlog : (Real.log ((b : ℝ)+1))^2 ≤ terminalCapRate M/64*((b : ℝ)+1) := by simpa only [Real.norm_eq_abs, id_eq, abs_of_nonneg (sq_nonneg (Real.log ((b : ℝ)+1))), abs_of_nonneg (by linarith : 0 ≤ (b : ℝ)+1)] using hb rw [Real.norm_eq_abs, abs_of_nonneg (terminalBandEnvelope_nonneg M b)] apply Real.exp_le_exp.mpr nlinarith [mul_nonneg hr.le (show 0 ≤ (b : ℝ)-1 by linarith)] /- Original line 48072: Erdos416Proof.FordBadFacet.terminalBandTail -/ noncomputable def terminalBandTail (M B : ℕ) : ℝ := ∑' b : ℕ, terminalBandEnvelope M (b+B) /- Original line 48075: Erdos416Proof.FordBadFacet.terminalBandTail_nonneg -/ theorem terminalBandTail_nonneg (M B : ℕ) : 0 ≤ terminalBandTail M B := tsum_nonneg (fun b => terminalBandEnvelope_nonneg M (b+B)) /- Original line 48078: Erdos416Proof.FordBadFacet.terminalBandTail_tendsto -/ theorem terminalBandTail_tendsto (M : ℕ) : Tendsto (terminalBandTail M) atTop (nhds 0) := tendsto_sum_nat_add (terminalBandEnvelope M) /- Original line 48081: Erdos416Proof.FordBadFacet.finite_terminalBand_tail_bound -/ theorem finite_terminalBand_tail_bound (M B : ℕ) (F : Finset ℕ) (hF : ∀ b ∈ F, B ≤ b) : (∑ b ∈ F, terminalBandEnvelope M b) ≤ terminalBandTail M B := by let G := F.image (fun b => b-B) have hinj : Set.InjOn (fun b : ℕ => b-B) (F : Set ℕ) := by intro b hb c hc he have hb' := hF b hb have hc' := hF c hc change b-B = c-B at he omega have he : (∑ b ∈ F, terminalBandEnvelope M b) = ∑ b ∈ G, terminalBandEnvelope M (b+B) := by rw [show G = F.image (fun b => b-B) by rfl, Finset.sum_image hinj] apply Finset.sum_congr rfl intro b hb rw [Nat.sub_add_cancel (hF b hb)] have hs : Summable (fun b : ℕ => terminalBandEnvelope M (b+B)) := (terminalBandEnvelope_summable M).comp_injective (fun _ _ h => Nat.add_right_cancel h) rw [he] exact hs.sum_le_tsum G (fun b _ => terminalBandEnvelope_nonneg M (b+B)) /-- The retained terminal band is defined using an actual positive preimage and its ordinary prime coordinates, including repeated primes. -/ /- Original line 48103: Erdos416Proof.FordBadFacet.retainedTerminalBandValues -/ noncomputable def retainedTerminalBandValues (x : ℝ) (M b : ℕ) : Finset ℕ := (totientsUpTo x).filter (fun m => Real.sqrt x ≤ (m : ℝ) ∧ m ∉ badFacetValues x 2 (1/1000) ∧ m ∉ fiveLogOmegaTotients x ∧ m ∉ largeSquareTotients x ∧ ∃ N : ℕ, 0 < N ∧ N.totient = m ∧ (fun idx : Fin (coreDimension M (logLog x)) => ordinaryPrimeCoordinate (logLog x) N (idx.val+1)) ∈ polytope (coreDimension M (logLog x)) (expandedParameter (optimalDimension (logLog x))) ∧ (b : ℝ) ≤ positiveLogLog (ordinaryPrimeAt N (coreDimension M (logLog x))) ∧ positiveLogLog (ordinaryPrimeAt N (coreDimension M (logLog x))) < (b : ℝ)+1) /- Original line 48113: Erdos416Proof.FordBadFacet.retainedTerminalTailValues -/ noncomputable def retainedTerminalTailValues (x : ℝ) (M B : ℕ) : Finset ℕ := (totientsUpTo x).filter (fun m => Real.sqrt x ≤ (m : ℝ) ∧ m ∉ badFacetValues x 2 (1/1000) ∧ m ∉ fiveLogOmegaTotients x ∧ m ∉ largeSquareTotients x ∧ ∃ N : ℕ, 0 < N ∧ N.totient = m ∧ (fun idx : Fin (coreDimension M (logLog x)) => ordinaryPrimeCoordinate (logLog x) N (idx.val+1)) ∈ polytope (coreDimension M (logLog x)) (expandedParameter (optimalDimension (logLog x))) ∧ (B : ℝ) ≤ positiveLogLog (ordinaryPrimeAt N (coreDimension M (logLog x)))) /- Original line 48122: Erdos416Proof.FordBadFacet.le_exp_exp_of_positiveLogLog_le -/ theorem le_exp_exp_of_positiveLogLog_le {q u : ℝ} (hq : 1 ≤ q) (hu : positiveLogLog q ≤ u) : q ≤ Real.exp (Real.exp u) := by rcases eq_or_lt_of_le hq with rfl | hq' · exact (Real.one_lt_exp_iff.mpr (Real.exp_pos _)).le · have hlog := Real.log_pos hq' have hLL : logLog q ≤ u := (le_max_right _ _).trans hu have h₁ := Real.exp_le_exp.mpr hLL change Real.exp (Real.log (Real.log q)) ≤ Real.exp u at h₁ rw [Real.exp_log hlog] at h₁ have h₂ := Real.exp_le_exp.mpr h₁ simpa only [Real.exp_log (by linarith : 0 < q)] using h₂ /- Original line 48134: Erdos416Proof.FordBadFacet.actual_terminal_suffix_mem_band -/ theorem actual_terminal_suffix_mem_band {N D b : ℕ} {x : ℝ} (hN : 0 < N) (hx : 0 ≤ x) (hphi : (N.totient : ℝ) ≤ x) (hband : positiveLogLog (ordinaryPrimeAt N D) < (b : ℝ)+1) : (ordinarySuffix (ordinarySuffix N 1) D).totient ∈ terminalBandSuffixValues x b := by let Q := ordinarySuffix (ordinarySuffix N 1) D have hQ : 0 < Q := ordinarySuffix_pos _ _ have hQphi : (Q.totient : ℝ) ≤ x := (Nat.cast_le.mpr ((ordinarySuffix_totient_le (ordinarySuffix_pos N 1) D).trans (ordinarySuffix_totient_le hN 1))).trans hphi have hqbound : (ordinaryPrimeAt N D : ℝ) ≤ terminalBandCutoff b := le_exp_exp_of_positiveLogLog_le (by exact_mod_cast ordinaryPrimeAt_one_le N D) hband.le have hsmooth : Q ∈ Nat.factoredNumbers (Nat.primesLE ⌊terminalBandCutoff b⌋₊) := by apply ordinarySuffix_factored_of_boundary_le rw [ordinaryPrimeAt_suffix] exact (Nat.cast_le.mpr (ordinaryPrimeAt_antitone N (show D ≤ 1+D by omega))).trans hqbound exact Finset.mem_filter.mpr ⟨(mem_totientsUpTo hx).mpr ⟨Nat.totient_pos.mpr hQ, hQphi, Q, hQ, rfl⟩, totient_mem_factored_primesLE (Real.exp_pos _).le hsmooth⟩ /- Original line 48153: Erdos416Proof.FordBadFacet.actual_terminal_point_mem_cap -/ theorem actual_terminal_point_mem_cap {N M b : ℕ} {x : ℝ} (hT : 0 < logLog x) (hD : 1 ≤ coreDimension M (logLog x)) (hpoint : (fun idx : Fin (coreDimension M (logLog x)) => ordinaryPrimeCoordinate (logLog x) N (idx.val+1)) ∈ polytope (coreDimension M (logLog x)) (expandedParameter (optimalDimension (logLog x)))) (hlow : (b : ℝ) ≤ positiveLogLog (ordinaryPrimeAt N (coreDimension M (logLog x)))) : (fun idx : Fin (coreDimension M (logLog x)) => ordinaryPrimeCoordinate (logLog x) N (idx.val+1)) ∈ coreTerminalCap M (b : ℝ) (logLog x) := by let p : Fin (coreDimension M (logLog x)) := ⟨coreDimension M (logLog x)-1, by omega⟩ have hp : p.val+1 = coreDimension M (logLog x) := by dsimp [Erdos416Proof.FordBadFacet.positiveLogLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_bottom, Erdos416Proof.FordBadFacet.reversedFacetLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_succ, Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.FordRestricted.suffixCutoff_log3, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, p]; omega refine ⟨hpoint, p, hp, ?_⟩ change (b : ℝ)/logLog x ≤ positiveLogLog (ordinaryPrimeAt N (p.val+1))/logLog x rw [hp] exact div_le_div_of_nonneg_right hlow hT.le /- Original line 48168: Erdos416Proof.FordBadFacet.retained_terminal_band_representation_eventually -/ theorem retained_terminal_band_representation_eventually (M : ℕ) : ∀ᶠ x : ℝ in atTop, ∀ b : ℕ, ∀ v ∈ retainedTerminalBandValues x M b, (v : ℝ) ≤ x ∧ ∃ N : ℕ, 0 < N ∧ N.totient = v ∧ (ordinaryPrimeAt N 0).Prime ∧ Real.log x/6 ≤ Real.log (ordinaryPrimeAt N 0) ∧ ordinaryPrimeAt N 1 < ordinaryPrimeAt N 0 ∧ (fun idx : Fin (coreDimension M (logLog x)) => ordinaryPrimeCoordinate (logLog x) N (idx.val+1)) ∈ coreTerminalCap M (b : ℝ) (logLog x) ∧ (ordinarySuffix (ordinarySuffix N 1) (coreDimension M (logLog x))).totient ∈ terminalBandSuffixValues x b := by have hLL : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [ordinary_top_log_lower_outside_fixed_facet, eventually_fourth_log_cutoff_lt_large_prime, hLL.eventually (coreDimension_eventual_mesh M), hLL.eventually_gt_atTop 0, eventually_gt_atTop (1 : ℝ)] with x htop hlarge hdim hT hx intro b v hv obtain ⟨hvV, hvlarge, hvbad, hvOmega, hvSquare, N, hN, hNv, hpoint, hlow, hupp⟩ := Finset.mem_filter.mp hv have hvx := ((mem_totientsUpTo (by linarith : 0 ≤ x)).mp hvV).2.1 obtain ⟨hp, hplog⟩ := htop v N hvV hvlarge hN hNv hvbad hvOmega hvSquare have hSq : NoLargePrimeSquare N (Real.log x^4) := by intro q hq hqbig hqdvd exact hvSquare (Finset.mem_filter.mpr ⟨hvV, N, hN, hNv, q, hq, hqbig, Or.inl hqdvd⟩) have hgap := ordinary_top_gap_of_top_large_square_exclusion hN hlarge.1 hSq (hlarge.2 _ hp hplog) refine ⟨hvx, N, hN, hNv, hp, hplog, hgap, ?_, ?_⟩ · exact actual_terminal_point_mem_cap hT (by have := hdim.1; omega) hpoint hlow · exact actual_terminal_suffix_mem_band hN (by linarith) (by simpa only [hNv] using hvx) hupp /-- Actual distinct value counts in every sufficiently high terminal band. The scale threshold is uniform in the band index. -/ /- Original line 48196: Erdos416Proof.FordBadFacet.exists_retained_terminal_band_count -/ theorem exists_retained_terminal_band_count : ∃ C : ℝ, 0 < C ∧ ∃ B₀ : ℕ, ∀ᶠ M : ℕ in atTop, ∀ᶠ x : ℝ in atTop, ∀ b : ℕ, B₀ ≤ b → ((retainedTerminalBandValues x M b).card : ℝ) ≤ C*terminalBandEnvelope M b*V x := by obtain ⟨J, hJ, hcount⟩ := exists_ordinary_geometric_split_count obtain ⟨K, hK, hcap⟩ := exists_core_terminal_cap_mass_V_bound obtain ⟨B₀, hB₀⟩ := eventually_atTop.mp eventually_terminalBandSuffixValues_reciprocal_bound refine ⟨6*J*K, by positivity, B₀, ?_⟩ filter_upwards [hcap] with M hcap have hLL : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [hcap, retained_terminal_band_representation_eventually M, hLL.eventually_gt_atTop 0, eventually_gt_atTop (1 : ℝ)] with x hcap hrepr hT hx intro b hb have hx0 : 0 < x := by linarith have hlog : 0 < Real.log x := Real.log_pos hx have hE : coreTerminalCap M (b : ℝ) (logLog x) ⊆ Set.Icc (fun _ => 0) (fun _ => 1) := fun _ h => ⟨h.1.1, h.1.2.1⟩ have hc := hcount (coreDimension M (logLog x)) (logLog x) x (Real.log x/6) (coreTerminalCap M (b : ℝ) (logLog x)) (terminalBandSuffixValues x b) (retainedTerminalBandValues x M b) hT hx0 (by positivity) hE (fun m hm => terminalBandSuffixValues_pos hx0.le hm) (hrepr b) have hsuffix := hB₀ b hb x hx0.le have hgeom := hcap (b : ℝ) (Nat.cast_nonneg b) have hmass := coreTerminalCapMass_nonneg M (b : ℝ) (logLog x) change ((retainedTerminalBandValues x M b).card : ℝ) ≤ J*x/(Real.log x/6)*coreTerminalCapMass M (b : ℝ) (logLog x)* (∑ m ∈ terminalBandSuffixValues x b, (1 : ℝ)/m) at hc calc _ ≤ _ := hc _ ≤ J*x/(Real.log x/6)*coreTerminalCapMass M (b : ℝ) (logLog x)* Real.exp (16*(Real.log ((b : ℝ)+1))^2) := mul_le_mul_of_nonneg_left hsuffix (mul_nonneg (by positivity) hmass) _ = (6*J*Real.exp (16*(Real.log ((b : ℝ)+1))^2))* ((x/Real.log x)*coreTerminalCapMass M (b : ℝ) (logLog x)) := by ring _ ≤ (6*J*Real.exp (16*(Real.log ((b : ℝ)+1))^2))* (K*Real.exp (-(terminalCapRate M*(b : ℝ)))*V x) := mul_le_mul_of_nonneg_left hgeom (by positivity) _ = _ := by unfold terminalBandEnvelope rw [Real.exp_add] rw [show -terminalCapRate M*(b : ℝ) = -(terminalCapRate M*(b : ℝ)) by ring] ring /- Original line 48239: Erdos416Proof.FordBadFacet.retainedTerminalTailValues_subset_bands -/ theorem retainedTerminalTailValues_subset_bands {x : ℝ} {M B : ℕ} (hT : 0 < logLog x) (hD : 1 ≤ coreDimension M (logLog x)) : retainedTerminalTailValues x M B ⊆ (Finset.Icc B ⌊logLog x⌋₊).biUnion (retainedTerminalBandValues x M) := by intro m hm obtain ⟨hmV, hlarge, hbad, hOmega, hSquare, N, hN, hNm, hpoint, hlow⟩ := Finset.mem_filter.mp hm let u := positiveLogLog (ordinaryPrimeAt N (coreDimension M (logLog x))) have hu0 : 0 ≤ u := le_max_left _ _ have huT : u ≤ logLog x := by let p : Fin (coreDimension M (logLog x)) := ⟨coreDimension M (logLog x)-1, by omega⟩ have hp : p.val+1 = coreDimension M (logLog x) := by dsimp [Erdos416Proof.FordBadFacet.positiveLogLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_bottom, Erdos416Proof.FordBadFacet.reversedFacetLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_succ, Erdos416Proof.FordGeometry.slackMap_apply, Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.FordRestricted.suffixCutoff_log3, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, p]; omega have h := hpoint.2.1 p change positiveLogLog (ordinaryPrimeAt N (p.val+1))/logLog x ≤ 1 at h rw [hp] at h exact (div_le_one hT).mp h have hB : B ≤ ⌊u⌋₊ := Nat.le_floor hlow have hupper : ⌊u⌋₊ ≤ ⌊logLog x⌋₊ := Nat.floor_mono huT apply Finset.mem_biUnion.mpr refine ⟨⌊u⌋₊, Finset.mem_Icc.mpr ⟨hB, hupper⟩, ?_⟩ exact Finset.mem_filter.mpr ⟨hmV, hlarge, hbad, hOmega, hSquare, N, hN, hNm, hpoint, Nat.floor_le hu0, Nat.lt_floor_add_one u⟩ /- Original line 48261: Erdos416Proof.FordBadFacet.retainedTerminalTailValues_card_le_band_sum -/ theorem retainedTerminalTailValues_card_le_band_sum {x : ℝ} {M B : ℕ} (hT : 0 < logLog x) (hD : 1 ≤ coreDimension M (logLog x)) : ((retainedTerminalTailValues x M B).card : ℝ) ≤ ∑ b ∈ Finset.Icc B ⌊logLog x⌋₊, ((retainedTerminalBandValues x M b).card : ℝ) := by have hc : (retainedTerminalTailValues x M B).card ≤ ∑ b ∈ Finset.Icc B ⌊logLog x⌋₊, (retainedTerminalBandValues x M b).card := (Finset.card_le_card (retainedTerminalTailValues_subset_bands (B := B) hT hD)).trans Finset.card_biUnion_le exact_mod_cast hc /-- Summing actual terminal bands makes the terminal-prime exceptional values arbitrarily sparse at every sufficiently large fixed core depth. -/ /- Original line 48273: Erdos416Proof.FordBadFacet.retained_terminal_tail_values_small_in_V -/ theorem retained_terminal_tail_values_small_in_V : ∀ᶠ M : ℕ in atTop, ∀ ε : ℝ, 0 < ε → ∃ B : ℕ, ∀ᶠ x : ℝ in atTop, ((retainedTerminalTailValues x M B).card : ℝ) ≤ ε*V x := by obtain ⟨C, hC, B₀, hband⟩ := exists_retained_terminal_band_count filter_upwards [hband] with M hband intro ε hε have htail : Tendsto (fun B => C*terminalBandTail M B) atTop (nhds 0) := by simpa only [mul_zero] using (terminalBandTail_tendsto M).const_mul C have htailε : ∀ᶠ B : ℕ in atTop, C*terminalBandTail M B < ε := by exact htail.eventually_lt_const hε obtain ⟨B, hB₀, hBε⟩ := ((eventually_ge_atTop B₀).and htailε).exists refine ⟨B, ?_⟩ have hLL : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [hband, hLL.eventually_gt_atTop 0, hLL.eventually (coreDimension_eventual_mesh M)] with x hband hT hdim have hV : 0 ≤ V x := Nat.cast_nonneg _ calc _ ≤ _ := retainedTerminalTailValues_card_le_band_sum hT (by have := hdim.1; omega) _ ≤ ∑ b ∈ Finset.Icc B ⌊logLog x⌋₊, C*terminalBandEnvelope M b*V x := by apply Finset.sum_le_sum intro b hb exact hband b (hB₀.trans (Finset.mem_Icc.mp hb).1) _ = C*(∑ b ∈ Finset.Icc B ⌊logLog x⌋₊, terminalBandEnvelope M b)*V x := by rw [Finset.mul_sum, Finset.sum_mul] _ ≤ C*terminalBandTail M B*V x := mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left (finite_terminalBand_tail_bound M B _ (fun b hb => (Finset.mem_Icc.mp hb).1)) hC.le) hV _ ≤ _ := mul_le_mul_of_nonneg_right hBε.le hV /- Original line 48302: Erdos416Proof.FordBadFacet.terminalTailValues -/ noncomputable def terminalTailValues (x : ℝ) (M B : ℕ) : Finset ℕ := (totientsUpTo x).filter (fun m => ∃ N : ℕ, 0 < N ∧ N.totient = m ∧ (fun idx : Fin (coreDimension M (logLog x)) => ordinaryPrimeCoordinate (logLog x) N (idx.val+1)) ∈ polytope (coreDimension M (logLog x)) (expandedParameter (optimalDimension (logLog x))) ∧ (B : ℝ) ≤ positiveLogLog (ordinaryPrimeAt N (coreDimension M (logLog x)))) /- Original line 48308: Erdos416Proof.FordBadFacet.terminalTailValues_subset_exceptions_retained -/ theorem terminalTailValues_subset_exceptions_retained {x : ℝ} {M B : ℕ} (hx : 0 ≤ x) : terminalTailValues x M B ⊆ firstFailedExceptionalValues x (optimalDimension (logLog x)) ∪ retainedTerminalTailValues x M B := by intro m hm obtain ⟨hmV, N, hN, hNm, hpoint, hlow⟩ := Finset.mem_filter.mp hm have hmdata := (mem_totientsUpTo hx).mp hmV by_cases hsmall : (m : ℝ) ≤ Real.sqrt x · apply Finset.mem_union.mpr left have hmem := (mem_totientsUpTo (Real.sqrt_nonneg x)).mpr ⟨hmdata.1, hsmall, hmdata.2.2⟩ simp only [firstFailedExceptionalValues, Finset.mem_union] tauto by_cases hbad : m ∈ badFacetValues x 2 (1/1000) · apply Finset.mem_union.mpr left simp only [firstFailedExceptionalValues, Finset.mem_union] tauto by_cases hOmega : m ∈ fiveLogOmegaTotients x · apply Finset.mem_union.mpr left simp only [firstFailedExceptionalValues, Finset.mem_union] tauto by_cases hSquare : m ∈ largeSquareTotients x · apply Finset.mem_union.mpr left simp only [firstFailedExceptionalValues, Finset.mem_union] tauto exact Finset.mem_union.mpr (Or.inr (Finset.mem_filter.mpr ⟨hmV, (lt_of_not_ge hsmall).le, hbad, hOmega, hSquare, N, hN, hNm, hpoint, hlow⟩)) /-- Arithmetic pruning is restored, so this estimate applies to every distinct totient value with an actual expanded-polytope preimage. -/ /- Original line 48340: Erdos416Proof.FordBadFacet.terminal_tail_values_small_in_V -/ theorem terminal_tail_values_small_in_V : ∀ᶠ M : ℕ in atTop, ∀ ε : ℝ, 0 < ε → ∃ B : ℕ, ∀ᶠ x : ℝ in atTop, ((terminalTailValues x M B).card : ℝ) ≤ ε*V x := by filter_upwards [retained_terminal_tail_values_small_in_V] with M hM intro ε hε obtain ⟨B, hB⟩ := hM (ε/2) (by positivity) refine ⟨B, ?_⟩ filter_upwards [hB, firstFailedExceptionalValues_negligible_in_V.bound (show 0 < ε/2 by positivity), eventually_ge_atTop (0 : ℝ)] with x hret hex hx have hc : (terminalTailValues x M B).card ≤ (firstFailedExceptionalValues x (optimalDimension (logLog x))).card+ (retainedTerminalTailValues x M B).card := (Finset.card_le_card (terminalTailValues_subset_exceptions_retained hx)).trans (Finset.card_union_le _ _) have hcr := (Nat.cast_le (α := ℝ)).mpr hc rw [Nat.cast_add] at hcr simp only [Real.norm_eq_abs, abs_of_nonneg (show 0 ≤ ((firstFailedExceptionalValues x (optimalDimension (logLog x))).card : ℝ) from Nat.cast_nonneg _), abs_of_nonneg (show 0 ≤ V x from Nat.cast_nonneg _)] at hex linarith /- Original line 48360: Erdos416Proof.FordBadFacet.largeTerminalValues -/ noncomputable def largeTerminalValues (x : ℝ) (M : ℕ) (P : ℝ) : Finset ℕ := (totientsUpTo x).filter (fun m => ∃ N : ℕ, 0 < N ∧ N.totient = m ∧ (fun idx : Fin (coreDimension M (logLog x)) => ordinaryPrimeCoordinate (logLog x) N (idx.val+1)) ∈ polytope (coreDimension M (logLog x)) (expandedParameter (optimalDimension (logLog x))) ∧ P ≤ (ordinaryPrimeAt N (coreDimension M (logLog x)) : ℝ)) /-- A fixed terminal prime cutoff outside arbitrarily few actual values. The cutoff is chosen after M and epsilon and before the counting endpoint. -/ /- Original line 48368: Erdos416Proof.FordBadFacet.exists_fixed_terminal_prime_cutoff -/ theorem exists_fixed_terminal_prime_cutoff : ∀ᶠ M : ℕ in atTop, ∀ ε : ℝ, 0 < ε → ∃ P : ℝ, 1 < P ∧ ∀ᶠ x : ℝ in atTop, ((largeTerminalValues x M P).card : ℝ) ≤ ε*V x := by filter_upwards [terminal_tail_values_small_in_V] with M hM intro ε hε obtain ⟨B, hB⟩ := hM ε hε let P := Real.exp (Real.exp (B : ℝ)) have hP : 1 < P := Real.one_lt_exp_iff.mpr (Real.exp_pos _) refine ⟨P, hP, ?_⟩ filter_upwards [hB] with x hx apply le_trans _ hx apply Nat.cast_le.mpr apply Finset.card_le_card intro m hm obtain ⟨hmV, N, hN, hNm, hpoint, hlarge⟩ := Finset.mem_filter.mp hm have hlog := positiveLogLog_mono hP.le hlarge have hLP : positiveLogLog P = (B : ℝ) := by simp only [P, positiveLogLog, logLog, Real.log_exp, max_eq_right (Nat.cast_nonneg B)] rw [hLP] at hlog exact Finset.mem_filter.mpr ⟨hmV, N, hN, hNm, hpoint, hlog⟩ end Erdos416Proof.FordBadFacet end /- Consolidated component: ResidualValueCount.lean. -/ section open Filter Asymptotics Finset open scoped Classical Topology BigOperators namespace Erdos416Proof.FordBadFacet open FordReciprocal FordScale FordGeometry /- Original line 48407: Erdos416Proof.FordBadFacet.largeSmoothResidualProperty -/ def largeSmoothResidualProperty (P R : ℝ) (n : ℕ) : Prop := R ≤ (n : ℝ) ∧ n ∈ Nat.factoredNumbers (Nat.primesLE ⌊P⌋₊) /- Original line 48410: Erdos416Proof.FordBadFacet.largeSmoothResidualValues -/ noncomputable def largeSmoothResidualValues (x : ℝ) (M : ℕ) (P R : ℝ) : Finset ℕ := (totientsUpTo x).filter (fun m => ∃ N : ℕ, 0 < N ∧ N.totient = m ∧ (fun idx : Fin (coreDimension M (logLog x)) => ordinaryPrimeCoordinate (logLog x) N (idx.val+1)) ∈ polytope (coreDimension M (logLog x)) (expandedParameter (optimalDimension (logLog x))) ∧ largeSmoothResidualProperty P R (ordinarySuffix (ordinarySuffix N 1) (coreDimension M (logLog x)))) /-- The residual cutoff is on an actual preimage at exactly the retained core dimension. Its reciprocal saving is uniform in the value endpoint. -/ /- Original line 48419: Erdos416Proof.FordBadFacet.largeSmoothResidualProperty_reciprocal_small -/ theorem largeSmoothResidualProperty_reciprocal_small {P : ℝ} (hP : Real.exp 20 ≤ P) {ε : ℝ} (hε : 0 < ε) : ∀ᶠ R : ℝ in atTop, ∀ x : ℝ, (∑ m ∈ preimagePropertyValues x (largeSmoothResidualProperty P R), (1 : ℝ)/m) ≤ ε := by filter_upwards [large_smooth_preimage_reciprocal_small hP hε] with R hR intro x apply hR intro m hm obtain ⟨_, N, hN, hNm, hlarge, hsmooth⟩ := Finset.mem_filter.mp hm exact ⟨N, hN, hNm, hlarge, hsmooth⟩ /- Original line 48430: Erdos416Proof.FordBadFacet.retained_large_smooth_residual_values_small_in_V -/ theorem retained_large_smooth_residual_values_small_in_V : ∀ᶠ M : ℕ in atTop, ∀ P : ℝ, Real.exp 20 ≤ P → ∀ ε : ℝ, 0 < ε → ∀ᶠ R : ℝ in atTop, ∀ᶠ x : ℝ in atTop, ((retainedGeometricValues x (coreDimension M (logLog x)) (polytope (coreDimension M (logLog x)) (expandedParameter (optimalDimension (logLog x)))) (largeSmoothResidualProperty P R)).card : ℝ) ≤ ε*V x := by obtain ⟨C, hC, hcount⟩ := exists_retained_geometric_value_count obtain ⟨K, hK, hmass⟩ := exists_core_tuple_mass_V_bound filter_upwards [hmass] with M hmass intro P hP ε hε have hδ : 0 < ε/(C*K) := div_pos hε (mul_pos hC hK) filter_upwards [largeSmoothResidualProperty_reciprocal_small hP hδ] with R hR filter_upwards [hcount, hmass, eventually_gt_atTop (1 : ℝ)] with x hcount hmass hx let D := coreDimension M (logLog x) let E := polytope D (expandedParameter (optimalDimension (logLog x))) have hE : E ⊆ Set.Icc (fun _ => 0) (fun _ => 1) := fun p hp => ⟨hp.1, hp.2.1⟩ have hc := hcount D E (largeSmoothResidualProperty P R) hE have hsum := hR x have hY : 0 ≤ x/Real.log x := div_nonneg (by linarith) (Real.log_pos hx).le have hmass0 : 0 ≤ coreTupleMass M (logLog x) := tupleReciprocalMass_nonneg _ _ _ change _ ≤ C*x/Real.log x*coreTupleMass M (logLog x)* (∑ m ∈ preimagePropertyValues x (largeSmoothResidualProperty P R), (1 : ℝ)/m) at hc calc _ ≤ _ := hc _ = C*((x/Real.log x)*coreTupleMass M (logLog x))* (∑ m ∈ preimagePropertyValues x (largeSmoothResidualProperty P R), (1 : ℝ)/m) := by ring _ ≤ C*((x/Real.log x)*coreTupleMass M (logLog x))*(ε/(C*K)) := mul_le_mul_of_nonneg_left hsum (mul_nonneg hC.le (mul_nonneg hY hmass0)) _ ≤ C*(K*V x)*(ε/(C*K)) := mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left hmass hC.le) hδ.le _ = ε*V x := by field_simp [hC.ne', hK.ne'] <;> ring /- Original line 48462: Erdos416Proof.FordBadFacet.largeSmoothResidualValues_subset_exceptions_retained -/ theorem largeSmoothResidualValues_subset_exceptions_retained {x : ℝ} {M : ℕ} {P R : ℝ} (hx : 0 ≤ x) : largeSmoothResidualValues x M P R ⊆ firstFailedExceptionalValues x (optimalDimension (logLog x)) ∪ retainedGeometricValues x (coreDimension M (logLog x)) (polytope (coreDimension M (logLog x)) (expandedParameter (optimalDimension (logLog x)))) (largeSmoothResidualProperty P R) := by intro m hm obtain ⟨hmV, N, hN, hNm, hpoint, hQ⟩ := Finset.mem_filter.mp hm have hmdata := (mem_totientsUpTo hx).mp hmV by_cases hsmall : (m : ℝ) ≤ Real.sqrt x · apply Finset.mem_union.mpr left have hmem := (mem_totientsUpTo (Real.sqrt_nonneg x)).mpr ⟨hmdata.1, hsmall, hmdata.2.2⟩ simp only [firstFailedExceptionalValues, Finset.mem_union] tauto by_cases hbad : m ∈ badFacetValues x 2 (1/1000) · apply Finset.mem_union.mpr left simp only [firstFailedExceptionalValues, Finset.mem_union] tauto by_cases hOmega : m ∈ fiveLogOmegaTotients x · apply Finset.mem_union.mpr left simp only [firstFailedExceptionalValues, Finset.mem_union] tauto by_cases hSquare : m ∈ largeSquareTotients x · apply Finset.mem_union.mpr left simp only [firstFailedExceptionalValues, Finset.mem_union] tauto exact Finset.mem_union.mpr (Or.inr (Finset.mem_filter.mpr ⟨hmV, (lt_of_not_ge hsmall).le, hbad, hOmega, hSquare, N, hN, hNm, hpoint, hQ⟩)) /-- All actual values with a large fixed-smoothness residual are negligible after taking a sufficiently large residual cutoff. No choice of a counting endpoint, preimage, or arithmetic coverage assumption enters the cutoff. -/ /- Original line 48499: Erdos416Proof.FordBadFacet.large_smooth_residual_values_small_in_V -/ theorem large_smooth_residual_values_small_in_V : ∀ᶠ M : ℕ in atTop, ∀ P : ℝ, Real.exp 20 ≤ P → ∀ ε : ℝ, 0 < ε → ∀ᶠ R : ℝ in atTop, ∀ᶠ x : ℝ in atTop, ((largeSmoothResidualValues x M P R).card : ℝ) ≤ ε*V x := by filter_upwards [retained_large_smooth_residual_values_small_in_V] with M hM intro P hP ε hε filter_upwards [hM P hP (ε/2) (by positivity)] with R hR filter_upwards [hR, firstFailedExceptionalValues_negligible_in_V.bound (show 0 < ε/2 by positivity), eventually_ge_atTop (0 : ℝ)] with x hret hex hx have hc := (Finset.card_le_card (largeSmoothResidualValues_subset_exceptions_retained (M := M) (P := P) (R := R) hx)).trans (Finset.card_union_le _ _) have hcr := (Nat.cast_le (α := ℝ)).mpr hc rw [Nat.cast_add] at hcr simp only [Real.norm_eq_abs, abs_of_nonneg (show 0 ≤ ((firstFailedExceptionalValues x (optimalDimension (logLog x))).card : ℝ) from Nat.cast_nonneg _), abs_of_nonneg (show 0 ≤ V x from Nat.cast_nonneg _)] at hex linarith /- Original line 48518: Erdos416Proof.FordBadFacet.exists_fixed_smooth_residual_cutoff -/ theorem exists_fixed_smooth_residual_cutoff : ∀ᶠ M : ℕ in atTop, ∀ P : ℝ, Real.exp 20 ≤ P → ∀ ε : ℝ, 0 < ε → ∃ R : ℝ, 0 < R ∧ ∀ᶠ x : ℝ in atTop, ((largeSmoothResidualValues x M P R).card : ℝ) ≤ ε*V x := by filter_upwards [large_smooth_residual_values_small_in_V] with M hM intro P hP ε hε exact ((eventually_gt_atTop (0 : ℝ)).and (hM P hP ε hε)).exists /- Original line 48525: Erdos416Proof.FordBadFacet.exists_fixed_nat_smooth_residual_cutoff -/ theorem exists_fixed_nat_smooth_residual_cutoff : ∀ᶠ M : ℕ in atTop, ∀ P : ℝ, Real.exp 20 ≤ P → ∀ ε : ℝ, 0 < ε → ∃ R : ℕ, 0 < R ∧ ∀ᶠ x : ℝ in atTop, ((largeSmoothResidualValues x M P (R : ℝ)).card : ℝ) ≤ ε*V x := by filter_upwards [large_smooth_residual_values_small_in_V] with M hM intro P hP ε hε have hR : ∀ᶠ R : ℕ in atTop, ∀ᶠ x : ℝ in atTop, ((largeSmoothResidualValues x M P (R : ℝ)).card : ℝ) ≤ ε*V x := tendsto_natCast_atTop_atTop.eventually (hM P hP ε hε) exact ((eventually_gt_atTop (0 : ℕ)).and hR).exists end Erdos416Proof.FordBadFacet end /- Consolidated component: SimplexMoments.lean. -/ section open Filter Finset MeasureTheory open scoped Classical Topology BigOperators namespace Erdos416Proof.SimplexVolume /-- The elementary beta integral, with natural powers and real values. -/ /- Original line 48552: Erdos416Proof.SimplexVolume.integral_pow_mul_one_sub_pow -/ theorem integral_pow_mul_one_sub_pow (a b : ℕ) : (∫ s : ℝ in 0..1, s^a * (1-s)^b) = (a.factorial : ℝ) * b.factorial / (a+b+1).factorial := by have hrep : Complex.betaIntegral ((a : ℂ)+1) ((b : ℂ)+1) = Complex.ofReal (∫ s : ℝ in 0..1, (s^a * (1-s)^b : ℝ)) := by unfold Complex.betaIntegral simpa only [add_sub_cancel_right, Complex.cpow_natCast, Complex.ofReal_mul, Complex.ofReal_pow, Complex.ofReal_sub, Complex.ofReal_one] using (intervalIntegral.integral_ofReal (a := 0) (b := 1) (f := fun s : ℝ => s^a * (1-s)^b)) have hbeta := Complex.betaIntegral_eq_Gamma_mul_div ((a : ℂ)+1) ((b : ℂ)+1) (by simp; positivity) (by simp; positivity) have hadd : ((a : ℂ)+1)+((b : ℂ)+1) = ((a+b+1 : ℕ) : ℂ)+1 := by push_cast ring rw [hadd, Complex.Gamma_nat_eq_factorial, Complex.Gamma_nat_eq_factorial, Complex.Gamma_nat_eq_factorial, hrep] at hbeta apply Complex.ofReal_injective simpa only [Complex.ofReal_div, Complex.ofReal_mul, Complex.ofReal_natCast] using hbeta /-- The scaled polynomial beta integral; the formula also covers t=0. -/ /- Original line 48574: Erdos416Proof.SimplexVolume.integral_pow_mul_sub_pow -/ theorem integral_pow_mul_sub_pow (a b : ℕ) (t : ℝ) : (∫ s : ℝ in 0..t, s^a * (t-s)^b) = ((a.factorial : ℝ) * b.factorial / (a+b+1).factorial) * t^(a+b+1) := by have hscale := intervalIntegral.smul_integral_comp_mul_left (fun s : ℝ => s^a * (t-s)^b) (a := 0) (b := 1) t have hfun (s : ℝ) : (t*s)^a * (t-t*s)^b = t^(a+b) * (s^a*(1-s)^b) := by rw [show t-t*s = t*(1-s) by ring, mul_pow, mul_pow, pow_add] ring calc _ = t * (∫ s : ℝ in 0..1, (t*s)^a * (t-t*s)^b) := by simpa only [mul_zero, mul_one, smul_eq_mul] using hscale.symm _ = t * (t^(a+b) * (∫ s : ℝ in 0..1, s^a*(1-s)^b)) := by simp_rw [hfun] rw [intervalIntegral.integral_const_mul] _ = _ := by rw [integral_pow_mul_one_sub_pow, pow_succ] ring /- Original line 48592: Erdos416Proof.SimplexVolume.setIntegral_pow_mul_sub_pow -/ theorem setIntegral_pow_mul_sub_pow (a b : ℕ) {t : ℝ} (ht : 0 ≤ t) : (∫ s : ℝ in Set.Icc 0 t, s^a * (t-s)^b) = ((a.factorial : ℝ) * b.factorial / (a+b+1).factorial) * t^(a+b+1) := by rw [integral_Icc_eq_integral_Ioc, ← intervalIntegral.integral_of_le ht] exact integral_pow_mul_sub_pow a b t /-- Fubini on the exact positive simplex used by the Ford geometry. -/ /- Original line 48599: Erdos416Proof.SimplexVolume.integral_positiveSimplex_cons -/ theorem integral_positiveSimplex_cons (n : ℕ) (t : ℝ) (f : (Fin (n+1) → ℝ) → ℝ) (hf : Continuous f) : (∫ x in positiveSimplex (n+1) t, f x) = ∫ s : ℝ in Set.Icc 0 t, ∫ x in positiveSimplex n (t-s), f (Fin.cons s x) := by let e : (ℝ × (Fin n → ℝ)) ≃ᵐ (Fin (n+1) → ℝ) := (MeasurableEquiv.piFinSuccAbove (fun _ => ℝ) 0).symm have he : MeasurePreserving e := (volume_preserving_piFinSuccAbove (fun _ : Fin (n+1) => ℝ) 0).symm _ have he_apply (s : ℝ) (x : Fin n → ℝ) : e (s,x) = Fin.cons s x := by simp [e, MeasurableEquiv.piFinSuccAbove_symm_apply, Fin.insertNthEquiv, Fin.insertNth_zero'] let g := (positiveSimplex (n+1) t).indicator f have hg : Integrable g volume := (hf.continuousOn.integrableOn_compact (positiveSimplex_isCompact (n+1) t)).integrable_indicator (positiveSimplex_measurable (n+1) t) have hge : Integrable (g ∘ e) volume := he.integrable_comp_of_integrable hg have hslice (s : ℝ) : (∫ x : Fin n → ℝ, g (Fin.cons s x)) = (Set.Icc 0 t).indicator (fun s : ℝ => ∫ x in positiveSimplex n (t-s), f (Fin.cons s x)) s := by by_cases hs : s ∈ Set.Icc 0 t · rw [Set.indicator_of_mem hs, ← integral_indicator (positiveSimplex_measurable n (t-s))] apply integral_congr_ae filter_upwards [] with x have hx : Fin.cons s x ∈ positiveSimplex (n+1) t ↔ x ∈ positiveSimplex n (t-s) := by rw [cons_mem_positiveSimplex] exact and_iff_right hs.1 simp only [g, Set.indicator, hx] · rw [Set.indicator_of_notMem hs] have hnot (x : Fin n → ℝ) : Fin.cons s x ∉ positiveSimplex (n+1) t := by intro hx obtain ⟨hs0, hx⟩ := (cons_mem_positiveSimplex t s x).mp hx have hsum := Finset.sum_nonneg (fun idx (_ : idx ∈ Finset.univ) => hx.1 idx) exact hs ⟨hs0, by linarith [hx.2]⟩ simp only [g, Set.indicator_of_notMem (hnot _), integral_zero] calc _ = ∫ x, g x := (integral_indicator (positiveSimplex_measurable (n+1) t)).symm _ = ∫ z : ℝ × (Fin n → ℝ), g (e z) := (he.integral_comp' g).symm _ = ∫ s : ℝ, ∫ x : Fin n → ℝ, g (Fin.cons s x) := by rw [Measure.volume_eq_prod] simpa only [he_apply] using integral_prod (fun z : ℝ × (Fin n → ℝ) => g (e z)) (by simpa only [Measure.volume_eq_prod, Function.comp_def] using hge) _ = _ := by simp_rw [hslice] exact integral_indicator measurableSet_Icc /-- All coordinate monomials, including the residual barycentric coordinate. This supplies every mixed moment needed for a fourth-moment argument. -/ /- Original line 48648: Erdos416Proof.SimplexVolume.integral_positiveSimplex_monomial -/ theorem integral_positiveSimplex_monomial (n r : ℕ) (k : Fin n → ℕ) {t : ℝ} (ht : 0 ≤ t) : (∫ x in positiveSimplex n t, (t-∑ j, x j)^r * ∏ j, (x j)^(k j)) = ((r.factorial : ℝ) * (∏ j, ((k j).factorial : ℝ)) / (n+r+∑ j, k j).factorial) * t^(n+r+∑ j, k j) := by induction n generalizing r t with | zero => simp only [Fin.sum_univ_zero, Fin.prod_univ_zero, sub_zero, mul_one, zero_add, add_zero, setIntegral_const, smul_eq_mul] rw [realVolume_positiveSimplex 0 ht] simp only [pow_zero, Nat.factorial_zero, Nat.cast_one, div_one, one_mul] rw [div_self (by positivity : (r.factorial : ℝ) ≠ 0), one_mul] | succ n ih => let k' : Fin n → ℕ := fun j => k j.succ let R : ℕ := n+r+∑ j, k' j let C : ℝ := (r.factorial : ℝ)*(∏ j, ((k' j).factorial : ℝ))/R.factorial have hf : Continuous (fun x : Fin (n+1) → ℝ => (t-∑ j, x j)^r * ∏ j, (x j)^(k j)) := by fun_prop rw [integral_positiveSimplex_cons n t _ hf] have hslice (s : ℝ) (hs : s ∈ Set.Icc 0 t) : (∫ x in positiveSimplex n (t-s), (t-∑ j, Fin.cons s x j)^r * ∏ j, (Fin.cons s x j)^(k j)) = s^(k 0) * (C*(t-s)^R) := by have hpoly (x : Fin n → ℝ) : (t-∑ j, Fin.cons s x j)^r * ∏ j, (Fin.cons s x j)^(k j) = s^(k 0) * ((t-s-∑ j, x j)^r * ∏ j, (x j)^(k' j)) := by simp only [Fin.sum_univ_succ, Fin.prod_univ_succ, Fin.cons_zero, Fin.cons_succ] rw [show t-(s+∑ j, x j) = t-s-∑ j, x j by ring] dsimp only [k'] ring simp_rw [hpoly] rw [integral_const_mul, ih r k' (sub_nonneg.mpr hs.2)] calc _ = ∫ s : ℝ in Set.Icc 0 t, s^(k 0)*(C*(t-s)^R) := by apply setIntegral_congr_fun measurableSet_Icc exact hslice _ = C * (∫ s : ℝ in Set.Icc 0 t, s^(k 0)*(t-s)^R) := by rw [← integral_const_mul] apply integral_congr_ae filter_upwards [] with s ring _ = C * ((((k 0).factorial : ℝ)*R.factorial/(k 0+R+1).factorial) * t^(k 0+R+1)) := by rw [setIntegral_pow_mul_sub_pow _ _ ht] _ = _ := by have hdegree : n+1+r+∑ j, k j = k 0+R+1 := by rw [Fin.sum_univ_succ] dsimp [R, k'] omega rw [hdegree, Fin.prod_univ_succ] dsimp [C, k'] field_simp /- Original line 48700: Erdos416Proof.SimplexVolume.integral_unitSimplex_monomial -/ theorem integral_unitSimplex_monomial (n : ℕ) (k : Fin n → ℕ) : (∫ x in positiveSimplex n 1, ∏ j, (x j)^(k j)) = (∏ j, ((k j).factorial : ℝ)) / (n+∑ j, k j).factorial := by simpa only [pow_zero, one_mul, Nat.factorial_zero, Nat.cast_one, add_zero, one_pow, mul_one] using integral_positiveSimplex_monomial n 0 k (t := 1) zero_le_one /- Original line 48707: Erdos416Proof.SimplexVolume.integral_unitSimplex_barycentric_monomial -/ theorem integral_unitSimplex_barycentric_monomial (n r : ℕ) (k : Fin n → ℕ) : (∫ x in positiveSimplex n 1, (1-∑ j, x j)^r * ∏ j, (x j)^(k j)) = (r.factorial : ℝ) * (∏ j, ((k j).factorial : ℝ)) / (n+r+∑ j, k j).factorial := by simpa only [one_pow, mul_one] using integral_positiveSimplex_monomial n r k (t := 1) zero_le_one end Erdos416Proof.SimplexVolume end /- Consolidated component: SimplexFourthMoment.lean. -/ section open Filter Finset MeasureTheory open scoped Classical Topology BigOperators namespace Erdos416Proof.SimplexVolume /-- The residual coordinate comes first, matching Fin.cons 0 a in the coefficient construction. -/ /- Original line 48732: Erdos416Proof.SimplexVolume.barycentric -/ def barycentric (n : ℕ) (x : Fin n → ℝ) : Fin (n+1) → ℝ := Fin.cons (1-∑ j, x j) x /- Original line 48735: Erdos416Proof.SimplexVolume.sum_barycentric -/ theorem sum_barycentric (n : ℕ) (x : Fin n → ℝ) : (∑ idx, barycentric n x idx) = 1 := by simp [barycentric, Fin.sum_univ_succ] /- Original line 48739: Erdos416Proof.SimplexVolume.barycentric_centering -/ theorem barycentric_centering (n : ℕ) (b : Fin (n+1) → ℝ) (c : ℝ) (x : Fin n → ℝ) : (∑ idx, (b idx-c)*barycentric n x idx) = (∑ idx, b idx*barycentric n x idx)-c := by simp only [sub_mul, Finset.sum_sub_distrib, ← Finset.mul_sum, sum_barycentric, mul_one] /- Original line 48745: Erdos416Proof.SimplexVolume.continuous_barycentric -/ theorem continuous_barycentric (n : ℕ) (idx : Fin (n+1)) : Continuous (fun x : Fin n → ℝ => barycentric n x idx) := by cases idx using Fin.cases with | zero => simp only [barycentric, Fin.cons_zero]; fun_prop | succ idx => simp only [barycentric, Fin.cons_succ]; fun_prop /- Original line 48751: Erdos416Proof.SimplexVolume.integral_barycentric_monomial -/ theorem integral_barycentric_monomial (n : ℕ) (k : Fin (n+1) → ℕ) : (∫ x in positiveSimplex n 1, ∏ j, (barycentric n x j)^(k j)) = (∏ j, ((k j).factorial : ℝ)) / (n+∑ j, k j).factorial := by simpa only [barycentric, Fin.prod_univ_succ, Fin.sum_univ_succ, Fin.cons_zero, Fin.cons_succ, Nat.add_assoc] using integral_unitSimplex_barycentric_monomial n (k 0) (fun j => k j.succ) section FiniteAlgebra variable {ι : Type*} [Fintype ι] [DecidableEq ι] /- Original line 48762: Erdos416Proof.SimplexVolume.fourExponent -/ def fourExponent (idx j k l v : ι) : ℕ := (if v=idx then 1 else 0) + ((if v=j then 1 else 0) + ((if v=k then 1 else 0) + (if v=l then 1 else 0))) /- Original line 48766: Erdos416Proof.SimplexVolume.sum_fourExponent -/ theorem sum_fourExponent (idx j k l : ι) : ∑ v, fourExponent idx j k l v = 4 := by simp [fourExponent, Finset.sum_add_distrib] /- Original line 48769: Erdos416Proof.SimplexVolume.prod_pow_fourExponent -/ theorem prod_pow_fourExponent (z : ι → ℝ) (idx j k l : ι) : (∏ v, (z v)^(fourExponent idx j k l v)) = z idx*z j*z k*z l := by simp only [fourExponent, pow_add, pow_ite, pow_one, pow_zero, Finset.prod_mul_distrib] simp only [Finset.prod_ite_eq', Finset.mem_univ, ↓reduceIte] ring /- Original line 48776: Erdos416Proof.SimplexVolume.prod_factorial_add_single -/ theorem prod_factorial_add_single (a : ι → ℕ) (idx : ι) : (∏ v, (((if v=idx then 1 else 0)+a v).factorial : ℝ)) = ((a idx : ℝ)+1) * ∏ v, ((a v).factorial : ℝ) := by have hp (v : ι) : (((if v=idx then 1 else 0)+a v).factorial : ℝ) = (if v=idx then (a idx : ℝ)+1 else 1) * (a v).factorial := by by_cases hv : v=idx · subst v simp only [↓reduceIte, Nat.add_comm 1, Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one] · simp [hv] simp_rw [hp] rw [Finset.prod_mul_distrib] simp only [Finset.prod_ite_eq', Finset.mem_univ, ↓reduceIte] /-- The mixed fourth moment numerator, written so its finite sums collapse using only Kronecker-delta identities. -/ /- Original line 48792: Erdos416Proof.SimplexVolume.mixedFourthWeight -/ def mixedFourthWeight (idx j k l : ι) : ℝ := 1 + (if idx=j then 1 else 0) + (if idx=k then 1 else 0) + (if idx=l then 1 else 0) + (if j=k then 1 else 0) + (if j=l then 1 else 0) + (if k=l then 1 else 0) + (if idx=j ∧ idx=k then 2 else 0) + (if idx=j ∧ idx=l then 2 else 0) + (if idx=k ∧ idx=l then 2 else 0) + (if j=k ∧ j=l then 2 else 0) + (if idx=j ∧ k=l then 1 else 0) + (if idx=k ∧ j=l then 1 else 0) + (if idx=l ∧ j=k then 1 else 0) + (if idx=j ∧ idx=k ∧ idx=l then 6 else 0) /- Original line 48803: Erdos416Proof.SimplexVolume.prod_factorial_fourExponent -/ theorem prod_factorial_fourExponent (idx j k l : ι) : (∏ v, ((fourExponent idx j k l v).factorial : ℝ)) = mixedFourthWeight idx j k l := by unfold fourExponent rw [prod_factorial_add_single, prod_factorial_add_single, prod_factorial_add_single] have hlast : (∏ v : ι, ((if v=l then 1 else 0).factorial : ℝ)) = 1 := by apply Finset.prod_eq_one intro v _ split_ifs <;> norm_num rw [hlast] by_cases hij : idx=j · subst j by_cases hik : idx=k · subst k by_cases hil : idx=l <;> norm_num [mixedFourthWeight, hil] · by_cases hil : idx=l · subst l norm_num [mixedFourthWeight, hik, Ne.symm hik] · by_cases hkl : k=l <;> norm_num [mixedFourthWeight, hik, hil, hkl] · by_cases hik : idx=k · subst k by_cases hil : idx=l · subst l norm_num [mixedFourthWeight, hij, Ne.symm hij] · by_cases hjl : j=l <;> norm_num [mixedFourthWeight, hij, Ne.symm hij, hil, Ne.symm hil, hjl] · by_cases hjk : j=k · subst k by_cases hil : idx=l · subst l norm_num [mixedFourthWeight, hij, Ne.symm hij] · by_cases hjl : j=l <;> norm_num [mixedFourthWeight, hij, hil, hjl] · by_cases hil : idx=l · subst l norm_num [mixedFourthWeight, hij, hik, hjk, Ne.symm hij, Ne.symm hik] · by_cases hjl : j=l · subst l norm_num [mixedFourthWeight, hij, hik, hjk, Ne.symm hjk] · by_cases hkl : k=l <;> norm_num [mixedFourthWeight, hij, hik, hjk, hil, hjl, hkl] omit [DecidableEq ι] in /- Original line 48845: Erdos416Proof.SimplexVolume.sum_four_product -/ theorem sum_four_product (z : ι → ℝ) : (∑ idx, ∑ j, ∑ k, ∑ l, z idx*z j*z k*z l) = (∑ idx, z idx)^4 := by simp only [← Finset.mul_sum, ← Finset.sum_mul] ring /- Original line 48850: Erdos416Proof.SimplexVolume.sum_mixedFourthWeight -/ theorem sum_mixedFourthWeight (b : ι → ℝ) : (∑ idx, ∑ j, ∑ k, ∑ l, b idx*b j*b k*b l*mixedFourthWeight idx j k l) = (∑ idx, b idx)^4 + 6*(∑ idx, b idx)^2*(∑ idx, (b idx)^2) + 8*(∑ idx, b idx)*(∑ idx, (b idx)^3) + 3*(∑ idx, (b idx)^2)^2 + 6*(∑ idx, (b idx)^4) := by simp only [mixedFourthWeight, mul_add, mul_ite, mul_one, mul_zero, Finset.sum_add_distrib, ite_and] simp only [Finset.sum_ite_irrel, Finset.sum_ite_eq, Finset.mem_univ, ↓reduceIte, Finset.sum_const_zero] ring_nf simp only [← Finset.mul_sum, ← Finset.sum_mul] ring_nf end FiniteAlgebra /- Original line 48865: Erdos416Proof.SimplexVolume.integral_barycentric_four -/ theorem integral_barycentric_four (n : ℕ) (idx j k l : Fin (n+1)) : (∫ x in positiveSimplex n 1, barycentric n x idx*barycentric n x j*barycentric n x k*barycentric n x l) = mixedFourthWeight idx j k l / (n+4).factorial := by have h := integral_barycentric_monomial n (fourExponent idx j k l) simpa only [prod_pow_fourExponent, prod_factorial_fourExponent, sum_fourExponent] using h /- Original line 48873: Erdos416Proof.SimplexVolume.barycentric_linear_fourth_expansion -/ theorem barycentric_linear_fourth_expansion (n : ℕ) (b : Fin (n+1) → ℝ) (x : Fin n → ℝ) : (∑ idx, b idx*barycentric n x idx)^4 = ∑ idx, ∑ j, ∑ k, ∑ l, (b idx*b j*b k*b l) * (barycentric n x idx*barycentric n x j*barycentric n x k*barycentric n x l) := by rw [← sum_four_product] apply Finset.sum_congr rfl intro idx _ apply Finset.sum_congr rfl intro j _ apply Finset.sum_congr rfl intro k _ apply Finset.sum_congr rfl intro l _ ring /- Original line 48890: Erdos416Proof.SimplexVolume.integral_barycentric_linear_fourth -/ theorem integral_barycentric_linear_fourth (n : ℕ) (b : Fin (n+1) → ℝ) : (∫ x in positiveSimplex n 1, (∑ idx, b idx*barycentric n x idx)^4) = ((∑ idx, b idx)^4 + 6*(∑ idx, b idx)^2*(∑ idx, (b idx)^2) + 8*(∑ idx, b idx)*(∑ idx, (b idx)^3) + 3*(∑ idx, (b idx)^2)^2 + 6*(∑ idx, (b idx)^4)) / (n+4).factorial := by have hBarycentric (idx : Fin (n+1)) := continuous_barycentric n idx let f (idx j k l : Fin (n+1)) (x : Fin n → ℝ) : ℝ := (b idx*b j*b k*b l) * (barycentric n x idx*barycentric n x j*barycentric n x k*barycentric n x l) have hsumIntegral (f : Fin (n+1) → (Fin n → ℝ) → ℝ) (hf : ∀ idx, Continuous (f idx)) : (∫ x in positiveSimplex n 1, ∑ idx, f idx x) = ∑ idx, ∫ x in positiveSimplex n 1, f idx x := integral_finsetSum Finset.univ (fun idx _ => (hf idx).continuousOn.integrableOn_compact (positiveSimplex_isCompact n 1)) have hexpand : (∫ x in positiveSimplex n 1, (∑ idx, b idx*barycentric n x idx)^4) = ∑ idx, ∑ j, ∑ k, ∑ l, ∫ x in positiveSimplex n 1, f idx j k l x := by simp_rw [barycentric_linear_fourth_expansion] change (∫ x in positiveSimplex n 1, ∑ idx, ∑ j, ∑ k, ∑ l, f idx j k l x) = _ rw [hsumIntegral (fun idx x => ∑ j, ∑ k, ∑ l, f idx j k l x) (by intro idx; dsimp [Erdos416Proof.SimplexVolume.sum_barycentric, f]; fun_prop)] apply Finset.sum_congr rfl intro idx _ rw [hsumIntegral (fun j x => ∑ k, ∑ l, f idx j k l x) (by intro j; dsimp [Erdos416Proof.SimplexVolume.sum_barycentric, f]; fun_prop)] apply Finset.sum_congr rfl intro j _ rw [hsumIntegral (fun k x => ∑ l, f idx j k l x) (by intro k; dsimp [Erdos416Proof.SimplexVolume.sum_barycentric, f]; fun_prop)] apply Finset.sum_congr rfl intro k _ exact hsumIntegral (fun l x => f idx j k l x) (by intro l; dsimp [Erdos416Proof.SimplexVolume.sum_barycentric, f]; fun_prop) rw [hexpand] dsimp only [f] simp_rw [integral_const_mul, integral_barycentric_four] simp only [← mul_div_assoc, ← Finset.sum_div] rw [sum_mixedFourthWeight] /-- Exact central fourth moment under normalized volume on the unit simplex. There are n+1 barycentric coordinates, including the residual coordinate. -/ /- Original line 48930: Erdos416Proof.SimplexVolume.barycentric_zero_mean_fourth_moment -/ theorem barycentric_zero_mean_fourth_moment (n : ℕ) (b : Fin (n+1) → ℝ) (hb : ∑ idx, b idx = 0) : (n.factorial : ℝ) * (∫ x in positiveSimplex n 1, (∑ idx, b idx*barycentric n x idx)^4) = (3*(∑ idx, (b idx)^2)^2 + 6*(∑ idx, (b idx)^4)) / (((n : ℝ)+1)*((n : ℝ)+2)*((n : ℝ)+3)*((n : ℝ)+4)) := by rw [integral_barycentric_linear_fourth, hb] simp only [zero_pow (by norm_num : 4 ≠ 0), zero_pow (by norm_num : 2 ≠ 0), mul_zero, zero_mul, zero_add] have hfac : ((n+4).factorial : ℝ) = (((n : ℝ)+1)*((n : ℝ)+2)*((n : ℝ)+3)*((n : ℝ)+4)) * n.factorial := by simp only [show n+4 = ((n+1)+1)+1+1 by omega, Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one] ring rw [hfac] field_simp end Erdos416Proof.SimplexVolume end /- Consolidated component: SimplexTail.lean. -/ section open Filter Finset MeasureTheory open scoped Classical Topology BigOperators namespace Erdos416Proof.SimplexVolume /-- Markov's fourth-moment inequality on the exact simplex, expressed with ordinary real volume and no probability-space infrastructure. -/ /- Original line 48965: Erdos416Proof.SimplexVolume.simplex_fourth_tail_le -/ theorem simplex_fourth_tail_le (n : ℕ) (f : (Fin n → ℝ) → ℝ) (hf : Continuous f) {ε : ℝ} (hε : 0 < ε) : ε^4 * volume.real (positiveSimplex n 1 ∩ {x | ε ≤ |f x|}) ≤ ∫ x in positiveSimplex n 1, (f x)^4 := by have hfi : Integrable (fun x => (f x)^4) (volume.restrict (positiveSimplex n 1)) := (hf.pow 4).continuousOn.integrableOn_compact (positiveSimplex_isCompact n 1) have hnonneg : 0 ≤ᵐ[volume.restrict (positiveSimplex n 1)] (fun x => (f x)^4) := Filter.Eventually.of_forall (fun x => by positivity) have h := mul_meas_ge_le_integral_of_nonneg hnonneg hfi (ε^4) have hset : {x : Fin n → ℝ | ε^4 ≤ (f x)^4} = {x | ε ≤ |f x|} := by ext x change ε^4 ≤ (f x)^4 ↔ ε ≤ |f x| rw [← (show Even (4 : ℕ) by decide).pow_abs (f x)] exact pow_le_pow_iff_left₀ hε.le (abs_nonneg _) (by norm_num) rw [hset, measureReal_restrict_apply' (positiveSimplex_measurable n 1), Set.inter_comm] at h exact h /-- Exact fourth-moment control of every centered linear statistic under normalized simplex volume. -/ /- Original line 48985: Erdos416Proof.SimplexVolume.barycentric_zero_mean_tail_le -/ theorem barycentric_zero_mean_tail_le (n : ℕ) (b : Fin (n+1) → ℝ) (hb : ∑ idx, b idx = 0) {ε : ℝ} (hε : 0 < ε) : (n.factorial : ℝ) * volume.real (positiveSimplex n 1 ∩ {x | ε ≤ |∑ idx, b idx*barycentric n x idx|}) ≤ ((3*(∑ idx, (b idx)^2)^2 + 6*(∑ idx, (b idx)^4)) / (((n : ℝ)+1)*((n : ℝ)+2)*((n : ℝ)+3)*((n : ℝ)+4))) / ε^4 := by have hBarycentric (idx : Fin (n+1)) := continuous_barycentric n idx have h := simplex_fourth_tail_le n (fun x => ∑ idx, b idx*barycentric n x idx) (by fun_prop) hε apply (le_div_iff₀ (pow_pos hε 4)).mpr calc _ = (n.factorial : ℝ) * (ε^4 * volume.real (positiveSimplex n 1 ∩ {x | ε ≤ |∑ idx, b idx*barycentric n x idx|})) := by ring _ ≤ (n.factorial : ℝ) * (∫ x in positiveSimplex n 1, (∑ idx, b idx*barycentric n x idx)^4) := mul_le_mul_of_nonneg_left h (Nat.cast_nonneg _) _ = _ := barycentric_zero_mean_fourth_moment n b hb end Erdos416Proof.SimplexVolume end /- Consolidated component: SimplexConcentration.lean. -/ section open Filter Finset MeasureTheory open scoped Classical Topology BigOperators namespace Erdos416Proof.FordGeometry open FordAnalysis SimplexVolume variable {L : ℕ} /- Original line 49021: Erdos416Proof.FordGeometry.simplexCoordinateStatistic -/ noncomputable def simplexCoordinateStatistic (idx : Fin L) (x : Fin L → ℝ) : ℝ := ∑ j, concentrationCoefficient idx j*x j /- Original line 49024: Erdos416Proof.FordGeometry.concentrationDistance -/ def concentrationDistance (idx : Fin L) : ℕ := L-(idx.val+1) /- Original line 49026: Erdos416Proof.FordGeometry.centered_statistic -/ theorem centered_statistic (idx : Fin L) (x : Fin L → ℝ) : (∑ j, centeredCoefficient idx j*barycentric L x j) = simplexCoordinateStatistic idx x-concentrationMean idx := by unfold centeredCoefficient rw [barycentric_centering] simp [Erdos416Proof.SimplexVolume.sum_barycentric, barycentricCoefficient, barycentric, Fin.sum_univ_succ, simplexCoordinateStatistic] /-- The threshold is relative to the standard coordinate profile. -/ /- Original line 49035: Erdos416Proof.FordGeometry.simplexConcentrationEvent -/ def simplexConcentrationEvent (idx : Fin L) (η : ℝ) : Set (Fin L → ℝ) := positiveSimplex L 1 ∩ {x | η ≤ |simplexCoordinateStatistic idx x / ((concentrationDistance idx : ℝ)/(L : ℝ))-1|} /- Original line 49040: Erdos416Proof.FordGeometry.relative_deviation_forces_centered -/ theorem relative_deviation_forces_centered {s m q η : ℝ} (hq : 0 < q) (hmean : |m/q-1| ≤ η/2) (hbad : η ≤ |s/q-1|) : η*q/2 ≤ |s-m| := by have ht := abs_sub_le (s/q) (m/q) 1 rw [← sub_div, abs_div, abs_of_pos hq] at ht have hc : η/2 ≤ |s-m|/q := by linarith have hm := (le_div_iff₀ hq).mp hc linarith /- Original line 49049: Erdos416Proof.FordGeometry.simplexConcentrationEvent_subset_centered -/ theorem simplexConcentrationEvent_subset_centered (idx : Fin L) (hi : idx.val+1 < L) {η : ℝ} (_hη : 0 < η) (hmargin : 412 ≤ η*(concentrationDistance idx : ℝ)) : simplexConcentrationEvent idx η ⊆ positiveSimplex L 1 ∩ {x | η*((concentrationDistance idx : ℝ)/(L : ℝ))/2 ≤ |∑ j, centeredCoefficient idx j*barycentric L x j|} := by have hr : 0 < (concentrationDistance idx : ℝ) := by exact_mod_cast (show 0 < concentrationDistance idx by unfold concentrationDistance; omega) have hL : 0 < (L : ℝ) := by exact_mod_cast (by omega : 0 < L) have hm := concentrationMean_relative_error idx hi change |concentrationMean idx/((concentrationDistance idx : ℝ)/(L : ℝ))-1| ≤ 206/(concentrationDistance idx : ℝ) at hm have hsmall : 206/(concentrationDistance idx : ℝ) ≤ η/2 := by apply (div_le_iff₀ hr).mpr nlinarith rintro x ⟨hx, hbad⟩ refine ⟨hx, ?_⟩ change η*((concentrationDistance idx : ℝ)/(L : ℝ))/2 ≤ |∑ j, centeredCoefficient idx j*barycentric L x j| rw [centered_statistic] exact relative_deviation_forces_centered (div_pos hr hL) (hm.trans hsmall) hbad /-- Fixed tolerance concentration for one coordinate, with a summable inverse-square suffix bound. The renewal bias is absorbed by the margin. -/ /- Original line 49073: Erdos416Proof.FordGeometry.simplexConcentrationEvent_volume -/ theorem simplexConcentrationEvent_volume (idx : Fin L) (hi : idx.val+1 < L) {η : ℝ} (hη : 0 < η) (hmargin : 412 ≤ η*(concentrationDistance idx : ℝ)) : (L.factorial : ℝ)*volume.real (simplexConcentrationEvent idx η) ≤ 360000/(η^4*(concentrationDistance idx : ℝ)^2) := by let r : ℝ := concentrationDistance idx let q : ℝ := r/(L : ℝ) let ε : ℝ := η*q/2 let d : ℝ := ((L : ℝ)+1)*((L : ℝ)+2)*((L : ℝ)+3)*((L : ℝ)+4) have hr : 0 < r := by dsimp [Erdos416Proof.SimplexVolume.sum_barycentric, r, concentrationDistance] exact_mod_cast (show 0 < L-(idx.val+1) by omega) have hL : 0 < (L : ℝ) := by exact_mod_cast (by omega : 0 < L) have hε : 0 < ε := div_pos (mul_pos hη (div_pos hr hL)) (by norm_num) have hd : 0 < d := by dsimp [Erdos416Proof.SimplexVolume.sum_barycentric, d]; positivity have hLp : 0 < (L : ℝ)^4 := pow_pos hL 4 have hden : (L : ℝ)^4 ≤ d := by dsimp [Erdos416Proof.SimplexVolume.sum_barycentric, d] calc _ = (L : ℝ)*(L : ℝ)*(L : ℝ)*(L : ℝ) := by ring _ ≤ _ := by gcongr <;> linarith have hsubset := simplexConcentrationEvent_subset_centered idx hi hη hmargin have hfinite : volume (positiveSimplex L 1 ∩ {x | ε ≤ |∑ j, centeredCoefficient idx j*barycentric L x j|}) ≠ ⊤ := measure_ne_top_of_subset Set.inter_subset_left (positiveSimplex_isCompact L 1).measure_lt_top.ne have htail := barycentric_zero_mean_tail_le L (centeredCoefficient idx) (centeredCoefficient_sum idx) hε have hnum := centeredCoefficient_fourth_numerator_le idx hi change _ ≤ 22500*r^2 at hnum calc _ ≤ (L.factorial : ℝ)*volume.real (positiveSimplex L 1 ∩ {x | ε ≤ |∑ j, centeredCoefficient idx j*barycentric L x j|}) := mul_le_mul_of_nonneg_left (measureReal_mono hsubset hfinite) (Nat.cast_nonneg _) _ ≤ _ := htail _ ≤ (22500*r^2/d)/ε^4 := div_le_div_of_nonneg_right (div_le_div_of_nonneg_right hnum hd.le) (pow_pos hε 4).le _ ≤ (22500*r^2/(L : ℝ)^4)/ε^4 := div_le_div_of_nonneg_right (div_le_div_of_nonneg_left (by positivity) hLp hden) (pow_pos hε 4).le _ = _ := by change (22500*r^2/(L : ℝ)^4)/(η*(r/(L : ℝ))/2)^4 = 360000/(η^4*r^2) field_simp [hη.ne', hL.ne', hr.ne'] ring /- Original line 49116: Erdos416Proof.FordGeometry.concentrationIndices -/ def concentrationIndices (L A : ℕ) : Finset (Fin L) := Finset.univ.filter (fun idx => A ≤ concentrationDistance idx) /- Original line 49119: Erdos416Proof.FordGeometry.simplexConcentrationUnion -/ def simplexConcentrationUnion (L A : ℕ) (η : ℝ) : Set (Fin L → ℝ) := ⋃ idx ∈ concentrationIndices L A, simplexConcentrationEvent idx η /- Original line 49122: Erdos416Proof.FordGeometry.concentrationDistance_injective -/ theorem concentrationDistance_injective : Function.Injective (concentrationDistance : Fin L → ℕ) := by intro idx j hij apply Fin.ext unfold concentrationDistance at hij have hi := idx.isLt have hj := j.isLt omega /- Original line 49131: Erdos416Proof.FordGeometry.concentration_distance_sum_le -/ theorem concentration_distance_sum_le {A : ℕ} (hA : 1 ≤ A) : (∑ idx ∈ concentrationIndices L A, ((concentrationDistance idx : ℝ)^2)⁻¹) ≤ 2/(A : ℝ) := by let s := concentrationIndices L A have hsub : s.image concentrationDistance ⊆ Finset.Ioo (A-1) L := by intro r hr obtain ⟨idx, hi, rfl⟩ := Finset.mem_image.mp hr have hAi : A ≤ concentrationDistance idx := (Finset.mem_filter.mp hi).2 have hiL := idx.isLt simp only [Finset.mem_Ioo] unfold concentrationDistance at * omega calc _ = ∑ r ∈ s.image concentrationDistance, ((r : ℝ)^2)⁻¹ := by rw [Finset.sum_image] intro idx hi j hj hij exact concentrationDistance_injective hij _ ≤ ∑ r ∈ Finset.Ioo (A-1) L, ((r : ℝ)^2)⁻¹ := Finset.sum_le_sum_of_subset_of_nonneg hsub (by intros; positivity) _ ≤ 2/((A-1 : ℕ)+1 : ℝ) := sum_Ioo_inv_sq_le (A-1) L _ = _ := by have he : ((A-1 : ℕ) : ℝ)+1 = (A : ℝ) := by exact_mod_cast (Nat.sub_add_cancel hA) rw [he] /-- Simultaneous concentration of every coordinate at suffix distance at least A. A is fixed before sending the dimension to infinity. -/ /- Original line 49158: Erdos416Proof.FordGeometry.simplexConcentrationUnion_volume -/ theorem simplexConcentrationUnion_volume {A : ℕ} (hA : 1 ≤ A) {η : ℝ} (hη : 0 < η) (hmargin : 412 ≤ η*(A : ℝ)) : (L.factorial : ℝ)*volume.real (simplexConcentrationUnion L A η) ≤ 720000/(η^4*(A : ℝ)) := by have hsum : ∀ idx ∈ concentrationIndices L A, (L.factorial : ℝ)*volume.real (simplexConcentrationEvent idx η) ≤ (360000/η^4)*((concentrationDistance idx : ℝ)^2)⁻¹ := by intro idx hi have hAi := (Finset.mem_filter.mp hi).2 have hir : idx.val+1 < L := by unfold concentrationDistance at hAi; omega have hAir : (A : ℝ) ≤ (concentrationDistance idx : ℝ) := by exact_mod_cast hAi have hmi : 412 ≤ η*(concentrationDistance idx : ℝ) := hmargin.trans (mul_le_mul_of_nonneg_left hAir hη.le) simpa only [div_mul_eq_div_mul_one_div, one_div] using simplexConcentrationEvent_volume idx hir hη hmi calc _ ≤ (L.factorial : ℝ)*(∑ idx ∈ concentrationIndices L A, volume.real (simplexConcentrationEvent idx η)) := mul_le_mul_of_nonneg_left (measureReal_biUnion_finset_le (concentrationIndices L A) (fun idx => simplexConcentrationEvent idx η)) (Nat.cast_nonneg _) _ = ∑ idx ∈ concentrationIndices L A, (L.factorial : ℝ)*volume.real (simplexConcentrationEvent idx η) := Finset.mul_sum .. _ ≤ ∑ idx ∈ concentrationIndices L A, (360000/η^4)*((concentrationDistance idx : ℝ)^2)⁻¹ := Finset.sum_le_sum hsum _ = (360000/η^4)*(∑ idx ∈ concentrationIndices L A, ((concentrationDistance idx : ℝ)^2)⁻¹) := (Finset.mul_sum ..).symm _ ≤ (360000/η^4)*(2/(A : ℝ)) := mul_le_mul_of_nonneg_left (concentration_distance_sum_le hA) (by positivity) _ = _ := by ring /-- Exact Jacobian of the normalized slack map, for arbitrary sets. -/ /- Original line 49190: Erdos416Proof.FordGeometry.normalizedSlack_volume_image -/ theorem normalizedSlack_volume_image (E : Set (Fin L → ℝ)) : volume.real (normalizedSlack '' E) = renewalDenominator L*volume.real E := by have hmap : normalizedSlack '' E = rescale L (fun idx => (simplexWeight L idx)⁻¹) '' (slackMap L '' E) := by rw [Set.image_image] congr 1 funext x idx simp [Erdos416Proof.FordGeometry.modelVolume_one, Erdos416Proof.FordGeometry.modelVolume_zero, Erdos416Proof.FordGeometry.slackEquiv_apply, Erdos416Proof.FordGeometry.slackMap_apply, Erdos416Proof.SimplexVolume.rescale_apply, normalizedSlack] rw [hmap, measureReal_def, Measure.addHaar_image_linearMap, rescale_det, Finset.prod_inv_distrib, inv_inv, simplexWeight_product, ENNReal.toReal_mul, ENNReal.toReal_ofReal (abs_nonneg _), abs_of_pos (renewalDenominator_pos L), ← measureReal_def, slack_volume_image] /- Original line 49203: Erdos416Proof.FordGeometry.normalizedSlack_volume_ratio -/ theorem normalizedSlack_volume_ratio (hL : 2 ≤ L) (E : Set (Fin L → ℝ)) : volume.real E/TStar L = (L.factorial : ℝ)*volume.real (normalizedSlack '' E) := by rw [normalizedSlack_volume_image, TStar_eq hL, div_div_eq_mul_div, div_one] ring /- Original line 49208: Erdos416Proof.FordGeometry.unorderedConcentrationUnion -/ def unorderedConcentrationUnion (L A : ℕ) (η : ℝ) : Set (Fin L → ℝ) := unorderedSimplex L ∩ {x | ∃ idx ∈ concentrationIndices L A, η ≤ |x idx/(rho^(idx.val+1)*((concentrationDistance idx : ℝ)/(L : ℝ)))-1|} /- Original line 49212: Erdos416Proof.FordGeometry.normalizedSlack_bad_union_subset -/ theorem normalizedSlack_bad_union_subset (hL : 2 ≤ L) (A : ℕ) (η : ℝ) : normalizedSlack '' unorderedConcentrationUnion L A η ⊆ simplexConcentrationUnion L A η := by rintro _ ⟨x, ⟨hx, idx, hi, hbad⟩, rfl⟩ apply Set.mem_iUnion_of_mem idx apply Set.mem_iUnion_of_mem hi refine ⟨normalizedSlack_mem_simplex hL hx, ?_⟩ change η ≤ |(∑ j, concentrationCoefficient idx j*normalizedSlack x j)/ ((concentrationDistance idx : ℝ)/(L : ℝ))-1| rw [normalized_slack_coordinate, div_div] exact hbad /-- The simultaneous concentration estimate in the original Ford simplex. This includes the arithmetic-free Jacobian transfer, with no coverage assumption. -/ /- Original line 49225: Erdos416Proof.FordGeometry.unorderedConcentrationUnion_volume -/ theorem unorderedConcentrationUnion_volume (hL : 2 ≤ L) {A : ℕ} (hA : 1 ≤ A) {η : ℝ} (hη : 0 < η) (hmargin : 412 ≤ η*(A : ℝ)) : volume.real (unorderedConcentrationUnion L A η)/TStar L ≤ 720000/(η^4*(A : ℝ)) := by have hfinite : volume (simplexConcentrationUnion L A η) ≠ ⊤ := by apply measure_ne_top_of_subset _ (positiveSimplex_isCompact L 1).measure_lt_top.ne intro x hx obtain ⟨idx, hx⟩ := Set.mem_iUnion.mp hx obtain ⟨hi, hx⟩ := Set.mem_iUnion.mp hx exact hx.1 rw [normalizedSlack_volume_ratio hL] exact (mul_le_mul_of_nonneg_left (measureReal_mono (normalizedSlack_bad_union_subset hL A η) hfinite) (Nat.cast_nonneg _)).trans (simplexConcentrationUnion_volume hA hη hmargin) end Erdos416Proof.FordGeometry end /- Consolidated component: ThickenedConcentration.lean. -/ section open Filter Finset MeasureTheory open scoped Classical Topology BigOperators Pointwise namespace Erdos416Proof.FordGeometry open FordAnalysis SimplexVolume variable {L : ℕ} /- Original line 49259: Erdos416Proof.FordGeometry.concentrationDilation -/ noncomputable def concentrationDilation (L : ℕ) (τ : ℝ) : ℝ := 1+2*τ*∑ j : Fin L, simplexWeight L j /- Original line 49262: Erdos416Proof.FordGeometry.weightedThickError -/ noncomputable def weightedThickError (τ : ℝ) (e : Fin L → ℝ) (j : Fin L) : ℝ := simplexWeight L j*thickSlack L τ e j /- Original line 49265: Erdos416Proof.FordGeometry.thickNormalizedSlack -/ noncomputable def thickNormalizedSlack (L : ℕ) (τ : ℝ) (x : Fin L → ℝ) (j : Fin L) : ℝ := simplexWeight L j*thickSlack L τ x j/concentrationDilation L τ /- Original line 49268: Erdos416Proof.FordGeometry.concentrationDilation_ge_one -/ theorem concentrationDilation_ge_one {τ : ℝ} (hτ : 0 ≤ τ) : 1 ≤ concentrationDilation L τ := by have hw : 0 ≤ ∑ j : Fin L, simplexWeight L j := Finset.sum_nonneg (fun j _ => (simplexWeight_pos j).le) have hm : 0 ≤ 2*τ*∑ j : Fin L, simplexWeight L j := by positivity dsimp [concentrationDilation] linarith /- Original line 49276: Erdos416Proof.FordGeometry.concentrationDilation_linear_bound -/ theorem concentrationDilation_linear_bound (hL : 2 ≤ L) {τ : ℝ} (hsmall : τ ≤ 10*rho^L/(L : ℝ)) : (L : ℝ)*(concentrationDilation L τ-1) ≤ 80 := by have hLp : (0 : ℝ) < L := by exact_mod_cast (show 0 < L by omega) have hs : 0 ≤ ∑ j : Fin L, simplexWeight L j := Finset.sum_nonneg (fun j _ => (simplexWeight_pos j).le) have hτL := (le_div_iff₀ hLp).mp hsmall have hprod := mul_le_mul_of_nonneg_right hτL hs have hsum := simplexWeight_scaled_sum_bound hL dsimp [concentrationDilation] nlinarith /- Original line 49288: Erdos416Proof.FordGeometry.weightedThickError_nonneg -/ theorem weightedThickError_nonneg {τ : ℝ} {e : Fin L → ℝ} (he : e ∈ errorCube L τ) (j : Fin L) : 0 ≤ weightedThickError τ e j := by have hz : (0 : Fin L → ℝ) ∈ unorderedSimplex L := by constructor · simp[Erdos416Proof.FordGeometry.slackMap_apply] · intro idx; simp[Erdos416Proof.FordGeometry.slackMap_apply] have h := thickSlack_nonneg hz he j unfold weightedThickError apply mul_nonneg (simplexWeight_pos j).le simpa only [zero_add] using h /- Original line 49299: Erdos416Proof.FordGeometry.weightedThickError_sum -/ theorem weightedThickError_sum (hL : 2 ≤ L) {τ : ℝ} {e : Fin L → ℝ} (he : e ∈ errorCube L τ) : (∑ j, weightedThickError τ e j) ≤ concentrationDilation L τ-1 := by have hshift : (∑ idx, simplexWeight L idx*slackShift L τ idx) = τ*∑ idx : Fin L, simplexWeight L idx*slackRowRadius idx := by simp [Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordGeometry.slackEquiv_apply, Erdos416Proof.FordGeometry.slackMap_apply, slackShift, Finset.mul_sum, mul_left_comm] have hw : (∑ idx, weightedThickError τ e idx) = outerForm L e+τ*∑ idx : Fin L, simplexWeight L idx*slackRowRadius idx := by simp only [weightedThickError, thickSlack, Pi.add_apply, mul_add, Finset.sum_add_distrib, weighted_slack_eq_outer hL, hshift] rw [hw, slackRowRadius_weight_sum hL] have ho : outerForm L e ≤ (∑ j : Fin L, fordWeight (j.val+1))*τ := (le_abs_self _).trans (weightedForm_errorCube_bound (fun j : Fin L => fordWeight (j.val+1)) (fun j => (fordWeight_bounds (by omega)).1) he) dsimp [Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordGeometry.slackEquiv_apply, Erdos416Proof.FordGeometry.slackMap_apply, concentrationDilation] nlinarith /- Original line 49317: Erdos416Proof.FordGeometry.thickNormalizedSlack_decomposition -/ theorem thickNormalizedSlack_decomposition (τ : ℝ) (x e : Fin L → ℝ) (j : Fin L) : thickNormalizedSlack L τ (x+e) j = (normalizedSlack x j+weightedThickError τ e j)/concentrationDilation L τ := by simp only [thickNormalizedSlack, weightedThickError, normalizedSlack, thickSlack, map_add, Pi.add_apply] ring /- Original line 49324: Erdos416Proof.FordGeometry.simplexCoordinateStatistic_bounds -/ theorem simplexCoordinateStatistic_bounds (idx : Fin L) {x : Fin L → ℝ} (hx : x ∈ positiveSimplex L 1) : 0 ≤ simplexCoordinateStatistic idx x ∧ simplexCoordinateStatistic idx x ≤ 5 := by constructor · exact Finset.sum_nonneg (fun j _ => mul_nonneg (concentrationCoefficient_nonneg idx j) (hx.1 j)) · have hsum : simplexCoordinateStatistic idx x ≤ ∑ j, 5*x j := Finset.sum_le_sum (fun j _ => mul_le_mul_of_nonneg_right (concentrationCoefficient_le_five idx j) (hx.1 j)) rw [← Finset.mul_sum] at hsum linarith [hx.2] /- Original line 49335: Erdos416Proof.FordGeometry.weightedThickError_statistic_bounds -/ theorem weightedThickError_statistic_bounds (hL : 2 ≤ L) (idx : Fin L) {τ : ℝ} {e : Fin L → ℝ} (he : e ∈ errorCube L τ) : 0 ≤ simplexCoordinateStatistic idx (weightedThickError τ e) ∧ simplexCoordinateStatistic idx (weightedThickError τ e) ≤ 5*(concentrationDilation L τ-1) := by constructor · exact Finset.sum_nonneg (fun j _ => mul_nonneg (concentrationCoefficient_nonneg idx j) (weightedThickError_nonneg he j)) · have hsum : simplexCoordinateStatistic idx (weightedThickError τ e) ≤ ∑ j, 5*weightedThickError τ e j := Finset.sum_le_sum (fun j _ => mul_le_mul_of_nonneg_right (concentrationCoefficient_le_five idx j) (weightedThickError_nonneg he j)) rw [← Finset.mul_sum] at hsum linarith [weightedThickError_sum hL he] /- Original line 49349: Erdos416Proof.FordGeometry.thickNormalizedSlack_mem_simplex -/ theorem thickNormalizedSlack_mem_simplex (hL : 2 ≤ L) {τ : ℝ} (hτ : 0 ≤ τ) {x e : Fin L → ℝ} (hx : x ∈ unorderedSimplex L) (he : e ∈ errorCube L τ) : thickNormalizedSlack L τ (x+e) ∈ positiveSimplex L 1 := by have hs : 0 < concentrationDilation L τ := lt_of_lt_of_le zero_lt_one (concentrationDilation_ge_one hτ) have hv := normalizedSlack_mem_simplex hL hx constructor · intro j rw [thickNormalizedSlack_decomposition] exact div_nonneg (add_nonneg (hv.1 j) (weightedThickError_nonneg he j)) hs.le · simp_rw [thickNormalizedSlack_decomposition] rw [← Finset.sum_div, Finset.sum_add_distrib] apply (div_le_one hs).mpr linarith [hv.2, weightedThickError_sum hL he] /- Original line 49363: Erdos416Proof.FordGeometry.bounded_statistic_perturbation -/ theorem bounded_statistic_perturbation {v g s : ℝ} (hs : 1 ≤ s) (hv : 0 ≤ v ∧ v ≤ 5) (hg : 0 ≤ g ∧ g ≤ 5*(s-1)) : |(v+g)/s-v| ≤ 5*(s-1)/s := by have hsp : 0 < s := lt_of_lt_of_le zero_lt_one hs have hprod := mul_le_mul_of_nonneg_left hv.2 (sub_nonneg.mpr hs) have hprod0 := mul_nonneg (sub_nonneg.mpr hs) hv.1 have hab : |g-(s-1)*v| ≤ 5*(s-1) := abs_le.mpr ⟨by nlinarith [hg.1], by nlinarith [hg.2]⟩ have he : (v+g)/s-v = (g-(s-1)*v)/s := by field_simp ring rw [he, abs_div, abs_of_pos hsp] exact div_le_div_of_nonneg_right hab hsp.le /- Original line 49376: Erdos416Proof.FordGeometry.thickNormalizedSlack_statistic_drift -/ theorem thickNormalizedSlack_statistic_drift (hL : 2 ≤ L) (idx : Fin L) {τ : ℝ} (hτ : 0 ≤ τ) {x e : Fin L → ℝ} (hx : x ∈ unorderedSimplex L) (he : e ∈ errorCube L τ) : |simplexCoordinateStatistic idx (thickNormalizedSlack L τ (x+e))- simplexCoordinateStatistic idx (normalizedSlack x)| ≤ 5*(concentrationDilation L τ-1)/concentrationDilation L τ := by have heq : simplexCoordinateStatistic idx (thickNormalizedSlack L τ (x+e)) = (simplexCoordinateStatistic idx (normalizedSlack x)+ simplexCoordinateStatistic idx (weightedThickError τ e))/concentrationDilation L τ := by simp only [simplexCoordinateStatistic, thickNormalizedSlack_decomposition, ← mul_div_assoc, mul_add, ← Finset.sum_div, Finset.sum_add_distrib] rw [heq] exact bounded_statistic_perturbation (concentrationDilation_ge_one hτ) (simplexCoordinateStatistic_bounds idx (normalizedSlack_mem_simplex hL hx)) (weightedThickError_statistic_bounds hL idx he) /- Original line 49392: Erdos416Proof.FordGeometry.thickNormalizedSlack_relative_drift -/ theorem thickNormalizedSlack_relative_drift (hL : 2 ≤ L) (idx : Fin L) (hi : idx.val+1 < L) {τ : ℝ} (hτ : 0 ≤ τ) (hsmall : τ ≤ 10*rho^L/(L : ℝ)) {x e : Fin L → ℝ} (hx : x ∈ unorderedSimplex L) (he : e ∈ errorCube L τ) : |simplexCoordinateStatistic idx (thickNormalizedSlack L τ (x+e))/ ((concentrationDistance idx : ℝ)/(L : ℝ))- simplexCoordinateStatistic idx (normalizedSlack x)/ ((concentrationDistance idx : ℝ)/(L : ℝ))| ≤ 400/(concentrationDistance idx : ℝ) := by have hr : 0 < (concentrationDistance idx : ℝ) := by exact_mod_cast (show 0 < concentrationDistance idx by unfold concentrationDistance; omega) have hLp : 0 < (L : ℝ) := by exact_mod_cast (show 0 < L by omega) have hs := concentrationDilation_ge_one (L := L) hτ have hsp : 0 < concentrationDilation L τ := lt_of_lt_of_le zero_lt_one hs have hd := thickNormalizedSlack_statistic_drift hL idx hτ hx he have hbound : 5*(concentrationDilation L τ-1)/concentrationDilation L τ ≤ 5*(concentrationDilation L τ-1) := by apply (div_le_iff₀ hsp).mpr nlinarith [mul_nonneg (sub_nonneg.mpr hs) (sub_nonneg.mpr hs)] rw [← sub_div, abs_div, abs_of_pos (div_pos hr hLp)] calc _ ≤ (5*(concentrationDilation L τ-1))/((concentrationDistance idx : ℝ)/(L : ℝ)) := div_le_div_of_nonneg_right (hd.trans hbound) (div_pos hr hLp).le _ = (5*((L : ℝ)*(concentrationDilation L τ-1)))/(concentrationDistance idx : ℝ) := by rw [div_div_eq_mul_div] ring _ ≤ _ := div_le_div_of_nonneg_right (by linarith [concentrationDilation_linear_bound hL hsmall]) hr.le /-- The affine normalization has the original terminal gStar Jacobian. -/ /- Original line 49419: Erdos416Proof.FordGeometry.thickNormalizedSlack_volume_image -/ theorem thickNormalizedSlack_volume_image {τ : ℝ} (hτ : 0 ≤ τ) (E : Set (Fin L → ℝ)) : volume.real (thickNormalizedSlack L τ '' E) = (concentrationDilation L τ^L)⁻¹*(renewalDenominator L*volume.real E) := by let c : Fin L → ℝ := fun j => simplexWeight L j*slackShift L τ j let s := concentrationDilation L τ have hs : 0 < s := lt_of_lt_of_le zero_lt_one (concentrationDilation_ge_one hτ) have hmap : thickNormalizedSlack L τ '' E = rescale L (fun _ => s) '' ((fun v => v+c) '' (normalizedSlack '' E)) := by rw [Set.image_image, Set.image_image] congr 1 funext x j simp only [rescale_apply, thickNormalizedSlack, thickSlack, Pi.add_apply, normalizedSlack, c] dsimp [Erdos416Proof.FordGeometry.modelVolume_one, Erdos416Proof.FordGeometry.modelVolume_zero, Erdos416Proof.FordGeometry.slackEquiv_apply, Erdos416Proof.FordGeometry.slackMap_apply, Erdos416Proof.SimplexVolume.rescale_apply, s] ring have hscale (F : Set (Fin L → ℝ)) : volume.real (rescale L (fun _ => s) '' F) = (s^L)⁻¹*volume.real F := by rw [measureReal_def, Measure.addHaar_image_linearMap, rescale_det, Finset.prod_const, Finset.card_univ, Fintype.card_fin, ENNReal.toReal_mul, ENNReal.toReal_ofReal (abs_nonneg _), abs_of_pos (inv_pos.mpr (pow_pos hs L))] rfl have htrans : volume.real ((fun v => v+c) '' (normalizedSlack '' E)) = volume.real (normalizedSlack '' E) := by rw [measureReal_def, Set.image_add_right, measure_preimage_add_right] rfl rw [hmap, hscale, htrans, normalizedSlack_volume_image] /- Original line 49447: Erdos416Proof.FordGeometry.thickNormalizedSlack_volume_ratio -/ theorem thickNormalizedSlack_volume_ratio (hL : 2 ≤ L) {τ : ℝ} (hτ : 0 ≤ τ) (E : Set (Fin L → ℝ)) : volume.real E/TStar L = concentrationDilation L τ^L * ((L.factorial : ℝ)*volume.real (thickNormalizedSlack L τ '' E)) := by have hs : 0 < concentrationDilation L τ := lt_of_lt_of_le zero_lt_one (concentrationDilation_ge_one hτ) rw [thickNormalizedSlack_volume_image hτ, TStar_eq hL, div_div_eq_mul_div, div_one] field_simp [hs.ne'] /- Original line 49456: Erdos416Proof.FordGeometry.thickNormalizedSlack_bad_union_subset -/ theorem thickNormalizedSlack_bad_union_subset (hL : 2 ≤ L) {A : ℕ} (hA : 1 ≤ A) {η : ℝ} (hη : 0 < η) (hmargin : 824 ≤ η*(A : ℝ)) {τ : ℝ} (hτ : 0 ≤ τ) (hsmall : τ ≤ 10*rho^L/(L : ℝ)) : thickNormalizedSlack L τ '' (unorderedConcentrationUnion L A η+errorCube L τ) ⊆ simplexConcentrationUnion L A (η/2) := by rintro _ ⟨z, hz, rfl⟩ obtain ⟨x, ⟨hx, idx, hi, hbad⟩, e, he, rfl⟩ := Set.mem_add.mp hz have hAi := (Finset.mem_filter.mp hi).2 have hir : idx.val+1 < L := by unfold concentrationDistance at hAi; omega have hr : 0 < (concentrationDistance idx : ℝ) := by exact_mod_cast (show 0 < concentrationDistance idx by unfold concentrationDistance; omega) have hAir : (A : ℝ) ≤ (concentrationDistance idx : ℝ) := by exact_mod_cast hAi have hmi : 824 ≤ η*(concentrationDistance idx : ℝ) := hmargin.trans (mul_le_mul_of_nonneg_left hAir hη.le) have hsmallDrift : 400/(concentrationDistance idx : ℝ) ≤ η/2 := by apply (div_le_iff₀ hr).mpr nlinarith have hd := (thickNormalizedSlack_relative_drift hL idx hir hτ hsmall hx he).trans hsmallDrift have hb : η ≤ |simplexCoordinateStatistic idx (normalizedSlack x)/ ((concentrationDistance idx : ℝ)/(L : ℝ))-1| := by simpa only [simplexCoordinateStatistic, normalized_slack_coordinate, div_div] using hbad apply Set.mem_iUnion_of_mem idx apply Set.mem_iUnion_of_mem hi refine ⟨thickNormalizedSlack_mem_simplex hL hτ hx he, ?_⟩ change η/2 ≤ |simplexCoordinateStatistic idx (thickNormalizedSlack L τ (x+e))/ ((concentrationDistance idx : ℝ)/(L : ℝ))-1| have ht := abs_sub_le (simplexCoordinateStatistic idx (normalizedSlack x)/((concentrationDistance idx : ℝ)/(L : ℝ))) (simplexCoordinateStatistic idx (thickNormalizedSlack L τ (x+e))/((concentrationDistance idx : ℝ)/(L : ℝ))) 1 rw [abs_sub_comm] at hd linarith /-- Uniform concentration remains summable after the mesh enlargement needed by reciprocal prime-tuple counting. -/ /- Original line 49490: Erdos416Proof.FordGeometry.thickened_unorderedConcentrationUnion_volume -/ theorem thickened_unorderedConcentrationUnion_volume (hL : 2 ≤ L) {A : ℕ} (hA : 1 ≤ A) {η : ℝ} (hη : 0 < η) (hmargin : 824 ≤ η*(A : ℝ)) {τ : ℝ} (hτ : 0 ≤ τ) (hsmall : τ ≤ 10*rho^L/(L : ℝ)) : volume.real (unorderedConcentrationUnion L A η+errorCube L τ)/TStar L ≤ (11520000*Real.exp 80)/(η^4*(A : ℝ)) := by have hηhalf : 0 < η/2 := by positivity have hmarginhalf : 412 ≤ (η/2)*(A : ℝ) := by nlinarith have hfinite : volume (simplexConcentrationUnion L A (η/2)) ≠ ⊤ := by apply measure_ne_top_of_subset _ (positiveSimplex_isCompact L 1).measure_lt_top.ne intro x hx obtain ⟨idx, hx⟩ := Set.mem_iUnion.mp hx obtain ⟨hi, hx⟩ := Set.mem_iUnion.mp hx exact hx.1 have hmono := measureReal_mono (thickNormalizedSlack_bad_union_subset hL hA hη hmargin hτ hsmall) hfinite have hs : 0 ≤ concentrationDilation L τ^L := pow_nonneg (zero_le_one.trans (concentrationDilation_ge_one hτ)) L calc _ = concentrationDilation L τ^L * ((L.factorial : ℝ)*volume.real (thickNormalizedSlack L τ '' (unorderedConcentrationUnion L A η+errorCube L τ))) := thickNormalizedSlack_volume_ratio hL hτ _ _ ≤ concentrationDilation L τ^L * ((L.factorial : ℝ)*volume.real (simplexConcentrationUnion L A (η/2))) := mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_left hmono (Nat.cast_nonneg _)) hs _ ≤ concentrationDilation L τ^L * (720000/((η/2)^4*(A : ℝ))) := mul_le_mul_of_nonneg_left (simplexConcentrationUnion_volume hA hηhalf hmarginhalf) hs _ ≤ Real.exp 80*(720000/((η/2)^4*(A : ℝ))) := mul_le_mul_of_nonneg_right (thickening_power_bound hL hτ hsmall) (by positivity) _ = _ := by ring end Erdos416Proof.FordGeometry end /- Consolidated component: ExpandedConcentration.lean. -/ section open Filter Finset MeasureTheory open scoped Classical Topology BigOperators Pointwise namespace Erdos416Proof.FordGeometry open FordAnalysis SimplexVolume variable {L : ℕ} /-- A small diagonal dilation can only halve the prescribed tolerance. -/ /- Original line 49540: Erdos416Proof.FordGeometry.diagonal_deviation_forces_normalized -/ theorem diagonal_deviation_forces_normalized {u s η : ℝ} (hη : 0 < η) (hη1 : η ≤ 1) (hs : 1 ≤ s) (hs' : s ≤ 1+η/4) (hbad : η ≤ |s*u-1|) : η/2 ≤ |u-1| := by by_contra hnot have hc : |u-1| < η/2 := lt_of_not_ge hnot obtain ⟨hcl, hcu⟩ := abs_lt.mp hc have hu : 0 ≤ u := by linarith have hsp : 0 < s := lt_of_lt_of_le zero_lt_one hs have hlo : u ≤ s*u := le_mul_of_one_le_left hu hs have hhi : s*u < s*(1+η/2) := mul_lt_mul_of_pos_left (by linarith) hsp have hhi' := mul_le_mul_of_nonneg_right hs' (by positivity : 0 ≤ 1+η/2) have hηsq := mul_le_mul_of_nonneg_left hη1 hη.le have hab : |s*u-1| < η := abs_lt.mpr ⟨by nlinarith, by nlinarith⟩ exact (not_le_of_gt hab) hbad /- Original line 49555: Erdos416Proof.FordGeometry.parameterConcentrationUnion -/ def parameterConcentrationUnion (L : ℕ) (ξ : ℕ → ℝ) (A : ℕ) (η : ℝ) : Set (Fin L → ℝ) := polytope L ξ ∩ {x | ∃ idx ∈ concentrationIndices L A, η ≤ |x idx/(rho^(idx.val+1)*((concentrationDistance idx : ℝ)/(L : ℝ)))-1|} /- Original line 49559: Erdos416Proof.FordGeometry.parameter_bad_normalized -/ theorem parameter_bad_normalized {ξ : ℕ → ℝ} (hξ : ∀ j, 1 ≤ ξ j) {η : ℝ} (hη : 0 < η) (hη1 : η ≤ 1) (hH : H L ξ ≤ 1+η/4) {A : ℕ} {x : Fin L → ℝ} (hx : x ∈ parameterConcentrationUnion L ξ A η) : normalized ξ x ∈ unorderedConcentrationUnion L A (η/2) := by obtain ⟨hx, idx, hi, hbad⟩ := hx refine ⟨polytope_subset_unorderedSimplex L (normalized_mem hξ hx), idx, hi, ?_⟩ have hs : 1 ≤ scaleProduct ξ (idx.val+1) := prefix_ge_one hξ _ have hs' : scaleProduct ξ (idx.val+1) ≤ 1+η/4 := ((prefix_monotone hξ (by have := idx.isLt; omega)).trans (scaleProduct_le_H hξ L)).trans hH have hprod : scaleProduct ξ (idx.val+1)*normalized ξ x idx = x idx := by have hp := congrArg (fun v : Fin L → ℝ => v idx) (diagonal_normalized (fun j => lt_of_lt_of_le zero_lt_one (hξ j)) x) simpa only [diagonal_apply] using hp apply diagonal_deviation_forces_normalized hη hη1 hs hs' rw [← mul_div_assoc, hprod] exact hbad /- Original line 49576: Erdos416Proof.FordGeometry.thickened_parameter_bad_subset_diagonal -/ theorem thickened_parameter_bad_subset_diagonal {ξ : ℕ → ℝ} (hξ : ∀ j, 1 ≤ ξ j) {η : ℝ} (hη : 0 < η) (hη1 : η ≤ 1) (hH : H L ξ ≤ 1+η/4) {A : ℕ} {τ : ℝ} (hτ : 0 ≤ τ) : parameterConcentrationUnion L ξ A η+errorCube L τ ⊆ diagonal L ξ '' (unorderedConcentrationUnion L A (η/2)+errorCube L τ) := by intro z hz obtain ⟨x, hx, e, he, rfl⟩ := Set.mem_add.mp hz refine ⟨normalized ξ x+normalized ξ e, Set.mem_add.mpr ⟨normalized ξ x, parameter_bad_normalized hξ hη hη1 hH hx, normalized ξ e, normalized_mem_errorCube hξ hτ he, rfl⟩, ?_⟩ rw [map_add, diagonal_normalized (fun j => lt_of_lt_of_le zero_lt_one (hξ j)), diagonal_normalized (fun j => lt_of_lt_of_le zero_lt_one (hξ j))] /-- Concentration for the perturbed Ford polytope after the mesh enlargement. The determinant and terminal coefficient are both retained exactly until the last numerical comparison. -/ /- Original line 49592: Erdos416Proof.FordGeometry.thickened_parameterConcentrationUnion_volume -/ theorem thickened_parameterConcentrationUnion_volume (hL : 2 ≤ L) {ξ : ℕ → ℝ} (hξ : ∀ j, 1 ≤ ξ j) {A : ℕ} (hA : 1 ≤ A) {η : ℝ} (hη : 0 < η) (hη1 : η ≤ 1) (hH : H L ξ ≤ 1+η/4) (hmargin : 1648 ≤ η*(A : ℝ)) {τ : ℝ} (hτ : 0 ≤ τ) (hsmall : τ ≤ 10*rho^L/(L : ℝ)) : volume.real (parameterConcentrationUnion L ξ A η+errorCube L τ)/TStar L ≤ (368640000*Real.exp 80)/(η^4*(A : ℝ)) := by have hH0 : 0 ≤ H L ξ := H_nonneg (fun j => zero_le_one.trans (hξ j)) have hH2 : H L ξ ≤ 2 := by linarith have hηhalf : 0 < η/2 := by positivity have hmarginhalf : 824 ≤ (η/2)*(A : ℝ) := by nlinarith have hcompact : IsCompact (diagonal L ξ '' (unorderedSimplex L+errorCube L τ)) := ((unorderedSimplex_isCompact hL).add isCompact_Icc).image (diagonal L ξ).continuous_of_finiteDimensional have hfin : volume (diagonal L ξ '' (unorderedConcentrationUnion L A (η/2)+errorCube L τ)) ≠ ⊤ := by apply measure_ne_top_of_subset _ hcompact.measure_lt_top.ne apply Set.image_mono exact Set.add_subset_add Set.inter_subset_left Set.Subset.rfl have hvolume : volume.real (parameterConcentrationUnion L ξ A η+errorCube L τ) ≤ H L ξ*volume.real (unorderedConcentrationUnion L A (η/2)+errorCube L τ) := by have hm := measureReal_mono (thickened_parameter_bad_subset_diagonal hξ hη hη1 hH hτ) hfin simpa only [diagonal_volume, abs_of_nonneg hH0] using hm calc _ ≤ (H L ξ*volume.real (unorderedConcentrationUnion L A (η/2)+errorCube L τ))/TStar L := div_le_div_of_nonneg_right hvolume (TStar_pos hL).le _ = H L ξ*(volume.real (unorderedConcentrationUnion L A (η/2)+errorCube L τ)/TStar L) := by ring _ ≤ H L ξ*((11520000*Real.exp 80)/((η/2)^4*(A : ℝ))) := mul_le_mul_of_nonneg_left (thickened_unorderedConcentrationUnion_volume hL hA hηhalf hmarginhalf hτ hsmall) hH0 _ ≤ 2*((11520000*Real.exp 80)/((η/2)^4*(A : ℝ))) := mul_le_mul_of_nonneg_right hH2 (by positivity) _ = _ := by ring /-- The expansion offset controls every later dimension at once. -/ /- Original line 49627: Erdos416Proof.FordGeometry.expanded_H_eventually_close -/ theorem expanded_H_eventually_close {δ : ℝ} (hδ : 0 < δ) : ∀ᶠ M : ℕ in atTop, ∀ L : ℕ, H L (expandedParameter (L+M)) ≤ 1+δ := by have hM : Tendsto (fun M : ℕ => (M : ℝ)/40) atTop atTop := tendsto_natCast_atTop_atTop.atTop_div_const (by norm_num : (0 : ℝ) < 40) have hz := Real.tendsto_exp_neg_atTop_nhds_zero.comp hM have hlim : Tendsto (fun M : ℕ => Real.exp (perturbationConstant*Real.exp (-((M : ℝ)/40)))) atTop (nhds 1) := by have he := (Real.continuous_exp.tendsto (perturbationConstant*0)).comp (hz.const_mul perturbationConstant) simpa only [Function.comp_def, mul_zero, Real.exp_zero] using! he filter_upwards [hlim.eventually (gt_mem_nhds (by linarith : (1 : ℝ) < 1+δ))] with M hM intro L exact (expanded_H_bound L M).trans hM.le /- Original line 49641: Erdos416Proof.FordGeometry.expandedConcentrationUnion_volume_eventually -/ theorem expandedConcentrationUnion_volume_eventually {η : ℝ} (hη : 0 < η) (hη1 : η ≤ 1) : ∀ᶠ M : ℕ in atTop, ∀ L : ℕ, 2 ≤ L → ∀ A : ℕ, 1 ≤ A → 1648 ≤ η*(A : ℝ) → ∀ τ : ℝ, 0 ≤ τ → τ ≤ 10*rho^L/(L : ℝ) → volume.real (parameterConcentrationUnion L (expandedParameter (L+M)) A η+ errorCube L τ)/TStar L ≤ (368640000*Real.exp 80)/(η^4*(A : ℝ)) := by filter_upwards [expanded_H_eventually_close (by positivity : 0 < η/4)] with M hM intro L hL A hA hmargin τ hτ hsmall exact thickened_parameterConcentrationUnion_volume hL (expandedParameter_ge_one _) hA hη hη1 (hM L) hmargin hτ hsmall end Erdos416Proof.FordGeometry end /- Consolidated component: ProfileConsequences.lean. -/ section open Filter Finset open scoped Classical Topology BigOperators namespace Erdos416Proof.FordGeometry open FordAnalysis FordScale /-- Coordinates are indexed from one; the top prime has index zero. -/ /- Original line 49670: Erdos416Proof.FordGeometry.coordinateProfile -/ noncomputable def coordinateProfile (D j : ℕ) : ℝ := rho^j*(((D-j : ℕ) : ℝ)/(D : ℝ)) /- Original line 49673: Erdos416Proof.FordGeometry.coordinateProfile_nonneg -/ theorem coordinateProfile_nonneg (D j : ℕ) : 0 ≤ coordinateProfile D j := by unfold coordinateProfile exact mul_nonneg (pow_nonneg rho_pos.le _) (div_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _)) /- Original line 49678: Erdos416Proof.FordGeometry.coordinateProfile_pos -/ theorem coordinateProfile_pos {D j : ℕ} (hj : j < D) : 0 < coordinateProfile D j := by have hD : 0 < (D : ℝ) := by exact_mod_cast (show 0 < D by omega) have hr : 0 < ((D-j : ℕ) : ℝ) := by exact_mod_cast Nat.sub_pos_of_lt hj exact mul_pos (pow_pos rho_pos j) (div_pos hr hD) /- Original line 49683: Erdos416Proof.FordGeometry.coordinateProfile_step -/ theorem coordinateProfile_step (D j : ℕ) : coordinateProfile D (j+1) ≤ rho*coordinateProfile D j := by have hr : ((D-(j+1) : ℕ) : ℝ) ≤ ((D-j : ℕ) : ℝ) := by exact_mod_cast (Nat.sub_le_sub_left (Nat.le_succ j) D) have hq := div_le_div_of_nonneg_right hr (Nat.cast_nonneg D : (0 : ℝ) ≤ D) unfold coordinateProfile rw [pow_succ] calc _ ≤ (rho^j*rho)*(((D-j : ℕ) : ℝ)/(D : ℝ)) := mul_le_mul_of_nonneg_left hq (mul_nonneg (pow_nonneg rho_pos.le _) rho_pos.le) _ = _ := by ring /- Original line 49695: Erdos416Proof.FordGeometry.coordinateProfile_le_rho -/ theorem coordinateProfile_le_rho {D j : ℕ} (hD : 0 < D) (hj : 1 ≤ j) : coordinateProfile D j ≤ rho := by have hDp : (0 : ℝ) < D := by exact_mod_cast hD have hq : ((D-j : ℕ) : ℝ)/(D : ℝ) ≤ 1 := by apply (div_le_one hDp).mpr exact_mod_cast (Nat.sub_le D j) exact (mul_le_of_le_one_right (pow_nonneg rho_pos.le _) hq).trans (pow_le_of_le_one rho_pos.le rho_lt_one.le (by omega)) /- Original line 49704: Erdos416Proof.FordGeometry.coordinateProfile_bounds_of_relative -/ theorem coordinateProfile_bounds_of_relative {D j : ℕ} (hj : j < D) {x : ℝ} (hx : |x/coordinateProfile D j-1| ≤ 1/20) : (19/20 : ℝ)*coordinateProfile D j ≤ x ∧ x ≤ (21/20 : ℝ)*coordinateProfile D j := by have hp := coordinateProfile_pos hj obtain ⟨hl, hu⟩ := abs_le.mp hx have hl' : (19/20 : ℝ) ≤ x/coordinateProfile D j := by linarith have hu' : x/coordinateProfile D j ≤ (21/20 : ℝ) := by linarith exact ⟨(le_div_iff₀ hp).mp hl', (div_le_iff₀ hp).mp hu'⟩ /- Original line 49714: Erdos416Proof.FordGeometry.coordinateProfile_bounds_outside_bad -/ theorem coordinateProfile_bounds_outside_bad {D A : ℕ} (hA : 1 ≤ A) {ξ : ℕ → ℝ} {x : Fin D → ℝ} (hx : x ∈ polytope D ξ) (hbad : x ∉ parameterConcentrationUnion D ξ A (1/20)) {idx : Fin D} (hi : idx ∈ concentrationIndices D A) : (19/20 : ℝ)*coordinateProfile D (idx.val+1) ≤ x idx ∧ x idx ≤ (21/20 : ℝ)*coordinateProfile D (idx.val+1) := by have hAi := (Finset.mem_filter.mp hi).2 have hir : idx.val+1 < D := by unfold concentrationDistance at hAi; omega have hrel : |x idx/coordinateProfile D (idx.val+1)-1| < 1/20 := by apply lt_of_not_ge intro h apply hbad exact ⟨hx, idx, hi, h⟩ exact coordinateProfile_bounds_of_relative hir hrel.le /-- The fixed tolerance supplies the precise gap constant used by the collision records, with room even under rho < 3/4. -/ /- Original line 49731: Erdos416Proof.FordGeometry.coordinateProfile_gap -/ theorem coordinateProfile_gap {D j : ℕ} {x y : ℝ} (hx : (19/20 : ℝ)*coordinateProfile D j ≤ x) (hy : y ≤ (21/20 : ℝ)*coordinateProfile D (j+1)) : (6/5 : ℝ)*y ≤ x := by have hstep := coordinateProfile_step D j have hcoeff : (6/5 : ℝ)*(21/20)*rho ≤ 19/20 := by linarith [rho_lt_three_quarters] calc _ ≤ (6/5 : ℝ)*((21/20)*coordinateProfile D (j+1)) := by linarith _ ≤ (6/5 : ℝ)*((21/20)*(rho*coordinateProfile D j)) := by nlinarith _ = ((6/5 : ℝ)*(21/20)*rho)*coordinateProfile D j := by ring _ ≤ (19/20 : ℝ)*coordinateProfile D j := mul_le_mul_of_nonneg_right hcoeff (coordinateProfile_nonneg D j) _ ≤ _ := hx /- Original line 49744: Erdos416Proof.FordGeometry.coordinateProfile_upper_four_fifths -/ theorem coordinateProfile_upper_four_fifths {D j : ℕ} (hD : 0 < D) (hj : 1 ≤ j) {x : ℝ} (hx : x ≤ (21/20 : ℝ)*coordinateProfile D j) : x ≤ 4/5 := by have hp := coordinateProfile_le_rho hD hj linarith [rho_lt_three_quarters] /- Original line 49749: Erdos416Proof.FordGeometry.logLog_gap_of_profile -/ theorem logLog_gap_of_profile {D j p q : ℕ} {T : ℝ} (hT : 0 < T) (hp : (19/20 : ℝ)*coordinateProfile D j ≤ logLog p/T) (hq : logLog q/T ≤ (21/20 : ℝ)*coordinateProfile D (j+1)) : (6/5 : ℝ)*logLog q ≤ logLog p := by have h := coordinateProfile_gap hp hq rw [← mul_div_assoc] at h exact (div_le_div_iff_of_pos_right hT).mp h /- Original line 49757: Erdos416Proof.FordGeometry.prime_cutoff_of_profile -/ theorem prime_cutoff_of_profile {D j p : ℕ} (hD : 0 < D) (hj : 1 ≤ j) {Y : ℝ} (hY : 1 < Y) (hT : 0 < logLog Y) (hp : 1 < p) (hprofile : logLog p/logLog Y ≤ (21/20 : ℝ)*coordinateProfile D j) : (p : ℝ) ≤ CollisionBox.cutoff Y (4/5) := by apply (CollisionMatching.le_cutoff_iff hY hT (by exact_mod_cast hp)).mpr exact coordinateProfile_upper_four_fifths hD hj hprofile /- Original line 49764: Erdos416Proof.FordGeometry.tuple_gaps_of_profile -/ theorem tuple_gaps_of_profile {D N : ℕ} {T : ℝ} (hT : 0 < T) (p : Fin (N+1) → ℕ) (hprofile : ∀ idx : Fin (N+1), 0 < idx.val → (19/20 : ℝ)*coordinateProfile D idx.val ≤ logLog (p idx)/T ∧ logLog (p idx)/T ≤ (21/20 : ℝ)*coordinateProfile D idx.val) : ∀ idx : Fin (N+1), 0 < idx.val → ∀ hi : idx.val+1 < N+1, (6/5 : ℝ)*logLog (p ⟨idx.val+1, hi⟩) ≤ logLog (p idx) := by intro idx hi hnext exact logLog_gap_of_profile hT (hprofile idx hi).1 (hprofile ⟨idx.val+1, hnext⟩ (by simp[Erdos416Proof.FordBadFacet.positiveLogLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_bottom, Erdos416Proof.FordBadFacet.reversedFacetLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_succ, Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.FordRestricted.suffixCutoff_log3, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint] )).2 /- Original line 49775: Erdos416Proof.FordGeometry.tuple_cutoffs_of_profile -/ theorem tuple_cutoffs_of_profile {D N : ℕ} (hD : 0 < D) {Y : ℝ} (hY : 1 < Y) (hT : 0 < logLog Y) (p : Fin (N+1) → ℕ) (hp : ∀ idx, 1 < p idx) (hprofile : ∀ idx : Fin (N+1), 0 < idx.val → logLog (p idx)/logLog Y ≤ (21/20 : ℝ)*coordinateProfile D idx.val) : ∀ idx : Fin (N+1), 0 < idx.val → (p idx : ℝ) ≤ CollisionBox.cutoff Y (4/5) := by intro idx hi exact prime_cutoff_of_profile hD hi hY hT (hp idx) (hprofile idx hi) /- Original line 49784: Erdos416Proof.FordGeometry.coordinateProfile_factorization -/ theorem coordinateProfile_factorization {D j : ℕ} (hj : j ≤ D) (T : ℝ) : T*coordinateProfile D j = (T*rho^D/(D : ℝ))* (((D-j : ℕ) : ℝ)/rho^(D-j)) := by by_cases hD : D = 0 · subst D have hj0 : j = 0 := by omega subst j simp [coordinateProfile] have hDr : (D : ℝ) ≠ 0 := by exact_mod_cast hD have hpow : rho^D = rho^j*rho^(D-j) := by rw [← pow_add, Nat.add_sub_of_le hj] rw [hpow] unfold coordinateProfile field_simp [rho_pos.ne', hDr] /- Original line 49798: Erdos416Proof.FordGeometry.core_profile_scale_upper -/ theorem core_profile_scale_upper (H : ℕ) : ∀ᶠ T : ℝ in atTop, T*rho^(coreDimension H T)/(coreDimension H T : ℝ) ≤ 1/(C*rho^(H+1)) := by filter_upwards [core_prefix_rate_lower H, (coreDimension_tendsto H).eventually (eventually_ge_atTop 1), eventually_gt_atTop (0 : ℝ)] with T hrate hD hT have hDp : 0 < (coreDimension H T : ℝ) := by exact_mod_cast (show 0 < coreDimension H T by omega) have hC : 0 < C*rho^(H+1) := mul_pos C_pos (pow_pos rho_pos _) have hr := (le_div_iff₀ (mul_pos hT (pow_pos rho_pos _))).mp hrate apply (div_le_div_iff₀ hDp hC).mpr nlinarith /- Original line 49809: Erdos416Proof.FordGeometry.terminalProfileBound -/ noncomputable def terminalProfileBound (H M : ℕ) : ℝ := (21/20 : ℝ)*(1/(C*rho^(H+1)))*(((M-H : ℕ) : ℝ)/rho^(M-H)) /- Original line 49812: Erdos416Proof.FordGeometry.terminalPrimeBound -/ noncomputable def terminalPrimeBound (H M : ℕ) : ℝ := Real.exp (Real.exp (terminalProfileBound H M)) /-- The terminal prime cutoff is fixed after the two dimension offsets are chosen and is uniform in the endpoint. -/ /- Original line 49817: Erdos416Proof.FordGeometry.terminal_prime_bound_eventually -/ theorem terminal_prime_bound_eventually (H M : ℕ) (hHM : H ≤ M) : ∀ᶠ T : ℝ in atTop, ∀ p : ℕ, 1 < p → logLog p/T ≤ (21/20 : ℝ)*coordinateProfile (coreDimension H T) (coreDimension M T) → (p : ℝ) ≤ terminalPrimeBound H M := by filter_upwards [core_profile_scale_upper H, coreDimension_add_tail H, coreDimension_add_tail M, eventually_gt_atTop (0 : ℝ)] with T hscale hDH hDM hT intro p hp hprofile have hLD : coreDimension M T ≤ coreDimension H T := by omega have hdiff : coreDimension H T-coreDimension M T = M-H := by omega have hfactor := coordinateProfile_factorization hLD T rw [hdiff] at hfactor have htail : T*coordinateProfile (coreDimension H T) (coreDimension M T) ≤ (1/(C*rho^(H+1)))*(((M-H : ℕ) : ℝ)/rho^(M-H)) := by rw [hfactor] exact mul_le_mul_of_nonneg_right hscale (div_nonneg (Nat.cast_nonneg _) (pow_nonneg rho_pos.le _)) have hLL : logLog p ≤ terminalProfileBound H M := by have hmul := (div_le_iff₀ hT).mp hprofile unfold terminalProfileBound nlinarith calc (p : ℝ) = Real.exp (Real.exp (logLog p)) := (CollisionMatching.exp_exp_logLog (by exact_mod_cast hp)).symm _ ≤ terminalPrimeBound H M := Real.exp_le_exp.mpr (Real.exp_le_exp.mpr hLL) end Erdos416Proof.FordGeometry end /- Consolidated component: ConcentrationMass.lean. -/ section open Filter Finset MeasureTheory open scoped Classical Topology BigOperators Pointwise namespace Erdos416Proof.FordReciprocal open FordGeometry FordAnalysis FordScale /-- Actual finite integer tuples whose expanded-polytope point violates one of the retained coordinate profiles. -/ /- Original line 49862: Erdos416Proof.FordReciprocal.coreConcentrationMass -/ noncomputable def coreConcentrationMass (H A : ℕ) (t : ℝ) : ℝ := tupleReciprocalMass (coreDimension H t) t (parameterConcentrationUnion (coreDimension H t) (expandedParameter (optimalDimension t)) A (1/20)) /- Original line 49867: Erdos416Proof.FordReciprocal.exists_core_concentration_mass_bound -/ theorem exists_core_concentration_mass_bound : ∃ B : ℝ, 0 < B ∧ ∀ᶠ H : ℕ in atTop, ∀ᶠ t : ℝ in atTop, ∀ A : ℕ, 32960 ≤ A → coreConcentrationMass H A t ≤ (B/(A : ℝ))*(t^(coreDimension H t)*modelVolume (coreDimension H t)) := by obtain ⟨C, hC, hmass⟩ := exists_tupleReciprocalMass_volume_bound let G : ℝ := (368640000*Real.exp 80)/(1/20 : ℝ)^4 refine ⟨C*G, by dsimp [Erdos416Proof.FordGeometry.modelVolume_one, Erdos416Proof.FordGeometry.modelVolume_zero, Erdos416Proof.FordGeometry.slackMap_apply, G]; positivity, ?_⟩ filter_upwards [expandedConcentrationUnion_volume_eventually (by norm_num : (0 : ℝ) < 1/20) (by norm_num : (1/20 : ℝ) ≤ 1)] with H hH filter_upwards [coreDimension_eventual_mesh H, coreDimension_add_tail H, eventually_gt_atTop (0 : ℝ)] with t hmesh hadd ht intro A hA have hA1 : 1 ≤ A := by omega have hAr : (32960 : ℝ) ≤ A := by exact_mod_cast hA have hmargin : (1648 : ℝ) ≤ (1/20)*(A : ℝ) := by linarith let D := coreDimension H t let E := parameterConcentrationUnion D (expandedParameter (optimalDimension t)) A (1/20) have hbox : E ⊆ Set.Icc (fun _ => 0) (fun _ => 1) := fun x hx => ⟨hx.1.1, hx.1.2.1⟩ have hratio : volume.real (E+errorCube D (1/t))/TStar D ≤ G/(A : ℝ) := by have h := hH D hmesh.1 A hA1 hmargin (1/t) (one_div_nonneg.mpr ht.le) hmesh.2 rw [hadd] at h dsimp only [E, D, G] convert h using 1 ring have hvol : volume.real (E+errorCube D (1/t)) ≤ (G/(A : ℝ))*modelVolume D := by rw [modelVolume_eq_TStar hmesh.1] exact (div_le_iff₀ (TStar_pos hmesh.1)).mp hratio calc _ ≤ C*t^D*volume.real (E+errorCube D (1/t)) := hmass D t E ht hbox _ ≤ C*t^D*((G/(A : ℝ))*modelVolume D) := mul_le_mul_of_nonneg_left hvol (mul_nonneg hC.le (pow_nonneg ht.le D)) _ = _ := by ring /-- The reciprocal exceptional mass is normalized against the actual totient count, with a constant independent of the two retained offsets. -/ /- Original line 49904: Erdos416Proof.FordReciprocal.exists_core_concentration_mass_V_bound -/ theorem exists_core_concentration_mass_V_bound : ∃ K : ℝ, 0 < K ∧ ∀ᶠ H : ℕ in atTop, ∀ᶠ x : ℝ in atTop, ∀ A : ℕ, 32960 ≤ A → (x/Real.log x)*coreConcentrationMass H A (logLog x) ≤ (K/(A : ℝ))*V x := by obtain ⟨B, hB, hmass⟩ := exists_core_concentration_mass_bound obtain ⟨K, hK, hcompare⟩ := exists_core_geometric_V_comparison refine ⟨22*B*K, by positivity, ?_⟩ have hLL : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [hmass, hcompare] with H hmass hcompare filter_upwards [hLL.eventually hmass, hcompare, hLL.eventually (coreDimension_eventual_mesh H), hLL.eventually ((coreDimension_tendsto H).eventually T_eventually_ge_TStar_div), hLL.eventually_gt_atTop 0, eventually_gt_atTop (1 : ℝ)] with x hxmass hxcompare hmesh hTstar hT hx intro A hA let D := coreDimension H (logLog x) change TStar D/22 ≤ T D at hTstar have hmodel : modelVolume D ≤ 22*T D := by rw [modelVolume_eq_TStar hmesh.1] linarith have hX : 0 ≤ x/Real.log x := (div_pos (by linarith) (Real.log_pos hx)).le have hBA : 0 ≤ B/(A : ℝ) := div_nonneg hB.le (Nat.cast_nonneg _) have hscale : (x/Real.log x)*((logLog x)^D*modelVolume D) ≤ 22*K*V x := by calc _ ≤ (x/Real.log x)*((logLog x)^D*(22*T D)) := mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_left hmodel (pow_nonneg hT.le D)) hX _ = 22*((x/Real.log x)*(logLog x)^D*T D) := by ring _ ≤ 22*(K*V x) := mul_le_mul_of_nonneg_left hxcompare (by norm_num) _ = _ := by ring calc _ ≤ (x/Real.log x)*((B/(A : ℝ))*((logLog x)^D*modelVolume D)) := mul_le_mul_of_nonneg_left (hxmass A hA) hX _ = (B/(A : ℝ))*((x/Real.log x)*((logLog x)^D*modelVolume D)) := by ring _ ≤ (B/(A : ℝ))*(22*K*V x) := mul_le_mul_of_nonneg_left hscale hBA _ = _ := by ring /- Original line 49940: Erdos416Proof.FordReciprocal.core_concentration_mass_small_in_V -/ theorem core_concentration_mass_small_in_V : ∀ᶠ H : ℕ in atTop, ∀ ε : ℝ, 0 < ε → ∃ A₀ : ℕ, 32960 ≤ A₀ ∧ ∀ A : ℕ, A₀ ≤ A → ∀ᶠ x : ℝ in atTop, (x/Real.log x)*coreConcentrationMass H A (logLog x) ≤ ε*V x := by obtain ⟨K, hK, hbound⟩ := exists_core_concentration_mass_V_bound filter_upwards [hbound] with H hH intro ε hε obtain ⟨A₀, hA₀⟩ := exists_nat_ge (max 32960 (K/ε)) have hA0num : 32960 ≤ A₀ := by exact_mod_cast (le_trans (le_max_left _ _) hA₀) refine ⟨A₀, hA0num, ?_⟩ intro A hA have hAbig : 32960 ≤ A := hA0num.trans hA have hAr : (A₀ : ℝ) ≤ A := by exact_mod_cast hA have hsmall : K/(A : ℝ) ≤ ε := by have hKε : K/ε ≤ (A : ℝ) := ((le_max_right _ _).trans hA₀).trans hAr have hAp : 0 < (A : ℝ) := by exact_mod_cast (show 0 < A by omega) apply (div_le_iff₀ hAp).mpr have hmul := (div_le_iff₀ hε).mp hKε nlinarith filter_upwards [hH] with x hx exact (hx A hAbig).trans (mul_le_mul_of_nonneg_right hsmall (V_nonneg x)) end Erdos416Proof.FordReciprocal end /- Consolidated component: GoodTupleProfiles.lean. -/ section open Filter Finset open scoped Classical Topology BigOperators namespace Erdos416Proof.FordReciprocal open FordGeometry FordAnalysis FordScale /-- A retained positive coordinate automatically removes padding by one and removes the max(0,loglog p) truncation in the tuple mesh. -/ /- Original line 49982: Erdos416Proof.FordReciprocal.good_tuple_entry_profile -/ theorem good_tuple_entry_profile {D A : ℕ} (hA : 1 ≤ A) {t : ℝ} (ht : 0 < t) {ξ : ℕ → ℝ} {q : Fin D → ℕ} (hq : ∀ idx, (q idx).Prime ∨ q idx = 1) (hpoint : tuplePoint t q ∈ polytope D ξ) (hbad : tuplePoint t q ∉ parameterConcentrationUnion D ξ A (1/20)) {idx : Fin D} (hi : idx ∈ concentrationIndices D A) : (q idx).Prime ∧ 0 < logLog (q idx) ∧ (19/20 : ℝ)*coordinateProfile D (idx.val+1) ≤ logLog (q idx)/t ∧ logLog (q idx)/t ≤ (21/20 : ℝ)*coordinateProfile D (idx.val+1) := by have hb := coordinateProfile_bounds_outside_bad hA hpoint hbad hi have hAi := (Finset.mem_filter.mp hi).2 have hir : idx.val+1 < D := by unfold concentrationDistance at hAi; omega have hcoord : 0 < tuplePoint t q idx := (mul_pos (by norm_num : (0 : ℝ) < 19/20) (coordinateProfile_pos hir)).trans_le hb.1 have hm := mul_pos hcoord ht simp only [tuplePoint, div_mul_cancel₀ _ ht.ne'] at hm have hlog : 0 < logLog (q idx) := (lt_max_iff.mp hm).resolve_left (lt_irrefl 0) have hp : (q idx).Prime := by rcases hq idx with hp | hp · exact hp · simp [Erdos416Proof.FordBadFacet.positiveLogLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_bottom, Erdos416Proof.FordBadFacet.reversedFacetLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_succ, Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.FordRestricted.suffixCutoff_log3, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, hp, logLog] at hlog refine ⟨hp, hlog, ?_⟩ simpa only [tuplePoint, max_eq_right hlog.le] using hb /- Original line 50005: Erdos416Proof.FordReciprocal.good_tuple_adjacent_gap -/ theorem good_tuple_adjacent_gap {D A : ℕ} (hA : 1 ≤ A) {t : ℝ} (ht : 0 < t) {ξ : ℕ → ℝ} {q : Fin D → ℕ} (hq : ∀ idx, (q idx).Prime ∨ q idx = 1) (hpoint : tuplePoint t q ∈ polytope D ξ) (hbad : tuplePoint t q ∉ parameterConcentrationUnion D ξ A (1/20)) (idx : Fin D) (hi : idx ∈ concentrationIndices D A) (hj : idx.val+1 < D) (hnext : (⟨idx.val+1, hj⟩ : Fin D) ∈ concentrationIndices D A) : (6/5 : ℝ)*logLog (q ⟨idx.val+1, hj⟩) ≤ logLog (q idx) := by have hp := good_tuple_entry_profile hA ht hq hpoint hbad hi have hq' := good_tuple_entry_profile hA ht hq hpoint hbad hnext exact logLog_gap_of_profile ht hp.2.2.1 hq'.2.2.2 /- Original line 50016: Erdos416Proof.FordReciprocal.good_tuple_prime_cutoff -/ theorem good_tuple_prime_cutoff {D A : ℕ} (hA : 1 ≤ A) {Y : ℝ} (hY : 1 < Y) (hT : 0 < logLog Y) {ξ : ℕ → ℝ} {q : Fin D → ℕ} (hq : ∀ idx, (q idx).Prime ∨ q idx = 1) (hpoint : tuplePoint (logLog Y) q ∈ polytope D ξ) (hbad : tuplePoint (logLog Y) q ∉ parameterConcentrationUnion D ξ A (1/20)) {idx : Fin D} (hi : idx ∈ concentrationIndices D A) : (q idx : ℝ) ≤ CollisionBox.cutoff Y (4/5) := by have hp := good_tuple_entry_profile hA hT hq hpoint hbad hi exact prime_cutoff_of_profile (by have := idx.isLt; omega) (by omega) hY hT hp.1.one_lt hp.2.2.2 /-- Consecutive retained entries are distinct, including the extra prime immediately below the final core. Thus multiplicities cannot cross this later boundary once concentration has been imposed. -/ /- Original line 50029: Erdos416Proof.FordReciprocal.good_tuple_adjacent_strict -/ theorem good_tuple_adjacent_strict {D A : ℕ} (hA : 1 ≤ A) {t : ℝ} (ht : 0 < t) {ξ : ℕ → ℝ} {q : Fin D → ℕ} (hq : ∀ idx, (q idx).Prime ∨ q idx = 1) (hpoint : tuplePoint t q ∈ polytope D ξ) (hbad : tuplePoint t q ∉ parameterConcentrationUnion D ξ A (1/20)) (idx : Fin D) (hi : idx ∈ concentrationIndices D A) (hj : idx.val+1 < D) (hnext : (⟨idx.val+1, hj⟩ : Fin D) ∈ concentrationIndices D A) : q ⟨idx.val+1, hj⟩ < q idx := by have hp := good_tuple_entry_profile hA ht hq hpoint hbad hi have hq' := good_tuple_entry_profile hA ht hq hpoint hbad hnext have hgap := good_tuple_adjacent_gap hA ht hq hpoint hbad idx hi hj hnext by_contra hn have hle : (q idx : ℝ) ≤ q ⟨idx.val+1, hj⟩ := by exact_mod_cast (Nat.le_of_not_gt hn) have hl := logLog_mono (by exact_mod_cast hp.1.one_lt) hle nlinarith [hq'.2.1] /- Original line 50044: Erdos416Proof.FordReciprocal.retained_index_mem_concentration -/ theorem retained_index_mem_concentration {D K H M : ℕ} (hshift : D+H = K+M) (hHM : H+2 ≤ M) (idx : Fin D) (hi : idx.val+1 ≤ K+1) : idx ∈ concentrationIndices D (M-H-1) := by apply Finset.mem_filter.mpr refine ⟨Finset.mem_univ _, ?_⟩ unfold concentrationDistance omega /- Original line 50052: Erdos416Proof.FordReciprocal.retained_profile_dimensions_eventually -/ theorem retained_profile_dimensions_eventually (H M : ℕ) (hHM : H+2 ≤ M) : ∀ᶠ t : ℝ in atTop, 1 ≤ coreDimension M t ∧ coreDimension M t+1 < coreDimension H t ∧ ∀ idx : Fin (coreDimension H t), idx.val+1 ≤ coreDimension M t+1 → idx ∈ concentrationIndices (coreDimension H t) (M-H-1) := by filter_upwards [coreDimension_add_tail H, coreDimension_add_tail M, (coreDimension_tendsto M).eventually (eventually_ge_atTop 1)] with t hH hM hK refine ⟨hK, by omega, ?_⟩ intro idx hi exact retained_index_mem_concentration (by omega) hHM idx hi /-- Actual prime-tuple profile conclusions hold through retained length plus one, while the terminal prime at the retained length has a fixed bound. -/ /- Original line 50065: Erdos416Proof.FordReciprocal.good_tuple_terminal_bound_eventually -/ theorem good_tuple_terminal_bound_eventually (H M : ℕ) (hHM : H+2 ≤ M) : ∀ᶠ t : ℝ in atTop, ∀ (q : Fin (coreDimension H t) → ℕ), (∀ idx, (q idx).Prime ∨ q idx = 1) → tuplePoint t q ∈ polytope (coreDimension H t) (expandedParameter (optimalDimension t)) → tuplePoint t q ∉ parameterConcentrationUnion (coreDimension H t) (expandedParameter (optimalDimension t)) (M-H-1) (1/20) → ∀ idx : Fin (coreDimension H t), idx.val+1 = coreDimension M t → (q idx : ℝ) ≤ terminalPrimeBound H M := by filter_upwards [terminal_prime_bound_eventually H M (by omega), retained_profile_dimensions_eventually H M hHM, eventually_gt_atTop (0 : ℝ)] with t hterminal hdimensions ht intro q hq hpoint hbad idx hi have hA : 1 ≤ M-H-1 := by omega have hindex := hdimensions.2.2 idx (by omega) have hp := good_tuple_entry_profile hA ht hq hpoint hbad hindex apply hterminal (q idx) hp.1.one_lt simpa only [hi] using hp.2.2.2 end Erdos416Proof.FordReciprocal end /- Consolidated component: LowerPrimeProfile.lean. -/ section open Filter Finset open scoped Classical Topology BigOperators namespace Erdos416Proof.FordGeometry open FordAnalysis FordScale FordReciprocal /- Original line 50101: Erdos416Proof.FordGeometry.core_profile_scale_lower -/ theorem core_profile_scale_lower (H : ℕ) : ∀ᶠ T : ℝ in atTop, 1/(4*rho^H) ≤ T*rho^(coreDimension H T)/(coreDimension H T : ℝ) := by filter_upwards [coreDimension_add_tail H, (coreDimension_tendsto H).eventually (eventually_ge_atTop 1), eventually_ge_atTop (Real.exp 1)] with T hadd hD hT have hTp : 0 < T := (Real.exp_pos 1).trans_le hT have hDp : 0 < (coreDimension H T : ℝ) := by exact_mod_cast (show 0 < coreDimension H T by omega) have hfour : 0 < 4*rho^H := mul_pos (by norm_num) (pow_pos rho_pos _) have hr := (div_le_iff₀ (mul_pos hTp (pow_pos rho_pos _))).mp (core_prefix_rate_bound H hT hadd) apply (div_le_div_iff₀ hfour hDp).mpr nlinarith /-- A lower profile bound uniform through the extra coordinate below the retained core. Its right-hand side tends to infinity with the gap. -/ /- Original line 50117: Erdos416Proof.FordGeometry.retained_profile_lower_eventually -/ theorem retained_profile_lower_eventually (H M : ℕ) (hHM : H+2 ≤ M) : ∀ᶠ T : ℝ in atTop, ∀ j : ℕ, j ≤ coreDimension M T+1 → (1/(4*rho^H))*((M-H-1 : ℕ) : ℝ) ≤ T*coordinateProfile (coreDimension H T) j := by filter_upwards [core_profile_scale_lower H, coreDimension_add_tail H, coreDimension_add_tail M] with T hscale hH hM intro j hj have hjD : j ≤ coreDimension H T := by omega have hr : M-H-1 ≤ coreDimension H T-j := by omega have hrr : ((M-H-1 : ℕ) : ℝ) ≤ ((coreDimension H T-j : ℕ) : ℝ) := by exact_mod_cast hr have hquot : ((coreDimension H T-j : ℕ) : ℝ) ≤ ((coreDimension H T-j : ℕ) : ℝ)/rho^(coreDimension H T-j) := by apply (le_div_iff₀ (pow_pos rho_pos _)).mpr exact mul_le_of_le_one_right (Nat.cast_nonneg _) (pow_le_one₀ rho_pos.le rho_lt_one.le) rw [coordinateProfile_factorization hjD T] calc _ ≤ (1/(4*rho^H))* (((coreDimension H T-j : ℕ) : ℝ)/rho^(coreDimension H T-j)) := mul_le_mul_of_nonneg_left (hrr.trans hquot) (one_div_nonneg.mpr (mul_nonneg (by norm_num) (pow_nonneg rho_pos.le _))) _ ≤ _ := mul_le_mul_of_nonneg_right hscale (div_nonneg (Nat.cast_nonneg _) (pow_nonneg rho_pos.le _)) /-- After fixing the outer offset, the retained offset can force every profile-controlled prime through the extra coordinate above any fixed bound. -/ /- Original line 50142: Erdos416Proof.FordGeometry.retained_prime_lower_bound_eventually -/ theorem retained_prime_lower_bound_eventually (H : ℕ) (P₀ : ℝ) : ∀ᶠ M : ℕ in atTop, H+2 ≤ M ∧ ∀ᶠ T : ℝ in atTop, ∀ p j : ℕ, 1 < p → j ≤ coreDimension M T+1 → (19/20 : ℝ)*coordinateProfile (coreDimension H T) j ≤ logLog p/T → P₀ < (p : ℝ) := by let c : ℝ := (19/20)*(1/(4*rho^H)) have hc : 0 < c := mul_pos (by norm_num) (one_div_pos.mpr (mul_pos (by norm_num) (pow_pos rho_pos _))) obtain ⟨N, hN⟩ := exists_nat_gt (logLog (max 2 P₀)/c+(H : ℝ)+1) filter_upwards [eventually_ge_atTop (max (H+2) N)] with M hM have hHM : H+2 ≤ M := (le_max_left _ _).trans hM have hNM : N ≤ M := (le_max_right _ _).trans hM have hMr : (N : ℝ) ≤ M := by exact_mod_cast hNM have hcast : ((M-H-1 : ℕ) : ℝ) = (M : ℝ)-(H : ℝ)-1 := by rw [Nat.cast_sub (by omega), Nat.cast_sub (by omega), Nat.cast_one] have hlarge : logLog (max 2 P₀) < c*((M-H-1 : ℕ) : ℝ) := by rw [mul_comm c] apply (div_lt_iff₀ hc).mp rw [hcast] linarith refine ⟨hHM, ?_⟩ filter_upwards [retained_profile_lower_eventually H M hHM, eventually_gt_atTop (0 : ℝ)] with T hprofile hT intro p j hp hj hlower have hmul := (le_div_iff₀ hT).mp hlower have hprof := hprofile j hj have hlog : logLog (max 2 P₀) < logLog p := by dsimp [Erdos416Proof.FordBadFacet.positiveLogLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_bottom, Erdos416Proof.FordBadFacet.reversedFacetLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_succ, Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.FordRestricted.suffixCutoff_log3, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, c] at hlarge nlinarith by_contra hn have hle : (p : ℝ) ≤ max 2 P₀ := (le_of_not_gt hn).trans (le_max_right _ _) exact (not_lt_of_ge (logLog_mono (by exact_mod_cast hp) hle)) hlog /- Original line 50175: Erdos416Proof.FordGeometry.good_tuple_fixed_lower_bound_eventually -/ theorem good_tuple_fixed_lower_bound_eventually (H : ℕ) (P₀ : ℝ) : ∀ᶠ M : ℕ in atTop, H+2 ≤ M ∧ ∀ᶠ t : ℝ in atTop, ∀ (q : Fin (coreDimension H t) → ℕ), (∀ idx, (q idx).Prime ∨ q idx = 1) → tuplePoint t q ∈ polytope (coreDimension H t) (expandedParameter (optimalDimension t)) → tuplePoint t q ∉ parameterConcentrationUnion (coreDimension H t) (expandedParameter (optimalDimension t)) (M-H-1) (1/20) → ∀ idx : Fin (coreDimension H t), idx.val+1 ≤ coreDimension M t+1 → P₀ < (q idx : ℝ) := by filter_upwards [retained_prime_lower_bound_eventually H P₀] with M hM refine ⟨hM.1, ?_⟩ filter_upwards [hM.2, retained_profile_dimensions_eventually H M hM.1, eventually_gt_atTop (0 : ℝ)] with t hlower hdimensions ht intro q hq hpoint hbad idx hi have hp := good_tuple_entry_profile (by omega : 1 ≤ M-H-1) ht hq hpoint hbad (hdimensions.2.2 idx hi) exact hlower (q idx) (idx.val+1) hp.1.one_lt hi hp.2.2.1 end Erdos416Proof.FordGeometry namespace Erdos416Proof.FordReciprocal /-- The concentration error is arbitrarily small when the final retained offset is chosen after the fixed expansion offset. -/ /- Original line 50199: Erdos416Proof.FordReciprocal.core_concentration_mass_small_retained_gap -/ theorem core_concentration_mass_small_retained_gap : ∀ᶠ H : ℕ in atTop, ∀ ε : ℝ, 0 < ε → ∀ᶠ M : ℕ in atTop, ∀ᶠ x : ℝ in atTop, (x/Real.log x)*coreConcentrationMass H (M-H-1) (logLog x) ≤ ε*V x := by filter_upwards [core_concentration_mass_small_in_V] with H hH intro ε hε obtain ⟨A₀, _, hA₀⟩ := hH ε hε filter_upwards [eventually_ge_atTop (H+A₀+1)] with M hM exact hA₀ (M-H-1) (by omega) end Erdos416Proof.FordReciprocal end /- Consolidated component: OrdinaryProfiles.lean. -/ section open Filter Finset open scoped Classical Topology BigOperators namespace Erdos416Proof.FordBadFacet open FordGeometry FordAnalysis FordScale FordReciprocal /- Original line 50227: Erdos416Proof.FordBadFacet.ordinaryLowerPoint -/ noncomputable abbrev ordinaryLowerPoint (D : ℕ) (T : ℝ) (N : ℕ) : Fin D → ℝ := fun idx => ordinaryPrimeCoordinate T N (idx.val+1) /- Original line 50230: Erdos416Proof.FordBadFacet.ordinaryLowerPoint_eq_tuplePoint -/ theorem ordinaryLowerPoint_eq_tuplePoint (D N : ℕ) (T : ℝ) : ordinaryLowerPoint D T N = tuplePoint T (fun idx : Fin D => ordinaryPrimeAt N (idx.val+1)) := rfl /- Original line 50233: Erdos416Proof.FordBadFacet.ordinaryLowerTuple_prime_or_one -/ theorem ordinaryLowerTuple_prime_or_one (D N : ℕ) : ∀ idx : Fin D, (ordinaryPrimeAt N (idx.val+1)).Prime ∨ ordinaryPrimeAt N (idx.val+1) = 1 := by intro idx rcases ordinaryPrimeAt_spec N (idx.val+1) with he | ⟨hp,_⟩ · exact Or.inr he · exact Or.inl hp /-- Profiles now refer to the actual prime factors of the preimage, with ordinary mathematical indices beginning at one below its largest prime. -/ /- Original line 50242: Erdos416Proof.FordBadFacet.ordinary_profile_entry -/ theorem ordinary_profile_entry {D A N : ℕ} (hA : 1 ≤ A) {T : ℝ} (hT : 0 < T) {ξ : ℕ → ℝ} (hpoint : ordinaryLowerPoint D T N ∈ polytope D ξ) (hbad : ordinaryLowerPoint D T N ∉ parameterConcentrationUnion D ξ A (1/20)) {j : ℕ} (hj : 1 ≤ j) (hjA : j ≤ D-A) : (ordinaryPrimeAt N j).Prime ∧ ordinaryPrimeAt N j ∣ N ∧ 0 < logLog (ordinaryPrimeAt N j) ∧ (19/20 : ℝ)*coordinateProfile D j ≤ logLog (ordinaryPrimeAt N j)/T ∧ logLog (ordinaryPrimeAt N j)/T ≤ (21/20 : ℝ)*coordinateProfile D j := by let idx : Fin D := ⟨j-1, by omega⟩ have hij : idx.val+1 = j := by dsimp [Erdos416Proof.FordBadFacet.positiveLogLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_bottom, Erdos416Proof.FordBadFacet.reversedFacetLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_succ, Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.FordRestricted.suffixCutoff_log3, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, idx]; omega have hi : idx ∈ concentrationIndices D A := by apply Finset.mem_filter.mpr refine ⟨Finset.mem_univ _, ?_⟩ unfold concentrationDistance dsimp [Erdos416Proof.FordBadFacet.positiveLogLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_bottom, Erdos416Proof.FordBadFacet.reversedFacetLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_succ, Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.FordRestricted.suffixCutoff_log3, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint, idx] omega rw [ordinaryLowerPoint_eq_tuplePoint] at hpoint hbad have hp := good_tuple_entry_profile hA hT (ordinaryLowerTuple_prime_or_one D N) hpoint hbad hi simp only [hij] at hp have hd : ordinaryPrimeAt N j ∣ N := by rcases ordinaryPrimeAt_spec N j with he | ⟨_,hd⟩ · exact False.elim (hp.1.ne_one he) · exact hd exact ⟨hp.1, hd, hp.2⟩ /- Original line 50267: Erdos416Proof.FordBadFacet.ordinary_profile_adjacent_gap -/ theorem ordinary_profile_adjacent_gap {D A N : ℕ} (hA : 1 ≤ A) {T : ℝ} (hT : 0 < T) {ξ : ℕ → ℝ} (hpoint : ordinaryLowerPoint D T N ∈ polytope D ξ) (hbad : ordinaryLowerPoint D T N ∉ parameterConcentrationUnion D ξ A (1/20)) {j : ℕ} (hj : 1 ≤ j) (hjA : j+1 ≤ D-A) : (6/5 : ℝ)*logLog (ordinaryPrimeAt N (j+1)) ≤ logLog (ordinaryPrimeAt N j) ∧ ordinaryPrimeAt N (j+1) < ordinaryPrimeAt N j := by obtain ⟨hp, _, _, hlo, _⟩ := ordinary_profile_entry hA hT hpoint hbad hj (by omega) obtain ⟨_, _, hqlog, _, hhi⟩ := ordinary_profile_entry hA hT hpoint hbad (by omega) hjA have hgap := logLog_gap_of_profile hT hlo hhi refine ⟨hgap, ?_⟩ by_contra hn have hle : (ordinaryPrimeAt N j : ℝ) ≤ ordinaryPrimeAt N (j+1) := by exact_mod_cast (Nat.le_of_not_gt hn) have hlog := logLog_mono (by exact_mod_cast hp.one_lt) hle nlinarith /- Original line 50283: Erdos416Proof.FordBadFacet.ordinary_profile_cutoff -/ theorem ordinary_profile_cutoff {D A N : ℕ} (hA : 1 ≤ A) {Y : ℝ} (hY : 1 < Y) (hT : 0 < logLog Y) {ξ : ℕ → ℝ} (hpoint : ordinaryLowerPoint D (logLog Y) N ∈ polytope D ξ) (hbad : ordinaryLowerPoint D (logLog Y) N ∉ parameterConcentrationUnion D ξ A (1/20)) {j : ℕ} (hj : 1 ≤ j) (hjA : j ≤ D-A) : (ordinaryPrimeAt N j : ℝ) ≤ CollisionBox.cutoff Y (4/5) := by obtain ⟨hp, _, _, _, hhi⟩ := ordinary_profile_entry hA hT hpoint hbad hj hjA exact prime_cutoff_of_profile (by omega) hj hY hT hp.one_lt hhi /- Original line 50292: Erdos416Proof.FordBadFacet.ordinary_retained_profiles_eventually -/ theorem ordinary_retained_profiles_eventually (H M : ℕ) (hHM : H+2 ≤ M) : ∀ᶠ T : ℝ in atTop, ∀ N : ℕ, ordinaryLowerPoint (coreDimension H T) T N ∈ polytope (coreDimension H T) (expandedParameter (optimalDimension T)) → ordinaryLowerPoint (coreDimension H T) T N ∉ parameterConcentrationUnion (coreDimension H T) (expandedParameter (optimalDimension T)) (M-H-1) (1/20) → (∀ j : ℕ, 1 ≤ j → j ≤ coreDimension M T+1 → (ordinaryPrimeAt N j).Prime ∧ ordinaryPrimeAt N j ∣ N ∧ 0 < logLog (ordinaryPrimeAt N j) ∧ (19/20 : ℝ)*coordinateProfile (coreDimension H T) j ≤ logLog (ordinaryPrimeAt N j)/T ∧ logLog (ordinaryPrimeAt N j)/T ≤ (21/20 : ℝ)*coordinateProfile (coreDimension H T) j) ∧ (∀ j : ℕ, 1 ≤ j → j ≤ coreDimension M T → (6/5 : ℝ)*logLog (ordinaryPrimeAt N (j+1)) ≤ logLog (ordinaryPrimeAt N j) ∧ ordinaryPrimeAt N (j+1) < ordinaryPrimeAt N j) ∧ (ordinaryPrimeAt N (coreDimension M T) : ℝ) ≤ terminalPrimeBound H M := by filter_upwards [coreDimension_add_tail H, coreDimension_add_tail M, (coreDimension_tendsto M).eventually (eventually_ge_atTop 1), terminal_prime_bound_eventually H M (by omega), eventually_gt_atTop (0 : ℝ)] with T hDH hDM hL hterminal hT intro N hpoint hbad have hA : 1 ≤ M-H-1 := by omega have hdim : coreDimension H T-(M-H-1) = coreDimension M T+1 := by omega have hentry (j : ℕ) (hj : 1 ≤ j) (hjL : j ≤ coreDimension M T+1) := ordinary_profile_entry hA hT hpoint hbad (j := j) hj (by omega : j ≤ coreDimension H T-(M-H-1)) refine ⟨?_, ?_, ?_⟩ · intro j hj hjL exact hentry j hj hjL · intro j hj hjL exact ordinary_profile_adjacent_gap hA hT hpoint hbad hj (by omega) · obtain ⟨hp, _, _, _, hhi⟩ := hentry (coreDimension M T) hL (by omega) exact hterminal _ hp.one_lt hhi /-- The checked ordinary profile yields strict order of the whole selected prefix once the separately established gap at the largest prime is supplied. -/ /- Original line 50327: Erdos416Proof.FordBadFacet.ordinary_retained_strictAnti -/ theorem ordinary_retained_strictAnti {N L : ℕ} (htop : ordinaryPrimeAt N 1 < ordinaryPrimeAt N 0) (hgap : ∀ j : ℕ, 1 ≤ j → j ≤ L → ordinaryPrimeAt N (j+1) < ordinaryPrimeAt N j) : StrictAnti (fun idx : Fin (L+2) => ordinaryPrimeAt N idx.val) := by intro idx j hij have hstep : ordinaryPrimeAt N (idx.val+1) < ordinaryPrimeAt N idx.val := by by_cases hi : idx.val = 0 · simpa only [hi, zero_add] using htop · exact hgap idx.val (by omega) (by have := j.isLt; omega) exact (ordinaryPrimeAt_antitone N (by exact Nat.succ_le_of_lt hij)).trans_lt hstep /- Original line 50338: Erdos416Proof.FordBadFacet.ordinary_retained_fixed_lower_eventually -/ theorem ordinary_retained_fixed_lower_eventually (H : ℕ) (P₀ : ℝ) : ∀ᶠ M : ℕ in atTop, H+2 ≤ M ∧ ∀ᶠ T : ℝ in atTop, ∀ N : ℕ, ordinaryLowerPoint (coreDimension H T) T N ∈ polytope (coreDimension H T) (expandedParameter (optimalDimension T)) → ordinaryLowerPoint (coreDimension H T) T N ∉ parameterConcentrationUnion (coreDimension H T) (expandedParameter (optimalDimension T)) (M-H-1) (1/20) → ∀ j : ℕ, j ≤ coreDimension M T+1 → P₀ < (ordinaryPrimeAt N j : ℝ) := by filter_upwards [retained_prime_lower_bound_eventually H P₀] with M hM refine ⟨hM.1, ?_⟩ filter_upwards [hM.2, ordinary_retained_profiles_eventually H M hM.1, (coreDimension_tendsto M).eventually (eventually_ge_atTop 1)] with T hlower hprofiles hL intro N hpoint hbad j hj have hdata := (hprofiles N hpoint hbad).1 have hq (k : ℕ) (hk : 1 ≤ k) (hkL : k ≤ coreDimension M T+1) : P₀ < (ordinaryPrimeAt N k : ℝ) := by obtain ⟨hp, _, _, hlo, _⟩ := hdata k hk hkL exact hlower _ k hp.one_lt hkL hlo by_cases hj0 : j = 0 · subst j exact (hq 1 (by omega) (by omega)).trans_le (Nat.cast_le.mpr (ordinaryPrimeAt_antitone N (by omega : 0 ≤ 1))) · exact hq j (by omega) hj end Erdos416Proof.FordBadFacet end /- Consolidated component: SmoothGeometricValues.lean. -/ section open Filter Finset Asymptotics open scoped Classical Topology BigOperators namespace Erdos416Proof.FordBadFacet open FordReciprocal FordGeometry FordScale /- Original line 50379: Erdos416Proof.FordBadFacet.smoothResidualProperty -/ def smoothResidualProperty (z : ℝ) (n : ℕ) : Prop := n ∈ Nat.factoredNumbers (Nat.primesLE ⌊z⌋₊) /- Original line 50382: Erdos416Proof.FordBadFacet.exists_smooth_property_reciprocal_bound -/ theorem exists_smooth_property_reciprocal_bound : ∃ C : ℝ, 0 < C ∧ ∀ z : ℝ, Real.exp 20 ≤ z → ∀ x : ℝ, (∑ m ∈ preimagePropertyValues x (smoothResidualProperty z), (1 : ℝ)/m) ≤ C*Real.log z := by obtain ⟨C,hC,hbound⟩ := exists_large_smooth_preimage_reciprocal_bound refine ⟨C,hC,?_⟩ intro z hz x have h := hbound z 1 hz (by norm_num) (preimagePropertyValues x (smoothResidualProperty z)) (by intro m hm obtain ⟨N,hN,hNm,hQ⟩ := (Finset.mem_filter.mp hm).2 exact ⟨N,hN,hNm,by exact_mod_cast (Nat.succ_le_iff.mpr hN),hQ⟩) simpa only [Real.one_rpow,one_mul] using h /- Original line 50394: Erdos416Proof.FordBadFacet.exists_smooth_geometric_value_count -/ theorem exists_smooth_geometric_value_count : ∃ C : ℝ, 0 < C ∧ ∀ᶠ x : ℝ in atTop, ∀ (D : ℕ) (E : Set (Fin D → ℝ)) (z : ℝ), Real.exp 20 ≤ z → E ⊆ Set.Icc (fun _ => 0) (fun _ => 1) → ((retainedGeometricValues x D E (smoothResidualProperty z)).card : ℝ) ≤ C*Real.log z*(x/Real.log x)*tupleReciprocalMass D (logLog x) E := by obtain ⟨C,hC,hcount⟩ := exists_retained_geometric_value_count obtain ⟨K,hK,hrecip⟩ := exists_smooth_property_reciprocal_bound refine ⟨C*K,by positivity,?_⟩ filter_upwards [hcount,eventually_gt_atTop (1 : ℝ)] with x hx hx1 intro D E z hz hE have hmass : 0 ≤ tupleReciprocalMass D (logLog x) E := Finset.sum_nonneg (fun _ _ => invTotient_nonneg _) have hnonneg : 0 ≤ C*x/Real.log x*tupleReciprocalMass D (logLog x) E := mul_nonneg (div_nonneg (mul_nonneg hC.le (by linarith)) (Real.log_pos hx1).le) hmass calc _ ≤ _ := hx D E (smoothResidualProperty z) hE _ ≤ C*x/Real.log x*tupleReciprocalMass D (logLog x) E*(K*Real.log z) := mul_le_mul_of_nonneg_left (hrecip z hz x) hnonneg _ = _ := by ring /- Original line 50415: Erdos416Proof.FordBadFacet.smoothConcentrationValues -/ noncomputable def smoothConcentrationValues (x : ℝ) (H A : ℕ) (z : ℝ) : Finset ℕ := retainedGeometricValues x (coreDimension H (logLog x)) (parameterConcentrationUnion (coreDimension H (logLog x)) (expandedParameter (optimalDimension (logLog x))) A (1/20)) (smoothResidualProperty z) /-- Actual exceptional totient values, rather than geometric mass alone, have a uniform 1/A concentration saving after a fixed residual prime bound. -/ /- Original line 50422: Erdos416Proof.FordBadFacet.exists_smooth_concentration_value_bound -/ theorem exists_smooth_concentration_value_bound : ∃ C : ℝ, 0 < C ∧ ∀ᶠ H : ℕ in atTop, ∀ᶠ x : ℝ in atTop, ∀ (z : ℝ) (A : ℕ), Real.exp 20 ≤ z → 32960 ≤ A → ((smoothConcentrationValues x H A z).card : ℝ) ≤ (C*Real.log z/(A : ℝ))*V x := by obtain ⟨C,hC,hcount⟩ := exists_smooth_geometric_value_count obtain ⟨K,hK,hmass⟩ := exists_core_concentration_mass_V_bound refine ⟨C*K,by positivity,?_⟩ filter_upwards [hmass] with H hH filter_upwards [hH,hcount] with x hxmass hxcount intro z A hz hA have hlogz : 0 ≤ Real.log z := by have h := Real.log_le_log (Real.exp_pos 20) hz rw [Real.log_exp] at h linarith have hc := hxcount (coreDimension H (logLog x)) (parameterConcentrationUnion (coreDimension H (logLog x)) (expandedParameter (optimalDimension (logLog x))) A (1/20)) z hz (fun u hu => ⟨hu.1.1,hu.1.2.1⟩) have hm := mul_le_mul_of_nonneg_left (hxmass A hA) (mul_nonneg hC.le hlogz) have hid : C*Real.log z*(x/Real.log x)*coreConcentrationMass H A (logLog x) = C*Real.log z*((x/Real.log x)*coreConcentrationMass H A (logLog x)) := by ring change ((smoothConcentrationValues x H A z).card : ℝ) ≤ C*Real.log z*(x/Real.log x)*coreConcentrationMass H A (logLog x) at hc rw [hid] at hc exact (hc.trans hm).trans_eq (by ring) /- Original line 50448: Erdos416Proof.FordBadFacet.smoothOuterShellValues -/ noncomputable def smoothOuterShellValues (x : ℝ) (H : ℕ) (z : ℝ) : Finset ℕ := retainedGeometricValues x (coreDimension H (logLog x)) (coreOuterShell H (logLog x)) (smoothResidualProperty z) /- Original line 50452: Erdos416Proof.FordBadFacet.smooth_outer_shell_values_negligible -/ theorem smooth_outer_shell_values_negligible : ∀ᶠ H : ℕ in atTop, ∀ z : ℝ, Real.exp 20 ≤ z → (fun x : ℝ => ((smoothOuterShellValues x H z).card : ℝ)) =o[atTop] V := by obtain ⟨C,hC,hcount⟩ := exists_smooth_geometric_value_count filter_upwards [core_outer_shell_mass_negligible_in_V] with H hH intro z hz have hlogz : 0 ≤ Real.log z := by have h := Real.log_le_log (Real.exp_pos 20) hz rw [Real.log_exp] at h linarith have hdom : (fun x : ℝ => ((smoothOuterShellValues x H z).card : ℝ)) =O[atTop] (fun x : ℝ => (C*Real.log z)*((x/Real.log x)*coreOuterShellMass H (logLog x))) := by apply IsBigO.of_norm_eventuallyLE filter_upwards [hcount,eventually_gt_atTop (1 : ℝ)] with x hx hx1 have hc := hx (coreDimension H (logLog x)) (coreOuterShell H (logLog x)) z hz (fun u hu => ⟨hu.1.1,hu.1.2.1⟩) have hmass : 0 ≤ coreOuterShellMass H (logLog x) := tupleReciprocalMass_nonneg _ _ _ have hnonneg : 0 ≤ (C*Real.log z)*((x/Real.log x)*coreOuterShellMass H (logLog x)) := mul_nonneg (mul_nonneg hC.le hlogz) (mul_nonneg (div_nonneg (by linarith) (Real.log_pos hx1).le) hmass) change ((smoothOuterShellValues x H z).card : ℝ) ≤ C*Real.log z*(x/Real.log x)*coreOuterShellMass H (logLog x) at hc simpa only [Real.norm_eq_abs,Nat.abs_cast,abs_of_nonneg hnonneg,mul_assoc] using hc exact hdom.trans_isLittleO (hH.const_mul_left (C*Real.log z)) end Erdos416Proof.FordBadFacet end /- Consolidated component: LowerCoreRecord.lean. -/ section open Filter Finset open scoped Classical Topology BigOperators namespace Erdos416Proof.CoreRecords open FordBadFacet FordGeometry FordReciprocal FordLower /-- Concrete lower-prime data. The numerical core is computed from the tail and the selected ordinary primes; no counting or coverage statement is a field. -/ /- Original line 50498: Erdos416Proof.CoreRecords.LowerCoreRecord -/ structure LowerCoreRecord (Y : ℝ) (L R : ℕ) (P : ℝ) where length_pos : 0 < L tail : ℕ tail_pos : 0 < tail tail_le : tail ≤ R lower : Fin L → ℕ prime : ∀ idx, (lower idx).Prime order : StrictAnti lower last_lower : max 17 (largestPrimeFactor tail) < lower ⟨L-1, by omega⟩ last_upper : (lower ⟨L-1, by omega⟩ : ℝ) ≤ P gaps : ∀ idx j : Fin L, j.val = idx.val+1 → (6/5 : ℝ)*logLog (lower j) ≤ logLog (lower idx) upper : ∀ idx, (lower idx : ℝ) ≤ CollisionBox.cutoff Y (4/5) facet : outerForm L (fun idx => CollisionBox.primeCoordinate (logLog Y) (lower idx)) ≤ 1-(logLog Y)^(-1/8 : ℝ) namespace LowerCoreRecord variable {Y P : ℝ} {L R : ℕ} (Q : LowerCoreRecord Y L R P) /- Original line 50518: Erdos416Proof.CoreRecords.LowerCoreRecord.integer -/ noncomputable def integer : ℕ := Q.tail * ∏ idx, Q.lower idx /- Original line 50519: Erdos416Proof.CoreRecords.LowerCoreRecord.numericalCore -/ noncomputable def numericalCore : ℕ := Q.tail.totient * ∏ idx, (Q.lower idx-1) /- Original line 50520: Erdos416Proof.CoreRecords.LowerCoreRecord.fullPrimes -/ noncomputable def fullPrimes (p : ℕ) : Fin (L+1) → ℕ := Fin.cons p Q.lower /- Original line 50522: Erdos416Proof.CoreRecords.LowerCoreRecord.integer_pos -/ theorem integer_pos : 0 < Q.integer := Nat.mul_pos Q.tail_pos (Finset.prod_pos fun idx _ => (Q.prime idx).pos) /- Original line 50525: Erdos416Proof.CoreRecords.LowerCoreRecord.prime_lower -/ theorem prime_lower (idx : Fin L) : max 17 (largestPrimeFactor Q.tail) < Q.lower idx := Q.last_lower.trans_le (Q.order.antitone (show idx ≤ ⟨L-1, by have := Q.length_pos; omega⟩ from by change idx.val ≤ L-1 omega)) /- Original line 50530: Erdos416Proof.CoreRecords.LowerCoreRecord.integer_totient -/ theorem integer_totient : Q.integer.totient = Q.numericalCore := by unfold integer numericalCore rw [Nat.totient_mul (Nat.coprime_prod_left_iff.mpr (fun idx _ => coprime_of_largestPrimeFactor_lt Q.tail_pos (Q.prime idx) ((le_max_right _ _).trans_lt (Q.prime_lower idx)))).symm] rw [totient_prod_injective_primes Finset.univ Q.lower (fun idx _ => Q.prime idx) Q.order.injective.injOn] /- Original line 50538: Erdos416Proof.CoreRecords.LowerCoreRecord.numericalCore_pos -/ theorem numericalCore_pos : 0 < Q.numericalCore := Q.integer_totient ▸ Nat.totient_pos.mpr Q.integer_pos /- Original line 50541: Erdos416Proof.CoreRecords.LowerCoreRecord.largest_eq_first -/ theorem largest_eq_first : largestPrimeFactor Q.integer = Q.lower ⟨0, Q.length_pos⟩ := by let i₀ : Fin L := ⟨0, Q.length_pos⟩ have hprod : 0 < ∏ idx, Q.lower idx := Finset.prod_pos fun idx _ => (Q.prime idx).pos have hbound : (largestPrimeFactor (∏ idx, Q.lower idx) : ℝ) ≤ Q.lower i₀ := by apply largestPrimeFactor_prod_le Finset.univ Q.lower (by exact_mod_cast (Q.prime i₀).one_le) (fun idx _ => (Q.prime idx).pos) intro idx _ rw [largestPrimeFactor_prime (Q.prime idx)] exact_mod_cast Q.order.antitone (show i₀ ≤ idx from Nat.zero_le _) have htail : largestPrimeFactor Q.tail < Q.lower i₀ := (le_max_right _ _).trans_lt (Q.prime_lower i₀) apply le_antisymm · rw [integer, largestPrimeFactor_mul Q.tail_pos hprod] exact max_le htail.le (by exact_mod_cast hbound) · apply prime_le_largestPrimeFactor Q.integer_pos (Q.prime i₀) exact dvd_mul_of_dvd_right (Finset.dvd_prod_of_mem Q.lower (Finset.mem_univ i₀)) Q.tail /- Original line 50559: Erdos416Proof.CoreRecords.LowerCoreRecord.largest_le_cutoff -/ theorem largest_le_cutoff : (largestPrimeFactor Q.integer : ℝ) ≤ CollisionBox.cutoff Y (4/5) := by rw [Q.largest_eq_first] exact Q.upper _ /- Original line 50563: Erdos416Proof.CoreRecords.LowerCoreRecord.extension_totient -/ theorem extension_totient {p : ℕ} (hp : p.Prime) (hsep : Q.lower ⟨0, Q.length_pos⟩ < p) : (p*Q.integer).totient = corePairValue (Q.numericalCore,p) := by rw [(top_prime_extension Q.integer_pos hp (by rwa [Q.largest_eq_first])).1, Q.integer_totient] rfl /- Original line 50570: Erdos416Proof.CoreRecords.LowerCoreRecord.extension_largest -/ theorem extension_largest {p : ℕ} (hp : p.Prime) (hsep : Q.lower ⟨0, Q.length_pos⟩ < p) : largestPrimeFactor (p*Q.integer) = p := (top_prime_extension Q.integer_pos hp (by rwa [Q.largest_eq_first])).2 /- Original line 50575: Erdos416Proof.CoreRecords.LowerCoreRecord.fullPrimes_last -/ theorem fullPrimes_last (p : ℕ) : Q.fullPrimes p (Fin.last L) = Q.lower ⟨L-1, by have := Q.length_pos; omega⟩ := by have he : Fin.last L = (⟨L-1, by have := Q.length_pos; omega⟩ : Fin L).succ := by apply Fin.ext simp only [Fin.val_last, Fin.val_succ] have := Q.length_pos omega rw [he] rfl /- Original line 50585: Erdos416Proof.CoreRecords.LowerCoreRecord.fullPrimes_order -/ theorem fullPrimes_order {p : ℕ} (hsep : Q.lower ⟨0, Q.length_pos⟩ < p) : StrictAnti (Q.fullPrimes p) := by intro idx j hij cases idx using Fin.cases with | zero => cases j using Fin.cases with | zero => exact (lt_irrefl (0 : Fin (L+1)) hij).elim | succ j => exact (Q.order.antitone (show (⟨0,Q.length_pos⟩ : Fin L) ≤ j from Nat.zero_le _)).trans_lt hsep | succ idx => cases j using Fin.cases with | zero => have h : idx.val+1 < 0 := hij; omega | succ j => exact Q.order (Fin.succ_lt_succ_iff.mp hij) /-- A prime attached to the concrete core yields exactly the tuple expected by the verified collision theorem. -/ /- Original line 50601: Erdos416Proof.CoreRecords.LowerCoreRecord.toTuple -/ theorem toTuple {p : ℕ} (hp : p.Prime) (hsep : Q.lower ⟨0, Q.length_pos⟩ < p) (htop : Y^(9/10 : ℝ) < (p : ℝ)) (hsize : (corePairValue (Q.numericalCore,p) : ℝ) ≤ Y) : Rigidity.Tuple Y P (6/5) (4/5) Q.tail (p*∏ idx,Q.lower idx) (Q.fullPrimes p) := by have hfullprime : ∀ idx, (Q.fullPrimes p idx).Prime := by intro idx exact Fin.cases hp (fun j => Q.prime j) idx have hprodφ : (p*∏ idx,Q.lower idx).totient = (p-1)*∏ idx,(Q.lower idx-1) := by have hprod : p*∏ idx,Q.lower idx = ∏ idx,Q.fullPrimes p idx := by simp only [Fin.prod_univ_succ,fullPrimes,Fin.cons_zero,Fin.cons_succ] rw [hprod,totient_prod_injective_primes Finset.univ (Q.fullPrimes p) (fun idx _ => hfullprime idx) (Q.fullPrimes_order hsep).injective.injOn] simp only [Fin.prod_univ_succ,fullPrimes,Fin.cons_zero,Fin.cons_succ] refine ⟨?_,hfullprime,Q.fullPrimes_order hsep,?_,?_,?_,?_,htop,?_,?_⟩ · simp only [Fin.prod_univ_succ,fullPrimes,Fin.cons_zero,Fin.cons_succ] · rw [Q.fullPrimes_last] exact Q.last_lower · rw [Q.fullPrimes_last] exact Q.last_upper · intro idx hi hij cases idx using Fin.cases with | zero => simp [Erdos416Proof.CollisionFacet.extend_apply, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordBadFacet.positiveLogLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_bottom, Erdos416Proof.FordBadFacet.reversedFacetLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_succ, Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.FordRestricted.suffixCutoff_log3, Erdos416Proof.largestPrimeFactor_one, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint] at hi | succ idx => let j : Fin L := ⟨idx.val+1,by simp only [Fin.val_succ] at hij; omega⟩ have he : (⟨idx.succ.val+1,hij⟩ : Fin (L+1)) = j.succ := Fin.ext (by rfl) rw [he] exact Q.gaps idx j rfl · intro idx hi cases idx using Fin.cases with | zero => simp [Erdos416Proof.CollisionFacet.extend_apply, Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordBadFacet.positiveLogLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_bottom, Erdos416Proof.FordBadFacet.reversedFacetLog_one, Erdos416Proof.FordBadFacet.reversedFacetLog_succ, Erdos416Proof.FordReciprocal.primeLabel_one, Erdos416Proof.FordRestricted.suffixCutoff_log3, Erdos416Proof.largestPrimeFactor_one, Erdos416Proof.logLog_growthIntervalEndpoint, Erdos416Proof.logLog_growthNormalityScale, Erdos416Proof.logLog_growthTailEndpoint, Erdos416Proof.logLog_normalityGridPoint] at hi | succ idx => exact Q.upper idx · rw [hprodφ] simpa only [corePairValue,numericalCore,mul_left_comm,mul_assoc] using hsize · rw [← outerForm_eq_extended_sum] exact Q.facet /- Original line 50638: Erdos416Proof.CoreRecords.LowerCoreRecord.integer_le -/ theorem integer_le : (Q.integer : ℝ) ≤ (R : ℝ)*(CollisionBox.cutoff Y (4/5))^L := by have hprod : (∏ idx : Fin L, (Q.lower idx : ℝ)) ≤ (CollisionBox.cutoff Y (4/5))^L := by calc _ ≤ ∏ _i : Fin L, CollisionBox.cutoff Y (4/5) := Finset.prod_le_prod (fun _ _ => Nat.cast_nonneg _) (fun idx _ => Q.upper idx) _ = _ := by simp have htail : (Q.tail : ℝ) ≤ R := by exact_mod_cast Q.tail_le simpa only [integer,Nat.cast_mul,Nat.cast_prod] using mul_le_mul htail hprod (Finset.prod_nonneg fun _ _ => Nat.cast_nonneg _) (Nat.cast_nonneg R) /- Original line 50648: Erdos416Proof.CoreRecords.LowerCoreRecord.log_integer_le -/ theorem log_integer_le {A : ℝ} (hY : 1 < Y) (hL : (L : ℝ) ≤ A*Real.log (logLog Y)) : Real.log Q.integer ≤ logCoreBound R A (4/5) Y := by have hR : (0 : ℝ) < R := by exact_mod_cast Q.tail_pos.trans_le Q.tail_le have hlog := Real.log_le_log (by exact_mod_cast Q.integer_pos) Q.integer_le change Real.log Q.integer ≤ Real.log ((R : ℝ)*Real.exp ((Real.log Y)^(4/5 : ℝ))^L) at hlog rw [Real.log_mul hR.ne' (pow_pos (Real.exp_pos _) _).ne',Real.log_pow, Real.log_exp] at hlog have hpow : 0 ≤ (Real.log Y)^(4/5 : ℝ) := Real.rpow_nonneg (Real.log_pos hY).le _ exact hlog.trans (by unfold logCoreBound simpa only [logLog] using add_le_add le_rfl (mul_le_mul_of_nonneg_right hL hpow)) /- Original line 50661: Erdos416Proof.CoreRecords.LowerCoreRecord.log_numericalCore_le -/ theorem log_numericalCore_le {A : ℝ} (hY : 1 < Y) (hL : (L : ℝ) ≤ A*Real.log (logLog Y)) : Real.log Q.numericalCore ≤ logCoreBound R A (4/5) Y := by apply le_trans (Real.log_le_log (by exact_mod_cast Q.numericalCore_pos) ?_) (Q.log_integer_le hY hL) rw [← Q.integer_totient] exact_mod_cast Nat.totient_le Q.integer /- Original line 50669: Erdos416Proof.CoreRecords.LowerCoreRecord.ext -/ theorem ext {Q₁ Q₂ : LowerCoreRecord Y L R P} (hr : Q₁.tail = Q₂.tail) (hq : Q₁.lower = Q₂.lower) : Q₁ = Q₂ := by cases Q₁ cases Q₂ cases hr cases hq rfl /-- The record family is finite because its tail and every selected prime are bounded. Geometric and arithmetic proof fields add no extra data. -/ /- Original line 50679: Erdos416Proof.CoreRecords.LowerCoreRecord.boundedEncoding -/ noncomputable def boundedEncoding : Fin (R+1) × (Fin L → Fin (⌊CollisionBox.cutoff Y (4/5)⌋₊+1)) := (⟨Q.tail,by have := Q.tail_le; omega⟩,fun idx => ⟨Q.lower idx,by have hcut : 0 ≤ CollisionBox.cutoff Y (4/5) := (Real.exp_pos _).le have hle := (Nat.le_floor_iff hcut).mpr (Q.upper idx) omega⟩) /- Original line 50685: Erdos416Proof.CoreRecords.LowerCoreRecord.boundedEncoding_injective -/ theorem boundedEncoding_injective : Function.Injective (boundedEncoding : LowerCoreRecord Y L R P → _) := by intro Q₁ Q₂ h apply ext · exact congrArg (fun z => z.1.val) h · exact funext fun idx => congrArg (fun z => (z.2 idx).val) h /- Original line 50692: Erdos416Proof.CoreRecords.LowerCoreRecord.__anonymous_50692 -/ noncomputable abbrev instFintype : Fintype (LowerCoreRecord Y L R P) := Fintype.ofInjective boundedEncoding boundedEncoding_injective end LowerCoreRecord /-- Conditions on the ordinary factors of one given preimage. -/ /- Original line 50698: Erdos416Proof.CoreRecords.OrdinaryLowerCoreConditions -/ structure OrdinaryLowerCoreConditions (Y : ℝ) (L R : ℕ) (P : ℝ) (N : ℕ) : Prop where length_pos : 0 < L tail_le : ordinarySuffix N (L+1) ≤ R order : StrictAnti (fun idx : Fin L => ordinaryPrimeAt N (idx.val+1)) last_lower : max 17 (largestPrimeFactor (ordinarySuffix N (L+1))) < ordinaryPrimeAt N L last_upper : (ordinaryPrimeAt N L : ℝ) ≤ P gaps : ∀ idx j : Fin L, j.val = idx.val+1 → (6/5 : ℝ)*logLog (ordinaryPrimeAt N (j.val+1)) ≤ logLog (ordinaryPrimeAt N (idx.val+1)) upper : ∀ idx : Fin L, (ordinaryPrimeAt N (idx.val+1) : ℝ) ≤ CollisionBox.cutoff Y (4/5) facet : outerForm L (fun idx : Fin L => CollisionBox.primeCoordinate (logLog Y) (ordinaryPrimeAt N (idx.val+1))) ≤ 1-(logLog Y)^(-1/8 : ℝ) namespace OrdinaryLowerCoreConditions variable {Y P : ℝ} {L R N : ℕ} (h : OrdinaryLowerCoreConditions Y L R P N) /- Original line 50715: Erdos416Proof.CoreRecords.OrdinaryLowerCoreConditions.record -/ noncomputable def record : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype LowerCoreRecord Y L R P := by letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact { length_pos := h.length_pos tail := ordinarySuffix N (L+1) tail_pos := ordinarySuffix_pos N (L+1) tail_le := h.tail_le lower := fun idx => ordinaryPrimeAt N (idx.val+1) prime := by intro idx have hlarge : 17 < ordinaryPrimeAt N (idx.val+1) := ((le_max_left _ _).trans_lt h.last_lower).trans_le (ordinaryPrimeAt_antitone N (by omega : idx.val+1 ≤ L)) rcases ordinaryPrimeAt_spec N (idx.val+1) with he | ⟨hp,_⟩ · omega · exact hp order := h.order last_lower := by simpa only [Nat.sub_add_cancel h.length_pos] using h.last_lower last_upper := by simpa only [Nat.sub_add_cancel h.length_pos] using h.last_upper gaps := h.gaps upper := h.upper facet := h.facet } /- Original line 50736: Erdos416Proof.CoreRecords.OrdinaryLowerCoreConditions.integer_identity -/ theorem integer_identity : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ (hN : 0 < N), ordinaryPrimeAt N 0*h.record.integer = N := by intro hN letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact by have hs := ordinary_split hN (L+1) rw [ordinaryPrefix_eq_fin_prod,Fin.prod_univ_succ] at hs simpa only [record,LowerCoreRecord.integer,Fin.val_zero,Fin.val_succ,mul_assoc, mul_left_comm,mul_comm] using hs /- Original line 50742: Erdos416Proof.CoreRecords.OrdinaryLowerCoreConditions.corePair_value -/ theorem corePair_value : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ (hN : 0 < N) (hgap : ordinaryPrimeAt N 1 < ordinaryPrimeAt N 0), corePairValue (h.record.numericalCore,ordinaryPrimeAt N 0) = N.totient := by intro hN hgap letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact by have hp : (ordinaryPrimeAt N 0).Prime := by rcases ordinaryPrimeAt_spec N 0 with he | ⟨hp,_⟩ · have := ordinaryPrimeAt_one_le N 1 omega · exact hp rw [← h.record.extension_totient hp (by exact hgap),h.integer_identity hN] /- Original line 50752: Erdos416Proof.CoreRecords.OrdinaryLowerCoreConditions.mem_corePairs -/ theorem mem_corePairs : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ {cores : Finset ℕ} {lo hi : ℝ} (hN : 0 < N) (hgap : ordinaryPrimeAt N 1 < ordinaryPrimeAt N 0) (hcores : ∀ b ∈ cores, 0 < b) (hb : h.record.numericalCore ∈ cores) (hlo : lo < (N.totient : ℝ)) (hhi : (N.totient : ℝ) ≤ hi), (h.record.numericalCore,ordinaryPrimeAt N 0) ∈ corePairs cores lo hi := by intro cores lo hi hN hgap hcores hb hlo hhi letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact by have hh : 0 ≤ hi := (Nat.cast_nonneg N.totient).trans hhi apply (Erdos416Proof.mem_corePairs hh hcores).mpr have hp : (ordinaryPrimeAt N 0).Prime := by rcases ordinaryPrimeAt_spec N 0 with he | ⟨hp,_⟩ · have := ordinaryPrimeAt_one_le N 1 omega · exact hp exact ⟨hb,hp,by simpa only [h.corePair_value hN hgap] using hlo, by simpa only [h.corePair_value hN hgap] using hhi⟩ end OrdinaryLowerCoreConditions /-- The lower cutoff is eventually strictly below every allowed leading prime. -/ /- Original line 50770: Erdos416Proof.CoreRecords.lower_cutoff_below_top -/ theorem lower_cutoff_below_top : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ᶠ Y : ℝ in atTop, CollisionBox.cutoff Y (4/5) < Y^(9/10 : ℝ) := by letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact by have hs : Tendsto (fun Y : ℝ => (Real.log Y)^(4/5 : ℝ)/Real.log Y) atTop (nhds 0) := by simpa only [Function.comp_def,pow_zero,one_mul,Real.rpow_one] using ((log_pow_mul_rpow_littleO 0 (show (4/5 : ℝ) < 1 by norm_num)).tendsto_div_nhds_zero.comp Real.tendsto_log_atTop) filter_upwards [hs.eventually (gt_mem_nhds (by norm_num : (0 : ℝ) < 9/10)), eventually_gt_atTop (1 : ℝ)] with Y hs hY have he := (div_lt_iff₀ (Real.log_pos hY)).mp hs rw [CollisionBox.cutoff,Real.rpow_def_of_pos (by linarith : 0 < Y)] exact Real.exp_lt_exp.mpr (by simpa only [mul_comm] using he) /- Original line 50782: Erdos416Proof.CoreRecords.record_top_separation_eventually -/ theorem record_top_separation_eventually : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ᶠ Y : ℝ in atTop, ∀ L R P (Q : LowerCoreRecord Y L R P) (p : ℕ), Y^(9/10 : ℝ) < (p : ℝ) → largestPrimeFactor Q.integer < p := by letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact by filter_upwards [lower_cutoff_below_top] with Y hcut intro L R P Q p hp exact_mod_cast Q.largest_le_cutoff.trans_lt (hcut.trans hp) /- Original line 50789: Erdos416Proof.CoreRecords.record_integer_subpower -/ theorem record_integer_subpower : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ (R : ℕ) (A : ℝ) {η : ℝ} (hη : 0 < η), ∀ᶠ Y : ℝ in atTop, ∀ L P (Q : LowerCoreRecord Y L R P), (L : ℝ) ≤ A*Real.log (logLog Y) → (Q.integer : ℝ) ≤ Y^η := by intro R A η hη letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact by filter_upwards [(logCoreBound_small R A (show (4/5 : ℝ) < 1 by norm_num)).eventually (gt_mem_nhds hη),eventually_gt_atTop (1 : ℝ)] with Y hsmall hY intro L P Q hL have hlog : Real.log Q.integer < Real.log Y*η := (Q.log_integer_le hY hL).trans_lt (by simpa only [mul_comm] using (div_lt_iff₀ (Real.log_pos hY)).mp hsmall) rw [Real.rpow_def_of_pos (by linarith : 0 < Y)] simpa only [Real.exp_log (by exact_mod_cast Q.integer_pos : (0 : ℝ) < Q.integer)] using (Real.exp_le_exp.mpr hlog.le) /-- Every raw pair in the PNT band automatically has a sufficiently large leading prime, uniformly over records of the permitted length. -/ /- Original line 50804: Erdos416Proof.CoreRecords.rawPair_top_eventually -/ theorem rawPair_top_eventually : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ (R : ℕ) (A : ℝ), ∀ᶠ Y : ℝ in atTop, ∀ L P (Q : LowerCoreRecord Y L R P), (L : ℝ) ≤ A*Real.log (logLog Y) → ∀ p, p.Prime → coreLowerFraction Y*Y < (corePairValue (Q.numericalCore,p) : ℝ) → (corePairValue (Q.numericalCore,p) : ℝ) ≤ Y → Y^(9/10 : ℝ) < (p : ℝ) ∧ Q.lower ⟨0,Q.length_pos⟩ < p := by intro R A letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact by filter_upwards [record_integer_subpower R A (show (0 : ℝ) < 1/40 by norm_num), lowerPrimeChoices_large_eventually,eventually_gt_atTop (1 : ℝ)] with Y hsmall hlarge hY intro L P Q hL p hp hlo hhi have hc : ∀ b ∈ ({Q.integer.totient} : Finset ℕ), 0 < b := by intro b hb simpa only [Finset.mem_singleton.mp hb] using Nat.totient_pos.mpr Q.integer_pos have hpair : (Q.integer.totient,p) ∈ corePairs {Q.integer.totient} (coreLowerFraction Y*Y) Y := by apply (Erdos416Proof.mem_corePairs (by linarith) hc).mpr exact ⟨Finset.mem_singleton_self _,hp,by simpa only [Q.integer_totient] using hlo, by simpa only [Q.integer_totient] using hhi⟩ have hchoice := (lowerPrimeChoices_pair_iff (by linarith) Q.integer_pos).mpr hpair have hg := hlarge Q.integer Q.integer_pos (hsmall L P Q hL) p hchoice refine ⟨(Real.rpow_le_rpow_of_exponent_le hY.le (by norm_num : (9/10 : ℝ) ≤ 19/20)).trans_lt hg.1,?_⟩ rw [← Q.largest_eq_first] exact (largestPrimeFactor_le Q.integer_pos).trans_lt hg.2 /-- Fix one concrete record for each retained numerical core. -/ /- Original line 50827: Erdos416Proof.CoreRecords.CoreSelection -/ structure CoreSelection (Y : ℝ) (L R : ℕ) (P : ℝ) where cores : Finset ℕ record : ∀ _b : cores, LowerCoreRecord Y L R P core_eq : ∀ b : cores, (record b).numericalCore = b.val namespace CoreSelection variable {Y P : ℝ} {L R : ℕ} (S : CoreSelection Y L R P) /-- Retain one representative of each numerical core in any concrete finite list of lower records. This selection is fixed before exceptional deletions. -/ /- Original line 50838: Erdos416Proof.CoreRecords.CoreSelection.ofRecords -/ noncomputable def ofRecords : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ (F : Finset (LowerCoreRecord Y L R P)), CoreSelection Y L R P := by intro F letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact { cores := F.image LowerCoreRecord.numericalCore record := fun b => Classical.choose (Finset.mem_image.mp b.property) core_eq := fun b => (Classical.choose_spec (Finset.mem_image.mp b.property)).2 } /- Original line 50843: Erdos416Proof.CoreRecords.CoreSelection.ofRecords_core_mem -/ theorem ofRecords_core_mem : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ {F : Finset (LowerCoreRecord Y L R P)} {Q : LowerCoreRecord Y L R P} (hQ : Q ∈ F), Q.numericalCore ∈ (ofRecords F).cores := by intro F Q hQ letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact Finset.mem_image.mpr ⟨Q,hQ,rfl⟩ /- Original line 50847: Erdos416Proof.CoreRecords.CoreSelection.fullSelection -/ noncomputable def fullSelection : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ (Y : ℝ) (L R : ℕ) (P : ℝ), CoreSelection Y L R P := by intro Y L R P letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact ofRecords Finset.univ /- Original line 50850: Erdos416Proof.CoreRecords.CoreSelection.fullSelection_core_mem -/ theorem fullSelection_core_mem : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ (Q : LowerCoreRecord Y L R P), Q.numericalCore ∈ (fullSelection Y L R P).cores := by intro Q letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact ofRecords_core_mem (Finset.mem_univ Q) /- Original line 50854: Erdos416Proof.CoreRecords.CoreSelection.cores_pos -/ theorem cores_pos : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ b ∈ S.cores, 0 < b := by letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact by intro b hb simpa only [S.core_eq] using (S.record ⟨b,hb⟩).numericalCore_pos /- Original line 50858: Erdos416Proof.CoreRecords.CoreSelection.actualInteger -/ noncomputable def actualInteger : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ (bp : ℕ × ℕ), ℕ := by intro bp letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact if hb : bp.1 ∈ S.cores then bp.2*(S.record ⟨bp.1,hb⟩).integer else 0 /- Original line 50861: Erdos416Proof.CoreRecords.CoreSelection.actualInteger_apply -/ theorem actualInteger_apply : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ {bp : ℕ × ℕ} (hb : bp.1 ∈ S.cores), S.actualInteger bp = bp.2*(S.record ⟨bp.1,hb⟩).integer := by intro bp hb letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact dif_pos hb /- Original line 50864: Erdos416Proof.CoreRecords.CoreSelection.actualInteger_totient -/ theorem actualInteger_totient : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ {bp : ℕ × ℕ} (hb : bp.1 ∈ S.cores) (hp : bp.2.Prime) (hsep : largestPrimeFactor (S.record ⟨bp.1,hb⟩).integer < bp.2), 0 < S.actualInteger bp ∧ (S.actualInteger bp).totient = corePairValue bp := by intro bp hb hp hsep letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact by rw [S.actualInteger_apply hb] refine ⟨Nat.mul_pos hp.pos (S.record ⟨bp.1,hb⟩).integer_pos,?_⟩ rw [(top_prime_extension (S.record ⟨bp.1,hb⟩).integer_pos hp hsep).1, LowerCoreRecord.integer_totient,S.core_eq] rfl /- Original line 50873: Erdos416Proof.CoreRecords.CoreSelection.equal_tail_shifted_product -/ theorem equal_tail_shifted_product : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ {a b : S.cores} (hr : (S.record a).tail = (S.record b).tail) (hprod : (∏ idx,((S.record a).lower idx-1)) = ∏ idx,((S.record b).lower idx-1)), a = b := by intro a b hr hprod letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact by apply Subtype.ext rw [← S.core_eq a,← S.core_eq b] simp only [LowerCoreRecord.numericalCore,hr,hprod] /-- Equal canonical integers recover their largest prime and then their numerical core. This does not assert injectivity of totient values. -/ /- Original line 50882: Erdos416Proof.CoreRecords.CoreSelection.actualInteger_injective -/ theorem actualInteger_injective : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ {lo hi : ℝ} (hhi : 0 ≤ hi) (hsep : ∀ bp ∈ corePairs S.cores lo hi, ∀ hb : bp.1 ∈ S.cores, largestPrimeFactor (S.record ⟨bp.1,hb⟩).integer < bp.2), Set.InjOn S.actualInteger (corePairs S.cores lo hi : Set (ℕ × ℕ)) := by intro lo hi hhi hsep letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact by intro a ha b hb hab have ha' := (Erdos416Proof.mem_corePairs hhi S.cores_pos).mp ha have hb' := (Erdos416Proof.mem_corePairs hhi S.cores_pos).mp hb rw [S.actualInteger_apply ha'.1,S.actualInteger_apply hb'.1] at hab have hpa := top_prime_extension (S.record ⟨a.1,ha'.1⟩).integer_pos ha'.2.1 (hsep a ha ha'.1) have hpb := top_prime_extension (S.record ⟨b.1,hb'.1⟩).integer_pos hb'.2.1 (hsep b hb hb'.1) have hp : a.2 = b.2 := by simpa only [hpa.2,hpb.2] using congrArg largestPrimeFactor hab apply corePair_eq_of_same_prime ha'.2.1 hp have he := congrArg Nat.totient hab simpa only [hpa.1,hpb.1,LowerCoreRecord.integer_totient,S.core_eq,corePairValue] using he /- Original line 50898: Erdos416Proof.CoreRecords.CoreSelection.rawPairs_toTuple_eventually -/ theorem rawPairs_toTuple_eventually : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ (R : ℕ) (A : ℝ), ∀ᶠ Y : ℝ in atTop, ∀ L P (S : CoreSelection Y L R P), (L : ℝ) ≤ A*Real.log (logLog Y) → ∀ lo hi, coreLowerFraction Y*Y ≤ lo → hi ≤ Y → 0 ≤ hi → ∀ bp ∈ corePairs S.cores lo hi, ∀ hb : bp.1 ∈ S.cores, Rigidity.Tuple Y P (6/5) (4/5) (S.record ⟨bp.1,hb⟩).tail (bp.2*∏ idx,(S.record ⟨bp.1,hb⟩).lower idx) ((S.record ⟨bp.1,hb⟩).fullPrimes bp.2) := by intro R A letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact by filter_upwards [rawPair_top_eventually R A] with Y htop intro L P S hL lo hi hlo hhi hhi0 bp hbp hb have hm := (Erdos416Proof.mem_corePairs hhi0 S.cores_pos).mp hbp have hv : corePairValue ((S.record ⟨bp.1,hb⟩).numericalCore,bp.2) = corePairValue bp := by rw [S.core_eq] have hg := htop L P (S.record ⟨bp.1,hb⟩) hL bp.2 hm.2.1 (by simpa only [hv] using hlo.trans_lt hm.2.2.1) (by simpa only [hv] using hm.2.2.2.trans hhi) exact (S.record ⟨bp.1,hb⟩).toTuple hm.2.1 hg.2 hg.1 (by simpa only [hv] using hm.2.2.2.trans hhi) end CoreSelection end Erdos416Proof.CoreRecords end /- Consolidated component: ProfileCoreBridge.lean. -/ section open Filter Finset open scoped Classical Topology BigOperators namespace Erdos416Proof.FordGeometry /-- An initial segment keeps every expanded-polytope inequality. The smaller polytope's final row follows from order and its parameter ≥1. -/ /- Original line 50936: Erdos416Proof.FordGeometry.initial_mem_expanded_polytope -/ theorem initial_mem_expanded_polytope : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ {K D : ℕ} (hKD : K ≤ D) {ξ : ℕ → ℝ} (hξ : ∀ j, 1 ≤ ξ j) {x : Fin D → ℝ} (hx : x ∈ polytope D ξ), (fun idx : Fin K => x (Fin.castLE hKD idx)) ∈ polytope K ξ := by intro K D hKD ξ hξ x hx letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact by refine ⟨fun idx => hx.1 _, fun idx => hx.2.1 _, ?_, ?_, ?_⟩ · intro idx j hij exact hx.2.2.1 hij · exact (sum_initial_le hKD (fun idx => fordWeight (idx.val+1)*x idx) (fun idx => mul_nonneg (fordWeight_bounds (by omega)).1 (hx.1 idx))).trans hx.2.2.2.1 · intro idx hi by_cases hrow : idx.val+2 < K · have hrowD : (Fin.castLE hKD idx).val+2 < D := by simpa [Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordGeometry.slackMap_apply] using hrow.trans_le hKD rw [tailForm_eq_sum idx _ hrow] have h := hx.2.2.2.2 (Fin.castLE hKD idx) (by simpa [Erdos416Proof.FordAnalysis.coeff_zero, Erdos416Proof.FordGeometry.slackMap_apply] using hi.trans_le hKD) rw [tailForm_eq_sum _ _ hrowD] at h apply le_trans _ h exact sum_initial_le hKD (fun j => if idx.val < j.val then fordWeight (j.val-idx.val)*x j else 0) (fun j => by split_ifs · exact mul_nonneg (fordWeight_bounds (by omega)).1 (hx.1 j) · rfl) · let j : Fin K := ⟨idx.val+1, hi⟩ rw [tailForm_last idx j (by omega) rfl] exact (hx.2.2.1 (by change idx.val ≤ idx.val+1; omega)).trans (le_mul_of_one_le_left (hx.1 _) (hξ _)) /- Original line 50963: Erdos416Proof.FordGeometry.outerForm_initial_le -/ theorem outerForm_initial_le : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ {K D : ℕ} (hKD : K ≤ D) {x : Fin D → ℝ} (hx : ∀ idx, 0 ≤ x idx), outerForm K (fun idx : Fin K => x (Fin.castLE hKD idx)) ≤ outerForm D x := by intro K D hKD x hx letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact sum_initial_le hKD (fun idx => fordWeight (idx.val+1)*x idx) (fun idx => mul_nonneg (fordWeight_bounds (by omega)).1 (hx idx)) end Erdos416Proof.FordGeometry namespace Erdos416Proof.FordBadFacet open FordGeometry FordReciprocal FordScale /- Original line 50975: Erdos416Proof.FordBadFacet.ordinary_initial_mem_expanded_polytope -/ theorem ordinary_initial_mem_expanded_polytope : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ {K D N : ℕ} (hKD : K ≤ D) {T : ℝ} {ξ : ℕ → ℝ} (hξ : ∀ j, 1 ≤ ξ j) (hpoint : ordinaryLowerPoint D T N ∈ polytope D ξ), ordinaryLowerPoint K T N ∈ polytope K ξ := by intro K D N hKD T ξ hξ hpoint letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact initial_mem_expanded_polytope hKD hξ hpoint /- Original line 50981: Erdos416Proof.FordBadFacet.ordinary_initial_raw_facet_le -/ theorem ordinary_initial_raw_facet_le : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ {K D N : ℕ} (hKD : K ≤ D) {T : ℝ} (hT : 0 ≤ T), outerForm K (fun idx : Fin K => CollisionBox.primeCoordinate T (ordinaryPrimeAt N (idx.val+1))) ≤ outerForm D (ordinaryLowerPoint D T N) := by intro K D N hKD T hT letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact by calc _ ≤ outerForm K (ordinaryLowerPoint K T N) := by change (∑ idx : Fin K, fordWeight (idx.val+1)* (logLog (ordinaryPrimeAt N (idx.val+1))/T)) ≤ ∑ idx : Fin K, fordWeight (idx.val+1)* (max 0 (logLog (ordinaryPrimeAt N (idx.val+1)))/T) apply Finset.sum_le_sum intro idx _ apply mul_le_mul_of_nonneg_left _ (fordWeight_bounds (by omega)).1 exact div_le_div_of_nonneg_right (le_max_right 0 _) hT _ ≤ _ := by have hnonneg (idx : Fin D) : 0 ≤ ordinaryLowerPoint D T N idx := div_nonneg (le_max_left 0 _) hT exact outerForm_initial_le hKD (x := ordinaryLowerPoint D T N) hnonneg /- Original line 51000: Erdos416Proof.FordBadFacet.ordinary_initial_facet_of_outside_shell -/ theorem ordinary_initial_facet_of_outside_shell : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ {H N K : ℕ} {T : ℝ} (hT : 0 ≤ T) (hKD : K ≤ coreDimension H T) (hpoint : ordinaryLowerPoint (coreDimension H T) T N ∈ polytope (coreDimension H T) (expandedParameter (optimalDimension T))) (hshell : ordinaryLowerPoint (coreDimension H T) T N ∉ coreOuterShell H T), outerForm K (fun idx : Fin K => CollisionBox.primeCoordinate T (ordinaryPrimeAt N (idx.val+1))) ≤ 1-T^(-1/8 : ℝ) := by intro H N K T hT hKD hpoint hshell letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact by have houter : outerForm (coreDimension H T) (ordinaryLowerPoint (coreDimension H T) T N) ≤ 1-T^(-1/8 : ℝ) := by apply le_of_not_gt intro h exact hshell ⟨hpoint,h⟩ exact (ordinary_initial_raw_facet_le hKD hT).trans houter /- Original line 51014: Erdos416Proof.FordBadFacet.ordinarySuffix_largest_le_boundary -/ theorem ordinarySuffix_largest_le_boundary : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ (N j : ℕ), largestPrimeFactor (ordinarySuffix N j) ≤ ordinaryPrimeAt N j := by intro N j letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact by by_cases hlarge : 1 < largestPrimeFactor (ordinarySuffix N j) · have h := prime_divisor_le_ordinary_top (ordinarySuffix_pos N j) (largestPrimeFactor_isPrime hlarge) (largestPrimeFactor_dvd _) simpa only [ordinaryPrimeAt_suffix,Nat.add_zero] using h · exact (le_of_not_gt hlarge).trans (ordinaryPrimeAt_one_le N j) end Erdos416Proof.FordBadFacet namespace Erdos416Proof.CoreRecords open FordGeometry FordBadFacet FordReciprocal FordScale /-- The actual retained core record follows deterministically from the three geometric exclusions and the actual residual and minimum-prime bounds. -/ /- Original line 51030: Erdos416Proof.CoreRecords.ordinary_lower_core_conditions_eventually -/ theorem ordinary_lower_core_conditions_eventually : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ (H M : ℕ) (hHM : H+2 ≤ M), ∀ᶠ Y : ℝ in atTop, ∀ N R : ℕ, ordinaryLowerPoint (coreDimension H (logLog Y)) (logLog Y) N ∈ polytope (coreDimension H (logLog Y)) (expandedParameter (optimalDimension (logLog Y))) → ordinaryLowerPoint (coreDimension H (logLog Y)) (logLog Y) N ∉ coreOuterShell H (logLog Y) → ordinaryLowerPoint (coreDimension H (logLog Y)) (logLog Y) N ∉ parameterConcentrationUnion (coreDimension H (logLog Y)) (expandedParameter (optimalDimension (logLog Y))) (M-H-1) (1/20) → 17 < ordinaryPrimeAt N (coreDimension M (logLog Y)) → ordinarySuffix N (coreDimension M (logLog Y)+1) ≤ R → OrdinaryLowerCoreConditions Y (coreDimension M (logLog Y)) R (terminalPrimeBound H M) N := by intro H M hHM letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact by have hLL : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [hLL.eventually (ordinary_retained_profiles_eventually H M hHM), hLL.eventually (retained_profile_dimensions_eventually H M hHM), hLL.eventually (coreDimension_add_tail H), hLL.eventually (coreDimension_add_tail M), hLL.eventually_gt_atTop 0, eventually_gt_atTop (1 : ℝ)] with Y hprofiles hdimensions hDH hDM hT hY intro N R hpoint hshell hbad h17 htail have hdata := hprofiles N hpoint hbad have hL : 0 < coreDimension M (logLog Y) := by have := hdimensions.1; omega have hA : 1 ≤ M-H-1 := by omega have hdim : coreDimension H (logLog Y)-(M-H-1) = coreDimension M (logLog Y)+1 := by omega refine ⟨hL,htail,?_,?_,hdata.2.2,?_,?_,?_⟩ · intro idx j hij have hstep := (hdata.2.1 (idx.val+1) (by omega) (by have := idx.isLt; omega)).2 exact (ordinaryPrimeAt_antitone N (by change idx.val+1+1 ≤ j.val+1; omega)).trans_lt hstep · refine max_lt_iff.mpr ⟨h17, ?_⟩ exact (ordinarySuffix_largest_le_boundary N _).trans_lt ((hdata.2.1 (coreDimension M (logLog Y)) (by omega) le_rfl).2) · intro idx j hij have hg := (hdata.2.1 (idx.val+1) (by omega) (by have := idx.isLt; omega)).1 simpa only [hij] using hg · intro idx exact ordinary_profile_cutoff hA hY hT hpoint hbad (by omega) (by have := idx.isLt; omega) · exact ordinary_initial_facet_of_outside_shell hT.le (by omega) hpoint hshell /-- Membership in the smaller expanded polytope is available separately when a later finite-family construction also needs the retained coordinates. -/ /- Original line 51067: Erdos416Proof.CoreRecords.ordinary_retained_polytope_eventually -/ theorem ordinary_retained_polytope_eventually : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ (H M : ℕ) (hHM : H ≤ M), ∀ᶠ T : ℝ in atTop, ∀ N : ℕ, ordinaryLowerPoint (coreDimension H T) T N ∈ polytope (coreDimension H T) (expandedParameter (optimalDimension T)) → ordinaryLowerPoint (coreDimension M T) T N ∈ polytope (coreDimension M T) (expandedParameter (optimalDimension T)) := by intro H M hHM letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact by filter_upwards [coreDimension_add_tail H, coreDimension_add_tail M] with T hH hM intro N hpoint exact ordinary_initial_mem_expanded_polytope (by omega) (expandedParameter_ge_one _) hpoint end Erdos416Proof.CoreRecords end /- Consolidated component: PowerCorePairs.lean. -/ section open Filter Finset Asymptotics open scoped Classical Topology BigOperators namespace Erdos416Proof.CoreRecords /-- The common raw pair family uses a fixed power cutoff below its endpoint. -/ /- Original line 51094: Erdos416Proof.CoreRecords.powerRawPairs -/ noncomputable def powerRawPairs : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ {Y P : ℝ} {L R : ℕ} (S : CoreSelection Y L R P), Finset (ℕ × ℕ) := by intro Y P L R S letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact corePairs S.cores (Y^(99/100 : ℝ)) Y /- Original line 51098: Erdos416Proof.CoreRecords.rawPair_power_top_eventually -/ theorem rawPair_power_top_eventually : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ (R : ℕ) (A : ℝ), ∀ᶠ Y : ℝ in atTop, ∀ L P (Q : LowerCoreRecord Y L R P), (L : ℝ) ≤ A*Real.log (logLog Y) → ∀ p, p.Prime → Y^(99/100 : ℝ) < (corePairValue (Q.numericalCore,p) : ℝ) → Y^(9/10 : ℝ) < (p : ℝ) ∧ Q.lower ⟨0,Q.length_pos⟩ < p := by intro R A letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact by filter_upwards [record_integer_subpower R A (show (0 : ℝ) < 9/100 by norm_num), record_top_separation_eventually,eventually_gt_atTop (1 : ℝ)] with Y hsmall hsep hY intro L P Q hL p hp hlo have htop : Y^(9/10 : ℝ) < (p : ℝ) := by by_contra hnot have hpY : (p : ℝ) ≤ Y^(9/10 : ℝ) := le_of_not_gt hnot have hcore : (Q.numericalCore : ℝ) ≤ Q.integer := by rw [← Q.integer_totient] exact_mod_cast Nat.totient_le Q.integer have hvalue : (corePairValue (Q.numericalCore,p) : ℝ) ≤ (p : ℝ)*Q.integer := by simp only [corePairValue,Nat.cast_mul] exact mul_le_mul (by exact_mod_cast Nat.sub_le p 1) hcore (Nat.cast_nonneg _) (Nat.cast_nonneg _) have hbound := mul_le_mul hpY (hsmall L P Q hL) (Nat.cast_nonneg _) (Real.rpow_nonneg (by linarith : 0 ≤ Y) _) have he : Y^(9/10 : ℝ)*Y^(9/100 : ℝ) = Y^(99/100 : ℝ) := by rw [← Real.rpow_add (by linarith : 0 < Y)] norm_num rw [he] at hbound exact (not_lt_of_ge (hvalue.trans hbound)) hlo refine ⟨htop,?_⟩ rw [← Q.largest_eq_first] exact hsep L R P Q p htop namespace CoreSelection /- Original line 51128: Erdos416Proof.CoreRecords.CoreSelection.powerRawPairs_toTuple_eventually -/ theorem powerRawPairs_toTuple_eventually : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ (R : ℕ) (A : ℝ), ∀ᶠ Y : ℝ in atTop, ∀ L P (S : CoreSelection Y L R P), (L : ℝ) ≤ A*Real.log (logLog Y) → ∀ bp ∈ powerRawPairs S, ∀ hb : bp.1 ∈ S.cores, Rigidity.Tuple Y P (6/5) (4/5) (S.record ⟨bp.1,hb⟩).tail (bp.2*∏ idx,(S.record ⟨bp.1,hb⟩).lower idx) ((S.record ⟨bp.1,hb⟩).fullPrimes bp.2) := by intro R A letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact by filter_upwards [rawPair_power_top_eventually R A,eventually_ge_atTop (0 : ℝ)] with Y htop hY intro L P S hL bp hbp hb have hm := (Erdos416Proof.mem_corePairs hY S.cores_pos).mp hbp have hv : corePairValue ((S.record ⟨bp.1,hb⟩).numericalCore,bp.2) = corePairValue bp := by rw [S.core_eq] have hg := htop L P (S.record ⟨bp.1,hb⟩) hL bp.2 hm.2.1 (by simpa only [hv] using hm.2.2.1) exact (S.record ⟨bp.1,hb⟩).toTuple hm.2.1 hg.2 hg.1 (by simpa only [hv] using hm.2.2.2) /- Original line 51144: Erdos416Proof.CoreRecords.CoreSelection.powerRawPairs_actual_eventually -/ theorem powerRawPairs_actual_eventually : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ (R : ℕ) (A : ℝ), ∀ᶠ Y : ℝ in atTop, ∀ L P (S : CoreSelection Y L R P), (L : ℝ) ≤ A*Real.log (logLog Y) → (∀ bp ∈ powerRawPairs S, 0 < S.actualInteger bp ∧ (S.actualInteger bp).totient = corePairValue bp ∧ corePairValue bp ∈ totientsUpTo Y) ∧ Set.InjOn S.actualInteger (powerRawPairs S : Set (ℕ × ℕ)) := by intro R A letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact by filter_upwards [rawPair_power_top_eventually R A,eventually_ge_atTop (0 : ℝ)] with Y htop hY intro L P S hL have hsep : ∀ bp ∈ powerRawPairs S, ∀ hb : bp.1 ∈ S.cores, largestPrimeFactor (S.record ⟨bp.1,hb⟩).integer < bp.2 := by intro bp hbp hb have hm := (Erdos416Proof.mem_corePairs hY S.cores_pos).mp hbp have hg := htop L P (S.record ⟨bp.1,hb⟩) hL bp.2 hm.2.1 (by simpa only [S.core_eq] using hm.2.2.1) simpa only [LowerCoreRecord.largest_eq_first] using hg.2 refine ⟨?_,S.actualInteger_injective hY hsep⟩ intro bp hbp have hm := (Erdos416Proof.mem_corePairs hY S.cores_pos).mp hbp obtain ⟨hN,hφ⟩ := S.actualInteger_totient hm.1 hm.2.1 (hsep bp hbp hm.1) exact ⟨hN,hφ,(mem_totientsUpTo hY).mpr ⟨corePairValue_pos (S.cores_pos _ hm.1) hm.2.1,hm.2.2.2,S.actualInteger bp,hN,hφ⟩⟩ end CoreSelection end Erdos416Proof.CoreRecords namespace Erdos416Proof /- Original line 51172: Erdos416Proof.power_corePairs_count_asymptotic -/ theorem power_corePairs_count_asymptotic : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ {C : ℝ → Finset ℕ} {G : ℝ → ℝ} (hG : Tendsto (fun y => G y/Real.log y) atTop (nhds 0)) (hC : ∀ᶠ y in atTop, ∀ b ∈ C y, 0 < b ∧ Real.log b ≤ G y) (hn : ∀ᶠ y in atTop, (C y).Nonempty) {t : ℝ} (ht : 0 < t), Tendsto (fun y => ((corePairs (C y) (y^(99/100 : ℝ)) (t*y)).card : ℝ)/ corePrimeMass (C y) y) atTop (nhds t) := by intro C G hG hC hn t ht letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact by have hs := tendsto_rpow_neg_atTop (show (0 : ℝ) < 1/100 by norm_num) have h := corePairs_count_asymptotic hG hs ((eventually_ge_atTop (0 : ℝ)).mono (fun y hy => Real.rpow_nonneg hy _)) hC hn ht apply h.congr' filter_upwards [eventually_gt_atTop (0 : ℝ)] with y hy have he : y^(-(1/100 : ℝ))*y = y^(99/100 : ℝ) := by calc _ = y^(-(1/100 : ℝ))*y^(1 : ℝ) := by rw [Real.rpow_one] _ = _ := by rw [← Real.rpow_add hy]; norm_num rw [he] /- Original line 51189: Erdos416Proof.power_corePairs_card_eventually_pos -/ theorem power_corePairs_card_eventually_pos : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ {C : ℝ → Finset ℕ} {G : ℝ → ℝ} (hG : Tendsto (fun y => G y/Real.log y) atTop (nhds 0)) (hC : ∀ᶠ y in atTop, ∀ b ∈ C y, 0 < b ∧ Real.log b ≤ G y) (hn : ∀ᶠ y in atTop, (C y).Nonempty), ∀ᶠ y in atTop, (0 : ℝ) < (corePairs (C y) (y^(99/100 : ℝ)) y).card := by intro C G hG hC hn letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact by have h := power_corePairs_count_asymptotic hG hC hn (show (0 : ℝ) < 1 by norm_num) filter_upwards [h.eventually (lt_mem_nhds (show (0 : ℝ) < 1 by norm_num)), hC,hn,eventually_gt_atTop (1 : ℝ)] with y hy hCy hny hy1 simp only [one_mul] at hy exact (div_pos_iff.mp hy).resolve_right (fun hneg => (not_lt_of_ge (Nat.cast_nonneg _)) hneg.1) |>.1 /- Original line 51201: Erdos416Proof.power_corePairs_imbalance_negligible -/ theorem power_corePairs_imbalance_negligible : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ {C : ℝ → Finset ℕ} {G : ℝ → ℝ} (hG : Tendsto (fun y => G y/Real.log y) atTop (nhds 0)) (hC : ∀ᶠ y in atTop, ∀ b ∈ C y, 0 < b ∧ Real.log b ≤ G y) (hn : ∀ᶠ y in atTop, (C y).Nonempty), (fun y => ((corePairs (C y) (y^(99/100 : ℝ)) y).card : ℝ) - 2*((corePairs (C y) (y^(99/100 : ℝ)) (y/2)).card : ℝ)) =o[atTop] (fun y => ((corePairs (C y) (y^(99/100 : ℝ)) y).card : ℝ)) := by intro C G hG hC hn letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact by have h₁ := power_corePairs_count_asymptotic hG hC hn (show (0 : ℝ) < 1 by norm_num) have h₂ := power_corePairs_count_asymptotic hG hC hn (show (0 : ℝ) < 1/2 by norm_num) have hp := power_corePairs_card_eventually_pos hG hC hn have hratio : Tendsto (fun y => ((corePairs (C y) (y^(99/100 : ℝ)) (y/2)).card : ℝ)/ ((corePairs (C y) (y^(99/100 : ℝ)) y).card : ℝ)) atTop (nhds (1/2)) := by have h := h₂.div h₁ (by norm_num : (1 : ℝ) ≠ 0) simp only [one_mul,div_one] at h apply h.congr' filter_upwards [hC,hn,eventually_gt_atTop (1 : ℝ)] with y hCy hny hy have hm := (corePrimeMass_pos (fun b hb => (hCy b hb).1) hny hy).ne' change (((corePairs (C y) (y^(99/100 : ℝ)) (1/2*y)).card : ℝ)/corePrimeMass (C y) y)/ (((corePairs (C y) (y^(99/100 : ℝ)) y).card : ℝ)/corePrimeMass (C y) y) = _ simpa only [one_div,inv_mul_eq_div] using (div_div_div_cancel_right₀ hm ((corePairs (C y) (y^(99/100 : ℝ)) (1/2*y)).card : ℝ) ((corePairs (C y) (y^(99/100 : ℝ)) y).card : ℝ)) apply (isLittleO_iff_tendsto' (hp.mono fun y hy hz => (hy.ne' hz).elim)).mpr have h := (tendsto_const_nhds : Tendsto (fun _ : ℝ => (1 : ℝ)) atTop (nhds 1)).sub (hratio.const_mul 2) have hz : (1 : ℝ)-2*(1/2)=0 := by norm_num rw [hz] at h apply h.congr' filter_upwards [hp] with y hy field_simp [hy.ne'] /- Original line 51235: Erdos416Proof.corePairs_filter_totients -/ theorem corePairs_filter_totients : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ {C : Finset ℕ} {lo Y : ℝ} (hY : 0 ≤ Y) (hC : ∀ b ∈ C, 0 < b) (hmap : ∀ bp ∈ corePairs C lo Y, corePairValue bp ∈ totientsUpTo Y), (corePairs C lo Y).filter (fun bp => corePairValue bp ∈ totientsUpTo (Y/2)) = corePairs C lo (Y/2) := by intro C lo Y hY hC hmap letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact by have hh : 0 ≤ Y/2 := by positivity apply Finset.ext intro bp constructor · intro hb obtain ⟨hb,hsmall⟩ := Finset.mem_filter.mp hb have hm := (mem_corePairs hY hC).mp hb exact (mem_corePairs hh hC).mpr ⟨hm.1,hm.2.1,hm.2.2.1,((mem_totientsUpTo hh).mp hsmall).2.1⟩ · intro hb have hm := (mem_corePairs hh hC).mp hb have hlarge : bp ∈ corePairs C lo Y := (mem_corePairs hY hC).mpr ⟨hm.1,hm.2.1,hm.2.2.1,hm.2.2.2.trans (by linarith)⟩ have hv := (mem_totientsUpTo hY).mp (hmap bp hlarge) exact Finset.mem_filter.mpr ⟨hlarge,(mem_totientsUpTo hh).mpr ⟨hv.1,hm.2.2.2,hv.2.2⟩⟩ namespace CoreRecords.CoreSelection /- Original line 51258: Erdos416Proof.CoreRecords.CoreSelection.powerRawPairs_imbalance_negligible -/ theorem powerRawPairs_imbalance_negligible : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ {R : ℕ} {P A : ℝ} {L : ℝ → ℕ} (S : ∀ Y : ℝ, CoreSelection Y (L Y) R P) (hL : ∀ᶠ Y in atTop, (L Y : ℝ) ≤ A*Real.log (logLog Y)) (hn : ∀ᶠ Y in atTop, (S Y).cores.Nonempty), (fun Y => ((powerRawPairs (S Y)).card : ℝ) - 2*(((powerRawPairs (S Y)).filter (fun bp => corePairValue bp ∈ totientsUpTo (Y/2))).card : ℝ)) =o[atTop] (fun Y => ((powerRawPairs (S Y)).card : ℝ)) := by intro R P A L S hL hn letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact by have hC : ∀ᶠ Y in atTop, ∀ b ∈ (S Y).cores, 0 < b ∧ Real.log b ≤ logCoreBound R A (4/5) Y := by filter_upwards [hL,eventually_gt_atTop (1 : ℝ)] with Y hLY hY intro b hb refine ⟨(S Y).cores_pos b hb,?_⟩ have h := ((S Y).record ⟨b,hb⟩).log_numericalCore_le hY hLY simpa only [(S Y).core_eq] using h have h := Erdos416Proof.power_corePairs_imbalance_negligible (logCoreBound_small R A (show (4/5 : ℝ) < 1 by norm_num)) hC hn apply h.congr' _ (Eventually.of_forall fun _ => rfl) filter_upwards [powerRawPairs_actual_eventually R A,hL,eventually_ge_atTop (0 : ℝ)] with Y hactual hLY hY have hmap := (hactual (L Y) P (S Y) hLY).1 have he := corePairs_filter_totients hY (S Y).cores_pos (fun bp hb => (hmap bp hb).2.2) change _ = ((powerRawPairs (S Y)).card : ℝ) - _ rw [powerRawPairs,he] end CoreRecords.CoreSelection end Erdos416Proof end /- Consolidated component: CorePairCollisions.lean. -/ section open Filter Finset Asymptotics open scoped Classical Topology BigOperators namespace Erdos416Proof.CoreRecords.CoreSelection variable {Y P : ℝ} {L R : ℕ} (S : CoreSelection Y L R P) /- Original line 51302: Erdos416Proof.CoreRecords.CoreSelection.mem_rawCollisionPoints -/ theorem mem_rawCollisionPoints : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ {F : Finset (ℕ × ℕ)} {a : ℕ × ℕ}, a ∈ collisionPoints F corePairValue ↔ a ∈ F ∧ ∃ b ∈ F,b ≠ a ∧ corePairValue b = corePairValue a := by intro F a letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact by simp only [collisionPoints,Finset.mem_filter] /- Original line 51307: Erdos416Proof.CoreRecords.CoreSelection.selectedTail -/ noncomputable def selectedTail : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ (bp : ℕ × ℕ), ℕ := by intro bp letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact if hb : bp.1 ∈ S.cores then (S.record ⟨bp.1,hb⟩).tail else 0 /- Original line 51310: Erdos416Proof.CoreRecords.CoreSelection.selectedProduct -/ noncomputable def selectedProduct : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ (bp : ℕ × ℕ), ℕ := by intro bp letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact if hb : bp.1 ∈ S.cores then bp.2*∏ idx,(S.record ⟨bp.1,hb⟩).lower idx else 0 /- Original line 51313: Erdos416Proof.CoreRecords.CoreSelection.selectedPrimes -/ noncomputable def selectedPrimes : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ (bp : ℕ × ℕ), Fin (L+1) → ℕ := by intro bp letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact if hb : bp.1 ∈ S.cores then (S.record ⟨bp.1,hb⟩).fullPrimes bp.2 else fun _ => 1 /- Original line 51316: Erdos416Proof.CoreRecords.CoreSelection.selectedTail_apply -/ theorem selectedTail_apply : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ {bp : ℕ × ℕ} (hb : bp.1 ∈ S.cores), S.selectedTail bp = (S.record ⟨bp.1,hb⟩).tail := by intro bp hb letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact dif_pos hb /- Original line 51319: Erdos416Proof.CoreRecords.CoreSelection.selectedProduct_apply -/ theorem selectedProduct_apply : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ {bp : ℕ × ℕ} (hb : bp.1 ∈ S.cores), S.selectedProduct bp = bp.2*∏ idx,(S.record ⟨bp.1,hb⟩).lower idx := by intro bp hb letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact dif_pos hb /- Original line 51322: Erdos416Proof.CoreRecords.CoreSelection.selectedPrimes_apply -/ theorem selectedPrimes_apply : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ {bp : ℕ × ℕ} (hb : bp.1 ∈ S.cores), S.selectedPrimes bp = (S.record ⟨bp.1,hb⟩).fullPrimes bp.2 := by intro bp hb letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact dif_pos hb /- Original line 51325: Erdos416Proof.CoreRecords.CoreSelection.selectedPrimes_zero -/ theorem selectedPrimes_zero : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ {bp : ℕ × ℕ} (hb : bp.1 ∈ S.cores), S.selectedPrimes bp 0 = bp.2 := by intro bp hb letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact by rw [S.selectedPrimes_apply hb]; rfl /- Original line 51328: Erdos416Proof.CoreRecords.CoreSelection.actualInteger_selected -/ theorem actualInteger_selected : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ {bp : ℕ × ℕ} (hb : bp.1 ∈ S.cores), S.actualInteger bp = S.selectedTail bp*S.selectedProduct bp := by intro bp hb letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact by rw [S.actualInteger_apply hb,S.selectedTail_apply hb,S.selectedProduct_apply hb] simp only [LowerCoreRecord.integer,mul_left_comm] /- Original line 51333: Erdos416Proof.CoreRecords.CoreSelection.selectedTail_mem -/ theorem selectedTail_mem : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ {bp : ℕ × ℕ} (hb : bp.1 ∈ S.cores), S.selectedTail bp ∈ Finset.Icc 1 R := by intro bp hb letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact by rw [S.selectedTail_apply hb] exact Finset.mem_Icc.mpr ⟨(S.record ⟨bp.1,hb⟩).tail_pos,(S.record ⟨bp.1,hb⟩).tail_le⟩ /- Original line 51338: Erdos416Proof.CoreRecords.CoreSelection.collisionTailPairs -/ noncomputable def collisionTailPairs : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ (F : Finset (ℕ × ℕ)) (r : ℕ), Finset (ℕ × ℕ) := by intro F r letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact (collisionPoints F corePairValue).filter (fun bp => S.selectedTail bp = r) /- Original line 51341: Erdos416Proof.CoreRecords.CoreSelection.collisionTailProducts -/ noncomputable def collisionTailProducts : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ (F : Finset (ℕ × ℕ)) (r : ℕ), Finset ℕ := by intro F r letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact (S.collisionTailPairs F r).image S.selectedProduct /- Original line 51344: Erdos416Proof.CoreRecords.CoreSelection.collisionTailPairs_mem -/ theorem collisionTailPairs_mem : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ {F : Finset (ℕ × ℕ)} {r : ℕ} {bp : ℕ × ℕ} (hb : bp ∈ S.collisionTailPairs F r), bp ∈ F ∧ S.selectedTail bp = r := by intro F r bp hb letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact by exact ⟨(mem_rawCollisionPoints.mp (Finset.mem_filter.mp hb).1).1,(Finset.mem_filter.mp hb).2⟩ /-- One raw collision class, after fixing its retained tail, is precisely a witnessed family to which the complete fixed-tail rigidity theorem applies. -/ /- Original line 51350: Erdos416Proof.CoreRecords.CoreSelection.collisionTailProducts_count -/ theorem collisionTailProducts_count : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ {F : Finset (ℕ × ℕ)} {r : ℕ} {B : ℝ} (hmem : ∀ bp ∈ F, bp.1 ∈ S.cores ∧ bp.2.Prime) (htuple : ∀ bp ∈ F, Rigidity.Tuple Y P (6/5) (4/5) (S.selectedTail bp) (S.selectedProduct bp) (S.selectedPrimes bp)) (hactual : ∀ bp ∈ F, 0 < S.actualInteger bp ∧ (S.actualInteger bp).totient = corePairValue bp) (hcount : ∀ (G : Finset ℕ) (p : ℕ → Fin (L+1) → ℕ), (∀ n ∈ G, Rigidity.Tuple Y P (6/5) (4/5) r n (p n)) → (∀ n ∈ G, ∀ m ∈ G, (∏ idx : Fin L,(p n idx.succ-1)) = (∏ idx : Fin L,(p m idx.succ-1)) → ∀ idx : Fin L,p n idx.succ = p m idx.succ) → (∀ n ∈ G, ∃ N : ℕ,0 1 have hp (n : ℕ) (hn : n ∈ G) : p n = S.selectedPrimes (pick n hn) := dif_pos hn apply hcount G p · intro n hn have hnr := S.collisionTailPairs_mem (hpick n hn).1 simpa only [hp n hn,hnr.2,(hpick n hn).2] using htuple (pick n hn) hnr.1 · intro n hn m hm he idx have hnr := S.collisionTailPairs_mem (hpick n hn).1 have hmr := S.collisionTailPairs_mem (hpick m hm).1 have hnc := (hmem (pick n hn) hnr.1).1 have hmc := (hmem (pick m hm) hmr.1).1 have hr : (S.record ⟨(pick n hn).1,hnc⟩).tail = (S.record ⟨(pick m hm).1,hmc⟩).tail := by rw [← S.selectedTail_apply hnc,← S.selectedTail_apply hmc,hnr.2,hmr.2] have hprod : (∏ j,((S.record ⟨(pick n hn).1,hnc⟩).lower j-1)) = ∏ j,((S.record ⟨(pick m hm).1,hmc⟩).lower j-1) := by simpa only [hp n hn,hp m hm,S.selectedPrimes_apply hnc,S.selectedPrimes_apply hmc, LowerCoreRecord.fullPrimes,Fin.cons_succ] using he have hrecord := congrArg S.record (S.equal_tail_shifted_product hr hprod) simpa only [hp n hn,hp m hm,S.selectedPrimes_apply hnc,S.selectedPrimes_apply hmc, LowerCoreRecord.fullPrimes,Fin.cons_succ] using congrArg (fun Q => Q.lower idx) hrecord · intro n hn let a := pick n hn have ha := S.collisionTailPairs_mem (hpick n hn).1 have hc : a ∈ collisionPoints F corePairValue := (Finset.mem_filter.mp (hpick n hn).1).1 obtain ⟨b,hb,hba,hvalue⟩ := (mem_rawCollisionPoints.mp hc).2 have hac := (hmem a ha.1).1 have hbc := (hmem b hb).1 have htailb : 0 < S.selectedTail b := (Finset.mem_Icc.mp (S.selectedTail_mem hbc)).1 have htaila : 0 < S.selectedTail a := (Finset.mem_Icc.mp (S.selectedTail_mem hac)).1 have hlargest : largestPrimeFactor (S.actualInteger b) = b.2 := by rw [S.actualInteger_selected hbc,(htuple b hb).canonical_largest htailb,S.selectedPrimes_zero hbc] refine ⟨S.actualInteger b,(hactual b hb).1,?_,?_⟩ · calc (S.actualInteger b).totient = corePairValue b := (hactual b hb).2 _ = corePairValue a := hvalue _ = (S.actualInteger a).totient := (hactual a ha.1).2.symm _ = (S.selectedTail a).totient*(S.selectedProduct a).totient := by rw [S.actualInteger_selected hac,(htuple a ha.1).canonical_totient htaila] _ = r.totient*n.totient := by rw [ha.2,(hpick n hn).2] · rw [hlargest,hp n hn,S.selectedPrimes_zero hac] exact corePair_distinct_primes_of_collision (hmem b hb).2 hba hvalue /- Original line 51414: Erdos416Proof.CoreRecords.CoreSelection.collision_points_card_le_sum_tailProducts -/ theorem collision_points_card_le_sum_tailProducts : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ {F : Finset (ℕ × ℕ)} (hmem : ∀ bp ∈ F,bp.1 ∈ S.cores) (hinj : Set.InjOn S.actualInteger (F : Set (ℕ × ℕ))), (collisionPoints F corePairValue).card ≤ ∑ r ∈ Finset.Icc 1 R,(S.collisionTailProducts F r).card := by intro F hmem hinj letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact by let G := (Finset.Icc 1 R).sigma (S.collisionTailProducts F) have hcard : (collisionPoints F corePairValue).card ≤ G.card := by apply Finset.card_le_card_of_injOn (fun bp => (⟨S.selectedTail bp,S.selectedProduct bp⟩ : Σ _ : ℕ,ℕ)) · intro bp hbp have hb := (mem_rawCollisionPoints.mp hbp).1 exact Finset.mem_sigma.mpr ⟨S.selectedTail_mem (hmem bp hb), Finset.mem_image.mpr ⟨bp,Finset.mem_filter.mpr ⟨hbp,rfl⟩,rfl⟩⟩ · intro a ha b hb he have haF := (mem_rawCollisionPoints.mp ha).1 have hbF := (mem_rawCollisionPoints.mp hb).1 apply hinj haF hbF rw [S.actualInteger_selected (hmem a haF),S.actualInteger_selected (hmem b hbF)] have ht : S.selectedTail a = S.selectedTail b := congrArg Sigma.fst he have hp : S.selectedProduct a = S.selectedProduct b := congrArg Sigma.snd he exact congrArg₂ Nat.mul ht hp simpa only [G,Finset.card_sigma] using hcard /-- Raw collisions are controlled directly; the invoked rigidity theorem already includes all normality and square exceptional families. -/ /- Original line 51438: Erdos416Proof.CoreRecords.CoreSelection.powerRawPairs_collisions_bound -/ theorem powerRawPairs_collisions_bound : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ (R : ℕ) (P A : ℝ) (hA : 0 < A), ∀ᶠ Y : ℝ in atTop,∀ L (S : CoreSelection Y L R P), (L : ℝ) ≤ A*Real.log (logLog Y) → ((collisionPoints (powerRawPairs S) corePairValue).card : ℝ) ≤ 4*R*(Y/(Real.log Y*(logLog Y)^2)) := by intro R P A hA letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact by have hfixed : ∀ᶠ Y : ℝ in atTop,∀ r ∈ Finset.Icc 1 R, ∀ (L : ℕ) (F : Finset ℕ) (p : ℕ → Fin (L+1) → ℕ), (L : ℝ) ≤ A*Real.log (logLog Y) → (∀ n ∈ F,Rigidity.Tuple Y P (6/5) (4/5) r n (p n)) → (∀ n ∈ F,∀ m ∈ F, (∏ idx : Fin L,(p n idx.succ-1))=(∏ idx : Fin L,(p m idx.succ-1)) → ∀ idx : Fin L,p n idx.succ=p m idx.succ) → (∀ n ∈ F,∃ N : ℕ,0 ⟨(hactual L P S hL).1 bp hbp |>.1,(hactual L P S hL).1 bp hbp |>.2.1⟩ have hc (r : ℕ) (hr : r ∈ Finset.Icc 1 R) : ((S.collisionTailProducts (powerRawPairs S) r).card : ℝ) ≤ 4*(Y/(Real.log Y*(logLog Y)^2)) := S.collisionTailProducts_count hm ht ha (fun G p => hfixed r hr L G p hL) have hcard := S.collision_points_card_le_sum_tailProducts (fun bp hbp => (hm bp hbp).1) (hactual L P S hL).2 calc _ ≤ ∑ r ∈ Finset.Icc 1 R,((S.collisionTailProducts (powerRawPairs S) r).card : ℝ) := by exact_mod_cast hcard _ ≤ ∑ _r ∈ Finset.Icc 1 R,4*(Y/(Real.log Y*(logLog Y)^2)) := Finset.sum_le_sum hc _ = _ := by simp only [Finset.sum_const,Nat.card_Icc,Nat.add_sub_cancel,nsmul_eq_mul]; ring /- Original line 51483: Erdos416Proof.CoreRecords.CoreSelection.powerRawPairs_collisions_negligible -/ theorem powerRawPairs_collisions_negligible : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ {R : ℕ} {P A : ℝ} {L : ℝ → ℕ} (hA : 0 < A) (S : ∀ Y : ℝ,CoreSelection Y (L Y) R P) (hL : ∀ᶠ Y in atTop,(L Y : ℝ) ≤ A*Real.log (logLog Y)), (fun Y => ((collisionPoints (powerRawPairs (S Y)) corePairValue).card : ℝ)) =o[atTop] V := by intro R P A L hA S hL letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact by rw [isLittleO_iff] intro ε hε have hT : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [powerRawPairs_collisions_bound R P A hA,hL,V_lower_bound_eventually, hT.eventually_ge_atTop (max 1 (8*(R : ℝ)/ε)),eventually_gt_atTop (1 : ℝ)] with Y hcount hLY hV hTlarge hY have hT1 : 1 ≤ logLog Y := (le_max_left _ _).trans hTlarge have hTq : 8*(R : ℝ)/ε ≤ logLog Y := (le_max_right _ _).trans hTlarge have hTp : 0 < logLog Y := by linarith have hTs : 0 < (logLog Y)^2 := sq_pos_of_pos hTp have hlog : 0 < Real.log Y := Real.log_pos hY have hY0 : 0 < Y := by linarith have hcoeff : 4*(R : ℝ)/(logLog Y)^2 ≤ ε/2 := by apply (div_le_iff₀ hTs).mpr have he := (div_le_iff₀ hε).mp hTq have hsq : logLog Y ≤ (logLog Y)^2 := by nlinarith have := mul_le_mul_of_nonneg_right hsq hε.le nlinarith have hV' : Y/Real.log Y ≤ 2*V Y := by apply (div_le_iff₀ hlog).mpr have hv := (div_le_iff₀ (by positivity : 0 < 2*Real.log Y)).mp hV nlinarith simp only [Real.norm_eq_abs,abs_of_nonneg (Nat.cast_nonneg _ : (0 : ℝ) ≤ (collisionPoints (powerRawPairs (S Y)) corePairValue).card),abs_of_nonneg (V_nonneg Y)] calc _ ≤ 4*R*(Y/(Real.log Y*(logLog Y)^2)) := hcount (L Y) (S Y) hLY _ = (4*(R : ℝ)/(logLog Y)^2)*(Y/Real.log Y) := by field_simp _ ≤ (ε/2)*(2*V Y) := mul_le_mul hcoeff hV' (div_nonneg hY0.le hlog.le) (by positivity) _ = ε*V Y := by ring end Erdos416Proof.CoreRecords.CoreSelection end /- Consolidated component: CoreCoverageCount.lean. -/ section open Filter Asymptotics Finset open scoped Classical Topology BigOperators namespace Erdos416Proof.FordBadFacet open FordReciprocal FordScale FordGeometry /- Original line 51536: Erdos416Proof.FordBadFacet.coreCoverageExceptions -/ noncomputable def coreCoverageExceptions : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ (x : ℝ) (H M : ℕ) (P_D P_L : ℝ) (R : ℕ), Finset ℕ := by intro x H M P_D P_L R letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact firstFailedExceptionalValues x (optimalDimension (logLog x)) ∪ polytopeFailureValues x (coreDimension H (logLog x)) (expandedParameter (optimalDimension (logLog x))) ∪ largeTerminalValues x H P_D ∪ smoothConcentrationValues x H (M-H-1) P_D ∪ smoothOuterShellValues x H P_D ∪ largeSmoothResidualValues x M P_L (R : ℝ) /- Original line 51545: Erdos416Proof.FordBadFacet.not_mem_coreCoverageExceptions -/ theorem not_mem_coreCoverageExceptions : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ {x P_D P_L : ℝ} {H M R m : ℕ}, m ∉ coreCoverageExceptions x H M P_D P_L R ↔ m ∉ firstFailedExceptionalValues x (optimalDimension (logLog x)) ∧ m ∉ polytopeFailureValues x (coreDimension H (logLog x)) (expandedParameter (optimalDimension (logLog x))) ∧ m ∉ largeTerminalValues x H P_D ∧ m ∉ smoothConcentrationValues x H (M-H-1) P_D ∧ m ∉ smoothOuterShellValues x H P_D ∧ m ∉ largeSmoothResidualValues x M P_L (R : ℝ) := by intro x P_D P_L H M R m letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact by simp only [coreCoverageExceptions, Finset.mem_union, not_or, and_assoc] /- Original line 51556: Erdos416Proof.FordBadFacet.largeTerminalValues_antitone_cutoff -/ theorem largeTerminalValues_antitone_cutoff : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ (x : ℝ) (H : ℕ) {P Q : ℝ} (hPQ : P ≤ Q), largeTerminalValues x H Q ⊆ largeTerminalValues x H P := by intro x H P Q hPQ letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact by intro m hm obtain ⟨hmV, N, hN, hNm, hp, hQ⟩ := Finset.mem_filter.mp hm exact Finset.mem_filter.mpr ⟨hmV, N, hN, hNm, hp, hPQ.trans hQ⟩ /- Original line 51562: Erdos416Proof.FordBadFacet.coreCoverageExceptions_card_le -/ theorem coreCoverageExceptions_card_le : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ (x : ℝ) (H M : ℕ) (P_D P_L : ℝ) (R : ℕ), ((coreCoverageExceptions x H M P_D P_L R).card : ℝ) ≤ ((firstFailedExceptionalValues x (optimalDimension (logLog x))).card : ℝ)+ ((polytopeFailureValues x (coreDimension H (logLog x)) (expandedParameter (optimalDimension (logLog x)))).card : ℝ)+ ((largeTerminalValues x H P_D).card : ℝ)+ ((smoothConcentrationValues x H (M-H-1) P_D).card : ℝ)+ ((smoothOuterShellValues x H P_D).card : ℝ)+ ((largeSmoothResidualValues x M P_L (R : ℝ)).card : ℝ) := by intro x H M P_D P_L R letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact by unfold coreCoverageExceptions have h₁ := Finset.card_union_le (firstFailedExceptionalValues x (optimalDimension (logLog x))) (polytopeFailureValues x (coreDimension H (logLog x)) (expandedParameter (optimalDimension (logLog x)))) have h₂ := Finset.card_union_le (firstFailedExceptionalValues x (optimalDimension (logLog x)) ∪ polytopeFailureValues x (coreDimension H (logLog x)) (expandedParameter (optimalDimension (logLog x)))) (largeTerminalValues x H P_D) have h₃ := Finset.card_union_le (firstFailedExceptionalValues x (optimalDimension (logLog x)) ∪ polytopeFailureValues x (coreDimension H (logLog x)) (expandedParameter (optimalDimension (logLog x))) ∪ largeTerminalValues x H P_D) (smoothConcentrationValues x H (M-H-1) P_D) have h₄ := Finset.card_union_le (firstFailedExceptionalValues x (optimalDimension (logLog x)) ∪ polytopeFailureValues x (coreDimension H (logLog x)) (expandedParameter (optimalDimension (logLog x))) ∪ largeTerminalValues x H P_D ∪ smoothConcentrationValues x H (M-H-1) P_D) (smoothOuterShellValues x H P_D) have h₅ := Finset.card_union_le (firstFailedExceptionalValues x (optimalDimension (logLog x)) ∪ polytopeFailureValues x (coreDimension H (logLog x)) (expandedParameter (optimalDimension (logLog x))) ∪ largeTerminalValues x H P_D ∪ smoothConcentrationValues x H (M-H-1) P_D ∪ smoothOuterShellValues x H P_D) (largeSmoothResidualValues x M P_L (R : ℝ)) exact_mod_cast (show _ ≤ _ from by omega : (firstFailedExceptionalValues x (optimalDimension (logLog x)) ∪ polytopeFailureValues x (coreDimension H (logLog x)) (expandedParameter (optimalDimension (logLog x))) ∪ largeTerminalValues x H P_D ∪ smoothConcentrationValues x H (M-H-1) P_D ∪ smoothOuterShellValues x H P_D ∪ largeSmoothResidualValues x M P_L (R : ℝ)).card ≤ (firstFailedExceptionalValues x (optimalDimension (logLog x))).card+ (polytopeFailureValues x (coreDimension H (logLog x)) (expandedParameter (optimalDimension (logLog x)))).card+ (largeTerminalValues x H P_D).card+ (smoothConcentrationValues x H (M-H-1) P_D).card+ (smoothOuterShellValues x H P_D).card+ (largeSmoothResidualValues x M P_L (R : ℝ)).card) /-- All numerical parameters are fixed before the counting endpoint. The retained offset may satisfy any additional eventual condition, and the final terminal bound may be any fixed number at least exp 20. -/ /- Original line 51614: Erdos416Proof.FordBadFacet.actual_core_coverage_exception_bound -/ theorem actual_core_coverage_exception_bound : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ {ε : ℝ} (hε : 0 < ε), ∀ᶠ H : ℕ in atTop, ∃ P_D : ℝ, Real.exp 20 ≤ P_D ∧ ∀ᶠ M : ℕ in atTop, H+2 ≤ M ∧ ∀ P_L : ℝ, Real.exp 20 ≤ P_L → ∃ R : ℕ, 0 < R ∧ ∀ᶠ x : ℝ in atTop, ((coreCoverageExceptions x H M P_D P_L R).card : ℝ) ≤ ε*V x := by intro ε hε letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact by obtain ⟨C, hC, hconc⟩ := exists_smooth_concentration_value_bound have hδ : 0 < ε/6 := by positivity filter_upwards [actual_expanded_polytope_failures_small (ε/6) hδ, exists_fixed_terminal_prime_cutoff, hconc, smooth_outer_shell_values_negligible] with H hpoly hterminal hconc houter obtain ⟨P, hP, hterminal⟩ := hterminal (ε/6) hδ let P_D := max (Real.exp 20) P have hPD : Real.exp 20 ≤ P_D := le_max_left _ _ have hterminal' : ∀ᶠ x : ℝ in atTop, ((largeTerminalValues x H P_D).card : ℝ) ≤ ε/6*V x := by filter_upwards [hterminal] with x hx exact (Nat.cast_le.mpr (Finset.card_le_card (largeTerminalValues_antitone_cutoff x H (le_max_right _ _)))).trans hx obtain ⟨A₀, hA₀⟩ := exists_nat_gt (C*Real.log P_D/(ε/6)) refine ⟨P_D, hPD, ?_⟩ filter_upwards [exists_fixed_nat_smooth_residual_cutoff, eventually_ge_atTop (H+A₀+32962)] with M hres hM refine ⟨by omega, ?_⟩ intro P_L hPL obtain ⟨R, hR, hres⟩ := hres P_L hPL (ε/6) hδ refine ⟨R, hR, ?_⟩ have hA : 32960 ≤ M-H-1 := by omega have hApos : (0 : ℝ) < ((M-H-1 : ℕ) : ℝ) := by exact_mod_cast (show 0 < M-H-1 by omega) have hcoef : C*Real.log P_D/((M-H-1 : ℕ) : ℝ) ≤ ε/6 := by apply (div_le_iff₀ hApos).mpr have h₀ := (div_lt_iff₀ hδ).mp hA₀ have h₁ : (A₀ : ℝ) ≤ ((M-H-1 : ℕ) : ℝ) := by exact_mod_cast (show A₀ ≤ M-H-1 by omega) nlinarith filter_upwards [hpoly, hterminal', hconc, hres, (houter P_D hPD).bound hδ, firstFailedExceptionalValues_negligible_in_V.bound hδ] with x hpoly hterminal hconc hres houter hex have hV : 0 ≤ V x := Nat.cast_nonneg _ have hc : ((smoothConcentrationValues x H (M-H-1) P_D).card : ℝ) ≤ ε/6*V x := (hconc P_D (M-H-1) hPD hA).trans (mul_le_mul_of_nonneg_right hcoef hV) simp only [Real.norm_eq_abs, abs_of_nonneg (show 0 ≤ ((smoothOuterShellValues x H P_D).card : ℝ) from Nat.cast_nonneg _), abs_of_nonneg hV] at houter simp only [Real.norm_eq_abs, abs_of_nonneg (show 0 ≤ ((firstFailedExceptionalValues x (optimalDimension (logLog x))).card : ℝ) from Nat.cast_nonneg _), abs_of_nonneg hV] at hex have hcard := coreCoverageExceptions_card_le x H M P_D P_L R linarith /- Original line 51663: Erdos416Proof.FordBadFacet.ordinarySuffix_comp -/ theorem ordinarySuffix_comp : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ (N j k : ℕ), ordinarySuffix (ordinarySuffix N j) k = ordinarySuffix N (j+k) := by intro N j k letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact by change ((ordinaryPrimeList (ordinarySuffix N j)).drop k).prod = ((ordinaryPrimeList N).drop (j+k)).prod rw [ordinarySuffix_list, List.drop_drop] /- Original line 51669: Erdos416Proof.FordBadFacet.ordinary_residual_smooth_of_terminal_le -/ theorem ordinary_residual_smooth_of_terminal_le : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ {N D : ℕ} {P : ℝ} (hP : (ordinaryPrimeAt N D : ℝ) ≤ P), smoothResidualProperty P (ordinarySuffix (ordinarySuffix N 1) D) := by intro N D P hP letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact by apply ordinarySuffix_factored_of_boundary_le rw [ordinaryPrimeAt_suffix] exact (Nat.cast_le.mpr (ordinaryPrimeAt_antitone N (by omega : D ≤ 1+D))).trans hP /- Original line 51676: Erdos416Proof.FordBadFacet.outside_coreCoverageExceptions_pruning -/ theorem outside_coreCoverageExceptions_pruning : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ {x P_D P_L : ℝ} {H M R m : ℕ} (hx : 0 ≤ x) (hm : m ∈ totientsUpTo x) (hgood : m ∉ coreCoverageExceptions x H M P_D P_L R), Real.sqrt x ≤ (m : ℝ) ∧ m ∉ badFacetValues x 2 (1/1000) ∧ m ∉ fiveLogOmegaTotients x ∧ m ∉ largeSquareTotients x := by intro x P_D P_L H M R m hx hm hgood letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact by have hex := (not_mem_coreCoverageExceptions.mp hgood).1 simp only [firstFailedExceptionalValues, Finset.mem_union, not_or, and_assoc] at hex refine ⟨?_, ?_, ?_, ?_⟩ · by_contra hsmall have hdata := (mem_totientsUpTo hx).mp hm have hmem : m ∈ totientsUpTo (Real.sqrt x) := (mem_totientsUpTo (Real.sqrt_nonneg x)).mpr ⟨hdata.1, (lt_of_not_ge hsmall).le, hdata.2.2⟩ exact hex.1 hmem · exact hex.2.1 · exact hex.2.2.1 · exact hex.2.2.2.1 /- Original line 51694: Erdos416Proof.FordBadFacet.outside_coreCoverageExceptions_top_eventually -/ theorem outside_coreCoverageExceptions_top_eventually : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ᶠ x : ℝ in atTop, ∀ (H M R m N : ℕ) (P_D P_L : ℝ), m ∈ totientsUpTo x → m ∉ coreCoverageExceptions x H M P_D P_L R → 0 < N → N.totient = m → (ordinaryPrimeAt N 0).Prime ∧ Real.log x/6 ≤ Real.log (ordinaryPrimeAt N 0) ∧ ordinaryPrimeAt N 1 < ordinaryPrimeAt N 0 := by letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact by filter_upwards [ordinary_top_log_lower_outside_fixed_facet, eventually_fourth_log_cutoff_lt_large_prime, eventually_ge_atTop (0 : ℝ)] with x htop hcut hx intro H M R m N P_D P_L hm hgood hN hNm obtain ⟨hlarge,hbad,hOmega,hSquare⟩ := outside_coreCoverageExceptions_pruning hx hm hgood obtain ⟨hp,hlog⟩ := htop m N hm hlarge hN hNm hbad hOmega hSquare have hSqN : NoLargePrimeSquare N (Real.log x^4) := by intro q hq hlarge hdiv exact hSquare (Finset.mem_filter.mpr ⟨hm,N,hN,hNm,q,hq,hlarge,Or.inl hdiv⟩) exact ⟨hp,hlog,ordinary_top_gap_of_top_large_square_exclusion hN hcut.1 hSqN (hcut.2 _ hp hlog)⟩ /-- Every actual preimage of a value outside the six counted exceptions has the initial polytope, concentration and outer-facet properties needed by the deterministic ordinary-prime profile construction. -/ /- Original line 51713: Erdos416Proof.FordBadFacet.outside_coreCoverageExceptions_initial -/ theorem outside_coreCoverageExceptions_initial : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ {x P_D P_L : ℝ} {H M R m N : ℕ} (hx : 0 ≤ x) (hm : m ∈ totientsUpTo x) (hgood : m ∉ coreCoverageExceptions x H M P_D P_L R) (hN : 0 < N) (hNm : N.totient = m), (fun idx : Fin (coreDimension H (logLog x)) => ordinaryPrimeCoordinate (logLog x) N (idx.val+1)) ∈ polytope (coreDimension H (logLog x)) (expandedParameter (optimalDimension (logLog x))) ∧ (ordinaryPrimeAt N (coreDimension H (logLog x)) : ℝ) < P_D ∧ (fun idx : Fin (coreDimension H (logLog x)) => ordinaryPrimeCoordinate (logLog x) N (idx.val+1)) ∉ parameterConcentrationUnion (coreDimension H (logLog x)) (expandedParameter (optimalDimension (logLog x))) (M-H-1) (1/20) ∧ (fun idx : Fin (coreDimension H (logLog x)) => ordinaryPrimeCoordinate (logLog x) N (idx.val+1)) ∉ coreOuterShell H (logLog x) := by intro x P_D P_L H M R m N hx hm hgood hN hNm letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact by have hparts := not_mem_coreCoverageExceptions.mp hgood have hpoly : (fun idx : Fin (coreDimension H (logLog x)) => ordinaryPrimeCoordinate (logLog x) N (idx.val+1)) ∈ polytope (coreDimension H (logLog x)) (expandedParameter (optimalDimension (logLog x))) := by by_contra hbad have hmem : m ∈ polytopeFailureValues x (coreDimension H (logLog x)) (expandedParameter (optimalDimension (logLog x))) := Finset.mem_filter.mpr ⟨hm, N, hN, hNm, hbad⟩ exact hparts.2.1 hmem have hterminal : (ordinaryPrimeAt N (coreDimension H (logLog x)) : ℝ) < P_D := by by_contra hbad have hmem : m ∈ largeTerminalValues x H P_D := Finset.mem_filter.mpr ⟨hm, N, hN, hNm, hpoly, le_of_not_gt hbad⟩ exact hparts.2.2.1 hmem have hsmooth := ordinary_residual_smooth_of_terminal_le hterminal.le obtain ⟨hlarge,hbad,hOmega,hSquare⟩ := outside_coreCoverageExceptions_pruning hx hm hgood refine ⟨hpoly, hterminal, ?_, ?_⟩ · intro hconc have hmem : m ∈ smoothConcentrationValues x H (M-H-1) P_D := Finset.mem_filter.mpr ⟨hm, hlarge, hbad, hOmega, hSquare, N, hN, hNm, hconc, hsmooth⟩ exact hparts.2.2.2.1 hmem · intro houter have hmem : m ∈ smoothOuterShellValues x H P_D := Finset.mem_filter.mpr ⟨hm, hlarge, hbad, hOmega, hSquare, N, hN, hNm, houter, hsmooth⟩ exact hparts.2.2.2.2.1 hmem /- Original line 51751: Erdos416Proof.FordBadFacet.outside_coreCoverageExceptions_residual -/ theorem outside_coreCoverageExceptions_residual : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ {x P_D P_L : ℝ} {H M R m N : ℕ} (hm : m ∈ totientsUpTo x) (hgood : m ∉ coreCoverageExceptions x H M P_D P_L R) (hN : 0 < N) (hNm : N.totient = m) (hpoly : (fun idx : Fin (coreDimension M (logLog x)) => ordinaryPrimeCoordinate (logLog x) N (idx.val+1)) ∈ polytope (coreDimension M (logLog x)) (expandedParameter (optimalDimension (logLog x)))) (hterminal : (ordinaryPrimeAt N (coreDimension M (logLog x)) : ℝ) ≤ P_L), ordinarySuffix N (coreDimension M (logLog x)+1) ≤ R := by intro x P_D P_L H M R m N hm hgood hN hNm hpoly hterminal letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact by have hsmooth := ordinary_residual_smooth_of_terminal_le hterminal have hsmall : (ordinarySuffix (ordinarySuffix N 1) (coreDimension M (logLog x)) : ℝ) < R := by by_contra hlarge have hmem : m ∈ largeSmoothResidualValues x M P_L (R : ℝ) := Finset.mem_filter.mpr ⟨hm, N, hN, hNm, hpoly, le_of_not_gt hlarge, hsmooth⟩ exact (not_mem_coreCoverageExceptions.mp hgood).2.2.2.2.2 hmem rw [ordinarySuffix_comp, Nat.add_comm 1] at hsmall exact_mod_cast hsmall.le end Erdos416Proof.FordBadFacet end /- Consolidated component: CoreCoverageWitness.lean. -/ section open Filter Asymptotics Finset open scoped Classical Topology BigOperators namespace Erdos416Proof.CoreRecords open FordBadFacet FordReciprocal FordScale FordGeometry Simplified /-- A single finite family, at a common retained length and with fixed terminal and residual cutoffs, covers all but arbitrarily few totient values. The explicit power-cutoff loss is retained in the conclusion. -/ /- Original line 51789: Erdos416Proof.CoreRecords.exists_powerRawPairs_fullSelection_coverage -/ theorem exists_powerRawPairs_fullSelection_coverage : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ {ε : ℝ} (hε : 0 < ε), ∃ (M R : ℕ) (P : ℝ), 0 < R ∧ 1 < P ∧ ∀ᶠ y : ℝ in atTop, V y-(((powerRawPairs (CoreSelection.fullSelection y (coreDimension M (logLog y)) R P)).image corePairValue).card : ℝ) ≤ ε*V y+V (y^(99/100 : ℝ)) := by intro ε hε letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact by obtain ⟨H, P_D, hPD, hH⟩ := (actual_core_coverage_exception_bound hε).exists obtain ⟨M, hM, hlower⟩ := (hH.and (ordinary_retained_fixed_lower_eventually H 17)).exists have hHM : H+2 ≤ M := hM.1 let P := terminalPrimeBound H M let P_L := max (Real.exp 20) P have hP : 1 < P := Real.one_lt_exp_iff.mpr (Real.exp_pos _) obtain ⟨R, hR, hcount⟩ := hM.2 P_L (le_max_left _ _) refine ⟨M, R, P, hR, hP, ?_⟩ have hLL : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop filter_upwards [hcount, ordinary_lower_core_conditions_eventually H M hHM, hLL.eventually (ordinary_retained_polytope_eventually H M (by omega)), hLL.eventually (ordinary_retained_profiles_eventually H M hHM), hLL.eventually hlower.2, outside_coreCoverageExceptions_top_eventually, eventually_ge_atTop (1 : ℝ)] with y hcount hconditions hpoly hprofiles hlower htop hy let S := CoreSelection.fullSelection y (coreDimension M (logLog y)) R P let F := powerRangeTotients (99/100) y let E := coreCoverageExceptions y H M P_D P_L R let I := (powerRawPairs S).image corePairValue have hy0 : 0 ≤ y := by linarith have hsub : F ⊆ I ∪ E := by intro m hm by_cases hmE : m ∈ E · exact Finset.mem_union.mpr (Or.inr hmE) apply Finset.mem_union.mpr left obtain ⟨hmV, hmlo⟩ := Finset.mem_filter.mp hm obtain ⟨_, hmhi, N, hN, hNm⟩ := (mem_totientsUpTo hy0).mp hmV obtain ⟨hpoint, _, hconc, hshell⟩ := outside_coreCoverageExceptions_initial hy0 hmV hmE hN hNm have hpointL := hpoly N hpoint have hterminal : (ordinaryPrimeAt N (coreDimension M (logLog y)) : ℝ) ≤ P_L := (hprofiles N hpoint hconc).2.2.trans (le_max_right _ _) have hres := outside_coreCoverageExceptions_residual hmV hmE hN hNm hpointL hterminal have h17 : 17 < ordinaryPrimeAt N (coreDimension M (logLog y)) := by exact_mod_cast hlower N hpoint hconc (coreDimension M (logLog y)) (by omega) have hcore := hconditions N R hpoint hshell hconc h17 hres have hgap := (htop H M R m N P_D P_L hmV hmE hN hNm).2.2 have hpairs : (hcore.record.numericalCore, ordinaryPrimeAt N 0) ∈ powerRawPairs S := by apply hcore.mem_corePairs hN hgap S.cores_pos (CoreSelection.fullSelection_core_mem hcore.record) · simpa only [hNm] using hmlo · simpa only [hNm] using hmhi exact Finset.mem_image.mpr ⟨(hcore.record.numericalCore, ordinaryPrimeAt N 0), hpairs, (hcore.corePair_value hN hgap).trans hNm⟩ have hcard := (Finset.card_le_card hsub).trans (Finset.card_union_le _ _) have hcardR := (Nat.cast_le (α := ℝ)).mpr hcard rw [Nat.cast_add] at hcardR have hdefect := powerRangeTotients_count_defect (show (99/100 : ℝ) ≤ 1 by norm_num) hy change V y-(F.card : ℝ) = V (y^(99/100 : ℝ)) at hdefect change (E.card : ℝ) ≤ ε*V y at hcount change V y-(I.card : ℝ) ≤ ε*V y+V (y^(99/100 : ℝ)) linarith /- Original line 51845: Erdos416Proof.CoreRecords.exists_powerRawPairs_fullSelection_coverage_small -/ theorem exists_powerRawPairs_fullSelection_coverage_small : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ {ε : ℝ} (hε : 0 < ε), ∃ (M R : ℕ) (P : ℝ), 0 < R ∧ 1 < P ∧ ∀ᶠ y : ℝ in atTop, V y-(((powerRawPairs (CoreSelection.fullSelection y (coreDimension M (logLog y)) R P)).image corePairValue).card : ℝ) ≤ ε*V y := by intro ε hε letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact by obtain ⟨M,R,P,hR,hP,hcover⟩ := exists_powerRawPairs_fullSelection_coverage (half_pos hε) refine ⟨M,R,P,hR,hP,?_⟩ filter_upwards [hcover, V_power_cutoff_negligible.bound (half_pos hε)] with y hcover hpower simp only [Real.norm_eq_abs, abs_of_nonneg (V_nonneg _)] at hpower linarith end Erdos416Proof.CoreRecords end /- Consolidated component: PowerCountingEndpoint.lean. -/ section open Filter Finset Asymptotics open scoped Classical Topology BigOperators namespace Erdos416Proof.Simplified /- Original line 51871: Erdos416Proof.Simplified.excess_le_collisionPoints -/ theorem excess_le_collisionPoints : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ {α β : Type*} [DecidableEq β] (Q : Finset α) (f : α → β), (Q.card : ℝ)-(Q.image f).card ≤ (collisionPoints Q f).card := by intro α β _localClass2 Q f letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact by have h := card_le_of_injective_off_bad Q (collisionPoints Q f) (Q.image f) f (fun a ha => Finset.mem_image.mpr ⟨a,ha,rfl⟩) (injective_off_collisionPoints Q f) have hr : (Q.card : ℝ) ≤ (Q.image f).card+(collisionPoints Q f).card := by exact_mod_cast h linarith /-- All excess representations are supported on the actual collision points, without choosing an injective subfamily or deleting raw pairs. -/ /- Original line 51880: Erdos416Proof.Simplified.excess_littleO_of_collisionPoints -/ theorem excess_littleO_of_collisionPoints : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ {α β : Type*} [DecidableEq β] (Q : ℝ → Finset α) (f : ℝ → α → β) (hcollision : (fun y => ((collisionPoints (Q y) (f y)).card : ℝ)) =o[atTop] V), (fun y => ((Q y).card : ℝ)-((Q y).image (f y)).card) =o[atTop] V := by intro α β _localClass2 Q f hcollision letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact by have hdom : (fun y => ((Q y).card : ℝ)-((Q y).image (f y)).card) =O[atTop] (fun y => ((collisionPoints (Q y) (f y)).card : ℝ)) := by apply IsBigO.of_norm_eventuallyLE apply Eventually.of_forall intro y have hnonneg : 0 ≤ ((Q y).card : ℝ)-((Q y).image (f y)).card := by have h : (((Q y).image (f y)).card : ℝ) ≤ (Q y).card := by exact_mod_cast Finset.card_image_le linarith simpa only [Real.norm_eq_abs,abs_of_nonneg hnonneg, abs_of_nonneg (Nat.cast_nonneg _ : (0 : ℝ) ≤ (collisionPoints (Q y) (f y)).card)] using excess_le_collisionPoints (Q y) (f y) exact hdom.trans_isLittleO hcollision /-- Approximate coverage also certifies eventual nonemptiness, which is the only extra input needed by the raw-pair prime-counting asymptotic. -/ /- Original line 51900: Erdos416Proof.Simplified.eventually_nonempty_of_missing_bound -/ theorem eventually_nonempty_of_missing_bound : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ {α : Type*} (Q : ℝ → Finset α) (f : ℝ → α → ℕ) (r : ℝ → ℝ) {ε : ℝ} (hε : ε < 1/2) (hmissing : ∀ᶠ y : ℝ in atTop, V y-((Q y).image (f y)).card ≤ ε*V y+r y) (hr : r =o[atTop] V), ∀ᶠ y : ℝ in atTop, (Q y).Nonempty := by intro α Q f r ε hε hmissing hr letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact by filter_upwards [hmissing,hr.def (by norm_num : (0 : ℝ) < 1/4),eventually_V_pos] with y hmissing hr hV simp only [Real.norm_eq_abs,abs_of_pos hV] at hr by_contra hQ have hzero : Q y = ∅ := Finset.not_nonempty_iff_eq_empty.mp hQ simp only [hzero,Finset.image_empty,Finset.card_empty,Nat.cast_zero,sub_zero] at hmissing have := (le_abs_self (r y)).trans hr nlinarith /-- The raw family may depend on the requested accuracy. Its finite map lands in actual totients, its missing values have arbitrarily small density, and both multiplicity errors and prime-counting imbalance vanish. -/ /- Original line 51917: Erdos416Proof.Simplified.doubling_of_raw_counting_contracts -/ theorem doubling_of_raw_counting_contracts : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ {α : Type*} (hcontracts : ∀ ε : ℝ, 0 < ε → ε < 1/2 → ∃ (Q : ℝ → Finset α) (f : ℝ → α → ℕ) (r : ℝ → ℝ), (∀ᶠ y : ℝ in atTop, (∀ a ∈ Q y, f y a ∈ totientsUpTo y) ∧ V y-((Q y).image (f y)).card ≤ ε*V y+r y) ∧ r =o[atTop] V ∧ (fun y => ((collisionPoints (Q y) (f y)).card : ℝ)) =o[atTop] V ∧ (fun y => ((Q y).card : ℝ)- 2*((Q y).filter (fun a => f y a ∈ totientsUpTo (y/2))).card) =o[atTop] (fun y => ((Q y).card : ℝ))), Tendsto (fun x => V (2*x)/V x) atTop (𝓝 2) := by intro α hcontracts letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact by have htwo : Tendsto (fun x : ℝ => 2*x) atTop atTop := tendsto_id.const_mul_atTop (by norm_num) apply doubling_of_finite_counting_littleO (α := α) intro ε hε hεsmall obtain ⟨Q,f,r,hmap,hr,hcollision,himbalance⟩ := hcontracts ε hε hεsmall refine ⟨fun x => Q (2*x),fun x => f (2*x),fun x => r (2*x), htwo.eventually hmap,hr.comp_tendsto htwo,?_,?_⟩ · simpa only [Function.comp_def] using (excess_littleO_of_collisionPoints Q f hcollision).comp_tendsto htwo · have hhalf (x : ℝ) : 2*x/2 = x := by ring simpa only [Function.comp_def,hhalf] using himbalance.comp_tendsto htwo /-- The checked fixed-power cutoff supplies the entire lower-end error in the final coverage theorem. No regularity of V is assumed here. -/ /- Original line 51943: Erdos416Proof.Simplified.doubling_of_power_raw_counting_contracts -/ theorem doubling_of_power_raw_counting_contracts : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype ∀ {α : Type*} (hcontracts : ∀ ε : ℝ, 0 < ε → ε < 1/2 → ∃ (Q : ℝ → Finset α) (f : ℝ → α → ℕ), (∀ᶠ y : ℝ in atTop, (∀ a ∈ Q y, f y a ∈ totientsUpTo y) ∧ V y-((Q y).image (f y)).card ≤ ε*V y+V (y^(99/100 : ℝ))) ∧ (fun y => ((collisionPoints (Q y) (f y)).card : ℝ)) =o[atTop] V ∧ (fun y => ((Q y).card : ℝ)- 2*((Q y).filter (fun a => f y a ∈ totientsUpTo (y/2))).card) =o[atTop] (fun y => ((Q y).card : ℝ))), Tendsto (fun x => V (2*x)/V x) atTop (𝓝 2) := by intro α hcontracts letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact by apply doubling_of_raw_counting_contracts intro ε hε hεsmall obtain ⟨Q,f,hmap,hcollision,himbalance⟩ := hcontracts ε hε hεsmall exact ⟨Q,f,fun y => V (y^(99/100 : ℝ)),hmap, V_power_cutoff_negligible,hcollision,himbalance⟩ end Erdos416Proof.Simplified end /- Consolidated component: FinalDoubling.lean. -/ section open Filter Finset Asymptotics open scoped Classical Topology BigOperators namespace Erdos416Proof.Simplified open CoreRecords FordScale /-- The full finite record families give the doubling law for distinct totient values after their collision and prime-counting errors vanish. -/ /- Original line 51980: Erdos416Proof.Simplified.doubling_limit -/ theorem doubling_limit : letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype Tendsto (fun x => V (2*x)/V x) atTop (𝓝 2) := by letI := @_root_.Erdos416Proof.CoreRecords.LowerCoreRecord.instFintype exact by apply doubling_of_power_raw_counting_contracts (α := ℕ × ℕ) intro ε hε hεsmall obtain ⟨M,R,P,_,_,hcoverage⟩ := exists_powerRawPairs_fullSelection_coverage hε let L : ℝ → ℕ := fun y => coreDimension M (logLog y) let S : ∀ y : ℝ, CoreSelection y (L y) R P := fun y => CoreSelection.fullSelection y (L y) R P let Q : ℝ → Finset (ℕ × ℕ) := fun y => powerRawPairs (S y) change ∀ᶠ y : ℝ in atTop, V y-((Q y).image corePairValue).card ≤ ε*V y+V (y^(99/100 : ℝ)) at hcoverage have hLL : Tendsto logLog atTop atTop := Real.tendsto_log_atTop.comp Real.tendsto_log_atTop have hL : ∀ᶠ y : ℝ in atTop, (L y : ℝ) ≤ 4*Real.log (logLog y) := by filter_upwards [hLL.eventually_ge_atTop (Real.exp 1)] with y hy exact coreDimension_le_four_log M hy have hactual : ∀ᶠ y : ℝ in atTop, ∀ bp ∈ Q y, corePairValue bp ∈ totientsUpTo y := by filter_upwards [CoreSelection.powerRawPairs_actual_eventually R 4,hL] with y hy hLy intro bp hbp exact ((hy (L y) P (S y) hLy).1 bp hbp).2.2 have hnonemptyQ : ∀ᶠ y : ℝ in atTop, (Q y).Nonempty := eventually_nonempty_of_missing_bound Q (fun _ => corePairValue) (fun y => V (y^(99/100 : ℝ))) hεsmall hcoverage V_power_cutoff_negligible have hnonemptyS : ∀ᶠ y : ℝ in atTop, (S y).cores.Nonempty := by filter_upwards [hnonemptyQ,eventually_ge_atTop (0 : ℝ)] with y hy hy0 obtain ⟨bp,hbp⟩ := hy exact ⟨bp.1,((mem_corePairs hy0 (S y).cores_pos).mp hbp).1⟩ refine ⟨Q,fun _ => corePairValue,hactual.and hcoverage,?_,?_⟩ · exact CoreSelection.powerRawPairs_collisions_negligible (by norm_num : (0 : ℝ) < 4) S hL · exact CoreSelection.powerRawPairs_imbalance_negligible S hL hnonemptyS end Erdos416Proof.Simplified end namespace Bounty theorem target : fcTypeOfName% "Erdos416.erdos_416.parts.i" := by exact Erdos416Proof.Simplified.doubling_limit /- Dependency license, reproduced from the supplied PNT-LICENSE.txt. Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -/