Add lean source and binary files (part 104)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- lean/OAI/NumberTheory/EgyptianFractions/ThreePrimeContinuousMinorArc.leanAdded+89
- lean/OAI/NumberTheory/EgyptianFractions/ThreePrimeCubicStability.leanAdded+110
- lean/OAI/NumberTheory/EgyptianFractions/ThreePrimeEulerProduct.leanAdded+93
- lean/OAI/NumberTheory/EgyptianFractions/ThreePrimeEulerTail.leanAdded+176
- lean/OAI/NumberTheory/EgyptianFractions/ThreePrimeFourier.leanAdded+203
- lean/OAI/NumberTheory/EgyptianFractions/ThreePrimeFourierBundle.leanAdded+4
- lean/OAI/NumberTheory/EgyptianFractions/ThreePrimeFourierReduction.leanAdded+53
- lean/OAI/NumberTheory/EgyptianFractions/ThreePrimeIntegralCount.leanAdded+52
- lean/OAI/NumberTheory/EgyptianFractions/ThreePrimeLocalDensity.leanAdded+319
- lean/OAI/NumberTheory/EgyptianFractions/ThreePrimeLocalFactor.leanAdded+105
- lean/OAI/NumberTheory/EgyptianFractions/ThreePrimeLocalFourier.leanAdded+43
- lean/OAI/NumberTheory/EgyptianFractions/ThreePrimeLocalSeries.leanAdded+72
- lean/OAI/NumberTheory/EgyptianFractions/ThreePrimeMangoldt.leanAdded+249
- lean/OAI/NumberTheory/EgyptianFractions/ThreePrimeMangoldtAsymptotics.leanAdded+82
- lean/OAI/NumberTheory/EgyptianFractions/ThreePrimeMangoldtBridge.leanAdded+31
- lean/OAI/NumberTheory/EgyptianFractions/ThreePrimeMangoldtIntegral.leanAdded+66
- lean/OAI/NumberTheory/EgyptianFractions/ThreePrimeMangoldtPowerError.leanAdded+89
- lean/OAI/NumberTheory/EgyptianFractions/ThreePrimeMinorArc.leanAdded+188
- lean/OAI/NumberTheory/EgyptianFractions/ThreePrimeMinorEnergy.leanAdded+102
- lean/OAI/NumberTheory/EgyptianFractions/ThreePrimePartialSummation.leanAdded+108
- lean/OAI/NumberTheory/EgyptianFractions/ThreePrimeSingularSeries.leanAdded+126
- lean/OAI/NumberTheory/EgyptianFractions/ThreePrimeSingularTail.leanAdded+174
- lean/OAI/NumberTheory/EgyptianFractions/ThreePrimeWeighted.leanAdded+62
- lean/OAI/NumberTheory/EgyptianFractions/TruncatedDivisors.leanAdded+128
- lean/OAI/NumberTheory/EgyptianFractions/TypeIIBlockScalar.leanAdded+43
- lean/OAI/NumberTheory/EgyptianFractions/UniformDivisorMoment.leanAdded+91
- lean/OAI/NumberTheory/EgyptianFractions/UniformSecondMoment.leanAdded+90
- lean/OAI/NumberTheory/EgyptianFractions/UpperSlope.leanAdded+94
- lean/OAI/NumberTheory/EgyptianFractions/VanDerCorput.leanAdded+239
- lean/OAI/NumberTheory/EgyptianFractions/VaughanBilinear.leanAdded+305
- lean/OAI/NumberTheory/EgyptianFractions/VaughanCutoff.leanAdded+192
- lean/OAI/NumberTheory/EgyptianFractions/VaughanDecomposition.leanAdded+105
- lean/OAI/NumberTheory/EgyptianFractions/VaughanDyadic.leanAdded+152
- lean/OAI/NumberTheory/EgyptianFractions/VaughanDyadicDecomposition.leanAdded+96
- lean/OAI/NumberTheory/EgyptianFractions/VaughanDyadicEstimate.leanAdded+96
- lean/OAI/NumberTheory/EgyptianFractions/VaughanDyadicUniform.leanAdded+127
- lean/OAI/NumberTheory/EgyptianFractions/VaughanEstimate.leanAdded+140
- lean/OAI/NumberTheory/EgyptianFractions/VaughanHyperbola.leanAdded+144
- lean/OAI/NumberTheory/EgyptianFractions/VaughanHyperbolicNearRational.leanAdded+55
- lean/OAI/NumberTheory/EgyptianFractions/VaughanIdentity.leanAdded+180
- lean/OAI/NumberTheory/EgyptianFractions/VaughanNearRational.leanAdded+269
- lean/OAI/NumberTheory/EgyptianFractions/VaughanOptimized.leanAdded+86
- lean/OAI/NumberTheory/EgyptianFractions/VaughanRealTypeIHyperbolic.leanAdded+112
- lean/OAI/NumberTheory/EgyptianFractions/VaughanTypeI.leanAdded+160
- lean/OAI/NumberTheory/EgyptianFractions/VaughanTypeINormalized.leanAdded+102
- lean/OAI/NumberTheory/EgyptianFractions/VaughanWeighted.leanAdded+108
- lean/OAI/NumberTheory/EgyptianFractions/WeightedBinomial.leanAdded+55
- lean/OAI/NumberTheory/GaussianMoat/AccurateScales.leanAdded+336
- lean/OAI/NumberTheory/GaussianMoat/BackwardCoverage.leanAdded+388
- lean/OAI/NumberTheory/GaussianMoat/BatchCertificate.leanAdded+271
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889import OAI.NumberTheory.EgyptianFractions.ThreePrimeContinuousEnergyimport OAI.NumberTheory.EgyptianFractions.ThreePrimeMinorArc
namespace OAInoncomputable sectionopen scoped BigOperatorsopen MeasureTheory
namespace Problem337.ThreePrimeContinuousMinorArc
/-- The actual prime logarithmic exponential sum, with positive phase. -/def primeExponentialSum (u : ℕ) (x : ℝ) : ℂ := ThreePrimeContinuousEnergy.natPolynomial (Nat.primesLE u) (fun p => (Real.log (p : ℝ) : ℂ)) x
lemma primeExponentialSum_eq (u : ℕ) (x : ℝ) : primeExponentialSum u x = ∑ p ∈ (Finset.Icc 1 u).filter Nat.Prime, (Real.log (p : ℝ) : ℂ) * Complex.exp (2 * Real.pi * Complex.I * (p : ℂ) * (x : ℂ)) := by rw [primeExponentialSum, ThreePrimeContinuousEnergy.natPolynomial, Nat.primesLE_eq_filter_Icc_one]
/-- Every real frequency gives a unit-modulus phase. -/lemma phase_norm (t x : ℝ) : ‖Complex.exp (2 * Real.pi * Complex.I * (t : ℂ) * (x : ℂ))‖ = 1 := by rw [Complex.norm_exp] simp [Complex.mul_re, Complex.mul_im]
/-- The unconditional amplitude estimate needed in major-arc error budgets. -/theorem primeExponentialSum_norm_le (u : ℕ) (x : ℝ) : ‖primeExponentialSum u x‖ ≤ Real.log 4 * (u : ℝ) := by apply ThreePrimeMinorArc.prime_sum_norm_le intro p hp exact (phase_norm p x).le
/-- Exact energy of the prime exponential sum on one unit interval. -/theorem primeExponentialSum_parseval (u : ℕ) : (∫ x : ℝ in 0..1, ‖primeExponentialSum u x‖ ^ 2) = ∑ p ∈ Nat.primesLE u, Real.log (p : ℝ) ^ 2 := by simpa only [primeExponentialSum, Complex.norm_real, Real.norm_eq_abs, sq_abs] using ThreePrimeContinuousEnergy.nat_polynomial_parseval_interval (Nat.primesLE u) (fun p => (Real.log (p : ℝ) : ℂ))
/-- Continuous prime minor arcs with an arbitrary norm-bounded twist.The prime supremum estimate remains an explicit analytic hypothesis. -/theorem prime_minor_cubic_bound (u : ℕ) (hu : 2 ≤ u) (phase : ℝ → ℂ) (minor : Set ℝ) (hmeas : MeasurableSet minor) (hsubset : minor ⊆ Set.Icc 0 1) (ε : ℝ) (hε : 0 ≤ ε) (hminor : ∀ x ∈ minor, ‖primeExponentialSum u x‖ ≤ ε * (u : ℝ) / Real.log (u : ℝ)) (hphase : ∀ x ∈ minor, ‖phase x‖ ≤ 1) : ‖∫ x in minor, primeExponentialSum u x ^ 3 * phase x‖ ≤ ε * Real.log 4 * (u : ℝ) ^ 2 := by have hu1 : 1 < (u : ℝ) := by exact_mod_cast (show 1 < u by omega) have hlog : 0 < Real.log (u : ℝ) := Real.log_pos hu1 have hB : 0 ≤ ε * (u : ℝ) / Real.log (u : ℝ) := by positivity have h := ThreePrimeContinuousEnergy.nat_polynomial_interval_minor_cubic_bound (Nat.primesLE u) (fun p => (Real.log (p : ℝ) : ℂ)) phase minor hmeas hsubset (ε * (u : ℝ) / Real.log (u : ℝ)) hB hminor hphase change ‖∫ x in minor, primeExponentialSum u x ^ 3 * phase x‖ ≤ _ at h simp only [Complex.norm_real, Real.norm_eq_abs, sq_abs] at h apply h.trans calc ε * (u : ℝ) / Real.log (u : ℝ) * (∑ p ∈ Nat.primesLE u, Real.log (p : ℝ) ^ 2) ≤ ε * (u : ℝ) / Real.log (u : ℝ) * (Real.log 4 * (u : ℝ) * Real.log (u : ℝ)) := mul_le_mul_of_nonneg_left (ThreePrimeMinorArc.prime_log_squares_le u (by omega)) hB _ = ε * Real.log 4 * (u : ℝ) ^ 2 := by field_simp
/-- Conventional negative extraction frequency for the cubic prime count. -/theorem prime_minor_extraction_bound (u : ℕ) (hu : 2 ≤ u) (minor : Set ℝ) (hmeas : MeasurableSet minor) (hsubset : minor ⊆ Set.Icc 0 1) (ε : ℝ) (hε : 0 ≤ ε) (hminor : ∀ x ∈ minor, ‖primeExponentialSum u x‖ ≤ ε * (u : ℝ) / Real.log (u : ℝ)) : ‖∫ x in minor, primeExponentialSum u x ^ 3 * Complex.exp (2 * Real.pi * Complex.I * (-(u : ℂ)) * (x : ℂ))‖ ≤ ε * Real.log 4 * (u : ℝ) ^ 2 := by apply prime_minor_cubic_bound u hu _ minor hmeas hsubset ε hε hminor intro x hx simpa only [Complex.ofReal_neg, Complex.ofReal_natCast] using (phase_norm (-(u : ℝ)) x).le
end Problem337.ThreePrimeContinuousMinorArc
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110import Mathlib
namespace OAInoncomputable sectionopen MeasureTheoryopen scoped ENNReal
namespace Problem337.ThreePrimeCubicStability
/-- Exact polynomial factorization gives a norm estimate without choosingcommon upper bounds for the two arguments. -/theorem norm_cube_sub_cube_le (z w : ℂ) : ‖z ^ 3 - w ^ 3‖ ≤ ‖z - w‖ * (‖z‖ ^ 2 + ‖z‖ * ‖w‖ + ‖w‖ ^ 2) := by have hfactor : z ^ 3 - w ^ 3 = (z - w) * (z ^ 2 + z * w + w ^ 2) := by ring rw [hfactor, norm_mul] apply mul_le_mul_of_nonneg_left _ (norm_nonneg _) calc ‖z ^ 2 + z * w + w ^ 2‖ ≤ ‖z ^ 2 + z * w‖ + ‖w ^ 2‖ := norm_add_le _ _ _ ≤ (‖z ^ 2‖ + ‖z * w‖) + ‖w ^ 2‖ := add_le_add (norm_add_le _ _) le_rfl _ = _ := by simp only [norm_pow, norm_mul]
/-- Asymmetric uniform error estimate for two cubic expressions. -/theorem norm_cube_sub_cube_le_of_bounds (z w : ℂ) {E M N : ℝ} (hE : 0 ≤ E) (hM : 0 ≤ M) (_hN : 0 ≤ N) (hdiff : ‖z - w‖ ≤ E) (hz : ‖z‖ ≤ M) (hw : ‖w‖ ≤ N) : ‖z ^ 3 - w ^ 3‖ ≤ E * (M ^ 2 + M * N + N ^ 2) := by apply (norm_cube_sub_cube_le z w).trans apply mul_le_mul hdiff _ (by positivity) hE exact add_le_add (add_le_add (pow_le_pow_left₀ (norm_nonneg _) hz 2) (mul_le_mul hz hw (norm_nonneg _) hM)) (pow_le_pow_left₀ (norm_nonneg _) hw 2)
/-- Cubic approximation error integrated over an arbitrary finite-measure set.No measurability or integrability is silently assumed: the Bochner norm boundis valid also when the displayed integral is defined by zero. -/theorem norm_cubic_error_integral_le {α : Type*} [MeasurableSpace α] {μ : Measure α} {s : Set α} (hs : μ s < ∞) (F G ψ : α → ℂ) {E M N : ℝ} (hE : 0 ≤ E) (hM : 0 ≤ M) (hN : 0 ≤ N) (hdiff : ∀ x ∈ s, ‖F x - G x‖ ≤ E) (hF : ∀ x ∈ s, ‖F x‖ ≤ M) (hG : ∀ x ∈ s, ‖G x‖ ≤ N) (hψ : ∀ x ∈ s, ‖ψ x‖ ≤ 1) : ‖∫ x in s, (F x ^ 3 - G x ^ 3) * ψ x ∂μ‖ ≤ E * (M ^ 2 + M * N + N ^ 2) * (μ s).toReal := by apply norm_setIntegral_le_of_norm_le_const hs intro x hx rw [norm_mul] calc ‖F x ^ 3 - G x ^ 3‖ * ‖ψ x‖ ≤ (E * (M ^ 2 + M * N + N ^ 2)) * 1 := mul_le_mul (norm_cube_sub_cube_le_of_bounds (F x) (G x) hE hM hN (hdiff x hx) (hF x hx) (hG x hx)) (hψ x hx) (norm_nonneg _) (by positivity) _ = _ := mul_one _
/-- A common amplitude bound gives the standard `3 E M²` cubic error. -/theorem norm_cubic_error_integral_le_common {α : Type*} [MeasurableSpace α] {μ : Measure α} {s : Set α} (hs : μ s < ∞) (F G ψ : α → ℂ) {E M : ℝ} (hE : 0 ≤ E) (hM : 0 ≤ M) (hdiff : ∀ x ∈ s, ‖F x - G x‖ ≤ E) (hF : ∀ x ∈ s, ‖F x‖ ≤ M) (hG : ∀ x ∈ s, ‖G x‖ ≤ M) (hψ : ∀ x ∈ s, ‖ψ x‖ ≤ 1) : ‖∫ x in s, (F x ^ 3 - G x ^ 3) * ψ x ∂μ‖ ≤ 3 * E * M ^ 2 * (μ s).toReal := by convert norm_cubic_error_integral_le hs F G ψ hE hM hM hdiff hF hG hψ using 1 ring
/-- When the two cubic integrands are integrable, the error estimate controlsthe difference of their integrals, as required by major-arc approximation. -/theorem norm_cubic_integral_sub_le {α : Type*} [MeasurableSpace α] {μ : Measure α} {s : Set α} (hs : μ s < ∞) (F G ψ : α → ℂ) {E M : ℝ} (hE : 0 ≤ E) (hM : 0 ≤ M) (hFi : IntegrableOn (fun x => F x ^ 3 * ψ x) s μ) (hGi : IntegrableOn (fun x => G x ^ 3 * ψ x) s μ) (hdiff : ∀ x ∈ s, ‖F x - G x‖ ≤ E) (hF : ∀ x ∈ s, ‖F x‖ ≤ M) (hG : ∀ x ∈ s, ‖G x‖ ≤ M) (hψ : ∀ x ∈ s, ‖ψ x‖ ≤ 1) : ‖(∫ x in s, F x ^ 3 * ψ x ∂μ) - (∫ x in s, G x ^ 3 * ψ x ∂μ)‖ ≤ 3 * E * M ^ 2 * (μ s).toReal := by rw [← integral_sub hFi hGi] simpa only [sub_mul] using norm_cubic_error_integral_le_common hs F G ψ hE hM hdiff hF hG hψ
/-- Oriented-interval version of cubic stability, independent of endpoint order. -/theorem norm_cubic_interval_error_le (F G ψ : ℝ → ℂ) (a b : ℝ) {E M : ℝ} (hE : 0 ≤ E) (hM : 0 ≤ M) (hdiff : ∀ x ∈ Set.uIoc a b, ‖F x - G x‖ ≤ E) (hF : ∀ x ∈ Set.uIoc a b, ‖F x‖ ≤ M) (hG : ∀ x ∈ Set.uIoc a b, ‖G x‖ ≤ M) (hψ : ∀ x ∈ Set.uIoc a b, ‖ψ x‖ ≤ 1) : ‖∫ x in a..b, (F x ^ 3 - G x ^ 3) * ψ x‖ ≤ 3 * E * M ^ 2 * |b - a| := by apply intervalIntegral.norm_integral_le_of_norm_le_const intro x hx have hbound : ‖F x ^ 3 - G x ^ 3‖ ≤ 3 * E * M ^ 2 := by convert norm_cube_sub_cube_le_of_bounds (F x) (G x) hE hM hM (hdiff x hx) (hF x hx) (hG x hx) using 1 ring rw [norm_mul] calc _ ≤ (3 * E * M ^ 2) * 1 := mul_le_mul hbound (hψ x hx) (norm_nonneg _) (by positivity) _ = _ := mul_one _
end Problem337.ThreePrimeCubicStability
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293import OAI.NumberTheory.EgyptianFractions.ThreePrimeSingularSeries
namespace OAInoncomputable sectionopen scoped BigOperators
namespace Problem337
/-- The standard ternary local Euler factor, extended by one at nonprimes. -/def ternaryEulerFactor (u p : ℕ) : ℝ := if p.Prime then if p ∣ u then 1 - 1 / ((p : ℝ) - 1) ^ 2 else 1 + 1 / ((p : ℝ) - 1) ^ 3 else 1
lemma ternaryEulerFactor_add_three (u n : ℕ) : ternaryEulerFactor u (n + 3) = 1 + threePrimeOddPerturbation u n := by have heq : ((n + 3 : ℕ) : ℝ) - 1 = (n : ℝ) + 2 := by push_cast; ring unfold ternaryEulerFactor threePrimeOddPerturbation rw [heq] split_ifs <;> ring
lemma ternaryEulerFactor_two (u : ℕ) : ternaryEulerFactor u 2 = if Odd u then 2 else 0 := by unfold ternaryEulerFactor norm_num only [Nat.prime_two, ite_true, Nat.cast_ofNat] by_cases h : 2 ∣ u · have hn : ¬ Odd u := fun ho => (Nat.not_even_iff_odd.mpr ho) (even_iff_two_dvd.mpr h) norm_num [h, hn] · have ho : Odd u := Nat.not_even_iff_odd.mp (fun he => h (even_iff_two_dvd.mp he)) norm_num [h, ho]
lemma ternaryEulerFactor_prefix (u : ℕ) : (∏ p ∈ Finset.range 3, ternaryEulerFactor u p) = if Odd u then 2 else 0 := by simp only [Finset.prod_range_succ, Finset.prod_range_zero, one_mul] have h0 : ternaryEulerFactor u 0 = 1 := by simp [ternaryEulerFactor, Nat.not_prime_zero] have h1 : ternaryEulerFactor u 1 = 1 := by simp [ternaryEulerFactor] rw [h0, h1, one_mul, one_mul, ternaryEulerFactor_two]
lemma ternaryEulerFactor_tail_multipliable (u : ℕ) : Multipliable (fun n : ℕ => ternaryEulerFactor u (n + 3)) := by exact (threePrimeOddFactors_multipliable u).congr (fun n => (ternaryEulerFactor_add_three u n).symm)
lemma ternaryEulerFactor_multipliable (u : ℕ) : Multipliable (ternaryEulerFactor u) := (ternaryEulerFactor_tail_multipliable u).comp_nat_add
/-- The shifted odd-prime definition is exactly the conventional Eulerproduct, including the vanishing local factor at two for even inputs. -/theorem threePrimeSingularSeries_eq_euler_tprod (u : ℕ) : threePrimeSingularSeries u = ∏' p : ℕ, ternaryEulerFactor u p := by calc threePrimeSingularSeries u = (if Odd u then 2 else 0) * ∏' n : ℕ, ternaryEulerFactor u (n + 3) := by unfold threePrimeSingularSeries congr 1 exact tprod_congr (fun n => (ternaryEulerFactor_add_three u n).symm) _ = (∏ p ∈ Finset.range 3, ternaryEulerFactor u p) * ∏' n : ℕ, ternaryEulerFactor u (n + 3) := by rw [ternaryEulerFactor_prefix] _ = ∏' p : ℕ, ternaryEulerFactor u p := (ternaryEulerFactor_tail_multipliable u).prod_mul_tprod_nat_mul'
/-- Removing the factors equal to one at nonprimes recovers the usualprime-indexed singular series. This identity is valid for all natural inputs. -/theorem threePrimeSingularSeries_eq_prime_tprod (u : ℕ) : threePrimeSingularSeries u = ∏' p : {p : ℕ // p.Prime}, (if p.val ∣ u then 1 - 1 / ((p.val : ℝ) - 1) ^ 2 else 1 + 1 / ((p.val : ℝ) - 1) ^ 3) := by have hs : Function.mulSupport (ternaryEulerFactor u) ⊆ {p : ℕ | p.Prime} := by intro p hp by_contra hn change ¬ p.Prime at hn exact hp (by simp [ternaryEulerFactor, hn]) rw [threePrimeSingularSeries_eq_euler_tprod, ← tprod_subtype_eq_of_mulSupport_subset hs] apply tprod_congr intro p have hp : Nat.Prime (p : ℕ) := p.property simp only [ternaryEulerFactor, hp, ite_true]
lemma threePrimeSingularSeries_eq_zero_of_even {u : ℕ} (hu : Even u) : threePrimeSingularSeries u = 0 := by have hn : ¬ Odd u := fun ho => Nat.not_even_iff_odd.mpr ho hu simp [threePrimeSingularSeries, hn]
end Problem337
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176import Mathlib
namespace OAInoncomputable sectionopen scoped BigOperators
namespace Problem337.ThreePrimeEulerTail
/-- A reciprocal-square tail is bounded by a telescoping reciprocal tail.The statement is for arbitrary finite sets, hence also for sets of primes. -/theorem reciprocal_square_tail (P : Finset ℕ) (N : ℕ) (hN : 2 ≤ N) (hP : ∀ p ∈ P, N < p) : (∑ p ∈ P, 1 / ((p : ℝ) - 1) ^ 2) ≤ 1 / ((N : ℝ) - 1) := by classical by_cases hempty : P = ∅ · subst P simp only [Finset.sum_empty] apply one_div_nonneg.mpr have : (2 : ℝ) ≤ N := by exact_mod_cast hN linarith have hne : P.Nonempty := Finset.nonempty_iff_ne_empty.mpr hempty let M := P.max' hne have hNM : N < M := hP M (Finset.max'_mem P hne) have hsub : P ⊆ Finset.Ico (N + 1) (M + 1) := by intro p hp exact Finset.mem_Ico.mpr ⟨by have := hP p hp; omega, by have := Finset.le_max' P p hp; omega⟩ have hpoint (p : ℕ) (hp : p ∈ Finset.Ico (N + 1) (M + 1)) : 1 / ((p : ℝ) - 1) ^ 2 ≤ 1 / ((p : ℝ) - 2) - 1 / (((p + 1 : ℕ) : ℝ) - 2) := by have hp3 : 3 ≤ p := by have := (Finset.mem_Ico.mp hp).1; omega have hpR : (3 : ℝ) ≤ p := by exact_mod_cast hp3 have hp1 : 0 < (p : ℝ) - 1 := by linarith have hp2 : 0 < (p : ℝ) - 2 := by linarith push_cast have heq : (p : ℝ) + 1 - 2 = (p : ℝ) - 1 := by ring rw [heq] field_simp nlinarith calc _ ≤ ∑ p ∈ Finset.Ico (N + 1) (M + 1), 1 / ((p : ℝ) - 1) ^ 2 := Finset.sum_le_sum_of_subset_of_nonneg hsub (by intros; positivity) _ ≤ ∑ p ∈ Finset.Ico (N + 1) (M + 1), (1 / ((p : ℝ) - 2) - 1 / (((p + 1 : ℕ) : ℝ) - 2)) := Finset.sum_le_sum hpoint _ = 1 / (((N + 1 : ℕ) : ℝ) - 2) - 1 / (((M + 1 : ℕ) : ℝ) - 2) := by have htel := Finset.sum_Ico_sub (fun p : ℕ => -(1 / ((p : ℝ) - 2))) (show N + 1 ≤ M + 1 by omega) simpa only [neg_sub_neg] using htel _ ≤ 1 / ((N : ℝ) - 1) := by have hM : (2 : ℝ) ≤ M := by exact_mod_cast (show 2 ≤ M by omega) have hpos : 0 ≤ 1 / (((M + 1 : ℕ) : ℝ) - 2) := by apply one_div_nonneg.mpr push_cast linarith push_cast at * have heq : (N : ℝ) + 1 - 2 = (N : ℝ) - 1 := by ring rw [heq] linarith
/-- Uniform finite Euler-tail error from the standard local-factor defect bound. -/theorem product_tail_abs_sub_one (f : ℕ → ℝ) (P : Finset ℕ) (N : ℕ) (hN : 2 ≤ N) (hP : ∀ p ∈ P, N < p) (hf : ∀ p ∈ P, |f p - 1| ≤ 1 / ((p : ℝ) - 1) ^ 2) : |(∏ p ∈ P, f p) - 1| ≤ 2 / ((N : ℝ) - 1) := by have hsum : (∑ p ∈ P, |f p - 1|) ≤ 1 / ((N : ℝ) - 1) := (Finset.sum_le_sum hf).trans (reciprocal_square_tail P N hN hP) have hNreal : (2 : ℝ) ≤ N := by exact_mod_cast hN have hden : 0 < (N : ℝ) - 1 := by linarith have hsmall : |1 / ((N : ℝ) - 1)| ≤ 1 := by rw [abs_of_nonneg (by positivity)] exact (div_le_one hden).mpr (by linarith) have hprod := P.norm_prod_one_add_sub_one_le (fun p => f p - 1) simp only [add_sub_cancel, Real.norm_eq_abs] at hprod calc _ ≤ Real.exp (∑ p ∈ P, |f p - 1|) - 1 := hprod _ ≤ Real.exp (1 / ((N : ℝ) - 1)) - 1 := sub_le_sub_right (Real.exp_le_exp.mpr hsum) 1 _ ≤ |Real.exp (1 / ((N : ℝ) - 1)) - 1| := le_abs_self _ _ ≤ 2 * |1 / ((N : ℝ) - 1)| := Real.abs_exp_sub_one_le hsmall _ = 2 / ((N : ℝ) - 1) := by rw [abs_of_nonneg (by positivity)]; ring
/-- The local-factor defect majorant gives absolute summability without imposingany condition on the finitely many initial factors. -/theorem summable_abs_sub_one (f : ℕ → ℝ) (hf : ∀ p : ℕ, 3 ≤ p → |f p - 1| ≤ 1 / ((p : ℝ) - 1) ^ 2) : Summable (fun p => |f p - 1|) := by have hseries : Summable (fun n : ℕ => 1 / (n : ℝ) ^ 2) := Real.summable_one_div_nat_pow.mpr (by norm_num) have hshift := (summable_nat_add_iff 2).mpr hseries apply (summable_nat_add_iff 3).mp apply hshift.of_nonneg_of_le (fun n => abs_nonneg _) intro n have h := hf (n + 3) (by omega) convert h using 1 push_cast ring
/-- Absolute summability of the local defects defines a genuine Euler product. -/theorem multipliable (f : ℕ → ℝ) (hf : ∀ p : ℕ, 3 ≤ p → |f p - 1| ≤ 1 / ((p : ℝ) - 1) ^ 2) : Multipliable f := by have hsum : Summable (fun p => f p - 1) := by apply Summable.of_norm simpa only [Real.norm_eq_abs] using summable_abs_sub_one f hf simpa only [add_sub_cancel] using Real.multipliable_one_add_of_summable hsum
/-- A partial Euler product approximates its infinite product with an explicitrelative error. Only the universal local defect estimate is needed. -/theorem tprod_sub_partial_abs_le (f : ℕ → ℝ) (hf : ∀ p : ℕ, 3 ≤ p → |f p - 1| ≤ 1 / ((p : ℝ) - 1) ^ 2) (N : ℕ) (hN : 2 ≤ N) : |(∏' p, f p) - ∏ p ∈ Finset.range (N + 1), f p| ≤ |∏ p ∈ Finset.range (N + 1), f p| * (2 / ((N : ℝ) - 1)) := by apply le_of_tendsto (((multipliable f hf).hasProd.tendsto_prod_nat.sub_const (∏ p ∈ Finset.range (N + 1), f p)).abs) filter_upwards [Filter.eventually_ge_atTop (N + 1)] with M hNM rw [← Finset.prod_range_mul_prod_Ico f hNM] have heq : (∏ p ∈ Finset.range (N + 1), f p) * (∏ p ∈ Finset.Ico (N + 1) M, f p) - (∏ p ∈ Finset.range (N + 1), f p) = (∏ p ∈ Finset.range (N + 1), f p) * ((∏ p ∈ Finset.Ico (N + 1) M, f p) - 1) := by ring rw [heq, abs_mul] apply mul_le_mul_of_nonneg_left _ (abs_nonneg _) apply product_tail_abs_sub_one f _ N hN · intro p hp have := (Finset.mem_Ico.mp hp).1 omega · intro p hp apply hf have := (Finset.mem_Ico.mp hp).1 omega
/-- All partial products are bounded by three times their first three factors.This estimate is uniform in any external parameter of the local factors. -/theorem partial_abs_le (f : ℕ → ℝ) (hf : ∀ p : ℕ, 3 ≤ p → |f p - 1| ≤ 1 / ((p : ℝ) - 1) ^ 2) (N : ℕ) (hN : 2 ≤ N) : |∏ p ∈ Finset.range (N + 1), f p| ≤ 3 * |∏ p ∈ Finset.range 3, f p| := by rw [← Finset.prod_range_mul_prod_Ico f (show 3 ≤ N + 1 by omega), abs_mul] have htail := product_tail_abs_sub_one f (Finset.Ico 3 (N + 1)) 2 (by omega) (by intro p hp; have := (Finset.mem_Ico.mp hp).1; omega) (by intro p hp; exact hf p (Finset.mem_Ico.mp hp).1) norm_num only [Nat.cast_ofNat, sub_self, one_div, Nat.cast_one, sub_zero] at htail have hbound : |∏ p ∈ Finset.Ico 3 (N + 1), f p| ≤ 3 := by calc _ = |((∏ p ∈ Finset.Ico 3 (N + 1), f p) - 1) + 1| := by ring_nf _ ≤ |(∏ p ∈ Finset.Ico 3 (N + 1), f p) - 1| + |(1 : ℝ)| := abs_add_le _ _ _ ≤ 3 := by norm_num at htail ⊢; linarith nlinarith [abs_nonneg (∏ p ∈ Finset.range 3, f p)]
/-- Uniform O(1/N) truncation error, stated with a bound for the only threeuncontrolled initial local factors. -/theorem tprod_sub_partial_abs_le_uniform (f : ℕ → ℝ) (hf : ∀ p : ℕ, 3 ≤ p → |f p - 1| ≤ 1 / ((p : ℝ) - 1) ^ 2) (B : ℝ) (hB : |∏ p ∈ Finset.range 3, f p| ≤ B) (N : ℕ) (hN : 2 ≤ N) : |(∏' p, f p) - ∏ p ∈ Finset.range (N + 1), f p| ≤ 6 * B / ((N : ℝ) - 1) := by have hNR : (2 : ℝ) ≤ N := by exact_mod_cast hN have hden : 0 < (N : ℝ) - 1 := by linarith calc _ ≤ |∏ p ∈ Finset.range (N + 1), f p| * (2 / ((N : ℝ) - 1)) := tprod_sub_partial_abs_le f hf N hN _ ≤ (3 * B) * (2 / ((N : ℝ) - 1)) := by apply mul_le_mul_of_nonneg_right _ (by positivity) exact (partial_abs_le f hf N hN).trans (mul_le_mul_of_nonneg_left hB (by norm_num)) _ = 6 * B / ((N : ℝ) - 1) := by ring
end Problem337.ThreePrimeEulerTail
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203import OAI.NumberTheory.EgyptianFractions.RationalSupplyReduction
namespace OAInoncomputable sectionopen scoped BigOperators
namespace Problem337.ThreePrimeFourier
/-- Exact Fourier extraction of a weighted ordered triple in a finite cyclic group. No primality or analytic estimate is needed. -/theorem weighted_triple_character_identity {q : ℕ} [NeZero q] {α : Type*} (s : Finset α) (f : α → ZMod q) (w : α → ℂ) (u : ZMod q) : (∑ r : ZMod q, (∑ a ∈ s, w a * ZMod.stdAddChar (f a * r)) ^ 3 * ZMod.stdAddChar (-u * r)) = (q : ℂ) * ∑ a ∈ s, ∑ b ∈ s, ∑ c ∈ s, if f a + f b + f c = u then w a * w b * w c else 0 := by classical have hexpand (r : ZMod q) : (∑ a ∈ s, w a * ZMod.stdAddChar (f a * r)) ^ 3 * ZMod.stdAddChar (-u * r) = ∑ a ∈ s, ∑ b ∈ s, ∑ c ∈ s, (w a * w b * w c) * ZMod.stdAddChar ((f a + f b + f c - u) * r) := by calc _ = ((∑ a ∈ s, w a * ZMod.stdAddChar (f a * r)) * (∑ b ∈ s, w b * ZMod.stdAddChar (f b * r)) * (∑ c ∈ s, w c * ZMod.stdAddChar (f c * r))) * ZMod.stdAddChar (-u * r) := by ring _ = _ := by simp only [Finset.sum_mul, Finset.mul_sum] apply Finset.sum_congr rfl intro a ha apply Finset.sum_congr rfl intro b hb apply Finset.sum_congr rfl intro c hc rw [sub_mul, add_mul, add_mul, sub_eq_add_neg, AddChar.map_add_eq_mul, AddChar.map_add_eq_mul, AddChar.map_add_eq_mul] rw [neg_mul] ring simp_rw [hexpand] rw [Finset.sum_comm] calc _ = ∑ a ∈ s, ∑ b ∈ s, ∑ c ∈ s, ∑ r : ZMod q, (w a * w b * w c) * ZMod.stdAddChar ((f a + f b + f c - u) * r) := by apply Finset.sum_congr rfl intro a ha rw [Finset.sum_comm] apply Finset.sum_congr rfl intro b hb rw [Finset.sum_comm] _ = _ := by simp_rw [← Finset.mul_sum, FiveProducts.character_sum, sub_eq_zero] simp only [Finset.mul_sum] apply Finset.sum_congr rfl intro a ha apply Finset.sum_congr rfl intro b hb apply Finset.sum_congr rfl intro c hc split_ifs <;> ring
/-- Choosing the cyclic modulus above every possible sum removes all modularaliasing. The resulting identity counts ordinary natural-number sums exactly. -/theorem weighted_natural_triple_character_identity {q : ℕ} [NeZero q] (s : Finset ℕ) (w : ℕ → ℂ) (u : ℕ) (hs : ∀ a ∈ s, a ≤ u) (hq : 3 * u < q) : (∑ r : ZMod q, (∑ a ∈ s, w a * ZMod.stdAddChar ((a : ZMod q) * r)) ^ 3 * ZMod.stdAddChar (-(u : ZMod q) * r)) = (q : ℂ) * ∑ a ∈ s, ∑ b ∈ s, ∑ c ∈ s, if a + b + c = u then w a * w b * w c else 0 := by classical rw [weighted_triple_character_identity] congr 1 apply Finset.sum_congr rfl intro a ha apply Finset.sum_congr rfl intro b hb apply Finset.sum_congr rfl intro c hc have habc : a + b + c < q := by have := hs a ha have := hs b hb have := hs c hc omega have hu : u < q := by omega have heq : (a : ZMod q) + (b : ZMod q) + (c : ZMod q) = (u : ZMod q) ↔ a + b + c = u := by rw [← Nat.cast_add, ← Nat.cast_add, ZMod.natCast_eq_natCast_iff', Nat.mod_eq_of_lt habc, Nat.mod_eq_of_lt hu] simp only [heq]
/-- Normalized inverse Fourier extraction for weighted ordinary triples. -/theorem weighted_natural_triple_fourier {q : ℕ} [NeZero q] (s : Finset ℕ) (w : ℕ → ℂ) (u : ℕ) (hs : ∀ a ∈ s, a ≤ u) (hq : 3 * u < q) : (∑ a ∈ s, ∑ b ∈ s, ∑ c ∈ s, if a + b + c = u then w a * w b * w c else 0) = (∑ r : ZMod q, (∑ a ∈ s, w a * ZMod.stdAddChar ((a : ZMod q) * r)) ^ 3 * ZMod.stdAddChar (-(u : ZMod q) * r)) / (q : ℂ) := by apply (eq_div_iff (NeZero.ne (q : ℂ))).2 simpa only [mul_comm] using (weighted_natural_triple_character_identity s w u hs hq).symm
/-- The existing ordered-prime-triple finset is exactly the filtered cube of the primes at most `u`. This identity also applies to arbitrary weights. -/theorem supply_prime_triple_sum_eq_nested (u : ℕ) (w : ℕ → ℂ) : (∑ t ∈ supplyPrimeTriples u, w t.1 * w t.2.1 * w t.2.2) = ∑ a ∈ (Finset.Icc 1 u).filter Nat.Prime, ∑ b ∈ (Finset.Icc 1 u).filter Nat.Prime, ∑ c ∈ (Finset.Icc 1 u).filter Nat.Prime, if a + b + c = u then w a * w b * w c else 0 := by classical let s := (Finset.Icc 1 u).filter Nat.Prime have hset : ((s ×ˢ (s ×ˢ s)).filter (fun t : ℕ × ℕ × ℕ => t.1 + t.2.1 + t.2.2 = u)) = supplyPrimeTriples u := by ext t simp only [s, supplyPrimeTriples, Finset.mem_filter, Finset.mem_product] tauto rw [← hset] simp only [Finset.sum_filter, Finset.sum_product, s]
/-- Exact extraction of the log-weighted prime count that occurs in the three-prime lower bound. The modulus condition excludes all circular sums. -/theorem supply_prime_weighted_fourier {q : ℕ} [NeZero q] (u : ℕ) (hq : 3 * u < q) : (∑ t ∈ supplyPrimeTriples u, (Real.log (t.1 : ℝ) : ℂ) * (Real.log (t.2.1 : ℝ) : ℂ) * (Real.log (t.2.2 : ℝ) : ℂ)) = (∑ r : ZMod q, (∑ a ∈ (Finset.Icc 1 u).filter Nat.Prime, (Real.log (a : ℝ) : ℂ) * ZMod.stdAddChar ((a : ZMod q) * r)) ^ 3 * ZMod.stdAddChar (-(u : ZMod q) * r)) / (q : ℂ) := by rw [supply_prime_triple_sum_eq_nested u (fun a => (Real.log (a : ℝ) : ℂ))] apply weighted_natural_triple_fourier _ _ _ _ hq intro a ha exact (Finset.mem_Icc.mp (Finset.mem_filter.mp ha).1).2
/-- Real-part version of the exact extraction formula. -/theorem supply_prime_weighted_fourier_re {q : ℕ} [NeZero q] (u : ℕ) (hq : 3 * u < q) : (∑ t ∈ supplyPrimeTriples u, Real.log (t.1 : ℝ) * Real.log (t.2.1 : ℝ) * Real.log (t.2.2 : ℝ)) = (∑ r : ZMod q, (∑ a ∈ (Finset.Icc 1 u).filter Nat.Prime, (Real.log (a : ℝ) : ℂ) * ZMod.stdAddChar ((a : ZMod q) * r)) ^ 3 * ZMod.stdAddChar (-(u : ZMod q) * r)).re / (q : ℝ) := by have h := congrArg Complex.re (supply_prime_weighted_fourier u hq) simpa only [Complex.re_sum, ← Complex.ofReal_mul, Complex.ofReal_re, ← Complex.ofReal_natCast, Complex.div_ofReal_re] using h
/-- Splitting frequencies into an arbitrary major set and its complement gives the standard lower bound by the major real part minus the minor norm. -/theorem major_minor_real_lower_bound {α : Type*} [Fintype α] [DecidableEq α] (s : Finset α) (F : α → ℂ) (Q : ℝ) (hQ : 0 < Q) : ((∑ r ∈ s, F r).re - ‖∑ r ∈ sᶜ, F r‖) / Q ≤ (∑ r, F r).re / Q := by classical apply div_le_div_of_nonneg_right _ hQ.le rw [← Finset.sum_add_sum_compl s F, Complex.add_re] have h := Complex.re_le_norm (-(∑ r ∈ sᶜ, F r)) simp only [Complex.neg_re, norm_neg] at h linarith
/-- A lower major-frequency bound and an upper minor-frequency norm bound imply a lower bound for the actual log-weighted ordered-prime-triple count. The genuinely analytic estimates remain explicit hypotheses. -/theorem supply_prime_weighted_lower_of_major_minor {q : ℕ} [NeZero q] (u : ℕ) (hq : 3 * u < q) (major : Finset (ZMod q)) (A E : ℝ) (hmajor : A * (q : ℝ) ≤ (∑ r ∈ major, (∑ a ∈ (Finset.Icc 1 u).filter Nat.Prime, (Real.log (a : ℝ) : ℂ) * ZMod.stdAddChar ((a : ZMod q) * r)) ^ 3 * ZMod.stdAddChar (-(u : ZMod q) * r)).re) (hminor : ‖∑ r ∈ majorᶜ, (∑ a ∈ (Finset.Icc 1 u).filter Nat.Prime, (Real.log (a : ℝ) : ℂ) * ZMod.stdAddChar ((a : ZMod q) * r)) ^ 3 * ZMod.stdAddChar (-(u : ZMod q) * r)‖ ≤ E * (q : ℝ)) : A - E ≤ ∑ t ∈ supplyPrimeTriples u, Real.log (t.1 : ℝ) * Real.log (t.2.1 : ℝ) * Real.log (t.2.2 : ℝ) := by classical have hqpos : (0 : ℝ) < q := by exact_mod_cast (Nat.pos_of_ne_zero (NeZero.ne q)) rw [supply_prime_weighted_fourier_re u hq] let F : ZMod q → ℂ := fun r => (∑ a ∈ (Finset.Icc 1 u).filter Nat.Prime, (Real.log (a : ℝ) : ℂ) * ZMod.stdAddChar ((a : ZMod q) * r)) ^ 3 * ZMod.stdAddChar (-(u : ZMod q) * r) change A - E ≤ (∑ r, F r).re / (q : ℝ) have hsplit := major_minor_real_lower_bound major F (q : ℝ) hqpos refine le_trans ?_ hsplit apply (le_div_iff₀ hqpos).2 change A * (q : ℝ) ≤ (∑ r ∈ major, F r).re at hmajor change ‖∑ r ∈ majorᶜ, F r‖ ≤ E * (q : ℝ) at hminor nlinarith
end Problem337.ThreePrimeFourier
end
end OAI1234import OAI.NumberTheory.EgyptianFractions.ThreePrimeFourierReductionimport OAI.NumberTheory.EgyptianFractions.ThreePrimeContinuousMinorArcimport OAI.NumberTheory.EgyptianFractions.ThreePrimeIntegralCountimport OAI.NumberTheory.EgyptianFractions.ThreePrimeMangoldtIntegral1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253import OAI.NumberTheory.EgyptianFractions.ThreePrimeFourierimport OAI.NumberTheory.EgyptianFractions.ThreePrimeWeighted
namespace OAInoncomputable sectionopen scoped BigOperatorsopen Filter
namespace Problem337.ThreePrimeFourier
/-- The ordinary positive-sign prime exponential sum, at the zero-paddedcyclic modulus `3*u+1`. -/def primeFourierSum (u : ℕ) (r : ZMod (3 * u + 1)) : ℂ := ∑ a ∈ (Finset.Icc 1 u).filter Nat.Prime, (Real.log (a : ℝ) : ℂ) * ZMod.stdAddChar ((a : ZMod (3 * u + 1)) * r)
/-- The cubic integrand extracting the ordered prime triples of sum `u`. -/def primeFourierIntegrand (u : ℕ) (r : ZMod (3 * u + 1)) : ℂ := primeFourierSum u r ^ 3 * ZMod.stdAddChar (-(u : ZMod (3 * u + 1)) * r)
/-- The canonical weighted count is exactly the real inverse Fourier sum. -/theorem weightedSupplyPrimeTriples_eq_fourier (u : ℕ) : weightedSupplyPrimeTriples u = (∑ r, primeFourierIntegrand u r).re / (3 * u + 1 : ℕ) := by exact supply_prime_weighted_fourier_re u (by omega)
/-- The remaining quantitative three-prime assertion follows from explicitmajor-frequency main terms and minor-frequency errors for the actual primeexponential sums. This theorem does not assert either analytic estimate. -/theorem quantitativeThreePrimeLowerBound_of_major_minor (major : (u : ℕ) → Finset (ZMod (3 * u + 1))) (c : ℝ) (hc : 0 < c) (hmajor : ∀ᶠ u : ℕ in atTop, Odd u → (2 * c * (u : ℝ) ^ 2) * (3 * u + 1 : ℕ) ≤ (∑ r ∈ major u, primeFourierIntegrand u r).re) (hminor : ∀ᶠ u : ℕ in atTop, Odd u → ‖∑ r ∈ (major u)ᶜ, primeFourierIntegrand u r‖ ≤ (c * (u : ℝ) ^ 2) * (3 * u + 1 : ℕ)) : QuantitativeThreePrimeLowerBound := by apply quantitativeThreePrimeLowerBound_of_weighted refine ⟨c, hc, ?_⟩ filter_upwards [hmajor, hminor] with u hma hmi intro hu have h := supply_prime_weighted_lower_of_major_minor u (by omega : 3 * u < 3 * u + 1) (major u) (2 * c * (u : ℝ) ^ 2) (c * (u : ℝ) ^ 2) (hma hu) (hmi hu) change 2 * c * (u : ℝ) ^ 2 - c * (u : ℝ) ^ 2 ≤ weightedSupplyPrimeTriples u at h nlinarith
end Problem337.ThreePrimeFourier
end
end OAI12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152import OAI.NumberTheory.EgyptianFractions.ThreePrimeContinuousFourierimport OAI.NumberTheory.EgyptianFractions.RationalSupplyReduction
namespace OAInoncomputable sectionopen scoped BigOperators
namespace Problem337.ThreePrimeContinuousFourier
/-- Positive prime frequencies up to the integer under representation. -/def primeFrequencies (u : ℕ) : Finset ℕ := (Finset.Icc 1 u).filter Nat.Prime
/-- The unweighted positive-sign prime exponential sum. -/def primePhaseSum (u : ℕ) (x : ℝ) : ℂ := ∑ p ∈ primeFrequencies u, phase (p : ℤ) x
lemma prime_triples_eq_filter (u : ℕ) : supplyPrimeTriples u = ((primeFrequencies u) ×ˢ ((primeFrequencies u) ×ˢ (primeFrequencies u))).filter (fun t => t.1 + t.2.1 + t.2.2 = u) := by ext t simp only [supplyPrimeTriples, primeFrequencies, Finset.mem_filter, Finset.mem_product] tauto
/-- The exact prime-triple count is a continuous cubic Fourier coefficient.This does not estimate the integral or assert a prime-distribution result. -/theorem prime_triple_integral (u : ℕ) : (∫ x in (0 : ℝ)..1, primePhaseSum u x ^ 3 * phase (-(u : ℤ)) x) = ((supplyPrimeTriples u).card : ℂ) := by classical have h := weighted_triple_finset_integral (primeFrequencies u) (fun p : ℕ => (p : ℤ)) (fun _ => (1 : ℂ)) (u : ℤ) simp only [one_mul, mul_one] at h change (∫ x in (0 : ℝ)..1, (∑ p ∈ primeFrequencies u, phase (p : ℤ) x) ^ 3 * phase (-(u : ℤ)) x) = _ rw [h, prime_triples_eq_filter] simp only [Finset.card_eq_sum_ones, Nat.cast_sum, Finset.sum_filter, Finset.sum_product] apply Finset.sum_congr rfl intro a ha apply Finset.sum_congr rfl intro b hb apply Finset.sum_congr rfl intro c hc have heq : ((a : ℤ) + (b : ℤ) + (c : ℤ) = (u : ℤ)) ↔ a + b + c = u := by omega simp [heq]
end Problem337.ThreePrimeContinuousFourier
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319import Mathlib
namespace OAInoncomputable section
open scoped BigOperators
namespace Problem337
/-- Nonzero residue classes modulo `p`. For prime `p`, these are exactlyits unit classes. -/def threePrimeNonzeroResidues (p : ℕ) [NeZero p] : Finset (ZMod p) := Finset.univ.erase 0
/-- Two-coordinate parametrization of nonzero residue triples with sum `u`:the third coordinate is `u - x - y`. -/def threePrimeLocalPairs (p : ℕ) [NeZero p] (u : ZMod p) : Finset (ZMod p × ZMod p) := (threePrimeNonzeroResidues p ×ˢ threePrimeNonzeroResidues p).filter (fun t => t.1 + t.2 ≠ u)
lemma mem_threePrimeLocalPairs {p : ℕ} [NeZero p] (u x y : ZMod p) : (x, y) ∈ threePrimeLocalPairs p u ↔ x ≠ 0 ∧ y ≠ 0 ∧ u - x - y ≠ 0 := by simp only [threePrimeLocalPairs, threePrimeNonzeroResidues, Finset.mem_filter, Finset.mem_product, Finset.mem_erase, Finset.mem_univ, and_true] constructor · rintro ⟨⟨hx, hy⟩, hsum⟩ refine ⟨hx, hy, ?_⟩ intro hz apply hsum linear_combination -hz · rintro ⟨hx, hy, hz⟩ refine ⟨⟨hx, hy⟩, ?_⟩ intro hsum apply hz linear_combination -hsum
lemma threePrimeLocalBadPairs_eq_image {p : ℕ} [NeZero p] (u : ZMod p) : (threePrimeNonzeroResidues p ×ˢ threePrimeNonzeroResidues p).filter (fun t => t.1 + t.2 = u) = ((threePrimeNonzeroResidues p).erase u).image (fun x => (x, u - x)) := by classical ext t rcases t with ⟨x, y⟩ simp only [threePrimeNonzeroResidues, Finset.mem_filter, Finset.mem_product, Finset.mem_erase, Finset.mem_univ, and_true, Finset.mem_image, Prod.mk.injEq] constructor · rintro ⟨⟨hx, hy⟩, hsum⟩ refine ⟨x, ⟨?_, hx⟩, rfl, ?_⟩ · intro hxu apply hy linear_combination hsum - hxu · linear_combination -hsum · rintro ⟨a, ⟨hau, ha⟩, hax, hay⟩ subst a refine ⟨⟨ha, ?_⟩, ?_⟩ · intro hy apply hau linear_combination -hay - hy · linear_combination -hay
lemma threePrimeNonzeroResidues_card (p : ℕ) [NeZero p] : (threePrimeNonzeroResidues p).card = p - 1 := by simp [threePrimeNonzeroResidues]
/-- Removing the forbidden third-coordinate-zero pairs leaves this exactcardinality balance. This identity uses only the additive residue group. -/theorem threePrimeLocalPairs_card_balance (p : ℕ) [NeZero p] (u : ZMod p) : (threePrimeLocalPairs p u).card + ((threePrimeNonzeroResidues p).erase u).card = (p - 1) ^ 2 := by classical have hcard := Finset.card_filter_add_card_filter_not (s := threePrimeNonzeroResidues p ×ˢ threePrimeNonzeroResidues p) (p := fun t : ZMod p × ZMod p => t.1 + t.2 = u) rw [threePrimeLocalBadPairs_eq_image] at hcard have hinj : Function.Injective (fun x : ZMod p => (x, u - x)) := by intro x y hxy exact congrArg Prod.fst hxy rw [Finset.card_image_of_injective _ hinj] at hcard simpa [threePrimeLocalPairs, Finset.card_product, threePrimeNonzeroResidues_card, pow_two, add_comm] using hcard
/-- Exact count of the local nonzero solutions to a three-term sum. -/theorem threePrimeLocalPairs_card (p : ℕ) [NeZero p] (hp : 2 ≤ p) (u : ZMod p) : (threePrimeLocalPairs p u).card = if u = 0 then (p - 1) * (p - 2) else (p - 1) * (p - 2) + 1 := by classical have hbalance := threePrimeLocalPairs_card_balance p u have hdiff : p - 1 = (p - 2) + 1 := by omega by_cases hu : u = 0 · subst u simp [threePrimeNonzeroResidues] at hbalance simp only [ite_true, eq_self] rw [hdiff] at hbalance ⊢ nlinarith · have hmem : u ∈ threePrimeNonzeroResidues p := by simp [threePrimeNonzeroResidues, hu] rw [Finset.card_erase_of_mem hmem, threePrimeNonzeroResidues_card] at hbalance simp only [ite_eq_right hu] rw [hdiff] at hbalance ⊢ simp only [Nat.add_sub_cancel] at hbalance nlinarith
/-- Polynomial form of the local solution count. -/theorem threePrimeLocalPairs_card_real (p : ℕ) [NeZero p] (hp : 2 ≤ p) (u : ZMod p) : ((threePrimeLocalPairs p u).card : ℝ) = (p : ℝ) ^ 2 - 3 * p + 3 - if u = 0 then 1 else 0 := by rw [threePrimeLocalPairs_card p hp u] split_ifs <;> push_cast [Nat.cast_sub (show 1 ≤ p by omega), Nat.cast_sub hp] <;> ring
/-- The local density relative to the heuristic density of three unit classes.The prime hypothesis is used when identifying this with a singular-seriesfactor; the finite expression is defined for every nonzero modulus. -/def threePrimeLocalFactor (p : ℕ) [NeZero p] (u : ZMod p) : ℝ := (p : ℝ) * (threePrimeLocalPairs p u).card / ((p : ℝ) - 1) ^ 3
/-- The exact local factor of the ternary prime singular series. -/theorem threePrimeLocalFactor_eq (p : ℕ) [NeZero p] (hp : 2 ≤ p) (u : ZMod p) : threePrimeLocalFactor p u = if u = 0 then 1 - 1 / ((p : ℝ) - 1) ^ 2 else 1 + 1 / ((p : ℝ) - 1) ^ 3 := by have hpR : (2 : ℝ) ≤ p := by exact_mod_cast hp have hden : (p : ℝ) - 1 ≠ 0 := by linarith rw [threePrimeLocalFactor, threePrimeLocalPairs_card_real p hp u] split_ifs <;> field_simp <;> ring
/-- The natural-number formulation distinguishes primes dividing the target. -/theorem threePrimeLocalFactor_natCast (p u : ℕ) [NeZero p] (hp : 2 ≤ p) : threePrimeLocalFactor p (u : ZMod p) = if p ∣ u then 1 - 1 / ((p : ℝ) - 1) ^ 2 else 1 + 1 / ((p : ℝ) - 1) ^ 3 := by rw [threePrimeLocalFactor_eq p hp] simp only [ZMod.natCast_eq_zero_iff]
/-- An odd target has the positive factor two at the prime two. -/theorem threePrimeLocalFactor_two (u : ℕ) (hu : Odd u) : threePrimeLocalFactor 2 (u : ZMod 2) = 2 := by rw [threePrimeLocalFactor_natCast 2 u (by omega)] have hnot : ¬2 ∣ u := by rw [← ZMod.natCast_eq_zero_iff] exact ZMod.natCast_ne_zero_iff_odd.mpr hu norm_num [hnot]
/-- The literal ordered triples underlying the local density. -/def threePrimeLocalTriples (p : ℕ) [NeZero p] (u : ZMod p) : Finset (ZMod p × ZMod p × ZMod p) := Finset.univ.filter (fun t => t.1 ≠ 0 ∧ t.2.1 ≠ 0 ∧ t.2.2 ≠ 0 ∧ t.1 + t.2.1 + t.2.2 = u)
/-- The third residue is uniquely determined by the first two. -/theorem threePrimeLocalTriples_eq_image (p : ℕ) [NeZero p] (u : ZMod p) : threePrimeLocalTriples p u = (threePrimeLocalPairs p u).image (fun t => (t.1, t.2, u - t.1 - t.2)) := by classical ext t rcases t with ⟨x, y, z⟩ constructor · intro ht obtain ⟨hx, hy, hz, hsum⟩ := (Finset.mem_filter.mp ht).2 have hthird : u - x - y = z := by linear_combination -hsum refine Finset.mem_image.mpr ⟨(x, y), ?_, ?_⟩ · exact (mem_threePrimeLocalPairs u x y).mpr ⟨hx, hy, by simpa [hthird] using hz⟩ · simp [hthird] · intro ht obtain ⟨⟨a, b⟩, hab, h⟩ := Finset.mem_image.mp ht obtain ⟨hx, hy, hz⟩ := (mem_threePrimeLocalPairs u a b).mp hab rw [← h] apply Finset.mem_filter.mpr refine ⟨Finset.mem_univ _, hx, hy, hz, ?_⟩ ring
/-- The two-coordinate parametrization does not change the local count. -/theorem threePrimeLocalTriples_card (p : ℕ) [NeZero p] (u : ZMod p) : (threePrimeLocalTriples p u).card = (threePrimeLocalPairs p u).card := by rw [threePrimeLocalTriples_eq_image] apply Finset.card_image_of_injective intro a b h apply Prod.ext · exact congrArg (fun t : ZMod p × ZMod p × ZMod p => t.1) h · exact congrArg (fun t : ZMod p × ZMod p × ZMod p => t.2.1) h
/-- For a prime modulus, the nonzero residue condition is exactly the unitcondition used in the prime singular series. -/theorem mem_threePrimeLocalTriples_iff_units (p : ℕ) [Fact p.Prime] (u : ZMod p) (t : ZMod p × ZMod p × ZMod p) : t ∈ threePrimeLocalTriples p u ↔ IsUnit t.1 ∧ IsUnit t.2.1 ∧ IsUnit t.2.2 ∧ t.1 + t.2.1 + t.2.2 = u := by simp [threePrimeLocalTriples, isUnit_iff_ne_zero]
/-- There is no local obstruction at a modulus of at least three when onlynonzero residue classes are required. -/theorem threePrimeLocalPairs_card_pos (p : ℕ) [NeZero p] (hp : 3 ≤ p) (u : ZMod p) : 0 < (threePrimeLocalPairs p u).card := by rw [threePrimeLocalPairs_card p (by omega) u] have hp1 : 0 < p - 1 := by omega have hp2 : 0 < p - 2 := by omega split_ifs <;> positivity
/-- In particular every odd-prime local density is strictly positive. -/theorem threePrimeLocalFactor_pos_of_three_le (p : ℕ) [NeZero p] (hp : 3 ≤ p) (u : ZMod p) : 0 < threePrimeLocalFactor p u := by have hpR : (3 : ℝ) ≤ p := by exact_mod_cast hp have hcard : (0 : ℝ) < (threePrimeLocalPairs p u).card := by exact_mod_cast threePrimeLocalPairs_card_pos p hp u dsimp [threePrimeLocalFactor] exact div_pos (mul_pos (by linarith) hcard) (pow_pos (by linarith) _)
/-- The only nonzero-residue ternary-sum obstruction is zero modulo two. -/theorem threePrimeLocalTriples_nonempty_iff (p : ℕ) [NeZero p] (hp : 2 ≤ p) (u : ZMod p) : (threePrimeLocalTriples p u).Nonempty ↔ p ≠ 2 ∨ u ≠ 0 := by rw [← Finset.card_pos, threePrimeLocalTriples_card] by_cases hp2 : p = 2 · subst p rw [threePrimeLocalPairs_card 2 (by omega)] by_cases hu : u = 0 <;> simp [hu] · have hpos := threePrimeLocalPairs_card_pos p (by omega) u simp [hp2, hpos]
/-- Every prime local factor is positive for odd natural targets. -/theorem threePrimeLocalFactor_pos (p u : ℕ) [Fact p.Prime] (hu : Odd u) : 0 < threePrimeLocalFactor p (u : ZMod p) := by have hp := (Fact.out : p.Prime).two_le by_cases hp2 : p = 2 · subst p rw [threePrimeLocalFactor_two u hu] norm_num · exact threePrimeLocalFactor_pos_of_three_le p (by omega) _
/-- Oddness is exactly the local-solubility condition for a sum of three unitresidue classes at every prime. This is only a local statement, not a theoremthat those residue classes lift simultaneously to three prime integers. -/theorem threePrimeLocalSolubility_iff_odd (u : ℕ) : (∀ p : ℕ, p.Prime → ∃ x y z : ZMod p, IsUnit x ∧ IsUnit y ∧ IsUnit z ∧ x + y + z = (u : ZMod p)) ↔ Odd u := by constructor · intro h obtain ⟨x, y, z, hx, hy, hz, hsum⟩ := h 2 Nat.prime_two have hmem : (x, y, z) ∈ threePrimeLocalTriples 2 (u : ZMod 2) := (mem_threePrimeLocalTriples_iff_units 2 _ _).mpr ⟨hx, hy, hz, hsum⟩ have hnonzero := (threePrimeLocalTriples_nonempty_iff 2 (by omega) _).mp ⟨_, hmem⟩ exact ZMod.natCast_ne_zero_iff_odd.mp (hnonzero.resolve_left (by simp)) · intro hu p hp let : Fact p.Prime := ⟨hp⟩ have hlocal : p ≠ 2 ∨ (u : ZMod p) ≠ 0 := by by_cases hp2 : p = 2 · right subst p exact ZMod.natCast_ne_zero_iff_odd.mpr hu · exact Or.inl hp2 obtain ⟨t, ht⟩ := (threePrimeLocalTriples_nonempty_iff p hp.two_le _).mpr hlocal exact ⟨t.1, t.2.1, t.2.2, (mem_threePrimeLocalTriples_iff_units p _ _).mp ht⟩
private lemma sum_zmod_zero_other (p : ℕ) [NeZero p] (hp : 1 ≤ p) (a b : ℝ) : (∑ u : ZMod p, if u = 0 then a else b) = ((p : ℝ) - 1) * b + a := by classical rw [← Finset.sum_erase_add (s := (Finset.univ : Finset (ZMod p))) (fun u => if u = 0 then a else b) (Finset.mem_univ 0)] have heq : (∑ u ∈ (Finset.univ : Finset (ZMod p)).erase 0, if u = 0 then a else b) = ∑ _u ∈ (Finset.univ : Finset (ZMod p)).erase 0, b := by apply Finset.sum_congr rfl intro u hu exact ite_eq_right (Finset.mem_erase.mp hu).1 rw [heq] simp [Nat.cast_sub hp]
/-- The normalized local solution density has exact average one. -/theorem sum_threePrimeLocalFactor (p : ℕ) [NeZero p] (hp : 2 ≤ p) : (∑ u : ZMod p, threePrimeLocalFactor p u) = (p : ℝ) := by simp_rw [threePrimeLocalFactor_eq p hp] rw [sum_zmod_zero_other p (by omega)] have hpR : (2 : ℝ) ≤ p := by exact_mod_cast hp have hden : (p : ℝ) - 1 ≠ 0 := by linarith field_simp ring
/-- Exact local variance of the ternary density: after dividing by the numberof residues, it is `(p - 1)⁻⁵`. -/theorem sum_threePrimeLocalFactor_centered_sq (p : ℕ) [NeZero p] (hp : 2 ≤ p) : (∑ u : ZMod p, (threePrimeLocalFactor p u - 1) ^ 2) = (p : ℝ) / ((p : ℝ) - 1) ^ 5 := by have hpR : (2 : ℝ) ≤ p := by exact_mod_cast hp have hden : (p : ℝ) - 1 ≠ 0 := by linarith have heq (u : ZMod p) : (threePrimeLocalFactor p u - 1) ^ 2 = if u = 0 then 1 / ((p : ℝ) - 1) ^ 4 else 1 / ((p : ℝ) - 1) ^ 6 := by rw [threePrimeLocalFactor_eq p hp] split_ifs <;> field_simp <;> ring simp_rw [heq] rw [sum_zmod_zero_other p (by omega)] field_simp ring
/-- The exact uncentered second moment, useful with the independent CRTmultiplicativity of local densities. -/theorem sum_threePrimeLocalFactor_sq (p : ℕ) [NeZero p] (hp : 2 ≤ p) : (∑ u : ZMod p, (threePrimeLocalFactor p u) ^ 2) = (p : ℝ) * (1 + 1 / ((p : ℝ) - 1) ^ 5) := by have heq (u : ZMod p) : (threePrimeLocalFactor p u) ^ 2 = (threePrimeLocalFactor p u - 1) ^ 2 + 2 * threePrimeLocalFactor p u - 1 := by ring simp_rw [heq] rw [Finset.sum_sub_distrib, Finset.sum_add_distrib, ← Finset.mul_sum, sum_threePrimeLocalFactor p hp, sum_threePrimeLocalFactor_centered_sq p hp] simp only [Finset.sum_const, Finset.card_univ, ZMod.card, nsmul_eq_mul, mul_one] ring
end Problem337
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105import OAI.NumberTheory.EgyptianFractions.FiveProducts
namespace OAInoncomputable section
open scoped BigOperators
namespace Problem337.ThreePrimeLocalFactor
/-- Orthogonality with the zero residue removed. -/theorem nonzero_character_sum {p : ℕ} [NeZero p] (t : ZMod p) : (∑ a ∈ (Finset.univ : Finset (ZMod p)).erase 0, ZMod.stdAddChar (t * a)) = if t = 0 then (p : ℂ) - 1 else -1 := by classical have hsum := FiveProducts.character_sum t have hsplit := Finset.sum_erase_add (s := (Finset.univ : Finset (ZMod p))) (fun a => ZMod.stdAddChar (t * a)) (Finset.mem_univ 0) simp only [mul_zero, AddChar.map_zero_eq_one] at hsplit rw [hsum] at hsplit split_ifs at hsplit ⊢ <;> linear_combination hsplit
/-- The prime-modulus Ramanujan sum, indexed by nonzero residues. -/def primeRamanujanSum (p : ℕ) [NeZero p] (u : ℕ) : ℂ := ∑ a ∈ (Finset.univ : Finset (ZMod p)).erase 0, ZMod.stdAddChar (-(u : ZMod p) * a)
/-- Removing the zero frequency from character orthogonality gives theprime Ramanujan sum. In fact this formula needs only a nonzero modulus. -/theorem primeRamanujanSum_eq (p : ℕ) [NeZero p] (u : ℕ) : primeRamanujanSum p u = if p ∣ u then (p : ℂ) - 1 else -1 := by simpa only [primeRamanujanSum, neg_eq_zero, ZMod.natCast_eq_zero_iff] using nonzero_character_sum (-(u : ZMod p))
/-- The normalized cubic prime-frequency contribution to the ternarysingular series. -/def localFactor (p u : ℕ) [NeZero p] : ℂ := 1 - primeRamanujanSum p u / ((p : ℂ) - 1) ^ 3
/-- The two familiar local factors follow exactly from finite characterorthogonality; this is not an asymptotic prime-counting assertion. -/theorem localFactor_eq (p u : ℕ) (hp : p.Prime) : letI : NeZero p := ⟨hp.ne_zero⟩ localFactor p u = if p ∣ u then 1 - 1 / ((p : ℂ) - 1) ^ 2 else 1 + 1 / ((p : ℂ) - 1) ^ 3 := by let : NeZero p := ⟨hp.ne_zero⟩ have hp1 : (p : ℂ) - 1 ≠ 0 := by exact sub_ne_zero.mpr (by exact_mod_cast hp.ne_one) rw [localFactor, primeRamanujanSum_eq] split_ifs · field_simp · ring
/-- The normalized cubic exponential-sum contribution of the nonzerofrequencies at a prime modulus. -/def cubicPrimeCoefficient (p u : ℕ) [NeZero p] : ℂ := ∑ a ∈ (Finset.univ : Finset (ZMod p)).erase 0, ((∑ b ∈ (Finset.univ : Finset (ZMod p)).erase 0, ZMod.stdAddChar (a * b)) / ((p : ℂ) - 1)) ^ 3 * ZMod.stdAddChar (-(u : ZMod p) * a)
/-- The cubic coefficient is exactly the signed, normalized Ramanujan sum.Thus the local Euler factor is the zero-frequency contribution plus theactual nonzero-frequency cubic sum. -/theorem cubicPrimeCoefficient_eq (p u : ℕ) [NeZero p] : cubicPrimeCoefficient p u = -primeRamanujanSum p u / ((p : ℂ) - 1) ^ 3 := by classical unfold cubicPrimeCoefficient calc _ = ∑ a ∈ (Finset.univ : Finset (ZMod p)).erase 0, (-1 / ((p : ℂ) - 1) ^ 3) * ZMod.stdAddChar (-(u : ZMod p) * a) := by apply Finset.sum_congr rfl intro a ha rw [nonzero_character_sum, ite_eq_right (Finset.mem_erase.mp ha).1, div_pow] norm_num _ = (-1 / ((p : ℂ) - 1) ^ 3) * primeRamanujanSum p u := by rw [← Finset.mul_sum] rfl _ = _ := by ring
theorem one_add_cubicPrimeCoefficient (p u : ℕ) [NeZero p] : 1 + cubicPrimeCoefficient p u = localFactor p u := by rw [cubicPrimeCoefficient_eq, localFactor] ring
/-- A real-valued statement of the local factor for direct use with realEuler products. -/theorem one_add_cubicPrimeCoefficient_eq_real (p u : ℕ) (hp : p.Prime) : letI : NeZero p := ⟨hp.ne_zero⟩ 1 + cubicPrimeCoefficient p u = ((if p ∣ u then 1 - 1 / ((p : ℝ) - 1) ^ 2 else 1 + 1 / ((p : ℝ) - 1) ^ 3 : ℝ) : ℂ) := by let : NeZero p := ⟨hp.ne_zero⟩ rw [one_add_cubicPrimeCoefficient, localFactor_eq p u hp] split_ifs <;> push_cast <;> rfl
end Problem337.ThreePrimeLocalFactor
end
end OAI12345678910111213141516171819202122232425262728293031323334353637383940414243import OAI.NumberTheory.EgyptianFractions.ThreePrimeLocalDensityimport OAI.NumberTheory.EgyptianFractions.ThreePrimeLocalFactor
namespace OAInoncomputable section
namespace Problem337
/-- The normalized actual local solution count agrees with the zero frequencyplus the normalized cubic nonzero-frequency sum. -/theorem threePrimeLocalFactor_eq_cubic (p u : ℕ) [Fact p.Prime] : (threePrimeLocalFactor p (u : ZMod p) : ℂ) = 1 + ThreePrimeLocalFactor.cubicPrimeCoefficient p u := by have hp := (Fact.out : p.Prime) rw [threePrimeLocalFactor_natCast p u hp.two_le] exact (ThreePrimeLocalFactor.one_add_cubicPrimeCoefficient_eq_real p u hp).symm
/-- An unnormalized finite Fourier identity for literal local unit triples.All normalizing constants are checked against the combinatorial count. -/theorem threePrimeLocalTriples_card_fourier (p u : ℕ) [Fact p.Prime] : (p : ℂ) * (threePrimeLocalTriples p (u : ZMod p)).card = ((p : ℂ) - 1) ^ 3 * (1 + ThreePrimeLocalFactor.cubicPrimeCoefficient p u) := by have hp := (Fact.out : p.Prime) have hp1 : (p : ℂ) - 1 ≠ 0 := by exact sub_ne_zero.mpr (by exact_mod_cast hp.ne_one) rw [threePrimeLocalTriples_card, ← threePrimeLocalFactor_eq_cubic] unfold threePrimeLocalFactor push_cast field_simp
/-- The cubic prime-frequency contribution is real, as follows from itsindependently counted local-density interpretation. -/theorem threePrimeCubicCoefficient_im (p u : ℕ) [Fact p.Prime] : (ThreePrimeLocalFactor.cubicPrimeCoefficient p u).im = 0 := by have h := congrArg Complex.im (threePrimeLocalFactor_eq_cubic p u) simpa using h.symm
end Problem337
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172import OAI.NumberTheory.EgyptianFractions.ThreePrimeLocalDensityimport OAI.NumberTheory.EgyptianFractions.ThreePrimeSingularSeries
namespace OAInoncomputable section
open scoped BigOperators
namespace Problem337
/-- The normalized actual local unit-triple count at prime moduli, with one atnonprime indices. The inactive branch makes this a total natural-indexedfunction without imposing a finiteness instance on `ZMod 0`. -/def threePrimeArithmeticFactor (p u : ℕ) : ℝ := if hp : p.Prime then @threePrimeLocalFactor p ⟨hp.ne_zero⟩ (u : ZMod p) else 1
lemma threePrimeArithmeticFactor_of_prime (p u : ℕ) (hp : p.Prime) : threePrimeArithmeticFactor p u = if p ∣ u then 1 - 1 / ((p : ℝ) - 1) ^ 2 else 1 + 1 / ((p : ℝ) - 1) ^ 3 := by let : NeZero p := ⟨hp.ne_zero⟩ simpa only [threePrimeArithmeticFactor, dite_eq_left hp] using threePrimeLocalFactor_natCast p u hp.two_le
lemma threePrimeArithmeticFactor_of_not_prime (p u : ℕ) (hp : ¬p.Prime) : threePrimeArithmeticFactor p u = 1 := by simp only [threePrimeArithmeticFactor, dite_eq_right hp]
/-- The analytically indexed odd-prime Euler factor is the normalized actualcount of its local unit solutions. -/theorem threePrimeOddFactor_eq_arithmeticFactor (u n : ℕ) : 1 + threePrimeOddPerturbation u n = threePrimeArithmeticFactor (n + 3) u := by by_cases hp : (n + 3).Prime · rw [threePrimeArithmeticFactor_of_prime _ _ hp] have hn : ((n + 3 : ℕ) : ℝ) - 1 = (n : ℝ) + 2 := by push_cast; ring rw [hn] simp only [threePrimeOddPerturbation, ite_eq_left hp] split_ifs <;> ring · simp [threePrimeOddPerturbation, hp, threePrimeArithmeticFactor_of_not_prime _ _ hp]
/-- The local unit-triple factor at two records precisely the parity obstruction. -/theorem threePrimeArithmeticFactor_two (u : ℕ) : threePrimeArithmeticFactor 2 u = if Odd u then 2 else 0 := by rw [threePrimeArithmeticFactor_of_prime 2 u Nat.prime_two] have hdvd : 2 ∣ u ↔ ¬Odd u := by rw [← ZMod.natCast_eq_zero_iff] exact not_iff_not.mp (by simp only [not_not, ZMod.natCast_ne_zero_iff_odd]) by_cases hu : Odd u <;> norm_num [hdvd, hu]
/-- Exact interpretation of the singular series as the product of normalizedfinite local unit-triple solution counts. -/theorem threePrimeSingularSeries_eq_localProduct (u : ℕ) : threePrimeSingularSeries u = threePrimeArithmeticFactor 2 u * ∏' n : ℕ, threePrimeArithmeticFactor (n + 3) u := by rw [threePrimeSingularSeries, threePrimeArithmeticFactor_two] simp_rw [threePrimeOddFactor_eq_arithmeticFactor]
/-- The actual local-factor product converges, rather than merely being aformal Euler-product notation. -/theorem threePrimeArithmeticFactors_multipliable (u : ℕ) : Multipliable (fun n : ℕ => threePrimeArithmeticFactor (n + 3) u) := by simpa only [threePrimeOddFactor_eq_arithmeticFactor] using threePrimeOddFactors_multipliable u
end Problem337
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249import OAI.NumberTheory.EgyptianFractions.RationalSupplyReductionimport Mathlib.NumberTheory.Chebyshev
namespace OAInoncomputable sectionopen scoped BigOperatorsopen Filter Asymptotics
namespace Problem337
/-- All positive ordered triples of fixed sum, without primality restrictions. -/def supplyIntegerTriples (u : ℕ) : Finset (ℕ × ℕ × ℕ) := ((Finset.Icc 1 u) ×ˢ ((Finset.Icc 1 u) ×ˢ (Finset.Icc 1 u))).filter (fun t => t.1 + t.2.1 + t.2.2 = u)
/-- Logarithmic weight supported only on primes, unlike the von Mangoldt weight. -/def primeLogWeight (n : ℕ) : ℝ := if n.Prime then Real.log n else 0
/-- The weighted ternary convolution used in the analytic three-prime theorem. -/def mangoldtTripleSum (u : ℕ) : ℝ := ∑ t ∈ supplyIntegerTriples u, ArithmeticFunction.vonMangoldt t.1 * ArithmeticFunction.vonMangoldt t.2.1 * ArithmeticFunction.vonMangoldt t.2.2
/-- The corresponding weighted sum over genuine prime triples. -/def primeTripleLogSum (u : ℕ) : ℝ := ∑ t ∈ supplyPrimeTriples u, Real.log (t.1 : ℝ) * Real.log (t.2.1 : ℝ) * Real.log (t.2.2 : ℝ)
lemma primeLogWeight_nonneg (n : ℕ) : 0 ≤ primeLogWeight n := by unfold primeLogWeight split_ifs with hn · exact Real.log_nonneg (by exact_mod_cast hn.one_le) · exact le_rfl
lemma primeLogWeight_le_vonMangoldt (n : ℕ) : primeLogWeight n ≤ ArithmeticFunction.vonMangoldt n := by unfold primeLogWeight split_ifs with hn · exact (ArithmeticFunction.vonMangoldt_apply_prime hn).ge · exact ArithmeticFunction.vonMangoldt_nonneg
lemma primeTripleLogSum_eq (u : ℕ) : primeTripleLogSum u = ∑ t ∈ supplyIntegerTriples u, primeLogWeight t.1 * primeLogWeight t.2.1 * primeLogWeight t.2.2 := by classical have hset : supplyPrimeTriples u = (supplyIntegerTriples u).filter (fun t => t.1.Prime ∧ t.2.1.Prime ∧ t.2.2.Prime) := by ext t simp only [supplyPrimeTriples, supplyIntegerTriples, Finset.mem_filter] tauto unfold primeTripleLogSum rw [hset, Finset.sum_filter] apply Finset.sum_congr rfl intro t ht by_cases h1 : t.1.Prime <;> by_cases h2 : t.2.1.Prime <;> by_cases h3 : t.2.2.Prime <;> simp [primeLogWeight, h1, h2, h3]
/-- A weighted version of the fixed-coordinate counting bound. -/lemma fixed_sum_coordinate_sum_le {α : Type*} [DecidableEq α] (T : Finset α) (U : Finset ℕ) (x y z : α → ℕ) (u : ℕ) (f : ℕ → ℝ) (hf : ∀ n ∈ U, 0 ≤ f n) (hsum : ∀ t ∈ T, x t + y t + z t = u) (hU : ∀ t ∈ T, x t ∈ U ∧ y t ∈ U) (hinj : Function.Injective (fun t => (x t, y t, z t))) : (∑ t ∈ T, f (x t)) ≤ (U.card : ℝ) * ∑ n ∈ U, f n := by classical have hi : Set.InjOn (fun t => (x t, y t)) (T : Set α) := by intro a ha b hb hab have hxy := Prod.mk.inj hab have hz : z a = z b := by have := hsum a ha have := hsum b hb omega exact hinj (Prod.ext hxy.1 (Prod.ext hxy.2 hz)) have hsub : T.image (fun t => (x t, y t)) ⊆ U ×ˢ U := by intro q hq obtain ⟨t, ht, rfl⟩ := Finset.mem_image.mp hq exact Finset.mem_product.mpr (hU t ht) calc (∑ t ∈ T, f (x t)) = ∑ q ∈ T.image (fun t => (x t, y t)), f q.1 := by rw [Finset.sum_image] exact hi _ ≤ ∑ q ∈ U ×ˢ U, f q.1 := by apply Finset.sum_le_sum_of_subset_of_nonneg hsub intro q hq _ exact hf q.1 (Finset.mem_product.mp hq).1 _ = (U.card : ℝ) * ∑ n ∈ U, f n := by rw [Finset.sum_product] simp only [Finset.sum_const, nsmul_eq_mul] rw [← Finset.mul_sum]
/-- Prime powers of exponent at least two carry exactly the difference of theChebyshev functions. -/lemma sum_primePowerLogWeight (u : ℕ) : (∑ n ∈ Finset.Icc 1 u, (ArithmeticFunction.vonMangoldt n - primeLogWeight n)) = Chebyshev.psi u - Chebyshev.theta u := by rw [Finset.sum_sub_distrib] congr 1 · simp only [Chebyshev.psi, Nat.floor_natCast] congr 1 · simp only [Chebyshev.theta, Nat.floor_natCast, Finset.sum_filter, primeLogWeight] congr 1
private lemma triple_product_difference_le (a b c p q r L : ℝ) (hp : 0 ≤ p) (hq : 0 ≤ q) (hr : 0 ≤ r) (hpa : p ≤ a) (hqb : q ≤ b) (hrc : r ≤ c) (ha : a ≤ L) (hb : b ≤ L) (hc : c ≤ L) : a * b * c ≤ p * q * r + L ^ 2 * ((a - p) + (b - q) + (c - r)) := by have hL : 0 ≤ L := hp.trans (hpa.trans ha) have ha0 := hp.trans hpa have hb0 := hq.trans hqb have hc0 := hr.trans hrc have hpL := hpa.trans ha have hqL := hqb.trans hb have h1 : (a - p) * b * c ≤ (a - p) * L * L := by gcongr have h2 : p * (b - q) * c ≤ L * (b - q) * L := by gcongr have h3 : p * q * (c - r) ≤ L * L * (c - r) := by gcongr nlinarith
lemma mangoldtTripleSum_le_primeTripleLogSum (u : ℕ) : mangoldtTripleSum u ≤ primeTripleLogSum u + 3 * (u : ℝ) * Real.log (u : ℝ) ^ 2 * (Chebyshev.psi u - Chebyshev.theta u) := by classical let U := Finset.Icc 1 u let T := supplyIntegerTriples u let d : ℕ → ℝ := fun n => ArithmeticFunction.vonMangoldt n - primeLogWeight n have hd (n : ℕ) : 0 ≤ d n := sub_nonneg.mpr (primeLogWeight_le_vonMangoldt n) have hT (t : ℕ × ℕ × ℕ) (ht : t ∈ T) : t.1 ∈ U ∧ t.2.1 ∈ U ∧ t.2.2 ∈ U := by obtain ⟨ht, _⟩ := Finset.mem_filter.mp ht exact (Finset.mem_product.mp ht).imp_right Finset.mem_product.mp have hsum (t : ℕ × ℕ × ℕ) (ht : t ∈ T) : t.1 + t.2.1 + t.2.2 = u := (Finset.mem_filter.mp ht).2 have hweight (n : ℕ) (hn : n ∈ U) : ArithmeticFunction.vonMangoldt n ≤ Real.log (u : ℝ) := by apply ArithmeticFunction.vonMangoldt_le_log.trans apply Real.log_le_log · exact_mod_cast (Finset.mem_Icc.mp hn).1 · exact_mod_cast (Finset.mem_Icc.mp hn).2 have h1 := fixed_sum_coordinate_sum_le T U (fun t => t.1) (fun t => t.2.1) (fun t => t.2.2) u d (fun n _ => hd n) hsum (fun t ht => ⟨(hT t ht).1, (hT t ht).2.1⟩) (by intro a b h; exact h) have h2 := fixed_sum_coordinate_sum_le T U (fun t => t.2.1) (fun t => t.1) (fun t => t.2.2) u d (fun n _ => hd n) (by intro t ht; have := hsum t ht; omega) (fun t ht => ⟨(hT t ht).2.1, (hT t ht).1⟩) (by intro a b h have hc := Prod.mk.inj h have hh := Prod.mk.inj hc.2 exact Prod.ext hh.1 (Prod.ext hc.1 hh.2)) have h3 := fixed_sum_coordinate_sum_le T U (fun t => t.2.2) (fun t => t.1) (fun t => t.2.1) u d (fun n _ => hd n) (by intro t ht; have := hsum t ht; omega) (fun t ht => ⟨(hT t ht).2.2, (hT t ht).1⟩) (by intro a b h have hc := Prod.mk.inj h have hh := Prod.mk.inj hc.2 exact Prod.ext hh.1 (Prod.ext hh.2 hc.1)) have hUcard : U.card = u := by simp [U, Nat.card_Icc] have hdSum : (∑ n ∈ U, d n) = Chebyshev.psi u - Chebyshev.theta u := sum_primePowerLogWeight u rw [hUcard, hdSum] at h1 h2 h3 have hlocal : mangoldtTripleSum u ≤ primeTripleLogSum u + Real.log (u : ℝ) ^ 2 * ((∑ t ∈ T, d t.1) + (∑ t ∈ T, d t.2.1) + (∑ t ∈ T, d t.2.2)) := by calc mangoldtTripleSum u ≤ ∑ t ∈ T, (primeLogWeight t.1 * primeLogWeight t.2.1 * primeLogWeight t.2.2 + Real.log (u : ℝ) ^ 2 * (d t.1 + d t.2.1 + d t.2.2)) := by apply Finset.sum_le_sum intro t ht have htU := hT t ht exact triple_product_difference_le (ArithmeticFunction.vonMangoldt t.1) (ArithmeticFunction.vonMangoldt t.2.1) (ArithmeticFunction.vonMangoldt t.2.2) (primeLogWeight t.1) (primeLogWeight t.2.1) (primeLogWeight t.2.2) (Real.log u) (primeLogWeight_nonneg _) (primeLogWeight_nonneg _) (primeLogWeight_nonneg _) (primeLogWeight_le_vonMangoldt _) (primeLogWeight_le_vonMangoldt _) (primeLogWeight_le_vonMangoldt _) (hweight _ htU.1) (hweight _ htU.2.1) (hweight _ htU.2.2) _ = _ := by rw [Finset.sum_add_distrib, ← Finset.mul_sum] simp only [Finset.sum_add_distrib, primeTripleLogSum_eq, T] have htotal := add_le_add (add_le_add h1 h2) h3 have hm := mul_le_mul_of_nonneg_left htotal (sq_nonneg (Real.log (u : ℝ))) nlinarith
/-- The contribution from genuine higher prime powers is lower order than thequadratic main term. This uses Mathlib's elementary `ψ - θ = O(sqrt x)` bound. -/theorem mangoldt_triple_error_isLittleO : (fun x : ℝ => 3 * x * Real.log x ^ 2 * (Chebyshev.psi x - Chebyshev.theta x)) =o[atTop] (fun x : ℝ => x ^ 2) := by have hlog : (fun x : ℝ => Real.log x ^ 2) =o[atTop] (fun x : ℝ => x ^ (1 / 2 : ℝ)) := by simpa only [Real.rpow_two] using isLittleO_log_rpow_rpow_atTop (2 : ℝ) (by norm_num : (0 : ℝ) < 1 / 2) have hsmall := hlog.mul_isBigO Chebyshev.isBigO_psi_sub_theta_sqrt have hscaled := hsmall.mul_isBigO (isBigO_refl (fun x : ℝ => x) atTop) have hquadratic : (fun x : ℝ => x * Real.log x ^ 2 * (Chebyshev.psi x - Chebyshev.theta x)) =o[atTop] (fun x : ℝ => x ^ 2) := by apply hscaled.congr' · exact Eventually.of_forall (fun x => by simp only [Pi.sub_apply]; ring) · filter_upwards [eventually_gt_atTop (0 : ℝ)] with x hx rw [Real.sqrt_eq_rpow, ← Real.rpow_add hx] norm_num ring simpa only [mul_assoc] using hquadratic.const_mul_left 3
/-- Explicit error absorption along the natural-number parameter. -/theorem eventually_mangoldt_triple_error_lt (ε : ℝ) (hε : 0 < ε) : ∀ᶠ u : ℕ in atTop, 3 * (u : ℝ) * Real.log (u : ℝ) ^ 2 * (Chebyshev.psi u - Chebyshev.theta u) < ε * (u : ℝ) ^ 2 := by have hsmall := mangoldt_triple_error_isLittleO.bound (show 0 < ε / 2 by positivity) have hn := (tendsto_natCast_atTop_atTop (R := ℝ)).eventually hsmall filter_upwards [hn, eventually_ge_atTop (1 : ℕ)] with u hu hu1 rw [Real.norm_of_nonneg (sq_nonneg (u : ℝ))] at hu have hu0 : (0 : ℝ) < u := by exact_mod_cast hu1 exact (le_trans (le_abs_self _) hu).trans_lt (by nlinarith [sq_pos_of_pos hu0])
/-- An analytic quadratic lower bound for the von Mangoldt convolution impliesone for the prime-only weighted sum. No analytic lower bound is asserted here. -/theorem weighted_prime_lower_bound_of_mangoldt (c : ℝ) (hc : 0 < c) (hmain : ∀ᶠ u : ℕ in atTop, Odd u → c * (u : ℝ) ^ 2 ≤ mangoldtTripleSum u) : ∀ᶠ u : ℕ in atTop, Odd u → (c / 2) * (u : ℝ) ^ 2 ≤ primeTripleLogSum u := by filter_upwards [hmain, eventually_mangoldt_triple_error_lt (c / 2) (by positivity)] with u hu herr intro hodd have hupper := mangoldtTripleSum_le_primeTripleLogSum u have hlower := hu hodd linarith
end Problem337
end
end OAI12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182import OAI.NumberTheory.EgyptianFractions.ThreePrimeMangoldt
namespace OAInoncomputable sectionopen scoped BigOperatorsopen Filter Asymptotics
namespace Problem337
/-- Removing higher prime powers can only reduce a nonnegative convolution. -/lemma primeTripleLogSum_le_mangoldtTripleSum (u : ℕ) : primeTripleLogSum u ≤ mangoldtTripleSum u := by rw [primeTripleLogSum_eq] unfold mangoldtTripleSum apply Finset.sum_le_sum intro t ht exact mul_le_mul (mul_le_mul (primeLogWeight_le_vonMangoldt t.1) (primeLogWeight_le_vonMangoldt t.2.1) (primeLogWeight_nonneg t.2.1) ArithmeticFunction.vonMangoldt_nonneg) (primeLogWeight_le_vonMangoldt t.2.2) (primeLogWeight_nonneg t.2.2) (mul_nonneg ArithmeticFunction.vonMangoldt_nonneg ArithmeticFunction.vonMangoldt_nonneg)
/-- Two-sided control of the actual convolution error, without an analytic hypothesis. -/theorem abs_mangoldtTripleSum_sub_primeTripleLogSum_le (u : ℕ) : |mangoldtTripleSum u - primeTripleLogSum u| ≤ 3 * (u : ℝ) * Real.log (u : ℝ) ^ 2 * (Chebyshev.psi u - Chebyshev.theta u) := by rw [abs_of_nonneg (sub_nonneg.mpr (primeTripleLogSum_le_mangoldtTripleSum u))] linarith [mangoldtTripleSum_le_primeTripleLogSum u]
/-- Higher prime powers do not affect the normalized quadratic main term. -/theorem mangoldtTripleSum_sub_primeTripleLogSum_isLittleO : (fun u : ℕ => mangoldtTripleSum u - primeTripleLogSum u) =o[atTop] (fun u : ℕ => (u : ℝ) ^ 2) := by have hbound := mangoldt_triple_error_isLittleO.comp_tendsto (tendsto_natCast_atTop_atTop (R := ℝ)) apply IsLittleO.of_bound intro c hc filter_upwards [hbound.bound hc] with u hu simp only [Function.comp_apply, Real.norm_eq_abs] at hu ⊢ exact (abs_mangoldtTripleSum_sub_primeTripleLogSum_le u).trans ((le_abs_self _).trans hu)
/-- The normalized difference converges to zero along all natural integers. -/theorem tendsto_mangoldtTripleSum_sub_primeTripleLogSum_div_sq : Tendsto (fun u : ℕ => (mangoldtTripleSum u - primeTripleLogSum u) / (u : ℝ) ^ 2) atTop (nhds 0) := mangoldtTripleSum_sub_primeTripleLogSum_isLittleO.tendsto_div_nhds_zero
/-- Any quadratic asymptotic, including a varying singular-series coefficient,is equivalent for the Mangoldt and prime-only convolutions. This is only anerror-transfer theorem: neither asymptotic formula is asserted. -/theorem mangoldt_prime_quadratic_asymptotic_iff_filter (l : Filter ℕ) (hl : l ≤ atTop) (σ : ℕ → ℝ) : ((fun u : ℕ => mangoldtTripleSum u - σ u * (u : ℝ) ^ 2) =o[l] (fun u : ℕ => (u : ℝ) ^ 2)) ↔ ((fun u : ℕ => primeTripleLogSum u - σ u * (u : ℝ) ^ 2) =o[l] (fun u : ℕ => (u : ℝ) ^ 2)) := by constructor · intro h exact (h.sub (mangoldtTripleSum_sub_primeTripleLogSum_isLittleO.mono hl)).congr_left (fun u => by ring) · intro h exact (h.add (mangoldtTripleSum_sub_primeTripleLogSum_isLittleO.mono hl)).congr_left (fun u => by ring)
/-- The same transfer without restricting the parameter (the filter version alsoapplies directly to the odd integers). -/theorem mangoldt_prime_quadratic_asymptotic_iff (σ : ℕ → ℝ) : ((fun u : ℕ => mangoldtTripleSum u - σ u * (u : ℝ) ^ 2) =o[atTop] (fun u : ℕ => (u : ℝ) ^ 2)) ↔ ((fun u : ℕ => primeTripleLogSum u - σ u * (u : ℝ) ^ 2) =o[atTop] (fun u : ℕ => (u : ℝ) ^ 2)) := mangoldt_prime_quadratic_asymptotic_iff_filter atTop le_rfl σ
end Problem337
end
end OAI12345678910111213141516171819202122232425262728293031import OAI.NumberTheory.EgyptianFractions.ThreePrimeMangoldtimport OAI.NumberTheory.EgyptianFractions.ThreePrimeWeighted
namespace OAInoncomputable sectionopen Filter
namespace Problem337
/-- The independently defined prime-weighted counts are identical. -/lemma primeTripleLogSum_eq_weightedSupplyPrimeTriples (u : ℕ) : primeTripleLogSum u = weightedSupplyPrimeTriples u := rfl
/-- The standard quadratic lower bound for the von Mangoldt convolution issufficient for the exact arithmetic hypothesis used in the Egyptian-fractionconstruction. The genuinely analytic lower bound remains an explicit premise. -/theorem quantitativeThreePrimeLowerBound_of_mangoldt (hmain : ∃ c : ℝ, 0 < c ∧ ∀ᶠ u : ℕ in atTop, Odd u → c * (u : ℝ) ^ 2 ≤ mangoldtTripleSum u) : QuantitativeThreePrimeLowerBound := by obtain ⟨c, hc, hmain⟩ := hmain apply quantitativeThreePrimeLowerBound_of_weighted refine ⟨c / 2, by positivity, ?_⟩ simpa only [primeTripleLogSum_eq_weightedSupplyPrimeTriples] using weighted_prime_lower_bound_of_mangoldt c hc hmain
end Problem337
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566import OAI.NumberTheory.EgyptianFractions.ThreePrimeContinuousFourierimport OAI.NumberTheory.EgyptianFractions.ThreePrimeMangoldt
namespace OAInoncomputable sectionopen scoped BigOperators
namespace Problem337.ThreePrimeContinuousFourier
/-- The actual positive-frequency Mangoldt polynomial on the unit circle. -/def mangoldtPhaseSum (u : ℕ) (x : ℝ) : ℂ := ∑ n ∈ Finset.Icc 1 u, (ArithmeticFunction.vonMangoldt n : ℂ) * phase (n : ℤ) x
lemma mangoldtPhaseSum_exp (u : ℕ) (x : ℝ) : mangoldtPhaseSum u x = ∑ n ∈ Finset.Icc 1 u, (ArithmeticFunction.vonMangoldt n : ℂ) * Complex.exp (2 * Real.pi * Complex.I * (n : ℂ) * x) := by simp only [mangoldtPhaseSum, phase_exp, Int.cast_natCast]
lemma mangoldtPhaseSum_continuous (u : ℕ) : Continuous (mangoldtPhaseSum u) := by unfold mangoldtPhaseSum exact continuous_finsetSum _ (fun n hn => continuous_const.mul (phase_continuous _))
/-- Exact continuous cubic extraction for the canonical positive-integerMangoldt convolution. In particular no prime-distribution estimate is used. -/theorem mangoldt_triple_integral (u : ℕ) : (∫ x in (0 : ℝ)..1, mangoldtPhaseSum u x ^ 3 * phase (-(u : ℤ)) x) = (mangoldtTripleSum u : ℂ) := by classical have h := weighted_triple_finset_integral (Finset.Icc 1 u) (fun n : ℕ => (n : ℤ)) (fun n => (ArithmeticFunction.vonMangoldt n : ℂ)) (u : ℤ) change (∫ x in (0 : ℝ)..1, (∑ n ∈ Finset.Icc 1 u, (ArithmeticFunction.vonMangoldt n : ℂ) * phase (n : ℤ) x) ^ 3 * phase (-(u : ℤ)) x) = _ rw [h] unfold mangoldtTripleSum supplyIntegerTriples simp only [Finset.sum_filter, Finset.sum_product, Complex.ofReal_sum] apply Finset.sum_congr rfl intro a ha apply Finset.sum_congr rfl intro b hb apply Finset.sum_congr rfl intro c hc have heq : ((a : ℤ) + (b : ℤ) + (c : ℤ) = (u : ℤ)) ↔ a + b + c = u := by omega by_cases hsum : a + b + c = u <;> simp [heq, hsum]
/-- The integral is a genuine integrable complex expression, not an appeal tothe default value of the Bochner integral on a nonintegrable function. -/theorem mangoldt_cubic_intervalIntegrable (u : ℕ) (a b : ℝ) : IntervalIntegrable (fun x => mangoldtPhaseSum u x ^ 3 * phase (-(u : ℤ)) x) MeasureTheory.volume a b := by exact ((mangoldtPhaseSum_continuous u).pow 3 |>.mul (phase_continuous _)).intervalIntegrable _ _
/-- Taking real parts recovers exactly the real arithmetic convolution. -/theorem re_mangoldt_triple_integral (u : ℕ) : (∫ x in (0 : ℝ)..1, mangoldtPhaseSum u x ^ 3 * phase (-(u : ℤ)) x).re = mangoldtTripleSum u := by rw [mangoldt_triple_integral] rfl
end Problem337.ThreePrimeContinuousFourier
end
end OAI1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889import OAI.NumberTheory.EgyptianFractions.ThreePrimeMangoldtAsymptotics
namespace OAInoncomputable sectionopen Filter Asymptotics
namespace Problem337
/-- The elementary prime-power error is smaller than every power above `3/2`. -/theorem mangoldt_triple_error_isLittleO_rpow (α : ℝ) (hα : 3 / 2 < α) : (fun x : ℝ => 3 * x * Real.log x ^ 2 * (Chebyshev.psi x - Chebyshev.theta x)) =o[atTop] (fun x : ℝ => x ^ α) := by have hlog : (fun x : ℝ => Real.log x ^ 2) =o[atTop] (fun x : ℝ => x ^ (α - 3 / 2)) := by simpa only [Real.rpow_two] using isLittleO_log_rpow_rpow_atTop (2 : ℝ) (by linarith : 0 < α - 3 / 2) have hsmall := hlog.mul_isBigO Chebyshev.isBigO_psi_sub_theta_sqrt have hscaled := hsmall.mul_isBigO (isBigO_refl (fun x : ℝ => x) atTop) have hfinal : (fun x : ℝ => x * Real.log x ^ 2 * (Chebyshev.psi x - Chebyshev.theta x)) =o[atTop] (fun x : ℝ => x ^ α) := by apply hscaled.congr' · exact Eventually.of_forall (fun x => by simp only [Pi.sub_apply]; ring) · filter_upwards [eventually_gt_atTop (0 : ℝ)] with x hx rw [Real.sqrt_eq_rpow] calc x ^ (α - 3 / 2) * x ^ (1 / 2 : ℝ) * x = x ^ (α - 3 / 2) * x ^ (1 / 2 : ℝ) * x ^ (1 : ℝ) := by rw [Real.rpow_one] _ = x ^ α := by rw [← Real.rpow_add hx, ← Real.rpow_add hx] congr 1 ring simpa only [mul_assoc] using hfinal.const_mul_left 3
/-- Actual Mangoldt and prime-only convolutions differ by `o(u^α)` for `α>3/2`. -/theorem mangoldtTripleSum_sub_primeTripleLogSum_isLittleO_rpow (α : ℝ) (hα : 3 / 2 < α) : (fun u : ℕ => mangoldtTripleSum u - primeTripleLogSum u) =o[atTop] (fun u : ℕ => (u : ℝ) ^ α) := by have hbound := (mangoldt_triple_error_isLittleO_rpow α hα).comp_tendsto (tendsto_natCast_atTop_atTop (R := ℝ)) apply IsLittleO.of_bound intro c hc filter_upwards [hbound.bound hc] with u hu simp only [Function.comp_apply, Real.norm_eq_abs] at hu ⊢ exact (abs_mangoldtTripleSum_sub_primeTripleLogSum_le u).trans ((le_abs_self _).trans hu)
/-- A positive power lower bound for the Mangoldt convolution survives removinghigher prime powers at any exponent above `3/2`. The lower bound itself remainsan explicit analytic premise. -/theorem weighted_prime_power_lower_bound_of_mangoldt (α : ℝ) (hα : 3 / 2 < α) (c : ℝ) (hc : 0 < c) (hmain : ∀ᶠ u : ℕ in atTop, Odd u → c * (u : ℝ) ^ α ≤ mangoldtTripleSum u) : ∀ᶠ u : ℕ in atTop, Odd u → (c / 2) * (u : ℝ) ^ α ≤ primeTripleLogSum u := by have herr := (mangoldtTripleSum_sub_primeTripleLogSum_isLittleO_rpow α hα).bound (show 0 < c / 2 by positivity) filter_upwards [hmain, herr] with u hu herr intro hodd rw [Real.norm_of_nonneg (Real.rpow_nonneg (Nat.cast_nonneg u) α), Real.norm_eq_abs] at herr have habs := le_abs_self (mangoldtTripleSum u - primeTripleLogSum u) have hlower := hu hodd linarith
/-- Transfer of an arbitrary power-scale asymptotic to genuine prime triples,including along the odd integers or any other subfilter tending to infinity. -/theorem mangoldt_prime_rpow_asymptotic_iff_filter (α : ℝ) (hα : 3 / 2 < α) (l : Filter ℕ) (hl : l ≤ atTop) (σ : ℕ → ℝ) : ((fun u : ℕ => mangoldtTripleSum u - σ u * (u : ℝ) ^ α) =o[l] (fun u : ℕ => (u : ℝ) ^ α)) ↔ ((fun u : ℕ => primeTripleLogSum u - σ u * (u : ℝ) ^ α) =o[l] (fun u : ℕ => (u : ℝ) ^ α)) := by have herr := (mangoldtTripleSum_sub_primeTripleLogSum_isLittleO_rpow α hα).mono hl constructor · intro h exact (h.sub herr).congr_left (fun u => by ring) · intro h exact (h.add herr).congr_left (fun u => by ring)
end Problem337
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188import OAI.NumberTheory.EgyptianFractions.BilinearFourierimport OAI.NumberTheory.EgyptianFractions.ThreePrimeMinorEnergy
namespace OAInoncomputable sectionopen scoped BigOperators
namespace Problem337.ThreePrimeMinorArc
/-- The prime logarithmic polynomial has global size at most Chebyshev'stheta function, for arbitrary phases of norm at most one. -/theorem prime_sum_norm_le_theta (u : ℕ) (phase : ℕ → ℂ) (hphase : ∀ p ∈ Nat.primesLE u, ‖phase p‖ ≤ 1) : ‖∑ p ∈ Nat.primesLE u, (Real.log (p : ℝ) : ℂ) * phase p‖ ≤ Chebyshev.theta (u : ℝ) := by rw [Chebyshev.theta_eq_sum_primesLE_log] apply (norm_sum_le _ _).trans apply Finset.sum_le_sum intro p hp have hlog : 0 ≤ Real.log (p : ℝ) := Real.log_nonneg (by exact_mod_cast (Nat.mem_primesLE.mp hp).2.one_le) rw [norm_mul, Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg hlog] simpa using mul_le_mul_of_nonneg_left (hphase p hp) hlog
/-- An unconditional linear global amplitude bound, with an explicit constant. -/theorem prime_sum_norm_le (u : ℕ) (phase : ℕ → ℂ) (hphase : ∀ p ∈ Nat.primesLE u, ‖phase p‖ ≤ 1) : ‖∑ p ∈ Nat.primesLE u, (Real.log (p : ℝ) : ℂ) * phase p‖ ≤ Real.log 4 * (u : ℝ) := (prime_sum_norm_le_theta u phase hphase).trans (Chebyshev.theta_le_log4_mul_x (Nat.cast_nonneg u))
/-- The cubic contribution of any set of frequencies is controlled by auniform bound on that set and the full Fourier energy. The twist may be anyfunction of norm at most one. This is the elementary minor-arc reduction,not an assertion of a prime exponential-sum estimate. -/theorem cubic_contribution_le_energy {q : ℕ} [NeZero q] (w : ZMod q → ℂ) (minor : Finset (ZMod q)) (twist : ZMod q → ℂ) (A : ℝ) (hA : 0 ≤ A) (hbound : ∀ r ∈ minor, ‖residueFourier w r‖ ≤ A) (htwist : ∀ r ∈ minor, ‖twist r‖ ≤ 1) : ‖(∑ r ∈ minor, residueFourier w r ^ 3 * twist r) / (q : ℂ)‖ ≤ A * ∑ n : ZMod q, ‖w n‖ ^ 2 := by have htransform (r : ZMod q) : residueFourier w r = ZMod.dft (fun n => w (-n)) r := by rw [ZMod.dft_comp_neg] simp only [residueFourier, ZMod.dft_apply, smul_eq_mul, mul_neg, neg_neg] apply Finset.sum_congr rfl intro n hn rw [mul_comm n r, mul_comm] have h := ThreePrimeMinorEnergy.minor_cubic_bound (fun n => w (-n)) twist minor A hA (by intro r hr rw [← htransform] exact hbound r hr) htwist simp_rw [← htransform] at h have henergy : (∑ n : ZMod q, ‖w (-n)‖ ^ 2) = ∑ n : ZMod q, ‖w n‖ ^ 2 := Equiv.sum_comp (Equiv.neg _) (fun n => ‖w n‖ ^ 2) rw [henergy] at h simpa only [div_eq_mul_inv, mul_comm] using h
/-- The usual additive-character twist for the coefficient at `u`. -/theorem cubic_character_contribution_le_energy {q : ℕ} [NeZero q] (w : ZMod q → ℂ) (minor : Finset (ZMod q)) (u : ZMod q) (A : ℝ) (hA : 0 ≤ A) (hbound : ∀ r ∈ minor, ‖residueFourier w r‖ ≤ A) : ‖(∑ r ∈ minor, residueFourier w r ^ 3 * ZMod.stdAddChar (-(r * u))) / (q : ℂ)‖ ≤ A * ∑ n : ZMod q, ‖w n‖ ^ 2 := by apply cubic_contribution_le_energy w minor _ A hA hbound intro r hr simp [ZMod.stdAddChar_apply]
/-- Prime logarithmic weights, zero padded in a cyclic group. -/def primeLogWeight {q : ℕ} [NeZero q] (u : ℕ) (n : ZMod q) : ℂ := if n.val ∈ Nat.primesLE u then (Real.log (n.val : ℝ) : ℂ) else 0
/-- Zero padding preserves the exact prime-weight energy when `u < q`. -/theorem primeLogWeight_energy {q : ℕ} [NeZero q] (u : ℕ) (huq : u < q) : (∑ n : ZMod q, ‖primeLogWeight u n‖ ^ 2) = ∑ p ∈ Nat.primesLE u, Real.log (p : ℝ) ^ 2 := by classical calc (∑ n : ZMod q, ‖primeLogWeight u n‖ ^ 2) = ∑ n ∈ Finset.univ.filter (fun n : ZMod q => n.val ∈ Nat.primesLE u), Real.log (n.val : ℝ) ^ 2 := by simp [primeLogWeight, Finset.sum_filter, apply_ite, Complex.norm_real, Real.norm_eq_abs, sq_abs] _ = ∑ p ∈ Nat.primesLE u, Real.log (p : ℝ) ^ 2 := by apply Finset.sum_bij (fun n _ => n.val) · intro n hn exact (Finset.mem_filter.mp hn).2 · intro n hn n' hn' heq exact ZMod.val_injective q heq · intro p hp have hpq : p < q := (Nat.mem_primesLE.mp hp).1.trans_lt huq refine ⟨(p : ZMod q), ?_, ZMod.val_natCast_of_lt hpq⟩ simp [ZMod.val_natCast_of_lt hpq, hp] · intro n hn rfl
/-- The zero-padded transform is exactly the usual prime exponential sum. -/theorem residueFourier_primeLogWeight {q : ℕ} [NeZero q] (u : ℕ) (huq : u < q) (r : ZMod q) : residueFourier (primeLogWeight u) r = ∑ p ∈ Nat.primesLE u, (Real.log (p : ℝ) : ℂ) * ZMod.stdAddChar (r * (p : ZMod q)) := by classical calc residueFourier (primeLogWeight u) r = ∑ n ∈ Finset.univ.filter (fun n : ZMod q => n.val ∈ Nat.primesLE u), (Real.log (n.val : ℝ) : ℂ) * ZMod.stdAddChar (r * n) := by simp [residueFourier, primeLogWeight, Finset.sum_filter, ite_mul] _ = ∑ p ∈ Nat.primesLE u, (Real.log (p : ℝ) : ℂ) * ZMod.stdAddChar (r * (p : ZMod q)) := by apply Finset.sum_bij (fun n _ => n.val) · intro n hn exact (Finset.mem_filter.mp hn).2 · intro n hn n' hn' heq exact ZMod.val_injective q heq · intro p hp have hpq : p < q := (Nat.mem_primesLE.mp hp).1.trans_lt huq refine ⟨(p : ZMod q), ?_, ZMod.val_natCast_of_lt hpq⟩ simp [ZMod.val_natCast_of_lt hpq, hp] · intro n hn simp only [ZMod.natCast_zmod_val]
/-- A Chebyshev energy bound saves one logarithm compared with the trivialbound obtained by counting all integers up to `u`. -/theorem prime_log_squares_le (u : ℕ) (hu : 1 ≤ u) : (∑ p ∈ Nat.primesLE u, Real.log (p : ℝ) ^ 2) ≤ Real.log 4 * (u : ℝ) * Real.log (u : ℝ) := by have hlogu : 0 ≤ Real.log (u : ℝ) := Real.log_nonneg (by exact_mod_cast hu) calc (∑ p ∈ Nat.primesLE u, Real.log (p : ℝ) ^ 2) ≤ ∑ p ∈ Nat.primesLE u, Real.log (p : ℝ) * Real.log (u : ℝ) := by apply Finset.sum_le_sum intro p hp obtain ⟨hpu, hprime⟩ := Nat.mem_primesLE.mp hp have hp0 : (0 : ℝ) < p := by exact_mod_cast hprime.pos have hplog : 0 ≤ Real.log (p : ℝ) := Real.log_nonneg (by exact_mod_cast hprime.one_le) have hlog : Real.log (p : ℝ) ≤ Real.log (u : ℝ) := Real.log_le_log hp0 (by exact_mod_cast hpu) simpa [pow_two] using mul_le_mul_of_nonneg_left hlog hplog _ = Chebyshev.theta (u : ℝ) * Real.log (u : ℝ) := by rw [Chebyshev.theta_eq_sum_primesLE_log, Finset.sum_mul] _ ≤ Real.log 4 * (u : ℝ) * Real.log (u : ℝ) := mul_le_mul_of_nonneg_right (Chebyshev.theta_le_log4_mul_x (Nat.cast_nonneg u)) hlogu
/-- A minor-frequency supremum bound for the actual prime sum yields aquadratic error with the Chebyshev constant made explicit. -/theorem prime_cubic_contribution_le {q : ℕ} [NeZero q] (u : ℕ) (hu : 2 ≤ u) (huq : u < q) (minor : Finset (ZMod q)) (ε : ℝ) (hε : 0 ≤ ε) (hbound : ∀ r ∈ minor, ‖∑ p ∈ Nat.primesLE u, (Real.log (p : ℝ) : ℂ) * ZMod.stdAddChar (r * (p : ZMod q))‖ ≤ ε * (u : ℝ) / Real.log (u : ℝ)) : ‖(∑ r ∈ minor, (∑ p ∈ Nat.primesLE u, (Real.log (p : ℝ) : ℂ) * ZMod.stdAddChar (r * (p : ZMod q))) ^ 3 * ZMod.stdAddChar (-(r * (u : ZMod q)))) / (q : ℂ)‖ ≤ ε * Real.log 4 * (u : ℝ) ^ 2 := by have hu1 : 1 < (u : ℝ) := by exact_mod_cast (show 1 < u by omega) have hlog : 0 < Real.log (u : ℝ) := Real.log_pos hu1 have hA : 0 ≤ ε * (u : ℝ) / Real.log (u : ℝ) := by positivity have h := cubic_character_contribution_le_energy (primeLogWeight u) minor (u : ZMod q) (ε * (u : ℝ) / Real.log (u : ℝ)) hA (by intro r hr rw [residueFourier_primeLogWeight u huq] exact hbound r hr) simp_rw [residueFourier_primeLogWeight u huq] at h rw [primeLogWeight_energy u huq] at h apply h.trans calc ε * (u : ℝ) / Real.log (u : ℝ) * (∑ p ∈ Nat.primesLE u, Real.log (p : ℝ) ^ 2) ≤ ε * (u : ℝ) / Real.log (u : ℝ) * (Real.log 4 * (u : ℝ) * Real.log (u : ℝ)) := mul_le_mul_of_nonneg_left (prime_log_squares_le u (by omega)) hA _ = ε * Real.log 4 * (u : ℝ) ^ 2 := by field_simp
end Problem337.ThreePrimeMinorArc
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102import Mathlib
namespace OAInoncomputable sectionopen scoped BigOperators ComplexConjugate
namespace Problem337.ThreePrimeMinorEnergy
variable {q : ℕ} [NeZero q]
/-- Transposition for the unnormalized discrete Fourier transform. -/theorem sum_dft_mul (f g : ZMod q → ℂ) : (∑ k, ZMod.dft f k * g k) = ∑ x, f x * ZMod.dft g x := by simp only [ZMod.dft_apply, smul_eq_mul, Finset.sum_mul, Finset.mul_sum] rw [Finset.sum_comm] apply Finset.sum_congr rfl intro x hx apply Finset.sum_congr rfl intro k hk rw [mul_comm k x] ring
/-- Complex conjugation reverses the Fourier frequency. -/theorem dft_conj (f : ZMod q → ℂ) (k : ZMod q) : ZMod.dft (fun x => conj (f x)) k = conj (ZMod.dft f (-k)) := by simp only [ZMod.dft_apply, smul_eq_mul, map_sum, map_mul, ← AddChar.map_neg_eq_conj] apply Finset.sum_congr rfl intro x hx congr 2 ring
/-- Exact Parseval identity, retaining the factor `q` for counting measure. -/theorem dft_parseval (f : ZMod q → ℂ) : (∑ k, ‖ZMod.dft f k‖ ^ 2) = (q : ℝ) * ∑ x, ‖f x‖ ^ 2 := by have h := sum_dft_mul f (fun k => conj (ZMod.dft f k)) have hconj (x : ZMod q) : ZMod.dft (fun k => conj (ZMod.dft f k)) x = (q : ℂ) * conj (f x) := by rw [dft_conj] simp only [ZMod.dft_dft, neg_neg, smul_eq_mul, map_mul, map_natCast] simp only [hconj] at h have h' : (∑ k, (‖ZMod.dft f k‖ ^ 2 : ℂ)) = (q : ℂ) * ∑ x, (‖f x‖ ^ 2 : ℂ) := by calc (∑ k, (‖ZMod.dft f k‖ ^ 2 : ℂ)) = ∑ k, ZMod.dft f k * conj (ZMod.dft f k) := by apply Finset.sum_congr rfl intro k hk rw [Complex.mul_conj, Complex.normSq_eq_norm_sq, Complex.ofReal_pow] _ = ∑ x, f x * ((q : ℂ) * conj (f x)) := h _ = (q : ℂ) * ∑ x, (‖f x‖ ^ 2 : ℂ) := by rw [Finset.mul_sum] apply Finset.sum_congr rfl intro x hx rw [← mul_assoc, mul_comm (f x) (q : ℂ), mul_assoc, Complex.mul_conj, Complex.normSq_eq_norm_sq, Complex.ofReal_pow] exact_mod_cast h'
/-- The cubic contribution of any frequency set is controlled by itssupremum Fourier bound and the exact input energy. The phase may be anyfunction of modulus at most one, so either Fourier sign convention is allowed. -/theorem minor_cubic_bound (f phase : ZMod q → ℂ) (minor : Finset (ZMod q)) (B : ℝ) (hB : 0 ≤ B) (hminor : ∀ k ∈ minor, ‖ZMod.dft f k‖ ≤ B) (hphase : ∀ k ∈ minor, ‖phase k‖ ≤ 1) : ‖(q : ℂ)⁻¹ * ∑ k ∈ minor, ZMod.dft f k ^ 3 * phase k‖ ≤ B * ∑ x, ‖f x‖ ^ 2 := by have hq : (0 : ℝ) < q := by exact_mod_cast Nat.pos_of_ne_zero (NeZero.ne q) have hsum : ‖∑ k ∈ minor, ZMod.dft f k ^ 3 * phase k‖ ≤ B * ((q : ℝ) * ∑ x, ‖f x‖ ^ 2) := by calc ‖∑ k ∈ minor, ZMod.dft f k ^ 3 * phase k‖ ≤ ∑ k ∈ minor, ‖ZMod.dft f k ^ 3 * phase k‖ := norm_sum_le _ _ _ ≤ ∑ k ∈ minor, B * ‖ZMod.dft f k‖ ^ 2 := by apply Finset.sum_le_sum intro k hk rw [norm_mul, norm_pow] calc ‖ZMod.dft f k‖ ^ 3 * ‖phase k‖ ≤ ‖ZMod.dft f k‖ ^ 3 := by simpa using mul_le_mul_of_nonneg_left (hphase k hk) (by positivity : 0 ≤ ‖ZMod.dft f k‖ ^ 3) _ ≤ B * ‖ZMod.dft f k‖ ^ 2 := by nlinarith [mul_le_mul_of_nonneg_right (hminor k hk) (sq_nonneg ‖ZMod.dft f k‖)] _ = B * ∑ k ∈ minor, ‖ZMod.dft f k‖ ^ 2 := (Finset.mul_sum ..).symm _ ≤ B * ∑ k, ‖ZMod.dft f k‖ ^ 2 := by apply mul_le_mul_of_nonneg_left _ hB exact Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ _) (by intros; positivity) _ = B * ((q : ℝ) * ∑ x, ‖f x‖ ^ 2) := by rw [dft_parseval] rw [norm_mul, norm_inv, Complex.norm_natCast] calc (q : ℝ)⁻¹ * ‖∑ k ∈ minor, ZMod.dft f k ^ 3 * phase k‖ ≤ (q : ℝ)⁻¹ * (B * ((q : ℝ) * ∑ x, ‖f x‖ ^ 2)) := mul_le_mul_of_nonneg_left hsum (inv_nonneg.mpr hq.le) _ = B * ∑ x, ‖f x‖ ^ 2 := by field_simp
end Problem337.ThreePrimeMinorEnergy
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108import OAI.NumberTheory.EgyptianFractions.FirstDerivativeSum
namespace OAInoncomputable sectionopen scoped BigOperators
namespace Problem337.ThreePrimeAnalysis
/-- Finite Abel summation controlled by initial partial sums and total variation. -/theorem weighted_sum_norm_le_partial_sum_bound (a b : ℕ → ℂ) (n : ℕ) (B : ℝ) (hprefix : ∀ k ≤ n + 1, ‖∑ j ∈ Finset.range k, a j‖ ≤ B) : ‖∑ j ∈ Finset.range (n + 1), b j * a j‖ ≤ B * (‖b n‖ + ∑ j ∈ Finset.range n, ‖b (j + 1) - b j‖) := by let A : ℕ → ℂ := fun k => ∑ j ∈ Finset.range k, a j have hdiff (j : ℕ) : A (j + 1) - A j = a j := by simp [A, Finset.sum_range_succ] have hid := Problem337.weighted_difference_sum A b n simp only [hdiff, A, Finset.range_zero, Finset.sum_empty, mul_zero, sub_zero] at hid rw [hid] calc _ ≤ ‖b n * ∑ j ∈ Finset.range (n + 1), a j‖ + ‖∑ j ∈ Finset.range n, (b (j + 1) - b j) * ∑ i ∈ Finset.range (j + 1), a i‖ := norm_sub_le _ _ _ ≤ ‖b n‖ * B + ∑ j ∈ Finset.range n, ‖b (j + 1) - b j‖ * B := by apply add_le_add · rw [norm_mul] exact mul_le_mul_of_nonneg_left (hprefix (n + 1) le_rfl) (norm_nonneg _) · apply (norm_sum_le _ _).trans apply Finset.sum_le_sum intro j hj rw [norm_mul] exact mul_le_mul_of_nonneg_left (hprefix (j + 1) (by have := Finset.mem_range.mp hj omega)) (norm_nonneg _) _ = _ := by rw [← Finset.sum_mul]; ring
/-- The unit exponential is one-Lipschitz in its real angle. -/theorem norm_exp_I_mul_sub_le (x y : ℝ) : ‖Complex.exp (Complex.I * (x : ℂ)) - Complex.exp (Complex.I * (y : ℂ))‖ ≤ |x - y| := by have hid : Complex.exp (Complex.I * (x : ℂ)) - Complex.exp (Complex.I * (y : ℂ)) = Complex.exp (Complex.I * (y : ℂ)) * (Complex.exp (Complex.I * ((x - y : ℝ) : ℂ)) - 1) := by rw [mul_sub, mul_one, ← Complex.exp_add] congr 2 push_cast ring rw [hid, norm_mul, Complex.norm_exp_I_mul_ofReal, one_mul] simpa only [Real.norm_eq_abs] using (Real.norm_exp_I_mul_ofReal_sub_one_le (x := x - y))
/-- Linear-phase Abel transfer, uniform in the initial angle and frequency. -/theorem linear_phase_sum_norm_le (a : ℕ → ℂ) (N : ℕ) (B α t : ℝ) (hB : 0 ≤ B) (hprefix : ∀ k ≤ N, ‖∑ j ∈ Finset.range k, a j‖ ≤ B) : ‖∑ j ∈ Finset.range N, Complex.exp (Complex.I * ((α + t * j : ℝ) : ℂ)) * a j‖ ≤ B * (1 + |t| * N) := by cases N with | zero => simpa using hB | succ n => have h := weighted_sum_norm_le_partial_sum_bound a (fun j => Complex.exp (Complex.I * ((α + t * j : ℝ) : ℂ))) n B hprefix have hvariation : (∑ j ∈ Finset.range n, ‖Complex.exp (Complex.I * ((α + t * (j + 1 : ℕ) : ℝ) : ℂ)) - Complex.exp (Complex.I * ((α + t * j : ℝ) : ℂ))‖) ≤ (n : ℝ) * |t| := by calc _ ≤ ∑ _j ∈ Finset.range n, |t| := by apply Finset.sum_le_sum intro j hj have heq : α + t * (j + 1 : ℕ) - (α + t * j) = t := by push_cast ring simpa only [heq] using norm_exp_I_mul_sub_le (α + t * (j + 1 : ℕ)) (α + t * j) _ = _ := by simp rw [Complex.norm_exp_I_mul_ofReal] at h apply h.trans apply mul_le_mul_of_nonneg_left _ hB have ht := abs_nonneg t push_cast at hvariation ⊢ nlinarith
/-- The major-arc partial-summation error estimate, in turns rather than radians.It is conditional only on the stated finite prefix discrepancy. -/theorem twisted_sum_sub_norm_le (a b : ℕ → ℂ) (N : ℕ) (B β : ℝ) (hB : 0 ≤ B) (hprefix : ∀ k ≤ N, ‖(∑ j ∈ Finset.range k, a j) - ∑ j ∈ Finset.range k, b j‖ ≤ B) : ‖(∑ j ∈ Finset.range N, Complex.exp (Complex.I * ((2 * Real.pi * β * j : ℝ) : ℂ)) * a j) - ∑ j ∈ Finset.range N, Complex.exp (Complex.I * ((2 * Real.pi * β * j : ℝ) : ℂ)) * b j‖ ≤ B * (1 + 2 * Real.pi * |β| * N) := by have h := linear_phase_sum_norm_le (fun j => a j - b j) N B 0 (2 * Real.pi * β) hB (by intro k hk simpa only [Finset.sum_sub_distrib] using hprefix k hk) simpa only [zero_add, mul_sub, Finset.sum_sub_distrib, abs_mul, abs_of_pos Real.pi_pos, abs_of_pos (show (0 : ℝ) < 2 by norm_num)] using h
end Problem337.ThreePrimeAnalysis
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126import OAI.NumberTheory.EgyptianFractions.RationalSupplyReduction
namespace OAInoncomputable sectionopen scoped BigOperatorsopen Filter
namespace Problem337
/-- The odd-prime local perturbation in the ternary Goldbach singular series.Index `n` corresponds to the integer `n + 3`; nonprimes contribute zero. -/def threePrimeOddPerturbation (u n : ℕ) : ℝ := if (n + 3).Prime then if n + 3 ∣ u then -(1 / ((n : ℝ) + 2) ^ 2) else 1 / ((n : ℝ) + 2) ^ 3 else 0
/-- The local factor at two, with all the odd-prime factors following it. -/def threePrimeSingularSeries (u : ℕ) : ℝ := (if Odd u then 2 else 0) * ∏' n : ℕ, (1 + threePrimeOddPerturbation u n)
lemma threePrimeOddPerturbation_norm_le (u n : ℕ) : ‖threePrimeOddPerturbation u n‖ ≤ 1 / ((n : ℝ) + 2) ^ 2 := by have hx : 1 ≤ (n : ℝ) + 2 := by have := Nat.cast_nonneg (α := ℝ) n; linarith have hx0 : 0 < (n : ℝ) + 2 := by positivity unfold threePrimeOddPerturbation split_ifs · simp [Real.norm_eq_abs] · rw [Real.norm_eq_abs, abs_of_nonneg (by positivity)] apply div_le_div_of_nonneg_left zero_le_one (by positivity) nlinarith [sq_nonneg ((n : ℝ) + 2)] · simp only [norm_zero] positivity
lemma threePrimeOddPerturbation_summable (u : ℕ) : Summable (threePrimeOddPerturbation u) := by have hs : Summable (fun n : ℕ => 1 / ((n : ℝ) + 2) ^ 2) := by simpa only [Nat.cast_add, Nat.cast_ofNat] using (summable_nat_add_iff 2).mpr (Real.summable_one_div_nat_pow.mpr (by norm_num : 1 < 2)) exact hs.of_norm_bounded (threePrimeOddPerturbation_norm_le u)
lemma threePrimeOddFactors_multipliable (u : ℕ) : Multipliable (fun n : ℕ => 1 + threePrimeOddPerturbation u n) := Real.multipliable_one_add_of_summable (threePrimeOddPerturbation_summable u)
/-- The telescoping product over all integers is a lower bound for the productof the negative local factors over any subset of odd primes. -/lemma prod_one_sub_reciprocal_square (N : ℕ) : (∏ n ∈ Finset.range N, (1 - 1 / ((n : ℝ) + 2) ^ 2)) = ((N : ℝ) + 2) / (2 * ((N : ℝ) + 1)) := by induction N with | zero => norm_num | succ N ih => rw [Finset.prod_range_succ, ih] push_cast have h1 : (N : ℝ) + 1 ≠ 0 := by positivity have h2 : (N : ℝ) + 2 ≠ 0 := by positivity field_simp ring
lemma one_sub_reciprocal_square_nonneg (n : ℕ) : 0 ≤ 1 - 1 / ((n : ℝ) + 2) ^ 2 := by have hsq : 1 ≤ ((n : ℝ) + 2) ^ 2 := by nlinarith [Nat.cast_nonneg (α := ℝ) n] have hdiv : 1 / ((n : ℝ) + 2) ^ 2 ≤ 1 := (div_le_one (by positivity)).2 hsq linarith
lemma threePrimeOddFactor_lower (u n : ℕ) : 1 - 1 / ((n : ℝ) + 2) ^ 2 ≤ 1 + threePrimeOddPerturbation u n := by unfold threePrimeOddPerturbation split_ifs <;> have h2 : 0 ≤ 1 / ((n : ℝ) + 2) ^ 2 := by positivity all_goals have h3 : 0 ≤ 1 / ((n : ℝ) + 2) ^ 3 := by positivity all_goals linarith
lemma threePrimeOddFactors_prod_lower (u N : ℕ) : (1 / 2 : ℝ) ≤ ∏ n ∈ Finset.range N, (1 + threePrimeOddPerturbation u n) := by calc (1 / 2 : ℝ) ≤ ((N : ℝ) + 2) / (2 * ((N : ℝ) + 1)) := by apply (le_div_iff₀ (by positivity)).2 linarith _ = ∏ n ∈ Finset.range N, (1 - 1 / ((n : ℝ) + 2) ^ 2) := (prod_one_sub_reciprocal_square N).symm _ ≤ _ := Finset.prod_le_prod₀ (fun n _ => one_sub_reciprocal_square_nonneg n) (fun n _ => threePrimeOddFactor_lower u n)
lemma threePrimeOddFactors_tprod_lower (u : ℕ) : (1 / 2 : ℝ) ≤ ∏' n : ℕ, (1 + threePrimeOddPerturbation u n) := by exact ge_of_tendsto' (threePrimeOddFactors_multipliable u).hasProd.tendsto_prod_nat (threePrimeOddFactors_prod_lower u)
/-- Uniform positivity does not require a prime number theorem: the all-integercomparison product gives the explicit lower bound one for every odd input. -/theorem threePrimeSingularSeries_one_le {u : ℕ} (hu : Odd u) : 1 ≤ threePrimeSingularSeries u := by rw [threePrimeSingularSeries, ite_eq_left hu] have h := threePrimeOddFactors_tprod_lower u linarith
/-- A uniform asymptotic error estimate for ordered prime triples suffices forthe precise quantitative number-theoretic interface used by the supply proof.The asymptotic estimate remains a hypothesis; no Vinogradov theorem is asserted. -/theorem quantitativeThreePrimeLowerBound_of_singular_error (A : ℝ) (hA : 0 < A) (herror : ∀ ε : ℝ, 0 < ε → ∀ᶠ u : ℕ in atTop, Odd u → |((supplyPrimeTriples u).card : ℝ) - A * threePrimeSingularSeries u * ((u : ℝ) ^ 2 / Real.log (u : ℝ) ^ 3)| ≤ ε * ((u : ℝ) ^ 2 / Real.log (u : ℝ) ^ 3)) : QuantitativeThreePrimeLowerBound := by refine ⟨A / 2, by positivity, ?_⟩ filter_upwards [herror (A / 2) (by positivity), eventually_ge_atTop 2] with u hu hu2 intro hodd have hs := threePrimeSingularSeries_one_le hodd have huR : 1 < (u : ℝ) := by exact_mod_cast (show 1 < u by omega) have hscale : 0 ≤ (u : ℝ) ^ 2 / Real.log (u : ℝ) ^ 3 := by exact div_nonneg (sq_nonneg _) (pow_nonneg (Real.log_pos huR).le _) have hmain := mul_le_mul_of_nonneg_right hs (mul_nonneg hA.le hscale) have hlow := (abs_le.mp (hu hodd)).1 nlinarith
end Problem337
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174import OAI.NumberTheory.EgyptianFractions.ThreePrimeEulerTailimport OAI.NumberTheory.EgyptianFractions.ThreePrimeSingularSeries
namespace OAInoncomputable sectionopen scoped BigOperatorsopen Filter
namespace Problem337
private lemma shifted_reciprocal_square_tail (P : Finset ℕ) (N : ℕ) (hP : ∀ n ∈ P, N ≤ n) : (∑ n ∈ P, 1 / ((n : ℝ) + 2) ^ 2) ≤ 1 / ((N : ℝ) + 1) := by have htail := ThreePrimeEulerTail.reciprocal_square_tail (P.image (fun n => n + 3)) (N + 2) (by omega) (by intro p hp obtain ⟨n, hn, rfl⟩ := Finset.mem_image.mp hp have := hP n hn omega) rw [Finset.sum_image (by intro a ha b hb hab; dsimp at hab; omega)] at htail convert htail using 1 · apply Finset.sum_congr rfl intro n hn push_cast ring · push_cast ring
/-- Every finite tail of the canonical ternary singular series has relativeerror at most `2 / (N + 1)`, uniformly in the integer being represented. -/theorem threePrimeOddFactors_tail_abs_sub_one (u N : ℕ) (P : Finset ℕ) (hP : ∀ n ∈ P, N ≤ n) : |(∏ n ∈ P, (1 + threePrimeOddPerturbation u n)) - 1| ≤ 2 / ((N : ℝ) + 1) := by have hsum : (∑ n ∈ P, ‖threePrimeOddPerturbation u n‖) ≤ 1 / ((N : ℝ) + 1) := (Finset.sum_le_sum (fun n _ => threePrimeOddPerturbation_norm_le u n)).trans (shifted_reciprocal_square_tail P N hP) have hsmall : |1 / ((N : ℝ) + 1)| ≤ 1 := by rw [abs_of_nonneg (by positivity)] exact (div_le_one (by positivity)).mpr (by linarith [Nat.cast_nonneg (α := ℝ) N]) have hprod := P.norm_prod_one_add_sub_one_le (threePrimeOddPerturbation u) rw [Real.norm_eq_abs] at hprod calc _ ≤ Real.exp (∑ n ∈ P, ‖threePrimeOddPerturbation u n‖) - 1 := hprod _ ≤ Real.exp (1 / ((N : ℝ) + 1)) - 1 := sub_le_sub_right (Real.exp_le_exp.mpr hsum) 1 _ ≤ |Real.exp (1 / ((N : ℝ) + 1)) - 1| := le_abs_self _ _ ≤ 2 * |1 / ((N : ℝ) + 1)| := Real.abs_exp_sub_one_le hsmall _ = 2 / ((N : ℝ) + 1) := by rw [abs_of_nonneg (by positivity)]; ring
/-- Uniform boundedness of the finite odd-prime factors. -/theorem threePrimeOddFactors_partial_abs_le (u N : ℕ) : |∏ n ∈ Finset.range N, (1 + threePrimeOddPerturbation u n)| ≤ 3 := by have htail := threePrimeOddFactors_tail_abs_sub_one u 0 (Finset.range N) (by intros; omega) norm_num only [Nat.cast_zero, zero_add, div_one] at htail calc _ = |((∏ n ∈ Finset.range N, (1 + threePrimeOddPerturbation u n)) - 1) + 1| := by ring_nf _ ≤ |(∏ n ∈ Finset.range N, (1 + threePrimeOddPerturbation u n)) - 1| + |(1 : ℝ)| := abs_add_le _ _ _ ≤ 3 := by norm_num at htail ⊢; linarith
/-- The canonical infinite odd-prime product is uniformly approximated by itsfirst `N` factors at the explicit rate `6 / (N + 1)`. -/theorem threePrimeOddFactors_tprod_sub_partial (u N : ℕ) : |(∏' n : ℕ, (1 + threePrimeOddPerturbation u n)) - ∏ n ∈ Finset.range N, (1 + threePrimeOddPerturbation u n)| ≤ 6 / ((N : ℝ) + 1) := by apply le_of_tendsto (((threePrimeOddFactors_multipliable u).hasProd.tendsto_prod_nat.sub_const (∏ n ∈ Finset.range N, (1 + threePrimeOddPerturbation u n))).abs) filter_upwards [eventually_ge_atTop N] with M hNM rw [← Finset.prod_range_mul_prod_Ico (fun n => 1 + threePrimeOddPerturbation u n) hNM] have heq : (∏ n ∈ Finset.range N, (1 + threePrimeOddPerturbation u n)) * (∏ n ∈ Finset.Ico N M, (1 + threePrimeOddPerturbation u n)) - (∏ n ∈ Finset.range N, (1 + threePrimeOddPerturbation u n)) = (∏ n ∈ Finset.range N, (1 + threePrimeOddPerturbation u n)) * ((∏ n ∈ Finset.Ico N M, (1 + threePrimeOddPerturbation u n)) - 1) := by ring rw [heq, abs_mul] calc _ ≤ 3 * (2 / ((N : ℝ) + 1)) := by apply mul_le_mul (threePrimeOddFactors_partial_abs_le u N) (threePrimeOddFactors_tail_abs_sub_one u N (Finset.Ico N M) (by intro n hn; exact (Finset.mem_Ico.mp hn).1)) (abs_nonneg _) (by norm_num) _ = 6 / ((N : ℝ) + 1) := by ring
/-- The finite canonical singular product, including the factor at two. -/def threePrimeSingularPartial (u N : ℕ) : ℝ := (if Odd u then 2 else 0) * ∏ n ∈ Finset.range N, (1 + threePrimeOddPerturbation u n)
/-- Uniform quantitative truncation of the actual defined singular series. -/theorem threePrimeSingularSeries_sub_partial (u N : ℕ) : |threePrimeSingularSeries u - threePrimeSingularPartial u N| ≤ 12 / ((N : ℝ) + 1) := by unfold threePrimeSingularSeries threePrimeSingularPartial rw [← mul_sub, abs_mul] have hfactor : |(if Odd u then 2 else 0 : ℝ)| ≤ 2 := by split_ifs <;> norm_num calc _ ≤ 2 * (6 / ((N : ℝ) + 1)) := mul_le_mul hfactor (threePrimeOddFactors_tprod_sub_partial u N) (abs_nonneg _) (by norm_num) _ = 12 / ((N : ℝ) + 1) := by ring
/-- Uniform convergence in the represented integer: the onset is independentof `u`, including even inputs where the singular series vanishes. -/theorem threePrimeSingularPartial_tendstoUniformly : TendstoUniformly (fun N u => threePrimeSingularPartial u N) threePrimeSingularSeries atTop := by apply Metric.tendstoUniformly_iff.mpr intro ε hε obtain ⟨N₀, hN₀⟩ := exists_nat_gt (12 / ε) filter_upwards [eventually_ge_atTop N₀] with N hN intro u rw [Real.dist_eq] apply (threePrimeSingularSeries_sub_partial u N).trans_lt apply (div_lt_iff₀ (by positivity : (0 : ℝ) < N + 1)).mpr have hNreal : (N₀ : ℝ) ≤ N := by exact_mod_cast hN have hbound := (div_lt_iff₀ hε).mp hN₀ nlinarith
/-- A simultaneous absolute bound for all singular series, useful whenconverting an additive asymptotic error into a relative error. -/theorem threePrimeSingularSeries_abs_le_six (u : ℕ) : |threePrimeSingularSeries u| ≤ 6 := by have hodd : |∏' n : ℕ, (1 + threePrimeOddPerturbation u n)| ≤ 3 := le_of_tendsto' (threePrimeOddFactors_multipliable u).hasProd.tendsto_prod_nat.abs (threePrimeOddFactors_partial_abs_le u) unfold threePrimeSingularSeries rw [abs_mul] have hfactor : |(if Odd u then 2 else 0 : ℝ)| ≤ 2 := by split_ifs <;> norm_num nlinarith [abs_nonneg (∏' n : ℕ, (1 + threePrimeOddPerturbation u n))]
/-- A cutoff tending to infinity may depend on the represented integer or onany other parameter; uniform truncation still makes the error tend to zero. -/theorem threePrimeSingularPartial_sub_tendsto_zero {α : Type*} {l : Filter α} (u Q : α → ℕ) (hQ : Tendsto Q l atTop) : Tendsto (fun x => threePrimeSingularSeries (u x) - threePrimeSingularPartial (u x) (Q x)) l (nhds 0) := by apply squeeze_zero_norm (fun x => by simpa only [Real.norm_eq_abs] using threePrimeSingularSeries_sub_partial (u x) (Q x)) apply tendsto_const_nhds.div_atTop apply tendsto_atTop_mono (fun x => ?_) (tendsto_natCast_atTop_atTop.comp hQ) exact le_add_of_nonneg_right zero_le_one
/-- Truncating the singular series changes any weighted main term by little-oof that same weight. No positivity or nonvanishing of the weight is needed. -/theorem threePrimeSingularPartial_weighted_isLittleO {α : Type*} {l : Filter α} (u Q : α → ℕ) (hQ : Tendsto Q l atTop) (w : α → ℝ) : (fun x => (threePrimeSingularSeries (u x) - threePrimeSingularPartial (u x) (Q x)) * w x) =o[l] w := by have hsmall : (fun x => threePrimeSingularSeries (u x) - threePrimeSingularPartial (u x) (Q x)) =o[l] (fun _ => (1 : ℝ)) := (Asymptotics.isLittleO_one_iff ℝ).mpr (threePrimeSingularPartial_sub_tendsto_zero u Q hQ) simpa only [one_mul] using hsmall.mul_isBigO (Asymptotics.isBigO_refl w l)
/-- An asymptotic formula with a growing finite singular product is equivalentto the formula with the canonical infinite series. This supplies the uniformEuler-tail transfer in a major-arc computation without asserting that formula. -/theorem threePrimeSingularPartial_asymptotic_iff {α : Type*} {l : Filter α} (u Q : α → ℕ) (hQ : Tendsto Q l atTop) (a w : α → ℝ) : ((fun x => a x - threePrimeSingularSeries (u x) * w x) =o[l] w) ↔ ((fun x => a x - threePrimeSingularPartial (u x) (Q x) * w x) =o[l] w) := by have htail := threePrimeSingularPartial_weighted_isLittleO u Q hQ w constructor · intro h exact (h.add htail).congr_left (fun x => by ring) · intro h exact (h.sub htail).congr_left (fun x => by ring)
end Problem337
end
end OAI1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162import OAI.NumberTheory.EgyptianFractions.RationalSupplyReduction
namespace OAInoncomputable sectionopen scoped BigOperatorsopen Filter
namespace Problem337
/-- The logarithmically weighted ordered prime triple count, with exactly thesame triples as the rational-divisor supply reduction. -/def weightedSupplyPrimeTriples (u : ℕ) : ℝ := ∑ t ∈ supplyPrimeTriples u, Real.log (t.1 : ℝ) * Real.log (t.2.1 : ℝ) * Real.log (t.2.2 : ℝ)
lemma weightedSupplyPrimeTriples_le (u : ℕ) : weightedSupplyPrimeTriples u ≤ (supplyPrimeTriples u).card * Real.log (u : ℝ) ^ 3 := by unfold weightedSupplyPrimeTriples calc _ ≤ ∑ _t ∈ supplyPrimeTriples u, Real.log (u : ℝ) ^ 3 := by apply Finset.sum_le_sum intro t ht obtain ⟨htmem, htprime⟩ := Finset.mem_filter.mp ht obtain ⟨hp, hq, hr⟩ := Finset.mem_product.mp htmem |>.imp_right Finset.mem_product.mp have hlog (p : ℕ) (hp : p ∈ Finset.Icc 1 u) : 0 ≤ Real.log (p : ℝ) ∧ Real.log (p : ℝ) ≤ Real.log (u : ℝ) := by obtain ⟨hp1, hpu⟩ := Finset.mem_Icc.mp hp have hp1r : (1 : ℝ) ≤ p := by exact_mod_cast hp1 exact ⟨Real.log_nonneg hp1r, Real.log_le_log (lt_of_lt_of_le zero_lt_one hp1r) (by exact_mod_cast hpu)⟩ obtain ⟨hp0, hpu⟩ := hlog t.1 hp obtain ⟨hq0, hqu⟩ := hlog t.2.1 hq obtain ⟨hr0, hru⟩ := hlog t.2.2 hr have hu0 : 0 ≤ Real.log (u : ℝ) := hp0.trans hpu calc _ ≤ (Real.log (u : ℝ) * Real.log (u : ℝ)) * Real.log (u : ℝ) := mul_le_mul (mul_le_mul hpu hqu hq0 hu0) hru hr0 (by positivity) _ = _ := by ring _ = _ := by simp
/-- Positive quadratic logarithmically weighted count is enough for theprecise unweighted lower-bound interface already used by the solution. -/theorem quantitativeThreePrimeLowerBound_of_weighted (hweighted : ∃ c : ℝ, 0 < c ∧ ∀ᶠ u : ℕ in atTop, Odd u → c * (u : ℝ) ^ 2 ≤ weightedSupplyPrimeTriples u) : QuantitativeThreePrimeLowerBound := by obtain ⟨c, hc, hw⟩ := hweighted refine ⟨c, hc, ?_⟩ filter_upwards [hw, eventually_ge_atTop 2] with u hu hu2 intro hodd have hur : (1 : ℝ) < u := by exact_mod_cast (show 1 < u by omega) have hlog : 0 < Real.log (u : ℝ) ^ 3 := pow_pos (Real.log_pos hur) 3 have h := (hu hodd).trans (weightedSupplyPrimeTriples_le u) rw [← mul_div_assoc] exact (div_le_iff₀ hlog).2 h
end Problem337
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128import Mathlib
namespace OAInamespace Problem337.DivisorMoment
/-- Positive divisors truncated at an integral threshold. -/def truncatedDivisors (X n : ℕ) : Finset ℕ := n.divisors.filter (fun a => a ≤ X)
@[simp] theorem mem_truncatedDivisors {X n a : ℕ} : a ∈ truncatedDivisors X n ↔ a ∣ n ∧ n ≠ 0 ∧ a ≤ X := by simp [truncatedDivisors, and_assoc]
/-- The second component of the gcd splitting is a divisor of the quotient.No coprimality of the chosen factor and the quotient is needed. -/theorem div_gcd_dvd_quotient {a d n : ℕ} (ha : a ∣ n) (hd : d ∣ n) : a / Nat.gcd a d ∣ n / d := by apply (Nat.dvd_div_iff_mul_dvd hd).2 have hlcm : Nat.lcm a d = d * (a / Nat.gcd a d) := by rw [Nat.lcm_eq_mul_div, Nat.mul_comm a d, Nat.mul_div_assoc d (Nat.gcd_dvd_left a d)] rw [← hlcm] exact Nat.lcm_dvd ha hd
/-- Divisor splitting is injective, because its components multiply to the input. -/theorem gcd_split_injective (d : ℕ) : Function.Injective (fun a : ℕ => (Nat.gcd a d, a / Nat.gcd a d)) := by intro a b hab have h := congrArg (fun z : ℕ × ℕ => z.2 * z.1) hab simpa only [Nat.div_mul_cancel (Nat.gcd_dvd_left a d), Nat.div_mul_cancel (Nat.gcd_dvd_left b d)] using h
/-- Truncated divisors of a product inject into a full divisor set and onetruncated divisor set. This is the prefix inequality in the divisor moment argument. -/theorem truncated_card_le_mul {X n d : ℕ} (hn : 0 < n) (hd : d ∣ n) : (truncatedDivisors X n).card ≤ d.divisors.card * (truncatedDivisors X (n / d)).card := by have hdpos : 0 < d := Nat.pos_of_dvd_of_pos hd hn have hquotpos : 0 < n / d := Nat.div_pos (Nat.le_of_dvd hn hd) hdpos rw [← Finset.card_product] apply Finset.card_le_card_of_injOn (fun a : ℕ => (Nat.gcd a d, a / Nat.gcd a d)) · intro a ha obtain ⟨han, _, haX⟩ := mem_truncatedDivisors.mp ha apply Finset.mem_product.mpr constructor · exact Nat.mem_divisors.mpr ⟨Nat.gcd_dvd_right a d, hdpos.ne'⟩ · exact mem_truncatedDivisors.mpr ⟨div_gcd_dvd_quotient han hd, hquotpos.ne', (Nat.div_le_self a (Nat.gcd a d)).trans haX⟩ · exact (gcd_split_injective d).injOn
/-- Multiples of a positive integer in a translated interval satisfy theuniform counting estimate needed for short-interval divisor moments. -/theorem interval_multiples_card_le (N Y d : ℕ) (hd : 0 < d) : ((Finset.Ioc N (N + Y)).filter (fun a => d ∣ a)).card ≤ Y / d + 1 := by have hcard : ((Finset.Ioc N (N + Y)).filter (fun a => d ∣ a)).card ≤ (Finset.Ioc (N / d) ((N + Y) / d)).card := by apply Finset.card_le_card_of_injOn (fun a : ℕ => a / d) · intro a ha obtain ⟨haI, had⟩ := Finset.mem_filter.mp ha obtain ⟨hNa, haNY⟩ := Finset.mem_Ioc.mp haI apply Finset.mem_Ioc.mpr constructor · apply (Nat.div_lt_iff_lt_mul hd).mpr simpa only [Nat.div_mul_cancel had] using hNa · exact Nat.div_le_div_right haNY · intro a ha b hb hab have had := (Finset.mem_filter.mp ha).2 have hbd := (Finset.mem_filter.mp hb).2 have h := congrArg (fun q => q * d) hab simpa only [Nat.div_mul_cancel had, Nat.div_mul_cancel hbd] using h rw [Nat.card_Ioc, Nat.add_div hd] at hcard split_ifs at hcard · simpa only [Nat.add_assoc, Nat.add_sub_cancel_left] using hcard · have h : ((Finset.Ioc N (N + Y)).filter (fun a => d ∣ a)).card ≤ Y / d := by simpa only [Nat.add_zero, Nat.add_sub_cancel_left] using hcard exact h.trans (Nat.le_succ _)
theorem interval_multiples_card_le_real (N Y d : ℕ) (hd : 0 < d) : (((Finset.Ioc N (N + Y)).filter (fun a => d ∣ a)).card : ℝ) ≤ (Y : ℝ) / d + 1 := by calc _ ≤ ((Y / d + 1 : ℕ) : ℝ) := by exact_mod_cast interval_multiples_card_le N Y d hd _ = ((Y / d : ℕ) : ℝ) + 1 := by norm_cast _ ≤ (Y : ℝ) / d + 1 := by have hcast : ((Y / d : ℕ) : ℝ) ≤ (Y : ℝ) / d := Nat.cast_div_le linarith
theorem interval_multiples_card_le_twice (N Y d : ℕ) (hd : 0 < d) (hdY : d ≤ Y) : (((Finset.Ioc N (N + Y)).filter (fun a => d ∣ a)).card : ℝ) ≤ 2 * (Y : ℝ) / d := by have hdR : (0 : ℝ) < d := by exact_mod_cast hd have hratio : (1 : ℝ) ≤ (Y : ℝ) / d := by apply (le_div_iff₀ hdR).mpr simpa only [one_mul] using (show (d : ℝ) ≤ Y by exact_mod_cast hdY) calc _ ≤ (Y : ℝ) / d + 1 := interval_multiples_card_le_real N Y d hd _ ≤ 2 * ((Y : ℝ) / d) := by linarith _ = 2 * (Y : ℝ) / d := by ring
/-- Real lengths are implemented by their natural floor, without changing theuniform interval bound. -/theorem interval_multiples_real_cutoff (N d : ℕ) (Y : ℝ) (hY : 0 ≤ Y) (hd : 0 < d) : (((Finset.Ioc N (N + ⌊Y⌋₊)).filter (fun a => d ∣ a)).card : ℝ) ≤ Y / d + 1 := by calc _ ≤ (⌊Y⌋₊ : ℝ) / d + 1 := interval_multiples_card_le_real N ⌊Y⌋₊ d hd _ ≤ Y / d + 1 := by gcongr exact Nat.floor_le hY
theorem interval_multiples_real_cutoff_twice (N d : ℕ) (Y : ℝ) (hY : 0 ≤ Y) (hd : 0 < d) (hdY : (d : ℝ) ≤ Y) : (((Finset.Ioc N (N + ⌊Y⌋₊)).filter (fun a => d ∣ a)).card : ℝ) ≤ 2 * Y / d := by calc _ ≤ 2 * (⌊Y⌋₊ : ℝ) / d := interval_multiples_card_le_twice N ⌊Y⌋₊ d hd (Nat.le_floor hdY) _ ≤ 2 * Y / d := by gcongr exact Nat.floor_le hY
end Problem337.DivisorMoment
end OAI12345678910111213141516171819202122232425262728293031323334353637383940414243import Mathlib
namespace OAInamespace Problem337.TypeIIBlockScalar
/-- The scalar aggregation for one dyadic Vaughan Type-II block. All analyticinformation is explicit in the three elementary size bounds. -/theorem block_bound (X M T Q U V H : ℝ) (hX : 0 ≤ X) (hM : 0 ≤ M) (hT : 0 ≤ T) (hQ : 0 < Q) (hU : 0 < U) (hV : 0 < V) (hH : 1 ≤ H) (hMT : M * T ≤ X) (hTU : T ≤ 2 * X / U) (hMV : M ≤ X / V) : (2 * M * H ^ 3) * ((2 * T / Q + 1) * (2 * M + 4 * Q * H)) * (T * H ^ 2) ≤ 32 * X * H ^ 6 * (X / Q + X / U + X / V + Q) := by have hH0 : 0 ≤ H := by linarith have hXQ : 0 ≤ X / Q := div_nonneg hX hQ.le have hXU : 0 ≤ X / U := div_nonneg hX hU.le have hXV : 0 ≤ X / V := div_nonneg hX hV.le have hMTQ : M * T / Q ≤ X / Q := div_le_div_of_nonneg_right hMT hQ.le have hTH : T * H ≤ (2 * X / U) * H := mul_le_mul_of_nonneg_right hTU hH0 have hQH : X / Q ≤ H * (X / Q) := by nlinarith [mul_le_mul_of_nonneg_right hH hXQ] have hVH : X / V ≤ H * (X / V) := by nlinarith [mul_le_mul_of_nonneg_right hH hXV] have hinner : (2 * T / Q + 1) * (2 * M + 4 * Q * H) ≤ 16 * H * (X / Q + X / U + X / V + Q) := by have heq : (2 * T / Q + 1) * (2 * M + 4 * Q * H) = 4 * (M * T / Q) + 8 * T * H + 2 * M + 4 * Q * H := by field_simp ring rw [heq] have hTH' : T * H ≤ 2 * (X / U) * H := by convert hTH using 1; ring nlinarith [mul_nonneg hH0 hXQ, mul_nonneg hH0 hXV, mul_nonneg hH0 hQ.le] have hfactor : 2 * (M * T) * H ^ 5 ≤ 2 * X * H ^ 5 := mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left hMT (by norm_num)) (by positivity) have hinner0 : 0 ≤ (2 * T / Q + 1) * (2 * M + 4 * Q * H) := by positivity calc _ = (2 * (M * T) * H ^ 5) * ((2 * T / Q + 1) * (2 * M + 4 * Q * H)) := by ring _ ≤ (2 * X * H ^ 5) * (16 * H * (X / Q + X / U + X / V + Q)) := mul_le_mul hfactor hinner hinner0 (by positivity) _ = _ := by ring
end Problem337.TypeIIBlockScalar
end OAI12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091import OAI.NumberTheory.EgyptianFractions.SmallPrimeMomentimport OAI.NumberTheory.EgyptianFractions.IntermediateBandBudgetimport OAI.NumberTheory.EgyptianFractions.LargeClassUniformimport OAI.NumberTheory.EgyptianFractions.DivisorClassAssembly
namespace OAInoncomputable section
open Filteropen scoped BigOperators
namespace Problem337.DivisorMoment
attribute [local instance] Classical.propDecidable
/-- The complete uniform shifted divisor moment, with the upper cutoffparameterized exponentially. All three prime-factor classes are estimatedunconditionally; the threshold depends only on the fixed `D` and `r`. -/theorem eventually_uniform_divisor_moment_exp (D r : ℝ) (hD : 1 ≤ D) (hr : 0 ≤ r) : ∀ᶠ S : ℝ in atTop, ∀ v Y : ℝ, ∀ N : ℕ, S / (2 * Real.log S) ≤ v → v ≤ D * S → Real.exp (v / 2) ≤ Y → Y ≤ Real.exp v → (N : ℝ) ≤ Real.exp (D * S) → (∑ h ∈ Finset.Icc 1 ⌊Y⌋₊, (truncatedDivisorCount (Real.exp v) (N + h) : ℝ) ^ r) ≤ Y * Real.exp (S ^ (1 / 4 : ℝ)) := by obtain ⟨C, hC, hlarge⟩ := eventually_large_class_moment_bound_exp D r hD hr filter_upwards [hlarge, small_class_truncated_moment_bound D r hD hr, eventually_intermediate_band_budget D r hD hr, DivisorClasses.eventually_class_budget_assembly D r C hD hr hC.le] with S hlarge hsmall hband hassemble intro v Y N hvlo hvhi hYlo hYhi hN have hYpos : 0 < Y := (Real.exp_pos (v / 2)).trans_le hYlo have hsqrt : Real.sqrt (Real.exp v) = Real.exp (v / 2) := by rw [Real.sqrt_eq_rpow, ← Real.exp_mul] congr 1 ring apply hassemble v Y hvlo hvhi hYlo hYhi (Finset.Icc 1 ⌊Y⌋₊) (fun h => N + h) (fun h => (truncatedDivisorCount (Real.exp v) (N + h) : ℝ) ^ r) · intro h hh positivity · exact hlarge v Y N hvlo hvhi hYlo hYhi hN · simpa only [Real.log_exp] using hsmall (Real.exp v) Y N (by simpa only [Real.log_exp] using hvlo) (by simpa only [Real.log_exp] using hvhi) (by simpa only [hsqrt] using hYlo) hYhi hN · intro j by_cases hj : 4 * Real.log S * 2 ^ j ≤ v ^ (15 / 16 : ℝ) · exact hband v Y N j hvlo hvhi hYlo hYhi hN hj · have hempty : (Finset.Icc 1 ⌊Y⌋₊).filter (fun h => DivisorClasses.BandClass (N + h) S v Y j) = ∅ := by apply Finset.filter_eq_empty_iff.mpr intro h hh hb exact hj (DivisorClasses.band_scale_lt hb).le simp only [hempty, Finset.sum_empty] positivity
/-- Uniform divisor moments with real cutoffs. The statement also covers a realinterval length through its floor. -/theorem eventually_uniform_divisor_moment (D r : ℝ) (hD : 1 ≤ D) (hr : 0 ≤ r) : ∀ᶠ S : ℝ in atTop, ∀ X Y : ℝ, ∀ N : ℕ, S / (2 * Real.log S) ≤ Real.log X → Real.log X ≤ D * S → Real.sqrt X ≤ Y → Y ≤ X → (N : ℝ) ≤ Real.exp (D * S) → (∑ h ∈ Finset.Icc 1 ⌊Y⌋₊, (truncatedDivisorCount X (N + h) : ℝ) ^ r) ≤ Y * Real.exp (S ^ (1 / 4 : ℝ)) := by filter_upwards [eventually_uniform_divisor_moment_exp D r hD hr, eventually_ge_atTop (2 : ℝ)] with S hmoment hS intro X Y N hvlo hvhi hYlo hYhi hN have hSpos : 0 < S := by linarith have hlogS : 0 < Real.log S := Real.log_pos (by linarith) have hlogX : 0 < Real.log X := (by positivity : 0 < S / (2 * Real.log S)).trans_le hvlo have hXnonneg : 0 ≤ X := (Real.sqrt_nonneg X).trans (hYlo.trans hYhi) have hX : 1 < X := (Real.log_pos_iff hXnonneg).mp hlogX have hXpos : 0 < X := by linarith have hsqrt : Real.exp (Real.log X / 2) = Real.sqrt X := by rw [Real.sqrt_eq_rpow, Real.rpow_def_of_pos hXpos] congr 1 ring simpa only [Real.exp_log hXpos] using hmoment (Real.log X) Y N hvlo hvhi (by simpa only [hsqrt] using hYlo) (by simpa only [Real.exp_log hXpos] using hYhi) hN
end Problem337.DivisorMoment
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990import OAI.NumberTheory.EgyptianFractions.SecondMomentAssemblyimport OAI.NumberTheory.EgyptianFractions.FiniteExposureAverage
namespace OAInoncomputable sectionopen scoped BigOperatorsnamespace Problem337
theorem norm_expect_sq_eq_expect_pairs {I : Type*} [Fintype I] (z : I → ℂ) : ‖𝔼 i, z i‖ ^ 2 = 𝔼 ij : I × I, (z ij.1 * star (z ij.2)).re := by simp only [Fintype.expect_eq_sum_div_card, norm_div, norm_natCast] rw [div_pow, norm_sum_sq_eq_sum_pair] simp only [Fintype.card_prod, Nat.cast_mul, pow_two]
theorem uniform_second_moment_identity {Ω I : Type*} [Fintype Ω] [Fintype I] (z : Ω → I → ℂ) : (𝔼 ω, ‖𝔼 i, z ω i‖ ^ 2) = 𝔼 ij : I × I, (𝔼 ω, z ω ij.1 * star (z ω ij.2)).re := by simp_rw [norm_expect_sq_eq_expect_pairs] rw [Finset.expect_comm] congr 1 funext ij exact (map_expect (Complex.reCLM.toLinearMap.restrictScalars ℚ≥0) (fun ω => z ω ij.1 * star (z ω ij.2)) Finset.univ).symm
/-- Uniform finite-average version of the Hamming second-moment reduction. -/theorem uniform_boolean_second_moment_bound {Ω : Type*} [Fintype Ω] [Nonempty Ω] (m : ℕ) (z : Ω → (Fin m → Bool) → ℂ) (hz : ∀ ω i, ‖z ω i‖ ≤ 1) (δ : ℝ) (hδ : 0 ≤ δ) (hgood : ∀ i j, (m : ℝ) / 4 ≤ (hammingDist i j : ℝ) → ‖𝔼 ω, z ω i * star (z ω j)‖ ≤ δ) : (𝔼 ω, ‖𝔼 i, z ω i‖ ^ 2) ≤ Real.exp (-(m : ℝ) / 16) + δ := by classical let E := Finset.univ.filter (fun ij : (Fin m → Bool) × (Fin m → Bool) => (hammingDist ij.1 ij.2 : ℝ) < (m : ℝ) / 4) have hall (i j : Fin m → Bool) : ‖𝔼 ω, z ω i * star (z ω j)‖ ≤ 1 := by calc _ ≤ 𝔼 ω, ‖z ω i * star (z ω j)‖ := RCLike.norm_expect_le (K := ℂ) _ ≤ 𝔼 _ω : Ω, (1 : ℝ) := by apply Finset.expect_le_expect intro ω hω rw [norm_mul, norm_star] nlinarith [hz ω i, hz ω j, norm_nonneg (z ω i), norm_nonneg (z ω j)] _ = 1 := Fintype.expect_const 1 have hexc : (E.card : ℝ) ≤ (4 : ℝ) ^ m * Real.exp (-(m : ℝ) / 16) := hamming_exception_count m have hcard : (Fintype.card ((Fin m → Bool) × (Fin m → Bool)) : ℝ) = (4 : ℝ) ^ m := by simp only [Fintype.card_prod, Fintype.card_fun, Fintype.card_bool, Fintype.card_fin, Nat.cast_mul, Nat.cast_pow, Nat.cast_ofNat] rw [← mul_pow] norm_num rw [uniform_second_moment_identity] calc (𝔼 ij : (Fin m → Bool) × (Fin m → Bool), (𝔼 ω, z ω ij.1 * star (z ω ij.2)).re) ≤ 𝔼 ij : (Fin m → Bool) × (Fin m → Bool), ((if ij ∈ E then 1 else 0) + δ : ℝ) := by apply Finset.expect_le_expect intro ij hij by_cases hb : ij ∈ E · simp only [ite_eq_left hb] exact (Complex.re_le_norm _).trans ((hall _ _).trans (by linarith)) · simp only [ite_eq_right hb, zero_add] apply (Complex.re_le_norm _).trans (hgood _ _ ?_) simpa only [E, Finset.mem_filter, Finset.mem_univ, true_and, not_lt] using hb _ = (E.card : ℝ) / (4 : ℝ) ^ m + δ := by rw [Finset.expect_add_distrib, expect_finset_indicator, Fintype.expect_const, hcard] _ ≤ Real.exp (-(m : ℝ) / 16) + δ := by have hdiv : (E.card : ℝ) / (4 : ℝ) ^ m ≤ Real.exp (-(m : ℝ) / 16) := (div_le_iff₀ (by positivity)).2 (by simpa only [mul_comm] using hexc) linarith
/-- Uniform-mean final random estimate, directly matching the second momentof the sampled Boolean-product exponential average. -/theorem uniform_boolean_random_second_moment_bound {Ω : Type*} [Fintype Ω] [Nonempty Ω] (m : ℕ) (V : ℝ) (z : Ω → (Fin m → Bool) → ℂ) (hz : ∀ ω i, ‖z ω i‖ ≤ 1) (hlarge : 50 ≤ min (m : ℝ) V) (hgood : ∀ i j, (m : ℝ) / 4 ≤ (hammingDist i j : ℝ) → ‖𝔼 ω, z ω i * star (z ω j)‖ ≤ Real.exp (-V / 20) + Real.exp (-V / 5)) : (𝔼 ω, ‖𝔼 i, z ω i‖ ^ 2) ≤ Real.exp (-min (m : ℝ) V / 100) := by have h := uniform_boolean_second_moment_bound m z hz (Real.exp (-V / 20) + Real.exp (-V / 5)) (by positivity) hgood exact h.trans (by simpa only [add_assoc] using random_second_moment_absorption (m : ℝ) V hlarge)
end Problem337
end
end OAI12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394import Mathlib
namespace OAIopen Filteropen scoped Topology
namespace Problem337
/-- A double logarithm estimate for the elementary denominator bound. -/theorem loglog_le_of_power_bound {k : ℕ} {x : ℝ} (hk : 2 ≤ k) (hx : 2 ≤ x) (hbound : x ≤ 1 + (k : ℝ) ^ (2 ^ (k - 1))) : Real.log (Real.log x) ≤ (k : ℝ) * Real.log 2 + Real.log (Real.log k) := by have hkR : 2 ≤ (k : ℝ) := by exact_mod_cast hk have hkpos : 0 < (k : ℝ) := by linarith have hkone : 1 ≤ (k : ℝ) := by linarith have hlogk : 0 < Real.log (k : ℝ) := Real.log_pos (by linarith) have hp : 1 ≤ (2 : ℕ) ^ (k - 1) := Nat.one_le_pow _ _ (by decide) have hpow : 2 ≤ (k : ℝ) ^ (2 ^ (k - 1)) := by calc 2 ≤ (k : ℝ) := hkR _ = (k : ℝ) ^ 1 := by simp _ ≤ (k : ℝ) ^ (2 ^ (k - 1)) := pow_le_pow_right₀ hkone hp have hexp : (2 : ℕ) ^ (k - 1) * 2 = 2 ^ k := by rw [← pow_succ, Nat.sub_add_cancel (by omega : 1 ≤ k)] have hbound' : x ≤ (k : ℝ) ^ (2 ^ k) := by calc x ≤ 1 + (k : ℝ) ^ (2 ^ (k - 1)) := hbound _ ≤ ((k : ℝ) ^ (2 ^ (k - 1))) ^ 2 := by nlinarith _ = (k : ℝ) ^ (2 ^ k) := by rw [← pow_mul, hexp] have hlog : Real.log x ≤ (2 : ℝ) ^ k * Real.log (k : ℝ) := by simpa only [Real.log_pow, Nat.cast_pow, Nat.cast_ofNat] using Real.log_le_log (by linarith : 0 < x) hbound' have hlogx : 0 < Real.log x := Real.log_pos (by linarith) calc Real.log (Real.log x) ≤ Real.log ((2 : ℝ) ^ k * Real.log (k : ℝ)) := Real.log_le_log hlogx hlog _ = (k : ℝ) * Real.log 2 + Real.log (Real.log k) := by rw [Real.log_mul (by positivity) (ne_of_gt hlogk), Real.log_pow]
/-- The logarithmic error in the denominator upper bound is negligible. -/theorem tendsto_log_nat_div_nat : Tendsto (fun k : ℕ => Real.log (k : ℝ) / (k : ℝ)) atTop (𝓝 0) := by have h := Real.tendsto_pow_log_div_mul_add_atTop 1 0 1 one_ne_zero simpa [Function.comp_def] using h.comp tendsto_natCast_atTop_atTop
/-- The elementary power upper bound forces the sharp upper logarithmic slope. -/theorem power_bound_slope_limits (u : ℕ → ℝ) (hu : ∀ᶠ k in atTop, 2 ≤ u k ∧ u k ≤ 1 + (k : ℝ) ^ (2 ^ (k - 1))) : 0 ≤ liminf (fun k => Real.log (Real.log (u k)) / (k : ℝ)) atTop ∧ liminf (fun k => Real.log (Real.log (u k)) / (k : ℝ)) atTop ≤ limsup (fun k => Real.log (Real.log (u k)) / (k : ℝ)) atTop ∧ limsup (fun k => Real.log (Real.log (u k)) / (k : ℝ)) atTop ≤ Real.log 2 := by let f : ℕ → ℝ := fun k => Real.log (Real.log (u k)) / (k : ℝ) have hupp : f ≤ᶠ[atTop] (fun k : ℕ => Real.log 2 + Real.log (k : ℝ) / (k : ℝ)) := by filter_upwards [hu, eventually_ge_atTop 2] with k hk hk2 have hkR : 2 ≤ (k : ℝ) := by exact_mod_cast hk2 have hkpos : 0 < (k : ℝ) := by linarith have hlog : Real.log (Real.log (k : ℝ)) ≤ Real.log (k : ℝ) := by apply Real.log_le_log (Real.log_pos (by linarith)) linarith [Real.log_le_sub_one_of_pos hkpos] have hmain := loglog_le_of_power_bound hk2 hk.1 hk.2 calc f k ≤ ((k : ℝ) * Real.log 2 + Real.log (k : ℝ)) / (k : ℝ) := by apply div_le_div_of_nonneg_right _ hkpos.le exact hmain.trans (add_le_add (le_refl _) hlog) _ = Real.log 2 + Real.log (k : ℝ) / (k : ℝ) := by field_simp have hlo : (fun k : ℕ => Real.log (Real.log 2) / (k : ℝ)) ≤ᶠ[atTop] f := by filter_upwards [hu, eventually_ge_atTop 2] with k hk hk2 apply div_le_div_of_nonneg_right _ (Nat.cast_nonneg k) exact Real.log_le_log (Real.log_pos (by norm_num)) (Real.log_le_log (by norm_num) hk.1) have htU : Tendsto (fun k : ℕ => Real.log 2 + Real.log (k : ℝ) / (k : ℝ)) atTop (𝓝 (Real.log 2)) := by simpa using tendsto_const_nhds.add tendsto_log_nat_div_nat have htL : Tendsto (fun k : ℕ => Real.log (Real.log 2) / (k : ℝ)) atTop (𝓝 0) := tendsto_const_nhds.div_atTop tendsto_natCast_atTop_atTop have hfbU : atTop.IsBoundedUnder (· ≤ ·) f := htU.isBoundedUnder_le.mono_le hupp have hfbL : atTop.IsBoundedUnder (· ≥ ·) f := htL.isBoundedUnder_ge.mono_ge hlo change 0 ≤ liminf f atTop ∧ liminf f atTop ≤ limsup f atTop ∧ limsup f atTop ≤ Real.log 2 refine ⟨?_, liminf_le_limsup hfbU hfbL, ?_⟩ · calc 0 = liminf (fun k : ℕ => Real.log (Real.log 2) / (k : ℝ)) atTop := htL.liminf_eq.symm _ ≤ liminf f atTop := liminf_le_liminf hlo htL.isBoundedUnder_ge hfbU.isCobounded_flip · calc limsup f atTop ≤ limsup (fun k : ℕ => Real.log 2 + Real.log (k : ℝ) / (k : ℝ)) atTop := limsup_le_limsup hupp hfbL.isCobounded_flip htU.isBoundedUnder_le _ = Real.log 2 := htU.limsup_eq
end Problem337
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239import OAI.NumberTheory.EgyptianFractions.FourierSecondMoment
namespace OAIopen scoped BigOperatorsopen ComplexConjugate
namespace Problem337
/-- Cauchy--Schwarz for the norm of a finite complex sum. -/theorem norm_sum_sq_le_card_mul_sum_norm_sq {α : Type*} (U : Finset α) (f : α → ℂ) : ‖∑ u ∈ U, f u‖ ^ 2 ≤ (U.card : ℝ) * ∑ u ∈ U, ‖f u‖ ^ 2 := by have hn := norm_sum_le U f have hs := Finset.sum_mul_sq_le_sq_mul_sq U (fun _ => (1 : ℝ)) (fun u => ‖f u‖) simp only [one_mul, one_pow, Finset.sum_const, nsmul_eq_mul, mul_one] at hs exact (pow_le_pow_left₀ (norm_nonneg _) hn 2).trans hs
/-- Averaging equal column sums and bounding their pairwise correlations.This is the finite algebraic core of van der Corput differencing. -/theorem averaged_columns_correlation_bound {α β : Type*} (U : Finset α) (T : Finset β) (z : α → β → ℂ) (S : ℂ) (D E : ℝ) (hcol : ∀ t ∈ T, ∑ u ∈ U, z u t = S) (hdiag : ∀ t ∈ T, ∑ u ∈ U, ‖z u t‖ ^ 2 ≤ D) (hcorr : ∀ t ∈ T, ∀ s ∈ T, t ≠ s → ‖∑ u ∈ U, z u t * conj (z u s)‖ ≤ E) : (T.card : ℝ) ^ 2 * ‖S‖ ^ 2 ≤ (U.card : ℝ) * ((T.card : ℝ) * D + (T.card : ℝ) * (T.card - 1 : ℝ) * E) := by classical have havg : (∑ u ∈ U, ∑ t ∈ T, z u t) = (T.card : ℂ) * S := by rw [Finset.sum_comm] simp_rw [Finset.sum_congr rfl hcol] simp have hcs := norm_sum_sq_le_card_mul_sum_norm_sq U (fun u => ∑ t ∈ T, z u t) rw [havg, norm_mul, Complex.norm_natCast, mul_pow] at hcs apply hcs.trans apply mul_le_mul_of_nonneg_left _ (Nat.cast_nonneg _) rw [finite_complex_second_moment_identity] have hentry (t : β) (ht : t ∈ T) (s : β) (hs : s ∈ T) : (∑ u ∈ U, z u t * conj (z u s)).re ≤ E + if t = s then D - E else 0 := by by_cases heq : t = s · subst s simp only [re_finset_sum, Complex.mul_conj, Complex.ofReal_re, Complex.normSq_eq_norm_sq, ite_true, add_sub_cancel] exact hdiag t ht · simpa [heq] using (Complex.re_le_norm _).trans (hcorr t ht s hs heq) calc (∑ t ∈ T, ∑ s ∈ T, (∑ u ∈ U, z u t * conj (z u s)).re) ≤ ∑ t ∈ T, ∑ s ∈ T, (E + if t = s then D - E else 0) := by exact Finset.sum_le_sum (fun t ht => Finset.sum_le_sum (fun s hs => hentry t ht s hs)) _ = (T.card : ℝ) * D + (T.card : ℝ) * (T.card - 1 : ℝ) * E := by have hrow (t : β) (ht : t ∈ T) : (∑ s ∈ T, (E + if t = s then D - E else 0)) = (T.card : ℝ) * E + D - E := by simp [Finset.sum_add_distrib, ht] ring simp_rw [Finset.sum_congr rfl hrow] simp only [Finset.sum_const, nsmul_eq_mul] ring
/-- Translation does not change a finite sum once the summation interval contains all translated points in its support. -/theorem sum_shift_supported {M : Type*} [AddCommMonoid M] (a : ℤ → M) (N H : ℕ) (t : ℤ) (ht0 : 0 ≤ t) (htH : t ≤ H) (hsupport : ∀ n : ℤ, n ∉ Finset.Icc (1 : ℤ) N → a n = 0) : (∑ n ∈ Finset.Icc (1 - (H : ℤ)) N, a (n + t)) = ∑ n ∈ Finset.Icc (1 : ℤ) N, a n := by classical apply Finset.sum_bij_ne_zero (fun n _ _ => n + t) · intro n hn hne by_contra hout exact hne (hsupport (n + t) hout) · intro n hn hn0 m hm hm0 heq omega · intro n hn hn0 refine ⟨n - t, ?_, ?_, by omega⟩ · simp only [Finset.mem_Icc] at hn ⊢ omega · simpa using hn0 · intros rfl
/-- A concrete finite-support shift bound, before using `H ≤ N` to simplify the two endpoint losses. Correlation assumptions are symmetric in the shift. -/theorem van_der_corput_interval_exact (a : ℤ → ℂ) (N H : ℕ) (hH : 1 ≤ H) (E : ℝ) (hE : 0 ≤ E) (hsupport : ∀ n : ℤ, n ∉ Finset.Icc (1 : ℤ) N → a n = 0) (hnorm : ∀ n : ℤ, ‖a n‖ ≤ 1) (hcorr : ∀ h : ℤ, -(H : ℤ) < h → h < H → h ≠ 0 → ‖∑ n ∈ Finset.Icc (1 : ℤ) N, a (n + h) * conj (a n)‖ ≤ E) : ‖∑ n ∈ Finset.Icc (1 : ℤ) N, a n‖ ^ 2 ≤ ((N : ℝ) + H) * ((N : ℝ) / H + E) := by classical let U := Finset.Icc (1 - (H : ℤ)) (N : ℤ) let T := Finset.range H let z : ℤ → ℕ → ℂ := fun n t => a (n + t) have hcardU : (U.card : ℝ) = (N : ℝ) + H := by dsimp [U] rw [Int.card_Icc] have heq : (N : ℤ) + 1 - (1 - (H : ℤ)) = ((N + H : ℕ) : ℤ) := by omega rw [heq] norm_cast have hcol (t : ℕ) (ht : t ∈ T) : (∑ n ∈ U, z n t) = ∑ n ∈ Finset.Icc (1 : ℤ) N, a n := by exact sum_shift_supported a N H t (by omega) (by have := Finset.mem_range.mp ht; omega) hsupport have hdiag (t : ℕ) (ht : t ∈ T) : (∑ n ∈ U, ‖z n t‖ ^ 2) ≤ (N : ℝ) := by have hs : ∀ n : ℤ, n ∉ Finset.Icc (1 : ℤ) N → ‖a n‖ ^ 2 = 0 := by intro n hn simp [hsupport n hn] have heq := sum_shift_supported (fun n => ‖a n‖ ^ 2) N H t (by omega) (by have := Finset.mem_range.mp ht; omega) hs change (∑ n ∈ U, ‖a (n + t)‖ ^ 2) ≤ (N : ℝ) rw [heq] calc (∑ n ∈ Finset.Icc (1 : ℤ) N, ‖a n‖ ^ 2) ≤ ∑ _n ∈ Finset.Icc (1 : ℤ) N, (1 : ℝ) := by exact Finset.sum_le_sum (fun n _ => by have := hnorm n; have := norm_nonneg (a n); nlinarith) _ = (N : ℝ) := by simp [Int.card_Icc] have hcorr' (t : ℕ) (ht : t ∈ T) (s : ℕ) (hs : s ∈ T) (hne : t ≠ s) : ‖∑ n ∈ U, z n t * conj (z n s)‖ ≤ E := by let b : ℤ → ℂ := fun n => a (n + ((t : ℤ) - s)) * conj (a n) have hb : ∀ n : ℤ, n ∉ Finset.Icc (1 : ℤ) N → b n = 0 := by intro n hn simp [b, hsupport n hn] have heq := sum_shift_supported b N H s (by omega) (by have := Finset.mem_range.mp hs; omega) hb have hz : (∑ n ∈ U, z n t * conj (z n s)) = ∑ n ∈ U, b (n + s) := by apply Finset.sum_congr rfl intro n hn simp [z, b] rw [hz, heq] apply hcorr · have := Finset.mem_range.mp ht have := Finset.mem_range.mp hs omega · have := Finset.mem_range.mp ht have := Finset.mem_range.mp hs omega · omega have hraw := averaged_columns_correlation_bound U T z (∑ n ∈ Finset.Icc (1 : ℤ) N, a n) N E hcol hdiag hcorr' have hHR : (0 : ℝ) < H := by exact_mod_cast (show 0 < H by omega) simp only [T, Finset.card_range, hcardU] at hraw apply (mul_le_mul_iff_left₀ (sq_pos_of_pos hHR)).mp have hweak : (H : ℝ)^2 * ‖∑ n ∈ Finset.Icc (1 : ℤ) N, a n‖^2 ≤ ((N : ℝ) + H) * ((H : ℝ) * N + (H : ℝ)^2 * E) := by apply hraw.trans apply mul_le_mul_of_nonneg_left _ (by positivity) nlinarith have heq : (((N : ℝ) + H) * ((N : ℝ) / H + E)) * (H : ℝ)^2 = ((N : ℝ) + H) * ((H : ℝ) * N + (H : ℝ)^2 * E) := by field_simp rw [heq] simpa [mul_comm] using hweak
/-- Opposite shifts give conjugate autocorrelations, with zero extension supplying the endpoint cancellation. -/theorem interval_correlation_neg (a : ℤ → ℂ) (N : ℕ) (h : ℤ) (hsupport : ∀ n : ℤ, n ∉ Finset.Icc (1 : ℤ) N → a n = 0) : (∑ n ∈ Finset.Icc (1 : ℤ) N, a (n + -h) * conj (a n)) = conj (∑ n ∈ Finset.Icc (1 : ℤ) N, a (n + h) * conj (a n)) := by classical rw [map_sum] apply Finset.sum_bij_ne_zero (fun n _ _ => n - h) · intro n hn hn0 by_contra hout have hz := hsupport (n - h) hout simp [sub_eq_add_neg] at hz simp [hz] at hn0 · intro n hn hn0 m hm hm0 heq omega · intro n hn hn0 have hmem : n + h ∈ Finset.Icc (1 : ℤ) N := by by_contra hout have hz := hsupport (n + h) hout simp [hz] at hn0 refine ⟨n + h, hmem, ?_, by omega⟩ simpa [map_mul, mul_comm] using hn0 · intro n hn hn0 simp [map_mul, sub_eq_add_neg, mul_comm]
/-- The elementary van der Corput inequality for an interval-supported sequence, in the positive-shift form required for iterated differencing. -/theorem van_der_corput_interval (a : ℤ → ℂ) (N H : ℕ) (hH : 1 ≤ H) (hHN : H ≤ N) (E : ℝ) (hE : 0 ≤ E) (hsupport : ∀ n : ℤ, n ∉ Finset.Icc (1 : ℤ) N → a n = 0) (hnorm : ∀ n : ℤ, ‖a n‖ ≤ 1) (hcorr : ∀ h : ℤ, 0 < h → h < H → ‖∑ n ∈ Finset.Icc (1 : ℤ) N, a (n + h) * conj (a n)‖ ≤ E) : ‖∑ n ∈ Finset.Icc (1 : ℤ) N, a n‖ ^ 2 ≤ 2 * (N : ℝ)^2 / H + 2 * (N : ℝ) * E := by have hsym : ∀ h : ℤ, -(H : ℤ) < h → h < H → h ≠ 0 → ‖∑ n ∈ Finset.Icc (1 : ℤ) N, a (n + h) * conj (a n)‖ ≤ E := by intro h hl hu hn by_cases hp : 0 < h · exact hcorr h hp hu · have hneg : 0 < -h := by omega have hnegb : -h < (H : ℤ) := by omega have heq := interval_correlation_neg a N (-h) hsupport simp only [neg_neg] at heq rw [heq, Complex.norm_conj] exact hcorr (-h) hneg hnegb have hraw := van_der_corput_interval_exact a N H hH E hE hsupport hnorm hsym have hHR : (0 : ℝ) < H := by exact_mod_cast (show 0 < H by omega) have hHNR : (H : ℝ) ≤ N := by exact_mod_cast hHN calc ‖∑ n ∈ Finset.Icc (1 : ℤ) N, a n‖ ^ 2 ≤ ((N : ℝ) + H) * ((N : ℝ) / H + E) := hraw _ ≤ (2 * (N : ℝ)) * ((N : ℝ) / H + E) := by apply mul_le_mul_of_nonneg_right (by linarith) positivity _ = 2 * (N : ℝ)^2 / H + 2 * (N : ℝ) * E := by ring
/-- Normalized van der Corput differencing, with an explicit absolute constant. -/theorem van_der_corput_interval_normalized (a : ℤ → ℂ) (N H : ℕ) (hH : 1 ≤ H) (hHN : H ≤ N) (E : ℝ) (hE : 0 ≤ E) (hsupport : ∀ n : ℤ, n ∉ Finset.Icc (1 : ℤ) N → a n = 0) (hnorm : ∀ n : ℤ, ‖a n‖ ≤ 1) (hcorr : ∀ h : ℤ, 0 < h → h < H → ‖∑ n ∈ Finset.Icc (1 : ℤ) N, a (n + h) * conj (a n)‖ ≤ E) : ‖��� n ∈ Finset.Icc (1 : ℤ) N, a n‖ ^ 2 / (N : ℝ)^2 ≤ 2 / (H : ℝ) + 2 * E / N := by have hNR : (0 : ℝ) < N := by exact_mod_cast (show 0 < N by omega) have hHR : (0 : ℝ) < H := by exact_mod_cast (show 0 < H by omega) apply (div_le_iff₀ (sq_pos_of_pos hNR)).mpr have hraw := van_der_corput_interval a N H hH hHN E hE hsupport hnorm hcorr have heq : (2 / (H : ℝ) + 2 * E / N) * (N : ℝ)^2 = 2 * (N : ℝ)^2 / H + 2 * (N : ℝ) * E := by field_simp rw [heq] exact hraw
end Problem337
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305import Mathlib
namespace OAInoncomputable sectionopen scoped BigOperators
namespace Problem337.VaughanBilinear
/-- The exact correlation expansion of a weighted finite bilinear energy.No distinctness or unit-modulus assumption on the phase is needed. -/theorem energy_identity {α β : Type*} (s : Finset α) (t : Finset β) (b : β → ℂ) (z : α → β → ℂ) : ((∑ m ∈ s, ‖∑ n ∈ t, b n * z m n‖ ^ 2 : ℝ) : ℂ) = ∑ n ∈ t, ∑ k ∈ t, b n * (starRingEnd ℂ) (b k) * ∑ m ∈ s, z m n * (starRingEnd ℂ) (z m k) := by classical have hpoint (m : α) : (‖∑ n ∈ t, b n * z m n‖ ^ 2 : ℂ) = ∑ n ∈ t, ∑ k ∈ t, b n * (starRingEnd ℂ) (b k) * (z m n * (starRingEnd ℂ) (z m k)) := by rw [← Complex.mul_conj'] simp only [map_sum, map_mul, Finset.sum_mul, Finset.mul_sum] rw [Finset.sum_comm] apply Finset.sum_congr rfl intro n hn apply Finset.sum_congr rfl intro k hk ring push_cast simp_rw [hpoint] rw [Finset.sum_comm] apply Finset.sum_congr rfl intro n hn rw [Finset.sum_comm] apply Finset.sum_congr rfl intro k hk rw [Finset.mul_sum]
/-- Bounding a bilinear energy by absolute correlations retains thearithmetic cancellation in the first variable. -/theorem energy_le_correlations {α β : Type*} (s : Finset α) (t : Finset β) (b : β → ℂ) (z : α → β → ℂ) : (∑ m ∈ s, ‖∑ n ∈ t, b n * z m n‖ ^ 2) ≤ ∑ n ∈ t, ∑ k ∈ t, ‖b n‖ * ‖b k‖ * ‖∑ m ∈ s, z m n * (starRingEnd ℂ) (z m k)‖ := by have h := congrArg Complex.re (energy_identity s t b z) simp only [Complex.ofReal_re, Complex.re_sum] at h rw [h] apply Finset.sum_le_sum intro n hn apply Finset.sum_le_sum intro k hk calc _ ≤ ‖b n * (starRingEnd ℂ) (b k) * ∑ m ∈ s, z m n * (starRingEnd ℂ) (z m k)‖ := Complex.re_le_norm _ _ = _ := by simp only [norm_mul, Complex.norm_conj]
/-- Finite Type-II Cauchy--Schwarz, with the full correlation sum explicit.This is an unconditional algebraic bound, not a minor-arc hypothesis. -/theorem norm_bilinear_sq_le {α β : Type*} (s : Finset α) (t : Finset β) (a : α → ℂ) (b : β → ℂ) (z : α → β → ℂ) : ‖∑ m ∈ s, a m * ∑ n ∈ t, b n * z m n‖ ^ 2 ≤ (∑ m ∈ s, ‖a m‖ ^ 2) * (∑ n ∈ t, ∑ k ∈ t, ‖b n‖ * ‖b k‖ * ‖∑ m ∈ s, z m n * (starRingEnd ℂ) (z m k)‖) := by calc _ ≤ (∑ m ∈ s, ‖a m‖ * ‖∑ n ∈ t, b n * z m n‖) ^ 2 := by apply pow_le_pow_left₀ (norm_nonneg _) simpa only [norm_mul] using norm_sum_le s (fun m => a m * ∑ n ∈ t, b n * z m n) _ ≤ (∑ m ∈ s, ‖a m‖ ^ 2) * ∑ m ∈ s, ‖∑ n ∈ t, b n * z m n‖ ^ 2 := Finset.sum_mul_sq_le_sq_mul_sq s _ _ _ ≤ _ := mul_le_mul_of_nonneg_left (energy_le_correlations s t b z) (Finset.sum_nonneg fun _ _ => sq_nonneg _)
/-- For unit phases the diagonal correlation is exactly the number of rows. -/theorem diagonal_correlation {α β : Type*} (s : Finset α) (z : α → β → ℂ) (n : β) (hz : ∀ m ∈ s, ‖z m n‖ = 1) : ‖∑ m ∈ s, z m n * (starRingEnd ℂ) (z m n)‖ = (s.card : ℝ) := by have h : (∑ m ∈ s, z m n * (starRingEnd ℂ) (z m n)) = (s.card : ℂ) := by calc _ = ∑ m ∈ s, (1 : ℂ) := by apply Finset.sum_congr rfl intro m hm rw [Complex.mul_conj', hz m hm] norm_num _ = _ := by simp rw [h, Complex.norm_natCast]
/-- Exact diagonal/off-diagonal separation; erased indices do not count adiagonal pair twice, including when either indexing set is empty. -/theorem correlation_sum_split {α β : Type*} [DecidableEq β] (s : Finset α) (t : Finset β) (z : α → β → ℂ) (hz : ∀ m ∈ s, ∀ n ∈ t, ‖z m n‖ = 1) : (∑ n ∈ t, ∑ k ∈ t, ‖∑ m ∈ s, z m n * (starRingEnd ℂ) (z m k)‖) = (s.card : ℝ) * t.card + ∑ n ∈ t, ∑ k ∈ t.erase n, ‖∑ m ∈ s, z m n * (starRingEnd ℂ) (z m k)‖ := by have hpoint (n : β) (hn : n ∈ t) : (∑ k ∈ t, ‖∑ m ∈ s, z m n * (starRingEnd ℂ) (z m k)‖) = (s.card : ℝ) + ∑ k ∈ t.erase n, ‖∑ m ∈ s, z m n * (starRingEnd ℂ) (z m k)‖ := by rw [← Finset.sum_erase_add (s := t) (fun k => ‖∑ m ∈ s, z m n * (starRingEnd ℂ) (z m k)‖) hn, diagonal_correlation s z n (fun m hm => hz m hm n hn)] ring calc _ = ∑ n ∈ t, ((s.card : ℝ) + ∑ k ∈ t.erase n, ‖∑ m ∈ s, z m n * (starRingEnd ℂ) (z m k)‖) := Finset.sum_congr rfl hpoint _ = _ := by rw [Finset.sum_add_distrib]; simp [mul_comm]
/-- Bounded coefficient version of Type-II Cauchy--Schwarz. The diagonalis evaluated exactly; only genuine off-diagonal correlations remain. -/theorem norm_bilinear_sq_le_offDiagonal {α β : Type*} [DecidableEq β] (s : Finset α) (t : Finset β) (a : α → ℂ) (b : β → ℂ) (z : α → β → ℂ) (B : ℝ) (hB : 0 ≤ B) (hb : ∀ n ∈ t, ‖b n‖ ≤ B) (hz : ∀ m ∈ s, ∀ n ∈ t, ‖z m n‖ = 1) : ‖∑ m ∈ s, a m * ∑ n ∈ t, b n * z m n‖ ^ 2 ≤ (∑ m ∈ s, ‖a m‖ ^ 2) * B ^ 2 * ((s.card : ℝ) * t.card + ∑ n ∈ t, ∑ k ∈ t.erase n, ‖∑ m ∈ s, z m n * (starRingEnd ℂ) (z m k)‖) := by have hbound : (∑ n ∈ t, ∑ k ∈ t, ‖b n‖ * ‖b k‖ * ‖∑ m ∈ s, z m n * (starRingEnd ℂ) (z m k)‖) ≤ B ^ 2 * ∑ n ∈ t, ∑ k ∈ t, ‖∑ m ∈ s, z m n * (starRingEnd ℂ) (z m k)‖ := by simp only [Finset.mul_sum] apply Finset.sum_le_sum intro n hn apply Finset.sum_le_sum intro k hk apply mul_le_mul_of_nonneg_right _ (norm_nonneg _) simpa only [pow_two] using mul_le_mul (hb n hn) (hb k hk) (norm_nonneg _) hB calc _ ≤ _ := norm_bilinear_sq_le s t a b z _ ≤ (∑ m ∈ s, ‖a m‖ ^ 2) * (B ^ 2 * ∑ n ∈ t, ∑ k ∈ t, ‖∑ m ∈ s, z m n * (starRingEnd ℂ) (z m k)‖) := mul_le_mul_of_nonneg_left hbound (Finset.sum_nonneg fun _ _ => sq_nonneg _) _ = _ := by rw [correlation_sum_split s t z hz]; ring
/-- The standard real additive phase, with the `2π` convention. -/def phase (x : ℝ) : ℂ := Real.fourierChar x
@[simp] theorem norm_phase (x : ℝ) : ‖phase x‖ = 1 := Circle.norm_coe _
theorem phase_mul_conj (x y : ℝ) : phase x * (starRingEnd ℂ) (phase y) = phase (x - y) := by unfold phase rw [Circle.starRingEnd_addChar, ← Circle.coe_mul, ← AddChar.map_add_eq_mul] congr 2
theorem phase_nat_mul (x : ℝ) (n : ℕ) : phase (x * n) = phase x ^ n := by unfold phase rw [mul_comm, ← nsmul_eq_mul, AddChar.map_nsmul_eq_pow, Circle.coe_pow]
/-- An exact geometric cancellation bound in a form valid even at resonance. -/theorem phase_sum_mul_bound (x : ℝ) (M : ℕ) : ‖∑ m ∈ Finset.range M, phase (x * m)‖ * ‖1 - phase x‖ ≤ 2 := by simp_rw [phase_nat_mul] rw [← norm_mul, geom_sum_mul_neg] calc ‖1 - phase x ^ M‖ ≤ ‖(1 : ℂ)‖ + ‖phase x ^ M‖ := norm_sub_le _ _ _ = 2 := by simp; norm_num
/-- The usual geometric sum bound away from resonance. -/theorem phase_sum_le_min (x : ℝ) (M : ℕ) (hx : phase x ≠ 1) : ‖∑ m ∈ Finset.range M, phase (x * m)‖ ≤ min (M : ℝ) (2 / ‖1 - phase x‖) := by apply le_min · calc _ ≤ ∑ m ∈ Finset.range M, ‖phase (x * m)‖ := norm_sum_le _ _ _ = M := by simp · have hpos : 0 < ‖1 - phase x‖ := norm_pos_iff.mpr (sub_ne_zero.mpr hx.symm) exact (le_div_iff₀ hpos).mpr (phase_sum_mul_bound x M)
/-- A total geometric majorant. Resonant frequencies use the trivial bound;the definition never interprets division by zero as cancellation. -/def geometricBound (M : ℕ) (x : ℝ) : ℝ := if phase x = 1 then M else min (M : ℝ) (2 / ‖1 - phase x‖)
theorem phase_sum_le_geometricBound (x : ℝ) (M : ℕ) : ‖∑ m ∈ Finset.range M, phase (x * m)‖ ≤ geometricBound M x := by unfold geometricBound split_ifs with hx · simp_rw [phase_nat_mul, hx] simp · exact phase_sum_le_min x M hx
/-- The finite Type-II estimate specialized to a real bilinear phase. Allremaining terms are explicit one-dimensional geometric sums, bounded withoutany Diophantine approximation assumption. -/theorem real_phase_bilinear_sq_le (M : ℕ) (t : Finset ℕ) (a b : ℕ → ℂ) (θ B : ℝ) (hB : 0 ≤ B) (hb : ∀ n ∈ t, ‖b n‖ ≤ B) : ‖∑ m ∈ Finset.range M, a m * ∑ n ∈ t, b n * phase (θ * m * n)‖ ^ 2 ≤ (∑ m ∈ Finset.range M, ‖a m‖ ^ 2) * B ^ 2 * ((M : ℝ) * t.card + ∑ n ∈ t, ∑ k ∈ t.erase n, geometricBound M (θ * ((n : ℝ) - k))) := by have hbase := norm_bilinear_sq_le_offDiagonal (Finset.range M) t a b (fun m n => phase (θ * m * n)) B hB hb (fun m hm n hn => norm_phase _) simp only [Finset.card_range] at hbase refine hbase.trans ?_ apply mul_le_mul_of_nonneg_left _ (mul_nonneg (Finset.sum_nonneg fun _ _ => sq_nonneg _) (sq_nonneg B)) apply add_le_add_right apply Finset.sum_le_sum intro n hn apply Finset.sum_le_sum intro k hk have hcorr : (∑ m ∈ Finset.range M, phase (θ * m * n) * (starRingEnd ℂ) (phase (θ * m * k))) = ∑ m ∈ Finset.range M, phase ((θ * ((n : ℝ) - k)) * m) := by apply Finset.sum_congr rfl intro m hm rw [phase_mul_conj] congr 1 ring rw [hcorr] exact phase_sum_le_geometricBound _ M
/-- A finite real Schur bound, proved by symmetrizing `2xy ≤ x²+y²`.The coefficients need not be nonnegative. -/theorem symmetric_weighted_sum_le {β : Type*} (t : Finset β) (f : β → ℝ) (K : β → β → ℝ) (hK : ∀ n ∈ t, ∀ k ∈ t, 0 ≤ K n k) (hsym : ∀ n ∈ t, ∀ k ∈ t, K n k = K k n) : (∑ n ∈ t, ∑ k ∈ t, f n * f k * K n k) ≤ ∑ n ∈ t, f n ^ 2 * ∑ k ∈ t, K n k := by have hfirst : (∑ n ∈ t, ∑ k ∈ t, f n ^ 2 * K n k) = ∑ n ∈ t, f n ^ 2 * ∑ k ∈ t, K n k := by simp only [Finset.mul_sum] have hsecond : (∑ n ∈ t, ∑ k ∈ t, f k ^ 2 * K n k) = ∑ n ∈ t, f n ^ 2 * ∑ k ∈ t, K n k := by rw [Finset.sum_comm] simp only [Finset.mul_sum] apply Finset.sum_congr rfl intro n hn apply Finset.sum_congr rfl intro k hk rw [hsym k hk n hn] calc _ ≤ ∑ n ∈ t, ∑ k ∈ t, (f n ^ 2 * K n k + f k ^ 2 * K n k) / 2 := by apply Finset.sum_le_sum intro n hn apply Finset.sum_le_sum intro k hk nlinarith [mul_nonneg (sq_nonneg (f n - f k)) (hK n hn k hk)] _ = ((∑ n ∈ t, ∑ k ∈ t, f n ^ 2 * K n k) + (∑ n ∈ t, ∑ k ∈ t, f k ^ 2 * K n k)) / 2 := by simp only [add_div, Finset.sum_div, Finset.sum_add_distrib] _ = _ := by rw [hfirst, hsecond]; ring
/-- Reversing a correlation conjugates it, hence preserves its norm. -/theorem correlation_norm_symm {α β : Type*} (s : Finset α) (z : α → β → ℂ) (n k : β) : ‖∑ m ∈ s, z m n * (starRingEnd ℂ) (z m k)‖ = ‖∑ m ∈ s, z m k * (starRingEnd ℂ) (z m n)‖ := by have hc : (∑ m ∈ s, z m n * (starRingEnd ℂ) (z m k)) = (starRingEnd ℂ) (∑ m ∈ s, z m k * (starRingEnd ℂ) (z m n)) := by simp only [map_sum, map_mul, starRingEnd_self_apply] apply Finset.sum_congr rfl intro m hm ring rw [hc, Complex.norm_conj]
/-- Type-II energy bound using an absolute correlation row bound. Unlike thebounded-coefficient version, this retains both coefficient squared sums andtherefore applies directly to divisor-coefficient second-moment estimates. -/theorem norm_bilinear_sq_le_energy {α β : Type*} (s : Finset α) (t : Finset β) (a : α → ℂ) (b : β → ℂ) (z : α → β → ℂ) (C : ℝ) (hrow : ∀ n ∈ t, (∑ k ∈ t, ‖∑ m ∈ s, z m n * (starRingEnd ℂ) (z m k)‖) ≤ C) : ‖∑ m ∈ s, a m * ∑ n ∈ t, b n * z m n‖ ^ 2 ≤ (∑ m ∈ s, ‖a m‖ ^ 2) * C * (∑ n ∈ t, ‖b n‖ ^ 2) := by have hweight := symmetric_weighted_sum_le t (fun n => ‖b n‖) (fun n k => ‖∑ m ∈ s, z m n * (starRingEnd ℂ) (z m k)‖) (fun _ _ _ _ => norm_nonneg _) (fun n _ k _ => correlation_norm_symm s z n k) have hbound : (∑ n ∈ t, ∑ k ∈ t, ‖b n‖ * ‖b k‖ * ‖∑ m ∈ s, z m n * (starRingEnd ℂ) (z m k)‖) ≤ C * ∑ n ∈ t, ‖b n‖ ^ 2 := by refine hweight.trans ?_ rw [Finset.mul_sum] apply Finset.sum_le_sum intro n hn simpa only [mul_comm] using mul_le_mul_of_nonneg_left (hrow n hn) (sq_nonneg ‖b n‖) calc _ ≤ _ := norm_bilinear_sq_le s t a b z _ ≤ (∑ m ∈ s, ‖a m‖ ^ 2) * (C * ∑ n ∈ t, ‖b n‖ ^ 2) := mul_le_mul_of_nonneg_left hbound (Finset.sum_nonneg fun _ _ => sq_nonneg _) _ = _ := by ring
end Problem337.VaughanBilinear
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192import Mathlib
namespace OAInoncomputable sectionopen Filter
namespace Problem337.Vaughan
/-- The conventional balanced natural cutoff for Vaughan's identity. -/def optimizedCutoff (X : ℝ) : ℕ := ⌊X ^ (2 / 5 : ℝ)⌋₊
theorem optimizedCutoff_le (X : ℝ) (hX : 0 ≤ X) : (optimizedCutoff X : ℝ) ≤ X ^ (2 / 5 : ℝ) := Nat.floor_le (Real.rpow_nonneg hX _)
theorem optimizedCutoff_lower (X : ℝ) (hX : 2 ≤ X ^ (2 / 5 : ℝ)) : X ^ (2 / 5 : ℝ) / 2 ≤ (optimizedCutoff X : ℝ) := by have hfloor := Nat.lt_floor_add_one (X ^ (2 / 5 : ℝ)) unfold optimizedCutoff linarith
theorem optimizedCutoff_pos (X : ℝ) (hX : 2 ≤ X ^ (2 / 5 : ℝ)) : 0 < optimizedCutoff X := by have h : 2 ≤ optimizedCutoff X := Nat.le_floor hX omega
theorem optimizedCutoff_sq_le (X : ℝ) (hX : 0 ≤ X) : (optimizedCutoff X : ℝ) ^ 2 ≤ X ^ (4 / 5 : ℝ) := by have hpow : (X ^ (2 / 5 : ℝ)) ^ 2 = X ^ (4 / 5 : ℝ) := by have h := Real.rpow_mul hX (2 / 5 : ℝ) (2 : ℝ) norm_num at h exact h.symm rw [← hpow] exact pow_le_pow_left₀ (Nat.cast_nonneg _) (optimizedCutoff_le X hX) 2
theorem optimizedCutoff_le_four_fifths (X : ℝ) (hX : 1 ≤ X) : (optimizedCutoff X : ℝ) ≤ X ^ (4 / 5 : ℝ) := (optimizedCutoff_le X (by linarith)).trans (Real.rpow_le_rpow_of_exponent_le hX (by norm_num))
/-- The reciprocal square-root loss from a long-variable cutoff has preciselythe required four-fifths power, with a harmless explicit constant. -/theorem div_sqrt_optimizedCutoff_le (X : ℝ) (hX : 0 < X) (hpow : 2 ≤ X ^ (2 / 5 : ℝ)) : X / Real.sqrt (optimizedCutoff X : ℝ) ≤ 2 * X ^ (4 / 5 : ℝ) := by have hsq : (X ^ (1 / 5 : ℝ)) ^ 2 = X ^ (2 / 5 : ℝ) := by have h := Real.rpow_mul hX.le (1 / 5 : ℝ) (2 : ℝ) norm_num at h exact h.symm have hcut := optimizedCutoff_lower X hpow have hs : X ^ (1 / 5 : ℝ) / 2 ≤ Real.sqrt (optimizedCutoff X : ℝ) := by apply (Real.le_sqrt (by positivity) (Nat.cast_nonneg _)).mpr nlinarith [sq_nonneg (X ^ (1 / 5 : ℝ))] have hpos : 0 < Real.sqrt (optimizedCutoff X : ℝ) := Real.sqrt_pos.mpr (by exact_mod_cast optimizedCutoff_pos X hpow) apply (div_le_iff₀ hpos).mpr have hprod : X ^ (4 / 5 : ℝ) * X ^ (1 / 5 : ℝ) = X := by rw [← Real.rpow_add hX] norm_num calc X = X ^ (4 / 5 : ℝ) * X ^ (1 / 5 : ℝ) := hprod.symm _ = (2 * X ^ (4 / 5 : ℝ)) * (X ^ (1 / 5 : ℝ) / 2) := by ring _ ≤ _ := mul_le_mul_of_nonneg_left hs (by positivity)
/-- A concrete scalar optimization of the cutoff-dependent error terms. -/theorem optimizedCutoff_error_le (X : ℝ) (hX : 1 ≤ X) (hpow : 2 ≤ X ^ (2 / 5 : ℝ)) : (optimizedCutoff X : ℝ) + (optimizedCutoff X : ℝ) ^ 2 + X / Real.sqrt (optimizedCutoff X : ℝ) ≤ 4 * X ^ (4 / 5 : ℝ) := by have h1 := optimizedCutoff_le_four_fifths X hX have h2 := optimizedCutoff_sq_le X (by linarith) have h3 := div_sqrt_optimizedCutoff_le X (by linarith) hpow linarith
/-- The short initial segment is also absorbed by the four-fifths budget. -/theorem optimizedCutoff_log_le (X : ℝ) (hX : 1 ≤ X) (hpow : 2 ≤ X ^ (2 / 5 : ℝ)) : (optimizedCutoff X : ℝ) * Real.log (optimizedCutoff X : ℝ) ≤ X ^ (4 / 5 : ℝ) * Real.log X := by have hUX : (optimizedCutoff X : ℝ) ≤ X := by calc _ ≤ X ^ (2 / 5 : ℝ) := optimizedCutoff_le X (by linarith) _ ≤ X ^ (1 : ℝ) := Real.rpow_le_rpow_of_exponent_le hX (by norm_num) _ = X := Real.rpow_one X have hlog : Real.log (optimizedCutoff X : ℝ) ≤ Real.log X := Real.log_le_log (by exact_mod_cast optimizedCutoff_pos X hpow) hUX have hlogX : 0 ≤ Real.log X := Real.log_nonneg hX exact (mul_le_mul_of_nonneg_left hlog (Nat.cast_nonneg _)).trans (mul_le_mul_of_nonneg_right (optimizedCutoff_le_four_fifths X hX) hlogX)
/-- Scalar normalization to the usual three-term Vaughan envelope. TheDiophantine denominator only needs the ordinary range `1 ≤ q ≤ X`. -/theorem optimizedCutoff_standard_envelope (X q : ℝ) (hX : 1 ≤ X) (hq : 1 ≤ q) (hqX : q ≤ X) (hpow : 2 ≤ X ^ (2 / 5 : ℝ)) : X / q + ((optimizedCutoff X : ℝ) + (optimizedCutoff X : ℝ) ^ 2 + X / Real.sqrt (optimizedCutoff X : ℝ)) + q ≤ 4 * (X / Real.sqrt q + X ^ (4 / 5 : ℝ) + Real.sqrt (X * q)) := by have hX0 : 0 ≤ X := by linarith have hq0 : 0 ≤ q := by linarith have hsqpos : 0 < Real.sqrt q := Real.sqrt_pos.mpr (by linarith) have hsqq : Real.sqrt q ≤ q := Real.sqrt_le_self_iff.mpr (Or.inr hq) have hdiv : X / q ≤ X / Real.sqrt q := div_le_div_of_nonneg_left hX0 hsqpos hsqq have hqsqrt : q ≤ Real.sqrt (X * q) := by apply (Real.le_sqrt hq0 (mul_nonneg hX0 hq0)).mpr nlinarith [mul_le_mul_of_nonneg_right hqX hq0] have herr := optimizedCutoff_error_le X hX hpow have hnonneg : 0 ≤ X / Real.sqrt q := div_nonneg hX0 hsqpos.le nlinarith [Real.sqrt_nonneg (X * q)]
/-- Optimization of the square-root expression arising from a Type II block.Both long-variable cutoffs are the same balanced natural cutoff. -/theorem sqrt_optimizedCutoff_envelope_le (X q : ℝ) (hX : 1 ≤ X) (hq : 0 < q) (hpow : 2 ≤ X ^ (2 / 5 : ℝ)) : Real.sqrt (X * (X / q + X / (optimizedCutoff X : ℝ) + X / (optimizedCutoff X : ℝ) + q)) ≤ 3 * (X / Real.sqrt q + X ^ (4 / 5 : ℝ) + Real.sqrt (X * q)) := by have hX0 : 0 ≤ X := by linarith have hU0 : 0 < (optimizedCutoff X : ℝ) := by exact_mod_cast optimizedCutoff_pos X hpow have hA : 0 ≤ X / Real.sqrt q := by positivity have hB : 0 ≤ X ^ (4 / 5 : ℝ) := by positivity have hC : 0 ≤ Real.sqrt (X * q) := Real.sqrt_nonneg _ have hqeq : X * (X / q) = (X / Real.sqrt q) ^ 2 := by rw [div_pow, Real.sq_sqrt hq.le] ring have hUeq : X * (X / (optimizedCutoff X : ℝ)) = (X / Real.sqrt (optimizedCutoff X : ℝ)) ^ 2 := by rw [div_pow, Real.sq_sqrt hU0.le] ring have hUbound := pow_le_pow_left₀ (show 0 ≤ X / Real.sqrt (optimizedCutoff X : ℝ) by positivity) (div_sqrt_optimizedCutoff_le X (by linarith) hpow) 2 have hCeq := Real.sq_sqrt (mul_nonneg hX0 hq.le) apply (Real.sqrt_le_left (by positivity)).mpr rw [mul_add, mul_add, mul_add, hqeq, hUeq] nlinarith [mul_nonneg hA hB, mul_nonneg hA hC, mul_nonneg hB hC, sq_nonneg (X / Real.sqrt q), sq_nonneg (X ^ (4 / 5 : ℝ)), sq_nonneg (Real.sqrt (X * q))]
/-- The precise squared Type II block budget transfers to the standardVaughan envelope after choosing both cutoffs as `optimizedCutoff X`. -/theorem optimizedCutoff_squared_budget (X q C R : ℝ) (hX : 1 ≤ X) (hq : 0 < q) (hC : 0 ≤ C) (hpow : 2 ≤ X ^ (2 / 5 : ℝ)) (hbound : R ^ 2 ≤ C * X * (1 + Real.log (2 * X)) ^ 6 * (X / q + X / (optimizedCutoff X : ℝ) + X / (optimizedCutoff X : ℝ) + q)) : R ≤ 3 * Real.sqrt C * (1 + Real.log (2 * X)) ^ 3 * (X / Real.sqrt q + X ^ (4 / 5 : ℝ) + Real.sqrt (X * q)) := by let L : ℝ := 1 + Real.log (2 * X) let E : ℝ := X / Real.sqrt q + X ^ (4 / 5 : ℝ) + Real.sqrt (X * q) have hX0 : 0 ≤ X := by linarith have hL : 0 ≤ L := by have := Real.log_nonneg (show (1 : ℝ) ≤ 2 * X by linarith) dsimp [L] linarith have hE : 0 ≤ E := by dsimp [E]; positivity have hD : X * (X / q + X / (optimizedCutoff X : ℝ) + X / (optimizedCutoff X : ℝ) + q) ≤ (3 * E) ^ 2 := (Real.sqrt_le_left (by positivity)).mp (sqrt_optimizedCutoff_envelope_le X q hX hq hpow) change R ≤ 3 * Real.sqrt C * L ^ 3 * E apply le_of_sq_le_sq _ (by positivity) calc R ^ 2 ≤ C * X * L ^ 6 * (X / q + X / (optimizedCutoff X : ℝ) + X / (optimizedCutoff X : ℝ) + q) := hbound _ = (C * L ^ 6) * (X * (X / q + X / (optimizedCutoff X : ℝ) + X / (optimizedCutoff X : ℝ) + q)) := by ring _ ≤ (C * L ^ 6) * (3 * E) ^ 2 := mul_le_mul_of_nonneg_left hD (by positivity) _ = (3 * Real.sqrt C * L ^ 3 * E) ^ 2 := by have hs := Real.sq_sqrt hC calc _ = (3 * E) ^ 2 * L ^ 6 * (Real.sqrt C) ^ 2 := by rw [hs]; ring _ = _ := by ring
/-- All cutoff inequalities hold simultaneously beyond one real threshold. -/theorem eventually_optimizedCutoff_bounds : ∀ᶠ X : ℝ in atTop, 0 < optimizedCutoff X ∧ X ^ (2 / 5 : ℝ) / 2 ≤ (optimizedCutoff X : ℝ) ∧ (optimizedCutoff X : ℝ) ≤ X ^ (2 / 5 : ℝ) ∧ (optimizedCutoff X : ℝ) ^ 2 ≤ X ^ (4 / 5 : ℝ) ∧ X / Real.sqrt (optimizedCutoff X : ℝ) ≤ 2 * X ^ (4 / 5 : ℝ) := by have hlarge := (tendsto_rpow_atTop (by norm_num : (0 : ℝ) < 2 / 5)).eventually (eventually_ge_atTop (2 : ℝ)) filter_upwards [hlarge, eventually_ge_atTop (1 : ℝ)] with X hpow hX exact ⟨optimizedCutoff_pos X hpow, optimizedCutoff_lower X hpow, optimizedCutoff_le X (by linarith), optimizedCutoff_sq_le X (by linarith), div_sqrt_optimizedCutoff_le X (by linarith) hpow⟩
end Problem337.Vaughan
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105import OAI.NumberTheory.EgyptianFractions.VaughanTypeI
namespace OAInoncomputable sectionopen scoped BigOperators ArithmeticFunction ArithmeticFunction.Moebius ArithmeticFunction.zeta
namespace Problem337.Vaughan
/-- Taking a short part restricts a finite weighted sum to the smaller interval. -/theorem weightedSum_shortPart (N V : ℕ) (w : ℕ → ℂ) (f : ArithmeticFunction ℝ) : weightedSum (Finset.Ioc 0 N) w (shortPart V f) = weightedSum (Finset.Ioc 0 (min V N)) w f := by unfold weightedSum calc _ = ∑ n ∈ Finset.Ioc 0 (min V N), (shortPart V f n : ℂ) * w n := by symm apply Finset.sum_subset · intro n hn obtain ⟨hn0, hnVN⟩ := Finset.mem_Ioc.mp hn exact Finset.mem_Ioc.mpr ⟨hn0, (le_min_iff.mp hnVN).2⟩ · intro n hn hnot have hV : ¬ n ≤ V := by simp only [Finset.mem_Ioc] at hn hnot omega simp [hV] _ = _ := by apply Finset.sum_congr rfl intro n hn simp [(le_min_iff.mp (Finset.mem_Ioc.mp hn).2).1]
/-- The initial von Mangoldt segment has the elementary `V log V` bound. -/theorem norm_short_vonMangoldt_sum_le (N V : ℕ) (w : ℕ → ℂ) (hw : ∀ n ∈ Finset.Ioc 0 N, ‖w n‖ ≤ 1) : ‖weightedSum (Finset.Ioc 0 N) w (shortPart V Λ)‖ ≤ (V : ℝ) * Real.log V := by rw [weightedSum_shortPart] unfold weightedSum calc _ ≤ ∑ n ∈ Finset.Ioc 0 (min V N), ‖(Λ n : ℂ) * w n‖ := norm_sum_le _ _ _ ≤ ∑ _n ∈ Finset.Ioc 0 (min V N), Real.log V := by apply Finset.sum_le_sum intro n hn obtain ⟨hn0, hnVN⟩ := Finset.mem_Ioc.mp hn obtain ⟨hnV, hnN⟩ := le_min_iff.mp hnVN rw [norm_mul, Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg ArithmeticFunction.vonMangoldt_nonneg] calc Λ n * ‖w n‖ ≤ Λ n * 1 := mul_le_mul_of_nonneg_left (hw n (Finset.mem_Ioc.mpr ⟨hn0, hnN⟩)) ArithmeticFunction.vonMangoldt_nonneg _ ≤ Real.log n := by simpa using (ArithmeticFunction.vonMangoldt_le_log (n := n)) _ ≤ Real.log V := Real.log_le_log (by exact_mod_cast hn0) (by exact_mod_cast hnV) _ = (min V N : ℕ) * Real.log V := by simp _ ≤ (V : ℝ) * Real.log V := mul_le_mul_of_nonneg_right (by exact_mod_cast min_le_left V N) (Real.log_natCast_nonneg V)
/-- The actual Type II term is a hyperbola with both short factors removed. -/theorem typeII_eq_hyperbola (N U V : ℕ) (w : ℕ → ℂ) : weightedSum (Finset.Ioc 0 N) w (typeIICoefficient U * longPart V Λ) = ∑ d ∈ (hyperbola N).filter (fun d => U < d.1 ∧ V < d.2), (typeIICoefficient U d.1 : ℂ) * (Λ d.2 : ℂ) * w (d.1 * d.2) := by unfold weightedSum rw [← positive_interval N, sum_real_convolution_hyperbola, Finset.sum_filter] apply Finset.sum_congr rfl intro d hd by_cases hU : U < d.1 · by_cases hV : V < d.2 <;> simp [hU, hV] · simp [hU, typeIICoefficient_eq_zero U d.1 (not_lt.mp hU)]
/-- A fully finite Vaughan estimate. Only the displayed elementary inner-sumenvelopes are hypotheses; the remaining Type II sum is retained explicitly. -/theorem norm_vonMangoldt_sum_le (N U V : ℕ) (w : ℕ → ℂ) (B₁ B₂ : ℕ → ℝ) (hw : ∀ n ∈ Finset.Ioc 0 N, ‖w n‖ ≤ 1) (hfirst : ∀ a ∈ Finset.Ioc 0 (min U N), ∀ k ≤ N / a, ‖∑ b ∈ Finset.Ioc 0 k, w (a * b)‖ ≤ B₁ a) (hsecond : ∀ a ∈ Finset.Ioc 0 (min (U * V) N), ‖∑ b ∈ Finset.Ioc 0 (N / a), w (a * b)‖ ≤ B₂ a) : ‖weightedSum (Finset.Ioc 0 N) w Λ‖ ≤ (V : ℝ) * Real.log V + 2 * Real.log N * (∑ a ∈ Finset.Ioc 0 (min U N), B₁ a) + Real.log N * (∑ a ∈ Finset.Ioc 0 (min (U * V) N), B₂ a) + ‖∑ d ∈ (hyperbola N).filter (fun d => U < d.1 ∧ V < d.2), (typeIICoefficient U d.1 : ℂ) * (Λ d.2 : ℂ) * w (d.1 * d.2)‖ := by have h0 := norm_short_vonMangoldt_sum_le N V w hw have h1 := first_typeI_bound w N U B₁ hfirst have h2 := second_typeI_bound w N U V B₂ hsecond rw [weighted_identity (Finset.Ioc 0 N) w U V] calc _ ≤ (‖weightedSum (Finset.Ioc 0 N) w (shortPart V Λ)‖ + ‖weightedSum (Finset.Ioc 0 N) w (shortPart U (μ : ArithmeticFunction ℝ) * ArithmeticFunction.log)‖) + ‖weightedSum (Finset.Ioc 0 N) w (typeICoefficient U V * ζ)‖ + ‖weightedSum (Finset.Ioc 0 N) w (typeIICoefficient U * longPart V Λ)‖ := by apply (norm_add_le _ _).trans apply add_le_add _ le_rfl apply (norm_sub_le _ _).trans exact add_le_add (norm_add_le _ _) le_rfl _ ≤ _ := by rw [typeII_eq_hyperbola] exact add_le_add (add_le_add (add_le_add h0 h1) h2) le_rfl
end Problem337.Vaughan
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152import Mathlib
namespace OAI/-!# Exact dyadic decomposition of a truncated hyperbola
The long--long convolution is partitioned into genuine dyadic row intervals.Each column interval is shortened to `N / 2^j`, retaining the exact `mn ≤ N`cutoff. This is a finite reindexing, with no analytic cancellation hypothesis.-/
noncomputable sectionopen scoped BigOperatorsopen Finset
namespace Problem337.VaughanDyadic
/-- Rows above the lower cutoff, inside one half-open power-of-two interval. -/def shell (U N j : ℕ) : Finset ℕ := (Ioc U N).filter fun m => 2 ^ j ≤ m ∧ m < 2 ^ (j + 1)
lemma mem_shell {U N j m : ℕ} : m ∈ shell U N j ↔ U < m ∧ m ≤ N ∧ 2 ^ j ≤ m ∧ m < 2 ^ (j + 1) := by simp only [shell, mem_filter, mem_Ioc] tauto
lemma shell_eq_log_fiber (U N j : ℕ) : shell U N j = (Ioc U N).filter (fun m => Nat.log 2 m = j) := by ext m simp only [shell, mem_filter] apply and_congr_right intro hm exact (Nat.log_eq_iff (Or.inr ⟨by decide, (lt_of_le_of_lt (Nat.zero_le U) (mem_Ioc.mp hm).1).ne'⟩)).symm
/-- The shell is a single consecutive interval, so its phase correlations remain geometric. -/lemma shell_eq_Icc (U N j : ℕ) : shell U N j = Icc (max (U + 1) (2 ^ j)) (min N (2 ^ (j + 1) - 1)) := by ext m rw [mem_shell] simp only [mem_Icc, max_le_iff, le_min_iff] have hp : 0 < 2 ^ (j + 1) := by positivity omega
/-- Exact partition, valid also when the original interval is empty. -/theorem sum_eq_sum_shells {E : Type*} [AddCommMonoid E] (U N : ℕ) (f : ℕ → E) : (∑ m ∈ Ioc U N, f m) = ∑ j ∈ range (Nat.log 2 N + 1), ∑ m ∈ shell U N j, f m := by simp_rw [shell_eq_log_fiber] apply (sum_fiberwise_of_maps_to ?_ f).symm intro m hm exact mem_range.mpr (Nat.lt_succ_of_le (Nat.log_mono_right (mem_Ioc.mp hm).2))
lemma inner_sum_eq_common_cutoff {E : Type*} [AddCommMonoid E] (N U V j m : ℕ) (hm : m ∈ shell U N j) (f : ℕ → E) : (∑ n ∈ Ioc V (N / m), f n) = ∑ n ∈ Ioc V (N / 2 ^ j), if m * n ≤ N then f n else 0 := by have hmem := mem_shell.mp hm have hm0 : 0 < m := lt_of_le_of_lt (Nat.zero_le U) hmem.1 have hpow : 0 < 2 ^ j := by positivity have hdiv : N / m ≤ N / 2 ^ j := Nat.div_le_div_left hmem.2.2.1 hpow have hsets : Ioc V (N / m) = (Ioc V (N / 2 ^ j)).filter (fun n => m * n ≤ N) := by ext n simp only [mem_Ioc, mem_filter] constructor · rintro ⟨hV, hn⟩ exact ⟨⟨hV, hn.trans hdiv⟩, by simpa [Nat.mul_comm] using (Nat.le_div_iff_mul_le hm0).mp hn⟩ · rintro ⟨⟨hV, _⟩, hn⟩ exact ⟨hV, (Nat.le_div_iff_mul_le hm0).mpr (by simpa [Nat.mul_comm] using hn)⟩ rw [hsets, sum_filter]
/-- The actual dyadic block, not a rectangular surrogate without the cutoff. -/def block {E : Type*} [AddCommMonoid E] (N U V j : ℕ) (F : ℕ → ℕ → E) : E := ∑ m ∈ shell U N j, ∑ n ∈ Ioc V (N / 2 ^ j), if m * n ≤ N then F m n else 0
/-- Exact long--long hyperbola decomposition into common-column dyadic blocks. -/theorem sum_hyperbola_eq_sum_blocks {E : Type*} [AddCommMonoid E] (N U V : ℕ) (F : ℕ → ℕ → E) : (∑ m ∈ Ioc U N, ∑ n ∈ Ioc V (N / m), F m n) = ∑ j ∈ range (Nat.log 2 N + 1), block N U V j F := by rw [sum_eq_sum_shells] apply sum_congr rfl intro j hj unfold block apply sum_congr rfl intro m hm exact inner_sum_eq_common_cutoff N U V j m hm (F m)
/-- Product-finset form of the same exact decomposition. -/theorem sum_filtered_product_eq_sum_blocks {E : Type*} [AddCommMonoid E] (N U V : ℕ) (F : ℕ → ℕ → E) : (∑ d ∈ (Ioc U N ×ˢ Ioc V N).filter (fun d => d.1 * d.2 ≤ N), F d.1 d.2) = ∑ j ∈ range (Nat.log 2 N + 1), block N U V j F := by rw [← sum_hyperbola_eq_sum_blocks, sum_filter, sum_product] apply sum_congr rfl intro m hm have hm0 : 0 < m := lt_of_le_of_lt (Nat.zero_le U) (mem_Ioc.mp hm).1 rw [← sum_filter] have he : (Ioc V N).filter (fun n => m * n ≤ N) = Ioc V (N / m) := by ext n simp only [mem_filter, mem_Ioc] constructor · rintro ⟨⟨hV, _⟩, hmn⟩ exact ⟨hV, (Nat.le_div_iff_mul_le hm0).mpr (by simpa [Nat.mul_comm] using hmn)⟩ · rintro ⟨hV, hn⟩ exact ⟨⟨hV, hn.trans (Nat.div_le_self N m)⟩, by simpa [Nat.mul_comm] using (Nat.le_div_iff_mul_le hm0).mp hn⟩ rw [he]
/-- Triangle inequality with the actual dyadic block norms. -/theorem norm_hyperbola_le_sum_block_norms {E : Type*} [SeminormedAddCommGroup E] (N U V : ℕ) (F : ℕ → ℕ → E) : ‖∑ m ∈ Ioc U N, ∑ n ∈ Ioc V (N / m), F m n‖ ≤ ∑ j ∈ range (Nat.log 2 N + 1), ‖block N U V j F‖ := by rw [sum_hyperbola_eq_sum_blocks] exact norm_sum_le _ _
/-- Any genuine uniform block estimate pays only the number of dyadic blocks. -/theorem norm_hyperbola_le_block_count {E : Type*} [SeminormedAddCommGroup E] (N U V : ℕ) (F : ℕ → ℕ → E) (B : ℝ) (hB : ∀ j < Nat.log 2 N + 1, ‖block N U V j F‖ ≤ B) : ‖∑ m ∈ Ioc U N, ∑ n ∈ Ioc V (N / m), F m n‖ ≤ (Nat.log 2 N + 1 : ℕ) * B := by calc _ ≤ ∑ j ∈ range (Nat.log 2 N + 1), ‖block N U V j F‖ := norm_hyperbola_le_sum_block_norms N U V F _ ≤ ∑ j ∈ range (Nat.log 2 N + 1), B := sum_le_sum fun j hj => hB j (mem_range.mp hj) _ = _ := by simp
/-- Real-log normalization of the finite dyadic block count. -/theorem norm_hyperbola_le_log_budget {E : Type*} [SeminormedAddCommGroup E] (N U V : ℕ) (F : ℕ → ℕ → E) (B : ℝ) (hB0 : 0 ≤ B) (hB : ∀ j < Nat.log 2 N + 1, ‖block N U V j F‖ ≤ B) : ‖∑ m ∈ Ioc U N, ∑ n ∈ Ioc V (N / m), F m n‖ ≤ (1 + Real.log N / Real.log 2) * B := by refine (norm_hyperbola_le_block_count N U V F B hB).trans ?_ apply mul_le_mul_of_nonneg_right _ hB0 have h := Real.natLog_le_logb N 2 simp only [Real.logb, Nat.cast_ofNat] at h push_cast linarith
end Problem337.VaughanDyadic
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596import OAI.NumberTheory.EgyptianFractions.VaughanDyadicimport OAI.NumberTheory.EgyptianFractions.VaughanDecompositionimport OAI.NumberTheory.EgyptianFractions.DivisorSquareMean
namespace OAInoncomputable sectionopen scoped BigOperators ArithmeticFunction ArithmeticFunction.Moebius ArithmeticFunction.zetaopen Finset
namespace Problem337.Vaughan
lemma long_hyperbola_eq_filtered_product (N U V : ℕ) : (hyperbola N).filter (fun d => U < d.1 ∧ V < d.2) = (Ioc U N ×ˢ Ioc V N).filter (fun d => d.1 * d.2 ≤ N) := by ext d rcases d with ⟨a, b⟩ simp only [mem_filter, mem_hyperbola, mem_product, mem_Ioc] constructor · rintro ⟨⟨ha, hb, hp⟩, hU, hV⟩ exact ⟨⟨⟨hU, (Nat.le_mul_of_pos_right a hb).trans hp⟩, ⟨hV, (Nat.le_mul_of_pos_left b ha).trans hp⟩⟩, hp⟩ · rintro ⟨⟨⟨hU, ha⟩, ⟨hV, hb⟩⟩, hp⟩ exact ⟨⟨by omega, by omega, hp⟩, hU, hV⟩
/-- The dyadic block with the actual arithmetic coefficients in Vaughan's identity. -/def typeIIBlock (N U V j : ℕ) (w : ℕ → ℂ) : ℂ := VaughanDyadic.block N U V j (fun m n => (typeIICoefficient U m : ℂ) * (Λ n : ℂ) * w (m * n))
/-- No arithmetic coefficient or hyperbolic cutoff is lost in dyadic decomposition. -/theorem typeII_eq_sum_dyadic_blocks (N U V : ℕ) (w : ℕ → ℂ) : weightedSum (Ioc 0 N) w (typeIICoefficient U * longPart V Λ) = ∑ j ∈ range (Nat.log 2 N + 1), typeIIBlock N U V j w := by rw [typeII_eq_hyperbola, long_hyperbola_eq_filtered_product] exact VaughanDyadic.sum_filtered_product_eq_sum_blocks (E := ℂ) N U V (fun m n => (typeIICoefficient U m : ℂ) * (Λ n : ℂ) * w (m * n))
theorem norm_typeII_le_sum_dyadic_blocks (N U V : ℕ) (w : ℕ → ℂ) : ‖weightedSum (Ioc 0 N) w (typeIICoefficient U * longPart V Λ)‖ ≤ ∑ j ∈ range (Nat.log 2 N + 1), ‖typeIIBlock N U V j w‖ := by rw [typeII_eq_sum_dyadic_blocks] exact norm_sum_le _ _
/-- A genuine uniform block bound has only a logarithmic decomposition cost. -/theorem norm_typeII_le_dyadic_log_budget (N U V : ℕ) (w : ℕ → ℂ) (B : ℝ) (hB0 : 0 ≤ B) (hB : ∀ j < Nat.log 2 N + 1, ‖typeIIBlock N U V j w‖ ≤ B) : ‖weightedSum (Ioc 0 N) w (typeIICoefficient U * longPart V Λ)‖ ≤ (1 + Real.log N / Real.log 2) * B := by let F : ℕ → ℕ → ℂ := fun m n => (typeIICoefficient U m : ℂ) * (Λ n : ℂ) * w (m * n) have he : weightedSum (Ioc 0 N) w (typeIICoefficient U * longPart V Λ) = ∑ m ∈ Ioc U N, ∑ n ∈ Ioc V (N / m), F m n := by rw [typeII_eq_sum_dyadic_blocks, VaughanDyadic.sum_hyperbola_eq_sum_blocks] rfl rw [he] exact VaughanDyadic.norm_hyperbola_le_log_budget N U V F B hB0 hB
/-- The complete finite Vaughan envelope, with its Type II term split intoactual dyadic blocks ready for interval correlation estimates. -/theorem norm_vonMangoldt_sum_le_dyadic (N U V : ℕ) (w : ℕ → ℂ) (B₁ B₂ : ℕ → ℝ) (hw : ∀ n ∈ Ioc 0 N, ‖w n‖ ≤ 1) (hfirst : ∀ a ∈ Ioc 0 (min U N), ∀ k ≤ N / a, ‖∑ b ∈ Ioc 0 k, w (a * b)‖ ≤ B₁ a) (hsecond : ∀ a ∈ Ioc 0 (min (U * V) N), ‖∑ b ∈ Ioc 0 (N / a), w (a * b)‖ ≤ B₂ a) : ‖weightedSum (Ioc 0 N) w Λ‖ ≤ (V : ℝ) * Real.log V + 2 * Real.log N * (∑ a ∈ Ioc 0 (min U N), B₁ a) + Real.log N * (∑ a ∈ Ioc 0 (min (U * V) N), B₂ a) + ∑ j ∈ range (Nat.log 2 N + 1), ‖typeIIBlock N U V j w‖ := by have h := norm_vonMangoldt_sum_le N U V w B₁ B₂ hw hfirst hsecond rw [← typeII_eq_hyperbola] at h exact h.trans (add_le_add le_rfl (norm_typeII_le_sum_dyadic_blocks N U V w))
/-- Sharp unconditional row energy for the actual Type II coefficient in a dyadic shell. -/theorem typeII_shell_energy_le (N U j : ℕ) : (∑ m ∈ VaughanDyadic.shell U N j, ‖(typeIICoefficient U m : ℂ)‖ ^ 2) ≤ (2 ^ (j + 1) : ℕ) * (1 + Real.log (2 ^ (j + 1) : ℕ)) ^ 3 := by have hT : VaughanDyadic.shell U N j ⊆ Ioc 0 (2 ^ (j + 1)) := by intro m hm have h := VaughanDyadic.mem_shell.mp hm exact mem_Ioc.mpr ⟨lt_of_le_of_lt (Nat.zero_le U) h.1, h.2.2.2.le⟩ have h := DivisorSquareMean.sum_norm_sq_le_log_of_subset (fun m => (typeIICoefficient U m : ℂ)) (VaughanDyadic.shell U N j) (2 ^ (j + 1)) 1 hT (by intro m hm simpa only [Complex.norm_real, Real.norm_eq_abs, one_mul] using abs_typeIICoefficient_le_divisors_card U m) simpa only [one_pow, one_mul] using h
end Problem337.Vaughan
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596import OAI.NumberTheory.EgyptianFractions.VaughanDyadicDecompositionimport OAI.NumberTheory.EgyptianFractions.VaughanHyperbolicNearRational
namespace OAInoncomputable sectionopen scoped BigOperators ArithmeticFunctionopen Finset
namespace Problem337.Vaughan
lemma typeIIBlock_eq_bilinear (θ : ℝ) (N U V j : ℕ) : typeIIBlock N U V j (fun k => VaughanBilinear.phase (θ * k)) = ∑ m ∈ Icc (max (U + 1) (2 ^ j)) (min N (2 ^ (j + 1) - 1)), (typeIICoefficient U m : ℂ) * ∑ n ∈ Ioc V (N / 2 ^ j), (Λ n : ℂ) * HyperbolaCorrelation.column θ N n m := by unfold typeIIBlock VaughanDyadic.block rw [VaughanDyadic.shell_eq_Icc] apply sum_congr rfl intro m hm rw [mul_sum] apply sum_congr rfl intro n hn unfold HyperbolaCorrelation.column by_cases h : m * n ≤ N · simp only [ite_eq_left h, HyperbolaCorrelation.phase_eq_vaughan] rw [mul_assoc] congr 2 congr 1 push_cast ring · simp [h]
lemma dyadic_row_length_le (N U j : ℕ) : min N (2 ^ (j + 1) - 1) + 1 - max (U + 1) (2 ^ j) ≤ 2 ^ j := by have htop : min N (2 ^ (j + 1) - 1) ≤ 2 ^ (j + 1) - 1 := min_le_right _ _ have hlow : 2 ^ j ≤ max (U + 1) (2 ^ j) := le_max_right _ _ have hp : 0 < 2 ^ j := by positivity rw [pow_succ] at htop omega
/-- The elementary bounded-weight column energy, used only as a normalizationinside the actual Type II block estimate. -/lemma mangoldt_column_energy_le (V T : ℕ) : (∑ n ∈ Ioc V T, ‖(Λ n : ℂ)‖ ^ 2) ≤ (T : ℝ) * (Real.log T) ^ 2 := by calc _ ≤ ∑ n ∈ Ioc V T, (Real.log T) ^ 2 := by apply sum_le_sum intro n hn have h := mem_Ioc.mp hn have hn0 : 0 < n := lt_of_le_of_lt (Nat.zero_le V) h.1 apply pow_le_pow_left₀ (norm_nonneg _) rw [Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg ArithmeticFunction.vonMangoldt_nonneg] exact ArithmeticFunction.vonMangoldt_le_log.trans (Real.log_le_log (by exact_mod_cast hn0) (by exact_mod_cast h.2)) _ = ((T - V : ℕ) : ℝ) * (Real.log T) ^ 2 := by simp _ ≤ _ := mul_le_mul_of_nonneg_right (by exact_mod_cast Nat.sub_le T V) (sq_nonneg _)
/-- A genuine rational-approximation estimate for one actual Vaughan block.All coefficient energies and correlations have been evaluated explicitly. -/theorem typeIIBlock_sq_le_raw (θ : ℝ) (a : ℤ) (q : ℕ) (hq : 0 < q) (hcop : IsCoprime a (q : ℤ)) (happrox : |θ - (a : ℝ) / q| ≤ 1 / (q : ℝ) ^ 2) (N U V j : ℕ) : ‖typeIIBlock N U V j (fun k => VaughanBilinear.phase (θ * k))‖ ^ 2 ≤ ((2 ^ (j + 1) : ℕ) * (1 + Real.log (2 ^ (j + 1) : ℕ)) ^ 3) * ((2 * ((N / 2 ^ j : ℕ) : ℝ) / q + 1) * (2 * ((2 ^ j : ℕ) : ℝ) + 4 * (q : ℝ) * (1 + Real.log (2 * (q : ℝ))))) * (((N / 2 ^ j : ℕ) : ℝ) * (Real.log (N / 2 ^ j : ℕ)) ^ 2) := by have hlog : 0 ≤ 1 + Real.log (2 * (q : ℝ)) := by have hq1 : (1 : ℝ) ≤ q := by exact_mod_cast hq have h := Real.log_nonneg (show (1 : ℝ) ≤ 2 * q by linarith) linarith have h := VaughanBilinear.near_rational_hyperbolic_bilinear_sq_le θ a q hq hcop happrox N (max (U + 1) (2 ^ j)) (min N (2 ^ (j + 1) - 1)) (V + 1) (N / 2 ^ j) (Ioc V (N / 2 ^ j)) (by intro n hn have hn' := mem_Ioc.mp hn exact mem_Ico.mpr ⟨by omega, by omega⟩) (fun n hn => lt_of_le_of_lt (Nat.zero_le V) (mem_Ioc.mp hn).1) (fun m => (typeIICoefficient U m : ℂ)) (fun n => (Λ n : ℂ)) rw [← typeIIBlock_eq_bilinear, ← VaughanDyadic.shell_eq_Icc] at h refine h.trans ?_ have hA := typeII_shell_energy_le N U j have hB := mangoldt_column_energy_le V (N / 2 ^ j) have hlength : ((min N (2 ^ (j + 1) - 1) + 1 - max (U + 1) (2 ^ j) : ℕ) : ℝ) ≤ ((2 ^ j : ℕ) : ℝ) := by exact_mod_cast dyadic_row_length_le N U j gcongr
end Problem337.Vaughan
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127import OAI.NumberTheory.EgyptianFractions.VaughanDyadicEstimateimport OAI.NumberTheory.EgyptianFractions.TypeIIBlockScalarimport OAI.NumberTheory.EgyptianFractions.HyperbolaDyadicBridge
namespace OAInoncomputable sectionopen scoped BigOperators ArithmeticFunctionopen Finset
namespace Problem337.Vaughan
def typeIILogScale (N : ℕ) : ℝ := 1 + Real.log (2 * (N : ℝ))
lemma one_le_typeIILogScale (N : ℕ) : 1 ≤ typeIILogScale N := by have h := Real.log_natCast_nonneg (2 * N) simp only [Nat.cast_mul, Nat.cast_ofNat] at h unfold typeIILogScale linarith
lemma log_nat_le_typeIILogScale (N T : ℕ) (hT : T ≤ N) : Real.log T ≤ typeIILogScale N := by by_cases h0 : T = 0 · simp only [h0, Nat.cast_zero, Real.log_zero] exact zero_le_one.trans (one_le_typeIILogScale N) have ht : (0 : ℝ) < T := by exact_mod_cast Nat.pos_of_ne_zero h0 have htn : (T : ℝ) ≤ 2 * (N : ℝ) := by have h := (Nat.cast_le (α := ℝ)).mpr hT nlinarith [Nat.cast_nonneg N (α := ℝ)] have hlog := Real.log_le_log ht htn unfold typeIILogScale linarith
/-- Uniform logarithmic normalization of the coefficient block estimate. -/theorem typeIIBlock_sq_le_normalized (θ : ℝ) (a : ℤ) (q : ℕ) (hq : 0 < q) (hcop : IsCoprime a (q : ℤ)) (happrox : |θ - (a : ℝ) / q| ≤ 1 / (q : ℝ) ^ 2) (N U V j : ℕ) (hqN : q ≤ N) (hM : 2 ^ j ≤ N) : ‖typeIIBlock N U V j (fun k => VaughanBilinear.phase (θ * k))‖ ^ 2 ≤ (2 * ((2 ^ j : ℕ) : ℝ) * (typeIILogScale N) ^ 3) * ((2 * ((N / 2 ^ j : ℕ) : ℝ) / q + 1) * (2 * ((2 ^ j : ℕ) : ℝ) + 4 * (q : ℝ) * typeIILogScale N)) * (((N / 2 ^ j : ℕ) : ℝ) * (typeIILogScale N) ^ 2) := by have hH0 : 0 ≤ typeIILogScale N := zero_le_one.trans (one_le_typeIILogScale N) have hqR : (0 : ℝ) < q := by exact_mod_cast hq have hMR : (0 : ℝ) < ((2 ^ j : ℕ) : ℝ) := by positivity have hqlog : 1 + Real.log (2 * (q : ℝ)) ≤ typeIILogScale N := by unfold typeIILogScale apply add_le_add le_rfl exact Real.log_le_log (by positivity) (by exact_mod_cast Nat.mul_le_mul_left 2 hqN) have hMlog : 1 + Real.log (2 ^ (j + 1) : ℕ) ≤ typeIILogScale N := by unfold typeIILogScale apply add_le_add le_rfl apply Real.log_le_log (by positivity) rw [pow_succ, Nat.cast_mul, Nat.cast_ofNat] have hMRN : ((2 ^ j : ℕ) : ℝ) ≤ N := by exact_mod_cast hM nlinarith have hTlog := log_nat_le_typeIILogScale N (N / 2 ^ j) (Nat.div_le_self _ _) have hraw := typeIIBlock_sq_le_raw θ a q hq hcop happrox N U V j refine hraw.trans ?_ have hqlog0 : 0 ≤ 1 + Real.log (2 * (q : ℝ)) := by have h := Real.log_natCast_nonneg (2 * q) simp only [Nat.cast_mul, Nat.cast_ofNat] at h linarith have hMlog0 : 0 ≤ 1 + Real.log (2 ^ (j + 1) : ℕ) := by linarith [Real.log_natCast_nonneg (2 ^ (j + 1))] have hTlog0 := Real.log_natCast_nonneg (N / 2 ^ j) have he : ((2 ^ (j + 1) : ℕ) : ℝ) = 2 * ((2 ^ j : ℕ) : ℝ) := by rw [pow_succ, Nat.cast_mul, Nat.cast_ofNat] ring rw [he] at hMlog hMlog0 ⊢ gcongr
/-- Uniform actual Type II block bound, with no cancellation or energy premise. -/theorem typeIIBlock_sq_le_uniform (θ : ℝ) (a : ℤ) (q : ℕ) (hq : 0 < q) (hcop : IsCoprime a (q : ℤ)) (happrox : |θ - (a : ℝ) / q| ≤ 1 / (q : ℝ) ^ 2) (N U V j : ℕ) (hqN : q ≤ N) (hU : 0 < U) (hV : 0 < V) : ‖typeIIBlock N U V j (fun k => VaughanBilinear.phase (θ * k))‖ ^ 2 ≤ 32 * (N : ℝ) * (typeIILogScale N) ^ 6 * ((N : ℝ) / q + (N : ℝ) / U + (N : ℝ) / V + q) := by have hH : 0 ≤ typeIILogScale N := zero_le_one.trans (one_le_typeIILogScale N) by_cases hb : typeIIBlock N U V j (fun k => VaughanBilinear.phase (θ * k)) = 0 · rw [hb, norm_zero, zero_pow (by decide : 2 ≠ 0)] positivity have hs : (VaughanDyadic.shell U N j).Nonempty := by by_contra he have he' : VaughanDyadic.shell U N j = ∅ := not_nonempty_iff_eq_empty.mp he apply hb simp [typeIIBlock, VaughanDyadic.block, he'] obtain ⟨m, hm⟩ := hs have hm' := VaughanDyadic.mem_shell.mp hm have hM : 2 ^ j ≤ N := hm'.2.2.1.trans hm'.2.1 have hbase := VaughanDyadic.base_le_div_of_block_ne_zero N U V j (fun m n => (typeIICoefficient U m : ℂ) * (Λ n : ℂ) * VaughanBilinear.phase (θ * (m * n : ℕ))) hb have hMT : (((2 ^ j : ℕ) : ℝ) * ((N / 2 ^ j : ℕ) : ℝ)) ≤ N := by exact_mod_cast Nat.mul_div_le N (2 ^ j) have hU2M : (U : ℝ) ≤ 2 * ((2 ^ j : ℕ) : ℝ) := by have hnat : U ≤ 2 * 2 ^ j := by have hu := hm'.1 have hmhi := hm'.2.2.2 rw [pow_succ] at hmhi omega exact_mod_cast hnat have hTU : ((N / 2 ^ j : ℕ) : ℝ) ≤ 2 * (N : ℝ) / U := by apply (le_div_iff₀ (by exact_mod_cast hU : (0 : ℝ) < U)).mpr nlinarith [mul_le_mul_of_nonneg_left hU2M (Nat.cast_nonneg (N / 2 ^ j) : (0 : ℝ) ≤ (N / 2 ^ j : ℕ))] have hMV : ((2 ^ j : ℕ) : ℝ) ≤ (N : ℝ) / V := by apply (le_div_iff₀ (by exact_mod_cast hV : (0 : ℝ) < V)).mpr have hn : 2 ^ j * V ≤ N := (Nat.mul_le_mul_left (2 ^ j) (Nat.le_succ V)).trans ((Nat.le_div_iff_mul_le (Nat.succ_pos V)).mp hbase) exact_mod_cast hn exact (typeIIBlock_sq_le_normalized θ a q hq hcop happrox N U V j hqN hM).trans (TypeIIBlockScalar.block_bound N (2 ^ j : ℕ) (N / 2 ^ j : ℕ) q U V (typeIILogScale N) (Nat.cast_nonneg N) (by positivity) (Nat.cast_nonneg _) (by exact_mod_cast hq) (by exact_mod_cast hU) (by exact_mod_cast hV) (one_le_typeIILogScale N) hMT hTU hMV)
end Problem337.Vaughan
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140import OAI.NumberTheory.EgyptianFractions.VaughanOptimizedimport OAI.NumberTheory.EgyptianFractions.VaughanTypeINormalized
namespace OAInoncomputable sectionopen scoped BigOperators ArithmeticFunction ArithmeticFunction.Moebius ArithmeticFunction.zeta
namespace Problem337.Vaughan
lemma realPhase_eq_bilinear_phase (x : ℝ) : RealPhase.phase x = VaughanBilinear.phase x := (VaughanBilinear.phase_eq_geometric_phase x).symm
lemma optimized_typeI_scales (X q : ℝ) (hX : 1 ≤ X) (hq : 1 ≤ q) (hqX : q ≤ X) (hpow : 2 ≤ X ^ (2 / 5 : ℝ)) : X / q + (optimizedCutoff X : ℝ) + q ≤ 4 * approximationEnvelope X q ∧ X / q + (optimizedCutoff X : ℝ) ^ 2 + q ≤ 4 * approximationEnvelope X q := by have hs := optimizedCutoff_standard_envelope X q hX hq hqX hpow have hdiv : 0 ≤ X / Real.sqrt (optimizedCutoff X : ℝ) := by positivity change _ ≤ 4 * approximationEnvelope X q at hs constructor <;> nlinarith [Nat.cast_nonneg (optimizedCutoff X) (α := ℝ), sq_nonneg (optimizedCutoff X : ℝ)]
/-- An explicit classical Vaughan estimate for the actual von Mangoldtexponential sum. The only analytic input is a reduced rational approximation;all Type I and Type II cancellation estimates have been proved above. -/theorem vonMangoldt_sum_bound (θ : ℝ) (a : ℤ) (q : ℕ) (hq : 0 < q) (hcop : IsCoprime a (q : ℤ)) (happrox : |θ - (a : ℝ) / q| ≤ 1 / (q : ℝ) ^ 2) (N : ℕ) (hqN : q ≤ N) (hpow : 2 ≤ (N : ℝ) ^ (2 / 5 : ℝ)) : ‖weightedSum (Finset.Ioc 0 N) (fun k => VaughanBilinear.phase (θ * k)) Λ‖ ≤ 200 * (typeIILogScale N) ^ 4 * approximationEnvelope N q := by let U := optimizedCutoff (N : ℝ) let w : ℕ → ℂ := fun k => VaughanBilinear.phase (θ * k) let H := typeIILogScale N let E := approximationEnvelope (N : ℝ) q have hN : 1 ≤ N := hq.trans_le hqN have hNr : (1 : ℝ) ≤ N := by exact_mod_cast hN have hqr : (1 : ℝ) ≤ q := by exact_mod_cast hq have hqNr : (q : ℝ) ≤ N := by exact_mod_cast hqN have hH : 1 ≤ H := one_le_typeIILogScale N have hH0 : 0 ≤ H := zero_le_one.trans hH have hE : 0 ≤ E := approximationEnvelope_nonneg N q (Nat.cast_nonneg N) have hH14 : H ≤ H ^ 4 := by simpa using (pow_le_pow_right₀ hH (show 1 ≤ 4 by omega)) have hH24 : H ^ 2 ≤ H ^ 4 := pow_le_pow_right₀ hH (by omega) have hcost := optimized_typeI_scales N q hNr hqr hqNr hpow have hfirst := VaughanHyperbolic.first_typeI_normalized_bound θ a q hq hcop happrox N U hN hqN have hsecond := VaughanHyperbolic.second_typeI_normalized_bound θ a q hq hcop happrox N U U hN hqN simp only [realPhase_eq_bilinear_phase] at hfirst hsecond have h1 : ‖weightedSum (Finset.Ioc 0 N) w (shortPart U (μ : ArithmeticFunction ℝ) * ArithmeticFunction.log)‖ ≤ 64 * H ^ 4 * E := by calc _ ≤ 16 * H ^ 2 * ((N : ℝ) / q + U + q) := hfirst _ ≤ 16 * H ^ 2 * (4 * E) := mul_le_mul_of_nonneg_left hcost.1 (by positivity) _ ≤ 64 * H ^ 4 * E := by nlinarith [mul_le_mul_of_nonneg_right hH24 hE] have h2 : ‖weightedSum (Finset.Ioc 0 N) w (typeICoefficient U U * ζ)‖ ≤ 32 * H ^ 4 * E := by calc _ ≤ 8 * H ^ 2 * ((N : ℝ) / q + (U : ℝ) ^ 2 + q) := by simpa only [H, typeIILogScale, w, pow_two] using hsecond _ ≤ 8 * H ^ 2 * (4 * E) := mul_le_mul_of_nonneg_left hcost.2 (by positivity) _ ≤ 32 * H ^ 4 * E := by nlinarith [mul_le_mul_of_nonneg_right hH24 hE] have h0 : ‖weightedSum (Finset.Ioc 0 N) w (shortPart U Λ)‖ ≤ H ^ 4 * E := by have hlog : Real.log N ≤ H ^ 4 := (log_nat_le_typeIILogScale N N le_rfl).trans hH14 have hpower : (N : ℝ) ^ (4 / 5 : ℝ) ≤ E := by dsimp [E, approximationEnvelope] have hd : 0 ≤ (N : ℝ) / Real.sqrt q := by positivity linarith [Real.sqrt_nonneg ((N : ℝ) * q)] calc _ ≤ (U : ℝ) * Real.log U := norm_short_vonMangoldt_sum_le N U w (by intro n hn simp [w]) _ ≤ (N : ℝ) ^ (4 / 5 : ℝ) * Real.log N := optimizedCutoff_log_le N hNr hpow _ ≤ E * H ^ 4 := mul_le_mul hpower hlog (Real.log_natCast_nonneg N) hE _ = _ := by ring have hII : ‖weightedSum (Finset.Ioc 0 N) w (typeIICoefficient U * longPart U Λ)‖ ≤ 54 * H ^ 4 * E := optimized_typeII_bound θ a q hq hcop happrox N hqN hpow change ‖weightedSum (Finset.Ioc 0 N) w Λ‖ ≤ 200 * H ^ 4 * E rw [weighted_identity (Finset.Ioc 0 N) w U U] calc _ ≤ (‖weightedSum (Finset.Ioc 0 N) w (shortPart U Λ)‖ + ‖weightedSum (Finset.Ioc 0 N) w (shortPart U (μ : ArithmeticFunction ℝ) * ArithmeticFunction.log)‖) + ‖weightedSum (Finset.Ioc 0 N) w (typeICoefficient U U * ζ)‖ + ‖weightedSum (Finset.Ioc 0 N) w (typeIICoefficient U * longPart U Λ)‖ := by apply (norm_add_le _ _).trans apply add_le_add _ le_rfl apply (norm_sub_le _ _).trans exact add_le_add (norm_add_le _ _) le_rfl _ ≤ _ := by nlinarith [mul_nonneg (pow_nonneg hH0 4) hE]
/-- The ordinary logarithmic form of the classical Vaughan estimate. -/theorem vonMangoldt_sum_log_bound (θ : ℝ) (a : ℤ) (q : ℕ) (hq : 0 < q) (hcop : IsCoprime a (q : ℤ)) (happrox : |θ - (a : ℝ) / q| ≤ 1 / (q : ℝ) ^ 2) (N : ℕ) (hqN : q ≤ N) (hpow : 2 ≤ (N : ℝ) ^ (2 / 5 : ℝ)) (hlog : 1 ≤ Real.log N) : ‖weightedSum (Finset.Ioc 0 N) (fun k => VaughanBilinear.phase (θ * k)) Λ‖ ≤ 16200 * (Real.log N) ^ 4 * approximationEnvelope N q := by have hNr : (0 : ℝ) < N := by exact_mod_cast hq.trans_le hqN have hH : typeIILogScale N ≤ 3 * Real.log N := by unfold typeIILogScale rw [Real.log_mul (by norm_num) hNr.ne'] linarith [Real.log_two_lt_d9] have hH0 : 0 ≤ typeIILogScale N := zero_le_one.trans (one_le_typeIILogScale N) have hE := approximationEnvelope_nonneg N q (Nat.cast_nonneg N) refine (vonMangoldt_sum_bound θ a q hq hcop happrox N hqN hpow).trans ?_ calc _ ≤ 200 * (3 * Real.log N) ^ 4 * approximationEnvelope N q := by gcongr _ = _ := by ring
open Filter in/-- The estimate holds uniformly in every reduced approximation once thesummation length is large, with an absolute explicit constant. -/theorem eventually_vonMangoldt_sum_log_bound : ∀ᶠ N : ℕ in atTop, ∀ (θ : ℝ) (a : ℤ) (q : ℕ), 0 < q → IsCoprime a (q : ℤ) → |θ - (a : ℝ) / q| ≤ 1 / (q : ℝ) ^ 2 → q ≤ N → ‖weightedSum (Finset.Ioc 0 N) (fun k => VaughanBilinear.phase (θ * k)) Λ‖ ≤ 16200 * (Real.log N) ^ 4 * approximationEnvelope N q := by have hlog : ∀ᶠ N : ℕ in atTop, 1 ≤ Real.log (N : ℝ) := (Real.tendsto_log_atTop.comp tendsto_natCast_atTop_atTop).eventually (eventually_ge_atTop (1 : ℝ)) have hpow : ∀ᶠ N : ℕ in atTop, 2 ≤ (N : ℝ) ^ (2 / 5 : ℝ) := ((tendsto_rpow_atTop (by norm_num : (0 : ℝ) < 2 / 5)).comp tendsto_natCast_atTop_atTop).eventually (eventually_ge_atTop (2 : ℝ)) filter_upwards [hlog, hpow] with N hlog hpow intro θ a q hq hcop happrox hqN exact vonMangoldt_sum_log_bound θ a q hq hcop happrox N hqN hpow hlog
end Problem337.Vaughan
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144import Mathlib.NumberTheory.ArithmeticFunction.VonMangoldtimport Mathlib.Basic.Complex.Basic
namespace OAI/-!# Finite hyperbola reindexing for Vaughan sums
An exact finite change of variables from `n = a*b` to pairs of positiveintegers below a hyperbola. The arbitrary weight version is suitable forboth rational additive characters and real-frequency exponential sums.-/
noncomputable sectionopen scoped BigOperators
namespace Problem337.Vaughan
/-- Positive lattice points below the multiplicative hyperbola `a*b ≤ N`. -/def hyperbola (N : ℕ) : Finset (ℕ × ℕ) := ((Finset.Icc 1 N).product (Finset.Icc 1 N)).filter (fun ab => ab.1 * ab.2 ≤ N)
@[simp] lemma mem_hyperbola {N a b : ℕ} : (a, b) ∈ hyperbola N ↔ 1 ≤ a ∧ 1 ≤ b ∧ a * b ≤ N := by change ((a, b) ∈ ((Finset.Icc 1 N).product (Finset.Icc 1 N)).filter (fun ab => ab.1 * ab.2 ≤ N)) ↔ _ rw [Finset.mem_filter] have hm : (a, b) ∈ (Finset.Icc 1 N).product (Finset.Icc 1 N) ↔ a ∈ Finset.Icc 1 N ∧ b ∈ Finset.Icc 1 N := Finset.mem_product rw [hm] simp only [Finset.mem_Icc] constructor · rintro ⟨⟨⟨ha, _⟩, ⟨hb, _⟩⟩, hp⟩ exact ⟨ha, hb, hp⟩ · rintro ⟨ha, hb, hp⟩ have haN : a ≤ N := (Nat.le_mul_of_pos_right a (by omega : 0 < b)).trans hp have hbN : b ≤ N := (Nat.le_mul_of_pos_left b (by omega : 0 < a)).trans hp exact ⟨⟨⟨ha, haN⟩, ⟨hb, hbN⟩⟩, hp⟩
/-- The divisor-antidiagonal fibers partition the positive hyperbola exactly.The summand may also depend on the product index `n`. -/theorem sum_divisor_fibers {A : Type*} [AddCommMonoid A] (N : ℕ) (F : ℕ → ℕ → ℕ → A) : (∑ n ∈ Finset.Icc 1 N, ∑ ab ∈ n.divisorsAntidiagonal, F n ab.1 ab.2) = ∑ ab ∈ hyperbola N, F (ab.1 * ab.2) ab.1 ab.2 := by rw [Finset.sum_sigma'] apply Finset.sum_nbij' (fun x : Sigma (fun _n : ℕ => ℕ × ℕ) => x.2) (fun ab : ℕ × ℕ => (⟨ab.1 * ab.2, ab⟩ : Sigma (fun _n : ℕ => ℕ × ℕ))) · rintro ⟨n, a, b⟩ hx obtain ⟨hn, hab⟩ := Finset.mem_sigma.mp hx obtain ⟨hn1, hnN⟩ := Finset.mem_Icc.mp hn obtain ⟨hprod, hn0⟩ := Nat.mem_divisorsAntidiagonal.mp hab apply mem_hyperbola.mpr change a * b = n at hprod change n ≠ 0 at hn0 have hab0 : a * b ≠ 0 := by rw [hprod]; exact hn0 exact ⟨Nat.pos_of_ne_zero (left_ne_zero_of_mul hab0), Nat.pos_of_ne_zero (right_ne_zero_of_mul hab0), by rw [hprod]; exact hnN⟩ · rintro ⟨a, b⟩ hab obtain ⟨ha, hb, hp⟩ := mem_hyperbola.mp hab apply Finset.mem_sigma.mpr constructor · exact Finset.mem_Icc.mpr ⟨Nat.mul_pos ha hb, hp⟩ · exact Nat.mem_divisorsAntidiagonal.mpr ⟨rfl, Nat.ne_of_gt (Nat.mul_pos ha hb)⟩ · rintro ⟨n, a, b⟩ hx have hprod := (Nat.mem_divisorsAntidiagonal.mp (Finset.mem_sigma.mp hx).2).1 change (⟨a * b, (a, b)⟩ : Sigma (fun _n : ℕ => ℕ × ℕ)) = ⟨n, (a, b)⟩ rw [hprod] · intro ab hab rfl · rintro ⟨n, a, b⟩ hx have hprod := (Nat.mem_divisorsAntidiagonal.mp (Finset.mem_sigma.mp hx).2).1 change F n a b = F (a * b) a b rw [hprod]
/-- The hyperbola sum as ordinary nested integer intervals. The inner endpointis the natural-number quotient `N / a`; the outer interval excludes zero. -/theorem sum_hyperbola_eq_nested {A : Type*} [AddCommMonoid A] (N : ℕ) (F : ℕ → ℕ → A) : (∑ ab ∈ hyperbola N, F ab.1 ab.2) = ∑ a ∈ Finset.Icc 1 N, ∑ b ∈ Finset.Icc 1 (N / a), F a b := by rw [Finset.sum_sigma'] apply Finset.sum_nbij' (fun ab : ℕ × ℕ => (⟨ab.1, ab.2⟩ : Sigma (fun _a : ℕ => ℕ))) (fun x : Sigma (fun _a : ℕ => ℕ) => (x.1, x.2)) · rintro ⟨a, b⟩ hab obtain ⟨ha, hb, hp⟩ := mem_hyperbola.mp hab apply Finset.mem_sigma.mpr constructor · exact Finset.mem_Icc.mpr ⟨ha, (Nat.le_mul_of_pos_right a (by omega : 0 < b)).trans hp⟩ · apply Finset.mem_Icc.mpr exact ⟨hb, (Nat.le_div_iff_mul_le (by omega : 0 < a)).mpr (by simpa [mul_comm] using hp)⟩ · rintro ⟨a, b⟩ hx obtain ⟨ha, hb⟩ := Finset.mem_sigma.mp hx obtain ⟨ha1, haN⟩ := Finset.mem_Icc.mp ha obtain ⟨hb1, hbN⟩ := Finset.mem_Icc.mp hb change 1 ≤ a at ha1 change 1 ≤ b at hb1 change b ≤ N / a at hbN apply mem_hyperbola.mpr refine ⟨ha1, hb1, ?_⟩ have hp := (Nat.le_div_iff_mul_le (by omega : 0 < a)).mp hbN simpa [mul_comm] using hp · intro ab hab rfl · intro x hx rfl · intro ab hab rfl
/-- Exact finite convolution reindexing with an arbitrary multiplicativeweight. No convergence or support hypotheses on the weight are needed. -/theorem sum_convolution_hyperbola {R : Type*} [Semiring R] (N : ℕ) (f g : ArithmeticFunction R) (w : ℕ → R) : (∑ n ∈ Finset.Icc 1 N, (f * g) n * w n) = ∑ ab ∈ hyperbola N, (f ab.1 * g ab.2) * w (ab.1 * ab.2) := by simp_rw [ArithmeticFunction.mul_apply, Finset.sum_mul] exact sum_divisor_fibers N (fun n a b => (f a * g b) * w n)
/-- Real arithmetic coefficients with complex weights, the combination usedfor the von-Mangoldt exponential sum. -/theorem sum_real_convolution_hyperbola (N : ℕ) (f g : ArithmeticFunction ℝ) (w : ℕ → ℂ) : (∑ n ∈ Finset.Icc 1 N, ((f * g) n : ℂ) * w n) = ∑ ab ∈ hyperbola N, ((f ab.1 * g ab.2 : ℝ) : ℂ) * w (ab.1 * ab.2) := by simp_rw [ArithmeticFunction.mul_apply, Complex.ofReal_sum, Finset.sum_mul] exact sum_divisor_fibers N (fun n a b => ((f a * g b : ℝ) : ℂ) * w n)
/-- The traditional nested-interval form of the finite convolution identity. -/theorem sum_real_convolution_eq_nested (N : ℕ) (f g : ArithmeticFunction ℝ) (w : ℕ → ℂ) : (∑ n ∈ Finset.Icc 1 N, ((f * g) n : ℂ) * w n) = ∑ a ∈ Finset.Icc 1 N, ∑ b ∈ Finset.Icc 1 (N / a), ((f a * g b : ℝ) : ℂ) * w (a * b) := by rw [sum_real_convolution_hyperbola] exact sum_hyperbola_eq_nested (A := ℂ) N (fun a b => ((f a * g b : ℝ) : ℂ) * w (a * b))
end Problem337.Vaughan
end
end OAI12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455import OAI.NumberTheory.EgyptianFractions.HyperbolaTypeIIimport OAI.NumberTheory.EgyptianFractions.VaughanNearRational
namespace OAInoncomputable sectionopen scoped BigOperators
namespace Problem337.VaughanBilinear
/-- A full Type-II estimate for the actual hyperbolic region `m*n ≤ X`.The rational approximation is the only analytic input: support intersection,geometric cancellation, harmonic spacing, and coefficient-energy estimatesare all supplied by checked lemmas. Empty row and column intervals are allowed. -/theorem near_rational_hyperbolic_bilinear_sq_le (θ : ℝ) (a : ℤ) (q : ℕ) (hq : 0 < q) (hcop : IsCoprime a (q : ℤ)) (happrox : |θ - (a : ℝ) / q| ≤ 1 / (q : ℝ) ^ 2) (X L U V N : ℕ) (t : Finset ℕ) (ht : t ⊆ Finset.Ico V (V + N)) (hpos : ∀ n ∈ t, 0 < n) (c b : ℕ → ℂ) : ‖∑ m ∈ Finset.Icc L U, c m * ∑ n ∈ t, b n * HyperbolaCorrelation.column θ X n m‖ ^ 2 ≤ (∑ m ∈ Finset.Icc L U, ‖c m‖ ^ 2) * ((2 * (N : ℝ) / q + 1) * (2 * ((U + 1 - L : ℕ) : ℝ) + 4 * (q : ℝ) * (1 + Real.log (2 * (q : ℝ))))) * (∑ n ∈ t, ‖b n‖ ^ 2) := by apply norm_bilinear_sq_le_energy intro n hn calc _ ≤ ∑ k ∈ t, geometricBound (U + 1 - L) (θ * ((n : ℝ) - k)) := by apply Finset.sum_le_sum intro k hk exact HyperbolaCorrelation.column_correlation_le θ X L U n k ((hpos n hn).trans_le (le_max_left _ _)) _ ≤ _ := by simpa only [Int.cast_sub, Int.cast_natCast] using (sum_geometricBound_difference_le θ a q hq hcop happrox (U + 1 - L) t (fun k : ℕ => (k : ℤ)) (V : ℤ) N (by intro k hk obtain ⟨hl, hu⟩ := Finset.mem_Ico.mp (ht hk) apply Finset.mem_Ico.mpr constructor <;> exact_mod_cast (by assumption)) (by intro i hi j hj hij dsimp at hij exact_mod_cast hij) (n : ℤ))
end Problem337.VaughanBilinear
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180import Mathlib.NumberTheory.ArithmeticFunction.VonMangoldt
namespace OAI/-!# Vaughan's identity with finite cutoffs
This file supplies an unconditional algebraic input to the analytic three-primeroute. Multiplication of arithmetic functions below is Dirichlet convolution.No estimate for exponential sums over primes is assumed or asserted here.-/
noncomputable section
open scoped BigOperators ArithmeticFunction ArithmeticFunction.Moebius ArithmeticFunction.zeta
namespace Problem337.Vaughan
/-- The part of an arithmetic function supported on integers at most `U`. -/def shortPart {R : Type*} [Zero R] (U : ℕ) (f : ArithmeticFunction R) : ArithmeticFunction R := ⟨fun n => if n ≤ U then f n else 0, by simp⟩
/-- The complementary part, supported on integers strictly above `U`. -/def longPart {R : Type*} [Zero R] (U : ℕ) (f : ArithmeticFunction R) : ArithmeticFunction R := ⟨fun n => if U < n then f n else 0, by simp⟩
@[simp] lemma shortPart_apply {R : Type*} [Zero R] (U : ℕ) (f : ArithmeticFunction R) (n : ℕ) : shortPart U f n = if n ≤ U then f n else 0 := rfl
@[simp] lemma longPart_apply {R : Type*} [Zero R] (U : ℕ) (f : ArithmeticFunction R) (n : ℕ) : longPart U f n = if U < n then f n else 0 := rfl
lemma shortPart_add_longPart {R : Type*} [AddMonoid R] (U : ℕ) (f : ArithmeticFunction R) : shortPart U f + longPart U f = f := by ext n by_cases hn : n ≤ U <;> simp [hn, Nat.not_lt.mpr, Nat.lt_of_not_ge]
lemma longPart_eq_sub_shortPart {R : Type*} [AddCommGroup R] (U : ℕ) (f : ArithmeticFunction R) : longPart U f = f - shortPart U f := by have h := shortPart_add_longPart U f exact eq_sub_iff_add_eq.mpr (by simpa only [add_comm] using h)
/-- Vaughan's four-term identity, valid also at zero and for zero cutoffs.The first convolution is Type I; the second has a coefficient supported on`[1,U*V]`; the last is the long-long Type II convolution. -/theorem vonMangoldt_identity (U V : ℕ) : ArithmeticFunction.vonMangoldt = shortPart V ArithmeticFunction.vonMangoldt + shortPart U (μ : ArithmeticFunction ℝ) * ArithmeticFunction.log - (shortPart U (μ : ArithmeticFunction ℝ) * shortPart V ArithmeticFunction.vonMangoldt) * (ζ : ArithmeticFunction ℝ) + (longPart U (μ : ArithmeticFunction ℝ) * (ζ : ArithmeticFunction ℝ)) * longPart V ArithmeticFunction.vonMangoldt := by rw [longPart_eq_sub_shortPart, longPart_eq_sub_shortPart] have hμ : (μ : ArithmeticFunction ℝ) * (ζ : ArithmeticFunction ℝ) = 1 := ArithmeticFunction.coe_moebius_mul_coe_zeta have hΛ : (ζ : ArithmeticFunction ℝ) * ArithmeticFunction.vonMangoldt = ArithmeticFunction.log := ArithmeticFunction.zeta_mul_vonMangoldt calc ArithmeticFunction.vonMangoldt = ((μ : ArithmeticFunction ℝ) * (ζ : ArithmeticFunction ℝ)) * ArithmeticFunction.vonMangoldt := by rw [hμ, one_mul] _ = _ := by rw [← hΛ] have hshort : ((μ : ArithmeticFunction ℝ) * (ζ : ArithmeticFunction ℝ)) * shortPart V ArithmeticFunction.vonMangoldt = shortPart V ArithmeticFunction.vonMangoldt := by rw [hμ, one_mul] linear_combination hshort
/-- A convolution of two short parts has the expected product support. -/lemma shortPart_mul_eq_zero_of_lt {R : Type*} [Semiring R] (U V n : ℕ) (f g : ArithmeticFunction R) (hn : U * V < n) : (shortPart U f * shortPart V g) n = 0 := by rw [ArithmeticFunction.mul_apply] apply Finset.sum_eq_zero intro ab hab have habn := (Nat.mem_divisorsAntidiagonal.mp hab).1 by_cases ha : ab.1 ≤ U · have hb : ¬ ab.2 ≤ V := by intro hb have hm := Nat.mul_le_mul ha hb rw [habn] at hm omega simp [ha, hb] · simp [ha]
/-- Convolving a long part cannot create a smaller positive index. -/lemma longPart_mul_eq_zero_of_le {R : Type*} [Semiring R] (U n : ℕ) (f g : ArithmeticFunction R) (hn : n ≤ U) : (longPart U f * g) n = 0 := by rw [ArithmeticFunction.mul_apply] apply Finset.sum_eq_zero intro ab hab obtain ⟨hprod, hn0⟩ := Nat.mem_divisorsAntidiagonal.mp hab have ha : ab.1 ≤ n := Nat.le_of_dvd (Nat.pos_of_ne_zero hn0) ⟨ab.2, hprod.symm⟩ have hnot : ¬ U < ab.1 := by omega simp [hnot]
lemma abs_shortPart_le (U : ℕ) (f : ArithmeticFunction ℝ) (n : ℕ) : |shortPart U f n| ≤ |f n| := by by_cases hn : n ≤ U <;> simp [hn, abs_nonneg]
lemma abs_longPart_le (U : ℕ) (f : ArithmeticFunction ℝ) (n : ℕ) : |longPart U f n| ≤ |f n| := by by_cases hn : U < n <;> simp [hn, abs_nonneg]
lemma abs_real_moebius_le_one (n : ℕ) : |(μ : ArithmeticFunction ℝ) n| ≤ 1 := by change |((ArithmeticFunction.moebius n : ℤ) : ℝ)| ≤ 1 exact_mod_cast (ArithmeticFunction.abs_moebius_le_one (n := n))
/-- The short convolution coefficient appearing in Type I sums. -/def typeICoefficient (U V : ℕ) : ArithmeticFunction ℝ := shortPart U (μ : ArithmeticFunction ℝ) * shortPart V ArithmeticFunction.vonMangoldt
/-- The coefficient appearing in the long-long Type II sum. -/def typeIICoefficient (U : ℕ) : ArithmeticFunction ℝ := longPart U (μ : ArithmeticFunction ℝ) * (ζ : ArithmeticFunction ℝ)
lemma typeICoefficient_eq_zero (U V n : ℕ) (hn : U * V < n) : typeICoefficient U V n = 0 := shortPart_mul_eq_zero_of_lt U V n _ _ hn
lemma typeIICoefficient_eq_zero (U n : ℕ) (hn : n ≤ U) : typeIICoefficient U n = 0 := longPart_mul_eq_zero_of_le U n _ _ hn
/-- The Type I coefficient costs only a logarithm, not a divisor function. -/lemma abs_typeICoefficient_le_log (U V n : ℕ) : |typeICoefficient U V n| ≤ Real.log n := by unfold typeICoefficient rw [ArithmeticFunction.mul_apply] calc _ ≤ ∑ ab ∈ n.divisorsAntidiagonal, |shortPart U (μ : ArithmeticFunction ℝ) ab.1 * shortPart V ArithmeticFunction.vonMangoldt ab.2| := Finset.abs_sum_le_sum_abs _ _ _ ≤ ∑ ab ∈ n.divisorsAntidiagonal, ArithmeticFunction.vonMangoldt ab.2 := by apply Finset.sum_le_sum intro ab hab rw [abs_mul] have hμ := (abs_shortPart_le U (μ : ArithmeticFunction ℝ) ab.1).trans (abs_real_moebius_le_one ab.1) have hΛ := abs_shortPart_le V ArithmeticFunction.vonMangoldt ab.2 rw [abs_of_nonneg ArithmeticFunction.vonMangoldt_nonneg] at hΛ calc _ ≤ 1 * ArithmeticFunction.vonMangoldt ab.2 := mul_le_mul hμ hΛ (abs_nonneg _) zero_le_one _ = _ := one_mul _ _ = Real.log n := by rw [Nat.sum_divisorsAntidiagonal' (fun _ b => ArithmeticFunction.vonMangoldt b)] exact ArithmeticFunction.vonMangoldt_sum
lemma typeIICoefficient_apply (U n : ℕ) : typeIICoefficient U n = ∑ d ∈ n.divisors.filter (U < ·), (μ : ArithmeticFunction ℝ) d := by rw [typeIICoefficient, ArithmeticFunction.coe_mul_zeta_apply] simp only [longPart_apply, Finset.sum_filter]
/-- A uniform elementary coefficient bound for the Type II sum. -/lemma abs_typeIICoefficient_le_divisors_card (U n : ℕ) : |typeIICoefficient U n| ≤ (n.divisors.card : ℝ) := by rw [typeIICoefficient, ArithmeticFunction.coe_mul_zeta_apply] calc _ ≤ ∑ d ∈ n.divisors, |longPart U (μ : ArithmeticFunction ℝ) d| := Finset.abs_sum_le_sum_abs _ _ _ ≤ ∑ _d ∈ n.divisors, (1 : ℝ) := by apply Finset.sum_le_sum intro d hd exact (abs_longPart_le U (μ : ArithmeticFunction ℝ) d).trans (abs_real_moebius_le_one d) _ = _ := by simp
end Problem337.Vaughan
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269import OAI.NumberTheory.EgyptianFractions.VaughanBilinearimport OAI.NumberTheory.EgyptianFractions.GeometricCharacterBoundimport OAI.NumberTheory.EgyptianFractions.RationalPhaseSpacing
namespace OAInoncomputable sectionopen scoped BigOperators
namespace Problem337.VaughanBilinear
theorem phase_int (n : ℤ) : phase n = 1 := by rw [phase, Real.fourierChar_apply] have he : (↑(2 * Real.pi * (n : ℝ)) : ℂ) * Complex.I = (n : ℂ) * (2 * (Real.pi : ℂ) * Complex.I) := by push_cast ring rw [he, Complex.exp_int_mul_two_pi_mul_I]
theorem phase_fract (x : ℝ) : phase (Int.fract x) = phase x := by rw [Int.fract, ← phase_mul_conj, phase_int] simp
theorem phase_eq_geometric_phase (x : ℝ) : phase x = Complex.exp (Complex.I * (2 * Real.pi * x : ℝ)) := by rw [phase, Real.fourierChar_apply] congr 1 ring
/-- The usual truncated reciprocal-distance majorant for a real geometricsum. Integer phases use the length cap, never a spurious zero reciprocal. -/theorem phase_sum_le_truncatedInv (x : ℝ) (M : ℕ) : ‖∑ m ∈ Finset.range M, phase (x * m)‖ ≤ RationalPhaseSpacing.truncatedInv M (RationalPhaseSpacing.intDistance x) := by have hcap : ‖∑ m ∈ Finset.range M, phase (x * m)‖ ≤ (M : ℝ) := by calc _ ≤ ∑ m ∈ Finset.range M, ‖phase (x * m)‖ := norm_sum_le _ _ _ = _ := by simp by_cases hx : RationalPhaseSpacing.intDistance x = 0 · simpa only [RationalPhaseSpacing.truncatedInv, ite_eq_left hx] using hcap have hpos : 0 < RationalPhaseSpacing.intDistance x := lt_of_le_of_ne (RationalPhaseSpacing.intDistance_nonneg x) (Ne.symm hx) rw [RationalPhaseSpacing.truncatedInv, ite_eq_right hx] refine le_min hcap ?_ have hlow : RationalPhaseSpacing.intDistance x ≤ Int.fract x := min_le_left _ _ have hhigh : Int.fract x ≤ 1 - RationalPhaseSpacing.intDistance x := by have h := min_le_right (Int.fract x) (1 - Int.fract x) change RationalPhaseSpacing.intDistance x ≤ 1 - Int.fract x at h linarith have hgeom := norm_geometric_phase_sum_le_middle hpos hlow hhigh M have heq : (∑ m ∈ Finset.range M, phase (x * m)) = ∑ m ∈ Finset.range M, Complex.exp (Complex.I * (2 * Real.pi * Int.fract x : ℝ)) ^ m := by apply Finset.sum_congr rfl intro m hm rw [phase_nat_mul, ← phase_fract x, phase_eq_geometric_phase] rw [heq] exact hgeom.trans (one_div_le_one_div_of_le hpos (by linarith))
/-- Rational approximation provides an actual Type-II correlation row boundon every short block of integer columns, uniformly in the chosen row. -/theorem near_rational_correlation_row_le (θ : ℝ) (a : ℤ) (q : ℕ) (hq : 0 < q) (hcop : IsCoprime a (q : ℤ)) (happrox : |θ - (a : ℝ) / q| ≤ 1 / (q : ℝ) ^ 2) (M : ℕ) (t : Finset ℤ) (hspan : ∀ n ∈ t, ∀ k ∈ t, 2 * |n - k| ≤ (q : ℤ)) (n : ℤ) : (∑ k ∈ t, ‖∑ m ∈ Finset.range M, phase (θ * m * n) * (starRingEnd ℂ) (phase (θ * m * k))‖) ≤ 2 * (M : ℝ) + 4 * (q : ℝ) * (1 + Real.log (2 * (q : ℝ))) := by classical let A := t.image (fun k => n - k) have hA : ∀ j ∈ A, ∀ l ∈ A, 2 * |j - l| ≤ (q : ℤ) := by intro j hj l hl obtain ⟨k, hk, rfl⟩ := Finset.mem_image.mp hj obtain ⟨i, hi, rfl⟩ := Finset.mem_image.mp hl have heq : (n - k) - (n - i) = i - k := by omega rw [heq] exact hspan i hi k hk have hsum := RationalPhaseSpacing.sum_truncatedInv_intDistance_le θ a q hq hcop happrox A hA (M : ℝ) (Nat.cast_nonneg M) have hcorr (k : ℤ) : (∑ m ∈ Finset.range M, phase (θ * m * n) * (starRingEnd ℂ) (phase (θ * m * k))) = ∑ m ∈ Finset.range M, phase ((θ * ((n - k : ℤ) : ℝ)) * m) := by apply Finset.sum_congr rfl intro m hm rw [phase_mul_conj] congr 1 push_cast ring calc _ ≤ ∑ k ∈ t, RationalPhaseSpacing.truncatedInv M (RationalPhaseSpacing.intDistance (θ * ((n - k : ℤ) : ℝ))) := by apply Finset.sum_le_sum intro k hk rw [hcorr] exact phase_sum_le_truncatedInv _ M _ = ∑ j ∈ A, RationalPhaseSpacing.truncatedInv M (RationalPhaseSpacing.intDistance (θ * j)) := by rw [Finset.sum_image] intro k hk i hi heq dsimp at heq omega _ ≤ _ := hsum
/-- A proved near-rational Type-II estimate with both coefficient energies.The only number-theoretic hypothesis is the stated reduced approximation;all correlation/spacing/cancellation estimates are discharged. -/theorem near_rational_bilinear_sq_le (θ : ℝ) (a : ℤ) (q : ℕ) (hq : 0 < q) (hcop : IsCoprime a (q : ℤ)) (happrox : |θ - (a : ℝ) / q| ≤ 1 / (q : ℝ) ^ 2) (M : ℕ) (t : Finset ℤ) (hspan : ∀ n ∈ t, ∀ k ∈ t, 2 * |n - k| ≤ (q : ℤ)) (c : ℕ → ℂ) (b : ℤ → ℂ) : ‖∑ m ∈ Finset.range M, c m * ∑ n ∈ t, b n * phase (θ * m * n)‖ ^ 2 ≤ (∑ m ∈ Finset.range M, ‖c m‖ ^ 2) * (2 * (M : ℝ) + 4 * (q : ℝ) * (1 + Real.log (2 * (q : ℝ)))) * (∑ n ∈ t, ‖b n‖ ^ 2) := by apply norm_bilinear_sq_le_energy intro n hn exact near_rational_correlation_row_le θ a q hq hcop happrox M t hspan n
/-- Actual near-rational row cancellation on an arbitrary integer interval,also valid for any subset of that interval. -/theorem near_rational_interval_correlation_row_le (θ : ℝ) (a : ℤ) (q : ℕ) (hq : 0 < q) (hcop : IsCoprime a (q : ℤ)) (happrox : |θ - (a : ℝ) / q| ≤ 1 / (q : ℝ) ^ 2) (M : ℕ) (t : Finset ℤ) (L : ℤ) (N : ℕ) (ht : t ⊆ Finset.Ico L (L + N)) (n : ℤ) : (∑ k ∈ t, ‖∑ m ∈ Finset.range M, phase (θ * m * n) * (starRingEnd ℂ) (phase (θ * m * k))‖) ≤ (2 * (N : ℝ) / q + 1) * (2 * (M : ℝ) + 4 * (q : ℝ) * (1 + Real.log (2 * (q : ℝ)))) := by classical let A := t.image (fun k => n - k) let L' : ℤ := n - L - N + 1 have hA : A ⊆ Finset.Ico L' (L' + N) := by intro j hj obtain ⟨k, hk, rfl⟩ := Finset.mem_image.mp hj have hk' := Finset.mem_Ico.mp (ht hk) apply Finset.mem_Ico.mpr dsimp [L'] omega calc _ ≤ ∑ k ∈ t, RationalPhaseSpacing.truncatedInv M (RationalPhaseSpacing.intDistance (θ * ((n - k : ℤ) : ℝ))) := by apply Finset.sum_le_sum intro k hk have heq : (∑ m ∈ Finset.range M, phase (θ * m * n) * (starRingEnd ℂ) (phase (θ * m * k))) = ∑ m ∈ Finset.range M, phase ((θ * ((n - k : ℤ) : ℝ)) * m) := by apply Finset.sum_congr rfl intro m hm rw [phase_mul_conj] congr 1 push_cast ring rw [heq] exact phase_sum_le_truncatedInv _ M _ = ∑ j ∈ A, RationalPhaseSpacing.truncatedInv M (RationalPhaseSpacing.intDistance (θ * j)) := by rw [Finset.sum_image] intro k hk i hi heq dsimp at heq omega _ ≤ ∑ j ∈ Finset.Ico L' (L' + N), RationalPhaseSpacing.truncatedInv M (RationalPhaseSpacing.intDistance (θ * j)) := Finset.sum_le_sum_of_subset_of_nonneg hA (fun _ _ _ => RationalPhaseSpacing.truncatedInv_nonneg (Nat.cast_nonneg M) (RationalPhaseSpacing.intDistance_nonneg _)) _ ≤ _ := RationalPhaseSpacing.sum_truncatedInv_intDistance_interval_le θ a q hq hcop happrox L' N M (Nat.cast_nonneg M)
/-- Full rectangular Type-II estimate from a reduced rational approximation.No spacing, correlation, or equidistribution estimate remains as a premise. -/theorem near_rational_interval_bilinear_sq_le (θ : ℝ) (a : ℤ) (q : ℕ) (hq : 0 < q) (hcop : IsCoprime a (q : ℤ)) (happrox : |θ - (a : ℝ) / q| ≤ 1 / (q : ℝ) ^ 2) (M : ℕ) (t : Finset ℤ) (L : ℤ) (N : ℕ) (ht : t ⊆ Finset.Ico L (L + N)) (c : ℕ → ℂ) (b : ℤ → ℂ) : ‖∑ m ∈ Finset.range M, c m * ∑ n ∈ t, b n * phase (θ * m * n)‖ ^ 2 ≤ (∑ m ∈ Finset.range M, ‖c m‖ ^ 2) * ((2 * (N : ℝ) / q + 1) * (2 * (M : ℝ) + 4 * (q : ℝ) * (1 + Real.log (2 * (q : ℝ))))) * (∑ n ∈ t, ‖b n‖ ^ 2) := by apply norm_bilinear_sq_le_energy intro n hn exact near_rational_interval_correlation_row_le θ a q hq hcop happrox M t L N ht n
/-- The explicit geometric majorant itself is bounded by the truncatedreciprocal distance. This also allows variable inner interval lengths. -/theorem geometricBound_le_truncatedInv (M : ℕ) (x : ℝ) : geometricBound M x ≤ RationalPhaseSpacing.truncatedInv M (RationalPhaseSpacing.intDistance x) := by by_cases hd : RationalPhaseSpacing.intDistance x = 0 · rw [RationalPhaseSpacing.truncatedInv, ite_eq_left hd] unfold geometricBound split_ifs · exact le_rfl · exact min_le_left _ _ have hdpos : 0 < RationalPhaseSpacing.intDistance x := lt_of_le_of_ne (RationalPhaseSpacing.intDistance_nonneg x) (Ne.symm hd) have hlow : RationalPhaseSpacing.intDistance x ≤ Int.fract x := min_le_left _ _ have hhigh : Int.fract x ≤ 1 - RationalPhaseSpacing.intDistance x := by have h := min_le_right (Int.fract x) (1 - Int.fract x) change RationalPhaseSpacing.intDistance x ≤ 1 - Int.fract x at h linarith have hs := sin_pi_mul_lower_on_middle hdpos hlow hhigh have hchord : 2 * RationalPhaseSpacing.intDistance x ≤ ‖1 - phase x‖ := by rw [norm_sub_rev, ← phase_fract x, phase_eq_geometric_phase, norm_exp_phase_sub_one] have habs := le_abs_self (Real.sin (Real.pi * Int.fract x)) nlinarith have hnorm : 0 < ‖1 - phase x‖ := by linarith have hx : phase x ≠ 1 := by intro hx simp [hx] at hnorm rw [geometricBound, ite_eq_right hx, RationalPhaseSpacing.truncatedInv, ite_eq_right hd] apply min_le_min_left apply (div_le_div_iff₀ hnorm hdpos).mpr simpa using hchord
/-- A uniform harmonic row bound for indexed integer frequencies. The mapinto the interval must be injective, but need not exhaust the interval. -/theorem sum_geometricBound_difference_le {β : Type*} (θ : ℝ) (a : ℤ) (q : ℕ) (hq : 0 < q) (hcop : IsCoprime a (q : ℤ)) (happrox : |θ - (a : ℝ) / q| ≤ 1 / (q : ℝ) ^ 2) (M : ℕ) (t : Finset β) (f : β → ℤ) (L : ℤ) (N : ℕ) (hf : ∀ k ∈ t, f k ∈ Finset.Ico L (L + N)) (hinj : Set.InjOn f t) (n : ℤ) : (∑ k ∈ t, geometricBound M (θ * ((n - f k : ℤ) : ℝ))) ≤ (2 * (N : ℝ) / q + 1) * (2 * (M : ℝ) + 4 * (q : ℝ) * (1 + Real.log (2 * (q : ℝ)))) := by classical let A := t.image (fun k => n - f k) let L' : ℤ := n - L - N + 1 have hA : A ⊆ Finset.Ico L' (L' + N) := by intro j hj obtain ⟨k, hk, rfl⟩ := Finset.mem_image.mp hj have hk' := Finset.mem_Ico.mp (hf k hk) apply Finset.mem_Ico.mpr dsimp [L'] omega calc _ ≤ ∑ k ∈ t, RationalPhaseSpacing.truncatedInv M (RationalPhaseSpacing.intDistance (θ * ((n - f k : ℤ) : ℝ))) := Finset.sum_le_sum (fun k _ => geometricBound_le_truncatedInv M _) _ = ∑ j ∈ A, RationalPhaseSpacing.truncatedInv M (RationalPhaseSpacing.intDistance (θ * j)) := by rw [Finset.sum_image] intro k hk i hi heq apply hinj hk hi dsimp at heq omega _ ≤ ∑ j ∈ Finset.Ico L' (L' + N), RationalPhaseSpacing.truncatedInv M (RationalPhaseSpacing.intDistance (θ * j)) := Finset.sum_le_sum_of_subset_of_nonneg hA (fun _ _ _ => RationalPhaseSpacing.truncatedInv_nonneg (Nat.cast_nonneg M) (RationalPhaseSpacing.intDistance_nonneg _)) _ ≤ _ := RationalPhaseSpacing.sum_truncatedInv_intDistance_interval_le θ a q hq hcop happrox L' N M (Nat.cast_nonneg M)
end Problem337.VaughanBilinear
end
end OAI1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586import OAI.NumberTheory.EgyptianFractions.VaughanDyadicUniformimport OAI.NumberTheory.EgyptianFractions.VaughanCutoff
namespace OAInoncomputable sectionopen scoped BigOperators ArithmeticFunction
namespace Problem337.Vaughan
/-- The standard three-term envelope for a reduced rational approximation. -/def approximationEnvelope (X q : ℝ) : ℝ := X / Real.sqrt q + X ^ (4 / 5 : ℝ) + Real.sqrt (X * q)
lemma approximationEnvelope_nonneg (X q : ℝ) (hX : 0 ≤ X) : 0 ≤ approximationEnvelope X q := by unfold approximationEnvelope positivity
lemma dyadic_log_le_three_scale (N : ℕ) : 1 + Real.log N / Real.log 2 ≤ 3 * typeIILogScale N := by have hlog := Real.log_natCast_nonneg N have htwo : (1 / 2 : ℝ) ≤ Real.log 2 := by linarith [Real.log_two_gt_d9] have hdiv : Real.log N / Real.log 2 ≤ 2 * Real.log N := by apply (div_le_iff₀ (by linarith : 0 < Real.log 2)).mpr nlinarith [mul_le_mul_of_nonneg_right htwo hlog] have hN := log_nat_le_typeIILogScale N N le_rfl have hH := one_le_typeIILogScale N linarith
/-- Balanced cutoffs turn each actual Type II block into the standard envelope. -/theorem optimized_typeIIBlock_bound (θ : ℝ) (a : ℤ) (q : ℕ) (hq : 0 < q) (hcop : IsCoprime a (q : ℤ)) (happrox : |θ - (a : ℝ) / q| ≤ 1 / (q : ℝ) ^ 2) (N j : ℕ) (hqN : q ≤ N) (hpow : 2 ≤ (N : ℝ) ^ (2 / 5 : ℝ)) : ‖typeIIBlock N (optimizedCutoff N) (optimizedCutoff N) j (fun k => VaughanBilinear.phase (θ * k))‖ ≤ 18 * (typeIILogScale N) ^ 3 * approximationEnvelope N q := by have hN : (1 : ℝ) ≤ N := by exact_mod_cast hq.trans_le hqN have hU := optimizedCutoff_pos N hpow have hs := typeIIBlock_sq_le_uniform θ a q hq hcop happrox N (optimizedCutoff N) (optimizedCutoff N) j hqN hU hU have hb := optimizedCutoff_squared_budget N q 32 ‖typeIIBlock N (optimizedCutoff N) (optimizedCutoff N) j (fun k => VaughanBilinear.phase (θ * k))‖ hN (by exact_mod_cast hq) (by norm_num) hpow hs have hsqrt : Real.sqrt (32 : ℝ) ≤ 6 := (Real.sqrt_le_left (by norm_num)).mpr (by norm_num) change _ ≤ 3 * Real.sqrt 32 * (typeIILogScale N) ^ 3 * approximationEnvelope N q at hb refine hb.trans ?_ have hH : 0 ≤ typeIILogScale N := zero_le_one.trans (one_le_typeIILogScale N) have hE := approximationEnvelope_nonneg N q (Nat.cast_nonneg N) gcongr norm_num at * linarith
/-- Summing the genuine dyadic blocks costs one further logarithm, not apower of the summation length. All cancellation hypotheses are discharged. -/theorem optimized_typeII_bound (θ : ℝ) (a : ℤ) (q : ℕ) (hq : 0 < q) (hcop : IsCoprime a (q : ℤ)) (happrox : |θ - (a : ℝ) / q| ≤ 1 / (q : ℝ) ^ 2) (N : ℕ) (hqN : q ≤ N) (hpow : 2 ≤ (N : ℝ) ^ (2 / 5 : ℝ)) : ‖weightedSum (Finset.Ioc 0 N) (fun k => VaughanBilinear.phase (θ * k)) (typeIICoefficient (optimizedCutoff N) * longPart (optimizedCutoff N) Λ)‖ ≤ 54 * (typeIILogScale N) ^ 4 * approximationEnvelope N q := by have hH : 0 ≤ typeIILogScale N := zero_le_one.trans (one_le_typeIILogScale N) have hE := approximationEnvelope_nonneg N q (Nat.cast_nonneg N) have hb := norm_typeII_le_dyadic_log_budget N (optimizedCutoff N) (optimizedCutoff N) (fun k => VaughanBilinear.phase (θ * k)) (18 * (typeIILogScale N) ^ 3 * approximationEnvelope N q) (by positivity) (fun j _ => optimized_typeIIBlock_bound θ a q hq hcop happrox N j hqN hpow) refine hb.trans ?_ calc _ ≤ (3 * typeIILogScale N) * (18 * (typeIILogScale N) ^ 3 * approximationEnvelope N q) := mul_le_mul_of_nonneg_right (dyadic_log_le_three_scale N) (by positivity) _ = _ := by ring
end Problem337.Vaughan
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112import OAI.NumberTheory.EgyptianFractions.VaughanTypeIimport OAI.NumberTheory.EgyptianFractions.RealTypeI
namespace OAI/-!# Actual near-rational estimates for the two Vaughan Type I terms
The prefix adapter uses the sharper canonical harmonic hyperbola boundfor its scalar aggregation.The variable hyperbolic lengths are retained throughout. In particular theright hand side has size `N / q + A + q`, up to logarithmic factors, ratherthan the much larger fixed-cap estimate obtained by replacing every `N / d`with `N`.-/
noncomputable sectionopen scoped BigOperators ArithmeticFunction ArithmeticFunction.Moebius ArithmeticFunction.zeta
namespace Problem337.VaughanHyperbolic
open Vaughan
open RationalPhaseSpacing
/-- Every hyperbolic inner prefix has the required variable-cap envelope.This includes the zero-frequency case and does not require a nonresonanceassumption. -/theorem norm_phase_Ioc_mul_le_variable (α : ℝ) (N d k : ℕ) (hk : k ≤ N / d) : ‖∑ b ∈ Finset.Ioc 0 k, RealPhase.phase (α * (d * b : ℕ))‖ ≤ truncatedInv ((N : ℝ) / d) (intDistance (α * d)) := by have heq : (∑ b ∈ Finset.Ioc 0 k, RealPhase.phase (α * (d * b : ℕ))) = ∑ j ∈ Finset.range k, RealPhase.phase ((α * d) * (1 + j) + 0) := by rw [sum_Ioc_zero_eq_sum_range_succ] apply Finset.sum_congr rfl intro j hj congr 1 push_cast ring rw [heq] exact (RealPhase.norm_sum_shift_phase_le_envelope (α * d) 0 1 k).trans (RealTypeI.geometric_envelope_le_truncated_real (α * d) k ((N : ℝ) / d) ((by exact_mod_cast hk : (k : ℝ) ≤ (N / d : ℕ)).trans Nat.cast_div_le))
/-- The positive-initial-interval convention used by Vaughan's identity. -/theorem sum_variable_reciprocal_Ioc_le (α : ℝ) (a : ℤ) (q : ℕ) (hq : 0 < q) (hcop : IsCoprime a (q : ℤ)) (happrox : |α - (a : ℝ) / q| ≤ 1 / (q : ℝ) ^ 2) (N A : ℕ) : (∑ d ∈ Finset.Ioc 0 A, truncatedInv ((N : ℝ) / d) (intDistance (α * d))) ≤ RealTypeI.hyperbolicCost (N : ℝ) A q := by have hcast : (∑ d ∈ Finset.Ioc 0 A, truncatedInv ((N : ℝ) / d) (intDistance (α * d))) = ∑ d ∈ Finset.Icc 1 (A : ℤ), truncatedInv ((N : ℝ) / d) (intDistance (α * d)) := by apply Finset.sum_nbij' (fun d : ℕ => (d : ℤ)) Int.toNat · intro d hd obtain ⟨hd0, hdA⟩ := Finset.mem_Ioc.mp hd exact Finset.mem_Icc.mpr ⟨by exact_mod_cast hd0, by exact_mod_cast hdA⟩ · intro d hd obtain ⟨hd1, hdA⟩ := Finset.mem_Icc.mp hd apply Finset.mem_Ioc.mpr omega · intro d hd exact Int.toNat_natCast d · intro d hd exact Int.toNat_of_nonneg (by have := (Finset.mem_Icc.mp hd).1; omega) · intro d hd simp rw [hcast] exact sum_truncatedInv_hyperbolic_le α a q hq hcop happrox N (Nat.cast_nonneg N) A
/-- The first actual Vaughan convolution, with its logarithmic inner weight,is bounded using only a reduced rational approximation to the frequency. -/theorem first_typeI_real_phase_bound (α : ℝ) (a : ℤ) (q : ℕ) (hq : 0 < q) (hcop : IsCoprime a (q : ℤ)) (happrox : |α - (a : ℝ) / q| ≤ 1 / (q : ℝ) ^ 2) (N U : ℕ) : ‖weightedSum (Finset.Ioc 0 N) (fun n => RealPhase.phase (α * n)) (shortPart U (μ : ArithmeticFunction ℝ) * ArithmeticFunction.log)‖ ≤ 2 * Real.log N * RealTypeI.hyperbolicCost (N : ℝ) (min U N) q := by apply (first_typeI_bound (fun n => RealPhase.phase (α * n)) N U (fun d => truncatedInv ((N : ℝ) / d) (intDistance (α * d))) (fun d _ k hk => norm_phase_Ioc_mul_le_variable α N d k hk)).trans exact mul_le_mul_of_nonneg_left (sum_variable_reciprocal_Ioc_le α a q hq hcop happrox N (min U N)) (by positivity)
/-- The second actual Vaughan convolution has one logarithmic coefficientfactor and the same variable-length reciprocal budget. -/theorem second_typeI_real_phase_bound (α : ℝ) (a : ℤ) (q : ℕ) (hq : 0 < q) (hcop : IsCoprime a (q : ℤ)) (happrox : |α - (a : ℝ) / q| ≤ 1 / (q : ℝ) ^ 2) (N U V : ℕ) : ‖weightedSum (Finset.Ioc 0 N) (fun n => RealPhase.phase (α * n)) (typeICoefficient U V * ζ)‖ ≤ Real.log N * RealTypeI.hyperbolicCost (N : ℝ) (min (U * V) N) q := by apply (second_typeI_bound (fun n => RealPhase.phase (α * n)) N U V (fun d => truncatedInv ((N : ℝ) / d) (intDistance (α * d))) (fun d _ => norm_phase_Ioc_mul_le_variable α N d (N / d) le_rfl)).trans exact mul_le_mul_of_nonneg_left (sum_variable_reciprocal_Ioc_le α a q hq hcop happrox N (min (U * V) N)) (Real.log_natCast_nonneg N)
end Problem337.VaughanHyperbolic
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160import OAI.NumberTheory.EgyptianFractions.VaughanWeightedimport OAI.NumberTheory.EgyptianFractions.ThreePrimePartialSummation
namespace OAInoncomputable sectionopen scoped BigOperators ArithmeticFunction ArithmeticFunction.Moebius ArithmeticFunction.zeta
namespace Problem337.Vaughan
/-- Indexing positive initial intervals by a zero-based range. -/lemma sum_Ioc_zero_eq_sum_range_succ {R : Type*} [AddCommMonoid R] (f : ℕ → R) (N : ℕ) : (∑ j ∈ Finset.Ioc 0 N, f j) = ∑ j ∈ Finset.range N, f (j + 1) := by induction N with | zero => simp | succ N ih => rw [Finset.sum_Ioc_succ_top (Nat.zero_le N), Finset.sum_range_succ, ih]
/-- Adding a logarithmic weight costs at most twice the endpoint logarithm.The prefix bound remains explicit; no cancellation estimate is assumed silently. -/theorem log_weighted_sum_norm_le (w : ℕ → ℂ) (N : ℕ) (B : ℝ) (hprefix : ∀ k ≤ N, ‖∑ j ∈ Finset.Ioc 0 k, w j‖ ≤ B) : ‖∑ j ∈ Finset.Ioc 0 N, (Real.log j : ℂ) * w j‖ ≤ 2 * B * Real.log N := by cases N with | zero => simp | succ n => have hlog (j : ℕ) : 0 ≤ Real.log (j + 1 : ℕ) := Real.log_nonneg (by exact_mod_cast Nat.succ_le_succ (Nat.zero_le j)) have hmono (j : ℕ) : Real.log (j + 1 : ℕ) ≤ Real.log (j + 1 + 1 : ℕ) := by apply Real.log_le_log · positivity · exact_mod_cast Nat.le_succ (j + 1) have hvar : (∑ j ∈ Finset.range n, ‖(Real.log (j + 1 + 1 : ℕ) : ℂ) - (Real.log (j + 1 : ℕ) : ℂ)‖) = Real.log (n + 1 : ℕ) := by calc _ = ∑ j ∈ Finset.range n, (Real.log (j + 1 + 1 : ℕ) - Real.log (j + 1 : ℕ)) := by apply Finset.sum_congr rfl intro j hj rw [← Complex.ofReal_sub, Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg (sub_nonneg.mpr (hmono j))] _ = _ := by simpa using Finset.sum_range_sub (fun j => Real.log (j + 1 : ℕ)) n have h := ThreePrimeAnalysis.weighted_sum_norm_le_partial_sum_bound (fun j => w (j + 1)) (fun j => (Real.log (j + 1 : ℕ) : ℂ)) n B (by intro k hk simpa only [sum_Ioc_zero_eq_sum_range_succ] using hprefix k hk) rw [hvar, Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg (hlog n)] at h rw [sum_Ioc_zero_eq_sum_range_succ] convert h using 1 ring
/-- Type I logarithmic bilinear estimate for coefficients bounded by one. -/theorem norm_log_bilinear_sum_le (w : ℕ → ℂ) (N A : ℕ) (c B : ℕ → ℝ) (hA : A ≤ N) (hc : ∀ a ∈ Finset.Ioc 0 A, |c a| ≤ 1) (hprefix : ∀ a ∈ Finset.Ioc 0 A, ∀ k ≤ N / a, ‖∑ b ∈ Finset.Ioc 0 k, w (a * b)‖ ≤ B a) : ‖∑ a ∈ Finset.Ioc 0 A, (c a : ℂ) * ∑ b ∈ Finset.Ioc 0 (N / a), (Real.log b : ℂ) * w (a * b)‖ ≤ 2 * Real.log N * ∑ a ∈ Finset.Ioc 0 A, B a := by calc _ ≤ ∑ a ∈ Finset.Ioc 0 A, ‖(c a : ℂ) * ∑ b ∈ Finset.Ioc 0 (N / a), (Real.log b : ℂ) * w (a * b)‖ := norm_sum_le _ _ _ ≤ ∑ a ∈ Finset.Ioc 0 A, 2 * Real.log N * B a := by apply Finset.sum_le_sum intro a ha obtain ⟨ha0, haA⟩ := Finset.mem_Ioc.mp ha have haN := haA.trans hA have hq : 1 ≤ N / a := (Nat.le_div_iff_mul_le ha0).mpr (by simpa using haN) have hB : 0 ≤ B a := by simpa using hprefix a ha 0 (Nat.zero_le _) have hlog : Real.log (N / a : ℕ) ≤ Real.log N := by apply Real.log_le_log · exact_mod_cast (Nat.zero_lt_of_lt hq) · exact_mod_cast Nat.div_le_self N a rw [norm_mul, Complex.norm_real, Real.norm_eq_abs] calc _ ≤ 1 * ‖∑ b ∈ Finset.Ioc 0 (N / a), (Real.log b : ℂ) * w (a * b)‖ := mul_le_mul_of_nonneg_right (hc a ha) (norm_nonneg _) _ ≤ 2 * B a * Real.log (N / a : ℕ) := by simpa using log_weighted_sum_norm_le (fun b => w (a * b)) (N / a) (B a) (hprefix a ha) _ ≤ 2 * Real.log N * B a := by nlinarith [mul_le_mul_of_nonneg_left hlog (show 0 ≤ 2 * B a by positivity)] _ = _ := by rw [Finset.mul_sum]
/-- Type I bilinear estimate for coefficients with the logarithmic majorant. -/theorem norm_bilinear_sum_le_log (w : ℕ → ℂ) (N A : ℕ) (c B : ℕ → ℝ) (hA : A ≤ N) (hc : ∀ a ∈ Finset.Ioc 0 A, |c a| ≤ Real.log a) (hinner : ∀ a ∈ Finset.Ioc 0 A, ‖∑ b ∈ Finset.Ioc 0 (N / a), w (a * b)‖ ≤ B a) : ‖∑ a ∈ Finset.Ioc 0 A, (c a : ℂ) * ∑ b ∈ Finset.Ioc 0 (N / a), w (a * b)‖ ≤ Real.log N * ∑ a ∈ Finset.Ioc 0 A, B a := by calc _ ≤ ∑ a ∈ Finset.Ioc 0 A, ‖(c a : ℂ) * ∑ b ∈ Finset.Ioc 0 (N / a), w (a * b)‖ := norm_sum_le _ _ _ ≤ ∑ a ∈ Finset.Ioc 0 A, Real.log N * B a := by apply Finset.sum_le_sum intro a ha obtain ⟨ha0, haA⟩ := Finset.mem_Ioc.mp ha have hB : 0 ≤ B a := (norm_nonneg _).trans (hinner a ha) have hlog : Real.log a ≤ Real.log N := Real.log_le_log (by exact_mod_cast ha0) (by exact_mod_cast haA.trans hA) have hlogN : 0 ≤ Real.log N := (abs_nonneg _).trans ((hc a ha).trans hlog) rw [norm_mul, Complex.norm_real, Real.norm_eq_abs] exact mul_le_mul ((hc a ha).trans hlog) (hinner a ha) (norm_nonneg _) hlogN _ = _ := by rw [Finset.mul_sum]
/-- The first Vaughan Type I term in its finite bilinear form. -/theorem first_typeI_sum_bound (w : ℕ → ℂ) (N U : ℕ) (B : ℕ → ℝ) (hprefix : ∀ a ∈ Finset.Ioc 0 (min U N), ∀ k ≤ N / a, ‖∑ b ∈ Finset.Ioc 0 k, w (a * b)‖ ≤ B a) : ‖∑ a ∈ Finset.Ioc 0 (min U N), ((μ a : ℝ) : ℂ) * ∑ b ∈ Finset.Ioc 0 (N / a), (Real.log b : ℂ) * w (a * b)‖ ≤ 2 * Real.log N * ∑ a ∈ Finset.Ioc 0 (min U N), B a := by apply norm_log_bilinear_sum_le w N (min U N) (fun a => (μ a : ℝ)) B (min_le_right _ _) _ hprefix intro a ha exact abs_real_moebius_le_one a
/-- The second Vaughan Type I term in its finite bilinear form. -/theorem second_typeI_sum_bound (w : ℕ → ℂ) (N U V : ℕ) (B : ℕ → ℝ) (hinner : ∀ a ∈ Finset.Ioc 0 (min (U * V) N), ‖∑ b ∈ Finset.Ioc 0 (N / a), w (a * b)‖ ≤ B a) : ‖∑ a ∈ Finset.Ioc 0 (min (U * V) N), (typeICoefficient U V a : ℂ) * ∑ b ∈ Finset.Ioc 0 (N / a), w (a * b)‖ ≤ Real.log N * ∑ a ∈ Finset.Ioc 0 (min (U * V) N), B a := by exact norm_bilinear_sum_le_log w N (min (U * V) N) (typeICoefficient U V) B (min_le_right _ _) (fun a _ => abs_typeICoefficient_le_log U V a) hinner
/-- First Type I estimate directly for the actual Vaughan convolution. -/theorem first_typeI_bound (w : ℕ → ℂ) (N U : ℕ) (B : ℕ → ℝ) (hprefix : ∀ a ∈ Finset.Ioc 0 (min U N), ∀ k ≤ N / a, ‖∑ b ∈ Finset.Ioc 0 k, w (a * b)‖ ≤ B a) : ‖weightedSum (Finset.Ioc 0 N) w (shortPart U (μ : ArithmeticFunction ℝ) * ArithmeticFunction.log)‖ ≤ 2 * Real.log N * ∑ a ∈ Finset.Ioc 0 (min U N), B a := by rw [first_typeI_eq_sum] exact first_typeI_sum_bound w N U B hprefix
/-- Second Type I estimate directly for the actual Vaughan convolution. -/theorem second_typeI_bound (w : ℕ → ℂ) (N U V : ℕ) (B : ℕ → ℝ) (hinner : ∀ a ∈ Finset.Ioc 0 (min (U * V) N), ‖∑ b ∈ Finset.Ioc 0 (N / a), w (a * b)‖ ≤ B a) : ‖weightedSum (Finset.Ioc 0 N) w (typeICoefficient U V * ζ)‖ ≤ Real.log N * ∑ a ∈ Finset.Ioc 0 (min (U * V) N), B a := by rw [second_typeI_eq_sum] exact second_typeI_sum_bound w N U V B hinner
end Problem337.Vaughan
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102import OAI.NumberTheory.EgyptianFractions.VaughanRealTypeIHyperbolic
namespace OAInoncomputable sectionopen scoped BigOperators ArithmeticFunction ArithmeticFunction.Moebius ArithmeticFunction.zeta
namespace Problem337.VaughanHyperbolic
/-- A common logarithmic majorant for both actual Type I costs. -/theorem hyperbolicCost_min_le (N A q : ℕ) (hN : 1 ≤ N) (hq : 0 < q) (hqN : q ≤ N) : RealTypeI.hyperbolicCost N (min A N) q ≤ 8 * ((N : ℝ) / q + A + q) * (1 + Real.log (2 * (N : ℝ))) := by have hNr : (1 : ℝ) ≤ N := by exact_mod_cast hN have hqr : (1 : ℝ) ≤ q := by exact_mod_cast hq have hqNr : (q : ℝ) ≤ N := by exact_mod_cast hqN have hminA : ((min A N : ℕ) : ℝ) ≤ A := by exact_mod_cast min_le_left A N have hminN : ((min A N : ℕ) : ℝ) ≤ N := by exact_mod_cast min_le_right A N have hlogq : 0 ≤ 1 + Real.log (2 * (q : ℝ)) := by have := Real.log_nonneg (show 1 ≤ 2 * (q : ℝ) by linarith) linarith have hH : 0 ≤ 1 + Real.log (2 * (N : ℝ)) := by have := Real.log_nonneg (show 1 ≤ 2 * (N : ℝ) by linarith) linarith have hlogqN : 1 + Real.log (2 * (q : ℝ)) ≤ 1 + Real.log (2 * (N : ℝ)) := by gcongr have hlogmin : 1 + Real.log (((min A N : ℕ) : ℝ) + 1) ≤ 1 + Real.log (2 * (N : ℝ)) := by exact add_le_add le_rfl (Real.log_le_log (by positivity) (by linarith)) unfold RealTypeI.hyperbolicCost calc _ ≤ 8 * ((A : ℝ) + q) * (1 + Real.log (2 * (N : ℝ))) + (4 * (N : ℝ) / q) * (1 + Real.log (2 * (N : ℝ))) := by apply add_le_add · exact mul_le_mul (by gcongr) hlogqN hlogq (by positivity) · exact mul_le_mul_of_nonneg_left hlogmin (by positivity) _ ≤ _ := by have hd : 0 ≤ (N : ℝ) / q := by positivity simp only [mul_div_assoc] nlinarith [mul_nonneg hd hH]
private lemma log_le_common (N : ℕ) (hN : 1 ≤ N) : Real.log N ≤ 1 + Real.log (2 * (N : ℝ)) := by have hNr : (1 : ℝ) ≤ N := by exact_mod_cast hN have h := Real.log_le_log (show 0 < (N : ℝ) by linarith) (show (N : ℝ) ≤ 2 * N by linarith) linarith
/-- Uniform Type I bound in the parameters of the optimized Vaughan cutoff. -/theorem first_typeI_normalized_bound (α : ℝ) (a : ℤ) (q : ℕ) (hq : 0 < q) (hcop : IsCoprime a (q : ℤ)) (happrox : |α - (a : ℝ) / q| ≤ 1 / (q : ℝ) ^ 2) (N U : ℕ) (hN : 1 ≤ N) (hqN : q ≤ N) : ‖Vaughan.weightedSum (Finset.Ioc 0 N) (fun n => RealPhase.phase (α * n)) (Vaughan.shortPart U (μ : ArithmeticFunction ℝ) * ArithmeticFunction.log)‖ ≤ 16 * (1 + Real.log (2 * (N : ℝ))) ^ 2 * ((N : ℝ) / q + U + q) := by have hH : 0 ≤ 1 + Real.log (2 * (N : ℝ)) := (Real.log_natCast_nonneg N).trans (log_le_common N hN) calc _ ≤ 2 * Real.log N * RealTypeI.hyperbolicCost N (min U N) q := first_typeI_real_phase_bound α a q hq hcop happrox N U _ ≤ 2 * Real.log N * (8 * ((N : ℝ) / q + U + q) * (1 + Real.log (2 * (N : ℝ)))) := mul_le_mul_of_nonneg_left (hyperbolicCost_min_le N U q hN hq hqN) (by positivity) _ ≤ _ := by have h := mul_le_mul_of_nonneg_right (log_le_common N hN) (show 0 ≤ 16 * ((N : ℝ) / q + U + q) * (1 + Real.log (2 * (N : ℝ))) by positivity) nlinarith
/-- Uniform second Type I bound with the full product support retained. -/theorem second_typeI_normalized_bound (α : ℝ) (a : ℤ) (q : ℕ) (hq : 0 < q) (hcop : IsCoprime a (q : ℤ)) (happrox : |α - (a : ℝ) / q| ≤ 1 / (q : ℝ) ^ 2) (N U V : ℕ) (hN : 1 ≤ N) (hqN : q ≤ N) : ‖Vaughan.weightedSum (Finset.Ioc 0 N) (fun n => RealPhase.phase (α * n)) (Vaughan.typeICoefficient U V * ζ)‖ ≤ 8 * (1 + Real.log (2 * (N : ℝ))) ^ 2 * ((N : ℝ) / q + U * V + q) := by have hH : 0 ≤ 1 + Real.log (2 * (N : ℝ)) := (Real.log_natCast_nonneg N).trans (log_le_common N hN) calc _ ≤ Real.log N * RealTypeI.hyperbolicCost N (min (U * V) N) q := second_typeI_real_phase_bound α a q hq hcop happrox N U V _ ≤ Real.log N * (8 * ((N : ℝ) / q + (U * V : ℕ) + q) * (1 + Real.log (2 * (N : ℝ)))) := mul_le_mul_of_nonneg_left (hyperbolicCost_min_le N (U * V) q hN hq hqN) (Real.log_natCast_nonneg N) _ ≤ _ := by have h := mul_le_mul_of_nonneg_right (log_le_common N hN) (show 0 ≤ 8 * ((N : ℝ) / q + U * V + q) * (1 + Real.log (2 * (N : ℝ))) by positivity) push_cast nlinarith
end Problem337.VaughanHyperbolic
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108import OAI.NumberTheory.EgyptianFractions.VaughanIdentityimport OAI.NumberTheory.EgyptianFractions.VaughanHyperbolaimport Mathlib
namespace OAInoncomputable sectionopen scoped BigOperators ArithmeticFunction ArithmeticFunction.Moebius ArithmeticFunction.zeta
namespace Problem337.Vaughan
/-- Finite complex weighted sum of a real arithmetic function. -/def weightedSum (s : Finset ℕ) (w : ℕ → ℂ) (f : ArithmeticFunction ℝ) : ℂ := ∑ n ∈ s, (f n : ℂ) * w n
@[simp] theorem weightedSum_add (s : Finset ℕ) (w : ℕ → ℂ) (f g : ArithmeticFunction ℝ) : weightedSum s w (f + g) = weightedSum s w f + weightedSum s w g := by simp [weightedSum, add_mul, Finset.sum_add_distrib]
@[simp] theorem weightedSum_sub (s : Finset ℕ) (w : ℕ → ℂ) (f g : ArithmeticFunction ℝ) : weightedSum s w (f - g) = weightedSum s w f - weightedSum s w g := by simp [sub_eq_add_neg, weightedSum, add_mul, Finset.sum_add_distrib]
/-- Exact complex weighted Vaughan decomposition, using the canonical cutoff API. -/theorem weighted_identity (s : Finset ℕ) (w : ℕ → ℂ) (U V : ℕ) : weightedSum s w Λ = weightedSum s w (shortPart V Λ) + weightedSum s w (shortPart U (μ : ArithmeticFunction ℝ) * ArithmeticFunction.log) - weightedSum s w (typeICoefficient U V * ζ) + weightedSum s w (typeIICoefficient U * longPart V Λ) := by have h := congrArg (weightedSum s w) (vonMangoldt_identity U V) simpa only [weightedSum_add, weightedSum_sub, typeICoefficient, typeIICoefficient] using h
/-- The Type II convolution is supported where both factors exceed the cutoffs. -/theorem typeII_apply (U V n : ℕ) : (typeIICoefficient U * longPart V Λ) n = ∑ d ∈ n.divisorsAntidiagonal.filter (fun d => U < d.1 ∧ V < d.2), typeIICoefficient U d.1 * Λ d.2 := by rw [ArithmeticFunction.mul_apply, Finset.sum_filter] apply Finset.sum_congr rfl intro d hd by_cases hU : U < d.1 · by_cases hV : V < d.2 <;> simp [hU, hV] · simp [hU, typeIICoefficient_eq_zero U d.1 (not_lt.mp hU)]
lemma positive_interval (N : ℕ) : Finset.Icc 1 N = Finset.Ioc 0 N := by ext n simp only [Finset.mem_Icc, Finset.mem_Ioc] omega
/-- A convolution sum with its outer coefficient factored out. -/theorem weightedSum_mul (N : ℕ) (w : ℕ → ℂ) (f g : ArithmeticFunction ℝ) : weightedSum (Finset.Ioc 0 N) w (f * g) = ∑ a ∈ Finset.Ioc 0 N, (f a : ℂ) * ∑ b ∈ Finset.Ioc 0 (N / a), (g b : ℂ) * w (a * b) := by simpa only [weightedSum, positive_interval, Finset.mul_sum, Complex.ofReal_mul, mul_assoc] using sum_real_convolution_eq_nested N f g w
/-- A compactly supported coefficient restricts the outer interval exactly. -/theorem weightedSum_mul_of_support (N A : ℕ) (w : ℕ → ℂ) (f g : ArithmeticFunction ℝ) (hf : ∀ a, A < a → f a = 0) : weightedSum (Finset.Ioc 0 N) w (f * g) = ∑ a ∈ Finset.Ioc 0 (min A N), (f a : ℂ) * ∑ b ∈ Finset.Ioc 0 (N / a), (g b : ℂ) * w (a * b) := by rw [weightedSum_mul] symm apply Finset.sum_subset · intro a ha obtain ⟨ha0, haAN⟩ := Finset.mem_Ioc.mp ha exact Finset.mem_Ioc.mpr ⟨ha0, (le_min_iff.mp haAN).2⟩ · intro a ha hnot have hA : A < a := by simp only [Finset.mem_Ioc] at ha hnot omega simp [hf a hA]
/-- Exact first Type I sum with its actual short cutoff. -/theorem first_typeI_eq_sum (N U : ℕ) (w : ℕ → ℂ) : weightedSum (Finset.Ioc 0 N) w (shortPart U (μ : ArithmeticFunction ℝ) * ArithmeticFunction.log) = ∑ a ∈ Finset.Ioc 0 (min U N), ((μ a : ℝ) : ℂ) * ∑ b ∈ Finset.Ioc 0 (N / a), (Real.log b : ℂ) * w (a * b) := by rw [weightedSum_mul_of_support N U w _ _ (by intro a ha simp [not_le.mpr ha])] apply Finset.sum_congr rfl intro a ha have haU := (le_min_iff.mp (Finset.mem_Ioc.mp ha).2).1 simp [haU]
/-- Exact second Type I sum, supported up to the product cutoff. -/theorem second_typeI_eq_sum (N U V : ℕ) (w : ℕ → ℂ) : weightedSum (Finset.Ioc 0 N) w (typeICoefficient U V * ζ) = ∑ a ∈ Finset.Ioc 0 (min (U * V) N), (typeICoefficient U V a : ℂ) * ∑ b ∈ Finset.Ioc 0 (N / a), w (a * b) := by rw [weightedSum_mul_of_support N (U * V) w _ _ (typeICoefficient_eq_zero U V)] apply Finset.sum_congr rfl intro a ha congr 1 apply Finset.sum_congr rfl intro b hb simp [ArithmeticFunction.zeta_apply_ne (Nat.ne_of_gt (Finset.mem_Ioc.mp hb).1)]
end Problem337.Vaughan
end
end OAI12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455import Mathlib
namespace OAInoncomputable sectionopen scoped BigOperatorsnamespace Problem337
/-- A weighted binomial bound, allowing a real cutoff on subset size. -/theorem weighted_binomial_bound (L : ℕ) (t q : ℝ) (hq0 : 0 < q) (hq1 : q ≤ 1) : (∑ j ∈ (Finset.range (L + 1)).filter (fun j : ℕ => (j : ℝ) ≤ t), (Nat.choose L j : ℝ)) ≤ q ^ (-t) * (1 + q) ^ L := by have hw : q ^ t * (∑ j ∈ (Finset.range (L + 1)).filter (fun j : ℕ => (j : ℝ) ≤ t), (Nat.choose L j : ℝ)) ≤ (1 + q) ^ L := by rw [Finset.mul_sum] calc _ ≤ ∑ j ∈ (Finset.range (L + 1)).filter (fun j : ℕ => (j : ℝ) ≤ t), q ^ j * (Nat.choose L j : ℝ) := by apply Finset.sum_le_sum intro j hj apply mul_le_mul_of_nonneg_right _ (Nat.cast_nonneg _) simpa only [Real.rpow_natCast] using Real.rpow_le_rpow_of_exponent_ge hq0 hq1 (Finset.mem_filter.mp hj).2 _ ≤ ∑ j ∈ Finset.range (L + 1), q ^ j * (Nat.choose L j : ℝ) := by apply Finset.sum_le_sum_of_subset_of_nonneg (Finset.filter_subset _ _) intro j hj hnot positivity _ = (1 + q) ^ L := by rw [show 1 + q = q + 1 by ring, add_pow] simp have hqt : 0 < q ^ t := Real.rpow_pos_of_pos hq0 t have hdiv : (∑ j ∈ (Finset.range (L + 1)).filter (fun j : ℕ => (j : ℝ) ≤ t), (Nat.choose L j : ℝ)) ≤ (1 + q) ^ L / q ^ t := (le_div_iff₀ hqt).2 (by simpa only [mul_comm] using hw) simpa only [Real.rpow_neg hq0.le, div_eq_mul_inv, mul_comm] using hdiv
/-- Exponential form of the weighted subset count used in divisor estimates. -/theorem weighted_binomial_exp_bound (L : ℕ) (t q : ℝ) (hq0 : 0 < q) (hq1 : q ≤ 1) : (∑ j ∈ (Finset.range (L + 1)).filter (fun j : ℕ => (j : ℝ) ≤ t), (Nat.choose L j : ℝ)) ≤ Real.exp (-t * Real.log q + (L : ℝ) * q) := by apply (weighted_binomial_bound L t q hq0 hq1).trans have hqadd : 0 < 1 + q := by positivity rw [← Real.rpow_natCast (1 + q) L, Real.rpow_def_of_pos hq0, Real.rpow_def_of_pos hqadd, ← Real.exp_add] apply Real.exp_le_exp.mpr have hlog : Real.log (1 + q) ≤ q := by simpa using Real.log_le_sub_one_of_pos hqadd nlinarith [mul_le_mul_of_nonneg_left hlog (Nat.cast_nonneg L : (0 : ℝ) ≤ L)]
end Problem337
end
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336import OAI.NumberTheory.GaussianMoat.SieveCertificate
namespace OAI
namespace GaussianMoat
sectionopen scoped BigOperators Classical
noncomputable def bandConstant (D : ℝ) : ℝ := 10000+100*|Real.log D|+100*|Real.log (max D ((latticeBall (4*D)).card:ℝ))|
lemma bandConstant_pos (D : ℝ) : 0<bandConstant D := by unfold bandConstant positivity
theorem entropyBand_from_margin (s : SplitSieve) (pre post : List ℕ) (N l : ℕ) {D g U δ : ℝ} (hD : 1≤D) (hg : 0<g) (hg1 : g≤1/200) (hU : 0<U) (hL : 1≤ s.meanLog) (hmargin : bandConstant D*s.meanLog≤g^5*bandScale g U l) (hcap : ⌊U/s.meanLog⌋₊≤ s.primes.card) (hpost : ∀ n∈post, (n:ℝ)≤Real.exp (g*bandScale g U l)) (hN : (N:ℝ)≤Real.exp (g*bandScale g U l)) (hlen : (post.length+2:ℝ)≤Real.exp (g*bandScale g U l)) (hδ : (1/2:ℝ)^l+90*g≤δ) : Nonempty (EntropyBand s D (pre++List.ofFn (fun i : Fin l => bandLength g U i.val)++post) N (bandSize s g U l) δ) := by let V := bandScale g U l have hV : 0<V := bandScale_pos hg hU l have hg01 : g≤1 := by linarith only [hg1] have hg5 : g^5≤g := by have hh : g^4≤1 := pow_le_one₀ hg.le hg01 calc g^5=g^4*g := by ring _ ≤ 1*g := mul_le_mul_of_nonneg_right hh hg.le _ = g := one_mul _ have hg52 : g^5≤g^2 := by have hh : g^3≤1 := pow_le_one₀ hg.le hg01 calc g^5=g^3*g^2 := by ring _ ≤ 1*g^2 := mul_le_mul_of_nonneg_right hh (sq_nonneg _) _ = g^2 := one_mul _ have hC : bandConstant D≤g^5*V := by have hh := mul_le_mul_of_nonneg_left hL (bandConstant_pos D).le simp only [mul_one] at hh exact hh.trans hmargin have hCg := hC.trans (mul_le_mul_of_nonneg_right hg5 hV.le) have hCg2 := hC.trans (mul_le_mul_of_nonneg_right hg52 hV.le) have hCV := hCg.trans (by nlinarith only [hg01,hV] : g*V≤V) have hl16 := Real.log_le_sub_one_of_pos (by norm_num : (0:ℝ)<16) have hl18 := Real.log_le_sub_one_of_pos (by norm_num : (0:ℝ)<18) have hl36 := Real.log_le_sub_one_of_pos (by norm_num : (0:ℝ)<36) have hld := le_abs_self (Real.log D) have hla := le_abs_self (Real.log (max D ((latticeBall (4*D)).card:ℝ))) have ha := abs_nonneg (Real.log D) have hb := abs_nonneg (Real.log (max D ((latticeBall (4*D)).card:ℝ))) have hC640 : 640≤bandConstant D := by unfold bandConstant; linarith only [ha,hb] apply entropyBand_from_suffix s pre post N l hD hg hg1 hU hL · dsimp only [bandConstant] at hCg linarith only [hCg,hl18,ha,hb] · exact (mul_le_mul_of_nonneg_right hC640 (by linarith only [hL])).trans hmargin · dsimp only [bandConstant] at hCg2 linarith only [hCg2,hl16,hla,ha,hb] · dsimp only [bandConstant] at hCg nlinarith only [hCg,hl36,hld,ha,hb] · dsimp only [bandConstant] at hCV linarith only [hCV,hl16,hld,ha,hb] · exact hcap · exact hpost · exact hN · exact hlen · dsimp only [bandConstant] at hCg linarith only [hCg,hl36,hld,ha,hb] · exact hδ
open scoped BigOperators Classicalopen Filter
theorem eventually_poly_le_exp (C : ℝ) {a : ℝ} (ha : 0<a) (d : ℕ) : ∀ᶠ y : ℝ in atTop, C*y^d≤a*Real.exp y := by by_cases hC : 0<C · have hh := (Real.isLittleO_pow_exp_atTop (n := d)).bound (div_pos ha hC) filter_upwards [hh,eventually_ge_atTop (0:ℝ)] with y hy hy0 rw [Real.norm_of_nonneg (pow_nonneg hy0 _),Real.norm_of_nonneg (Real.exp_nonneg _)] at hy have hm := mul_le_mul_of_nonneg_left hy hC.le rwa [←mul_assoc,mul_div_cancel₀ _ hC.ne'] at hm · filter_upwards [eventually_ge_atTop (0:ℝ)] with y hy exact (mul_nonpos_of_nonpos_of_nonneg (le_of_not_gt hC) (pow_nonneg hy _)).trans (mul_nonneg ha.le (Real.exp_nonneg _))
theorem eventually_linear_le_square (A B : ℝ) : ∀ᶠ y : ℝ in atTop, A*y+B≤y^2 := by filter_upwards [eventually_ge_atTop (max (|A|+|B|+1) 1)] with y hy have h1 : 1≤y := (le_max_right _ _).trans hy have h2 : |A|+|B|+1≤y := (le_max_left _ _).trans hy have h3 : A≤|A| := le_abs_self _ have h4 : B≤|B| := le_abs_self _ nlinarith only [h1,h2,h3,h4,abs_nonneg A,abs_nonneg B]
noncomputable def accurateGrid (m : ℕ) : ℝ := Real.exp (-((m:ℝ)^2))def accurateIterations (m : ℕ) : ℕ := 4*m^2
lemma accurateGrid_pos (m : ℕ) : 0<accurateGrid m := Real.exp_pos _
lemma accurateGrid_le_one (m : ℕ) : accurateGrid m≤1 := by exact Real.exp_le_one_iff.mpr (neg_nonpos.mpr (sq_nonneg _))
lemma accurateIterations_error (m : ℕ) : (1/2:ℝ)^(accurateIterations m)+90*accurateGrid m≤91*accurateGrid m := by have hl : (1/2:ℝ)≤Real.log 2 := by have hh := Real.one_sub_inv_le_log_of_pos (by norm_num : (0:ℝ)<2) norm_num at hh exact hh have he : (1/2:ℝ)^(accurateIterations m)≤accurateGrid m := by rw [show (1/2:ℝ)=Real.exp (-Real.log 2) by rw [Real.exp_neg,Real.exp_log (by norm_num)]; norm_num] rw [←Real.exp_nat_mul] apply Real.exp_le_exp.mpr simp only [accurateIterations,Nat.cast_mul,Nat.cast_pow,Nat.cast_ofNat] nlinarith only [sq_nonneg (m:ℝ),hl] linarith only [he]
lemma accurateGrid_scale (m : ℕ) (a : ℝ) : bandScale (accurateGrid m) (Real.exp (a*Real.exp m)) (accurateIterations m)= Real.exp (a*Real.exp m-8*(m:ℝ)^4) := by unfold bandScale accurateGrid accurateIterations rw [←Real.exp_nat_mul,←Real.exp_nat_mul,←Real.exp_add] congr 1 push_cast ring
theorem eventually_accurate_scale {a : ℝ} (ha : 0<a) (k : ℕ) : ∀ᶠ m : ℕ in atTop, Real.exp ((a/2)*Real.exp m)≤(accurateGrid m)^k * bandScale (accurateGrid m) (Real.exp (a*Real.exp m)) (accurateIterations m) := by have h4 := eventually_poly_le_exp 8 (a := a/4) (by positivity) 4 have h2 := eventually_poly_le_exp (k:ℝ) (a := a/4) (by positivity) 2 have hh := (h4.and h2).filter_mono (show Filter.map ((↑) : ℕ → ℝ) atTop≤atTop from tendsto_natCast_atTop_atTop) change ∀ᶠ m : ℕ in atTop, _ at hh filter_upwards [hh] with m hm rw [accurateGrid_scale] unfold accurateGrid rw [←Real.exp_nat_mul,←Real.exp_add] apply Real.exp_le_exp.mpr nlinarith only [hm.1,hm.2]
theorem eventually_accurate_error (C : ℝ) {ε : ℝ} (hε : 0<ε) : ∀ᶠ m : ℕ in atTop, 91*accurateGrid m*(C*Real.exp m)≤ε := by by_cases hC : 0<C · have hh := eventually_linear_le_square 1 (Real.log (91*C/ε)) have hh' := hh.filter_mono (show Filter.map ((↑) : ℕ → ℝ) atTop≤atTop from tendsto_natCast_atTop_atTop) filter_upwards [hh'] with m hm change 1*(m:ℝ)+Real.log (91*C/ε)≤(m:ℝ)^2 at hm have he : Real.exp ((m:ℝ)-(m:ℝ)^2)≤ε/(91*C) := by rw [←Real.exp_log (show 0<ε/(91*C) by positivity)] apply Real.exp_le_exp.mpr rw [Real.log_div (by positivity) (by positivity)] rw [Real.log_div (by positivity) hε.ne'] at hm linarith only [hm] have hmul := (le_div_iff₀ (show 0<91*C by positivity)).mp he unfold accurateGrid rw [show 91*Real.exp (-((m:ℝ)^2))*(C*Real.exp m)= Real.exp ((m:ℝ)-(m:ℝ)^2)*(91*C) by rw [Real.exp_sub,Real.exp_neg]; ring] exact hmul · filter_upwards [] with m have : C*Real.exp (m:ℝ)≤0 := mul_nonpos_of_nonpos_of_nonneg (le_of_not_gt hC) (Real.exp_nonneg _) exact (mul_nonpos_of_nonneg_of_nonpos (by exact mul_nonneg (by norm_num) (accurateGrid_pos m).le : 0≤91*accurateGrid m) this).trans hε.le
end
sectionopen scoped BigOperators Classicalopen Filter
lemma eventually_const_le_exp_mul {a : ℝ} (ha : 0<a) (C : ℝ) : ∀ᶠ m : ℕ in atTop, C≤a*Real.exp m := by have hh : Tendsto (fun m : ℕ => Real.exp (m:ℝ)*a) atTop atTop := (Real.tendsto_exp_atTop.comp tendsto_natCast_atTop_atTop).atTop_mul_const ha simpa only [mul_comm] using hh.eventually (eventually_ge_atTop C)
lemma eventually_mul_le_double_exp {a : ℝ} (ha : 0<a) (C : ℝ) : ∀ᶠ m : ℕ in atTop, C*Real.exp m≤Real.exp (a*Real.exp m) := by have hh := eventually_poly_le_exp (C/a) (a := 1) (by norm_num) 1 have ht : Tendsto (fun m : ℕ => a*Real.exp m) atTop atTop := by simpa only [Function.comp_apply] using Filter.Tendsto.const_mul_atTop ha (Real.tendsto_exp_atTop.comp (tendsto_natCast_atTop_atTop (R := ℝ))) filter_upwards [ht.eventually hh] with m hm simpa only [pow_one,one_mul,←mul_assoc,div_mul_cancel₀ _ ha.ne'] using hm
lemma eventually_accurate_small {ε : ℝ} (hε : 0<ε) : ∀ᶠ m : ℕ in atTop, accurateGrid m≤ε := by have hh := eventually_linear_le_square 0 (-Real.log ε) filter_upwards [tendsto_natCast_atTop_atTop.eventually hh] with m hm change 0*(m:ℝ)-Real.log ε≤(m:ℝ)^2 at hm unfold accurateGrid rw [←Real.exp_log hε] apply Real.exp_le_exp.mpr linarith only [hm]
lemma dense_sieve_cap (s : SplitSieve) (hne : s.primes.Nonempty) {T δ U : ℝ} (hT : 2≤T) (hp : ∀ p∈s.primes, T≤(p:ℝ) ∧ (p:ℝ)≤2*T) (hdense : δ*T/Real.log (2*T)≤ s.primes.card) (hsize : 2*U≤δ*T) : ⌊U/s.meanLog⌋₊≤ s.primes.card := by have hT0 : 0<T := by linarith only [hT] have hlogT : 0<Real.log T := Real.log_pos (by linarith only [hT]) have hm := s.meanLog_bounds hne hT0 hp have hmean : 0<s.meanLog := hlogT.trans_le hm.1 have hl2 : Real.log 2≤Real.log T := Real.log_le_log (by norm_num) hT have hhlog : Real.log (2*T)≤2*s.meanLog := by rw [Real.log_mul (by norm_num) hT0.ne'] linarith only [hl2,hm.1] have hlo : 0<Real.log (2*T) := Real.log_pos (by linarith only [hT]) have hd : δ*T≤(s.primes.card:ℝ)*Real.log (2*T) := (div_le_iff₀ hlo).mp hdense have hk : δ*T≤(s.primes.card:ℝ)*(2*s.meanLog) := hd.trans (mul_le_mul_of_nonneg_left hhlog (Nat.cast_nonneg _)) apply Nat.floor_le_of_le apply (div_le_iff₀ hmean).mpr nlinarith only [hsize,hk]
theorem eventually_accurate_band {D A B a b δ : ℝ} (hD : 1≤D) (hA : 0<A) (ha : 0<a) (haA : a<A) (hba : b≤a/2) (hδ : 0<δ) : ∀ᶠ m : ℕ in atTop, ∀ (s : SplitSieve) (T : ℝ) (pre post : List ℕ) (N : ℕ), s.primes.Nonempty → (∀ p∈s.primes, T≤(p:ℝ) ∧ (p:ℝ)≤2*T) → δ*T/Real.log (2*T)≤ s.primes.card → Real.exp (A*Real.exp m)≤T → Real.log T≤B*Real.exp m → (∀ n∈post, (n:ℝ)≤Real.exp (Real.exp (b*Real.exp m))) → (N:ℝ)≤Real.exp (Real.exp (b*Real.exp m)) → (post.length+2:ℝ)≤Real.exp (Real.exp (b*Real.exp m)) → Nonempty (EntropyBand s D (pre++List.ofFn (fun i : Fin (accurateIterations m) => bandLength (accurateGrid m) (Real.exp (a*Real.exp m)) i.val)++post) N (bandSize s (accurateGrid m) (Real.exp (a*Real.exp m)) (accurateIterations m)) (91*accurateGrid m)) := by have hlarge := eventually_mul_le_double_exp (a := a/2) (by positivity) (bandConstant D*(B+1)) have hgap := eventually_const_le_exp_mul (a := A-a) (by linarith only [haA]) (Real.log (2/δ)) have htwo := eventually_const_le_exp_mul hA 2 filter_upwards [eventually_accurate_scale ha 5,eventually_accurate_scale ha 1, eventually_accurate_small (show (0:ℝ)<1/200 by norm_num),hlarge,hgap,htwo] with m hm5 hm1 hsmall hlarge hgap htwo intro s T pre post N hne hp hdense hT hThi hpost hN hlen have he1 : 1≤Real.exp (m:ℝ) := Real.one_le_exp_iff.mpr (Nat.cast_nonneg _) have hT0 : 0<T := (Real.exp_pos _).trans_le hT have hT2 : 2≤T := by have hh := Real.add_one_le_exp (A*Real.exp m) linarith only [hh,htwo,hT] have hm := s.meanLog_bounds hne hT0 hp have hmean : 1≤ s.meanLog := by have hh := Real.log_le_log (Real.exp_pos _) hT rw [Real.log_exp] at hh linarith only [hh,hm.1,htwo] have hl2 : Real.log 2≤1 := by have hh := Real.log_le_sub_one_of_pos (by norm_num : (0:ℝ)<2) linarith only [hh] have hmean' : s.meanLog≤(B+1)*Real.exp m := by rw [Real.log_mul (by norm_num) hT0.ne'] at hm nlinarith only [hm.2,hThi,hl2,he1] have hmargin := (mul_le_mul_of_nonneg_left hmean' (bandConstant_pos D).le).trans (by simpa only [mul_assoc] using hlarge.trans hm5) have hsize : 2*Real.exp (a*Real.exp m)≤δ*T := by have he : Real.exp (a*Real.exp m+Real.log (2/δ))≤Real.exp (A*Real.exp m) := by apply Real.exp_le_exp.mpr nlinarith only [hgap] rw [Real.exp_add,Real.exp_log (div_pos (by norm_num) hδ)] at he have hh := mul_le_mul_of_nonneg_left (he.trans hT) hδ.le have heq : δ*(Real.exp (a*Real.exp m)*(2/δ))=2*Real.exp (a*Real.exp m) := by field_simp rwa [heq] at hh have hcap := dense_sieve_cap s hne hT2 hp hdense hsize have htail : Real.exp (b*Real.exp m)≤accurateGrid m* bandScale (accurateGrid m) (Real.exp (a*Real.exp m)) (accurateIterations m) := by simpa only [pow_one] using ((Real.exp_le_exp.mpr (mul_le_mul_of_nonneg_right hba (Real.exp_nonneg _))).trans hm1) exact entropyBand_from_margin s pre post N (accurateIterations m) hD (accurateGrid_pos m) hsmall (Real.exp_pos _) hmean hmargin hcap (fun n hn => (hpost n hn).trans (Real.exp_le_exp.mpr htail)) (hN.trans (Real.exp_le_exp.mpr htail)) (hlen.trans (Real.exp_le_exp.mpr htail)) (accurateIterations_error m)
end
open scoped BigOperators Classical
lemma EntropyBand.size_cap {s : SplitSieve} {D δ : ℝ} {ns : List ℕ} {N b : ℕ} (q : EntropyBand s D ns N b δ) (hmean : 0< s.meanLog) : b≤ s.primes.card := by rw [q.size] apply le_trans _ q.cap apply Nat.floor_mono apply div_le_div_of_nonneg_right _ hmean.le have hh := bandScale_antitone q.positive.le (by linarith only [q.small]) q.scale.le (Nat.zero_le q.l) simpa only [bandScale,pow_zero,one_mul] using hh
lemma EntropyBand.size_lower {s : SplitSieve} {D δ : ℝ} {ns : List ℕ} {N b : ℕ} (q : EntropyBand s D ns N b δ) (hmean : 0< s.meanLog) : bandScale q.g q.U q.l/2≤(b:ℝ)*s.meanLog := by have hV := bandScale_pos q.positive q.scale q.l have hg5 : q.g^5≤1 := pow_le_one₀ q.positive.le (by linarith only [q.small]) have hh := mul_le_mul_of_nonneg_right hg5 hV.le have hlarge := q.large have hVL : 2*s.meanLog≤bandScale q.g q.U q.l := by nlinarith only [hh,hlarge,hmean] have hf := Nat.lt_floor_add_one (bandScale q.g q.U q.l/s.meanLog) have hm := mul_lt_mul_of_pos_right hf hmean rw [div_mul_cancel₀ _ hmean.ne',add_mul,one_mul] at hm have ht : bandScale q.g q.U q.l/2≤(⌊bandScale q.g q.U q.l/s.meanLog⌋₊:ℝ)*s.meanLog := by linarith only [hm,hVL] simpa only [q.size,bandSize] using ht
lemma EntropyBand.size_pos {s : SplitSieve} {D δ : ℝ} {ns : List ℕ} {N b : ℕ} (q : EntropyBand s D ns N b δ) (hmean : 0< s.meanLog) : 0<b := by have hh := q.size_lower hmean have hV := bandScale_pos q.positive q.scale q.l by_contra h have hb : b=0 := by omega have he : (b:ℝ)=0 := by exact_mod_cast hb rw [he,zero_mul] at hh linarith only [hh,hV]
lemma bandSize_lower_of_scale {s : SplitSieve} {g U C T : ℝ} {l : ℕ} (hmean : 0< s.meanLog) (hlog : 0<Real.log T) (hm : s.meanLog≤2*Real.log T) (hV : 2*s.meanLog≤bandScale g U l) (hscale : C*T≤bandScale g U l) : C*T/(4*Real.log T)≤(bandSize s g U l:ℝ) := by have hf := Nat.lt_floor_add_one (bandScale g U l/s.meanLog) have hh := mul_lt_mul_of_pos_right hf hmean rw [div_mul_cancel₀ _ hmean.ne',add_mul,one_mul] at hh have hlo : bandScale g U l/2≤(bandSize s g U l:ℝ)*s.meanLog := by change _≤(⌊bandScale g U l/s.meanLog⌋₊:ℝ)*_ linarith only [hh,hV] have hu := mul_le_mul_of_nonneg_left hm (Nat.cast_nonneg (bandSize s g U l)) apply (div_le_iff₀ (by positivity)).mpr nlinarith only [hlo,hu,hscale]
end GaussianMoat
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388import OAI.NumberTheory.GaussianMoat.GroupCoverage
namespace OAI
universe uOmega uAlpha uBeta uIota uCapitalGamma uGroup
namespace GaussianMoatopen scoped BigOperators Classicalnamespace FinLawvariable {Ω : Type uOmega} {α : Type uAlpha} {β : Type uBeta} [Fintype Ω] [Fintype α] [Fintype β]
lemma short_list_probability_deficit (p : FinLaw Ω) (X : Ω → α) (C : Ω → β) (L : β → Finset α) {b : ℝ} (hb : 1 ≤ b) : let a := p.prob (fun ω => X ω ∈ L (C ω) ∧ ((L (C ω)).card:ℝ) ≤ b) a*(Real.log (Fintype.card α)-Real.log b)-Real.binEntropy a ≤ Real.log (Fintype.card α)-p.cHf X C := by dsimp only have hh := p.short_list_deficit X C L (fun ω => decide (X ω ∈ L (C ω) ∧ ((L (C ω)).card:ℝ) ≤ b)) hb (fun ω _ he => of_decide_eq_true he) have ha : (p.map (fun ω => decide (X ω ∈ L (C ω) ∧ ((L (C ω)).card:ℝ) ≤ b))) true = p.prob (fun ω => X ω ∈ L (C ω) ∧ ((L (C ω)).card:ℝ) ≤ b) := by simp only [map_mass,decide_eq_true_eq,prob] apply Finset.sum_congr rfl intro ω _ split_ifs <;> rfl rw [ha] at hh simpa only [condH,← Hf_eq_H,cHf] using hh
lemma average_deficit_lower {ι : Type uIota} [Fintype ι] (w : FinLaw ι) (a d : ι → ℝ) {a₀ v : ℝ} (ha : ∀ i, a i ∈ Set.Icc (0:ℝ) 1) (ha₀ : 0 < a₀) (hav : a₀ ≤ ∑ i, w i*a i) (hv : 2*(1-Real.log a₀) ≤ v) (hdef : ∀ i, a i*v-Real.binEntropy (a i) ≤ d i) : a₀*v/2 ≤ ∑ i, w i*d i := by let A := ∑ i, w i*a i have hA : 0 < A := lt_of_lt_of_le ha₀ hav have hA1 : A ≤ 1 := by have hh := Finset.sum_le_sum (s := Finset.univ) (fun i _ => mul_le_mul_of_nonneg_left (ha i).2 (w.nonneg i)) simpa only [mul_one,w.sum_one] using hh have ha₀1 : a₀ ≤ 1 := hav.trans hA1 have hl : Real.log a₀ ≤ Real.log A := Real.log_le_log ha₀ hav have hl0 : Real.log a₀ ≤ 0 := Real.log_nonpos ha₀.le ha₀1 have hv0 : 0 ≤ v := by linarith only [hv,hl0] have hh := w.binEntropy_sum_le a ha have hp := binEntropy_le_log_inverse hA hA1 have hdl := Finset.sum_le_sum (s := Finset.univ) (fun i _ => mul_le_mul_of_nonneg_left (hdef i) (w.nonneg i)) rw [show (∑ i, w i*(a i*v-Real.binEntropy (a i))) = A*v-∑ i, w i*Real.binEntropy (a i) by simp only [mul_sub,Finset.sum_sub_distrib,← mul_assoc,← Finset.sum_mul,A]] at hdl have hlog := mul_le_mul_of_nonneg_left hl hA.le have hmult := mul_le_mul_of_nonneg_left hv hA.le have ham := mul_le_mul_of_nonneg_right hav hv0 change (∑ i, w i*Real.binEntropy (a i)) ≤ Real.binEntropy A at hh nlinarith only [hdl,hh,hp,hlog,hmult,ham]
theorem shared_coverage_deficit {Γ : Type uCapitalGamma} {G : Type uGroup} [Fintype Γ] [Fintype G] [AddCommGroup G] (p : FinLaw Ω) (q : Ω → FinLaw Γ) (Y : Ω → G) (h : Γ → G) (K : Finset G) (hK : K.Nonempty) (E : Ω → Finset G) (Bad : Ω → Prop) {τ δ ε b : ℝ} {n : ℕ} (hn : 0<n) (hτ : 0≤τ) (hτ1 : τ≤3/8) (hδ : 0<δ) (hδ1 : δ≤1/64) (hε : 0≤ε) (hb : 1≤b) (hp : (p.joint q).prob (fun v => Y v.1+h v.2∈K) ≤ τ*K.card/(Fintype.card G:ℝ)) (hq : ∀ ω, ¬ Bad ω → ∀ y ∉ E ω, (τ+4*δ)/(Fintype.card G:ℝ) ≤ (q ω).map h y) (hE : ∀ ω, ¬ Bad ω → ((E ω).card:ℝ)/δ≤b) (herr : (Fintype.card G:ℝ)*Real.exp (-(n:ℝ)*δ^2*K.card/(2*(Fintype.card G:ℝ)))≤ε) : let P := p.joint (fun ω => (q ω).iid n) let L := fun v : Fin n → Γ => coverageList K n τ δ (fun i => h (v i)) let a := P.prob (fun v => Y v.1 ∈ L v.2 ∧ ((L v.2).card:ℝ)≤b) δ/(τ+δ)-p.prob Bad-ε ≤ a ∧ a*(Real.log (Fintype.card G)-Real.log b)-Real.binEntropy a ≤ Real.log (Fintype.card G)-P.cHf (fun v => Y v.1) Prod.snd := by dsimp only constructor · have htrue := p.true_coverageList_probability q Y h K hK hτ hδ hn hp have hsize := p.coverageList_size_probability q h K hK E Bad hτ hτ1 hδ hδ1 hε n hq hE herr have hi := (p.joint (fun ω => (q ω).iid n)).prob_inter_ge (fun v => Y v.1 ∈ coverageList K n τ δ (fun i => h (v.2 i))) (fun v => ((coverageList K n τ δ (fun i => h (v.2 i))).card:ℝ)≤b) simp only [not_le] at hi linarith only [htrue,hsize,hi] · exact short_list_probability_deficit (p.joint (fun ω => (q ω).iid n)) (fun v => Y v.1) Prod.snd (fun v => coverageList K n τ δ (fun i => h (v i))) hb
end FinLaw
lemma perm_expect_apply {ι : Type uIota} [Fintype ι] [DecidableEq ι] (f : ι → ℝ) (i : ι) : (𝔼 π : Equiv.Perm ι, f (π i)) = 𝔼 j, f j := by let : Nonempty ι := ⟨i⟩ calc _ = 𝔼 j : ι, 𝔼 π : Equiv.Perm ι, f (π j) := by rw [show (fun j : ι => 𝔼 π : Equiv.Perm ι, f (π j)) = (fun _ => 𝔼 π : Equiv.Perm ι, f (π i)) by funext j; exact perm_expect_exchange f j i] simp only [Fintype.expect_const] _ = 𝔼 π : Equiv.Perm ι, 𝔼 j : ι, f (π j) := Finset.expect_comm _ _ _ _ = _ := by have he (π : Equiv.Perm ι) : (𝔼 j, f (π j)) = 𝔼 j, f j := Fintype.expect_equiv π _ _ (fun _ => rfl) simp only [he,Fintype.expect_const]
namespace FinLawvariable {Ω : Type uOmega} {α : Type uAlpha} {β : Type uBeta} [Fintype Ω] {k : ℕ}
lemma Hf_sub_le_cHf (p : FinLaw Ω) (X : Ω → α) (Y : Ω → β) : p.Hf X-p.Hf Y ≤ p.cHf X Y := by have h := p.Hf_pair_ge_snd Y X rw [p.Hf_pair_comm Y X] at h exact sub_le_sub_right h _
lemma orderedEntropy_conditioning (p : FinLaw Ω) (X : Ω → Fin k → α) (C : Ω → β) {b : ℕ} (hb : b ≤ k) : p.orderedEntropy X b-p.Hf C ≤ b*(𝔼 i : Fin k, p.cHf (fun ω => X ω i) C) := by have hh (π : Equiv.Perm (Fin k)) : p.Hf (prefixVar X π b)-p.Hf C ≤ ∑ i : Fin b, p.cHf (fun ω => X ω (π ⟨i.val,lt_of_lt_of_le i.isLt hb⟩)) C := by apply (p.Hf_sub_le_cHf _ C).trans apply (p.cHf_le_of_determined _ (fun ω (i : Fin b) => X ω (π ⟨i.val,lt_of_lt_of_le i.isLt hb⟩)) C ?_).trans (p.cHf_fintype_subadd _ C) intro ω ν hx _ funext i by_cases hi : i.val<b · simpa only [prefixVar,hi,ite_eq_left] using congrArg some (congrFun hx ⟨i.val,hi⟩) · simp only [prefixVar,hi,ite_false] have hav := Finset.expect_le_expect (s := Finset.univ) (fun π _ => hh π) have he (i : Fin b) : (𝔼 π : Equiv.Perm (Fin k), p.cHf (fun ω => X ω (π ⟨i.val,lt_of_lt_of_le i.isLt hb⟩)) C) = 𝔼 j : Fin k, p.cHf (fun ω => X ω j) C := perm_expect_apply (fun j => p.cHf (fun ω => X ω j) C) _ simpa only [orderedEntropy,Finset.expect_sub_distrib,Fintype.expect_const, Finset.expect_sum_comm,he,Finset.sum_const,Finset.card_univ, Fintype.card_fin,nsmul_eq_mul] using hav
lemma signedEntropy_conditioning (p : FinLaw Ω) (X : (Fin k → Bool) → Ω → Fin k → α) (C : Ω → β) {b : ℕ} (hb : b ≤ k) : p.signedEntropy X b-p.Hf C ≤ b*(𝔼 σ : Fin k → Bool, 𝔼 i : Fin k, p.cHf (fun ω => X σ ω i) C) := by have h := Finset.expect_le_expect (s := Finset.univ) (fun σ _ => p.orderedEntropy_conditioning (X σ) C hb) simpa only [signedEntropy,Finset.expect_sub_distrib,Fintype.expect_const, Finset.mul_expect] using h
end FinLaw
theorem SplitSieve.coverage_conditioning {Ω : Type uOmega} {β : Type uBeta} [Fintype Ω] (s : SplitSieve) (p : FinLaw Ω) (Y : Ω → GaussianInt) (C : Ω → β) {b : ℕ} (hb : b ≤ s.primes.card) : s.pointEntropy p Y b-p.Hf C ≤ b*(𝔼 σ : Fin s.primes.card → Bool, 𝔼 i : Fin s.primes.card, p.cHf (fun ω => s.residueVector σ (Y ω) i) C) := p.signedEntropy_conditioning _ C hb
namespace FinLaw
section
theorem backward_coverage_step {Ω : Type uOmega} {Γ : Type uCapitalGamma} {ι : Type uIota} [Fintype Ω] [Fintype Γ] [Fintype ι] (G : ι → Type uGroup) [∀ i, Fintype (G i)] [∀ i, AddCommGroup (G i)] (w : FinLaw ι) (p : FinLaw Ω) (q : Ω → FinLaw Γ) (Y : (i : ι) → Ω → G i) (h : (i : ι) → Γ → G i) (Bad₀ : ι → Prop) (Bad₁ : ι → Ω → Prop) (K : (i : ι) → Finset (G i)) (E : (i : ι) → Ω → Finset (G i)) (b : ι → ℝ) {τ δ ε η η' e v : ℝ} {n : ℕ} (hn : 0 < n) (hτ : 0 ≤ τ) (hτ1 : τ ≤ 3/8) (hδ : 0 < δ) (hδ1 : δ ≤ 1/64) (hε : 0 ≤ ε) (hη : 0 < η) (hnext : ∑ i, w i*p.prob (Bad₁ i) ≤ η') (hsmall : η'+ε ≤ η*δ/2) (hscale : 2*(1-Real.log (η*δ/2)) ≤ v) (hgap : e < η*δ*v/4) (hdata : (∑ i, w i*(Real.log (Fintype.card (G i))- (p.joint (fun ω => (q ω).iid n)).cHf (fun x => Y i x.1) Prod.snd)) ≤ e) (hK : ∀ i, Bad₀ i → (K i).Nonempty) (hb : ∀ i, Bad₀ i → 1 ≤ b i) (hv : ∀ i, Bad₀ i → v ≤ Real.log (Fintype.card (G i))-Real.log (b i)) (hp : ∀ i, Bad₀ i → (p.joint q).prob (fun x => Y i x.1+h i x.2 ∈ K i) ≤ τ*(K i).card/(Fintype.card (G i):ℝ)) (hq : ∀ i, Bad₀ i → ∀ ω, ¬Bad₁ i ω → ∀ y ∉ E i ω, (τ+4*δ)/(Fintype.card (G i):ℝ) ≤ (q ω).map (h i) y) (hE : ∀ i, Bad₀ i → ∀ ω, ¬Bad₁ i ω → ((E i ω).card:ℝ)/δ ≤ b i) (herr : ∀ i, Bad₀ i → (Fintype.card (G i):ℝ)* Real.exp (-(n:ℝ)*δ^2*(K i).card/(2*(Fintype.card (G i):ℝ))) ≤ ε) : w.prob Bad₀ ≤ η := by let P := p.joint (fun ω => (q ω).iid n) let L := fun i (x : Fin n → Γ) => coverageList (K i) n τ δ (fun j => h i (x j)) let a := fun i => if Bad₀ i then P.prob (fun x => Y i x.1 ∈ L i x.2 ∧ ((L i x.2).card:ℝ) ≤ b i) else 0 let d := fun i => Real.log (Fintype.card (G i))-P.cHf (fun x => Y i x.1) Prod.snd have hd (i : ι) : 0 ≤ d i := by exact sub_nonneg.mpr ((P.cHf_le_Hf _ _).trans (P.Hf_le_log_card_type _)) have ha (i : ι) : a i ∈ Set.Icc (0:ℝ) 1 := by dsimp only [a] split_ifs · exact ⟨P.prob_nonneg _,P.prob_le_one _⟩ · norm_num have hstep (i : ι) (hi : Bad₀ i) : δ-p.prob (Bad₁ i)-ε ≤ a i ∧ a i*v-Real.binEntropy (a i) ≤ d i := by have hh := shared_coverage_deficit p q (Y i) (h i) (K i) (hK i hi) (E i) (Bad₁ i) hn hτ hτ1 hδ hδ1 hε (hb i hi) (hp i hi) (hq i hi) (hE i hi) (herr i hi) dsimp only at hh have hh' : δ/(τ+δ)-p.prob (Bad₁ i)-ε ≤ a i ∧ a i*(Real.log (Fintype.card (G i))-Real.log (b i))-Real.binEntropy (a i) ≤ d i := by simpa only [a,hi,ite_eq_left,P,L,d] using hh constructor · have htd : 0 < τ+δ := by linarith only [hτ,hδ] have htd1 : τ+δ ≤ 1 := by linarith only [hτ1,hδ1] have hfrac : δ ≤ δ/(τ+δ) := (le_div_iff₀ htd).mpr (by nlinarith only [htd1,hδ]) linarith only [hh'.1,hfrac] · have hm := mul_le_mul_of_nonneg_left (hv i hi) (ha i).1 linarith only [hh'.2,hm] have hl (i : ι) : δ*(if Bad₀ i then (1:ℝ) else 0)-p.prob (Bad₁ i)-ε ≤ a i := by by_cases hi : Bad₀ i · simpa only [hi,ite_true,mul_one] using (hstep i hi).1 · simp only [hi,ite_false,mul_zero,a] linarith only [p.prob_nonneg (Bad₁ i),hε] have hdef (i : ι) : a i*v-Real.binEntropy (a i) ≤ d i := by by_cases hi : Bad₀ i · exact (hstep i hi).2 · simpa only [a,hi,ite_false,Real.binEntropy_zero,zero_mul,sub_zero] using hd i by_contra hc have hθη : η < w.prob Bad₀ := lt_of_not_ge hc have hlavg := Finset.sum_le_sum (s := Finset.univ) (fun i _ => mul_le_mul_of_nonneg_left (hl i) (w.nonneg i)) have heq : (∑ i, w i*(δ*(if Bad₀ i then (1:ℝ) else 0)-p.prob (Bad₁ i)-ε)) = δ*w.prob Bad₀-(∑ i, w i*p.prob (Bad₁ i))-ε := by simp only [mul_sub,Finset.sum_sub_distrib,← Finset.sum_mul,w.sum_one,one_mul,prob, Finset.mul_sum] congr 2 apply Finset.sum_congr rfl intro i _ split_ifs <;> ring rw [heq] at hlavg have hav : η*δ/2 ≤ ∑ i, w i*a i := by have hm := mul_le_mul_of_nonneg_left hθη.le hδ.le linarith only [hlavg,hm,hnext,hsmall] have hbnd := average_deficit_lower w a d ha (by positivity : 0 < η*δ/2) hav hscale hdef change (∑ i, w i*d i) ≤ e at hdata nlinarith only [hbnd,hdata,hgap]
variable {Ω : Type uOmega} {G : Type uGroup} [Fintype Ω] [Fintype G]
theorem low_mass_average {ι : Type uIota} [Fintype ι] (G : ι → Type uGroup) [∀ i, Fintype (G i)] (w : FinLaw ι) (p : (i : ι) → FinLaw (G i)) (K : (i : ι) → Finset (G i)) (Bad : ι → Prop) {b e : ℝ} (hb : 0 < b) (hK : ∀ i, ∀ x ∈ K i, p i x ≤ (3/8:ℝ)/(Fintype.card (G i):ℝ)) (hbad : ∀ i, Bad i → b ≤ ((K i).card:ℝ)/(8*(Fintype.card (G i):ℝ))) (hdef : (∑ i, w i*(Real.log (Fintype.card (G i))-(p i).entropy)) ≤ e) : w.prob Bad ≤ e/b := by have h (i : ι) : b*(if Bad i then (1:ℝ) else 0) ≤ Real.log (Fintype.card (G i))-(p i).entropy := by by_cases hi : Bad i · simp only [hi,ite_true,mul_one] exact (hbad i hi).trans ((p i).low_mass_deficit (K i) (by intro x hx convert hK i x hx using 1; ring)) · simp only [hi,ite_false,mul_zero] exact sub_nonneg.mpr (p i).entropy_le_log_card have hs := Finset.sum_le_sum (s := Finset.univ) (fun i _ => mul_le_mul_of_nonneg_left (h i) (w.nonneg i)) have he : (∑ i, w i*(b*(if Bad i then (1:ℝ) else 0)))=b*w.prob Bad := by rw [prob,Finset.mul_sum] apply Finset.sum_congr rfl intro i _ split_ifs <;> ring rw [he] at hs apply (le_div_iff₀ hb).mpr linarith only [hs,hdef]
end
variable {Ω : Type uOmega} {α : Type uAlpha} {β : Type uBeta} [Fintype Ω] [Fintype α] [Fintype β]
lemma uniform_map_perm [Nonempty Ω] (e : Equiv.Perm Ω) : (uniform Ω).map e = uniform Ω := by ext x rw [map_equiv_mass] rfl
lemma prob_uniform (E : Ω → Prop) [Nonempty Ω] : (uniform Ω).prob E = ((Finset.univ.filter E).card:ℝ)/(Fintype.card Ω:ℝ) := by simp only [prob,uniform_mass,div_eq_mul_inv] rw [← Finset.sum_boole] rw [Finset.sum_mul] apply Finset.sum_congr rfl intro ω _ split_ifs <;> simp
lemma uniform_no_wrap (n a : ℕ) (ha : a ≤ n+1) : (uniform (Fin (n+1))).prob (fun i => i.val+a<n+1) = 1-(a:ℝ)/(n+1) := by rw [prob_uniform] have he : (Finset.univ.filter (fun i : Fin (n+1) => i.val+a<n+1)) = Finset.univ.filter (fun i : Fin (n+1) => i.val<n+1-a) := by ext i simp only [Finset.mem_filter,Finset.mem_univ,true_and] omega have hcard : (Finset.univ.filter (fun i : Fin (n+1) => i.val+a<n+1)).card = n+1-a := by rw [he,Fin.card_filter_val_lt,Nat.min_eq_right (by omega)] calc _ = ((n+1-a:ℕ):ℝ)/(n+1) := by congr 1 · convert! congrArg (fun k : ℕ => (k:ℝ)) hcard using 1 congr 2 ext i simp · simp _ = _ := by rw [Nat.cast_sub ha,Nat.cast_add,Nat.cast_one] field_simp
lemma joint_perm_second (p : FinLaw Ω) {Γ : Type uCapitalGamma} [Fintype Γ] [Nonempty Γ] (e : Equiv.Perm Γ) : (p.joint (fun _ => uniform Γ)).map (fun v => (v.1,e v.2)) = p.joint (fun _ => uniform Γ) := by have h := joint_map_fiber p (fun _ => uniform Γ) (fun _ v => e v) simpa only [uniform_map_perm] using h
lemma smoothing_prob (p : FinLaw Ω) (t : Ω → ℕ) (n a : ℕ) (ha : a≤n) (E : ℕ → Prop) : (p.joint (fun _ => uniform (Fin (n+1)))).prob (fun v => E (t v.1+v.2.val)) ≤ (p.joint (fun _ => uniform (Fin (n+1)))).prob (fun v => E (t v.1+v.2.val+a))+ (a:ℝ)/(n+1) := by let e : Equiv.Perm (Fin (n+1)) := Equiv.addRight ⟨a,by omega⟩ let P := p.joint (fun _ => uniform (Fin (n+1))) have hprob : P.prob (fun v => E (t v.1+(e v.2).val)) = P.prob (fun v => E (t v.1+v.2.val)) := by have hh := congrArg (fun Q : FinLaw (Ω × Fin (n+1)) => Q.prob (fun v => E (t v.1+v.2.val))) (p.joint_perm_second e) simpa only [prob_map] using hh have hgood : P.prob (fun v => v.2.val+a<n+1) = 1-(a:ℝ)/(n+1) := by rw [prob_joint] simp only [uniform_no_wrap n a (by omega),← Finset.sum_mul,p.sum_one,one_mul] have hE : P.prob (fun v => E (t v.1+(e v.2).val) ∧ v.2.val+a<n+1) ≤ P.prob (fun v => E (t v.1+v.2.val+a)) := by apply P.prob_mono intro v hv have he : (e v.2).val = v.2.val+a := by change (v.2+(⟨a,by omega⟩ : Fin (n+1))).val = _ exact Fin.val_add_eq_of_add_lt hv.2 simpa only [he,Nat.add_assoc] using hv.1 have hh := P.prob_inter_ge (fun v => E (t v.1+(e v.2).val)) (fun v => v.2.val+a<n+1) have hc := P.prob_compl (fun v => v.2.val+a<n+1) rw [hgood] at hc rw [hprob] at hh linarith only [hE,hh,hc]
lemma smoothing_condH (p : FinLaw Ω) (t : Ω → ℕ) (n a : ℕ) (ha : a≤n) (X : ℕ → α) (C : ℕ → β) : (p.joint (fun _ => uniform (Fin (n+1)))).condH (fun v => X (t v.1+v.2.val+a)) (fun v => C (t v.1+v.2.val+a)) ≤ (p.joint (fun _ => uniform (Fin (n+1)))).condH (fun v => X (t v.1+v.2.val)) (fun v => C (t v.1+v.2.val)) + 2*Real.binEntropy ((a:ℝ)/(n+1))+ ((a:ℝ)/(n+1))*(Real.log (Fintype.card α)+2*Real.log (Fintype.card β)) := by let e : Equiv.Perm (Fin (n+1)) := Equiv.addRight ⟨a,by omega⟩ let P := p.joint (fun _ => uniform (Fin (n+1))) let good := fun v : Ω × Fin (n+1) => decide (v.2.val+a<n+1) have hm : P.map good true=1-(a:ℝ)/(n+1) := by have hh : P.map good true=P.prob (fun v => v.2.val+a<n+1) := by simp only [map_mass,good,prob,decide_eq_true_eq] apply Finset.sum_congr rfl intro v _ split_ifs <;> rfl rw [hh,prob_joint] simp only [uniform_no_wrap n a (by omega), ← Finset.sum_mul,p.sum_one,one_mul] have he : P.condH (fun v => X (t v.1+(e v.2).val)) (fun v => C (t v.1+(e v.2).val)) = P.condH (fun v => X (t v.1+v.2.val)) (fun v => C (t v.1+v.2.val)) := by have hh := congrArg (fun Q : FinLaw (Ω × Fin (n+1)) => Q.condH (fun v => X (t v.1+v.2.val)) (fun v => C (t v.1+v.2.val))) (p.joint_perm_second e) simpa only [condH,H_map,Function.comp_def] using hh have h := P.condH_sub_condH_of_agree (fun v => X (t v.1+v.2.val+a)) (fun v => X (t v.1+(e v.2).val)) (fun v => C (t v.1+v.2.val+a)) (fun v => C (t v.1+(e v.2).val)) good (by intro v _ hv have hlt : v.2.val+a<n+1 := of_decide_eq_true hv have hev : (e v.2).val=v.2.val+a := Fin.val_add_eq_of_add_lt hlt simp only [hev,Nat.add_assoc,and_self]) rw [hm,he,Real.binEntropy_one_sub] at h linarith only [h]
end FinLawend GaussianMoat
end OAI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271import OAI.NumberTheory.GaussianMoat.DyadicSieve
namespace OAI
namespace GaussianMoat
sectionopen scoped BigOperators Classical
structure BatchCertificate (D : ℝ) (ns : List ℕ) (N : ℕ) (s : SplitSieve) (L : ℕ) (E r : ℝ) where pre : List ℕ rest : List ℕ schedule : ns=pre++rest T : ℝ nonempty : s.primes.Nonempty prime_scale : ∀ p∈s.primes, T≤(p:ℝ) ∧ (p:ℝ)≤2*T large : 5≤T mean : 1≤ s.meanLog b : ℕ n : ℕ τ : ℝ A : ℝ η : ℝ δ : ℝ u : s.SignedIndex → ℝ band : EntropyBand s D pre 0 b δ coverage : CoverageDerivation s D N rest τ u η cap : b≤ s.primes.card repetitions : 0<n length : 0<L floor : 0≤τ gain : 0≤A exceptions : ∀ i, 0≤u i short : ∀ i, (D*L)^2<(s.signedPrime i:ℝ) smooth_length : L≤N smooth_error : ∀ i, (L:ℝ)/(N+1)≤(τ/(s.signedPrime i:ℝ))/2 list : ∀ i, Real.log (4*u i+(s.signedPrime i:ℝ)*Real.exp (-(n:ℝ)*(((L:ℝ)*(τ/(s.signedPrime i:ℝ))/2)/4)))≤Real.log (s.signedPrime i)-A rate : (n:ℝ)*((L:ℝ)*r+2*(Real.log 36+2*Real.log (D*(rest.sum+N))))≤ (b:ℝ)*(A*(1-2*η)-δ*s.meanLog)-E
theorem BatchCertificate.sound {D E r : ℝ} {ns : List ℕ} {N L : ℕ} {s : SplitSieve} (q : BatchCertificate D ns N s L E r) (hD : 1≤D) (z : ℕ → GaussianInt) (hz : Function.Injective z) (ha : ∀ t, z t∈s.avoiding) (hs : ∀ t, dist (z t:ℂ) (z (t+1):ℂ)≤D) (F : Finset GaussianInt) (hf : ∀ f∈F, f≠0) (hF : residueWeight F≤E) : ∃ G : Finset GaussianInt, F⊆G ∧ G⊆F∪s.availableFactors ∧ r≤((TimeLaw.at 0).advance (commonSchedule z ns N)).info (fun a (f : G) => residueCode f.val (z a)) (incrementWord z L) (fun a (f : F) => residueCode f.val (z a)) / L := by let Q := (TimeLaw.at 0).advance (commonSchedule z q.pre 0) have hOld : Q.law.Hf (fun t (f : F) => residueCode f.val (z t.val))≤E := (residue_finset_entropy Q.law (fun t => z t.val) F hf).trans hF obtain ⟨σ,π,hh⟩ := schedule_batch_information s q.nonempty z hz ha q.pre q.rest hD q.large q.mean hs q.prime_scale q.band q.u q.coverage (fun f : F => f.val) hOld q.cap q.repetitions q.length q.floor q.gain q.exceptions q.short q.smooth_length q.smooth_error q.list q.rate let f := fun j => s.signedFactorAt (s.selectedIndex q.cap σ π j) let G := F∪Finset.univ.image f refine ⟨G,Finset.subset_union_left,?_,?_⟩ · apply Finset.union_subset Finset.subset_union_left intro g hg obtain ⟨j,_,rfl⟩ := Finset.mem_image.mp hg exact Finset.mem_union_right F (s.signed_mem_available _) · rw [q.schedule] unfold TimeLaw.info rw [FinLaw.cIf_finset_union] exact hh
theorem greedy_finite_selection (A : ℕ → Finset GaussianInt) (hA : ∀ j, A j⊆A (j+1)) (n : ℕ) (R : ℕ → Finset GaussianInt → Finset GaussianInt → Prop) (hstep : ∀ j≤n, ∀ F⊆A j, ∃ G, F⊆G ∧ G⊆A (j+1) ∧ R j F G) : ∃ F : ℕ → Finset GaussianInt, (∀ j, F j⊆A j) ∧ (∀ j, F j⊆F (j+1)) ∧ (∀ j≤n, R j (F j) (F (j+1))) := by have step (j : ℕ) (F : {F : Finset GaussianInt // F⊆A j}) : ∃ G : {G : Finset GaussianInt // G⊆A (j+1)}, F.val⊆G.val ∧ (j≤n → R j F.val G.val) := by by_cases hj : j≤n · obtain ⟨G,hFG,hG,hR⟩ := hstep j hj F.val F.property exact ⟨⟨G,hG⟩,hFG,fun _ => hR⟩ · exact ⟨⟨F.val,F.property.trans (hA j)⟩,Finset.Subset.refl _,fun h => (hj h).elim⟩ let f (j : ℕ) (F : {F : Finset GaussianInt // F⊆A j}) := (step j F).choose let F : (j : ℕ) → {F : Finset GaussianInt // F⊆A j} := @Nat.rec (fun j => {F : Finset GaussianInt // F⊆A j}) ⟨∅,Finset.empty_subset _⟩ f refine ⟨fun j => (F j).val,fun j => (F j).property,?_,?_⟩ · intro j exact (step j (F j)).choose_spec.1 · intro j hj exact (step j (F j)).choose_spec.2 hj
noncomputable def precedingFactors (s : ℕ → SplitSieve) (j : ℕ) : Finset GaussianInt := (Finset.range j).biUnion (fun i => (s i).availableFactors)
lemma precedingFactors_mono (s : ℕ → SplitSieve) {i j : ℕ} (h : i≤j) : precedingFactors s i⊆precedingFactors s j :=by intro f hf obtain ⟨k,hk,hf⟩ := Finset.mem_biUnion.mp hf exact Finset.mem_biUnion.mpr ⟨k,(Finset.range_mono h) hk,hf⟩
lemma precedingFactors_succ (s : ℕ → SplitSieve) (j : ℕ) : precedingFactors s (j+1)=precedingFactors s j∪(s j).availableFactors := by simp only [precedingFactors,Finset.range_add_one,Finset.biUnion_insert,Finset.union_comm]
lemma precedingFactors_ne_zero (s : ℕ → SplitSieve) {j : ℕ} {f : GaussianInt} (h : f∈precedingFactors s j) : f≠0 := by obtain ⟨i,_,hi⟩ := Finset.mem_biUnion.mp h exact (s i).available_ne_zero hi
theorem certificate_no_walk {D ε : ℝ} (hD : 1≤D) (ns : List ℕ) (N n : ℕ) (s : ℕ → SplitSieve) (L : ℕ → ℕ) (r : ℕ → ℝ) (cert : ∀ j≤n, BatchCertificate D ns N (s j) (L j) (residueWeight (precedingFactors s j)) (r j)) (hdiv : ∀ j<n, L j∣L (j+1)) (hε : 0≤ε) (herr : ∀ j<n, ∀ a<L (j+1), 2*Real.binEntropy ((a:ℝ)/(N+1))+ ((a:ℝ)/(N+1))*((L j:ℝ)*Real.log (latticeBall D).card+ 2*residueWeight (precedingFactors s (n+1)))≤ε) (hexcess : Real.log (latticeBall D).card+n*ε<∑ j∈Finset.range (n+1), r j) (z : ℕ → GaussianInt) (hz : Function.Injective z) (ha : ∀ j≤n, ∀ t, z t∈(s j).avoiding) (hs : ∀ t, dist (z t:ℂ) (z (t+1):ℂ)≤D) : False := by let P := (TimeLaw.at 0).advance (commonSchedule z ns N) let rate (j : ℕ) (F G : Finset GaussianInt) := P.info (fun a (f : G) => residueCode f.val (z a)) (incrementWord z (L j)) (fun a (f : F) => residueCode f.val (z a)) / L j obtain ⟨F,hFA,hFF,hR⟩ := greedy_finite_selection (precedingFactors s) (fun j => precedingFactors_mono s (Nat.le_succ j)) n (fun j F G => r j≤rate j F G) (by intro j hj F hF obtain ⟨G,hFG,hG,hI⟩ := (cert j hj).sound hD z hz (ha j hj) hs F (fun f hf => precedingFactors_ne_zero s (hF hf)) (residueWeight_mono hF) refine ⟨G,hFG,?_,hI⟩ rw [precedingFactors_succ] exact hG.trans (Finset.union_subset_union_left hF)) have ht := schedule_information_telescope z hs ns N n F hFF (fun j f hf => precedingFactors_ne_zero s (hFA j hf)) L (fun j hj => (cert j hj).length) hdiv (fun j hj => (cert j hj).smooth_length) hε (by intro j hj a ha have hw := residueWeight_mono ((hFA (j+1)).trans (precedingFactors_mono s (j := n+1) (by omega))) have hh := herr j hj a ha have hx : 0≤(a:ℝ)/(N+1) := by positivity change _+_ * (_+2*residueWeight (F (j+1)))≤ε nlinarith only [hw,hh,hx]) have hh := Finset.sum_le_sum (s := Finset.range (n+1)) (fun j hj => hR j (by simpa only [Finset.mem_range,Nat.lt_succ_iff] using hj)) exact (not_lt_of_ge (hh.trans ht)) hexcess
open scoped BigOperators Classicalopen Filter
theorem thin_bins (J : Finset ℕ) {K : ℕ} (hK : 0<K) : ∃ a<K, ((J.card:ℝ)/K)≤(J.filter (fun j => j%K=a)).card ∧ ∀ i∈J.filter (fun j => j%K=a), ∀ j∈J.filter (fun j => j%K=a), i<j → i+K≤j := by have hh : (Finset.range K).card • ((J.card:ℝ)/K)≤(J.card:ℝ) := by rw [Finset.card_range,nsmul_eq_mul,mul_div_cancel₀ _ (by exact_mod_cast hK.ne')] obtain ⟨a,ha,hc⟩ := Finset.exists_le_card_fiber_of_nsmul_le_card_of_maps_to (s := J) (t := Finset.range K) (f := fun j => j%K) (fun j _ => Finset.mem_range.mpr (Nat.mod_lt _ hK)) (Finset.nonempty_range_iff.mpr hK.ne') hh refine ⟨a,Finset.mem_range.mp ha,hc,?_⟩ intro i hi j hj hij have hi' := (Finset.mem_filter.mp hi).2 have hj' := (Finset.mem_filter.mp hj).2 have hd : i%K=j%K := hi'.trans hj'.symm have hei := Nat.mod_add_div i K have hej := Nat.mod_add_div j K have hq : i/K<j/K := by nlinarith only [hei,hej,hd,hij] nlinarith only [hei,hej,hd,hq]
theorem eventually_separated_split_bins (K : ℕ) (hK : 0<K) : ∃ c δ : ℝ, 0<c ∧ 0<δ ∧ ∀ᶠ X : ℝ in atTop, ∃ J : Finset ℕ, c*X≤J.card ∧ (∀ i∈J, ∀ j∈J, i<j → i+K≤j) ∧ ∀ j∈J, X≤j*Real.log 2 ∧ j*Real.log 2≤21/20*X ∧ δ*(2:ℝ)^j/Real.log ((2:ℝ)^(j+1))≤(PrimeLogMass.dyadicBatch j).card := by obtain ⟨c,δ,hc,hδ,he⟩ := PrimeLogMass.eventually_dense_split_bins refine ⟨c/K,δ,div_pos hc (by exact_mod_cast hK),hδ,?_⟩ filter_upwards [he] with X hX obtain ⟨J,hJ,hp⟩ := hX obtain ⟨a,_,hcard,hsep⟩ := thin_bins J hK refine ⟨J.filter (fun j => j%K=a),?_,hsep,?_⟩ · have hh := (div_le_div_of_nonneg_right hJ (Nat.cast_nonneg K)).trans hcard simpa only [div_mul_eq_mul_div] using hh · intro j hj exact hp j (Finset.mem_filter.mp hj).1
lemma dyadicSieve_available_weight (j : ℕ) : residueWeight (dyadicSieve j).availableFactors≤4*Real.log 4*(2:ℝ)^j := by have hp : (∑ p∈PrimeLogMass.dyadicBatch j, Real.log (p:ℝ))≤Real.log 4*(2:ℝ)^(j+1) := PrimeLogMass.prime_log_mass_le_theta _ (by positivity) (by intro p hp have h := (PrimeLogMass.mem_dyadicBatch j p).mp hp exact ⟨h.2.2.1,by exact_mod_cast h.2.1.le⟩) have hh := (dyadicSieve j).available_weight change residueWeight (dyadicSieve j).availableFactors≤2*∑ p∈PrimeLogMass.dyadicBatch j, Real.log (p:ℝ) at hh rw [pow_succ] at hp nlinarith only [hh,hp]
end
open scoped BigOperators Classical
lemma bandScale_add (g U : ℝ) (j k : ℕ) : bandScale g U (j+k)=bandScale g (bandScale g U j) k := by unfold bandScale rw [pow_add] ring
lemma bandLength_add (g U : ℝ) (j k : ℕ) : bandLength g U (j+k)=bandLength g (bandScale g U j) k := by unfold bandLength rw [bandScale_add]
lemma bandList_split (g U : ℝ) (j l r : ℕ) : List.ofFn (fun i : Fin (j+l+r) => bandLength g U i.val)= List.ofFn (fun i : Fin j => bandLength g U i.val)++ List.ofFn (fun i : Fin l => bandLength g (bandScale g U j) i.val)++ List.ofFn (fun i : Fin r => bandLength g (bandScale g U (j+l)) i.val) := by rw [List.ofFn_add,List.ofFn_add] simp only [Fin.val_castLE,Fin.val_natAdd,bandLength_add]
theorem band_first_crossing {g U V : ℝ} {m : ℕ} (hg : 0<g) (hg1 : g<1) (hV : 0<V) (hstart : V≤U) (hend : bandScale g U m≤V) : ∃ k, k ≤ m ∧ g^2*V<bandScale g U k ∧ bandScale g U k≤V := by have hex : ∃ k, bandScale g U k≤V := ⟨m,hend⟩ let k := Nat.find hex have hk : bandScale g U k≤V := Nat.find_spec hex have hkm : k ≤ m := Nat.find_min' hex hend refine ⟨k,hkm,?_,hk⟩ by_cases hk0 : k=0 · simp only [hk0,bandScale,pow_zero,one_mul] have hg2 : g^2<1 := pow_lt_one₀ hg.le hg1 (by omega : 2≠0) exact (mul_lt_of_lt_one_left hV hg2).trans_le hstart · have hkpos : 0<k := Nat.pos_of_ne_zero hk0 have hprev : V<bandScale g U (k-1) := lt_of_not_ge (Nat.find_min hex (by omega)) have he : k=k-1+1 := by omega rw [he,bandScale_succ] exact mul_lt_mul_of_pos_left hprev (sq_pos_of_pos hg)
lemma bandScale_log {g U : ℝ} (hg : 0<g) (hU : 0<U) (k : ℕ) : Real.log (bandScale g U k)=(k:ℝ)*(2*Real.log g)+Real.log U := by unfold bandScale rw [Real.log_mul (ne_of_gt (pow_pos (sq_pos_of_pos hg) _)) hU.ne',Real.log_pow,Real.log_pow] norm_num
theorem schedule_log_bound (ns : List ℕ) (N : ℕ) {H : ℝ} (hH : 0≤H) (hns : ∀ n∈ns, (n:ℝ)≤Real.exp H) : Real.log ((ns.sum+N:ℕ)+1)≤Real.log ((ns.length:ℝ)+1)+H+Real.log ((N:ℝ)+1) := by have hs : (ns.sum:ℝ)≤(ns.length:ℝ)*Real.exp H := by induction ns with | nil => simp | cons n ns ih => have hn := hns n (List.mem_cons_self ..) have hi := ih (fun m hm => hns m (List.mem_cons_of_mem n hm)) simp only [List.sum_cons,List.length_cons,Nat.cast_add,Nat.cast_one] nlinarith only [hn,hi] have he : 1≤Real.exp H := Real.one_le_exp_iff.mpr hH have hc : 0≤(ns.length:ℝ)*Real.exp H := mul_nonneg (Nat.cast_nonneg _) (Real.exp_nonneg _) have hN : 1≤(N:ℝ)+1 := by linarith only [(Nat.cast_nonneg N : (0:ℝ)≤N)] have hle : ((ns.sum+N:ℕ)+1:ℝ)≤((ns.length:ℝ)+1)*Real.exp H*((N:ℝ)+1) := by simp only [Nat.cast_add] nlinarith only [hs,he,hc,hN,(Nat.cast_nonneg N : (0:ℝ)≤N)] have hh := Real.log_le_log (show (0:ℝ)<((ns.sum+N:ℕ)+1) by positivity) hle rw [Real.log_mul (by positivity) (by positivity),Real.log_mul (by positivity) (Real.exp_ne_zero _), Real.log_exp] at hh exact hh
end GaussianMoat
end OAIlean/OAI/NumberTheory/EgyptianFractions/ThreePrimeContinuousMinorArc.leanAdded+89
lean/OAI/NumberTheory/EgyptianFractions/ThreePrimeCubicStability.leanAdded+110
lean/OAI/NumberTheory/EgyptianFractions/ThreePrimeEulerProduct.leanAdded+93
lean/OAI/NumberTheory/EgyptianFractions/ThreePrimeEulerTail.leanAdded+176
lean/OAI/NumberTheory/EgyptianFractions/ThreePrimeFourier.leanAdded+203
lean/OAI/NumberTheory/EgyptianFractions/ThreePrimeFourierBundle.leanAdded+4
lean/OAI/NumberTheory/EgyptianFractions/ThreePrimeFourierReduction.leanAdded+53
lean/OAI/NumberTheory/EgyptianFractions/ThreePrimeIntegralCount.leanAdded+52
lean/OAI/NumberTheory/EgyptianFractions/ThreePrimeLocalDensity.leanAdded+319
lean/OAI/NumberTheory/EgyptianFractions/ThreePrimeLocalFactor.leanAdded+105
lean/OAI/NumberTheory/EgyptianFractions/ThreePrimeLocalFourier.leanAdded+43
lean/OAI/NumberTheory/EgyptianFractions/ThreePrimeLocalSeries.leanAdded+72
lean/OAI/NumberTheory/EgyptianFractions/ThreePrimeMangoldt.leanAdded+249
lean/OAI/NumberTheory/EgyptianFractions/ThreePrimeMangoldtAsymptotics.leanAdded+82
lean/OAI/NumberTheory/EgyptianFractions/ThreePrimeMangoldtBridge.leanAdded+31
lean/OAI/NumberTheory/EgyptianFractions/ThreePrimeMangoldtIntegral.leanAdded+66
lean/OAI/NumberTheory/EgyptianFractions/ThreePrimeMangoldtPowerError.leanAdded+89
lean/OAI/NumberTheory/EgyptianFractions/ThreePrimeMinorArc.leanAdded+188
lean/OAI/NumberTheory/EgyptianFractions/ThreePrimeMinorEnergy.leanAdded+102
lean/OAI/NumberTheory/EgyptianFractions/ThreePrimePartialSummation.leanAdded+108
lean/OAI/NumberTheory/EgyptianFractions/ThreePrimeSingularSeries.leanAdded+126
lean/OAI/NumberTheory/EgyptianFractions/ThreePrimeSingularTail.leanAdded+174
lean/OAI/NumberTheory/EgyptianFractions/ThreePrimeWeighted.leanAdded+62
lean/OAI/NumberTheory/EgyptianFractions/TruncatedDivisors.leanAdded+128
lean/OAI/NumberTheory/EgyptianFractions/TypeIIBlockScalar.leanAdded+43
lean/OAI/NumberTheory/EgyptianFractions/UniformDivisorMoment.leanAdded+91
lean/OAI/NumberTheory/EgyptianFractions/UniformSecondMoment.leanAdded+90
lean/OAI/NumberTheory/EgyptianFractions/UpperSlope.leanAdded+94
lean/OAI/NumberTheory/EgyptianFractions/VanDerCorput.leanAdded+239
lean/OAI/NumberTheory/EgyptianFractions/VaughanBilinear.leanAdded+305
lean/OAI/NumberTheory/EgyptianFractions/VaughanCutoff.leanAdded+192
lean/OAI/NumberTheory/EgyptianFractions/VaughanDecomposition.leanAdded+105
lean/OAI/NumberTheory/EgyptianFractions/VaughanDyadic.leanAdded+152
lean/OAI/NumberTheory/EgyptianFractions/VaughanDyadicDecomposition.leanAdded+96
lean/OAI/NumberTheory/EgyptianFractions/VaughanDyadicEstimate.leanAdded+96
lean/OAI/NumberTheory/EgyptianFractions/VaughanDyadicUniform.leanAdded+127
lean/OAI/NumberTheory/EgyptianFractions/VaughanEstimate.leanAdded+140
lean/OAI/NumberTheory/EgyptianFractions/VaughanHyperbola.leanAdded+144
lean/OAI/NumberTheory/EgyptianFractions/VaughanHyperbolicNearRational.leanAdded+55
lean/OAI/NumberTheory/EgyptianFractions/VaughanIdentity.leanAdded+180
lean/OAI/NumberTheory/EgyptianFractions/VaughanNearRational.leanAdded+269
lean/OAI/NumberTheory/EgyptianFractions/VaughanOptimized.leanAdded+86
lean/OAI/NumberTheory/EgyptianFractions/VaughanRealTypeIHyperbolic.leanAdded+112
lean/OAI/NumberTheory/EgyptianFractions/VaughanTypeI.leanAdded+160
lean/OAI/NumberTheory/EgyptianFractions/VaughanTypeINormalized.leanAdded+102
lean/OAI/NumberTheory/EgyptianFractions/VaughanWeighted.leanAdded+108
lean/OAI/NumberTheory/EgyptianFractions/WeightedBinomial.leanAdded+55
lean/OAI/NumberTheory/GaussianMoat/AccurateScales.leanAdded+336
lean/OAI/NumberTheory/GaussianMoat/BackwardCoverage.leanAdded+388
lean/OAI/NumberTheory/GaussianMoat/BatchCertificate.leanAdded+271