Add lean source and binary files (part 117)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- lean/OAI/NumberTheory/TotientAsymptotic/SurvivingComparison.leanAdded+118
- lean/OAI/NumberTheory/TotientAsymptotic/SurvivingGridGeometry.leanAdded+80
- lean/OAI/NumberTheory/TotientAsymptotic/SurvivingHeights.leanAdded+138
- lean/OAI/NumberTheory/TotientAsymptotic/SurvivingSlack.leanAdded+106
- lean/OAI/NumberTheory/TotientAsymptotic/TailArray.leanAdded+93
- lean/OAI/NumberTheory/TotientAsymptotic/TailBelowPrefix.leanAdded+95
- lean/OAI/NumberTheory/TotientAsymptotic/TailBounds.leanAdded+377
- lean/OAI/NumberTheory/TotientAsymptotic/TailBoxAggregation.leanAdded+77
- lean/OAI/NumberTheory/TotientAsymptotic/TailBoxCoordinates.leanAdded+74
- lean/OAI/NumberTheory/TotientAsymptotic/TailCofactor.leanAdded+73
- lean/OAI/NumberTheory/TotientAsymptotic/TailCutScale.leanAdded+45
- lean/OAI/NumberTheory/TotientAsymptotic/TailEncoding.leanAdded+93
- lean/OAI/NumberTheory/TotientAsymptotic/TailHeadCount.leanAdded+79
- lean/OAI/NumberTheory/TotientAsymptotic/TailPower.leanAdded+83
- lean/OAI/NumberTheory/TotientAsymptotic/TailProductBounds.leanAdded+74
- lean/OAI/NumberTheory/TotientAsymptotic/TailRenewal.leanAdded+120
- lean/OAI/NumberTheory/TotientAsymptotic/TailVolume.leanAdded+73
- lean/OAI/NumberTheory/TotientAsymptotic/TerminalBandCount.leanAdded+109
- lean/OAI/NumberTheory/TotientAsymptotic/TerminalLogBudget.leanAdded+48
- lean/OAI/NumberTheory/TotientAsymptotic/TerminalMassSeries.leanAdded+51
- lean/OAI/NumberTheory/TotientAsymptotic/TerminalPrefixMassCount.leanAdded+71
- lean/OAI/NumberTheory/TotientAsymptotic/TerminalPrimeGap.leanAdded+76
- lean/OAI/NumberTheory/TotientAsymptotic/TerminalSliceCount.leanAdded+72
- lean/OAI/NumberTheory/TotientAsymptotic/TerminalStateCount.leanAdded+69
- lean/OAI/NumberTheory/TotientAsymptotic/TerminalStateMass.leanAdded+62
- lean/OAI/NumberTheory/TotientAsymptotic/ThickenedWitness.leanAdded+76
- lean/OAI/NumberTheory/TotientAsymptotic/ThirdPrimeSize.leanAdded+67
- lean/OAI/NumberTheory/TotientAsymptotic/TopRowCount.leanAdded+76
- lean/OAI/NumberTheory/TotientAsymptotic/TotientCountingEnvelope.leanAdded+97
- lean/OAI/NumberTheory/TotientAsymptotic/TotientPreimageBound.leanAdded+56
- lean/OAI/NumberTheory/TotientAsymptotic/TotientRatioLogLog.leanAdded+128
- lean/OAI/NumberTheory/TotientAsymptotic/TranslatedOrder.leanAdded+93
- lean/OAI/NumberTheory/TotientAsymptotic/TranslatedPrefix.leanAdded+51
- lean/OAI/NumberTheory/TotientAsymptotic/TripleDensity.leanAdded+56
- lean/OAI/NumberTheory/TotientAsymptotic/TripleDiscriminant.leanAdded+64
- lean/OAI/NumberTheory/TotientAsymptotic/TripleEulerProduct.leanAdded+93
- lean/OAI/NumberTheory/TotientAsymptotic/TriplePrimeBound.leanAdded+39
- lean/OAI/NumberTheory/TotientAsymptotic/TripleSieveCRT.leanAdded+81
- lean/OAI/NumberTheory/TotientAsymptotic/TripleSieveCount.leanAdded+86
- lean/OAI/NumberTheory/TotientAsymptotic/TripleSieveCutoff.leanAdded+53
- lean/OAI/NumberTheory/TotientAsymptotic/TripleSieveDenominator.leanAdded+145
- lean/OAI/NumberTheory/TotientAsymptotic/TripleSieveError.leanAdded+80
- lean/OAI/NumberTheory/TotientAsymptotic/TripleSieveModel.leanAdded+85
- lean/OAI/NumberTheory/TotientAsymptotic/TripleSieveRoots.leanAdded+52
- lean/OAI/NumberTheory/TotientAsymptotic/TruncatedConcentration.leanAdded+63
- lean/OAI/NumberTheory/TotientAsymptotic/TupleCandidate.leanAdded+83
- lean/OAI/NumberTheory/TotientAsymptotic/TupleCoefficient.leanAdded+94
- lean/OAI/NumberTheory/TotientAsymptotic/TupleCounting.leanAdded+91
- lean/OAI/NumberTheory/TotientAsymptotic/TupleMassApproximation.leanAdded+80
- lean/OAI/NumberTheory/TotientAsymptotic/TupleMassBound.leanAdded+70
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118import OAI.NumberTheory.TotientAsymptotic.CollisionCanceledimport OAI.NumberTheory.TotientAsymptotic.ComparisonLargePart
namespace OAI
/-! Assemble Ford's pointwise comparison hypotheses for actual surviving lists. -/
noncomputable sectionopen scoped BigOperators Topologyopen Filter
namespace TotientAsymptotic
lemma normal_prime_omega_below {S y : ℝ} {p : ℕ} (hp : IsNormalPrime S p) (hS : 1 < S) (hBS : 0 ≤ B S) (hSy : S ≤ y) (hpy : (p-1 : ℕ) ≤ y) : ((p-1).primeFactorsList.length : ℝ) ≤ 4*B y := by have hSb : B S ≤ B y := Real.log_le_log (Real.log_pos hS) (Real.log_le_log (zero_lt_one.trans hS) hSy) have hBy := hBS.trans hSb by_cases hp3 : 3 ≤ p · have hp1 : (1 : ℝ) < (p-1 : ℕ) := by exact_mod_cast (show 2 ≤ p-1 by omega) have hpb : B (p-1 : ℕ) ≤ B y := Real.log_le_log (Real.log_pos hp1) (Real.log_le_log (zero_lt_one.trans hp1) hpy) exact (normality_total_uniform hp hS hBS hSb hpb).trans (by linarith) · have he : p=2 := by have := hp.1.two_le; omega simp only [he, Nat.reduceSub, Nat.primeFactorsList_one, List.length_nil, Nat.cast_zero] positivity
/-- All pointwise hypotheses, including the large-prime-part condition, followfor the actual canceled lists once their ordered factor intervals are chosen.The remaining interval construction and summation are separate obligations. -/theorem surviving_comparison_conditions : ∀ᶠ y : ℝ in atTop, ∀ {x : ℝ} {H i p q : ℕ} {η ξ : RemainderDatum (L x H)}, IsBasicRemainder x H η → IsBasicRemainder x H ξ → p.Prime → L x H < m x → R x H < L x H → i ≤ R x H → collisionLastIndex x i < L x H → tupleValue (witnessTuple p η)=tupleValue (witnessTuple q ξ) → wholeWitnessPrime p η i ≠ wholeWitnessPrime q ξ i → (∀ j < i, wholeWitnessPrime p η j=wholeWitnessPrime q ξ j) → GoodWitnessConditions p η → GoodWitnessConditions q ξ → ∀ Y U : ℕ → ℝ, 1 < normalityScale x i → 0 ≤ B (normalityScale x i) → normalityScale x i ≤ y → Y (collisionSurvivors p q η ξ i (collisionLastIndex x i)).card=collisionSmoothCutoff x i → (∀ j : Fin (collisionSurvivors p q η ξ i (collisionLastIndex x i)).card, U j ≤ largestPrimeFactor ((survivingPair p q η ξ i (collisionLastIndex x i)).left j-1) ∧ (largestPrimeFactor ((survivingPair p q η ξ i (collisionLastIndex x i)).left j-1) : ℝ) ≤ Y j ∧ U j ≤ largestPrimeFactor ((survivingPair p q η ξ i (collisionLastIndex x i)).right j-1) ∧ (largestPrimeFactor ((survivingPair p q η ξ i (collisionLastIndex x i)).right j-1) : ℝ) ≤ Y j) → ((suffixPreimage η (collisionLastIndex x i)).totient * (∏ j ∈ Finset.Icc i (collisionLastIndex x i), (wholeWitnessPrime p η j-1)) : ℕ) ≤ y → (largestPrimeFactor (collisionResidual ξ i) : ℝ) ≤ collisionSmoothCutoff x i → y^(9/10 : ℝ) ≤ wholeWitnessPrime p η i → 1 ≤ Y 1 → Y 1 ≤ Real.exp (Real.exp ((4/5 : ℝ)*B y)) → FordComparisonConditions (collisionSurvivors p q η ξ i (collisionLastIndex x i)).card y (normalityScale x i) (collisionResidual η i) (collisionCanceledProduct p q η ξ i (collisionLastIndex x i)) Y U (survivingPair p q η ξ i (collisionLastIndex x i)) := by filter_upwards [comparison_large_prime_part] with y hlarge intro x H i p q η ξ hη hξ hp hL hR hi hk hv hfirst hcommon hgη hgξ Y U hS hBS hSy hYb hinterval hsize hres hhead hY1 hY1u have hik : i ≤ collisionLastIndex x i := Nat.le_add_right _ _ have heq := surviving_collision_identity hη hξ hp hL hR hk hik hv hfirst hcommon have hgood := surviving_good_conditions hi hgη hgξ have hrpos := collisionCanceledProduct_pos hη hp hk.le (q := q) (ξ := ξ) (i := i) have hDpos := Nat.totient_pos.mpr (suffixPreimage_pos hη (i := collisionLastIndex x i)) have hrempos := Nat.totient_pos.mpr (suffixPreimage_pos hξ (i := collisionLastIndex x i)) have hprodpos : 0 < (collisionResidual η i)* shiftedProduct (survivingPair p q η ξ i (collisionLastIndex x i)).left := by apply Nat.mul_pos hDpos apply Finset.prod_pos intro j _ exact Nat.sub_pos_of_lt (hgood j).1.1.one_lt have hfactor : collisionCanceledProduct p q η ξ i (collisionLastIndex x i) * ((collisionResidual η i)*shiftedProduct (survivingPair p q η ξ i (collisionLastIndex x i)).left) = (collisionResidual η i)*∏ j ∈ Finset.Icc i (collisionLastIndex x i), (wholeWitnessPrime p η j-1) := by rw [mul_left_comm, canceled_surviving_product] have hprodsize : ((collisionResidual η i)*shiftedProduct (survivingPair p q η ξ i (collisionLastIndex x i)).left : ℕ) ≤ y := by have hh := Nat.le_mul_of_pos_left ((collisionResidual η i)*shiftedProduct (survivingPair p q η ξ i (collisionLastIndex x i)).left) hrpos rw [hfactor] at hh exact (show (((collisionResidual η i)*shiftedProduct (survivingPair p q η ξ i (collisionLastIndex x i)).left : ℕ) : ℝ) ≤ ((collisionResidual η i)*∏ j ∈ Finset.Icc i (collisionLastIndex x i), (wholeWitnessPrime p η j-1) : ℕ) by exact_mod_cast hh).trans hsize have hshift (j : Fin (collisionSurvivors p q η ξ i (collisionLastIndex x i)).card) : (((survivingPair p q η ξ i (collisionLastIndex x i)).left j-1 : ℕ) : ℝ) ≤ y := by exact (show (((survivingPair p q η ξ i (collisionLastIndex x i)).left j-1 : ℕ) : ℝ) ≤ ((collisionResidual η i)*shiftedProduct (survivingPair p q η ξ i (collisionLastIndex x i)).left : ℕ) by exact_mod_cast Nat.le_of_dvd hprodpos ((shifted_factor_dvd _ j).trans (dvd_mul_left _ _))).trans hprodsize refine ⟨hrempos,?_,heq,?_,?_,?_,?_⟩ · intro j exact ⟨(hgood j).1,(hgood j).2.1,(hgood j).2.2.1, (hinterval j).1,(hinterval j).2.1,(hinterval j).2.2.1,(hinterval j).2.2.2, hYb.symm ▸ (hgood j).2.2.2.1,hYb.symm ▸ (hgood j).2.2.2.2⟩ · apply (le_div_iff₀ (by exact_mod_cast hrpos : (0 : ℝ) < collisionCanceledProduct p q η ξ i (collisionLastIndex x i))).mpr rw [mul_comm,← Nat.cast_mul,hfactor] exact hsize · simpa only [hYb,survivingPair,collisionResidual] using hres · intro hb obtain ⟨hb',hfirstidx⟩ := survivingIndex_first hik hfirst have hfirstp : (survivingPair p q η ξ i (collisionLastIndex x i)).left ⟨0,hb⟩ = wholeWitnessPrime p η i := by change wholeWitnessPrime p η (survivingIndex p q η ξ i (collisionLastIndex x i) ⟨0,hb⟩)=_ rw [hfirstidx] apply hlarge _ _ (hgood ⟨0,hb⟩).1.1 (by simpa only [hfirstp] using hhead) hY1 hY1u exact normal_prime_omega_below (hgood ⟨0,hb⟩).1 hS hBS hSy (hshift ⟨0,hb⟩)
· rw [hYb] apply squarefreeAbove_of_dvd ?_ ((hgη i (Finset.mem_Icc.mpr ⟨Nat.zero_le _,hi⟩)).2.2.1) refine ⟨collisionCanceledProduct p q η ξ i (collisionLastIndex x i),?_⟩ rw [mul_comm,canceled_surviving_product]
end TotientAsymptotic
end
end OAI1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980import OAI.NumberTheory.TotientAsymptotic.CollisionFactorHeightsimport OAI.NumberTheory.TotientAsymptotic.PairedComparisonGrid
namespace OAI
/-! Numerical grid margins for the ordered surviving Ford bands. -/
noncomputable section
namespace TotientAsymptotic
lemma collision_last_band_le_half {x : ℝ} {i : ℕ} (hB : 1<B x) (hi : i < m x) (hh : 2 ≤ m x-i) (hcut : 2*collisionCutoff (m x-i)< m x-i) : fordBandScale x (collisionLastIndex x i) ≤ fordBandScale x i/2 := by have hb := fordBandScale_pos (zero_lt_one.trans hB) hi have hp : (2 : ℝ) ≤ ((m x-i : ℕ) : ℝ)^18 := by have h2 : (2 : ℝ) ≤ (m x-i : ℕ) := by exact_mod_cast hh have hp := pow_le_pow_left₀ (by norm_num : (0 : ℝ)≤2) h2 18 norm_num at hp linarith have hr := (div_le_iff₀ hb).mp (ford_collision_layer_ratio hB hi hcut).2 have hfrac : 1/((m x-i : ℕ) : ℝ)^18 ≤ (1/2 : ℝ) := by exact one_div_le_one_div_of_le (by norm_num) hp exact hr.trans (by nlinarith)
/-- This statement concerns the actual band heights only; the finite gridrounding is added afterwards. The first height uses the large head-primebound, and every other height uses its own Ford band. -/theorem ordered_surviving_band_margins {x Y : ℝ} {i k b : ℕ} (hb : 0<b) (hB : 1<B x) (hi : i < m x) (hk : k < m x) (j : Fin b ↪o ℕ) (hj0 : j ⟨0,hb⟩=i) (hjk : ∀ r, j r≤k) (_hY : 0<Y) (hYl : (87/100 : ℝ)*fordBandScale x i≤Y) (hlast : fordBandScale x k ≤ fordBandScale x i/2) (u v : Fin b → ℝ) (hhead : (9/10 : ℝ)*Y≤ min (u ⟨0,hb⟩) (v ⟨0,hb⟩)) (hlo : ∀ r, 0<r.val → (22/25 : ℝ)*fordBandScale x (j r)≤ min (u r) (v r)) (hhi : ∀ r, 0<r.val → max (u r) (v r)≤(28/25 : ℝ)*fordBandScale x (j r)) : (∀ r, 0<r.val → max (u r) (v r)≤(18/25 : ℝ)*Y) ∧ (∀ r, (4/5 : ℝ)*fordBandScale x k≤ min (u r) (v r)) ∧ (∀ r s, r<s → (1/10 : ℝ)*fordBandScale x k≤ min (u r) (v r)-max (u s) (v s)) := by have hbi := fordBandScale_pos (zero_lt_one.trans hB) hi have hbk := fordBandScale_pos (zero_lt_one.trans hB) hk have htail (r : Fin b) (hr : 0<r.val) : max (u r) (v r)≤(28/25 : ℝ)*rho*fordBandScale x i := by have hir : i<j r := by rw [← hj0] exact j.strictMono hr have hs := ford_band_step hB hir ((hjk r).trans_lt hk) exact (hhi r hr).trans (by nlinarith) constructor · intro r hr have hh := htail r hr have hρ := mul_lt_mul_of_pos_right collision_rho_bounds.2 hbi nlinarith constructor · intro r by_cases hr : r.val=0 · have he : r=⟨0,hb⟩ := Fin.ext hr subst r nlinarith · have hm := ford_band_antitone hB (hjk r) hk have hl := hlo r (by omega) nlinarith · intro r s hrs have hs0 : 0<s.val := by have h0 : (0 : ℕ) ≤ r.val := Nat.zero_le _; exact h0.trans_lt hrs by_cases hr : r.val=0 · have he : r=⟨0,hb⟩ := Fin.ext hr subst r have ht := htail s hs0 have hρ := mul_lt_mul_of_pos_right collision_rho_bounds.2 hbi nlinarith · have hg := normal_factor_band_gap hB (j.strictMono hrs) (hjk s) hk (hlo r (by omega)) (hhi s hs0) linarith
end TotientAsymptotic
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138import OAI.NumberTheory.TotientAsymptotic.CollisionFactorHeightsimport OAI.NumberTheory.TotientAsymptotic.CollisionEndpointDomainimport OAI.NumberTheory.TotientAsymptotic.SurvivingCollision
namespace OAI
/-! Actual surviving factors, with uniform top and positive-coordinate bounds. -/
noncomputable sectionopen scoped Topologyopen Filter
namespace TotientAsymptotic
lemma one_lt_nat_of_doubleLog_pos {n : ℕ} (hn : 0 < B n) : 1<n := by by_contra! h interval_cases n <;> norm_num [B] at hn
/-- Unlike the positive-coordinate band lemma, this also covers collisionswhose first different prime is the largest prime of the tuple. -/theorem surviving_factor_heights : ∀ᶠ H : ℕ in atTop, ∀ᶠ x : ℝ in atTop, ∀ i p q : ℕ, i ≤ R x H → ∀ η ξ : RemainderDatum (L x H), IsBasicRemainder x H η → IsBasicRemainder x H ξ → GoodWitnessConditions p η → GoodWitnessConditions q ξ → wholeWitnessPrime p η i ≠ wholeWitnessPrime q ξ i → ∀ y : ℝ, 1<y → 0<B y → fordBandScale x i/2 ≤ B y → B y ≤ 2*fordBandScale x i → y^(9/10 : ℝ) ≤ wholeWitnessPrime p η i → y^(9/10 : ℝ) ≤ wholeWitnessPrime q ξ i → (∀ r : Fin (collisionSurvivors p q η ξ i (collisionLastIndex x i)).card, ((survivingPair p q η ξ i (collisionLastIndex x i)).left r-1 : ℕ) ≤ y ∧ ((survivingPair p q η ξ i (collisionLastIndex x i)).right r-1 : ℕ) ≤ y) → ∃ hb : 0<(collisionSurvivors p q η ξ i (collisionLastIndex x i)).card, ((9/10 : ℝ)*B y ≤ B (largestPrimeFactor ((survivingPair p q η ξ i (collisionLastIndex x i)).left ⟨0,hb⟩-1)) ∧ (9/10 : ℝ)*B y ≤ B (largestPrimeFactor ((survivingPair p q η ξ i (collisionLastIndex x i)).right ⟨0,hb⟩-1))) ∧ (∀ r : Fin (collisionSurvivors p q η ξ i (collisionLastIndex x i)).card, (0 < B (largestPrimeFactor ((survivingPair p q η ξ i (collisionLastIndex x i)).left r-1)) ∧ B (largestPrimeFactor ((survivingPair p q η ξ i (collisionLastIndex x i)).left r-1)) ≤ B y) ∧ (0 < B (largestPrimeFactor ((survivingPair p q η ξ i (collisionLastIndex x i)).right r-1)) ∧ B (largestPrimeFactor ((survivingPair p q η ξ i (collisionLastIndex x i)).right r-1)) ≤ B y)) ∧ (∀ r : Fin (collisionSurvivors p q η ξ i (collisionLastIndex x i)).card, 0<r.val → ((22/25 : ℝ)*fordBandScale x (survivingIndex p q η ξ i (collisionLastIndex x i) r) ≤ B (largestPrimeFactor ((survivingPair p q η ξ i (collisionLastIndex x i)).left r-1)) ∧ B (largestPrimeFactor ((survivingPair p q η ξ i (collisionLastIndex x i)).left r-1)) ≤ (28/25 : ℝ)*fordBandScale x (survivingIndex p q η ξ i (collisionLastIndex x i) r)) ∧ ((22/25 : ℝ)*fordBandScale x (survivingIndex p q η ξ i (collisionLastIndex x i) r) ≤ B (largestPrimeFactor ((survivingPair p q η ξ i (collisionLastIndex x i)).right r-1)) ∧ B (largestPrimeFactor ((survivingPair p q η ξ i (collisionLastIndex x i)).right r-1)) ≤ (28/25 : ℝ)*fordBandScale x (survivingIndex p q η ξ i (collisionLastIndex x i) r))) := by filter_upwards [collision_factor_ford_bands,collision_normality_domain, collision_endpoints_eventually normal_head_largest_factor,eventually_collision_indices] with H hband hdomain hhead hind filter_upwards [hband,hdomain,hhead,m_tendsto.eventually (eventually_ge_atTop H), B_tendsto.eventually (eventually_gt_atTop (1 : ℝ))] with x hband hdomain hhead hm hBx intro i p q hi η ξ hη hξ hgη hgξ hfirst y hy hBy hByl hByu hpmin hqmin hsize obtain ⟨hb,hidx0⟩ := survivingIndex_first (Nat.le_add_right i _) hfirst change 0 < (collisionSurvivors p q η ξ i (collisionLastIndex x i)).card at hb change survivingIndex p q η ξ i (collisionLastIndex x i) ⟨0,hb⟩=i at hidx0 have hk := (hind x hm i hi).2.2 have hgood := surviving_good_conditions hi hgη hgξ obtain ⟨hSbig,hBS,hSy⟩ := hdomain i hi y hy hByl have hS : 1 < normalityScale x i := (Real.one_lt_exp_iff.mpr (Real.exp_pos 1)).trans_le hSbig have hBS0 : 0 ≤ B (normalityScale x i) := by linarith have hheadfun := hhead i hi y hy hByl have hfirstp : (survivingPair p q η ξ i (collisionLastIndex x i)).left ⟨0,hb⟩ = wholeWitnessPrime p η i := by simp only [survivingPair,hidx0] have hfirstq : (survivingPair p q η ξ i (collisionLastIndex x i)).right ⟨0,hb⟩ = wholeWitnessPrime q ξ i := by simp only [survivingPair,hidx0] have hl := hheadfun _ _ (hgood ⟨0,hb⟩).1 hS hBS0 hSy (by simpa only [hfirstp] using hpmin) (hsize ⟨0,hb⟩).1 have hr := hheadfun _ _ (hgood ⟨0,hb⟩).2.1 hS hBS0 hSy (by simpa only [hfirstq] using hqmin) (hsize ⟨0,hb⟩).2 have hpositive (r : Fin (collisionSurvivors p q η ξ i (collisionLastIndex x i)).card) (hr0 : 0<r.val) : ((22/25 : ℝ)*fordBandScale x (survivingIndex p q η ξ i (collisionLastIndex x i) r) ��� B (largestPrimeFactor ((survivingPair p q η ξ i (collisionLastIndex x i)).left r-1)) ∧ B (largestPrimeFactor ((survivingPair p q η ξ i (collisionLastIndex x i)).left r-1)) ≤ (28/25 : ℝ)*fordBandScale x (survivingIndex p q η ξ i (collisionLastIndex x i) r)) ∧ ((22/25 : ℝ)*fordBandScale x (survivingIndex p q η ξ i (collisionLastIndex x i) r) ≤ B (largestPrimeFactor ((survivingPair p q η ξ i (collisionLastIndex x i)).right r-1)) ∧ B (largestPrimeFactor ((survivingPair p q η ξ i (collisionLastIndex x i)).right r-1)) ≤ (28/25 : ℝ)*fordBandScale x (survivingIndex p q η ξ i (collisionLastIndex x i) r)) := by have hlt : i < survivingIndex p q η ξ i (collisionLastIndex x i) r := by calc i = survivingIndex p q η ξ i (collisionLastIndex x i) ⟨0,hb⟩ := hidx0.symm _ < _ := (survivingIndex p q η ξ i (collisionLastIndex x i)).strictMono hr0 have hj := (Finset.mem_Icc.mp (Finset.mem_filter.mp (survivingIndex_mem p q η ξ i (collisionLastIndex x i) r)).1).2 have hj0 : survivingIndex p q η ξ i (collisionLastIndex x i) r ≠ 0 := by omega have hbη := hband i hi _ (Finset.mem_Icc.mpr ⟨by omega,hj⟩) (hj.trans hk.le) η hη y hS hBS0 hSy hBy hByu have hbξ := hband i hi _ (Finset.mem_Icc.mpr ⟨by omega,hj⟩) (hj.trans hk.le) ξ hξ y hS hBS0 hSy hBy hByu have hg := hgood r have hs := hsize r simp only [survivingPair,wholeWitnessPrime,ite_eq_right hj0] at hg hs ⊢ exact ⟨hbη hg.1 hs.1,hbξ hg.2.1 hs.2⟩ refine ⟨hb,⟨hl,hr⟩,?_,hpositive⟩ intro r have hpos : 0 < B (largestPrimeFactor ((survivingPair p q η ξ i (collisionLastIndex x i)).left r-1)) ∧ 0 < B (largestPrimeFactor ((survivingPair p q η ξ i (collisionLastIndex x i)).right r-1)) := by by_cases hr0 : r.val=0 · have he : r=⟨0,hb⟩ := Fin.ext hr0 subst r exact ⟨(mul_pos (by norm_num) hBy).trans_le hl,(mul_pos (by norm_num) hBy).trans_le hr⟩ · have hj := (Finset.mem_Icc.mp (Finset.mem_filter.mp (survivingIndex_mem p q η ξ i (collisionLastIndex x i) r)).1).2 have hjm := (hj.trans_lt hk).trans_le (Nat.sub_le _ _) have hbp := fordBandScale_pos (zero_lt_one.trans hBx) hjm exact ⟨(mul_pos (by norm_num) hbp).trans_le (hpositive r (by omega)).1.1, (mul_pos (by norm_num) hbp).trans_le (hpositive r (by omega)).2.1⟩ have hupper (n : ℕ) (hn : 0<B n) (hmn : (n : ℝ)≤y) : B n≤B y := by have hn1 : (1 : ℝ)<n := by exact_mod_cast one_lt_nat_of_doubleLog_pos hn exact Real.log_le_log (Real.log_pos hn1) (Real.log_le_log (zero_lt_one.trans hn1) hmn)
constructor · refine ⟨hpos.1,hupper _ hpos.1 ?_⟩ have hn : 1≤(survivingPair p q η ξ i (collisionLastIndex x i)).left r-1 := by have := (hgood r).1.1.two_le omega exact (show (largestPrimeFactor ((survivingPair p q η ξ i (collisionLastIndex x i)).left r-1) : ℝ) ≤ ((survivingPair p q η ξ i (collisionLastIndex x i)).left r-1 : ℕ) by exact_mod_cast largestPrimeFactor_le_self hn).trans (hsize r).1 · refine ⟨hpos.2,hupper _ hpos.2 ?_⟩ have hn : 1≤(survivingPair p q η ξ i (collisionLastIndex x i)).right r-1 := by have := (hgood r).2.1.1.two_le omega exact (show (largestPrimeFactor ((survivingPair p q η ξ i (collisionLastIndex x i)).right r-1) : ℝ) ≤ ((survivingPair p q η ξ i (collisionLastIndex x i)).right r-1 : ℕ) by exact_mod_cast largestPrimeFactor_le_self hn).trans (hsize r).2
end TotientAsymptotic
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106import OAI.NumberTheory.TotientAsymptotic.ActualComparisonCutoffs
namespace OAI
/-! Renumbering the actual surviving indices preserves the good-witness slack. -/
noncomputable sectionopen scoped BigOperators
namespace TotientAsymptotic
lemma orderEmbedding_offset_le {b i : ℕ} (j : Fin b ↪o ℕ) (hb : 0< b) (hfirst : j ⟨0,hb⟩=i) (r : Fin b) : i+r.val≤ j r := by have hall : ∀ n (hn : n< b), i+n≤ j ⟨n,hn⟩ := by intro n induction n with | zero => intro hn; simpa only [Nat.add_zero,hfirst] using (le_refl i) | succ n ih => intro hn have hn' : n< b := by omega have hprev := ih hn' have hs := j.strictMono (show (⟨n,hn'⟩ : Fin b)<⟨n+1,hn⟩ from Nat.lt_succ_self n) omega exact hall r.val r.isLt
lemma shifted_slack_sum {J i : ℕ} (hi : i≤ J) (u : ℕ → ℝ) : (∑ k ∈ Finset.Icc 1 (J-i), a k*u (i+k)) = ∑ r ∈ Finset.Icc (i+1) J, a (r-i)*u r := by apply Finset.sum_bij (fun k _ => i+k) · intro k hk have := Finset.mem_Icc.mp hk apply Finset.mem_Icc.mpr omega · intro k hk l hl he omega · intro r hr refine ⟨r-i,?_,?_⟩ · have := Finset.mem_Icc.mp hr apply Finset.mem_Icc.mpr omega · have := Finset.mem_Icc.mp hr omega · intro k hk simp only [Nat.add_sub_cancel_left]
/-- The discarded matching coordinates cannot consume slack. This is statedfor the actual order embedding of survivors, with the original index offset. -/theorem surviving_weighted_slack {x : ℝ} {H i p q : ℕ} {η ξ : RemainderDatum (L x H)} (hη : IsBasicRemainder x H η) (hk : collisionLastIndex x i< L x H) (hfirst : wholeWitnessPrime p η i≠wholeWitnessPrime q ξ i) (ν : ℕ → ℝ) {Y σ e : ℝ} (hY : 0< Y) (hbudget : (∑ r ∈ Finset.Icc (i+1) (L x H), a (r-i)*remainderCoord x η r)≤(1-σ)*Y) (hgrid : ∀ r (hr : r ∈ Finset.Icc 1 ((collisionSurvivors p q η ξ i (collisionLastIndex x i)).card-1)), ν r≤ remainderCoord x η (survivingIndex p q η ξ i (collisionLastIndex x i) ⟨r,by have := Finset.mem_Icc.mp hr; omega⟩)/Y+e) : (∑ r ∈ Finset.Icc 1 ((collisionSurvivors p q η ξ i (collisionLastIndex x i)).card-1), a r*ν r)≤ 1-σ+e*(∑ r ∈ Finset.Icc 1 ((collisionSurvivors p q η ξ i (collisionLastIndex x i)).card-1), a r) := by obtain ⟨hb,hidx0⟩ := survivingIndex_first (Nat.le_add_right i _) hfirst change 0 < (collisionSurvivors p q η ξ i (collisionLastIndex x i)).card at hb change survivingIndex p q η ξ i (collisionLastIndex x i) ⟨0,hb⟩=i at hidx0 let b := (collisionSurvivors p q η ξ i (collisionLastIndex x i)).card let j : ℕ → ℕ := fun r => if hr : r< b then survivingIndex p q η ξ i (collisionLastIndex x i) ⟨r,hr⟩-i else 0 let u : ℕ → ℝ := fun r => remainderCoord x η (i+r) have hir : i≤ L x H := (Nat.le_add_right i (collisionCutoff (m x-i))).trans hk.le have hidx (r : ℕ) (hr : r∈Finset.Icc 1 (b-1)) : r≤ j r ∧ j r≤ L x H-i := by have hrb : r< b := by have := Finset.mem_Icc.mp hr; omega have hoff := orderEmbedding_offset_le (survivingIndex p q η ξ i (collisionLastIndex x i)) hb hidx0 ⟨r,hrb⟩ change i+r ≤ survivingIndex p q η ξ i (collisionLastIndex x i) ⟨r,hrb⟩ at hoff have hmem := survivingIndex_mem p q η ξ i (collisionLastIndex x i) ⟨r,hrb⟩ have hupper := (Finset.mem_Icc.mp (Finset.mem_filter.mp hmem).1).2 simp only [j,dite_eq_left hrb] constructor <;> omega have hinj : Set.InjOn j (↑(Finset.Icc 1 (b-1)) : Set ℕ) := by intro r hr s hs he have hrb : r< b := by have := Finset.mem_Icc.mp hr; omega have hsb : s< b := by have := Finset.mem_Icc.mp hs; omega simp only [j,dite_eq_left hrb,dite_eq_left hsb] at he have hrlo := (orderEmbedding_offset_le (survivingIndex p q η ξ i (collisionLastIndex x i)) hb hidx0 ⟨r,hrb⟩) have hslo := (orderEmbedding_offset_le (survivingIndex p q η ξ i (collisionLastIndex x i)) hb hidx0 ⟨s,hsb⟩) change i+r ≤ survivingIndex p q η ξ i (collisionLastIndex x i) ⟨r,hrb⟩ at hrlo change i+s ≤ survivingIndex p q η ξ i (collisionLastIndex x i) ⟨s,hsb⟩ at hslo have heq : survivingIndex p q η ξ i (collisionLastIndex x i) ⟨r,hrb⟩= survivingIndex p q η ξ i (collisionLastIndex x i) ⟨s,hsb⟩ := by omega exact congrArg Fin.val ((survivingIndex p q η ξ i (collisionLastIndex x i)).injective heq) apply gridded_weighted_slack (b-1) (L x H-i) j u ν Y σ e hY hinj hidx · intro r hr have hmem := Finset.mem_Icc.mp hr have hirL : i+r∈Finset.Icc 1 (L x H) := by apply Finset.mem_Icc.mpr; omega have hu := (hη.2.1 (i+r) hirL).2.1 exact (mul_nonneg (by norm_num) (bandScale_nonnegative _ _)).trans hu · simpa only [u,shifted_slack_sum hir] using hbudget · intro r hr have hrb : r< b := by have := Finset.mem_Icc.mp hr; omega have hoff := orderEmbedding_offset_le (survivingIndex p q η ξ i (collisionLastIndex x i)) hb hidx0 ⟨r,hrb⟩ have hadd : i+(survivingIndex p q η ξ i (collisionLastIndex x i) ⟨r,hrb⟩-i)= survivingIndex p q η ξ i (collisionLastIndex x i) ⟨r,hrb⟩ := by omega simpa only [u,j,dite_eq_left hrb,hadd] using hgrid r hr
end TotientAsymptotic
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293import OAI.NumberTheory.TotientAsymptotic.RemainderSplit
namespace OAI
/-! The discrete tail, in the coordinate order used by the full simplex. -/
noncomputable sectionopen scoped BigOperators
namespace TotientAsymptotic
def tailVector {H : ℕ} (η : TailDatum H) : Fin (H-P H) → ℝ := fun i => tailLog η (H-1-i.val)
lemma tailVector_nonneg {H : ℕ} {s : ℝ} {η : TailDatum H} (hη : IsWitness H s η) (i : Fin (H-P H)) : 0 ≤ tailVector η i := by apply tailLog_nonneg hη apply Finset.mem_Ico.mpr have := i.isLt omega
lemma D_eq_tailVector_sum {H : ℕ} (η : TailDatum H) (hPH : P H ≤ H) (h : ℕ) : D h η = ∑ i : Fin (H-P H), a (h-(H-1-i.val))*tailVector η i := by unfold D apply Finset.sum_bij (fun l hl => (⟨H-1-l, by have := Finset.mem_Ico.mp hl omega⟩ : Fin (H-P H))) · intro l hl exact Finset.mem_univ _ · intro l hl k hk he have := Finset.mem_Ico.mp hl have := Finset.mem_Ico.mp hk have hv := congrArg Fin.val he simp only at hv omega · intro i _ have hi := i.isLt refine ⟨H-1-i.val, Finset.mem_Ico.mpr ⟨by omega, by omega⟩, ?_⟩ apply Fin.ext simp only omega · intro l hl have := Finset.mem_Ico.mp hl dsimp only [tailVector] have he : H-1-(H-1-l)=l := by omega rw [he]
lemma tailVector_row {H : ℕ} (η : TailDatum H) (i : Fin (H-P H)) : (∑ j : Fin (H-P H), if i < j then a (j.val-i.val)*tailVector η j else 0) = ∑ l ∈ Finset.Ico (P H) (H-1-i.val), a (H-1-i.val-l)*tailLog η l := by rw [← Finset.sum_filter] apply Finset.sum_bij (fun j _ => H-1-j.val) · intro j hj have hj' : i < j := (Finset.mem_filter.mp hj).2 have hi := i.isLt have hjb := j.isLt exact Finset.mem_Ico.mpr (by simp only [Fin.lt_def] at hj'; omega) · intro j hj k hk he apply Fin.ext have := j.isLt have := k.isLt omega · intro l hl have hl' := Finset.mem_Ico.mp hl refine ⟨⟨H-1-l, by omega⟩, Finset.mem_filter.mpr ⟨Finset.mem_univ _, ?_⟩, ?_⟩ · change i.val < H-1-l omega · simp only omega · intro j hj have hij : i < j := (Finset.mem_filter.mp hj).2 have hi := i.isLt have hjb := j.isLt dsimp only [tailVector] congr 2 simp only [Fin.lt_def] at hij omega
lemma tailVector_simplex {H : ℕ} {s : ℝ} {η : TailDatum H} (hη : IsWitness H s η) (i : Fin (H-P H)) : (∑ j : Fin (H-P H), if i < j then a (j.val-i.val)*tailVector η j else 0) ≤ (1+(1/10000 : ℝ)*Real.exp (-((H-1-i.val : ℕ) : ℝ)/40))*tailVector η i := by rw [tailVector_row] have hi : H-1-i.val ∈ Finset.Ico (P H) H := by have := i.isLt exact Finset.mem_Ico.mpr (by omega) exact (hη.2.2.1 _ hi).2.2.2
end TotientAsymptotic
end
end OAI1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495import OAI.NumberTheory.TotientAsymptotic.CofactorShellDecayimport OAI.NumberTheory.TotientAsymptotic.SuffixSizeimport OAI.NumberTheory.TotientAsymptotic.CollisionIndices
namespace OAI
noncomputable sectionopen scoped Topologyopen Filter
namespace TotientAsymptotic
lemma tail_log_comparison : ∀ᶠ b : ℝ in atTop, 4*b*Real.exp ((7/10 : ℝ)*b) < Real.exp ((9/10 : ℝ)*b) := by have ht : Tendsto (fun b : ℝ => 4*(b*Real.exp (-(1/5 : ℝ)*b))) atTop (nhds 0) := by simpa only [Real.rpow_one,mul_zero] using (tendsto_rpow_mul_exp_neg_mul_atTop_nhds_zero 1 (1/5) (by norm_num : (0 : ℝ)<1/5)).const_mul 4 filter_upwards [ht.eventually (eventually_lt_nhds (by norm_num : (0 : ℝ)<1))] with b hb have h := mul_lt_mul_of_pos_right hb (Real.exp_pos ((9/10 : ℝ)*b)) rw [mul_assoc,mul_assoc,← Real.exp_add] at h rw [show -(1/5 : ℝ)*b+9/10*b=(7/10 : ℝ)*b by ring,one_mul] at h simpa only [mul_assoc] using h
/-- The exact arithmetic tail lies below every retained prefix prime. This isuniform in the phase; the cofactor cut grows much slower than the prefix cut. -/theorem basic_tail_lt_last_prefix : ∀ᶠ H : ℕ in atTop, ∀ x : ℝ, theta x ∈ Set.Ico (0 : ℝ) 1 → H < m x → ∀ η : RemainderDatum (L x H), IsBasicRemainder x H η → remainderTail x H η < remainderPrime η (R x H) := by obtain ⟨b₀,hb₀⟩ := eventually_atTop.mp tail_log_comparison filter_upwards [eventually_ge_atTop 2, P_tendsto.eventually (eventually_ge_atTop 1), cofactor_envelope_le_self (2*(lam/rho)), (tendsto_natCast_atTop_atTop.const_mul_atTop lam_pos).eventually (eventually_ge_atTop b₀)] with H hH hP hcof hlarge intro x hs hm η hη have hPH := P_lt_self hH have hR : 0 < R x H := by unfold R; omega have hRL : R x H < L x H := by unfold R L; omega have hRmem : R x H ∈ Finset.Icc 1 (L x H) := Finset.mem_Icc.mpr ⟨hR,hRL.le⟩ have hRH : m x-R x H=H := by unfold R; omega have hLP : m x-L x H=P H := by unfold L; omega let b := bandScale x (R x H) have hb0 : 0 ≤ b := bandScale_nonnegative _ _ have hα : lam ≤ alpha (theta x) := by unfold alpha exact le_mul_of_one_le_right lam_pos.le (Real.one_le_exp (mul_nonneg lam_pos.le hs.1)) have hpow : (1 : ℝ) ≤ (rho^H)⁻¹ := one_le_inv₀ (pow_pos rho_pos H) |>.mpr (pow_le_one₀ rho_pos.le rho_lt_one.le) have hbH : lam*H ≤ b := by change _ ≤ alpha (theta x)*(m x-R x H : ℕ)*(rho^(m x-R x H))⁻¹ rw [hRH] exact (mul_le_mul_of_nonneg_right hα (Nat.cast_nonneg H)).trans (le_mul_of_one_le_right (mul_nonneg (alpha_pos _).le (Nat.cast_nonneg _)) hpow) have hHb : (H : ℝ) ≤ 2*b := by have hl := collision_lambda_bounds.1 nlinarith [Nat.cast_nonneg (α := ℝ) H] have hsuc : (11/10 : ℝ)*bandScale x (R x H+1) ≤ (7/10 : ℝ)*b := by have hh := bandScale_succ_le x (R x H) have hr := collision_rho_bounds.2 change bandScale x (R x H+1) ≤ rho*b at hh nlinarith have hlast : Real.exp (2*bandScale x (L x H)) ≤ H := by apply (Real.exp_le_exp.mpr ?_).trans hcof rw [bandScale,hLP] unfold cofactorScale have hi := (inv_pos.mpr (pow_pos rho_pos (P H))).le have ha := alpha_le _ hs nlinarith [mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_right ha (Nat.cast_nonneg (P H))) hi] have hlen : L x H-R x H ≤ H := by unfold L R; omega have hlenR : (L x H-R x H : ℕ) ≤ (H : ℝ) := by exact_mod_cast hlen have he : (1 : ℝ) ≤ Real.exp ((7/10 : ℝ)*b) := Real.one_le_exp (by positivity) have hlog := basic_suffix_log_bound (j := R x H) hη have hu : Real.log (remainderTail x H η : ℝ) < Real.exp ((9/10 : ℝ)*b) := by change Real.log (suffixPreimage η (R x H) : ℝ) < _ calc _ ≤ (H : ℝ)*Real.exp ((7/10 : ℝ)*b)+H := hlog.trans (add_le_add (mul_le_mul hlenR (Real.exp_le_exp.mpr hsuc) (Real.exp_pos _).le (Nat.cast_nonneg _)) hlast) _ ≤ 4*b*Real.exp ((7/10 : ℝ)*b) := by nlinarith _ < _ := hb₀ b (hlarge.trans hbH) have hp := hη.2.1 _ hRmem have hpR : (1 : ℝ) < remainderPrime η (R x H) := by exact_mod_cast hp.1.one_lt have hlower : Real.exp ((9/10 : ℝ)*b) ≤ Real.log (remainderPrime η (R x H) : ℝ) := by apply (Real.le_log_iff_exp_le (Real.log_pos hpR)).mp simpa only [remainderCoord,ite_eq_right (ne_of_gt hR)] using hp.2.1 have hpos : (0 : ℝ) < remainderTail x H η := by exact_mod_cast suffixPreimage_pos (i := R x H) hη exact_mod_cast (Real.log_lt_log_iff hpos (zero_lt_one.trans hpR)).mp (hu.trans_le hlower)
end TotientAsymptotic
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377import OAI.NumberTheory.TotientAsymptotic.Renewal
namespace OAI
/-! Uniform finite tail bounds and nonnegative coefficients from exponential random variables. -/
noncomputable sectionopen scoped BigOperators Topologyopen Filter
namespace TotientAsymptotic
lemma alpha_le (s : ℝ) (hs : s ∈ Set.Ico (0 : ℝ) 1) : alpha s ≤ lam / rho := by have h : lam * s ≤ lam := by nlinarith [lam_pos, hs.2] have he : Real.exp lam = 1 / rho := Real.exp_log (div_pos zero_lt_one rho_pos) unfold alpha calc lam * Real.exp (lam * s) ≤ lam * Real.exp lam := mul_le_mul_of_nonneg_left (Real.exp_le_exp.mpr h) lam_pos.le _ = lam / rho := by rw [he]; ring
def tailPrimeBound (H : ℕ) : ℕ := ⌈Real.exp (Real.exp ((11/10 : ℝ) * (lam/rho) * H * (rho^H)⁻¹))⌉₊
def tailCofactorBound (H : ℕ) : ℕ := ⌈Real.exp (Real.exp (2 * (lam/rho) * (P H : ℝ) * (rho^(P H))⁻¹))⌉₊
lemma one_le_tailPrimeBound (H : ℕ) : 1 ≤ tailPrimeBound H := by have h : (1 : ℝ) ≤ Real.exp (Real.exp ((11/10 : ℝ) * (lam/rho) * H * (rho^H)⁻¹)) := Real.one_le_exp (Real.exp_pos _).le exact_mod_cast h.trans (Nat.le_ceil _)
lemma index_inv_pow_mono {h H : ℕ} (hh : h ≤ H) : (h : ℝ) * (rho^h)⁻¹ ≤ (H : ℝ) * (rho^H)⁻¹ := by have hr := rho_pos apply mul_le_mul (by exact_mod_cast hh) · exact (inv_le_inv₀ (pow_pos rho_pos _) (pow_pos rho_pos _)).2 (pow_le_pow_of_le_one rho_pos.le rho_lt_one.le hh) · positivity · positivity
lemma witness_prime_bound {H : ℕ} {s : ℝ} {η : TailDatum H} (hs : s ∈ Set.Ico (0 : ℝ) 1) (hη : IsWitness H s η) (i : Fin H) : 1 ≤ η.Q i ∧ η.Q i ≤ tailPrimeBound H := by by_cases hi : i.val < P H · rw [hη.1 i hi] exact ⟨le_rfl, one_le_tailPrimeBound H⟩ · have himem : i.val ∈ Finset.Ico (P H) H := by simp; omega obtain ⟨hprime, hlo, hhi, hineq⟩ := hη.2.2.1 i.val himem have ht : tailPrime η i.val = η.Q i := by simp [tailPrime, i.isLt] rw [ht] at hprime have hQ : (1 : ℝ) < η.Q i := by exact_mod_cast hprime.one_lt have hlog : Real.log (η.Q i : ℝ) > 0 := Real.log_pos hQ have hupper : tailLog η i.val ≤ (11/10 : ℝ) * (lam/rho) * H * (rho^H)⁻¹ := by apply hhi.trans calc _ = (11/10 : ℝ) * alpha s * ((i.val : ℝ) * (rho^i.val)⁻¹) := by ring _ ≤ (11/10 : ℝ) * (lam/rho) * ((H : ℝ) * (rho^H)⁻¹) := by apply mul_le_mul · exact mul_le_mul_of_nonneg_left (alpha_le s hs) (by norm_num) · exact index_inv_pow_mono (Nat.le_of_lt i.isLt) · have := rho_pos; positivity · have := lam_pos; have := rho_pos; positivity _ = _ := by ring change Real.log (Real.log (tailPrime η i.val : ℝ)) ≤ _ at hupper rw [ht] at hupper have hh := (Real.log_le_iff_le_exp hlog).1 hupper have hh' := (Real.log_le_iff_le_exp (lt_trans zero_lt_one hQ)).1 hh have hb : (η.Q i : ℝ) ≤ (tailPrimeBound H : ℝ) := hh'.trans (Nat.le_ceil _) exact ⟨hprime.pos, by exact_mod_cast hb⟩
lemma witness_cofactor_bound {H : ℕ} {s : ℝ} {η : TailDatum H} (hs : s ∈ Set.Ico (0 : ℝ) 1) (hη : IsWitness H s η) : 1 ≤ η.cofactor ∧ η.cofactor ≤ tailCofactorBound H := by have hpos : (0 : ℝ) < η.cofactor := by exact_mod_cast hη.2.1 have hlog : Real.log (η.cofactor : ℝ) ≤ Real.exp (2 * (lam/rho) * (P H : ℝ) * (rho^(P H))⁻¹) := by apply hη.2.2.2.2.trans apply Real.exp_le_exp.mpr have hr := rho_pos gcongr exact alpha_le s hs have hb : (η.cofactor : ℝ) ≤ (tailCofactorBound H : ℝ) := ((Real.log_le_iff_le_exp hpos).1 hlog).trans (Nat.le_ceil _) exact ⟨hη.2.1, by exact_mod_cast hb⟩
def tailUniverse (H : ℕ) : Set (TailDatum H) := {η | (∀ i, η.Q i ∈ Set.Icc 1 (tailPrimeBound H)) ∧ η.cofactor ∈ Set.Icc 1 (tailCofactorBound H)}
lemma tailUniverse_finite (H : ℕ) : (tailUniverse H).Finite := by let F : TailDatum H → (Fin H → ℕ) × ℕ := fun η => (η.Q, η.cofactor) have hF : Function.Injective F := by intro η ξ h cases η cases ξ simpa [F, Prod.mk.injEq] using h have hf := (Set.Finite.pi (fun _ : Fin H => Set.finite_Icc 1 (tailPrimeBound H))).prod (Set.finite_Icc 1 (tailCofactorBound H)) have hp := hf.preimage hF.injOn convert hp using 1 ext η simp [tailUniverse, F, Pi.le_def, forall_and, and_assoc, and_left_comm, and_comm]
lemma witness_mem_tailUniverse {H : ℕ} {s : ℝ} {η : TailDatum H} (hs : s ∈ Set.Ico (0 : ℝ) 1) (hη : IsWitness H s η) : η ∈ tailUniverse H := by exact ⟨fun i => witness_prime_bound hs hη i, witness_cofactor_bound hs hη⟩
theorem finite_tail_data (H : ℕ) : {η : TailDatum H | ∃ s ∈ Set.Ico (0 : ℝ) 1, IsWitness H s η}.Finite := by apply (tailUniverse_finite H).subset rintro η ⟨s, hs, hη⟩ exact witness_mem_tailUniverse hs hη
lemma witnesses_finite (H : ℕ) {s : ℝ} (hs : s ∈ Set.Ico (0 : ℝ) 1) (d : ℕ) : (witnesses H s d).Finite := by apply (finite_tail_data H).subset intro η hη exact ⟨s, hs, hη.1⟩
lemma witness_w_bound {H : ℕ} {s : ℝ} {η : TailDatum H} (hs : s ∈ Set.Ico (0 : ℝ) 1) (hη : IsWitness H s η) : w η ≤ tailCofactorBound H * (tailPrimeBound H)^(H-P H) := by have hp : ∏ h ∈ Finset.Ico (P H) H, tailPrime η h ≤ (tailPrimeBound H)^(H-P H) := by calc _ ≤ ∏ _h ∈ Finset.Ico (P H) H, tailPrimeBound H := by apply Finset.prod_le_prod intro h hh have hhH := (Finset.mem_Ico.mp hh).2 simpa [tailPrime, hhH] using (witness_prime_bound hs hη ⟨h, hhH⟩).2 _ = _ := by simp exact Nat.mul_le_mul (witness_cofactor_bound hs hη).2 hp
lemma witness_totient_bound {H : ℕ} {s : ℝ} {d : ℕ} (hs : s ∈ Set.Ico (0 : ℝ) 1) (η : TailDatum H) (hη : η ∈ witnesses H s d) : d ≤ tailCofactorBound H * (tailPrimeBound H)^(H-P H) := by rw [← hη.2] exact (Nat.totient_le _).trans (witness_w_bound hs hη.1)
lemma tailLog_nonneg {H : ℕ} {s : ℝ} {η : TailDatum H} (hη : IsWitness H s η) {l : ℕ} (hl : l ∈ Finset.Ico (P H) H) : 0 ≤ tailLog η l := by have hr := rho_pos exact (by have := alpha_pos s; positivity : (0 : ℝ) ≤ (9/10 : ℝ) * alpha s * l * (rho^l)⁻¹).trans (hη.2.2.1 l hl).2.1
lemma D_nonneg {H : ℕ} {s : ℝ} {η : TailDatum H} (hη : IsWitness H s η) {h : ℕ} (hh : H ≤ h) : 0 ≤ D h η := by unfold D apply Finset.sum_nonneg intro l hl have hlH := (Finset.mem_Ico.mp hl).2 exact mul_nonneg (a_pos (by omega)).le (tailLog_nonneg hη hl)
def tailMass {H : ℕ} (η : TailDatum H) : ℝ := ∑ l ∈ Finset.Ico (P H) H, tailLog η l
lemma tailMass_nonneg {H : ℕ} {s : ℝ} {η : TailDatum H} (hη : IsWitness H s η) : 0 ≤ tailMass η := Finset.sum_nonneg (fun _ hl => tailLog_nonneg hη hl)
lemma D_le_log {H : ℕ} {s : ℝ} {η : TailDatum H} (hη : IsWitness H s η) {h : ℕ} (hh : H ≤ h) : D h η ≤ Real.log (h+1 : ℝ) * tailMass η := by unfold D tailMass rw [Finset.mul_sum] apply Finset.sum_le_sum intro l hl have hlH := (Finset.mem_Ico.mp hl).2 have hj : 1 ≤ h-l := by omega apply mul_le_mul_of_nonneg_right _ (tailLog_nonneg hη hl) apply (a_le_log hj).trans apply Real.log_le_log (by positivity) have hsub : h-l ≤ h := Nat.sub_le _ _ exact_mod_cast Nat.add_le_add_right hsub 1
lemma D_le_linear {H : ℕ} {s : ℝ} {η : TailDatum H} (hη : IsWitness H s η) {h : ℕ} (hh : H ≤ h) : D h η ≤ h * tailMass η := by apply (D_le_log hη hh).trans apply mul_le_mul_of_nonneg_right _ (tailMass_nonneg hη) have hlog := Real.log_le_sub_one_of_pos (x := (h+1 : ℝ)) (by positivity) linarith
lemma maxD_nonneg {H : ℕ} {s : ℝ} {T : Finset (TailDatum H)} (hT : ∀ η ∈ T, IsWitness H s η) {h : ℕ} (hh : H ≤ h) : 0 ≤ maxD h T := by classical unfold maxD split_ifs with ht · obtain ⟨η, hη⟩ := ht exact (D_nonneg (hT η hη) hh).trans (Finset.le_sup' (s := T) (D h) hη) · exact le_rfl
lemma maxD_le_linear {H : ℕ} {s : ℝ} {T : Finset (TailDatum H)} (hT : ∀ η ∈ T, IsWitness H s η) {h : ℕ} (hh : H ≤ h) : maxD h T ≤ (h : ℝ) * ∑ η ∈ T, tailMass η := by classical unfold maxD split_ifs with ht · apply Finset.sup'_le intro η hη apply (D_le_linear (hT η hη) hh).trans apply mul_le_mul_of_nonneg_left _ (Nat.cast_nonneg _) exact Finset.single_le_sum (fun ξ hξ => tailMass_nonneg (hT ξ hξ)) hη · have hz : T = ∅ := Finset.not_nonempty_iff_eq_empty.mp ht simp [hz]
theorem summable_tail_threshold {H : ℕ} {s : ℝ} {T : Finset (TailDatum H)} (hT : ∀ η ∈ T, IsWitness H s η) : Summable (fun n : ℕ => rho^(H+n) * maxD (H+n) T) := by have hs : Summable (fun n : ℕ => (n : ℝ) * rho^n) := by simpa using summable_pow_mul_geometric_of_norm_lt_one 1 (show ‖rho‖ < 1 by simpa [Real.norm_eq_abs, abs_of_pos rho_pos] using rho_lt_one) have hshift : Summable (fun n : ℕ => ((H+n : ℕ) : ℝ) * rho^(H+n)) := by simpa [Nat.add_comm] using (summable_nat_add_iff H).2 hs apply Summable.of_nonneg_of_le (fun n => mul_nonneg (pow_nonneg rho_pos.le _) (maxD_nonneg hT (by omega))) (fun n => ?_) (hshift.mul_right (∑ η ∈ T, tailMass η)) have hb := mul_le_mul_of_nonneg_left (maxD_le_linear hT (h := H+n) (by omega)) (pow_nonneg rho_pos.le (H+n)) simpa only [mul_assoc, mul_comm, mul_left_comm] using hb
lemma finite_witness_subsets (H : ℕ) {s : ℝ} (hs : s ∈ Set.Ico (0 : ℝ) 1) (d : ℕ) : {T : Finset (TailDatum H) | (↑T : Set (TailDatum H)) ⊆ witnesses H s d}.Finite := by have h := (witnesses_finite H hs d).finite_subsets exact h.preimage Finset.coe_injective.injOn
open MeasureTheory ProbabilityTheoryopen scoped Classical
private instance expOne_probability : IsProbabilityMeasure (expMeasure 1) := isProbabilityMeasure_expMeasure zero_lt_one
def exponentialProduct : Measure (ℕ → ℝ) := Measure.infinitePi (fun _ : ℕ => expMeasure 1)
instance exponentialProduct_probability : IsProbabilityMeasure exponentialProduct := by unfold exponentialProduct infer_instance
lemma expOne_real_Ioi {t : ℝ} (ht : 0 ≤ t) : (expMeasure 1).real (Set.Ioi t) = Real.exp (-t) := by rw [← Set.compl_Iic, probReal_compl_eq_one_sub measurableSet_Iic, ← cdf_eq_real, cdf_expMeasure_eq zero_lt_one, ite_eq_left ht, one_mul] ring
lemma expOne_Ioi {t : ℝ} (ht : 0 ≤ t) : expMeasure 1 (Set.Ioi t) = ENNReal.ofReal (Real.exp (-t)) := by rw [← expOne_real_Ioi ht, measureReal_def, ENNReal.ofReal_toReal (measure_ne_top _ _)]
lemma exponential_box_probability (b : ℕ → ℝ) (hb : ∀ n, 0 ≤ b n) (hbs : Summable b) : exponentialProduct.real (Set.univ.pi (fun n => Set.Ioi (b n))) = Real.exp (-(∑' n, b n)) := by have hp : HasProd (fun n : ℕ => ENNReal.ofReal (Real.exp (-b n))) (ENNReal.ofReal (Real.exp (-∑' n, b n))) := by have hs := hbs.hasSum.neg.rexp have he := (ENNReal.continuous_ofReal.tendsto (Real.exp (-∑' n, b n))).comp hs unfold HasProd convert he using 1 ext T exact (ENNReal.ofReal_prod_of_nonneg (fun n _ => Real.exp_nonneg (-b n))).symm unfold Measure.real exponentialProduct rw [Measure.infinitePi_pi_univ _ (fun _ => measurableSet_Ioi)] simp_rw [expOne_Ioi (hb _)] rw [hp.tprod_eq, ENNReal.toReal_ofReal (Real.exp_nonneg _)]
def witnessEvent {H : ℕ} (s : ℝ) (η : TailDatum H) : Set (ℕ → ℝ) := Set.univ.pi (fun n => Set.Ioi ((gamma / alpha s) * rho^(H+n) * D (H+n) η))
lemma measurableSet_witnessEvent {H : ℕ} (s : ℝ) (η : TailDatum H) : MeasurableSet (witnessEvent s η) := MeasurableSet.pi Set.countable_univ (fun _ _ => measurableSet_Ioi)
lemma threshold_coefficient_pos (H n : ℕ) (s : ℝ) : 0 < (gamma / alpha s) * rho^(H+n) := mul_pos (div_pos gamma_pos (alpha_pos s)) (pow_pos rho_pos _)
lemma witnessEvent_intersection {H : ℕ} (s : ℝ) (T : Finset (TailDatum H)) (ht : T.Nonempty) : (⋂ η ∈ T, witnessEvent s η) = Set.univ.pi (fun n => Set.Ioi ((gamma / alpha s) * rho^(H+n) * maxD (H+n) T)) := by classical ext u simp only [Set.mem_iInter, witnessEvent, Set.mem_pi, Set.mem_univ, forall_true_left, Set.mem_Ioi] constructor · intro h n unfold maxD rw [dite_eq_left ht] rw [mul_comm ((gamma / alpha s) * rho^(H+n))] apply (lt_div_iff₀ (threshold_coefficient_pos H n s)).mp rw [Finset.sup'_lt_iff ht] intro η hη apply (lt_div_iff₀ (threshold_coefficient_pos H n s)).mpr simpa only [mul_comm] using h η hη n · intro h η hη n apply lt_of_le_of_lt _ (h n) apply mul_le_mul_of_nonneg_left _ (threshold_coefficient_pos H n s).le unfold maxD rw [dite_eq_left ht] exact Finset.le_sup' (s := T) (D (H+n)) hη
lemma witnessEvent_intersection_probability {H : ℕ} {s : ℝ} (T : Finset (TailDatum H)) (ht : T.Nonempty) (hT : ∀ η ∈ T, IsWitness H s η) : exponentialProduct.real (⋂ η ∈ T, witnessEvent s η) = Real.exp (-(gamma / alpha s) * ∑' n, rho^(H+n) * maxD (H+n) T) := by rw [witnessEvent_intersection s T ht] have hs : Summable (fun n => (gamma / alpha s) * rho^(H+n) * maxD (H+n) T) := by simpa only [mul_assoc] using (summable_tail_threshold hT).mul_left (gamma / alpha s) rw [exponential_box_probability _ (fun n => mul_nonneg (threshold_coefficient_pos H n s).le (maxD_nonneg hT (by omega))) hs] congr 1 simp only [mul_assoc, tsum_mul_left, neg_mul]
lemma coefficient_eq_union_probability (H : ℕ) {s : ℝ} (hs : s ∈ Set.Ico (0 : ℝ) 1) (d : ℕ) : (∑ᶠ T : Finset (TailDatum H), if T.Nonempty ∧ (↑T : Set (TailDatum H)) ⊆ witnesses H s d then (-1 : ℝ)^(T.card-1) * Real.exp (-(gamma / alpha s) * ∑' n : ℕ, rho^(H+n) * maxD (H+n) T) else 0) = exponentialProduct.real (⋃ η ∈ (witnesses_finite H hs d).toFinset, witnessEvent s η) := by classical let W := (witnesses_finite H hs d).toFinset have hW (T : Finset (TailDatum H)) : (↑T : Set (TailDatum H)) ⊆ witnesses H s d ↔ T ⊆ W := by constructor · intro h η hη exact ((witnesses_finite H hs d).mem_toFinset).mpr (h hη) · intro h η hη exact ((witnesses_finite H hs d).mem_toFinset).mp (h hη) rw [finsum_eq_sum_of_support_subset _ (s := W.powerset.filter Finset.Nonempty)] · rw [measureReal_biUnion_eq_sum_powerset (fun η _ => measurableSet_witnessEvent s η)] apply Finset.sum_congr rfl intro T hT obtain ⟨hTW, ht⟩ := Finset.mem_filter.mp hT have hsub : (↑T : Set (TailDatum H)) ⊆ witnesses H s d := (hW T).mpr (Finset.mem_powerset.mp hTW) rw [ite_eq_left ⟨ht, hsub⟩, witnessEvent_intersection_probability T ht (fun η hη => (hsub hη).1)] congr 1 have hc : T.card + 1 = T.card - 1 + 2 := by have := Finset.card_pos.mpr ht omega rw [hc, pow_add] norm_num · intro T hT have ht : T.Nonempty ∧ (↑T : Set (TailDatum H)) ⊆ witnesses H s d := by by_contra h simp only [Function.mem_support, ite_eq_right h, ne_eq, not_true_eq_false] at hT exact Finset.mem_filter.mpr ⟨Finset.mem_powerset.mpr ((hW T).mp ht.2), ht.1⟩
theorem AH_nonneg (H : ℕ) {s : ℝ} (hs : s ∈ Set.Ico (0 : ℝ) 1) (f : ℝ → ℝ) (hf : ∀ r : ℝ, 1 ≤ r → 0 ≤ f r ∧ f r ≤ 1) : 0 ≤ AH H f s := by classical unfold AH apply mul_nonneg (mul_nonneg (pow_nonneg rho_pos.le _) (pow_nonneg (div_pos gamma_pos (alpha_pos s)).le _)) apply finsum_nonneg intro d split_ifs with hd · apply mul_nonneg (div_nonneg (hf _ (one_le_ell_ratio hd)).1 (Nat.cast_nonneg d)) rw [coefficient_eq_union_probability H hs d] exact measureReal_nonneg · exact le_rfl
end TotientAsymptotic
end
end OAI1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677import OAI.NumberTheory.TotientAsymptotic.PrimeBoxGeometryimport Mathlib.MeasureTheory.Constructions.Pi
namespace OAI
/-! Aggregate all discrete tails in a box before measuring the continuousprefix. No factor counting the number of tail witnesses occurs. -/
noncomputable sectionopen scoped BigOperatorsopen MeasureTheory
namespace TotientAsymptotic
def tailBoxLift {R T : ℕ} (K : Finset (Fin T → ℕ)) (U : (Fin T → ℕ) → Set (Fin R → ℝ)) : Set ((Fin R → ℝ) × (Fin T → ℝ)) := ⋃ b ∈ K, U b ×ˢ unitGridCell b
lemma measurableSet_tailBoxLift {R T : ℕ} (K : Finset (Fin T → ℕ)) (U : (Fin T → ℕ) → Set (Fin R → ℝ)) (hU : ∀ b ∈ K, MeasurableSet (U b)) : MeasurableSet (tailBoxLift K U) := K.measurableSet_biUnion (fun b hb => (hU b hb).prod (measurableSet_unitGridCell b))
lemma volume_tailBoxLift {R T : ℕ} (K : Finset (Fin T → ℕ)) (U : (Fin T → ℕ) → Set (Fin R → ℝ)) (hU : ∀ b ∈ K, MeasurableSet (U b)) : volume (tailBoxLift K U) = ∑ b ∈ K, volume (U b) := by unfold tailBoxLift rw [measure_biUnion_finset] · apply Finset.sum_congr rfl intro b _ rw [Measure.volume_eq_prod, Measure.prod_prod, volume_unitGridCell, mul_one] · intro b _ c _ hbc exact Set.disjoint_left.mpr (fun z hz hw => Set.disjoint_left.mp (unitGridCell_disjoint hbc) hz.2 hw.2) · intro b hb exact (hU b hb).prod (measurableSet_unitGridCell b)
lemma volumeReal_tailBoxLift {R T : ℕ} (K : Finset (Fin T → ℕ)) (U : (Fin T → ℕ) → Set (Fin R → ℝ)) (hU : ∀ b ∈ K, MeasurableSet (U b)) (hfin : ∀ b ∈ K, volume (U b) ≠ ⊤) : volume.real (tailBoxLift K U) = ∑ b ∈ K, volume.real (U b) := by simp only [measureReal_def, volume_tailBoxLift K U hU, ENNReal.toReal_sum hfin]
/-- A common prefix envelope for every tail in one unit box costs only thereciprocal prime mass of that box. Summing disjoint tail boxes then givesone full-dimensional volume. -/theorem tail_box_aggregation {R T : ℕ} (K : Finset (Fin T → ℕ)) (S : (Fin T → ℕ) → Set (Fin R → ℝ)) (U : (Fin T → ℕ) → Set (Fin R → ℝ)) (C : ℝ) (hU : ∀ b ∈ K, MeasurableSet (U b)) (hfin : ∀ b ∈ K, volume (U b) ≠ ⊤) (hsub : ∀ b ∈ K, ∀ p ∈ primeBoxTuples b, S p ⊆ U b) (hmass : ∀ b ∈ K, (∏ i, unitPrimeWeight (b i)) ≤ C) : (∑ p ∈ gridPrimeTuples K, reciprocalShiftWeight p * volume.real (S p)) ≤ C * volume.real (tailBoxLift K U) := by classical rw [gridPrimeTuples, Finset.sum_biUnion (fun b _ c _ hbc => primeBoxTuples_disjoint hbc), volumeReal_tailBoxLift K U hU hfin, Finset.mul_sum] apply Finset.sum_le_sum intro b hb calc _ ≤ ∑ p ∈ primeBoxTuples b, reciprocalShiftWeight p * volume.real (U b) := by apply Finset.sum_le_sum intro p hp exact mul_le_mul_of_nonneg_left (measureReal_mono (hsub b hb p hp) (hfin b hb)) (reciprocalShiftWeight_nonneg p) _ = (∏ i, unitPrimeWeight (b i))*volume.real (U b) := by rw [← Finset.sum_mul, prime_box_mass] _ ≤ C*volume.real (U b) := mul_le_mul_of_nonneg_right (hmass b hb) measureReal_nonneg
end TotientAsymptotic
end
end OAI1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374import OAI.NumberTheory.TotientAsymptotic.TailBoxAggregation
namespace OAI
/-! The prefix-times-tail-box measure is the usual full-coordinate volume. -/
noncomputable sectionopen scoped BigOperatorsopen MeasureTheory
namespace TotientAsymptotic
def joinCoordinates (R T : ℕ) : ((Fin R → ℝ) × (Fin T → ℝ)) ≃ᵐ (Fin (R+T) → ℝ) := (MeasurableEquiv.sumPiEquivProdPi (fun _ : Fin R ⊕ Fin T => ℝ)).symm.trans (MeasurableEquiv.piCongrLeft (fun _ : Fin (R+T) => ℝ) finSumFinEquiv)
lemma joinCoordinates_left {R T : ℕ} (u : (Fin R → ℝ) × (Fin T → ℝ)) (i : Fin R) : joinCoordinates R T u (Fin.castAdd T i) = u.1 i := by simp [joinCoordinates, MeasurableEquiv.piCongrLeft, Equiv.piCongrLeft, finSumFinEquiv] rfl
lemma joinCoordinates_right {R T : ℕ} (u : (Fin R → ℝ) × (Fin T → ℝ)) (i : Fin T) : joinCoordinates R T u (Fin.natAdd R i) = u.2 i := by simp [joinCoordinates, MeasurableEquiv.piCongrLeft, Equiv.piCongrLeft, finSumFinEquiv] rfl
lemma joinCoordinates_preserves_volume (R T : ℕ) : MeasurePreserving (joinCoordinates R T) volume volume := (volume_measurePreserving_piCongrLeft (fun _ : Fin (R+T) => ℝ) finSumFinEquiv).comp (volume_measurePreserving_sumPiEquivProdPi_symm (fun _ : Fin R ⊕ Fin T => ℝ))
lemma volume_joinCoordinates_image {R T : ℕ} (S : Set ((Fin R → ℝ) × (Fin T → ℝ))) : volume (joinCoordinates R T '' S) = volume S := by have hh := (joinCoordinates_preserves_volume R T).measure_preimage_equiv (joinCoordinates R T '' S) rw [Set.preimage_image_eq S (joinCoordinates R T).injective] at hh exact hh.symm
/-- A full-dimensional enclosure bounds the aggregated weighted prefixvolumes without multiplying by the number of tail witnesses. -/theorem tail_box_aggregation_enclosure {R T : ℕ} (K : Finset (Fin T → ℕ)) (S : (Fin T → ℕ) → Set (Fin R → ℝ)) (U : (Fin T → ℕ) → Set (Fin R → ℝ)) (W : Set (Fin (R+T) → ℝ)) (C : ℝ) (hC : 0 ≤ C) (hU : ∀ b ∈ K, MeasurableSet (U b)) (hfin : volume W ≠ ⊤) (hsub : ∀ b ∈ K, ∀ p ∈ primeBoxTuples b, S p ⊆ U b) (hmass : ∀ b ∈ K, (∏ i, unitPrimeWeight (b i)) ≤ C) (henclose : joinCoordinates R T '' tailBoxLift K U ⊆ W) : (∑ p ∈ gridPrimeTuples K, reciprocalShiftWeight p * volume.real (S p)) ≤ C * volume.real W := by have hmeasure : volume (tailBoxLift K U) ≤ volume W := by rw [← volume_joinCoordinates_image] exact measure_mono henclose have hUfin (b) (hb : b ∈ K) : volume (U b) ≠ ⊤ := by apply ne_top_of_le_ne_top hfin apply le_trans _ hmeasure have hh : U b ×ˢ unitGridCell b ⊆ tailBoxLift K U := by intro z hz exact Set.mem_iUnion.mpr ⟨b, Set.mem_iUnion.mpr ⟨hb, hz⟩⟩ have hm : volume (U b ×ˢ unitGridCell b) ≤ volume (tailBoxLift K U) := measure_mono hh simpa only [Measure.volume_eq_prod, Measure.prod_prod, volume_unitGridCell, mul_one] using hm exact (tail_box_aggregation K S U C hU hUfin hsub hmass).trans (mul_le_mul_of_nonneg_left (ENNReal.toReal_mono hfin hmeasure) hC)
end TotientAsymptotic
end
end OAI12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273import OAI.NumberTheory.TotientAsymptotic.CofactorEnvelope
namespace OAI
/-! The uniform reciprocal cofactor envelope at the discrete tail cut. -/
noncomputable sectionopen scoped BigOperators
namespace TotientAsymptotic
def exponentialCofactorCap (T : ℝ) : ℕ := ⌈Real.exp (Real.exp T)⌉₊
lemma exponentialCofactorCap_bounds {T : ℝ} (hT : 0 ≤ T) : 2 ≤ exponentialCofactorCap T ∧ Real.log (exponentialCofactorCap T : ℝ) ≤ 2*Real.exp T := by have he : 1 ≤ Real.exp T := Real.one_le_exp hT have hY : 2 ≤ Real.exp (Real.exp T) := by linarith [Real.add_one_le_exp (Real.exp T)] have hN : (2 : ℝ) ≤ exponentialCofactorCap T := hY.trans (Nat.le_ceil _) have hNpos : (0 : ℝ) < exponentialCofactorCap T := by linarith refine ⟨by exact_mod_cast hN, ?_⟩ have hcap : (exponentialCofactorCap T : ℝ) ≤ 2*Real.exp (Real.exp T) := by have hh := Nat.ceil_lt_add_one (Real.exp_pos (Real.exp T)).le change (exponentialCofactorCap T : ℝ) < Real.exp (Real.exp T)+1 at hh linarith calc _ ≤ Real.log (2*Real.exp (Real.exp T)) := Real.log_le_log hNpos hcap _ = Real.log 2+Real.exp T := by rw [Real.log_mul (by norm_num) (Real.exp_pos _).ne', Real.log_exp] _ ≤ 2*Real.exp T := by linarith [Real.log_le_sub_one_of_pos (by norm_num : (0 : ℝ)<2)]
theorem exponential_cofactor_sum (hmertens : MertensProductInput) : ∃ C : ℝ, 0 < C ∧ ∀ T : ℝ, 0 ≤ T → (∑ a ∈ Finset.Icc 1 (exponentialCofactorCap T), (a.totient : ℝ)⁻¹) ≤ C*Real.exp (2*T) := by obtain ⟨C, hC, hc⟩ := sum_reciprocal_totient_le hmertens refine ⟨6*C, by positivity, ?_⟩ intro T hT obtain ⟨hN, hlog⟩ := exponentialCofactorCap_bounds hT have he := Real.one_le_exp hT have hlog0 : 0 ≤ Real.log (exponentialCofactorCap T : ℝ) := Real.log_nonneg (by exact_mod_cast (show 1 ≤ exponentialCofactorCap T by omega)) apply (hc _ hN).trans calc _ ≤ C*(2*Real.exp T)*(3*Real.exp T) := by apply mul_le_mul · exact mul_le_mul_of_nonneg_left hlog hC.le · linarith · linarith · positivity _ = 6*C*Real.exp (2*T) := by rw [show 2*T=T+T by ring, Real.exp_add]; ring
/-- The entire allowed cofactor sum has the manuscript's exponential envelopein `P rho^(-P)`, uniformly over the phase. -/theorem tail_cofactor_sum (hmertens : MertensProductInput) : ∃ C : ℝ, 0 < C ∧ ∀ H : ℕ, (∑ a ∈ Finset.Icc 1 (tailCofactorBound H), (a.totient : ℝ)⁻¹) ≤ C*Real.exp (4*(lam/rho)*(P H : ℝ)*(rho^(P H))⁻¹) := by obtain ⟨C, hC, hc⟩ := exponential_cofactor_sum hmertens refine ⟨C, hC, fun H => ?_⟩ have h := hc (2*(lam/rho)*(P H : ℝ)*(rho^(P H))⁻¹) (by have := lam_pos have := rho_pos positivity) convert h using 1 · rfl · congr 2 ring
end TotientAsymptotic
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445import OAI.NumberTheory.TotientAsymptotic.MassUpper
namespace OAI
/-! The logarithmic tail cut is negligible relative to the retained cut. -/
noncomputable sectionopen scoped Topologyopen Filter
namespace TotientAsymptotic
lemma P_div_self_tendsto : Tendsto (fun H : ℕ => (P H : ℝ)/(H : ℝ)) atTop (nhds 0) := by have hlog := Real.tendsto_log_atTop.comp (tendsto_natCast_atTop_atTop : Tendsto (fun H : ℕ => (H : ℝ)) atTop atTop) have hLL := Real.tendsto_log_atTop.comp hlog have ht := Real.isLittleO_log_id_atTop.tendsto_div_nhds_zero.comp (tendsto_natCast_atTop_atTop : Tendsto (fun H : ℕ => (H : ℝ)) atTop atTop) apply squeeze_zero' (g := fun H : ℕ => Real.log (H : ℝ)/(H : ℝ)) · exact Eventually.of_forall (fun _ => div_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _)) · filter_upwards [hLL.eventually (eventually_ge_atTop (0 : ℝ)), eventually_ge_atTop (1 : ℕ)] with H hloglog hH apply div_le_div_of_nonneg_right _ (Nat.cast_nonneg _) exact (Nat.floor_le hloglog).trans (Real.log_le_self (Real.log_nonneg (by exact_mod_cast hH))) · exact ht
lemma eventually_tail_cut_separated : ∀ᶠ H : ℕ in atTop, 1 ≤ P H ∧ P H+2 ≤ H ∧ 100*P H ≤ H ∧ 2*P H ≤ H := by filter_upwards [P_tendsto.eventually (eventually_ge_atTop 1), P_div_self_tendsto.eventually (eventually_lt_nhds (by norm_num : (0 : ℝ)<1/100)), eventually_ge_atTop (1 : ℕ)] with H hP hratio hH have hHpos : (0 : ℝ) < H := by exact_mod_cast (show 0 < H by omega) have hh : (100 : ℝ)*(P H : ℝ) ≤ H := by have hx := (div_lt_iff₀ hHpos).mp hratio linarith have hnat : 100*P H ≤ H := by exact_mod_cast hh exact ⟨hP, by omega, hnat, by omega⟩
end TotientAsymptotic
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293import OAI.NumberTheory.TotientAsymptotic.TailArrayimport OAI.NumberTheory.TotientAsymptotic.CofactorMassimport OAI.NumberTheory.TotientAsymptotic.PrimeBoxGeometry
namespace OAI
/-! A fixed cofactor and the ordered tail-prime vector determine a witness. -/
noncomputable sectionopen scoped BigOperators
namespace TotientAsymptotic
def tailPrimeVector {H : ℕ} (η : TailDatum H) : Fin (H-P H) → ℕ := fun i => tailPrime η (H-1-i.val)
lemma tailVector_eq_primeCoord {H : ℕ} (η : TailDatum H) : tailVector η = primePrefixCoord (tailPrimeVector η) := rfl
lemma tailPrimeVector_prime {H : ℕ} {s : ℝ} {η : TailDatum H} (hη : IsWitness H s η) (i : Fin (H-P H)) : (tailPrimeVector η i).Prime := by apply (hη.2.2.1 _ _).1 have := i.isLt exact Finset.mem_Ico.mpr (by omega)
lemma tailDatum_eq_of_primeVector {H : ℕ} {s t : ℝ} {η ξ : TailDatum H} (hη : IsWitness H s η) (hξ : IsWitness H t ξ) (hcof : η.cofactor=ξ.cofactor) (hvec : tailPrimeVector η=tailPrimeVector ξ) : η=ξ := by have hQ : η.Q=ξ.Q := by funext i by_cases hi : i.val < P H · rw [hη.1 i hi, hξ.1 i hi] · have hib := i.isLt let j : Fin (H-P H) := ⟨H-1-i.val, by omega⟩ have hh := congrFun hvec j have he : H-1-j.val=i.val := by dsimp [j]; omega simpa only [tailPrimeVector, he, tailPrime, dite_eq_left i.isLt] using hh cases η cases ξ cases hQ cases hcof rfl
lemma prod_tail_indices {M : Type*} [CommMonoid M] {H : ℕ} (hPH : P H ≤ H) (f : ℕ → M) : (∏ l ∈ Finset.Ico (P H) H, f l) = ∏ i : Fin (H-P H), f (H-1-i.val) := by apply Finset.prod_bij (fun l hl => (⟨H-1-l, by have := Finset.mem_Ico.mp hl omega⟩ : Fin (H-P H))) · intro l hl exact Finset.mem_univ _ · intro l hl k hk he have := Finset.mem_Ico.mp hl have := Finset.mem_Ico.mp hk have hv := congrArg Fin.val he simp only at hv omega · intro i _ have hi := i.isLt refine ⟨H-1-i.val, Finset.mem_Ico.mpr ⟨by omega, by omega⟩, ?_⟩ apply Fin.ext simp only omega · intro l hl have := Finset.mem_Ico.mp hl have he : H-1-(H-1-l)=l := by omega rw [he]
lemma tail_value_eq_vector {H : ℕ} (η : TailDatum H) (hPH : P H ≤ H) : w η = η.cofactor*∏ i, tailPrimeVector η i := by rw [w, prod_tail_indices hPH] rfl
lemma tail_reciprocal_vector {H : ℕ} {s : ℝ} {η : TailDatum H} (hη : IsWitness H s η) (hPH : P H ≤ H) : ((w η).totient : ℝ)⁻¹ ≤ (η.cofactor.totient : ℝ)⁻¹*reciprocalShiftWeight (tailPrimeVector η) := by have hh := tail_reciprocal_majorant hη rw [prod_tail_indices hPH] at hh have he : (∏ i : Fin (H-P H), (tailPrime η (H-1-i.val)-1 : ℝ)⁻¹) = reciprocalShiftWeight (tailPrimeVector η) := by unfold reciprocalShiftWeight rw [Nat.cast_prod, ← Finset.prod_inv_distrib] apply Finset.prod_congr rfl intro i _ rw [Nat.cast_sub (tailPrimeVector_prime hη i).one_lt.le, Nat.cast_one] rfl rwa [he] at hh
end TotientAsymptotic
end
end OAI12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879import OAI.NumberTheory.TotientAsymptotic.HeadPrimeCountimport OAI.NumberTheory.TotientAsymptotic.OrderedPrimeProductimport OAI.NumberTheory.TotientAsymptotic.PPTComparisonBridgeimport Mathlib.Order.Fin.Tuple
namespace OAI
/-! Counting distinct candidate integers by a finite sum over ordered tails. -/noncomputable sectionopen scoped BigOperators Topologyopen Filternamespace TotientAsymptotic
lemma prime_tail_totient_weight {n : ℕ} (p : Fin n → ℕ) (hp : ∀ i,(p i).Prime) (horder : StrictAnti p) : ((∏ i,p i).totient:ℝ)⁻¹=reciprocalShiftWeight p := by rw [ppt_totient_primeProduct p hp horder.injective] rfl
def tailHeadPairs {n : ℕ} (x : ℝ) (d : ℕ) (Q : Finset (Fin n → ℕ)) : Finset (Σ _p : Fin n → ℕ,ℕ) := Q.sigma (fun p => primeInterval (x/(2*((d*(∏ i,p i).totient:ℕ):ℝ))) (x/((d*(∏ i,p i).totient:ℕ):ℝ)))
theorem tail_head_pair_count : ∀ᶠ x : ℝ in atTop, ∀ d : ℕ,0 < d → ∀ n : ℕ,∀ Q : Finset (Fin n → ℕ), (∀ p ∈ Q,(∀ i,(p i).Prime) ∧ StrictAnti p ∧ Real.log ((d*(∏ i,p i).totient:ℕ):ℝ) ≤ (Real.log x)^(4/5:ℝ)) → (x/(4*d*Real.log x))*(∑ p ∈ Q,reciprocalShiftWeight p) ≤ ((tailHeadPairs x d Q).card:ℝ) := by filter_upwards [head_prime_count_lower,eventually_gt_atTop (1:ℝ)] with x hx hx1 intro d hd n Q hQ have hcount (p) (hp : p ∈ Q) : (x/(4*d*Real.log x))*reciprocalShiftWeight p ≤ ((primeInterval (x/(2*((d*(∏ i,p i).totient:ℕ):ℝ))) (x/((d*(∏ i,p i).totient:ℕ):ℝ))).card:ℝ) := by obtain ⟨hprime,horder,hlog⟩ := hQ p hp have hr : 0 < ∏ i,p i := Finset.prod_pos (fun i _ => (hprime i).pos) have hφ := Nat.totient_pos.mpr hr have hD : (1:ℝ) ≤ ((d*(∏ i,p i).totient:ℕ):ℝ) := by exact_mod_cast Nat.mul_pos hd hφ have hh := hx _ hD hlog apply le_trans _ hh rw [←prime_tail_totient_weight p hprime horder,Nat.cast_mul] ring_nf exact le_rfl have hh := Finset.sum_le_sum hcount simpa only [tailHeadPairs,Finset.card_sigma,Nat.cast_sum,Finset.mul_sum] using hh
lemma ordered_head_product_injective {n : ℕ} {p q : Fin n → ℕ} {a b : ℕ} (hp : ∀ i,(p i).Prime) (hq : ∀ i,(q i).Prime) (ha : a.Prime) (hb : b.Prime) (hpo : StrictAnti p) (hqo : StrictAnti q) (hap : ∀ i,p i < a) (hbq : ∀ i,q i < b) (he : a*(∏ i,p i)=b*(∏ i,q i)) : a=b ∧ p=q := by have hpc : ∀ i : Fin (n+1),Nat.Prime ((Fin.cons a p : Fin (n+1) → ℕ) i) := by intro i refine Fin.cases ha (fun j => ?_) i simpa using hp j have hqc : ∀ i : Fin (n+1),Nat.Prime ((Fin.cons b q : Fin (n+1) → ℕ) i) := by intro i refine Fin.cases hb (fun j => ?_) i simpa using hq j have hpa : StrictAnti (Fin.cons a p) := (Fin.strictMono_cons (α:=OrderDual ℕ)).mpr ⟨hap,hpo⟩ have hqa : StrictAnti (Fin.cons b q) := (Fin.strictMono_cons (α:=OrderDual ℕ)).mpr ⟨hbq,hqo⟩ have hh := ordered_prime_product_injective hpc hqc hpa hqa (by simpa only [Fin.prod_cons] using he) constructor · simpa only [Fin.cons_zero] using congrFun hh 0 · funext i simpa only [Fin.cons_succ] using congrFun hh i.succ
end TotientAsymptotic
end
end OAI1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283import OAI.NumberTheory.TotientAsymptotic.TailRenewalimport OAI.NumberTheory.TotientAsymptotic.PowerApproximation
namespace OAI
/-! Exponential limit of the finite-tail simplex factor, uniformly in phase. -/
noncomputable sectionopen scoped BigOperators Topologyopen Filter
namespace TotientAsymptotic
lemma tailBudget_nonneg {x : ℝ} {H : ℕ} {s : ℝ} (T : Finset (TailDatum H)) (hT : ∀ η ∈ T, IsWitness H s η) (hm : H ≤ m x) : 0 ≤ tailBudget x H T := by unfold tailBudget apply add_nonneg (maxD_nonneg hT hm) apply Finset.sum_nonneg intro i _ apply mul_nonneg (g_pos _).le apply maxD_nonneg hT have hi := i.isLt unfold R at hi omega
/-- The exact power appearing in each intersection volume tends to itsphase-dependent exponential weight; no continuity in the phase is assumed. -/theorem tail_simplex_power_limit (hford : FordRenewalInput) {H : ℕ} {s : ℝ} (T : Finset (TailDatum H)) (hT : ∀ η ∈ T, IsWitness H s η) : Tendsto (fun x : ℝ => (max (1-tailBudget x H T/B x) 0)^(R x H) - Real.exp (-(gamma/alpha (theta x)) * ∑' n : ℕ, rho^(H+n)*maxD (H+n) T)) atTop (nhds 0) := by let S := ∑' n : ℕ, rho^(H+n)*maxD (H+n) T let q : ℝ → ℝ := fun x => tailBudget x H T/B x let b : ℝ → ℝ := fun x => (gamma/alpha (theta x))*S let K := (gamma/lam)*S have hS : 0 ≤ S := tsum_nonneg (fun n => mul_nonneg (pow_nonneg rho_pos.le _) (maxD_nonneg hT (by omega))) have hK : 0 ≤ K := mul_nonneg (div_pos gamma_pos lam_pos).le hS have hq : ∀ᶠ x : ℝ in atTop, 0 ≤ q x := by filter_upwards [m_tendsto.eventually (eventually_ge_atTop H), B_tendsto.eventually (eventually_gt_atTop 0)] with x hm hB exact div_nonneg (tailBudget_nonneg T hT hm) hB.le have hb : ∀ᶠ x : ℝ in atTop, 0 ≤ b x ∧ b x ≤ K := by filter_upwards [theta_eventually_mem] with x hx refine ⟨mul_nonneg (div_pos gamma_pos (alpha_pos _)).le hS, ?_⟩ exact mul_le_mul_of_nonneg_right (div_le_div_of_nonneg_left gamma_pos.le lam_pos (alpha_ge_lam hx.1)) hS have hmerr : Tendsto (fun x => (m x : ℝ)*q x-b x) atTop (nhds 0) := by simpa only [q, b, S, mul_div_assoc] using tailBudget_exponent_error hford T hT have hbound : ∀ᶠ x : ℝ in atTop, (m x : ℝ)*q x ≤ K+1 := by filter_upwards [hmerr.eventually (eventually_lt_nhds (show (0 : ℝ) < 1 by norm_num)), hb] with x he hb linarith have hq0 : Tendsto q atTop (nhds 0) := by apply squeeze_zero' hq · filter_upwards [hbound, m_tendsto.eventually (eventually_gt_atTop 0)] with x hx hm have hmR : (0 : ℝ) < m x := Nat.cast_pos.mpr hm show q x ≤ (K+1)*(m x : ℝ)⁻¹ rw [← div_eq_mul_inv, le_div_iff₀ hmR] nlinarith · simpa using (tendsto_inv_atTop_zero.comp (tendsto_natCast_atTop_atTop.comp m_tendsto)).const_mul (K+1) have hRerr : Tendsto (fun x => (R x H : ℝ)*q x-b x) atTop (nhds 0) := by have hh : Tendsto (fun x => (m x : ℝ)*q x-b x-(H : ℝ)*q x) atTop (nhds 0) := by simpa using hmerr.sub (hq0.const_mul (H : ℝ)) apply hh.congr' filter_upwards [m_tendsto.eventually (eventually_ge_atTop H)] with x hm dsimp [R] rw [Nat.cast_sub hm] ring have hlim := simplex_power_approximation (fun x => R x H) q b K hK ((tendsto_sub_atTop_nat H).comp m_tendsto) hq hb hRerr simpa only [q, b, S, neg_mul] using hlim
end TotientAsymptotic
end
end OAI1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374import OAI.NumberTheory.TotientAsymptotic.HeadLimitedPrimeMass
namespace OAI
/-! The capped tail has the subpower denominator required by the prime window. -/noncomputable sectionopen scoped BigOperators Topologyopen Filternamespace TotientAsymptotic
lemma prime_tail_log_bound {n : ℕ} (p : Fin n → ℕ) (hp : ∀ i,(p i).Prime) {T : ℝ} (hT : ∀ i,primePrefixCoord p i ≤ T) : Real.log ((∏ i,p i : ℕ):ℝ) ≤ n*Real.exp T := by rw [Nat.cast_prod,Real.log_prod (fun i _ => by exact_mod_cast (hp i).ne_zero)] calc _ ≤ ∑ i : Fin n,Real.exp T := by apply Finset.sum_le_sum intro i _ have hi := Real.exp_le_exp.mpr (hT i) have hip : (1:ℝ) < p i := by exact_mod_cast (hp i).one_lt simpa only [primePrefixCoord,Real.exp_log (Real.log_pos hip)] using hi _ = _ := by simp
lemma capped_tail_denominator_budget (d : ℕ) : ∀ᶠ x : ℝ in atTop, Real.log (d:ℝ)+(m x:ℝ)*Real.exp ((19/25:ℝ)*B x) ≤ (Real.log x)^(4/5:ℝ) := by have h₁ : Tendsto (fun x : ℝ => B x*Real.exp (-(1/25:ℝ)*B x)) atTop (nhds 0) := by simpa only [Real.rpow_one,Function.comp_def,neg_mul] using (tendsto_rpow_mul_exp_neg_mul_atTop_nhds_zero (1:ℝ) (1/25) (by norm_num)).comp B_tendsto have h₂ : Tendsto (fun x : ℝ => Real.log (d:ℝ)*Real.exp (-(4/5:ℝ)*B x)) atTop (nhds 0) := by simpa only [Real.rpow_zero,one_mul,mul_zero,Function.comp_def,neg_mul] using ((tendsto_rpow_mul_exp_neg_mul_atTop_nhds_zero (0:ℝ) (4/5) (by norm_num)).comp B_tendsto).const_mul (Real.log (d:ℝ)) have hs := (h₁.add h₂).eventually (eventually_lt_nhds (by norm_num : (0:ℝ)+0<1)) filter_upwards [hs,ambient_polynomial_budget 1 1,eventually_gt_atTop (1:ℝ)] with x hx hm hx1 have hm' : (m x:ℝ) ≤ B x := by simpa only [one_mul,pow_one] using hm have he : (B x*Real.exp (-(1/25:ℝ)*B x)+Real.log (d:ℝ)*Real.exp (-(4/5:ℝ)*B x))* Real.exp ((4/5:ℝ)*B x)= B x*Real.exp ((19/25:ℝ)*B x)+Real.log (d:ℝ) := by rw [add_mul,mul_assoc,mul_assoc,←Real.exp_add,←Real.exp_add] rw [show -(1/25:ℝ)*B x+(4/5:ℝ)*B x=(19/25:ℝ)*B x by ring, show -(4/5:ℝ)*B x+(4/5:ℝ)*B x=0 by ring,Real.exp_zero,mul_one] have hh := mul_le_mul_of_nonneg_right hx.le (Real.exp_pos ((4/5:ℝ)*B x)).le rw [he,one_mul] at hh have hpower : Real.exp ((4/5:ℝ)*B x)=(Real.log x)^(4/5:ℝ) := by rw [Real.rpow_def_of_pos (Real.log_pos hx1)] unfold B rw [mul_comm] rw [hpower] at hh have hmul := mul_le_mul_of_nonneg_right hm' (Real.exp_pos ((19/25:ℝ)*B x)).le linarith only [hmul,hh]
lemma capped_prime_tail_denominator {d : ℕ} (hd : 0 < d) : ∀ᶠ x : ℝ in atTop,∀ n : ℕ,n ≤ m x → ∀ p : Fin n → ℕ, (∀ i,(p i).Prime) → (∀ i,primePrefixCoord p i ≤ (19/25:ℝ)*B x) → Real.log ((d*(∏ i,p i).totient:ℕ):ℝ) ≤ (Real.log x)^(4/5:ℝ) := by filter_upwards [capped_tail_denominator_budget d] with x hx intro n hn p hp hcap have hr : 0 < ∏ i,p i := Finset.prod_pos (fun i _ => (hp i).pos) have hφ : 0 < (∏ i,p i).totient := Nat.totient_pos.mpr hr have hd' : (0:ℝ) < d := by exact_mod_cast hd have hφ' : (0:ℝ) < (∏ i,p i:ℕ).totient := by exact_mod_cast hφ have hlog := Real.log_le_log hφ' (show ((∏ i,p i:ℕ).totient:ℝ) ≤ (∏ i,p i:ℕ) by exact_mod_cast Nat.totient_le (∏ i,p i)) have htail := prime_tail_log_bound p hp hcap have hdim := mul_le_mul_of_nonneg_right (show (n:ℝ) ≤ m x by exact_mod_cast hn) (Real.exp_pos ((19/25:ℝ)*B x)).le rw [Nat.cast_mul,Real.log_mul hd'.ne' hφ'.ne'] linarith only [hlog,htail,hdim,hx]
end TotientAsymptotic
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120import OAI.NumberTheory.TotientAsymptotic.TailVolumeimport OAI.NumberTheory.TotientAsymptotic.RenewalConvolutionimport OAI.NumberTheory.TotientAsymptotic.BandComparison
namespace OAI
/-! The normalized finite-tail budget and its renewal-convolution limit. -/
noncomputable sectionopen scoped BigOperators Topologyopen Filter
namespace TotientAsymptotic
def tailSequence {H : ℕ} (T : Finset (TailDatum H)) (n : ℕ) : ℝ := rho^(H+n)*maxD (H+n) T
lemma tailBudget_eq_sum (x : ℝ) (H : ℕ) (T : Finset (TailDatum H)) : tailBudget x H T = ∑ i ∈ Finset.range (R x H+1), g i*maxD (m x-i) T := by rw [Finset.sum_range_succ'] have hg0 : g 0 = 1 := by simp [g] simp only [Nat.sub_zero, hg0, one_mul] rw [← Fin.sum_univ_eq_sum_range] unfold tailBudget ring
lemma renewalConvolution_tailSequence (x : ℝ) (H : ℕ) (T : Finset (TailDatum H)) (hm : H ≤ m x) : renewalConvolution (tailSequence T) (R x H) = rho^(m x)*tailBudget x H T := by rw [renewalConvolution, tailBudget_eq_sum, Finset.mul_sum] apply Finset.sum_bij (fun i _ => R x H-i) · intro i hi have hi' := Finset.mem_range.mp hi exact Finset.mem_range.mpr (by omega) · intro i hi j hj hij have hi' := Finset.mem_range.mp hi have hj' := Finset.mem_range.mp hj omega · intro j hj have hj' := Finset.mem_range.mp hj exact ⟨R x H-j, Finset.mem_range.mpr (by omega), by omega⟩ · intro i hi have hi' := Finset.mem_range.mp hi have hR : R x H = m x-H := rfl have hidx : m x-(R x H-i) = H+i := by omega have hexp : (R x H-i)+(H+i) = m x := by omega have hpow : rho^(R x H-i)*rho^(H+i) = rho^(m x) := by rw [← pow_add, hexp] dsimp [normalizedRenewal, tailSequence] rw [hidx] calc _ = (rho^(R x H-i)*rho^(H+i)) * (g (R x H-i)*maxD (H+i) T) := by ring _ = _ := by rw [hpow]
/-- The exact tail budget converges after multiplication by `rho^m`.This is the analytic numerator in the manuscript's finite-tail approximation. -/theorem normalized_tailBudget_tendsto (hford : FordRenewalInput) {H : ℕ} {s : ℝ} (T : Finset (TailDatum H)) (hT : ∀ η ∈ T, IsWitness H s η) : Tendsto (fun x : ℝ => rho^(m x)*tailBudget x H T) atTop (nhds (gamma * ∑' n : ℕ, rho^(H+n)*maxD (H+n) T)) := by have hc : Summable (tailSequence T) := summable_tail_threshold hT have hh := (renewalConvolution_tendsto hford (tailSequence T) hc).comp ((tendsto_sub_atTop_nat H).comp m_tendsto) apply hh.congr' filter_upwards [m_tendsto.eventually (eventually_ge_atTop H)] with x hx exact renewalConvolution_tailSequence x H T hx
lemma alpha_ge_lam {s : ℝ} (hs : 0 ≤ s) : lam ≤ alpha s := by unfold alpha have he : 1 ≤ Real.exp (lam*s) := Real.one_le_exp (mul_nonneg lam_pos.le hs) nlinarith [lam_pos]
lemma phase_division_error {ι : Type*} {l : Filter ι} (z v a : ι → ℝ) (L c : ℝ) (hc : 0 < c) (hz : Tendsto z l (nhds L)) (hv : Tendsto v l (nhds 1)) (ha : ∀ᶠ x in l, c ≤ a x) : Tendsto (fun x => z x/(a x*v x)-L/a x) l (nhds 0) := by have ht : Tendsto (fun x => z x/v x-L) l (nhds 0) := by simpa using (hz.div hv (by norm_num : (1 : ℝ) ≠ 0)).sub_const L apply squeeze_zero_norm' (a := fun x => |z x/v x-L|/c) · filter_upwards [ha] with x hx have he : z x/(a x*v x)-L/a x = (z x/v x-L)/a x := by simp only [div_eq_mul_inv, mul_inv_rev] ring rw [he, Real.norm_eq_abs, abs_div, abs_of_pos (hc.trans_le hx)] exact div_le_div_of_nonneg_left (abs_nonneg _) hc hx · simpa using ht.abs.div_const c
/-- The phase-dependent exponent in the simplex volume, before replacing `m`by the prefix dimension `m-H`. -/theorem tailBudget_exponent_error (hford : FordRenewalInput) {H : ℕ} {s : ℝ} (T : Finset (TailDatum H)) (hT : ∀ η ∈ T, IsWitness H s η) : Tendsto (fun x : ℝ => (m x : ℝ)*tailBudget x H T/B x - (gamma / alpha (theta x)) * ∑' n : ℕ, rho^(H+n)*maxD (H+n) T) atTop (nhds 0) := by have hphase : ∀ᶠ x : ℝ in atTop, lam ≤ alpha (theta x) := theta_eventually_mem.mono (fun _ hx => alpha_ge_lam hx.1) have hh := phase_division_error (fun x : ℝ => rho^(m x)*tailBudget x H T) bandCenterRatio (fun x => alpha (theta x)) (gamma * ∑' n : ℕ, rho^(H+n)*maxD (H+n) T) lam lam_pos (normalized_tailBudget_tendsto hford T hT) bandCenterRatio_tendsto hphase apply hh.congr' filter_upwards [B_tendsto.eventually (eventually_gt_atTop (1 : ℝ)), m_tendsto.eventually (eventually_gt_atTop 0)] with x hB hm have hmn : (m x : ℝ) ≠ 0 := Nat.cast_ne_zero.mpr hm.ne' have hr : rho^(m x) ≠ 0 := pow_ne_zero _ rho_pos.ne' have hl : Real.log (B x) ≠ 0 := (Real.log_pos hB).ne' rw [alpha_theta_eq hB] unfold bandCenterRatio field_simp [hmn, hr, hl, lam_pos.ne', (zero_lt_one.trans hB).ne']
end TotientAsymptotic
end
end OAI12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273import OAI.NumberTheory.TotientAsymptotic.SimplexVolumeimport OAI.NumberTheory.TotientAsymptotic.TailBounds
namespace OAI
/-! Exact finite-tail intersection volumes, before prime-box approximation. -/
noncomputable sectionopen scoped BigOperatorsopen MeasureTheory
namespace TotientAsymptotic
lemma prod_g_shifted (N : ℕ) : (∏ i : Fin N, g (i.val+1)) = ∏ i ∈ Finset.Icc 1 N, g i := by rw [Fin.prod_univ_eq_prod_range (fun i => g (i+1))] apply Finset.prod_bij (fun i _ => i+1) · intro i hi have := Finset.mem_range.mp hi exact Finset.mem_Icc.mpr (by omega) · intro i _ j _ hij omega · intro j hj have := Finset.mem_Icc.mp hj refine ⟨j-1, Finset.mem_range.mpr (by omega), by omega⟩ · intro i _ rfl
def tailPrefixRegion (x : ℝ) (H : ℕ) (η : TailDatum H) : Set (Fin (R x H) → ℝ) := prefixRegion (R x H) (B x) (D (m x) η) (fun i => D (m x-(i.val+1)) η)
def tailIntersection (x : ℝ) (H : ℕ) (T : Finset (TailDatum H)) : Set (Fin (R x H) → ℝ) := {u | ∀ η ∈ T, u ∈ tailPrefixRegion x H η}
def tailBudget (x : ℝ) (H : ℕ) (T : Finset (TailDatum H)) : ℝ := maxD (m x) T + ∑ i : Fin (R x H), g (i.val+1) * maxD (m x-(i.val+1)) T
lemma tailIntersection_eq (x : ℝ) (H : ℕ) (T : Finset (TailDatum H)) (hT : T.Nonempty) : tailIntersection x H T = prefixRegion (R x H) (B x) (maxD (m x) T) (fun i => maxD (m x-(i.val+1)) T) := by unfold tailIntersection tailPrefixRegion rw [prefixRegion_intersection (R x H) (B x) T hT] simp only [maxD, dite_eq_left hT]
/-- The intersection-volume identity with the tail budget indexed by the prefix.This form avoids a reversed-index convention in subsequent finite sums. -/theorem volume_tailIntersection (x : ℝ) (H : ℕ) (T : Finset (TailDatum H)) (hT : T.Nonempty) (hR : 0 < R x H) (hB : 0 < B x) : volume (tailIntersection x H T) = ENNReal.ofReal (G x (R x H) * (max (1-tailBudget x H T/B x) 0)^(R x H)) := by rw [tailIntersection_eq x H T hT, volume_prefixRegion_explicit _ hR] have hb : max (B x-tailBudget x H T) 0 = B x * max (1-tailBudget x H T/B x) 0 := by have he : B x * (1-tailBudget x H T/B x) = B x-tailBudget x H T := by field_simp rw [mul_max_of_nonneg _ _ hB.le, he, mul_zero] have he : B x - maxD (m x) T - ∑ i : Fin (R x H), g (i.val+1)*maxD (m x-(i.val+1)) T = B x-tailBudget x H T := by unfold tailBudget; ring rw [he, hb, mul_pow, prod_g_shifted] congr 1 unfold G ring
end TotientAsymptotic
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109import OAI.NumberTheory.TotientAsymptotic.FixedTerminalMassimport OAI.NumberTheory.TotientAsymptotic.SmoothTerminalMassBoundimport OAI.NumberTheory.TotientAsymptotic.TerminalMassSeriesimport OAI.NumberTheory.TotientAsymptotic.PrefixResidualCountimport OAI.NumberTheory.TotientAsymptotic.SmallTerminalPrefix
namespace OAI
/-! Count actual values in a terminal-coordinate strip through distinct residuals. -/noncomputable sectionopen scoped BigOperators Topologyopen Filternamespace TotientAsymptotic
theorem terminal_band_value_count (H : ℕ) : ∃ C c : ℝ,0 < C ∧ 0 < c ∧ ∀ᶠ x : ℝ in atTop,∀ N : ℕ,N+2+H=m x → ∀ k : ℕ,2 ≤ k → ∀ Q : Finset ℕ,∀ n : ℕ → ℕ, (∀ v ∈ Q,0 < n v ∧ (n v).totient=v ∧ x^(1/4:ℝ) ≤ fordPrime (n v) 0 ∧ (v:ℝ) ≤ x ∧ N+2 ≤ (n v).primeFactorsList.length ∧ fordPrime (n v) (N+2) < fordPrime (n v) (N+1) ∧ (k:ℝ) ≤ fordPrimeCoordinate (n v) (N+2) ∧ fordPrimeCoordinate (n v) (N+2) ≤ (k:ℝ)+1 ∧ ∀ i < N+2,fordRowSum (m x) (fordPrimeCoordinate (n v)) i ≤ xi x i*(if i=0 then B x else fordPrimeCoordinate (n v) i)) → (Q.card:ℝ) ≤ C*(x/Real.log x)*G x (N+1)*terminalMassWeight c k := by classical obtain ⟨A,c,hA,hc,hmass⟩ := fixed_terminal_prime_mass (H+1) obtain ⟨D,hD,hres⟩ := smooth_terminal_mass_bound refine ⟨64*A*D,c,by positivity,hc,?_⟩ filter_upwards [hmass,large_prime_product_value_count,eventually_gt_atTop (1:ℝ), B_tendsto.eventually (eventually_gt_atTop (0:ℝ))] with x hm hcount hx hB intro N hNm k hk Q n hQ let P := Q.image (fun v => fordPrefixPrimes (n v) (N+1)) let R := Q.image (fun v => (fordCofactor (n v) (N+2)).totient) have hk' : (2:ℝ) ≤ k := by exact_mod_cast hk have hpre (v) (hv : v ∈ Q) : (∀ i,(fordPrefixPrimes (n v) (N+1) i).Prime) ∧ primePrefixCoord (fordPrefixPrimes (n v) (N+1)) ∈ enlargedSimplex (N+1) (B x) (xi x 0) (fun i => xi x (i.val+1)) ∧ (1/100:ℝ) ≤ primePrefixCoord (fordPrefixPrimes (n v) (N+1)) (Fin.last N) := by have ho := ford_coordinate_antitone (n v) (show N+1 ≤ N+2 by omega) have hprev : 1 < fordPrimeCoordinate (n v) (N+1) := by linarith only [ho,(hQ v hv).2.2.2.2.2.2.1,hk'] have hh := terminal_prefix_conditions (j:=N+2) (L:=m x) (by omega) (by omega) (by norm_num : (1/100:ℝ) ≤ 1) hprev (hQ v hv).2.2.2.2.2.2.2.2 exact ⟨hh.1,hh.2.1,hh.2.2 (Fin.last N) (by simp)⟩ have hlast (v) (hv : v ∈ Q) : primePrefixCoord (fordPrefixPrimes (n v) (N+1)) (Fin.last N)= fordPrimeCoordinate (n v) (N+1) := by have ho := ford_coordinate_antitone (n v) (show N+1 ≤ N+2 by omega) have hpos : 0 < fordPrimeCoordinate (n v) (N+1) := by linarith only [ho,(hQ v hv).2.2.2.2.2.2.1,hk'] change primeDoubleLog (n v) (N+1)=fordPrimeCoordinate (n v) (N+1) exact (fordPrimeCoordinate_eq_raw_of_pos hpos).symm have hPmass : (∑ p ∈ P,reciprocalShiftWeight p) ≤ A*G x (N+1)*Real.exp (-c*(k:ℝ)) := by apply hm N (by omega) k (by positivity) P intro p hp obtain ⟨v,hv,rfl⟩ := Finset.mem_image.mp hp refine ⟨(hpre v hv).1,?_,(hpre v hv).2.2,?_⟩ · simpa only [xi_eq_simplexBoxError,Nat.sub_zero] using (hpre v hv).2.1 · rw [hlast v hv] exact ((hQ v hv).2.2.2.2.2.2.1).trans (ford_coordinate_antitone (n v) (by omega)) have hRpos (d) (hd : d ∈ R) : 0 < d := by obtain ⟨v,_,rfl⟩ := Finset.mem_image.mp hd exact Nat.totient_pos.mpr (fordCofactor_pos _ _) have hRmass : (∑ d ∈ R,(d:ℝ)⁻¹) ≤ D*Real.exp (10*(Real.log ((k:ℝ)+5))^2) := by apply hres k (by positivity) R intro d hd obtain ⟨v,hv,rfl⟩ := Finset.mem_image.mp hd exact ⟨⟨fordCofactor (n v) (N+2),fordCofactor_pos _ _,rfl⟩, small_terminal_smooth (by positivity) (hQ v hv).2.2.2.2.2.2.2.1⟩ have hh := hcount (N+1) P R Q (by intro p hp obtain ⟨v,hv,rfl⟩ := Finset.mem_image.mp hp exact (hpre v hv).1) hRpos (by intro v hv obtain ⟨hn,hφ,hhead,hvx,hlen,hgap,_,_,_⟩ := hQ v hv refine ⟨n v,fordPrime (n v) 0,hn,hφ,fordPrime_prime (by omega),?_,hhead,hvx,?_⟩ · have he := fordCofactor_step (n v) 0 rw [fordCofactor_zero hn] at he exact ⟨fordCofactor (n v) 1,he⟩ · apply Finset.mem_image.mpr refine ⟨(fordPrefixPrimes (n v) (N+1),(fordCofactor (n v) (N+2)).totient), Finset.mem_product.mpr ⟨Finset.mem_image.mpr ⟨v,hv,rfl⟩, Finset.mem_image.mpr ⟨v,hv,rfl⟩⟩,?_⟩ exact (strict_gap_residual_totient hn (by omega) hlen hgap).symm) have hnon : 0 ≤ 64*x/Real.log x := by have hl := Real.log_pos hx positivity have hsum := mul_le_mul hPmass hRmass (Finset.sum_nonneg (fun _ _ => inv_nonneg.mpr (Nat.cast_nonneg _))) (by have hG := G_pos hB (N+1); positivity) apply hh.trans have hmul := mul_le_mul_of_nonneg_left hsum hnon rw [←mul_assoc] at hmul apply hmul.trans_eq unfold terminalMassWeight rw [show 10*(Real.log ((k:ℝ)+5))^2-c*k=(-c*(k:ℝ))+10*(Real.log ((k:ℝ)+5))^2 by ring,Real.exp_add] ring
end TotientAsymptotic
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748import OAI.NumberTheory.TotientAsymptotic.TerminalStateMass
namespace OAI
/-! Absorption of the terminal allocation factor into Ford's logarithmic exponent. -/noncomputable sectionnamespace TotientAsymptotic
lemma terminal_allocation_log_le {k : ℕ} (hk : 2 ≤ k) : Real.log ((k:ℝ)*(k+1)) ≤ 3*Real.log k := by have hkR : (2:ℝ) ≤ k := by exact_mod_cast hk have hk0 : (0:ℝ) < k := by linarith have hle : (k:ℝ)+1 ≤ (k:ℝ)^2 := by nlinarith have hh := Real.log_le_log (by linarith : (0:ℝ) < k+1) hle rw [Real.log_pow] at hh norm_num only [Nat.cast_ofNat] at hh rw [Real.log_mul hk0.ne' (by linarith : (k:ℝ)+1 ≠ 0)] linarith
lemma terminal_allocation_log_budget {k : ℕ} {v : ℝ} (hk : 2 ≤ k) (hv : 1 < v) (hBv : 0 ≤ B v) : ((k:ℝ)*(k+1))^(4*(k:ℝ)*B v)*(Real.log v) ≤ (Real.log v)^(20*(k:ℝ)*Real.log k+1) := by have hkR : (2:ℝ) ≤ k := by exact_mod_cast hk have hk0 : (0:ℝ) < k := by linarith have hbase : (0:ℝ) < (k:ℝ)*(k+1) := by positivity have hlogv : 0 < Real.log v := Real.log_pos hv have hlogk : 0 ≤ Real.log k := Real.log_nonneg (by linarith) have he : 4*(k:ℝ)*B v*Real.log ((k:ℝ)*(k+1)) ≤ (20*(k:ℝ)*Real.log k)*B v := by have h := mul_le_mul_of_nonneg_left (terminal_allocation_log_le hk) (show 0 ≤ 4*(k:ℝ)*B v by positivity) nlinarith [mul_nonneg (mul_nonneg hk0.le hBv) hlogk] have hh : ((k:ℝ)*(k+1))^(4*(k:ℝ)*B v) ≤ (Real.log v)^(20*(k:ℝ)*Real.log k) := by rw [Real.rpow_def_of_pos hbase,Real.rpow_def_of_pos hlogv] apply Real.exp_le_exp.mpr simpa only [B,mul_comm] using he calc _ ≤ (Real.log v)^(20*(k:ℝ)*Real.log k)*Real.log v := mul_le_mul_of_nonneg_right hh hlogv.le _ = _ := by rw [Real.rpow_add hlogv,Real.rpow_one]
end TotientAsymptotic
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051import OAI.NumberTheory.TotientAsymptotic.QuarterPowerBudget
namespace OAI
/-! The smooth residual mass is summable against terminal-coordinate decay. -/noncomputable sectionopen scoped BigOperators Topologyopen Filternamespace TotientAsymptotic
def terminalMassWeight (c : ℝ) (k : ℕ) : ℝ := Real.exp (10*(Real.log ((k:ℝ)+5))^2-c*k)
lemma terminalMassWeight_pos (c : ℝ) (k : ℕ) : 0 < terminalMassWeight c k := Real.exp_pos _
theorem summable_terminalMassWeight {c : ℝ} (hc : 0 < c) : Summable (terminalMassWeight c) := by let q := Real.exp (-c/2) have hq0 : 0 ≤ q := (Real.exp_pos _).le have hq1 : q < 1 := Real.exp_lt_one_iff.mpr (by linarith only [hc]) apply (summable_geometric_of_lt_one hq0 hq1).of_norm_bounded_eventually_nat filter_upwards [tendsto_natCast_atTop_atTop.eventually (eventually_ge_atTop (((10000*((0:ℝ)+31)^2)/(c/4))^(4/3:ℝ))), eventually_ge_atTop (1:ℕ)] with k hk hk1 have hk0 : (1:ℝ) ≤ k := by exact_mod_cast hk1 have hb : 1 ≤ (k:ℝ)+1 := by linarith only [hk0] have hthreshold : ((10000*((0:ℝ)+31)^2)/(c/4))^(4/3:ℝ) ≤ (k:ℝ)+1 := by linarith only [hk] have hbudget := four_thirds_threshold_budget hb (le_refl (0:ℝ)) (show 0 < c/4 by linarith only [hc]) hthreshold have hlog : 0 ≤ Real.log ((k:ℝ)+5) := Real.log_nonneg (by linarith only [hk0]) have he : 10*(Real.log ((k:ℝ)+5))^2-c*k ≤ -(c/2)*(k:ℝ) := by simp only [add_zero] at hbudget rw [show (k:ℝ)+1+4=(k:ℝ)+5 by ring] at hbudget have hh : c/4*((k:ℝ)+1) ≤ (c/2)*(k:ℝ) := by nlinarith only [hc,hk0] nlinarith only [hbudget,hh,hlog,sq_nonneg (Real.log ((k:ℝ)+5))] rw [Real.norm_eq_abs,abs_of_pos (terminalMassWeight_pos c k)] dsimp only [terminalMassWeight,q] rw [← Real.exp_nat_mul] apply Real.exp_le_exp.mpr nlinarith only [he]
lemma finite_terminal_mass_bound {c : ℝ} (hc : 0 < c) (I : Finset ℕ) : (∑ k ∈ I,terminalMassWeight c k) ≤ ∑' k : ℕ,terminalMassWeight c k := (summable_terminalMassWeight hc).sum_le_tsum _ (fun k _ => (terminalMassWeight_pos c k).le)
end TotientAsymptotic
end
end OAI1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071import OAI.NumberTheory.TotientAsymptotic.TerminalBandCount
namespace OAI
/-! Retain an arbitrary restriction on the prime prefix while counting aterminal strip through its distinct residual totients. -/noncomputable sectionopen scoped BigOperators Topologyopen Filternamespace TotientAsymptotic
theorem terminal_prefix_mass_count : ∃ D : ℝ,0 < D ∧ ∀ᶠ x : ℝ in atTop,∀ K k : ℕ,∀ Q : Finset ℕ,∀ n : ℕ → ℕ, (∀ v∈Q,0 < n v ∧ (n v).totient=v ∧ x^(1/4:ℝ) ≤ fordPrime (n v) 0 ∧ (v:ℝ) ≤ x ∧ K+1 ≤ (n v).primeFactorsList.length ∧ fordPrime (n v) (K+1) < fordPrime (n v) K ∧ fordPrimeCoordinate (n v) (K+1) ≤ (k:ℝ)+1) → (Q.card:ℝ) ≤ D*(x/Real.log x)* (∑ p∈Q.image (fun v => fordPrefixPrimes (n v) K),reciprocalShiftWeight p)* Real.exp (10*(Real.log ((k:ℝ)+5))^2) := by obtain ⟨D,hD,hres⟩ := smooth_terminal_mass_bound refine ⟨64*D,by positivity,?_⟩ filter_upwards [large_prime_product_value_count,eventually_gt_atTop (1:ℝ)] with x hx hx1 intro K k Q n hQ let P := Q.image (fun v => fordPrefixPrimes (n v) K) let R := Q.image (fun v => (fordCofactor (n v) (K+1)).totient) have hRpos (d) (hd : d∈R) : 0 < d := by obtain ⟨v,_,rfl⟩ := Finset.mem_image.mp hd exact Nat.totient_pos.mpr (fordCofactor_pos _ _) have hRmass : (∑ d∈R,(d:ℝ)⁻¹) ≤ D*Real.exp (10*(Real.log ((k:ℝ)+5))^2) := by apply hres k (by positivity) R intro d hd obtain ⟨v,hv,rfl⟩ := Finset.mem_image.mp hd exact ⟨⟨fordCofactor (n v) (K+1),fordCofactor_pos _ _,rfl⟩, small_terminal_smooth (by positivity) (hQ v hv).2.2.2.2.2.2⟩ have hh := hx K P R Q (by intro p hp i obtain ⟨v,hv,rfl⟩ := Finset.mem_image.mp hp apply fordPrime_prime have hlen := (hQ v hv).2.2.2.2.1 have := i.isLt omega) hRpos (by intro v hv obtain ⟨hn,hφ,hhead,hvx,hlen,hgap,_⟩ := hQ v hv refine ⟨n v,fordPrime (n v) 0,hn,hφ,fordPrime_prime (by omega),?_,hhead,hvx,?_⟩ · have he := fordCofactor_step (n v) 0 rw [fordCofactor_zero hn] at he exact ⟨fordCofactor (n v) 1,he⟩ · apply Finset.mem_image.mpr refine ⟨(fordPrefixPrimes (n v) K,(fordCofactor (n v) (K+1)).totient), Finset.mem_product.mpr ⟨Finset.mem_image.mpr ⟨v,hv,rfl⟩, Finset.mem_image.mpr ⟨v,hv,rfl⟩⟩,?_⟩ have he := (strict_gap_residual_totient (n:=n v) (j:=K+1) hn (by omega) hlen hgap).symm change (fordCofactor (n v) (K+1)).totient * (∏ i : Fin K,fordPrime (n v) (i.val+1)).totient = _ rw [Fin.prod_univ_eq_prod_range (fun i => fordPrime (n v) (i+1))] at he ⊢ simpa only [Nat.add_sub_cancel] using he) apply hh.trans have hcoef : 0 ≤ (64*x/Real.log x)*(∑ p∈P,reciprocalShiftWeight p) := mul_nonneg (div_nonneg (by positivity) (Real.log_pos hx1).le) (Finset.sum_nonneg (fun p _ => reciprocalShiftWeight_nonneg p)) have hh' := mul_le_mul_of_nonneg_left hRmass hcoef convert hh' using 1; dsimp only [P]; ring
end TotientAsymptotic
end
end OAI12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576import OAI.NumberTheory.TotientAsymptotic.SmallTerminalPrefix
namespace OAI
/-! A valid Ford row forbids three consecutive equal positive coordinates. -/noncomputable sectionopen scoped BigOperatorsnamespace TotientAsymptotic
lemma ford_first_two_coefficient_sum : (32/25:ℝ) ≤ a 1+a 2 := by have he : a 1+a 2=3*Real.log 3-2 := by norm_num [a]; ring rw [he] linarith [Real.log_three_gt_d9]
lemma ford_row_forbids_flat_triple {x : ℝ} {n L i : ℕ} (hi : i+2 ≤ L) (hpos : 0 < fordPrimeCoordinate n i) (h1 : fordPrimeCoordinate n (i+1)=fordPrimeCoordinate n i) (h2 : fordPrimeCoordinate n (i+2)=fordPrimeCoordinate n i) (hrow : fordRowSum L (fordPrimeCoordinate n) i ≤ xi x i*fordPrimeCoordinate n i) : False := by have hs : a 1*fordPrimeCoordinate n (i+1)+a 2*fordPrimeCoordinate n (i+2) ≤ fordRowSum L (fordPrimeCoordinate n) i := by calc _ = ∑ r ∈ ({i+1,i+2}:Finset ℕ),a (r-i)*fordPrimeCoordinate n r := by simp _ ≤ _ := by apply Finset.sum_le_sum_of_subset_of_nonneg · intro r hr rcases Finset.mem_insert.mp hr with rfl | hr · exact Finset.mem_Icc.mpr (by omega) · have he := Finset.mem_singleton.mp hr subst r exact Finset.mem_Icc.mpr (by omega) · intro r hr _ have hr := Finset.mem_Icc.mp hr exact mul_nonneg (a_pos (by omega)).le (le_max_left _ _) have hxi : xi x i ≤ (10001/10000:ℝ) := by have he : Real.exp (-((m x-i:ℕ):ℝ)/40) ≤ 1 := Real.exp_le_one_iff.mpr (by have := Nat.cast_nonneg (α:=ℝ) (m x-i); linarith) unfold xi linarith only [he] rw [h1,h2] at hs have ha := mul_le_mul_of_nonneg_right ford_first_two_coefficient_sum hpos.le have hb := mul_le_mul_of_nonneg_right hxi hpos.le nlinarith only [hs,hrow,ha,hb,hpos]
/-- At one of the last two boundaries there is a strict prime gap, and theresidual largest coordinate is exactly the final one. -/lemma terminal_strict_prime_gap {x : ℝ} {n L : ℕ} (hL : 3 ≤ L) (hpos : 0 < fordPrimeCoordinate n L) (hrow : fordRowSum L (fordPrimeCoordinate n) (L-2) ≤ xi x (L-2)*fordPrimeCoordinate n (L-2)) : ∃ j : ℕ,L-1 ≤ j ∧ j ≤ L ∧ fordPrime n j < fordPrime n (j-1) ∧ fordPrimeCoordinate n j=fordPrimeCoordinate n L := by have hprev := ford_coordinate_antitone n (show L-1 ≤ L by omega) by_cases hgap : fordPrimeCoordinate n L < fordPrimeCoordinate n (L-1) · exact ⟨L,by omega,le_rfl,fordPrime_lt_of_coordinate_lt hgap,rfl⟩ have he : fordPrimeCoordinate n (L-1)=fordPrimeCoordinate n L := le_antisymm (le_of_not_gt hgap) hprev have hprev' := ford_coordinate_antitone n (show L-2 ≤ L-1 by omega) have hgap' : fordPrimeCoordinate n (L-1) < fordPrimeCoordinate n (L-2) := by by_contra hh have he' : fordPrimeCoordinate n (L-2)=fordPrimeCoordinate n (L-1) := le_antisymm (le_of_not_gt hh) hprev' apply ford_row_forbids_flat_triple (i:=L-2) (by omega) (by linarith only [he,he',hpos]) ?_ ?_ hrow · simpa only [show L-2+1=L-1 by omega] using he'.symm · simpa only [show L-2+2=L by omega] using (he'.trans he).symm refine ⟨L-1,le_rfl,by omega,?_,he⟩ have hh := fordPrime_lt_of_coordinate_lt hgap' simpa only [Nat.sub_sub] using hh
end TotientAsymptotic
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172import OAI.NumberTheory.TotientAsymptotic.TerminalBandCount
namespace OAI
/-! Sum the actual terminal-coordinate strips using their finite residual masses. -/noncomputable sectionopen scoped BigOperators Topologyopen Filternamespace TotientAsymptotic
theorem terminal_slice_value_count (H : ℕ) : ∃ C : ℝ,0 < C ∧ ∀ᶠ x : ℝ in atTop,∀ N : ℕ,N+2+H=m x → ∀ Q : Finset ℕ,∀ n : ℕ → ℕ, (∀ v ∈ Q,0 < n v ∧ (n v).totient=v ∧ x^(1/4:ℝ) ≤ fordPrime (n v) 0 ∧ (v:ℝ) ≤ x ∧ N+2 ≤ (n v).primeFactorsList.length ∧ fordPrime (n v) (N+2) < fordPrime (n v) (N+1) ∧ 2 < fordPrimeCoordinate (n v) (N+2) ∧ ∀ i < N+2,fordRowSum (m x) (fordPrimeCoordinate (n v)) i ≤ xi x i*(if i=0 then B x else fordPrimeCoordinate (n v) i)) → (Q.card:ℝ) ≤ C*(x/Real.log x)*G x (N+1) := by classical obtain ⟨A,c,hA,hc,hcount⟩ := terminal_band_value_count H let T := ∑' k : ℕ,terminalMassWeight c k have hT : 0 ≤ T := tsum_nonneg (fun k => (terminalMassWeight_pos c k).le) refine ⟨A*(T+1),by positivity,?_⟩ filter_upwards [hcount,eventually_gt_atTop (1:ℝ), B_tendsto.eventually (eventually_gt_atTop (0:ℝ))] with x hx hx1 hB intro N hNm Q n hQ let key : ℕ → ℕ := fun v => ⌊fordPrimeCoordinate (n v) (N+2)⌋₊ let I := Q.image key let R (k : ℕ) := Q.filter (fun v => key v=k) have hcover : Q ⊆ I.biUnion R := by intro v hv exact Finset.mem_biUnion.mpr ⟨key v,Finset.mem_image.mpr ⟨v,hv,rfl⟩, Finset.mem_filter.mpr ⟨hv,rfl⟩⟩ have hcard : (Q.card:ℝ) ≤ ∑ k ∈ I,((R k).card:ℝ) := by exact_mod_cast (Finset.card_le_card hcover).trans Finset.card_biUnion_le have hrow (k : ℕ) (hk : k ∈ I) : ((R k).card:ℝ) ≤ A*(x/Real.log x)*G x (N+1)*terminalMassWeight c k := by obtain ⟨v,hv,rfl⟩ := Finset.mem_image.mp hk have hk2 : 2 ≤ key v := Nat.le_floor (hQ v hv).2.2.2.2.2.2.1.le apply hx N hNm (key v) hk2 (R (key v)) n intro w hw obtain ⟨hw,hkey⟩ := Finset.mem_filter.mp hw obtain ⟨hn,hφ,hhead,hwx,hlen,hgap,hlarge,hrows⟩ := hQ w hw refine ⟨hn,hφ,hhead,hwx,hlen,hgap,?_,?_,hrows⟩ · rw [← hkey] exact Nat.floor_le (le_max_left _ _) · rw [← hkey] exact (Nat.lt_floor_add_one _).le have hfac : 0 ≤ A*(x/Real.log x)*G x (N+1) := by have hlog := Real.log_pos hx1 have hG := G_pos hB (N+1) positivity calc _ ≤ ∑ k ∈ I,((R k).card:ℝ) := hcard _ ≤ ∑ k ∈ I,A*(x/Real.log x)*G x (N+1)*terminalMassWeight c k := Finset.sum_le_sum hrow _ = (A*(x/Real.log x)*G x (N+1))*(∑ k ∈ I,terminalMassWeight c k) := by rw [Finset.mul_sum] _ ≤ (A*(x/Real.log x)*G x (N+1))*T := mul_le_mul_of_nonneg_left (finite_terminal_mass_bound hc I) hfac _ ≤ (A*(x/Real.log x)*G x (N+1))*(T+1) := mul_le_mul_of_nonneg_left (by linarith) hfac _ = _ := by ring
end TotientAsymptotic
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869import OAI.NumberTheory.TotientAsymptotic.BandStatesimport OAI.NumberTheory.TotientAsymptotic.TupleRecoveryimport OAI.NumberTheory.TotientAsymptotic.ResidualFactorCount
namespace OAI
/-! Exact multiplicity bounds for the final smooth factor states. -/noncomputable sectionopen scoped BigOperatorsattribute [local instance] Classical.propDecidablenamespace TotientAsymptotic
def terminalRight {k : ℕ} (t : ShiftedPair k) : Fin (k+1) → ℕ := Fin.cons t.remainder t.right
lemma terminalRight_product {k : ℕ} (t : ShiftedPair k) : (∏ j,terminalRight t j)=t.remainder*(∏ j,t.right j) := by simp only [terminalRight,Fin.prod_univ_succ,Fin.cons_zero,Fin.cons_succ]
lemma terminal_state_encoding_injective {k : ℕ} : Function.Injective (fun t : ShiftedPair k => (t.left,terminalRight t)) := by intro t s he have hl : t.left=s.left := congrArg Prod.fst he have hr : terminalRight t=terminalRight s := congrArg Prod.snd he have he₀ : t.remainder=s.remainder := congrFun hr 0 have he₁ : t.right=s.right := by funext j exact congrFun hr j.succ cases t cases s cases hl cases he₁ cases he₀ rfl
lemma terminal_state_card_le {k d s : ℕ} (hd : 0 < d) (hs : 0 < s) (Q : Finset (ShiftedPair k)) (hQ : ∀ t ∈ Q,factorProduct t=s ∧ d*factorProduct t=t.remainder*(∏ j,t.right j)) : Q.card ≤ (k+1)^d.primeFactorsList.length*(k*(k+1))^s.primeFactorsList.length := by classical let L := Q.image (fun t => t.left) let R := Q.image terminalRight let E := Q.image (fun t => (t.left,terminalRight t)) have hE : E ⊆ L ×ˢ R := by intro w hw obtain ⟨t,ht,rfl⟩ := Finset.mem_image.mp hw exact Finset.mem_product.mpr ⟨Finset.mem_image.mpr ⟨t,ht,rfl⟩,Finset.mem_image.mpr ⟨t,ht,rfl⟩⟩ have hc := ordered_factorization_pairs_card_le s (d*s) hs (Nat.mul_pos hd hs) L R (by intro f hf obtain ⟨t,ht,rfl⟩ := Finset.mem_image.mp hf exact (hQ t ht).1) (by intro f hf obtain ⟨t,ht,rfl⟩ := Finset.mem_image.mp hf rw [terminalRight_product,← (hQ t ht).2,(hQ t ht).1]) have hcard : E.card=Q.card := Finset.card_image_of_injective Q terminal_state_encoding_injective calc Q.card=E.card := hcard.symm _ ≤ (L ×ˢ R).card := Finset.card_le_card hE _ ≤ k^s.primeFactorsList.length*(k+1)^(d*s).primeFactorsList.length := by simpa only [Fintype.card_fin] using hc _ = _ := by rw [omega_count_mul hd.ne' hs.ne',pow_add,mul_pow]; ring
end TotientAsymptotic
end
end OAI1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162import OAI.NumberTheory.TotientAsymptotic.TerminalStateCountimport OAI.NumberTheory.TotientAsymptotic.SmoothResidualMass
namespace OAI
/-! The final smooth-state mass with its exact cancelled-product exponent. -/noncomputable sectionopen scoped BigOperatorsattribute [local instance] Classical.propDecidablenamespace TotientAsymptotic
theorem terminal_state_mass {k d N : ℕ} {L : ℝ} (hk : 1 ≤ k) (hd : 0 < d) (Q : Finset (ShiftedPair k)) (hQ : ∀ t ∈ Q,0 < factorProduct t ∧ d*factorProduct t=t.remainder*(∏ j,t.right j) ∧ largestPrimeFactor (factorProduct t) ≤ N ∧ ((factorProduct t).primeFactorsList.length:ℝ) ≤ L) : (∑ t ∈ Q,(factorProduct t:ℝ)⁻¹) ≤ (k+1:ℝ)^d.primeFactorsList.length*((k:ℝ)*(k+1))^L*primeEulerProduct N := by classical let P := Q.image factorProduct let W := (k+1:ℝ)^d.primeFactorsList.length*((k:ℝ)*(k+1))^L have hW : 0 ≤ W := by dsimp [W]; positivity have hmap : ∀ t ∈ Q,factorProduct t ∈ P := fun t ht => Finset.mem_image.mpr ⟨t,ht,rfl⟩ have hP (s : ℕ) (hs : s ∈ P) : 0 < s ∧ largestPrimeFactor s ≤ N ∧ (s.primeFactorsList.length:ℝ) ≤ L := by obtain ⟨t,ht,rfl⟩ := Finset.mem_image.mp hs exact ⟨(hQ t ht).1,(hQ t ht).2.2⟩ have hfiber (s : ℕ) (hs : s ∈ P) : (∑ t ∈ Q.filter (fun t => factorProduct t=s),(factorProduct t:ℝ)⁻¹) ≤ W*(s:ℝ)⁻¹ := by let F := Q.filter (fun t => factorProduct t=s) have hF : ∀ t ∈ F,factorProduct t=s ∧ d*factorProduct t=t.remainder*(∏ j,t.right j) := by intro t ht exact ⟨(Finset.mem_filter.mp ht).2,(hQ t (Finset.mem_filter.mp ht).1).2.1⟩ have hc := terminal_state_card_le hd (hP s hs).1 F hF have hcr : (F.card:ℝ) ≤ (k+1:ℝ)^d.primeFactorsList.length* ((k:ℝ)*(k+1))^s.primeFactorsList.length := by exact_mod_cast hc have hkR : (1:ℝ) ≤ k := by exact_mod_cast hk have hb : (1:ℝ) ≤ (k:ℝ)*(k+1) := by nlinarith have hp := Real.rpow_le_rpow_of_exponent_le hb (hP s hs).2.2 rw [Real.rpow_natCast] at hp have hcard : (F.card:ℝ) ≤ W := hcr.trans (mul_le_mul_of_nonneg_left hp (by positivity)) have he : (∑ t ∈ F,(factorProduct t:ℝ)⁻¹)=(F.card:ℝ)*(s:ℝ)⁻¹ := by calc _ = ∑ _t ∈ F,(s:ℝ)⁻¹ := Finset.sum_congr rfl (fun t ht => by rw [(hF t ht).1]) _ = _ := by simp rw [show Q.filter (fun t => factorProduct t=s)=F from rfl,he] exact mul_le_mul_of_nonneg_right hcard (inv_nonneg.mpr (Nat.cast_nonneg s)) calc _ = ∑ s ∈ P,∑ t ∈ Q.filter (fun t => factorProduct t=s),(factorProduct t:ℝ)⁻¹ := (Finset.sum_fiberwise_of_maps_to hmap (fun t => (factorProduct t:ℝ)⁻¹)).symm _ ≤ ∑ s ∈ P,W*(s:ℝ)⁻¹ := Finset.sum_le_sum hfiber _ = W*(∑ s ∈ P,(s:ℝ)⁻¹) := (Finset.mul_sum ..).symm _ ≤ _ := mul_le_mul_of_nonneg_left (smooth_residual_reciprocal_mass N P (fun s hs => ⟨(hP s hs).1,(hP s hs).2.1⟩)) hW
end TotientAsymptotic
end
end OAI12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576import OAI.NumberTheory.TotientAsymptotic.JoinedSimpleximport OAI.NumberTheory.TotientAsymptotic.PointEnclosureimport OAI.NumberTheory.TotientAsymptotic.TailCutScale
namespace OAI
/-! Thickening a discrete witness tail to its entire unit box preservesmembership in the same controlled full-dimensional enlargement. -/
noncomputable sectionopen scoped BigOperators Topologyopen Filter
namespace TotientAsymptotic
lemma thickened_witness_enclosure {x : ℝ} {H : ℕ} {η : TailDatum H} (hs : 0 ≤ theta x) (hcut : 4 ≤ lam*(P H : ℝ)) (hHm : H ≤ m x) (hPH : P H < H) (hB : 0 ≤ B x) (hBr : 1 ≤ B x*rho^(m x)) (hη : IsWitness H (theta x) η) {u : Fin (R x H) → ℝ} (hu : u ∈ tailPrefixRegion x H η) (hprefix : ∀ i, 1 ≤ rho^(m x-(i.val+1))*u i) {v : Fin (H-P H) → ℝ} (hv : ∀ i, |tailVector η i-v i| ≤ 1) : joinCoordinates (R x H) (H-P H) (u,v) ∈ enlargedSimplex (R x H+(H-P H)) (B x) (1+simplexBoxError 4 (m x)) (fun i => 1+simplexBoxError 4 (m x-(i.val+1))) := by have hP : 1 ≤ P H := by by_contra hn have hz : P H=0 := by omega simp only [hz, Nat.cast_zero, mul_zero] at hcut norm_num at hcut have hsize : R x H+(H-P H) < m x := by unfold R; omega apply point_cube_full_enclosure hsize hBr (join_witness_enlarged hη hPH hHm hB hu) · intro i refine Fin.addCases (fun j => ?_) (fun j => ?_) i · simp only [joinCoordinates_left, sub_self, abs_zero, zero_le_one] · simpa only [joinCoordinates_right] using hv j · intro i refine Fin.addCases (fun j => ?_) (fun j => ?_) i · simpa only [Fin.val_castAdd, joinCoordinates_left] using hprefix j · simp only [Fin.val_natAdd, joinCoordinates_right] have hj := j.isLt have he : m x-(R x H+j.val+1)=H-1-j.val := by unfold R; omega have hmem : H-1-j.val ∈ Finset.Ico (P H) H := Finset.mem_Ico.mpr (by omega) have hb := (hη.2.2.1 _ hmem).2.1 have hband : (9/10 : ℝ)*bandScale x (R x H+j.val+1) ≤ tailVector η j := by simpa only [bandScale, he, tailVector, mul_assoc] using hb exact cube_band_lower hs hcut (by unfold R; omega) hband (hv j)
/-- The prefix lower-bound hypothesis above is automatic uniformly over allwitnesses and all prefix points once the tail cut is large. -/theorem eventually_thickened_witness_enclosure (hren : FordRenewalInput) : ∀ᶠ H : ℕ in atTop, ∀ {x : ℝ} {η : TailDatum H}, 0 ≤ theta x → H ≤ m x → P H < H → 0 ≤ B x → 1 ≤ B x*rho^(m x) → IsWitness H (theta x) η → ∀ {u : Fin (R x H) → ℝ}, u ∈ tailPrefixRegion x H η → ∀ {v : Fin (H-P H) → ℝ}, (∀ i, |tailVector η i-v i| ≤ 1) → joinCoordinates (R x H) (H-P H) (u,v) ∈ enlargedSimplex (R x H+(H-P H)) (B x) (1+simplexBoxError 4 (m x)) (fun i => 1+simplexBoxError 4 (m x-(i.val+1))) := by obtain ⟨c, hc, hlower⟩ := tailPrefixRegion_scaled_lower hren have hgrow : Tendsto (fun H : ℕ => c*((H-1 : ℕ) : ℝ)) atTop atTop := (tendsto_natCast_atTop_atTop.comp (tendsto_sub_atTop_nat 1)).const_mul_atTop hc have hcut : Tendsto (fun H : ℕ => lam*(P H : ℝ)) atTop atTop := (tendsto_natCast_atTop_atTop.comp P_tendsto).const_mul_atTop lam_pos filter_upwards [hgrow.eventually (eventually_ge_atTop (1 : ℝ)), hcut.eventually (eventually_ge_atTop (4 : ℝ))] with H hH hP intro x η hs hHm hPH hB hBr hη u hu v hv apply thickened_witness_enclosure hs hP hHm hPH hB hBr hη hu _ hv intro i exact hH.trans (hlower hs hη hPH hHm hu i)
end TotientAsymptotic
end
end OAI12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667import OAI.NumberTheory.TotientAsymptotic.FordCoordinateBounds
namespace OAI
/-! The complement of the two-coordinate exception has a small third prime. -/noncomputable sectionnamespace TotientAsymptotic
lemma ford_coordinate_antitone (n : ℕ) {i j : ℕ} (hij : i ≤ j) : fordPrimeCoordinate n j ≤ fordPrimeCoordinate n i := by by_cases hj : j < n.primeFactorsList.length · have hi : i < n.primeFactorsList.length := by omega have hp := fordPrime_prime hj have horder := fordPrime_antitone hi hj hij have hB : primeDoubleLog n j ≤ primeDoubleLog n i := Real.log_le_log (Real.log_pos (by exact_mod_cast hp.one_lt)) (Real.log_le_log (by exact_mod_cast hp.pos) (by exact_mod_cast horder)) exact max_le_max le_rfl hB · have he : fordPrime n j=1 := by unfold fordPrime rw [List.getElem?_eq_none (by simpa using Nat.le_of_not_gt hj)] rfl simp only [fordPrimeCoordinate,primeDoubleLog,he,Nat.cast_one,Real.log_one,Real.log_zero,max_self] exact le_max_left _ _
lemma third_coordinate_bound {x : ℝ} {n : ℕ} (hscore : a 1*fordPrimeCoordinate n 1+a 2*fordPrimeCoordinate n 2 ≤ (101/100:ℝ)*B x) : fordPrimeCoordinate n 2 ≤ (4/5:ℝ)*B x := by have ha := first_two_a_bounds have hsum : (32/25:ℝ) ≤ a 1+a 2 := by have he : a 1+a 2=3*Real.log 3-2 := by norm_num [a]; ring rw [he] linarith [Real.log_three_gt_d9] have horder := ford_coordinate_antitone n (show 1 ≤ 2 by norm_num) have hnon : 0 ≤ fordPrimeCoordinate n 2 := le_max_left _ _ have h1 := mul_le_mul_of_nonneg_left horder ha.1.le have h2 := mul_le_mul_of_nonneg_right hsum hnon nlinarith only [hscore,h1,h2,hnon]
lemma third_prime_size {x : ℝ} {n : ℕ} (hx : 1 < x) (hscore : a 1*fordPrimeCoordinate n 1+a 2*fordPrimeCoordinate n 2 ≤ (101/100:ℝ)*B x) : (fordPrime n 2:ℝ) ≤ Real.exp ((Real.log x)^(4/5:ℝ)) := by have hcoord := third_coordinate_bound hscore have hraw : B (fordPrime n 2) ≤ (4/5:ℝ)*B x := (le_max_right _ _).trans hcoord by_cases hi : 2 < n.primeFactorsList.length · have hp := fordPrime_prime hi have hplog : 0 < Real.log (fordPrime n 2) := Real.log_pos (by exact_mod_cast hp.one_lt) have hxp : 0 < Real.log x := Real.log_pos hx have hh := Real.exp_le_exp.mpr (Real.exp_le_exp.mpr hraw) rw [B,Real.exp_log hplog,Real.exp_log (by exact_mod_cast hp.pos)] at hh convert hh using 1 rw [Real.rpow_def_of_pos hxp] congr 2 unfold B ring · have he : fordPrime n 2=1 := by unfold fordPrime rw [List.getElem?_eq_none (by simpa using Nat.le_of_not_gt hi)] rfl rw [he,Nat.cast_one] exact Real.one_le_exp (Real.rpow_nonneg (Real.log_pos hx).le _)
end TotientAsymptotic
end
end OAI12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576import OAI.NumberTheory.TotientAsymptotic.FailedRowCutoffimport OAI.NumberTheory.TotientAsymptotic.FordDimensionScale
namespace OAI
/-! Failure of the initial Ford simplex row has a uniform Gaussian saving. -/noncomputable sectionopen scoped BigOperators Topologyopen Filternamespace TotientAsymptotic
theorem top_row_failure_count : ∃ C : ℝ,0 < C ∧ ∀ᶠ x : ℝ in atTop, ∀ Ψ : ℕ, Ψ ≤ m x → ∀ Q : Finset ℕ, (∀ v ∈ Q,∃ n : ℕ,0 < n ∧ n.totient=v ∧ (v:ℝ) ≤ x ∧ xi x 0*B x < fordRowSum (m x) (fordPrimeCoordinate n) 0) → (Q.card:ℝ) ≤ C*(x/Real.log x)*G x (m x)*Real.exp (-(Ψ:ℝ)^2/4) := by obtain ⟨C,F,hC,hF,hcount⟩ := real_coordinate_deviation refine ⟨C,hC,?_⟩ filter_upwards [dimension_row_model_budget hF.le,central_volume_one_le, eventually_ge_atTop (512:ℝ),eventually_ge_atTop (2*Real.exp (Real.exp 1)), B_tendsto.eventually (eventually_gt_atTop (0:ℝ))] with x hb hG hx hxexp hB intro Ψ hΨ Q hQ let k := m x let ω : ℝ := Real.exp (-(k:ℝ)/40)/10000 have hω : 0 < ω := by dsimp [ω]; positivity have hω1 : ω ≤ 1 := by have he : Real.exp (-(k:ℝ)/40) ≤ 1 := Real.exp_le_one_iff.mpr (by have := Nat.cast_nonneg (α:=ℝ) k; linarith) dsimp [ω] linarith only [he] have hmodel : coordinateDecay (ω/4) k=rowModelDecay k := by dsimp [coordinateDecay,rowModelDecay,ω] ring have hbudget := failed_row_cutoff_budget hF.le hω hω1 k obtain ⟨_,_,_,_,_,_,hthreshold,_,_⟩ := hbudget rw [failed_row_cutoff_loglog,hmodel] at hthreshold have hthreshold' : max 300000000 ((coordinateBudgetConstant F/coordinateDecay (ω/4) k)^(4/3:ℝ)) ≤ B x-1 := by rw [hmodel] exact hthreshold.trans (by dsimp [k] at *; linarith only [hb.1]) have hc := hcount x hx hxexp k (ω/4) (by linarith) (by linarith) hthreshold' Q (by intro v hv obtain ⟨n,hn,hφ,hvx,hrow⟩ := hQ v hv refine ⟨⟨n,hn,hφ⟩,hvx,n,hn,hφ,?_⟩ have hxi : xi x 0=1+ω := by dsimp [xi,ω,k]; ring rw [hxi] at hrow have hsum : fordRowSum (m x) (fordPrimeCoordinate n) 0 = ∑ i : Fin k,a (i.val+1)*fordPrimeCoordinate n (i.val+1) := by simpa only [Nat.sub_zero,fordCofactor_zero hn] using (fordRowSum_cofactor (n:=n) (L:=m x) (j:=0) (Nat.zero_le _)) rw [hsum] at hrow have hh := mul_le_mul_of_nonneg_right (show 1+ω/4 ≤ 1+ω by linarith) hB.le exact hh.trans hrow.le) have hΨsq : (Ψ:ℝ)^2 ≤ (m x:ℝ)^2 := by have hle : (Ψ:ℝ) ≤ m x := by exact_mod_cast hΨ nlinarith only [hle,Nat.cast_nonneg (α:=ℝ) Ψ,Nat.cast_nonneg (α:=ℝ) (m x)] have hsave : Real.exp (-coordinateDecay (ω/4) k*B x) ≤ Real.exp (-(Ψ:ℝ)^2/4) := by apply Real.exp_le_exp.mpr rw [hmodel] dsimp [k] linarith only [hb.2,hΨsq] have hx1 : 1 < x := by linarith only [hx] have hfac : 0 ≤ C*(x/Real.log x) := mul_nonneg hC.le (div_nonneg (by linarith only [hx]) (Real.log_pos hx1).le) calc _ ≤ C*(x/Real.log x)*Real.exp (-coordinateDecay (ω/4) k*B x) := by simpa only [div_eq_mul_inv,mul_assoc] using hc _ ≤ C*(x/Real.log x)*Real.exp (-(Ψ:ℝ)^2/4) := mul_le_mul_of_nonneg_left hsave hfac _ ≤ _ := by have hh := mul_le_mul_of_nonneg_left hG hfac simpa only [mul_one] using mul_le_mul_of_nonneg_right hh (Real.exp_pos _).le
end TotientAsymptotic
end
end OAI12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697import OAI.NumberTheory.TotientAsymptotic.FiniteDyadicHarmonicimport OAI.NumberTheory.TotientAsymptotic.TupleTotients
namespace OAI
/-! The finite dyadic counting envelope used to bootstrap the global upper bound. -/noncomputable sectionopen scoped BigOperatorsnamespace TotientAsymptotic
def dyadicTotientEnvelope (J : ℕ) : ℝ := max 1 ((Finset.range (J+1)).sup' (by simp) (fun k => V ((2:ℝ)^k)*(k:ℝ)/(2:ℝ)^k))
lemma dyadicTotientEnvelope_one_le (J : ℕ) : 1 ≤ dyadicTotientEnvelope J := le_max_left _ _
lemma dyadicTotientEnvelope_mono {I J : ℕ} (hIJ : I ≤ J) : dyadicTotientEnvelope I ≤ dyadicTotientEnvelope J := by unfold dyadicTotientEnvelope apply max_le_max le_rfl exact Finset.sup'_mono (s₁ := Finset.range (I+1)) (s₂ := Finset.range (J+1)) (fun k : ℕ => V ((2:ℝ)^k)*(k:ℝ)/(2:ℝ)^k) (Finset.range_mono (Nat.add_le_add_right hIJ 1)) (by simp)
lemma dyadicTotientEnvelope_term_le {k J : ℕ} (hkJ : k ≤ J) : V ((2:ℝ)^k)*(k:ℝ)/(2:ℝ)^k ≤ dyadicTotientEnvelope J := by unfold dyadicTotientEnvelope have hs : k ∈ Finset.range (J+1) := Finset.mem_range.mpr (by omega) exact (Finset.le_sup' (s:=Finset.range (J+1)) (fun k => V ((2:ℝ)^k)*(k:ℝ)/(2:ℝ)^k) hs).trans (le_max_right _ _)
lemma dyadic_totient_count_le {k J : ℕ} (hk : 1 ≤ k) (hkJ : k ≤ J) : V ((2:ℝ)^k) ≤ dyadicTotientEnvelope J*(2:ℝ)^k/(k:ℝ) := by have hk0 : (0:ℝ) < k := by exact_mod_cast hk have hpow : (0:ℝ) < 2^k := by positivity have he := dyadicTotientEnvelope_term_le hkJ apply (le_div_iff₀ hk0).mpr exact (div_le_iff₀ hpow).mp he
lemma totient_values_subset {x y : ℝ} (hxy : x ≤ y) : totientValues x ⊆ totientValues y := by classical intro v hv obtain ⟨hv,ht⟩ := Finset.mem_filter.mp hv exact Finset.mem_filter.mpr ⟨Finset.mem_Icc.mpr ⟨(Finset.mem_Icc.mp hv).1,(Finset.mem_Icc.mp hv).2.trans (Nat.floor_mono hxy)⟩,ht⟩
lemma V_monotone : Monotone V := by intro x y hxy exact Nat.cast_le.mpr (Finset.card_le_card (totient_values_subset hxy))
lemma dyadic_totient_reciprocal_mass {J : ℕ} (_hJ : 1 ≤ J) (Q : Finset ℕ) (hQ : ∀ v ∈ Q,IsTotient v ∧ (v:ℝ) ≤ (2:ℝ)^J) : (∑ v ∈ Q,(v:ℝ)⁻¹) ≤ 1+4*dyadicTotientEnvelope J*(1+Real.log J) := by classical let E := Q.erase 1 have hE (v : ℕ) (hv : v ∈ E) : IsTotient v ∧ 1 < v ∧ (v:ℝ) ≤ (2:ℝ)^J := by obtain ⟨hne,hv⟩ := Finset.mem_erase.mp hv have h := hQ v hv exact ⟨h.1,by have := isTotient_pos h.1; omega,h.2⟩ have hn : ∀ v ∈ E,Nat.clog 2 v ∈ Finset.Icc 1 J := by intro v hv have hb := dyadic_nat_bounds (hE v hv).2.1 refine Finset.mem_Icc.mpr ⟨hb.1,?_⟩ apply (Nat.clog_le_iff_le_pow (by decide : 1 < 2)).mpr exact_mod_cast (hE v hv).2.2 have hcount (k : ℕ) (hk : k ∈ Finset.Icc 1 J) : ((E.filter (fun v => Nat.clog 2 v=k)).card:ℝ) ≤ dyadicTotientEnvelope J*(2:ℝ)^k/(k:ℝ) := by have hsub : E.filter (fun v => Nat.clog 2 v=k) ⊆ totientValues ((2:ℝ)^k) := by intro v hv obtain ⟨hv,he⟩ := Finset.mem_filter.mp hv have h := hE v hv have hb := (dyadic_nat_bounds h.2.1).2.2 rw [he] at hb exact Finset.mem_filter.mpr ⟨Finset.mem_Icc.mpr ⟨isTotient_pos h.1,Nat.le_floor hb⟩,h.1⟩ exact (Nat.cast_le.mpr (Finset.card_le_card hsub)).trans (dyadic_totient_count_le (Finset.mem_Icc.mp hk).1 (Finset.mem_Icc.mp hk).2) have hm := finite_dyadic_harmonic_mass E (Nat.clog 2) (fun v => (v:ℝ)) J (zero_le_one.trans (dyadicTotientEnvelope_one_le J)) hn (by intro v hv have hh := (dyadic_nat_bounds (hE v hv).2.1).2.1 have hp : (0:ℝ) < 2^(Nat.clog 2 v) := by positivity linarith) hcount have hs : (∑ v ∈ Q,(v:ℝ)⁻¹) ≤ 1+∑ v ∈ E,(v:ℝ)⁻¹ := by by_cases h1 : 1 ∈ Q · rw [← Finset.add_sum_erase Q _ h1] norm_num [E] · have he : E=Q := Finset.erase_eq_of_notMem h1 rw [he] linarith exact hs.trans (add_le_add le_rfl hm)
end TotientAsymptotic
end
end OAI1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556import OAI.NumberTheory.TotientAsymptotic.TotientRatioLogLog
namespace OAI
/-! Concrete preimage bounds for the finite totient counting reductions. -/noncomputable sectionopen scoped BigOperatorsnamespace TotientAsymptotic
lemma prime_le_shift_square {p : ℕ} (hp : p.Prime) (hp2 : p ≠ 2) : p ≤ (p-1)^2 := by have h3 : 3 ≤ p := by have := hp.two_le; omega have he : p-1+1=p := by omega nlinarith
lemma radical_le_twice_shift_product_square (n : ℕ) : (∏ p ∈ n.primeFactors,p) ≤ 2*(∏ p ∈ n.primeFactors,(p-1))^2 := by let E := n.primeFactors.erase 2 have hprod : (∏ p ∈ E,p) ≤ (∏ p ∈ E,(p-1))^2 := by rw [← Finset.prod_pow] apply Finset.prod_le_prod intro p hp exact prime_le_shift_square (Nat.prime_of_mem_primeFactors (Finset.mem_of_mem_erase hp)) (Finset.mem_erase.mp hp).1 by_cases h2 : 2 ∈ n.primeFactors · have hrad := Finset.mul_prod_erase n.primeFactors (fun p : ℕ => p) h2 have hshift := Finset.mul_prod_erase n.primeFactors (fun p : ℕ => p-1) h2 norm_num only [Nat.reduceSub,one_mul] at hshift rw [← hrad,← hshift] exact Nat.mul_le_mul_left 2 hprod · have hE : E=n.primeFactors := Finset.erase_eq_of_notMem h2 rw [hE] at hprod omega
lemma totient_preimage_quadratic {n : ℕ} (hn : 0 < n) : n ≤ 2*n.totient^2 := by let r := ∏ p ∈ n.primeFactors,p let s := ∏ p ∈ n.primeFactors,(p-1) have hr : 0 < r := Finset.prod_pos (fun p hp => (Nat.prime_of_mem_primeFactors hp).pos) have hs : 0 < s := Finset.prod_pos (fun p hp => by have := (Nat.prime_of_mem_primeFactors hp).two_le; omega) obtain ⟨w,hw⟩ := n.prod_primeFactors_dvd change n=r*w at hw have hw0 : 0 < w := by nlinarith have he := Nat.totient_mul_prod_primeFactors n change n.totient*r=n*s at he have hφ : n.totient=w*s := by apply Nat.eq_of_mul_eq_mul_left hr rw [Nat.mul_comm r n.totient,he,hw] ring have hrad : r ≤ 2*s^2 := radical_le_twice_shift_product_square n rw [hφ,hw] nlinarith [Nat.mul_le_mul_right w hrad,show w ≤ w^2 by nlinarith]
end TotientAsymptotic
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128import OAI.NumberTheory.TotientAsymptotic.MertensProductimport OAI.NumberTheory.TotientAsymptotic.CanceledPrimeMass
namespace OAI
/-! A uniform log-log bound for the elementary totient ratio. -/noncomputable sectionopen scoped BigOperatorsnamespace TotientAsymptotic
lemma totient_factor_large_prime {p : ℕ} (hp : p.Prime) {L : ℝ} (hL : 0<L) (hpL : L≤p) : (p:ℝ)/(p-1) ≤ Real.exp (4*Real.log p/L) := 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 hlog : (1/2:ℝ)≤Real.log p := by have hh := Real.log_le_log (by norm_num : (0:ℝ)<2) hp2 linarith [Real.log_two_gt_d9] have hfirst : (1:ℝ)/(p-1) ≤ 2/(p:ℝ) := by apply (div_le_div_iff₀ hp1 hp0).mpr linarith have hsecond : 2/(p:ℝ) ≤ 4*Real.log p/L := by apply (div_le_div_iff₀ hp0 hL).mpr nlinarith have he : (p:ℝ)/(p-1) = 1+1/(p-1) := by field_simp; ring rw [he] have hh := Real.add_one_le_exp (4*Real.log p/L) linarith
lemma totient_large_prime_product {b : ℕ} (hb : 0<b) {L : ℝ} (hL : 0<L) (hbL : Real.log b ≤ L) (T : Finset ℕ) (hT : T ⊆ b.primeFactors) (hlarge : ∀ p ∈ T,L≤p) : (∏ p ∈ T,(p:ℝ)/(p-1)) ≤ Real.exp 4 := by have hprimes : ∀ p ∈ T,p.Prime := fun p hp => Nat.prime_of_mem_primeFactors (hT hp) have hprod0 : (0:ℝ)<(∏ p ∈ T,p : ℕ) := by exact_mod_cast Finset.prod_pos (fun p hp => (hprimes p hp).pos) have hdvd : (∏ p ∈ T,p) ∣ b := (Finset.prod_dvd_prod_of_subset T b.primeFactors id hT).trans b.prod_primeFactors_dvd have hsum : (∑ p ∈ T,Real.log p) ≤ L := by have he : Real.log ((∏ p ∈ T,p : ℕ):ℝ) = ∑ p ∈ T,Real.log p := by rw [Nat.cast_prod,Real.log_prod (fun p hp => by exact_mod_cast (hprimes p hp).ne_zero)] rw [← he] exact (Real.log_le_log hprod0 (by exact_mod_cast Nat.le_of_dvd hb hdvd)).trans hbL calc _ ≤ ∏ p ∈ T,Real.exp (4*Real.log p/L) := by apply Finset.prod_le_prod₀ · intro p hp have hp1 : (1:ℝ)<p := by exact_mod_cast (hprimes p hp).one_lt exact div_nonneg (Nat.cast_nonneg _) (by linarith) · intro p hp exact totient_factor_large_prime (hprimes p hp) hL (hlarge p hp) _ = Real.exp ((4/L)*(∑ p ∈ T,Real.log p)) := by rw [← Real.exp_sum,Finset.mul_sum] congr 1 apply Finset.sum_congr rfl intro p _ ring _ ≤ _ := by apply Real.exp_le_exp.mpr have hh := mul_le_mul_of_nonneg_left hsum (show 0≤4/L by positivity) have he : (4/L)*L=4 := by field_simp rwa [he] at hh
/-- Uniformity in `b ≤ x` is the form needed when summing shifted prime pairs. -/theorem totient_ratio_loglog_bound : ∃ C : ℝ, 0<C ∧ ∀ x : ℝ, Real.exp 2 ≤ x → ∀ b : ℕ, 0<b → (b:ℝ)≤x → (b:ℝ)/b.totient ≤ C*Real.log (Real.log x) := by classical obtain ⟨C,hC,hM⟩ := mertensProductInput refine ⟨C*Real.exp 4,by positivity,?_⟩ intro x hx b hb hbx have hx0 : 0<x := (Real.exp_pos 2).trans_le hx have hlog : 2 ≤ Real.log x := (Real.le_log_iff_exp_le hx0).mpr hx have hN : 2 ≤ ⌊Real.log x⌋₊ := (Nat.le_floor_iff (by linarith)).mpr hlog let S := b.primeFactors.filter (fun p : ℕ => (p:ℝ)≤Real.log x) let T := b.primeFactors.filter (fun p : ℕ => ¬(p:ℝ)≤Real.log x) have hsmall : (∏ p ∈ S,(p:ℝ)/(p-1)) ≤ primeEulerProduct ⌊Real.log x⌋₊ := by apply Finset.prod_le_prod_of_subset_of_one_le₀ · intro p hp obtain ⟨hpb,hpL⟩ := Finset.mem_filter.mp hp exact Finset.mem_filter.mpr ⟨Finset.mem_Icc.mpr ⟨(Nat.prime_of_mem_primeFactors hpb).two_le,Nat.le_floor hpL⟩, Nat.prime_of_mem_primeFactors hpb⟩ · intro p hp have hp1 : (1:ℝ)<p := by exact_mod_cast (Nat.prime_of_mem_primeFactors (Finset.mem_filter.mp hp).1).one_lt exact div_nonneg (Nat.cast_nonneg _) (by linarith) · intro p hp _ have hp1 : (1:ℝ)<p := by exact_mod_cast (Finset.mem_filter.mp hp).2.one_lt apply (le_div_iff₀ (by linarith : (0:ℝ)<p-1)).mpr linarith have hlarge : (∏ p ∈ T,(p:ℝ)/(p-1)) ≤ Real.exp 4 := totient_large_prime_product hb (by linarith) (Real.log_le_log (by exact_mod_cast hb) hbx) T (Finset.filter_subset _ _) (fun p hp => (le_of_not_ge (Finset.mem_filter.mp hp).2)) have hsmall0 : 0 ≤ ∏ p ∈ S,(p:ℝ)/(p-1) := by apply Finset.prod_nonneg intro p hp have hp1 : (1:ℝ)<p := by exact_mod_cast (Nat.prime_of_mem_primeFactors (Finset.mem_filter.mp hp).1).one_lt exact div_nonneg (Nat.cast_nonneg _) (by linarith) have hsplit : (b:ℝ)/b.totient = (∏ p ∈ S,(p:ℝ)/(p-1))*(∏ p ∈ T,(p:ℝ)/(p-1)) := by rw [totient_ratio_product hb] exact (Finset.prod_filter_mul_prod_filter_not b.primeFactors (fun p : ℕ => (p:ℝ)≤Real.log x) (fun p => (p:ℝ)/(p-1))).symm have hlN : Real.log (��Real.log x⌋₊:ℝ) ≤ Real.log (Real.log x) := Real.log_le_log (by exact_mod_cast (show 0<⌊Real.log x⌋₊ by omega)) (Nat.floor_le (by linarith)) calc (b:ℝ)/b.totient = _ := hsplit _ ≤ primeEulerProduct ⌊Real.log x⌋₊ * Real.exp 4 := mul_le_mul hsmall hlarge (Finset.prod_nonneg (fun p hp => by have hp1 : (1:ℝ)<p := by exact_mod_cast (Nat.prime_of_mem_primeFactors (Finset.mem_filter.mp hp).1).one_lt exact div_nonneg (Nat.cast_nonneg _) (by linarith))) (primeEulerProduct_pos _).le _ ≤ (C*Real.log (⌊Real.log x⌋₊:ℝ))*Real.exp 4 := mul_le_mul_of_nonneg_right (hM _ hN) (Real.exp_pos _).le _ ≤ _ := by have hh := mul_le_mul_of_nonneg_left hlN (show 0≤C*Real.exp 4 by positivity) nlinarith
end TotientAsymptotic
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293import OAI.NumberTheory.TotientAsymptotic.TranslatedPrefiximport OAI.NumberTheory.TotientAsymptotic.PrefixGapVolume
namespace OAI
/-! Summing adjacent inversions in the translated prime-coordinate region. -/noncomputable sectionopen scoped BigOperatorsopen MeasureTheorynamespace TotientAsymptotic
lemma finite_gap_exponential_sum {c : ℝ} (hc : 0 < c) (N : ℕ) : (∑ i : Fin (N+1),Real.exp (-c*((N+2-i.val:ℕ):ℝ))) ≤ 1/(1-Real.exp (-c)) := by classical let q := Real.exp (-c) have hq : 0 ≤ q := (Real.exp_pos _).le have hq1 : q < 1 := Real.exp_lt_one_iff.mpr (by linarith) have hinj : Set.InjOn (fun i : Fin (N+1) => N+2-i.val) ↑(Finset.univ : Finset (Fin (N+1))) := by intro i _ j _ he apply Fin.ext change N+2-i.val=N+2-j.val at he have := i.isLt have := j.isLt omega have he (i : Fin (N+1)) : Real.exp (-c*((N+2-i.val:ℕ):ℝ))=q^(N+2-i.val) := by dsimp [q] rw [←Real.exp_nat_mul] congr 1 ring simp_rw [he] rw [←Finset.sum_image hinj] have hs := hasSum_geometric_of_lt_one hq hq1 simpa only [one_div,q] using (hs.summable.sum_le_tsum _ (fun k _ => pow_nonneg hq k)).trans_eq hs.tsum_eq
theorem translated_prefix_inversions : ∃ A c s : ℝ,0 < A ∧ 0 < c ∧ 0 < s ∧ ∀ (N : ℕ) (B t T : ℝ),0 < B → 0 ≤ T → s*T ≤ B → (∀ i : Fin (N+1),rho^(i.val+1)*T ≤ renewalBackground (N+2) t i.castSucc-renewalBackground (N+2) t i.succ) → volume.real {u : Fin (N+2) → ℝ | u ∈ prefixRegion (N+2) B 0 0 ∧ ¬StrictAnti (fun i => u i+renewalBackground (N+2) t i)} ≤ (Real.exp (A-s*(N+2:ℝ)*T/B)/(1-Real.exp (-c)))* volume.real (prefixRegion (N+2) B 0 0) := by classical obtain ⟨A,c,s,hA,hc,hs,hbound⟩ := prefix_gap_volume refine ⟨A,c,s,hA,hc,hs,?_⟩ intro N B t T hB hT hTB hgap let S := prefixRegion (N+2) B 0 0 let E (i : Fin (N+1)) := S ∩ {u | u i.castSucc-u i.succ ≤ -rho^(i.val+1)*T} have hsub : {u : Fin (N+2) → ℝ | u ∈ S ∧ ¬StrictAnti (fun i => u i+renewalBackground (N+2) t i)} ⊆ ⋃ i,E i := by intro u hu have hn := hu.2 rw [Fin.strictAnti_iff_succ_lt] at hn push Not at hn obtain ⟨i,hi⟩ := hn apply Set.mem_iUnion.mpr refine ⟨i,hu.1,?_⟩ have hg := hgap i change u i.castSucc-u i.succ ≤ -rho^(i.val+1)*T nlinarith only [hi,hg] have hfinite : volume (⋃ i,E i) ≠ ⊤ := by apply ne_top_of_le_ne_top (show volume S ≠ ⊤ from ?_) (measure_mono (by intro u hu; obtain ⟨i,hi⟩ := Set.mem_iUnion.mp hu; exact hi.1)) dsimp [S] rw [volume_prefixRegion_explicit (N+2) (by omega)] exact ENNReal.ofReal_ne_top have hmeasure := ENNReal.toReal_mono hfinite (measure_mono hsub) apply hmeasure.trans apply (measureReal_iUnion_fintype_le E).trans have hsum := Finset.sum_le_sum (fun i (_ : i ∈ Finset.univ) => hbound N i B T hB hT hTB) apply hsum.trans have he (i : Fin (N+1)) : Real.exp (A-c*((N+2-i.val:ℕ):ℝ)-s*(N+2:ℝ)*T/B)= Real.exp (A-s*(N+2:ℝ)*T/B)*Real.exp (-c*((N+2-i.val:ℕ):ℝ)) := by rw [←Real.exp_add] congr 1 ring simp_rw [he] rw [←Finset.sum_mul,←Finset.mul_sum] have hh := mul_le_mul_of_nonneg_left (finite_gap_exponential_sum hc N) (Real.exp_pos (A-s*(N+2:ℝ)*T/B)).le simpa only [div_eq_mul_inv,mul_assoc,one_mul,S] using mul_le_mul_of_nonneg_right hh (show 0 ≤ volume.real S from ENNReal.toReal_nonneg)
end TotientAsymptotic
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051import OAI.NumberTheory.TotientAsymptotic.RenewalBackgroundimport OAI.NumberTheory.TotientAsymptotic.SimplexVolume
namespace OAI
/-! A renewal translate gives strict positive slack without losing dimension. -/noncomputable sectionopen scoped BigOperatorsopen MeasureTheorynamespace TotientAsymptotic
lemma renewal_translate_prefix {N : ℕ} {B t : ℝ} (ht : 0 ≤ t) {u : Fin N → ℝ} (hu : u ∈ prefixRegion N (B-t*(g (N+1)-a (N+1))) 0 0) : u+renewalBackground N t ∈ prefixRegion N B 0 0 ∧ ∀ i,t*a (N-i.val) ≤ prefixLinear N (u+renewalBackground N t) i := by have hslack (i : Fin N) : t*a (N-i.val) ≤ prefixLinear N (u+renewalBackground N t) i := by rw [map_add,Pi.add_apply,renewalBackground_slack] have hh := hu.1 i change 0 ≤ prefixLinear N u i at hh linarith only [hh] refine ⟨⟨?_,?_⟩,hslack⟩ · intro i exact (mul_nonneg ht (a_pos (by have := i.isLt; omega)).le).trans (hslack i) · change (∑ i : Fin N,a (i.val+1)*(u i+renewalBackground N t i)) ≤ B-0 simp only [mul_add,Finset.sum_add_distrib,renewalBackground_top,sub_zero] have hh := hu.2 simp only [sub_zero] at hh linarith only [hh]
lemma renewal_translated_volume (N : ℕ) (hN : 0 < N) (B t : ℝ) : volume {v : Fin N → ℝ | v-renewalBackground N t ∈ prefixRegion N (B-t*(g (N+1)-a (N+1))) 0 0} = ENNReal.ofReal ((max (B-t*(g (N+1)-a (N+1))) 0)^N/ ((N.factorial:ℝ)*∏ i : Fin N,g (i.val+1))) := by have hh := measure_preimage_add_right (volume : Measure (Fin N → ℝ)) (-renewalBackground N t) (prefixRegion N (B-t*(g (N+1)-a (N+1))) 0 0) change volume ((fun v => v-renewalBackground N t) ⁻¹' prefixRegion N (B-t*(g (N+1)-a (N+1))) 0 0)=_ rw [show (fun v : Fin N → ℝ => v-renewalBackground N t)= (fun v => v+(-renewalBackground N t)) by rfl,hh] rw [volume_prefixRegion_explicit N hN] simp only [Pi.zero_apply,mul_zero,Finset.sum_const_zero,sub_zero]
end TotientAsymptotic
end
end OAI1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556import OAI.NumberTheory.TotientAsymptotic.TripleSieveModel
namespace OAI
/-! Exact multiplicative residue proportions for the three-form sieve. -/noncomputable sectionopen scoped BigOperatorsnamespace TotientAsymptotic
lemma tripleRootCount_one (a b : ℕ) : tripleRootCount 1 a b = 1 := by rw [tripleRootCount_eq_count 1 a b (by norm_num),Nat.count_one] simp [tripleSievePolynomial]
lemma tripleRootCount_prod (a b : ℕ) (S : Finset ℕ) (hS : ∀ p ∈ S,p.Prime) : tripleRootCount (∏ p ∈ S,p) a b = ∏ p ∈ S,tripleRootCount p a b := by classical induction S using Finset.induction_on with | empty => simpa using tripleRootCount_one a b | @insert p S hp ih => have hprime := 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 intro q hq apply hprime.coprime_iff_not_dvd.mpr intro hd have he := (Nat.prime_dvd_prime_iff_eq hprime (hS' q hq)).mp hd exact hp (he ▸ hq) rw [Finset.prod_insert hp,tripleRootCount_mul hprime.ne_zero (Finset.prod_ne_zero_iff.mpr (fun q hq => (hS' q hq).ne_zero)) hcop, ih hS',Finset.prod_insert hp]
lemma tripleRootCount_density (a b d : ℕ) (hd : Squarefree d) : (tripleRootCount d a b:ℝ) = d*tripleSieveDensity a b d := by classical have hprod : ∏ p ∈ d.primeFactors,p = d := Nat.prod_primeFactors_of_squarefree hd have hcount : tripleRootCount d a b = ∏ p ∈ d.primeFactors,tripleRootCount p a b := by conv_lhs => rw [← hprod] exact tripleRootCount_prod a b d.primeFactors (fun p hp => Nat.prime_of_mem_primeFactors hp) have hdensity : tripleSieveDensity a b d = ∏ p ∈ d.primeFactors,(tripleRootCount p a b:ℝ)/p := ArithmeticFunction.prodPrimeFactors_apply hd.ne_zero calc _ = ∏ p ∈ d.primeFactors,(tripleRootCount p a b:ℝ) := by rw [hcount,Nat.cast_prod] _ = ∏ p ∈ d.primeFactors,(p:ℝ)*((tripleRootCount p a b:ℝ)/p) := by apply Finset.prod_congr rfl intro p hp have hp0 : (p:ℝ) ≠ 0 := by exact_mod_cast (Nat.prime_of_mem_primeFactors hp).ne_zero field_simp _ = _ := by rw [Finset.prod_mul_distrib,hdensity,← Nat.cast_prod,hprod]
end TotientAsymptotic
end
end OAI12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364import OAI.NumberTheory.TotientAsymptotic.TripleSieveDenominator
namespace OAI
/-! Exactly the primes dividing ab(b-a) can merge roots of the three forms. -/noncomputable sectionnamespace TotientAsymptotic
def tripleDiscriminant (a b : ℕ) : ℕ := a*b*(b-a)
lemma tripleDiscriminant_pos {a b : ℕ} (ha : 0 < a) (hab : a < b) : 0 < tripleDiscriminant a b := Nat.mul_pos (Nat.mul_pos ha (ha.trans hab)) (Nat.sub_pos_of_lt hab)
lemma tripleRootCount_of_not_dvd {a b p : ℕ} (hab : a < b) (hp : p.Prime) (hd : ¬p ∣ tripleDiscriminant a b) : tripleRootCount p a b = 3 := by let _ : Fact p.Prime := ⟨hp⟩ have ha : ¬p ∣ a := fun h => hd (dvd_mul_of_dvd_left (dvd_mul_of_dvd_left h b) (b-a)) have hb : ¬p ∣ b := fun h => hd (dvd_mul_of_dvd_left (dvd_mul_of_dvd_right h a) (b-a)) have hdiff : ¬p ∣ b-a := fun h => hd (dvd_mul_of_dvd_right h (a*b)) have hneq : (a:ZMod p) ≠ b := by intro he apply hdiff apply (ZMod.natCast_eq_zero_iff (b-a) p).mp rw [Nat.cast_sub hab.le,he,sub_self] rw [tripleRootCount_eq_card] exact tripleSieveRoots_card_eq_three p a b ha hb hneq
lemma tripleRootCount_bounds (a b p : ℕ) (hp : p.Prime) : 1 ≤ tripleRootCount p a b ∧ tripleRootCount p a b ≤ 3 := by let _ : Fact p.Prime := ⟨hp⟩ rw [tripleRootCount_eq_card] exact ⟨Finset.card_pos.mpr ⟨0,zero_mem_tripleSieveRoots p a b⟩,tripleSieveRoots_card_le p a b⟩
lemma tripleSieveWeight_euler_factor {a b p : ℕ} (hab : a < b) (hp : p.Prime) (hp3 : 3 < p) : ((p:ℝ)/(p-1))^3 ≤ (1+tripleSieveWeight a b p)* (if p ∣ tripleDiscriminant a b then ((p:ℝ)/(p-1))^2 else 1) := by have hpR : (3:ℝ) < p := by exact_mod_cast hp3 have hb := tripleRootCount_bounds a b p hp have hk1 : (1:ℝ) ≤ tripleRootCount p a b := by exact_mod_cast hb.1 have hk3 : (tripleRootCount p a b:ℝ) ≤ 3 := by exact_mod_cast hb.2 have he : 1+tripleSieveWeight a b p = (p:ℝ)/(p-tripleRootCount p a b) := by rw [tripleSieveWeight,tripleSieveDensity_prime a b p hp] field_simp [show (p:ℝ)-(tripleRootCount p a b:ℝ) ≠ 0 by linarith] ring rw [he] split_ifs with hd · have hsingle : (p:ℝ)/(p-1) ≤ (p:ℝ)/(p-tripleRootCount p a b) := by apply div_le_div_of_nonneg_left (by linarith) (by linarith) linarith have hh := mul_le_mul_of_nonneg_right hsingle (sq_nonneg ((p:ℝ)/(p-1))) nlinarith · rw [tripleRootCount_of_not_dvd hab hp hd,mul_one] norm_num only [Nat.cast_ofNat] rw [div_pow] apply (div_le_div_iff₀ (pow_pos (by linarith : (0:ℝ) < p-1) 3) (by linarith)).mpr nlinarith
end TotientAsymptotic
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293import OAI.NumberTheory.TotientAsymptotic.TripleDiscriminantimport OAI.NumberTheory.TotientAsymptotic.SieveEulerProduct
namespace OAI
/-! The dimension-three lower bound for the collision sieve's Euler product. -/noncomputable sectionopen scoped BigOperatorsnamespace TotientAsymptotic
lemma tripleEulerProduct_eq (z : ℕ) (hz : 3 ≤ z) : primeEulerProduct z = 3*∏ p ∈ tripleSievePrimes z,(p:ℝ)/(p-1) := by classical have hthree : 3 ∈ oddSievePrimes z := by norm_num [mem_oddSievePrimes,hz] have hs : tripleSievePrimes z = (oddSievePrimes z).erase 3 := by ext p simp only [mem_tripleSievePrimes,mem_oddSievePrimes,Finset.mem_erase] constructor · rintro ⟨hpz,hpp,hp3⟩ exact ⟨by omega,hpz,hpp,by omega⟩ · rintro ⟨hp3,hpz,hpp,hp2⟩ have hp := hpp.two_le exact ⟨hpz,hpp,by omega⟩ rw [oddEulerProduct_eq z (by omega),hs,← Finset.mul_prod_erase _ _ hthree] norm_num ring
lemma tripleEulerProduct_log_lower (z : ℕ) (hz : 3 ≤ z) : Real.log z/3 ≤ ∏ p ∈ tripleSievePrimes z,(p:ℝ)/(p-1) := by have h := primeEulerProduct_log_lower z rw [tripleEulerProduct_eq z hz] at h linarith
lemma triple_exceptional_product_le_totient {D : ℕ} (hD : 0 < D) (z : ℕ) : (∏ p ∈ tripleSievePrimes z,if p ∣ D then ((p:ℝ)/(p-1))^2 else 1) ≤ ((D:ℝ)/D.totient)^2 := by classical have hp : (∏ p ∈ (tripleSievePrimes z).filter (fun p => p ∣ D),(p:ℝ)/(p-1)) ≤ (D:ℝ)/D.totient := by rw [totient_ratio_product hD] apply Finset.prod_le_prod_of_subset_of_one_le₀ · intro p hp obtain ⟨hp,hd⟩ := Finset.mem_filter.mp hp exact Nat.mem_primeFactors.mpr ⟨(mem_tripleSievePrimes.mp hp).2.1,hd,hD.ne'⟩ · intro p hp have hpp := (mem_tripleSievePrimes.mp (Finset.mem_filter.mp hp).1).2.1 have hp1 : (1:ℝ) < p := by exact_mod_cast hpp.one_lt exact div_nonneg (Nat.cast_nonneg _) (by linarith) · intro p hp _ have hp1 : (1:ℝ) < p := by exact_mod_cast (Nat.prime_of_mem_primeFactors hp).one_lt apply (le_div_iff₀ (by linarith : (0:ℝ) < p-1)).mpr linarith rw [← Finset.prod_filter,Finset.prod_pow] apply pow_le_pow_left₀ _ hp 2 apply Finset.prod_nonneg intro p hp have hp1 : (1:ℝ) < p := by exact_mod_cast (mem_tripleSievePrimes.mp (Finset.mem_filter.mp hp).1).2.1.one_lt exact div_nonneg (Nat.cast_nonneg _) (by linarith)
lemma tripleSieveEulerProduct_lower {a b : ℕ} (ha : 0 < a) (hab : a < b) (z : ℕ) (hz : 3 ≤ z) : (Real.log z)^3/27 ≤ (∏ p ∈ tripleSievePrimes z,(1+tripleSieveWeight a b p))* ((tripleDiscriminant a b:ℝ)/(tripleDiscriminant a b).totient)^2 := by have hfactor : (∏ p ∈ tripleSievePrimes z,(p:ℝ)/(p-1))^3 ≤ (∏ p ∈ tripleSievePrimes z,(1+tripleSieveWeight a b p))* (∏ p ∈ tripleSievePrimes z,if p ∣ tripleDiscriminant a b then ((p:ℝ)/(p-1))^2 else 1) := by rw [← Finset.prod_pow,← Finset.prod_mul_distrib] apply Finset.prod_le_prod₀ · intro p hp have hpR : (3:ℝ) < p := by exact_mod_cast (mem_tripleSievePrimes.mp hp).2.2 exact pow_nonneg (div_nonneg (Nat.cast_nonneg _) (by linarith)) 3 · intro p hp exact tripleSieveWeight_euler_factor hab (mem_tripleSievePrimes.mp hp).2.1 (mem_tripleSievePrimes.mp hp).2.2 have hp : 0 ≤ ∏ p ∈ tripleSievePrimes z,(1+tripleSieveWeight a b p) := Finset.prod_nonneg (fun p hp => by have := tripleSieveWeight_nonneg a b hp; linarith) have he := mul_le_mul_of_nonneg_left (triple_exceptional_product_le_totient (tripleDiscriminant_pos ha hab) z) hp have hl := pow_le_pow_left₀ (show 0 ≤ Real.log z/3 by have hz1 : (1:ℝ) ≤ z := by exact_mod_cast (show 1 ≤ z by omega) exact div_nonneg (Real.log_nonneg hz1) (by norm_num)) (tripleEulerProduct_log_lower z hz) 3 calc _ = (Real.log z/3)^3 := by ring _ ≤ _ := hl _ ≤ _ := hfactor.trans he
end TotientAsymptotic
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839import OAI.NumberTheory.TotientAsymptotic.TripleEulerProductimport OAI.NumberTheory.TotientAsymptotic.TripleSieveError
namespace OAI
/-! Elimination of Selberg's auxiliary quantities in the three-form bound. -/noncomputable sectionopen scoped BigOperatorsopen SelbergSievenamespace TotientAsymptotic
lemma triplePrimeTuples_log_bound {a b : ℕ} (ha : 0 < a) (hab : a < b) (X z : ℕ) (y : ℝ) (hy : 1 < y) (hz : 3 ≤ z) (hscale : 12*Real.log 4*(2+Real.log z) ≤ Real.log y) : ((triplePrimeTuples a b X z).card:ℝ) ≤ 54*X*((tripleDiscriminant a b:ℝ)/(tripleDiscriminant a b).totient)^2/(Real.log z)^3+2*y^3 := by let s := triplePrimeSieve a b X z y hy.le let P := ∏ p ∈ tripleSievePrimes z,(1+tripleSieveWeight a b p) let R : ℝ := ((tripleDiscriminant a b:ℝ)/(tripleDiscriminant a b).totient)^2 have hR : 0 ≤ R := sq_nonneg _ have hD : 0 < selbergBoundingSum s := selbergBoundingSum_pos s have hlog : 0 < Real.log z := Real.log_pos (by exact_mod_cast (show 1 < z by omega)) have hP : P/2 ≤ selbergBoundingSum s := tripleSieveBoundingSum_lower a b X z y hy (by omega) hscale have hprod : (Real.log z)^3/27 ≤ P*R := tripleSieveEulerProduct_lower ha hab z hz have hden : (Real.log z)^3 ≤ 54*selbergBoundingSum s*R := by have hh := mul_le_mul_of_nonneg_right hP hR nlinarith have hmain : (X:ℝ)/selbergBoundingSum s ≤ 54*X*R/(Real.log z)^3 := by apply (div_le_div_iff₀ hD (pow_pos hlog 3)).mpr have hh := mul_le_mul_of_nonneg_left hden (Nat.cast_nonneg X : (0:ℝ) ≤ X) nlinarith exact (triplePrimeTuples_bound a b X z y hy.le).trans (add_le_add hmain le_rfl)
end TotientAsymptotic
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081import OAI.NumberTheory.TotientAsymptotic.TripleSieveRootsimport OAI.NumberTheory.TotientAsymptotic.PeriodicSieveCount
namespace OAI
/-! Exact CRT and interval discrepancies for the three-form collision sieve. -/noncomputable sectionnamespace TotientAsymptotic
def tripleSievePolynomial (a b q : ℕ) : ℕ := q*(a*q+1)*(b*q+1)
def tripleRootCount (d a b : ℕ) : ℕ := Nat.card {r : ZMod d // r*((a:ZMod d)*r+1)*((b:ZMod d)*r+1)=0}
lemma tripleRootCount_eq_card (d a b : ℕ) [NeZero d] : tripleRootCount d a b = (tripleSieveRoots d a b).card := by rw [tripleRootCount,Nat.card_eq_fintype_card,Fintype.card_subtype] rfl
lemma tripleRootCount_mul {m n : ℕ} (hm : m ≠ 0) (hn : n ≠ 0) (hcop : m.Coprime n) (a b : ℕ) : tripleRootCount (m*n) a b = tripleRootCount m a b*tripleRootCount n a b := by let _ : NeZero m := ⟨hm⟩ let _ : NeZero n := ⟨hn⟩ let e := ZMod.chineseRemainder hcop have he (r : ZMod (m*n)) : r*((a:ZMod (m*n))*r+1)*((b:ZMod (m*n))*r+1)=0 ↔ (e r).1*((a:ZMod m)*(e r).1+1)*((b:ZMod m)*(e r).1+1)=0 ∧ (e r).2*((a:ZMod n)*(e r).2+1)*((b:ZMod n)*(e r).2+1)=0 := by calc _ ↔ e (r*((a:ZMod (m*n))*r+1)*((b:ZMod (m*n))*r+1))=0 := e.map_eq_zero_iff.symm _ ↔ _ := by simp only [map_mul,map_add,map_natCast,map_one,Prod.ext_iff] rfl let ep : {r : ZMod (m*n) // r*((a:ZMod (m*n))*r+1)*((b:ZMod (m*n))*r+1)=0} ≃ {r : ZMod m × ZMod n // r.1*((a:ZMod m)*r.1+1)*((b:ZMod m)*r.1+1)=0 ∧ r.2*((a:ZMod n)*r.2+1)*((b:ZMod n)*r.2+1)=0} := e.toEquiv.subtypeEquiv he let ee := ep.trans (Equiv.subtypeProdEquivProd (p := fun r : ZMod m => r*((a:ZMod m)*r+1)*((b:ZMod m)*r+1)=0) (q := fun r : ZMod n => r*((a:ZMod n)*r+1)*((b:ZMod n)*r+1)=0)) unfold tripleRootCount rw [Nat.card_eq_fintype_card,Nat.card_eq_fintype_card,Nat.card_eq_fintype_card] exact (Fintype.card_congr ee).trans (Fintype.card_prod _ _)
lemma tripleRootCount_eq_count (d a b : ℕ) (hd : 0 < d) : tripleRootCount d a b = Nat.count (fun q => d ∣ tripleSievePolynomial a b q) d := by let _ : NeZero d := ⟨hd.ne'⟩ let e : {q : ℕ // q<d ∧ d ∣ tripleSievePolynomial a b q} ≃ {r : ZMod d // r*((a:ZMod d)*r+1)*((b:ZMod d)*r+1)=0} := { toFun := fun q => ⟨q.val,by have hh := (ZMod.natCast_eq_zero_iff (tripleSievePolynomial a b q.val) d).mpr q.property.2 simpa only [tripleSievePolynomial,Nat.cast_mul,Nat.cast_add,Nat.cast_one] using hh⟩ invFun := fun r => ⟨r.val.val,ZMod.val_lt r.val,by apply (ZMod.natCast_eq_zero_iff (tripleSievePolynomial a b r.val.val) d).mp simpa only [tripleSievePolynomial,Nat.cast_mul,Nat.cast_add,Nat.cast_one, ZMod.natCast_zmod_val] using r.property⟩ left_inv := fun q => by apply Subtype.ext; exact ZMod.val_natCast_of_lt q.property.1 right_inv := fun r => by apply Subtype.ext; exact ZMod.natCast_zmod_val r.val } let _ : Fintype {q : ℕ // q<d ∧ d ∣ tripleSievePolynomial a b q} := Nat.CountSet.fintype (fun q => d ∣ tripleSievePolynomial a b q) d rw [Nat.count_eq_card_fintype] exact (Nat.card_congr e).symm.trans Nat.card_eq_fintype_card
lemma tripleSievePolynomial_mod (a b d q : ℕ) : tripleSievePolynomial a b q % d = tripleSievePolynomial a b (q%d) % d := by simp [tripleSievePolynomial,Nat.add_mod,Nat.mul_mod]
lemma tripleSieve_count_error (a b d : ℕ) (hd : 0 < d) (N : ℕ) : |(Nat.count (fun q => d ∣ tripleSievePolynomial a b q) N:ℝ)- (N:ℝ)/d*(tripleRootCount d a b:ℝ)| ≤ d := by rw [tripleRootCount_eq_count d a b hd] apply count_periodic_error d hd intro q simp only [Nat.dvd_iff_mod_eq_zero,tripleSievePolynomial_mod a b d q]
end TotientAsymptotic
end
end OAI1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586import OAI.NumberTheory.TotientAsymptotic.TripleDensity
namespace OAI
/-! The actual simultaneous primes counted by the three-form sieve. -/noncomputable sectionopen scoped BigOperatorsopen BoundingSieve SelbergSievenamespace TotientAsymptotic
def triplePrimeTuples (a b X z : ℕ) : Finset ℕ := (Finset.Icc 1 X).filter (fun q => q.Prime ∧ (a*q+1).Prime ∧ (b*q+1).Prime ∧ z < q ∧ z < a*q+1 ∧ z < b*q+1)
lemma triplePrimeTuples_coprime {a b X z q : ℕ} (hq : q ∈ triplePrimeTuples a b X z) : (∏ p ∈ tripleSievePrimes z,p).Coprime (tripleSievePolynomial a b q) := by obtain ⟨_,hq,ha,hb,hzq,hza,hzb⟩ := Finset.mem_filter.mp hq apply Nat.coprime_of_dvd intro p hp hpd hpv have hpz := (mem_tripleSievePrimes.mp (mem_tripleSievePrimes_of_dvd hp hpd)).1 change p ∣ q*(a*q+1)*(b*q+1) at hpv rcases hp.dvd_mul.mp hpv with hqa|hb' · rcases hp.dvd_mul.mp hqa with hq'|ha' · have he := (Nat.prime_dvd_prime_iff_eq hp hq).mp hq' omega · have he := (Nat.prime_dvd_prime_iff_eq hp ha).mp ha' omega · have he := (Nat.prime_dvd_prime_iff_eq hp hb).mp hb' omega
lemma triplePrimeTuples_le_sifted (a b X z : ℕ) (y : ℝ) (hy : 1 ≤ y) : ((triplePrimeTuples a b X z).card:ℝ) ≤ siftedSum (s := (triplePrimeSieve a b X z y hy).toBoundingSieve) := by let f := tripleSievePolynomial a b have hinj := (tripleSievePolynomial_strictMono a b).injective have hsubset : (triplePrimeTuples a b X z).image f ⊆ ((Finset.Icc 1 X).image f).filter (fun n => (∏ p ∈ tripleSievePrimes z,p).Coprime n) := by intro n hn obtain ⟨q,hq,rfl⟩ := Finset.mem_image.mp hn exact Finset.mem_filter.mpr ⟨Finset.mem_image.mpr ⟨q,(Finset.mem_filter.mp hq).1,rfl⟩, triplePrimeTuples_coprime hq⟩ have hh := Finset.card_le_card hsubset rw [Finset.card_image_of_injective _ hinj] at hh have he : siftedSum (s := (triplePrimeSieve a b X z y hy).toBoundingSieve) = (((Finset.Icc 1 X).image f).filter (fun n => (∏ p ∈ tripleSievePrimes z,p).Coprime n)).card := by change (∑ d ∈ (Finset.Icc 1 X).image f, if (∏ p ∈ tripleSievePrimes z,p).Coprime d then (1:ℝ) else 0) = _ rw [← Finset.sum_filter] simp rw [he] exact_mod_cast hh
lemma triplePrimeSieve_multSum (a b X z : ℕ) (y : ℝ) (hy : 1 ≤ y) (d : ℕ) : multSum (s := (triplePrimeSieve a b X z y hy).toBoundingSieve) d = (((Finset.Icc 1 X).filter (fun q => d ∣ tripleSievePolynomial a b q)).card:ℝ) := by simp only [multSum,triplePrimeSieve] rw [Finset.sum_image] · simp only [Finset.sum_boole] · exact fun r _ s _ h => (tripleSievePolynomial_strictMono _ _).injective h
lemma triplePrimeSieve_rem_le (a b X z : ℕ) (y : ℝ) (hy : 1 ≤ y) {d : ℕ} (hd : Squarefree d) : |rem (s := (triplePrimeSieve a b X z y hy).toBoundingSieve) d| ≤ d+1 := by rw [rem,triplePrimeSieve_multSum] change |(((Finset.Icc 1 X).filter (fun q => d ∣ tripleSievePolynomial a b q)).card:ℝ)- tripleSieveDensity a b d*(X:ℝ)| ≤ d+1 have he : (X:ℝ)/d*(tripleRootCount d a b:ℝ) = tripleSieveDensity a b d*(X:ℝ) := by rw [tripleRootCount_density a b d hd] field_simp [show (d:ℝ) ≠ 0 by exact_mod_cast hd.ne_zero] rw [← he] calc _ ≤ |(((Finset.Icc 1 X).filter (fun q => d ∣ tripleSievePolynomial a b q)).card:ℝ)- (Nat.count (fun q => d ∣ tripleSievePolynomial a b q) X:ℝ)|+ |(Nat.count (fun q => d ∣ tripleSievePolynomial a b q) X:ℝ)- (X:ℝ)/d*(tripleRootCount d a b:ℝ)| := abs_sub_le _ _ _ _ ≤ 1+d := add_le_add (interval_count_discrepancy _ X) (tripleSieve_count_error a b d (Nat.pos_of_ne_zero hd.ne_zero) X) _ = _ := by ring
end TotientAsymptotic
end
end OAI1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253import OAI.NumberTheory.TotientAsymptotic.SieveCutoff
namespace OAI
/-! The existing small-power cutoff also supports sieve dimension three. -/noncomputable sectionnamespace TotientAsymptotic
lemma tripleSieveCutoff_three {L : ℝ} (hL : 512*Real.log 4 ≤ L) : 3 ≤ shiftedPrimeCutoff L := by have hc : 0 < Real.log (4:ℝ) := Real.log_pos (by norm_num) have hz := shiftedPrimeCutoff_bounds hL have hlow : (2:ℝ) ≤ L/(256*Real.log 4) := (le_div_iff₀ (by positivity)).mpr (by linarith) have hp : (0:ℝ) < shiftedPrimeCutoff L := by exact_mod_cast (show 0 < shiftedPrimeCutoff L by omega) have hh := Real.log_le_sub_one_of_pos hp have hthree : (3:ℝ) ≤ shiftedPrimeCutoff L := by linarith [hz.2.1] exact_mod_cast hthree
lemma tripleSieveCutoff_scale {L : ℝ} (hL : 512*Real.log 4 ≤ L) : 12*Real.log 4*(2+Real.log (shiftedPrimeCutoff L)) ≤ Real.log (Real.exp (L/4)) := by have hc : 0 < Real.log (4:ℝ) := Real.log_pos (by norm_num) have hh := (shiftedPrimeCutoff_bounds hL).2.2.1 have hm := mul_le_mul_of_nonneg_left hh (show 0 ≤ 12*Real.log 4 by positivity) have he : 12*Real.log 4*(L/(128*Real.log 4))=3*L/32 := by field_simp; ring rw [he] at hm rw [Real.log_exp] nlinarith
lemma tripleSieveCutoff_error {L : ℝ} (hL : 512*Real.log 4 ≤ L) : (shiftedPrimeCutoff L:ℝ)+2*(Real.exp (L/4))^3 ≤ 1152*Real.exp L/L^3 := by have hc : 0 < Real.log (4:ℝ) := Real.log_pos (by norm_num) have hL0 : 0 < L := by nlinarith have he : (Real.exp (L/4))^3 = Real.exp (3*L/4) := by rw [← Real.exp_nat_mul]; congr 1; ring have hcube := Real.pow_div_factorial_le_exp (L/4) (show 0 ≤ L/4 by positivity) 3 norm_num only [Nat.factorial] at hcube have hsmall : L^3 ≤ 384*Real.exp (L/4) := by nlinarith have hm := mul_le_mul_of_nonneg_right hsmall (Real.exp_pos (3*L/4)).le have hsum : Real.exp (L/4)*Real.exp (3*L/4)=Real.exp L := by rw [← Real.exp_add]; congr 1; ring have hbound : 3*Real.exp (3*L/4) ≤ 1152*Real.exp L/L^3 := by apply (le_div_iff₀ (pow_pos hL0 3)).mpr rw [mul_assoc,hsum] at hm nlinarith rw [he] exact (by linarith [(shiftedPrimeCutoff_bounds hL).2.2.2] : (shiftedPrimeCutoff L:ℝ)+2*Real.exp (3*L/4) ≤ 3*Real.exp (3*L/4)).trans hbound
end TotientAsymptotic
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145import OAI.NumberTheory.TotientAsymptotic.TripleSieveModelimport OAI.NumberTheory.TotientAsymptotic.FiniteSieveMassimport OAI.NumberTheory.TotientAsymptotic.MertensLogMass
namespace OAI
/-! A finite Euler-product lower bound for the concrete Selberg denominator. -/noncomputable sectionopen scoped BigOperatorsopen BoundingSieve SelbergSievenamespace TotientAsymptotic
def tripleSieveWeight (a b p : ℕ) : ℝ := tripleSieveDensity a b p / (1-tripleSieveDensity a b p)
lemma tripleSieveWeight_nonneg (a b : ℕ) {z p : ℕ} (hp : p ∈ tripleSievePrimes z) : 0 ≤ tripleSieveWeight a b p := by obtain ⟨_,hpp,hp2⟩ := mem_tripleSievePrimes.mp hp exact div_nonneg (tripleSieveDensity_positive a b p hpp).le (sub_pos.mpr (tripleSieveDensity_lt_one a b p hpp hp2)).le
lemma tripleSieveWeight_moment (a b : ℕ) {z p : ℕ} (hp : p ∈ tripleSievePrimes z) : tripleSieveWeight a b p * Real.log p / (1+tripleSieveWeight a b p) = tripleSieveDensity a b p * Real.log p := by obtain ⟨_,hpp,hp2⟩ := mem_tripleSievePrimes.mp hp have hn : 1-tripleSieveDensity a b p ≠ 0 := (sub_pos.mpr (tripleSieveDensity_lt_one a b p hpp hp2)).ne' have hn' : 1+tripleSieveWeight a b p ≠ 0 := by have := tripleSieveWeight_nonneg a b hp linarith unfold tripleSieveWeight field_simp ring
lemma tripleSieve_moment_le (a b z : ℕ) (hz : 2 ≤ z) : (∑ p ∈ tripleSievePrimes z, tripleSieveWeight a b p * Real.log p / (1+tripleSieveWeight a b p)) ≤ 3*Real.log 4*(2+Real.log z) := by have hpoint (p : ℕ) (hp : p ∈ tripleSievePrimes z) : tripleSieveWeight a b p * Real.log p / (1+tripleSieveWeight a b p) ≤ 3*(Real.log p/(p:ℝ)) := by obtain ⟨_,hpp,_⟩ := mem_tripleSievePrimes.mp hp rw [tripleSieveWeight_moment a b hp,tripleSieveDensity_prime a b p hpp] let _ : Fact p.Prime := ⟨hpp⟩ rw [tripleRootCount_eq_card] have hc : ((tripleSieveRoots p a b).card:ℝ) ≤ 3 := by exact_mod_cast tripleSieveRoots_card_le p a b have hp0 : (0:ℝ) < p := by exact_mod_cast hpp.pos have hl : 0 ≤ Real.log p := Real.log_nonneg (by exact_mod_cast hpp.one_lt.le) have hh := mul_le_mul_of_nonneg_right hc (div_nonneg hl hp0.le) convert hh using 1 ring
calc _ ≤ ∑ p ∈ tripleSievePrimes z,3*(Real.log p/(p:ℝ)) := Finset.sum_le_sum hpoint _ ≤ ∑ p ∈ (Finset.Icc 2 z).filter Nat.Prime,3*(Real.log p/(p:ℝ)) := by apply Finset.sum_le_sum_of_subset_of_nonneg · intro p hp obtain ⟨hpz,hpp,_⟩ := mem_tripleSievePrimes.mp hp exact Finset.mem_filter.mpr ⟨Finset.mem_Icc.mpr ⟨hpp.two_le,hpz⟩,hpp⟩ · intro p hp _ have hpp := (Finset.mem_filter.mp hp).2 exact mul_nonneg (by norm_num) (div_nonneg (Real.log_nonneg (by exact_mod_cast hpp.one_lt.le)) (Nat.cast_nonneg _)) _ ≤ _ := by rw [← Finset.mul_sum] nlinarith [prime_log_mass_le z hz]
lemma tripleSieveTerms_prod (a b X z : ℕ) (y : ℝ) (hy : 1 ≤ y) (T : Finset ℕ) (hT : T ⊆ tripleSievePrimes z) : selbergTerms (triplePrimeSieve a b X z y hy).toBoundingSieve (∏ p ∈ T,p) = ∏ p ∈ T,tripleSieveWeight a b p := by rw [(selbergTerms_mult _).map_prod_of_prime T (fun p hp => (mem_tripleSievePrimes.mp (hT hp)).2.1)] apply Finset.prod_congr rfl intro p hp have hpp := (mem_tripleSievePrimes.mp (hT hp)).2.1 rw [SelbergSieve.selbergTerms_apply] simp only [hpp.primeFactors,Finset.prod_singleton] change tripleSieveDensity a b p * (1/(1-tripleSieveDensity a b p)) = _ simp [tripleSieveWeight,div_eq_mul_inv]
lemma tripleSieveBoundingSum_powerset (a b X z : ℕ) (y : ℝ) (hy : 1 ≤ y) : selbergBoundingSum (triplePrimeSieve a b X z y hy) = ∑ T ∈ (tripleSievePrimes z).powerset, if ((∏ p ∈ T,p : ℕ):ℝ)^2 ≤ y then ∏ p ∈ T,tripleSieveWeight a b p else 0 := by classical have hsq := tripleSievePrimes_squarefree z unfold selbergBoundingSum change (∑ d ∈ (∏ p ∈ tripleSievePrimes z,p).divisors, if (d:ℝ)^2 ≤ y then selbergTerms (triplePrimeSieve a b X z y hy).toBoundingSieve d else 0) = _ rw [← Nat.divisors_filter_squarefree_of_squarefree hsq, Nat.sum_divisors_filter_squarefree hsq.ne_zero,Nat.factors_eq] simp only [List.toFinset_coe,Finset.prod_val] change (∑ T ∈ (∏ p ∈ tripleSievePrimes z,p).primeFactors.powerset, if ((∏ p ∈ T,p : ℕ):ℝ)^2 ≤ y then selbergTerms (triplePrimeSieve a b X z y hy).toBoundingSieve (∏ p ∈ T,p) else 0) = _ rw [Nat.primeFactors_prod (fun p hp => (mem_tripleSievePrimes.mp hp).2.1)] apply Finset.sum_congr rfl intro T hT rw [tripleSieveTerms_prod a b X z y hy T (Finset.mem_powerset.mp hT)]
/-- The logarithmic first moment confines at least half of the Euler product tointegers within the square-root cutoff used by Selberg's denominator. -/theorem tripleSieveBoundingSum_lower (a b X z : ℕ) (y : ℝ) (hy : 1 < y) (hz : 2 ≤ z) (hscale : 12*Real.log 4*(2+Real.log z) ≤ Real.log y) : (∏ p ∈ tripleSievePrimes z,(1+tripleSieveWeight a b p))/2 ≤ selbergBoundingSum (triplePrimeSieve a b X z y hy.le) := by classical have hlogy : 0 < Real.log y := Real.log_pos hy have hl : 0 < Real.log y / 2 := by positivity have hm : (∑ p ∈ tripleSievePrimes z, tripleSieveWeight a b p * Real.log p / (1+tripleSieveWeight a b p)) ≤ (Real.log y/2)/2 := by nlinarith [tripleSieve_moment_le a b z hz] have hh := subset_weight_below_half (tripleSievePrimes z) (tripleSieveWeight a b) (fun p => Real.log p) (fun p hp => tripleSieveWeight_nonneg a b hp) (fun p hp => Real.log_nonneg (by exact_mod_cast (mem_tripleSievePrimes.mp hp).2.1.one_lt.le)) hl hm apply hh.trans rw [tripleSieveBoundingSum_powerset] apply Finset.sum_le_sum intro T hT have hTp := Finset.mem_powerset.mp hT have hprimes : ∀ p ∈ T,p.Prime := fun p hp => (mem_tripleSievePrimes.mp (hTp hp)).2.1 have hpos : (0:ℝ) < (∏ p ∈ T,p : ℕ) := by exact_mod_cast Finset.prod_pos (fun p hp => (hprimes p hp).pos) have hlog : Real.log ((∏ p ∈ T,p : ℕ):ℝ) = ∑ p ∈ T,Real.log p := by rw [Nat.cast_prod,Real.log_prod (fun p hp => by exact_mod_cast (hprimes p hp).ne_zero)] split_ifs with hsmall hcut hcut · exact le_rfl · exfalso apply hcut apply (Real.log_le_log_iff (sq_pos_of_pos hpos) (by linarith : 0<y)).mp rw [Real.log_pow,hlog] norm_num linarith · exact Finset.prod_nonneg (fun p hp => tripleSieveWeight_nonneg a b (hTp hp)) · exact le_rfl
end TotientAsymptotic
end
end OAI1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980import OAI.NumberTheory.TotientAsymptotic.TripleSieveCount
namespace OAI
/-! A polynomial bound for the complete error term of the concrete Selberg sieve. -/noncomputable sectionopen scoped BigOperatorsopen BoundingSieve SelbergSievenamespace TotientAsymptotic
lemma triple_sieve_divisor_weight {z d : ℕ} (hd : d ∣ ∏ p ∈ tripleSievePrimes z,p) : (3:ℕ)^ArithmeticFunction.cardDistinctFactors d ≤ d := by have hsq := (tripleSievePrimes_squarefree z).squarefree_of_dvd hd have hlen : ArithmeticFunction.cardDistinctFactors d ≤ d.primeFactorsList.length := d.primeFactorsList.dedup_sublist.length_le calc _ ≤ 3^d.primeFactorsList.length := Nat.pow_le_pow_right (by norm_num) hlen _ ≤ d.primeFactorsList.prod := List.pow_length_le_prod _ 3 (by intro p hp have hprime := Nat.prime_of_mem_primeFactorsList hp have hmem := mem_tripleSievePrimes_of_dvd hprime ((Nat.dvd_of_mem_primeFactorsList hp).trans hd) have hh := mem_tripleSievePrimes.mp hmem exact hh.2.2.le) _ = d := Nat.prod_primeFactorsList hsq.ne_zero
lemma triplePrimeSieve_error_sum (a b X z : ℕ) (y : ℝ) (hy : 1 ≤ y) : (∑ d ∈ (∏ p ∈ tripleSievePrimes z,p).divisors, if (d:ℝ) ≤ y then (3:ℝ)^ArithmeticFunction.cardDistinctFactors d* |rem (s := (triplePrimeSieve a b X z y hy).toBoundingSieve) d| else 0) ≤ 2*y^3 := by classical let P : ℕ := ∏ p ∈ tripleSievePrimes z,p let T : Finset ℕ := P.divisors.filter (fun d : ℕ => (d:ℝ) ≤ y) have hP := tripleSievePrimes_squarefree z have hT (d : ℕ) (hd : d∈T) : d∣P ∧ 1≤d ∧ (d:ℝ)≤y := by obtain ⟨hd,hy⟩ := Finset.mem_filter.mp hd obtain ⟨hd,hP0⟩ := Nat.mem_divisors.mp hd have h0 : d≠0 := by intro h subst d exact hP0 (zero_dvd_iff.mp hd) exact ⟨hd,Nat.one_le_iff_ne_zero.mpr h0,hy⟩ have hcard : (T.card:ℝ) ≤ y := by have hsub : T ⊆ Finset.Icc 1 ⌊y⌋₊ := by intro d hd have hh := hT d hd exact Finset.mem_Icc.mpr ⟨hh.2.1,Nat.le_floor hh.2.2⟩ have hh := Finset.card_le_card hsub have hc : (T.card:ℝ) ≤ ⌊y⌋₊ := by exact_mod_cast (by simpa using hh : T.card ≤ ⌊y⌋₊) exact hc.trans (Nat.floor_le (by linarith)) rw [← Finset.sum_filter] change (∑ d ∈ T,(3:ℝ)^ArithmeticFunction.cardDistinctFactors d* |rem (s := (triplePrimeSieve a b X z y hy).toBoundingSieve) d|) ≤ _ calc _ ≤ ∑ _d ∈ T,2*y^2 := by apply Finset.sum_le_sum intro d hd obtain ⟨hd,h1,hdy⟩ := hT d hd have hweight : (3:ℝ)^ArithmeticFunction.cardDistinctFactors d ≤ d := by exact_mod_cast triple_sieve_divisor_weight hd have hrem := triplePrimeSieve_rem_le a b X z y hy (hP.squarefree_of_dvd hd) have hdR : (1:ℝ)≤d := by exact_mod_cast h1 have hh := mul_le_mul hweight hrem (abs_nonneg _) (by positivity : (0:ℝ)≤d) nlinarith _ = (T.card:ℝ)*(2*y^2) := by simp _ ≤ y*(2*y^2) := mul_le_mul_of_nonneg_right hcard (by positivity) _ = _ := by ring
/-- All arithmetic remainders in the three-linear-form sieve are now eliminated. -/theorem triplePrimeTuples_bound (a b X z : ℕ) (y : ℝ) (hy : 1 ≤ y) : ((triplePrimeTuples a b X z).card:ℝ) ≤ X/selbergBoundingSum (triplePrimeSieve a b X z y hy)+2*y^3 := (triplePrimeTuples_le_sifted a b X z y hy).trans ((selberg_bound_simple (triplePrimeSieve a b X z y hy)).trans (add_le_add le_rfl (triplePrimeSieve_error_sum a b X z y hy)))
end TotientAsymptotic
end
end OAI12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485import OAI.NumberTheory.TotientAsymptotic.TripleSieveCRTimport PrimeNumberTheoremAnd.Mathlib.NumberTheory.Sieve.Selberg
namespace OAI
/-! Concrete Selberg sieve for q, aq+1 and bq+1. -/noncomputable sectionopen scoped BigOperatorsnamespace TotientAsymptotic
def tripleSievePrimes (z : ℕ) : Finset ℕ := (Nat.primesLE z).filter (fun p => 3 < p)
lemma mem_tripleSievePrimes {z p : ℕ} : p ∈ tripleSievePrimes z ↔ p ≤ z ∧ p.Prime ∧ 3 < p := by simp [tripleSievePrimes,Nat.mem_primesLE,and_assoc]
lemma tripleSievePrimes_squarefree (z : ℕ) : Squarefree (∏ p ∈ tripleSievePrimes z,p) := by apply Finset.squarefree_prod_of_pairwise_isCoprime · intro p hp q hq hpq apply Nat.coprime_iff_isRelPrime.mp have hpp := (mem_tripleSievePrimes.mp hp).2.1 have hqp := (mem_tripleSievePrimes.mp hq).2.1 exact hpp.coprime_iff_not_dvd.mpr (fun hd => hpq ((Nat.prime_dvd_prime_iff_eq hpp hqp).mp hd)) · intro p hp exact (mem_tripleSievePrimes.mp hp).2.1.squarefree
lemma mem_tripleSievePrimes_of_dvd {z p : ℕ} (hp : p.Prime) (hd : p ∣ ∏ q ∈ tripleSievePrimes z,q) : p ∈ tripleSievePrimes z := by obtain ⟨q,hq,hdq⟩ := hp.prime.exists_mem_finset_dvd hd have he := (Nat.prime_dvd_prime_iff_eq hp (mem_tripleSievePrimes.mp hq).2.1).mp hdq simpa only [he] using hq
def tripleSieveDensity (a b : ℕ) : ArithmeticFunction ℝ := ArithmeticFunction.prodPrimeFactors (fun p => (tripleRootCount p a b:ℝ)/p)
lemma tripleSieveDensity_prime (a b p : ℕ) (hp : p.Prime) : tripleSieveDensity a b p = (tripleRootCount p a b:ℝ)/p := by simp [tripleSieveDensity,ArithmeticFunction.prodPrimeFactors_apply hp.ne_zero,hp.primeFactors]
lemma tripleSieveDensity_positive (a b p : ℕ) (hp : p.Prime) : 0 < tripleSieveDensity a b p := by let _ : Fact p.Prime := ⟨hp⟩ rw [tripleSieveDensity_prime a b p hp,tripleRootCount_eq_card] have hc : 0 < (tripleSieveRoots p a b).card := Finset.card_pos.mpr ⟨0,zero_mem_tripleSieveRoots p a b⟩ exact div_pos (by exact_mod_cast hc) (by exact_mod_cast hp.pos)
lemma tripleSieveDensity_lt_one (a b p : ℕ) (hp : p.Prime) (hp3 : 3 < p) : tripleSieveDensity a b p < 1 := by let _ : Fact p.Prime := ⟨hp⟩ rw [tripleSieveDensity_prime a b p hp,tripleRootCount_eq_card] apply (div_lt_one (by exact_mod_cast hp.pos)).mpr exact_mod_cast (tripleSieveRoots_card_le p a b).trans_lt hp3
lemma tripleSievePolynomial_strictMono (a b : ℕ) : StrictMono (tripleSievePolynomial a b) := by intro q r hqr have ha : a*q+1 ≤ a*r+1 := Nat.add_le_add_right (Nat.mul_le_mul_left a hqr.le) 1 have hb : b*q+1 ≤ b*r+1 := Nat.add_le_add_right (Nat.mul_le_mul_left b hqr.le) 1 have hp : 0 < (a*r+1)*(b*r+1) := Nat.mul_pos (by omega) (by omega) calc tripleSievePolynomial a b q = q*((a*q+1)*(b*q+1)) := by unfold tripleSievePolynomial; ring _ ≤ q*((a*r+1)*(b*r+1)) := Nat.mul_le_mul_left q (Nat.mul_le_mul ha hb) _ < r*((a*r+1)*(b*r+1)) := Nat.mul_lt_mul_of_pos_right hqr hp _ = tripleSievePolynomial a b r := by unfold tripleSievePolynomial; ring
def triplePrimeSieve (a b X z : ℕ) (y : ℝ) (hy : 1 ≤ y) : SelbergSieve where support := (Finset.Icc 1 X).image (tripleSievePolynomial a b) prodPrimes := ∏ p ∈ tripleSievePrimes z,p prodPrimes_squarefree := tripleSievePrimes_squarefree z weights := fun _ => 1 weights_nonneg := fun _ => zero_le_one totalMass := X nu := tripleSieveDensity a b nu_mult := ArithmeticFunction.IsMultiplicative.prodPrimeFactors _ nu_pos_of_prime := fun p hp _ => tripleSieveDensity_positive a b p hp nu_lt_one_of_prime := fun p hp hd => tripleSieveDensity_lt_one a b p hp (mem_tripleSievePrimes.mp (mem_tripleSievePrimes_of_dvd hp hd)).2.2 level := y one_le_level := hy
end TotientAsymptotic
end
end OAI12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152import OAI.NumberTheory.TotientAsymptotic.ShiftedSieveRoots
namespace OAI
/-! The local three-linear-form sieve in Ford's collision argument. -/noncomputable sectionnamespace TotientAsymptotic
def tripleSieveRoots (p a b : ℕ) [NeZero p] : Finset (ZMod p) := Finset.univ.filter (fun r => r*((a:ZMod p)*r+1)*((b:ZMod p)*r+1)=0)
lemma tripleSieveRoots_eq_union (p a b : ℕ) [Fact p.Prime] : tripleSieveRoots p a b = shiftedSieveRoots p a ∪ shiftedSieveRoots p b := by ext r simp only [tripleSieveRoots,shiftedSieveRoots,Finset.mem_filter,Finset.mem_univ, true_and,Finset.mem_union,mul_eq_zero] tauto
lemma zero_mem_tripleSieveRoots (p a b : ℕ) [NeZero p] : (0:ZMod p) ∈ tripleSieveRoots p a b := by simp [tripleSieveRoots]
lemma tripleSieveRoots_card_le (p a b : ℕ) [Fact p.Prime] : (tripleSieveRoots p a b).card ≤ 3 := by have hcard := Finset.card_union_add_card_inter (shiftedSieveRoots p a) (shiftedSieveRoots p b) have hint : 1 ≤ (shiftedSieveRoots p a ∩ shiftedSieveRoots p b).card := by apply Finset.card_pos.mpr exact ⟨0,by simp [shiftedSieveRoots]⟩ rw [shiftedSieveRoots_card,shiftedSieveRoots_card] at hcard rw [tripleSieveRoots_eq_union] split_ifs at hcard <;> omega
lemma tripleSieveRoots_card_eq_three (p a b : ℕ) [Fact p.Prime] (ha : ¬p ∣ a) (hb : ¬p ∣ b) (hab : (a:ZMod p) ≠ b) : (tripleSieveRoots p a b).card = 3 := by have ha0 : (a:ZMod p) ≠ 0 := (ZMod.natCast_eq_zero_iff a p).not.mpr ha have hb0 : (b:ZMod p) ≠ 0 := (ZMod.natCast_eq_zero_iff b p).not.mpr hb have hinv : -(a:ZMod p)⁻¹ ≠ -(b:ZMod p)⁻¹ := by intro h apply hab exact inv_injective (neg_injective h) rw [tripleSieveRoots_eq_union,shiftedSieveRoots_of_not_dvd p a ha, shiftedSieveRoots_of_not_dvd p b hb] have he : ({0,-(a:ZMod p)⁻¹} ∪ {0,-(b:ZMod p)⁻¹} : Finset (ZMod p)) = {0,-(a:ZMod p)⁻¹,-(b:ZMod p)⁻¹} := by ext r; simp rw [he] simp [Finset.card_insert_of_notMem,ha0,hb0,hinv]
end TotientAsymptotic
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263import OAI.NumberTheory.TotientAsymptotic.CenterComparison
namespace OAI
/-! Concentration at the full-scale bands after truncating the simplex. -/
noncomputable sectionopen MeasureTheory
namespace TotientAsymptotic
def fullSimplexCenter (m : ℕ) (B : ℝ) (k : ℕ) : ℝ := B*rho^k*((m-k : ℕ) : ℝ)/m
def coarseCoordinateBad (m : ℕ) (B : ℝ) {N : ℕ} (i : Fin N) : Set (Fin N → ℝ) := {u | u i < (95/100 : ℝ)*fullSimplexCenter m B (i.val+1) ∨ (105/100 : ℝ)*fullSimplexCenter m B (i.val+1) < u i}
theorem truncated_simplex_concentration (hford : FordCoordinateConcentrationInput) : ∃ C c : ℝ, ∃ N₀ : ℕ, 0 < C ∧ 0 < c ∧ ∀ N ≥ N₀, ∀ (m q : ℕ) (B : ℝ), 0 < B → m-q=N+2 → ∀ i : Fin (N+2), i.val < N → 100*q ≤ m-(i.val+1) → (volume (prefixRegion (N+2) B 0 0 ∩ coarseCoordinateBad m B i)).toReal ≤ C*Real.exp (-c*(N+2-(i.val+1) : ℕ))*(volume (prefixRegion (N+2) B 0 0)).toReal := by obtain ⟨C, c, N₀, hC, hc, hconc⟩ := simplex_coordinate_concentration hford refine ⟨C, c, N₀, hC, hc, ?_⟩ intro N hN m q B hB hdim i hi hsmall have hqm : q < m := by omega have hik : i.val+1 ≤ m-q := by omega have him : i.val+1 < m := by omega have hmn : (m : ℝ) ≠ 0 := by exact_mod_cast (show m ≠ 0 by omega) have hS : 0 < B*rho^(i.val+1) := mul_pos hB (pow_pos rho_pos _) have hb : 0 < fullSimplexCenter m B (i.val+1) := by unfold fullSimplexCenter exact div_pos (mul_pos hS (Nat.cast_pos.mpr (Nat.sub_pos_of_lt him))) (Nat.cast_pos.mpr (by omega)) have hcenter : fordSimplexCenter N B i = (B*rho^(i.val+1))*((N+2-(i.val+1) : ℕ) : ℝ)/(N+2) := by unfold fordSimplexCenter rw [Nat.cast_sub (by omega : i.val+1 ≤ N+2)] push_cast field_simp have hcompare := truncated_center_close hS.le hqm hik hsmall rw [hdim] at hcompare simp only [Nat.cast_add, Nat.cast_ofNat] at hcompare rw [← hcenter] at hcompare change (99/100 : ℝ)*fullSimplexCenter m B (i.val+1) ≤ fordSimplexCenter N B i ∧ fordSimplexCenter N B i ≤ fullSimplexCenter m B (i.val+1) at hcompare have hbad : coarseCoordinateBad m B i ⊆ fordCoordinateBad N B i := by intro u hu apply outside_band_implies_deviation hb (by nlinarith [hcompare.1]) (by nlinarith [hcompare.2]) hu have hfin : volume (prefixRegion (N+2) B 0 0 ∩ fordCoordinateBad N B i) ≠ ⊤ := ne_top_of_le_ne_top (prefixRegion_volume_ne_top (by omega) B) (measure_mono Set.inter_subset_left) exact (ENNReal.toReal_mono hfin (measure_mono (Set.inter_subset_inter_right _ hbad))).trans (hconc N hN B hB i hi)
end TotientAsymptotic
end
end OAI1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283import OAI.NumberTheory.TotientAsymptotic.PrefixPreimageimport OAI.NumberTheory.TotientAsymptotic.TailBelowPrefix
namespace OAI
noncomputable sectionopen scoped BigOperators Topologyopen Filter
namespace TotientAsymptotic
lemma remainderTail_dvd_suffix {x : ℝ} {H : ℕ} (η : RemainderDatum (L x H)) (hRL : R x H ≤ L x H) : remainderTail x H η ∣ suffixPreimage η 0 := by have he : suffixPreimage η 0 = remainderTail x H η * ∏ i ∈ Finset.Icc 1 (R x H), remainderPrime η i := by unfold suffixPreimage remainderTail rw [prod_Icc_split_at (Nat.zero_le (R x H)) hRL] simp only [Nat.zero_add] ring rw [he] exact dvd_mul_right _ _
lemma basic_tail_lt_all_tuple_primes : ∀ᶠ H : ℕ in atTop, ∀ᶠ x : ℝ in atTop, ∀ p : ℕ, p.Prime → x^(9/10 : ℝ) ≤ p → ∀ η : RemainderDatum (L x H), IsBasicRemainder x H η → ∀ i, remainderTail x H η < tuplePrimes (witnessTuple p η) i := by filter_upwards [basic_tail_lt_last_prefix,eventually_ge_atTop 2, P_tendsto.eventually (eventually_ge_atTop 1)] with H hlast hH hP filter_upwards [theta_eventually_mem,m_tendsto.eventually (eventually_gt_atTop H), basic_remainder_subpower H (show (0 : ℝ)<1/10 by norm_num), eventually_gt_atTop (1 : ℝ)] with x hs hm hsub hx1 intro p hp hpl η hη i have hPH := P_lt_self hH have hRL : R x H < L x H := by unfold R L; omega have hLm : L x H < m x := by unfold L; omega have hRpos : 0 < R x H := by unfold R; omega refine Fin.cases ?_ (fun j => ?_) i · change remainderTail x H η < p have hwle : remainderTail x H η ≤ suffixPreimage η 0 := Nat.le_of_dvd (suffixPreimage_pos hη) (remainderTail_dvd_suffix η hRL.le) have hsmall := (show (remainderTail x H η : ℝ) ≤ suffixPreimage η 0 by exact_mod_cast hwle).trans (hsub η hη) exact_mod_cast hsmall.trans_lt ((Real.rpow_lt_rpow_of_exponent_lt hx1 (show (1/10 : ℝ)<9/10 by norm_num)).trans_le hpl) · change remainderTail x H η < remainderPrime η (j.val+1) have hj : j.val+1 ≤ R x H := by have := j.isLt; omega have hl := hlast x hs hm η hη rcases lt_or_eq_of_le hj with hj | hj · exact hl.trans (basic_remainder_prime_strictAnti hη (Finset.mem_Icc.mpr ⟨by omega,hj.le.trans hRL.le⟩) (Finset.mem_Icc.mpr ⟨hRpos,hRL.le⟩) hj (hj.trans hRL |>.trans hLm)) · simpa only [hj] using hl
/-- Every basic tuple has the candidate obtained by replacing its arithmetictail by the least inverse image of the same tail totient. -/theorem basic_tuple_candidate_realizes : ∀ᶠ H : ℕ in atTop, ∀ᶠ x : ℝ in atTop, ∀ t : ℝ, ∀ τ : TotientTuple (R x H), IsBasicTuple x H t τ → (tupleLeastCandidate τ).totient=tupleValue τ := by filter_upwards [basic_tail_lt_all_tuple_primes,eventually_tail_cut_separated] with H hsmall hH obtain ⟨hP,hcuts⟩ := hH have hPH : P H < H := by omega filter_upwards [hsmall,basic_head_coprime H,m_tendsto.eventually (eventually_ge_atTop H)] with x hsmall hc hm intro t τ hτ obtain ⟨η,hη,he⟩ := (isPrefixDatum_iff x H τ.tail).mp hτ.2.2.1 have hτe : witnessTuple τ.head η=τ := by cases τ simpa only [witnessTuple,TotientTuple.mk.injEq,true_and] using he have hRL : R x H < L x H := by unfold R L; omega apply tuple_candidate_realizes (w := remainderTail x H η) hPH.le hτ (suffixPreimage_pos (i := R x H) hη) · exact congrArg PrefixDatum.d he · intro i rw [← hτe] exact hsmall _ hτ.1 hτ.2.1 η hη i · rw [← hτe,← wholePreimage_prefix_split _ _ hRL.le] exact wholePreimage_totient hτ.1 hη (by unfold L; omega) hRL (hc _ hτ.1 hτ.2.1 η hη)
end TotientAsymptotic
end
end OAI12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394import OAI.NumberTheory.TotientAsymptotic.TupleMassApproximationimport OAI.NumberTheory.TotientAsymptotic.MassVolumeApproximation
namespace OAI
/-! The actual tuple count approximates the finite arithmetic coefficient. -/
noncomputable sectionopen scoped BigOperators Topologyopen Filter
namespace TotientAsymptotic
def tupleNormalization (x : ℝ) : ℝ := x/Real.log x*G x (m x)
lemma tupleNormalization_pos {x : ℝ} (hx : 1 < x) (hB : 0 < B x) : 0 < tupleNormalization x := mul_pos (div_pos (zero_lt_one.trans hx) (Real.log_pos hx)) (G_pos hB _)
/-- The largest-prime summation error tends to zero for each fixed cutoff,uniformly over all bounded weights and all comparable endpoints. -/theorem tuple_mass_normalized_approximation (hpnt : PrimeNumberTheoremInput) (hbox : FordUnitPrimeBoxInput) (hren : FordRenewalInput) (hmertens : MertensProductInput) {a : ℝ} (ha : 0 < a) : ∀ᶠ H : ℕ in atTop, ∀ ε : ℝ, 0 < ε → ∀ᶠ x : ℝ in atTop, ∀ t : ℝ, a*x ≤ t → t ≤ x → ∀ f : ℝ → ℝ, (∀ r, 0 ≤ f r ∧ f r ≤ 1) → |weightedTupleCount x H t f/tupleNormalization x-(t/x)*(M x H f/G x (m x))| ≤ ε := by obtain ⟨C,hC,hupper⟩ := mass_upper hbox hren hmertens filter_upwards [hupper, eventually_ge_atTop 2, P_tendsto.eventually (eventually_ge_atTop 1)] with H hH hH2 hP let C₀ := C*Real.exp ((4*(lam/rho))*cofactorScale H) have hC₀ : 0 < C₀ := mul_pos hC (Real.exp_pos _) intro ε hε filter_upwards [weighted_tuple_mass_relative hpnt ha (P_lt_self hH2) hP (div_pos hε hC₀), hH, eventually_gt_atTop (1 : ℝ), B_tendsto.eventually (eventually_gt_atTop (0 : ℝ))] with x herr hmass hx hB intro t ht htx f hf have hnorm := tupleNormalization_pos hx hB have hG := G_pos hB (m x) have ht0 : 0 < t := (mul_pos ha (zero_lt_one.trans hx)).trans_le ht have hlog := Real.log_pos hx have heq : weightedTupleCount x H t f/tupleNormalization x-(t/x)*(M x H f/G x (m x)) = (weightedTupleCount x H t f-(t/Real.log x)*M x H f)/tupleNormalization x := by unfold tupleNormalization field_simp rw [heq, abs_div, abs_of_pos hnorm] apply (div_le_iff₀ hnorm).mpr apply (herr t ht htx f hf).trans have hm : M x H (fun _ => 1) ≤ C₀*G x (m x) := hmass _ (fun _ => le_rfl) calc (ε/C₀)*(t/Real.log x)*M x H (fun _ => 1) ≤ (ε/C₀)*(t/Real.log x)*(C₀*G x (m x)) := mul_le_mul_of_nonneg_left hm (by positivity) _ = ε*(t/Real.log x)*G x (m x) := by field_simp _ ≤ ε*tupleNormalization x := by unfold tupleNormalization simpa only [mul_assoc] using mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left (div_le_div_of_nonneg_right htx hlog.le) hε.le) hG.le
/-- Combining the proved prime summation with the proved mass/volume bridgeleaves only the distinct-value/collision argument. This is a theorem aboutactual tuples, not a published hypothesis. -/theorem tuple_finite_coefficient_approximation (hpnt : PrimeNumberTheoremInput) (hbox : FordUnitPrimeBoxInput) (hmertens : MertensProductInput) (hren : FordRenewalInput) (hford : FordCoordinateConcentrationInput) {a : ℝ} (ha : 0 < a) : ∃ δ : ℕ → ℝ, Tendsto δ atTop (nhds 0) ∧ ∀ᶠ H : ℕ in atTop, ∀ f : ℝ → ℝ, (∀ r, 0 ≤ f r ∧ f r ≤ 1) → ∀ ε : ℝ, 0 < ε → ∀ᶠ x : ℝ in atTop, ∀ t : ℝ, a*x ≤ t → t ≤ x → |weightedTupleCount x H t f/tupleNormalization x-(t/x)*AH H f (theta x)| ≤ δ H+ε := by obtain ⟨δ,hδ,hmass⟩ := mass_finite_coefficient_approximation hbox hmertens hren hford refine ⟨fun H => |δ H|, by simpa using hδ.abs, ?_⟩ filter_upwards [hmass, tuple_mass_normalized_approximation hpnt hbox hren hmertens ha] with H hH htuple intro f hf ε hε filter_upwards [hH f hf (ε/2) (by positivity), htuple (ε/2) (by positivity), eventually_gt_atTop (1 : ℝ)] with x hx htup hx1 intro t ht htx have ht0 : 0 ≤ t/x := div_nonneg ((mul_pos ha (zero_lt_one.trans hx1)).trans_le ht).le (zero_lt_one.trans hx1).le have ht1 : t/x ≤ 1 := (div_le_one (zero_lt_one.trans hx1)).mpr htx calc _ ≤ |weightedTupleCount x H t f/tupleNormalization x-(t/x)*(M x H f/G x (m x))|+ |(t/x)*(M x H f/G x (m x))-(t/x)*AH H f (theta x)| := abs_sub_le _ _ _ _ ≤ ε/2+(δ H+ε/2) := by apply add_le_add (htup t ht htx f hf) rw [← mul_sub, abs_mul, abs_of_nonneg ht0] exact (mul_le_of_le_one_left (abs_nonneg _) ht1).trans hx _ ≤ |δ H|+ε := by linarith [le_abs_self (δ H)]
end TotientAsymptotic
end
end OAI12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091import OAI.NumberTheory.TotientAsymptotic.CollisionTuplesimport OAI.NumberTheory.TotientAsymptotic.CollisionIndices
namespace OAI
/-! The finite set of distinct arithmetic tuples used in the collision count. -/
noncomputable sectionopen scoped BigOperatorsattribute [local instance] Classical.propDecidable
namespace TotientAsymptotic
lemma basic_tuple_head_bound {x t : ℝ} {H : ℕ} {τ : TotientTuple (R x H)} (hPH : P H ≤ H) (hτ : IsBasicTuple x H t τ) : τ.head < ⌊t⌋₊+2 := by have hpos := basic_prefix_data_positive hPH hτ.2.2.1 have hd : 0 < τ.tail.d*∏ i, (τ.tail.primes i-1) := by apply Nat.mul_pos hpos.1 exact Finset.prod_pos (fun i _ => Nat.sub_pos_of_lt (hpos.2 i).one_lt) have hv : tupleValue τ = (τ.head-1)*(τ.tail.d*∏ i, (τ.tail.primes i-1)) := by unfold tupleValue tuplePrimes rw [Fin.prod_univ_succ] simp only [Fin.cons_zero, Fin.cons_succ] ring have hl : τ.head-1 ≤ tupleValue τ := by rw [hv]; nlinarith have hfloor : τ.head-1 ≤ ⌊t⌋₊ := Nat.le_floor ((by exact_mod_cast hl : ((τ.head-1 : ℕ) : ℝ) ≤ tupleValue τ).trans hτ.2.2.2) omega
def tupleFinset (x : ℝ) (H : ℕ) (t : ℝ) : Finset (TotientTuple (R x H)) := by classical exact (((Finset.range (⌊t⌋₊+2)) ×ˢ prefixDataFinset x H).image (fun p => TotientTuple.mk p.1 p.2)).filter (IsBasicTuple x H t)
lemma mem_tupleFinset {x t : ℝ} {H : ℕ} {τ : TotientTuple (R x H)} (hPH : P H ≤ H) : τ ∈ tupleFinset x H t ↔ IsBasicTuple x H t τ := by classical constructor · exact fun ht => (Finset.mem_filter.mp ht).2 · intro ht apply Finset.mem_filter.mpr refine ⟨?_, ht⟩ apply Finset.mem_image.mpr exact ⟨(τ.head, τ.tail), Finset.mem_product.mpr ⟨Finset.mem_range.mpr (basic_tuple_head_bound hPH ht), mem_prefixDataFinset.mpr ht.2.2.1⟩, rfl⟩
/-- The tuple fiber over a fixed tail is exactly the allowed largest-primeinterval. The prime number theorem is applied to this finite set later. -/lemma tuple_fiber_card (x : ℝ) (H : ℕ) (t : ℝ) (ζ : PrefixDatum (R x H)) : ((tupleFinset x H t).filter (fun τ : TotientTuple (R x H) => τ.tail = ζ)).card = if IsPrefixDatum x H ζ then ((Finset.range (⌊t⌋₊+2)).filter (fun p : ℕ => p.Prime ∧ x^(9/10 : ℝ) ≤ p ∧ (tupleValue (TotientTuple.mk p ζ) : ℝ) ≤ t)).card else 0 := by classical by_cases hζ : IsPrefixDatum x H ζ · rw [ite_eq_left hζ] apply Finset.card_bij (fun τ _ => τ.head) · intro τ hτ obtain ⟨hτ, ht⟩ := Finset.mem_filter.mp hτ obtain ⟨hu, hb⟩ := Finset.mem_filter.mp hτ obtain ⟨p, hp, he⟩ := Finset.mem_image.mp hu have hpr : τ.head ∈ Finset.range (⌊t⌋₊+2) := by rw [← he] exact (Finset.mem_product.mp hp).1 exact Finset.mem_filter.mpr ⟨hpr, hb.1, hb.2.1, by simpa [← ht] using hb.2.2.2⟩ · intro τ hτ σ hσ hh have ht := (Finset.mem_filter.mp hτ).2 have hs := (Finset.mem_filter.mp hσ).2 cases τ cases σ simp_all · intro p hp obtain ⟨hr, hprime, hlo, hval⟩ := Finset.mem_filter.mp hp refine ⟨⟨p, ζ⟩, Finset.mem_filter.mpr ⟨?_, rfl⟩, rfl⟩ apply Finset.mem_filter.mpr refine ⟨?_, hprime, hlo, hζ, hval⟩ exact Finset.mem_image.mpr ⟨(p, ζ), Finset.mem_product.mpr ⟨hr, mem_prefixDataFinset.mpr hζ⟩, rfl⟩ · rw [ite_eq_right hζ] apply Finset.card_eq_zero.mpr apply Finset.eq_empty_iff_forall_notMem.mpr intro τ hτ obtain ⟨hτ, ht⟩ := Finset.mem_filter.mp hτ have hb := (Finset.mem_filter.mp hτ).2.2.2.1 exact hζ (ht ▸ hb)
end TotientAsymptotic
end
end OAI1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980import OAI.NumberTheory.TotientAsymptotic.LowerPrimeCutoffimport OAI.NumberTheory.TotientAsymptotic.MassUpper
namespace OAI
/-! Largest-prime summation over the actual finite tuple set, with all weights. -/
noncomputable sectionopen scoped BigOperators Topologyopen Filterattribute [local instance] Classical.propDecidable
namespace TotientAsymptotic
def weightedTupleCount (x : ℝ) (H : ℕ) (t : ℝ) (f : ℝ → ℝ) : ℝ := ∑ τ ∈ tupleFinset x H t, f ((ell τ.tail.d : ℝ)/τ.tail.d)
lemma weightedTupleCount_eq_fibers {x t : ℝ} {H : ℕ} (hPH : P H ≤ H) (f : ℝ → ℝ) : weightedTupleCount x H t f = ∑ ζ ∈ prefixDataFinset x H, f ((ell ζ.d : ℝ)/ζ.d)*((tupleFinset x H t).filter (fun τ => τ.tail=ζ)).card := by have hmap : ∀ τ ∈ tupleFinset x H t, τ.tail ∈ prefixDataFinset x H := by intro τ hτ exact mem_prefixDataFinset.mpr ((mem_tupleFinset hPH).mp hτ).2.2.1 have he := Finset.sum_fiberwise_of_maps_to' hmap (fun ζ : PrefixDatum (R x H) => f ((ell ζ.d : ℝ)/ζ.d)) rw [weightedTupleCount, ← he] apply Finset.sum_congr rfl intro ζ _ simp [mul_comm]
/-- Relative error in largest-prime summation, uniformly over all boundedweights and all endpoints in a fixed interval `[a*x,x]`. -/theorem weighted_tuple_mass_relative (hpnt : PrimeNumberTheoremInput) {a : ℝ} (ha : 0 < a) {H : ℕ} (hPH : P H < H) (hP : 1 ≤ P H) {ε : ℝ} (hε : 0 < ε) : ∀ᶠ x : ℝ in atTop, ∀ t : ℝ, a*x ≤ t → t ≤ x → ∀ f : ℝ → ℝ, (∀ r, 0 ≤ f r ∧ f r ≤ 1) → |weightedTupleCount x H t f-(t/Real.log x)*M x H f| ≤ ε*(t/Real.log x)*M x H (fun _ => 1) := by filter_upwards [shifted_prime_uniform_asymptotic hpnt ha hε, basic_prefix_denominator_log_small hPH hP, eventually_gt_atTop (1 : ℝ)] with x hp hs hx intro t ht htx f hf have ht0 : 0 < t := (mul_pos ha (zero_lt_one.trans hx)).trans_le ht rw [weightedTupleCount_eq_fibers hPH.le, mass_eq_sum_prefixData, mass_eq_sum_prefixData, Finset.mul_sum, Finset.mul_sum, ← Finset.sum_sub_distrib] apply (Finset.abs_sum_le_sum_abs _ _).trans apply Finset.sum_le_sum intro ζ hζ have hz := mem_prefixDataFinset.mp hζ rw [tuple_fiber_eq_shiftedPrimeSet hPH.le ht0.le hz] have hD := basic_prefix_denominator_pos hPH.le hz have hc := hp (prefixDenominator ζ) hD (hs ζ hz) t ht htx have hD0 : (prefixDenominator ζ : ℝ) ≠ 0 := by exact_mod_cast hD.ne' have hden : (ζ.d : ℝ)*∏ i, (ζ.primes i-1 : ℕ) = prefixDenominator ζ := by simp only [prefixDenominator, Nat.cast_mul, Nat.cast_prod] rw [hden] have he : f ((ell ζ.d : ℝ)/ζ.d)*(↑(shiftedPrimeSet x t (prefixDenominator ζ)).card : ℝ)- t/Real.log x*(f ((ell ζ.d : ℝ)/ζ.d)/(prefixDenominator ζ : ℝ)) = f ((ell ζ.d : ℝ)/ζ.d)*((↑(shiftedPrimeSet x t (prefixDenominator ζ)).card : ℝ)- t/((prefixDenominator ζ : ℝ)*Real.log x)) := by ring rw [he, abs_mul, abs_of_nonneg (hf _).1] calc _ ≤ f ((ell ζ.d : ℝ)/ζ.d)*(ε*(t/((prefixDenominator ζ : ℝ)*Real.log x))) := mul_le_mul_of_nonneg_left hc (hf _).1 _ ≤ ε*(t/((prefixDenominator ζ : ℝ)*Real.log x)) := mul_le_of_le_one_left (mul_nonneg hε.le (div_nonneg ht0.le (mul_nonneg (Nat.cast_nonneg _) (Real.log_pos hx).le))) (hf _).2 _ = _ := by field_simp
lemma weightedTupleCount_one (x t : ℝ) (H : ℕ) : weightedTupleCount x H t (fun _ => 1) = (tupleFinset x H t).card := by simp [weightedTupleCount]
end TotientAsymptotic
end
end OAI12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970import OAI.NumberTheory.TotientAsymptotic.LargestPrimeCount
namespace OAI
/-! Tuple counts controlled by arithmetic mass. -/
noncomputable sectionopen scoped BigOperators Topologyopen Filterattribute [local instance] Classical.propDecidable
namespace TotientAsymptotic
lemma tupleValue_eq_head {R : ℕ} (p : ℕ) (ζ : PrefixDatum R) : tupleValue (TotientTuple.mk p ζ) = (p-1)*(ζ.d*∏ i, (ζ.primes i-1)) := by unfold tupleValue tuplePrimes rw [Fin.prod_univ_succ] simp only [Fin.cons_zero, Fin.cons_succ] ring
lemma basic_prefix_denominator_pos {x : ℝ} {H : ℕ} {ζ : PrefixDatum (R x H)} (hPH : P H ≤ H) (hζ : IsPrefixDatum x H ζ) : 0 < ζ.d*∏ i, (ζ.primes i-1) := by have hp := basic_prefix_data_positive hPH hζ exact Nat.mul_pos hp.1 (Finset.prod_pos (fun i _ => Nat.sub_pos_of_lt (hp.2 i).one_lt))
lemma tupleFinset_card_eq_sum_fibers {x t : ℝ} {H : ℕ} (hPH : P H ≤ H) : (tupleFinset x H t).card = ∑ ζ ∈ prefixDataFinset x H, ((tupleFinset x H t).filter (fun τ => τ.tail = ζ)).card := by rw [Finset.sum_card_fiberwise_eq_card_filter (tupleFinset x H t) (prefixDataFinset x H) TotientTuple.tail] congr 1 symm apply Finset.filter_eq_self.mpr intro τ hτ exact mem_prefixDataFinset.mpr ((mem_tupleFinset hPH).mp hτ).2.2.1
/-- Uniform at both common endpoints: an arbitrary smaller endpoint can onlyreduce the largest-prime fibers. -/theorem tuple_count_le_mass : ∀ᶠ x : ℝ in atTop, ∀ H : ℕ, P H ≤ H → ∀ t : ℝ, t ≤ x → ( (tupleFinset x H t).card : ℝ) ≤ (10*x/Real.log x)*M x H (fun _ => 1) := by filter_upwards [largest_prime_count_upper, eventually_gt_atTop (1 : ℝ)] with x hx hx1 intro H hPH t ht rw [tupleFinset_card_eq_sum_fibers hPH, Nat.cast_sum, mass_eq_sum_prefixData, Finset.mul_sum] apply Finset.sum_le_sum intro ζ hζ have hz := mem_prefixDataFinset.mp hζ rw [tuple_fiber_card, ite_eq_left hz] let D := ζ.d*∏ i, (ζ.primes i-1) let Q := (Finset.range (⌊t⌋₊+2)).filter (fun p : ℕ => p.Prime ∧ x^(9/10 : ℝ) ≤ p ∧ (tupleValue (TotientTuple.mk p ζ) : ℝ) ≤ t) have hD : 0 < D := basic_prefix_denominator_pos hPH hz have hb := hx D hD Q (by intro p hp obtain ⟨_, hprime, hlo, hval⟩ := Finset.mem_filter.mp hp refine ⟨hprime, hlo, ?_⟩ rw [tupleValue_eq_head] at hval exact hval.trans ht) change (Q.card : ℝ) ≤ _ apply hb.trans_eq dsimp [D] push_cast field_simp
end TotientAsymptotic
end
end OAIlean/OAI/NumberTheory/TotientAsymptotic/SurvivingComparison.leanAdded+118
lean/OAI/NumberTheory/TotientAsymptotic/SurvivingGridGeometry.leanAdded+80
lean/OAI/NumberTheory/TotientAsymptotic/SurvivingHeights.leanAdded+138
lean/OAI/NumberTheory/TotientAsymptotic/SurvivingSlack.leanAdded+106
lean/OAI/NumberTheory/TotientAsymptotic/TailArray.leanAdded+93
lean/OAI/NumberTheory/TotientAsymptotic/TailBelowPrefix.leanAdded+95
lean/OAI/NumberTheory/TotientAsymptotic/TailBounds.leanAdded+377
lean/OAI/NumberTheory/TotientAsymptotic/TailBoxAggregation.leanAdded+77
lean/OAI/NumberTheory/TotientAsymptotic/TailBoxCoordinates.leanAdded+74
lean/OAI/NumberTheory/TotientAsymptotic/TailCofactor.leanAdded+73
lean/OAI/NumberTheory/TotientAsymptotic/TailCutScale.leanAdded+45
lean/OAI/NumberTheory/TotientAsymptotic/TailEncoding.leanAdded+93
lean/OAI/NumberTheory/TotientAsymptotic/TailHeadCount.leanAdded+79
lean/OAI/NumberTheory/TotientAsymptotic/TailPower.leanAdded+83
lean/OAI/NumberTheory/TotientAsymptotic/TailProductBounds.leanAdded+74
lean/OAI/NumberTheory/TotientAsymptotic/TailRenewal.leanAdded+120
lean/OAI/NumberTheory/TotientAsymptotic/TailVolume.leanAdded+73
lean/OAI/NumberTheory/TotientAsymptotic/TerminalBandCount.leanAdded+109
lean/OAI/NumberTheory/TotientAsymptotic/TerminalLogBudget.leanAdded+48
lean/OAI/NumberTheory/TotientAsymptotic/TerminalMassSeries.leanAdded+51
lean/OAI/NumberTheory/TotientAsymptotic/TerminalPrefixMassCount.leanAdded+71
lean/OAI/NumberTheory/TotientAsymptotic/TerminalPrimeGap.leanAdded+76
lean/OAI/NumberTheory/TotientAsymptotic/TerminalSliceCount.leanAdded+72
lean/OAI/NumberTheory/TotientAsymptotic/TerminalStateCount.leanAdded+69
lean/OAI/NumberTheory/TotientAsymptotic/TerminalStateMass.leanAdded+62
lean/OAI/NumberTheory/TotientAsymptotic/ThickenedWitness.leanAdded+76
lean/OAI/NumberTheory/TotientAsymptotic/ThirdPrimeSize.leanAdded+67
lean/OAI/NumberTheory/TotientAsymptotic/TopRowCount.leanAdded+76
lean/OAI/NumberTheory/TotientAsymptotic/TotientCountingEnvelope.leanAdded+97
lean/OAI/NumberTheory/TotientAsymptotic/TotientPreimageBound.leanAdded+56
lean/OAI/NumberTheory/TotientAsymptotic/TotientRatioLogLog.leanAdded+128
lean/OAI/NumberTheory/TotientAsymptotic/TranslatedOrder.leanAdded+93
lean/OAI/NumberTheory/TotientAsymptotic/TranslatedPrefix.leanAdded+51
lean/OAI/NumberTheory/TotientAsymptotic/TripleDensity.leanAdded+56
lean/OAI/NumberTheory/TotientAsymptotic/TripleDiscriminant.leanAdded+64
lean/OAI/NumberTheory/TotientAsymptotic/TripleEulerProduct.leanAdded+93
lean/OAI/NumberTheory/TotientAsymptotic/TriplePrimeBound.leanAdded+39
lean/OAI/NumberTheory/TotientAsymptotic/TripleSieveCRT.leanAdded+81
lean/OAI/NumberTheory/TotientAsymptotic/TripleSieveCount.leanAdded+86
lean/OAI/NumberTheory/TotientAsymptotic/TripleSieveCutoff.leanAdded+53
lean/OAI/NumberTheory/TotientAsymptotic/TripleSieveDenominator.leanAdded+145
lean/OAI/NumberTheory/TotientAsymptotic/TripleSieveError.leanAdded+80
lean/OAI/NumberTheory/TotientAsymptotic/TripleSieveModel.leanAdded+85
lean/OAI/NumberTheory/TotientAsymptotic/TripleSieveRoots.leanAdded+52
lean/OAI/NumberTheory/TotientAsymptotic/TruncatedConcentration.leanAdded+63
lean/OAI/NumberTheory/TotientAsymptotic/TupleCandidate.leanAdded+83
lean/OAI/NumberTheory/TotientAsymptotic/TupleCoefficient.leanAdded+94
lean/OAI/NumberTheory/TotientAsymptotic/TupleCounting.leanAdded+91
lean/OAI/NumberTheory/TotientAsymptotic/TupleMassApproximation.leanAdded+80
lean/OAI/NumberTheory/TotientAsymptotic/TupleMassBound.leanAdded+70